@relayflows/sdk 2.0.9 → 2.0.10
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/adapters/base.d.ts +46 -0
- package/dist/adapters/base.d.ts.map +1 -0
- package/dist/adapters/base.js +15 -0
- package/dist/adapters/base.js.map +1 -0
- package/dist/adapters/claude.d.ts +5 -0
- package/dist/adapters/claude.d.ts.map +1 -0
- package/dist/adapters/claude.js +44 -0
- package/dist/adapters/claude.js.map +1 -0
- package/dist/adapters/codex.d.ts +5 -0
- package/dist/adapters/codex.d.ts.map +1 -0
- package/dist/adapters/codex.js +45 -0
- package/dist/adapters/codex.js.map +1 -0
- package/dist/adapters/index.d.ts +14 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +29 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/wrapper.d.ts +12 -0
- package/dist/adapters/wrapper.d.ts.map +1 -0
- package/dist/adapters/wrapper.js +31 -0
- package/dist/adapters/wrapper.js.map +1 -0
- package/dist/agent-relay-transport.d.ts +84 -0
- package/dist/agent-relay-transport.d.ts.map +1 -0
- package/dist/agent-relay-transport.js +134 -0
- package/dist/agent-relay-transport.js.map +1 -0
- package/dist/authored-budget.d.ts +13 -0
- package/dist/authored-budget.d.ts.map +1 -0
- package/dist/authored-budget.js +78 -0
- package/dist/authored-budget.js.map +1 -0
- package/dist/authored-flow-error.d.ts +2 -21
- package/dist/authored-flow-error.d.ts.map +1 -1
- package/dist/authored-flow-error.js +1 -12
- package/dist/authored-flow-error.js.map +1 -1
- package/dist/authored-flow-executor.d.ts +13 -7
- package/dist/authored-flow-executor.d.ts.map +1 -1
- package/dist/authored-flow-executor.js +116 -235
- package/dist/authored-flow-executor.js.map +1 -1
- package/dist/authored-flow-loader.d.ts +10 -1
- package/dist/authored-flow-loader.d.ts.map +1 -1
- package/dist/authored-flow-loader.js +56 -3
- package/dist/authored-flow-loader.js.map +1 -1
- package/dist/authored-flow-operation.d.ts +9 -1
- package/dist/authored-flow-operation.d.ts.map +1 -1
- package/dist/authored-flow-operation.js +35 -4
- package/dist/authored-flow-operation.js.map +1 -1
- package/dist/authored-helper-effect.d.ts +12 -0
- package/dist/authored-helper-effect.d.ts.map +1 -0
- package/dist/authored-helper-effect.js +144 -0
- package/dist/authored-helper-effect.js.map +1 -0
- package/dist/authored-mcp.d.ts +17 -0
- package/dist/authored-mcp.d.ts.map +1 -0
- package/dist/authored-mcp.js +171 -0
- package/dist/authored-mcp.js.map +1 -0
- package/dist/authored-memory.d.ts +7 -0
- package/dist/authored-memory.d.ts.map +1 -0
- package/dist/authored-memory.js +60 -0
- package/dist/authored-memory.js.map +1 -0
- package/dist/authored-plugin-effect.d.ts +16 -0
- package/dist/authored-plugin-effect.d.ts.map +1 -0
- package/dist/authored-plugin-effect.js +163 -0
- package/dist/authored-plugin-effect.js.map +1 -0
- package/dist/authored-step-output.d.ts +23 -0
- package/dist/authored-step-output.d.ts.map +1 -0
- package/dist/authored-step-output.js +67 -0
- package/dist/authored-step-output.js.map +1 -0
- package/dist/authored-worker-step.d.ts +15 -0
- package/dist/authored-worker-step.d.ts.map +1 -0
- package/dist/authored-worker-step.js +136 -0
- package/dist/authored-worker-step.js.map +1 -0
- package/dist/budget-preflight.d.ts +5 -0
- package/dist/budget-preflight.d.ts.map +1 -0
- package/dist/budget-preflight.js +33 -0
- package/dist/budget-preflight.js.map +1 -0
- package/dist/budget.d.ts +14 -0
- package/dist/budget.d.ts.map +1 -0
- package/dist/budget.js +52 -0
- package/dist/budget.js.map +1 -0
- package/dist/bundle-transport.d.ts +18 -0
- package/dist/bundle-transport.d.ts.map +1 -0
- package/dist/bundle-transport.js +111 -0
- package/dist/bundle-transport.js.map +1 -0
- package/dist/bundle-typescript.d.ts +8 -0
- package/dist/bundle-typescript.d.ts.map +1 -0
- package/dist/bundle-typescript.js +108 -0
- package/dist/bundle-typescript.js.map +1 -0
- package/dist/bundle.d.ts +25 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +199 -0
- package/dist/bundle.js.map +1 -0
- package/dist/child-stop.d.ts +59 -0
- package/dist/child-stop.d.ts.map +1 -0
- package/dist/child-stop.js +94 -0
- package/dist/child-stop.js.map +1 -0
- package/dist/cli/add.d.ts +6 -0
- package/dist/cli/add.d.ts.map +1 -0
- package/dist/cli/add.js +47 -0
- package/dist/cli/add.js.map +1 -0
- package/dist/cli/build.d.ts +13 -0
- package/dist/cli/build.d.ts.map +1 -0
- package/dist/cli/build.js +224 -0
- package/dist/cli/build.js.map +1 -0
- package/dist/cli/bundle-preflight.d.ts +5 -0
- package/dist/cli/bundle-preflight.d.ts.map +1 -0
- package/dist/cli/bundle-preflight.js +28 -0
- package/dist/cli/bundle-preflight.js.map +1 -0
- package/dist/cli/check-helper-body.d.ts +4 -0
- package/dist/cli/check-helper-body.d.ts.map +1 -0
- package/dist/cli/check-helper-body.js +15 -0
- package/dist/cli/check-helper-body.js.map +1 -0
- package/dist/cli/check-triggers.d.ts +14 -0
- package/dist/cli/check-triggers.d.ts.map +1 -0
- package/dist/cli/check-triggers.js +37 -0
- package/dist/cli/check-triggers.js.map +1 -0
- package/dist/cli/check-typescript.d.ts +20 -0
- package/dist/cli/check-typescript.d.ts.map +1 -0
- package/dist/cli/check-typescript.js +54 -0
- package/dist/cli/check-typescript.js.map +1 -0
- package/dist/cli/check.d.ts +36 -3
- package/dist/cli/check.d.ts.map +1 -1
- package/dist/cli/check.js +122 -11
- package/dist/cli/check.js.map +1 -1
- package/dist/cli/cloud-run.d.ts +8 -0
- package/dist/cli/cloud-run.d.ts.map +1 -0
- package/dist/cli/cloud-run.js +50 -0
- package/dist/cli/cloud-run.js.map +1 -0
- package/dist/cli/deploy.d.ts +9 -0
- package/dist/cli/deploy.d.ts.map +1 -0
- package/dist/cli/deploy.js +58 -0
- package/dist/cli/deploy.js.map +1 -0
- package/dist/cli/deterministic-failure.d.ts +5 -0
- package/dist/cli/deterministic-failure.d.ts.map +1 -0
- package/dist/cli/deterministic-failure.js +66 -0
- package/dist/cli/deterministic-failure.js.map +1 -0
- package/dist/cli/direct-run.d.ts.map +1 -1
- package/dist/cli/direct-run.js +83 -18
- package/dist/cli/direct-run.js.map +1 -1
- package/dist/cli/hn-monitor.d.ts.map +1 -1
- package/dist/cli/hn-monitor.js +2 -1
- package/dist/cli/hn-monitor.js.map +1 -1
- package/dist/cli/replay.d.ts +12 -0
- package/dist/cli/replay.d.ts.map +1 -0
- package/dist/cli/replay.js +82 -0
- package/dist/cli/replay.js.map +1 -0
- package/dist/cli/reuse.d.ts +8 -0
- package/dist/cli/reuse.d.ts.map +1 -0
- package/dist/cli/reuse.js +25 -0
- package/dist/cli/reuse.js.map +1 -0
- package/dist/cli/run-digest.d.ts +4 -0
- package/dist/cli/run-digest.d.ts.map +1 -0
- package/dist/cli/run-digest.js +24 -0
- package/dist/cli/run-digest.js.map +1 -0
- package/dist/cli/run.d.ts +16 -5
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +99 -17
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/serve-webhook.d.ts +40 -0
- package/dist/cli/serve-webhook.d.ts.map +1 -0
- package/dist/cli/serve-webhook.js +233 -0
- package/dist/cli/serve-webhook.js.map +1 -0
- package/dist/cli/tick-runner.d.ts.map +1 -1
- package/dist/cli/tick-runner.js +2 -1
- package/dist/cli/tick-runner.js.map +1 -1
- package/dist/cli-adapter.d.ts +8 -14
- package/dist/cli-adapter.d.ts.map +1 -1
- package/dist/cli-adapter.js +19 -64
- package/dist/cli-adapter.js.map +1 -1
- package/dist/cli-watch.d.ts +13 -0
- package/dist/cli-watch.d.ts.map +1 -0
- package/dist/cli-watch.js +185 -0
- package/dist/cli-watch.js.map +1 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +387 -14
- package/dist/cli.js.map +1 -1
- package/dist/cloud-http.d.ts +22 -0
- package/dist/cloud-http.d.ts.map +1 -0
- package/dist/cloud-http.js +84 -0
- package/dist/cloud-http.js.map +1 -0
- package/dist/cloud-run.d.ts +38 -0
- package/dist/cloud-run.d.ts.map +1 -0
- package/dist/cloud-run.js +112 -0
- package/dist/cloud-run.js.map +1 -0
- package/dist/compile.d.ts +21 -3
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +97 -23
- package/dist/compile.js.map +1 -1
- package/dist/create-flow.d.ts +17 -0
- package/dist/create-flow.d.ts.map +1 -0
- package/dist/create-flow.js +72 -0
- package/dist/create-flow.js.map +1 -0
- package/dist/daemon-connection.d.ts +14 -0
- package/dist/daemon-connection.d.ts.map +1 -1
- package/dist/daemon-connection.js +33 -1
- package/dist/daemon-connection.js.map +1 -1
- package/dist/demo-hn-monitor.js +2 -1
- package/dist/demo-hn-monitor.js.map +1 -1
- package/dist/effect-channel.d.ts +30 -0
- package/dist/effect-channel.d.ts.map +1 -0
- package/dist/effect-channel.js +71 -0
- package/dist/effect-channel.js.map +1 -0
- package/dist/failure-kinds.d.ts +14 -3
- package/dist/failure-kinds.d.ts.map +1 -1
- package/dist/failure-kinds.js +27 -0
- package/dist/failure-kinds.js.map +1 -1
- package/dist/gate-contract.d.ts.map +1 -1
- package/dist/gate-contract.js +9 -0
- package/dist/gate-contract.js.map +1 -1
- package/dist/helper-preflight.d.ts +18 -0
- package/dist/helper-preflight.d.ts.map +1 -0
- package/dist/helper-preflight.js +32 -0
- package/dist/helper-preflight.js.map +1 -0
- package/dist/helper-storage.d.ts +5 -0
- package/dist/helper-storage.d.ts.map +1 -0
- package/dist/helper-storage.js +31 -0
- package/dist/helper-storage.js.map +1 -0
- package/dist/helper-writeback.d.ts +12 -0
- package/dist/helper-writeback.d.ts.map +1 -0
- package/dist/helper-writeback.js +95 -0
- package/dist/helper-writeback.js.map +1 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/input-binding.d.ts +4 -0
- package/dist/input-binding.d.ts.map +1 -0
- package/dist/input-binding.js +78 -0
- package/dist/input-binding.js.map +1 -0
- package/dist/journal-client.d.ts +12 -4
- package/dist/journal-client.d.ts.map +1 -1
- package/dist/journal-client.js +17 -6
- package/dist/journal-client.js.map +1 -1
- package/dist/journal-offset.d.ts +3 -0
- package/dist/journal-offset.d.ts.map +1 -0
- package/dist/journal-offset.js +69 -0
- package/dist/journal-offset.js.map +1 -0
- package/dist/journal-reader.d.ts +30 -0
- package/dist/journal-reader.d.ts.map +1 -0
- package/dist/journal-reader.js +156 -0
- package/dist/journal-reader.js.map +1 -0
- package/dist/json-schema.d.ts +2 -0
- package/dist/json-schema.d.ts.map +1 -1
- package/dist/json-schema.js +38 -22
- package/dist/json-schema.js.map +1 -1
- package/dist/llm-worker.d.ts +16 -0
- package/dist/llm-worker.d.ts.map +1 -0
- package/dist/llm-worker.js +79 -0
- package/dist/llm-worker.js.map +1 -0
- package/dist/local-agent.d.ts +8 -0
- package/dist/local-agent.d.ts.map +1 -0
- package/dist/local-agent.js +25 -0
- package/dist/local-agent.js.map +1 -0
- package/dist/mcp-client.d.ts +15 -0
- package/dist/mcp-client.d.ts.map +1 -0
- package/dist/mcp-client.js +104 -0
- package/dist/mcp-client.js.map +1 -0
- package/dist/mcp-config.d.ts +4 -0
- package/dist/mcp-config.d.ts.map +1 -0
- package/dist/mcp-config.js +61 -0
- package/dist/mcp-config.js.map +1 -0
- package/dist/mcp-stdio.d.ts +24 -0
- package/dist/mcp-stdio.d.ts.map +1 -0
- package/dist/mcp-stdio.js +89 -0
- package/dist/mcp-stdio.js.map +1 -0
- package/dist/model-pricing.d.ts +22 -0
- package/dist/model-pricing.d.ts.map +1 -0
- package/dist/model-pricing.js +30 -0
- package/dist/model-pricing.js.map +1 -0
- package/dist/mount-registry.d.ts +9 -0
- package/dist/mount-registry.d.ts.map +1 -0
- package/dist/mount-registry.js +47 -0
- package/dist/mount-registry.js.map +1 -0
- package/dist/named-gate-lowering.d.ts +9 -0
- package/dist/named-gate-lowering.d.ts.map +1 -0
- package/dist/named-gate-lowering.js +152 -0
- package/dist/named-gate-lowering.js.map +1 -0
- package/dist/named-gates.d.ts +10 -0
- package/dist/named-gates.d.ts.map +1 -0
- package/dist/named-gates.js +69 -0
- package/dist/named-gates.js.map +1 -0
- package/dist/observer-link.d.ts +129 -0
- package/dist/observer-link.d.ts.map +1 -0
- package/dist/observer-link.js +274 -0
- package/dist/observer-link.js.map +1 -0
- package/dist/plugin-loader.d.ts +13 -0
- package/dist/plugin-loader.d.ts.map +1 -0
- package/dist/plugin-loader.js +110 -0
- package/dist/plugin-loader.js.map +1 -0
- package/dist/plugin-manifest.d.ts +27 -0
- package/dist/plugin-manifest.d.ts.map +1 -0
- package/dist/plugin-manifest.js +89 -0
- package/dist/plugin-manifest.js.map +1 -0
- package/dist/preflight.d.ts +26 -2
- package/dist/preflight.d.ts.map +1 -1
- package/dist/preflight.js +175 -1
- package/dist/preflight.js.map +1 -1
- package/dist/progress.d.ts +14 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +39 -0
- package/dist/progress.js.map +1 -0
- package/dist/protocol.d.ts +11 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/pty-sidechannel.d.ts +14 -0
- package/dist/pty-sidechannel.d.ts.map +1 -0
- package/dist/pty-sidechannel.js +103 -0
- package/dist/pty-sidechannel.js.map +1 -0
- package/dist/scope-compiler.d.ts +52 -0
- package/dist/scope-compiler.d.ts.map +1 -0
- package/dist/scope-compiler.js +62 -0
- package/dist/scope-compiler.js.map +1 -0
- package/dist/slack-preflight.d.ts +6 -0
- package/dist/slack-preflight.d.ts.map +1 -0
- package/dist/slack-preflight.js +28 -0
- package/dist/slack-preflight.js.map +1 -0
- package/dist/slack-writeback.d.ts +40 -0
- package/dist/slack-writeback.d.ts.map +1 -0
- package/dist/slack-writeback.js +60 -0
- package/dist/slack-writeback.js.map +1 -0
- package/dist/spec.d.ts +134 -4
- package/dist/spec.d.ts.map +1 -1
- package/dist/spec.js.map +1 -1
- package/dist/step-dependencies.d.ts.map +1 -1
- package/dist/step-dependencies.js +2 -1
- package/dist/step-dependencies.js.map +1 -1
- package/dist/step-fields.d.ts +4 -4
- package/dist/step-fields.d.ts.map +1 -1
- package/dist/step-fields.js +5 -2
- package/dist/step-fields.js.map +1 -1
- package/dist/trigger-executor.d.ts +7 -0
- package/dist/trigger-executor.d.ts.map +1 -0
- package/dist/trigger-executor.js +35 -0
- package/dist/trigger-executor.js.map +1 -0
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +53 -6
- package/dist/validate.js.map +1 -1
- package/dist/webhook-rate-limit.d.ts +29 -0
- package/dist/webhook-rate-limit.d.ts.map +1 -0
- package/dist/webhook-rate-limit.js +38 -0
- package/dist/webhook-rate-limit.js.map +1 -0
- package/dist/webhook-signature.d.ts +22 -0
- package/dist/webhook-signature.d.ts.map +1 -0
- package/dist/webhook-signature.js +53 -0
- package/dist/webhook-signature.js.map +1 -0
- package/dist/worker-cli.d.ts +13 -1
- package/dist/worker-cli.d.ts.map +1 -1
- package/dist/worker-cli.js +133 -12
- package/dist/worker-cli.js.map +1 -1
- package/dist/worker-input.d.ts +4 -0
- package/dist/worker-input.d.ts.map +1 -0
- package/dist/worker-input.js +14 -0
- package/dist/worker-input.js.map +1 -0
- package/dist/worker-lease.d.ts +5 -0
- package/dist/worker-lease.d.ts.map +1 -0
- package/dist/worker-lease.js +80 -0
- package/dist/worker-lease.js.map +1 -0
- package/dist/worker-spend.d.ts +19 -0
- package/dist/worker-spend.d.ts.map +1 -0
- package/dist/worker-spend.js +22 -0
- package/dist/worker-spend.js.map +1 -0
- package/dist/worker-usage.d.ts +7 -0
- package/dist/worker-usage.d.ts.map +1 -0
- package/dist/worker-usage.js +54 -0
- package/dist/worker-usage.js.map +1 -0
- package/dist/worker.d.ts +2 -0
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +22 -8
- package/dist/worker.js.map +1 -1
- package/dist/wrapper-session.d.ts +1 -1
- package/dist/wrapper-session.d.ts.map +1 -1
- package/dist/wrapper-session.js +56 -19
- package/dist/wrapper-session.js.map +1 -1
- package/dist/yaml-helper-effect.d.ts +8 -0
- package/dist/yaml-helper-effect.d.ts.map +1 -0
- package/dist/yaml-helper-effect.js +79 -0
- package/dist/yaml-helper-effect.js.map +1 -0
- package/dist/yaml-helpers.d.ts +18 -0
- package/dist/yaml-helpers.d.ts.map +1 -0
- package/dist/yaml-helpers.js +116 -0
- package/dist/yaml-helpers.js.map +1 -0
- package/package.json +19 -2
- package/src/adapters/base.ts +53 -0
- package/src/adapters/claude.ts +55 -0
- package/src/adapters/codex.ts +56 -0
- package/src/adapters/index.ts +36 -0
- package/src/adapters/wrapper.ts +42 -0
- package/src/agent-relay-transport.ts +187 -0
- package/src/authored-budget.ts +69 -0
- package/src/authored-flow-error.ts +10 -10
- package/src/authored-flow-executor.ts +171 -347
- package/src/authored-flow-loader.ts +60 -3
- package/src/authored-flow-operation.ts +38 -5
- package/src/authored-helper-effect.ts +143 -0
- package/src/authored-mcp.ts +166 -0
- package/src/authored-memory.ts +55 -0
- package/src/authored-plugin-effect.ts +152 -0
- package/src/authored-step-output.ts +107 -0
- package/src/authored-worker-step.ts +181 -0
- package/src/budget-preflight.ts +31 -0
- package/src/budget.ts +49 -0
- package/src/bundle-transport.ts +79 -0
- package/src/bundle-typescript.ts +98 -0
- package/src/bundle.ts +182 -0
- package/src/child-stop.ts +138 -0
- package/src/cli/add.ts +45 -0
- package/src/cli/build.ts +214 -0
- package/src/cli/bundle-preflight.ts +28 -0
- package/src/cli/check-helper-body.ts +14 -0
- package/src/cli/check-triggers.ts +41 -0
- package/src/cli/check-typescript.ts +63 -0
- package/src/cli/check.ts +132 -14
- package/src/cli/cloud-run.ts +47 -0
- package/src/cli/deploy.ts +52 -0
- package/src/cli/deterministic-failure.ts +69 -0
- package/src/cli/direct-run.ts +79 -18
- package/src/cli/hn-monitor.ts +2 -1
- package/src/cli/replay.ts +81 -0
- package/src/cli/reuse.ts +23 -0
- package/src/cli/run-digest.ts +24 -0
- package/src/cli/run.ts +104 -21
- package/src/cli/serve-webhook.ts +246 -0
- package/src/cli/tick-runner.ts +2 -1
- package/src/cli-adapter.ts +31 -74
- package/src/cli-watch.ts +174 -0
- package/src/cli.ts +396 -17
- package/src/cloud-http.ts +100 -0
- package/src/cloud-run.ts +137 -0
- package/src/compile.ts +102 -23
- package/src/create-flow.ts +82 -0
- package/src/daemon-connection.ts +32 -1
- package/src/demo-hn-monitor.ts +2 -1
- package/src/effect-channel.ts +97 -0
- package/src/failure-kinds.ts +38 -0
- package/src/gate-contract.ts +7 -0
- package/src/helper-preflight.ts +34 -0
- package/src/helper-storage.ts +23 -0
- package/src/helper-writeback.ts +83 -0
- package/src/index.ts +26 -0
- package/src/input-binding.ts +76 -0
- package/src/journal-client.ts +20 -7
- package/src/journal-offset.ts +60 -0
- package/src/journal-reader.ts +165 -0
- package/src/json-schema.ts +34 -18
- package/src/llm-worker.ts +82 -0
- package/src/local-agent.ts +30 -0
- package/src/mcp-client.ts +97 -0
- package/src/mcp-config.ts +42 -0
- package/src/mcp-stdio.ts +84 -0
- package/src/model-pricing.ts +32 -0
- package/src/mount-registry.ts +44 -0
- package/src/named-gate-lowering.ts +147 -0
- package/src/named-gates.ts +76 -0
- package/src/observer-link.ts +368 -0
- package/src/plugin-loader.ts +88 -0
- package/src/plugin-manifest.ts +76 -0
- package/src/preflight.ts +178 -4
- package/src/progress.ts +51 -0
- package/src/protocol.ts +12 -0
- package/src/pty-sidechannel.ts +92 -0
- package/src/scope-compiler.ts +105 -0
- package/src/slack-preflight.ts +25 -0
- package/src/slack-writeback.ts +63 -0
- package/src/spec.ts +112 -4
- package/src/step-dependencies.ts +3 -1
- package/src/step-fields.ts +5 -2
- package/src/trigger-executor.ts +34 -0
- package/src/validate.ts +47 -6
- package/src/webhook-rate-limit.ts +69 -0
- package/src/webhook-signature.ts +74 -0
- package/src/worker-cli.ts +156 -11
- package/src/worker-input.ts +15 -0
- package/src/worker-lease.ts +85 -0
- package/src/worker-spend.ts +23 -0
- package/src/worker-usage.ts +48 -0
- package/src/worker.ts +27 -9
- package/src/wrapper-session.ts +50 -15
- package/src/yaml-helper-effect.ts +78 -0
- package/src/yaml-helpers.ts +131 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authored-budget.js","sourceRoot":"","sources":["../src/authored-budget.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,28 +1,9 @@
|
|
|
1
|
-
import type { CheckFailureKind } from './failure-kinds.js';
|
|
2
1
|
import type { CompletionReason as ProtocolCompletionReason, RunCompletionReason as ProtocolRunCompletionReason } from './protocol.js';
|
|
3
|
-
export type AuthoredFlowExecutionErrorCode = 'agent_cli_unresolved' | 'agent_parked' | 'duplicate_completion' | 'journal_protocol_violation' | 'missing_completion' | 'operation_after_completion' | 'operation_callback_failed' | 'step_failed' | 'unsupported_completion' | 'unsupported_gate' | 'unsupported_header' | 'unsettled_derived_work' | 'unsupported_promise_lifecycle' | 'unsupported_workspace_permission' | 'unawaited_step' | 'unsupported_verb';
|
|
2
|
+
export type AuthoredFlowExecutionErrorCode = 'helper_provider.mount_required' | 'helper_provider.unsupported' | 'helper_slack.credential_missing' | 'helper_slack.mount_required' | 'budget_syntax_invalid' | 'budget_missing_price' | 'agent_cli_unresolved' | 'agent_parked' | 'llm_cli_unresolved' | 'llm_parked' | 'duplicate_completion' | 'journal_protocol_violation' | 'missing_completion' | 'memory_unreachable' | 'operation_after_completion' | 'operation_callback_failed' | 'step_failed' | 'lease_exceeded' | 'unsupported_completion' | 'unsupported_gate' | 'unsupported_header' | 'unsettled_derived_work' | 'unsupported_promise_lifecycle' | 'unsupported_workspace_permission' | 'unawaited_step' | 'unsupported_verb';
|
|
4
3
|
export declare class AuthoredFlowExecutionError extends Error {
|
|
5
4
|
readonly code: AuthoredFlowExecutionErrorCode;
|
|
6
5
|
readonly completionReason?: (ProtocolCompletionReason | ProtocolRunCompletionReason) | undefined;
|
|
7
6
|
readonly runId?: string | undefined;
|
|
8
|
-
|
|
9
|
-
* Set only for `code === 'agent_cli_unresolved'`: the specific preflight
|
|
10
|
-
* refusal kind (`cli_missing`, `model_unknown`, `model_unavailable`, ...)
|
|
11
|
-
* `checkAuthoredFlow` actually produced, so a caller can distinguish a bad
|
|
12
|
-
* model declaration from a missing CLI the same way the declarative
|
|
13
|
-
* `flows check` path's `report.diagnostics[].kind` already lets it —
|
|
14
|
-
* collapsing every refusal to one generic code would lose that taxonomy.
|
|
15
|
-
*/
|
|
16
|
-
readonly refusalKind?: CheckFailureKind | undefined;
|
|
17
|
-
constructor(code: AuthoredFlowExecutionErrorCode, message: string, completionReason?: (ProtocolCompletionReason | ProtocolRunCompletionReason) | undefined, runId?: string | undefined,
|
|
18
|
-
/**
|
|
19
|
-
* Set only for `code === 'agent_cli_unresolved'`: the specific preflight
|
|
20
|
-
* refusal kind (`cli_missing`, `model_unknown`, `model_unavailable`, ...)
|
|
21
|
-
* `checkAuthoredFlow` actually produced, so a caller can distinguish a bad
|
|
22
|
-
* model declaration from a missing CLI the same way the declarative
|
|
23
|
-
* `flows check` path's `report.diagnostics[].kind` already lets it —
|
|
24
|
-
* collapsing every refusal to one generic code would lose that taxonomy.
|
|
25
|
-
*/
|
|
26
|
-
refusalKind?: CheckFailureKind | undefined);
|
|
7
|
+
constructor(code: AuthoredFlowExecutionErrorCode, message: string, completionReason?: (ProtocolCompletionReason | ProtocolRunCompletionReason) | undefined, runId?: string | undefined);
|
|
27
8
|
}
|
|
28
9
|
//# sourceMappingURL=authored-flow-error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authored-flow-error.d.ts","sourceRoot":"","sources":["../src/authored-flow-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"authored-flow-error.d.ts","sourceRoot":"","sources":["../src/authored-flow-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,IAAI,wBAAwB,EAC5C,mBAAmB,IAAI,2BAA2B,EACnD,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,8BAA8B,GACtC,gCAAgC,GAChC,6BAA6B,GAC7B,iCAAiC,GACjC,6BAA6B,GAC7B,uBAAuB,GACvB,sBAAsB,GACtB,sBAAsB,GACtB,cAAc,GACd,oBAAoB,GACpB,YAAY,GACZ,sBAAsB,GACtB,4BAA4B,GAC5B,oBAAoB,GACpB,oBAAoB,GACpB,4BAA4B,GAC5B,2BAA2B,GAC3B,aAAa,GACb,gBAAgB,GAChB,wBAAwB,GACxB,kBAAkB,GAClB,oBAAoB,GACpB,wBAAwB,GACxB,+BAA+B,GAC/B,kCAAkC,GAClC,gBAAgB,GAChB,kBAAkB,CAAC;AAEvB,qBAAa,0BAA2B,SAAQ,KAAK;IAEjD,QAAQ,CAAC,IAAI,EAAE,8BAA8B;IAE7C,QAAQ,CAAC,gBAAgB,CAAC,GAAE,wBAAwB,GAAG,2BAA2B;IAClF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM;gBAHd,IAAI,EAAE,8BAA8B,EAC7C,OAAO,EAAE,MAAM,EACN,gBAAgB,CAAC,GAAE,wBAAwB,GAAG,2BAA2B,aAAA,EACzE,KAAK,CAAC,EAAE,MAAM,YAAA;CAK1B"}
|
|
@@ -2,22 +2,11 @@ export class AuthoredFlowExecutionError extends Error {
|
|
|
2
2
|
code;
|
|
3
3
|
completionReason;
|
|
4
4
|
runId;
|
|
5
|
-
|
|
6
|
-
constructor(code, message, completionReason, runId,
|
|
7
|
-
/**
|
|
8
|
-
* Set only for `code === 'agent_cli_unresolved'`: the specific preflight
|
|
9
|
-
* refusal kind (`cli_missing`, `model_unknown`, `model_unavailable`, ...)
|
|
10
|
-
* `checkAuthoredFlow` actually produced, so a caller can distinguish a bad
|
|
11
|
-
* model declaration from a missing CLI the same way the declarative
|
|
12
|
-
* `flows check` path's `report.diagnostics[].kind` already lets it —
|
|
13
|
-
* collapsing every refusal to one generic code would lose that taxonomy.
|
|
14
|
-
*/
|
|
15
|
-
refusalKind) {
|
|
5
|
+
constructor(code, message, completionReason, runId) {
|
|
16
6
|
super(`${code}: ${message}`);
|
|
17
7
|
this.code = code;
|
|
18
8
|
this.completionReason = completionReason;
|
|
19
9
|
this.runId = runId;
|
|
20
|
-
this.refusalKind = refusalKind;
|
|
21
10
|
this.name = 'AuthoredFlowExecutionError';
|
|
22
11
|
}
|
|
23
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authored-flow-error.js","sourceRoot":"","sources":["../src/authored-flow-error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"authored-flow-error.js","sourceRoot":"","sources":["../src/authored-flow-error.ts"],"names":[],"mappings":"AAiCA,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAExC;IAEA;IACA;IAJX,YACW,IAAoC,EAC7C,OAAe,EACN,gBAAyE,EACzE,KAAc;QAEvB,KAAK,CAAC,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;QALpB,SAAI,GAAJ,IAAI,CAAgC;QAEpC,qBAAgB,GAAhB,gBAAgB,CAAyD;QACzE,UAAK,GAAL,KAAK,CAAS;QAGvB,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;IAC3C,CAAC;CACF"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type FlowCompletionReason } from '@relayflows/surface';
|
|
2
|
+
import { type FlowHandle } from '@relayflows/surface/runtime';
|
|
3
|
+
import { type ProgressEvent } from './progress.js';
|
|
2
4
|
import type { GetFlowDefinition } from './authored-flow-loader.js';
|
|
3
|
-
import {
|
|
5
|
+
import type { RunLifecycleOptions } from './cli/run.js';
|
|
4
6
|
import { AuthoredFlowExecutionError, type AuthoredFlowExecutionErrorCode } from './authored-flow-error.js';
|
|
5
7
|
import { JournalClient } from './journal-client.js';
|
|
6
|
-
import type { CompletionReason as ProtocolCompletionReason
|
|
8
|
+
import type { CompletionReason as ProtocolCompletionReason } from './protocol.js';
|
|
7
9
|
export { AuthoredFlowExecutionError, type AuthoredFlowExecutionErrorCode };
|
|
8
10
|
export interface AuthoredFlowJournalStep {
|
|
9
11
|
readonly id: string;
|
|
@@ -12,7 +14,7 @@ export interface AuthoredFlowJournalStep {
|
|
|
12
14
|
}
|
|
13
15
|
export interface AuthoredFlowExecutionResult {
|
|
14
16
|
readonly name: string;
|
|
15
|
-
readonly completionReason:
|
|
17
|
+
readonly completionReason: FlowCompletionReason;
|
|
16
18
|
readonly journalSteps: readonly AuthoredFlowJournalStep[];
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
@@ -20,9 +22,9 @@ export interface AuthoredFlowExecutionResult {
|
|
|
20
22
|
*
|
|
21
23
|
* This is deliberately not exported by the SDK package: without a durable
|
|
22
24
|
* authored root, it is not a resumable public runner. The seam is narrow: an
|
|
23
|
-
*
|
|
24
|
-
* `f.done("success")`.
|
|
25
|
-
*
|
|
25
|
+
* flow with an optional budget may await `f.run`, `f.llm`, and `f.agent` steps and must
|
|
26
|
+
* finish with `f.done("success")` or `f.done("needs_human")`. Each step and the terminal marker is
|
|
27
|
+
* a compiled spec submitted through
|
|
26
28
|
* `JournalClient`; values are read back from `step.completed` journal entries.
|
|
27
29
|
* Unsupported headers, verbs, gates, or completion lowering fail closed.
|
|
28
30
|
*/
|
|
@@ -34,6 +36,8 @@ export interface ExecuteAuthoredFlowOptions {
|
|
|
34
36
|
* `getDefinition` instead; see authored-flow-loader.ts's comment on why.
|
|
35
37
|
*/
|
|
36
38
|
readonly getDefinition?: GetFlowDefinition;
|
|
39
|
+
/** Helper receipt and mock-writeback storage; CLI passes its daemon data directory. */
|
|
40
|
+
readonly dataDir?: string;
|
|
37
41
|
/**
|
|
38
42
|
* The flow file's own path — passed straight to `checkAuthoredFlow`
|
|
39
43
|
* (cli/check.ts) so `f.agent` resolves a CLI the same way a declarative
|
|
@@ -49,6 +53,8 @@ export interface ExecuteAuthoredFlowOptions {
|
|
|
49
53
|
/** Passed straight through to classifyOutcome (cli/run.ts) for f.agent's wait. */
|
|
50
54
|
readonly signal?: RunLifecycleOptions['signal'];
|
|
51
55
|
readonly onWait?: RunLifecycleOptions['onWait'];
|
|
56
|
+
readonly onProgress?: (event: ProgressEvent) => void;
|
|
57
|
+
readonly localAgentStream?: string;
|
|
52
58
|
}
|
|
53
59
|
export declare function executeAuthoredFlow<Input = undefined>(handle: FlowHandle, journal: JournalClient, input?: Input, options?: ExecuteAuthoredFlowOptions): Promise<AuthoredFlowExecutionResult>;
|
|
54
60
|
//# sourceMappingURL=authored-flow-executor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authored-flow-executor.d.ts","sourceRoot":"","sources":["../src/authored-flow-executor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"authored-flow-executor.d.ts","sourceRoot":"","sources":["../src/authored-flow-executor.ts"],"names":[],"mappings":"AAcA,OAAO,EAML,KAAK,oBAAoB,EAG1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAmD,KAAK,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE/G,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAGhE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EACL,0BAA0B,EAC1B,KAAK,8BAA8B,EACpC,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EACV,gBAAgB,IAAI,wBAAwB,EAE7C,MAAM,eAAe,CAAC;AAoBvB,OAAO,EAAE,0BAA0B,EAAE,KAAK,8BAA8B,EAAE,CAAC;AAE3E,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,gBAAgB,EAAE,wBAAwB,CAAC;CACrD;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,gBAAgB,EAAE,oBAAoB,CAAC;IAChD,QAAQ,CAAC,YAAY,EAAE,SAAS,uBAAuB,EAAE,CAAC;CAC3D;AASD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;;;OAKG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAC3C,uFAAuF;IACvF,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,kFAAkF;IAClF,QAAQ,CAAC,MAAM,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAChD,QAAQ,CAAC,MAAM,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAChD,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACrD,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC;AAED,wBAAsB,mBAAmB,CAAC,KAAK,GAAG,SAAS,EACzD,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,aAAa,EACtB,KAAK,CAAC,EAAE,KAAK,EACb,OAAO,GAAE,0BAA+B,GACvC,OAAO,CAAC,2BAA2B,CAAC,CAsQtC"}
|
|
@@ -1,174 +1,133 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { pluginHelpers } from './plugin-loader.js';
|
|
2
|
+
import { runPluginEffect } from './authored-plugin-effect.js';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
import { dirname } from 'node:path';
|
|
5
|
+
import { runHelperEffect } from './authored-helper-effect.js';
|
|
6
|
+
import { checkSlackHelpers } from './slack-preflight.js';
|
|
7
|
+
import { snapshotJsonValue } from './json-value.js';
|
|
8
|
+
import { checkMcpHeader, McpPreflightError } from './cli/check-typescript.js';
|
|
9
|
+
import { buildMcpProxy, runMcpEffect } from './authored-mcp.js';
|
|
10
|
+
import { AuthoredBudget } from './authored-budget.js';
|
|
11
|
+
import { assertMemoryReachable, authoredMemory, scriptMemoryScope } from './authored-memory.js';
|
|
12
|
+
import { authoredDeterministicRunner, authoredWorkerRunner } from './authored-worker-step.js';
|
|
13
|
+
import { isSurfaceRunCompletionReason } from './authored-step-output.js';
|
|
14
|
+
import { createHelpers, helperProviders } from '@relayflows/surface/runtime';
|
|
2
15
|
import { join } from 'node:path';
|
|
3
|
-
import {
|
|
16
|
+
import { observeStep } from './progress.js';
|
|
17
|
+
import { parseStepTimeout } from './compile.js';
|
|
4
18
|
import { getAuthoredFlowDefinition } from './authored-flow.js';
|
|
5
|
-
import { checkAuthoredFlow } from './cli/check.js';
|
|
6
|
-
import { classifyOutcome } from './cli/run.js';
|
|
7
19
|
import { AuthoredFlowExecutionError, } from './authored-flow-error.js';
|
|
8
20
|
import { AuthoredFlowOperation, stopAuthoredOperations, verifyAuthoredOperations, } from './authored-flow-operation.js';
|
|
9
21
|
import { AuthoredFlowLifecycle } from './authored-flow-lifecycle.js';
|
|
10
|
-
import { SPEC_SCHEMA_VERSION } from './spec.js';
|
|
11
22
|
export { AuthoredFlowExecutionError };
|
|
12
|
-
/**
|
|
13
|
-
* Matches the `"path/glob: readonly"` / `"path/glob: readwrite"` shorthand
|
|
14
|
-
* shown in docs/SURFACE.md and the examples — the only shape a workspace
|
|
15
|
-
* string could plausibly declare a permission in. No parser anywhere in this
|
|
16
|
-
* package turns that annotation into a real restriction, so `lowerAgent`
|
|
17
|
-
* refuses rather than silently accepting and ignoring it.
|
|
18
|
-
*/
|
|
19
|
-
const WORKSPACE_PERMISSION_ANNOTATION = /:\s*(readonly|readwrite)\s*$/i;
|
|
20
23
|
export async function executeAuthoredFlow(handle, journal, input, options = {}) {
|
|
21
24
|
const getDefinition = options.getDefinition ?? getAuthoredFlowDefinition;
|
|
25
|
+
const localAgentStream = options.localAgentStream;
|
|
26
|
+
const onProgress = options.onProgress;
|
|
22
27
|
const flowPath = options.flowPath ?? join(process.cwd(), 'flow.ts');
|
|
23
|
-
// Named separately from `options` because `lowerAgent` below has its own,
|
|
24
|
-
// differently-typed `options: AgentOptions` parameter that shadows this one.
|
|
25
28
|
const waitOptions = {
|
|
26
29
|
...(options.signal !== undefined ? { signal: options.signal } : {}),
|
|
27
30
|
...(options.onWait !== undefined ? { onWait: options.onWait } : {}),
|
|
28
31
|
};
|
|
29
32
|
const definition = getDefinition(handle);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (
|
|
37
|
-
|
|
33
|
+
const headerFields = Object.keys(definition.header).filter(key => key !== 'tools' && key !== 'budget' && key !== 'memory');
|
|
34
|
+
if (definition.header.tools && Object.keys(definition.header.tools).some(key => !['mcp', ...helperProviders.map(p => p.namespace)].includes(key)))
|
|
35
|
+
headerFields.push('tools');
|
|
36
|
+
if (definition.header.tools?.relayfile !== undefined)
|
|
37
|
+
headerFields.push('tools.relayfile');
|
|
38
|
+
const helperPreflight = checkSlackHelpers(definition);
|
|
39
|
+
if (!helperPreflight.ok) {
|
|
40
|
+
const diagnostic = helperPreflight.diagnostics[0];
|
|
41
|
+
throw new AuthoredFlowExecutionError(diagnostic.kind, diagnostic.message);
|
|
38
42
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
name: `${definition.name}/declared-agents`,
|
|
54
|
-
agents: { ...definition.header.agents },
|
|
55
|
-
steps: [{ id: 'declared-agents', type: 'deterministic', command: ':' }],
|
|
56
|
-
}, flowPath);
|
|
57
|
-
if (!report.ok) {
|
|
58
|
-
const refusal = report.diagnostics.find((diagnostic) => diagnostic.severity === 'refusal');
|
|
59
|
-
throw new AuthoredFlowExecutionError('agent_cli_unresolved', refusal?.message
|
|
60
|
-
?? `flow "${definition.name}" declares an invalid named agent`, undefined, undefined, refusal?.kind ?? 'invalid_spec');
|
|
61
|
-
}
|
|
43
|
+
if (headerFields.length > 0) {
|
|
44
|
+
throw new AuthoredFlowExecutionError('unsupported_header', `flow "${definition.name}" uses unsupported header fields: ${headerFields.join(', ')}`);
|
|
45
|
+
}
|
|
46
|
+
const checkedMcp = await checkMcpHeader(definition, flowPath);
|
|
47
|
+
if (!checkedMcp.report.ok)
|
|
48
|
+
throw new McpPreflightError(checkedMcp.report);
|
|
49
|
+
const budget = new AuthoredBudget(definition.header.budget);
|
|
50
|
+
if (definition.header.memory?.agent === true) {
|
|
51
|
+
throw new AuthoredFlowExecutionError('unsupported_header', 'memory.agent requires the follow-up identity-scoped agent memory adapter');
|
|
52
|
+
}
|
|
53
|
+
// Direct member use is checked before any body effects; aliases are checked
|
|
54
|
+
// by the helper itself, without executing the body during discovery.
|
|
55
|
+
if (definition.header.memory !== undefined || /\.memory\b/.test(String(definition.body))) {
|
|
56
|
+
await assertMemoryReachable();
|
|
62
57
|
}
|
|
63
58
|
const journalSteps = [];
|
|
64
59
|
const authoredSteps = [];
|
|
65
60
|
const lifecycle = new AuthoredFlowLifecycle();
|
|
66
61
|
let nextStep = 1;
|
|
67
62
|
let requestedCompletion;
|
|
68
|
-
const lowerDeterministic =
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const namedAgents = definition.header.agents;
|
|
101
|
-
const matchesNamedAgent = namedAgents !== undefined && Object.hasOwn(namedAgents, name);
|
|
102
|
-
const authoring = {
|
|
103
|
-
version: SPEC_SCHEMA_VERSION,
|
|
104
|
-
name: `${definition.name}/${id}`,
|
|
105
|
-
...(namedAgents === undefined ? {} : { agents: { ...namedAgents } }),
|
|
106
|
-
steps: [{
|
|
107
|
-
id,
|
|
108
|
-
type: 'agent',
|
|
109
|
-
instruction: options.task,
|
|
110
|
-
...(matchesNamedAgent ? { agent: name } : {}),
|
|
111
|
-
...(options.cli === undefined ? {} : { cli: options.cli }),
|
|
112
|
-
...(options.model === undefined ? {} : { model: options.model }),
|
|
113
|
-
...(options.workspace === undefined ? {} : {
|
|
114
|
-
surfaces: { workspace: [{ surface: options.workspace }] },
|
|
115
|
-
}),
|
|
116
|
-
}],
|
|
117
|
-
};
|
|
118
|
-
// The kernel never resolves a `cli` on its own — every declarative
|
|
119
|
-
// `flows run`/`flows check` binds it first via this exact function
|
|
120
|
-
// (cli/check.ts), searching for the nearest flows.json from `flowPath`
|
|
121
|
-
// and real-probing auth/model readiness. An authored agent step gets
|
|
122
|
-
// nothing for free just because it was declared in TS instead of YAML.
|
|
123
|
-
const { report, flow: resolved } = checkAuthoredFlow(authoring, flowPath);
|
|
124
|
-
if (!report.ok || resolved === undefined) {
|
|
125
|
-
const refusal = report.diagnostics.find((diagnostic) => diagnostic.severity === 'refusal');
|
|
126
|
-
throw new AuthoredFlowExecutionError('agent_cli_unresolved', refusal?.message
|
|
127
|
-
?? `flow "${definition.name}" step "${id}": no CLI could be resolved for f.agent `
|
|
128
|
-
+ `(searched for flows.json from "${flowPath}")`, undefined, undefined, refusal?.kind ?? 'invalid_spec');
|
|
129
|
-
}
|
|
130
|
-
const spec = toKernelSpec(resolved);
|
|
131
|
-
const outcome = await journal.runStart(spec);
|
|
132
|
-
// Reuse the declarative CLI's own wait/classification (cli/run.ts) rather
|
|
133
|
-
// than a hand-rolled poll: `step.completed` and the run's own terminal
|
|
134
|
-
// state are appended as two SEPARATE actions (kernel/relayflowd-core/src/machine.rs
|
|
135
|
-
// completion_actions vs complete_run_actions), so a naive read right
|
|
136
|
-
// after runStart can race a real, valid completion — and a genuinely
|
|
137
|
-
// long-running agent has no reason to be bounded by anything other than
|
|
138
|
-
// its own worker's lease, which classifyOutcome already follows
|
|
139
|
-
// (renewing as the lease renews, per docs/SURFACE.md §5's WAITING
|
|
140
|
-
// [worker_lease] contract), never an unrelated fixed deadline.
|
|
141
|
-
const execution = await classifyOutcome(journal, 'run', outcome, report, '', waitOptions);
|
|
142
|
-
if (execution.exitCode === 3) {
|
|
143
|
-
const parked = execution.report.parkedStep;
|
|
144
|
-
throw new AuthoredFlowExecutionError('agent_parked', execution.report.diagnostics.at(-1)?.message
|
|
145
|
-
?? `flow "${definition.name}" step "${id}" parked`
|
|
146
|
-
+ (parked !== undefined ? ` (${parked.type})` : '')
|
|
147
|
-
+ ': no worker is attached to run it.', undefined, outcome.run_id);
|
|
148
|
-
}
|
|
149
|
-
if (execution.exitCode !== 0) {
|
|
150
|
-
const reason = execution.report.completionReason;
|
|
151
|
-
throw new AuthoredFlowExecutionError('step_failed', execution.report.diagnostics.at(-1)?.message
|
|
152
|
-
?? `flow "${definition.name}" step "${id}" did not complete successfully `
|
|
153
|
-
+ `(status: ${execution.report.status ?? 'unknown'})`, isSurfaceCompletionReason(reason) ? reason : undefined, outcome.run_id);
|
|
154
|
-
}
|
|
155
|
-
return readSuccessfulAgentOutput(journal, outcome.run_id, id, journalSteps);
|
|
156
|
-
};
|
|
63
|
+
const lowerDeterministic = authoredDeterministicRunner(definition.name, journal, journalSteps, budget);
|
|
64
|
+
const worker = authoredWorkerRunner(definition, journal, flowPath, journalSteps, waitOptions, localAgentStream, budget, definition.header.budget);
|
|
65
|
+
function llmOperation(prompt, ...values) {
|
|
66
|
+
assertOperationAllowed('llm', definition.name, requestedCompletion);
|
|
67
|
+
const id = `llm-${nextStep++}`;
|
|
68
|
+
// Hoist the operation reference so the start closure can read the
|
|
69
|
+
// caller's `.gate(config)` at spec-build time. AuthoredFlowOperation
|
|
70
|
+
// begins after construction returns, so `llmOp` is defined by then.
|
|
71
|
+
let llmOp;
|
|
72
|
+
llmOp = new AuthoredFlowOperation(id, 'llm', () => assertOperationAllowed('llm', definition.name, requestedCompletion), () => observeStep(id, 'llm', () => {
|
|
73
|
+
if (typeof prompt === 'string') {
|
|
74
|
+
if (values.length !== 1 || values[0] === undefined) {
|
|
75
|
+
throw new AuthoredFlowExecutionError('llm_cli_unresolved', 'f.llm(prompt, options) requires an output JSON Schema.');
|
|
76
|
+
}
|
|
77
|
+
return worker.llm(id, prompt, values[0], llmOp.namedGate);
|
|
78
|
+
}
|
|
79
|
+
const text = prompt.reduce((result, part, index) => result + part
|
|
80
|
+
+ (index < values.length ? String(values[index]) : ''), '');
|
|
81
|
+
return worker.llm(id, text, undefined, llmOp.namedGate);
|
|
82
|
+
}, onProgress), lifecycle);
|
|
83
|
+
return trackStep(authoredSteps, llmOp);
|
|
84
|
+
}
|
|
85
|
+
const slackRun = randomUUID();
|
|
86
|
+
function slackOperation(call) {
|
|
87
|
+
assertOperationAllowed(`slack.${call.verb}`, definition.name, requestedCompletion);
|
|
88
|
+
const snapshot = snapshotJsonValue(call, 'f.slack call');
|
|
89
|
+
const id = `slack-${slackRun}-${nextStep++}`;
|
|
90
|
+
return trackStep(authoredSteps, new AuthoredFlowOperation(id, `slack.${call.verb}`, () => assertOperationAllowed(`slack.${call.verb}`, definition.name, requestedCompletion), async () => {
|
|
91
|
+
const receipt = await runHelperEffect(journal, definition.name, id, snapshot, options.dataDir ?? dirname(journal.socketPath), journalSteps);
|
|
92
|
+
return (call.verb === 'react' ? undefined : receipt);
|
|
93
|
+
}, lifecycle));
|
|
94
|
+
}
|
|
157
95
|
const context = {
|
|
158
|
-
|
|
96
|
+
...createHelpers((call) => {
|
|
97
|
+
const verb = `${call.provider}.${call.verb}`;
|
|
98
|
+
assertOperationAllowed(verb, definition.name, requestedCompletion);
|
|
99
|
+
const snapshot = snapshotJsonValue(call, `f.${verb} call`);
|
|
100
|
+
const id = `${call.provider}-${slackRun}-${nextStep++}`;
|
|
101
|
+
return trackStep(authoredSteps, new AuthoredFlowOperation(id, verb, () => assertOperationAllowed(verb, definition.name, requestedCompletion), async () => await runHelperEffect(journal, definition.name, id, snapshot, options.dataDir ?? dirname(journal.socketPath), journalSteps), lifecycle));
|
|
102
|
+
}),
|
|
103
|
+
slack: {
|
|
104
|
+
post: (channel, text, opts) => slackOperation({ type: 'effect', provider: 'slack', verb: 'post', params: { channel, text, ...(opts === undefined ? {} : { opts }) } }),
|
|
105
|
+
dm: (user, text) => slackOperation({ type: 'effect', provider: 'slack', verb: 'dm', params: { user, text } }),
|
|
106
|
+
reply: (channel, threadTs, text) => slackOperation({ type: 'effect', provider: 'slack', verb: 'reply', params: { channel, threadTs, text } }),
|
|
107
|
+
react: (channel, messageTs, emoji) => slackOperation({ type: 'effect', provider: 'slack', verb: 'react', params: { channel, messageTs, emoji } }),
|
|
108
|
+
},
|
|
109
|
+
mcp: buildMcpProxy(checkedMcp.inventory, (server, tool, args, known) => {
|
|
110
|
+
assertOperationAllowed('mcp', definition.name, requestedCompletion);
|
|
111
|
+
const id = `mcp-${nextStep++}`;
|
|
112
|
+
return trackStep(authoredSteps, new AuthoredFlowOperation(id, 'mcp', () => assertOperationAllowed('mcp', definition.name, requestedCompletion), () => runMcpEffect(journal, definition.name, id, server, tool, args, known, checkedMcp.servers[server], journalSteps), lifecycle));
|
|
113
|
+
}),
|
|
114
|
+
memory: authoredMemory(scriptMemoryScope(flowPath, definition.name), () => assertOperationAllowed('memory', definition.name, requestedCompletion), definition.header.memory?.script !== false),
|
|
115
|
+
run(command, runOptions) {
|
|
159
116
|
assertOperationAllowed('run', definition.name, requestedCompletion);
|
|
117
|
+
const leaseMs = runOptions?.timeout === undefined ? undefined : parseStepTimeout(runOptions.timeout);
|
|
160
118
|
const id = `run-${nextStep++}`;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
assertOperationAllowed('llm', definition.name, requestedCompletion);
|
|
165
|
-
const id = `llm-${nextStep++}`;
|
|
166
|
-
return trackStep(authoredSteps, unsupportedStep(id, 'llm', () => assertOperationAllowed('llm', definition.name, requestedCompletion), lifecycle));
|
|
119
|
+
let runOp;
|
|
120
|
+
runOp = new AuthoredFlowOperation(id, 'run', () => assertOperationAllowed('run', definition.name, requestedCompletion), () => observeStep(id, 'deterministic', () => lowerDeterministic(id, command, false, leaseMs, runOp.namedGate), options.onProgress), lifecycle);
|
|
121
|
+
return trackStep(authoredSteps, runOp);
|
|
167
122
|
},
|
|
123
|
+
llm: llmOperation,
|
|
168
124
|
agent(name, options) {
|
|
169
125
|
assertOperationAllowed('agent', definition.name, requestedCompletion);
|
|
126
|
+
void name; // Authored headers do not yet declare reusable named agents.
|
|
170
127
|
const id = `agent-${nextStep++}`;
|
|
171
|
-
|
|
128
|
+
let agentOp;
|
|
129
|
+
agentOp = new AuthoredFlowOperation(id, 'agent', () => assertOperationAllowed('agent', definition.name, requestedCompletion), () => observeStep(id, 'agent', () => worker.agent(id, options, agentOp.namedGate), onProgress), lifecycle);
|
|
130
|
+
return trackStep(authoredSteps, agentOp);
|
|
172
131
|
},
|
|
173
132
|
human() {
|
|
174
133
|
assertOperationAllowed('human', definition.name, requestedCompletion);
|
|
@@ -179,13 +138,13 @@ export async function executeAuthoredFlow(handle, journal, input, options = {})
|
|
|
179
138
|
throw unsupportedVerb('dispatch');
|
|
180
139
|
},
|
|
181
140
|
done(reason) {
|
|
182
|
-
if (!isSurfaceRunCompletionReason(reason)) {
|
|
141
|
+
if (reason !== 'needs_human' && !isSurfaceRunCompletionReason(reason)) {
|
|
183
142
|
throw new AuthoredFlowExecutionError('unsupported_completion', `unknown completion reason: ${String(reason)}`);
|
|
184
143
|
}
|
|
185
144
|
if (requestedCompletion !== undefined) {
|
|
186
145
|
throw new AuthoredFlowExecutionError('duplicate_completion', `flow "${definition.name}" called done() more than once`);
|
|
187
146
|
}
|
|
188
|
-
if (reason !== 'success') {
|
|
147
|
+
if (reason !== 'success' && reason !== 'needs_human') {
|
|
189
148
|
throw new AuthoredFlowExecutionError('unsupported_completion', `the initial authored executor cannot lower done("${reason}")`, reason);
|
|
190
149
|
}
|
|
191
150
|
lifecycle.markCompletion();
|
|
@@ -193,6 +152,12 @@ export async function executeAuthoredFlow(handle, journal, input, options = {})
|
|
|
193
152
|
},
|
|
194
153
|
cloud: unsupportedCloud(() => assertOperationAllowed('cloud', definition.name, requestedCompletion)),
|
|
195
154
|
};
|
|
155
|
+
Object.assign(context, pluginHelpers(checkedMcp.plugins ?? [], (plugin, verb, args) => {
|
|
156
|
+
const label = `${verb.namespace}.${verb.method}`;
|
|
157
|
+
assertOperationAllowed(label, definition.name, requestedCompletion);
|
|
158
|
+
const id = `plugin-${nextStep++}`;
|
|
159
|
+
return trackStep(authoredSteps, new AuthoredFlowOperation(id, label, () => assertOperationAllowed(label, definition.name, requestedCompletion), () => runPluginEffect(journal, definition.name, id, plugin, verb, args, journalSteps, budget), lifecycle));
|
|
160
|
+
}));
|
|
196
161
|
let bodyFailed = false;
|
|
197
162
|
let bodyFailure;
|
|
198
163
|
try {
|
|
@@ -242,7 +207,11 @@ export async function executeAuthoredFlow(handle, journal, input, options = {})
|
|
|
242
207
|
finally {
|
|
243
208
|
lifecycle.close();
|
|
244
209
|
}
|
|
245
|
-
|
|
210
|
+
// The authored runner has no durable root yet. Record the handoff as a
|
|
211
|
+
// successful effect containing the authored outcome, not a fabricated kernel
|
|
212
|
+
// run.completed reason. The CLI reports this outcome as parked (exit 3).
|
|
213
|
+
await lowerDeterministic(`complete-${nextStep}`, requestedCompletion === 'needs_human'
|
|
214
|
+
? `printf '%s' '{"completionReason":"needs_human"}'` : ':', true);
|
|
246
215
|
return Object.freeze({
|
|
247
216
|
name: definition.name,
|
|
248
217
|
completionReason: requestedCompletion,
|
|
@@ -253,17 +222,12 @@ function trackStep(tracked, operation) {
|
|
|
253
222
|
tracked.push(operation);
|
|
254
223
|
return operation.step;
|
|
255
224
|
}
|
|
256
|
-
function unsupportedStep(id, verb, assertCanStart, lifecycle) {
|
|
257
|
-
return new AuthoredFlowOperation(id, verb, assertCanStart, async () => {
|
|
258
|
-
throw unsupportedVerb(verb);
|
|
259
|
-
}, lifecycle);
|
|
260
|
-
}
|
|
261
225
|
function unsupportedVerb(verb) {
|
|
262
226
|
return new AuthoredFlowExecutionError('unsupported_verb', `the initial authored executor does not lower f.${verb}`);
|
|
263
227
|
}
|
|
264
228
|
function assertOperationAllowed(verb, flowName, completion) {
|
|
265
229
|
if (completion !== undefined) {
|
|
266
|
-
throw new AuthoredFlowExecutionError('operation_after_completion', `flow "${flowName}" called f.${verb} after done()`, completion);
|
|
230
|
+
throw new AuthoredFlowExecutionError('operation_after_completion', `flow "${flowName}" called f.${verb} after done()`, completion === 'needs_human' ? undefined : completion);
|
|
267
231
|
}
|
|
268
232
|
}
|
|
269
233
|
function unsupportedCloud(assertOpen) {
|
|
@@ -274,87 +238,4 @@ function unsupportedCloud(assertOpen) {
|
|
|
274
238
|
},
|
|
275
239
|
});
|
|
276
240
|
}
|
|
277
|
-
/**
|
|
278
|
-
* Shared by every `f.*` verb that lowers to one kernel step run in isolation:
|
|
279
|
-
* find its `step.completed` entry, record it, and refuse anything but a
|
|
280
|
-
* clean success before handing the raw `output` back for verb-specific
|
|
281
|
-
* extraction (a plain string for `f.run`, an `AgentResult` for `f.agent`).
|
|
282
|
-
*
|
|
283
|
-
* Callers are responsible for having already established that the RUN
|
|
284
|
-
* reached a terminal, successful state before calling this — `f.run`'s
|
|
285
|
-
* caller relies on `runStart`'s own immediate response (the kernel drives a
|
|
286
|
-
* deterministic step to completion inline, no race); `f.agent`'s caller
|
|
287
|
-
* relies on `classifyOutcome` (cli/run.ts) having already polled to a true
|
|
288
|
-
* terminal state. Given that, a single read from the start of this run's
|
|
289
|
-
* (small, single-step) journal is enough — no polling here, and no run
|
|
290
|
-
* outcome ever needs re-checking.
|
|
291
|
-
*/
|
|
292
|
-
async function readCompletedStepOutput(journal, runId, stepId, journalSteps) {
|
|
293
|
-
const entries = (await journal.journalRead(runId, 1)).entries;
|
|
294
|
-
const completed = entries.find((entry) => isStepCompleted(entry, stepId));
|
|
295
|
-
if (!isStepCompleted(completed, stepId)) {
|
|
296
|
-
throw protocolViolation(runId, `journal has no step.completed for "${stepId}"`);
|
|
297
|
-
}
|
|
298
|
-
const reason = completed.payload.completionReason;
|
|
299
|
-
journalSteps.push(Object.freeze({ id: stepId, runId, completionReason: reason }));
|
|
300
|
-
if (reason !== 'success') {
|
|
301
|
-
throw new AuthoredFlowExecutionError('step_failed', `journal step "${stepId}" completed with ${reason}`, reason, runId);
|
|
302
|
-
}
|
|
303
|
-
return completed.payload.output;
|
|
304
|
-
}
|
|
305
|
-
async function readSuccessfulOutput(journal, outcome, stepId, journalSteps) {
|
|
306
|
-
const output = await readCompletedStepOutput(journal, outcome.run_id, stepId, journalSteps);
|
|
307
|
-
if (!isRecord(output) || typeof output['stdout_tail'] !== 'string') {
|
|
308
|
-
throw protocolViolation(outcome.run_id, `step "${stepId}" has no string stdout_tail`);
|
|
309
|
-
}
|
|
310
|
-
return output['stdout_tail'];
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* The kernel journals an agent step's raw `CliResult` shape
|
|
314
|
-
* (`exit_code`/`stdout_tail`/`stderr_tail`) — same as a deterministic step —
|
|
315
|
-
* UNLESS the CLI's stdout parsed as JSON, in which case `output` is that
|
|
316
|
-
* parsed object directly (worker.ts: `parseJsonOutput(result.stdout_tail) ??
|
|
317
|
-
* result`). Neither shape carries a real `artifacts` list today: nothing in
|
|
318
|
-
* the kernel or worker enumerates files an agent wrote, and `f.agent`'s
|
|
319
|
-
* `AgentOptions` has no `output` schema parameter for a CLI to target either
|
|
320
|
-
* (unlike the declarative `AgentStepSpec.output` field). `artifacts` is
|
|
321
|
-
* therefore always empty here — honest about what data exists, not a
|
|
322
|
-
* placeholder for something not yet wired.
|
|
323
|
-
*/
|
|
324
|
-
async function readSuccessfulAgentOutput(journal, runId, stepId, journalSteps) {
|
|
325
|
-
const output = await readCompletedStepOutput(journal, runId, stepId, journalSteps);
|
|
326
|
-
if (!isRecord(output)) {
|
|
327
|
-
throw protocolViolation(runId, `step "${stepId}" produced a non-object output`);
|
|
328
|
-
}
|
|
329
|
-
if (typeof output['stdout_tail'] === 'string') {
|
|
330
|
-
return { summary: output['stdout_tail'], artifacts: [] };
|
|
331
|
-
}
|
|
332
|
-
// The CLI's stdout parsed as JSON, so `output` is that value, not a
|
|
333
|
-
// CliResult. Fall back to a stable, inspectable summary rather than
|
|
334
|
-
// refusing a run whose agent step genuinely succeeded.
|
|
335
|
-
return { summary: JSON.stringify(output), artifacts: [] };
|
|
336
|
-
}
|
|
337
|
-
function isStepCompleted(value, stepId) {
|
|
338
|
-
if (!isRecord(value) || value['entry_type'] !== 'step.completed' || value['step_id'] !== stepId) {
|
|
339
|
-
return false;
|
|
340
|
-
}
|
|
341
|
-
const payload = value['payload'];
|
|
342
|
-
return isRecord(payload)
|
|
343
|
-
&& isSurfaceCompletionReason(payload['completionReason'])
|
|
344
|
-
&& 'output' in payload;
|
|
345
|
-
}
|
|
346
|
-
function isSurfaceCompletionReason(value) {
|
|
347
|
-
return typeof value === 'string'
|
|
348
|
-
&& COMPLETION_REASONS.includes(value);
|
|
349
|
-
}
|
|
350
|
-
function isSurfaceRunCompletionReason(value) {
|
|
351
|
-
return typeof value === 'string'
|
|
352
|
-
&& RUN_COMPLETION_REASONS.includes(value);
|
|
353
|
-
}
|
|
354
|
-
function isRecord(value) {
|
|
355
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
356
|
-
}
|
|
357
|
-
function protocolViolation(runId, detail) {
|
|
358
|
-
return new AuthoredFlowExecutionError('journal_protocol_violation', detail, undefined, runId);
|
|
359
|
-
}
|
|
360
241
|
//# sourceMappingURL=authored-flow-executor.js.map
|