Commit graph

484 commits

Author SHA1 Message Date
Max
8d44ef31c1 refactor(assistant): replace JSON LIKE handling with JSON contains logic
- Updated GetAssistants and DeleteAssistants methods to utilize jsonContainsValue for filtering tags and locales, improving query compatibility across database drivers.
- Renamed related test functions to reflect the new JSON handling approach.
- Removed deprecated jsonLikeExpr and whereJsonLike methods to streamline codebase.
2026-04-06 10:56:45 +08:00
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
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
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
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
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
Max
fddd137806 fix(sandbox): update token generation and improve ClaudeRunner file handling
- Changed token generation from "sandbox:mcp" to "grpc:mcp" for both access and refresh tokens, aligning with updated service requirements.
- Enhanced ClaudeRunner to copy skills from the specified directory to the ".claude/skills" path, improving skill management.
- Updated MCP configuration file path to ".claude/mcp.json" for better organization and consistency in file handling.
- Added error logging for skill copying and exit code handling in stream execution, enhancing debugging capabilities.

Made-with: Cursor
2026-03-15 17:22:44 +08:00
Max
89e5840490 feat(sandbox): update sandbox status messages and improve loading feedback
- Modified Docker run commands in CI workflows to include the `-direct` flag for enhanced server operation.
- Removed outdated loading status message during sandbox preparation and added new messages for improved user feedback.
- Introduced a loading message for waiting on AI responses, enhancing the user experience during sandbox execution.
- Refactored identity handling in stream processing to streamline message management.

Made-with: Cursor
2026-03-15 13:52:38 +08:00
Max
a5c8109db8 feat(sandbox): enhance sandbox initialization and image management
- Updated Docker run commands in CI workflows to include the `-direct` flag for improved server operation.
- Implemented image existence checks and automatic pulling for sandbox environments, enhancing reliability during initialization.
- Added loading status updates for sandbox operations, providing better feedback during the setup process.
- Refactored lifecycle management to ensure accurate tracking of sandbox states and improved error handling.

Made-with: Cursor
2026-03-15 13:17:58 +08:00
Max
3797091d37 feat(sandbox): enhance lifecycle management and box status handling
- Updated BuildIdentifier to include assistant ID in session identifiers for better uniqueness.
- Implemented automatic starting of stopped boxes in resolveBox, improving recovery processes.
- Introduced status management for boxes, allowing for accurate tracking of their state (running, exited, stopped).
- Added idle timeout defaults based on lifecycle policy in BuildCreateOptions, enhancing configuration flexibility.
- Refactored tests to validate new box status behavior and lifecycle management improvements.

Made-with: Cursor
2026-03-15 11:51:09 +08:00
Max
d26bbd1e1f feat(sandbox): enhance sandbox configuration with display name and identifier updates
- Introduced a human-readable display name for the sandbox, constructed from the agent and workspace names.
- Updated the BuildIdentifier function to include workspace ID in identifiers for long-running and persistent lifecycles.
- Modified sandbox creation options to incorporate the display name, improving clarity in sandbox management.
- Refactored related tests to ensure compatibility with the new identifier structure and display name integration.

Made-with: Cursor
2026-03-14 18:32:09 +08:00
Max
223d02ebfe feat(sandbox): implement sandbox token handling in stream execution
- Added support for issuing and passing a sandbox token during stream execution in the Assistant.
- Updated StreamRequest to include a Token field for managing user authentication.
- Enhanced ClaudeRunner to set environment variables for the sandbox token and refresh token.
- Refactored SandboxToken structure to clarify its purpose and manage token credentials effectively.
- Modified sandbox management routes to enforce OAuth guard for improved security.

Made-with: Cursor
2026-03-14 15:50:59 +08:00
Max
82bb44cbda feat(workspace): add root directory retrieval for workspaces
- Implemented a new endpoint to retrieve the absolute path of a workspace's root directory.
- Enhanced the workspace interface with a GetRoot method to facilitate this functionality.
- Updated the workspace manager to utilize the new method for improved path resolution.

Made-with: Cursor
2026-03-13 18:25:14 +08:00
Max
7cccf62841 feat(tai): refactor Dial* functions and remove requireKubeConfig hard-fail
- Consolidate DialRemote/DialTunnel common logic into buildResources + dialEnv interface
- Remove strict capability check that prevented ConnResources creation for host-exec-only nodes
- Merge gRPC-discovered capabilities with registration-declared capabilities in DialTunnel
- Replace requireKubeConfig hard-fail with graceful skip when kubeconfig is absent
- Introduce tai/types package for shared Ports/Capabilities/SystemInfo/AuthInfo/NodeMeta
- Add tai/conn.go (ConnResources) and tai/dial.go (DialRemote/DialTunnel/DialLocal)
- Rename tai/sandbox → tai/runtime for clarity
- Update sandbox/v2, workspace, agent/sandbox/v2 test utilities for build-tag isolation

Made-with: Cursor
2026-03-12 15:44:24 +08:00
Max
c366ce4d0a feat(assistant): enhance assistant info structure and sandbox integration
- Updated the AssistantInfo struct to include new fields: Connector, ConnectorOptions, Modes, DefaultMode, Sandbox, and ComputerFilter for improved assistant configuration.
- Enhanced the loading process to extract Sandbox flag and ComputerFilter from V2 sandbox configuration.
- Refactored GetInfo method to return comprehensive assistant details for better UI integration.
- Introduced new endpoint for workspace options to streamline InputArea selector functionality.

Made-with: Cursor
2026-03-12 10:42:22 +08:00
Max
5ec7801689 feat(sandbox/v2): enhance connector integration and VNC configuration
- Refactored the sandbox initialization process to resolve the connector before obtaining the Computer, allowing for the injection of OPENAI_PROXY_* environment variables.
- Updated the GetComputer and BuildCreateOptions functions to accept an optional connector parameter for improved environment variable management.
- Standardized the VNC configuration by replacing SANDBOX_VNC_ENABLED with VNC_ENABLED across Dockerfiles and related scripts for consistency.
- Enhanced the VNC service startup script to check the new VNC_ENABLED variable, ensuring proper service initialization.

Made-with: Cursor
2026-03-10 23:28:31 +08:00