Commit graph

3135 commits

Author SHA1 Message Date
Max
4170fbd13b Add text content storage functionality to attachment manager
- Implemented `GetText` and `SaveText` methods in the attachment manager to handle storing and retrieving parsed text content from files.
- Enhanced the `manager_test.go` with comprehensive tests for various scenarios, including saving, updating, and retrieving text, as well as handling non-existent file IDs.
- Updated the README.md to document the new text content storage features, providing examples for saving and retrieving parsed text.
- Modified the attachment model to include a new `content` field for storing text content, improving the overall functionality of the attachment management system.
2025-12-03 18:18:46 +08:00
Max
60fef5744a Implement custom connector extraction in GetCompletionRequest
- Enhanced the GetCompletionRequest function to support custom connectors by validating the model field against existing connectors.
- If the model is a valid connector ID, it sets the ctx.Connector; otherwise, it defaults to the assistant ID behavior.
- This change improves flexibility in handling different model types while maintaining compatibility with existing functionality.
2025-12-03 12:01:44 +08:00
Max
ede240302a Update ConnectorOptions handling in tests and types
- Changed the `Optional` field in `ConnectorOptions` from a boolean to a pointer to allow for nil values, enhancing flexibility in option handling.
- Updated tests in `load_test.go`, `convert_test.go`, and `assistant_test.go` to reflect the new pointer type for `Optional`, ensuring proper assertions and error handling.
- Added new test cases to validate behavior when `Optional` is nil or false, improving test coverage and robustness of the ConnectorOptions functionality.
2025-12-03 10:57:47 +08:00
Max
bbba6b9fdb Add modes and database support to Assistant model
- Enhanced the `loadMap` function to include handling for `modes` and `default_mode` fields, allowing for flexible operational modes and a specified primary mode.
- Introduced a new `DB` field in the Assistant model to support database configuration, improving data management capabilities.
- Implemented the `ToModes` conversion function to facilitate various input types for modes, ensuring robust handling and validation.
- Added comprehensive tests for the `ToModes` function to validate its functionality across different input scenarios, enhancing overall reliability.
- Updated relevant methods to ensure consistent integration of the new fields and functionalities within the Assistant model.
2025-12-03 10:50:24 +08:00
Max
8d762964b2 Refactor assistant capabilities retrieval and enhance API endpoints
- Replaced the deprecated getConnectorCapabilities method with a unified capability getter in the Assistant model, improving capability retrieval logic.
- Added a new API endpoint to retrieve essential assistant information, including fields like id, name, avatar, and connector options, enhancing the assistant's data accessibility.
- Updated the LLM management to support filtering by capabilities, allowing for more flexible provider listings based on user-defined models.
- Improved overall structure and clarity in the assistant's capabilities and API responses, ensuring better maintainability and usability.
2025-12-03 10:05:23 +08:00
Max
ed62033761 Add modes and default mode fields to Assistant model
- Introduced `modes` field to support multiple operational modes for the assistant, allowing for flexible functionality (e.g., chat, task).
- Added `default_mode` field to specify the primary mode of operation for the assistant.
- Updated the `Map`, `Clone`, and `Update` methods to handle the new fields appropriately.
- Enhanced the `ToAssistantModel` conversion function to include the new fields.
- Added tests to validate the integration and functionality of modes and default mode within the assistant model.
2025-12-02 19:02:31 +08:00
Max
da48896bdf Add database support to Assistant model and related functionalities
- Introduced a new `Database` type to encapsulate database models and options.
- Updated the `Assistant` model to include a `DB` field for database configuration.
- Enhanced the `Map`, `Clone`, and `Update` methods to handle the new `DB` field appropriately.
- Implemented the `ToDatabase` conversion function to support various input types for database initialization.
- Added comprehensive tests to validate the integration of the database functionality within the assistant model.
- Updated relevant fields and methods to ensure consistent handling of the new database configuration.
2025-12-02 18:45:03 +08:00
Max
4b747a5bfa Add GetStorage function and enhance loadSource logic
- Introduced GetStorage function for testing purposes, allowing retrieval of the current storage instance.
- Enhanced loadSource function to load scripts from the source field if present, improving assistant initialization.
- Updated comments for clarity on TypeScript handling in loadSource, ensuring better understanding of script loading mechanics.
2025-12-02 16:54:57 +08:00
Max
ee44432e69 Enhance assistant prompt handling with new preset and global prompt controls
- Introduced prompt preset selection and global prompt disabling features in the assistant's message building process.
- Updated the `buildSystemPrompts` method to prioritize prompt presets and manage global prompt settings based on context and hook responses.
- Added new fields to the `HookCreateResponse` struct for prompt configuration, allowing for dynamic adjustments during message processing.
- Refactored tests to validate the integration of prompt presets and global prompt controls, ensuring robust functionality and context-aware behavior.
2025-12-02 16:24:22 +08:00
Max
42e920eed6 Implement global prompts functionality in the assistant module
- Added methods to set and retrieve global prompts, enhancing the assistant's capabilities.
- Updated the assistant's message building process to include global prompts, ensuring context-aware parsing.
- Introduced tests to validate the integration and functionality of global prompts within the assistant.
- Improved context variable handling for prompt parsing, supporting dynamic content generation.
2025-12-02 16:03:31 +08:00
Max
45029269af Enhance assistant model with global prompts functionality
- Introduced the `disable_global_prompts` field in the Assistant model to control the usage of global prompts.
- Updated the Load and Get methods to initialize and retrieve global prompts from the configuration.
- Refactored tests to validate the new global prompts functionality and ensure proper loading and context handling.
- Improved the overall structure and clarity of the assistant's capabilities and configurations.
2025-12-02 15:37:41 +08:00
Max
51092e3324 Refactor assistant model and enhance data handling
- Removed the GetByConnector method from the Assistant model to streamline the retrieval process.
- Introduced new fields for connector options and prompt presets, allowing for more flexible configurations.
- Updated the Map method to include additional fields such as connector options and prompt presets.
- Enhanced the Clone method to support deep copying of new fields.
- Improved the Update method to handle updates for the new source, connector options, and prompt presets fields.
- Refactored tests to ensure comprehensive coverage of the new functionalities and maintain clarity in the assistant structure.
2025-12-02 14:54:35 +08:00
Max
339a486eb4 Refactor assistant capabilities and update data handling
- Enhanced the getConnectorCapabilities method to prioritize model capabilities and connector settings, improving capability retrieval logic.
- Deprecated the tools field in the Assistant model, transitioning to MCP for tool management, and updated related methods accordingly.
- Introduced new fields for connector options and prompt presets in the Assistant model, allowing for more flexible configurations.
- Updated the GetAssistant method to support field selection, improving data retrieval efficiency and flexibility.
- Refactored tests and documentation to reflect changes in the assistant structure and capabilities, ensuring clarity and maintainability.
2025-12-02 12:36:47 +08:00
Max
3dd63e5530 Refactor model capabilities to use OpenAI struct
- Updated the model capabilities throughout the agent to utilize the new gouOpenAI.Capabilities struct instead of the previous ModelCapabilities.
- Adjusted related methods and types to ensure compatibility with the new capabilities structure, enhancing clarity and maintainability.
- Improved context handling and message processing by directly integrating OpenAI capabilities, streamlining the overall architecture.
2025-12-02 11:33:09 +08:00
Max
7e8b2d8d9f Add LLM failure tracing in executeLLMStream and executeLLMForToolRetry methods
- Implemented traceLLMFail method to mark LLM requests as failed in the trace context.
- Updated executeLLMStream and executeLLMForToolRetry methods to call traceLLMFail on errors, enhancing error tracking and debugging capabilities.
- Improved overall error handling in LLM execution flows, ensuring failures are properly logged in the trace.
2025-12-02 09:32:21 +08:00
Max
5ca78e0133 Enhance tool call handling in stream processing
- Updated handleToolCall method to parse tool call delta data from OpenAI, improving the handling of single and multiple tool calls.
- Implemented dynamic delta actions ("append" for arguments, "merge" for static fields) to optimize message sending.
- Enhanced message structure to include appropriate DeltaAction and DeltaPath for better frontend integration.
- Improved error handling during JSON parsing to ensure robustness in tool call processing.
2025-12-01 16:25:35 +08:00
Max
b45165b0ae Implement thread-safe message and block metadata storage
- Introduced a new messageMetadataStore type for managing message and block metadata with thread-safe operations.
- Added methods for setting, getting, and updating message and block metadata, enhancing concurrency handling.
- Removed redundant metadata store implementation from types.go, centralizing functionality in message.go for improved organization.
2025-12-01 08:35:38 +08:00
Max
a868b4d741 Refactor context initialization and enhance tool call handling
- Updated context creation methods to remove unnecessary payload parameter, simplifying initialization.
- Enhanced handleToolCall method to manage message sequencing and delta actions more effectively, ensuring proper message tracking.
- Improved error handling in message sending to ensure robustness in tool call processing.
2025-11-30 16:40:45 +08:00
Max
4e8508649e Add automatic ChunkID generation for messages in Send method
- Implemented logic to auto-generate ChunkID for messages when not provided, enhancing message tracking.
- Utilized IDGenerator if available; otherwise, fallback to message.GenerateNanoID for unique identification.
- Improved message handling consistency by ensuring ChunkID is always set for non-event messages.
2025-11-30 15:28:09 +08:00
Max
6c295db8d5 Implement EndBlock method and enhance message lifecycle management
- Added EndBlock method to explicitly mark the end of a message block, sending a block_end event.
- Updated message handling to include lifecycle events for message start and end, improving tracking and management of message durations.
- Enhanced message metadata structure to support chunk counting and message types, facilitating better message operations.
- Improved JSAPI documentation to include new lifecycle management features, clarifying usage for developers.
2025-11-30 15:09:27 +08:00
Max
1af1afaaee Refactor delegated assistant context handling in Stream method
- Simplified context management by directly passing the existing context to the delegated assistant's Stream method, ensuring proper stack tracing.
- Updated comments to clarify the delegation process and the relationship between parent and delegated assistants, enhancing code readability.
2025-11-30 11:57:02 +08:00
Max
0fe0843b43 Refactor agent and assistant structure for improved clarity and performance
- Removed deprecated API and vision components, streamlining the agent's architecture.
- Updated the Load function to utilize a new agentDSL variable, enhancing the management of assistant capabilities.
- Enhanced context handling by introducing a message metadata store for thread-safe operations, improving message tracking and management.
- Refactored context methods to eliminate deprecated fields, ensuring cleaner and more maintainable code.
- Improved documentation and comments throughout the codebase to clarify changes and enhance developer understanding.
2025-11-30 11:47:25 +08:00
Max
ab240443f8 Add message metadata handling and new context methods for message operations
- Introduced recordMessageMetadata and getMessageMetadata methods to manage metadata for sent messages, enabling BlockID and ThreadID inheritance in delta operations.
- Implemented new methods (Append, Merge, Set) in the context to enhance message management capabilities, allowing for more flexible message updates.
- Updated the Send method to automatically manage BlockID and ThreadID for delta operations, improving message handling consistency.
- Enhanced JSAPI documentation to reflect new methods and usage patterns, improving developer experience and clarity.
2025-11-30 10:39:51 +08:00
Max
c11bc0a1ae Enhance tracing and message handling in Assistant context
- Added error handling and logging for completion node creation in the traceAgentCompletion method, improving traceability of failures.
- Introduced a new replaceMethod in the context to allow message content replacement, enhancing message management capabilities.
- Updated documentation for sendMethod and replaceMethod to clarify usage and return values, improving developer experience.
2025-11-30 09:40:17 +08:00
Max
78494f8622 Refactor agent tracing and completion handling
- Updated the traceAgentOutput method to be deprecated in favor of the new traceAgentCompletion method, which creates a dedicated completion node for reporting final outputs.
- Enhanced the i18n messages to include labels and descriptions for the new agent completion functionality, improving localization support.
- Removed debug logging related to MCP tools from the buildCompletionOptions method to streamline the code and improve clarity.
2025-11-30 08:31:31 +08:00
Max
3bfd40b701 Refactor Assistant's Stream method to support Next hook responses
- Updated the Stream method to return a flexible final response, accommodating both standard and Next hook responses.
- Introduced NextProcessContext to encapsulate context for processing Next hook responses, enhancing clarity and maintainability.
- Removed deprecated Done and Failback hooks, streamlining the hook management process.
- Enhanced error handling and logging for improved traceability during streaming operations.
2025-11-29 22:52:06 +08:00
Max
9acf6b64e1 Add MCP hook override functionality in Assistant tests and implementation
- Introduced a new test case for MCP hook overrides in build_mcp_test.go, validating that hooks can successfully modify MCP server configurations.
- Updated the applyMCPTools and buildMCPTools methods to prioritize hook-provided MCP servers over assistant configurations, enhancing flexibility in tool management.
- Enhanced the HookCreateResponse struct to include MCPServers, allowing hooks to specify server configurations for requests.
- Improved error handling and logging throughout the MCP tool application process, ensuring better traceability and debugging capabilities.
2025-11-29 20:45:39 +08:00
Max
9c7be8401a Enhance stress test performance assertions for CI environments
- Updated the performance assertion for no-op operations in the stress test to account for slower execution times in CI environments, allowing a maximum time of 15ms instead of 5ms.
- Added comments to clarify expected performance metrics for local versus CI runs, improving test documentation and understanding.
2025-11-29 20:17:28 +08:00
Max
fab6d19c14 Refactor GenTraceID function for improved uniqueness and clarity
- Updated the GenTraceID function to generate a trace ID using a combination of a date prefix and a 12-character random suffix from NanoID, enhancing collision resistance.
- Removed the timestamp-based suffix generation in favor of a more robust random approach, ensuring better uniqueness in concurrent scenarios.
- Added comments to clarify the new implementation and fallback mechanism for NanoID generation failures.
2025-11-29 18:37:46 +08:00
Max
613ccc658e Update i18n test cases to reflect changes in built-in message formats
- Modified expected values in test cases to remove prefixes from assistant labels in both English and Chinese translations, ensuring consistency with the updated message structure.
- Adjusted comments to clarify the changes made to the label formats in the translation functions.
2025-11-29 17:48:28 +08:00
Max
9ea1fceda4 Enhance debugging and error tracing in Assistant's streaming process
- Added detailed debug logging throughout the Stream method to trace execution flow and tool call results, improving visibility during runtime.
- Implemented error tracing with the new traceAgentFail method to capture failures in agent nodes, enhancing error handling.
- Updated MCP tools debugging to provide insights into tool application and validation processes, aiding in troubleshooting.
- Refactored output handling in traceAgentOutput for better clarity and consistency in response management.
2025-11-29 17:18:47 +08:00
Max
739a03b4cf Refactor tool call result methods and update i18n messages for clarity
- Renamed methods in ToolCallResult from ServerID to Server and ToolName to Tool for improved clarity and consistency.
- Updated i18n messages in builtin.go to remove redundant context, simplifying the label and description for the assistant's streaming process.
2025-11-29 16:06:34 +08:00
Max
a686483f15 Implement tool call retry logic in Assistant's streaming process
- Enhanced the Stream method to include a retry mechanism for tool calls, allowing for up to three attempts in case of errors.
- Introduced detailed logging for each retry attempt, improving traceability and debugging capabilities.
- Added a new method, buildToolRetryMessages, to construct messages for LLM retries, ensuring proper context is maintained.
- Updated the executeLLMForToolRetry method to handle streaming output during retries, providing real-time feedback to users.
- Improved error handling to differentiate between retryable and non-retryable errors, enhancing the robustness of tool call executions.
2025-11-29 12:44:37 +08:00
Max
151d7f19e0 Enhance Assistant's message building and completion options handling
- Refactored the BuildRequest method to improve clarity and maintainability by separating the building of completion options and final messages.
- Updated the buildMessages function to include MCP samples as system messages, enhancing the message prioritization logic.
- Introduced applyMCPTools method to integrate MCP tools into completion options, improving functionality and flexibility in tool usage.
- Enhanced error handling in completion options to ensure robust application flow.
2025-11-29 11:08:42 +08:00
Max
cfde900ada Refactor MCP server configuration and enhance Assistant functionality
- Updated MCP server configuration to support advanced formats, including tools and resources.
- Refactored the Assistant's Stream method for improved readability and maintainability, adding clear section comments.
- Enhanced error handling and logging for better traceability during streaming operations.
- Removed deprecated methods and streamlined MCP server handling in tests to ensure robust functionality and validation.
2025-11-29 10:04:19 +08:00
Max
a0483bac5d Refactor Assistant streaming logic and remove MCP hook
- Simplified the Stream method by extracting capability initialization into a separate function, improving readability and maintainability.
- Enhanced error handling by centralizing trace logging for failures and history tracking.
- Removed the MCP hook implementation as it was no longer needed, streamlining the codebase.
- Updated agent trace handling to ensure consistent logging of agent output and errors.
2025-11-29 09:13:18 +08:00
Max
e3fde0aa6c Enhance memory leak tests and performance reporting in stress tests
- Added context release calls in multiple test cases to ensure proper resource cleanup and prevent memory leaks.
- Updated performance thresholds in memory leak tests, increasing acceptable growth per iteration from 10KB to 15KB to account for overhead.
- Improved validation checks in stress tests to ensure response integrity and metadata accuracy, enhancing overall test robustness.
- Refactored performance report for clarity, consolidating key metrics and findings for better readability.
2025-11-28 21:09:27 +08:00
Max
125c32a0b5 Improve MCP loading process by verifying directory existence before file operations
- Added a check to confirm the existence of the 'mcps' directory prior to loading MCP files, enhancing error handling and preventing unnecessary attempts to load from a non-existent directory.
- Updated error handling to ensure that any issues encountered during the loading process are logged appropriately.
2025-11-28 19:56:16 +08:00
Max
36e3334058 Enhance MCP loading functionality by checking for directory existence
- Added a check to verify if the 'mcps' directory exists before attempting to load MCP files, improving error handling and preventing unnecessary operations.
- Updated the error handling in the MCP loading function to ensure robustness in the application flow.
2025-11-28 19:53:48 +08:00
Max
8bf128e3ba Refactor stress test and i18n translations for improved clarity and consistency
- Cleaned up whitespace in the realworld_stress_test.go file to enhance readability.
- Updated i18n translations for MCP tool operations, ensuring consistent formatting and clarity in both English and Chinese descriptions.
2025-11-28 19:37:17 +08:00
Max
8dedd93a90 Remove deprecated agent_test.go and mcp package files; refactor context and trace handling for improved functionality.
- Deleted agent_test.go to streamline testing structure.
- Removed mcp package and its related fetch and search files to simplify the codebase.
- Enhanced context handling in jsapi_test.go and jsapi.go for better integration with JavaScript.
- Introduced no-op objects for Trace and Node to handle uninitialized states gracefully.
- Updated i18n translations to include new MCP-related labels and descriptions.
2025-11-28 19:26:33 +08:00
Max
0eed12165f Update dependencies in go.mod and go.sum
- Upgraded jsonschema from v0.5.2 to v0.6.1 for improved functionality.
- Updated go-json-experiment/json from a specific commit to a newer version for better compatibility.
- Added jsonpointer v0.4.6 and updated messageformat-go to v0.4.6 to ensure all dependencies are up-to-date and functioning correctly.
2025-11-27 21:09:14 +08:00
Max
55f7d03458 Enhance state management with safeSend method to prevent panics on closed channels
- Introduced safeSend method to handle context cancellation and prevent panics when sending commands to state command channel.
- Updated existing state management methods to utilize safeSend, ensuring robust handling of command sending in various states.
- Improved overall stability of state management by addressing potential race conditions and channel closure issues.
2025-11-26 19:45:22 +08:00
Max
17b71ee4cc Refactor message handling to support individual message lifecycle events
- Replaced group-related event types with message-specific types, enhancing clarity in event management.
- Updated stream handling functions to utilize new message start and end events, improving the granularity of message tracking.
- Refactored context management to integrate a context-scoped ID generator for unique message identifiers.
- Removed deprecated group handling methods and streamlined message processing logic.
- Updated tests and documentation to reflect changes in message handling and ensure proper functionality.
2025-11-26 19:03:47 +08:00
Max
ef49827faf Refactor message handling for improved streaming and event management
- Updated message structures to replace 'StreamStartData' and 'StreamEndData' with 'EventStreamStartData' and 'EventStreamEndData' for better clarity and consistency.
- Introduced 'EventMessageStartData' and 'EventMessageEndData' to represent individual message lifecycle events, enhancing the granularity of message tracking.
- Refactored the 'streamState' and 'groupTracker' to utilize the new message structures, improving the organization and handling of streaming events.
- Enhanced the context management by integrating an ID generator for unique message identifiers, facilitating better tracking of message sequences.
- Updated documentation and tests to reflect the new message structures and ensure proper functionality across the system.
2025-11-26 18:30:43 +08:00
Max
f0495ab990 Enhance streaming and grouping functionality in Assistant
- Introduced SendGroupStart and SendGroupEnd methods for better control over message grouping, allowing for automatic ID generation and event handling.
- Updated streamState structure to track group IDs, message sequences, and chunk counts, improving message organization during streaming.
- Refactored message handling to eliminate the 'done' field, signaling message completion through group_end events instead.
- Revised JSAPI documentation to reflect new methods and usage patterns, enhancing clarity for developers.
- Improved test cases to validate new group handling features and ensure proper functionality.
2025-11-26 11:00:52 +08:00
Max
afab9c2173 Update JSAPI documentation and examples for enhanced clarity and usage guidance
- Revised the JSAPI_OUTPUT.md to provide a comprehensive overview of Agent Hook functions and their usage.
- Added detailed examples for each hook function, demonstrating real-time messaging and error handling.
- Improved the structure and clarity of the documentation, ensuring users can easily understand how to implement and utilize the Context object methods.
- Removed deprecated sections and streamlined the content for better readability.
2025-11-26 09:00:39 +08:00
Max
673e36a7c9 Refactor: Decouple Output From Context 2025-11-25 22:08:00 +08:00
Max
824757aec7 Register jsapi output agent in main.go for enhanced output handling 2025-11-25 18:09:16 +08:00
Max
fb7799f187 Add user input message type and associated structures for frontend display
- Introduced a new message type `user_input` to handle user input specifically for frontend display.
- Defined `UserInputProps` structure to standardize the properties of user input messages, including content, role, and name.
- Implemented `NewUserInputMessage` function to facilitate the creation of user input messages.
- Updated built-in type checks to include the new user input type, ensuring compatibility across the system.
2025-11-25 16:29:44 +08:00