@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,422 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WorkflowService - Session-based Workflow Execution
|
|
3
|
+
*
|
|
4
|
+
* After session-based refactoring, workflow runs are managed via SessionComponent.
|
|
5
|
+
* The workflows table is still used for storing workflow definitions.
|
|
6
|
+
*
|
|
7
|
+
* Key concepts:
|
|
8
|
+
* - Session IS a workflow run (no separate runId concept)
|
|
9
|
+
* - Session.metadata stores workflow run state (status, input, agentSessions)
|
|
10
|
+
* - Session.messages stores node execution history with workflow.node.* roles
|
|
11
|
+
* - Resume is based on session state and messages
|
|
12
|
+
*/
|
|
13
|
+
import type { Workflow, WorkflowDefinition, RunOptions, RunResult, WorkflowMetadata, WorkflowConfig } from '../types';
|
|
14
|
+
export interface WorkflowRepository {
|
|
15
|
+
create(workflow: Omit<Workflow, 'id' | 'createdAt' | 'updatedAt'>): Workflow;
|
|
16
|
+
getById(id: string): Workflow | null;
|
|
17
|
+
getByName(name: string): Workflow | null;
|
|
18
|
+
list(options?: ListOptions): Workflow[];
|
|
19
|
+
update(id: string, updates: Partial<Workflow>): Workflow | null;
|
|
20
|
+
delete(id: string): boolean;
|
|
21
|
+
/** v2: 在事务中执行一个函数,回滚任何抛出 */
|
|
22
|
+
transaction<T>(fn: () => T): T;
|
|
23
|
+
/** v4: 拿过滤后的全局总数(不应用 limit/offset) */
|
|
24
|
+
countAll(options?: {
|
|
25
|
+
tag?: string;
|
|
26
|
+
tags?: string[];
|
|
27
|
+
taskId?: number;
|
|
28
|
+
search?: string;
|
|
29
|
+
}): number;
|
|
30
|
+
}
|
|
31
|
+
export interface ITagRepository {
|
|
32
|
+
upsertMany(names: string[]): void;
|
|
33
|
+
decrementMany(names: string[]): void;
|
|
34
|
+
list(options?: {
|
|
35
|
+
sortBy?: "usage_count" | "name" | "created_at";
|
|
36
|
+
order?: "asc" | "desc";
|
|
37
|
+
limit?: number;
|
|
38
|
+
}): {
|
|
39
|
+
name: string;
|
|
40
|
+
usage_count: number;
|
|
41
|
+
created_at: string;
|
|
42
|
+
updated_at: string;
|
|
43
|
+
}[];
|
|
44
|
+
get(name: string): {
|
|
45
|
+
name: string;
|
|
46
|
+
usage_count: number;
|
|
47
|
+
created_at: string;
|
|
48
|
+
updated_at: string;
|
|
49
|
+
} | undefined;
|
|
50
|
+
}
|
|
51
|
+
export interface ListWorkflowsWithTagsResult {
|
|
52
|
+
workflows: Workflow[];
|
|
53
|
+
available_tags: {
|
|
54
|
+
name: string;
|
|
55
|
+
count: number;
|
|
56
|
+
}[];
|
|
57
|
+
total: number;
|
|
58
|
+
}
|
|
59
|
+
export interface SearchWorkflowsWithTagsResult extends ListWorkflowsWithTagsResult {
|
|
60
|
+
keyword?: string;
|
|
61
|
+
tags?: string[];
|
|
62
|
+
}
|
|
63
|
+
import type { NodeDefinition } from '../types';
|
|
64
|
+
/**
|
|
65
|
+
* Tag validation constants
|
|
66
|
+
*
|
|
67
|
+
* Tags are required for all workflows and are constrained to:
|
|
68
|
+
* - At least 1 tag
|
|
69
|
+
* - At most 3 tags
|
|
70
|
+
*
|
|
71
|
+
* This supports fine-grained workflow discovery (filtering) while preventing
|
|
72
|
+
* tag spam.
|
|
73
|
+
*/
|
|
74
|
+
export declare const TAG_MIN_COUNT = 1;
|
|
75
|
+
export declare const TAG_MAX_COUNT = 3;
|
|
76
|
+
export declare const DEFAULT_TAG = "default";
|
|
77
|
+
export declare class TagValidationError extends Error {
|
|
78
|
+
constructor(message: string);
|
|
79
|
+
}
|
|
80
|
+
export interface CreateOptions {
|
|
81
|
+
tags?: string[];
|
|
82
|
+
metadata?: WorkflowMetadata;
|
|
83
|
+
taskId?: number;
|
|
84
|
+
force?: boolean;
|
|
85
|
+
}
|
|
86
|
+
export interface ListOptions {
|
|
87
|
+
tag?: string;
|
|
88
|
+
taskId?: number;
|
|
89
|
+
search?: string;
|
|
90
|
+
limit?: number;
|
|
91
|
+
offset?: number;
|
|
92
|
+
}
|
|
93
|
+
export interface SearchOptions {
|
|
94
|
+
keyword?: string;
|
|
95
|
+
tags?: string[];
|
|
96
|
+
limit?: number;
|
|
97
|
+
offset?: number;
|
|
98
|
+
}
|
|
99
|
+
export interface WorkflowUpdates {
|
|
100
|
+
definition?: WorkflowDefinition;
|
|
101
|
+
config?: WorkflowConfig;
|
|
102
|
+
tags?: string[];
|
|
103
|
+
metadata?: WorkflowMetadata;
|
|
104
|
+
}
|
|
105
|
+
export interface WorkflowEngine {
|
|
106
|
+
createSession(workflowId: string, options?: {
|
|
107
|
+
input?: Record<string, any>;
|
|
108
|
+
workflowName?: string;
|
|
109
|
+
workflowVersion?: string;
|
|
110
|
+
}): Promise<string>;
|
|
111
|
+
run(sessionId: string, options?: RunOptions): Promise<RunResult>;
|
|
112
|
+
runWorkflow(workflow: Workflow | WorkflowDefinition, options?: RunOptions): Promise<RunResult>;
|
|
113
|
+
stop(sessionId: string, reason?: string): Promise<void>;
|
|
114
|
+
addNode(sessionId: string, nodeDefinition: NodeDefinition): Promise<void>;
|
|
115
|
+
removeNode(sessionId: string, nodeId: string): Promise<void>;
|
|
116
|
+
}
|
|
117
|
+
export type WorkflowEngineFactory = (workflow: Workflow, options?: RunOptions) => Pick<WorkflowEngine, 'run' | 'stop' | 'runWorkflow'>;
|
|
118
|
+
export interface SessionInfo {
|
|
119
|
+
id: string;
|
|
120
|
+
title: string;
|
|
121
|
+
metadata: WorkflowSessionMetadata;
|
|
122
|
+
createdAt: Date;
|
|
123
|
+
updatedAt: Date;
|
|
124
|
+
/**
|
|
125
|
+
* Task #1739 — top-level parent session id (mirrors legacy `parentID`).
|
|
126
|
+
* Workflow sessions created by a sub-agent carry the sub-agent's session id
|
|
127
|
+
* here, so cascade-stop queries (`WorkflowService.stopAllForParent`) can
|
|
128
|
+
* find them. May be null for top-level sessions.
|
|
129
|
+
*/
|
|
130
|
+
parentSessionId?: string | null;
|
|
131
|
+
}
|
|
132
|
+
export interface WorkflowSessionMetadata {
|
|
133
|
+
type: 'workflow';
|
|
134
|
+
runId?: string;
|
|
135
|
+
workflowId?: string;
|
|
136
|
+
workflowName: string;
|
|
137
|
+
workflowVersion?: string;
|
|
138
|
+
status: 'running' | 'paused' | 'completed' | 'failed' | 'stopped';
|
|
139
|
+
input?: any;
|
|
140
|
+
rootNodeId?: string;
|
|
141
|
+
agentSessions?: AgentSessionRef[];
|
|
142
|
+
}
|
|
143
|
+
export interface AgentSessionRef {
|
|
144
|
+
nodeId: string;
|
|
145
|
+
sessionId: string;
|
|
146
|
+
status: 'active' | 'paused' | 'completed';
|
|
147
|
+
}
|
|
148
|
+
export declare class WorkflowService {
|
|
149
|
+
private workflowRepository;
|
|
150
|
+
private engineFactory;
|
|
151
|
+
private sessionComponent?;
|
|
152
|
+
/**
|
|
153
|
+
* v2: 可选 tag 仓库,用于维护 workflow_tags 表
|
|
154
|
+
*/
|
|
155
|
+
tagRepository?: ITagRepository;
|
|
156
|
+
constructor(workflowRepository: WorkflowRepository, engineFactory: WorkflowEngineFactory, sessionComponent?: {
|
|
157
|
+
create(options: {
|
|
158
|
+
id?: string;
|
|
159
|
+
title: string;
|
|
160
|
+
metadata: any;
|
|
161
|
+
}): Promise<{
|
|
162
|
+
id: string;
|
|
163
|
+
}>;
|
|
164
|
+
get(id: string): Promise<SessionInfo | null | undefined>;
|
|
165
|
+
list?(options?: {
|
|
166
|
+
limit?: number;
|
|
167
|
+
offset?: number;
|
|
168
|
+
}): Promise<SessionInfo[]>;
|
|
169
|
+
update(id: string, updates: {
|
|
170
|
+
metadata?: any;
|
|
171
|
+
}): Promise<boolean>;
|
|
172
|
+
addMessage(sessionId: string, message: any): Promise<string>;
|
|
173
|
+
getMessages(sessionId: string): Promise<any[]>;
|
|
174
|
+
} | undefined, tagRepository?: ITagRepository);
|
|
175
|
+
/**
|
|
176
|
+
* Task #2245 — Codex P1-2: paginated session fetch.
|
|
177
|
+
*
|
|
178
|
+
* Fetches ALL workflow sessions via `sessionComponent.list` with
|
|
179
|
+
* `limit: 1000` chunks, accumulated until a short batch signals EOF.
|
|
180
|
+
* This replaces the previous single-call `list({ limit: 1000 })`
|
|
181
|
+
* which silently dropped sessions beyond the first 1000.
|
|
182
|
+
*
|
|
183
|
+
* Safety cap of 50,000 total sessions to prevent runaway fetches
|
|
184
|
+
* against an unbounded `sessionComponent.list` implementation.
|
|
185
|
+
*/
|
|
186
|
+
private listAllSessions;
|
|
187
|
+
/**
|
|
188
|
+
* Task #2245 — Engine instance cache (BL-1).
|
|
189
|
+
*
|
|
190
|
+
* Maps sessionId → WorkflowEngine instance that actually owns the run.
|
|
191
|
+
* The engineFactory returns a NEW WorkflowEngine on every call, but
|
|
192
|
+
* `WorkflowEngine.activeSessions` is a private per-instance Map. So a
|
|
193
|
+
* freshly-created engine has no record of the running session, and its
|
|
194
|
+
* `stop(sessionId)` only updates the database (no abort, no executor
|
|
195
|
+
* cancel). This cache lets `stopRun` locate the real engine.
|
|
196
|
+
*
|
|
197
|
+
* Lifecycle: `runWorkflow` registers the engine after `runWorkflow()`
|
|
198
|
+
* returns (which synchronously populates `engine.activeSessions` before the
|
|
199
|
+
* first await). `stopRun` consults the cache first; on miss it falls back
|
|
200
|
+
* to a fresh engine (DB-only stop).
|
|
201
|
+
*/
|
|
202
|
+
/**
|
|
203
|
+
* Task #2245 — Codex P0-1: cache engine instance per workflowName so
|
|
204
|
+
* `stopRun` can find the engine during in-flight execution.
|
|
205
|
+
*
|
|
206
|
+
* Previous design cached by `sessionId` AFTER `engine.runWorkflow()`
|
|
207
|
+
* returned — useless for the in-flight case. New design caches by
|
|
208
|
+
* `workflowName` (one engine owns the named workflow), so the engine
|
|
209
|
+
* is registered BEFORE `runWorkflow` is awaited and is available
|
|
210
|
+
* for `stopRun` at any time during execution.
|
|
211
|
+
*
|
|
212
|
+
* `workflowName` → `WorkflowEngine` (one engine owns the workflow's
|
|
213
|
+
* `activeSessions` Map, including any in-flight or completed sessions).
|
|
214
|
+
*/
|
|
215
|
+
private engineInstances;
|
|
216
|
+
/**
|
|
217
|
+
* Codex P0-1: reverse index `sessionId` → `engine` for O(1) stopRun lookup.
|
|
218
|
+
* Populated when the engine is registered (BEFORE runWorkflow) and
|
|
219
|
+
* cleaned up via pruneStaleEngines() / dispose().
|
|
220
|
+
*/
|
|
221
|
+
private sessionToEngine;
|
|
222
|
+
/**
|
|
223
|
+
* P0-3 (Task #2269): reverse index `sessionId` → `parentSessionId` for
|
|
224
|
+
* precise `hasActiveWorkflowForParent` lookup. Populated when runWorkflow
|
|
225
|
+
* resolves (the engine factory call carries `parentSessionId` via
|
|
226
|
+
* `options`) and cleaned up when the session is force-stopped / stopped
|
|
227
|
+
* via stopRun. Without this, hasActiveWorkflowForParent would have to
|
|
228
|
+
* iterate ALL engines and return true on any active session — false
|
|
229
|
+
* positives in multi-REPL scenarios.
|
|
230
|
+
*/
|
|
231
|
+
private sessionToParent;
|
|
232
|
+
/**
|
|
233
|
+
* Validate tag count is within allowed range (1-3 tags).
|
|
234
|
+
* Throws TagValidationError with a friendly message on failure.
|
|
235
|
+
*/
|
|
236
|
+
private validateTags;
|
|
237
|
+
/**
|
|
238
|
+
* Create a new workflow from definition
|
|
239
|
+
*
|
|
240
|
+
* v2: create + tag upsert 在同一事务(由 WorkflowRepository.transaction 包装)
|
|
241
|
+
*/
|
|
242
|
+
createWorkflow(definition: WorkflowDefinition, options?: CreateOptions): Promise<Workflow>;
|
|
243
|
+
/**
|
|
244
|
+
* v2: 在 update 时同步 tag 表
|
|
245
|
+
*/
|
|
246
|
+
private syncTagsOnUpdate;
|
|
247
|
+
/**
|
|
248
|
+
* Get workflow by id or name
|
|
249
|
+
*/
|
|
250
|
+
getWorkflow(idOrName: string): Workflow | null;
|
|
251
|
+
/**
|
|
252
|
+
* Get workflow by id
|
|
253
|
+
*/
|
|
254
|
+
getWorkflowById(id: string): Workflow | null;
|
|
255
|
+
/**
|
|
256
|
+
* Get workflow by name
|
|
257
|
+
*/
|
|
258
|
+
getWorkflowByName(name: string): Workflow | null;
|
|
259
|
+
/**
|
|
260
|
+
* List workflows with optional filters
|
|
261
|
+
*/
|
|
262
|
+
listWorkflows(options?: ListOptions): Workflow[];
|
|
263
|
+
/**
|
|
264
|
+
* Search workflows with combined keyword + multi-tag AND filter.
|
|
265
|
+
*
|
|
266
|
+
* - `keyword`: matched (case-insensitive) against name and description
|
|
267
|
+
* - `tags`: ALL tags must be present on the workflow (AND filter)
|
|
268
|
+
* - `limit`/`offset`: pagination
|
|
269
|
+
*/
|
|
270
|
+
searchWorkflows(options?: SearchOptions): Workflow[];
|
|
271
|
+
/**
|
|
272
|
+
* Update an existing workflow
|
|
273
|
+
*/
|
|
274
|
+
updateWorkflow(idOrName: string, updates: WorkflowUpdates, options?: {
|
|
275
|
+
tags?: string[];
|
|
276
|
+
}): Promise<Workflow>;
|
|
277
|
+
/**
|
|
278
|
+
* Delete a workflow by name or id
|
|
279
|
+
*
|
|
280
|
+
* v2: delete + tag decrement 在同一事务
|
|
281
|
+
*/
|
|
282
|
+
deleteWorkflow(idOrName: string): Promise<boolean>;
|
|
283
|
+
/**
|
|
284
|
+
* v2: list workflows + available_tags(按 usage_count DESC, name ASC)
|
|
285
|
+
* v4: total 字段修复 — 使用 repository.countAll() 拿过滤后全局总数
|
|
286
|
+
*/
|
|
287
|
+
listWorkflowsWithTags(options?: ListOptions): Promise<ListWorkflowsWithTagsResult>;
|
|
288
|
+
/**
|
|
289
|
+
* v2: search workflows + available_tags
|
|
290
|
+
* v4: total 字段修复 — 使用 repository.countAll() 拿过滤后全局总数
|
|
291
|
+
*/
|
|
292
|
+
searchWorkflowsWithTags(options?: SearchOptions): Promise<SearchWorkflowsWithTagsResult>;
|
|
293
|
+
/**
|
|
294
|
+
* v3: List all tags from the workflow_tags table with flexible sort/limit.
|
|
295
|
+
*
|
|
296
|
+
* Used by:
|
|
297
|
+
* - `workflow_tag_list` MCP tool (lets agents discover the tag pool)
|
|
298
|
+
* - `workflow tag list` CLI subcommand
|
|
299
|
+
*
|
|
300
|
+
* Default sort: usage_count DESC, name ASC (most-used tags first).
|
|
301
|
+
*/
|
|
302
|
+
listTags(options?: {
|
|
303
|
+
sortBy?: 'usage_count' | 'name' | 'created_at';
|
|
304
|
+
order?: 'asc' | 'desc';
|
|
305
|
+
limit?: number;
|
|
306
|
+
}): Promise<{
|
|
307
|
+
tags: Array<{
|
|
308
|
+
name: string;
|
|
309
|
+
usage_count: number;
|
|
310
|
+
created_at: string;
|
|
311
|
+
updated_at: string;
|
|
312
|
+
}>;
|
|
313
|
+
total: number;
|
|
314
|
+
}>;
|
|
315
|
+
/**
|
|
316
|
+
* v3: Get a single tag by name (returns undefined when not found).
|
|
317
|
+
*/
|
|
318
|
+
getTag(name: string): {
|
|
319
|
+
name: string;
|
|
320
|
+
usage_count: number;
|
|
321
|
+
created_at: string;
|
|
322
|
+
updated_at: string;
|
|
323
|
+
} | undefined;
|
|
324
|
+
/**
|
|
325
|
+
* Run a workflow by definition or name
|
|
326
|
+
*
|
|
327
|
+
* This creates a Session that represents the workflow run.
|
|
328
|
+
* The Session ID is used as the run identifier for pause/resume.
|
|
329
|
+
*/
|
|
330
|
+
runWorkflow(idOrNameOrDefinition: string | WorkflowDefinition, input?: Record<string, any>, options?: RunOptions): Promise<RunResult>;
|
|
331
|
+
/**
|
|
332
|
+
* Run workflow by name (convenience method)
|
|
333
|
+
*/
|
|
334
|
+
runWorkflowByName(name: string, input?: Record<string, any>, options?: RunOptions): Promise<RunResult>;
|
|
335
|
+
/**
|
|
336
|
+
* Stop a running workflow session
|
|
337
|
+
*/
|
|
338
|
+
stopRun(sessionId: string, reason?: string): Promise<void>;
|
|
339
|
+
/**
|
|
340
|
+
* Codex P0-2: prune engineInstances entries whose `activeSessions` map
|
|
341
|
+
* no longer contains any session (engine is "stale" — no in-flight work).
|
|
342
|
+
* Called after stopRun / dispose to prevent the engine cache from
|
|
343
|
+
* accumulating engines across long-running REPL sessions.
|
|
344
|
+
*/
|
|
345
|
+
private pruneStaleEngines;
|
|
346
|
+
/**
|
|
347
|
+
* Codex P0-2: dispose all engine caches. Called from
|
|
348
|
+
* BackgroundTaskManager.dispose() or directly on service shutdown.
|
|
349
|
+
*/
|
|
350
|
+
dispose(): Promise<void>;
|
|
351
|
+
/**
|
|
352
|
+
* Task #2245 — ESC cascade stop.
|
|
353
|
+
*
|
|
354
|
+
* Stop all workflow sessions whose `parentSessionId === parentSessionId` and
|
|
355
|
+
* whose metadata is type=workflow with status in {running, paused}. Calls
|
|
356
|
+
* the existing `stopRun(sessionId, reason)` per entry, which already invokes
|
|
357
|
+
* `engine.stop()` and cascades mark of nested agent sessions (Task #1837).
|
|
358
|
+
*
|
|
359
|
+
* Returns `{ stoppedSessionIds, errors }` for audit / caller logging.
|
|
360
|
+
* P1-#7: errors array includes per-session failure details so
|
|
361
|
+
* cascadeStopSessionTree can surface them in CascadeStopResult.errors.
|
|
362
|
+
*
|
|
363
|
+
* Idempotent: re-running on an already-stopped set is a no-op for those
|
|
364
|
+
* sessions; running/paused entries that succeeded are returned.
|
|
365
|
+
*/
|
|
366
|
+
hasActiveWorkflowForParent(parentSessionId: string): boolean;
|
|
367
|
+
stopAllForParent(parentSessionId: string): Promise<{
|
|
368
|
+
stoppedSessionIds: string[];
|
|
369
|
+
errors: Array<{
|
|
370
|
+
sessionId: string;
|
|
371
|
+
error: string;
|
|
372
|
+
stack?: string;
|
|
373
|
+
}>;
|
|
374
|
+
}>;
|
|
375
|
+
/**
|
|
376
|
+
* Task #2245 — ESC force-stop (second-press within 2s window).
|
|
377
|
+
*
|
|
378
|
+
* Traverse ALL workflow sessions (regardless of parent), mark running/paused
|
|
379
|
+
* ones as `stopped` via sessionComponent.update. Used as the force path when
|
|
380
|
+
* `stopAllForParent` (graceful) leaves residual orphans.
|
|
381
|
+
*
|
|
382
|
+
* Idempotent: re-running on already-stopped sessions is a no-op.
|
|
383
|
+
* Does NOT invoke engine.stop() — direct DB mark is sufficient for force
|
|
384
|
+
* cleanup; engine session has either completed or is being torn down.
|
|
385
|
+
*/
|
|
386
|
+
forceStopAll(): Promise<void>;
|
|
387
|
+
/**
|
|
388
|
+
* Resume an existing workflow session.
|
|
389
|
+
*
|
|
390
|
+
* Looks up the session, verifies it's a workflow session, resolves the
|
|
391
|
+
* workflow definition from session metadata, then re-enters execution
|
|
392
|
+
* via `engine.run(sessionId, options)`. The engine's unified `run()`
|
|
393
|
+
* detects the existing session and infers the resume point from
|
|
394
|
+
* persisted messages (Task #1829).
|
|
395
|
+
*
|
|
396
|
+
* Replaces the CLI's `(service as any).engineFactory` hack with a
|
|
397
|
+
* proper public API.
|
|
398
|
+
*
|
|
399
|
+
* @param sessionId - Existing workflow runId/sessionId (Task #1837:
|
|
400
|
+
* runId == sessionId, both start with `workflow_`)
|
|
401
|
+
* @param options - Optional RunOptions (input is forwarded as userResponse
|
|
402
|
+
* for ask_user interrupt resume paths)
|
|
403
|
+
* @returns Promise resolving to RunResult
|
|
404
|
+
* @throws Error when session not found / not a workflow session / workflow not registered
|
|
405
|
+
*/
|
|
406
|
+
resumeSession(sessionId: string, options?: RunOptions): Promise<RunResult>;
|
|
407
|
+
/**
|
|
408
|
+
* Get workflow session by ID
|
|
409
|
+
*/
|
|
410
|
+
getSession(sessionId: string): Promise<SessionInfo | null>;
|
|
411
|
+
/**
|
|
412
|
+
* List workflow sessions
|
|
413
|
+
*/
|
|
414
|
+
listSessions(options?: {
|
|
415
|
+
limit?: number;
|
|
416
|
+
offset?: number;
|
|
417
|
+
}): Promise<SessionInfo[]>;
|
|
418
|
+
/**
|
|
419
|
+
* Get messages from a workflow session
|
|
420
|
+
*/
|
|
421
|
+
getSessionMessages(sessionId: string): Promise<any[]>;
|
|
422
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Workflow Storage Module
|
|
3
|
+
*
|
|
4
|
+
* Re-exports all storage components for the workflow component.
|
|
5
|
+
*
|
|
6
|
+
* Note: After session-based refactoring, workflow runs are now managed via SessionComponent.
|
|
7
|
+
* The workflows table is still used for storing workflow definitions.
|
|
8
|
+
*/
|
|
9
|
+
export { getDatabase, closeDatabase, initializeTables, getDatabasePath, resetDatabase, initDatabase, type BunDatabase, } from './sqlite';
|
|
10
|
+
export { WorkflowRepository, rowToWorkflow, migrateEmptyTagsToDefault, type WorkflowRow, type ListWorkflowsOptions, type UpdateWorkflowOptions, } from './workflow-repo';
|
|
11
|
+
export { TagRepository, type TagInfo, } from './tag-repo';
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock Repositories for Testing
|
|
3
|
+
*
|
|
4
|
+
* Note: After session-based refactoring, workflow runs are managed via SessionComponent.
|
|
5
|
+
* These mock repositories only handle workflow definitions.
|
|
6
|
+
*/
|
|
7
|
+
import type { Workflow, WorkflowRun, RunStatus } from '../types';
|
|
8
|
+
export interface MockRunRepositoryOptions {
|
|
9
|
+
workflowId?: string;
|
|
10
|
+
workflowName?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare class MockRunRepository {
|
|
13
|
+
private runs;
|
|
14
|
+
private options;
|
|
15
|
+
constructor(options?: MockRunRepositoryOptions);
|
|
16
|
+
setWorkflowInfo(workflowId: string, workflowName: string): void;
|
|
17
|
+
createWorkflowRun(run: Omit<WorkflowRun, 'id'>): WorkflowRun;
|
|
18
|
+
getWorkflowRun(id: string): WorkflowRun | null;
|
|
19
|
+
listWorkflowRuns(workflowId?: string, options?: {
|
|
20
|
+
status?: RunStatus;
|
|
21
|
+
}): WorkflowRun[];
|
|
22
|
+
updateWorkflowRun(id: string, updates: Partial<WorkflowRun>): WorkflowRun | null;
|
|
23
|
+
clear(): void;
|
|
24
|
+
count(): number;
|
|
25
|
+
setWorkflowName(name: string): void;
|
|
26
|
+
}
|
|
27
|
+
export declare class MockWorkflowRepository {
|
|
28
|
+
private workflows;
|
|
29
|
+
private nameIndex;
|
|
30
|
+
create(workflow: Omit<Workflow, 'id' | 'createdAt' | 'updatedAt'>): Workflow;
|
|
31
|
+
getById(id: string): Workflow | null;
|
|
32
|
+
getByName(name: string): Workflow | null;
|
|
33
|
+
list(options?: {
|
|
34
|
+
tag?: string;
|
|
35
|
+
limit?: number;
|
|
36
|
+
offset?: number;
|
|
37
|
+
}): Workflow[];
|
|
38
|
+
update(id: string, updates: Partial<Workflow>): Workflow | null;
|
|
39
|
+
delete(id: string): boolean;
|
|
40
|
+
exists(name: string): boolean;
|
|
41
|
+
clear(): void;
|
|
42
|
+
count(): number;
|
|
43
|
+
/**
|
|
44
|
+
* v4: 拿过滤后的全局总数(不应用 limit/offset)
|
|
45
|
+
*
|
|
46
|
+
* 与 list() 共享 tag 过滤逻辑,但忽略 limit/offset。
|
|
47
|
+
* 支持单 tag (SQL 风格) 和多 tag AND。
|
|
48
|
+
*/
|
|
49
|
+
countAll(options?: {
|
|
50
|
+
tag?: string;
|
|
51
|
+
tags?: string[];
|
|
52
|
+
taskId?: number;
|
|
53
|
+
search?: string;
|
|
54
|
+
}): number;
|
|
55
|
+
/**
|
|
56
|
+
* v2: in-memory 事务支持
|
|
57
|
+
*
|
|
58
|
+
* 通过快照/回滚实现:拷贝当前 state,函数成功则 commit,失败则恢复快照。
|
|
59
|
+
*/
|
|
60
|
+
transaction<T>(fn: () => T): T;
|
|
61
|
+
}
|
|
62
|
+
export interface MockEngineCall {
|
|
63
|
+
method: string;
|
|
64
|
+
args: any[];
|
|
65
|
+
result?: any;
|
|
66
|
+
timestamp: number;
|
|
67
|
+
}
|
|
68
|
+
export type MockEngineFactory = () => MockWorkflowEngine;
|
|
69
|
+
export declare class MockWorkflowEngine {
|
|
70
|
+
calls: MockEngineCall[];
|
|
71
|
+
private sessionResults;
|
|
72
|
+
private workflowName;
|
|
73
|
+
constructor();
|
|
74
|
+
setWorkflowName(name: string): void;
|
|
75
|
+
getWorkflowName(): string;
|
|
76
|
+
createSession(workflowId: string, options?: {
|
|
77
|
+
input?: Record<string, any>;
|
|
78
|
+
workflowName?: string;
|
|
79
|
+
workflowVersion?: string;
|
|
80
|
+
}): Promise<string>;
|
|
81
|
+
createRun(workflowNameOrDefinition: string | any, options?: {
|
|
82
|
+
input?: Record<string, any>;
|
|
83
|
+
debug?: boolean;
|
|
84
|
+
}): Promise<string>;
|
|
85
|
+
run(runId: string, options?: any): Promise<any>;
|
|
86
|
+
runWorkflow(workflow: any, options?: any): Promise<any>;
|
|
87
|
+
pause(sessionId: string): Promise<void>;
|
|
88
|
+
resume(sessionId: string, options?: {
|
|
89
|
+
userResponse?: string;
|
|
90
|
+
pendingNodeId?: string;
|
|
91
|
+
agentSessionId?: string;
|
|
92
|
+
}): Promise<any>;
|
|
93
|
+
stop(sessionId: string, reason?: string): Promise<void>;
|
|
94
|
+
addNode(sessionId: string, nodeDefinition: any): Promise<void>;
|
|
95
|
+
removeNode(sessionId: string, nodeId: string): Promise<void>;
|
|
96
|
+
clearCalls(): void;
|
|
97
|
+
getLastCall(): MockEngineCall | undefined;
|
|
98
|
+
getCallsByMethod(method: string): MockEngineCall[];
|
|
99
|
+
}
|
|
100
|
+
export declare class MockNodeRegistry {
|
|
101
|
+
private nodes;
|
|
102
|
+
register(type: string, factory: any): void;
|
|
103
|
+
get(type: string): any;
|
|
104
|
+
has(type: string): boolean;
|
|
105
|
+
list(): string[];
|
|
106
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Safe JSON parsing helpers for storage layer
|
|
3
|
+
*
|
|
4
|
+
* 历史背景:Bug 修复 Task #4033 / Task #4037
|
|
5
|
+
* ----------------------------------------------------------------
|
|
6
|
+
* Bug #4033:task-store 的 rowToTask 对 tags 字段做裸 `JSON.parse`,
|
|
7
|
+
* 当 tags 被存成 CSV 字符串 `'html-styling, css-refactor, v34, ...'`
|
|
8
|
+
* 时抛 SyntaxError,整个 `tasks list` 命令挂掉。
|
|
9
|
+
*
|
|
10
|
+
* Bug #4037(sibling-risk):workflow-repo 的 rowToWorkflow 同样有 4 处
|
|
11
|
+
* 裸 JSON.parse(metadata / definition / config / tags),本文件统一
|
|
12
|
+
* 收口成 4 个语义明确的 helper:
|
|
13
|
+
*
|
|
14
|
+
* - parseJsonOrThrow(raw, fieldName, rowCtx)
|
|
15
|
+
* 业务关键字段(definition / metadata)损坏时直接抛错。
|
|
16
|
+
* 错误信息带 fieldName + row.name + row.id,便于排查。
|
|
17
|
+
* 原则:宁可让上层在 ReportError 路径上挂掉,也别返回 silent-corrupt 数据。
|
|
18
|
+
*
|
|
19
|
+
* - parseJsonObjectOrEmpty(raw, fieldName)
|
|
20
|
+
* 辅助对象字段(config)损坏时 fallback 到 {}。
|
|
21
|
+
*
|
|
22
|
+
* - parseTagsSafely(raw)
|
|
23
|
+
* tags 字段专用,复用 task-store 的 5-tier fallback 策略:
|
|
24
|
+
* 1. null/undefined/空串 → []
|
|
25
|
+
* 2. 合法 JSON 数组 → 原样返回
|
|
26
|
+
* 3. 合法 JSON 但不是数组(如 "tag1" 单字符串)→ 包成单元素数组
|
|
27
|
+
* 4. 非法 JSON(CSV / 纯文本)→ 当作单个 tag,包成单元素数组
|
|
28
|
+
* 5. 其他类型 → []
|
|
29
|
+
*
|
|
30
|
+
* - parseJsonArrayOrEmpty(raw, fieldName)
|
|
31
|
+
* 通用数组字段 fallback(如未来 workflow_tags 表新增数组字段)。
|
|
32
|
+
* 当前 task-store 的 parseTagsSafely 是 private static,未来重构时
|
|
33
|
+
* 可以考虑迁到这里以避免重复。
|
|
34
|
+
*/
|
|
35
|
+
export interface RowContext {
|
|
36
|
+
/** 数据库行 id(UUID),用于错误信息定位 */
|
|
37
|
+
id?: string;
|
|
38
|
+
/** workflow/task 名字,便于人在错误里直接 grep */
|
|
39
|
+
name?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 业务关键字段:损坏时抛错,错误信息带 fieldName + row.name + row.id。
|
|
43
|
+
*
|
|
44
|
+
* @throws {Error} 包含 fieldName / row.name / row.id / 原始片段
|
|
45
|
+
*/
|
|
46
|
+
export declare function parseJsonOrThrow<T = unknown>(raw: unknown, fieldName: string, rowCtx?: RowContext): T;
|
|
47
|
+
/**
|
|
48
|
+
* 辅助对象字段:损坏时 fallback 到 {},不抛错。
|
|
49
|
+
*/
|
|
50
|
+
export declare function parseJsonObjectOrEmpty<T extends object = Record<string, unknown>>(raw: unknown, fieldName: string): T;
|
|
51
|
+
/**
|
|
52
|
+
* 通用数组字段 fallback。
|
|
53
|
+
* 损坏时返回 [],不抛错。
|
|
54
|
+
*/
|
|
55
|
+
export declare function parseJsonArrayOrEmpty<T = unknown>(raw: unknown, fieldName: string): T[];
|
|
56
|
+
/**
|
|
57
|
+
* tags 字段专用,语义与 task-store 的 parseTagsSafely 完全一致。
|
|
58
|
+
*
|
|
59
|
+
* 未来如果 task-store 的 private static parseTagsSafely 重构到这里,
|
|
60
|
+
* 可以从 sqlite-task-store.ts 删掉私有版本,统一从本函数导入。
|
|
61
|
+
*/
|
|
62
|
+
export declare function parseTagsSafely(raw: unknown): string[];
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview SQLite Storage for Workflow Component
|
|
3
|
+
*
|
|
4
|
+
* 根据运行环境自动选择 SQLite 实现:
|
|
5
|
+
* - Bun 运行时:使用 bun:sqlite
|
|
6
|
+
* - Node.js/Electron:使用 better-sqlite3
|
|
7
|
+
*
|
|
8
|
+
* 存储路径:~/.local/share/roy-agent/workflows.db
|
|
9
|
+
*
|
|
10
|
+
* Note: After session-based refactoring, workflow runs are managed via SessionComponent.
|
|
11
|
+
* Only the workflows table is used here for storing workflow definitions.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Get the database file path
|
|
15
|
+
* Default: ~/.local/share/roy-agent/workflows.db
|
|
16
|
+
*/
|
|
17
|
+
export declare function getDatabasePath(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Get the singleton database instance
|
|
20
|
+
* @param path - Optional custom database path. If not provided, uses default path.
|
|
21
|
+
* Use ':memory:' for in-memory database (testing)
|
|
22
|
+
*/
|
|
23
|
+
export declare function getDatabase(path?: string): any;
|
|
24
|
+
/**
|
|
25
|
+
* Close the database connection
|
|
26
|
+
*/
|
|
27
|
+
export declare function closeDatabase(): void;
|
|
28
|
+
export type BunDatabase = {
|
|
29
|
+
exec(sql: string): void;
|
|
30
|
+
query<T>(sql: string): {
|
|
31
|
+
all(): T[];
|
|
32
|
+
get(...params: any[]): T | null;
|
|
33
|
+
};
|
|
34
|
+
run(sql: string, ...params: any[]): {
|
|
35
|
+
lastInsertRowid: number;
|
|
36
|
+
changes: number;
|
|
37
|
+
};
|
|
38
|
+
close(): void;
|
|
39
|
+
pragma?: (sql: string) => void;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Initialize all required tables
|
|
43
|
+
*
|
|
44
|
+
* Note: Only workflows table is created. Workflow runs are managed via SessionComponent
|
|
45
|
+
* using the session/message storage, following the session-based design.
|
|
46
|
+
*/
|
|
47
|
+
export declare function initializeTables(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Reset the database instance (for testing purposes)
|
|
50
|
+
* This is useful for tests that need a fresh database
|
|
51
|
+
*/
|
|
52
|
+
export declare function resetDatabase(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Initialize tables and return a ready database
|
|
55
|
+
* This is a convenience function that combines getDatabase and initializeTables
|
|
56
|
+
*/
|
|
57
|
+
export declare function initDatabase(path?: string): any;
|