Commit graph

3681 commits

Author SHA1 Message Date
Max
4b30e80924 refactor(assistant): streamline JSON handling in query filters
- Introduced utility functions for applying LIKE conditions on JSON columns, enhancing compatibility with PostgreSQL.
- Simplified the filtering logic for tags and keywords in the GetAssistants and DeleteAssistants methods.
- Added unit tests for the new JSON handling functions to ensure correctness across different database drivers.
2026-04-06 03:22:39 +08:00
Max
8786aa9a6a feat(database): add PostgreSQL support and enhance JSON handling
- Updated database configuration to include PostgreSQL 14.0 in CI workflows.
- Enhanced JSON null detection in the Xun store to support PostgreSQL dialect.
- Refactored time conversion utilities to handle multiple database formats, including PostgreSQL.
- Improved cleanup logic in the DataCleaner to ensure proper order of operations for referential integrity.
- Added utility functions for converting between Unix timestamps and database timestamps.
2026-04-06 02:56:04 +08:00
Max
93641dea58 feat(profile): add endpoint to retrieve linked OAuth accounts for the user
- Implemented the GinProfileProviders function to fetch and return the current user's linked OAuth accounts.
- Added error handling for authentication and provider retrieval, ensuring proper responses for unauthorized access and server errors.
- Updated the user routing to include a new GET endpoint for accessing linked OAuth providers.
2026-04-03 10:28:07 +08:00
Max
413fd71841 feat(middleware): add support for markdown content negotiation and rendering
- Implemented content negotiation for markdown files based on URL suffix and Accept header.
- Introduced a new RenderRaw method to serve raw markdown content, bypassing HTML rendering.
- Updated PageConfig to include a handler for markdown output, enhancing flexibility in content delivery.
2026-04-02 18:55:36 +08:00
Max
99ce3ea456 chore(dependencies): update golang.org/x/text, golang.org/x/image, and golang.org/x/sync to latest versions
Updated the dependencies in go.mod and go.sum files to use golang.org/x/text v0.35.0, golang.org/x/image v0.38.0, and golang.org/x/sync v0.20.0. This ensures compatibility with the latest features and improvements in these libraries.
2026-04-01 08:26:18 +08:00
Max
032488512a refactor(response): remove hardcoded cookie path from refresh token functions
Eliminated the hardcoded path "/auth" from the SendRefreshTokenCookie functions and the DeleteAllAuthCookies function. This change enhances flexibility by allowing the cookie path to be managed more dynamically in the future.
2026-03-31 20:27:49 +08:00
Max
31e6bd8ec8 refactor(sandbox/v2): replace resolveEnvRef with str.EnvVar for environment variable handling
Removed the resolveEnvRef function and replaced its usage with str.EnvVar for processing environment variables in BuildCreateOptions and buildEnv functions. This change simplifies the code and enhances consistency in how environment variables are managed across the sandbox.
2026-03-30 11:18:36 +08:00
Max
46ea2cfbe4 fix(sandbox/v2): enhance resolveEnvRef to support base64-encoded environment variables
Updated the resolveEnvRef function to handle $ENV_B64.XXX references, allowing for base64-decoding of environment variables. This enhancement is particularly useful for managing multi-line values such as SSH private keys, improving the flexibility of environment variable handling.
2026-03-30 10:24:41 +08:00
Max
5e708010cd fix(sandbox/v2): update initSandboxV2 to return a per-request SandboxConfig
Modified the initSandboxV2 function to return a per-request copy of the SandboxConfig, ensuring that concurrent requests to the same assistant have their own mutable configuration. Updated related logging and cleanup processes to utilize the new configuration structure. Additionally, introduced a DefaultOneShotMaxAge constant to manage the lifecycle of OneShot containers more effectively.
2026-03-30 08:10:58 +08:00
Max
56fe84fa33 Revert "fix(sandbox/v2): oneshot containers never cleaned up by watcher"
This reverts commit c26d764857.
2026-03-29 23:18:21 +08:00
Max
cc0bb7e161 fix(sandbox/v2): LifecycleAction uses computer.BoxID instead of cfg.ID
cfg (ast.SandboxV2) is a pointer shared across all concurrent calls to
the same Assistant. GetComputer writes cfg.ID = <random hex> for each
oneshot request, so concurrent tasks overwrite each other's ID.

