@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,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build AgentNode execution output, flattening JSON fields for template access.
|
|
3
|
+
*
|
|
4
|
+
* When output.mode=json, the structured JSON is extracted from agentResult.structuredOutput
|
|
5
|
+
* (populated by workflow-json-output-plugin via json-extract sub-agent tool call).
|
|
6
|
+
* Individual JSON fields are spread so downstream nodes can reference them directly:
|
|
7
|
+
* {{nodes.foo.output.field}} rather than {{nodes.foo.output.result.field}}
|
|
8
|
+
*/
|
|
9
|
+
import type { AgentResult } from '../nodes/agent-node';
|
|
10
|
+
import type { AgentOutputConfig } from './parse-agent-output-config';
|
|
11
|
+
export declare function buildAgentNodeOutput(agentResult: AgentResult, outputConfig: AgentOutputConfig): Record<string, unknown>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 便捷函数:createWorkflowFromClass
|
|
3
|
+
*/
|
|
4
|
+
import type { ConvertedWorkflowDefinition } from '../types/decorators-types';
|
|
5
|
+
/**
|
|
6
|
+
* 从装饰器类创建 WorkflowDefinition
|
|
7
|
+
*
|
|
8
|
+
* 这是最常用的便捷函数,自动处理实例创建和转换
|
|
9
|
+
*
|
|
10
|
+
* @param targetClass - 使用 @Workflow 装饰的类
|
|
11
|
+
* @param options - 可选配置
|
|
12
|
+
* @returns WorkflowDefinition
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* @Workflow({ name: 'my-workflow', entry: 'start' })
|
|
17
|
+
* class MyWorkflow {
|
|
18
|
+
* @NodeAs({ nodeId: 'start' })
|
|
19
|
+
* async start() { return { done: true }; }
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* // 方式一:自动创建实例
|
|
23
|
+
* const workflow = createWorkflowFromClass(MyWorkflow);
|
|
24
|
+
*
|
|
25
|
+
* // 方式二:传入自定义实例
|
|
26
|
+
* const myInstance = new MyWorkflow(customDep);
|
|
27
|
+
* const workflow = createWorkflowFromClass(MyWorkflow, { instance: myInstance });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function createWorkflowFromClass(targetClass: new (...args: any[]) => any, options?: {
|
|
31
|
+
/** 自定义实例,不传则自动创建 */
|
|
32
|
+
instance?: any;
|
|
33
|
+
/** 构造函数参数 */
|
|
34
|
+
constructorArgs?: any[];
|
|
35
|
+
}): ConvertedWorkflowDefinition;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Workflow 依赖前置检查 (Step 6.0.5 of roy-rd-with-trace v1.3.0)
|
|
3
|
+
*
|
|
4
|
+
* 在 cli-e2e-test 节点的 build/test/cli_smoke/trace_check 之前,对任务涉及的
|
|
5
|
+
* workflow YAML 文件做 4 类静态依赖一致性检查:
|
|
6
|
+
*
|
|
7
|
+
* 1. checkDependsOnNodesExist — depends_on 节点 ID 是否都存在
|
|
8
|
+
* 2. checkEdgesNodesExist — edges from/to 节点 ID 是否都存在
|
|
9
|
+
* 3. checkEdgesDependsOnConsistency — edges 目标节点的 depends_on 是否包含 from (fan-out/fan-in 反模式)
|
|
10
|
+
* 4. checkEntryNodeExists — entry 节点是否存在
|
|
11
|
+
*
|
|
12
|
+
* 任何一个 FAIL → cli_e2e_status = "FAIL",fail-fast。
|
|
13
|
+
*
|
|
14
|
+
* Task #2241 — v1.3.0 新增(Plan: docs/superpowers/plans/2026-07-21-fix-workflow-parallel-deps-reverify-plan.md)
|
|
15
|
+
*/
|
|
16
|
+
import type { WorkflowDefinition } from '../types/workflow';
|
|
17
|
+
/**
|
|
18
|
+
* A single finding from prescan.
|
|
19
|
+
*/
|
|
20
|
+
export interface PrescanFinding {
|
|
21
|
+
checkName: 'checkDependsOnNodesExist' | 'checkEdgesNodesExist' | 'checkEdgesDependsOnConsistency' | 'checkEntryNodeExists';
|
|
22
|
+
severity: 'FAIL' | 'WARN';
|
|
23
|
+
message: string;
|
|
24
|
+
nodeIds?: string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Aggregate result of prescan.
|
|
28
|
+
*/
|
|
29
|
+
export interface PrescanResult {
|
|
30
|
+
ok: boolean;
|
|
31
|
+
findings: PrescanFinding[];
|
|
32
|
+
}
|
|
33
|
+
declare function _prescanWorkflowImpl(workflow: WorkflowDefinition): PrescanResult;
|
|
34
|
+
declare function _checkDependsOnNodesExistImpl(workflow: WorkflowDefinition, nodeIds: Set<string>): PrescanFinding[];
|
|
35
|
+
declare function _checkEdgesNodesExistImpl(workflow: WorkflowDefinition, nodeIds: Set<string>): PrescanFinding[];
|
|
36
|
+
declare function _checkEdgesDependsOnConsistencyImpl(workflow: WorkflowDefinition, _nodeIds: Set<string>): PrescanFinding[];
|
|
37
|
+
declare function _checkEntryNodeExistsImpl(workflow: WorkflowDefinition, nodeIds: Set<string>): PrescanFinding[];
|
|
38
|
+
/**
|
|
39
|
+
* Main entry: prescan a workflow definition object.
|
|
40
|
+
*/
|
|
41
|
+
export declare const prescanWorkflow: typeof _prescanWorkflowImpl;
|
|
42
|
+
/**
|
|
43
|
+
* Check 1: every depends_on reference resolves to an existing node ID.
|
|
44
|
+
*/
|
|
45
|
+
export declare const checkDependsOnNodesExist: typeof _checkDependsOnNodesExistImpl;
|
|
46
|
+
/**
|
|
47
|
+
* Check 2: every edge from/to resolves to an existing node ID.
|
|
48
|
+
*/
|
|
49
|
+
export declare const checkEdgesNodesExist: typeof _checkEdgesNodesExistImpl;
|
|
50
|
+
/**
|
|
51
|
+
* Check 3: for every edge from → to, target node declares from in depends_on.
|
|
52
|
+
* This catches the fan-out/fan-in anti-pattern where edges trigger downstream
|
|
53
|
+
* but the downstream's depends_on declaration doesn't include the source.
|
|
54
|
+
*/
|
|
55
|
+
export declare const checkEdgesDependsOnConsistency: typeof _checkEdgesDependsOnConsistencyImpl;
|
|
56
|
+
/**
|
|
57
|
+
* Check 4: the entry node must exist in the nodes list.
|
|
58
|
+
* (Only checked when entry is a string; arrays are skipped — array entry is
|
|
59
|
+
* considered advanced and not covered by this fail-fast rule.)
|
|
60
|
+
*/
|
|
61
|
+
export declare const checkEntryNodeExists: typeof _checkEntryNodeExistsImpl;
|
|
62
|
+
/**
|
|
63
|
+
* Load a workflow YAML file from disk and run prescan.
|
|
64
|
+
* Convenience wrapper for Step 6.0.5 CLI invocation.
|
|
65
|
+
*/
|
|
66
|
+
export declare function prescanWorkflowFile(path: string): PrescanResult;
|
|
67
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execution State Builder
|
|
3
|
+
*
|
|
4
|
+
* Builds execution state from session messages and workflow definition.
|
|
5
|
+
*/
|
|
6
|
+
import type { WorkflowDefinition } from '../types';
|
|
7
|
+
import type { SessionMessage } from '../../session/types';
|
|
8
|
+
import type { ExecutionState } from './validation-rules';
|
|
9
|
+
/**
|
|
10
|
+
* Builder for constructing ExecutionState from session data
|
|
11
|
+
*/
|
|
12
|
+
export declare class ExecutionStateBuilder {
|
|
13
|
+
build(messages: SessionMessage[], definition: WorkflowDefinition): ExecutionState;
|
|
14
|
+
/**
|
|
15
|
+
* Parse session messages to extract node states and outputs
|
|
16
|
+
*/
|
|
17
|
+
private parseMessages;
|
|
18
|
+
/**
|
|
19
|
+
* Build pending nodes from workflow definition
|
|
20
|
+
*/
|
|
21
|
+
private buildPendingNodes;
|
|
22
|
+
/**
|
|
23
|
+
* Get entry nodes from workflow definition
|
|
24
|
+
*/
|
|
25
|
+
private getEntryNodes;
|
|
26
|
+
/**
|
|
27
|
+
* Mark all nodes as pending starting from a given node
|
|
28
|
+
*/
|
|
29
|
+
private markPendingFromNode;
|
|
30
|
+
/**
|
|
31
|
+
* Get direct children of a node
|
|
32
|
+
*/
|
|
33
|
+
private getDirectChildren;
|
|
34
|
+
/**
|
|
35
|
+
* Extract input from a workflow.node.call message
|
|
36
|
+
*/
|
|
37
|
+
private extractInput;
|
|
38
|
+
/**
|
|
39
|
+
* Extract output from a workflow.node.result message
|
|
40
|
+
*/
|
|
41
|
+
private extractOutput;
|
|
42
|
+
/**
|
|
43
|
+
* Extract variables from node output and add to state
|
|
44
|
+
*/
|
|
45
|
+
private extractVariables;
|
|
46
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract structured JSON output from agent result (tool submission only).
|
|
3
|
+
*/
|
|
4
|
+
import type { AgentResult } from '../nodes/agent-node';
|
|
5
|
+
import type { JsonSchemaObject } from './json-schema-to-zod';
|
|
6
|
+
export declare function extractAgentJsonOutput(agentResult: AgentResult, schema?: JsonSchemaObject): Record<string, unknown> | undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow Utilities
|
|
3
|
+
*/
|
|
4
|
+
export { TemplateResolver, resolveTemplates, resolveTemplateString } from './template-resolver';
|
|
5
|
+
export type { TemplateResolverOptions, ResolvedValue } from './template-resolver';
|
|
6
|
+
export { getFromMapWithNormalization } from './node-id-utils';
|
|
7
|
+
export { validateWorkflowDefinition, type ValidateWorkflowResult, type ValidateWorkflowOptions, } from './validate-workflow-definition';
|
|
8
|
+
export { validateTemplateContracts, getTemplateContractErrors, getTemplateContractWarnings, formatTemplateContractFindings, type TemplateContractFinding, type TemplateContractRule, type TemplateContractSeverity, } from './template-contract-validator';
|
|
9
|
+
export { NODE_OUTPUT_CONTRACTS, VIRTUAL_OUTPUT_FIELD, RESULT_INVALID_NODE_TYPES, getNodeOutputContract, hasClosedOutputContract, getAgentDeclaredJsonFields, type NodeOutputContract, } from './node-output-contracts';
|
|
10
|
+
export { RecoveryValidator } from './recovery-validator';
|
|
11
|
+
export { ExecutionStateBuilder } from './execution-state';
|
|
12
|
+
export { ValidationErrorType, SuggestedAction, } from './validation-rules';
|
|
13
|
+
export type { ValidationError, ValidationResult, RecoveryPlan, ExecutionState, } from './validation-rules';
|
|
14
|
+
export { sanitizeWorkflowDefinition, sanitizeShellScript, } from './workflow-sanitize';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal JSON Schema → Zod converter for workflow agent output schemas.
|
|
3
|
+
* Supports object types with boolean, string, number, and integer properties.
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
export interface JsonSchemaObject {
|
|
7
|
+
type?: string;
|
|
8
|
+
properties?: Record<string, JsonSchemaProperty>;
|
|
9
|
+
required?: string[];
|
|
10
|
+
}
|
|
11
|
+
export interface JsonSchemaProperty {
|
|
12
|
+
type?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
items?: JsonSchemaProperty;
|
|
15
|
+
properties?: Record<string, JsonSchemaProperty>;
|
|
16
|
+
required?: string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Validate workflow AgentNode output.schema at config parse time (YAML load path).
|
|
20
|
+
* Only supports the minimal JSON Schema subset used by jsonSchemaToZod.
|
|
21
|
+
*/
|
|
22
|
+
export declare function validateJsonOutputSchema(schema: unknown): JsonSchemaObject;
|
|
23
|
+
export declare function jsonSchemaToZod(schema: JsonSchemaObject): z.ZodObject<z.ZodRawShape>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Node ID utility functions
|
|
3
|
+
*
|
|
4
|
+
* Provides shared utilities for node ID handling, including
|
|
5
|
+
* hyphen/underscore normalization for flexible node ID matching.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Get a value from a Map with hyphen/underscore normalization.
|
|
9
|
+
*
|
|
10
|
+
* First tries exact match, then tries replacing hyphens with underscores,
|
|
11
|
+
* then tries replacing underscores with hyphens.
|
|
12
|
+
*
|
|
13
|
+
* This handles cases where workflow defines a node with underscore but
|
|
14
|
+
* a template uses hyphen, or vice versa.
|
|
15
|
+
*
|
|
16
|
+
* @param map - The Map to search in
|
|
17
|
+
* @param key - The key to look up
|
|
18
|
+
* @returns The value if found, undefined otherwise
|
|
19
|
+
*/
|
|
20
|
+
export declare function getFromMapWithNormalization<V>(map: Map<string, V>, key: string): V | undefined;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Node output contracts — what a node's stored output looks like
|
|
3
|
+
* at runtime, expressed as the set of first-level fields that a downstream
|
|
4
|
+
* template (`{{nodes.<id>.<field>}}`) can legally navigate into.
|
|
5
|
+
*
|
|
6
|
+
* ## Why this exists (Task #4296 / #4298)
|
|
7
|
+
*
|
|
8
|
+
* A real incident: `wheels-validate-v1` v1.3.0 shipped a workflow whose final
|
|
9
|
+
* `report-results` (agent) node built its prompt from
|
|
10
|
+
* `{{nodes.run-validation-tests.result}}`. But `run-validation-tests` is a
|
|
11
|
+
* **tool** node, and the workflow engine stores `result.output` into
|
|
12
|
+
* `sessionState.nodeOutputs` (engine.ts `nodeOutputs.set(nodeId, result.output)`),
|
|
13
|
+
* i.e. the stored value is the tool's *output*, **never** a `{ result, ... }`
|
|
14
|
+
* envelope.
|
|
15
|
+
*
|
|
16
|
+
* Consequences of the mismatch (all silent):
|
|
17
|
+
* - `template-resolver.navigateTokens()` does property access on a string → `undefined`
|
|
18
|
+
* - `stringify(undefined)` → `''` (Task #2912 behavior)
|
|
19
|
+
* - the engine's non-strict pre-execute validation only `warn`s
|
|
20
|
+
* (`Node "report-results" has unresolved templates: [...]`)
|
|
21
|
+
*
|
|
22
|
+
* Net effect: the agent received an empty string, mis-judged the run and wrote
|
|
23
|
+
* 0/0/0 while the workflow reported `completed`. Nothing failed, nothing was
|
|
24
|
+
* blocked — the definition was semantically wrong but structurally fine.
|
|
25
|
+
*
|
|
26
|
+
* This module supplies the missing *semantic* contract so `workflow_validate`
|
|
27
|
+
* can reject such definitions up-front with an actionable message.
|
|
28
|
+
*
|
|
29
|
+
* ## The contract table (derived from source, not guessed)
|
|
30
|
+
*
|
|
31
|
+
* Every node's `execute()` returns a `NodeExecutionResult`
|
|
32
|
+
* (`{ success?, output, error?, durationMs?/duration? }`) — see
|
|
33
|
+
* `types/run.ts` `NodeExecutionResult`. The engine then stores **only
|
|
34
|
+
* `result.output`** into the shared outputs map. Therefore the fields a
|
|
35
|
+
* downstream template can reach are the fields of that *inner* `output` value
|
|
36
|
+
* (plus the virtual `.output` prefix, which `template-resolver` treats as
|
|
37
|
+
* "unwrap the stored value").
|
|
38
|
+
*
|
|
39
|
+
* | node type | node returns (`output`) | reachable first-level fields |
|
|
40
|
+
* |----------------|-----------------------------------------------|-------------------------------------|
|
|
41
|
+
* | `tool` | tool result (`output`, usually a string) | `output` |
|
|
42
|
+
* | `python_call` | JSON-parsed stdout (object / scalar / string) | `output` |
|
|
43
|
+
* | `skill` | `skill.invoke()` return value | `output` |
|
|
44
|
+
* | `condition` | `{ success, condition }` | `output`, `success`, `condition` |
|
|
45
|
+
* | `merge` | `{ strategy, results, count }` | `output`, `strategy`, `results`, `count` |
|
|
46
|
+
* | `agent` | `{ result, metadata, workflowHistory, ...json }` | `result`, `output`, `metadata`, `workflowHistory`, + declared JSON schema fields |
|
|
47
|
+
* | `workflow` | child workflow's top-level output (unknown) | `output`, `result` (both tolerated) |
|
|
48
|
+
* | `ask_user` | never returns (always throws to pause) | (none) |
|
|
49
|
+
*
|
|
50
|
+
* Source anchors:
|
|
51
|
+
* - `tool-node.ts` (returns `{ output: extractedOutput, error, durationMs }`)
|
|
52
|
+
* - `python-call-node.ts` (`{ output, error: undefined, durationMs }`)
|
|
53
|
+
* - `skill-node.ts` (`{ output, error: undefined, durationMs }`)
|
|
54
|
+
* - `condition-node.ts` (`output: { success, condition }`)
|
|
55
|
+
* - `merge-node.ts` (`output: { strategy, results, count }`)
|
|
56
|
+
* - `agent-node.ts` + `build-agent-node-output.ts` (`{ result, ...json }`)
|
|
57
|
+
* - `workflow-node.ts` (`output: result.output` of the child run)
|
|
58
|
+
*/
|
|
59
|
+
/** Fields that are always reachable because `.output` is a virtual prefix
|
|
60
|
+
* (template-resolver treats `{{nodes.X.output}}` as "unwrap the stored value"). */
|
|
61
|
+
export declare const VIRTUAL_OUTPUT_FIELD = "output";
|
|
62
|
+
export interface NodeOutputContract {
|
|
63
|
+
/**
|
|
64
|
+
* First-level fields reachable via `{{nodes.<id>.<field>}}` **in addition to**
|
|
65
|
+
* the virtual `output` prefix (`VIRTUAL_OUTPUT_FIELD` is always allowed).
|
|
66
|
+
*/
|
|
67
|
+
fields: string[];
|
|
68
|
+
/**
|
|
69
|
+
* `true` when the field set is *closed* — i.e. any other first-level field is
|
|
70
|
+
* provably unresolvable at runtime and should be flagged.
|
|
71
|
+
* `false` when the shape is open/unknown (agent free-text, child workflow),
|
|
72
|
+
* in which case only a best-effort hint is produced.
|
|
73
|
+
*/
|
|
74
|
+
closed: boolean;
|
|
75
|
+
/** Human-readable description of the stored value, used in error messages. */
|
|
76
|
+
description: string;
|
|
77
|
+
/**
|
|
78
|
+
* Suggested replacement field when an unresolvable one is referenced. Used to
|
|
79
|
+
* mint the "Did you mean ...?" hint.
|
|
80
|
+
*
|
|
81
|
+
* Note: for `.result` misuse on a *structured* node (condition / merge) the
|
|
82
|
+
* validator prefers `canonicalField` over this generic fallback — see
|
|
83
|
+
* `getSuggestionFieldForResultMisuse()`.
|
|
84
|
+
*/
|
|
85
|
+
suggestedField?: string;
|
|
86
|
+
/**
|
|
87
|
+
* The field that actually carries the node's *answer* (CV-4298 P2#2). Used to
|
|
88
|
+
* make the "Did you mean ...?" hint point at the useful field rather than the
|
|
89
|
+
* generic `.output` wrapper.
|
|
90
|
+
*
|
|
91
|
+
* e.g. a `condition` node's answer is `.condition`; a `merge` node's is
|
|
92
|
+
* `.results`. Leaving it undefined means "no better answer than `.output`".
|
|
93
|
+
*/
|
|
94
|
+
canonicalField?: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Canonical contracts keyed by node `type`.
|
|
98
|
+
*
|
|
99
|
+
* NOTE on `python_call`: the YAML type token is `pythonCall` in some docs but
|
|
100
|
+
* the registered node type is `python_call` (`python-call-node.ts`:
|
|
101
|
+
* `readonly type = 'python_call'`). Both spellings are registered here so the
|
|
102
|
+
* validator is robust to either.
|
|
103
|
+
*/
|
|
104
|
+
export declare const NODE_OUTPUT_CONTRACTS: Record<string, NodeOutputContract>;
|
|
105
|
+
/**
|
|
106
|
+
* Resolve the contract for a node type. Unknown/custom node types get an
|
|
107
|
+
* open-ended contract (`closed: false`) so the validator never false-positives
|
|
108
|
+
* on node types it does not know about.
|
|
109
|
+
*/
|
|
110
|
+
export declare function getNodeOutputContract(nodeType: string): NodeOutputContract;
|
|
111
|
+
/**
|
|
112
|
+
* Pick the field to recommend when a `.result` reference is invalid on this node
|
|
113
|
+
* type (CV-4298 P2#2).
|
|
114
|
+
*
|
|
115
|
+
* Order of preference:
|
|
116
|
+
* 1. `canonicalField` — the field that carries the node's answer
|
|
117
|
+
* (condition → `condition`, merge → `results`).
|
|
118
|
+
* 2. `suggestedField` — generic fallback (usually `.output`).
|
|
119
|
+
* 3. `.output` — always resolvable (the virtual unwrap prefix).
|
|
120
|
+
*/
|
|
121
|
+
export declare function getSuggestionFieldForResultMisuse(nodeType: string): string;
|
|
122
|
+
/** Whether a contracted node type has a *closed* (fully enumerable) field set. */
|
|
123
|
+
export declare function hasClosedOutputContract(nodeType: string): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Node types whose stored value is *definitely not* an `{ result, ... }`
|
|
126
|
+
* envelope. Referencing `.result` on these is the canonical "agent idiom
|
|
127
|
+
* misapplied to a data node" bug — treated as an **error**.
|
|
128
|
+
*/
|
|
129
|
+
export declare const RESULT_INVALID_NODE_TYPES: Set<string>;
|
|
130
|
+
/**
|
|
131
|
+
* Extract the declared JSON output field names from an agent node's config
|
|
132
|
+
* (`config.output.schema.properties`), when `output.mode === "json"`.
|
|
133
|
+
*
|
|
134
|
+
* Returns `undefined` when the node does not declare a structured schema — in
|
|
135
|
+
* which case the agent's field set is unknowable and the validator stays lenient.
|
|
136
|
+
*/
|
|
137
|
+
export declare function getAgentDeclaredJsonFields(config: Record<string, unknown> | undefined): string[] | undefined;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NodeRegistry 集成辅助
|
|
3
|
+
*
|
|
4
|
+
* 提供函数来帮助将 decorator 节点类型注册到 NodeRegistry
|
|
5
|
+
*/
|
|
6
|
+
import type { NodeRegistry } from '../engine/node-registry';
|
|
7
|
+
/**
|
|
8
|
+
* 将所有内置节点类型注册到 NodeRegistry
|
|
9
|
+
*
|
|
10
|
+
* @param registry - NodeRegistry 实例
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { registerDecoratorNodeType } from '@roy-agent/workflow-decorators';
|
|
15
|
+
*
|
|
16
|
+
* // 在 WorkflowComponent 初始化时调用
|
|
17
|
+
* registerDecoratorNodeType(registry);
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function registerDecoratorNodeType(registry: NodeRegistry): void;
|
|
21
|
+
/**
|
|
22
|
+
* 检查 WorkflowDefinition 是否包含 decorator 类型的节点
|
|
23
|
+
*/
|
|
24
|
+
export declare function hasDecoratorNodes(nodes: Array<{
|
|
25
|
+
type: string;
|
|
26
|
+
}>): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* 从 WorkflowDefinition 中提取所有 decorator 类型的节点
|
|
29
|
+
*/
|
|
30
|
+
export declare function getDecoratorNodes(nodes: Array<{
|
|
31
|
+
type: string;
|
|
32
|
+
id: string;
|
|
33
|
+
}>): Array<{
|
|
34
|
+
type: string;
|
|
35
|
+
id: string;
|
|
36
|
+
}>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Human-readable hints derived from AgentNode output JSON schema.
|
|
3
|
+
*/
|
|
4
|
+
import type { JsonSchemaObject } from './json-schema-to-zod';
|
|
5
|
+
export declare function describeOutputSchema(schema: JsonSchemaObject | Record<string, unknown> | undefined): string;
|
|
6
|
+
export declare function buildJsonOutputNudgeMessage(schema?: JsonSchemaObject | Record<string, unknown>): string;
|
|
7
|
+
export declare function buildJsonOutputRerunHint(schema?: JsonSchemaObject | Record<string, unknown>): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse AgentNode output configuration from workflow node config.
|
|
3
|
+
*/
|
|
4
|
+
export type AgentOutputMode = 'string' | 'json';
|
|
5
|
+
export interface AgentOutputConfig {
|
|
6
|
+
mode: AgentOutputMode;
|
|
7
|
+
schema?: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
export declare function parseAgentOutputConfig(config: Record<string, unknown>): AgentOutputConfig;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RecoveryValidator - 分层恢复验证框架
|
|
3
|
+
*
|
|
4
|
+
* 遵循保守策略,严格验证状态完整性
|
|
5
|
+
*/
|
|
6
|
+
import type { WorkflowDefinition } from '../types';
|
|
7
|
+
import type { SessionMessage } from '../../session/types';
|
|
8
|
+
import type { ValidationResult, RecoveryPlan } from './validation-rules';
|
|
9
|
+
/**
|
|
10
|
+
* RecoveryValidator - 分层恢复验证框架
|
|
11
|
+
*
|
|
12
|
+
* 遵循保守策略,严格验证状态完整性
|
|
13
|
+
*/
|
|
14
|
+
export declare class RecoveryValidator {
|
|
15
|
+
private stateBuilder;
|
|
16
|
+
constructor();
|
|
17
|
+
validate(messages: SessionMessage[], definition: WorkflowDefinition): Promise<ValidationResult>;
|
|
18
|
+
generatePlan(messages: SessionMessage[], definition: WorkflowDefinition): Promise<RecoveryPlan>;
|
|
19
|
+
private validateStateIntegrity;
|
|
20
|
+
private validateParallelBranches;
|
|
21
|
+
private validateConditionBranches;
|
|
22
|
+
private validateLoopState;
|
|
23
|
+
private validateNestedWorkflows;
|
|
24
|
+
private extractVariableRefs;
|
|
25
|
+
private identifyParallelGroups;
|
|
26
|
+
private findMergeNodeForParallel;
|
|
27
|
+
private identifyLoops;
|
|
28
|
+
private determineResumePoint;
|
|
29
|
+
private generateSummary;
|
|
30
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview sensitive-redact.ts — Redact sensitive fields from input before persisting (Task #2900 P1)
|
|
3
|
+
*
|
|
4
|
+
* Background: engine.ts was persisting the raw workflow `input` object into
|
|
5
|
+
* session metadata.input, leaking sensitive fields (password / LDAP_PASSWORD /
|
|
6
|
+
* apiKey / token / secret) to the session DB. This util produces a deep-copy
|
|
7
|
+
* with sensitive keys replaced by the `"[REDACTED]"` sentinel.
|
|
8
|
+
*
|
|
9
|
+
* Design choices:
|
|
10
|
+
* - Case-insensitive matching (PASSWORD / Password / password all redacted).
|
|
11
|
+
* - Recurses into nested objects AND arrays (so {config:{auth:{password}}}
|
|
12
|
+
* and [{user, password}] are both safe).
|
|
13
|
+
* - Does NOT mutate the input — callers can safely pass the original object
|
|
14
|
+
* elsewhere.
|
|
15
|
+
* - Returns undefined for undefined/null input so engine.ts:447 etc. behave
|
|
16
|
+
* identically when no input was supplied.
|
|
17
|
+
* - Returns non-object scalars (strings, numbers, booleans) unchanged —
|
|
18
|
+
* they can't contain field names.
|
|
19
|
+
*
|
|
20
|
+
* Sensitive key list (lowercase, prefix-matched):
|
|
21
|
+
* password, ldap_password, apikey, api_key, token, secret, auth,
|
|
22
|
+
* access_token, refresh_token, authorization, cookie, private_key,
|
|
23
|
+
* session_token, sid
|
|
24
|
+
*
|
|
25
|
+
* Note: 'sid' is included to redact the ONES ones-ids-sid cookie value if
|
|
26
|
+
* accidentally passed as a top-level field (the workflow uses sidCookie,
|
|
27
|
+
* not sid, so this is defensive).
|
|
28
|
+
*/
|
|
29
|
+
/** Sentinel value used to replace redacted fields. */
|
|
30
|
+
export declare const REDACTED_SENTINEL = "[REDACTED]";
|
|
31
|
+
/**
|
|
32
|
+
* Redact sensitive fields from `input`. Returns a new object/array with
|
|
33
|
+
* sensitive values replaced by "[REDACTED]". Non-sensitive scalars and
|
|
34
|
+
* non-object values pass through unchanged. Returns undefined for
|
|
35
|
+
* undefined/null input.
|
|
36
|
+
*/
|
|
37
|
+
export declare function redactSensitiveFields<T = unknown>(input: T): T | undefined;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SessionMessage } from '../../session/types';
|
|
2
|
+
/**
|
|
3
|
+
* 查找最后一个 workflow.node.interrupt 消息
|
|
4
|
+
*/
|
|
5
|
+
export declare function findLastInterruptMessage(messages: SessionMessage[]): SessionMessage | null;
|
|
6
|
+
/**
|
|
7
|
+
* 解析节点输出
|
|
8
|
+
*
|
|
9
|
+
* 通过匹配 workflow.node.start 和 workflow.node.end 消息对来提取节点输出
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseNodeOutputs(messages: SessionMessage[]): Map<string, unknown>;
|
|
12
|
+
/**
|
|
13
|
+
* 获取下一个待执行的节点
|
|
14
|
+
*/
|
|
15
|
+
export declare function getNextPendingNode(messages: SessionMessage[]): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* 从 interrupt 消息获取 agentSessionId
|
|
18
|
+
*/
|
|
19
|
+
export declare function getAgentSessionIdFromInterrupt(interruptMessage: SessionMessage): string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* 检查 session 是否在等待用户
|
|
22
|
+
*/
|
|
23
|
+
export declare function isWaitingForUser(messages: SessionMessage[]): boolean;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Recovery Utilities
|
|
3
|
+
*
|
|
4
|
+
* Utilities for inferring the next execution point from session messages.
|
|
5
|
+
* This is the core of the unified run/resume mechanism.
|
|
6
|
+
*
|
|
7
|
+
* Message types:
|
|
8
|
+
* - workflow.node.start: Node execution started (对应 tool-call)
|
|
9
|
+
* - workflow.node.interrupt: Node waiting for user input
|
|
10
|
+
* - workflow.node.end: Node execution completed (对应 tool-result)
|
|
11
|
+
* - workflow.node.resume: Node resumed after user response
|
|
12
|
+
*/
|
|
13
|
+
import type { SessionMessage } from '../../session/types';
|
|
14
|
+
import type { AgentSessionRef } from '../types/workflow-message';
|
|
15
|
+
/**
|
|
16
|
+
* Represents a resume point - where to continue execution from
|
|
17
|
+
*/
|
|
18
|
+
export interface ResumePoint {
|
|
19
|
+
/** Type of resume point */
|
|
20
|
+
type: 'entry_node' | 'resume_node' | 'ask_user' | 'next_nodes';
|
|
21
|
+
/** Node ID (for single node resume) */
|
|
22
|
+
nodeId?: string;
|
|
23
|
+
/** Node IDs (for multiple next nodes) */
|
|
24
|
+
nodeIds?: string[];
|
|
25
|
+
/** Agent sub-session ID (for agent node resume) */
|
|
26
|
+
agentSessionId?: string;
|
|
27
|
+
/** Input for the node */
|
|
28
|
+
input?: unknown;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Infer the next node to execute based on session messages
|
|
32
|
+
*
|
|
33
|
+
* Decision logic:
|
|
34
|
+
* - No messages → execute entry node
|
|
35
|
+
* - Last = workflow.node.start → resume this node (incomplete/interrupted)
|
|
36
|
+
* - Last = workflow.node.interrupt → resume this node (ask_user)
|
|
37
|
+
* - Last = workflow.node.end → execute next nodes from DAG
|
|
38
|
+
* - Unknown → find last start, resume it, or fallback to entry
|
|
39
|
+
*/
|
|
40
|
+
export declare function inferNextNode(messages: SessionMessage[], definition: {
|
|
41
|
+
entryNode?: string;
|
|
42
|
+
edges?: Array<{
|
|
43
|
+
from: string;
|
|
44
|
+
to: string;
|
|
45
|
+
}>;
|
|
46
|
+
}): ResumePoint;
|
|
47
|
+
/**
|
|
48
|
+
* Find the last interrupt message in the session
|
|
49
|
+
*/
|
|
50
|
+
export declare function findLastInterruptMessage(messages: SessionMessage[]): SessionMessage | null;
|
|
51
|
+
/**
|
|
52
|
+
* Find the last start message in the session
|
|
53
|
+
*/
|
|
54
|
+
export declare function findLastStartMessage(messages: SessionMessage[]): SessionMessage | null;
|
|
55
|
+
/**
|
|
56
|
+
* Find the last call message (workflow.node.call) in the session
|
|
57
|
+
*/
|
|
58
|
+
export declare function findLastCallMessage(messages: SessionMessage[]): SessionMessage | null;
|
|
59
|
+
/**
|
|
60
|
+
* Parse node outputs from session messages
|
|
61
|
+
*
|
|
62
|
+
* Extracts outputs by matching:
|
|
63
|
+
* - workflow.node.start with workflow.node.end pairs
|
|
64
|
+
* - workflow.node.call with workflow.node.result pairs
|
|
65
|
+
*/
|
|
66
|
+
export declare function parseNodeOutputs(messages: SessionMessage[]): Map<string, unknown>;
|
|
67
|
+
/**
|
|
68
|
+
* Check if session has pending ask_user interrupt
|
|
69
|
+
*/
|
|
70
|
+
export declare function hasPendingAskUser(messages: SessionMessage[]): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Get agent session ID from last interrupt message
|
|
73
|
+
*/
|
|
74
|
+
export declare function getAgentSessionIdFromInterrupt(messages: SessionMessage[]): string | null;
|
|
75
|
+
/**
|
|
76
|
+
* Resolve agent sub-session ID for a pending node.
|
|
77
|
+
* Prefers explicit agentSessionId from messages; falls back to workflow metadata.agentSessions.
|
|
78
|
+
*/
|
|
79
|
+
export declare function resolveAgentSessionId(nodeId: string | undefined, agentSessionId: string | undefined, agentSessions?: AgentSessionRef[]): string | undefined;
|
|
80
|
+
export declare function enrichResumeInfoWithAgentSessions(resumeInfo: ResumeInfo, agentSessions?: AgentSessionRef[]): ResumeInfo;
|
|
81
|
+
export declare function enrichResumePointWithAgentSessions(resumePoint: ResumePoint, agentSessions?: AgentSessionRef[]): ResumePoint;
|
|
82
|
+
/**
|
|
83
|
+
* Complete resume information extracted from session messages
|
|
84
|
+
*/
|
|
85
|
+
export interface ResumeInfo {
|
|
86
|
+
/** Pending node ID (if any node was interrupted) */
|
|
87
|
+
pendingNodeId: string | undefined;
|
|
88
|
+
/** Agent sub-session ID for the pending node */
|
|
89
|
+
agentSessionId: string | undefined;
|
|
90
|
+
/** Whether there is a pending interrupt (ask_user) */
|
|
91
|
+
hasInterrupt: boolean;
|
|
92
|
+
/** Node outputs from completed nodes */
|
|
93
|
+
nodeOutputs: Map<string, unknown>;
|
|
94
|
+
/** Last interrupt message content (query) */
|
|
95
|
+
lastInterruptQuery?: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Extract complete resume information from session messages
|
|
99
|
+
*
|
|
100
|
+
* This function consolidates the logic that was previously scattered across
|
|
101
|
+
* engine.ts and other places. It extracts all information needed to resume
|
|
102
|
+
* a workflow from its session messages.
|
|
103
|
+
*
|
|
104
|
+
* The key insight is:
|
|
105
|
+
* - If the last message is an interrupt, use its metadata for resume
|
|
106
|
+
* - No need for complex userResponse distinction
|
|
107
|
+
* - agentSessionId comes from interrupt message metadata
|
|
108
|
+
* - userQuery comes from the input provided during resume
|
|
109
|
+
*
|
|
110
|
+
* @param messages - Session messages to analyze
|
|
111
|
+
* @returns Complete resume information
|
|
112
|
+
*/
|
|
113
|
+
export declare function extractResumeInfo(messages: SessionMessage[]): ResumeInfo;
|
|
114
|
+
/**
|
|
115
|
+
* Split ephemeral resume userQuery from durable workflow input.
|
|
116
|
+
* userQuery is only valid for the node being resumed and must not persist
|
|
117
|
+
* in workflowInput for subsequent nodes.
|
|
118
|
+
*/
|
|
119
|
+
export declare function stripEphemeralResumeInput(input?: Record<string, unknown>): {
|
|
120
|
+
workflowInput?: Record<string, unknown>;
|
|
121
|
+
userQuery?: unknown;
|
|
122
|
+
};
|