@ai-setting/roy-agent-core 1.7.52 → 1.7.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/config-component.d.ts +346 -0
- package/dist/config/config-parser.d.ts +45 -0
- package/dist/config/env-key.d.ts +97 -0
- package/dist/config/env-source.d.ts +113 -0
- package/dist/config/file-source.d.ts +90 -0
- package/dist/config/index.d.ts +4 -0
- package/dist/config/protocol-resolver.d.ts +94 -0
- package/dist/env/agent/agent-component.d.ts +646 -0
- package/dist/env/agent/agent-config-registration.d.ts +18 -0
- package/dist/env/agent/agent-registry.d.ts +500 -0
- package/dist/env/agent/index.d.ts +9 -0
- package/dist/env/agent/index.js +3 -3
- package/dist/env/agent/summary-agent.d.ts +44 -0
- package/dist/env/agent/types.d.ts +503 -0
- package/dist/env/commands/commands-component.d.ts +97 -0
- package/dist/env/commands/commands-config-registration.d.ts +19 -0
- package/dist/env/commands/index.d.ts +7 -0
- package/dist/env/commands/parser.d.ts +18 -0
- package/dist/env/commands/types.d.ts +133 -0
- package/dist/env/component.d.ts +186 -0
- package/dist/env/constants.d.ts +112 -0
- package/dist/env/context/env-context.d.ts +420 -0
- package/dist/env/context/env-event.d.ts +144 -0
- package/dist/env/context/index.d.ts +13 -0
- package/dist/env/debug/debug-component.d.ts +160 -0
- package/dist/env/debug/formatters/index.d.ts +8 -0
- package/dist/env/debug/formatters/repl-formatter.d.ts +80 -0
- package/dist/env/debug/formatters/trace-formatter.d.ts +43 -0
- package/dist/env/debug/formatters/tree-formatter.d.ts +72 -0
- package/dist/env/debug/index.d.ts +15 -0
- package/dist/env/debug/index.js +1 -1
- package/dist/env/debug/parser/regex-parser.d.ts +49 -0
- package/dist/env/debug/parser/span-builder.d.ts +79 -0
- package/dist/env/debug/reader/log-reader.d.ts +55 -0
- package/dist/env/debug/reader/span-db-reader.d.ts +70 -0
- package/dist/env/debug/types.d.ts +145 -0
- package/dist/env/environment.d.ts +185 -0
- package/dist/env/error-reply.d.ts +184 -0
- package/dist/env/errors.d.ts +120 -0
- package/dist/env/event-source/bounty-cli-handler.d.ts +42 -0
- package/dist/env/event-source/bounty-im-handler.d.ts +232 -0
- package/dist/env/event-source/event-source-component.d.ts +177 -0
- package/dist/env/event-source/event-source-config-registration.d.ts +18 -0
- package/dist/env/event-source/event-source-handlers.d.ts +472 -0
- package/dist/env/event-source/event-store.d.ts +110 -0
- package/dist/env/event-source/idempotency-key.d.ts +19 -0
- package/dist/env/event-source/index.d.ts +15 -0
- package/dist/env/event-source/index.js +6 -6
- package/dist/env/event-source/timer-handler.d.ts +74 -0
- package/dist/env/event-source/types.d.ts +803 -0
- package/dist/env/hook/global-hook-manager.d.ts +73 -0
- package/dist/env/hook/hook-manager.d.ts +139 -0
- package/dist/env/hook/index.d.ts +9 -0
- package/dist/env/hook/types.d.ts +107 -0
- package/dist/env/index.d.ts +24 -0
- package/dist/env/index.js +18 -18
- package/dist/env/interface.d.ts +156 -0
- package/dist/env/lark-mention-utils.d.ts +59 -0
- package/dist/env/llm/adapter-ai-sdk.d.ts +10 -0
- package/dist/env/llm/adapter-pi-ai.d.ts +184 -0
- package/dist/env/llm/adapter.d.ts +100 -0
- package/dist/env/llm/factory.d.ts +13 -0
- package/dist/env/llm/hooks.d.ts +150 -0
- package/dist/env/llm/index.d.ts +16 -0
- package/dist/env/llm/index.js +2 -2
- package/dist/env/llm/invoke.d.ts +304 -0
- package/dist/env/llm/llm-cache.d.ts +38 -0
- package/dist/env/llm/llm.d.ts +263 -0
- package/dist/env/llm/opencode-session.d.ts +79 -0
- package/dist/env/llm/provider.d.ts +40 -0
- package/dist/env/llm/reasoning-defense.d.ts +104 -0
- package/dist/env/llm/tool-args-parser.d.ts +77 -0
- package/dist/env/llm/tool-schema.d.ts +54 -0
- package/dist/env/llm/transform.d.ts +57 -0
- package/dist/env/llm/types.d.ts +844 -0
- package/dist/env/log-trace/decorator.d.ts +88 -0
- package/dist/env/log-trace/index.d.ts +14 -0
- package/dist/env/log-trace/log-trace-component.d.ts +268 -0
- package/dist/env/log-trace/log-trace-config-registration.d.ts +25 -0
- package/dist/env/log-trace/logger.d.ts +83 -0
- package/dist/env/log-trace/opentelemetry/cli-propagation.d.ts +105 -0
- package/dist/env/log-trace/opentelemetry/mod.d.ts +24 -0
- package/dist/env/log-trace/opentelemetry/propagation-env.d.ts +81 -0
- package/dist/env/log-trace/opentelemetry/propagation.d.ts +79 -0
- package/dist/env/log-trace/opentelemetry/tracer-provider.d.ts +157 -0
- package/dist/env/log-trace/span-storage.d.ts +37 -0
- package/dist/env/log-trace/trace-context.d.ts +28 -0
- package/dist/env/log-trace/types.d.ts +127 -0
- package/dist/env/mcp/command-resolver.d.ts +12 -0
- package/dist/env/mcp/config.d.ts +103 -0
- package/dist/env/mcp/index.d.ts +13 -0
- package/dist/env/mcp/loader.d.ts +78 -0
- package/dist/env/mcp/mcp-component.d.ts +54 -0
- package/dist/env/mcp/mcp-config-registration.d.ts +19 -0
- package/dist/env/mcp/npm-prefix/index.d.ts +17 -0
- package/dist/env/mcp/scanner.d.ts +38 -0
- package/dist/env/mcp/tool/adapter.d.ts +32 -0
- package/dist/env/mcp/tool/index.d.ts +4 -0
- package/dist/env/mcp/types.d.ts +131 -0
- package/dist/env/memory/built-in/index.d.ts +41 -0
- package/dist/env/memory/built-in/recall-memory.d.ts +29 -0
- package/dist/env/memory/built-in/record-memory.d.ts +44 -0
- package/dist/env/memory/index.d.ts +10 -0
- package/dist/env/memory/memory-component.d.ts +114 -0
- package/dist/env/memory/memory-config-registration.d.ts +18 -0
- package/dist/env/memory/memory-config.d.ts +18 -0
- package/dist/env/memory/plugin/index.d.ts +16 -0
- package/dist/env/memory/plugin/memory-agent.d.ts +126 -0
- package/dist/env/memory/plugin/memory-manager.d.ts +71 -0
- package/dist/env/memory/plugin/memory-plugin.d.ts +103 -0
- package/dist/env/memory/plugin/recall-memory.d.ts +16 -0
- package/dist/env/memory/plugin/types.d.ts +75 -0
- package/dist/env/memory/tools/memory-agent-tools.d.ts +109 -0
- package/dist/env/memory/types.d.ts +80 -0
- package/dist/env/paths.d.ts +46 -0
- package/dist/env/plugin/bounty-cli-notification-channel.d.ts +60 -0
- package/dist/env/plugin/event-bus-notification-channel.d.ts +50 -0
- package/dist/env/plugin/index.d.ts +13 -0
- package/dist/env/plugin/lark-cli-notification-channel.d.ts +61 -0
- package/dist/env/plugin/notification-channel.d.ts +143 -0
- package/dist/env/plugin/plugin-component.d.ts +232 -0
- package/dist/env/plugin/types.d.ts +146 -0
- package/dist/env/prompt/index.d.ts +7 -0
- package/dist/env/prompt/index.js +2 -2
- package/dist/env/prompt/prompt-component.d.ts +194 -0
- package/dist/env/prompt/prompt-config-registration.d.ts +18 -0
- package/dist/env/prompt/prompt-store.d.ts +26 -0
- package/dist/env/prompt/prompts-index.d.ts +146 -0
- package/dist/env/prompt/renderer.d.ts +21 -0
- package/dist/env/prompt/types.d.ts +176 -0
- package/dist/env/session/hooks.d.ts +14 -0
- package/dist/env/session/index.d.ts +19 -0
- package/dist/env/session/index.js +4 -4
- package/dist/env/session/search-query-parser.d.ts +41 -0
- package/dist/env/session/session-component.d.ts +464 -0
- package/dist/env/session/session-config-registration.d.ts +18 -0
- package/dist/env/session/session-id.d.ts +26 -0
- package/dist/env/session/session-message-converter.d.ts +142 -0
- package/dist/env/session/session-store.d.ts +188 -0
- package/dist/env/session/storage/index.d.ts +5 -0
- package/dist/env/session/storage/index.js +3 -3
- package/dist/env/session/storage/memory.d.ts +119 -0
- package/dist/env/session/storage/sqlite.d.ts +108 -0
- package/dist/env/session/types.d.ts +705 -0
- package/dist/env/session-tree-stopper.d.ts +79 -0
- package/dist/env/skill/config.d.ts +13 -0
- package/dist/env/skill/index.d.ts +6 -0
- package/dist/env/skill/parser.d.ts +9 -0
- package/dist/env/skill/scanner.d.ts +25 -0
- package/dist/env/skill/skill-component.d.ts +89 -0
- package/dist/env/skill/skill-config-registration.d.ts +18 -0
- package/dist/env/skill/tool/index.d.ts +1 -0
- package/dist/env/skill/tool/skill-tool.d.ts +15 -0
- package/dist/env/skill/types.d.ts +61 -0
- package/dist/env/task/backend/index.d.ts +24 -0
- package/dist/env/task/backend/index.js +702 -0
- package/dist/env/task/backend/roy-sidecar-task-port.d.ts +148 -0
- package/dist/env/task/backend/sqlite-task-port.d.ts +28 -0
- package/dist/env/task/backend/task-store-backend.d.ts +107 -0
- package/dist/env/task/backend/types.d.ts +282 -0
- package/dist/env/task/delegate/bg-task-id-storage.d.ts +9 -0
- package/dist/env/task/delegate/delegate-tool.d.ts +681 -0
- package/dist/env/task/delegate/index.d.ts +8 -0
- package/dist/env/task/delegate/index.js +2 -2
- package/dist/env/task/delegate/process-registry.d.ts +58 -0
- package/dist/env/task/delegate/stop-tool.d.ts +12 -0
- package/dist/env/task/delegate/subagent-resolver.d.ts +25 -0
- package/dist/env/task/events/index.d.ts +7 -0
- package/dist/env/task/events/task-event-payloads.d.ts +101 -0
- package/dist/env/task/events/task-event-types.d.ts +23 -0
- package/dist/env/task/hooks/contexts.d.ts +191 -0
- package/dist/env/task/hooks/index.d.ts +7 -0
- package/dist/env/task/hooks/task-hook-points.d.ts +42 -0
- package/dist/env/task/index.d.ts +7 -0
- package/dist/env/task/index.js +3 -3
- package/dist/env/task/plugins/auto-task-plugin.d.ts +38 -0
- package/dist/env/task/plugins/card-chat-routing.d.ts +88 -0
- package/dist/env/task/plugins/fake-user-message-helper.d.ts +90 -0
- package/dist/env/task/plugins/index.d.ts +8 -0
- package/dist/env/task/plugins/index.js +4 -4
- package/dist/env/task/plugins/lark-card-action-handler.d.ts +166 -0
- package/dist/env/task/plugins/lark-card-patch-notifier.d.ts +600 -0
- package/dist/env/task/plugins/lark-cli-task-notify-plugin.d.ts +231 -0
- package/dist/env/task/plugins/max-iteration-reminder-plugin.d.ts +112 -0
- package/dist/env/task/plugins/per-task-group-chat-plugin.d.ts +561 -0
- package/dist/env/task/plugins/task-tag-plugin.d.ts +70 -0
- package/dist/env/task/plugins/workflow-extractor-agent.d.ts +43 -0
- package/dist/env/task/registry-hook-installer.d.ts +43 -0
- package/dist/env/task/storage/index.d.ts +5 -0
- package/dist/env/task/storage/migrations/001_add_project_path_context.d.ts +14 -0
- package/dist/env/task/storage/migrations/002_add_task_type.d.ts +14 -0
- package/dist/env/task/storage/migrations/003_add_process_description.d.ts +20 -0
- package/dist/env/task/storage/migrations/004_rename_action_to_milestone.d.ts +37 -0
- package/dist/env/task/storage/migrations/005_convert_blob_description_to_text.d.ts +51 -0
- package/dist/env/task/storage/sqlite-task-store.d.ts +241 -0
- package/dist/env/task/tag-service.d.ts +138 -0
- package/dist/env/task/task-child-context.d.ts +70 -0
- package/dist/env/task/task-component.d.ts +270 -0
- package/dist/env/task/task-config-registration.d.ts +19 -0
- package/dist/env/task/task-creation-registry.d.ts +181 -0
- package/dist/env/task/task-reuse-context.d.ts +52 -0
- package/dist/env/task/task-reuse-registry.d.ts +31 -0
- package/dist/env/task/tools/batch-archive-tool.d.ts +9 -0
- package/dist/env/task/tools/batch-delete-tool.d.ts +9 -0
- package/dist/env/task/tools/complete-tool.d.ts +12 -0
- package/dist/env/task/tools/create-tool.d.ts +6 -0
- package/dist/env/task/tools/delete-tool.d.ts +6 -0
- package/dist/env/task/tools/get-tool.d.ts +6 -0
- package/dist/env/task/tools/index.d.ts +13 -0
- package/dist/env/task/tools/list-tool.d.ts +6 -0
- package/dist/env/task/tools/operation/create-tool.d.ts +12 -0
- package/dist/env/task/tools/operation/delete-tool.d.ts +6 -0
- package/dist/env/task/tools/operation/get-tool.d.ts +6 -0
- package/dist/env/task/tools/operation/index.d.ts +8 -0
- package/dist/env/task/tools/operation/list-tool.d.ts +6 -0
- package/dist/env/task/tools/operation/operation-types.d.ts +225 -0
- package/dist/env/task/tools/operation/update-tool.d.ts +6 -0
- package/dist/env/task/tools/search-tool.d.ts +9 -0
- package/dist/env/task/tools/task-tree-tool.d.ts +65 -0
- package/dist/env/task/tools/task-types.d.ts +255 -0
- package/dist/env/task/tools/update-tool.d.ts +6 -0
- package/dist/env/task/types.d.ts +290 -0
- package/dist/env/tool/built-in/bash-effect.d.ts +36 -0
- package/dist/env/tool/built-in/bash.d.ts +16 -0
- package/dist/env/tool/built-in/echo.d.ts +7 -0
- package/dist/env/tool/built-in/edit-file.d.ts +6 -0
- package/dist/env/tool/built-in/glob.d.ts +6 -0
- package/dist/env/tool/built-in/grep.d.ts +6 -0
- package/dist/env/tool/built-in/index.d.ts +39 -0
- package/dist/env/tool/built-in/query-background-process-tool.d.ts +113 -0
- package/dist/env/tool/built-in/read-file.d.ts +5 -0
- package/dist/env/tool/built-in/understand-image.d.ts +59 -0
- package/dist/env/tool/built-in/write-file.d.ts +5 -0
- package/dist/env/tool/index.d.ts +16 -0
- package/dist/env/tool/registry.d.ts +61 -0
- package/dist/env/tool/tool-component.d.ts +242 -0
- package/dist/env/tool/tool-config-registration.d.ts +18 -0
- package/dist/env/tool/types.d.ts +274 -0
- package/dist/env/tool/validator.d.ts +14 -0
- package/dist/env/types.d.ts +184 -0
- package/dist/env/workflow/decorators/decorator-node.d.ts +76 -0
- package/dist/env/workflow/decorators/edge.d.ts +42 -0
- package/dist/env/workflow/decorators/index.d.ts +13 -0
- package/dist/env/workflow/decorators/node-as.d.ts +40 -0
- package/dist/env/workflow/decorators/workflow.d.ts +30 -0
- package/dist/env/workflow/engine/dag-manager.d.ts +176 -0
- package/dist/env/workflow/engine/engine.d.ts +440 -0
- package/dist/env/workflow/engine/event-bus.d.ts +54 -0
- package/dist/env/workflow/engine/executor.d.ts +122 -0
- package/dist/env/workflow/engine/index.d.ts +15 -0
- package/dist/env/workflow/engine/index.js +2 -2
- package/dist/env/workflow/engine/node-registry.d.ts +159 -0
- package/dist/env/workflow/engine/scheduler.d.ts +164 -0
- package/dist/env/workflow/extractor/workflow-converter.d.ts +55 -0
- package/dist/env/workflow/fixtures.d.ts +401 -0
- package/dist/env/workflow/hooks/index.d.ts +4 -0
- package/dist/env/workflow/hooks/workflow-hook-points.d.ts +161 -0
- package/dist/env/workflow/index.d.ts +30 -0
- package/dist/env/workflow/index.js +9 -9
- package/dist/env/workflow/metadata/keys.d.ts +6 -0
- package/dist/env/workflow/nodes/agent-component-adapter.d.ts +175 -0
- package/dist/env/workflow/nodes/agent-node.d.ts +206 -0
- package/dist/env/workflow/nodes/ask-user-node.d.ts +66 -0
- package/dist/env/workflow/nodes/condition-node.d.ts +39 -0
- package/dist/env/workflow/nodes/index.d.ts +8 -0
- package/dist/env/workflow/nodes/index.js +1 -1
- package/dist/env/workflow/nodes/merge-node.d.ts +40 -0
- package/dist/env/workflow/nodes/python-call-node.d.ts +95 -0
- package/dist/env/workflow/nodes/skill-node.d.ts +29 -0
- package/dist/env/workflow/nodes/tool-node.d.ts +64 -0
- package/dist/env/workflow/nodes/workflow-node.d.ts +118 -0
- package/dist/env/workflow/plugins/index.d.ts +6 -0
- package/dist/env/workflow/plugins/index.js +2 -2
- package/dist/env/workflow/plugins/lark-cli-workflow-notify-plugin.d.ts +107 -0
- package/dist/env/workflow/plugins/workflow-json-output-plugin.d.ts +166 -0
- package/dist/env/workflow/runtime/runtime-cancellation-scope.d.ts +121 -0
- package/dist/env/workflow/service/index.d.ts +9 -0
- package/dist/env/workflow/service/registry.d.ts +37 -0
- package/dist/env/workflow/service/workflow-service.d.ts +422 -0
- package/dist/env/workflow/storage/index.d.ts +11 -0
- package/dist/env/workflow/storage/mock-repositories.d.ts +106 -0
- package/dist/env/workflow/storage/safe-json.d.ts +62 -0
- package/dist/env/workflow/storage/sqlite.d.ts +57 -0
- package/dist/env/workflow/storage/tag-repo.d.ts +65 -0
- package/dist/env/workflow/storage/workflow-repo.d.ts +161 -0
- package/dist/env/workflow/tools/ask-user-tool.d.ts +35 -0
- package/dist/env/workflow/tools/index.d.ts +16 -0
- package/dist/env/workflow/tools/index.js +6 -6
- package/dist/env/workflow/tools/run-workflow.d.ts +130 -0
- package/dist/env/workflow/tools/submit-json-output-tool.d.ts +38 -0
- package/dist/env/workflow/tools/workflow-add-tool.d.ts +47 -0
- package/dist/env/workflow/tools/workflow-get-tool.d.ts +29 -0
- package/dist/env/workflow/tools/workflow-list-tool.d.ts +55 -0
- package/dist/env/workflow/tools/workflow-run-status-tool.d.ts +26 -0
- package/dist/env/workflow/tools/workflow-run-stop-tool.d.ts +29 -0
- package/dist/env/workflow/tools/workflow-search-tool.d.ts +33 -0
- package/dist/env/workflow/tools/workflow-tag-list-tool.d.ts +59 -0
- package/dist/env/workflow/tools/workflow-validate-tool.d.ts +69 -0
- package/dist/env/workflow/types/context.d.ts +17 -0
- package/dist/env/workflow/types/decorators-types.d.ts +182 -0
- package/dist/env/workflow/types/edge.d.ts +33 -0
- package/dist/env/workflow/types/event.d.ts +869 -0
- package/dist/env/workflow/types/index.d.ts +16 -0
- package/dist/env/workflow/types/run.d.ts +254 -0
- package/dist/env/workflow/types/workflow-error.d.ts +79 -0
- package/dist/env/workflow/types/workflow-hil.d.ts +57 -0
- package/dist/env/workflow/types/workflow-message.d.ts +193 -0
- package/dist/env/workflow/types/workflow-session.d.ts +17 -0
- package/dist/env/workflow/types/workflow.d.ts +654 -0
- package/dist/env/workflow/types_compat.d.ts +10 -0
- package/dist/env/workflow/utils/agent-session-metadata.d.ts +48 -0
- package/dist/env/workflow/utils/build-agent-node-output.d.ts +11 -0
- package/dist/env/workflow/utils/create-workflow.d.ts +35 -0
- package/dist/env/workflow/utils/dependency-prescan.d.ts +67 -0
- package/dist/env/workflow/utils/execution-state.d.ts +46 -0
- package/dist/env/workflow/utils/extract-agent-json-output.d.ts +6 -0
- package/dist/env/workflow/utils/index.d.ts +14 -0
- package/dist/env/workflow/utils/index.js +1 -1
- package/dist/env/workflow/utils/json-schema-to-zod.d.ts +23 -0
- package/dist/env/workflow/utils/node-id-utils.d.ts +20 -0
- package/dist/env/workflow/utils/node-output-contracts.d.ts +137 -0
- package/dist/env/workflow/utils/node-registry-helper.d.ts +36 -0
- package/dist/env/workflow/utils/output-schema-hint.d.ts +7 -0
- package/dist/env/workflow/utils/parse-agent-output-config.d.ts +9 -0
- package/dist/env/workflow/utils/recovery-validator.d.ts +30 -0
- package/dist/env/workflow/utils/redact-command-secrets.d.ts +70 -0
- package/dist/env/workflow/utils/sensitive-redact.d.ts +37 -0
- package/dist/env/workflow/utils/session-parser.d.ts +23 -0
- package/dist/env/workflow/utils/session-recovery.d.ts +122 -0
- package/dist/env/workflow/utils/shell-dialect-lint.d.ts +75 -0
- package/dist/env/workflow/utils/template-contract-validator.d.ts +87 -0
- package/dist/env/workflow/utils/template-resolver.d.ts +285 -0
- package/dist/env/workflow/utils/validate-workflow-definition.d.ts +79 -0
- package/dist/env/workflow/utils/validation-rules.d.ts +103 -0
- package/dist/env/workflow/utils/workflow-message-metadata.d.ts +20 -0
- package/dist/env/workflow/utils/workflow-sanitize.d.ts +51 -0
- package/dist/env/workflow/workflow-component.d.ts +138 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.js +21 -21
- package/dist/shared/@ai-setting/{roy-agent-core-stnddvx9.js → roy-agent-core-12d2xap8.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-pk1b3kvf.js → roy-agent-core-2b8jtv7m.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-x8n1r7h4.js → roy-agent-core-2bscfrr1.js} +188 -7
- package/dist/shared/@ai-setting/{roy-agent-core-gdsqp6j8.js → roy-agent-core-6masakz4.js} +45 -0
- package/dist/shared/@ai-setting/{roy-agent-core-vvxb9522.js → roy-agent-core-6qxh4xrm.js} +67 -6
- package/dist/shared/@ai-setting/{roy-agent-core-h93v6p6y.js → roy-agent-core-7qy3nffr.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-s214vmmd.js → roy-agent-core-8eqngasy.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-brwzs8wf.js → roy-agent-core-9h72sk1n.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-na73mym1.js → roy-agent-core-a4vzsn0g.js} +212 -1
- package/dist/shared/@ai-setting/{roy-agent-core-35s1w7tc.js → roy-agent-core-aer5kw1j.js} +142 -70
- package/dist/shared/@ai-setting/{roy-agent-core-j8e92gj8.js → roy-agent-core-b5ew8t0k.js} +0 -59
- package/dist/shared/@ai-setting/{roy-agent-core-rcfewbzr.js → roy-agent-core-cd62e9p1.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-39xejr39.js → roy-agent-core-e2z1etk4.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-pkpkctvf.js → roy-agent-core-g36jevrk.js} +14 -183
- package/dist/shared/@ai-setting/{roy-agent-core-ezgsem94.js → roy-agent-core-j2nvedt6.js} +465 -128
- package/dist/shared/@ai-setting/{roy-agent-core-p2r27era.js → roy-agent-core-mxdc756a.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-p8ak03s0.js → roy-agent-core-w527pcpe.js} +293 -42
- package/dist/shared/@ai-setting/{roy-agent-core-3tv1q6f2.js → roy-agent-core-ytr2w0vb.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-yd21n6c7.js → roy-agent-core-zvemdfx5.js} +1 -1
- package/dist/test-utils/child-process-mock.d.ts +73 -0
- package/dist/util/process/process-tree-killer.d.ts +67 -0
- package/dist/utils/id.d.ts +11 -0
- package/dist/utils/loose-json.d.ts +30 -0
- package/dist/utils/media.d.ts +70 -0
- package/dist/utils/temp-file-manager/index.d.ts +99 -0
- package/package.json +5 -3
- /package/dist/shared/@ai-setting/{roy-agent-core-zy3hqfwg.js → roy-agent-core-0hq21px2.js} +0 -0
- /package/dist/shared/@ai-setting/{roy-agent-core-0cfaqnz9.js → roy-agent-core-k25gv86p.js} +0 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Session Message Converter
|
|
3
|
+
*
|
|
4
|
+
* Converts between SessionMessage (storage format) and AI SDK ModelMessage (LLM format).
|
|
5
|
+
*
|
|
6
|
+
* This module provides a class-based API for message conversion.
|
|
7
|
+
*/
|
|
8
|
+
import type { SessionMessage } from "./types";
|
|
9
|
+
interface ModelMessage {
|
|
10
|
+
role: "user" | "assistant" | "system" | "tool";
|
|
11
|
+
content: string | ModelContentPart[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Content part for AI SDK ModelMessage
|
|
15
|
+
*/
|
|
16
|
+
type ModelContentPart = TextContentPart | ReasoningContentPart | ToolCallContentPart | ToolResultContentPart | FileContentPart | ImageContentPart;
|
|
17
|
+
interface TextContentPart {
|
|
18
|
+
type: "text";
|
|
19
|
+
text: string;
|
|
20
|
+
synthetic?: boolean;
|
|
21
|
+
}
|
|
22
|
+
interface ReasoningContentPart {
|
|
23
|
+
type: "reasoning";
|
|
24
|
+
text: string;
|
|
25
|
+
reasoningType?: "core" | "effort" | "summary";
|
|
26
|
+
}
|
|
27
|
+
interface ToolCallContentPart {
|
|
28
|
+
type: "tool-call";
|
|
29
|
+
toolCallId: string;
|
|
30
|
+
toolName: string;
|
|
31
|
+
input: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
interface ToolResultContentPart {
|
|
34
|
+
type: "tool-result";
|
|
35
|
+
toolCallId: string;
|
|
36
|
+
toolName: string;
|
|
37
|
+
output: string;
|
|
38
|
+
}
|
|
39
|
+
interface FileContentPart {
|
|
40
|
+
type: "file";
|
|
41
|
+
url: string;
|
|
42
|
+
mimeType?: string;
|
|
43
|
+
filename?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* AI SDK v6 image part (lossless round-trip with `ImagePart`).
|
|
47
|
+
*
|
|
48
|
+
* @see https://ai-sdk.dev/docs/reference/ai-sdk-core/image-part
|
|
49
|
+
*
|
|
50
|
+
* The `image` field accepts `string | URL | Uint8Array` (and `DataContent`,
|
|
51
|
+
* which is itself a union that includes `Uint8Array`). We widen the local
|
|
52
|
+
* type to `Uint8Array` so that legacy `{type:"Buffer", data:[]}` payloads
|
|
53
|
+
* recovered from SQLite can be rehydrated into a typed array instead of
|
|
54
|
+
* a plain object. This unblocks the B1 round-trip regression.
|
|
55
|
+
*/
|
|
56
|
+
interface ImageContentPart {
|
|
57
|
+
type: "image";
|
|
58
|
+
/** Image data — base64/data URL, raw bytes, or a remote URL */
|
|
59
|
+
image: string | URL | Uint8Array;
|
|
60
|
+
/** Optional MIME type (e.g. "image/png") */
|
|
61
|
+
mimeType?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* SessionMessageConverter
|
|
65
|
+
*
|
|
66
|
+
* Converts between SessionMessage (storage format) and AI SDK ModelMessage (LLM format).
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const converter = new SessionMessageConverter();
|
|
71
|
+
* const modelMsg = converter.toModelMessage(sessionMsg);
|
|
72
|
+
* const sessionMsg = converter.fromModelMessage(modelMsg);
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare class SessionMessageConverter {
|
|
76
|
+
/**
|
|
77
|
+
* Convert a SessionMessage to AI SDK ModelMessage format
|
|
78
|
+
*
|
|
79
|
+
* @param msg - SessionMessage to convert
|
|
80
|
+
* @returns ModelMessage compatible with AI SDK v6
|
|
81
|
+
*/
|
|
82
|
+
toModelMessage(msg: SessionMessage): ModelMessage;
|
|
83
|
+
/**
|
|
84
|
+
* Convert an AI SDK ModelMessage to SessionMessage format
|
|
85
|
+
*
|
|
86
|
+
* @param aiMsg - AI SDK ModelMessage to convert (accepts any object with role and content)
|
|
87
|
+
* @param options - Optional sessionID and messageID
|
|
88
|
+
* @returns SessionMessage compatible with storage format
|
|
89
|
+
*
|
|
90
|
+
* 设置 metadata.type 以便后续正确过滤:
|
|
91
|
+
* - "tool_call": assistant 消息包含 tool-call parts
|
|
92
|
+
* - "tool_result": tool 消息
|
|
93
|
+
*/
|
|
94
|
+
fromModelMessage(aiMsg: {
|
|
95
|
+
role: string;
|
|
96
|
+
content: unknown;
|
|
97
|
+
[key: string]: unknown;
|
|
98
|
+
}, options?: {
|
|
99
|
+
sessionID?: string;
|
|
100
|
+
messageID?: string;
|
|
101
|
+
}): SessionMessage;
|
|
102
|
+
/**
|
|
103
|
+
* Convert a list of SessionMessages to AI SDK history format
|
|
104
|
+
*
|
|
105
|
+
* @param messages - Array of SessionMessages to convert
|
|
106
|
+
* @returns Array of ModelMessages filtered by archived status
|
|
107
|
+
*/
|
|
108
|
+
sessionToHistory(messages: SessionMessage[]): ModelMessage[];
|
|
109
|
+
/**
|
|
110
|
+
* Extract provider-specific options from SessionMessage
|
|
111
|
+
*
|
|
112
|
+
* Some models (e.g., DeepSeek R1, Kimi k2.5) require reasoning configuration
|
|
113
|
+
* through providerOptions.
|
|
114
|
+
*
|
|
115
|
+
* @param msg - SessionMessage to extract options from
|
|
116
|
+
* @returns Provider-specific options object for LLM calls
|
|
117
|
+
*/
|
|
118
|
+
extractProviderOptions(msg: SessionMessage): Record<string, unknown>;
|
|
119
|
+
/**
|
|
120
|
+
* Migrate old format message to new format
|
|
121
|
+
*
|
|
122
|
+
* Handles backward compatibility by converting old messages with just content
|
|
123
|
+
* to new format with proper parts array.
|
|
124
|
+
*
|
|
125
|
+
* @param oldMsg - Message in possibly old format
|
|
126
|
+
* @returns Message in new format with parts array
|
|
127
|
+
*/
|
|
128
|
+
migrateMessage(oldMsg: Partial<SessionMessage>): SessionMessage;
|
|
129
|
+
}
|
|
130
|
+
export declare function toModelMessage(msg: SessionMessage): ModelMessage;
|
|
131
|
+
export declare function fromModelMessage(aiMsg: {
|
|
132
|
+
role: string;
|
|
133
|
+
content: unknown;
|
|
134
|
+
[key: string]: unknown;
|
|
135
|
+
}, options?: {
|
|
136
|
+
sessionID?: string;
|
|
137
|
+
messageID?: string;
|
|
138
|
+
}): SessionMessage;
|
|
139
|
+
export declare function sessionToHistory(messages: SessionMessage[]): ModelMessage[];
|
|
140
|
+
export declare function extractProviderOptions(msg: SessionMessage): Record<string, unknown>;
|
|
141
|
+
export declare function migrateMessage(oldMsg: Partial<SessionMessage>): SessionMessage;
|
|
142
|
+
export {};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Session Store Interface
|
|
3
|
+
*/
|
|
4
|
+
import type { Session, CreateSessionOptions, UpdateSessionOptions, ListSessionsOptions, SessionMessage, SessionCheckpoint, // (new)
|
|
5
|
+
GetMessagesOptions, // (new)
|
|
6
|
+
SearchMessagesOptions, // (new)
|
|
7
|
+
MessageMatch } from "./types";
|
|
8
|
+
/**
|
|
9
|
+
* Session Store Interface
|
|
10
|
+
* Defines the contract for session storage implementations
|
|
11
|
+
*/
|
|
12
|
+
export interface SessionStore {
|
|
13
|
+
/**
|
|
14
|
+
* Create a new session
|
|
15
|
+
*/
|
|
16
|
+
create(options: CreateSessionOptions): Promise<Session>;
|
|
17
|
+
/**
|
|
18
|
+
* Get a session by ID
|
|
19
|
+
*/
|
|
20
|
+
get(id: string): Promise<Session | undefined>;
|
|
21
|
+
/**
|
|
22
|
+
* List sessions with optional filtering
|
|
23
|
+
*/
|
|
24
|
+
list(options?: ListSessionsOptions): Promise<Session[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Update a session
|
|
27
|
+
*/
|
|
28
|
+
update(id: string, updates: UpdateSessionOptions): Promise<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* Delete a session
|
|
31
|
+
*/
|
|
32
|
+
delete(id: string): Promise<boolean>;
|
|
33
|
+
/**
|
|
34
|
+
* Get total session count (without pagination)
|
|
35
|
+
*/
|
|
36
|
+
getCount(): Promise<number>;
|
|
37
|
+
/**
|
|
38
|
+
* Add a message to a session
|
|
39
|
+
*/
|
|
40
|
+
addMessage(sessionId: string, message: {
|
|
41
|
+
role: string;
|
|
42
|
+
content: string;
|
|
43
|
+
parts?: unknown[];
|
|
44
|
+
metadata?: Record<string, unknown>;
|
|
45
|
+
}): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Add multiple messages to a session atomically (single transaction).
|
|
48
|
+
*
|
|
49
|
+
* Layer 3 of sessions.db fix: one BEGIN/COMMIT block per call, instead
|
|
50
|
+
* of N×2 separate statements (each `addMessage` does an INSERT plus a
|
|
51
|
+
* UPDATE on `session` for `message_count`). This eliminates the lock-
|
|
52
|
+
* amplification problem that triggered `database is locked` storms in
|
|
53
|
+
* production. If any row fails (e.g. FK violation), the whole batch is
|
|
54
|
+
* rolled back.
|
|
55
|
+
*
|
|
56
|
+
* @returns Array of generated message IDs in input order. Empty array
|
|
57
|
+
* for an empty input array.
|
|
58
|
+
*/
|
|
59
|
+
addMessages(sessionId: string, messages: Array<{
|
|
60
|
+
role: string;
|
|
61
|
+
content: string;
|
|
62
|
+
parts?: unknown[];
|
|
63
|
+
metadata?: Record<string, unknown>;
|
|
64
|
+
}>): Promise<string[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Update an existing message by id
|
|
67
|
+
*/
|
|
68
|
+
updateMessage(sessionId: string, messageId: string, updates: {
|
|
69
|
+
metadata?: Record<string, unknown>;
|
|
70
|
+
parts?: unknown[];
|
|
71
|
+
content?: string;
|
|
72
|
+
}): Promise<boolean>;
|
|
73
|
+
/**
|
|
74
|
+
* Get messages from a session
|
|
75
|
+
* @param sessionId - Session ID
|
|
76
|
+
* @param offset - Starting index
|
|
77
|
+
* @param limit - Number of messages to return
|
|
78
|
+
* @param options - Additional options (includeArchived, fromCheckpointId, reverse)
|
|
79
|
+
*/
|
|
80
|
+
getMessages(sessionId: string, offset?: number, limit?: number, options?: GetMessagesOptions): Promise<SessionMessage[]>;
|
|
81
|
+
/**
|
|
82
|
+
* Get message indexes by role
|
|
83
|
+
* @param sessionId - Session ID
|
|
84
|
+
* @param role - Role to filter by
|
|
85
|
+
*/
|
|
86
|
+
getMessageIndexes(sessionId: string, role: string): Promise<number[]>;
|
|
87
|
+
/**
|
|
88
|
+
* Get message count for a session
|
|
89
|
+
* @param sessionId - Session ID
|
|
90
|
+
* @param includeArchived - Whether to include archived messages
|
|
91
|
+
*/
|
|
92
|
+
getMessageCount(sessionId: string, includeArchived?: boolean): Promise<number>;
|
|
93
|
+
/**
|
|
94
|
+
* Save a checkpoint to session metadata
|
|
95
|
+
*/
|
|
96
|
+
saveCheckpoint(sessionId: string, checkpoint: SessionCheckpoint): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Get all checkpoints for a session
|
|
99
|
+
*/
|
|
100
|
+
getCheckpoints(sessionId: string): Promise<SessionCheckpoint[]>;
|
|
101
|
+
/**
|
|
102
|
+
* Get a specific checkpoint
|
|
103
|
+
*/
|
|
104
|
+
getCheckpoint(sessionId: string, checkpointId: string): Promise<SessionCheckpoint | undefined>;
|
|
105
|
+
/**
|
|
106
|
+
* Delete a checkpoint and restore archived messages
|
|
107
|
+
*/
|
|
108
|
+
deleteCheckpoint(sessionId: string, checkpointId: string): Promise<boolean>;
|
|
109
|
+
/**
|
|
110
|
+
* Archive messages (mark as archived for compact)
|
|
111
|
+
* @returns Number of messages archived
|
|
112
|
+
*/
|
|
113
|
+
archiveMessages(sessionId: string, checkpointId: string, beforeIndex: number): Promise<number>;
|
|
114
|
+
/**
|
|
115
|
+
* Get active (non-archived) messages only
|
|
116
|
+
*/
|
|
117
|
+
getActiveMessages(sessionId: string, offset?: number, limit?: number): Promise<SessionMessage[]>;
|
|
118
|
+
/**
|
|
119
|
+
* Close and cleanup resources
|
|
120
|
+
*/
|
|
121
|
+
close(): Promise<void>;
|
|
122
|
+
/**
|
|
123
|
+
* Search messages across all sessions
|
|
124
|
+
*
|
|
125
|
+
* @param options - Search options including query, session filter, time range
|
|
126
|
+
* @returns Array of message matches
|
|
127
|
+
*/
|
|
128
|
+
searchMessages(options: SearchMessagesOptions): Promise<MessageMatch[]>;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Base class for `SessionStore` implementations that do NOT need to
|
|
132
|
+
* override `addMessages`. The default implementation simply loops over
|
|
133
|
+
* `addMessage`, which keeps the per-message retry policy from
|
|
134
|
+
* `SessionComponent` in effect but loses the BEGIN/COMMIT batching
|
|
135
|
+
* optimization. Implementations that want the optimization (such as
|
|
136
|
+
* SQLiteSessionStore) should override `addMessages`.
|
|
137
|
+
*
|
|
138
|
+
* Code Review note: adding `addMessages` as a required interface
|
|
139
|
+
* method would break downstream `SessionStore` implementations at
|
|
140
|
+
* compile time. Providing a default here keeps the contract additive.
|
|
141
|
+
*/
|
|
142
|
+
export declare abstract class BaseSessionStore implements SessionStore {
|
|
143
|
+
abstract create(options: CreateSessionOptions): Promise<Session>;
|
|
144
|
+
abstract get(id: string): Promise<Session | undefined>;
|
|
145
|
+
abstract list(options?: ListSessionsOptions): Promise<Session[]>;
|
|
146
|
+
abstract update(id: string, updates: UpdateSessionOptions): Promise<boolean>;
|
|
147
|
+
abstract delete(id: string): Promise<boolean>;
|
|
148
|
+
abstract getCount(): Promise<number>;
|
|
149
|
+
abstract addMessage(sessionId: string, message: {
|
|
150
|
+
role: string;
|
|
151
|
+
content: string;
|
|
152
|
+
parts?: unknown[];
|
|
153
|
+
metadata?: Record<string, unknown>;
|
|
154
|
+
}): Promise<string>;
|
|
155
|
+
abstract updateMessage(sessionId: string, messageId: string, updates: {
|
|
156
|
+
metadata?: Record<string, unknown>;
|
|
157
|
+
parts?: unknown[];
|
|
158
|
+
content?: string;
|
|
159
|
+
}): Promise<boolean>;
|
|
160
|
+
abstract getMessages(sessionId: string, offset?: number, limit?: number, options?: GetMessagesOptions): Promise<SessionMessage[]>;
|
|
161
|
+
abstract getMessageIndexes(sessionId: string, role: string): Promise<number[]>;
|
|
162
|
+
abstract getMessageCount(sessionId: string, includeArchived?: boolean): Promise<number>;
|
|
163
|
+
abstract saveCheckpoint(sessionId: string, checkpoint: SessionCheckpoint): Promise<void>;
|
|
164
|
+
abstract getCheckpoints(sessionId: string): Promise<SessionCheckpoint[]>;
|
|
165
|
+
abstract getCheckpoint(sessionId: string, checkpointId: string): Promise<SessionCheckpoint | undefined>;
|
|
166
|
+
abstract deleteCheckpoint(sessionId: string, checkpointId: string): Promise<boolean>;
|
|
167
|
+
abstract archiveMessages(sessionId: string, checkpointId: string, beforeIndex: number): Promise<number>;
|
|
168
|
+
abstract getActiveMessages(sessionId: string, offset?: number, limit?: number): Promise<SessionMessage[]>;
|
|
169
|
+
abstract close(): Promise<void>;
|
|
170
|
+
abstract searchMessages(options: SearchMessagesOptions): Promise<MessageMatch[]>;
|
|
171
|
+
/**
|
|
172
|
+
* Default batch implementation: sequential `addMessage` calls.
|
|
173
|
+
*
|
|
174
|
+
* Subclasses are strongly encouraged to override this with a real
|
|
175
|
+
* transaction (see SQLiteSessionStore.addMessages), because:
|
|
176
|
+
* 1. atomicity: a partial failure here will leave the session in an
|
|
177
|
+
* inconsistent state;
|
|
178
|
+
* 2. contention: N separate transactions mean N separate chances to
|
|
179
|
+
* hit SQLITE_BUSY, which is exactly the failure mode the Layer 1
|
|
180
|
+
* + Layer 2 fix tries to prevent.
|
|
181
|
+
*/
|
|
182
|
+
addMessages(sessionId: string, messages: Array<{
|
|
183
|
+
role: string;
|
|
184
|
+
content: string;
|
|
185
|
+
parts?: unknown[];
|
|
186
|
+
metadata?: Record<string, unknown>;
|
|
187
|
+
}>): Promise<string[]>;
|
|
188
|
+
}
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
SQLiteSessionStore,
|
|
4
4
|
getDefaultDataDir,
|
|
5
5
|
getDefaultSessionDbPath
|
|
6
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
7
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
8
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
6
|
+
} from "../../../shared/@ai-setting/roy-agent-core-7qy3nffr.js";
|
|
7
|
+
import"../../../shared/@ai-setting/roy-agent-core-2b8jtv7m.js";
|
|
8
|
+
import"../../../shared/@ai-setting/roy-agent-core-0hq21px2.js";
|
|
9
9
|
import"../../../shared/@ai-setting/roy-agent-core-8seq65bp.js";
|
|
10
10
|
import"../../../shared/@ai-setting/roy-agent-core-jnszp0jq.js";
|
|
11
11
|
import"../../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Memory Session Store
|
|
3
|
+
*
|
|
4
|
+
* In-memory implementation of SessionStore with checkpoint support
|
|
5
|
+
*/
|
|
6
|
+
import type { Session, CreateSessionOptions, UpdateSessionOptions, ListSessionsOptions, SessionMessage, SessionCheckpoint, GetMessagesOptions, SearchMessagesOptions, MessageMatch } from "../types";
|
|
7
|
+
import { BaseSessionStore } from "../session-store";
|
|
8
|
+
/**
|
|
9
|
+
* Memory-based Session Store with checkpoint support
|
|
10
|
+
*/
|
|
11
|
+
export interface MemorySessionStoreOptions {
|
|
12
|
+
/** Maximum retained messages per session; oldest messages are discarded. */
|
|
13
|
+
maxMessagesPerSession?: number;
|
|
14
|
+
/** Maximum retained checkpoints per session; oldest checkpoints are discarded. */
|
|
15
|
+
maxCheckpointsPerSession?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Task #2539 — 精细化裁剪开关。
|
|
18
|
+
* 默认 true(向后兼容):保留所有 message 直到 maxMessagesPerSession 触发。
|
|
19
|
+
* 设为 false 后,saveCheckpoint / endSessionCleanup 会按 checkpoint 对齐裁剪
|
|
20
|
+
* messages(保留「最新 checkpoint 之后」的消息,旧 checkpoint 之前的消息直接释放);
|
|
21
|
+
* 同时将 checkpoint 数组裁剪到仅保留最新 1 个(覆盖 maxCheckpointsPerSession)。
|
|
22
|
+
*/
|
|
23
|
+
keepAllMessagesUntilCompaction?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface MemorySessionStoreEndCleanupOptions {
|
|
26
|
+
/**
|
|
27
|
+
* Task #2539 — 终态清理时是否按 checkpoint 对齐裁剪 messages。
|
|
28
|
+
* 不传则使用 store 的默认 keepAllMessagesUntilCompaction。
|
|
29
|
+
*/
|
|
30
|
+
keepAllMessagesUntilCompaction?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Task #2539 — 终态清理时保留多少个最新 checkpoint(默认 1)。
|
|
33
|
+
* 设为 0 等同于 "完全丢弃所有 checkpoint"(不推荐,会丢失所有 checkpoint context)。
|
|
34
|
+
*/
|
|
35
|
+
keepLatestCheckpoints?: number;
|
|
36
|
+
}
|
|
37
|
+
export declare class MemorySessionStore extends BaseSessionStore {
|
|
38
|
+
private readonly maxMessagesPerSession;
|
|
39
|
+
private readonly maxCheckpointsPerSession;
|
|
40
|
+
/**
|
|
41
|
+
* Task #2539 — 默认值缓存,避免每次 endSessionCleanup 都访问 options。
|
|
42
|
+
*/
|
|
43
|
+
private readonly defaultKeepAllMessagesUntilCompaction;
|
|
44
|
+
private sessions;
|
|
45
|
+
private messages;
|
|
46
|
+
private checkpoints;
|
|
47
|
+
private messageConverter;
|
|
48
|
+
constructor(options?: MemorySessionStoreOptions);
|
|
49
|
+
private trimMessages;
|
|
50
|
+
create(options: CreateSessionOptions): Promise<Session>;
|
|
51
|
+
get(id: string): Promise<Session | undefined>;
|
|
52
|
+
list(options?: ListSessionsOptions): Promise<Session[]>;
|
|
53
|
+
update(id: string, updates: UpdateSessionOptions): Promise<boolean>;
|
|
54
|
+
delete(id: string): Promise<boolean>;
|
|
55
|
+
getCount(): Promise<number>;
|
|
56
|
+
addMessage(sessionId: string, message: {
|
|
57
|
+
role: string;
|
|
58
|
+
content: string;
|
|
59
|
+
parts?: unknown[];
|
|
60
|
+
metadata?: Record<string, unknown>;
|
|
61
|
+
}): Promise<string>;
|
|
62
|
+
/**
|
|
63
|
+
* Layer 3 (MemorySessionStore): batch version. Memory has no real
|
|
64
|
+
* "transaction" — we just append all rows and update the count once.
|
|
65
|
+
*/
|
|
66
|
+
addMessages(sessionId: string, messages: Array<{
|
|
67
|
+
role: string;
|
|
68
|
+
content: string;
|
|
69
|
+
parts?: unknown[];
|
|
70
|
+
metadata?: Record<string, unknown>;
|
|
71
|
+
}>): Promise<string[]>;
|
|
72
|
+
updateMessage(sessionId: string, messageId: string, updates: {
|
|
73
|
+
metadata?: Record<string, unknown>;
|
|
74
|
+
parts?: unknown[];
|
|
75
|
+
content?: string;
|
|
76
|
+
}): Promise<boolean>;
|
|
77
|
+
getMessages(sessionId: string, offset?: number, limit?: number, options?: GetMessagesOptions): Promise<SessionMessage[]>;
|
|
78
|
+
getMessageCount(sessionId: string, includeArchived?: boolean): Promise<number>;
|
|
79
|
+
getMessageIndexes(sessionId: string, role: string): Promise<number[]>;
|
|
80
|
+
saveCheckpoint(sessionId: string, checkpoint: SessionCheckpoint): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Task #2539 — 累积裁剪偏移量(per-session)。
|
|
83
|
+
* checkpoint 的 messageIndex 是相对「初始 push 顺序」的索引;当 messages 被多次裁剪后,
|
|
84
|
+
* 后续的 checkpoint 仍以原始 messageIndex 调用 truncateMessagesBeforeIndex。
|
|
85
|
+
* 用 truncOffsets 把原始索引换算到当前数组中的位置,裁完后更新偏移 + 同步 cps messageIndex。
|
|
86
|
+
*/
|
|
87
|
+
private readonly messageTruncOffsets;
|
|
88
|
+
/**
|
|
89
|
+
* Task #2539 — 裁掉「原始位置 < originalBeforeIndex」的 message(保留之后所有 message)。
|
|
90
|
+
* 与 archiveMessages 不同:archiveMessages 只置 isArchived 标记;本方法直接 splice 释放对象。
|
|
91
|
+
* originalBeforeIndex 是相对于「该 session 初始 message 顺序」的索引(与 checkpoint.messageIndex 同语义)。
|
|
92
|
+
* 多次调用累加裁剪(不会重复裁已被裁掉的部分)。
|
|
93
|
+
*/
|
|
94
|
+
private truncateMessagesBeforeIndex;
|
|
95
|
+
/**
|
|
96
|
+
* Task #2539 — sub session 终态(success / error / cancel / timeout)触发时调用。
|
|
97
|
+
* 默认保留最近 1 个 checkpoint + 其后消息;其它 checkpoint 及其前 message 全部释放。
|
|
98
|
+
*
|
|
99
|
+
* 设计目标(避免纯 splice 硬截断):
|
|
100
|
+
* - keepAllMessagesUntilCompaction=true(默认)→ 保留所有 message,裁旧 checkpoint 至 maxCheckpointsPerSession
|
|
101
|
+
* - keepAllMessagesUntilCompaction=false → 仅保留最新 1 个 checkpoint + 其后 message
|
|
102
|
+
* - keepLatestCheckpoints 控制保留多少个最新 checkpoint(默认 1)
|
|
103
|
+
*
|
|
104
|
+
* 幂等:重复调用 endSessionCleanup(sessionId) 结果稳定。
|
|
105
|
+
* 不存在的 sessionId:no-op,不报错。
|
|
106
|
+
*/
|
|
107
|
+
endSessionCleanup(sessionId: string, opts?: MemorySessionStoreEndCleanupOptions): Promise<void>;
|
|
108
|
+
getCheckpoints(sessionId: string): Promise<SessionCheckpoint[]>;
|
|
109
|
+
getCheckpoint(sessionId: string, checkpointId: string): Promise<SessionCheckpoint | undefined>;
|
|
110
|
+
deleteCheckpoint(sessionId: string, checkpointId: string): Promise<boolean>;
|
|
111
|
+
archiveMessages(sessionId: string, checkpointId: string, beforeIndex: number): Promise<number>;
|
|
112
|
+
getActiveMessages(sessionId: string, offset?: number, limit?: number): Promise<SessionMessage[]>;
|
|
113
|
+
searchMessages(options: SearchMessagesOptions): Promise<MessageMatch[]>;
|
|
114
|
+
/**
|
|
115
|
+
* Parse simple query into terms
|
|
116
|
+
*/
|
|
117
|
+
private parseQuery;
|
|
118
|
+
close(): Promise<void>;
|
|
119
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview SQLite Session Store
|
|
3
|
+
*
|
|
4
|
+
* SQLite-based implementation of SessionStore with checkpoint support.
|
|
5
|
+
*
|
|
6
|
+
* 根据运行环境自动选择 SQLite 实现:
|
|
7
|
+
* - Bun 运行时:使用 bun:sqlite
|
|
8
|
+
* - Node.js/Electron:使用 better-sqlite3
|
|
9
|
+
*/
|
|
10
|
+
import type { Session, CreateSessionOptions, UpdateSessionOptions, ListSessionsOptions, SessionMessage, SessionCheckpoint, GetMessagesOptions, SearchMessagesOptions, MessageMatch } from "../types";
|
|
11
|
+
import { BaseSessionStore } from "../session-store";
|
|
12
|
+
/**
|
|
13
|
+
* Get default data directory for session storage
|
|
14
|
+
*/
|
|
15
|
+
declare function getDefaultDataDir(): string;
|
|
16
|
+
/**
|
|
17
|
+
* Get default database path for session storage
|
|
18
|
+
*/
|
|
19
|
+
declare function getDefaultSessionDbPath(): string;
|
|
20
|
+
/**
|
|
21
|
+
* SQLite-based Session Store with checkpoint support
|
|
22
|
+
*
|
|
23
|
+
* Provides persistent storage for sessions and messages using SQLite.
|
|
24
|
+
* Follows the same interface as MemorySessionStore but persists to disk.
|
|
25
|
+
*/
|
|
26
|
+
export declare class SQLiteSessionStore extends BaseSessionStore {
|
|
27
|
+
private db;
|
|
28
|
+
private dbPath;
|
|
29
|
+
private initialized;
|
|
30
|
+
private sessionsCache;
|
|
31
|
+
private messagesCache;
|
|
32
|
+
private checkpointsCache;
|
|
33
|
+
private messageConverter;
|
|
34
|
+
constructor(dbPath?: string);
|
|
35
|
+
private initialize;
|
|
36
|
+
create(options: CreateSessionOptions): Promise<Session>;
|
|
37
|
+
get(id: string): Promise<Session | undefined>;
|
|
38
|
+
list(options?: ListSessionsOptions): Promise<Session[]>;
|
|
39
|
+
getCount(): Promise<number>;
|
|
40
|
+
update(id: string, updates: UpdateSessionOptions): Promise<boolean>;
|
|
41
|
+
delete(id: string): Promise<boolean>;
|
|
42
|
+
addMessage(sessionId: string, message: {
|
|
43
|
+
role: string;
|
|
44
|
+
content: string;
|
|
45
|
+
parts?: unknown[];
|
|
46
|
+
metadata?: Record<string, unknown>;
|
|
47
|
+
}): Promise<string>;
|
|
48
|
+
/**
|
|
49
|
+
* Layer 3: batch insert messages in a single transaction.
|
|
50
|
+
*
|
|
51
|
+
* The previous per-message path issued N×2 statements (INSERT message +
|
|
52
|
+
* UPDATE session), each grabbing the write lock independently. Under
|
|
53
|
+
* React-driven async fan-out, that lock amplification turned short
|
|
54
|
+
* contentions into full SQLITE_BUSY storms.
|
|
55
|
+
*
|
|
56
|
+
* This path:
|
|
57
|
+
* 1. Validates the session exists (cheap, indexed SELECT)
|
|
58
|
+
* 2. Opens a single transaction (BEGIN)
|
|
59
|
+
* 3. Inserts all N rows in one batch (parameterized prepared stmt)
|
|
60
|
+
* 4. Recomputes messageCount ONCE via COUNT(*) and issues ONE session
|
|
61
|
+
* UPDATE
|
|
62
|
+
* 5. Commits (or ROLLBACK on any error — preserves atomicity)
|
|
63
|
+
*
|
|
64
|
+
* Errors (FK violation, etc.) propagate to the caller; the txn is
|
|
65
|
+
* rolled back so the DB stays consistent. Empty input is a no-op.
|
|
66
|
+
*/
|
|
67
|
+
addMessages(sessionId: string, messages: Array<{
|
|
68
|
+
role: string;
|
|
69
|
+
content: string;
|
|
70
|
+
parts?: unknown[];
|
|
71
|
+
metadata?: Record<string, unknown>;
|
|
72
|
+
}>): Promise<string[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Single-attempt body of `addMessages`, extracted so the retry loop
|
|
75
|
+
* can call it without a recursion hazard.
|
|
76
|
+
*/
|
|
77
|
+
private addMessagesOnce;
|
|
78
|
+
updateMessage(sessionId: string, messageId: string, updates: {
|
|
79
|
+
metadata?: Record<string, unknown>;
|
|
80
|
+
parts?: unknown[];
|
|
81
|
+
content?: string;
|
|
82
|
+
}): Promise<boolean>;
|
|
83
|
+
getMessages(sessionId: string, offset?: number, limit?: number, options?: GetMessagesOptions): Promise<SessionMessage[]>;
|
|
84
|
+
/**
|
|
85
|
+
* Run a PRAGMA and log if the engine reports a different value than
|
|
86
|
+
* requested. Read-only PRAGMAs (`journal_mode`, `busy_timeout`,
|
|
87
|
+
* `synchronous`, `wal_autocheckpoint`) all return the *current* value
|
|
88
|
+
* as the first row, so a single `prepare().get()` is enough.
|
|
89
|
+
*/
|
|
90
|
+
private applyPragma;
|
|
91
|
+
getMessageCount(sessionId: string, includeArchived?: boolean): Promise<number>;
|
|
92
|
+
getMessageIndexes(sessionId: string, role: string): Promise<number[]>;
|
|
93
|
+
saveCheckpoint(sessionId: string, checkpoint: SessionCheckpoint): Promise<void>;
|
|
94
|
+
getCheckpoints(sessionId: string): Promise<SessionCheckpoint[]>;
|
|
95
|
+
getCheckpoint(sessionId: string, checkpointId: string): Promise<SessionCheckpoint | undefined>;
|
|
96
|
+
deleteCheckpoint(sessionId: string, checkpointId: string): Promise<boolean>;
|
|
97
|
+
archiveMessages(sessionId: string, checkpointId: string, beforeIndex: number): Promise<number>;
|
|
98
|
+
getActiveMessages(sessionId: string, offset?: number, limit?: number): Promise<SessionMessage[]>;
|
|
99
|
+
searchMessages(options: SearchMessagesOptions): Promise<MessageMatch[]>;
|
|
100
|
+
/**
|
|
101
|
+
* Parse simple query into terms
|
|
102
|
+
*/
|
|
103
|
+
private parseQuery;
|
|
104
|
+
close(): Promise<void>;
|
|
105
|
+
private rowToSession;
|
|
106
|
+
private rowToMessage;
|
|
107
|
+
}
|
|
108
|
+
export { getDefaultSessionDbPath, getDefaultDataDir };
|