When cleanup runs in defer, cfg.ID holds whichever task last wrote it —
not the ID of the box this request created — so manager.Remove/Heartbeat
silently fails with "sandbox: not found" and the container leaks.

Fix: derive the box ID from computer.ComputerInfo().BoxID, which is the
immutable b.id set at Create time and never mutated by concurrent callers.

Made-with: Cursor
2026-03-29 23:08:50 +08:00
Max
c26d764857 fix(sandbox/v2): oneshot containers never cleaned up by watcher
Three related bugs caused oneshot containers to run indefinitely:

1. watcher.go: switch b.policy had no case OneShot, so even when the
   idle timeout fired, no remove action was emitted.

2. watcher.go + manager.go/recoverBoxes: idleTimeoutD was only set for
   Session and LongRunning on recovery; OneShot defaulted to 0, which
   caused the watcher to hit the `timeout <= 0` early-return and skip
   all checks entirely.

3. agent/sandbox/v2/options.go: same gap — opts.IdleTimeout == 0 guard
   only filled defaults for Session and LongRunning.

Fix: add DefaultOneShotIdleTimeout (30 min), wire it in recoverBoxes
and options.go, and add case OneShot → Remove in watcher.go.

Made-with: Cursor
2026-03-29 23:01:21 +08:00
Max
8fdd1a3a6c feat(robot): add workspace support to robot management
- Introduced a new `workspace` field across various robot-related structures, including `CreateRobotRequest`, `UpdateRobotRequest`, and `RobotResponse`, allowing for better organization and management of robots within specific workspaces.
- Updated database queries and response mappings to accommodate the new workspace field, ensuring seamless integration with existing functionalities.
- Enhanced agent execution context to include workspace information, improving the contextual awareness of agents during operations.
- Added tests to validate the creation and updating of robots with workspace data, ensuring robust functionality and backward compatibility.
2026-03-28 16:59:52 +08:00
Max
79cd95e6cc fix(claude): update environment variable setup to use dynamic model values
- Modified the buildEnv function to set environment variables for ANTHROPIC_MODEL and related keys dynamically based on the provided model value, enhancing flexibility and configurability.
2026-03-28 10:35:09 +08:00
Max
7c96458d8c fix(tai/tunnel): handle concurrent "open" frames in TestRegister_Ping
In CI environments where a real tai gRPC endpoint is reachable on
port 19100, the asynchronous connectTunnelNode goroutine can dial
successfully and send an "open" TunnelControl frame on the Register
stream before the test's "pong" arrives.

Loop on Recv() and skip non-pong frames so the test passes regardless
of whether connectTunnelNode fires in the background.

