@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,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Session Component Index
|
|
3
|
+
*
|
|
4
|
+
* Session management component for Environment
|
|
5
|
+
*/
|
|
6
|
+
export { SessionComponent } from "./session-component";
|
|
7
|
+
export { SessionMessageConverter } from "./session-message-converter";
|
|
8
|
+
export type { Session, SessionMessage, SessionConfig, SessionCheckpoint, // (new)
|
|
9
|
+
SessionCheckpointsMeta, // (new)
|
|
10
|
+
CreateSessionOptions, UpdateSessionOptions, ListSessionsOptions, AddMessageOptions, CompactOptions, // (new)
|
|
11
|
+
CompactResult, // (new)
|
|
12
|
+
CompactPreview, // (new)
|
|
13
|
+
GetContextOptions, // (new)
|
|
14
|
+
GetContextResult, // (new)
|
|
15
|
+
GetMessagesOptions, } from "./types";
|
|
16
|
+
export type { SessionStore } from "./session-store";
|
|
17
|
+
export { MemorySessionStore } from "./storage/memory";
|
|
18
|
+
export * from "./hooks";
|
|
19
|
+
export { isValidSessionId, MIN_SESSION_ID_LENGTH, MAX_SESSION_ID_LENGTH, } from "./session-id";
|
|
@@ -3,16 +3,16 @@ import {
|
|
|
3
3
|
MIN_SESSION_ID_LENGTH,
|
|
4
4
|
SessionComponent,
|
|
5
5
|
isValidSessionId
|
|
6
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
6
|
+
} from "../../shared/@ai-setting/roy-agent-core-zvemdfx5.js";
|
|
7
7
|
import {
|
|
8
8
|
MemorySessionStore
|
|
9
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
9
|
+
} from "../../shared/@ai-setting/roy-agent-core-7qy3nffr.js";
|
|
10
10
|
import"../../shared/@ai-setting/roy-agent-core-ze068vc9.js";
|
|
11
11
|
import"../../shared/@ai-setting/roy-agent-core-rvxg1wps.js";
|
|
12
12
|
import {
|
|
13
13
|
SessionMessageConverter
|
|
14
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
15
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
14
|
+
} from "../../shared/@ai-setting/roy-agent-core-2b8jtv7m.js";
|
|
15
|
+
import"../../shared/@ai-setting/roy-agent-core-0hq21px2.js";
|
|
16
16
|
import"../../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
|
|
17
17
|
import"../../shared/@ai-setting/roy-agent-core-tdbv7ff4.js";
|
|
18
18
|
import"../../shared/@ai-setting/roy-agent-core-qcspfszy.js";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Search Query Parser
|
|
3
|
+
*
|
|
4
|
+
* Parses search query strings into structured terms for message matching.
|
|
5
|
+
*
|
|
6
|
+
* Supported syntax:
|
|
7
|
+
* - AND: term1 AND term2 (both required, default behavior)
|
|
8
|
+
* - OR: term1 OR term2 (either required)
|
|
9
|
+
* - NOT: term1 NOT term2 (term1 required, term2 excluded)
|
|
10
|
+
* - Quoted phrases: "exact phrase"
|
|
11
|
+
* - Default: AND (space-separated terms are ANDed together)
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* parseSearchQuery("hello world") // { required: ["hello", "world"], excluded: [], phrases: [] }
|
|
15
|
+
* parseSearchQuery("hello OR world") // { required: ["hello", "world"], orMode: true }
|
|
16
|
+
* parseSearchQuery("hello NOT world") // { required: ["hello"], excluded: ["world"] }
|
|
17
|
+
* parseSearchQuery('"exact phrase"') // { required: [], excluded: [], phrases: ["exact phrase"] }
|
|
18
|
+
*/
|
|
19
|
+
export interface ParsedQuery {
|
|
20
|
+
/** Required terms (AND logic by default) */
|
|
21
|
+
required: string[];
|
|
22
|
+
/** Terms to exclude */
|
|
23
|
+
excluded: string[];
|
|
24
|
+
/** Exact phrases to match */
|
|
25
|
+
phrases: string[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Parse a search query string into structured terms
|
|
29
|
+
*
|
|
30
|
+
* @param query - Search query string
|
|
31
|
+
* @returns Parsed query structure
|
|
32
|
+
*/
|
|
33
|
+
export declare function parseSearchQuery(query: string): ParsedQuery;
|
|
34
|
+
/**
|
|
35
|
+
* Check if content matches parsed query
|
|
36
|
+
*
|
|
37
|
+
* @param content - Content to search
|
|
38
|
+
* @param query - Parsed query structure
|
|
39
|
+
* @returns true if content matches query
|
|
40
|
+
*/
|
|
41
|
+
export declare function matchesQuery(content: string, query: ParsedQuery): boolean;
|
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Session Component
|
|
3
|
+
*
|
|
4
|
+
* Component for managing session lifecycle
|
|
5
|
+
*/
|
|
6
|
+
import { BaseComponent, type ComponentConfig } from "../component";
|
|
7
|
+
import { type SessionConfig, type Session, type CreateSessionOptions, type UpdateSessionOptions, type ListSessionsOptions, type SessionMessage, type AddMessageOptions, type SessionCheckpoint, // (new)
|
|
8
|
+
type CompactOptions, // (new)
|
|
9
|
+
type CompactResult, // (new)
|
|
10
|
+
type CompactPreview, // (new)
|
|
11
|
+
type GetContextOptions, // (new)
|
|
12
|
+
type GetContextResult, // (new)
|
|
13
|
+
type SearchMessagesOptions, // (new)
|
|
14
|
+
type SearchResult, // (new)
|
|
15
|
+
type ChatTaskBinding, // Task #4023
|
|
16
|
+
type UpsertChatTaskBindingOptions } from "./types";
|
|
17
|
+
import type { ConfigComponent } from "../../config/config-component";
|
|
18
|
+
import type { SummaryAgentResult } from "../agent/types";
|
|
19
|
+
export type { SessionConfig, Session, SessionMessage, CreateSessionOptions, UpdateSessionOptions, ListSessionsOptions, AddMessageOptions, SessionCheckpoint, // (new)
|
|
20
|
+
CompactOptions, // (new)
|
|
21
|
+
CompactResult, // (new)
|
|
22
|
+
CompactPreview, // (new)
|
|
23
|
+
GetContextOptions, // (new)
|
|
24
|
+
GetContextResult, // (new)
|
|
25
|
+
SearchMessagesOptions, // (new) Search
|
|
26
|
+
SearchResult, // (new) Search
|
|
27
|
+
MessageMatch, // (new) Search
|
|
28
|
+
ChatTaskBinding, // Task #4023
|
|
29
|
+
UpsertChatTaskBindingOptions, } from "./types";
|
|
30
|
+
/**
|
|
31
|
+
* 把 compact agent 通过 `workflow_submit_output` 提交的数据归一化。
|
|
32
|
+
*/
|
|
33
|
+
export declare function normalizeAgentCheckpoint(data: Record<string, unknown>): SummaryAgentResult;
|
|
34
|
+
/**
|
|
35
|
+
* 判断一段文本是否可作为 checkpoint 正文(拒绝空白与降级哨兵)。
|
|
36
|
+
*/
|
|
37
|
+
export declare function isUsableCheckpointText(text?: string | null): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* 降级路径:compact agent 没有调用 `workflow_submit_output` 时,用它输出的
|
|
40
|
+
* 纯文本 `finalText` 兜底构造 checkpoint。
|
|
41
|
+
*
|
|
42
|
+
* 为什么需要(2026-10-16 生产事故 traceId=83eadac2316d5be7529ca42ce7057d63):
|
|
43
|
+
* compact 是子 agent。首轮若没调提交工具,`checkpointData` 就是 undefined,
|
|
44
|
+
* 旧代码会写出全空 checkpoint(`"Untitled Checkpoint"`)**然后照样归档几百条消息**
|
|
45
|
+
* (实测生产 9 次 / 累计吞掉 4731 条 / 单次最多 2710 条)→ 上下文永久丢失且用户无感知。
|
|
46
|
+
*
|
|
47
|
+
* 而实际上模型往往已经产出了可用的 checkpoint 内容,只是以纯文本形式落在
|
|
48
|
+
* `finalText` 里(例:`"## 📌 Checkpoint: lark-cli profile 配置 ..."`),
|
|
49
|
+
* 或者包在 ```json 代码块里。这些内容全部可以救回来。
|
|
50
|
+
*
|
|
51
|
+
* 策略:
|
|
52
|
+
* 1. 先从文本里抠 JSON(```json 代码块 / 裸 JSON / 第一个 {...})→ 结构化解析;
|
|
53
|
+
* 2. 否则把整段文本作为 `currentState`,title 取首个 markdown 标题行(或首行);
|
|
54
|
+
* 3. 文本为空 / 是降级哨兵 → 返回 undefined(调用方继续降级或抛错)
|
|
55
|
+
*
|
|
56
|
+
* @returns 归一化后的 checkpoint,或 undefined(无可用文本)
|
|
57
|
+
*/
|
|
58
|
+
export declare function buildCheckpointFromFinalText(finalText?: string): SummaryAgentResult | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Marker error class so callers can distinguish "lock exhausted after
|
|
61
|
+
* retries" from "validation rejected on first attempt". Previously both
|
|
62
|
+
* returned `undefined`, hiding the difference from `recordSessionMessages`
|
|
63
|
+
* and any future operator.
|
|
64
|
+
*/
|
|
65
|
+
export declare class AddMessageLockExhaustedError extends Error {
|
|
66
|
+
readonly kind: "lock_exhausted";
|
|
67
|
+
readonly attempts: number;
|
|
68
|
+
readonly cause: unknown;
|
|
69
|
+
constructor(attempts: number, cause: unknown);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* SessionComponent 配置选项(通过 options 传递)
|
|
73
|
+
*
|
|
74
|
+
* 配置加载顺序(优先级从低到高):
|
|
75
|
+
* 1. File - 配置文件(通过 configPath 指定)
|
|
76
|
+
* 2. Env - 环境变量(通过 envPrefix 配置前缀)
|
|
77
|
+
* 3. Object - 直接传入的 config 对象(最高优先级)
|
|
78
|
+
*/
|
|
79
|
+
export interface SessionComponentOptions {
|
|
80
|
+
/** ConfigComponent 实例(必填) */
|
|
81
|
+
configComponent: ConfigComponent;
|
|
82
|
+
/** 配置文件相对路径(可选,基于 XDG_DATA_HOME) */
|
|
83
|
+
configPath?: string;
|
|
84
|
+
/** 环境变量前缀(可选,默认 "SESSION") */
|
|
85
|
+
envPrefix?: string;
|
|
86
|
+
/** 直接传入的配置对象(可选,优先级最高) */
|
|
87
|
+
config?: Partial<SessionConfig>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* SessionComponent
|
|
91
|
+
*
|
|
92
|
+
* Manages session lifecycle including:
|
|
93
|
+
* - Session CRUD operations
|
|
94
|
+
* - Message management
|
|
95
|
+
* - Active session tracking
|
|
96
|
+
*/
|
|
97
|
+
export declare class SessionComponent extends BaseComponent {
|
|
98
|
+
/**
|
|
99
|
+
* Exponential backoff schedule for SQLITE_BUSY retry. Indexed by
|
|
100
|
+
* attempt number (0-based). Worst-case total wait across 3 attempts:
|
|
101
|
+
* 50 + 100 + 200 = 350 ms, which is well under the 5 s busy_timeout
|
|
102
|
+
* so the next retry always starts before the lock has had time to
|
|
103
|
+
* expire and re-arm.
|
|
104
|
+
*/
|
|
105
|
+
private static readonly BACKOFFS_MS;
|
|
106
|
+
readonly name = "session";
|
|
107
|
+
readonly version = "1.1.0";
|
|
108
|
+
private config?;
|
|
109
|
+
private store?;
|
|
110
|
+
private activeSessionId?;
|
|
111
|
+
private hooksConfig;
|
|
112
|
+
/** ConfigComponent 用于配置管理 */
|
|
113
|
+
private configComponent?;
|
|
114
|
+
/** 配置变更 watcher 清理函数 */
|
|
115
|
+
private configWatcher?;
|
|
116
|
+
constructor();
|
|
117
|
+
/**
|
|
118
|
+
* Initialize the component
|
|
119
|
+
*
|
|
120
|
+
* 配置加载优先级(从高到低):
|
|
121
|
+
* 1. Object - 直接传入的 config 对象
|
|
122
|
+
* 2. Env - 环境变量(通过 envPrefix 配置前缀)
|
|
123
|
+
* 3. File - 配置文件(通过 configPath 指定)
|
|
124
|
+
*/
|
|
125
|
+
init(config?: ComponentConfig): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* 获取默认 session 数据库路径
|
|
128
|
+
*/
|
|
129
|
+
private getDefaultSessionDbPath;
|
|
130
|
+
/**
|
|
131
|
+
* 注册配置到 ConfigComponent
|
|
132
|
+
*
|
|
133
|
+
* 配置加载顺序(优先级从低到高):
|
|
134
|
+
* 1. Defaults - 默认值(最低)
|
|
135
|
+
* 2. FileSource - 从配置文件加载
|
|
136
|
+
* 3. EnvSource - 从环境变量加载
|
|
137
|
+
* 4. config 对象 - 直接传入的配置(最高)
|
|
138
|
+
*/
|
|
139
|
+
private registerConfig;
|
|
140
|
+
/**
|
|
141
|
+
* 构建最终配置对象
|
|
142
|
+
*/
|
|
143
|
+
private buildConfig;
|
|
144
|
+
/**
|
|
145
|
+
* 将配置对象展平为点号路径
|
|
146
|
+
*/
|
|
147
|
+
private flattenConfig;
|
|
148
|
+
/**
|
|
149
|
+
* 注册配置热更新监听
|
|
150
|
+
*/
|
|
151
|
+
private registerConfigWatcher;
|
|
152
|
+
/**
|
|
153
|
+
* 处理配置变更
|
|
154
|
+
*/
|
|
155
|
+
protected onConfigChange(event: {
|
|
156
|
+
key: string;
|
|
157
|
+
oldValue?: unknown;
|
|
158
|
+
newValue?: unknown;
|
|
159
|
+
}): void;
|
|
160
|
+
/**
|
|
161
|
+
* Start the component
|
|
162
|
+
*/
|
|
163
|
+
onStart(): Promise<void>;
|
|
164
|
+
/**
|
|
165
|
+
* Stop the component
|
|
166
|
+
*/
|
|
167
|
+
onStop(): Promise<void>;
|
|
168
|
+
/**
|
|
169
|
+
* Create a new session
|
|
170
|
+
*/
|
|
171
|
+
create(options?: CreateSessionOptions): Promise<Session>;
|
|
172
|
+
/**
|
|
173
|
+
* Get a session by ID
|
|
174
|
+
*/
|
|
175
|
+
get(id: string): Promise<Session | undefined>;
|
|
176
|
+
/**
|
|
177
|
+
* Get a session with full context (for Memory Agent)
|
|
178
|
+
*/
|
|
179
|
+
getSession(id: string): Promise<{
|
|
180
|
+
sessionId: string;
|
|
181
|
+
title: string;
|
|
182
|
+
messages: any[];
|
|
183
|
+
} | null>;
|
|
184
|
+
/**
|
|
185
|
+
* Search sessions by query (for Memory Agent)
|
|
186
|
+
*
|
|
187
|
+
* Simple implementation: list all sessions and return them for the agent to filter
|
|
188
|
+
*/
|
|
189
|
+
searchSessions(query: string, options?: {
|
|
190
|
+
session_id?: string;
|
|
191
|
+
limit?: number;
|
|
192
|
+
}): Promise<Array<{
|
|
193
|
+
sessionId: string;
|
|
194
|
+
title: string;
|
|
195
|
+
preview: string;
|
|
196
|
+
timestamp: number;
|
|
197
|
+
}>>;
|
|
198
|
+
/**
|
|
199
|
+
* List all sessions
|
|
200
|
+
*/
|
|
201
|
+
list(options?: ListSessionsOptions): Promise<Session[]>;
|
|
202
|
+
/**
|
|
203
|
+
* Get total session count
|
|
204
|
+
*/
|
|
205
|
+
getCount(): Promise<number>;
|
|
206
|
+
/**
|
|
207
|
+
* Update a session
|
|
208
|
+
*/
|
|
209
|
+
update(id: string, updates: UpdateSessionOptions): Promise<boolean>;
|
|
210
|
+
/**
|
|
211
|
+
* Delete a session
|
|
212
|
+
*/
|
|
213
|
+
delete(id: string): Promise<boolean>;
|
|
214
|
+
/**
|
|
215
|
+
* 飞书 chat_id → task_id 反向绑定缓存(LRU + TTL)
|
|
216
|
+
*
|
|
217
|
+
* 为什么不放 store 缓存里?
|
|
218
|
+
* - 群消息事件频率高(每条消息都会查一次),避免每条消息都打 DB。
|
|
219
|
+
* - binding 信息只关心 taskId,不关心整个 session 对象。
|
|
220
|
+
* - TTL 60s 容忍 task 端被外部归档后残留的 stale 数据。
|
|
221
|
+
*/
|
|
222
|
+
private chatBindingCache;
|
|
223
|
+
private static readonly CHAT_BINDING_CACHE_TTL_MS;
|
|
224
|
+
private static readonly CHAT_BINDING_CACHE_MAX;
|
|
225
|
+
/**
|
|
226
|
+
* 同 chatId 的 upsert 串行化锁(Task #4023)。
|
|
227
|
+
*
|
|
228
|
+
* upsertChatTaskBinding 是"读-改-写"(先 getChatTaskBinding 再 create/update),
|
|
229
|
+
* 同一 chatId 并发调用时两个请求都可能读到 null → 各自 create → 后写覆盖前写
|
|
230
|
+
* (丢失 taskId / rebindCount)。这里用 per-chatId promise 链把同一 chatId 的
|
|
231
|
+
* upsert 串行化,保证读到的 existing 是最新的。
|
|
232
|
+
*/
|
|
233
|
+
private chatBindingLocks;
|
|
234
|
+
/**
|
|
235
|
+
* 在 chatId 维度串行执行 fn;不同 chatId 互不阻塞。
|
|
236
|
+
*/
|
|
237
|
+
private runChatBindingExclusive;
|
|
238
|
+
/**
|
|
239
|
+
* Upsert 飞书 chat_id → task_id 绑定
|
|
240
|
+
*
|
|
241
|
+
* - 首次:新建 session(id=chatId)并写入 larkChat 元数据
|
|
242
|
+
* - 重复绑定同一 taskId:更新 status / boundAt
|
|
243
|
+
* - 绑定不同 taskId:rebindCount++ 但不覆盖 taskId(防误覆盖丢失数据)
|
|
244
|
+
* - rebind 路径会发 warn 日志,便于诊断
|
|
245
|
+
*
|
|
246
|
+
* @returns 最终写入的 ChatTaskBinding(包含 rebindCount)
|
|
247
|
+
*/
|
|
248
|
+
upsertChatTaskBinding(opts: UpsertChatTaskBindingOptions): Promise<ChatTaskBinding>;
|
|
249
|
+
/**
|
|
250
|
+
* upsertChatTaskBinding 的实际实现(调用方已持有 chatId 锁)。
|
|
251
|
+
*/
|
|
252
|
+
private upsertChatTaskBindingLocked;
|
|
253
|
+
/**
|
|
254
|
+
* 查询 chat_id → task_id 绑定
|
|
255
|
+
*
|
|
256
|
+
* @returns binding 对象;若不存在或 session 元数据不含 larkChat → 返回 null
|
|
257
|
+
*/
|
|
258
|
+
getChatTaskBinding(chatId: string): Promise<ChatTaskBinding | null>;
|
|
259
|
+
/**
|
|
260
|
+
* 清理过期/超容的 chat binding 缓存
|
|
261
|
+
*/
|
|
262
|
+
private evictStaleChatBindingCache;
|
|
263
|
+
/**
|
|
264
|
+
* Get the current active session
|
|
265
|
+
*/
|
|
266
|
+
getActiveSession(): Session | undefined;
|
|
267
|
+
/**
|
|
268
|
+
* Get the active session ID
|
|
269
|
+
*/
|
|
270
|
+
getActiveSessionId(): string | undefined;
|
|
271
|
+
/**
|
|
272
|
+
* Set the active session
|
|
273
|
+
*/
|
|
274
|
+
setActiveSession(id: string): Promise<boolean>;
|
|
275
|
+
/**
|
|
276
|
+
* Add a message to a session.
|
|
277
|
+
*
|
|
278
|
+
* Layer 2 of sessions.db fix: wrap the store call in a 3-attempt retry
|
|
279
|
+
* loop with exponential backoff (50ms, 100ms, 200ms). ONLY retries
|
|
280
|
+
* `SQLITE_BUSY` / `database is locked` errors — any other failure
|
|
281
|
+
* (validation, FK violation, etc.) bubbles up immediately on the
|
|
282
|
+
* first attempt.
|
|
283
|
+
*
|
|
284
|
+
* Why 3 attempts × 50/100/200ms (~350ms total worst case):
|
|
285
|
+
* - The 2026-07-07 incident had 102 consecutive `database is locked`
|
|
286
|
+
* errors over 8 minutes (≈ 4.7s average spacing). A 5s busy_timeout
|
|
287
|
+
* (Layer 1) + 350ms retry window absorbs typical contention.
|
|
288
|
+
* - Going much higher would risk blocking the React event loop on
|
|
289
|
+
* a real deadlock (which retry can't fix anyway).
|
|
290
|
+
*/
|
|
291
|
+
addMessage(sessionId: string, message: AddMessageOptions): Promise<string | undefined>;
|
|
292
|
+
/**
|
|
293
|
+
* Retry-wrapped addMessage. Exposed via the public `addMessage` entry
|
|
294
|
+
* point; tests assert behavior through that public method.
|
|
295
|
+
*
|
|
296
|
+
* Behavior contract:
|
|
297
|
+
* - Success → returns the new message id
|
|
298
|
+
* - Non-busy error → logs and returns `undefined` (preserves the
|
|
299
|
+
* pre-retry behavior so callers that already handle `undefined`
|
|
300
|
+
* keep working)
|
|
301
|
+
* - Busy error, retries exhausted → throws
|
|
302
|
+
* `AddMessageLockExhaustedError` so the caller can distinguish
|
|
303
|
+
* "lock could not be obtained" from "validation failed" and log
|
|
304
|
+
* at the appropriate severity. (Pre-retry this distinction was
|
|
305
|
+
* hidden behind a uniform `undefined` return.)
|
|
306
|
+
*/
|
|
307
|
+
private addMessageWithRetry;
|
|
308
|
+
/**
|
|
309
|
+
* Layer 3 wiring: expose `addMessages` so agent-component (recordSessionMessages)
|
|
310
|
+
* can write a batch in one transaction instead of N individual calls.
|
|
311
|
+
*
|
|
312
|
+
* Forwards to the store; if the store throws (e.g. FK violation), the
|
|
313
|
+
* error propagates and the caller's existing try/catch handles it.
|
|
314
|
+
* Retries at the batch level would mask real schema errors, so we
|
|
315
|
+
* deliberately don't add retry here — the per-call `addMessage` retry
|
|
316
|
+
* already covers the contention case.
|
|
317
|
+
*/
|
|
318
|
+
addMessages(sessionId: string, messages: AddMessageOptions[]): Promise<string[]>;
|
|
319
|
+
/**
|
|
320
|
+
* Get messages from a session
|
|
321
|
+
*/
|
|
322
|
+
getMessages(sessionId: string, options?: {
|
|
323
|
+
offset?: number;
|
|
324
|
+
limit?: number;
|
|
325
|
+
}): Promise<SessionMessage[]>;
|
|
326
|
+
/**
|
|
327
|
+
* Update an existing message in a session
|
|
328
|
+
*/
|
|
329
|
+
updateMessage(sessionId: string, messageId: string, updates: {
|
|
330
|
+
metadata?: Record<string, unknown>;
|
|
331
|
+
parts?: unknown[];
|
|
332
|
+
content?: string;
|
|
333
|
+
}): Promise<boolean>;
|
|
334
|
+
/**
|
|
335
|
+
* Get message count for a session
|
|
336
|
+
*/
|
|
337
|
+
getMessageCount(sessionId: string, includeArchived?: boolean): Promise<number>;
|
|
338
|
+
/**
|
|
339
|
+
* Get indexes of all messages with the specified role
|
|
340
|
+
* @param sessionId - Session ID
|
|
341
|
+
* @param role - Role to filter by (e.g., "user", "assistant")
|
|
342
|
+
* @returns Array of message indexes (0-indexed, in chronological order)
|
|
343
|
+
*/
|
|
344
|
+
getMessageIndexes(sessionId: string, role: string): Promise<number[]>;
|
|
345
|
+
private executeBeforeHooks;
|
|
346
|
+
private executeAfterHooks;
|
|
347
|
+
private generateTitle;
|
|
348
|
+
/**
|
|
349
|
+
* 生成场景化压缩提示 (Compact Hint)
|
|
350
|
+
*
|
|
351
|
+
* 两阶段自动压缩的第一阶段:使用内置 compact-hint agent 分析
|
|
352
|
+
* 父 session 历史,生成场景化的压缩提示。
|
|
353
|
+
*
|
|
354
|
+
* compact-hint agent 通过 filterHistory=false 自动读取父 session 的
|
|
355
|
+
* 对话历史,LLM 服务端可缓存 system prompt。
|
|
356
|
+
*
|
|
357
|
+
* @param sessionId 会话 ID
|
|
358
|
+
* @returns 生成的场景化提示
|
|
359
|
+
*/
|
|
360
|
+
generateCompactHint(sessionId: string): Promise<string>;
|
|
361
|
+
/**
|
|
362
|
+
* Compact a session
|
|
363
|
+
*
|
|
364
|
+
* 1. Get messages from latest checkpoint to current
|
|
365
|
+
* 2. Call Summary Agent to generate checkpoint
|
|
366
|
+
* 3. Save checkpoint and archive messages
|
|
367
|
+
*
|
|
368
|
+
* 支持 scenarioHint 参数,用于指导不同场景下的压缩重点提取
|
|
369
|
+
*/
|
|
370
|
+
compact(sessionId: string, options?: CompactOptions): Promise<CompactResult>;
|
|
371
|
+
/**
|
|
372
|
+
* Extract recent messages from the conversation for checkpoint context
|
|
373
|
+
*
|
|
374
|
+
* Extracts the last N turns of user query + assistant text response,
|
|
375
|
+
* excluding tool calls and tool results.
|
|
376
|
+
*
|
|
377
|
+
* @param messages - All messages in the conversation
|
|
378
|
+
* @param turnCount - Number of turns to extract (default: 2)
|
|
379
|
+
* @returns Array of recent messages formatted as { role, content }
|
|
380
|
+
*/
|
|
381
|
+
/**
|
|
382
|
+
* 提取最近的若干「用户 → 助手纯文本」轮次,写入 `checkpoint.recentMessages`。
|
|
383
|
+
*
|
|
384
|
+
* ⚠️ 用途澄清(2026-10-16 独立 review P2-2 更正):
|
|
385
|
+
* `recentMessages` **不会进入 LLM 上下文**。全仓非测试引用只有
|
|
386
|
+
* `packages/cli/src/commands/sessions/compact.ts`(CLI 展示 checkpoint),
|
|
387
|
+
* `createCheckpointMessage()` 也不渲染它。所以它**不是**「压缩后保住最近上下文」
|
|
388
|
+
* 的安全网 —— 此前 commit 里那种说法是过度声称,已更正。
|
|
389
|
+
* 它的价值限于 CLI `sessions compact` 预览 / 审计可读性。
|
|
390
|
+
*
|
|
391
|
+
* ★ 仍然值得修的部分(2026-10-16):
|
|
392
|
+
* 原实现只接受「assistant 消息**没有任何 tool-call/tool-result part** 且 content 非空」。
|
|
393
|
+
* 但真实 agentic 会话里 assistant 几乎总带 tool part(最后一条正文往往为空),
|
|
394
|
+
* 于是它在生产里**几乎永远返回 []** —— 三条事故 trace 的
|
|
395
|
+
* `checkpoint.recentMessages` 全是空数组,CLI 里这个字段等于没有。
|
|
396
|
+
*
|
|
397
|
+
* 现在:优先取干净的纯文本轮次(信息密度最高),一轮都没取到时兜底保留最近
|
|
398
|
+
* 若干条原始消息(含 tool 轮次),至少让 CLI 能看到「刚才在干什么」。
|
|
399
|
+
*/
|
|
400
|
+
private extractRecentMessages;
|
|
401
|
+
/**
|
|
402
|
+
* Preview compact operation
|
|
403
|
+
*/
|
|
404
|
+
previewCompact(sessionId: string): Promise<CompactPreview>;
|
|
405
|
+
/**
|
|
406
|
+
* Get all checkpoints for a session
|
|
407
|
+
*/
|
|
408
|
+
getCheckpoints(sessionId: string): Promise<SessionCheckpoint[]>;
|
|
409
|
+
/**
|
|
410
|
+
* Get a specific checkpoint
|
|
411
|
+
*/
|
|
412
|
+
getCheckpoint(sessionId: string, checkpointId: string): Promise<SessionCheckpoint | undefined>;
|
|
413
|
+
/**
|
|
414
|
+
* Delete a checkpoint and restore archived messages
|
|
415
|
+
*/
|
|
416
|
+
deleteCheckpoint(sessionId: string, checkpointId: string): Promise<boolean>;
|
|
417
|
+
/**
|
|
418
|
+
* Task #2539 — 终态联动释放 sub session 的内存占用(OOM 修复)。
|
|
419
|
+
*
|
|
420
|
+
* 触发场景:BackgroundTaskManager 检测到 sub session 终态(success / error /
|
|
421
|
+
* cancel / timeout)后调用本方法。
|
|
422
|
+
*
|
|
423
|
+
* 行为:
|
|
424
|
+
* - MemorySessionStore:按 checkpoint 对齐裁剪 messages + 保留最新 1 checkpoint(激进模式)
|
|
425
|
+
* 或仅裁旧 checkpoint(保守模式 keepAllMessagesUntilCompaction=true)
|
|
426
|
+
* - SQLiteSessionStore:no-op(SQLite 不受内存压力影响;保留完整历史便于审计)
|
|
427
|
+
*
|
|
428
|
+
* 幂等:重复调用结果稳定。
|
|
429
|
+
* 不存在的 sessionId:no-op。
|
|
430
|
+
*/
|
|
431
|
+
endSessionCleanup(sessionId: string, opts?: {
|
|
432
|
+
keepAllMessagesUntilCompaction?: boolean;
|
|
433
|
+
keepLatestCheckpoints?: number;
|
|
434
|
+
}): Promise<void>;
|
|
435
|
+
/**
|
|
436
|
+
* Get session context
|
|
437
|
+
*
|
|
438
|
+
* Returns messages starting from the latest checkpoint by default
|
|
439
|
+
*/
|
|
440
|
+
getContext(sessionId: string, options?: GetContextOptions): Promise<GetContextResult>;
|
|
441
|
+
/**
|
|
442
|
+
* Check if session needs compaction
|
|
443
|
+
*/
|
|
444
|
+
shouldCompact(sessionId: string): Promise<boolean>;
|
|
445
|
+
/**
|
|
446
|
+
* Search messages across sessions
|
|
447
|
+
*
|
|
448
|
+
* Searches all messages matching the query, aggregated by session.
|
|
449
|
+
* Supports SQLite FTS5 for fast full-text search.
|
|
450
|
+
*/
|
|
451
|
+
searchMessages(options: SearchMessagesOptions): Promise<SearchResult[]>;
|
|
452
|
+
/**
|
|
453
|
+
* Get latest checkpoint from session
|
|
454
|
+
*/
|
|
455
|
+
private getLatestCheckpoint;
|
|
456
|
+
/**
|
|
457
|
+
* Create checkpoint message (user role)
|
|
458
|
+
*
|
|
459
|
+
* Generates a markdown-formatted checkpoint summary as a user message,
|
|
460
|
+
* allowing it to appear in the message list and provide context for
|
|
461
|
+
* subsequent LLM calls.
|
|
462
|
+
*/
|
|
463
|
+
private createCheckpointMessage;
|
|
464
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Session Component 配置注册
|
|
3
|
+
*
|
|
4
|
+
* 使用 ConfigComponent.registerComponent() 机制统一管理配置
|
|
5
|
+
*/
|
|
6
|
+
import type { ComponentRegistration } from "../../config/config-component";
|
|
7
|
+
/**
|
|
8
|
+
* Session Component 默认配置值
|
|
9
|
+
*
|
|
10
|
+
* 注意:键使用完整格式(带 "session." 前缀),在 registerConfig 中手动设置
|
|
11
|
+
*/
|
|
12
|
+
export declare const SESSION_DEFAULTS: Record<string, unknown>;
|
|
13
|
+
/**
|
|
14
|
+
* Session Component 配置注册常量
|
|
15
|
+
*
|
|
16
|
+
* 定义了所有 Session 相关的配置项和来源
|
|
17
|
+
*/
|
|
18
|
+
export declare const SESSION_CONFIG_REGISTRATION: ComponentRegistration;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Session-id validation helper (Issue #8)
|
|
3
|
+
*
|
|
4
|
+
* `ROY_PARENT_SESSION_ID` is a cross-process propagation channel (set by an
|
|
5
|
+
* outer parent process and consumed by the spawned child CLI). Because the
|
|
6
|
+
* value crosses a trust boundary, callers must validate it before using it
|
|
7
|
+
* to write into the session tree — otherwise a malicious or buggy parent
|
|
8
|
+
* can inject arbitrary strings into the database or cause log noise.
|
|
9
|
+
*
|
|
10
|
+
* The policy:
|
|
11
|
+
* - Length: 8..128 characters (covers session_/run_/agent_ UUIDs + a bit of
|
|
12
|
+
* headroom; rejects empty, single-char, and absurdly long strings).
|
|
13
|
+
* - Character set: `[A-Za-z0-9_-]` (alphanumerics plus `_` and `-`).
|
|
14
|
+
* This covers all known session-id formats and rejects any control chars,
|
|
15
|
+
* spaces, slashes, dots, or shell metacharacters.
|
|
16
|
+
*/
|
|
17
|
+
export declare const MIN_SESSION_ID_LENGTH = 8;
|
|
18
|
+
export declare const MAX_SESSION_ID_LENGTH = 128;
|
|
19
|
+
/**
|
|
20
|
+
* Returns true if the given string is a well-formed session id we are willing
|
|
21
|
+
* to propagate cross-process (e.g. via `ROY_PARENT_SESSION_ID`).
|
|
22
|
+
*
|
|
23
|
+
* Pass `null` / `undefined` / empty string → false (defensive: callers often
|
|
24
|
+
* pull from env where missing values are common).
|
|
25
|
+
*/
|
|
26
|
+
export declare function isValidSessionId(value: unknown): value is string;
|