@travisliu/open-dynamic-workflow 0.3.0
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/CHANGELOG.md +20 -0
- package/LICENSE +21 -0
- package/README.md +312 -0
- package/dist/agents/antigravity-cli.d.ts +19 -0
- package/dist/agents/antigravity-cli.js +177 -0
- package/dist/agents/antigravity-cli.js.map +1 -0
- package/dist/agents/codex-exec.d.ts +12 -0
- package/dist/agents/codex-exec.js +283 -0
- package/dist/agents/codex-exec.js.map +1 -0
- package/dist/agents/execute-agent.d.ts +21 -0
- package/dist/agents/execute-agent.js +593 -0
- package/dist/agents/execute-agent.js.map +1 -0
- package/dist/agents/execution-types.d.ts +20 -0
- package/dist/agents/execution-types.js +2 -0
- package/dist/agents/execution-types.js.map +1 -0
- package/dist/agents/gemini-cli.d.ts +14 -0
- package/dist/agents/gemini-cli.js +176 -0
- package/dist/agents/gemini-cli.js.map +1 -0
- package/dist/agents/github-copilot-cli.d.ts +16 -0
- package/dist/agents/github-copilot-cli.js +256 -0
- package/dist/agents/github-copilot-cli.js.map +1 -0
- package/dist/agents/mock-adapter.d.ts +12 -0
- package/dist/agents/mock-adapter.js +66 -0
- package/dist/agents/mock-adapter.js.map +1 -0
- package/dist/agents/model-args.d.ts +2 -0
- package/dist/agents/model-args.js +15 -0
- package/dist/agents/model-args.js.map +1 -0
- package/dist/agents/opencode-cli.d.ts +22 -0
- package/dist/agents/opencode-cli.js +245 -0
- package/dist/agents/opencode-cli.js.map +1 -0
- package/dist/agents/pi-coding-agent.d.ts +31 -0
- package/dist/agents/pi-coding-agent.js +317 -0
- package/dist/agents/pi-coding-agent.js.map +1 -0
- package/dist/agents/process-runner.d.ts +2 -0
- package/dist/agents/process-runner.js +130 -0
- package/dist/agents/process-runner.js.map +1 -0
- package/dist/agents/provider-health.d.ts +3 -0
- package/dist/agents/provider-health.js +30 -0
- package/dist/agents/provider-health.js.map +1 -0
- package/dist/agents/registry.d.ts +12 -0
- package/dist/agents/registry.js +45 -0
- package/dist/agents/registry.js.map +1 -0
- package/dist/agents/resolve-model.d.ts +11 -0
- package/dist/agents/resolve-model.js +30 -0
- package/dist/agents/resolve-model.js.map +1 -0
- package/dist/agents/types.d.ts +2 -0
- package/dist/agents/types.js +2 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/artifacts/call-cache.d.ts +117 -0
- package/dist/artifacts/call-cache.js +449 -0
- package/dist/artifacts/call-cache.js.map +1 -0
- package/dist/artifacts/logs.d.ts +13 -0
- package/dist/artifacts/logs.js +24 -0
- package/dist/artifacts/logs.js.map +1 -0
- package/dist/artifacts/manifest.d.ts +18 -0
- package/dist/artifacts/manifest.js +29 -0
- package/dist/artifacts/manifest.js.map +1 -0
- package/dist/artifacts/run-store.d.ts +22 -0
- package/dist/artifacts/run-store.js +148 -0
- package/dist/artifacts/run-store.js.map +1 -0
- package/dist/bin/open-dynamic-workflow.d.ts +2 -0
- package/dist/bin/open-dynamic-workflow.js +45 -0
- package/dist/bin/open-dynamic-workflow.js.map +1 -0
- package/dist/cli/args.d.ts +36 -0
- package/dist/cli/args.js +68 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +9 -0
- package/dist/cli/commands/doctor.js +109 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/init.d.ts +23 -0
- package/dist/cli/commands/init.js +147 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/list.d.ts +12 -0
- package/dist/cli/commands/list.js +65 -0
- package/dist/cli/commands/list.js.map +1 -0
- package/dist/cli/commands/resume.d.ts +5 -0
- package/dist/cli/commands/resume.js +81 -0
- package/dist/cli/commands/resume.js.map +1 -0
- package/dist/cli/commands/run.d.ts +18 -0
- package/dist/cli/commands/run.js +318 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +14 -0
- package/dist/cli/commands/validate.js +66 -0
- package/dist/cli/commands/validate.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +169 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/init/defaults.d.ts +12 -0
- package/dist/cli/init/defaults.js +54 -0
- package/dist/cli/init/defaults.js.map +1 -0
- package/dist/cli/init/planner.d.ts +10 -0
- package/dist/cli/init/planner.js +163 -0
- package/dist/cli/init/planner.js.map +1 -0
- package/dist/cli/init/prompts.d.ts +15 -0
- package/dist/cli/init/prompts.js +83 -0
- package/dist/cli/init/prompts.js.map +1 -0
- package/dist/cli/init/providers.d.ts +13 -0
- package/dist/cli/init/providers.js +100 -0
- package/dist/cli/init/providers.js.map +1 -0
- package/dist/cli/init/renderer.d.ts +8 -0
- package/dist/cli/init/renderer.js +84 -0
- package/dist/cli/init/renderer.js.map +1 -0
- package/dist/cli/init/smoke-test.d.ts +15 -0
- package/dist/cli/init/smoke-test.js +47 -0
- package/dist/cli/init/smoke-test.js.map +1 -0
- package/dist/cli/init/summary.d.ts +11 -0
- package/dist/cli/init/summary.js +65 -0
- package/dist/cli/init/summary.js.map +1 -0
- package/dist/cli/init/types.d.ts +81 -0
- package/dist/cli/init/types.js +2 -0
- package/dist/cli/init/types.js.map +1 -0
- package/dist/cli/init/writer.d.ts +3 -0
- package/dist/cli/init/writer.js +57 -0
- package/dist/cli/init/writer.js.map +1 -0
- package/dist/cli/package-info.d.ts +1 -0
- package/dist/cli/package-info.js +13 -0
- package/dist/cli/package-info.js.map +1 -0
- package/dist/cli/paths.d.ts +2 -0
- package/dist/cli/paths.js +8 -0
- package/dist/cli/paths.js.map +1 -0
- package/dist/cli/print.d.ts +22 -0
- package/dist/cli/print.js +48 -0
- package/dist/cli/print.js.map +1 -0
- package/dist/config/defaults.d.ts +3 -0
- package/dist/config/defaults.js +116 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/load.d.ts +10 -0
- package/dist/config/load.js +72 -0
- package/dist/config/load.js.map +1 -0
- package/dist/config/merge.d.ts +10 -0
- package/dist/config/merge.js +58 -0
- package/dist/config/merge.js.map +1 -0
- package/dist/config/schema.d.ts +2 -0
- package/dist/config/schema.js +236 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/config/types.d.ts +93 -0
- package/dist/config/types.js +2 -0
- package/dist/config/types.js.map +1 -0
- package/dist/discovery/collect-files.d.ts +10 -0
- package/dist/discovery/collect-files.js +189 -0
- package/dist/discovery/collect-files.js.map +1 -0
- package/dist/discovery/definition-call.d.ts +10 -0
- package/dist/discovery/definition-call.js +37 -0
- package/dist/discovery/definition-call.js.map +1 -0
- package/dist/discovery/diagnostics.d.ts +17 -0
- package/dist/discovery/diagnostics.js +32 -0
- package/dist/discovery/diagnostics.js.map +1 -0
- package/dist/discovery/directories.d.ts +8 -0
- package/dist/discovery/directories.js +32 -0
- package/dist/discovery/directories.js.map +1 -0
- package/dist/discovery/duplicate-detector.d.ts +8 -0
- package/dist/discovery/duplicate-detector.js +40 -0
- package/dist/discovery/duplicate-detector.js.map +1 -0
- package/dist/discovery/extract-agent.d.ts +2 -0
- package/dist/discovery/extract-agent.js +166 -0
- package/dist/discovery/extract-agent.js.map +1 -0
- package/dist/discovery/extract-tool.d.ts +2 -0
- package/dist/discovery/extract-tool.js +188 -0
- package/dist/discovery/extract-tool.js.map +1 -0
- package/dist/discovery/extract-workflow.d.ts +2 -0
- package/dist/discovery/extract-workflow.js +180 -0
- package/dist/discovery/extract-workflow.js.map +1 -0
- package/dist/discovery/file-patterns.d.ts +3 -0
- package/dist/discovery/file-patterns.js +93 -0
- package/dist/discovery/file-patterns.js.map +1 -0
- package/dist/discovery/index.d.ts +7 -0
- package/dist/discovery/index.js +8 -0
- package/dist/discovery/index.js.map +1 -0
- package/dist/discovery/schema-summary.d.ts +13 -0
- package/dist/discovery/schema-summary.js +37 -0
- package/dist/discovery/schema-summary.js.map +1 -0
- package/dist/discovery/service.d.ts +4 -0
- package/dist/discovery/service.js +135 -0
- package/dist/discovery/service.js.map +1 -0
- package/dist/discovery/static-values.d.ts +13 -0
- package/dist/discovery/static-values.js +68 -0
- package/dist/discovery/static-values.js.map +1 -0
- package/dist/discovery/types.d.ts +95 -0
- package/dist/discovery/types.js +2 -0
- package/dist/discovery/types.js.map +1 -0
- package/dist/doctors/public.d.ts +15 -0
- package/dist/doctors/public.js +2 -0
- package/dist/doctors/public.js.map +1 -0
- package/dist/errors/codes.d.ts +53 -0
- package/dist/errors/codes.js +53 -0
- package/dist/errors/codes.js.map +1 -0
- package/dist/errors/exit-codes.d.ts +13 -0
- package/dist/errors/exit-codes.js +72 -0
- package/dist/errors/exit-codes.js.map +1 -0
- package/dist/errors/list-errors.d.ts +4 -0
- package/dist/errors/list-errors.js +11 -0
- package/dist/errors/list-errors.js.map +1 -0
- package/dist/errors/serialize.d.ts +2 -0
- package/dist/errors/serialize.js +38 -0
- package/dist/errors/serialize.js.map +1 -0
- package/dist/errors/types.d.ts +15 -0
- package/dist/errors/types.js +13 -0
- package/dist/errors/types.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/orchestration/cancellation.d.ts +13 -0
- package/dist/orchestration/cancellation.js +41 -0
- package/dist/orchestration/cancellation.js.map +1 -0
- package/dist/orchestration/event-bus.d.ts +24 -0
- package/dist/orchestration/event-bus.js +50 -0
- package/dist/orchestration/event-bus.js.map +1 -0
- package/dist/orchestration/fail-fast.d.ts +8 -0
- package/dist/orchestration/fail-fast.js +21 -0
- package/dist/orchestration/fail-fast.js.map +1 -0
- package/dist/orchestration/scheduler.d.ts +37 -0
- package/dist/orchestration/scheduler.js +330 -0
- package/dist/orchestration/scheduler.js.map +1 -0
- package/dist/orchestration/tool-limiter.d.ts +10 -0
- package/dist/orchestration/tool-limiter.js +62 -0
- package/dist/orchestration/tool-limiter.js.map +1 -0
- package/dist/output/events.d.ts +290 -0
- package/dist/output/events.js +10 -0
- package/dist/output/events.js.map +1 -0
- package/dist/output/failed-artifacts.d.ts +5 -0
- package/dist/output/failed-artifacts.js +62 -0
- package/dist/output/failed-artifacts.js.map +1 -0
- package/dist/output/json-reporter.d.ts +13 -0
- package/dist/output/json-reporter.js +31 -0
- package/dist/output/json-reporter.js.map +1 -0
- package/dist/output/jsonl-reporter.d.ts +12 -0
- package/dist/output/jsonl-reporter.js +29 -0
- package/dist/output/jsonl-reporter.js.map +1 -0
- package/dist/output/list-json-reporter.d.ts +9 -0
- package/dist/output/list-json-reporter.js +22 -0
- package/dist/output/list-json-reporter.js.map +1 -0
- package/dist/output/list-jsonl-reporter.d.ts +9 -0
- package/dist/output/list-jsonl-reporter.js +43 -0
- package/dist/output/list-jsonl-reporter.js.map +1 -0
- package/dist/output/list-pretty-reporter.d.ts +13 -0
- package/dist/output/list-pretty-reporter.js +120 -0
- package/dist/output/list-pretty-reporter.js.map +1 -0
- package/dist/output/list-reporter.d.ts +14 -0
- package/dist/output/list-reporter.js +20 -0
- package/dist/output/list-reporter.js.map +1 -0
- package/dist/output/pretty-format.d.ts +19 -0
- package/dist/output/pretty-format.js +75 -0
- package/dist/output/pretty-format.js.map +1 -0
- package/dist/output/pretty-renderer.d.ts +2 -0
- package/dist/output/pretty-renderer.js +97 -0
- package/dist/output/pretty-renderer.js.map +1 -0
- package/dist/output/pretty-reporter.d.ts +14 -0
- package/dist/output/pretty-reporter.js +155 -0
- package/dist/output/pretty-reporter.js.map +1 -0
- package/dist/output/pretty-view-builder.d.ts +26 -0
- package/dist/output/pretty-view-builder.js +374 -0
- package/dist/output/pretty-view-builder.js.map +1 -0
- package/dist/output/pretty-view.d.ts +85 -0
- package/dist/output/pretty-view.js +6 -0
- package/dist/output/pretty-view.js.map +1 -0
- package/dist/output/reporter.d.ts +34 -0
- package/dist/output/reporter.js +24 -0
- package/dist/output/reporter.js.map +1 -0
- package/dist/output/verbose-formatter.d.ts +6 -0
- package/dist/output/verbose-formatter.js +137 -0
- package/dist/output/verbose-formatter.js.map +1 -0
- package/dist/pipeline/artifacts.d.ts +6 -0
- package/dist/pipeline/artifacts.js +44 -0
- package/dist/pipeline/artifacts.js.map +1 -0
- package/dist/pipeline/concurrency.d.ts +11 -0
- package/dist/pipeline/concurrency.js +60 -0
- package/dist/pipeline/concurrency.js.map +1 -0
- package/dist/pipeline/context.d.ts +15 -0
- package/dist/pipeline/context.js +17 -0
- package/dist/pipeline/context.js.map +1 -0
- package/dist/pipeline/events.d.ts +10 -0
- package/dist/pipeline/events.js +83 -0
- package/dist/pipeline/events.js.map +1 -0
- package/dist/pipeline/id.d.ts +10 -0
- package/dist/pipeline/id.js +61 -0
- package/dist/pipeline/id.js.map +1 -0
- package/dist/pipeline/item-streaming.d.ts +3 -0
- package/dist/pipeline/item-streaming.js +122 -0
- package/dist/pipeline/item-streaming.js.map +1 -0
- package/dist/pipeline/results.d.ts +10 -0
- package/dist/pipeline/results.js +88 -0
- package/dist/pipeline/results.js.map +1 -0
- package/dist/pipeline/run.d.ts +10 -0
- package/dist/pipeline/run.js +93 -0
- package/dist/pipeline/run.js.map +1 -0
- package/dist/pipeline/stage-barrier.d.ts +3 -0
- package/dist/pipeline/stage-barrier.js +135 -0
- package/dist/pipeline/stage-barrier.js.map +1 -0
- package/dist/pipeline/stage-runner.d.ts +13 -0
- package/dist/pipeline/stage-runner.js +185 -0
- package/dist/pipeline/stage-runner.js.map +1 -0
- package/dist/pipeline/summary.d.ts +12 -0
- package/dist/pipeline/summary.js +24 -0
- package/dist/pipeline/summary.js.map +1 -0
- package/dist/pipeline/types.d.ts +92 -0
- package/dist/pipeline/types.js +2 -0
- package/dist/pipeline/types.js.map +1 -0
- package/dist/pipeline/validate.d.ts +11 -0
- package/dist/pipeline/validate.js +139 -0
- package/dist/pipeline/validate.js.map +1 -0
- package/dist/runtime/public.d.ts +3 -0
- package/dist/runtime/public.js +4 -0
- package/dist/runtime/public.js.map +1 -0
- package/dist/security/env.d.ts +38 -0
- package/dist/security/env.js +186 -0
- package/dist/security/env.js.map +1 -0
- package/dist/security/metadata.d.ts +6 -0
- package/dist/security/metadata.js +41 -0
- package/dist/security/metadata.js.map +1 -0
- package/dist/shared-agents/context.d.ts +2 -0
- package/dist/shared-agents/context.js +5 -0
- package/dist/shared-agents/context.js.map +1 -0
- package/dist/shared-agents/define-agent.d.ts +3 -0
- package/dist/shared-agents/define-agent.js +15 -0
- package/dist/shared-agents/define-agent.js.map +1 -0
- package/dist/shared-agents/execute.d.ts +24 -0
- package/dist/shared-agents/execute.js +63 -0
- package/dist/shared-agents/execute.js.map +1 -0
- package/dist/shared-agents/index.d.ts +5 -0
- package/dist/shared-agents/index.js +6 -0
- package/dist/shared-agents/index.js.map +1 -0
- package/dist/shared-agents/load.d.ts +8 -0
- package/dist/shared-agents/load.js +141 -0
- package/dist/shared-agents/load.js.map +1 -0
- package/dist/shared-agents/registry.d.ts +8 -0
- package/dist/shared-agents/registry.js +25 -0
- package/dist/shared-agents/registry.js.map +1 -0
- package/dist/shared-agents/render.d.ts +11 -0
- package/dist/shared-agents/render.js +31 -0
- package/dist/shared-agents/render.js.map +1 -0
- package/dist/shared-agents/resolver.d.ts +7 -0
- package/dist/shared-agents/resolver.js +22 -0
- package/dist/shared-agents/resolver.js.map +1 -0
- package/dist/shared-agents/types.d.ts +33 -0
- package/dist/shared-agents/types.js +2 -0
- package/dist/shared-agents/types.js.map +1 -0
- package/dist/shared-agents/validate.d.ts +7 -0
- package/dist/shared-agents/validate.js +223 -0
- package/dist/shared-agents/validate.js.map +1 -0
- package/dist/structured/extract-json.d.ts +11 -0
- package/dist/structured/extract-json.js +79 -0
- package/dist/structured/extract-json.js.map +1 -0
- package/dist/structured/normalize-agent-output.d.ts +18 -0
- package/dist/structured/normalize-agent-output.js +89 -0
- package/dist/structured/normalize-agent-output.js.map +1 -0
- package/dist/structured/structured-output.d.ts +14 -0
- package/dist/structured/structured-output.js +51 -0
- package/dist/structured/structured-output.js.map +1 -0
- package/dist/structured/validate-json.d.ts +13 -0
- package/dist/structured/validate-json.js +32 -0
- package/dist/structured/validate-json.js.map +1 -0
- package/dist/tools/artifacts.d.ts +8 -0
- package/dist/tools/artifacts.js +31 -0
- package/dist/tools/artifacts.js.map +1 -0
- package/dist/tools/define-tool.d.ts +10 -0
- package/dist/tools/define-tool.js +24 -0
- package/dist/tools/define-tool.js.map +1 -0
- package/dist/tools/executor-types.d.ts +40 -0
- package/dist/tools/executor-types.js +2 -0
- package/dist/tools/executor-types.js.map +1 -0
- package/dist/tools/executor.d.ts +23 -0
- package/dist/tools/executor.js +455 -0
- package/dist/tools/executor.js.map +1 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.js +5 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/load.d.ts +7 -0
- package/dist/tools/load.js +133 -0
- package/dist/tools/load.js.map +1 -0
- package/dist/tools/registry.d.ts +9 -0
- package/dist/tools/registry.js +97 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/serialization.d.ts +11 -0
- package/dist/tools/serialization.js +68 -0
- package/dist/tools/serialization.js.map +1 -0
- package/dist/tools/validate.d.ts +18 -0
- package/dist/tools/validate.js +55 -0
- package/dist/tools/validate.js.map +1 -0
- package/dist/types/agent.d.ts +136 -0
- package/dist/types/agent.js +2 -0
- package/dist/types/agent.js.map +1 -0
- package/dist/types/artifacts.d.ts +88 -0
- package/dist/types/artifacts.js +2 -0
- package/dist/types/artifacts.js.map +1 -0
- package/dist/types/common.d.ts +15 -0
- package/dist/types/common.js +2 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/config.d.ts +119 -0
- package/dist/types/config.js +2 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/errors.d.ts +21 -0
- package/dist/types/errors.js +50 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/events.d.ts +4 -0
- package/dist/types/events.js +2 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/index.js +12 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/process.d.ts +20 -0
- package/dist/types/process.js +2 -0
- package/dist/types/process.js.map +1 -0
- package/dist/types/reporter.d.ts +1 -0
- package/dist/types/reporter.js +2 -0
- package/dist/types/reporter.js.map +1 -0
- package/dist/types/scheduler.d.ts +30 -0
- package/dist/types/scheduler.js +2 -0
- package/dist/types/scheduler.js.map +1 -0
- package/dist/types/tool.d.ts +129 -0
- package/dist/types/tool.js +2 -0
- package/dist/types/tool.js.map +1 -0
- package/dist/types/workflow.d.ts +127 -0
- package/dist/types/workflow.js +2 -0
- package/dist/types/workflow.js.map +1 -0
- package/dist/workflow/discovery.d.ts +15 -0
- package/dist/workflow/discovery.js +134 -0
- package/dist/workflow/discovery.js.map +1 -0
- package/dist/workflow/dsl.d.ts +13 -0
- package/dist/workflow/dsl.js +683 -0
- package/dist/workflow/dsl.js.map +1 -0
- package/dist/workflow/errors.d.ts +18 -0
- package/dist/workflow/errors.js +33 -0
- package/dist/workflow/errors.js.map +1 -0
- package/dist/workflow/invocation-artifacts.d.ts +42 -0
- package/dist/workflow/invocation-artifacts.js +114 -0
- package/dist/workflow/invocation-artifacts.js.map +1 -0
- package/dist/workflow/invocation-manager.d.ts +31 -0
- package/dist/workflow/invocation-manager.js +516 -0
- package/dist/workflow/invocation-manager.js.map +1 -0
- package/dist/workflow/invocation-types.d.ts +63 -0
- package/dist/workflow/invocation-types.js +15 -0
- package/dist/workflow/invocation-types.js.map +1 -0
- package/dist/workflow/json.d.ts +10 -0
- package/dist/workflow/json.js +117 -0
- package/dist/workflow/json.js.map +1 -0
- package/dist/workflow/load.d.ts +2 -0
- package/dist/workflow/load.js +18 -0
- package/dist/workflow/load.js.map +1 -0
- package/dist/workflow/parse.d.ts +2 -0
- package/dist/workflow/parse.js +135 -0
- package/dist/workflow/parse.js.map +1 -0
- package/dist/workflow/registry.d.ts +18 -0
- package/dist/workflow/registry.js +55 -0
- package/dist/workflow/registry.js.map +1 -0
- package/dist/workflow/resolve-target.d.ts +45 -0
- package/dist/workflow/resolve-target.js +162 -0
- package/dist/workflow/resolve-target.js.map +1 -0
- package/dist/workflow/runtime.d.ts +46 -0
- package/dist/workflow/runtime.js +398 -0
- package/dist/workflow/runtime.js.map +1 -0
- package/dist/workflow/sandbox.d.ts +14 -0
- package/dist/workflow/sandbox.js +79 -0
- package/dist/workflow/sandbox.js.map +1 -0
- package/dist/workflow/scope.d.ts +18 -0
- package/dist/workflow/scope.js +108 -0
- package/dist/workflow/scope.js.map +1 -0
- package/dist/workflow/types.d.ts +65 -0
- package/dist/workflow/types.js +2 -0
- package/dist/workflow/types.js.map +1 -0
- package/dist/workflow/validate.d.ts +28 -0
- package/dist/workflow/validate.js +1059 -0
- package/dist/workflow/validate.js.map +1 -0
- package/dist/workflow/workflow-call.d.ts +12 -0
- package/dist/workflow/workflow-call.js +61 -0
- package/dist/workflow/workflow-call.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,683 @@
|
|
|
1
|
+
import { resolveAgentModel } from "../agents/resolve-model.js";
|
|
2
|
+
import { InvalidDslCallError } from "./errors.js";
|
|
3
|
+
import { OpenDynamicWorkflowError } from "../errors/types.js";
|
|
4
|
+
import { ErrorCode } from "../errors/codes.js";
|
|
5
|
+
import { runPipeline } from "../pipeline/run.js";
|
|
6
|
+
import { getActivePipelineContext, recordChildAgentId } from "../pipeline/context.js";
|
|
7
|
+
import { createPipelineAgentId } from "../pipeline/id.js";
|
|
8
|
+
import { isStructuredOutputTransport } from "../structured/structured-output.js";
|
|
9
|
+
import { computeAgentFingerprint, computeToolFingerprint, findPrefixCacheHit, materializeCachedAgentResult, materializeCachedToolResult, recordAgentCall, recordToolCall, resolveCallId } from "../artifacts/call-cache.js";
|
|
10
|
+
import { executeSharedAgent } from "../shared-agents/execute.js";
|
|
11
|
+
import { serializeError } from "../errors/serialize.js";
|
|
12
|
+
import { cloneJsonValue } from "./json.js";
|
|
13
|
+
import { getActiveWorkflowInvocation } from "./invocation-types.js";
|
|
14
|
+
import { assertToolAllowed, withToolForbidden } from "./scope.js";
|
|
15
|
+
function normalizeToolCallInput(input, runtime) {
|
|
16
|
+
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
17
|
+
throw new InvalidDslCallError("tool() requires an input object.");
|
|
18
|
+
}
|
|
19
|
+
const allowedKeys = ["definition", "args", "id", "label", "timeoutMs", "failureMode", "metadata"];
|
|
20
|
+
const unknownKeys = Object.keys(input).filter(k => !allowedKeys.includes(k));
|
|
21
|
+
if (unknownKeys.length > 0) {
|
|
22
|
+
throw new InvalidDslCallError(`tool() call contains unknown keys: ${unknownKeys.join(", ")}`);
|
|
23
|
+
}
|
|
24
|
+
const typedInput = input;
|
|
25
|
+
if (!typedInput.definition || typeof typedInput.definition !== "string") {
|
|
26
|
+
throw new InvalidDslCallError("tool() 'definition' must be a non-empty string.");
|
|
27
|
+
}
|
|
28
|
+
if (typedInput.args === undefined) {
|
|
29
|
+
throw new InvalidDslCallError("tool() 'args' is required.");
|
|
30
|
+
}
|
|
31
|
+
if (typedInput.id !== undefined) {
|
|
32
|
+
if (typeof typedInput.id !== "string" || typedInput.id.trim() === "") {
|
|
33
|
+
throw new InvalidDslCallError("tool() 'id' must be a non-empty string.");
|
|
34
|
+
}
|
|
35
|
+
if (/[^a-zA-Z0-9_-]/.test(typedInput.id)) {
|
|
36
|
+
throw new InvalidDslCallError(`tool() 'id' contains unsafe characters: "${typedInput.id}"`);
|
|
37
|
+
}
|
|
38
|
+
if (runtime.toolCallIds?.has(typedInput.id)) {
|
|
39
|
+
throw new InvalidDslCallError(`tool() 'id' is already used in this run: "${typedInput.id}"`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (typedInput.timeoutMs !== undefined) {
|
|
43
|
+
if (typeof typedInput.timeoutMs !== "number" || typedInput.timeoutMs <= 0 || !Number.isInteger(typedInput.timeoutMs)) {
|
|
44
|
+
throw new InvalidDslCallError("tool() 'timeoutMs' must be a positive integer.");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (typedInput.failureMode !== undefined && typedInput.failureMode !== "throw" && typedInput.failureMode !== "settled") {
|
|
48
|
+
throw new InvalidDslCallError('tool() \'failureMode\' must be "throw" or "settled".');
|
|
49
|
+
}
|
|
50
|
+
if (typedInput.label !== undefined && (typeof typedInput.label !== "string" || typedInput.label.trim() === "")) {
|
|
51
|
+
throw new InvalidDslCallError("tool() 'label' must be a non-empty string.");
|
|
52
|
+
}
|
|
53
|
+
if (typedInput.metadata !== undefined) {
|
|
54
|
+
if (typeof typedInput.metadata !== "object" || typedInput.metadata === null || Array.isArray(typedInput.metadata)) {
|
|
55
|
+
throw new InvalidDslCallError("tool() 'metadata' must be an object.");
|
|
56
|
+
}
|
|
57
|
+
const proto = Object.getPrototypeOf(typedInput.metadata);
|
|
58
|
+
if (proto !== null && proto.constructor?.name !== "Object") {
|
|
59
|
+
throw new InvalidDslCallError("tool() 'metadata' must be a plain object.");
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
cloneJsonValue(typedInput.metadata, "tool metadata");
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
throw new OpenDynamicWorkflowError(ErrorCode.TOOL_SERIALIZATION_FAILED, err.message, { cause: err });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Also validate args for serializability early
|
|
69
|
+
try {
|
|
70
|
+
cloneJsonValue(typedInput.args, "tool args");
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
throw new OpenDynamicWorkflowError(ErrorCode.TOOL_SERIALIZATION_FAILED, err.message, { cause: err });
|
|
74
|
+
}
|
|
75
|
+
return typedInput;
|
|
76
|
+
}
|
|
77
|
+
function nextToolCallId(runtime, definitionId) {
|
|
78
|
+
const counter = (runtime.toolCounter || 0) + 1;
|
|
79
|
+
runtime.toolCounter = counter;
|
|
80
|
+
const suffix = definitionId.replace(/[^a-zA-Z0-9]/g, "-").toLowerCase();
|
|
81
|
+
return `tool-${counter.toString().padStart(4, "0")}-${suffix}`;
|
|
82
|
+
}
|
|
83
|
+
export function createDsl(runtime) {
|
|
84
|
+
const logWorkflow = (message, data) => {
|
|
85
|
+
if (typeof message !== "string") {
|
|
86
|
+
throw new InvalidDslCallError("log() message must be a string.");
|
|
87
|
+
}
|
|
88
|
+
if (runtime.eventSink) {
|
|
89
|
+
const activeInvocation = getActiveWorkflowInvocation();
|
|
90
|
+
const payload = { message };
|
|
91
|
+
if (activeInvocation) {
|
|
92
|
+
payload.workflowInvocationId = activeInvocation.workflowInvocationId;
|
|
93
|
+
}
|
|
94
|
+
if (data !== undefined) {
|
|
95
|
+
payload.data = data;
|
|
96
|
+
}
|
|
97
|
+
runtime.eventSink.emit("workflow.log", payload);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const runDirectAgent = async (input) => {
|
|
101
|
+
const activeInvocation = getActiveWorkflowInvocation();
|
|
102
|
+
if (!input || typeof input !== "object") {
|
|
103
|
+
throw new InvalidDslCallError("agent() requires an input object.");
|
|
104
|
+
}
|
|
105
|
+
if (!input.prompt || typeof input.prompt !== "string" || input.prompt.trim() === "") {
|
|
106
|
+
throw new InvalidDslCallError("agent() requires a non-empty prompt string.");
|
|
107
|
+
}
|
|
108
|
+
if (input.id !== undefined && (typeof input.id !== "string" || input.id.trim() === "")) {
|
|
109
|
+
throw new InvalidDslCallError("agent() id must be a non-empty string.");
|
|
110
|
+
}
|
|
111
|
+
if (input.provider !== undefined && (typeof input.provider !== "string" || input.provider.trim() === "")) {
|
|
112
|
+
throw new InvalidDslCallError("agent() provider must be a non-empty string.");
|
|
113
|
+
}
|
|
114
|
+
if (input.timeoutMs !== undefined && (typeof input.timeoutMs !== "number" || input.timeoutMs <= 0)) {
|
|
115
|
+
throw new InvalidDslCallError("agent() timeoutMs must be a positive number.");
|
|
116
|
+
}
|
|
117
|
+
if (input.cwd !== undefined && (typeof input.cwd !== "string" || input.cwd.trim() === "")) {
|
|
118
|
+
throw new InvalidDslCallError("agent() cwd must be a non-empty string.");
|
|
119
|
+
}
|
|
120
|
+
if (input.structuredOutput !== undefined &&
|
|
121
|
+
(typeof input.structuredOutput !== "object" || input.structuredOutput === null || Array.isArray(input.structuredOutput))) {
|
|
122
|
+
throw new InvalidDslCallError("agent() structuredOutput must be an object when provided.");
|
|
123
|
+
}
|
|
124
|
+
if (input.structuredOutput?.transport !== undefined &&
|
|
125
|
+
!isStructuredOutputTransport(input.structuredOutput.transport)) {
|
|
126
|
+
throw new InvalidDslCallError('agent() structuredOutput.transport must be one of "validate-only", "prompt", "native", or "auto".');
|
|
127
|
+
}
|
|
128
|
+
if (input.permissions !== undefined) {
|
|
129
|
+
if (typeof input.permissions !== "object" || input.permissions === null || Array.isArray(input.permissions)) {
|
|
130
|
+
throw new InvalidDslCallError("agent() permissions must be an object.");
|
|
131
|
+
}
|
|
132
|
+
if (!("mode" in input.permissions)) {
|
|
133
|
+
throw new InvalidDslCallError("agent() permissions must include a 'mode' property.");
|
|
134
|
+
}
|
|
135
|
+
if (input.permissions.mode !== "dangerously-full-access") {
|
|
136
|
+
throw new InvalidDslCallError("agent() permissions.mode must be 'dangerously-full-access'.");
|
|
137
|
+
}
|
|
138
|
+
const extraKeys = Object.keys(input.permissions).filter(k => k !== "mode");
|
|
139
|
+
if (extraKeys.length > 0) {
|
|
140
|
+
throw new InvalidDslCallError("agent() permissions object cannot contain extra keys.");
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const resolvedPermissions = input.permissions
|
|
144
|
+
? { mode: "dangerously-full-access" }
|
|
145
|
+
: { mode: "default" };
|
|
146
|
+
const originMetadata = activeInvocation ? {
|
|
147
|
+
workflowInvocationId: activeInvocation.workflowInvocationId,
|
|
148
|
+
parentWorkflowInvocationId: activeInvocation.parentWorkflowInvocationId,
|
|
149
|
+
workflowName: activeInvocation.workflowName,
|
|
150
|
+
workflowDepth: activeInvocation.depth
|
|
151
|
+
} : {};
|
|
152
|
+
// Normalization
|
|
153
|
+
let normalizedId = input.id;
|
|
154
|
+
const activePipeline = getActivePipelineContext();
|
|
155
|
+
if (!normalizedId) {
|
|
156
|
+
if (activePipeline) {
|
|
157
|
+
activePipeline.agentCounter++;
|
|
158
|
+
normalizedId = createPipelineAgentId({
|
|
159
|
+
pipelineId: activePipeline.pipelineId,
|
|
160
|
+
itemIndex: activePipeline.itemIndex,
|
|
161
|
+
stageName: activePipeline.stageName,
|
|
162
|
+
suffix: activePipeline.agentCounter.toString()
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
normalizedId = runtime.idGenerator ? runtime.idGenerator.nextId("agent") : `agent-${++runtime.agentCounter}`;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (activePipeline) {
|
|
170
|
+
recordChildAgentId(normalizedId);
|
|
171
|
+
}
|
|
172
|
+
const normalizedProvider = input.provider || runtime.config.defaultProvider || "mock";
|
|
173
|
+
const normalizedTimeoutMs = input.timeoutMs || runtime.config.timeoutMs || 30000;
|
|
174
|
+
const normalizedCwd = input.cwd || runtime.cwd;
|
|
175
|
+
const resolved = resolveAgentModel({
|
|
176
|
+
agentModel: input.model,
|
|
177
|
+
cliModel: runtime.cli?.model,
|
|
178
|
+
providerDefaultModel: runtime.config.providers?.[normalizedProvider]?.defaultModel,
|
|
179
|
+
globalDefaultModel: runtime.config.defaultModel
|
|
180
|
+
});
|
|
181
|
+
const sequence = (runtime.callSequence ?? 0) + 1;
|
|
182
|
+
runtime.callSequence = sequence;
|
|
183
|
+
const callId = resolveCallId(input);
|
|
184
|
+
const fingerprint = computeAgentFingerprint({
|
|
185
|
+
call: input,
|
|
186
|
+
provider: normalizedProvider,
|
|
187
|
+
model: resolved.model,
|
|
188
|
+
timeoutMs: normalizedTimeoutMs,
|
|
189
|
+
cwd: normalizedCwd,
|
|
190
|
+
providerConfig: runtime.config.providers?.[normalizedProvider]
|
|
191
|
+
});
|
|
192
|
+
const cachedEntry = findPrefixCacheHit({
|
|
193
|
+
cache: runtime.callCache,
|
|
194
|
+
kind: "agent",
|
|
195
|
+
sequence,
|
|
196
|
+
callId,
|
|
197
|
+
fingerprint
|
|
198
|
+
});
|
|
199
|
+
if (cachedEntry && runtime.artifactStore && runtime.callCache?.previousRunRoot) {
|
|
200
|
+
const cachedResult = await materializeCachedAgentResult({
|
|
201
|
+
store: runtime.artifactStore,
|
|
202
|
+
previousRunRoot: runtime.callCache.previousRunRoot,
|
|
203
|
+
previousRunId: runtime.callCache.previousRunId,
|
|
204
|
+
entry: cachedEntry,
|
|
205
|
+
currentAgentId: normalizedId,
|
|
206
|
+
label: input.label,
|
|
207
|
+
provider: normalizedProvider,
|
|
208
|
+
model: resolved.model,
|
|
209
|
+
permissions: resolvedPermissions
|
|
210
|
+
});
|
|
211
|
+
runtime.agentResults.push(cachedResult);
|
|
212
|
+
runtime.eventSink?.emit("agent.cache_hit", {
|
|
213
|
+
agentId: normalizedId,
|
|
214
|
+
label: input.label,
|
|
215
|
+
provider: normalizedProvider,
|
|
216
|
+
model: resolved.model,
|
|
217
|
+
sequence,
|
|
218
|
+
callId,
|
|
219
|
+
previousRunId: runtime.callCache.previousRunId,
|
|
220
|
+
previousAgentId: cachedEntry.agentId,
|
|
221
|
+
artifacts: cachedResult.artifacts
|
|
222
|
+
});
|
|
223
|
+
await recordAgentCall({
|
|
224
|
+
store: runtime.artifactStore,
|
|
225
|
+
cache: runtime.callCache,
|
|
226
|
+
sequence,
|
|
227
|
+
callId,
|
|
228
|
+
fingerprint,
|
|
229
|
+
result: cachedResult
|
|
230
|
+
});
|
|
231
|
+
return cachedResult;
|
|
232
|
+
}
|
|
233
|
+
const task = {
|
|
234
|
+
id: normalizedId,
|
|
235
|
+
provider: normalizedProvider,
|
|
236
|
+
model: resolved.model,
|
|
237
|
+
permissions: resolvedPermissions,
|
|
238
|
+
metadata: {
|
|
239
|
+
...input.metadata,
|
|
240
|
+
...originMetadata,
|
|
241
|
+
modelResolutionSource: resolved.source
|
|
242
|
+
},
|
|
243
|
+
run: async (schedulerSignal) => {
|
|
244
|
+
let finalSignal = schedulerSignal;
|
|
245
|
+
let onAbort;
|
|
246
|
+
const invocationSignal = activeInvocation?.signal;
|
|
247
|
+
if ((activePipeline && activePipeline.stageSignal) || invocationSignal) {
|
|
248
|
+
const combinedController = new AbortController();
|
|
249
|
+
onAbort = () => {
|
|
250
|
+
combinedController.abort(schedulerSignal.reason || activePipeline?.stageSignal?.reason || invocationSignal?.reason || "Aborted");
|
|
251
|
+
};
|
|
252
|
+
if (schedulerSignal.aborted) {
|
|
253
|
+
combinedController.abort(schedulerSignal.reason);
|
|
254
|
+
}
|
|
255
|
+
else if (activePipeline?.stageSignal?.aborted) {
|
|
256
|
+
combinedController.abort(activePipeline.stageSignal.reason);
|
|
257
|
+
}
|
|
258
|
+
else if (invocationSignal?.aborted) {
|
|
259
|
+
combinedController.abort(invocationSignal.reason);
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
schedulerSignal.addEventListener("abort", onAbort);
|
|
263
|
+
if (activePipeline?.stageSignal) {
|
|
264
|
+
activePipeline.stageSignal.addEventListener("abort", onAbort);
|
|
265
|
+
}
|
|
266
|
+
invocationSignal?.addEventListener("abort", onAbort);
|
|
267
|
+
}
|
|
268
|
+
finalSignal = combinedController.signal;
|
|
269
|
+
}
|
|
270
|
+
const execInput = {
|
|
271
|
+
id: normalizedId,
|
|
272
|
+
provider: normalizedProvider,
|
|
273
|
+
prompt: input.prompt,
|
|
274
|
+
timeoutMs: normalizedTimeoutMs,
|
|
275
|
+
cwd: normalizedCwd,
|
|
276
|
+
permissions: resolvedPermissions,
|
|
277
|
+
signal: finalSignal,
|
|
278
|
+
metadata: {
|
|
279
|
+
...input.metadata,
|
|
280
|
+
...originMetadata,
|
|
281
|
+
modelResolutionSource: resolved.source
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
if (input.label !== undefined)
|
|
285
|
+
execInput.label = input.label;
|
|
286
|
+
if (resolved.model !== undefined)
|
|
287
|
+
execInput.model = resolved.model;
|
|
288
|
+
if (input.schema !== undefined)
|
|
289
|
+
execInput.schema = input.schema;
|
|
290
|
+
if (input.structuredOutput !== undefined)
|
|
291
|
+
execInput.structuredOutput = input.structuredOutput;
|
|
292
|
+
try {
|
|
293
|
+
return await runtime.agentExecutor.execute(execInput);
|
|
294
|
+
}
|
|
295
|
+
finally {
|
|
296
|
+
if (onAbort) {
|
|
297
|
+
schedulerSignal.removeEventListener("abort", onAbort);
|
|
298
|
+
if (activePipeline?.stageSignal) {
|
|
299
|
+
activePipeline.stageSignal.removeEventListener("abort", onAbort);
|
|
300
|
+
}
|
|
301
|
+
invocationSignal?.removeEventListener("abort", onAbort);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
if (input.label !== undefined) {
|
|
307
|
+
task.label = input.label;
|
|
308
|
+
}
|
|
309
|
+
const scheduleOptions = {
|
|
310
|
+
provider: normalizedProvider,
|
|
311
|
+
model: resolved.model,
|
|
312
|
+
timeoutMs: normalizedTimeoutMs,
|
|
313
|
+
failFast: runtime.failFast,
|
|
314
|
+
cwd: normalizedCwd
|
|
315
|
+
};
|
|
316
|
+
if (activeInvocation?.concurrencyBudget) {
|
|
317
|
+
await activeInvocation.concurrencyBudget.acquire();
|
|
318
|
+
}
|
|
319
|
+
try {
|
|
320
|
+
const result = await runtime.scheduler.schedule(task, scheduleOptions);
|
|
321
|
+
runtime.agentResults.push(result);
|
|
322
|
+
await recordAgentCall({
|
|
323
|
+
store: runtime.artifactStore,
|
|
324
|
+
cache: runtime.callCache,
|
|
325
|
+
sequence,
|
|
326
|
+
callId,
|
|
327
|
+
fingerprint,
|
|
328
|
+
result
|
|
329
|
+
});
|
|
330
|
+
if (!result.ok && result.error?.code === ErrorCode.PROVIDER_UNAVAILABLE) {
|
|
331
|
+
throw new OpenDynamicWorkflowError(ErrorCode.PROVIDER_UNAVAILABLE, result.error.message);
|
|
332
|
+
}
|
|
333
|
+
return result;
|
|
334
|
+
}
|
|
335
|
+
finally {
|
|
336
|
+
if (activeInvocation?.concurrencyBudget) {
|
|
337
|
+
activeInvocation.concurrencyBudget.release();
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
const runAgentCall = async (input) => {
|
|
342
|
+
if (!input || typeof input !== "object") {
|
|
343
|
+
throw new InvalidDslCallError("agent() requires an input object.");
|
|
344
|
+
}
|
|
345
|
+
if ("definition" in input && input.definition !== undefined) {
|
|
346
|
+
if (!runtime.sharedAgentRegistry) {
|
|
347
|
+
throw new OpenDynamicWorkflowError(ErrorCode.SHARED_AGENT_NOT_FOUND, "Shared agent registry is not available.");
|
|
348
|
+
}
|
|
349
|
+
const activePipeline = getActivePipelineContext();
|
|
350
|
+
const activeInvocation = getActiveWorkflowInvocation();
|
|
351
|
+
try {
|
|
352
|
+
return await executeSharedAgent({
|
|
353
|
+
sharedAgentId: input.definition,
|
|
354
|
+
context: input,
|
|
355
|
+
origin: activePipeline ? "pipeline-stage" : "workflow",
|
|
356
|
+
pipeline: activePipeline ? {
|
|
357
|
+
pipelineId: activePipeline.pipelineId,
|
|
358
|
+
itemIndex: activePipeline.itemIndex,
|
|
359
|
+
stageIndex: activePipeline.stageIndex,
|
|
360
|
+
stageName: activePipeline.stageName,
|
|
361
|
+
pipelineLabel: activePipeline.pipelineLabel
|
|
362
|
+
} : undefined
|
|
363
|
+
}, {
|
|
364
|
+
registry: runtime.sharedAgentRegistry,
|
|
365
|
+
config: runtime.config,
|
|
366
|
+
runId: runtime.runId,
|
|
367
|
+
cwd: runtime.cwd,
|
|
368
|
+
artifactsDir: runtime.artifactsDir,
|
|
369
|
+
signal: activeInvocation?.signal || runtime.abortController.signal,
|
|
370
|
+
agent: async (innerInput) => {
|
|
371
|
+
if ("definition" in innerInput && innerInput.definition !== undefined) {
|
|
372
|
+
throw new OpenDynamicWorkflowError(ErrorCode.SHARED_AGENT_RUNTIME_FAILED, "Nested shared agent definitions are not supported.");
|
|
373
|
+
}
|
|
374
|
+
return runDirectAgent(innerInput);
|
|
375
|
+
},
|
|
376
|
+
log: logWorkflow
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
catch (err) {
|
|
380
|
+
if (err instanceof OpenDynamicWorkflowError && err.code === ErrorCode.SHARED_AGENT_CONTEXT_VALIDATION_FAILED) {
|
|
381
|
+
let failureAgentId = input.id;
|
|
382
|
+
if (!failureAgentId) {
|
|
383
|
+
if (activePipeline) {
|
|
384
|
+
activePipeline.agentCounter++;
|
|
385
|
+
failureAgentId = createPipelineAgentId({
|
|
386
|
+
pipelineId: activePipeline.pipelineId,
|
|
387
|
+
itemIndex: activePipeline.itemIndex,
|
|
388
|
+
stageName: activePipeline.stageName,
|
|
389
|
+
suffix: activePipeline.agentCounter.toString()
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
failureAgentId = runtime.idGenerator ? runtime.idGenerator.nextId("agent") : `agent-${++runtime.agentCounter}`;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
if (activePipeline) {
|
|
397
|
+
recordChildAgentId(failureAgentId);
|
|
398
|
+
}
|
|
399
|
+
const failureResult = {
|
|
400
|
+
ok: false,
|
|
401
|
+
status: "failed",
|
|
402
|
+
id: failureAgentId,
|
|
403
|
+
label: input.definition,
|
|
404
|
+
provider: "mock",
|
|
405
|
+
stdout: "",
|
|
406
|
+
stderr: err.message,
|
|
407
|
+
exitCode: null,
|
|
408
|
+
durationMs: 0,
|
|
409
|
+
artifacts: {
|
|
410
|
+
dir: "",
|
|
411
|
+
promptPath: "",
|
|
412
|
+
stdoutPath: "",
|
|
413
|
+
stderrPath: ""
|
|
414
|
+
},
|
|
415
|
+
error: serializeError(err),
|
|
416
|
+
permissions: { mode: "default" },
|
|
417
|
+
metadata: {
|
|
418
|
+
sharedAgentId: input.definition,
|
|
419
|
+
sharedAgentSource: "registry",
|
|
420
|
+
...(activePipeline ? {
|
|
421
|
+
pipelineId: activePipeline.pipelineId,
|
|
422
|
+
itemIndex: activePipeline.itemIndex,
|
|
423
|
+
stageIndex: activePipeline.stageIndex,
|
|
424
|
+
stageName: activePipeline.stageName,
|
|
425
|
+
pipelineLabel: activePipeline.pipelineLabel
|
|
426
|
+
} : {})
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
runtime.agentResults.push(failureResult);
|
|
430
|
+
throw err;
|
|
431
|
+
}
|
|
432
|
+
throw err;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return runDirectAgent(input);
|
|
436
|
+
};
|
|
437
|
+
const runTool = async (input) => {
|
|
438
|
+
const scope = assertToolAllowed();
|
|
439
|
+
const normalizedInput = normalizeToolCallInput(input, runtime);
|
|
440
|
+
if (!runtime.toolRegistry || !runtime.toolExecutor) {
|
|
441
|
+
throw new OpenDynamicWorkflowError(ErrorCode.TOOL_INVALID_CONTEXT, "tool() is not configured for this run.");
|
|
442
|
+
}
|
|
443
|
+
const definition = runtime.toolRegistry.require(normalizedInput.definition);
|
|
444
|
+
const inputValidation = definition.validateInput(normalizedInput.args);
|
|
445
|
+
if (!inputValidation.ok) {
|
|
446
|
+
const errors = inputValidation.errors.map(e => `${e.path} ${e.message}`).join(", ");
|
|
447
|
+
throw new OpenDynamicWorkflowError(ErrorCode.TOOL_INVALID_INPUT, `Input validation failed for tool '${normalizedInput.definition}': ${errors}`);
|
|
448
|
+
}
|
|
449
|
+
let toolCallId = normalizedInput.id;
|
|
450
|
+
if (!toolCallId) {
|
|
451
|
+
toolCallId = nextToolCallId(runtime, normalizedInput.definition);
|
|
452
|
+
}
|
|
453
|
+
runtime.toolCallIds?.add(toolCallId);
|
|
454
|
+
const failureMode = normalizedInput.failureMode || "throw";
|
|
455
|
+
const activeInvocation = getActiveWorkflowInvocation();
|
|
456
|
+
const preparedCall = {
|
|
457
|
+
toolCallId,
|
|
458
|
+
definition,
|
|
459
|
+
args: cloneJsonValue(normalizedInput.args, "tool args"),
|
|
460
|
+
label: normalizedInput.label,
|
|
461
|
+
failureMode,
|
|
462
|
+
timeoutMs: normalizedInput.timeoutMs || definition.definition.defaultTimeoutMs,
|
|
463
|
+
deadline: activeInvocation?.deadlineAt,
|
|
464
|
+
metadata: normalizedInput.metadata ? cloneJsonValue(normalizedInput.metadata, "tool metadata") : undefined,
|
|
465
|
+
workflowInvocationId: scope.workflowInvocationId,
|
|
466
|
+
parentWorkflowInvocationId: scope.parentWorkflowInvocationId,
|
|
467
|
+
queuedAt: new Date().toISOString(),
|
|
468
|
+
artifactPath: `tools/${toolCallId}/output.json`,
|
|
469
|
+
invocationSignal: activeInvocation?.signal || runtime.abortController.signal
|
|
470
|
+
};
|
|
471
|
+
const isCacheable = !!definition.definition.cacheable;
|
|
472
|
+
let sequence;
|
|
473
|
+
let fingerprint;
|
|
474
|
+
let callId;
|
|
475
|
+
if (isCacheable) {
|
|
476
|
+
sequence = (runtime.callSequence ?? 0) + 1;
|
|
477
|
+
runtime.callSequence = sequence;
|
|
478
|
+
callId = normalizedInput.id ?? normalizedInput.label;
|
|
479
|
+
fingerprint = computeToolFingerprint({
|
|
480
|
+
definitionId: definition.definition.id,
|
|
481
|
+
args: preparedCall.args,
|
|
482
|
+
timeoutMs: preparedCall.timeoutMs,
|
|
483
|
+
metadata: preparedCall.metadata,
|
|
484
|
+
sourcePath: definition.sourcePath,
|
|
485
|
+
definitionVersion: definition.definition.metadata?.version
|
|
486
|
+
});
|
|
487
|
+
const cachedEntry = findPrefixCacheHit({
|
|
488
|
+
cache: runtime.callCache,
|
|
489
|
+
kind: "tool",
|
|
490
|
+
sequence,
|
|
491
|
+
callId,
|
|
492
|
+
fingerprint
|
|
493
|
+
});
|
|
494
|
+
if (cachedEntry && runtime.artifactStore && runtime.callCache?.previousRunRoot) {
|
|
495
|
+
const cachedResult = await materializeCachedToolResult({
|
|
496
|
+
store: runtime.artifactStore,
|
|
497
|
+
previousRunRoot: runtime.callCache.previousRunRoot,
|
|
498
|
+
previousRunId: runtime.callCache.previousRunId,
|
|
499
|
+
entry: cachedEntry,
|
|
500
|
+
currentToolCallId: toolCallId,
|
|
501
|
+
definitionId: definition.definition.id,
|
|
502
|
+
failureMode,
|
|
503
|
+
label: normalizedInput.label,
|
|
504
|
+
workflowInvocationId: scope.workflowInvocationId,
|
|
505
|
+
parentWorkflowInvocationId: scope.parentWorkflowInvocationId
|
|
506
|
+
});
|
|
507
|
+
runtime.eventSink?.emit("tool.cache_hit", {
|
|
508
|
+
toolCallId,
|
|
509
|
+
definition: definition.definition.id,
|
|
510
|
+
label: normalizedInput.label,
|
|
511
|
+
sequence,
|
|
512
|
+
callId,
|
|
513
|
+
previousRunId: runtime.callCache.previousRunId,
|
|
514
|
+
previousToolCallId: cachedEntry.toolCallId,
|
|
515
|
+
artifactPath: cachedResult.artifactPath
|
|
516
|
+
});
|
|
517
|
+
await recordToolCall({
|
|
518
|
+
store: runtime.artifactStore,
|
|
519
|
+
cache: runtime.callCache,
|
|
520
|
+
sequence,
|
|
521
|
+
callId,
|
|
522
|
+
fingerprint,
|
|
523
|
+
result: cachedResult
|
|
524
|
+
});
|
|
525
|
+
const toolResult = returnToolResult(cachedResult, failureMode);
|
|
526
|
+
runtime.toolResults.push(cachedResult);
|
|
527
|
+
if (runtime.toolExecutor) {
|
|
528
|
+
runtime.toolExecutor.addSummary({
|
|
529
|
+
toolCallId: cachedResult.toolCallId,
|
|
530
|
+
definition: cachedResult.definitionId,
|
|
531
|
+
status: cachedResult.status,
|
|
532
|
+
ok: cachedResult.ok,
|
|
533
|
+
workflowInvocationId: cachedResult.workflowInvocationId,
|
|
534
|
+
parentWorkflowInvocationId: cachedResult.parentWorkflowInvocationId,
|
|
535
|
+
durationMs: cachedResult.durationMs,
|
|
536
|
+
artifactPath: cachedResult.artifactPath,
|
|
537
|
+
cache: cachedResult.cache
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
return toolResult;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
else {
|
|
544
|
+
if (runtime.callCache) {
|
|
545
|
+
runtime.callCache.prefixCacheUsable = false;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
const result = await runtime.toolExecutor.execute(preparedCall);
|
|
549
|
+
if (isCacheable && sequence !== undefined && fingerprint !== undefined) {
|
|
550
|
+
await recordToolCall({
|
|
551
|
+
store: runtime.artifactStore,
|
|
552
|
+
cache: runtime.callCache,
|
|
553
|
+
sequence,
|
|
554
|
+
callId,
|
|
555
|
+
fingerprint,
|
|
556
|
+
result
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
runtime.toolResults.push(result);
|
|
560
|
+
return returnToolResult(result, failureMode);
|
|
561
|
+
};
|
|
562
|
+
function returnToolResult(result, failureMode) {
|
|
563
|
+
if (failureMode === "throw") {
|
|
564
|
+
if (!result.ok) {
|
|
565
|
+
let code = ErrorCode.TOOL_EXECUTION_FAILED;
|
|
566
|
+
if (result.status === "cancelled")
|
|
567
|
+
code = ErrorCode.TOOL_CANCELLED;
|
|
568
|
+
if (result.status === "timed_out")
|
|
569
|
+
code = ErrorCode.TOOL_TIMEOUT;
|
|
570
|
+
const error = result.error || { name: "ToolExecutionError", message: `Tool execution failed` };
|
|
571
|
+
throw new OpenDynamicWorkflowError(code, `Tool execution ${result.status}: ${error.message}`, { cause: error });
|
|
572
|
+
}
|
|
573
|
+
return result.output;
|
|
574
|
+
}
|
|
575
|
+
if (result.ok) {
|
|
576
|
+
return {
|
|
577
|
+
status: result.status,
|
|
578
|
+
ok: true,
|
|
579
|
+
toolCallId: result.toolCallId,
|
|
580
|
+
definition: result.definitionId,
|
|
581
|
+
value: result.output,
|
|
582
|
+
startedAt: result.startedAt,
|
|
583
|
+
finishedAt: result.finishedAt,
|
|
584
|
+
durationMs: result.durationMs,
|
|
585
|
+
artifactPath: result.artifactPath
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
return {
|
|
589
|
+
status: result.status,
|
|
590
|
+
ok: false,
|
|
591
|
+
toolCallId: result.toolCallId,
|
|
592
|
+
definition: result.definitionId,
|
|
593
|
+
error: result.error?.error || {
|
|
594
|
+
name: "ToolExecutionError",
|
|
595
|
+
message: result.error?.message || `Tool failed`,
|
|
596
|
+
code: result.error?.code
|
|
597
|
+
},
|
|
598
|
+
startedAt: result.startedAt,
|
|
599
|
+
finishedAt: result.finishedAt,
|
|
600
|
+
durationMs: result.durationMs,
|
|
601
|
+
artifactPath: result.artifactPath
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
return {
|
|
605
|
+
phase: (name) => {
|
|
606
|
+
if (!name || typeof name !== "string" || name.trim() === "") {
|
|
607
|
+
throw new InvalidDslCallError("phase() requires a non-empty string for the phase name.");
|
|
608
|
+
}
|
|
609
|
+
const activeInvocation = getActiveWorkflowInvocation();
|
|
610
|
+
const currentPhase = activeInvocation ? activeInvocation.currentPhase : runtime.currentPhase;
|
|
611
|
+
if (currentPhase) {
|
|
612
|
+
if (runtime.eventSink) {
|
|
613
|
+
runtime.eventSink.emit("phase.completed", { name: currentPhase });
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
if (activeInvocation) {
|
|
617
|
+
activeInvocation.currentPhase = name;
|
|
618
|
+
}
|
|
619
|
+
else {
|
|
620
|
+
runtime.currentPhase = name;
|
|
621
|
+
}
|
|
622
|
+
if (runtime.eventSink) {
|
|
623
|
+
runtime.eventSink.emit("phase.started", { name });
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
log: logWorkflow,
|
|
627
|
+
agent: runAgentCall,
|
|
628
|
+
tool: runTool,
|
|
629
|
+
parallel: async (tasks) => {
|
|
630
|
+
if (!tasks || typeof tasks !== "object") {
|
|
631
|
+
throw new InvalidDslCallError("parallel() requires an array or an object of task thunks.");
|
|
632
|
+
}
|
|
633
|
+
if (Array.isArray(tasks)) {
|
|
634
|
+
const promises = tasks.map((task, idx) => {
|
|
635
|
+
if (typeof task !== "function") {
|
|
636
|
+
throw new InvalidDslCallError(`parallel() task at index ${idx} must be a function.`);
|
|
637
|
+
}
|
|
638
|
+
return withToolForbidden("parallel-task", () => task());
|
|
639
|
+
});
|
|
640
|
+
return Promise.all(promises);
|
|
641
|
+
}
|
|
642
|
+
else {
|
|
643
|
+
const keys = Object.keys(tasks);
|
|
644
|
+
const promises = keys.map((key) => {
|
|
645
|
+
const task = tasks[key];
|
|
646
|
+
if (typeof task !== "function") {
|
|
647
|
+
throw new InvalidDslCallError(`parallel() task '${key}' must be a function.`);
|
|
648
|
+
}
|
|
649
|
+
return withToolForbidden("parallel-task", () => task());
|
|
650
|
+
});
|
|
651
|
+
const results = await Promise.all(promises);
|
|
652
|
+
const resultObj = {};
|
|
653
|
+
for (let i = 0; i < keys.length; i++) {
|
|
654
|
+
const key = keys[i];
|
|
655
|
+
resultObj[key] = results[i];
|
|
656
|
+
}
|
|
657
|
+
return resultObj;
|
|
658
|
+
}
|
|
659
|
+
},
|
|
660
|
+
pipeline: async (items, stages, options) => {
|
|
661
|
+
const activeInvocation = getActiveWorkflowInvocation();
|
|
662
|
+
return runPipeline({
|
|
663
|
+
items,
|
|
664
|
+
stages,
|
|
665
|
+
options: options || {},
|
|
666
|
+
runtime,
|
|
667
|
+
signal: activeInvocation?.signal || runtime.abortController.signal
|
|
668
|
+
});
|
|
669
|
+
},
|
|
670
|
+
workflow: async (input) => {
|
|
671
|
+
const activeInvocation = getActiveWorkflowInvocation();
|
|
672
|
+
if (!activeInvocation) {
|
|
673
|
+
throw new OpenDynamicWorkflowError(ErrorCode.WORKFLOW_FAILED, "workflow() can only be called from within a workflow invocation.");
|
|
674
|
+
}
|
|
675
|
+
if (!runtime.invocationManager) {
|
|
676
|
+
throw new OpenDynamicWorkflowError(ErrorCode.WORKFLOW_FAILED, "Workflow invocation manager is not available.");
|
|
677
|
+
}
|
|
678
|
+
const result = await runtime.invocationManager.invokeChild(activeInvocation, input);
|
|
679
|
+
return result;
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
//# sourceMappingURL=dsl.js.map
|