Made-with: Cursor
2026-03-28 09:13:21 +08:00
Max
03e6febc35 feat(claude): enhance logging of environment variables in Stream method
- Added detailed logging of environment variables passed to the session in the Stream method, improving visibility into the execution context.
- Implemented conditional logging to display sensitive variables in a secure manner, ensuring that only relevant information is shown.
2026-03-28 09:02:42 +08:00
Max
e90808e861 feat(claude): refactor runner and enhance request handling
- Renamed ClaudeRunner to Runner for consistency across the codebase, aligning with the sandbox Runner interface.
- Updated buildCommand and Stream methods to utilize AssistantID directly from StreamRequest, improving clarity and reducing dependency on Config.
- Modified tests to reflect the changes in runner instantiation and argument handling, ensuring compatibility with the new Runner structure.
- Enhanced environment variable setup in buildEnv to include WORKDIR, streamlining the execution context for the runner.
2026-03-27 23:07:11 +08:00
Max
6e003875b4 feat(licenses): implement machine ID binding for license validation
- Added support for machine ID binding in license certificates, ensuring that if a machine ID is specified, it must match the current runtime machine ID for the license to be valid.
- Introduced new tests to verify behavior for empty, matching, and mismatching machine IDs in certificates, enhancing the robustness of license validation.
- Updated LicenseInfo struct to include MachineID field, reflecting the new binding requirement.
2026-03-27 17:18:17 +08:00
Max
ac8cdaeda9 refactor(workflows): remove license root certificate injection from build process
- Eliminated the steps for injecting commercial license root certificates from GitHub Secrets in both Linux and macOS workflows, streamlining the build process.
- Updated the `inspect` command to load commercial license information directly, enhancing the application's licensing capabilities without relying on external secrets during the build.
2026-03-27 15:46:01 +08:00
Max
aa5a16c4a7 refactor(tests): update synchronization handling in certificate pool tests
- Replaced direct initialization of sync.Once instances with pointers to enhance clarity and consistency in the test setup.
- Updated the `withTestRootPool` function to use new `doneOnce` variables for managing synchronization, ensuring proper initialization of the root certificate pool and revoked serials.
2026-03-27 15:09:05 +08:00
Max
789cc85996 feat(certificates): inject commercial license root certificates into build process
- Added steps in both Linux and macOS workflows to inject commercial license root certificates from GitHub Secrets during the build process.
- Updated the `inspect` and `load` packages to include license information, enhancing the application's licensing capabilities.
- Included license metadata in the OpenAPI response for better visibility of licensing status.
2026-03-27 12:51:30 +08:00
Max
c89570f3a7 chore(dependencies): remove unused Go module dependencies
- Removed `github.com/blang/semver` and `github.com/rhysd/go-github-selfupdate` from go.mod as they are no longer needed.
- Cleaned up go.sum to reflect the removal of these dependencies, ensuring a more streamlined module management.
2026-03-27 09:31:33 +08:00
Max
890ca3e25a refactor(tests): rename and consolidate input building functions for clarity
- Renamed `buildInput` to `buildLastUserMessageJSONL` to better reflect its purpose of constructing JSONL from the last user message.
- Updated test cases to use the new function, ensuring they accurately verify the behavior of skipping system messages and only including the last user message.
- Removed the now redundant `buildFirstRequestJSONL` function, streamlining the input building process in the Claude command tests.
2026-03-27 09:30:35 +08:00
Max
14426327dd chore(logging): enhance logging and context management in agent and sandbox components
- Updated logging in various methods to include detailed traces for better monitoring of execution flow, including assistantID and chatID.
- Improved context management by ensuring proper release of resources and tracking of execution durations in agent calls.
- Added heartbeat logging in the Claude parser to monitor stream processing and prevent potential issues with long-running tasks.
- Refined the .gitignore file to exclude additional markdown files in the sandbox directory.
2026-03-25 22:00:58 +08:00
Max
2b0ac0d270 refactor(agent): update buildAgentContext to include assistantID
- Modified the buildAgentContext function to accept assistantID as a parameter, enhancing the context building process for agent calls.
- Updated multiple Call methods to pass the assistantID, ensuring proper context management during agent interactions.
2026-03-25 18:03:48 +08:00
Max
abde3adf13 feat(claude): enhance session management and argument building
- Introduced session ID and name handling in the buildArgs function, allowing for better tracking of chat sessions.
- Added chatIDToSessionUUID and sanitizeSessionName functions to generate and format session identifiers.
- Updated the Stream method to store session information and manage session lifecycle more effectively.
- Implemented KillSessionCmd for precise process termination based on session names in both Windows and POSIX platforms.
- Enhanced tests to cover new session management features and ensure correct behavior in various scenarios.
2026-03-25 17:25:55 +08:00
Max
427c38bac7 fix(robot): improve locale handling in agent context
- Updated agent context to ensure locale is propagated correctly, defaulting to "en" when no locale is provided. This change enhances internationalization support and ensures consistent behavior across different contexts.
- Adjusted test assertions to reflect the updated execution trigger logic for times mode robots, allowing for a maximum of 2 triggers instead of 1.
2026-03-25 15:18:02 +08:00
Max
dc941636c3 test(robot): update integration tests to use dry run executor
- Modified integration tests to utilize the new dry run executor in the manager configuration, ensuring consistent execution behavior during testing.
- Updated multiple test cases to replace direct manager instantiation with the new configuration method, enhancing test reliability and maintainability.
2026-03-25 00:19:22 +08:00
Max
68c29ca1c0 test(robot): extend timeout for execution status checks in E2E tests
- Increased the timeout duration from 60 seconds to 120 seconds for waiting on execution statuses in multiple E2E test cases, ensuring more reliable test outcomes during longer execution scenarios.
2026-03-24 23:04:26 +08:00
Max
38a3316336 feat(robot): enhance execution management and slot acquisition
- Implemented pre-acquisition of execution slots in the Tick method to prevent race conditions, ensuring that robots do not submit duplicate executions.
- Updated TryAcquireSlot method to support idempotent behavior, allowing for early slot reservation without consuming additional resources.
- Modified worker execution logic to skip pre-checks for robots that have already acquired a slot, streamlining the execution process.
- Improved error handling during execution submission to ensure proper tracking and removal of failed executions.
2026-03-24 22:30:37 +08:00
Max
96194110d1 refactor(assistant): improve sandbox version extraction logic
- Enhanced the extractSandboxVersion function to support multiple input types, including *sandboxTypes.SandboxConfig and map[string]any, for better flexibility in version retrieval.
- Simplified the version extraction process, ensuring consistent handling of sandbox configurations.
2026-03-24 20:45:05 +08:00
Max
d43b637ad4 feat(assistant): enhance sandbox handling and improve assistant tag filtering
- Added support for sandbox configuration in the LoadPath function, allowing for better management of sandbox settings.
- Updated tests to validate the retrieval of assistant tags with type filters, ensuring accurate responses for both assistant and robot types.
- Enhanced the assistant model to differentiate between sandbox versions, improving the handling of sandbox data in the database.
- Improved API responses to include computer filter details for V2 sandboxes, enhancing the information returned to clients.
2026-03-24 19:19:04 +08:00
Max
6d57c99357 fix(parser): improve text message handling and logging in Claude
- Added logic to buffer whitespace when no active text message is present, preventing unnecessary message group creation.
- Ensured proper closure of open text messages before executing new messages to maintain message integrity.
- Enhanced logging in the Stream and runStream methods to provide better visibility into execution flow and errors.
- Implemented shutdown logic to handle process termination gracefully after stream completion, addressing known issues with the Claude CLI.
2026-03-24 17:40:09 +08:00
Max
c4696380f4 feat(robot): implement global phase agent resolution for improved agent configuration
- Introduced a new global phase agent resolver to streamline agent ID retrieval for various robot pipeline phases, enhancing flexibility in agent configuration.
- Updated existing phase agent retrieval logic to prioritize per-robot configurations, falling back to global settings when necessary.
- Enhanced error handling to provide clearer messages when no agent is configured for specific phases.
- Added tests to validate the new resolution logic and ensure proper functionality across different configurations.
2026-03-24 12:11:55 +08:00
Max
09af247a7c feat(robot): add Weixin integration and enhance existing adapters
- Introduced Weixin integration support with new configuration options for WeChat iLink Bot.
- Updated existing adapters (DingTalk, Discord, Feishu, Telegram) to include sender_id and app_id in message metadata for improved context handling.
- Enhanced dispatcher logic to accommodate the new Weixin adapter and ensure proper initialization and shutdown processes.
- Improved message handling across integrations to support typing indicators, providing a more interactive user experience.
2026-03-23 23:47:25 +08:00
Max
c5bc1fe1c0 refactor(robot): streamline execution insertion logic in tests
- Replaced direct database insertion with a structured approach using ExecutionStore for better maintainability.
- Updated time parsing logic to handle both timezone-aware and local time formats, improving robustness.
- Enhanced the insertWatcherExec function to utilize the new execution record structure, ensuring consistency in execution data handling.
2026-03-23 18:42:57 +08:00
Max
ce19e9bdb7 feat(robot): enhance manager and execution handling
- Added GetManager function to retrieve the global manager instance, returning nil if not started.
- Introduced ExecRecovered event to notify about recovered non-terminal executions during manager startup.
- Updated execution store to support querying by multiple statuses with ListByStatuses method.
- Enhanced integration tests to accommodate longer tick intervals and added sleep delays for stability.
- Improved cleanup logic in integration tests to prevent interference from previous execution records.
2026-03-23 17:46:32 +08:00
Max
1bddac44a4 refactor(robot): rename ListRobots to ListAllRobots and enhance caching logic
- Renamed ListRobots function to ListAllRobots for clarity and consistency across the codebase.
- Updated related API endpoints and tests to reflect the new function name.
- Improved caching logic to ensure both autonomous and non-autonomous robots are loaded correctly.
- Enhanced filtering and pagination capabilities within the ListAllRobots function.
- Added new test cases to validate the updated functionality and ensure robust performance.
2026-03-23 12:25:17 +08:00
Max
0e1e60b39c chore(deps): update dependencies in go.mod and go.sum
- Upgraded google.golang.org/grpc from v1.78.0 to v1.79.3 for improved performance and features.
- Updated golang.org/x/oauth2 from v0.32.0 to v0.34.0 to incorporate the latest enhancements and fixes.
- Added agent/robot/ROBOT-WATCHER-IMPROVEMENT.md to .gitignore to prevent tracking of specific improvement documentation.
2026-03-23 09:59:50 +08:00
Max
ff5a3e4220 refactor(sandbox): streamline connector configuration injection and cleanup
- Removed the RegisterProxyConfigs function and its related logic from the sandbox initialization, simplifying the setup process.
- Updated the GetComputer function to handle connector configuration injection directly within the ClaudeRunner.Stream method, ensuring a more cohesive approach to configuration management.
- Introduced a new injectA2OConfig function to push connector configurations to the a2o proxy, enhancing flexibility and error handling.
- Improved logging for connector configuration injection to provide better traceability during execution.
2026-03-22 23:29:03 +08:00
Max
5465fb2718 feat(sandbox): enhance connector configuration and streamline sandbox execution
- Introduced a new sandboxV2StreamParams struct to group parameters for the executeSandboxV2Stream function, improving code clarity and maintainability.
- Updated the GetComputer function to handle connector configuration injection via the a2o proxy, removing the need for direct connector parameters.
- Enhanced the executeSandboxV2Stream function to utilize the new parameters struct, simplifying the function signature and improving readability.
- Implemented RegisterProxyConfigs to inject OpenAI-compatible connector configurations into the a2o proxy, ensuring proper environment setup for sandbox execution.
- Refactored BuildCreateOptions to remove direct connector handling, aligning with the new configuration injection approach.
2026-03-21 23:10:15 +08:00
Max
10e004bfad feat(logging): enhance logging across various components for improved traceability
- Added detailed trace logging in the Assistant's Stream function to capture computer and workspace information.
- Replaced fmt.Printf statements with kunlog.Trace in the Telegram polling adapter for consistent logging.
- Updated sandbox lifecycle management functions to utilize kunlog for logging workspace and node resolution details.
- Enhanced error handling in the Claude parser with trace logging for JSON unmarshal and scanner errors.
- Improved file handling logging in the workspace API to provide clearer insights into file read operations.
2026-03-21 20:44:59 +08:00
Max
6f1cc27baf feat(sandbox): enhance workspace and node handling in lifecycle management
- Updated the BuildIdentifier function to use the ownerID as a fallback for workspaceID, improving identifier generation consistency.
- Enhanced ResolveNodeID to auto-select nodes based on filters and added detailed logging for better traceability.
- Modified GetComputer to include improved logging and streamlined node resolution logic.
- Introduced StringOrArray type for flexible handling of computer filter parameters in the SandboxConfig.
- Enriched workspace response structure to include detailed node information, enhancing API response clarity.
- Implemented default workspace ID generation based on owner and node, ensuring consistent workspace identification.
- Added locale support in CreateOptions for better internationalization.
2026-03-21 20:10:08 +08:00
Max
4f7989d796 feat(tests): enhance bash script validation in platform tests
- Added assertions to ensure the presence and order of `set -e` and `set +e` in the generated bash script when a system prompt is included.
- Updated the test for the scenario without a prompt to confirm that `set -e` is not present, ensuring correct script behavior.
- Improved documentation in the `buildBashScript` function to clarify the use of `set -e` for error handling during script execution.
2026-03-21 11:04:18 +08:00
Max
610e6b3506 feat(stream): introduce execute message handling for sandbox CLI actions
- Added support for "execute" message type to track tool execution observations within the sandbox environment.
- Implemented handling for execute messages in the stream processing, allowing for real-time updates on tool execution status.
- Enhanced the stream parser to manage the lifecycle of execute messages, including merging input and output data.
- Updated the stream handler to accommodate new message types, improving overall message processing capabilities.
- Refactored related tests to ensure coverage for the new execute message functionality, enhancing reliability.
2026-03-20 22:48:36 +08:00
Max
020927e9af feat(sandbox): enhance assistant directory handling and update RunPrepareSteps signature
- Updated the sandbox initialization to resolve both the assistant directory and skills subdirectory, improving directory management.
- Modified the RunPrepareSteps function signature to include an assistantDir parameter, allowing for better handling of file copy operations.
- Adjusted all relevant calls to RunPrepareSteps across the codebase to accommodate the new parameter, ensuring consistency in execution.
- Enhanced test cases to reflect the updated function signature, improving coverage and reliability of the sandbox preparation process.
2026-03-18 22:58:38 +08:00
Max
42b45f9357 refactor(sandbox): streamline sandbox configuration loading and enhance local execution capabilities
- Replaced the previous file extension checks with a unified parsing function for sandbox configuration, improving code clarity and maintainability.
- Introduced a new HostExecConfig structure to manage local execution settings, allowing for more granular control over command execution permissions.
- Removed deprecated Moapi API files and related functionality, simplifying the codebase and reducing maintenance overhead.
- Updated the Tai node registration process to ensure local capabilities are accurately reflected based on the environment, enhancing overall system robustness.
2026-03-18 11:22:08 +08:00
Max
9ba95498f9 feat(stream): enhance process management and error handling in Claude CLI
- Improved the PowerShell script for killing processes on Windows to ensure child processes are also terminated.
- Introduced a sentinel error for stream completion, allowing for better handling of normal stream terminations.
- Updated the parsing function to close stdout on context cancellation, preventing indefinite blocking on read errors.
- Enhanced logging to provide clearer feedback on stream completion and process management during execution.
2026-03-17 20:58:59 +08:00
Max
0e64d05dbf feat(oscompat): improve PowerShell script for Claude CLI compatibility on Windows
- Added UTF-8 encoding settings for input and output streams to prevent JSON corruption on CJK Windows.
- Implemented a search for common installation paths of claude.exe across user profiles to ensure accessibility when running as a different user.
- Updated logging in the Stream function to include the working directory for better context during execution.
2026-03-17 18:49:15 +08:00
Max
b037475c14 feat(build): enhance macOS application signing process
- Updated the Makefile and GitHub workflows to include entitlements during the codesigning process for macOS applications, improving security and compliance.
- Added timestamp and runtime options to the codesigning commands, ensuring better handling of application signatures.
- Refactored the signing logic to maintain consistency across different build targets, enhancing the overall release process.
2026-03-16 23:30:20 +08:00