@relayflows/sdk 2.0.8 → 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 +1 -1
- package/dist/authored-flow-error.d.ts.map +1 -1
- 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 +115 -194
- 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 -7
- 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 -0
- package/src/authored-flow-executor.ts +170 -293
- 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 -7
- 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,78 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { statSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { writeJsonFile } from '@relayfile/adapter-core/vfs-client';
|
|
5
|
+
import type { RelayTransport } from '@relayfile/relay-helpers';
|
|
6
|
+
import type { JournalClient } from './journal-client.js';
|
|
7
|
+
import type { StepDispatchEvent } from './protocol.js';
|
|
8
|
+
import { atomicJson, readSlackReceipt, receiptPath, slackWriteback } from './slack-writeback.js';
|
|
9
|
+
import { invokeHelper, type HelperCall } from './yaml-helpers.js';
|
|
10
|
+
import { withWorkerLease } from './worker-lease.js';
|
|
11
|
+
|
|
12
|
+
export function helperMount(provider: string, env = process.env): string | undefined {
|
|
13
|
+
const root = [env.RELAYFILE_MOUNT_PATH, env.WORKSPACE_ROOT, env.WORKFORCE_SANDBOX_ROOT,
|
|
14
|
+
env.RELAYFILE_MOUNT_ROOT, env.RELAYFILE_ROOT].find(value => value?.trim());
|
|
15
|
+
if (!root) return undefined;
|
|
16
|
+
try { return statSync(join(root, provider)).isDirectory() ? root : undefined; }
|
|
17
|
+
catch { return undefined; }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function helperReady(provider: string): boolean {
|
|
21
|
+
return (provider === 'slack' && process.env.RELAYFLOWS_SLACK_MOCK === '1') || helperMount(provider) !== undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function writeback(call: HelperCall, dataDir: string, runId: string, stepId: string, signal: AbortSignal) {
|
|
25
|
+
// Exactly the TS surface's client, transport, idempotency stamp and receipt checks.
|
|
26
|
+
if (call.provider === 'slack') return slackWriteback(call, dataDir, runId, stepId, signal);
|
|
27
|
+
const mount = helperMount(call.provider);
|
|
28
|
+
if (mount === undefined) throw new Error(`${call.provider} helper requires a relayfile mount`);
|
|
29
|
+
const idempotencyKey = `${runId}:${stepId}`;
|
|
30
|
+
const transport: RelayTransport = {
|
|
31
|
+
async read() { throw new Error('Helper effect transport is write-only'); },
|
|
32
|
+
async list() { throw new Error('Helper effect transport is write-only'); },
|
|
33
|
+
async write(request) {
|
|
34
|
+
signal.throwIfAborted();
|
|
35
|
+
const body = { ...request.body as Record<string, unknown>, idempotencyKey };
|
|
36
|
+
// Item updates keep the client's canonical path. Creates use a stable draft.
|
|
37
|
+
const path = request.path.endsWith('.json') ? request.path
|
|
38
|
+
: `${request.path}/draft-${createHash('sha256').update(idempotencyKey).digest('hex')}.json`;
|
|
39
|
+
const result = await writeJsonFile({ relayfileMountRoot: mount }, request.provider,
|
|
40
|
+
`write.${request.resource}`, path, body);
|
|
41
|
+
if (result.deliveryStatus !== 'confirmed' || !result.receipt) {
|
|
42
|
+
throw new Error(`${call.provider} writeback is pending; no delivery receipt`);
|
|
43
|
+
}
|
|
44
|
+
signal.throwIfAborted();
|
|
45
|
+
return result;
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
return invokeHelper(call, transport);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Existing lease/effect election protocol; provider verbs never enter the kernel. */
|
|
52
|
+
export async function completeHelperDispatch(
|
|
53
|
+
client: JournalClient, dispatch: StepDispatchEvent, call: HelperCall, dataDir: string,
|
|
54
|
+
): Promise<void> {
|
|
55
|
+
const surfacePath = `/${call.provider}`;
|
|
56
|
+
const output = await withWorkerLease(client, dispatch, async signal => {
|
|
57
|
+
const file = receiptPath(dataDir, dispatch.run_id, dispatch.step_id);
|
|
58
|
+
let receipt: unknown;
|
|
59
|
+
await client.performEffect({
|
|
60
|
+
runId: dispatch.run_id, stepId: dispatch.step_id, attempt: dispatch.attempt,
|
|
61
|
+
idempotencyKey: dispatch.idempotency_key, surfacePath,
|
|
62
|
+
revisionBefore: 'pending', revisionAfter: `${dispatch.run_id}:${dispatch.step_id}`,
|
|
63
|
+
}, async () => {
|
|
64
|
+
try { receipt = await readSlackReceipt(file); }
|
|
65
|
+
catch (error) {
|
|
66
|
+
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;
|
|
67
|
+
receipt = await writeback(call, dataDir, dispatch.run_id, dispatch.step_id, signal);
|
|
68
|
+
await atomicJson(file, receipt);
|
|
69
|
+
}
|
|
70
|
+
signal.throwIfAborted();
|
|
71
|
+
});
|
|
72
|
+
if (receipt === undefined) receipt = await readSlackReceipt(file);
|
|
73
|
+
return { ...call, idempotencyKey: `${dispatch.run_id}:${dispatch.step_id}`, receipt };
|
|
74
|
+
});
|
|
75
|
+
await client.stepComplete(dispatch.run_id, dispatch.step_id, dispatch.attempt,
|
|
76
|
+
dispatch.idempotency_key, 'success', { output, started_pins: dispatch.pins, end_pins: dispatch.pins,
|
|
77
|
+
effects: [{ surface_path: surfacePath, idempotency_key: dispatch.idempotency_key }] });
|
|
78
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import Ajv from 'ajv';
|
|
2
|
+
import { githubClient, linearClient, slackClient, type RelayTransport } from '@relayfile/relay-helpers';
|
|
3
|
+
import type { AgentStepSpec, KernelAgentStep, YamlHelperParams } from './spec.js';
|
|
4
|
+
import { canonicalize } from './canonical.js';
|
|
5
|
+
import { unknownKeyErrors } from './unknown-keys.js';
|
|
6
|
+
|
|
7
|
+
const string = { type: 'string', minLength: 1 };
|
|
8
|
+
const text = { type: 'string' };
|
|
9
|
+
const strings = { type: 'array', items: string };
|
|
10
|
+
const object = (properties: Record<string, unknown>, required = Object.keys(properties)) =>
|
|
11
|
+
({ type: 'object', properties, required, additionalProperties: false });
|
|
12
|
+
const target = object({ owner: string, repo: string, number: { type: 'integer', minimum: 1 } });
|
|
13
|
+
const issueChanges = { title: string, description: text, assigneeId: string, stateId: string,
|
|
14
|
+
projectId: string, labelIds: strings, addedLabelIds: strings, removedLabelIds: strings };
|
|
15
|
+
const ajv = new Ajv({ allErrors: true });
|
|
16
|
+
|
|
17
|
+
function verb<P>(schema: object, invoke: (params: P, transport: RelayTransport) => Promise<unknown>) {
|
|
18
|
+
const validate = ajv.compile(schema);
|
|
19
|
+
return { validate, invoke: (params: unknown, transport: RelayTransport) => invoke(params as P, transport) };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Closed catalog: only write verbs with a declared argument schema can execute. */
|
|
23
|
+
const helpers = {
|
|
24
|
+
slack: {
|
|
25
|
+
post: verb<YamlHelperParams['slack']['post']>(object({ channel: string, text,
|
|
26
|
+
opts: object({ replyTo: string }, []) }, ['channel', 'text']),
|
|
27
|
+
(p, transport) => slackClient({ transport }).post(p.channel, p.text as string, p.opts as { replyTo?: string } | undefined)),
|
|
28
|
+
dm: verb<YamlHelperParams['slack']['dm']>(object({ user: string, text }),
|
|
29
|
+
(p, transport) => slackClient({ transport }).dm(p.user, p.text)),
|
|
30
|
+
reply: verb<YamlHelperParams['slack']['reply']>(object({ channel: string, threadTs: string, text }),
|
|
31
|
+
(p, transport) => slackClient({ transport }).reply(p.channel, p.threadTs, p.text)),
|
|
32
|
+
react: verb<YamlHelperParams['slack']['react']>(object({ channel: string, messageTs: string, emoji: string }),
|
|
33
|
+
(p, transport) => slackClient({ transport }).react(p.channel, p.messageTs, p.emoji)),
|
|
34
|
+
},
|
|
35
|
+
github: {
|
|
36
|
+
comment: verb<YamlHelperParams['github']['comment']>(object({ target, body: text }),
|
|
37
|
+
(p, transport) => githubClient({ transport }).comment(p.target, p.body)),
|
|
38
|
+
createIssue: verb<YamlHelperParams['github']['createIssue']>(object({ owner: string, repo: string,
|
|
39
|
+
title: string, body: text, labels: strings }, ['owner', 'repo', 'title', 'body']),
|
|
40
|
+
(p, transport) => githubClient({ transport }).createIssue(p)),
|
|
41
|
+
createPullRequest: verb<YamlHelperParams['github']['createPullRequest']>(object({ owner: string,
|
|
42
|
+
repo: string, title: string, head: string, base: string, body: text, draft: { type: 'boolean' },
|
|
43
|
+
author: { enum: ['app', 'user'] } }, ['owner', 'repo', 'title', 'head', 'base']),
|
|
44
|
+
(p, transport) => githubClient({ transport }).createPullRequest(p)),
|
|
45
|
+
closePullRequest: verb<YamlHelperParams['github']['closePullRequest']>(target,
|
|
46
|
+
(p, transport) => githubClient({ transport }).closePullRequest(p)),
|
|
47
|
+
},
|
|
48
|
+
linear: {
|
|
49
|
+
comment: verb<YamlHelperParams['linear']['comment']>(object({ issueId: string, body: text }),
|
|
50
|
+
(p, transport) => linearClient({ transport }).comment(p.issueId, p.body)),
|
|
51
|
+
createIssue: verb<YamlHelperParams['linear']['createIssue']>(object({ teamId: string, title: string,
|
|
52
|
+
description: text, assigneeId: string, labelIds: strings, projectId: string, stateId: string }, ['teamId', 'title']),
|
|
53
|
+
(p, transport) => linearClient({ transport }).createIssue(p)),
|
|
54
|
+
updateIssue: verb<YamlHelperParams['linear']['updateIssue']>(object({ issueId: string,
|
|
55
|
+
args: object(issueChanges, []) }),
|
|
56
|
+
(p, transport) => linearClient({ transport }).updateIssue(p.issueId, p.args)),
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type HelperCall = { [P in keyof YamlHelperParams]: { [V in keyof YamlHelperParams[P]]:
|
|
61
|
+
{ type: 'effect'; provider: P; verb: V; params: YamlHelperParams[P][V] }
|
|
62
|
+
}[keyof YamlHelperParams[P]] }[keyof YamlHelperParams];
|
|
63
|
+
|
|
64
|
+
const prefix = 'relayflows:helper:v1\n';
|
|
65
|
+
const commonFields = ['id', 'dependsOn', 'maxIterations', 'verification', 'output'] as const;
|
|
66
|
+
const isObject = (value: unknown): value is Record<string, unknown> =>
|
|
67
|
+
value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
68
|
+
|
|
69
|
+
function descriptor(provider: string, name: string) {
|
|
70
|
+
if (!Object.hasOwn(helpers, provider)) throw new Error(`unknown helper provider "${provider}"`);
|
|
71
|
+
const verbs = helpers[provider as keyof typeof helpers];
|
|
72
|
+
if (!Object.hasOwn(verbs, name)) throw new Error(`unknown ${provider} helper verb "${name}"`);
|
|
73
|
+
return (verbs as Record<string, ReturnType<typeof verb>>)[name]!;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function validateCall(value: unknown): HelperCall {
|
|
77
|
+
if (!isObject(value) || value.type !== 'effect' || typeof value.provider !== 'string' || typeof value.verb !== 'string') {
|
|
78
|
+
throw new Error('expected a helper effect call');
|
|
79
|
+
}
|
|
80
|
+
const extra = unknownKeyErrors(value, ['type', 'provider', 'verb', 'params'], 'helper');
|
|
81
|
+
if (extra.length) throw new Error(extra.join('; '));
|
|
82
|
+
const entry = descriptor(value.provider, value.verb);
|
|
83
|
+
if (!entry.validate(value.params)) {
|
|
84
|
+
throw new Error(`${value.provider}.${value.verb}: ${ajv.errorsText(entry.validate.errors)}`);
|
|
85
|
+
}
|
|
86
|
+
return value as HelperCall;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Runs on the inert JSON snapshot, before ordinary step validation. */
|
|
90
|
+
export function expandYamlHelpers(spec: unknown): unknown {
|
|
91
|
+
if (!isObject(spec) || !Array.isArray(spec.steps)) return spec;
|
|
92
|
+
return { ...spec, steps: spec.steps.map((step, index) => {
|
|
93
|
+
if (!isObject(step)) return step;
|
|
94
|
+
const providers = Object.keys(helpers).filter(provider => Object.hasOwn(step, provider));
|
|
95
|
+
if (!providers.length) {
|
|
96
|
+
// Recompiling a canonical envelope must fail with the same compile error
|
|
97
|
+
// contract as authoring it, before preflight or workers see it.
|
|
98
|
+
helperCall(step);
|
|
99
|
+
return step;
|
|
100
|
+
}
|
|
101
|
+
const at = `spec.steps[${index}]`;
|
|
102
|
+
try {
|
|
103
|
+
if (providers.length !== 1) throw new Error('expected exactly one helper provider per step');
|
|
104
|
+
const provider = providers[0]!;
|
|
105
|
+
const errors = unknownKeyErrors(step, [...commonFields, provider], at);
|
|
106
|
+
if (errors.length) throw new Error(errors.join('; '));
|
|
107
|
+
const verbs = step[provider];
|
|
108
|
+
if (!isObject(verbs) || Object.keys(verbs).length !== 1) throw new Error(`${provider}: expected exactly one helper verb`);
|
|
109
|
+
const name = Object.keys(verbs)[0]!;
|
|
110
|
+
const call = validateCall({ type: 'effect', provider, verb: name, params: verbs[name] });
|
|
111
|
+
const { [provider]: _, ...base } = step;
|
|
112
|
+
return { ...base, type: 'agent', instruction: prefix + canonicalize(call),
|
|
113
|
+
recoveryMode: 'reset', surfaces: { external: [`/${provider}`] } };
|
|
114
|
+
} catch (error) {
|
|
115
|
+
throw new Error(`${at}: ${error instanceof Error ? error.message : String(error)}`);
|
|
116
|
+
}
|
|
117
|
+
}) };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** The versioned instruction envelope survives canonical specs and journal resume. */
|
|
121
|
+
export function helperCall(step: Partial<AgentStepSpec | KernelAgentStep>): HelperCall | undefined {
|
|
122
|
+
if (step.type !== 'agent' || typeof step.instruction !== 'string' || !step.instruction.startsWith(prefix)) return undefined;
|
|
123
|
+
const call = validateCall(JSON.parse(step.instruction.slice(prefix.length)));
|
|
124
|
+
if (!step.surfaces?.external?.includes(`/${call.provider}`)) throw new Error('helper effect is missing its declared external surface');
|
|
125
|
+
return call;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export async function invokeHelper(call: HelperCall, transport: RelayTransport): Promise<unknown> {
|
|
129
|
+
const validated = validateCall(call);
|
|
130
|
+
return (await descriptor(validated.provider, validated.verb).invoke(validated.params, transport)) ?? null;
|
|
131
|
+
}
|