@relayflows/sdk 2.0.9 → 2.0.11
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-receipt.d.ts +24 -0
- package/dist/agent-relay-receipt.d.ts.map +1 -0
- package/dist/agent-relay-receipt.js +66 -0
- package/dist/agent-relay-receipt.js.map +1 -0
- package/dist/agent-relay-state.d.ts +18 -0
- package/dist/agent-relay-state.d.ts.map +1 -0
- package/dist/agent-relay-state.js +58 -0
- package/dist/agent-relay-state.js.map +1 -0
- package/dist/agent-relay-transport.d.ts +31 -0
- package/dist/agent-relay-transport.d.ts.map +1 -0
- package/dist/agent-relay-transport.js +199 -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 +16 -1
- package/dist/worker-cli.d.ts.map +1 -1
- package/dist/worker-cli.js +129 -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 +29 -9
- 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-receipt.ts +120 -0
- package/src/agent-relay-state.ts +73 -0
- package/src/agent-relay-transport.ts +273 -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 +150 -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 +34 -10
- 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":"yaml-helper-effect.js","sourceRoot":"","sources":["../src/yaml-helper-effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAInE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACjG,OAAO,EAAE,YAAY,EAAmB,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,UAAU,WAAW,CAAC,QAAgB,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG;IAC7D,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,oBAAoB,EAAE,GAAG,CAAC,cAAc,EAAE,GAAG,CAAC,sBAAsB;QACpF,GAAG,CAAC,oBAAoB,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EA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CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI;QACjG,OAAO,EAAE,CAAC,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,QAAQ,CAAC,eAAe,EAAE,CAAC,EAAE,CAAC,CAAC;AAC7F,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type RelayTransport } from '@relayfile/relay-helpers';
|
|
2
|
+
import type { AgentStepSpec, KernelAgentStep, YamlHelperParams } from './spec.js';
|
|
3
|
+
export type HelperCall = {
|
|
4
|
+
[P in keyof YamlHelperParams]: {
|
|
5
|
+
[V in keyof YamlHelperParams[P]]: {
|
|
6
|
+
type: 'effect';
|
|
7
|
+
provider: P;
|
|
8
|
+
verb: V;
|
|
9
|
+
params: YamlHelperParams[P][V];
|
|
10
|
+
};
|
|
11
|
+
}[keyof YamlHelperParams[P]];
|
|
12
|
+
}[keyof YamlHelperParams];
|
|
13
|
+
/** Runs on the inert JSON snapshot, before ordinary step validation. */
|
|
14
|
+
export declare function expandYamlHelpers(spec: unknown): unknown;
|
|
15
|
+
/** The versioned instruction envelope survives canonical specs and journal resume. */
|
|
16
|
+
export declare function helperCall(step: Partial<AgentStepSpec | KernelAgentStep>): HelperCall | undefined;
|
|
17
|
+
export declare function invokeHelper(call: HelperCall, transport: RelayTransport): Promise<unknown>;
|
|
18
|
+
//# sourceMappingURL=yaml-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml-helpers.d.ts","sourceRoot":"","sources":["../src/yaml-helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAA2C,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACxG,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAyDlF,MAAM,MAAM,UAAU,GAAG;KAAG,CAAC,IAAI,MAAM,gBAAgB,GAAG;SAAG,CAAC,IAAI,MAAM,gBAAgB,CAAC,CAAC,CAAC,GACzF;YAAE,IAAI,EAAE,QAAQ,CAAC;YAAC,QAAQ,EAAE,CAAC,CAAC;YAAC,IAAI,EAAE,CAAC,CAAC;YAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;SAAE;KACzE,CAAC,MAAM,gBAAgB,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC,MAAM,gBAAgB,CAAC,CAAC;AA2BvD,wEAAwE;AACxE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CA4BxD;AAED,sFAAsF;AACtF,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,GAAG,eAAe,CAAC,GAAG,UAAU,GAAG,SAAS,CAKjG;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAGhG"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import Ajv from 'ajv';
|
|
2
|
+
import { githubClient, linearClient, slackClient } from '@relayfile/relay-helpers';
|
|
3
|
+
import { canonicalize } from './canonical.js';
|
|
4
|
+
import { unknownKeyErrors } from './unknown-keys.js';
|
|
5
|
+
const string = { type: 'string', minLength: 1 };
|
|
6
|
+
const text = { type: 'string' };
|
|
7
|
+
const strings = { type: 'array', items: string };
|
|
8
|
+
const object = (properties, required = Object.keys(properties)) => ({ type: 'object', properties, required, additionalProperties: false });
|
|
9
|
+
const target = object({ owner: string, repo: string, number: { type: 'integer', minimum: 1 } });
|
|
10
|
+
const issueChanges = { title: string, description: text, assigneeId: string, stateId: string,
|
|
11
|
+
projectId: string, labelIds: strings, addedLabelIds: strings, removedLabelIds: strings };
|
|
12
|
+
const ajv = new Ajv({ allErrors: true });
|
|
13
|
+
function verb(schema, invoke) {
|
|
14
|
+
const validate = ajv.compile(schema);
|
|
15
|
+
return { validate, invoke: (params, transport) => invoke(params, transport) };
|
|
16
|
+
}
|
|
17
|
+
/** Closed catalog: only write verbs with a declared argument schema can execute. */
|
|
18
|
+
const helpers = {
|
|
19
|
+
slack: {
|
|
20
|
+
post: verb(object({ channel: string, text,
|
|
21
|
+
opts: object({ replyTo: string }, []) }, ['channel', 'text']), (p, transport) => slackClient({ transport }).post(p.channel, p.text, p.opts)),
|
|
22
|
+
dm: verb(object({ user: string, text }), (p, transport) => slackClient({ transport }).dm(p.user, p.text)),
|
|
23
|
+
reply: verb(object({ channel: string, threadTs: string, text }), (p, transport) => slackClient({ transport }).reply(p.channel, p.threadTs, p.text)),
|
|
24
|
+
react: verb(object({ channel: string, messageTs: string, emoji: string }), (p, transport) => slackClient({ transport }).react(p.channel, p.messageTs, p.emoji)),
|
|
25
|
+
},
|
|
26
|
+
github: {
|
|
27
|
+
comment: verb(object({ target, body: text }), (p, transport) => githubClient({ transport }).comment(p.target, p.body)),
|
|
28
|
+
createIssue: verb(object({ owner: string, repo: string,
|
|
29
|
+
title: string, body: text, labels: strings }, ['owner', 'repo', 'title', 'body']), (p, transport) => githubClient({ transport }).createIssue(p)),
|
|
30
|
+
createPullRequest: verb(object({ owner: string,
|
|
31
|
+
repo: string, title: string, head: string, base: string, body: text, draft: { type: 'boolean' },
|
|
32
|
+
author: { enum: ['app', 'user'] } }, ['owner', 'repo', 'title', 'head', 'base']), (p, transport) => githubClient({ transport }).createPullRequest(p)),
|
|
33
|
+
closePullRequest: verb(target, (p, transport) => githubClient({ transport }).closePullRequest(p)),
|
|
34
|
+
},
|
|
35
|
+
linear: {
|
|
36
|
+
comment: verb(object({ issueId: string, body: text }), (p, transport) => linearClient({ transport }).comment(p.issueId, p.body)),
|
|
37
|
+
createIssue: verb(object({ teamId: string, title: string,
|
|
38
|
+
description: text, assigneeId: string, labelIds: strings, projectId: string, stateId: string }, ['teamId', 'title']), (p, transport) => linearClient({ transport }).createIssue(p)),
|
|
39
|
+
updateIssue: verb(object({ issueId: string,
|
|
40
|
+
args: object(issueChanges, []) }), (p, transport) => linearClient({ transport }).updateIssue(p.issueId, p.args)),
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
const prefix = 'relayflows:helper:v1\n';
|
|
44
|
+
const commonFields = ['id', 'dependsOn', 'maxIterations', 'verification', 'output'];
|
|
45
|
+
const isObject = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
46
|
+
function descriptor(provider, name) {
|
|
47
|
+
if (!Object.hasOwn(helpers, provider))
|
|
48
|
+
throw new Error(`unknown helper provider "${provider}"`);
|
|
49
|
+
const verbs = helpers[provider];
|
|
50
|
+
if (!Object.hasOwn(verbs, name))
|
|
51
|
+
throw new Error(`unknown ${provider} helper verb "${name}"`);
|
|
52
|
+
return verbs[name];
|
|
53
|
+
}
|
|
54
|
+
function validateCall(value) {
|
|
55
|
+
if (!isObject(value) || value.type !== 'effect' || typeof value.provider !== 'string' || typeof value.verb !== 'string') {
|
|
56
|
+
throw new Error('expected a helper effect call');
|
|
57
|
+
}
|
|
58
|
+
const extra = unknownKeyErrors(value, ['type', 'provider', 'verb', 'params'], 'helper');
|
|
59
|
+
if (extra.length)
|
|
60
|
+
throw new Error(extra.join('; '));
|
|
61
|
+
const entry = descriptor(value.provider, value.verb);
|
|
62
|
+
if (!entry.validate(value.params)) {
|
|
63
|
+
throw new Error(`${value.provider}.${value.verb}: ${ajv.errorsText(entry.validate.errors)}`);
|
|
64
|
+
}
|
|
65
|
+
return value;
|
|
66
|
+
}
|
|
67
|
+
/** Runs on the inert JSON snapshot, before ordinary step validation. */
|
|
68
|
+
export function expandYamlHelpers(spec) {
|
|
69
|
+
if (!isObject(spec) || !Array.isArray(spec.steps))
|
|
70
|
+
return spec;
|
|
71
|
+
return { ...spec, steps: spec.steps.map((step, index) => {
|
|
72
|
+
if (!isObject(step))
|
|
73
|
+
return step;
|
|
74
|
+
const providers = Object.keys(helpers).filter(provider => Object.hasOwn(step, provider));
|
|
75
|
+
if (!providers.length) {
|
|
76
|
+
// Recompiling a canonical envelope must fail with the same compile error
|
|
77
|
+
// contract as authoring it, before preflight or workers see it.
|
|
78
|
+
helperCall(step);
|
|
79
|
+
return step;
|
|
80
|
+
}
|
|
81
|
+
const at = `spec.steps[${index}]`;
|
|
82
|
+
try {
|
|
83
|
+
if (providers.length !== 1)
|
|
84
|
+
throw new Error('expected exactly one helper provider per step');
|
|
85
|
+
const provider = providers[0];
|
|
86
|
+
const errors = unknownKeyErrors(step, [...commonFields, provider], at);
|
|
87
|
+
if (errors.length)
|
|
88
|
+
throw new Error(errors.join('; '));
|
|
89
|
+
const verbs = step[provider];
|
|
90
|
+
if (!isObject(verbs) || Object.keys(verbs).length !== 1)
|
|
91
|
+
throw new Error(`${provider}: expected exactly one helper verb`);
|
|
92
|
+
const name = Object.keys(verbs)[0];
|
|
93
|
+
const call = validateCall({ type: 'effect', provider, verb: name, params: verbs[name] });
|
|
94
|
+
const { [provider]: _, ...base } = step;
|
|
95
|
+
return { ...base, type: 'agent', instruction: prefix + canonicalize(call),
|
|
96
|
+
recoveryMode: 'reset', surfaces: { external: [`/${provider}`] } };
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
throw new Error(`${at}: ${error instanceof Error ? error.message : String(error)}`);
|
|
100
|
+
}
|
|
101
|
+
}) };
|
|
102
|
+
}
|
|
103
|
+
/** The versioned instruction envelope survives canonical specs and journal resume. */
|
|
104
|
+
export function helperCall(step) {
|
|
105
|
+
if (step.type !== 'agent' || typeof step.instruction !== 'string' || !step.instruction.startsWith(prefix))
|
|
106
|
+
return undefined;
|
|
107
|
+
const call = validateCall(JSON.parse(step.instruction.slice(prefix.length)));
|
|
108
|
+
if (!step.surfaces?.external?.includes(`/${call.provider}`))
|
|
109
|
+
throw new Error('helper effect is missing its declared external surface');
|
|
110
|
+
return call;
|
|
111
|
+
}
|
|
112
|
+
export async function invokeHelper(call, transport) {
|
|
113
|
+
const validated = validateCall(call);
|
|
114
|
+
return (await descriptor(validated.provider, validated.verb).invoke(validated.params, transport)) ?? null;
|
|
115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
1
|
{
|
|
2
2
|
"name": "@relayflows/sdk",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.11",
|
|
4
4
|
"description": "TypeScript-first authoring SDK for Relayflows. Compiles specs; speaks the journal protocol.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -12,6 +12,18 @@
|
|
|
12
12
|
".": {
|
|
13
13
|
"types": "./dist/index.d.ts",
|
|
14
14
|
"import": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./create-flow": {
|
|
17
|
+
"types": "./dist/create-flow.d.ts",
|
|
18
|
+
"import": "./dist/create-flow.js"
|
|
19
|
+
},
|
|
20
|
+
"./progress": {
|
|
21
|
+
"types": "./dist/progress.d.ts",
|
|
22
|
+
"import": "./dist/progress.js"
|
|
23
|
+
},
|
|
24
|
+
"./cli": {
|
|
25
|
+
"types": "./dist/cli.d.ts",
|
|
26
|
+
"import": "./dist/cli.js"
|
|
15
27
|
}
|
|
16
28
|
},
|
|
17
29
|
"files": [
|
|
@@ -30,11 +42,16 @@
|
|
|
30
42
|
},
|
|
31
43
|
"license": "Apache-2.0",
|
|
32
44
|
"dependencies": {
|
|
33
|
-
"@
|
|
45
|
+
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
46
|
+
"@relayfile/adapter-core": "0.5.24",
|
|
47
|
+
"@relayfile/relay-helpers": "0.4.11",
|
|
48
|
+
"@relayflows/surface": "2.0.11",
|
|
34
49
|
"@types/js-yaml": "^4.0.9",
|
|
50
|
+
"ai-hist": "0.4.1",
|
|
35
51
|
"ajv": "^8.17.1",
|
|
36
52
|
"ajv-draft-04": "^1.0.0",
|
|
37
53
|
"js-yaml": "^5.4.1",
|
|
54
|
+
"re2js": "^2.8.6",
|
|
38
55
|
"yaml": "^2.5.1"
|
|
39
56
|
},
|
|
40
57
|
"devDependencies": {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* First-class headless adapter contract (flows#141).
|
|
3
|
+
*
|
|
4
|
+
* Every supported agent CLI ships one implementation. `worker-cli.ts` and
|
|
5
|
+
* `cli/check.ts` dispatch through the registry in `./index.ts` — never string
|
|
6
|
+
* formatting against per-CLI knowledge inline. Adding a new CLI is one new
|
|
7
|
+
* file that implements this interface.
|
|
8
|
+
*
|
|
9
|
+
* Behavior-preserving migration: the exported functions in `cli-adapter.ts`
|
|
10
|
+
* (`agentExecution`, `llmExecution`, `authenticationProbe`,
|
|
11
|
+
* `modelReadinessProbe`, `adapterIdentification`) now delegate to the
|
|
12
|
+
* registered adapter for the resolved kind, so callers don't change.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export interface CliInvocation {
|
|
16
|
+
args: string[];
|
|
17
|
+
timeoutMs: number;
|
|
18
|
+
/** Set only for wrapper readiness probes; raw providers receive a model flag. */
|
|
19
|
+
modelEnv?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface CliAdapterIdentification {
|
|
23
|
+
invocation: CliInvocation;
|
|
24
|
+
expectedStdout?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The declared, per-CLI headless contract. Members intentionally mirror the
|
|
29
|
+
* function-scoped predecessors in `cli-adapter.ts` so migration is mechanical.
|
|
30
|
+
*/
|
|
31
|
+
export interface HeadlessAdapter {
|
|
32
|
+
/** Identity of this adapter — matches CliAdapterKind for registry keys. */
|
|
33
|
+
readonly kind: string;
|
|
34
|
+
|
|
35
|
+
/** Shape-check invocation before classifying an auth failure. */
|
|
36
|
+
buildIdentification(): CliAdapterIdentification;
|
|
37
|
+
|
|
38
|
+
/** Non-interactive auth-status probe. */
|
|
39
|
+
buildAuthProbe(): CliInvocation;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Real, noninteractive model round-trip. Providers hand the model via a
|
|
43
|
+
* native flag; wrappers hand it via the explicitly identified environment
|
|
44
|
+
* contract on `modelEnv`.
|
|
45
|
+
*/
|
|
46
|
+
buildModelReadinessProbe(model: string): CliInvocation;
|
|
47
|
+
|
|
48
|
+
/** Agent-step worker argv for an instruction under an optional model. */
|
|
49
|
+
buildAgentInvocation(instruction: string, model?: string): CliInvocation;
|
|
50
|
+
|
|
51
|
+
/** LLM-step worker argv for a prompt under an optional model. */
|
|
52
|
+
buildLlmInvocation(prompt: string, model?: string): CliInvocation;
|
|
53
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CliAdapterIdentification,
|
|
3
|
+
CliInvocation,
|
|
4
|
+
HeadlessAdapter,
|
|
5
|
+
} from './base.js';
|
|
6
|
+
|
|
7
|
+
const MODEL_PROBE_PROMPT = 'Reply with exactly RELAYFLOWS_MODEL_READY and nothing else.';
|
|
8
|
+
|
|
9
|
+
/** Claude Code CLI headless contract. Wire and behavior identical to the
|
|
10
|
+
* pre-#141 inline shape in `cli-adapter.ts` — only the packaging changed. */
|
|
11
|
+
export const claudeAdapter: HeadlessAdapter = {
|
|
12
|
+
kind: 'claude',
|
|
13
|
+
|
|
14
|
+
buildIdentification(): CliAdapterIdentification {
|
|
15
|
+
return { invocation: { args: ['auth', 'status', '--help'], timeoutMs: 10_000 } };
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
buildAuthProbe(): CliInvocation {
|
|
19
|
+
return { args: ['auth', 'status'], timeoutMs: 10_000 };
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
buildModelReadinessProbe(model: string): CliInvocation {
|
|
23
|
+
return {
|
|
24
|
+
args: [
|
|
25
|
+
'-p', '--model', model, '--tools', '', '--no-session-persistence',
|
|
26
|
+
MODEL_PROBE_PROMPT,
|
|
27
|
+
],
|
|
28
|
+
timeoutMs: 60_000,
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
buildAgentInvocation(instruction: string, model?: string): CliInvocation {
|
|
33
|
+
return {
|
|
34
|
+
args: [
|
|
35
|
+
'-p',
|
|
36
|
+
// Symmetric to codex's --dangerously-bypass-approvals-and-sandbox: in
|
|
37
|
+
// agent mode the flow explicitly delegates writes. Without this
|
|
38
|
+
// claude's headless mode prompts for tool approval, gets no TTY,
|
|
39
|
+
// and completes "successfully" without touching files.
|
|
40
|
+
'--dangerously-skip-permissions',
|
|
41
|
+
...(model === undefined ? [] : ['--model', model]),
|
|
42
|
+
instruction,
|
|
43
|
+
],
|
|
44
|
+
timeoutMs: 0,
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
buildLlmInvocation(prompt: string, model?: string): CliInvocation {
|
|
49
|
+
return {
|
|
50
|
+
args: ['-p', '--tools', '', '--no-session-persistence',
|
|
51
|
+
...(model === undefined ? [] : ['--model', model]), prompt],
|
|
52
|
+
timeoutMs: 0,
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CliAdapterIdentification,
|
|
3
|
+
CliInvocation,
|
|
4
|
+
HeadlessAdapter,
|
|
5
|
+
} from './base.js';
|
|
6
|
+
|
|
7
|
+
const MODEL_PROBE_PROMPT = 'Reply with exactly RELAYFLOWS_MODEL_READY and nothing else.';
|
|
8
|
+
|
|
9
|
+
/** OpenAI Codex CLI headless contract. Behavior identical to the pre-#141
|
|
10
|
+
* inline shape in `cli-adapter.ts` — only the packaging changed. */
|
|
11
|
+
export const codexAdapter: HeadlessAdapter = {
|
|
12
|
+
kind: 'codex',
|
|
13
|
+
|
|
14
|
+
buildIdentification(): CliAdapterIdentification {
|
|
15
|
+
return { invocation: { args: ['login', 'status', '--help'], timeoutMs: 10_000 } };
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
buildAuthProbe(): CliInvocation {
|
|
19
|
+
return { args: ['login', 'status'], timeoutMs: 10_000 };
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
buildModelReadinessProbe(model: string): CliInvocation {
|
|
23
|
+
return {
|
|
24
|
+
args: [
|
|
25
|
+
'exec', '--ephemeral', '--sandbox', 'read-only', '--skip-git-repo-check',
|
|
26
|
+
'--model', model, MODEL_PROBE_PROMPT,
|
|
27
|
+
],
|
|
28
|
+
timeoutMs: 60_000,
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
buildAgentInvocation(instruction: string, model?: string): CliInvocation {
|
|
33
|
+
return {
|
|
34
|
+
args: [
|
|
35
|
+
'exec', '--ephemeral', '--skip-git-repo-check',
|
|
36
|
+
// Agent-mode is where the flow explicitly delegates code changes to
|
|
37
|
+
// the CLI. Without this flag codex prompts for approval on every
|
|
38
|
+
// write, gets nothing (no TTY), and completes "successfully" without
|
|
39
|
+
// touching files — the dogfood no-op failure mode. LLM-mode stays
|
|
40
|
+
// read-only and does NOT get the bypass.
|
|
41
|
+
'--dangerously-bypass-approvals-and-sandbox',
|
|
42
|
+
...(model === undefined ? [] : ['--model', model]),
|
|
43
|
+
instruction,
|
|
44
|
+
],
|
|
45
|
+
timeoutMs: 0,
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
buildLlmInvocation(prompt: string, model?: string): CliInvocation {
|
|
50
|
+
return {
|
|
51
|
+
args: ['exec', '--ephemeral', '--sandbox', 'read-only', '--skip-git-repo-check',
|
|
52
|
+
...(model === undefined ? [] : ['--model', model]), prompt],
|
|
53
|
+
timeoutMs: 0,
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { basename } from 'node:path';
|
|
2
|
+
|
|
3
|
+
import { claudeAdapter } from './claude.js';
|
|
4
|
+
import { codexAdapter } from './codex.js';
|
|
5
|
+
import { wrapperAdapter } from './wrapper.js';
|
|
6
|
+
import type { HeadlessAdapter } from './base.js';
|
|
7
|
+
|
|
8
|
+
export type CliAdapterKind = 'claude' | 'codex' | 'relayflows-wrapper-v1';
|
|
9
|
+
|
|
10
|
+
/** The registered adapter set. Adding a CLI is adding one file + one entry. */
|
|
11
|
+
const ADAPTERS: Record<CliAdapterKind, HeadlessAdapter> = {
|
|
12
|
+
claude: claudeAdapter,
|
|
13
|
+
codex: codexAdapter,
|
|
14
|
+
'relayflows-wrapper-v1': wrapperAdapter,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** Select the adapter for the resolved executable basename. */
|
|
18
|
+
export function resolveAdapter(executable: string): HeadlessAdapter {
|
|
19
|
+
const name = basename(executable).replace(/\.exe$/i, '');
|
|
20
|
+
if (name === 'claude') return ADAPTERS.claude;
|
|
21
|
+
if (name === 'codex') return ADAPTERS.codex;
|
|
22
|
+
return ADAPTERS['relayflows-wrapper-v1'];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Backward-compatible kind lookup for callers still speaking string-tag lang. */
|
|
26
|
+
export function resolveAdapterKind(executable: string): CliAdapterKind {
|
|
27
|
+
return resolveAdapter(executable).kind as CliAdapterKind;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Registered adapters by kind (read-only view for tests and diagnostics). */
|
|
31
|
+
export function registeredAdapters(): Readonly<Record<CliAdapterKind, HeadlessAdapter>> {
|
|
32
|
+
return ADAPTERS;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { claudeAdapter, codexAdapter, wrapperAdapter };
|
|
36
|
+
export type { HeadlessAdapter, CliInvocation, CliAdapterIdentification } from './base.js';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CliAdapterIdentification,
|
|
3
|
+
CliInvocation,
|
|
4
|
+
HeadlessAdapter,
|
|
5
|
+
} from './base.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* `relayflows-adapter-v1` identifies a per-flow wrapper script — the pre-#141
|
|
9
|
+
* per-flow shim shape. The wrapper answers a probe with a known token; agent
|
|
10
|
+
* and llm execution flow through `runWrapperSession`, so this adapter refuses
|
|
11
|
+
* to construct a direct-argv invocation for them.
|
|
12
|
+
*/
|
|
13
|
+
export const WRAPPER_IDENTIFY_ARG = '--relayflows-adapter-v1';
|
|
14
|
+
export const WRAPPER_IDENTIFY_TOKEN = 'relayflows-agent-cli-v1';
|
|
15
|
+
export const WRAPPER_EXECUTE_TOKEN = 'relayflows-agent-cli-v1-execute';
|
|
16
|
+
|
|
17
|
+
export const wrapperAdapter: HeadlessAdapter = {
|
|
18
|
+
kind: 'relayflows-wrapper-v1',
|
|
19
|
+
|
|
20
|
+
buildIdentification(): CliAdapterIdentification {
|
|
21
|
+
return {
|
|
22
|
+
invocation: { args: [WRAPPER_IDENTIFY_ARG], timeoutMs: 10_000 },
|
|
23
|
+
expectedStdout: WRAPPER_IDENTIFY_TOKEN,
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
buildAuthProbe(): CliInvocation {
|
|
28
|
+
return { args: ['auth', 'status'], timeoutMs: 10_000 };
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
buildModelReadinessProbe(model: string): CliInvocation {
|
|
32
|
+
return { args: ['auth', 'status'], timeoutMs: 60_000, modelEnv: model };
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
buildAgentInvocation(): CliInvocation {
|
|
36
|
+
throw new Error('custom wrapper execution requires the runAgentCli same-process session');
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
buildLlmInvocation(): CliInvocation {
|
|
40
|
+
throw new Error('custom wrapper execution requires the same-process session');
|
|
41
|
+
},
|
|
42
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { canonicalize } from "./canonical.js";
|
|
2
|
+
|
|
3
|
+
export const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
4
|
+
typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5
|
+
export const nonempty = (value: unknown): value is string =>
|
|
6
|
+
typeof value === "string" && value.length > 0;
|
|
7
|
+
|
|
8
|
+
export interface RelayTaskExecution {
|
|
9
|
+
execution_id: string;
|
|
10
|
+
run_id: string;
|
|
11
|
+
step_id: string;
|
|
12
|
+
dispatch_id: string;
|
|
13
|
+
deadline: string;
|
|
14
|
+
worker_generation?: string;
|
|
15
|
+
accepted_at?: string;
|
|
16
|
+
accounting?: Record<string, number>;
|
|
17
|
+
}
|
|
18
|
+
export interface RelayTaskReceipt {
|
|
19
|
+
invocation_id: string;
|
|
20
|
+
action_name: "task.run";
|
|
21
|
+
status: "pending" | "dispatched" | "running" | "completed" | "failed";
|
|
22
|
+
task_execution: RelayTaskExecution;
|
|
23
|
+
output: unknown;
|
|
24
|
+
error: string | null;
|
|
25
|
+
completed_at: string | null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** GET is authoritative. A spawn/POST acknowledgment is never a task result. */
|
|
29
|
+
export function readTaskReceipt(
|
|
30
|
+
value: unknown,
|
|
31
|
+
invocationId: string,
|
|
32
|
+
input: Record<string, unknown>,
|
|
33
|
+
previous?: RelayTaskReceipt,
|
|
34
|
+
): RelayTaskReceipt {
|
|
35
|
+
const context = input.task_context as Record<string, unknown>;
|
|
36
|
+
if (
|
|
37
|
+
!isRecord(value) ||
|
|
38
|
+
value.invocation_id !== invocationId ||
|
|
39
|
+
value.action_name !== "task.run" ||
|
|
40
|
+
canonicalize(value.input) !== canonicalize(input) ||
|
|
41
|
+
!isRecord(value.task_execution)
|
|
42
|
+
) {
|
|
43
|
+
throw new Error("Relay task receipt has mismatched invocation or input");
|
|
44
|
+
}
|
|
45
|
+
const execution = value.task_execution;
|
|
46
|
+
const validDate = (date: unknown): date is string =>
|
|
47
|
+
nonempty(date) && Number.isFinite(Date.parse(date));
|
|
48
|
+
if (
|
|
49
|
+
!nonempty(execution.execution_id) ||
|
|
50
|
+
!validDate(execution.deadline) ||
|
|
51
|
+
["run_id", "step_id", "dispatch_id"].some(
|
|
52
|
+
(key) => execution[key] !== context[key],
|
|
53
|
+
) ||
|
|
54
|
+
!["pending", "dispatched", "running", "completed", "failed"].includes(
|
|
55
|
+
String(value.status),
|
|
56
|
+
)
|
|
57
|
+
) {
|
|
58
|
+
throw new Error("Relay task receipt has invalid execution correlation");
|
|
59
|
+
}
|
|
60
|
+
const accepted =
|
|
61
|
+
nonempty(execution.worker_generation) && validDate(execution.accepted_at);
|
|
62
|
+
if (
|
|
63
|
+
(value.status === "running" || value.status === "completed") &&
|
|
64
|
+
!accepted
|
|
65
|
+
) {
|
|
66
|
+
throw new Error("Relay task receipt is missing durable acceptance");
|
|
67
|
+
}
|
|
68
|
+
if (
|
|
69
|
+
(execution.worker_generation !== undefined ||
|
|
70
|
+
execution.accepted_at !== undefined) &&
|
|
71
|
+
!accepted
|
|
72
|
+
) {
|
|
73
|
+
throw new Error("Relay task receipt has incomplete durable acceptance");
|
|
74
|
+
}
|
|
75
|
+
if (
|
|
76
|
+
previous !== undefined &&
|
|
77
|
+
(previous.task_execution.execution_id !== execution.execution_id ||
|
|
78
|
+
previous.task_execution.deadline !== execution.deadline ||
|
|
79
|
+
(previous.task_execution.worker_generation !== undefined &&
|
|
80
|
+
(previous.task_execution.worker_generation !==
|
|
81
|
+
execution.worker_generation ||
|
|
82
|
+
previous.task_execution.accepted_at !== execution.accepted_at)))
|
|
83
|
+
) {
|
|
84
|
+
throw new Error(
|
|
85
|
+
"Relay task receipt changed its execution, accepted generation/time, or deadline",
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
if (
|
|
89
|
+
execution.accounting !== undefined &&
|
|
90
|
+
(!isRecord(execution.accounting) ||
|
|
91
|
+
Object.values(execution.accounting).some(
|
|
92
|
+
(n) => typeof n !== "number" || !Number.isFinite(n) || n < 0,
|
|
93
|
+
))
|
|
94
|
+
) {
|
|
95
|
+
throw new Error("Relay task receipt has invalid accounting");
|
|
96
|
+
}
|
|
97
|
+
if (
|
|
98
|
+
value.status === "completed" &&
|
|
99
|
+
(!Object.hasOwn(value, "output") ||
|
|
100
|
+
value.error !== null ||
|
|
101
|
+
!validDate(value.completed_at))
|
|
102
|
+
) {
|
|
103
|
+
throw new Error("Relay task receipt has no authoritative final output");
|
|
104
|
+
}
|
|
105
|
+
if (
|
|
106
|
+
value.status === "failed" &&
|
|
107
|
+
(!nonempty(value.error) || !validDate(value.completed_at))
|
|
108
|
+
) {
|
|
109
|
+
throw new Error("Relay task failure receipt has no reason");
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
invocation_id: invocationId,
|
|
113
|
+
action_name: "task.run",
|
|
114
|
+
status: value.status as RelayTaskReceipt["status"],
|
|
115
|
+
task_execution: execution as unknown as RelayTaskExecution,
|
|
116
|
+
output: value.output,
|
|
117
|
+
error: value.error as string | null,
|
|
118
|
+
completed_at: value.completed_at as string | null,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { mkdir, open, readFile } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { canonicalize } from "./canonical.js";
|
|
5
|
+
|
|
6
|
+
export interface RelayTaskClaim {
|
|
7
|
+
version: 1;
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
callerId: string;
|
|
10
|
+
workspaceId: string;
|
|
11
|
+
invocationId: string;
|
|
12
|
+
runId: string;
|
|
13
|
+
stepId: string;
|
|
14
|
+
idempotencyKey: string;
|
|
15
|
+
input: Record<string, unknown>;
|
|
16
|
+
startedAt: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Exclusive creation pins the request before POST; no last-writer overwrite. */
|
|
20
|
+
export async function claimRelayTask(
|
|
21
|
+
dataDir: string,
|
|
22
|
+
claim: RelayTaskClaim,
|
|
23
|
+
): Promise<{ claim: RelayTaskClaim; created: boolean }> {
|
|
24
|
+
const directory = join(dataDir, "relay-tasks");
|
|
25
|
+
await mkdir(directory, { recursive: true });
|
|
26
|
+
const parent = await open(dataDir, "r");
|
|
27
|
+
try {
|
|
28
|
+
await parent.sync();
|
|
29
|
+
} finally {
|
|
30
|
+
await parent.close();
|
|
31
|
+
}
|
|
32
|
+
const digest = createHash("sha256")
|
|
33
|
+
.update(canonicalize([claim.runId, claim.stepId, claim.idempotencyKey]))
|
|
34
|
+
.digest("hex");
|
|
35
|
+
const path = join(directory, `${digest}.json`);
|
|
36
|
+
let file;
|
|
37
|
+
try {
|
|
38
|
+
file = await open(path, "wx", 0o600);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
if ((error as NodeJS.ErrnoException).code !== "EEXIST") throw error;
|
|
41
|
+
const prior: unknown = JSON.parse(await readFile(path, "utf8"));
|
|
42
|
+
if (
|
|
43
|
+
typeof prior !== "object" ||
|
|
44
|
+
prior === null ||
|
|
45
|
+
!("startedAt" in prior) ||
|
|
46
|
+
typeof prior.startedAt !== "number" ||
|
|
47
|
+
!Number.isSafeInteger(prior.startedAt) ||
|
|
48
|
+
prior.startedAt < 0 ||
|
|
49
|
+
canonicalize(prior) !==
|
|
50
|
+
canonicalize({ ...claim, startedAt: prior.startedAt })
|
|
51
|
+
) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
"Relay task dispatch conflicts with its durable caller, endpoint, or input",
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
return { claim: prior as RelayTaskClaim, created: false };
|
|
57
|
+
}
|
|
58
|
+
// A crash during creation leaves a partial claim that fails closed on read.
|
|
59
|
+
// Never remove an uncertain claim and retry under a different identity.
|
|
60
|
+
try {
|
|
61
|
+
await file.writeFile(canonicalize(claim));
|
|
62
|
+
await file.sync();
|
|
63
|
+
} finally {
|
|
64
|
+
await file.close();
|
|
65
|
+
}
|
|
66
|
+
const dir = await open(directory, "r");
|
|
67
|
+
try {
|
|
68
|
+
await dir.sync();
|
|
69
|
+
} finally {
|
|
70
|
+
await dir.close();
|
|
71
|
+
}
|
|
72
|
+
return { claim, created: true };
|
|
73
|
+
}
|