@parcha/agentrun-serve 0.1.0-beta.36 → 0.1.0-beta.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +452 -0
- package/README.md +311 -142
- package/dist/agent-rows.d.ts +1 -1
- package/dist/agents-store.d.ts +35 -3
- package/dist/agents-store.js +39 -14
- package/dist/answer-json.d.ts +34 -1
- package/dist/answer-json.js +91 -9
- package/dist/api-only.d.ts +1 -1
- package/dist/api-only.js +2 -2
- package/dist/attach-conformance-cli.d.ts +1 -0
- package/dist/attach-conformance-cli.js +18 -0
- package/dist/attach-conformance.d.ts +25 -0
- package/dist/attach-conformance.js +343 -0
- package/dist/browser-cost.d.ts +1 -1
- package/dist/browser-cost.js +52 -93
- package/dist/browser-live.d.ts +20 -8
- package/dist/browser-live.js +50 -27
- package/dist/cap.d.ts +0 -407
- package/dist/cap.js +4 -1028
- package/dist/catalog.d.ts +1 -12
- package/dist/catalog.js +4 -34
- package/dist/cli.js +13 -4
- package/dist/composio-preset.d.ts +53 -0
- package/dist/composio-preset.js +221 -0
- package/dist/computer-attach.d.ts +125 -0
- package/dist/computer-attach.js +330 -0
- package/dist/computer-calls.d.ts +60 -0
- package/dist/computer-calls.js +209 -0
- package/dist/computer-channel.d.ts +57 -0
- package/dist/computer-channel.js +115 -0
- package/dist/computer-commands.d.ts +1 -1
- package/dist/computer-held-routes.d.ts +35 -0
- package/dist/computer-held-routes.js +106 -0
- package/dist/computer-held.d.ts +48 -0
- package/dist/computer-held.js +87 -0
- package/dist/computer-keys.d.ts +21 -1
- package/dist/computer-keys.js +53 -11
- package/dist/computer-live.d.ts +165 -0
- package/dist/computer-live.js +655 -0
- package/dist/computer-setting.d.ts +15 -2
- package/dist/computer-setting.js +20 -4
- package/dist/computer-view.d.ts +14 -0
- package/dist/computer-view.js +51 -3
- package/dist/computer-viewer.d.ts +6 -0
- package/dist/computer-viewer.js +311 -0
- package/dist/computers.d.ts +37 -8
- package/dist/computers.js +62 -14
- package/dist/console/assets/index-CjqQirbo.css +1 -0
- package/dist/console/assets/index-b6-XY5A9.js +576 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +2 -0
- package/dist/console-links.js +3 -0
- package/dist/decisions.js +4 -0
- package/dist/faux-computers.d.ts +9 -20
- package/dist/faux-computers.js +56 -26
- package/dist/github-connection.d.ts +10 -2
- package/dist/github-connection.js +65 -2
- package/dist/github-faux.js +1 -1
- package/dist/graph-view.d.ts +1 -1
- package/dist/harness-opencode/adapter.js +7 -3
- package/dist/harness-opencode/facts.js +0 -2
- package/dist/harness-opencode/host/policy.d.ts +2 -5
- package/dist/harness-opencode/host/policy.js +8 -32
- package/dist/harness-table.d.ts +0 -2
- package/dist/harness-table.js +0 -2
- package/dist/harness.d.ts +1 -0
- package/dist/harness.js +35 -1
- package/dist/host-tools.d.ts +2 -6
- package/dist/host-tools.js +7 -10
- package/dist/hosted-search.d.ts +5 -6
- package/dist/hosted-search.js +2 -28
- package/dist/import-sources.d.ts +10 -0
- package/dist/import-sources.js +44 -2
- package/dist/import.d.ts +3 -3
- package/dist/import.js +37 -6
- package/dist/key-words.d.ts +3 -2
- package/dist/key-words.js +4 -2
- package/dist/learn/check.d.ts +10 -2
- package/dist/learn/check.js +13 -5
- package/dist/learn/commit.d.ts +14 -2
- package/dist/learn/commit.js +23 -9
- package/dist/learn/compile.d.ts +243 -0
- package/dist/learn/compile.js +471 -0
- package/dist/learn/folder.d.ts +6 -0
- package/dist/learn/folder.js +4 -1
- package/dist/learn/general.d.ts +69 -0
- package/dist/learn/general.js +75 -0
- package/dist/learn/grade.d.ts +5 -1
- package/dist/learn/grade.js +29 -7
- package/dist/learn/notes.d.ts +8 -0
- package/dist/learn/notes.js +18 -0
- package/dist/learn/promote.d.ts +253 -0
- package/dist/learn/promote.js +428 -0
- package/dist/learn/refit.d.ts +39 -0
- package/dist/learn/refit.js +236 -0
- package/dist/learn/reflect.d.ts +9 -20
- package/dist/learn/reflect.js +18 -125
- package/dist/learn/replay-calls.d.ts +63 -0
- package/dist/learn/replay-calls.js +158 -0
- package/dist/learn/skills.d.ts +50 -14
- package/dist/learn/skills.js +183 -47
- package/dist/learn/workflow-nodes.d.ts +15 -0
- package/dist/learn/workflow-nodes.js +44 -0
- package/dist/learned-nodes.d.ts +50 -2
- package/dist/learned-nodes.js +41 -2
- package/dist/learned-workflow.d.ts +43 -3
- package/dist/learned-workflow.js +170 -28
- package/dist/learning-batch.d.ts +283 -0
- package/dist/learning-batch.js +574 -0
- package/dist/learning-cost.d.ts +18 -6
- package/dist/learning-cost.js +15 -7
- package/dist/learning-evals.d.ts +33 -0
- package/dist/learning-evals.js +98 -0
- package/dist/learning-routes.d.ts +37 -2
- package/dist/learning-routes.js +52 -8
- package/dist/learning-words.d.ts +13 -0
- package/dist/learning-words.js +13 -0
- package/dist/learning.d.ts +55 -17
- package/dist/learning.js +91 -48
- package/dist/live/stream.js +6 -3
- package/dist/live/translate.d.ts +4 -3
- package/dist/live/translate.js +8 -4
- package/dist/live-reach.d.ts +37 -0
- package/dist/live-reach.js +62 -0
- package/dist/llm.js +0 -3
- package/dist/mcp-gateway.d.ts +21 -20
- package/dist/mcp-gateway.js +76 -55
- package/dist/mcp-oauth.d.ts +62 -7
- package/dist/mcp-oauth.js +134 -19
- package/dist/mcp-pin-first.d.ts +37 -0
- package/dist/mcp-pin-first.js +107 -0
- package/dist/mcp-private-hosts.d.ts +4 -4
- package/dist/mcp-private-hosts.js +20 -12
- package/dist/mcp-probe.d.ts +27 -11
- package/dist/mcp-probe.js +60 -42
- package/dist/mcp-secret-writes.js +4 -0
- package/dist/mcp-servers-store.d.ts +115 -25
- package/dist/mcp-servers-store.js +241 -43
- package/dist/mcp-sources.d.ts +39 -0
- package/dist/mcp-sources.js +74 -0
- package/dist/mcp-store.d.ts +21 -4
- package/dist/mcp-store.js +33 -8
- package/dist/mcp-wire.d.ts +22 -0
- package/dist/mcp-wire.js +36 -0
- package/dist/mcp.js +3 -3
- package/dist/meta-tool-names.d.ts +1 -0
- package/dist/meta-tool-names.js +3 -0
- package/dist/model-form.d.ts +26 -0
- package/dist/model-form.js +80 -0
- package/dist/model.d.ts +13 -0
- package/dist/model.js +69 -25
- package/dist/monid.d.ts +51 -25
- package/dist/monid.js +226 -140
- package/dist/openapi.js +694 -59
- package/dist/page.d.ts +18 -0
- package/dist/page.js +48 -20
- package/dist/paid-calls.d.ts +26 -29
- package/dist/paid-calls.js +46 -102
- package/dist/place-offers.d.ts +2 -3
- package/dist/place-offers.js +3 -7
- package/dist/place.js +1 -2
- package/dist/print.d.ts +15 -1
- package/dist/print.js +14 -3
- package/dist/propose.d.ts +10 -1
- package/dist/propose.js +30 -10
- package/dist/provider.js +12 -4
- package/dist/reflect-range.d.ts +8 -1
- package/dist/reflect-range.js +3 -2
- package/dist/rows.d.ts +5 -3
- package/dist/rows.js +15 -4
- package/dist/run-launch.d.ts +27 -2
- package/dist/run-launch.js +15 -4
- package/dist/run-learning-served.d.ts +13 -2
- package/dist/run-manifest.d.ts +5 -0
- package/dist/run-manifest.js +20 -0
- package/dist/run-reads-over-store.d.ts +1 -1
- package/dist/run-repo.d.ts +20 -0
- package/dist/run-repo.js +63 -0
- package/dist/run-secrets.js +2 -3
- package/dist/run-timeline-served.d.ts +1 -1
- package/dist/run-timeline-served.js +5 -2
- package/dist/run-view.d.ts +19 -8
- package/dist/run-view.js +62 -26
- package/dist/runnable.d.ts +0 -3
- package/dist/runnable.js +37 -29
- package/dist/runner/adapter-loop.d.ts +47 -17
- package/dist/runner/adapter-loop.js +1427 -303
- package/dist/runner/adapter-run-spec.d.ts +23 -9
- package/dist/runner/adapter-run-spec.js +162 -56
- package/dist/runner/adapters/pi-computer.d.ts +9 -0
- package/dist/runner/adapters/pi-computer.js +51 -0
- package/dist/runner/adapters/pi.d.ts +25 -11
- package/dist/runner/adapters/pi.js +168 -45
- package/dist/runner/beside.d.ts +7 -3
- package/dist/runner/beside.js +21 -11
- package/dist/runner/claim-secrets.d.ts +4 -0
- package/dist/runner/claim-secrets.js +6 -1
- package/dist/runner/cli-run-spec.d.ts +20 -3
- package/dist/runner/cli-run-spec.js +174 -64
- package/dist/runner/commands.d.ts +3 -1
- package/dist/runner/commands.js +28 -3
- package/dist/runner/computer-channel.d.ts +34 -0
- package/dist/runner/computer-channel.js +62 -0
- package/dist/runner/conformance/harness.d.ts +3 -0
- package/dist/runner/conformance/harness.js +224 -17
- package/dist/runner/conformance/subject.d.ts +12 -5
- package/dist/runner/dispatch.js +3 -0
- package/dist/runner/end-of-run.d.ts +23 -12
- package/dist/runner/end-of-run.js +41 -16
- package/dist/runner/feedback-round.d.ts +52 -0
- package/dist/runner/feedback-round.js +79 -0
- package/dist/runner/github-app.d.ts +2 -1
- package/dist/runner/github-app.js +4 -2
- package/dist/runner/harness-loops.js +15 -1
- package/dist/runner/held-run.d.ts +65 -0
- package/dist/runner/held-run.js +158 -0
- package/dist/runner/journal-kinds.d.ts +44 -7
- package/dist/runner/journal-kinds.js +29 -0
- package/dist/runner/journal-reader.d.ts +5 -4
- package/dist/runner/journal-reader.js +12 -10
- package/dist/runner/learning-ask.d.ts +7 -1
- package/dist/runner/learning-ask.js +21 -6
- package/dist/runner/learning-dispatch.d.ts +22 -0
- package/dist/runner/learning-dispatch.js +77 -10
- package/dist/runner/learning-end.d.ts +69 -13
- package/dist/runner/learning-end.js +340 -87
- package/dist/runner/learning-factory.d.ts +1 -1
- package/dist/runner/learning-factory.js +11 -5
- package/dist/runner/learning-loop.d.ts +86 -8
- package/dist/runner/learning-loop.js +178 -23
- package/dist/runner/learning-seed.d.ts +11 -0
- package/dist/runner/learning-seed.js +27 -0
- package/dist/runner/live-ticker.js +1 -0
- package/dist/runner/loop-contract.d.ts +26 -3
- package/dist/runner/loop.d.ts +21 -2
- package/dist/runner/loop.js +23 -2
- package/dist/runner/main.d.ts +13 -1
- package/dist/runner/main.js +27 -5
- package/dist/runner/mcp-claim.d.ts +15 -8
- package/dist/runner/mcp-claim.js +176 -71
- package/dist/runner/mcp-github.js +1 -1
- package/dist/runner/mcp-run.d.ts +21 -57
- package/dist/runner/mcp-run.js +25 -85
- package/dist/runner/meta-tools.d.ts +37 -0
- package/dist/runner/meta-tools.js +268 -0
- package/dist/runner/metrics.d.ts +11 -2
- package/dist/runner/metrics.js +26 -5
- package/dist/runner/model-route.js +12 -3
- package/dist/runner/monid-run.d.ts +16 -0
- package/dist/runner/monid-run.js +96 -0
- package/dist/runner/pr-checkout.d.ts +1 -0
- package/dist/runner/pr-checkout.js +1 -1
- package/dist/runner/promotion.d.ts +80 -0
- package/dist/runner/promotion.js +562 -0
- package/dist/runner/reflect-hook.d.ts +46 -13
- package/dist/runner/reflect-hook.js +149 -48
- package/dist/runner/runner.d.ts +26 -0
- package/dist/runner/runner.js +208 -17
- package/dist/runner/scratch-sweep.d.ts +13 -0
- package/dist/runner/scratch-sweep.js +62 -0
- package/dist/runner/sessions.d.ts +9 -4
- package/dist/runner/sessions.js +5 -1
- package/dist/runner/step-guard.d.ts +62 -0
- package/dist/runner/step-guard.js +93 -0
- package/dist/runner/store-port.d.ts +4 -2
- package/dist/runner/store-secrets.js +4 -3
- package/dist/runner/subagent.d.ts +0 -3
- package/dist/runner/subagent.js +10 -13
- package/dist/runner/workflow-first.d.ts +216 -0
- package/dist/runner/workflow-first.js +303 -0
- package/dist/runner/workflow-host.d.ts +6 -1
- package/dist/runner/workflow-host.js +1 -1
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +17 -10
- package/dist/runner/workflow-spec.d.ts +15 -2
- package/dist/runner/workflow-spec.js +63 -23
- package/dist/runs-over-store.d.ts +17 -3
- package/dist/runs-over-store.js +59 -20
- package/dist/seal-key.js +3 -3
- package/dist/sealed-settings-store.d.ts +5 -2
- package/dist/sealed-settings-store.js +10 -4
- package/dist/secret-writes.d.ts +5 -4
- package/dist/secret-writes.js +5 -4
- package/dist/server-secrets-store.d.ts +4 -3
- package/dist/server-secrets-store.js +15 -9
- package/dist/server-secrets.js +3 -2
- package/dist/server.d.ts +119 -18
- package/dist/server.js +841 -202
- package/dist/settings-wake.d.ts +23 -0
- package/dist/settings-wake.js +65 -0
- package/dist/standard-webhooks.d.ts +4 -1
- package/dist/standard-webhooks.js +8 -4
- package/dist/store/agent-body.d.ts +14 -3
- package/dist/store/agent-body.js +14 -10
- package/dist/store/command-wake.d.ts +13 -0
- package/dist/store/command-wake.js +37 -0
- package/dist/store/dialect.d.ts +6 -0
- package/dist/store/dialect.js +5 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/journal/storage.d.ts +3 -2
- package/dist/store/journal/storage.js +13 -5
- package/dist/store/postgres/connection.js +3 -1
- package/dist/store/postgres/dialect.js +4 -0
- package/dist/store/postgres/migrations/0005_learning_rounds.sql +14 -0
- package/dist/store/postgres/migrations/0006_run_changes_channel_attempts.sql +57 -0
- package/dist/store/postgres/migrations/0007_viewer_host.sql +11 -0
- package/dist/store/postgres/migrations/0008_paired_computers.sql +30 -0
- package/dist/store/postgres/migrations/0009_commands_answer.sql +10 -0
- package/dist/store/postgres/migrations/0010_imported_templates.sql +18 -0
- package/dist/store/postgres/migrations/0011_revision_mcp_pin.sql +13 -0
- package/dist/store/schema.d.ts +10 -1
- package/dist/store/schema.js +104 -15
- package/dist/store/sqlite/connection.d.ts +2 -2
- package/dist/store/sqlite/connection.js +2 -2
- package/dist/store/sqlite/run-patch.d.ts +7 -5
- package/dist/store/sqlite/run-patch.js +45 -18
- package/dist/store/sqlite/store.js +331 -72
- package/dist/store/store.d.ts +312 -21
- package/dist/store/store.js +12 -1
- package/dist/store-reads/cap.d.ts +1 -1
- package/dist/store-reads/cap.js +8 -1
- package/dist/store-reads/decisions.d.ts +2 -2
- package/dist/store-reads/decisions.js +1 -1
- package/dist/store-reads/import-summary.d.ts +1 -1
- package/dist/store-reads/journal.d.ts +30 -5
- package/dist/store-reads/journal.js +128 -56
- package/dist/store-reads/learning.d.ts +114 -12
- package/dist/store-reads/learning.js +238 -48
- package/dist/store-reads/loop.d.ts +61 -0
- package/dist/store-reads/loop.js +111 -0
- package/dist/store-reads/runs.d.ts +1 -1
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-view.d.ts +6 -0
- package/dist/store-view.js +59 -26
- package/dist/template-eval.d.ts +18 -9
- package/dist/template-eval.js +95 -68
- package/dist/template-github-permissions.d.ts +24 -10
- package/dist/template-github-permissions.js +36 -15
- package/dist/template-import.d.ts +31 -0
- package/dist/template-import.js +121 -0
- package/dist/template-source.d.ts +51 -0
- package/dist/template-source.js +371 -0
- package/dist/templates.d.ts +218 -46
- package/dist/templates.js +493 -181
- package/dist/timeline/computer.d.ts +48 -0
- package/dist/timeline/computer.js +169 -0
- package/dist/timeline/index.d.ts +4 -3
- package/dist/timeline/index.js +4 -3
- package/dist/timeline/labels.d.ts +6 -2
- package/dist/timeline/labels.js +93 -2
- package/dist/timeline/origin.d.ts +19 -5
- package/dist/timeline/origin.js +11 -4
- package/dist/timeline/timeline.d.ts +22 -1
- package/dist/timeline/timeline.js +34 -18
- package/dist/timeline/util.d.ts +4 -0
- package/dist/timeline/util.js +14 -0
- package/dist/tool-gate.d.ts +84 -50
- package/dist/tool-gate.js +179 -101
- package/dist/tool-keys.d.ts +4 -1
- package/dist/tool-keys.js +8 -3
- package/dist/tool-list.d.ts +26 -0
- package/dist/tool-list.js +43 -0
- package/dist/tool-names.d.ts +71 -0
- package/dist/tool-names.js +99 -0
- package/dist/tool-plane.d.ts +33 -27
- package/dist/tool-plane.js +72 -39
- package/dist/tools.d.ts +32 -7
- package/dist/tools.js +37 -24
- package/dist/trigger-adapter.d.ts +4 -0
- package/dist/trigger-secrets-shown.d.ts +2 -2
- package/dist/trigger-secrets-shown.js +1 -1
- package/dist/trigger-signatures.d.ts +25 -6
- package/dist/trigger-signatures.js +41 -7
- package/dist/trigger-targets.d.ts +2 -0
- package/dist/trigger-targets.js +1 -0
- package/dist/trigger-webhook.js +5 -2
- package/dist/triggers.d.ts +7 -3
- package/dist/triggers.js +35 -5
- package/dist/turns.js +16 -1
- package/dist/validate.d.ts +15 -7
- package/dist/validate.js +102 -45
- package/dist/web-fetch.d.ts +2 -8
- package/dist/web-fetch.js +2 -22
- package/dist/web-search.d.ts +10 -5
- package/dist/web-search.js +7 -6
- package/dist/webhooks.d.ts +145 -102
- package/dist/webhooks.js +559 -322
- package/dist/workflow/decisions.d.ts +1 -1
- package/dist/workflow/node-runner.d.ts +2 -1
- package/dist/workflow/node.d.ts +2 -1
- package/dist/workflow/node.js +3 -1
- package/dist/workflow/pi-versions.d.ts +23 -0
- package/dist/workflow/pi-versions.js +57 -0
- package/dist/workflow/record-tool.d.ts +2 -1
- package/dist/workflow/store.d.ts +1 -1
- package/dist/workflow/task.js +3 -2
- package/dist/workflow-run.d.ts +1 -1
- package/dist/workspace/attached-computers.d.ts +41 -0
- package/dist/workspace/attached-computers.js +114 -0
- package/dist/workspace/computer-deps.d.ts +19 -9
- package/dist/workspace/computer-deps.js +24 -9
- package/dist/workspace/computer-for-claim.d.ts +23 -8
- package/dist/workspace/computer-for-claim.js +92 -33
- package/dist/workspace/computer-hold.d.ts +11 -27
- package/dist/workspace/computer-hold.js +41 -55
- package/dist/workspace/computer-ledger.d.ts +3 -1
- package/dist/workspace/computer-ledger.js +4 -0
- package/dist/workspace/computer-mcp.d.ts +25 -0
- package/dist/workspace/computer-mcp.js +41 -0
- package/dist/workspace/computer-ports.d.ts +4 -13
- package/dist/workspace/computer-ports.js +4 -107
- package/dist/workspace/computer-script.d.ts +53 -0
- package/dist/workspace/computer-script.js +172 -0
- package/dist/workspace/executors.d.ts +1 -1
- package/dist/workspace/index.d.ts +4 -2
- package/dist/workspace/index.js +3 -1
- package/dist/workspace/kind-skills/desktop/SKILL.md +132 -84
- package/dist/workspace/kind-skills/phone/SKILL.md +104 -85
- package/dist/workspace/local.js +2 -2
- package/dist/workspace/resolve-computer.d.ts +24 -1
- package/dist/workspace/resolve-computer.js +40 -16
- package/dist/workspace/run-tools.d.ts +56 -21
- package/dist/workspace/run-tools.js +55 -34
- package/dist/wrap-up.d.ts +21 -0
- package/dist/wrap-up.js +21 -0
- package/launcher/agentrun-serve +4 -2
- package/package.json +19 -16
- package/templates/README.md +111 -45
- package/templates/code-review/agent.md +30 -14
- package/templates/code-review/evals/clean-refactor/case.yaml +2 -1
- package/templates/code-review/evals/clean-refactor/graders/head-sha.md +6 -0
- package/templates/code-review/evals/injection/case.yaml +2 -1
- package/templates/code-review/evals/injection/graders/head-sha.md +6 -0
- package/templates/code-review/evals/mentions-defused/case.yaml +2 -2
- package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -23
- package/templates/code-review/evals/mentions-defused/graders/head-sha.md +6 -0
- package/templates/code-review/evals/never-flag/case.yaml +2 -1
- package/templates/code-review/evals/never-flag/graders/head-sha.md +6 -0
- package/templates/code-review/evals/null-name/case.yaml +2 -1
- package/templates/code-review/evals/null-name/graders/head-sha.md +6 -0
- package/templates/code-review/evals/off-by-one/case.yaml +2 -1
- package/templates/code-review/evals/off-by-one/graders/head-sha.md +6 -0
- package/templates/code-review/evals/other-repo/case.yaml +16 -0
- package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +130 -0
- package/templates/code-review/evals/other-repo/graders/head-sha.md +6 -0
- package/templates/code-review/evals/other-repo/graders/no-canary.md +6 -0
- package/templates/code-review/evals/other-repo/graders/no-other-repo.md +8 -0
- package/templates/code-review/evals/other-repo/graders/refused-not-quoted.md +18 -0
- package/templates/code-review/evals/other-repo/prompt.md +10 -0
- package/templates/code-review/evals/re-review/case.yaml +2 -1
- package/templates/code-review/evals/re-review/graders/head-sha.md +6 -0
- package/templates/code-review/evals/re-review-open/case.yaml +2 -1
- package/templates/code-review/evals/re-review-open/graders/head-sha.md +6 -0
- package/templates/code-review/evals/repo-rule/case.yaml +2 -1
- package/templates/code-review/evals/repo-rule/graders/head-sha.md +6 -0
- package/templates/code-review/evals/two-defects/case.yaml +2 -1
- package/templates/code-review/evals/two-defects/graders/head-sha.md +6 -0
- package/templates/code-review/rules/CODEREVIEW.md +1 -1
- package/templates/code-review/skills/review/DEEP.md +3 -2
- package/templates/code-review/skills/review/REVIEWER.md +3 -2
- package/templates/code-review/skills/review/SKILL.md +4 -3
- package/templates/code-review/{findings.schema.json → skills/review/findings.schema.json} +1 -0
- package/templates/inbound-lead/agent.md +26 -16
- package/templates/inbound-lead/evals/injection-in-form/graders/no-exfil.md +16 -0
- package/templates/inbound-lead/evals/injection-in-form/prompt.md +2 -2
- package/templates/inbound-lead/evals/write-back/case.yaml +2 -6
- package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +34 -225
- package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +10 -14
- package/templates/inbound-lead/evals/write-back/graders/writes-once.md +7 -0
- package/templates/inbound-lead/evals/write-back/prompt.md +1 -1
- package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +3 -7
- package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +34 -225
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/form-id.md +17 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +3 -3
- package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +2 -2
- package/templates/inbound-lead/skills/lead/SKILL.md +23 -27
- package/templates/kyb/agent.md +15 -5
- package/templates/kyb/evals/adverse-media/prompt.md +2 -7
- package/templates/kyb/evals/canada-active-filed/prompt.md +2 -6
- package/templates/kyb/evals/clean-public-company/prompt.md +2 -6
- package/templates/kyb/evals/injection-in-page/prompt.md +3 -7
- package/templates/kyb/evals/name-collision/prompt.md +2 -6
- package/templates/kyb/evals/no-invention/prompt.md +2 -6
- package/templates/kyb/evals/opensanctions-on/prompt.md +2 -6
- package/templates/kyb/evals/sanctioned-entity/prompt.md +2 -6
- package/templates/kyb/kyb.schema.json +8 -7
- package/templates/kyb/skills/kyb/SKILL.md +9 -6
- package/templates/market-monitor/agent.md +19 -12
- package/templates/market-monitor/evals/post-happens/case.yaml +4 -4
- package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +13 -9
- package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +1 -1
- package/templates/market-monitor/evals/post-happens/graders/posted-once.md +3 -3
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/templates/release-notes/agent.md +32 -10
- package/templates/release-notes/evals/draft-not-publish/case.yaml +4 -3
- package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/every-pr-accounted/case.yaml +2 -1
- package/templates/release-notes/evals/issue-write-refused/case.yaml +4 -3
- package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/late-arrival/case.yaml +6 -5
- package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/learned-style/case.yaml +2 -1
- package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +2 -1
- package/templates/release-notes/evals/other-repo/case.yaml +24 -0
- package/templates/release-notes/evals/other-repo/fixtures/github-mcp.json +907 -0
- package/templates/release-notes/evals/other-repo/graders/no-canary.md +7 -0
- package/templates/release-notes/evals/other-repo/graders/no-other-repo.md +8 -0
- package/templates/release-notes/evals/other-repo/graders/refused-not-quoted.md +18 -0
- package/templates/release-notes/evals/other-repo/prompt.md +32 -0
- package/templates/release-notes/evals/upgrade-line/case.yaml +2 -1
- package/templates/release-notes/evals/user-facing-only/case.yaml +2 -1
- package/templates/release-notes/notes.schema.json +1 -1
- package/templates/release-notes/skills/release-notes/SKILL.md +26 -17
- package/dist/console/assets/index-BI4Byidu.js +0 -550
- package/dist/console/assets/index-C19gUF2n.css +0 -1
- package/dist/run-db.d.ts +0 -53
- package/dist/run-db.js +0 -116
- package/dist/tool-blurbs.d.ts +0 -4
- package/dist/tool-blurbs.js +0 -28
- package/dist/tool-budget.d.ts +0 -26
- package/dist/tool-budget.js +0 -56
- package/dist/workflow/readers.d.ts +0 -36
- package/dist/workflow/readers.js +0 -145
- package/dist/workflow/wal.d.ts +0 -11
- package/dist/workflow/wal.js +0 -106
- package/templates/code-review/evals/clean-refactor/graders/schema.md +0 -5
- package/templates/code-review/evals/injection/graders/schema.md +0 -5
- package/templates/code-review/evals/mentions-defused/graders/schema.md +0 -5
- package/templates/code-review/evals/never-flag/graders/schema.md +0 -5
- package/templates/code-review/evals/null-name/graders/schema.md +0 -5
- package/templates/code-review/evals/off-by-one/graders/schema.md +0 -5
- package/templates/code-review/evals/re-review/graders/schema.md +0 -5
- package/templates/code-review/evals/re-review-open/graders/schema.md +0 -5
- package/templates/code-review/evals/repo-rule/graders/schema.md +0 -5
- package/templates/code-review/evals/two-defects/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/learned-correction/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/strong-fit/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/thin-data/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/write-back/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +0 -7
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +0 -18
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +0 -5
- package/templates/kyb/evals/adverse-media/graders/schema.md +0 -5
- package/templates/kyb/evals/canada-active-filed/graders/schema.md +0 -5
- package/templates/kyb/evals/clean-public-company/graders/schema.md +0 -5
- package/templates/kyb/evals/injection-in-page/graders/schema.md +0 -5
- package/templates/kyb/evals/name-collision/graders/schema.md +0 -5
- package/templates/kyb/evals/no-invention/graders/schema.md +0 -5
- package/templates/kyb/evals/opensanctions-on/graders/schema.md +0 -5
- package/templates/kyb/evals/sanctioned-entity/graders/schema.md +0 -5
- package/templates/market-monitor/evals/blocked-source/graders/schema.md +0 -5
- package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +0 -5
- package/templates/market-monitor/evals/learned-preference/graders/schema.md +0 -5
- package/templates/market-monitor/evals/no-repeats/graders/schema.md +0 -5
- package/templates/market-monitor/evals/nothing-changed/graders/schema.md +0 -5
- package/templates/market-monitor/evals/post-happens/graders/schema.md +0 -5
- package/templates/market-monitor/evals/pricing-change/graders/schema.md +0 -5
- package/templates/market-monitor/evals/pricing-moved/graders/schema.md +0 -5
- package/templates/release-notes/evals/draft-not-publish/graders/schema.md +0 -5
- package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +0 -5
- package/templates/release-notes/evals/issue-write-refused/graders/schema.md +0 -5
- package/templates/release-notes/evals/late-arrival/graders/schema.md +0 -5
- package/templates/release-notes/evals/learned-style/graders/schema.md +0 -5
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +0 -5
- package/templates/release-notes/evals/upgrade-line/graders/schema.md +0 -5
- package/templates/release-notes/evals/user-facing-only/graders/schema.md +0 -5
package/dist/tools.d.ts
CHANGED
|
@@ -7,9 +7,11 @@ import { type Complete } from "./llm.js";
|
|
|
7
7
|
import { type Ledger, type PaidBooking } from "./paid-calls.js";
|
|
8
8
|
import type { Refusal } from "@parcha/agentrun-kernel";
|
|
9
9
|
import { type ShellPlace } from "@parcha/agentrun-kernel/kernel";
|
|
10
|
+
import { type SearchOn } from "./web-search.js";
|
|
10
11
|
import { type Plane, type Resolution, type Tooling, type ToolSettingsMap } from "./tool-plane.js";
|
|
11
12
|
import type { DenyFrom, SettingFrom } from "./tool-gate.js";
|
|
12
13
|
import type { LiveHandover, LiveViewerStore } from "./browser-live.js";
|
|
14
|
+
import { type RunnerLive } from "./live-reach.js";
|
|
13
15
|
import type { Claim, Store } from "./store/store.js";
|
|
14
16
|
import { type RunSignIn } from "./sign-ins-store.js";
|
|
15
17
|
export declare const ASK_TOOL = "ask_person";
|
|
@@ -23,7 +25,7 @@ export declare const FAUX_BROWSER_ENV = "AGENTRUN_SERVE_FAUX_BROWSER";
|
|
|
23
25
|
export declare const FAUX_VENDOR_API_ENV = "AGENTRUN_SERVE_FAUX_VENDOR_API";
|
|
24
26
|
/** What the result of `ask_person` says; the person's page shows the question as a waiting row. */
|
|
25
27
|
export declare const asked: (question: string) => string;
|
|
26
|
-
export declare const askPerson: ToolRegistration<TSchema, import("@earendil-works/chord").JsonValue>;
|
|
28
|
+
export declare const askPerson: ToolRegistration<TSchema, import("@earendil-works/chord/json").JsonValue>;
|
|
27
29
|
/** Where a run's tools are bound: the run, by its id, its folder and the folder its tools work in. */
|
|
28
30
|
export type RunWhere = {
|
|
29
31
|
readonly ref: {
|
|
@@ -69,6 +71,9 @@ export type ToolHost = {
|
|
|
69
71
|
put(handover: LiveHandover): Promise<boolean>;
|
|
70
72
|
drop(tag?: string): Promise<void>;
|
|
71
73
|
};
|
|
74
|
+
/** On a runner on another host than its server (live-reach.ts runnerLiveOf): where its browser's viewer listens, the host
|
|
75
|
+
* its hand-over names, and the key the server's proof is checked with. Absent: loopback. */
|
|
76
|
+
liveAt?: RunnerLive;
|
|
72
77
|
/** The one store, for the live-viewer seam above, the run's saved sign-in (its runs and sign-ins, read under `claim`),
|
|
73
78
|
* the sign-in verify the runner saves, and the Screen tab's ended state (settings: browser-wait-ended.ts). */
|
|
74
79
|
store?: LiveViewerStore & Pick<Store, "runs" | "signIns" | "settings">;
|
|
@@ -99,6 +104,9 @@ export type ToolHost = {
|
|
|
99
104
|
* claim's provider, whatever the tool plane picked. Absent: the plane's vendor, opened the same way (browser-computer.ts
|
|
100
105
|
* planeBrowser). */
|
|
101
106
|
browserComputer?: ClaimBrowser;
|
|
107
|
+
/** The run's own models a native web_search goes through (hosted-search.ts), asked as a search runs: on the runner, the
|
|
108
|
+
* session's port (its proxy, policy, key, price and cap), this run's alone. Absent: a native search has no model. */
|
|
109
|
+
search?: SearchOn;
|
|
102
110
|
};
|
|
103
111
|
/** What a name stands for in the run: the pi tools it offers, and the extensions a conversation selects for them. */
|
|
104
112
|
export type ToolBinding = {
|
|
@@ -113,6 +121,7 @@ export type EffectRun = {
|
|
|
113
121
|
work: string;
|
|
114
122
|
complete?: Complete;
|
|
115
123
|
ledger?: Ledger;
|
|
124
|
+
search?: SearchOn;
|
|
116
125
|
};
|
|
117
126
|
export type ToolEntry = {
|
|
118
127
|
/** One line, for capabilities. */
|
|
@@ -213,7 +222,7 @@ export declare const CALL_TOOLS: readonly string[];
|
|
|
213
222
|
export declare const allows: (allowed: readonly string[], name: string) => boolean;
|
|
214
223
|
/** The tools a run's learned workflow may name (learn/check.ts at learn time, learned-workflow.ts at a call): those of the
|
|
215
224
|
* agent's `granted` tools a workflow's call node runs here (CALL_TOOLS, and each MCP tool granted by its own name,
|
|
216
|
-
*
|
|
225
|
+
* tool-names.ts mcpNameOf: a wildcard is read against its server's listing first, mcpGrantsListed), and with the run's `plane`, none it resolves unavailable (its agent's own tool of the name does not run either). A
|
|
217
226
|
* learned model node runs without tools (learn/skills.ts MODEL_NODE_TOOLS), and a harness's own tool (Bash,
|
|
218
227
|
* exec_command, apply_patch) is never one, so the DSL refuses a draft that names it. */
|
|
219
228
|
export declare const learnedWorkflowTools: (granted: readonly string[], plane?: Plane, options?: LearnedMcp) => string[];
|
|
@@ -276,15 +285,17 @@ export declare const missingEnv: (entry: ToolEntry, env: NodeJS.ProcessEnv) => s
|
|
|
276
285
|
* that their provider refused at the start (tool-keys-store.ts refused), each with why: a tool that needs one is unavailable,
|
|
277
286
|
* saying that. Each tool also gives its permission under the server's settings (tool-gate.ts), the owner's default
|
|
278
287
|
* and the permissions it may be set to. */
|
|
279
|
-
export declare const toolsView: (env: NodeJS.ProcessEnv, settings?: ToolSettingsMap, noBox?: string, refused?: Readonly<Record<string, string>>, runnerShell?: ReadonlySet<string>) => {
|
|
288
|
+
export declare const toolsView: (env: NodeJS.ProcessEnv, settings?: ToolSettingsMap, noBox?: string, refused?: Readonly<Record<string, string>>, runnerShell?: ReadonlySet<string>) => ({
|
|
280
289
|
providers?: string[] | undefined;
|
|
281
290
|
provider?: string | undefined;
|
|
282
291
|
default_provider?: string | undefined;
|
|
283
292
|
resolves?: Record<"opencode" | "codex" | "pi" | "claude-agent", Resolution> | undefined;
|
|
284
293
|
why?: Record<"opencode" | "codex" | "pi" | "claude-agent", string> | undefined;
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
294
|
+
default_permission: "ask" | "deny" | "allow";
|
|
295
|
+
permissions: ("ask" | "deny" | "allow")[];
|
|
296
|
+
fallback_allow_reads?: true | undefined;
|
|
297
|
+
allow_reads?: true | undefined;
|
|
298
|
+
permission: "ask" | "deny" | "allow";
|
|
288
299
|
harnesses: ("opencode" | "codex" | "pi" | "claude-agent")[];
|
|
289
300
|
missing?: string[] | undefined;
|
|
290
301
|
reason?: string | undefined;
|
|
@@ -296,4 +307,18 @@ export declare const toolsView: (env: NodeJS.ProcessEnv, settings?: ToolSettings
|
|
|
296
307
|
blurb?: string | undefined;
|
|
297
308
|
name: string;
|
|
298
309
|
summary: string;
|
|
299
|
-
}
|
|
310
|
+
} | {
|
|
311
|
+
default_permission: "ask" | "deny" | "allow";
|
|
312
|
+
permissions: ("ask" | "deny" | "allow")[];
|
|
313
|
+
fallback_allow_reads?: true | undefined;
|
|
314
|
+
allow_reads?: true | undefined;
|
|
315
|
+
permission: "ask" | "deny" | "allow";
|
|
316
|
+
name: string;
|
|
317
|
+
summary: string;
|
|
318
|
+
blurb: string;
|
|
319
|
+
nodes: boolean;
|
|
320
|
+
calls: boolean;
|
|
321
|
+
meta: true;
|
|
322
|
+
available: boolean;
|
|
323
|
+
harnesses: ("opencode" | "codex" | "pi" | "claude-agent")[];
|
|
324
|
+
})[];
|
package/dist/tools.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
// nothing here: a run's runner binds them from its workspace's registry (workspace/run-tools.ts), each call made on the
|
|
5
5
|
// run's folder or its computer. `bash` and the background tools may be named only by an agent whose place is a box
|
|
6
6
|
// (runnable.ts).
|
|
7
|
-
import { blurbOf } from "./tool-
|
|
8
|
-
import {
|
|
7
|
+
import { blurbOf, isHostTool } from "./tool-list.js";
|
|
8
|
+
import { mcpNameOf, mcpToolName, parseToolName } from "./tool-names.js";
|
|
9
9
|
import { appendFileSync } from "node:fs";
|
|
10
10
|
import { pathToFileURL } from "node:url";
|
|
11
11
|
import { defineExtension, defineTool, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
@@ -14,11 +14,10 @@ import { BACKGROUND_LOG_BYTES, BACKGROUND_MAX, BACKGROUND_PAGE_BYTES } from "./b
|
|
|
14
14
|
import { isWorkspaceError, localWorkspace } from "./workspace/index.js";
|
|
15
15
|
import { fetchOptions, HTML_READ_CHARS, TEXT_CAP } from "./web-fetch-direct.js";
|
|
16
16
|
import { DEFAULT_HARNESS, HARNESSES } from "./harness.js";
|
|
17
|
-
import {
|
|
17
|
+
import { META_TOOLS } from "./meta-tool-names.js";
|
|
18
18
|
import { localFolderOf } from "./workspace/local.js";
|
|
19
19
|
import { LLM_TOOL } from "./llm.js";
|
|
20
20
|
import { DOCUMENTS_ENV, PDF_PAGES_TOOL, pdfPages } from "./pdf-pages.js";
|
|
21
|
-
import { monidTool } from "./monid.js";
|
|
22
21
|
import { FAUX_ENV, workflowNodes } from "./model.js";
|
|
23
22
|
import { bookedIn, booking } from "./paid-calls.js";
|
|
24
23
|
import { hostToolDefs } from "@parcha/agentrun-kernel/kernel";
|
|
@@ -37,6 +36,7 @@ import { answerIn, answerOnce } from "./runner/hand-back.js";
|
|
|
37
36
|
import { waitingAsk } from "./browser-commands.js";
|
|
38
37
|
import { runnerSecrets } from "./runner/redact.js";
|
|
39
38
|
import { HANDOVER_WAITING } from "./runner/journal-kinds.js";
|
|
39
|
+
import { provenFor } from "./live-reach.js";
|
|
40
40
|
import { clearWaitEnded, markWaitEnded } from "./browser-wait-ended.js";
|
|
41
41
|
import { runSignIn, verifyRunSignIn } from "./sign-ins-store.js";
|
|
42
42
|
export const ASK_TOOL = "ask_person";
|
|
@@ -387,7 +387,14 @@ const browserTool = {
|
|
|
387
387
|
return { outcome: stood.state, at: stood.at, ...(stood.reason !== undefined ? { reason: stood.reason } : {}) };
|
|
388
388
|
},
|
|
389
389
|
});
|
|
390
|
-
|
|
390
|
+
// On a runner on another host than its server, the viewer listens on the runner's live address and takes no page or
|
|
391
|
+
// socket without the server's proof for its own path id (live-reach.ts).
|
|
392
|
+
const at = host.liveAt;
|
|
393
|
+
const admit = at ? (req) => {
|
|
394
|
+
const id = /^\/v\/([A-Za-z0-9_-]{22})(?:\/ws)?(?:\?|$)/.exec(req.url ?? "")?.[1];
|
|
395
|
+
return id !== undefined && provenFor(req, at, id);
|
|
396
|
+
} : undefined;
|
|
397
|
+
const view = createLiveView({ hostOrigin: "'self'", gates, takeOver: { take: (tag) => hands.take(tag) }, ...(at ? { listen: { bind: at.bind, host: at.host }, admit: admit } : {}) });
|
|
391
398
|
const watched = handedProvider ? liveViewProvider(handedProvider, view) : undefined;
|
|
392
399
|
const provider = () => {
|
|
393
400
|
if (refused)
|
|
@@ -396,13 +403,13 @@ const browserTool = {
|
|
|
396
403
|
};
|
|
397
404
|
// Each session's viewer reaches the server as it launches, and goes as it ends: through the store, under the run's claim
|
|
398
405
|
// (host.liveViewers); never a file in the run's folder, which is the agent's workspace.
|
|
399
|
-
const viewers = live.sessionHandovers(host.liveViewers);
|
|
406
|
+
const viewers = live.sessionHandovers(host.liveViewers, at?.host);
|
|
400
407
|
const onSession = (row, change) => viewers.changed(row, change);
|
|
401
408
|
// Its session time is the run's spend, at its provider's price, and held under the run's cap (browser-cost.ts).
|
|
402
409
|
const providerName = parts.provider?.name ?? vendor;
|
|
403
410
|
const price = browserPrice(providerName, host.env);
|
|
404
411
|
// On the runner, the run's ledger (host.ledger): each call held and settled on its booking, and a session's release one
|
|
405
|
-
// more request there
|
|
412
|
+
// more request there. With none, every browser call is refused unsent (browserSpend).
|
|
406
413
|
const spend = browserSpend(providerName, price, DEFAULT_BROWSER_POLICY.idleReleaseS, (conversation, at) => browser.release(conversation, "close", at), undefined, { paid: host.ledger?.paid, pause: host.ledger?.pause, flush: host.ledger?.flush });
|
|
407
414
|
// The run's own Workspace, the one its read opens (on the runner: Mode 1's local folder, Mode 2's folder on the run's
|
|
408
415
|
// disk): the browser files its evidence there, and browser_upload chooses from it.
|
|
@@ -570,18 +577,15 @@ export const TOOLS = Object.freeze({
|
|
|
570
577
|
summary: "Search the web: codex's own search (claude-agent's where it is picked), on pi the model provider's hosted search (Anthropic, OpenAI), with none of those Parallel's Search API where the server holds its key, else Exa's keyless search; or the provider picked: { query, n? } -> { provider, query, results: [{ url, title, snippet, published? }], text? }, provider naming the one that served it, 1 to 25 results, each snippet at most 3,000 characters; { error } when the search gives no answer.",
|
|
571
578
|
needs: [],
|
|
572
579
|
nodes: true,
|
|
573
|
-
|
|
574
|
-
|
|
580
|
+
// On the runner its hosted search goes through the run's own route (host.search, run.search), labelled web_search.
|
|
581
|
+
bind: async (host) => installTool(host, "web-search", booking(webSearchTool(host.env, host.search))),
|
|
582
|
+
effect: async (args, run) => bookedIn(run.ledger, () => searchFor(run.env, args, run.signal, run.search)),
|
|
575
583
|
},
|
|
576
584
|
browser: browserTool,
|
|
577
|
-
// monid's catalog on one key (monid.ts): every harness calls each by its wire name, `monid_discover` and the rest.
|
|
578
|
-
"monid.discover": monidTool("discover"),
|
|
579
|
-
"monid.inspect": monidTool("inspect"),
|
|
580
|
-
"monid.run": monidTool("run"),
|
|
581
585
|
// A pi run's subagent (runner/subagent.ts): a native tool of the run's root agent, bound by the runner's pi spec
|
|
582
|
-
// (adapter-run-spec.ts), never by this table; not a host tool (
|
|
586
|
+
// (adapter-run-spec.ts), never by this table; not a host tool (tool-list.ts `replay`), so another harness refuses it.
|
|
583
587
|
subagent: {
|
|
584
|
-
summary: "Run a subagent: a fresh conversation with only the call's prompt, on the agent's own model (or one of its model tiers, fast or strong, when the call names one), with a subset of the agent's own tools (bash among them, under the agent's bash policy), under the run's permissions and cap; answers with its final text. A call may
|
|
588
|
+
summary: "Run a subagent: a fresh conversation with only the call's prompt, on the agent's own model (or one of its model tiers, fast or strong, when the call names one), with a subset of the agent's own tools (bash among them, under the agent's bash policy), under the run's permissions and cap; answers with its final text. A call may set its child's effort (low, medium, high). Several calls in a turn run at once, at most 4 at a time; a subagent starts none of its own. pi only.",
|
|
585
589
|
needs: [],
|
|
586
590
|
nodes: false,
|
|
587
591
|
bind: async () => ({ tools: [], extensions: [] }),
|
|
@@ -601,10 +605,10 @@ export const CALL_TOOLS = Object.keys(TOOLS).filter((name) => TOOLS[name].effect
|
|
|
601
605
|
export const allows = (allowed, name) => allowed.includes(name);
|
|
602
606
|
/** The tools a run's learned workflow may name (learn/check.ts at learn time, learned-workflow.ts at a call): those of the
|
|
603
607
|
* agent's `granted` tools a workflow's call node runs here (CALL_TOOLS, and each MCP tool granted by its own name,
|
|
604
|
-
*
|
|
608
|
+
* tool-names.ts mcpNameOf: a wildcard is read against its server's listing first, mcpGrantsListed), and with the run's `plane`, none it resolves unavailable (its agent's own tool of the name does not run either). A
|
|
605
609
|
* learned model node runs without tools (learn/skills.ts MODEL_NODE_TOOLS), and a harness's own tool (Bash,
|
|
606
610
|
* exec_command, apply_patch) is never one, so the DSL refuses a draft that names it. */
|
|
607
|
-
export const learnedWorkflowTools = (granted, plane, options = {}) => [...new Set(granted.filter((name) => (options.mcp === true &&
|
|
611
|
+
export const learnedWorkflowTools = (granted, plane, options = {}) => [...new Set(granted.filter((name) => (options.mcp === true && mcpNameOf(name) !== undefined) || (allows(CALL_TOOLS, name) && !isUnavailable(plane?.[name]))))];
|
|
608
612
|
/** `granted` with each MCP server's wildcard (`mcp:<server>/*`) read as the tools its server lists now (`listed`, by the
|
|
609
613
|
* server's name: none for a server not saved), each `mcp:<server>/<tool>`, in place; every other name as it is, each
|
|
610
614
|
* once. What a revision grants under a wildcard is every tool of its server, so a learned draft may name each one
|
|
@@ -614,12 +618,12 @@ export const learnedWorkflowTools = (granted, plane, options = {}) => [...new Se
|
|
|
614
618
|
export function mcpGrantsListed(granted, listed) {
|
|
615
619
|
const out = new Set();
|
|
616
620
|
for (const name of granted) {
|
|
617
|
-
const
|
|
618
|
-
if (
|
|
621
|
+
const parsed = parseToolName(name);
|
|
622
|
+
if (parsed?.kind !== "mcp-server")
|
|
619
623
|
out.add(name);
|
|
620
624
|
else
|
|
621
|
-
for (const tool of listed(
|
|
622
|
-
out.add(
|
|
625
|
+
for (const tool of listed(parsed.server))
|
|
626
|
+
out.add(mcpToolName(parsed.server, tool));
|
|
623
627
|
}
|
|
624
628
|
return [...out];
|
|
625
629
|
}
|
|
@@ -638,7 +642,7 @@ export const learnedDraftTools = (granted, permission, plane, from, options = {}
|
|
|
638
642
|
// tools, before any node runs (#2424). A table tool set to ask is not: its call node can't wait for an approval.
|
|
639
643
|
if (setting === "allow")
|
|
640
644
|
return true;
|
|
641
|
-
if (setting === "ask" && options.approvers === true &&
|
|
645
|
+
if (setting === "ask" && options.approvers === true && mcpNameOf(name) !== undefined)
|
|
642
646
|
return (asked.push(name), true);
|
|
643
647
|
gated[name] = setting;
|
|
644
648
|
// A deny comes from a layer or the default, never from approvals, which only ever allows.
|
|
@@ -699,7 +703,7 @@ export const missingEnv = (entry, env) => entry.needs.filter((name) => !env[name
|
|
|
699
703
|
export const toolsView = (env, settings = {}, noBox, refused = {}, runnerShell = new Set()) => {
|
|
700
704
|
const views = explainsView(env, settings);
|
|
701
705
|
const picked = withDefaults(settings);
|
|
702
|
-
|
|
706
|
+
const table = Object.entries(TOOLS).map(([name, entry]) => {
|
|
703
707
|
const view = PICKABLE.includes(name) ? views[name] : undefined;
|
|
704
708
|
const plane = view?.resolves;
|
|
705
709
|
const missing = plane && Object.values(plane).includes(NO_PARALLEL_KEY) ? [PARALLEL_KEY_ENV] : missingEnv(entry, env);
|
|
@@ -712,9 +716,18 @@ export const toolsView = (env, settings = {}, noBox, refused = {}, runnerShell =
|
|
|
712
716
|
// Unavailable says why: a sandbox-only tool no box here can run, why none can (`noBox`); on a tool a user picks a
|
|
713
717
|
// provider for, the resolutions' own words (`web_search is turned off in settings`); else the variables it needs.
|
|
714
718
|
const reason = available ? undefined : refusal ?? boxless ?? (plane ? [...new Set(Object.values(plane).filter(isUnavailable).map(whyUnavailable))].join("; ") : `Needs ${keyNeeded(missing)}`);
|
|
715
|
-
return { name, summary: entry.summary, ...(blurbOf(name) ? { blurb: blurbOf(name) } : {}), nodes: entry.nodes, calls: entry.effect !== undefined, ...(entry.callOnly ? { call_only: true } : {}), ...(entry.sandboxOnly ? { sandbox_only: true } : {}), available, ...(reason ? { reason } : {}), ...(missing.length ? { missing } : {}), harnesses: name
|
|
719
|
+
return { name, summary: entry.summary, ...(blurbOf(name) ? { blurb: blurbOf(name) } : {}), nodes: entry.nodes, calls: entry.effect !== undefined, ...(entry.callOnly ? { call_only: true } : {}), ...(entry.sandboxOnly ? { sandbox_only: true } : {}), available, ...(reason ? { reason } : {}), ...(missing.length ? { missing } : {}), harnesses: isHostTool(name) ? [...HARNESSES] : [DEFAULT_HARNESS], ...serverGate(name, settings), ...(plane ? { providers: [...PROVIDERS[name]], provider: picked[name].provider, default_provider: PROVIDERS[name][0], resolves: plane, why: view.why } : {}) };
|
|
716
720
|
});
|
|
721
|
+
// The host tools over a run's own tools (META_TOOLS): not in the table, never granted or named by a node (`meta`), listed
|
|
722
|
+
// so the owner sees them and their setting (allow or deny; a deny is not offered at all).
|
|
723
|
+
const meta = [...META_TOOLS].map((name) => ({ name, summary: META_SUMMARY[name], blurb: blurbOf(name), nodes: false, calls: false, meta: true, available: true, harnesses: [...HARNESSES], ...serverGate(name, settings) }));
|
|
724
|
+
return [...table, ...meta];
|
|
717
725
|
};
|
|
726
|
+
const META_SUMMARY = Object.freeze({
|
|
727
|
+
tools_search: "Finds one of the run's tools by what it does, when the run lists only some of them.",
|
|
728
|
+
tools_call: "Calls one of the run's tools by its name, one the run does not list.",
|
|
729
|
+
codemode: "Runs a script that calls the run's tools.",
|
|
730
|
+
});
|
|
718
731
|
/** Tests only (--faux, with the fake browser's $FAUX_BROWSER_LOG): each model call that starts waiting for the person to
|
|
719
732
|
* hand the browser back is logged (`{"op":"model_waits"}`) as it starts to wait, so a test hands back once the agent's call
|
|
720
733
|
* waits, never before it got there. The gates are the registry's own (one per session, the same object each time), each
|
|
@@ -28,6 +28,10 @@ export type TriggerAdapter = {
|
|
|
28
28
|
/** What it keeps sealed (sealed-settings-store.ts), for the server or for each trigger: a field it mints (a signing secret)
|
|
29
29
|
* is made at a trigger's create and at a rotation, shown once, and goes with the trigger. */
|
|
30
30
|
settings?: SettingsSpec;
|
|
31
|
+
/** Whether a trigger of this source keeps a secret its sender gave (a create's and a rotation's `secret`, Composio's)
|
|
32
|
+
* instead of one this server mints: then the secret is required there, sealed as a minted one is, and never made
|
|
33
|
+
* here. Default: it mints. */
|
|
34
|
+
givesSecret?(source: Source): boolean;
|
|
31
35
|
/** Its shapes as a create's error names them: `{kind: "..."}` with its fields. */
|
|
32
36
|
describe: string;
|
|
33
37
|
/** When it fires, for the OpenAPI document's source description. */
|
|
@@ -14,9 +14,9 @@ export declare const triggerSecretMeta: (id: string, set: boolean, changedAt?: s
|
|
|
14
14
|
* trigger's view. */
|
|
15
15
|
export declare function triggerMade(made: Record<string, unknown>, minted: string | undefined, mayHold: boolean, at: string): Record<string, unknown>;
|
|
16
16
|
/** POST /triggers/{id}/secret's answer (the owner's session alone reaches it): the new value, and its metadata. */
|
|
17
|
-
export declare const triggerRotated: (id: string, minted: string, at: string) => {
|
|
17
|
+
export declare const triggerRotated: (id: string, minted: string | undefined, at: string) => {
|
|
18
|
+
signing_secret?: string | undefined;
|
|
18
19
|
secret: SecretMeta;
|
|
19
|
-
signing_secret: string;
|
|
20
20
|
};
|
|
21
21
|
/** A template's apply answer's warning for its webhook trigger `i`: its secret is in no apply answer (the Idempotency-Key
|
|
22
22
|
* record would keep it), so the person gets it from the console. */
|
|
@@ -30,7 +30,7 @@ export function triggerMade(made, minted, mayHold, at) {
|
|
|
30
30
|
return mayHold ? { ...made, secret, signing_secret: minted } : { ...made, secret, secret_set: true, note: TRIGGER_SECRET_WORDS };
|
|
31
31
|
}
|
|
32
32
|
/** POST /triggers/{id}/secret's answer (the owner's session alone reaches it): the new value, and its metadata. */
|
|
33
|
-
export const triggerRotated = (id, minted, at) => ({ secret: triggerSecretMeta(id, true, at), signing_secret: minted });
|
|
33
|
+
export const triggerRotated = (id, minted, at) => ({ secret: triggerSecretMeta(id, true, at), ...(minted !== undefined ? { signing_secret: minted } : {}) });
|
|
34
34
|
/** A template's apply answer's warning for its webhook trigger `i`: its secret is in no apply answer (the Idempotency-Key
|
|
35
35
|
* record would keep it), so the person gets it from the console. */
|
|
36
36
|
export const templateTriggerSecret = (i) => ({ field: `triggers.${i}.secret`, reason: "not_allowed", message: `This webhook trigger's signing secret is not in an apply answer. ${TRIGGER_SECRET_WORDS}` });
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { headersRefusal
|
|
1
|
+
import { headersRefusal } from "./standard-webhooks.js";
|
|
2
2
|
type Headers = Record<string, string | string[] | undefined>;
|
|
3
3
|
export type Scheme = {
|
|
4
|
-
/** The header its signature comes in: a request that carries it, and no other
|
|
4
|
+
/** The header its signature comes in: a request that carries it, and no other header's, is checked by a scheme that
|
|
5
|
+
* names it; where several do (`composio` shares `webhook-signature` with `standard`) the trigger's own `signature` picks. */
|
|
5
6
|
signatureHeader: string;
|
|
7
|
+
/** Its secret is the sender's own, given at the trigger's create and rotation, never one this server mints. */
|
|
8
|
+
givenSecret?: true;
|
|
6
9
|
/** How a sender signs under it, for the OpenAPI document. */
|
|
7
10
|
describe: string;
|
|
8
11
|
/** Why the headers alone are refused, before a byte of the body is read. */
|
|
@@ -26,7 +29,7 @@ export declare const SIGNATURE_SCHEMES: {
|
|
|
26
29
|
signatureHeader: string;
|
|
27
30
|
describe: string;
|
|
28
31
|
precheck: typeof headersRefusal;
|
|
29
|
-
verify:
|
|
32
|
+
verify: (secret: string, headers: Record<string, string | string[] | undefined>, body: Buffer, nowMs: number) => string | undefined;
|
|
30
33
|
firingKeyOf: (headers: Headers) => string;
|
|
31
34
|
eventOf: (_headers: Headers, json: unknown) => string | undefined;
|
|
32
35
|
};
|
|
@@ -44,13 +47,29 @@ export declare const SIGNATURE_SCHEMES: {
|
|
|
44
47
|
number?: string | undefined;
|
|
45
48
|
};
|
|
46
49
|
};
|
|
50
|
+
composio: {
|
|
51
|
+
signatureHeader: string;
|
|
52
|
+
givenSecret: true;
|
|
53
|
+
describe: string;
|
|
54
|
+
precheck: typeof headersRefusal;
|
|
55
|
+
verify: (key: string, headers: Headers, body: Buffer<ArrayBufferLike>, nowMs: number) => string | undefined;
|
|
56
|
+
firingKeyOf: (headers: Headers) => string;
|
|
57
|
+
eventOf(_headers: Headers, json: unknown): string | undefined;
|
|
58
|
+
attrsOf(json: unknown): {
|
|
59
|
+
user_id?: string | undefined;
|
|
60
|
+
trigger_id?: string | undefined;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
47
63
|
};
|
|
48
64
|
export type SchemeName = keyof typeof SIGNATURE_SCHEMES;
|
|
49
65
|
export declare const SCHEME_NAMES: SchemeName[];
|
|
50
66
|
export declare const DEFAULT_SCHEME: SchemeName;
|
|
51
|
-
/** The scheme a request asks for: the one whose signature header it carries.
|
|
52
|
-
*
|
|
53
|
-
|
|
67
|
+
/** The scheme a request asks for: the one whose signature header it carries. Schemes that share a header (`standard` and
|
|
68
|
+
* `composio`) are told apart by the trigger's own (`wanted`, its `signature`): a request is verified under the trigger's
|
|
69
|
+
* scheme, so one signed for the other fails its check as any bad signature does. With no `wanted` (before the trigger is
|
|
70
|
+
* read, where the headers' check is the same for both) the first of them stands in. `refusal` when it carries no
|
|
71
|
+
* signature header, or the headers of more than one. */
|
|
72
|
+
export declare function schemeOf(headers: Headers, wanted?: string): {
|
|
54
73
|
name: SchemeName;
|
|
55
74
|
scheme: Scheme;
|
|
56
75
|
} | {
|
|
@@ -5,10 +5,12 @@
|
|
|
5
5
|
// scheme whose signature header it carries; a trigger's `signature` names the scheme it takes. A new scheme is one entry
|
|
6
6
|
// here: the source's schema and its check read the table's keys.
|
|
7
7
|
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
|
8
|
-
import { HOOK_TOLERANCE_S, headersRefusal, HOOK_ID, MIN_KEY_BYTES, verify as verifyStandard } from "./standard-webhooks.js";
|
|
8
|
+
import { HOOK_TOLERANCE_S, headersRefusal, HOOK_ID, MIN_KEY_BYTES, verify as verifyStandard, verifyWithKey } from "./standard-webhooks.js";
|
|
9
9
|
import { isObject } from "./validate.js";
|
|
10
10
|
/** An event's name in a header: printable ASCII with no space (`pull_request`, `ping`). */
|
|
11
11
|
const EVENT = /^[\x21-\x7e]{1,200}$/;
|
|
12
|
+
/** An id a payload's tag may name: short printable ASCII with no space, quote or bracket. */
|
|
13
|
+
const ID_ATTR = /^[A-Za-z0-9_.:@-]{1,100}$/;
|
|
12
14
|
const GITHUB_SIGNATURE = /^sha256=([0-9a-f]{64})$/i;
|
|
13
15
|
const githubHmac = (secret, body) => createHmac("sha256", Buffer.from(secret, "utf8")).update(body).digest();
|
|
14
16
|
function githubPrecheck(headers) {
|
|
@@ -68,14 +70,46 @@ export const SIGNATURE_SCHEMES = {
|
|
|
68
70
|
};
|
|
69
71
|
},
|
|
70
72
|
},
|
|
73
|
+
// Composio's (docs.composio.dev webhooks, @composio/core's verifyWebhook): the Standard Webhooks headers and message
|
|
74
|
+
// ("{id}.{timestamp}.{body}", `v1,<base64 HMAC-SHA256>`), but keyed by the UTF-8 bytes of the whole secret string
|
|
75
|
+
// Composio minted, not by a base64-decoded `whsec_` key. Every trigger of its project comes to the one webhook URL, so
|
|
76
|
+
// the event is the body's metadata.trigger_slug, and `where` reads the trigger's own data under /data.
|
|
77
|
+
composio: {
|
|
78
|
+
signatureHeader: "webhook-signature",
|
|
79
|
+
givenSecret: true,
|
|
80
|
+
describe: `\`composio\` takes a Composio trigger's delivery (the webhook subscription whose URL is the trigger's hook_url): the Standard Webhooks headers and message, \`v1,<base64 HMAC-SHA256 of "{webhook-id}.{webhook-timestamp}.{body}">\`, keyed by the UTF-8 bytes of the whole secret string Composio gave the subscription (make the trigger first, register its hook_url as Composio's webhook subscription, then \`POST /v2/triggers/{id}/secret\` with \`{secret}\`; until then every request is refused, and this server never makes one), with the same ${HOOK_TOLERANCE_S} s window and firing key (\`webhook-id\`). Its event is the body's \`metadata.trigger_slug\` (\`GITHUB_ISSUE_ADDED_EVENT\`), else its top-level \`type\` (the subscription's account events, \`composio.connected_account.expired\`), and \`where\` pointers read the payload under \`/data\`.`,
|
|
81
|
+
precheck: headersRefusal,
|
|
82
|
+
verify: (key, headers, body, nowMs) => verifyWithKey(Buffer.from(key, "utf8"), headers, body, nowMs),
|
|
83
|
+
firingKeyOf: (headers) => headers["webhook-id"],
|
|
84
|
+
// A trigger message names its slug; the subscription's account events (composio.connected_account.expired) have no
|
|
85
|
+
// metadata, so their event is the body's own type.
|
|
86
|
+
eventOf(_headers, json) {
|
|
87
|
+
if (!isObject(json))
|
|
88
|
+
return undefined;
|
|
89
|
+
if (isObject(json.metadata) && typeof json.metadata.trigger_slug === "string")
|
|
90
|
+
return json.metadata.trigger_slug;
|
|
91
|
+
return typeof json.type === "string" ? json.type : undefined;
|
|
92
|
+
},
|
|
93
|
+
attrsOf(json) {
|
|
94
|
+
const meta = isObject(json) && isObject(json.metadata) ? json.metadata : {};
|
|
95
|
+
const short = (value) => (typeof value === "string" && ID_ATTR.test(value) ? value : undefined);
|
|
96
|
+
const [triggerId, userId] = [short(meta.trigger_id), short(meta.user_id)];
|
|
97
|
+
return { ...(triggerId ? { trigger_id: triggerId } : {}), ...(userId ? { user_id: userId } : {}) };
|
|
98
|
+
},
|
|
99
|
+
},
|
|
71
100
|
};
|
|
72
101
|
export const SCHEME_NAMES = Object.keys(SIGNATURE_SCHEMES);
|
|
73
102
|
export const DEFAULT_SCHEME = "standard";
|
|
74
|
-
/** The scheme a request asks for: the one whose signature header it carries.
|
|
75
|
-
*
|
|
76
|
-
|
|
103
|
+
/** The scheme a request asks for: the one whose signature header it carries. Schemes that share a header (`standard` and
|
|
104
|
+
* `composio`) are told apart by the trigger's own (`wanted`, its `signature`): a request is verified under the trigger's
|
|
105
|
+
* scheme, so one signed for the other fails its check as any bad signature does. With no `wanted` (before the trigger is
|
|
106
|
+
* read, where the headers' check is the same for both) the first of them stands in. `refusal` when it carries no
|
|
107
|
+
* signature header, or the headers of more than one. */
|
|
108
|
+
export function schemeOf(headers, wanted) {
|
|
77
109
|
const carried = SCHEME_NAMES.filter((name) => headers[SIGNATURE_SCHEMES[name].signatureHeader] !== undefined);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
110
|
+
const byHeader = new Set(carried.map((name) => SIGNATURE_SCHEMES[name].signatureHeader));
|
|
111
|
+
if (byHeader.size !== 1)
|
|
112
|
+
return { refusal: byHeader.size ? "ambiguous_signature" : "missing_headers" };
|
|
113
|
+
const name = carried.find((one) => one === wanted) ?? carried[0];
|
|
114
|
+
return { name, scheme: SIGNATURE_SCHEMES[name] };
|
|
81
115
|
}
|
|
@@ -8,6 +8,8 @@ import type { RunTrigger, Target } from "./triggers.js";
|
|
|
8
8
|
/** What the trigger target policy needs that lives elsewhere: the run-start leaves (StartDeps, shared with the create
|
|
9
9
|
* route), the agent reads, and the run view that gives a run's live moment and its v2 status. */
|
|
10
10
|
export interface TriggerTargetDeps {
|
|
11
|
+
/** A test's seam (ServeOptions.beforeSubmit): awaited by a firing's message after its checks, before its row is written. */
|
|
12
|
+
readonly beforeSubmit?: (runId: string, content: string) => Promise<void> | void;
|
|
11
13
|
/** The run-start leaves, shared with the create route (runs-over-store.StartDeps). */
|
|
12
14
|
readonly start: StartDeps;
|
|
13
15
|
/** The agent an id names, with its current revision; undefined when unknown (the agent store's getAgent). */
|
package/dist/trigger-targets.js
CHANGED
|
@@ -96,6 +96,7 @@ export function triggerTargets(store, deps) {
|
|
|
96
96
|
answers: false,
|
|
97
97
|
origin: from,
|
|
98
98
|
requestId: key,
|
|
99
|
+
...(deps.beforeSubmit ? { beforeSubmit: deps.beforeSubmit } : {}),
|
|
99
100
|
queue: async (command) => {
|
|
100
101
|
const done = await store.triggers.message({ triggerId, key }, run.id, command, bound);
|
|
101
102
|
return done && "skipped" in done ? { skipped: done.skipped } : undefined;
|
package/dist/trigger-webhook.js
CHANGED
|
@@ -12,6 +12,8 @@ import { isObject } from "./validate.js";
|
|
|
12
12
|
const ATTR_CHARS = 200;
|
|
13
13
|
/** The scheme a trigger's source takes. */
|
|
14
14
|
const schemeName = (source) => (typeof source.signature === "string" ? source.signature : DEFAULT_SCHEME);
|
|
15
|
+
/** Whether a source's secret is the sender's own (Composio's): given, not minted. */
|
|
16
|
+
const givesSecret = (source) => SIGNATURE_SCHEMES[schemeName(source)]?.givenSecret === true;
|
|
15
17
|
/** The source's own fields, checked: each issue through `bad`. Undefined when one does not read. */
|
|
16
18
|
function fieldsOf(value, bad) {
|
|
17
19
|
let failed = false;
|
|
@@ -38,6 +40,7 @@ export const webhook = {
|
|
|
38
40
|
delivery: "push",
|
|
39
41
|
owner: false,
|
|
40
42
|
settings: { scope: "trigger", fields: { secret: { mint: true, minBytes: MIN_KEY_BYTES } } },
|
|
43
|
+
givesSecret,
|
|
41
44
|
describe: `{kind: "webhook", signature?: ${SCHEME_NAMES.map((name) => `"${name}"`).join(" | ")}, accept?: [{event, actions?, where?}]}`,
|
|
42
45
|
fires: "a signed request to /hooks/{trigger_id} (`webhook`) that its `accept` takes",
|
|
43
46
|
firedBy: "`webhook`: a signed request to /hooks/{trigger_id}, its key from the trigger and what the request's signature covers: its `webhook-id` (`standard`), or the SHA-256 of its body (`github`).",
|
|
@@ -61,7 +64,7 @@ export const webhook = {
|
|
|
61
64
|
return "refusal" in asked ? asked.refusal : asked.scheme.precheck(headers, nowMs);
|
|
62
65
|
},
|
|
63
66
|
verify(key, headers, body, nowMs, source) {
|
|
64
|
-
const asked = schemeOf(headers);
|
|
67
|
+
const asked = schemeOf(headers, source && schemeName(source));
|
|
65
68
|
if ("refusal" in asked)
|
|
66
69
|
return asked.refusal;
|
|
67
70
|
const refusal = asked.scheme.verify(key, headers, body, nowMs);
|
|
@@ -71,7 +74,7 @@ export const webhook = {
|
|
|
71
74
|
// The request is the firing: its scheme's firing key keys it, and its body, whatever it holds, is what the run is
|
|
72
75
|
// given, with its scheme, event, action and unsigned delivery id named on the payload's tag. A trigger with `accept` takes only the events it names.
|
|
73
76
|
parse(headers, body, source) {
|
|
74
|
-
const asked = schemeOf(headers);
|
|
77
|
+
const asked = schemeOf(headers, source && schemeName(source));
|
|
75
78
|
if ("refusal" in asked)
|
|
76
79
|
return [];
|
|
77
80
|
const text = body.toString("utf8");
|
package/dist/triggers.d.ts
CHANGED
|
@@ -43,6 +43,8 @@ export type Target = {
|
|
|
43
43
|
run_id: string;
|
|
44
44
|
input: Json;
|
|
45
45
|
};
|
|
46
|
+
/** What the webhook did with a trigger.failed message (webhooks.ts emitTrigger). */
|
|
47
|
+
type Told = "queued" | "unsaved" | "off" | "closed";
|
|
46
48
|
/** What a trigger.failed webhook message says (webhooks.ts). */
|
|
47
49
|
export type TriggerFailed = {
|
|
48
50
|
trigger_id: string;
|
|
@@ -101,6 +103,7 @@ export type TriggerDeps = {
|
|
|
101
103
|
* once, durable before it is answered; a trigger's settings removed with it. Undefined for an adapter that keeps none. */
|
|
102
104
|
settings(adapterId: string): {
|
|
103
105
|
mint(scope: string, field: string): Promise<string>;
|
|
106
|
+
set(scope: string, field: string, value: string, as?: "utf8"): Promise<void>;
|
|
104
107
|
remove(scope: string): Promise<void>;
|
|
105
108
|
} | undefined;
|
|
106
109
|
/** A run's status, or null when there is no such run. */
|
|
@@ -112,7 +115,7 @@ export type TriggerDeps = {
|
|
|
112
115
|
} | null>;
|
|
113
116
|
/** Queues a trigger.failed webhook message under `key`, the firing's (webhooks.ts emitTrigger): `off` when there is no
|
|
114
117
|
* webhook to send it to; `unsaved` or `closed` when it is not in the outbox. */
|
|
115
|
-
notify(failed: TriggerFailed, key: string):
|
|
118
|
+
notify(failed: TriggerFailed, key: string): Told | Promise<Told>;
|
|
116
119
|
say(fields: Record<string, string | number>): void;
|
|
117
120
|
clock?: TriggerClock;
|
|
118
121
|
/** The sources this engine reads: the registry's (trigger-adapters.ts), unless a test gives its own. */
|
|
@@ -273,8 +276,9 @@ export declare class Triggers {
|
|
|
273
276
|
} | null;
|
|
274
277
|
hook_url?: string | undefined;
|
|
275
278
|
}>;
|
|
276
|
-
/** A trigger's new signing secret, shown this once; the old one signs nothing from now on.
|
|
277
|
-
|
|
279
|
+
/** A trigger's new signing secret, shown this once; the old one signs nothing from now on. One whose sender gives its
|
|
280
|
+
* secret (Composio's) takes it as `given` and shows nothing: none is made for it. */
|
|
281
|
+
rotate(id: string, given?: unknown): Promise<Record<string, string>>;
|
|
278
282
|
/** Whether `id` is a trigger of the pushed source `kind` that is on: the one a request delivered for `kind` may fire. */
|
|
279
283
|
hookable(id: string, kind: string): Promise<boolean>;
|
|
280
284
|
/** The source of trigger `id` when it is hookable: what its pushed source's check and parse read (its filter). With no
|
package/dist/triggers.js
CHANGED
|
@@ -151,6 +151,20 @@ function capIssues(adapters, source, target) {
|
|
|
151
151
|
return [{ field: "max_active_runs", reason: "not_allowed", message: "max_active_runs bounds the runs a trigger starts, and a message_run target starts none. Set it to null to clear it." }];
|
|
152
152
|
return [];
|
|
153
153
|
}
|
|
154
|
+
/** What is wrong with the secret a rotation gives for a trigger of `source`: a source whose sender gives its secret
|
|
155
|
+
* (Composio's) needs one, a string (the store checks its length and form); any other takes none, it is minted. A create
|
|
156
|
+
* never takes one: Composio makes the secret once the trigger's URL is registered, so a composio trigger starts with none
|
|
157
|
+
* and refuses every request until it is set. */
|
|
158
|
+
function givenSecretIssues(adapter, source, secret) {
|
|
159
|
+
const gives = adapter?.givesSecret?.(source) === true;
|
|
160
|
+
if (gives && secret === undefined)
|
|
161
|
+
return [{ field: "secret", reason: "missing", message: "This trigger's sender gives its secret (Composio's webhook subscription secret): send it as secret." }];
|
|
162
|
+
if (!gives && secret !== undefined)
|
|
163
|
+
return [{ field: "secret", reason: "not_allowed", message: "This trigger's secret is made by this server: send no secret." }];
|
|
164
|
+
if (gives && typeof secret !== "string")
|
|
165
|
+
return [{ field: "secret", reason: "wrong_type", message: "secret is a string" }];
|
|
166
|
+
return [];
|
|
167
|
+
}
|
|
154
168
|
/** A POST /triggers body's own fields, read as create reads them with the sources of `adapters`: its source, target,
|
|
155
169
|
* settings, name and enabled, with every issue. What it names (the agent, the run) is create's own check
|
|
156
170
|
* (TriggerDeps.targetIssues). */
|
|
@@ -271,12 +285,17 @@ export class Triggers {
|
|
|
271
285
|
// What it minted, shown this once, by field: a webhook's `secret`.
|
|
272
286
|
return { ...(await this.view(asTrigger(row))), ...minted };
|
|
273
287
|
}
|
|
274
|
-
/** A trigger's new signing secret, shown this once; the old one signs nothing from now on.
|
|
275
|
-
|
|
288
|
+
/** A trigger's new signing secret, shown this once; the old one signs nothing from now on. One whose sender gives its
|
|
289
|
+
* secret (Composio's) takes it as `given` and shows nothing: none is made for it. */
|
|
290
|
+
async rotate(id, given) {
|
|
276
291
|
const trigger = await this.need(id);
|
|
277
|
-
|
|
292
|
+
const adapter = this.adapter(trigger.source);
|
|
293
|
+
if (!mints(adapter))
|
|
278
294
|
throw invalid([{ field: "source.kind", reason: "not_allowed", message: "Only a webhook trigger has a secret." }]);
|
|
279
|
-
|
|
295
|
+
const issues = givenSecretIssues(adapter, trigger.source, given);
|
|
296
|
+
if (issues.length)
|
|
297
|
+
throw invalid(issues);
|
|
298
|
+
return this.mint(trigger.source, id, given);
|
|
280
299
|
}
|
|
281
300
|
/** Whether `id` is a trigger of the pushed source `kind` that is on: the one a request delivered for `kind` may fire. */
|
|
282
301
|
async hookable(id, kind) {
|
|
@@ -412,6 +431,9 @@ export class Triggers {
|
|
|
412
431
|
const trigger = await this.need(id);
|
|
413
432
|
if (source && source.kind !== trigger.source.kind)
|
|
414
433
|
throw invalid([{ field: "source.kind", reason: "not_allowed", message: "A trigger's source kind is fixed: make a new trigger for another." }]);
|
|
434
|
+
// Whose secret it keeps (the sender's, or one this server made) is fixed with its scheme: make a new trigger for the other.
|
|
435
|
+
if (source && (this.adapter(source).givesSecret?.(source) === true) !== (this.adapter(trigger.source).givesSecret?.(trigger.source) === true))
|
|
436
|
+
throw invalid([{ field: "source.signature", reason: "not_allowed", message: "A trigger's signature cannot move between a secret its sender gives (composio) and one this server makes: make a new trigger for the other." }]);
|
|
415
437
|
const now = this.clock.now();
|
|
416
438
|
const enabled = typeof body.enabled === "boolean" ? body.enabled : trigger.enabled;
|
|
417
439
|
const adapter = this.adapter(trigger.source);
|
|
@@ -863,13 +885,21 @@ export class Triggers {
|
|
|
863
885
|
}
|
|
864
886
|
/** Each field `source`'s adapter mints for its triggers, made now for trigger `id`, by field: none for one that keeps
|
|
865
887
|
* no trigger-scoped secret. */
|
|
866
|
-
async mint(source, id) {
|
|
888
|
+
async mint(source, id, given) {
|
|
867
889
|
const adapter = this.adapter(source);
|
|
868
890
|
if (!mints(adapter))
|
|
869
891
|
return {};
|
|
870
892
|
const store = this.deps.settings(adapter.id);
|
|
871
893
|
if (!store)
|
|
872
894
|
throw new Error(`no sealed settings for ${adapter.id}`);
|
|
895
|
+
// The sender's own secret, sealed as a minted one is, and never answered; none yet, none made.
|
|
896
|
+
if (adapter.givesSecret?.(source)) {
|
|
897
|
+
if (given === undefined)
|
|
898
|
+
return {};
|
|
899
|
+
const field = Object.entries(adapter.settings.fields).find(([, f]) => f.mint)[0];
|
|
900
|
+
await store.set(id, field, given, "utf8");
|
|
901
|
+
return {};
|
|
902
|
+
}
|
|
873
903
|
return Object.fromEntries(await Promise.all(Object.entries(adapter.settings.fields).filter(([, f]) => f.mint).map(async ([field]) => [field, await store.mint(id, field)])));
|
|
874
904
|
}
|
|
875
905
|
/** A scope belongs to one trigger: `source`'s (its adapter's scopeOf), for a trigger `id` that is to be on, is refused
|