Commit graph

3693 commits

Author SHA1 Message Date
Max
dd9c81068b feat(user): implement Device Flow support in OAuth provider configuration
- Added DeviceClientID and DeviceClientSecret fields to the Provider struct for Device Flow (RFC 8628) support.
- Introduced new types and methods for handling Device Authorization and Token requests/responses.
- Updated API routes to include endpoints for initiating Device Flow and polling for tokens.
- Enhanced loadProviders function to process new device-related environment variables.
2026-04-14 18:23:30 +08:00
Max
1deef3cabf feat(robot): enhance DeliveryAttachment structure with size and content type fields
- Added Size field to represent the file size in bytes.
- Introduced ContentType field to specify the MIME type of the attachment.
- Updated API endpoint to support bundling multiple files into a ZIP archive.
2026-04-14 15:01:05 +08:00
Max
c976a3e398 chore(dependencies): update Go module dependencies to latest versions
- Upgraded several dependencies in go.mod and go.sum, including golang.org/x/crypto, golang.org/x/net, golang.org/x/sys, and google.golang.org/grpc to their latest versions for improved security and performance.
- Updated opentelemetry packages to v1.43.0 and added new indirect dependencies for better observability support.
- Adjusted the handling of execute messages in stream.go to ensure proper persistence based on message status.
- Enhanced command handling in command.go to maintain system prompt constraints during continuation turns.
2026-04-13 23:43:17 +08:00
Max
0cbc7d961d refactor(parser): streamline event handling and tool state management
- Replaced chunkRecord with recordedEvent to simplify event recording.
- Introduced activeToolID to manage the currently streaming tool, allowing for better state handling during parsing.
- Enhanced closeStreamingTool and suspendStreamingTool methods for improved tool message management.
- Updated parsing logic to handle multiple concurrent tool calls more effectively.
- Added utility functions for extracting message groups and properties from recorded events.
2026-04-13 22:24:40 +08:00
Max
c987bd687f fix(sandbox): pass explicit user to docker exec for UID-mapped containers
After tai sandbox containers start as root with dynamic UID mapping,
docker exec defaults to root. Add User field to ExecOptions and
hardcode "sandbox" in Box.Exec/Stream to ensure commands run as the
correct user.

Made-with: Cursor
2026-04-13 18:26:41 +08:00
Max
2084e20479 feat(workspace): add workspace ID retrieval and integration into environment configuration
- Implemented GetWorkspaceID method in the context package to retrieve the workspace ID.
- Updated buildContextVariables to include WORKSPACE_ID in the context variables if available.
- Enhanced buildEnv function to set CTX_WORKSPACE_ID in the environment configuration based on the workspace ID.
- Refactored role connector handling to support multiple connectors in the environment setup.
- Added tests for new role connector functionality and workspace ID integration.
2026-04-13 14:47:08 +08:00
Max
cc5e888f5a feat(system): add Vision and Voice capabilities to System configuration
- Introduced Vision and Voice fields in the SystemConfig and System types to support new capabilities.
- Updated resolveEnvStrings function to handle environment variables for Vision and Voice.
- Enhanced unit tests to validate the new Vision and Voice configurations, ensuring correct environment variable resolution.
- Added GetVisionConnector and GetVoiceConnector functions to retrieve connectors for vision and voice capabilities.
2026-04-10 11:22:18 +08:00
Max
0c7d635966 chore(dependencies): update AWS SDK and related packages to latest versions
- Upgraded AWS SDK for Go v2 and its related packages in go.mod and go.sum to improve compatibility and access to new features.
- Updated session management logic in the Runner to ensure proper handling of chat sessions.
- Added new unit tests for keyword search functionality in the Assistant model, enhancing search capabilities across locales.
- Refactored JSON handling in the Assistant package to streamline options configuration.
2026-04-08 17:24:35 +08:00
Max
15a71692a2 fix(tests): improve error handling in unit tests and Makefile
- Enhanced the Makefile to include additional checks for test failures, specifically for panic messages and general failure indicators.
- Updated service tests to dynamically retrieve the server port, ensuring accurate request routing.
- Added a clear function call in the dashboard process test setup to ensure a clean state before tests run.
2026-04-06 17:17:11 +08:00
Max
5c1664e882 feat(job): enhance health checker and data cleaner with panic recovery and graceful shutdown
- Added panic recovery to health checker and data cleaner to prevent crashes from unexpected errors.
- Implemented graceful shutdown for both components, ensuring they complete ongoing tasks before stopping.
- Updated the job import in the load module to manage health checker and data cleaner lifecycle.
- Introduced new channels to signal completion of health checks and data cleanups.
2026-04-06 12:37:58 +08:00
Max
1a5e1db2ec refactor(time): enhance timestamp handling with utility functions
- Introduced NanoToTime and TimeToNano functions for converting between UnixNano and time.Time, improving clarity and consistency in timestamp management.
- Updated Assistant model to utilize the new utility functions for created_at and updated_at fields.
- Refactored Xun store methods to ensure UTC compatibility for timestamp serialization across different database drivers.
- Added unit tests for the new conversion functions to validate their correctness and behavior.
2026-04-06 11:21:12 +08:00
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
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