@ai-setting/roy-agent-core 1.7.52 → 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 +2 -2
- 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 +4 -4
- 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 +1 -1
- 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/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 +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-rcfewbzr.js → roy-agent-core-4sx6sdb2.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-ezgsem94.js → roy-agent-core-ph5qbqcx.js} +1 -1
- 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-pkpkctvf.js → roy-agent-core-hch2geta.js} +0 -0
- /package/dist/shared/@ai-setting/{roy-agent-core-0cfaqnz9.js → roy-agent-core-k25gv86p.js} +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './edge';
|
|
2
|
+
export * from './workflow';
|
|
3
|
+
export * from './workflow-message';
|
|
4
|
+
export * from './workflow-session';
|
|
5
|
+
export * from './context';
|
|
6
|
+
export * from './workflow-hil';
|
|
7
|
+
export * from './event';
|
|
8
|
+
export * from './run';
|
|
9
|
+
export type { AgentSessionInfo } from './workflow-message';
|
|
10
|
+
export type { AgentSessionRef } from './workflow-session';
|
|
11
|
+
export type { RunStatus, NodeStatus, WorkflowRun, NodeRun, RunOptions, RunResult, NodeExecutionContext, NodeExecutionResult, } from './run';
|
|
12
|
+
export { createNodeExecutionContext } from './run';
|
|
13
|
+
export type { WorkflowDefinition, WorkflowDefinitionExtended, Workflow, WorkflowConfig, WorkflowMetadata, RetryConfig, Node, NodeDefinition, NodeDefinitionSchema, DependsOn, DependsOnSchema, OutputDefinition, OutputDefinitionSchema, InputParameter, WorkflowInputs, } from './workflow';
|
|
14
|
+
export type { TemplateResolver } from '../utils/template-resolver';
|
|
15
|
+
export { WorkflowError, TemplateUnresolvedError, WorkflowValidationError, nodeNotFound, pathNotFound, unresolvedVariable, } from './workflow-error';
|
|
16
|
+
export type { WorkflowErrorContext } from './workflow-error';
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { EventBus } from '../engine/event-bus';
|
|
3
|
+
import type { SessionComponent } from '../../session/session-component';
|
|
4
|
+
import type { TemplateResolver } from '../utils/template-resolver';
|
|
5
|
+
export declare const RunStatusSchema: z.ZodEnum<["idle", "running", "paused", "stopped", "completed", "failed"]>;
|
|
6
|
+
export type RunStatus = z.infer<typeof RunStatusSchema>;
|
|
7
|
+
export declare const NodeStatusSchema: z.ZodEnum<["pending", "scheduled", "started", "running", "completed", "failed", "skipped"]>;
|
|
8
|
+
export type NodeStatus = z.infer<typeof NodeStatusSchema>;
|
|
9
|
+
export interface WorkflowRun {
|
|
10
|
+
id: string;
|
|
11
|
+
workflowId: string;
|
|
12
|
+
workflowName: string;
|
|
13
|
+
status: RunStatus;
|
|
14
|
+
input?: Record<string, any>;
|
|
15
|
+
output?: Record<string, any>;
|
|
16
|
+
error?: string;
|
|
17
|
+
startedAt?: Date;
|
|
18
|
+
pausedAt?: Date;
|
|
19
|
+
resumedAt?: Date;
|
|
20
|
+
stoppedAt?: Date;
|
|
21
|
+
completedAt?: Date;
|
|
22
|
+
durationMs?: number;
|
|
23
|
+
debugMode: boolean;
|
|
24
|
+
parentRunId?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface NodeRun {
|
|
27
|
+
id: string;
|
|
28
|
+
runId: string;
|
|
29
|
+
nodeId: string;
|
|
30
|
+
nodeType: string;
|
|
31
|
+
status: NodeStatus;
|
|
32
|
+
input?: any;
|
|
33
|
+
output?: any;
|
|
34
|
+
error?: string;
|
|
35
|
+
startedAt?: Date;
|
|
36
|
+
completedAt?: Date;
|
|
37
|
+
durationMs?: number;
|
|
38
|
+
retryCount: number;
|
|
39
|
+
}
|
|
40
|
+
export interface RunOptions {
|
|
41
|
+
input?: Record<string, any>;
|
|
42
|
+
debug?: boolean;
|
|
43
|
+
parallelLimit?: number | null;
|
|
44
|
+
timeout?: number | null;
|
|
45
|
+
/** Strict mode: fail on unresolved templates instead of warning */
|
|
46
|
+
strict?: boolean;
|
|
47
|
+
/** Maximum iterations to prevent infinite loops (default: 100) */
|
|
48
|
+
maxIterations?: number;
|
|
49
|
+
/** Enable loop mode to allow re-entry of completed nodes (for workflow cycles) */
|
|
50
|
+
loopEnabled?: boolean;
|
|
51
|
+
/** Global workflow input for condition evaluation */
|
|
52
|
+
workflowInput?: Record<string, unknown>;
|
|
53
|
+
/**
|
|
54
|
+
* Caller-reserved runId for a fresh workflow run.
|
|
55
|
+
*
|
|
56
|
+
* When set, `WorkflowEngine.createSession` uses this runId (instead of
|
|
57
|
+
* calling `generateRunId()`), so the caller can pre-allocate a runId
|
|
58
|
+
* that the tool layer surfaces on every termination path (timeout /
|
|
59
|
+
* abort / error). Task #1837 already established that runId ===
|
|
60
|
+
* sessionId, and Task #2106 closes the gap where the `workflow_run`
|
|
61
|
+
* tool's synthesized fallback runId was shape-compatible but not
|
|
62
|
+
* queryable / stoppable on the engine.
|
|
63
|
+
*
|
|
64
|
+
* Contract:
|
|
65
|
+
* - Must start with `workflow_` (Task #1837 prefix requirement)
|
|
66
|
+
* - Must be unique across all active workflow sessions
|
|
67
|
+
* - On the resume path, callers should pass `sessionId` instead
|
|
68
|
+
*
|
|
69
|
+
* Task #2106 — required by `workflow_run` tool's reserved-ID contract.
|
|
70
|
+
*/
|
|
71
|
+
runId?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Parent session id — when set, the workflow run session will be created
|
|
74
|
+
* with `parentSessionId === parentSessionId`. Used by `workflow_run` tool
|
|
75
|
+
* and `roy-agent workflow run` CLI to track the parent→workflow session
|
|
76
|
+
* hierarchy for `sessions list --graph` (Task #1739).
|
|
77
|
+
*/
|
|
78
|
+
parentSessionId?: string | null;
|
|
79
|
+
/**
|
|
80
|
+
* Session id to resume — when set, the engine re-enters an existing
|
|
81
|
+
* workflow session instead of starting a fresh run. Set by the
|
|
82
|
+
* `workflow_run` tool's `session` field and `roy-agent workflow run --session`
|
|
83
|
+
* CLI to power workflow-runner re-entry into paused/interrupted workflows.
|
|
84
|
+
* (Task #1829)
|
|
85
|
+
*/
|
|
86
|
+
sessionId?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Callback fired immediately after the workflow session is created
|
|
89
|
+
* (or resolved for resume). The sessionId argument is also the
|
|
90
|
+
* runId (Task #1837: runId == sessionId).
|
|
91
|
+
*
|
|
92
|
+
* Use this to capture the runId/sessionId BEFORE execution, so callers
|
|
93
|
+
* can still reference it when execution later times out, aborts, or
|
|
94
|
+
* throws. Without this callback, the tool layer has no way to surface
|
|
95
|
+
* the runId on failure paths (Task #1840).
|
|
96
|
+
*
|
|
97
|
+
* The callback must be safe to call: a throwing callback is caught
|
|
98
|
+
* and logged, but does NOT abort session creation.
|
|
99
|
+
*/
|
|
100
|
+
onSessionCreated?: (sessionId: string) => void;
|
|
101
|
+
/**
|
|
102
|
+
* Per-node runtime config overrides.
|
|
103
|
+
*
|
|
104
|
+
* Keyed by `node.id`. Values are shallow-merged into the node's
|
|
105
|
+
* `nodeDef.config` at buildNodeContext time. Keys present in BOTH
|
|
106
|
+
* nodeDef.config and nodeConfig[nodeId] are taken from nodeConfig
|
|
107
|
+
* (input wins). Unknown node IDs are silently ignored.
|
|
108
|
+
*
|
|
109
|
+
* Common use cases:
|
|
110
|
+
* - `timeout`: per-node execution timeout (ms), overrides engine's
|
|
111
|
+
* global timeout. Read by AgentNode and ToolNode.
|
|
112
|
+
* - `maxIterations`: only honored when loopEnabled=true.
|
|
113
|
+
* - `model`, `allowedTools`, `deniedTools`: forwarded to AgentNode
|
|
114
|
+
* via `options.*`.
|
|
115
|
+
*
|
|
116
|
+
* Task #1974 — Workflow Node-Level Config + Resume + Stop.
|
|
117
|
+
* Backward compatible: when omitted (or empty), engine behavior is
|
|
118
|
+
* unchanged.
|
|
119
|
+
*/
|
|
120
|
+
nodeConfig?: Record<string, Record<string, unknown>>;
|
|
121
|
+
}
|
|
122
|
+
export interface RunResult {
|
|
123
|
+
runId: string;
|
|
124
|
+
/** Session ID — Task #1837: equals runId exactly (no derivation). */
|
|
125
|
+
sessionId?: string;
|
|
126
|
+
status: RunStatus;
|
|
127
|
+
output?: Record<string, any>;
|
|
128
|
+
error?: string;
|
|
129
|
+
durationMs?: number;
|
|
130
|
+
/** Pending node ID (when status is 'paused') */
|
|
131
|
+
pendingNodeId?: string;
|
|
132
|
+
/** Query from ask_user (when status is 'paused') */
|
|
133
|
+
query?: string;
|
|
134
|
+
/** Agent sub-session ID (for resuming agent nodes) */
|
|
135
|
+
agentSessionId?: string;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* 节点执行上下文
|
|
139
|
+
*
|
|
140
|
+
* 扩展后包含:
|
|
141
|
+
* - sessionId: Session ID,用于消息持久化
|
|
142
|
+
* - askUser(): 方法,让节点可以请求用户输入
|
|
143
|
+
*/
|
|
144
|
+
export interface NodeExecutionContext {
|
|
145
|
+
runId: string;
|
|
146
|
+
/** Task #1837: sessionId == runId (runId natively carries workflow_ prefix). */
|
|
147
|
+
sessionId: string;
|
|
148
|
+
workflowName: string;
|
|
149
|
+
nodeId: string;
|
|
150
|
+
input: unknown;
|
|
151
|
+
previousOutputs: Map<string, unknown>;
|
|
152
|
+
nodeOutputs: Map<string, unknown>;
|
|
153
|
+
config: Record<string, unknown>;
|
|
154
|
+
debug: boolean;
|
|
155
|
+
eventBus: EventBus;
|
|
156
|
+
workflowHistory?: Array<{
|
|
157
|
+
role: 'user' | 'assistant' | 'tool';
|
|
158
|
+
content: string;
|
|
159
|
+
toolCallId?: string;
|
|
160
|
+
toolName?: string;
|
|
161
|
+
nodeId?: string;
|
|
162
|
+
}>;
|
|
163
|
+
sessionComponent?: SessionComponent;
|
|
164
|
+
agentSessionId?: string;
|
|
165
|
+
workflowInput?: Record<string, unknown>;
|
|
166
|
+
templateResolver?: TemplateResolver;
|
|
167
|
+
/**
|
|
168
|
+
* Pre-resolved node configuration
|
|
169
|
+
*
|
|
170
|
+
* This is the node's config with all template references resolved
|
|
171
|
+
* using the TemplateResolver. Nodes should use this instead of the
|
|
172
|
+
* raw `config` to avoid duplicate template resolution.
|
|
173
|
+
*
|
|
174
|
+
* Example: A node with config.prompt = "{{nodes.fetch.result}}" will have
|
|
175
|
+
* resolvedConfig.prompt = "The weather is sunny" after resolution.
|
|
176
|
+
*/
|
|
177
|
+
resolvedConfig?: Record<string, unknown>;
|
|
178
|
+
/**
|
|
179
|
+
* 请求用户输入
|
|
180
|
+
*
|
|
181
|
+
* 调用此方法会抛出 AskUserError,引擎捕获后会暂停 workflow
|
|
182
|
+
*
|
|
183
|
+
* @param query - 向用户询问的问题
|
|
184
|
+
* @throws AskUserError - 总是抛出此异常
|
|
185
|
+
*/
|
|
186
|
+
askUser(query: string): never;
|
|
187
|
+
/** Patch agent sub-session id onto latest workflow.node.start (agent nodes) */
|
|
188
|
+
attachAgentSessionToLastStart?(nodeId: string, agentSessionId: string): Promise<void>;
|
|
189
|
+
/**
|
|
190
|
+
* Abort signal for this node's execution (Task #1976).
|
|
191
|
+
*
|
|
192
|
+
* Populated by the workflow executor from its per-node `AbortController`.
|
|
193
|
+
* The signal fires when:
|
|
194
|
+
* 1. The node's timeout elapses (timeoutPromise rejects the race → executor
|
|
195
|
+
* calls `this.cancelNode(nodeId)` which triggers this signal).
|
|
196
|
+
* 2. The user issues `workflow_run_stop` (engine.stop → executor.cancelAll).
|
|
197
|
+
* 3. The retry path on inner-attempt timeout (existing behavior preserved).
|
|
198
|
+
*
|
|
199
|
+
* Nodes SHOULD pass this signal to any long-running async operation they
|
|
200
|
+
* own (e.g. AgentRunner.run, LLM calls, network requests) so that timeout
|
|
201
|
+
* truly cancels the underlying work, not just the engine's wait.
|
|
202
|
+
*
|
|
203
|
+
* Optional for backward compat — nodes that don't opt in still work
|
|
204
|
+
* (their execution will be leaked on timeout, which is the bug this field
|
|
205
|
+
* is designed to fix).
|
|
206
|
+
*/
|
|
207
|
+
abortSignal?: AbortSignal;
|
|
208
|
+
}
|
|
209
|
+
export interface NodeExecutionResult {
|
|
210
|
+
success?: boolean;
|
|
211
|
+
output?: any;
|
|
212
|
+
error?: string | Error;
|
|
213
|
+
duration?: number;
|
|
214
|
+
durationMs?: number;
|
|
215
|
+
metadata?: Record<string, unknown>;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* 创建 NodeExecutionContext
|
|
219
|
+
*/
|
|
220
|
+
export declare function createNodeExecutionContext(params: {
|
|
221
|
+
runId: string;
|
|
222
|
+
workflowName: string;
|
|
223
|
+
nodeId: string;
|
|
224
|
+
input: unknown;
|
|
225
|
+
previousOutputs: Map<string, unknown>;
|
|
226
|
+
nodeOutputs: Map<string, unknown>;
|
|
227
|
+
config: Record<string, unknown>;
|
|
228
|
+
debug: boolean;
|
|
229
|
+
eventBus: EventBus;
|
|
230
|
+
sessionId: string;
|
|
231
|
+
workflowHistory?: NodeExecutionContext['workflowHistory'];
|
|
232
|
+
workflowInput?: Record<string, unknown>;
|
|
233
|
+
templateResolver?: TemplateResolver;
|
|
234
|
+
resolvedConfig?: Record<string, unknown>;
|
|
235
|
+
}): NodeExecutionContext;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Workflow Error Types
|
|
3
|
+
*
|
|
4
|
+
* Defines error classes for workflow template resolution and validation.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
/**
|
|
8
|
+
* Error context schema for structured error data
|
|
9
|
+
*/
|
|
10
|
+
export declare const WorkflowErrorContextSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
11
|
+
export type WorkflowErrorContext = z.infer<typeof WorkflowErrorContextSchema>;
|
|
12
|
+
/**
|
|
13
|
+
* Base workflow error class
|
|
14
|
+
*/
|
|
15
|
+
export declare class WorkflowError extends Error {
|
|
16
|
+
readonly context: WorkflowErrorContext;
|
|
17
|
+
constructor(message: string, context?: WorkflowErrorContext);
|
|
18
|
+
/**
|
|
19
|
+
* Convert error to JSON-serializable object
|
|
20
|
+
*/
|
|
21
|
+
toJSON(): Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Error thrown when template resolution fails due to unresolved templates.
|
|
25
|
+
*
|
|
26
|
+
* This error captures the list of unresolved template strings for debugging
|
|
27
|
+
* and potential user feedback.
|
|
28
|
+
*/
|
|
29
|
+
export declare class TemplateUnresolvedError extends WorkflowError {
|
|
30
|
+
/**
|
|
31
|
+
* List of template strings that could not be resolved
|
|
32
|
+
*/
|
|
33
|
+
readonly unresolved: string[];
|
|
34
|
+
constructor(message: string, unresolved?: string[], context?: WorkflowErrorContext);
|
|
35
|
+
toJSON(): Record<string, unknown>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Error thrown when workflow definition validation fails.
|
|
39
|
+
*
|
|
40
|
+
* This includes validation of node configurations, input schemas,
|
|
41
|
+
* output definitions, and edge connections.
|
|
42
|
+
*/
|
|
43
|
+
export declare class WorkflowValidationError extends WorkflowError {
|
|
44
|
+
/**
|
|
45
|
+
* The field or path that failed validation
|
|
46
|
+
*/
|
|
47
|
+
readonly field: string;
|
|
48
|
+
/**
|
|
49
|
+
* The invalid value that was provided
|
|
50
|
+
*/
|
|
51
|
+
readonly invalidValue: unknown;
|
|
52
|
+
constructor(message: string, field: string, invalidValue?: unknown);
|
|
53
|
+
toJSON(): Record<string, unknown>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Create a TemplateUnresolvedError for when a referenced node is not found.
|
|
57
|
+
*
|
|
58
|
+
* @param referencedNodeId - The referenced node ID that was not found
|
|
59
|
+
* @param unresolved - List of template strings referencing the node
|
|
60
|
+
* @returns TemplateUnresolvedError instance
|
|
61
|
+
*/
|
|
62
|
+
export declare function nodeNotFound(referencedNodeId: string, unresolved: string[]): TemplateUnresolvedError;
|
|
63
|
+
/**
|
|
64
|
+
* Create a TemplateUnresolvedError for when a path within a node's output is not found.
|
|
65
|
+
*
|
|
66
|
+
* @param referencedNodeId - The referenced node ID
|
|
67
|
+
* @param path - The path that was not found
|
|
68
|
+
* @param template - The template string that referenced this path
|
|
69
|
+
* @returns TemplateUnresolvedError instance
|
|
70
|
+
*/
|
|
71
|
+
export declare function pathNotFound(referencedNodeId: string, path: string, template: string): TemplateUnresolvedError;
|
|
72
|
+
/**
|
|
73
|
+
* Create a TemplateUnresolvedError for an unresolved variable reference.
|
|
74
|
+
*
|
|
75
|
+
* @param template - The unresolved template string
|
|
76
|
+
* @param path - The path that could not be resolved
|
|
77
|
+
* @returns TemplateUnresolvedError instance
|
|
78
|
+
*/
|
|
79
|
+
export declare function unresolvedVariable(template: string, path?: string): TemplateUnresolvedError;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Human-in-Loop (HIL) types for workflow
|
|
3
|
+
*
|
|
4
|
+
* This module contains types and utilities for human-in-loop functionality:
|
|
5
|
+
* - NodeInterruptEvent: Event when a node needs human input
|
|
6
|
+
* - WorkflowAskUserEvent: Event when the workflow needs human confirmation
|
|
7
|
+
* - AskUserError: Error thrown when a node requests user input
|
|
8
|
+
*/
|
|
9
|
+
import type { BaseEvent } from './event';
|
|
10
|
+
/**
|
|
11
|
+
* Node 中断事件 - 节点等待用户输入
|
|
12
|
+
*/
|
|
13
|
+
export interface NodeInterruptEvent extends BaseEvent {
|
|
14
|
+
type: 'node.interrupt';
|
|
15
|
+
node_id: string;
|
|
16
|
+
node_type: string;
|
|
17
|
+
query: string;
|
|
18
|
+
/** Agent sub-session ID (for agent nodes that need resume) */
|
|
19
|
+
agent_session_id?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Workflow Ask User 事件 - Workflow 等待用户输入
|
|
23
|
+
*/
|
|
24
|
+
export interface WorkflowAskUserEvent extends BaseEvent {
|
|
25
|
+
type: 'workflow.ask-user';
|
|
26
|
+
session_id: string;
|
|
27
|
+
node_id: string;
|
|
28
|
+
node_type: string;
|
|
29
|
+
query: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 创建 NodeInterruptEvent
|
|
33
|
+
*/
|
|
34
|
+
export declare function createNodeInterruptEvent(runId: string, nodeId: string, nodeType: string, query: string, agentSessionId?: string): NodeInterruptEvent;
|
|
35
|
+
/**
|
|
36
|
+
* 创建 WorkflowAskUserEvent
|
|
37
|
+
*/
|
|
38
|
+
export declare function createWorkflowAskUserEvent(runId: string, sessionId: string, nodeId: string, nodeType: string, query: string): WorkflowAskUserEvent;
|
|
39
|
+
/**
|
|
40
|
+
* AskUserError - 当节点调用 askUser() 时抛出
|
|
41
|
+
*/
|
|
42
|
+
export declare class AskUserError extends Error {
|
|
43
|
+
readonly runId: string;
|
|
44
|
+
readonly sessionId: string;
|
|
45
|
+
readonly nodeId: string;
|
|
46
|
+
readonly nodeType: string;
|
|
47
|
+
readonly query: string;
|
|
48
|
+
readonly agentSessionId?: string | undefined;
|
|
49
|
+
readonly timestamp: number;
|
|
50
|
+
readonly type = "ask-user";
|
|
51
|
+
readonly name = "AskUserError";
|
|
52
|
+
constructor(runId: string, sessionId: string, nodeId: string, nodeType: string, query: string, agentSessionId?: string | undefined, timestamp?: number);
|
|
53
|
+
/**
|
|
54
|
+
* 转换为 WorkflowAskUserEvent
|
|
55
|
+
*/
|
|
56
|
+
toEvent(): WorkflowAskUserEvent;
|
|
57
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Workflow 节点执行消息角色类型
|
|
4
|
+
*
|
|
5
|
+
* 设计原则:
|
|
6
|
+
* - workflow.node.start: 对应 tool-call,节点开始执行
|
|
7
|
+
* - workflow.node.interrupt: 节点中断等待用户输入
|
|
8
|
+
* - workflow.node.end: 对应 tool-result,节点执行结束
|
|
9
|
+
* - workflow.node.resume: 用户响应后恢复节点执行
|
|
10
|
+
*/
|
|
11
|
+
export declare const WorkflowMessageRoleSchema: z.ZodEnum<["workflow.node.start", "workflow.node.interrupt", "workflow.node.end", "workflow.node.resume"]>;
|
|
12
|
+
export type WorkflowMessageRole = z.infer<typeof WorkflowMessageRoleSchema>;
|
|
13
|
+
/**
|
|
14
|
+
* workflow.node.start 消息 part
|
|
15
|
+
* 对应 tool-call,节点开始执行
|
|
16
|
+
*/
|
|
17
|
+
export interface WorkflowNodeStartPart {
|
|
18
|
+
type: 'workflow-node-start';
|
|
19
|
+
nodeId: string;
|
|
20
|
+
nodeType: string;
|
|
21
|
+
input?: unknown;
|
|
22
|
+
startTime: number;
|
|
23
|
+
/** Agent session ID (only for agent nodes) */
|
|
24
|
+
agentSessionId?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* workflow.node.interrupt 消息 part
|
|
28
|
+
* 节点中断等待用户输入
|
|
29
|
+
*/
|
|
30
|
+
export interface WorkflowNodeInterruptPart {
|
|
31
|
+
type: 'workflow-node-interrupt';
|
|
32
|
+
nodeId: string;
|
|
33
|
+
nodeType: string;
|
|
34
|
+
query: string;
|
|
35
|
+
timestamp: number;
|
|
36
|
+
/** Agent session ID (only for agent nodes) - 用于恢复 agent 子会话 */
|
|
37
|
+
agentSessionId?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* workflow.node.end 消息 part
|
|
41
|
+
* 对应 tool-result,节点执行结束
|
|
42
|
+
*/
|
|
43
|
+
export interface WorkflowNodeEndPart {
|
|
44
|
+
type: 'workflow-node-end';
|
|
45
|
+
nodeId: string;
|
|
46
|
+
nodeType: string;
|
|
47
|
+
output?: unknown;
|
|
48
|
+
error?: string;
|
|
49
|
+
durationMs: number;
|
|
50
|
+
/** Agent session ID (only for agent nodes) */
|
|
51
|
+
agentSessionId?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* workflow.node.resume 消息 part
|
|
55
|
+
* 用户响应后恢复节点执行
|
|
56
|
+
*/
|
|
57
|
+
export interface WorkflowNodeResumePart {
|
|
58
|
+
type: 'workflow-node-resume';
|
|
59
|
+
nodeId: string;
|
|
60
|
+
response: string;
|
|
61
|
+
timestamp: number;
|
|
62
|
+
/** Agent session ID (only for agent nodes) */
|
|
63
|
+
agentSessionId?: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* workflow 消息 part 联合类型
|
|
67
|
+
*/
|
|
68
|
+
export type WorkflowMessagePart = WorkflowNodeStartPart | WorkflowNodeInterruptPart | WorkflowNodeEndPart | WorkflowNodeResumePart;
|
|
69
|
+
/**
|
|
70
|
+
* Workflow Session 元数据(简化版)
|
|
71
|
+
*
|
|
72
|
+
* 简化原则:只保留必要字段,其他信息从 messages 推断
|
|
73
|
+
*
|
|
74
|
+
* 设计原则(Task #1837):
|
|
75
|
+
* - sessionId 直接作为 runId 使用(runId 天然带 workflow_ 前缀)
|
|
76
|
+
* - Session.metadata.status 跟踪运行状态
|
|
77
|
+
* - Session.messages 按时间顺序记录节点执行状态
|
|
78
|
+
* - Next node 从 messages 推断(最后一条消息决定恢复点)
|
|
79
|
+
*/
|
|
80
|
+
export interface WorkflowSessionMetadata {
|
|
81
|
+
type: 'workflow';
|
|
82
|
+
/** Used to load workflow definition */
|
|
83
|
+
workflowId: string;
|
|
84
|
+
/** Display name */
|
|
85
|
+
workflowName: string;
|
|
86
|
+
/** Workflow 版本 (可选) */
|
|
87
|
+
workflowVersion?: string;
|
|
88
|
+
/** Execution status */
|
|
89
|
+
status: 'running' | 'paused' | 'completed' | 'failed' | 'stopped';
|
|
90
|
+
/** Run id — Task #1837: equals sessionId exactly. Kept for backward compat with older session records. */
|
|
91
|
+
runId?: string;
|
|
92
|
+
/** Workflow input (fresh + resume merged) */
|
|
93
|
+
input?: unknown;
|
|
94
|
+
/** Timestamps and lifecycle */
|
|
95
|
+
startedAt?: number;
|
|
96
|
+
completedAt?: number;
|
|
97
|
+
failedAt?: number;
|
|
98
|
+
durationMs?: number;
|
|
99
|
+
/** Final workflow output summary */
|
|
100
|
+
output?: Record<string, unknown>;
|
|
101
|
+
/** Pause/resume hints */
|
|
102
|
+
pendingNodeId?: string;
|
|
103
|
+
pauseReason?: 'ask_user' | string;
|
|
104
|
+
/** Agent sub-session refs */
|
|
105
|
+
agentSessions?: AgentSessionRef[];
|
|
106
|
+
/** Allow additional properties for metadata extension */
|
|
107
|
+
[key: string]: unknown;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Agent Session 引用(存储在 workflow session metadata 中)
|
|
111
|
+
*/
|
|
112
|
+
export interface AgentSessionRef {
|
|
113
|
+
nodeId: string;
|
|
114
|
+
sessionId: string;
|
|
115
|
+
/**
|
|
116
|
+
* Agent session 状态
|
|
117
|
+
* - 'active': 节点正在执行
|
|
118
|
+
* - 'paused': 节点因 ask_user 中断暂停(可恢复)
|
|
119
|
+
* - 'completed': 节点成功完成
|
|
120
|
+
* - 'failed': 节点执行失败
|
|
121
|
+
* - 'stopped': 节点因 workflow.stop() 强制终止
|
|
122
|
+
*/
|
|
123
|
+
status: 'active' | 'paused' | 'completed' | 'failed' | 'stopped';
|
|
124
|
+
createdAt?: number;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* workflow.node.start 消息元数据
|
|
128
|
+
* 对应 tool-call
|
|
129
|
+
*/
|
|
130
|
+
export interface WorkflowNodeStartMetadata {
|
|
131
|
+
type: 'workflow.node.start';
|
|
132
|
+
/** Canonical node id (alias of workflowNodeId) */
|
|
133
|
+
nodeId: string;
|
|
134
|
+
workflowNodeId: string;
|
|
135
|
+
workflowNodeType: string;
|
|
136
|
+
/** Agent session ID (only for agent nodes) */
|
|
137
|
+
agentSessionId?: string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* workflow.node.interrupt 消息元数据
|
|
141
|
+
*/
|
|
142
|
+
export interface WorkflowNodeInterruptMetadata {
|
|
143
|
+
type: 'workflow.node.interrupt';
|
|
144
|
+
nodeId: string;
|
|
145
|
+
workflowNodeId: string;
|
|
146
|
+
workflowNodeType: string;
|
|
147
|
+
query: string;
|
|
148
|
+
/** Agent session ID (only for agent nodes) */
|
|
149
|
+
agentSessionId?: string;
|
|
150
|
+
timestamp?: number;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* workflow.node.end 消息元数据
|
|
154
|
+
* 对应 tool-result
|
|
155
|
+
*/
|
|
156
|
+
export interface WorkflowNodeEndMetadata {
|
|
157
|
+
type: 'workflow.node.end';
|
|
158
|
+
nodeId: string;
|
|
159
|
+
workflowNodeId: string;
|
|
160
|
+
workflowNodeType: string;
|
|
161
|
+
success: boolean;
|
|
162
|
+
agentSessionId?: string;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* workflow.node.resume 消息元数据
|
|
166
|
+
*/
|
|
167
|
+
export interface WorkflowNodeResumeMetadata {
|
|
168
|
+
type: 'workflow.node.resume';
|
|
169
|
+
nodeId: string;
|
|
170
|
+
workflowNodeId: string;
|
|
171
|
+
workflowNodeType: string;
|
|
172
|
+
response: string;
|
|
173
|
+
/** Agent session ID (only for agent nodes) */
|
|
174
|
+
agentSessionId?: string;
|
|
175
|
+
timestamp?: number;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* workflow 消息元数据联合类型
|
|
179
|
+
*/
|
|
180
|
+
export type WorkflowMessageMetadata = WorkflowNodeStartMetadata | WorkflowNodeInterruptMetadata | WorkflowNodeEndMetadata | WorkflowNodeResumeMetadata;
|
|
181
|
+
/**
|
|
182
|
+
* Agent Session 信息(存储在 workflow message metadata 中)
|
|
183
|
+
*/
|
|
184
|
+
export interface AgentSessionInfo {
|
|
185
|
+
/** Agent session ID */
|
|
186
|
+
sessionId: string;
|
|
187
|
+
/** Node ID */
|
|
188
|
+
nodeId: string;
|
|
189
|
+
/** 创建时间 */
|
|
190
|
+
createdAt: number;
|
|
191
|
+
}
|
|
192
|
+
export { AskUserError, createNodeInterruptEvent, createWorkflowAskUserEvent, } from './workflow-hil';
|
|
193
|
+
export type { NodeInterruptEvent, WorkflowAskUserEvent, } from './workflow-hil';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { WorkflowSessionMetadata } from './workflow-message';
|
|
2
|
+
export type { WorkflowSessionMetadata } from './workflow-message';
|
|
3
|
+
export type { AgentSessionRef } from './workflow-message';
|
|
4
|
+
/**
|
|
5
|
+
* 检查 SessionMetadata 是否为 Workflow 类型
|
|
6
|
+
*
|
|
7
|
+
* 简化验证:只检查必要字段存在性
|
|
8
|
+
* - type === 'workflow'
|
|
9
|
+
* - workflowId 存在
|
|
10
|
+
* - workflowName 存在
|
|
11
|
+
* - status 存在且为有效值
|
|
12
|
+
*/
|
|
13
|
+
export declare function isWorkflowSessionMetadata(metadata: unknown): metadata is WorkflowSessionMetadata;
|
|
14
|
+
/**
|
|
15
|
+
* 获取 workflow session 的状态
|
|
16
|
+
*/
|
|
17
|
+
export declare function getWorkflowSessionStatus(metadata: WorkflowSessionMetadata): 'running' | 'paused' | 'completed' | 'failed' | 'stopped';
|