@ai-setting/roy-agent-core 1.7.51 → 1.7.53
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/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/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 +486 -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 +4 -4
- 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 +6 -6
- 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 +39 -0
- package/dist/env/llm/adapter.d.ts +80 -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/invoke.d.ts +264 -0
- package/dist/env/llm/llm-cache.d.ts +38 -0
- package/dist/env/llm/llm.d.ts +238 -0
- package/dist/env/llm/opencode-session.d.ts +79 -0
- package/dist/env/llm/provider.d.ts +40 -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 +818 -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/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/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/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 +704 -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 +293 -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/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/plugins/auto-task-plugin.d.ts +38 -0
- package/dist/env/task/plugins/card-chat-routing.d.ts +135 -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 +2 -2
- package/dist/env/task/plugins/lark-card-action-handler.d.ts +166 -0
- package/dist/env/task/plugins/lark-card-patch-notifier.d.ts +651 -0
- package/dist/env/task/plugins/lark-cli-task-notify-plugin.d.ts +248 -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 +375 -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/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 +1 -1
- 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/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 +58 -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/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 +60 -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 +235 -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 +35 -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/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/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/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 +57 -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 +7 -7
- package/dist/shared/@ai-setting/{roy-agent-core-9faekt5n.js → roy-agent-core-4sx6sdb2.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-wxsgay02.js → roy-agent-core-brwzs8wf.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-kyasfzeh.js → roy-agent-core-hch2geta.js} +45 -14
- package/dist/shared/@ai-setting/{roy-agent-core-zd077w51.js → roy-agent-core-j8e92gj8.js} +43 -1
- package/dist/shared/@ai-setting/{roy-agent-core-wwytg8rv.js → roy-agent-core-ph5qbqcx.js} +566 -78
- 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 +4 -2
- /package/dist/shared/@ai-setting/{roy-agent-core-s214vmmd.js → roy-agent-core-4vpk40ss.js} +0 -0
- /package/dist/shared/@ai-setting/{roy-agent-core-0cfaqnz9.js → roy-agent-core-k25gv86p.js} +0 -0
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview WorkflowEngine - Session-based workflow execution engine
|
|
3
|
+
*
|
|
4
|
+
* 统一的 run() 方法同时支持:
|
|
5
|
+
* - 初次运行:session 不存在 → 创建 session,从 entry node 开始
|
|
6
|
+
* - 中断恢复:session 存在 + 有消息 → 从消息推断下一个节点继续执行
|
|
7
|
+
*
|
|
8
|
+
* Session 通过 workflow.node.* 消息记录节点执行状态
|
|
9
|
+
*
|
|
10
|
+
* @version v3.0 (移除 resume() 方法,统一使用 run())
|
|
11
|
+
*/
|
|
12
|
+
import { EventEmitter } from 'events';
|
|
13
|
+
import type { WorkflowDefinition, Workflow, RunOptions, RunResult, RunStatus } from '../types/index';
|
|
14
|
+
import { NodeRegistry } from './node-registry';
|
|
15
|
+
import type { SessionComponent } from '../../session/session-component';
|
|
16
|
+
/**
|
|
17
|
+
* Agent Session Recovery Info
|
|
18
|
+
*/
|
|
19
|
+
export interface AgentSessionRecoveryInfo {
|
|
20
|
+
nodeId: string;
|
|
21
|
+
agentSessionId: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Options for creating WorkflowEngine via static factory
|
|
25
|
+
*/
|
|
26
|
+
export interface WorkflowEngineCreateOptions {
|
|
27
|
+
env?: {
|
|
28
|
+
getComponent<T>(name: string): T | undefined;
|
|
29
|
+
};
|
|
30
|
+
toolRegistry?: any;
|
|
31
|
+
skillRegistry?: any;
|
|
32
|
+
workflowRunner?: any;
|
|
33
|
+
sessionComponent?: SessionComponent;
|
|
34
|
+
/** Repository for loading workflow definitions during resume */
|
|
35
|
+
workflowRepository?: WorkflowRepository;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Workflow Repository interface (abstraction)
|
|
39
|
+
*/
|
|
40
|
+
export interface WorkflowRepository {
|
|
41
|
+
getById(id: string): Workflow | null;
|
|
42
|
+
getByName(name: string): Workflow | null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* WorkflowEngine Configuration
|
|
46
|
+
*/
|
|
47
|
+
export interface WorkflowEngineConfig {
|
|
48
|
+
parallelLimit: number | null;
|
|
49
|
+
timeout: number | null;
|
|
50
|
+
debug: boolean;
|
|
51
|
+
/** Strict mode: fail on unresolved templates instead of warning */
|
|
52
|
+
strict: boolean;
|
|
53
|
+
/** Maximum iterations to prevent infinite loops (default: 100) */
|
|
54
|
+
maxIterations: number;
|
|
55
|
+
/** Global workflow input for condition evaluation (P0-3 fix) */
|
|
56
|
+
workflowInput?: Record<string, unknown>;
|
|
57
|
+
/** Enable loop mode to allow re-entry of completed nodes (P0-1 fix) */
|
|
58
|
+
loopEnabled?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Per-node runtime overrides.
|
|
61
|
+
*
|
|
62
|
+
* Task #1974 — Workflow Node-Level Config + Resume + Stop. Set by
|
|
63
|
+
* `engine.initializeSessionState` from `RunOptions.nodeConfig`. Used
|
|
64
|
+
* by `buildNodeContext` to shallow-merge into each node's effective
|
|
65
|
+
* config (input wins over nodeDef.config).
|
|
66
|
+
*
|
|
67
|
+
* Always present (defaults to `{}`); engine treats `undefined` and
|
|
68
|
+
* `{}` identically.
|
|
69
|
+
*/
|
|
70
|
+
nodeConfig?: Record<string, Record<string, unknown>>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* WorkflowEngine
|
|
74
|
+
*
|
|
75
|
+
* Session-based workflow execution engine.
|
|
76
|
+
* Uses Session to manage workflow run state and node execution history.
|
|
77
|
+
*/
|
|
78
|
+
export declare class WorkflowEngine extends EventEmitter {
|
|
79
|
+
/** 活跃的 session 状态,key 为 sessionId */
|
|
80
|
+
private activeSessions;
|
|
81
|
+
/** Session ID 计数器 */
|
|
82
|
+
private sessionIdCounter;
|
|
83
|
+
/** Session component */
|
|
84
|
+
private sessionComponent?;
|
|
85
|
+
/** Node registry */
|
|
86
|
+
private nodeRegistry;
|
|
87
|
+
/** Workflow repository for loading definitions during resume */
|
|
88
|
+
private workflowRepository?;
|
|
89
|
+
/**
|
|
90
|
+
* Create a new WorkflowEngine
|
|
91
|
+
*/
|
|
92
|
+
constructor(nodeRegistry: NodeRegistry, sessionComponent?: SessionComponent, workflowRepository?: WorkflowRepository);
|
|
93
|
+
/**
|
|
94
|
+
* Create a WorkflowEngine with automatic AgentComponent integration
|
|
95
|
+
*/
|
|
96
|
+
static create(options: WorkflowEngineCreateOptions): Promise<WorkflowEngine>;
|
|
97
|
+
/**
|
|
98
|
+
* Generate a unique run ID
|
|
99
|
+
*/
|
|
100
|
+
private generateRunId;
|
|
101
|
+
/**
|
|
102
|
+
* Get session ID for a run.
|
|
103
|
+
*
|
|
104
|
+
* Task #1837: now an identity function — runId already has the
|
|
105
|
+
* `workflow_` prefix, so sessionId equals runId exactly. The legacy
|
|
106
|
+
* `\`workflow_${runId}\`` mapping is collapsed.
|
|
107
|
+
*
|
|
108
|
+
* Kept as a public method for backward compatibility with external
|
|
109
|
+
* callers that may still derive sessionId from runId.
|
|
110
|
+
*/
|
|
111
|
+
getSessionId(runId: string): string;
|
|
112
|
+
/**
|
|
113
|
+
* Extract runId from sessionId.
|
|
114
|
+
*
|
|
115
|
+
* Task #1837: sessionId IS the runId (no prefix to strip). Returns the
|
|
116
|
+
* input verbatim. Existing callers (event emission, pause/stop) still
|
|
117
|
+
* work because they don't care about the prefix format — they just
|
|
118
|
+
* need a unique identifier for the workflow run.
|
|
119
|
+
*/
|
|
120
|
+
private getRunIdFromSessionId;
|
|
121
|
+
/**
|
|
122
|
+
* Create a new workflow session
|
|
123
|
+
*
|
|
124
|
+
* @param workflow - Workflow definition or entity
|
|
125
|
+
* @param options - Optional configuration
|
|
126
|
+
* @returns Promise resolving to sessionId (format: workflow_{runId})
|
|
127
|
+
*/
|
|
128
|
+
createSession(workflow: Workflow | WorkflowDefinition, options?: RunOptions): Promise<string>;
|
|
129
|
+
/**
|
|
130
|
+
* Run a workflow by sessionId (unified entry point)
|
|
131
|
+
*
|
|
132
|
+
* This method supports both:
|
|
133
|
+
* 1. First run: session doesn't exist → create session, start from entry node
|
|
134
|
+
* 2. Resume: session exists with messages → infer next node from messages
|
|
135
|
+
*
|
|
136
|
+
* @param sessionId - Session ID (format: workflow_{runId} or any string)
|
|
137
|
+
* @param options - Optional configuration
|
|
138
|
+
* @returns Promise resolving to RunResult
|
|
139
|
+
*/
|
|
140
|
+
run(sessionId: string, options?: RunOptions & {
|
|
141
|
+
workflowId?: string;
|
|
142
|
+
}): Promise<RunResult>;
|
|
143
|
+
/**
|
|
144
|
+
* Initialize session state
|
|
145
|
+
*/
|
|
146
|
+
private initializeSessionState;
|
|
147
|
+
/**
|
|
148
|
+
* Run with resume point
|
|
149
|
+
*
|
|
150
|
+
* Simplified logic:
|
|
151
|
+
* - input is passed directly to execution (string or object)
|
|
152
|
+
* - For resume with ask_user, the input should contain userQuery
|
|
153
|
+
* - agentSessionId comes from session messages via resumePoint
|
|
154
|
+
*/
|
|
155
|
+
private runWithResume;
|
|
156
|
+
/**
|
|
157
|
+
* Convenience method to run a workflow directly
|
|
158
|
+
*/
|
|
159
|
+
runWorkflow(workflow: Workflow | WorkflowDefinition, options?: RunOptions): Promise<RunResult>;
|
|
160
|
+
/**
|
|
161
|
+
* Pause a running workflow
|
|
162
|
+
*/
|
|
163
|
+
pause(sessionId: string): Promise<void>;
|
|
164
|
+
/**
|
|
165
|
+
* Stop a running or paused workflow.
|
|
166
|
+
*
|
|
167
|
+
* Task #2275: now structured through `RuntimeCancellationScope` so that:
|
|
168
|
+
* - The session's `completedPromise` is resolved with `{status:'stopped'}`
|
|
169
|
+
* once tracked cleanup settles, NOT just metadata update.
|
|
170
|
+
* - `force=true` escalates to the scope's force level and fires any
|
|
171
|
+
* registered force handlers (e.g. process kill paths).
|
|
172
|
+
* - Cooperative runners listening to the scope signal will abort.
|
|
173
|
+
* - The legacy `abortController` is also aborted for backward compat.
|
|
174
|
+
*
|
|
175
|
+
* The function is idempotent — calling it twice (or stop+stop(force))
|
|
176
|
+
* coalesces into a single transition.
|
|
177
|
+
*/
|
|
178
|
+
stop(sessionId: string, reason?: string, options?: {
|
|
179
|
+
force?: boolean;
|
|
180
|
+
}): Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* Get session status
|
|
183
|
+
*/
|
|
184
|
+
getSessionStatus(sessionId: string): RunStatus | null;
|
|
185
|
+
/**
|
|
186
|
+
* Task #2275 — propagate a workflow stop to each actual child agent
|
|
187
|
+
* session record. The previous engine.stop only updated the workflow
|
|
188
|
+
* session's `agentSessions[]` references, leaving child session
|
|
189
|
+
* metadata.status stale (a gap visible in `sessions list --graph`
|
|
190
|
+
* where the user saw `agent_plan_*` and `agent_init-task_*` still
|
|
191
|
+
* listed without a stopped status after the workflow was stopped).
|
|
192
|
+
*
|
|
193
|
+
* Behavior:
|
|
194
|
+
* - Iterates ALL sessions whose parentSessionId matches this
|
|
195
|
+
* workflow session (not just refs in metadata.agentSessions, so
|
|
196
|
+
* children created in the brief window between schedule and stop
|
|
197
|
+
* are also caught).
|
|
198
|
+
* - For each child session:
|
|
199
|
+
* - Skip if status is already terminal (completed/failed/stopped)
|
|
200
|
+
* - Update metadata.status = "stopped", append stop reason
|
|
201
|
+
* - Errors are isolated per child — one failure does not block siblings
|
|
202
|
+
* - No-op when sessionComponent is missing or workflow has no children
|
|
203
|
+
*
|
|
204
|
+
* Idempotency: a second invocation only touches children that are
|
|
205
|
+
* still non-terminal, so double-stop is safe.
|
|
206
|
+
*/
|
|
207
|
+
private propagateStopToChildSessions;
|
|
208
|
+
/**
|
|
209
|
+
* Check if session is active
|
|
210
|
+
*/
|
|
211
|
+
isSessionActive(sessionId: string): boolean;
|
|
212
|
+
/**
|
|
213
|
+
* Setup event handlers for a run
|
|
214
|
+
*/
|
|
215
|
+
private setupEventHandlers;
|
|
216
|
+
/**
|
|
217
|
+
* Main scheduling loop
|
|
218
|
+
*/
|
|
219
|
+
private scheduleAndExecute;
|
|
220
|
+
/**
|
|
221
|
+
* Wait for next node event
|
|
222
|
+
*
|
|
223
|
+
* Optimization: When there are running nodes, use pure event-driven waiting
|
|
224
|
+
* (no polling). When there are only pending nodes (dependencies not yet met),
|
|
225
|
+
* use a small timeout to re-check scheduling conditions.
|
|
226
|
+
*/
|
|
227
|
+
private waitForNextNodeEvent;
|
|
228
|
+
/**
|
|
229
|
+
* Start execution of a single node
|
|
230
|
+
*/
|
|
231
|
+
private startNode;
|
|
232
|
+
/**
|
|
233
|
+
* Write workflow.node.start message
|
|
234
|
+
*/
|
|
235
|
+
private writeNodeStart;
|
|
236
|
+
/**
|
|
237
|
+
* Resume execution of a paused node
|
|
238
|
+
*
|
|
239
|
+
* Simplified logic:
|
|
240
|
+
* - Load agent session from agentSessionId
|
|
241
|
+
* - Pass userQuery from input to agentNode
|
|
242
|
+
* - No complex userResponse distinction
|
|
243
|
+
*/
|
|
244
|
+
private resumeNode;
|
|
245
|
+
/**
|
|
246
|
+
* Pre-execute validation
|
|
247
|
+
* Validates node configuration before execution
|
|
248
|
+
* Checks for unresolved templates and throws in strict mode
|
|
249
|
+
*/
|
|
250
|
+
private preExecuteValidation;
|
|
251
|
+
/**
|
|
252
|
+
* Validate node configuration and execute it
|
|
253
|
+
* Common method used by both startNode and resumeNode
|
|
254
|
+
*/
|
|
255
|
+
private validateAndExecute;
|
|
256
|
+
/**
|
|
257
|
+
* Loop-guard check for a single back-edge re-entry.
|
|
258
|
+
*
|
|
259
|
+
* Task #2283 — engine-side progress guard. Reads the node's
|
|
260
|
+
* `config.loop_guard` and decides whether the upcoming re-entry would
|
|
261
|
+
* be a no-progress attempt. If the no-progress counter reaches
|
|
262
|
+
* `max_consecutive_no_progress`, the function returns
|
|
263
|
+
* `{ trip: true, failMessage }` so the caller can short-circuit the
|
|
264
|
+
* agent and inject a fail output.
|
|
265
|
+
*
|
|
266
|
+
* Behavior matrix for the `value_unchanged` type:
|
|
267
|
+
* - previous_value === current_value (after JSON.stringify)
|
|
268
|
+
* → increment counter; if >= maxAllowed → trip; else allow
|
|
269
|
+
* - previous_value !== current_value
|
|
270
|
+
* → reset counter to 0; allow
|
|
271
|
+
* - previous_value is undefined (first run for this node)
|
|
272
|
+
* → first re-entry: count this as a "change" (we don't know the
|
|
273
|
+
* prior state); allow
|
|
274
|
+
* - current_signal_command fails to execute
|
|
275
|
+
* → allow (defensive: don't false-positive on transient shell errors)
|
|
276
|
+
*
|
|
277
|
+
* The counter is persisted in `sessionState.loopGuardCounters`
|
|
278
|
+
* (Task #2286 fix — dedicated map, independent of `nodeOutputs`).
|
|
279
|
+
*
|
|
280
|
+
* Earlier versions stored the counter under the well-known key
|
|
281
|
+
* `_loop_guard_consecutive_<nodeId>` directly on the node's prior
|
|
282
|
+
* output map. That broke once `max_consecutive_no_progress >= 2`,
|
|
283
|
+
* because the next agent run overwrote the whole output via
|
|
284
|
+
* `sessionState.nodeOutputs.set(nodeId, result.output)`, clobbering
|
|
285
|
+
* the counter on every back-edge. The dedicated map survives agent
|
|
286
|
+
* output writes because nothing else mutates it.
|
|
287
|
+
*
|
|
288
|
+
* The caller MUST pass a `templateResolver` whose previousOutputs
|
|
289
|
+
* already include the pre-cascade-reset snapshot for `reEntryId`.
|
|
290
|
+
* The post-reset state would otherwise resolve `{{nodes.<reEntryId>.*}}`
|
|
291
|
+
* to undefined.
|
|
292
|
+
*/
|
|
293
|
+
private checkLoopGuardWithSnapshot;
|
|
294
|
+
/**
|
|
295
|
+
* Evaluate conditional edges after a node completes and start matching targets.
|
|
296
|
+
*
|
|
297
|
+
* IMPORTANT: For conditional edge workflows to work correctly:
|
|
298
|
+
* 1. All non-entry nodes MUST specify depends_on for their expected upstream node(s)
|
|
299
|
+
* 2. edges.when acts as a gate AFTER depends_on is satisfied
|
|
300
|
+
* 3. If depends_on is empty, the node will be scheduled at start regardless of edges
|
|
301
|
+
*/
|
|
302
|
+
private processConditionalEdgesAfterCompletion;
|
|
303
|
+
/**
|
|
304
|
+
* Build node execution context (renamed from createExecutionContext)
|
|
305
|
+
*
|
|
306
|
+
* @param sessionState - Active session state
|
|
307
|
+
* @param nodeId - Node ID to create context for
|
|
308
|
+
* @param globalInput - Global workflow input
|
|
309
|
+
*/
|
|
310
|
+
/**
|
|
311
|
+
* 安全取 DAG 节点总数(供 hook payload 用)。
|
|
312
|
+
*
|
|
313
|
+
* ★ 2026-10-16 独立 review P0:hook payload 的构造**绝不能**让 engine 抛错。
|
|
314
|
+
* 原实现直接写 `sessionState.dagManager.getNodeCount()`,而 legacy 测试 fixture
|
|
315
|
+
* 会直接 cast 构造 ActiveSessionState(可能没有 dagManager)→
|
|
316
|
+
* `TypeError: undefined is not an object`。
|
|
317
|
+
*
|
|
318
|
+
* 致命点:该异常发生在 **HookManager 之前**(还在构造 payload),所以
|
|
319
|
+
* "hook 抛错由 safeExecute 隔离"这条保护**完全救不了** —— 异常是 engine 自己
|
|
320
|
+
* 抛的,会连带吞掉 `resolveCompleted` / agentSessions 传播 / 原始 error。
|
|
321
|
+
* 实测它打红了 7 条既有测试
|
|
322
|
+
* (engine-fail-agentsessions ×4、engine-node-completed-agentsessions ×3)。
|
|
323
|
+
*
|
|
324
|
+
* 兜底返回 undefined:hook 消费方(如通知插件)本就把 totalNodes 当可选。
|
|
325
|
+
*/
|
|
326
|
+
private safeNodeCount;
|
|
327
|
+
private buildNodeContext;
|
|
328
|
+
/**
|
|
329
|
+
* Check if workflow is complete and finalize
|
|
330
|
+
*/
|
|
331
|
+
private checkAndFinalize;
|
|
332
|
+
/**
|
|
333
|
+
* Complete a workflow successfully.
|
|
334
|
+
*
|
|
335
|
+
* === RunResult Output Behavior ===
|
|
336
|
+
*
|
|
337
|
+
* 1. ALL node outputs (intermediate + exit) are included in the final
|
|
338
|
+
* RunResult.output as { nodeId: output, ... }. The shape stays
|
|
339
|
+
* consistent regardless of how many nodes or exit points a
|
|
340
|
+
* workflow has.
|
|
341
|
+
*
|
|
342
|
+
* 2. The same all-node-outputs map is also stored in session metadata
|
|
343
|
+
* for debugging/reference.
|
|
344
|
+
*
|
|
345
|
+
* 3. Intermediate node outputs are additionally recorded in session
|
|
346
|
+
* messages via workflow.node.end messages written by
|
|
347
|
+
* executor.writeNodeEnd().
|
|
348
|
+
*
|
|
349
|
+
* 4. Consumers can always access a node's output via
|
|
350
|
+
* result.output[nodeId], including agents that need to chain state
|
|
351
|
+
* across pause/resume cycles (see agent-resume-history.test.ts,
|
|
352
|
+
* dual-agent-resume-userquery.test.ts).
|
|
353
|
+
*/
|
|
354
|
+
private completeWorkflow;
|
|
355
|
+
/**
|
|
356
|
+
* Fail a workflow
|
|
357
|
+
*/
|
|
358
|
+
private failWorkflow;
|
|
359
|
+
/**
|
|
360
|
+
* Cleanup session resources
|
|
361
|
+
*/
|
|
362
|
+
private cleanupSession;
|
|
363
|
+
/**
|
|
364
|
+
* Wait for a run to complete
|
|
365
|
+
*/
|
|
366
|
+
private waitForCompletion;
|
|
367
|
+
/**
|
|
368
|
+
* Get session metadata
|
|
369
|
+
*/
|
|
370
|
+
private getSessionMetadata;
|
|
371
|
+
/**
|
|
372
|
+
* Find workflow definition from repository
|
|
373
|
+
*/
|
|
374
|
+
private findDefinitionForWorkflow;
|
|
375
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { WorkflowEvent } from '../types/event';
|
|
2
|
+
export type EventHandler = (event: WorkflowEvent) => void | Promise<void>;
|
|
3
|
+
/**
|
|
4
|
+
* EventBus for workflow events.
|
|
5
|
+
* Custom event bus implementation with support for wildcard subscriptions.
|
|
6
|
+
*/
|
|
7
|
+
export declare class EventBus {
|
|
8
|
+
private handlers;
|
|
9
|
+
private wildcardHandlers;
|
|
10
|
+
constructor();
|
|
11
|
+
/**
|
|
12
|
+
* Subscribe to a specific event type.
|
|
13
|
+
* @returns Unsubscribe function
|
|
14
|
+
*/
|
|
15
|
+
on(eventType: string, handler: EventHandler): () => void;
|
|
16
|
+
/**
|
|
17
|
+
* Subscribe to an event type only once (auto-unsubscribe after first call).
|
|
18
|
+
* @returns Unsubscribe function
|
|
19
|
+
*/
|
|
20
|
+
once(eventType: string, handler: EventHandler): () => void;
|
|
21
|
+
/**
|
|
22
|
+
* Unsubscribe from an event type.
|
|
23
|
+
*/
|
|
24
|
+
off(eventType: string, handler: EventHandler): void;
|
|
25
|
+
/**
|
|
26
|
+
* Subscribe to all events (wildcard subscription).
|
|
27
|
+
* @returns Unsubscribe function
|
|
28
|
+
*/
|
|
29
|
+
onAny(handler: EventHandler): () => void;
|
|
30
|
+
/**
|
|
31
|
+
* Publish an event to all subscribers.
|
|
32
|
+
* Handler errors are caught and do not crash the bus.
|
|
33
|
+
*
|
|
34
|
+
* @param event - The event to publish
|
|
35
|
+
* @param waitForHandlers - If true, waits for all async handlers to complete (default: false)
|
|
36
|
+
*/
|
|
37
|
+
publish(event: WorkflowEvent, waitForHandlers?: boolean): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Execute a handler safely, catching any errors.
|
|
40
|
+
*/
|
|
41
|
+
private executeHandler;
|
|
42
|
+
/**
|
|
43
|
+
* Clear all subscriptions.
|
|
44
|
+
*/
|
|
45
|
+
clear(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Get statistics about the event bus.
|
|
48
|
+
*/
|
|
49
|
+
getStats(): {
|
|
50
|
+
eventTypes: number;
|
|
51
|
+
wildcardHandlers: number;
|
|
52
|
+
totalHandlers: number;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Executor - Executes nodes in a workflow
|
|
3
|
+
*
|
|
4
|
+
* The Executor is responsible for:
|
|
5
|
+
* - Executing individual nodes
|
|
6
|
+
* - Handling retries
|
|
7
|
+
* - Managing timeouts
|
|
8
|
+
* - Tracking execution state
|
|
9
|
+
*/
|
|
10
|
+
import type { NodeDefinition, RetryConfig, NodeExecutionContext, NodeExecutionResult } from '../types/index';
|
|
11
|
+
import { EventBus } from './event-bus';
|
|
12
|
+
import { NodeRegistry } from './node-registry';
|
|
13
|
+
import type { SessionComponent } from '../../session/session-component';
|
|
14
|
+
/**
|
|
15
|
+
* Executor Options
|
|
16
|
+
*/
|
|
17
|
+
export interface ExecutorOptions {
|
|
18
|
+
/** Global timeout for node execution (ms). null = no timeout */
|
|
19
|
+
globalTimeout: number | null;
|
|
20
|
+
/** Global retry configuration */
|
|
21
|
+
globalRetry: RetryConfig | null;
|
|
22
|
+
/** Debug mode */
|
|
23
|
+
debug: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Executor
|
|
27
|
+
*
|
|
28
|
+
* Executes nodes in a workflow with support for:
|
|
29
|
+
* - Timeout handling
|
|
30
|
+
* - Retry with configurable backoff
|
|
31
|
+
* - Error propagation
|
|
32
|
+
* - Session message writing
|
|
33
|
+
* - AskUserError handling
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const executor = new Executor(nodeRegistry, eventBus, {
|
|
38
|
+
* globalTimeout: 60000,
|
|
39
|
+
* globalRetry: { max_attempts: 3, backoff: 'exponential', initial_delay: 1000 },
|
|
40
|
+
* debug: false
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* const result = await executor.executeNode(nodeDefinition, context);
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare class Executor {
|
|
47
|
+
private nodeRegistry;
|
|
48
|
+
private eventBus;
|
|
49
|
+
private options;
|
|
50
|
+
private sessionComponent?;
|
|
51
|
+
private abortControllers;
|
|
52
|
+
constructor(nodeRegistry: NodeRegistry, eventBus: EventBus, options: ExecutorOptions, sessionComponent?: SessionComponent | undefined);
|
|
53
|
+
/**
|
|
54
|
+
* Execute a node with timeout and retry handling
|
|
55
|
+
*/
|
|
56
|
+
executeNode(definition: NodeDefinition, context: NodeExecutionContext): Promise<NodeExecutionResult>;
|
|
57
|
+
/**
|
|
58
|
+
* Execute node with timeout handling
|
|
59
|
+
*
|
|
60
|
+
* Task #1976: when the timeout fires, also abort the controller so the
|
|
61
|
+
* node has a chance to react via its AbortSignal — instead of being
|
|
62
|
+
* silently orphaned (the bug this method was leaking).
|
|
63
|
+
*/
|
|
64
|
+
private executeWithTimeout;
|
|
65
|
+
/**
|
|
66
|
+
* Execute node with retry handling
|
|
67
|
+
*/
|
|
68
|
+
private executeWithRetry;
|
|
69
|
+
/**
|
|
70
|
+
* Cancel execution of a specific node
|
|
71
|
+
*/
|
|
72
|
+
cancelNode(nodeId: string): void;
|
|
73
|
+
/**
|
|
74
|
+
* Cancel all running nodes
|
|
75
|
+
*/
|
|
76
|
+
cancelAll(): void;
|
|
77
|
+
/**
|
|
78
|
+
* Combine two abort signals.
|
|
79
|
+
*
|
|
80
|
+
* Task #2291 P0-1 / P1-3:
|
|
81
|
+
* Replaced the addEventListener-based composition with `AbortSignal.any`
|
|
82
|
+
* which (a) preserves the abort reason from the firing input and
|
|
83
|
+
* (b) aborts synchronously when any input is already aborted.
|
|
84
|
+
*/
|
|
85
|
+
private combineAbortSignals;
|
|
86
|
+
/**
|
|
87
|
+
* Sleep for specified milliseconds, with optional signal-aware abort
|
|
88
|
+
* (Task #2275). When `signal` is provided, the returned Promise rejects
|
|
89
|
+
* with `signal.reason` if the signal aborts before the timer fires,
|
|
90
|
+
* and the underlying setTimeout is cleared (no leftover timer).
|
|
91
|
+
*/
|
|
92
|
+
private sleep;
|
|
93
|
+
/**
|
|
94
|
+
* Write workflow.node.start message
|
|
95
|
+
* 对应 tool-call,节点开始执行
|
|
96
|
+
*/
|
|
97
|
+
writeNodeStart(sessionId: string, nodeId: string, nodeType: string, input: unknown, agentSessionId?: string): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Patch agentSessionId onto the latest workflow.node.start for a node (P1).
|
|
100
|
+
*/
|
|
101
|
+
attachAgentSessionToLastStart(sessionId: string, nodeId: string, agentSessionId: string): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Create a meaningful content summary for call message
|
|
104
|
+
*/
|
|
105
|
+
private summarizeCall;
|
|
106
|
+
/**
|
|
107
|
+
* Write workflow.node.interrupt message
|
|
108
|
+
*/
|
|
109
|
+
writeNodeInterrupt(sessionId: string, nodeId: string, nodeType: string, query: string, agentSessionId?: string): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Write workflow.node.end message (对应 tool-result)
|
|
112
|
+
*/
|
|
113
|
+
writeNodeEnd(sessionId: string, nodeId: string, nodeType: string, output: unknown, error: string | undefined, durationMs: number, agentSessionId?: string): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Create a meaningful content summary for result display
|
|
116
|
+
*/
|
|
117
|
+
private summarizeResult;
|
|
118
|
+
/**
|
|
119
|
+
* Write workflow.node.resume message
|
|
120
|
+
*/
|
|
121
|
+
writeNodeResume(sessionId: string, nodeId: string, nodeType: string, response: string, agentSessionId?: string): Promise<void>;
|
|
122
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Engine exports
|
|
3
|
+
*/
|
|
4
|
+
export type { NodeExecutionContext, RunOptions, RunResult, RunStatus, NodeStatus, } from '../types/index';
|
|
5
|
+
export { EventBus } from './event-bus';
|
|
6
|
+
export { DAGManager } from './dag-manager';
|
|
7
|
+
export type { DAGAnalysis } from './dag-manager';
|
|
8
|
+
export { Scheduler } from './scheduler';
|
|
9
|
+
export type { SchedulerOptions, SchedulerState } from './scheduler';
|
|
10
|
+
export { Executor } from './executor';
|
|
11
|
+
export type { ExecutorOptions } from './executor';
|
|
12
|
+
export { WorkflowEngine } from './engine';
|
|
13
|
+
export type { WorkflowEngineConfig, WorkflowEngineCreateOptions, WorkflowRepository } from './engine';
|
|
14
|
+
export { NodeRegistry } from './node-registry';
|
|
15
|
+
export type { NodeContext, NodeFactory } from './node-registry';
|