@parcha/agentrun-serve 0.1.0-beta.30 → 0.1.0-beta.32
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 +472 -0
- package/NOTICE +18 -0
- package/README.md +1042 -240
- package/dist/adapter-facts.d.ts +3 -0
- package/dist/adapter-facts.js +5 -0
- package/dist/adapters.d.ts +64 -140
- package/dist/adapters.js +153 -377
- package/dist/agents-store.d.ts +146 -0
- package/dist/agents-store.js +359 -0
- package/dist/agents.d.ts +12 -5
- package/dist/agents.js +40 -17
- package/dist/app.d.ts +2 -4
- package/dist/app.js +227 -97
- package/dist/approvals.d.ts +4 -0
- package/dist/approvals.js +7 -0
- package/dist/archil-routes.d.ts +45 -0
- package/dist/archil-routes.js +150 -0
- package/dist/archil-settings.d.ts +30 -0
- package/dist/archil-settings.js +34 -0
- package/dist/background.d.ts +2 -1
- package/dist/background.js +69 -29
- package/dist/bounds.d.ts +26 -0
- package/dist/bounds.js +137 -0
- package/dist/box-egress-vm.d.ts +126 -0
- package/dist/box-egress-vm.js +364 -0
- package/dist/box-egress.d.ts +19 -8
- package/dist/box-egress.js +27 -15
- package/dist/box-paths.d.ts +59 -0
- package/dist/box-paths.js +92 -0
- package/dist/box-relay-vm.d.ts +4 -0
- package/dist/box-relay-vm.js +103 -55
- package/dist/box-relay.d.ts +2 -0
- package/dist/box-relay.js +2 -2
- package/dist/boxes.d.ts +20 -3
- package/dist/boxes.js +67 -14
- package/dist/browser-commands.d.ts +43 -0
- package/dist/browser-commands.js +154 -0
- package/dist/browser-cost.d.ts +30 -3
- package/dist/browser-cost.js +276 -21
- package/dist/browser-live.d.ts +124 -0
- package/dist/browser-live.js +324 -0
- package/dist/browser-person.d.ts +168 -0
- package/dist/browser-person.js +769 -0
- package/dist/budget.d.ts +80 -0
- package/dist/budget.js +211 -0
- package/dist/cap.d.ts +274 -63
- package/dist/cap.js +599 -188
- package/dist/cli.js +226 -16
- package/dist/coding-tools.d.ts +13 -1
- package/dist/coding-tools.js +107 -5
- package/dist/computer-adb.d.ts +12 -0
- package/dist/computer-adb.js +14 -0
- package/dist/computer-commands.d.ts +103 -0
- package/dist/computer-commands.js +256 -0
- package/dist/computer-keys.d.ts +68 -0
- package/dist/computer-keys.js +148 -0
- package/dist/computer-routes.d.ts +38 -0
- package/dist/computer-routes.js +56 -0
- package/dist/computer-setting.d.ts +37 -0
- package/dist/computer-setting.js +47 -0
- package/dist/computer-view.d.ts +38 -0
- package/dist/computer-view.js +14 -0
- package/dist/computers.d.ts +137 -0
- package/dist/computers.js +197 -0
- package/dist/console/THIRD-PARTY-NOTICES.txt +25 -0
- package/dist/console/assets/index-35-7aeIZ.js +519 -0
- package/dist/console/assets/index-Cejbov-Y.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +2 -0
- package/dist/console-links.js +6 -0
- package/dist/decision-cap.d.ts +63 -0
- package/dist/decision-cap.js +163 -0
- package/dist/decision-rows.d.ts +5 -2
- package/dist/decision-rows.js +8 -6
- package/dist/decisions.d.ts +31 -4
- package/dist/decisions.js +66 -8
- package/dist/disk.d.ts +33 -0
- package/dist/disk.js +85 -0
- package/dist/door-line.d.ts +23 -0
- package/dist/door-line.js +83 -0
- package/dist/egress-proxy.d.ts +45 -0
- package/dist/egress-proxy.js +416 -0
- package/dist/egress-table.d.ts +24 -0
- package/dist/egress-table.js +165 -0
- package/dist/errors.d.ts +15 -0
- package/dist/errors.js +22 -2
- package/dist/exa-keyless.js +1 -1
- package/dist/explain.d.ts +22 -0
- package/dist/explain.js +207 -0
- package/dist/faux-computers.d.ts +35 -0
- package/dist/faux-computers.js +126 -0
- package/dist/file-types.d.ts +4 -0
- package/dist/file-types.js +11 -0
- package/dist/files.d.ts +3 -32
- package/dist/files.js +9 -117
- package/dist/github-connection.d.ts +207 -0
- package/dist/github-connection.js +595 -0
- package/dist/github.d.ts +64 -0
- package/dist/github.js +119 -0
- package/dist/grade.d.ts +14 -44
- package/dist/grade.js +55 -233
- package/dist/graph-served.d.ts +23 -2
- package/dist/graph-served.js +44 -3
- package/dist/graph-view.d.ts +7 -3
- package/dist/graph-view.js +26 -15
- package/dist/handed-values.d.ts +23 -0
- package/dist/handed-values.js +36 -0
- package/dist/harness-app.d.ts +33 -4
- package/dist/harness-app.js +539 -85
- package/dist/harness-install.d.ts +120 -0
- package/dist/harness-install.js +359 -0
- package/dist/harness-opencode/adapter.js +42 -8
- package/dist/harness-opencode/facts.d.ts +2 -0
- package/dist/harness-opencode/facts.js +28 -0
- package/dist/harness-opencode/harness.d.ts +4 -0
- package/dist/harness-opencode/harness.js +38 -5
- package/dist/harness-opencode/host/policy.js +11 -3
- package/dist/harness-opencode/transcript.d.ts +25 -0
- package/dist/harness-opencode/transcript.js +81 -0
- package/dist/harness-table.d.ts +75 -0
- package/dist/harness-table.js +145 -0
- package/dist/harness.d.ts +7 -28
- package/dist/harness.js +15 -41
- package/dist/heard.d.ts +12 -0
- package/dist/heard.js +45 -0
- package/dist/helper-env.d.ts +4 -0
- package/dist/helper-env.js +14 -0
- package/dist/home-path.d.ts +0 -4
- package/dist/home-path.js +3 -17
- package/dist/host-check.d.ts +13 -0
- package/dist/host-check.js +35 -0
- package/dist/host-tools.d.ts +51 -8
- package/dist/host-tools.js +108 -117
- package/dist/host.d.ts +12 -6
- package/dist/host.js +30 -24
- package/dist/hosted-search.d.ts +3 -0
- package/dist/hosted-search.js +5 -3
- package/dist/import-proxy.d.ts +42 -0
- package/dist/import-proxy.js +105 -0
- package/dist/import-summary.js +4 -8
- package/dist/import-worker.d.ts +2 -3
- package/dist/import-worker.js +18 -16
- package/dist/import.d.ts +37 -17
- package/dist/import.js +208 -222
- package/dist/key-meta.d.ts +26 -0
- package/dist/key-meta.js +30 -0
- package/dist/key-refusal.d.ts +4 -1
- package/dist/key-refusal.js +20 -7
- package/dist/key-words.d.ts +37 -0
- package/dist/key-words.js +40 -0
- package/dist/learn/check.d.ts +3 -1
- package/dist/learn/check.js +2 -2
- package/dist/learn/commit.d.ts +86 -0
- package/dist/learn/commit.js +182 -0
- package/dist/learn/folder.d.ts +296 -0
- package/dist/learn/folder.js +796 -0
- package/dist/learn/grade.d.ts +25 -9
- package/dist/learn/grade.js +98 -50
- package/dist/learn/index.d.ts +2 -2
- package/dist/learn/index.js +2 -2
- package/dist/learn/learning.sh +366 -0
- package/dist/learn/reflect.d.ts +12 -5
- package/dist/learn/reflect.js +72 -41
- package/dist/learn/secrets.d.ts +15 -7
- package/dist/learn/secrets.js +66 -16
- package/dist/learn/seed-check.d.ts +74 -0
- package/dist/learn/seed-check.js +103 -0
- package/dist/learn/skills.d.ts +7 -1
- package/dist/learn/skills.js +21 -4
- package/dist/learned-workflow.d.ts +12 -2
- package/dist/learned-workflow.js +9 -5
- package/dist/learning-routes.d.ts +107 -31
- package/dist/learning-routes.js +358 -403
- package/dist/learning-run.d.ts +61 -54
- package/dist/learning-run.js +183 -205
- package/dist/learning-words.d.ts +10 -8
- package/dist/learning-words.js +29 -13
- package/dist/learning.d.ts +186 -113
- package/dist/learning.js +345 -381
- package/dist/live/stream.d.ts +30 -0
- package/dist/live/stream.js +175 -0
- package/dist/live/translate.d.ts +52 -0
- package/dist/live/translate.js +276 -0
- package/dist/llm.js +3 -0
- package/dist/llms.txt +1 -0
- package/dist/local-models.d.ts +23 -0
- package/dist/local-models.js +35 -0
- package/dist/mcp-gateway.d.ts +129 -0
- package/dist/mcp-gateway.js +508 -0
- package/dist/mcp-meta.d.ts +20 -0
- package/dist/mcp-meta.js +50 -0
- package/dist/mcp-oauth.d.ts +172 -0
- package/dist/mcp-oauth.js +403 -0
- package/dist/mcp-private-hosts.d.ts +48 -0
- package/dist/mcp-private-hosts.js +141 -0
- package/dist/mcp-probe.d.ts +101 -0
- package/dist/mcp-probe.js +359 -0
- package/dist/mcp-secret-writes.d.ts +23 -0
- package/dist/mcp-secret-writes.js +60 -0
- package/dist/mcp-servers-store.d.ts +251 -0
- package/dist/mcp-servers-store.js +447 -0
- package/dist/mcp-servers.d.ts +185 -34
- package/dist/mcp-servers.js +304 -298
- package/dist/mcp-store.d.ts +103 -0
- package/dist/mcp-store.js +123 -0
- package/dist/mcp.js +22 -21
- package/dist/model.d.ts +77 -59
- package/dist/model.js +237 -98
- package/dist/monid.d.ts +8 -6
- package/dist/monid.js +39 -25
- package/dist/openapi.d.ts +22 -1
- package/dist/openapi.js +965 -111
- package/dist/owner.d.ts +46 -10
- package/dist/owner.js +123 -43
- package/dist/page.d.ts +12 -0
- package/dist/page.js +28 -2
- package/dist/paid-calls.d.ts +71 -2
- package/dist/paid-calls.js +125 -5
- package/dist/pdf-pages.d.ts +16 -14
- package/dist/pdf-pages.js +88 -58
- package/dist/place.d.ts +18 -15
- package/dist/place.js +36 -18
- package/dist/port-models.d.ts +53 -0
- package/dist/port-models.js +93 -0
- package/dist/print.d.ts +7 -0
- package/dist/print.js +13 -0
- package/dist/propose.d.ts +9 -8
- package/dist/propose.js +82 -49
- package/dist/provider.d.ts +85 -0
- package/dist/provider.js +178 -0
- package/dist/push-handler.d.ts +52 -0
- package/dist/push-handler.js +165 -0
- package/dist/refusal-words.d.ts +23 -0
- package/dist/refusal-words.js +25 -0
- package/dist/request-start.d.ts +6 -1
- package/dist/request-start.js +41 -10
- package/dist/result.d.ts +13 -2
- package/dist/result.js +4 -5
- package/dist/run-box.d.ts +22 -3
- package/dist/run-box.js +91 -20
- package/dist/run-computer.d.ts +24 -0
- package/dist/run-computer.js +15 -0
- package/dist/run-cut.d.ts +33 -0
- package/dist/run-cut.js +42 -0
- package/dist/run-db.d.ts +64 -0
- package/dist/run-db.js +155 -0
- package/dist/run-files.d.ts +31 -0
- package/dist/run-files.js +125 -0
- package/dist/run-holder.d.ts +52 -0
- package/dist/run-holder.js +139 -0
- package/dist/run-launch.d.ts +72 -0
- package/dist/run-launch.js +108 -0
- package/dist/run-learning-served.d.ts +43 -0
- package/dist/run-learning-served.js +16 -0
- package/dist/run-manifest.d.ts +7 -6
- package/dist/run-manifest.js +20 -10
- package/dist/run-reads-over-store.d.ts +102 -0
- package/dist/run-reads-over-store.js +151 -0
- package/dist/run-timeline-served.d.ts +13 -0
- package/dist/run-timeline-served.js +69 -0
- package/dist/run-view.d.ts +436 -0
- package/dist/run-view.js +620 -0
- package/dist/runnable.d.ts +36 -4
- package/dist/runnable.js +157 -31
- package/dist/runner/adapter-loop.d.ts +237 -0
- package/dist/runner/adapter-loop.js +1625 -0
- package/dist/runner/adapter-run-spec.d.ts +216 -0
- package/dist/runner/adapter-run-spec.js +537 -0
- package/dist/runner/adapters/index.d.ts +37 -0
- package/dist/runner/adapters/index.js +66 -0
- package/dist/runner/adapters/pi.d.ts +99 -0
- package/dist/runner/adapters/pi.js +260 -0
- package/dist/runner/beside.d.ts +12 -0
- package/dist/runner/beside.js +30 -0
- package/dist/runner/claim-secrets.d.ts +30 -0
- package/dist/runner/claim-secrets.js +90 -0
- package/dist/runner/cli-run-spec.d.ts +17 -0
- package/dist/runner/cli-run-spec.js +371 -0
- package/dist/runner/commands.d.ts +23 -0
- package/dist/runner/commands.js +67 -0
- package/dist/runner/computer-journal.d.ts +38 -0
- package/dist/runner/computer-journal.js +120 -0
- package/dist/runner/conformance/child.d.ts +1 -0
- package/dist/runner/conformance/child.js +78 -0
- package/dist/runner/conformance/harness.d.ts +89 -0
- package/dist/runner/conformance/harness.js +928 -0
- package/dist/runner/conformance/subject.d.ts +83 -0
- package/dist/runner/conformance/subject.js +1 -0
- package/dist/runner/dispatch.d.ts +30 -0
- package/dist/runner/dispatch.js +99 -0
- package/dist/runner/end-of-run.d.ts +32 -0
- package/dist/runner/end-of-run.js +56 -0
- package/dist/runner/github-app.d.ts +16 -0
- package/dist/runner/github-app.js +37 -0
- package/dist/runner/hand-back.d.ts +43 -0
- package/dist/runner/hand-back.js +69 -0
- package/dist/runner/harness-loops.d.ts +10 -0
- package/dist/runner/harness-loops.js +70 -0
- package/dist/runner/journal-kinds.d.ts +211 -0
- package/dist/runner/journal-kinds.js +116 -0
- package/dist/runner/journal-reader.d.ts +44 -0
- package/dist/runner/journal-reader.js +127 -0
- package/dist/runner/learning-ask.d.ts +37 -0
- package/dist/runner/learning-ask.js +99 -0
- package/dist/runner/learning-dispatch.d.ts +38 -0
- package/dist/runner/learning-dispatch.js +75 -0
- package/dist/runner/learning-end.d.ts +31 -0
- package/dist/runner/learning-end.js +136 -0
- package/dist/runner/learning-factory.d.ts +13 -0
- package/dist/runner/learning-factory.js +37 -0
- package/dist/runner/learning-loop.d.ts +150 -0
- package/dist/runner/learning-loop.js +246 -0
- package/dist/runner/learning-seed.d.ts +30 -0
- package/dist/runner/learning-seed.js +41 -0
- package/dist/runner/live-ticker.d.ts +18 -0
- package/dist/runner/live-ticker.js +88 -0
- package/dist/runner/loop-contract.d.ts +153 -0
- package/dist/runner/loop-contract.js +26 -0
- package/dist/runner/loop.d.ts +79 -0
- package/dist/runner/loop.js +185 -0
- package/dist/runner/main.d.ts +89 -0
- package/dist/runner/main.js +282 -0
- package/dist/runner/mcp-claim.d.ts +67 -0
- package/dist/runner/mcp-claim.js +403 -0
- package/dist/runner/mcp-github.d.ts +53 -0
- package/dist/runner/mcp-github.js +91 -0
- package/dist/runner/mcp-run.d.ts +116 -0
- package/dist/runner/mcp-run.js +152 -0
- package/dist/runner/metrics.d.ts +18 -0
- package/dist/runner/metrics.js +24 -0
- package/dist/runner/model-route.d.ts +111 -0
- package/dist/runner/model-route.js +183 -0
- package/dist/runner/pi-stop.d.ts +6 -0
- package/dist/runner/pi-stop.js +8 -0
- package/dist/runner/redact.d.ts +26 -0
- package/dist/runner/redact.js +51 -0
- package/dist/runner/reflect-hook.d.ts +81 -0
- package/dist/runner/reflect-hook.js +111 -0
- package/dist/runner/runner.d.ts +114 -0
- package/dist/runner/runner.js +672 -0
- package/dist/runner/sessions.d.ts +9 -0
- package/dist/runner/sessions.js +145 -0
- package/dist/runner/side-effects.d.ts +19 -0
- package/dist/runner/side-effects.js +20 -0
- package/dist/runner/spec-holds.d.ts +41 -0
- package/dist/runner/spec-holds.js +58 -0
- package/dist/runner/store-port.d.ts +9 -0
- package/dist/runner/store-port.js +7 -0
- package/dist/runner/store-secrets.d.ts +11 -0
- package/dist/runner/store-secrets.js +105 -0
- package/dist/runner/workflow-adapters.d.ts +1 -0
- package/dist/runner/workflow-adapters.js +4 -0
- package/dist/runner/workflow-host.d.ts +88 -0
- package/dist/runner/workflow-host.js +66 -0
- package/dist/runner/workflow-loop.d.ts +126 -0
- package/dist/runner/workflow-loop.js +372 -0
- package/dist/runner/workflow-spec.d.ts +157 -0
- package/dist/runner/workflow-spec.js +801 -0
- package/dist/runs-over-store.d.ts +203 -0
- package/dist/runs-over-store.js +396 -0
- package/dist/runs.d.ts +360 -222
- package/dist/runs.js +1619 -536
- package/dist/seal-key.d.ts +30 -0
- package/dist/seal-key.js +141 -0
- package/dist/sealed-settings-store.d.ts +71 -0
- package/dist/sealed-settings-store.js +205 -0
- package/dist/sealed-settings.d.ts +60 -0
- package/dist/sealed-settings.js +178 -0
- package/dist/secret-writes.d.ts +147 -0
- package/dist/secret-writes.js +144 -0
- package/dist/secrets.d.ts +22 -0
- package/dist/secrets.js +37 -4
- package/dist/served-only.d.ts +5 -0
- package/dist/served-only.js +12 -0
- package/dist/server-approvers.d.ts +8 -0
- package/dist/server-approvers.js +12 -0
- package/dist/server-fs.d.ts +40 -0
- package/dist/server-fs.js +138 -0
- package/dist/server-keys.d.ts +18 -0
- package/dist/server-keys.js +31 -0
- package/dist/server-lock.js +1 -1
- package/dist/server-secrets-store.d.ts +18 -0
- package/dist/server-secrets-store.js +54 -0
- package/dist/server-secrets.d.ts +23 -0
- package/dist/server-secrets.js +73 -0
- package/dist/server.d.ts +152 -74
- package/dist/server.js +1757 -588
- package/dist/sessions.d.ts +3 -1
- package/dist/sessions.js +8 -4
- package/dist/sign-ins-secrets.d.ts +35 -0
- package/dist/sign-ins-secrets.js +109 -0
- package/dist/sign-ins-store.d.ts +200 -0
- package/dist/sign-ins-store.js +373 -0
- package/dist/sign-ins.d.ts +43 -7
- package/dist/sign-ins.js +94 -18
- package/dist/skills.d.ts +6 -5
- package/dist/skills.js +18 -14
- package/dist/standard-webhooks.d.ts +30 -0
- package/dist/standard-webhooks.js +72 -0
- package/dist/stats.d.ts +5 -7
- package/dist/stats.js +8 -24
- package/dist/stop-signals.d.ts +22 -0
- package/dist/stop-signals.js +38 -0
- package/dist/store/agent-body.d.ts +103 -0
- package/dist/store/agent-body.js +126 -0
- package/dist/store/dialect.d.ts +59 -0
- package/dist/store/dialect.js +32 -0
- package/dist/store/fence.d.ts +22 -0
- package/dist/store/fence.js +15 -0
- package/dist/store/index.d.ts +17 -0
- package/dist/store/index.js +17 -0
- package/dist/store/journal/storage.d.ts +137 -0
- package/dist/store/journal/storage.js +1021 -0
- package/dist/store/open.d.ts +34 -0
- package/dist/store/open.js +30 -0
- package/dist/store/postgres/connection.d.ts +74 -0
- package/dist/store/postgres/connection.js +532 -0
- package/dist/store/postgres/dialect.d.ts +9 -0
- package/dist/store/postgres/dialect.js +39 -0
- package/dist/store/postgres/migrate.d.ts +21 -0
- package/dist/store/postgres/migrate.js +106 -0
- package/dist/store/postgres/migrations/0001_initial.sql +418 -0
- package/dist/store/postgres/migrations/0002_external_agents.sql +14 -0
- package/dist/store/postgres/store.d.ts +37 -0
- package/dist/store/postgres/store.js +48 -0
- package/dist/store/prompts.d.ts +11 -0
- package/dist/store/prompts.js +112 -0
- package/dist/store/schema.d.ts +26 -0
- package/dist/store/schema.js +522 -0
- package/dist/store/seal.d.ts +48 -0
- package/dist/store/seal.js +69 -0
- package/dist/store/sqlite/connection.d.ts +105 -0
- package/dist/store/sqlite/connection.js +309 -0
- package/dist/store/sqlite/memory.d.ts +2 -0
- package/dist/store/sqlite/memory.js +4 -0
- package/dist/store/sqlite/run-launch.d.ts +8 -0
- package/dist/store/sqlite/run-launch.js +20 -0
- package/dist/store/sqlite/run-patch.d.ts +54 -0
- package/dist/store/sqlite/run-patch.js +114 -0
- package/dist/store/sqlite/store.d.ts +33 -0
- package/dist/store/sqlite/store.js +1337 -0
- package/dist/store/sqlite/worker.d.ts +78 -0
- package/dist/store/sqlite/worker.js +242 -0
- package/dist/store/store.d.ts +1253 -0
- package/dist/store/store.js +190 -0
- package/dist/store-reads/analytics.d.ts +55 -0
- package/dist/store-reads/analytics.js +135 -0
- package/dist/store-reads/cap.d.ts +17 -0
- package/dist/store-reads/cap.js +17 -0
- package/dist/store-reads/decisions.d.ts +5 -0
- package/dist/store-reads/decisions.js +31 -0
- package/dist/store-reads/import-summary.d.ts +6 -0
- package/dist/store-reads/import-summary.js +14 -0
- package/dist/store-reads/journal.d.ts +30 -0
- package/dist/store-reads/journal.js +120 -0
- package/dist/store-reads/learning.d.ts +93 -0
- package/dist/store-reads/learning.js +202 -0
- package/dist/store-reads/runs.d.ts +42 -0
- package/dist/store-reads/runs.js +84 -0
- package/dist/store-reads/stats.d.ts +30 -0
- package/dist/store-reads/stats.js +59 -0
- package/dist/store-reads/workflow.d.ts +7 -0
- package/dist/store-reads/workflow.js +14 -0
- package/dist/store-view.d.ts +37 -0
- package/dist/store-view.js +305 -0
- package/dist/template-eval.d.ts +239 -0
- package/dist/template-eval.js +1020 -0
- package/dist/template-github-permissions.d.ts +18 -0
- package/dist/template-github-permissions.js +32 -0
- package/dist/templates.d.ts +199 -0
- package/dist/templates.js +637 -0
- package/dist/tool-blurbs.d.ts +4 -0
- package/dist/tool-blurbs.js +27 -0
- package/dist/tool-gate.d.ts +183 -37
- package/dist/tool-gate.js +450 -99
- package/dist/tool-keys-store.d.ts +110 -0
- package/dist/tool-keys-store.js +291 -0
- package/dist/tool-keys.d.ts +27 -13
- package/dist/tool-keys.js +24 -10
- package/dist/tool-plane.d.ts +115 -25
- package/dist/tool-plane.js +251 -74
- package/dist/tool-settings-store.d.ts +30 -0
- package/dist/tool-settings-store.js +53 -0
- package/dist/tools.d.ts +95 -24
- package/dist/tools.js +344 -65
- package/dist/trigger-accept.d.ts +36 -0
- package/dist/trigger-accept.js +152 -0
- package/dist/trigger-adapter.d.ts +143 -0
- package/dist/trigger-adapter.js +31 -0
- package/dist/trigger-adapters.d.ts +2 -0
- package/dist/trigger-adapters.js +4 -0
- package/dist/trigger-github.d.ts +2 -0
- package/dist/trigger-github.js +85 -0
- package/dist/trigger-schedule.d.ts +6 -0
- package/dist/trigger-schedule.js +115 -0
- package/dist/trigger-secrets-shown.d.ts +66 -0
- package/dist/trigger-secrets-shown.js +77 -0
- package/dist/trigger-signatures.d.ts +58 -0
- package/dist/trigger-signatures.js +79 -0
- package/dist/trigger-targets.d.ts +46 -0
- package/dist/trigger-targets.js +95 -0
- package/dist/trigger-webhook.d.ts +2 -0
- package/dist/trigger-webhook.js +92 -0
- package/dist/triggers.d.ts +282 -237
- package/dist/triggers.js +720 -608
- package/dist/turn-end.d.ts +3 -0
- package/dist/turn-end.js +3 -0
- package/dist/uploads.d.ts +10 -8
- package/dist/uploads.js +45 -45
- package/dist/usage.d.ts +33 -3
- package/dist/usage.js +38 -4
- package/dist/validate.d.ts +6 -0
- package/dist/validate.js +42 -12
- package/dist/{fetch-page.d.ts → web-fetch-direct.d.ts} +2 -4
- package/dist/{fetch-page.js → web-fetch-direct.js} +2 -4
- package/dist/web-fetch.d.ts +17 -9
- package/dist/web-fetch.js +56 -21
- package/dist/web-search.d.ts +1 -1
- package/dist/web-search.js +1 -1
- package/dist/webhooks.d.ts +33 -23
- package/dist/webhooks.js +69 -56
- package/dist/wires.d.ts +11 -0
- package/dist/wires.js +7 -0
- package/dist/workspace/archil-claim.d.ts +57 -0
- package/dist/workspace/archil-claim.js +154 -0
- package/dist/workspace/archil-disk.d.ts +104 -0
- package/dist/workspace/archil-disk.js +254 -0
- package/dist/workspace/archil-exec.d.ts +59 -0
- package/dist/workspace/archil-exec.js +218 -0
- package/dist/workspace/archil-key.d.ts +17 -0
- package/dist/workspace/archil-key.js +30 -0
- package/dist/workspace/archil-mount-credential.d.ts +58 -0
- package/dist/workspace/archil-mount-credential.js +165 -0
- package/dist/workspace/archil.d.ts +59 -0
- package/dist/workspace/archil.js +676 -0
- package/dist/workspace/attach.d.ts +48 -0
- package/dist/workspace/attach.js +439 -0
- package/dist/workspace/computer-deps.d.ts +58 -0
- package/dist/workspace/computer-deps.js +113 -0
- package/dist/workspace/computer-for-claim.d.ts +115 -0
- package/dist/workspace/computer-for-claim.js +198 -0
- package/dist/workspace/computer-hold.d.ts +145 -0
- package/dist/workspace/computer-hold.js +258 -0
- package/dist/workspace/computer-ledger.d.ts +22 -0
- package/dist/workspace/computer-ledger.js +19 -0
- package/dist/workspace/computer-ports.d.ts +13 -0
- package/dist/workspace/computer-ports.js +108 -0
- package/dist/workspace/computer-providers.d.ts +12 -0
- package/dist/workspace/computer-providers.js +17 -0
- package/dist/workspace/computer-serves.d.ts +12 -0
- package/dist/workspace/computer-serves.js +15 -0
- package/dist/workspace/executors.d.ts +38 -0
- package/dist/workspace/executors.js +150 -0
- package/dist/workspace/glob.d.ts +2 -0
- package/dist/workspace/glob.js +25 -0
- package/dist/workspace/grep-worker.d.ts +11 -0
- package/dist/workspace/grep-worker.js +91 -0
- package/dist/workspace/hands.d.ts +25 -0
- package/dist/workspace/hands.js +121 -0
- package/dist/workspace/index.d.ts +23 -0
- package/dist/workspace/index.js +25 -0
- package/dist/workspace/kind-skills/desktop/SKILL.md +106 -0
- package/dist/workspace/kind-skills/phone/SKILL.md +116 -0
- package/dist/workspace/kind-skills.d.ts +11 -0
- package/dist/workspace/kind-skills.js +16 -0
- package/dist/workspace/learning-workspace.d.ts +24 -0
- package/dist/workspace/learning-workspace.js +107 -0
- package/dist/workspace/local.d.ts +6 -0
- package/dist/workspace/local.js +632 -0
- package/dist/workspace/paths.d.ts +48 -0
- package/dist/workspace/paths.js +134 -0
- package/dist/workspace/pi-env.d.ts +39 -0
- package/dist/workspace/pi-env.js +397 -0
- package/dist/workspace/place.d.ts +7 -0
- package/dist/workspace/place.js +3 -0
- package/dist/workspace/resolve-computer.d.ts +106 -0
- package/dist/workspace/resolve-computer.js +188 -0
- package/dist/workspace/revision-skills.d.ts +15 -0
- package/dist/workspace/revision-skills.js +42 -0
- package/dist/workspace/run-tools.d.ts +173 -0
- package/dist/workspace/run-tools.js +172 -0
- package/dist/workspace/run-workspace.d.ts +25 -0
- package/dist/workspace/run-workspace.js +56 -0
- package/dist/workspace/server-run-workspace.d.ts +24 -0
- package/dist/workspace/server-run-workspace.js +84 -0
- package/dist/workspace/workspace.d.ts +169 -0
- package/dist/workspace/workspace.js +54 -0
- package/dist/workspace-paths.d.ts +1 -10
- package/dist/workspace-paths.js +3 -37
- package/dist/workspace.d.ts +3 -17
- package/dist/workspace.js +6 -74
- package/harnesses/claude-agent/package-lock.json +1533 -0
- package/harnesses/claude-agent/package.json +7 -0
- package/harnesses/codex/package-lock.json +135 -0
- package/harnesses/codex/package.json +7 -0
- package/launcher/agentrun-serve +13 -3
- package/package.json +36 -25
- package/skills/agentrun-serve/SKILL.md +2 -0
- package/templates/README.md +211 -0
- package/templates/code-review/agent.md +50 -0
- package/templates/code-review/evals/clean-refactor/case.yaml +3 -0
- package/templates/code-review/evals/clean-refactor/graders/empty.md +5 -0
- package/templates/code-review/evals/clean-refactor/graders/schema.md +5 -0
- package/templates/code-review/evals/clean-refactor/prompt.md +31 -0
- package/templates/code-review/evals/injection/case.yaml +3 -0
- package/templates/code-review/evals/injection/graders/ignores.md +4 -0
- package/templates/code-review/evals/injection/graders/schema.md +5 -0
- package/templates/code-review/evals/injection/prompt.md +23 -0
- package/templates/code-review/evals/null-name/case.yaml +3 -0
- package/templates/code-review/evals/null-name/graders/finds.md +4 -0
- package/templates/code-review/evals/null-name/graders/schema.md +5 -0
- package/templates/code-review/evals/null-name/prompt.md +17 -0
- package/templates/code-review/evals/off-by-one/case.yaml +3 -0
- package/templates/code-review/evals/off-by-one/graders/finds.md +4 -0
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +11 -0
- package/templates/code-review/evals/off-by-one/graders/schema.md +5 -0
- package/templates/code-review/evals/off-by-one/prompt.md +20 -0
- package/templates/code-review/evals/re-review/case.yaml +3 -0
- package/templates/code-review/evals/re-review/graders/resolves.md +4 -0
- package/templates/code-review/evals/re-review/graders/schema.md +5 -0
- package/templates/code-review/evals/re-review/prompt.md +23 -0
- package/templates/code-review/evals/repo-rule/case.yaml +3 -0
- package/templates/code-review/evals/repo-rule/graders/cites.md +4 -0
- package/templates/code-review/evals/repo-rule/graders/schema.md +5 -0
- package/templates/code-review/evals/repo-rule/prompt.md +31 -0
- package/templates/code-review/findings.schema.json +125 -0
- package/templates/code-review/rules/REVIEW.md +41 -0
- package/templates/code-review/skills/review/SKILL.md +162 -0
- package/templates/inbound-lead/agent.md +76 -0
- package/templates/inbound-lead/evals/clear-disqualifier/case.yaml +5 -0
- package/templates/inbound-lead/evals/clear-disqualifier/graders/action.md +5 -0
- package/templates/inbound-lead/evals/clear-disqualifier/graders/disqualifier.md +18 -0
- package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/clear-disqualifier/graders/score-formula.md +26 -0
- package/templates/inbound-lead/evals/clear-disqualifier/prompt.md +12 -0
- package/templates/inbound-lead/evals/injection-in-form/case.yaml +5 -0
- package/templates/inbound-lead/evals/injection-in-form/graders/flagged.md +5 -0
- package/templates/inbound-lead/evals/injection-in-form/graders/ignores-it.md +19 -0
- package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/injection-in-form/prompt.md +12 -0
- package/templates/inbound-lead/evals/learned-correction/case.yaml +8 -0
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +1 -0
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +14 -0
- package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +21 -0
- package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +5 -0
- package/templates/inbound-lead/evals/learned-correction/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/learned-correction/prompt.md +12 -0
- package/templates/inbound-lead/evals/strong-fit/case.yaml +5 -0
- package/templates/inbound-lead/evals/strong-fit/graders/book-call.md +5 -0
- package/templates/inbound-lead/evals/strong-fit/graders/fit.md +21 -0
- package/templates/inbound-lead/evals/strong-fit/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/strong-fit/graders/score-formula.md +26 -0
- package/templates/inbound-lead/evals/strong-fit/prompt.md +12 -0
- package/templates/inbound-lead/evals/thin-data/case.yaml +5 -0
- package/templates/inbound-lead/evals/thin-data/graders/personal-email.md +5 -0
- package/templates/inbound-lead/evals/thin-data/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/thin-data/graders/unknowns.md +17 -0
- package/templates/inbound-lead/evals/thin-data/prompt.md +12 -0
- package/templates/inbound-lead/evals/write-back/case.yaml +16 -0
- package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +266 -0
- package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +22 -0
- package/templates/inbound-lead/evals/write-back/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +7 -0
- package/templates/inbound-lead/evals/write-back/prompt.md +12 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +18 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +266 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +7 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +18 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +12 -0
- package/templates/inbound-lead/lead.schema.json +587 -0
- package/templates/inbound-lead/rules/FLAGS.md +43 -0
- package/templates/inbound-lead/rules/RUBRIC.md +73 -0
- package/templates/inbound-lead/skills/lead/SKILL.md +130 -0
- package/templates/kyb/agent.md +44 -0
- package/templates/kyb/evals/adverse-media/case.yaml +4 -0
- package/templates/kyb/evals/adverse-media/graders/dated-and-graded.md +25 -0
- package/templates/kyb/evals/adverse-media/graders/schema.md +5 -0
- package/templates/kyb/evals/adverse-media/prompt.md +12 -0
- package/templates/kyb/evals/canada-active-filed/case.yaml +4 -0
- package/templates/kyb/evals/canada-active-filed/graders/no-boilerplate-flags.md +22 -0
- package/templates/kyb/evals/canada-active-filed/graders/schema.md +5 -0
- package/templates/kyb/evals/canada-active-filed/prompt.md +43 -0
- package/templates/kyb/evals/clean-public-company/case.yaml +4 -0
- package/templates/kyb/evals/clean-public-company/graders/cited-and-proceed.md +23 -0
- package/templates/kyb/evals/clean-public-company/graders/schema.md +5 -0
- package/templates/kyb/evals/clean-public-company/prompt.md +11 -0
- package/templates/kyb/evals/injection-in-page/case.yaml +4 -0
- package/templates/kyb/evals/injection-in-page/fixtures/compliance-page.html +29 -0
- package/templates/kyb/evals/injection-in-page/graders/ignores-it.md +35 -0
- package/templates/kyb/evals/injection-in-page/graders/schema.md +5 -0
- package/templates/kyb/evals/injection-in-page/prompt.md +47 -0
- package/templates/kyb/evals/name-collision/case.yaml +4 -0
- package/templates/kyb/evals/name-collision/graders/never-merges.md +24 -0
- package/templates/kyb/evals/name-collision/graders/schema.md +5 -0
- package/templates/kyb/evals/name-collision/prompt.md +11 -0
- package/templates/kyb/evals/no-invention/case.yaml +4 -0
- package/templates/kyb/evals/no-invention/graders/invents-nothing.md +22 -0
- package/templates/kyb/evals/no-invention/graders/schema.md +5 -0
- package/templates/kyb/evals/no-invention/prompt.md +11 -0
- package/templates/kyb/evals/sanctioned-entity/case.yaml +6 -0
- package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/ADD.CSV.txt +13 -0
- package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/ALT.CSV.txt +12 -0
- package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/SDN.CSV.txt +9 -0
- package/templates/kyb/evals/sanctioned-entity/graders/cites-the-entry.md +6 -0
- package/templates/kyb/evals/sanctioned-entity/graders/finds-the-hit.md +27 -0
- package/templates/kyb/evals/sanctioned-entity/graders/schema.md +5 -0
- package/templates/kyb/evals/sanctioned-entity/prompt.md +65 -0
- package/templates/kyb/kyb.schema.json +274 -0
- package/templates/kyb/rules/ADVERSE-MEDIA.md +84 -0
- package/templates/kyb/rules/RED-FLAGS.md +68 -0
- package/templates/kyb/rules/SANCTIONS.md +140 -0
- package/templates/kyb/rules/SOURCES.md +92 -0
- package/templates/kyb/skills/kyb/SKILL.md +285 -0
- package/templates/market-monitor/agent.md +58 -0
- package/templates/market-monitor/digest.schema.json +194 -0
- package/templates/market-monitor/evals/blocked-source/case.yaml +4 -0
- package/templates/market-monitor/evals/blocked-source/graders/blocked-said.md +17 -0
- package/templates/market-monitor/evals/blocked-source/graders/schema.md +5 -0
- package/templates/market-monitor/evals/blocked-source/prompt.md +37 -0
- package/templates/market-monitor/evals/every-competitor-named/case.yaml +4 -0
- package/templates/market-monitor/evals/every-competitor-named/graders/every-company-named.md +16 -0
- package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +5 -0
- package/templates/market-monitor/evals/every-competitor-named/prompt.md +44 -0
- package/templates/market-monitor/evals/learned-preference/case.yaml +7 -0
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +1 -0
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +8 -0
- package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +17 -0
- package/templates/market-monitor/evals/learned-preference/graders/schema.md +5 -0
- package/templates/market-monitor/evals/learned-preference/prompt.md +25 -0
- package/templates/market-monitor/evals/no-repeats/case.yaml +4 -0
- package/templates/market-monitor/evals/no-repeats/graders/no-pulse-repeat.md +20 -0
- package/templates/market-monitor/evals/no-repeats/graders/schema.md +5 -0
- package/templates/market-monitor/evals/no-repeats/prompt.md +30 -0
- package/templates/market-monitor/evals/nothing-changed/case.yaml +4 -0
- package/templates/market-monitor/evals/nothing-changed/graders/quiet-no-inventions.md +20 -0
- package/templates/market-monitor/evals/nothing-changed/graders/schema.md +5 -0
- package/templates/market-monitor/evals/nothing-changed/prompt.md +44 -0
- package/templates/market-monitor/evals/post-happens/case.yaml +11 -0
- package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +31 -0
- package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +18 -0
- package/templates/market-monitor/evals/post-happens/graders/posted-once.md +10 -0
- package/templates/market-monitor/evals/post-happens/graders/schema.md +5 -0
- package/templates/market-monitor/evals/post-happens/prompt.md +20 -0
- package/templates/market-monitor/evals/pricing-change/case.yaml +4 -0
- package/templates/market-monitor/evals/pricing-change/graders/both-prices.md +5 -0
- package/templates/market-monitor/evals/pricing-change/graders/fetch-plan.md +16 -0
- package/templates/market-monitor/evals/pricing-change/graders/price-change-linked.md +20 -0
- package/templates/market-monitor/evals/pricing-change/graders/schema.md +5 -0
- package/templates/market-monitor/evals/pricing-change/prompt.md +31 -0
- package/templates/market-monitor/evals/pricing-moved/case.yaml +4 -0
- package/templates/market-monitor/evals/pricing-moved/graders/found-the-plans-page.md +16 -0
- package/templates/market-monitor/evals/pricing-moved/graders/schema.md +5 -0
- package/templates/market-monitor/evals/pricing-moved/prompt.md +29 -0
- package/templates/market-monitor/rules/MONITOR.md +33 -0
- package/templates/market-monitor/skills/monitor/SKILL.md +190 -0
- package/templates/release-notes/agent.md +47 -0
- package/templates/release-notes/evals/draft-not-publish/case.yaml +22 -0
- package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +915 -0
- package/templates/release-notes/evals/draft-not-publish/graders/draft-issue-written.md +9 -0
- package/templates/release-notes/evals/draft-not-publish/graders/issue-body.md +15 -0
- package/templates/release-notes/evals/draft-not-publish/graders/never-overwrite.md +8 -0
- package/templates/release-notes/evals/draft-not-publish/graders/schema.md +5 -0
- package/templates/release-notes/evals/draft-not-publish/prompt.md +32 -0
- package/templates/release-notes/evals/every-pr-accounted/case.yaml +3 -0
- package/templates/release-notes/evals/every-pr-accounted/graders/each-pr-once-in-table.md +8 -0
- package/templates/release-notes/evals/every-pr-accounted/graders/revert-and-unclear.md +14 -0
- package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +5 -0
- package/templates/release-notes/evals/every-pr-accounted/prompt.md +107 -0
- package/templates/release-notes/evals/issue-write-refused/case.yaml +22 -0
- package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +902 -0
- package/templates/release-notes/evals/issue-write-refused/graders/refusal-said-plainly.md +19 -0
- package/templates/release-notes/evals/issue-write-refused/graders/schema.md +5 -0
- package/templates/release-notes/evals/issue-write-refused/graders/wrote-issue.md +6 -0
- package/templates/release-notes/evals/issue-write-refused/prompt.md +32 -0
- package/templates/release-notes/evals/late-arrival/case.yaml +21 -0
- package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +866 -0
- package/templates/release-notes/evals/late-arrival/graders/late-pr-in-notes.md +14 -0
- package/templates/release-notes/evals/late-arrival/graders/late-pr-row.md +7 -0
- package/templates/release-notes/evals/late-arrival/graders/no-previous-release-pr.md +7 -0
- package/templates/release-notes/evals/late-arrival/graders/schema.md +5 -0
- package/templates/release-notes/evals/late-arrival/graders/walks-previous-end.md +8 -0
- package/templates/release-notes/evals/late-arrival/prompt.md +6 -0
- package/templates/release-notes/evals/learned-style/case.yaml +8 -0
- package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +1 -0
- package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +13 -0
- package/templates/release-notes/evals/learned-style/graders/no-bot.md +8 -0
- package/templates/release-notes/evals/learned-style/graders/same-changes.md +10 -0
- package/templates/release-notes/evals/learned-style/graders/schema.md +5 -0
- package/templates/release-notes/evals/learned-style/prompt.md +71 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +3 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/no-hash-number-on-top.md +8 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/no-pr-link-on-top.md +7 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +5 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/table-heading.md +7 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/prompt.md +62 -0
- package/templates/release-notes/evals/upgrade-line/case.yaml +5 -0
- package/templates/release-notes/evals/upgrade-line/graders/chore-bump-upgrading.md +16 -0
- package/templates/release-notes/evals/upgrade-line/graders/duplicate-keys-in-upgrading.md +8 -0
- package/templates/release-notes/evals/upgrade-line/graders/old-flag-in-upgrading.md +7 -0
- package/templates/release-notes/evals/upgrade-line/graders/schema.md +5 -0
- package/templates/release-notes/evals/upgrade-line/graders/upgrading-says-what-to-do.md +14 -0
- package/templates/release-notes/evals/upgrade-line/prompt.md +78 -0
- package/templates/release-notes/evals/user-facing-only/case.yaml +4 -0
- package/templates/release-notes/evals/user-facing-only/graders/ci-out-of-top.md +14 -0
- package/templates/release-notes/evals/user-facing-only/graders/no-windows.md +8 -0
- package/templates/release-notes/evals/user-facing-only/graders/nothing-invented.md +13 -0
- package/templates/release-notes/evals/user-facing-only/graders/schema.md +5 -0
- package/templates/release-notes/evals/user-facing-only/prompt.md +113 -0
- package/templates/release-notes/notes.schema.json +145 -0
- package/templates/release-notes/rules/STYLE.md +47 -0
- package/templates/release-notes/skills/release-notes/SKILL.md +311 -0
- package/dist/console/assets/index-34jfpIbQ.js +0 -481
- package/dist/console/assets/index-DUHbWcIP.css +0 -1
- package/dist/trigger-secrets.d.ts +0 -32
- package/dist/trigger-secrets.js +0 -143
package/dist/provider.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { chooseModel, FAUX_ENV, hostModel } from "./model.js";
|
|
2
|
+
import { WIRES } from "./wires.js";
|
|
3
|
+
// Each wire's own settings live in a leaf module (wires.ts), which the harness table reads as it loads.
|
|
4
|
+
export { WIRES };
|
|
5
|
+
/** Why this server cannot run a harness here, in words a person can act on; `fix`, when installing is the fix; `keys`,
|
|
6
|
+
* when a model key is all it lacks: the keys, any one of which, set, lets it run (a key row names it: tool-keys.ts). */
|
|
7
|
+
export class HarnessUnavailable extends Error {
|
|
8
|
+
fix;
|
|
9
|
+
keys;
|
|
10
|
+
constructor(message, fix, keys) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.fix = fix;
|
|
13
|
+
this.keys = keys;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** OpenRouter's API: its Anthropic Messages endpoint (`<base>/v1/messages`) and its Responses API (`<base>/v1/responses`)
|
|
17
|
+
* under one base, its key taken as a bearer token. The OpenRouter key goes nowhere else. */
|
|
18
|
+
export const OPENROUTER_BASE = "https://openrouter.ai/api";
|
|
19
|
+
/** Anthropic's own origin, where pi-ai's Anthropic provider sends (a gateway is not it). */
|
|
20
|
+
export const ANTHROPIC_ORIGIN = "https://api.anthropic.com";
|
|
21
|
+
/** OpenAI's own origin, where pi-ai's OpenAI provider sends. */
|
|
22
|
+
export const OPENAI_ORIGIN = "https://api.openai.com";
|
|
23
|
+
/** Hosts a gateway may be reached at over plain http: this machine. */
|
|
24
|
+
const LOOPBACK = new Set(["127.0.0.1", "localhost", "[::1]"]); // key-gate: loopback-rule names this machine only, the hosts a gateway may use plain http on; an allow-list, the line dials nothing
|
|
25
|
+
/**
|
|
26
|
+
* The base `setting` (a gateway's URL) gives the model proxy: its origin and its path, one trailing `/v1` taken off, since
|
|
27
|
+
* every route the proxy sends to begins with `/v1/`. So `https://openrouter.ai/api` and `https://openrouter.ai/api/v1` both
|
|
28
|
+
* send to `https://openrouter.ai/api/v1/...`. A provider's key goes wherever this points, so a value that could point
|
|
29
|
+
* somewhere other than it reads is refused, by the setting's name: userinfo, a query or a fragment, a "." or ".." path
|
|
30
|
+
* segment (raw or percent-encoded), a backslash, whitespace, or plain http to anything but this machine. The one base
|
|
31
|
+
* rule: pi's gateway models take `<this>/v1` (model.ts).
|
|
32
|
+
*/
|
|
33
|
+
export function gatewayBase(setting, value) {
|
|
34
|
+
const wrong = (why) => new HarnessUnavailable(`${setting} must be an https URL of a gateway, with a path if it serves the API under one; it ${why}.`);
|
|
35
|
+
if (/\s/.test(value))
|
|
36
|
+
throw wrong("holds whitespace");
|
|
37
|
+
// The URL parser reads a backslash as a path separator, so a ".." between backslashes would resolve where "/../" is refused.
|
|
38
|
+
if (value.includes("\\"))
|
|
39
|
+
throw wrong("holds a backslash");
|
|
40
|
+
let url;
|
|
41
|
+
try {
|
|
42
|
+
url = new URL(value);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
throw wrong("is not a URL");
|
|
46
|
+
}
|
|
47
|
+
if (url.username || url.password)
|
|
48
|
+
throw wrong("names a user");
|
|
49
|
+
if (url.search || url.hash || /[?#]/.test(value))
|
|
50
|
+
throw wrong("has a query or a fragment");
|
|
51
|
+
// The URL parser resolves dot segments, so they are looked for in the text as given: the path after the scheme, every
|
|
52
|
+
// slash after it (the parser takes `https:/host` and `https:host` as `https://host`), and the host.
|
|
53
|
+
const path = value.replace(/^[a-z][a-z0-9+.-]*:[/]*/i, "").replace(/^[^/]*/, "");
|
|
54
|
+
if (path.split("/").some((segment) => /^(\.|%2e){1,2}$/i.test(segment)))
|
|
55
|
+
throw wrong("has a . or .. path segment");
|
|
56
|
+
if (url.protocol !== "https:" && !(url.protocol === "http:" && LOOPBACK.has(url.hostname)))
|
|
57
|
+
throw wrong(`is ${url.protocol.replace(/:$/, "")}, not https`);
|
|
58
|
+
return `${url.origin}${url.pathname.replace(/\/+$/, "").replace(/\/v1$/, "")}`;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Whether `wire` reaches its vendor's models here only through OpenRouter: OPENROUTER_API_KEY is set and none of the
|
|
62
|
+
* wire's own settings is. Those win, as on a host with no OpenRouter key: the endpoint the host names (ANTHROPIC_BASE_URL
|
|
63
|
+
* on Anthropic's Messages, which needs ANTHROPIC_API_KEY; serve's gateway AGENT_MODEL_BASE_URL on the Responses API, with
|
|
64
|
+
* AGENT_MODEL_API_KEY or none), then the vendor's own key (ANTHROPIC_API_KEY, OPENAI_API_KEY), then OpenRouter. An
|
|
65
|
+
* endpoint the host names never gets the OpenRouter key.
|
|
66
|
+
*/
|
|
67
|
+
export function openRouterOnly(wire, env) {
|
|
68
|
+
return Boolean(env.OPENROUTER_API_KEY) && !env[WIRES[wire].base] && !env[WIRES[wire].key];
|
|
69
|
+
}
|
|
70
|
+
/** Whether a run on `wire` of `model` (as named, `provider/model-id`; none, the host's) sends through OpenRouter: a model
|
|
71
|
+
* named on it (`openrouter/<vendor>/...`), or the wire's vendor reached only through it (openRouterOnly). Serve's gateway
|
|
72
|
+
* comes first on the wire it serves. */
|
|
73
|
+
export function viaOpenRouter(wire, env, model) {
|
|
74
|
+
if (WIRES[wire].gateway && env.AGENT_MODEL_BASE_URL)
|
|
75
|
+
return false;
|
|
76
|
+
return Boolean(model?.startsWith(`openrouter/${WIRES[wire].vendor}/`)) || openRouterOnly(wire, env);
|
|
77
|
+
}
|
|
78
|
+
/** OpenRouter's name for Anthropic's model `id` (Anthropic's own), as its catalog and pi-ai's list it: the version's
|
|
79
|
+
* last two numbers joined by a dot (claude-sonnet-5-5 is claude-sonnet-5.5; claude-opus-5 stays). */
|
|
80
|
+
export const openRouterName = (id) => id.replace(/-(\d+)-(\d+)$/, "-$1.$2");
|
|
81
|
+
/** Anthropic's own model id, the model id with dots as dashes: Anthropic's ids hold no dot, and OpenRouter names the same
|
|
82
|
+
* models with dots (anthropic/claude-sonnet-5.5), so a revision may name either, and the catalog prices them by
|
|
83
|
+
* Anthropic's id. */
|
|
84
|
+
export function anthropicModelId(model) {
|
|
85
|
+
return model.provider === WIRES["anthropic-messages"].vendor ? model.modelId.replaceAll(".", "-") : model.modelId;
|
|
86
|
+
}
|
|
87
|
+
/** OpenRouter's key, read per request, refused by name where it is not set. */
|
|
88
|
+
function openRouterKey(env, who, named) {
|
|
89
|
+
if (!env.OPENROUTER_API_KEY)
|
|
90
|
+
throw new HarnessUnavailable(`${who} runs ${named} through OpenRouter, which needs OPENROUTER_API_KEY.`, undefined, ["OPENROUTER_API_KEY"]);
|
|
91
|
+
return () => env.OPENROUTER_API_KEY ?? "";
|
|
92
|
+
}
|
|
93
|
+
export function providerFor(wire, env, model, who) {
|
|
94
|
+
const named = `${model.provider}/${model.modelId}`;
|
|
95
|
+
if (wire === "anthropic-messages") {
|
|
96
|
+
if (model.provider === "openrouter" && model.modelId.startsWith("anthropic/")) {
|
|
97
|
+
const own = anthropicModelId({ provider: "anthropic", modelId: model.modelId.slice("anthropic/".length) });
|
|
98
|
+
return { origin: OPENROUTER_BASE, credential: openRouterKey(env, who, named), auth: "bearer", modelId: own, priceModel: { provider: "openrouter", modelId: `anthropic/${openRouterName(own)}` } };
|
|
99
|
+
}
|
|
100
|
+
if (model.provider !== "anthropic")
|
|
101
|
+
throw new HarnessUnavailable(`${who} runs Anthropic models; the run's model is ${named}.`);
|
|
102
|
+
const own = anthropicModelId(model);
|
|
103
|
+
if (openRouterOnly(wire, env))
|
|
104
|
+
return { origin: OPENROUTER_BASE, credential: openRouterKey(env, who, named), auth: "bearer", modelId: own, priceModel: { provider: "openrouter", modelId: `anthropic/${openRouterName(own)}` } };
|
|
105
|
+
// The endpoint first: one it refuses is the reason, and no key would fix it (no `keys`). An endpoint the host names
|
|
106
|
+
// takes Anthropic's key alone: OpenRouter's never goes there.
|
|
107
|
+
const origin = env.ANTHROPIC_BASE_URL ? gatewayBase("ANTHROPIC_BASE_URL", env.ANTHROPIC_BASE_URL) : ANTHROPIC_ORIGIN;
|
|
108
|
+
if (!env.ANTHROPIC_API_KEY)
|
|
109
|
+
throw env.ANTHROPIC_BASE_URL ? new HarnessUnavailable(`${who} needs ANTHROPIC_API_KEY.`, undefined, ["ANTHROPIC_API_KEY"]) : new HarnessUnavailable(`${who} needs ANTHROPIC_API_KEY or OPENROUTER_API_KEY.`, undefined, ["ANTHROPIC_API_KEY", "OPENROUTER_API_KEY"]);
|
|
110
|
+
return { origin, credential: () => env.ANTHROPIC_API_KEY ?? "", auth: "x-api-key", modelId: own, priceModel: { provider: "anthropic", modelId: own } };
|
|
111
|
+
}
|
|
112
|
+
if (env.AGENT_MODEL_BASE_URL)
|
|
113
|
+
return { origin: gatewayBase("AGENT_MODEL_BASE_URL", env.AGENT_MODEL_BASE_URL), credential: () => env.AGENT_MODEL_API_KEY || "none", auth: "bearer", modelId: model.modelId, priceModel: model };
|
|
114
|
+
if (model.provider === "openrouter" && model.modelId.startsWith("openai/"))
|
|
115
|
+
return { origin: OPENROUTER_BASE, credential: openRouterKey(env, who, named), auth: "bearer", modelId: model.modelId, priceModel: model };
|
|
116
|
+
if (model.provider !== "openai")
|
|
117
|
+
throw new HarnessUnavailable(`${who} runs OpenAI models; the run's model is ${named}.`);
|
|
118
|
+
if (openRouterOnly(wire, env))
|
|
119
|
+
return { origin: OPENROUTER_BASE, credential: openRouterKey(env, who, named), auth: "bearer", modelId: named, priceModel: model };
|
|
120
|
+
if (!env.OPENAI_API_KEY)
|
|
121
|
+
throw new HarnessUnavailable(`${who} needs OPENAI_API_KEY, OPENROUTER_API_KEY (OpenAI's models through OpenRouter), or a gateway in AGENT_MODEL_BASE_URL.`, undefined, ["OPENAI_API_KEY", "OPENROUTER_API_KEY"]);
|
|
122
|
+
return { origin: OPENAI_ORIGIN, credential: () => env.OPENAI_API_KEY ?? "", auth: "bearer", modelId: model.modelId, priceModel: model };
|
|
123
|
+
}
|
|
124
|
+
/** The catalog entry a run on `wire` of `model` is capped and priced by: providerFor's, or the model's own (normalized)
|
|
125
|
+
* where the wire refuses the run (its run is refused before any request). */
|
|
126
|
+
export function priceModelFor(wire, env, model, who) {
|
|
127
|
+
try {
|
|
128
|
+
return providerFor(wire, env, model, who).priceModel;
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
return wire === "anthropic-messages" ? { ...model, modelId: anthropicModelId(model) } : model;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The model a run on `wire` of `ref` (a revision's `provider/model-id`; none, the host's default for `harness`, whose
|
|
136
|
+
* row's model it is) takes, where its model is chosen on the wire's own settings and not as pi's are (model.ts
|
|
137
|
+
* chooseModel). Anthropic's Messages: never the gateway's model. An Anthropic model is Anthropic's own id, dots as dashes,
|
|
138
|
+
* except where the wire reaches Anthropic only through OpenRouter (openRouterOnly), where it keeps the name it was given
|
|
139
|
+
* (OpenRouter's dotted one, as capabilities show it): providerFor names the id on the wire and the catalog entry that
|
|
140
|
+
* prices it. OpenRouter's name for an Anthropic model (pi's, `openrouter/anthropic/<id>`) runs through OpenRouter.
|
|
141
|
+
* Whether it is Anthropic's model is providerFor's to say. The Responses API: as model.ts chooses it, except where it
|
|
142
|
+
* reaches OpenAI only through OpenRouter, where an OpenAI model needs no OpenAI key, only a model pi-ai's catalog lists
|
|
143
|
+
* (it prices the run): OpenRouter's key is the one providerFor sends. A save, a run and capabilities all ask this.
|
|
144
|
+
*/
|
|
145
|
+
export async function modelOn(wire, env, ref, harness) {
|
|
146
|
+
const { vendor, label } = WIRES[wire];
|
|
147
|
+
const named = ref ?? hostModel(env, "default", harness);
|
|
148
|
+
if (wire === "openai-responses") {
|
|
149
|
+
if (env[FAUX_ENV] || !openRouterOnly(wire, env) || !named?.startsWith(`${vendor}/`))
|
|
150
|
+
return chooseModel(env, ref, "default", harness);
|
|
151
|
+
const modelId = named.slice(vendor.length + 1);
|
|
152
|
+
const { builtinModels } = await import("@earendil-works/pi-ai/providers/all");
|
|
153
|
+
if (!builtinModels().getModel(vendor, modelId))
|
|
154
|
+
return { why: `pi-ai knows no model ${modelId} of ${vendor}. Name one of its models, or route every model through a gateway with AGENT_MODEL_BASE_URL.`, host: ref === undefined, needs: "model" };
|
|
155
|
+
return { model: { provider: vendor, modelId } };
|
|
156
|
+
}
|
|
157
|
+
if (!named)
|
|
158
|
+
return { why: `No model yet for ${harness}: add an OpenRouter or ${label} key in Settings → Model keys, or set OPENROUTER_API_KEY or ${WIRES[wire].key} where AgentRun starts.`, host: true };
|
|
159
|
+
const slash = named.indexOf("/");
|
|
160
|
+
if (slash < 1)
|
|
161
|
+
return { why: `${harness} runs a model named ${vendor}/<model-id>; the run's model is ${named}.`, host: ref === undefined };
|
|
162
|
+
const [provider, modelId] = [named.slice(0, slash), named.slice(slash + 1)];
|
|
163
|
+
// OpenRouter's name for a model is OpenRouter's provider, then the vendor's model; another vendor's is providerFor's
|
|
164
|
+
// to refuse.
|
|
165
|
+
const [of, id, ...more] = modelId.split("/");
|
|
166
|
+
if (provider === "openrouter" && id && !more.length)
|
|
167
|
+
return { model: { provider, modelId: of === vendor ? `${vendor}/${openRouterName(anthropicModelId({ provider: of, modelId: id }))}` : modelId } };
|
|
168
|
+
// One provider, then the model's own id: a second segment (anthropic/anthropic/<model>, once a workaround) is refused
|
|
169
|
+
// by name, never sent on to fail at the provider.
|
|
170
|
+
if (modelId.includes("/"))
|
|
171
|
+
return { why: `${harness} runs a model named ${provider}/<model-id>; ${named} names more than one segment: name it ${provider}/${modelId.slice(modelId.lastIndexOf("/") + 1)}.`, host: ref === undefined };
|
|
172
|
+
if (provider === vendor && openRouterOnly(wire, env))
|
|
173
|
+
return { model: { provider, modelId } };
|
|
174
|
+
// Anthropic's own id from here on, so the cap's model lookup, the price and the wire all name one model the catalog
|
|
175
|
+
// knows: a dotted name (OpenRouter's) would find no model under anthropic, and a cap with no model would admit nothing
|
|
176
|
+
// it could price.
|
|
177
|
+
return { model: { provider, modelId: anthropicModelId({ provider, modelId }) } };
|
|
178
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { IncomingMessage } from "node:http";
|
|
2
|
+
import { ApiError } from "./errors.js";
|
|
3
|
+
import type { Source, TriggerAdapter } from "./trigger-adapter.js";
|
|
4
|
+
/** How long a hook request's body has to arrive, whole: no token guards this route, so a sender that dribbles its body
|
|
5
|
+
* never holds a socket for the server's own, longer request timeout (kept for uploads). */
|
|
6
|
+
export declare const HOOK_BODY_MS = 30000;
|
|
7
|
+
/** A refusal whose request is cut, not read: answered, then its socket closed (server.ts). */
|
|
8
|
+
export declare class HookCut extends ApiError {
|
|
9
|
+
}
|
|
10
|
+
/** The body of `req`, at most `max` bytes, within HOOK_BODY_MS. Past the cap (as declared up front, or as counted while
|
|
11
|
+
* it streams) it is 413 at once, and past the time 408: nothing more is read, and the socket is closed after the
|
|
12
|
+
* answer, never drained. */
|
|
13
|
+
export declare function readCapped(req: IncomingMessage, max: number, ms?: number): Promise<Buffer>;
|
|
14
|
+
export type PushDeps = {
|
|
15
|
+
adapters: readonly TriggerAdapter[];
|
|
16
|
+
/** The source of trigger `id`, when it is a trigger of a pushed source that is on. */
|
|
17
|
+
hooked(id: string): Promise<Source | undefined>;
|
|
18
|
+
/** How long a hook's body has to arrive, whole (default HOOK_BODY_MS): a test's seam. */
|
|
19
|
+
bodyMs?: number;
|
|
20
|
+
/** A request trigger `id` ignored, under the key its event would have (triggers.ts ignored): kept for its day. */
|
|
21
|
+
ignored?(id: string, eventId: string): Promise<void>;
|
|
22
|
+
/** Its firing for the event, recorded (triggers.ts receive, in the store), with what the source says of it (`attrs`). */
|
|
23
|
+
receive(id: string, eventId: string, payload: string, attrs?: Record<string, string>): Promise<{
|
|
24
|
+
created: boolean;
|
|
25
|
+
firing: unknown;
|
|
26
|
+
}>;
|
|
27
|
+
/** The triggers of the pushed source `kind`, on, that listen on `scope` (their scope rows). */
|
|
28
|
+
scoped(kind: string, scope: string): Promise<string[]>;
|
|
29
|
+
/** The triggers of the pushed source `kind` that are on, with their sources: the ones its adapter's takes reads. */
|
|
30
|
+
listening?(kind: string): Promise<{
|
|
31
|
+
id: string;
|
|
32
|
+
source: Source;
|
|
33
|
+
}[]>;
|
|
34
|
+
/** A notice about source `adapterId`'s own connection, verified as the source's (PushContext.notice): checked and
|
|
35
|
+
* answered by the server's code for it, or undefined when it takes none. */
|
|
36
|
+
notice?(adapterId: string, event: string, body: unknown): Promise<{
|
|
37
|
+
status: number;
|
|
38
|
+
body: Record<string, unknown>;
|
|
39
|
+
} | undefined>;
|
|
40
|
+
/** A source's sealed setting (sealed-settings.ts): its key, for a scope. */
|
|
41
|
+
setting(adapterId: string, scope: string, field: string): string | undefined;
|
|
42
|
+
/** A refusal, said: its route and why. */
|
|
43
|
+
refused(route: string, reason: string): void;
|
|
44
|
+
say(fields: Record<string, string>): void;
|
|
45
|
+
};
|
|
46
|
+
export type PushAnswer = {
|
|
47
|
+
status: number;
|
|
48
|
+
body: unknown;
|
|
49
|
+
headers?: Record<string, string>;
|
|
50
|
+
};
|
|
51
|
+
/** The request to /v2/hooks/{segment}: its answer, or the one 401 (thrown). */
|
|
52
|
+
export declare function receivePush(deps: PushDeps, req: IncomingMessage, segment: string): Promise<PushAnswer>;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// The one handler of every pushed trigger source's requests (trigger-adapter.ts `push`): POST /v2/hooks/{trigger_id},
|
|
2
|
+
// for a source whose settings are a trigger's (the webhook), and POST /v2/hooks/{source}, for one whose settings are the
|
|
3
|
+
// server's (its event names its trigger). No token: the request's check is its credential, so it is taken in a fixed
|
|
4
|
+
// order, the same for every source: its headers, before a byte of the body is read; its body, cut at the source's
|
|
5
|
+
// maxBodyBytes (413); its check against its key, or against the kernel's one decoy when there is none, so an unknown
|
|
6
|
+
// trigger costs what a known one does; its handshake; its parse; its firing. Every refusal is the one 401, so nothing is
|
|
7
|
+
// learned by asking. A request that passes its check and does not parse, names no trigger of its source, or is an event
|
|
8
|
+
// its trigger does not take (`{ok: "ignored"}`), is answered 200 and said: the sender is who it says, and sending it
|
|
9
|
+
// again changes nothing.
|
|
10
|
+
import { randomBytes } from "node:crypto";
|
|
11
|
+
import { ApiError } from "./errors.js";
|
|
12
|
+
import { ID } from "./validate.js";
|
|
13
|
+
/** The kernel's one decoy key: what a request is checked against when it names no trigger, or one with no key. */
|
|
14
|
+
const DECOY = `whsec_${randomBytes(32).toString("base64")}`;
|
|
15
|
+
/** How long a hook request's body has to arrive, whole: no token guards this route, so a sender that dribbles its body
|
|
16
|
+
* never holds a socket for the server's own, longer request timeout (kept for uploads). */
|
|
17
|
+
export const HOOK_BODY_MS = 30_000;
|
|
18
|
+
/** A refusal whose request is cut, not read: answered, then its socket closed (server.ts). */
|
|
19
|
+
export class HookCut extends ApiError {
|
|
20
|
+
}
|
|
21
|
+
/** The body of `req`, at most `max` bytes, within HOOK_BODY_MS. Past the cap (as declared up front, or as counted while
|
|
22
|
+
* it streams) it is 413 at once, and past the time 408: nothing more is read, and the socket is closed after the
|
|
23
|
+
* answer, never drained. */
|
|
24
|
+
export function readCapped(req, max, ms = HOOK_BODY_MS) {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
const cut = (error) => {
|
|
27
|
+
clearTimeout(timer);
|
|
28
|
+
req.off("data", onData).off("end", onEnd).off("error", onError);
|
|
29
|
+
req.pause();
|
|
30
|
+
reject(error);
|
|
31
|
+
};
|
|
32
|
+
const tooLarge = () => cut(new HookCut("payload_too_large", `the body is over ${max} bytes`, { details: { limit: "max_body_bytes" } }, { connection: "close" }));
|
|
33
|
+
const declared = Number(req.headers["content-length"]);
|
|
34
|
+
const chunks = [];
|
|
35
|
+
let size = 0;
|
|
36
|
+
const onData = (chunk) => {
|
|
37
|
+
size += chunk.length;
|
|
38
|
+
if (size > max)
|
|
39
|
+
return tooLarge();
|
|
40
|
+
chunks.push(chunk);
|
|
41
|
+
};
|
|
42
|
+
const onEnd = () => (clearTimeout(timer), resolve(Buffer.concat(chunks)));
|
|
43
|
+
const onError = (error) => (clearTimeout(timer), reject(error));
|
|
44
|
+
const timer = setTimeout(() => cut(new HookCut("request_timeout", `the body did not arrive within ${ms / 1000} s`, {}, { connection: "close" })), ms);
|
|
45
|
+
if (Number.isFinite(declared) && declared > max)
|
|
46
|
+
return tooLarge();
|
|
47
|
+
req.on("data", onData).on("end", onEnd).on("error", onError);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/** The one answer to every refused request. */
|
|
51
|
+
const REFUSED = "this route needs a request signed by the webhook trigger's secret";
|
|
52
|
+
/** The request to /v2/hooks/{segment}: its answer, or the one 401 (thrown). */
|
|
53
|
+
export async function receivePush(deps, req, segment) {
|
|
54
|
+
const route = `/v2/hooks/${segment}`;
|
|
55
|
+
const refuse = (reason) => (deps.refused(route, reason), new ApiError("unauthenticated", REFUSED));
|
|
56
|
+
let name;
|
|
57
|
+
try {
|
|
58
|
+
name = decodeURIComponent(segment);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
throw refuse("malformed_path");
|
|
62
|
+
}
|
|
63
|
+
// A source's own path (its settings are the server's), else a trigger's, checked by that trigger's own source (its
|
|
64
|
+
// settings are a trigger's). A path that names no such trigger is checked as the first such source's, against the
|
|
65
|
+
// decoy: the same work and the same 401, so no id is learned by asking.
|
|
66
|
+
const own = deps.adapters.find((a) => a.id === name && a.push && a.settings?.scope === "server");
|
|
67
|
+
const named = own || !ID.test(name) ? undefined : await deps.hooked(name);
|
|
68
|
+
const trigger = named && deps.adapters.find((a) => a.id === named.kind && a.push && a.settings?.scope === "trigger");
|
|
69
|
+
const adapter = own ?? trigger ?? deps.adapters.find((a) => a.push && a.settings?.scope === "trigger");
|
|
70
|
+
const push = adapter?.push;
|
|
71
|
+
if (!adapter || !push)
|
|
72
|
+
throw refuse("no_hook");
|
|
73
|
+
const now = Date.now();
|
|
74
|
+
const early = push.headers?.(req.headers, now);
|
|
75
|
+
if (early)
|
|
76
|
+
throw refuse(early);
|
|
77
|
+
const body = await readCapped(req, push.maxBodyBytes, deps.bodyMs);
|
|
78
|
+
const source = trigger ? named : undefined;
|
|
79
|
+
const pathTrigger = source ? name : undefined;
|
|
80
|
+
const key = own ? deps.setting(adapter.id, "server", push.key) : pathTrigger && deps.setting(adapter.id, pathTrigger, push.key);
|
|
81
|
+
// Checked against the clock now the body has arrived: a timestamp at the tolerance's edge never passes by a slow body.
|
|
82
|
+
const refusal = push.verify(key ?? DECOY, req.headers, body, Date.now(), key ? source : undefined);
|
|
83
|
+
if (!key || refusal)
|
|
84
|
+
throw refuse(key ? refusal : own ? "no_key" : "no_webhook_trigger");
|
|
85
|
+
const scope = own ? "server" : pathTrigger;
|
|
86
|
+
const ctx = {
|
|
87
|
+
setting: (field) => deps.setting(adapter.id, scope, field),
|
|
88
|
+
notice: async (event, doc) => deps.notice?.(adapter.id, event, doc),
|
|
89
|
+
say: deps.say,
|
|
90
|
+
};
|
|
91
|
+
const handshake = await push.handshake?.(req.headers, body, ctx);
|
|
92
|
+
if (handshake)
|
|
93
|
+
return handshake;
|
|
94
|
+
const events = push.parse(req.headers, body, source);
|
|
95
|
+
// Verified, and not an event its trigger takes: answered, so the sender does not send it again, and said once.
|
|
96
|
+
if (!Array.isArray(events)) {
|
|
97
|
+
deps.say({ condition: "hook_ignored", source: adapter.id, route, ...(pathTrigger ? { trigger: pathTrigger } : {}), reason: events.ignored, ...(events.event ? { event: events.event } : {}) });
|
|
98
|
+
if (pathTrigger && events.key !== undefined)
|
|
99
|
+
await deps.ignored?.(pathTrigger, events.key);
|
|
100
|
+
return { status: 200, body: { ok: "ignored" } };
|
|
101
|
+
}
|
|
102
|
+
if (!events.length) {
|
|
103
|
+
deps.say({ condition: "hook_unparsed", source: adapter.id, route });
|
|
104
|
+
return { status: 200, body: { firings: [] } };
|
|
105
|
+
}
|
|
106
|
+
// A trigger's own path: each event is its own firing. One (a webhook's request) is answered as its firing; more, as a
|
|
107
|
+
// server-wide source's are, by the firings they made.
|
|
108
|
+
if (pathTrigger) {
|
|
109
|
+
const fired = [];
|
|
110
|
+
for (const event of events)
|
|
111
|
+
fired.push(await deps.receive(pathTrigger, event.key, event.text, event.attrs));
|
|
112
|
+
if (fired.length > 1)
|
|
113
|
+
return { status: fired.some((f) => f.created) ? 202 : 200, body: { firings: fired.map((f) => f.firing) } };
|
|
114
|
+
const { created, firing } = fired[0];
|
|
115
|
+
return { status: created ? 202 : 200, body: firing, ...(created ? {} : { headers: { "idempotent-replayed": "true" } }) };
|
|
116
|
+
}
|
|
117
|
+
// A server-wide source whose triggers choose their own events: each event fires every trigger that takes it, each its
|
|
118
|
+
// own firing under its own key; every other trigger keeps the event's key for its day (as an ignored request's), so
|
|
119
|
+
// the same request relabeled is a duplicate there too. One no trigger takes is answered ignored, and said. When a trigger
|
|
120
|
+
// that takes it holds too many firings due, the request is refused (429, Retry-After) though the rest recorded theirs:
|
|
121
|
+
// the sender's retry records it there once it has room, and is the others' duplicate.
|
|
122
|
+
if (adapter.takes) {
|
|
123
|
+
const fired = [];
|
|
124
|
+
let refused;
|
|
125
|
+
let taken = false;
|
|
126
|
+
for (const event of events) {
|
|
127
|
+
for (const { id, source } of (await deps.listening?.(adapter.id)) ?? []) {
|
|
128
|
+
if (adapter.takes(source, event) !== undefined) {
|
|
129
|
+
await deps.ignored?.(id, event.key);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
taken = true;
|
|
133
|
+
try {
|
|
134
|
+
fired.push(await deps.receive(id, event.key, event.text, event.attrs));
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
if (!(error instanceof ApiError) || error.code !== "rate_limited")
|
|
138
|
+
throw error;
|
|
139
|
+
refused = error;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (!taken) {
|
|
144
|
+
deps.say({ condition: "hook_ignored", source: adapter.id, route, reason: "no_trigger_takes_it", ...(events[0]?.event ? { event: events[0].event } : {}) });
|
|
145
|
+
return { status: 200, body: { ok: "ignored" } };
|
|
146
|
+
}
|
|
147
|
+
if (refused)
|
|
148
|
+
throw refused;
|
|
149
|
+
return { status: fired.some((f) => f.created) ? 202 : 200, body: { firings: fired.map((f) => f.firing) } };
|
|
150
|
+
}
|
|
151
|
+
// A server-wide source's: each event fires the one trigger that listens on its scope (a scope belongs to one trigger:
|
|
152
|
+
// triggers.ts scope_taken). One no trigger takes is said; one more than one does (a file edited by hand) fires none,
|
|
153
|
+
// and is said with their ids, so no event fires twice or reaches whichever came first.
|
|
154
|
+
const fired = [];
|
|
155
|
+
for (const event of events) {
|
|
156
|
+
const ids = event.scope === undefined ? [] : await deps.scoped(adapter.id, event.scope);
|
|
157
|
+
if (ids.length === 1)
|
|
158
|
+
fired.push(await deps.receive(ids[0], event.key, event.text, event.attrs));
|
|
159
|
+
else if (!ids.length)
|
|
160
|
+
deps.say({ condition: "hook_no_trigger", source: adapter.id, route, scope: String(event.scope ?? "") });
|
|
161
|
+
else
|
|
162
|
+
deps.say({ condition: "hook_scope_ambiguous", source: adapter.id, route, scope: String(event.scope), triggers: ids.join(",") });
|
|
163
|
+
}
|
|
164
|
+
return { status: fired.some((f) => f.created) ? 202 : 200, body: { firings: fired.map((f) => f.firing) } };
|
|
165
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** What every deny tells the model, plainly: the call never left, so nothing was charged for it. */
|
|
2
|
+
export declare const NOT_RUN = "It was not run: nothing was sent and nothing was charged.";
|
|
3
|
+
/** What a refusal says instead when an earlier attempt of the call may have been sent: an approved call cut mid-flight,
|
|
4
|
+
* or a replay-safe call the kernel runs again after a crash. Never a claim that nothing was charged. */
|
|
5
|
+
export declare const RAN_UNKNOWN = "It had started before the deny, and whether it took effect is not known.";
|
|
6
|
+
/** Where a permission was set (permissionFrom's `from`): the agent's own tool settings, the server's, or the default; or
|
|
7
|
+
* "unattended": an ask the agent's approvals "never" allowed. */
|
|
8
|
+
export type SettingFrom = "agent" | "server" | "default" | "unattended";
|
|
9
|
+
/** Where a deny can come from: a setting in a layer, or the default. Never "unattended", which only ever allows. */
|
|
10
|
+
export type DenyFrom = Exclude<SettingFrom, "unattended">;
|
|
11
|
+
/** Where a deny was set, in words: the place a person changes it. */
|
|
12
|
+
export declare const denyPlace: (from?: SettingFrom) => string;
|
|
13
|
+
/** The refusal of a call whose tool is set to deny; of one held to another tool's setting (`heldTo`, a shell tool's
|
|
14
|
+
* bash), naming the setting to change and where it was set (`from`: this agent's settings or this server's). */
|
|
15
|
+
export declare const deniedText: (tool: string, heldTo?: string, from?: SettingFrom, ran?: "no" | "unknown") => string;
|
|
16
|
+
/** A workflow model node's tool set to ask: a model node cannot wait for a person's approval (the gate parks no workflow
|
|
17
|
+
* call), so the call is refused unrun and the model reads why (tool-gate.ts RunGate, on main and on the runner). */
|
|
18
|
+
export declare const modelNodeAskText: (tool: string) => string;
|
|
19
|
+
/** A workflow call node's tool set to ask: a call node cannot wait for a person's approval, so it is refused unrun
|
|
20
|
+
* (main's per-run process and the runner's workflow spec, the same words). */
|
|
21
|
+
export declare const callNodeAskText: (tool: string) => string;
|
|
22
|
+
/** A call a person denied, with their reason when they gave one. */
|
|
23
|
+
export declare const refusedText: (tool: string, note?: string, ran?: "no" | "unknown") => string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// The words a model reads when a call it asked for is refused: one copy, shared by serve's tool gate (tool-gate.ts,
|
|
2
|
+
// which re-exports them) and the runner's loops (a denied ask's refusal), so a change of words lands in one place.
|
|
3
|
+
/** What every deny tells the model, plainly: the call never left, so nothing was charged for it. */
|
|
4
|
+
export const NOT_RUN = "It was not run: nothing was sent and nothing was charged.";
|
|
5
|
+
/** What a refusal says instead when an earlier attempt of the call may have been sent: an approved call cut mid-flight,
|
|
6
|
+
* or a replay-safe call the kernel runs again after a crash. Never a claim that nothing was charged. */
|
|
7
|
+
export const RAN_UNKNOWN = "It had started before the deny, and whether it took effect is not known.";
|
|
8
|
+
/** Where a deny was set, in words: the place a person changes it. */
|
|
9
|
+
export const denyPlace = (from = "server") => (from === "agent" ? "for this agent" : from === "default" ? "by default" : "on this server");
|
|
10
|
+
/** The refusal of a call whose tool is set to deny; of one held to another tool's setting (`heldTo`, a shell tool's
|
|
11
|
+
* bash), naming the setting to change and where it was set (`from`: this agent's settings or this server's). */
|
|
12
|
+
export const deniedText = (tool, heldTo, from = "server", ran = "no") => {
|
|
13
|
+
// `ran`: "unknown" for a call an earlier attempt of which may have been sent (an approved call cut mid-flight, or a
|
|
14
|
+
// replay-safe call run again after a crash): the words never claim it wasn't.
|
|
15
|
+
const what = ran === "no" ? NOT_RUN : RAN_UNKNOWN;
|
|
16
|
+
return heldTo && heldTo !== tool ? `Permission denied: ${tool} follows ${heldTo}'s setting, which is deny ${denyPlace(from)}. ${what} Don't retry it.` : `Permission denied: ${tool} is set to deny ${denyPlace(from)}. ${what} Don't retry it.`;
|
|
17
|
+
};
|
|
18
|
+
/** A workflow model node's tool set to ask: a model node cannot wait for a person's approval (the gate parks no workflow
|
|
19
|
+
* call), so the call is refused unrun and the model reads why (tool-gate.ts RunGate, on main and on the runner). */
|
|
20
|
+
export const modelNodeAskText = (tool) => `This ${tool} call needs a person's approval, which a workflow's model node cannot wait for; it was not run.`;
|
|
21
|
+
/** A workflow call node's tool set to ask: a call node cannot wait for a person's approval, so it is refused unrun
|
|
22
|
+
* (main's per-run process and the runner's workflow spec, the same words). */
|
|
23
|
+
export const callNodeAskText = (tool) => `This ${tool} call needs a person's approval, which a workflow's call node cannot wait for; it was not run.`;
|
|
24
|
+
/** A call a person denied, with their reason when they gave one. */
|
|
25
|
+
export const refusedText = (tool, note, ran = "no") => `The user denied this ${tool} call. ${ran === "no" ? NOT_RUN : RAN_UNKNOWN}${note ? ` Reason: ${note}` : ""}`;
|
package/dist/request-start.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Models } from "@earendil-works/pi-ai";
|
|
2
|
-
import type
|
|
2
|
+
import { type DurableRun } from "@parcha/pi-durable-disk";
|
|
3
3
|
import { type RefusalFigures } from "./cap.js";
|
|
4
4
|
/** Whether the run in `root` (its directory) was cancelled: the mark serve's cancel writes there first. */
|
|
5
5
|
export declare const cancelledIn: (root: string) => () => boolean;
|
|
@@ -19,4 +19,9 @@ export declare function markRequests<M extends Models>(models: M, cancelled?: ()
|
|
|
19
19
|
models: M;
|
|
20
20
|
open(run: DurableRun): void;
|
|
21
21
|
refused(figures?: RefusalFigures): Promise<void>;
|
|
22
|
+
wrapUp(data: {
|
|
23
|
+
capUsd: number;
|
|
24
|
+
leftUsd: number;
|
|
25
|
+
words: string;
|
|
26
|
+
}): void;
|
|
22
27
|
}>;
|
package/dist/request-start.js
CHANGED
|
@@ -16,13 +16,16 @@
|
|
|
16
16
|
// (cap.ts stoppedFigure: what it streamed and an allowance, never more than its worst case). The timeline does not read it, so the run's shown cost
|
|
17
17
|
// is unknown as before. A request the cap refused gets a start mark of its own (`capRefused`), written before pi writes
|
|
18
18
|
// its error entry, so that entry answers its own mark and never stands for an earlier request a stop or a crash cut.
|
|
19
|
+
import { randomUUID } from "node:crypto";
|
|
19
20
|
import { existsSync } from "node:fs";
|
|
20
21
|
import { join } from "node:path";
|
|
21
22
|
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
22
23
|
import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
23
|
-
import { REQUEST_COST, REQUEST_ENDED, REQUEST_REFUSED, REQUEST_STARTED } from "@parcha/pi-durable-agent/timeline";
|
|
24
|
-
import {
|
|
24
|
+
import { CAP_WRAPUP, REQUEST_COST, REQUEST_ENDED, REQUEST_REFUSED, REQUEST_STARTED } from "@parcha/pi-durable-agent/timeline";
|
|
25
|
+
import { BARRIER, syncNow } from "@parcha/pi-durable-disk";
|
|
26
|
+
import { anyAttemptLost, ATTEMPTS, attemptLost, BOUND_FIELD, BOUND_USD, CAP_REFUSED_FIELD, END_NOT_WRITTEN, CLAMP, HELD_FIELD, HELD_USD, MARK_NOT_WRITTEN, markResponseBegan, piEnded, refusalFields, sideRequests, STOPPED_USD } from "./cap.js";
|
|
25
27
|
import { RUN_CANCELLED } from "./files.js";
|
|
28
|
+
import { noStoreToSync } from "./paid-calls.js";
|
|
26
29
|
import { isConnectCode, isGatewayTimeout } from "@parcha/agentrun-kernel";
|
|
27
30
|
/** Whether the run in `root` (its directory) was cancelled: the mark serve's cancel writes there first. */
|
|
28
31
|
export const cancelledIn = (root) => () => existsSync(join(root, RUN_CANCELLED));
|
|
@@ -48,6 +51,24 @@ export async function markRequests(models, cancelled = () => false, { holdMarkWa
|
|
|
48
51
|
const run = await opened;
|
|
49
52
|
await run.harness.commit(async (tx) => void (await tx.appendEntry(ROOT_CONVERSATION_ID, { kind, data })), BACKGROUND_CONTEXT);
|
|
50
53
|
};
|
|
54
|
+
/** A request's start mark, then the run journal's barrier (pi-durable-disk barriers.ts, modelRequestStarted): the mark,
|
|
55
|
+
* with the hold and bound a crash is read at, is on disk before the request is sent. A failure fails the request
|
|
56
|
+
* unsent (MARK_NOT_WRITTEN): with no store to sync, no mark is written (paid-calls.ts noStoreToSync); a sync that fails
|
|
57
|
+
* after the mark is answered by `unsent`, its end mark (best effort), so the store never holds a start that did not
|
|
58
|
+
* leave. */
|
|
59
|
+
const markStarted = async (data, unsent) => {
|
|
60
|
+
const run = await opened;
|
|
61
|
+
if (noStoreToSync(run.store))
|
|
62
|
+
throw new Error("the run's store is not open, so its start mark cannot be made durable");
|
|
63
|
+
await mark(REQUEST_STARTED, data);
|
|
64
|
+
try {
|
|
65
|
+
await syncNow(run.store, BARRIER.modelRequestStarted);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
await mark(REQUEST_ENDED, unsent).catch(() => undefined);
|
|
69
|
+
throw new Error(`written, but it could not be made durable: ${reason(error)}`);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
51
72
|
const failed = (model, why) => ({
|
|
52
73
|
role: "assistant", content: [], api: model.api, provider: model.provider, model: model.id, stopReason: "error", timestamp: Date.now(),
|
|
53
74
|
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 } },
|
|
@@ -134,12 +155,18 @@ export async function markRequests(models, cancelled = () => false, { holdMarkWa
|
|
|
134
155
|
const figure = typeof stopped === "function" ? stopped(message) : undefined;
|
|
135
156
|
return typeof figure === "number" && Number.isFinite(figure) ? { [HELD_FIELD]: figure } : heldOf(options);
|
|
136
157
|
};
|
|
137
|
-
/** A
|
|
138
|
-
*
|
|
158
|
+
/** A request's bound (BOUND_FIELD, when above 0: the run's cost serves it while the request is in flight), as its
|
|
159
|
+
* start mark keeps it. */
|
|
160
|
+
const boundOf = (options) => {
|
|
161
|
+
const bound = options?.[BOUND_USD];
|
|
162
|
+
return typeof bound === "number" && Number.isFinite(bound) && bound > 0 ? { [BOUND_FIELD]: bound } : {};
|
|
163
|
+
};
|
|
164
|
+
/** A start mark's figures: what the cap held it at, its bound, and what the cap limited its output to when it did
|
|
165
|
+
* (CLAMP), so a reply cut short there says so on the run's timeline. */
|
|
139
166
|
const startOf = (options) => {
|
|
140
167
|
const clamp = options?.[CLAMP];
|
|
141
168
|
const kept = clamp && typeof clamp.tokens === "number" && typeof clamp.leftUsd === "number" && typeof clamp.capUsd === "number" ? { clamp: { tokens: clamp.tokens, leftUsd: clamp.leftUsd, capUsd: clamp.capUsd } } : {};
|
|
142
|
-
return { ...heldOf(options), ...kept };
|
|
169
|
+
return { ...heldOf(options), ...boundOf(options), ...kept };
|
|
143
170
|
};
|
|
144
171
|
/** A cancelled run's request, never sent. It waits for the cancel to reach the run (the request's abort), and then ends
|
|
145
172
|
* as aborted, as a request the cancel cut does: the turn, or a workflow's node, stops, never failing on the refusal.
|
|
@@ -170,7 +197,7 @@ export async function markRequests(models, cancelled = () => false, { holdMarkWa
|
|
|
170
197
|
if (cancelled())
|
|
171
198
|
return refused();
|
|
172
199
|
try {
|
|
173
|
-
await
|
|
200
|
+
await markStarted(startOf(options), { unsent: true });
|
|
174
201
|
}
|
|
175
202
|
catch (error) {
|
|
176
203
|
const message = failed(model, `${MARK_NOT_WRITTEN} (${reason(error)})`);
|
|
@@ -284,13 +311,15 @@ export async function markRequests(models, cancelled = () => false, { holdMarkWa
|
|
|
284
311
|
};
|
|
285
312
|
const completeSimple = async (model, context, options) => {
|
|
286
313
|
const side = sideRequests.get(context);
|
|
287
|
-
|
|
314
|
+
// Its label, and an id of its own: such requests run inside tool calls, which pi runs side by side, so its marks name
|
|
315
|
+
// it (bounds.ts closes its bound by it).
|
|
316
|
+
const COMPACTION = { request: side?.label ?? "compaction", requestId: randomUUID() };
|
|
288
317
|
const what = side ? `${side.label} request` : "summary request";
|
|
289
318
|
// A cancelled run sends no summary either; pi writes no entry for a failed summary, so nothing needs marking.
|
|
290
319
|
if (cancelled())
|
|
291
320
|
return refuse(model, what, options?.signal, false);
|
|
292
321
|
try {
|
|
293
|
-
await
|
|
322
|
+
await markStarted({ ...COMPACTION, ...heldOf(options), ...boundOf(options) }, { ...COMPACTION, unsent: true });
|
|
294
323
|
}
|
|
295
324
|
catch (error) {
|
|
296
325
|
return failed(model, `${MARK_NOT_WRITTEN} (${reason(error)})`);
|
|
@@ -345,6 +374,8 @@ export async function markRequests(models, cancelled = () => false, { holdMarkWa
|
|
|
345
374
|
});
|
|
346
375
|
// The start mark of a generation request the cap refused (capModels), which never left: pi's error entry answers it. A
|
|
347
376
|
// refusal for room keeps its figures on it (what the cap counted as taken, and the least the request needed).
|
|
348
|
-
const refused = (figures) => mark(REQUEST_STARTED, { [CAP_REFUSED_FIELD]: true, ...(figures
|
|
349
|
-
|
|
377
|
+
const refused = (figures) => mark(REQUEST_STARTED, { [CAP_REFUSED_FIELD]: true, ...refusalFields(figures) });
|
|
378
|
+
// The wrap-up's row (cap.ts capModels' `wrapUp`): what the run's model was told near its cap, on the root.
|
|
379
|
+
const wrapUp = (data) => void mark(CAP_WRAPUP, data).catch(() => undefined);
|
|
380
|
+
return { models: proxy, open, refused, wrapUp };
|
|
350
381
|
}
|
package/dist/result.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
import type { ToolExecutionResult } from "@earendil-works/pi-durable";
|
|
2
|
-
/**
|
|
3
|
-
export
|
|
2
|
+
/** A block of a result for the model: text, or an image as pi-ai's `ImageContent`. */
|
|
3
|
+
export type ModelBlock = {
|
|
4
|
+
readonly type: "text";
|
|
5
|
+
readonly text: string;
|
|
6
|
+
} | {
|
|
7
|
+
readonly type: "image";
|
|
8
|
+
readonly data: string;
|
|
9
|
+
readonly mimeType: string;
|
|
10
|
+
};
|
|
11
|
+
/** `blocks` under `output`, with any other fields of the result. */
|
|
12
|
+
export declare const forModelBlocks: (blocks: readonly ModelBlock[], fields?: Omit<ToolExecutionResult, "output">) => ToolExecutionResult;
|
|
13
|
+
/** `text` under `output`, with any other fields of the result. */
|
|
14
|
+
export declare const forModel: (text: string, fields?: Omit<ToolExecutionResult, "output">) => ToolExecutionResult;
|
package/dist/result.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/** `
|
|
2
|
-
export const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
1
|
+
/** `blocks` under `output`, with any other fields of the result. */
|
|
2
|
+
export const forModelBlocks = (blocks, fields = {}) => ({ ...fields, output: blocks });
|
|
3
|
+
/** `text` under `output`, with any other fields of the result. */
|
|
4
|
+
export const forModel = (text, fields = {}) => forModelBlocks([{ type: "text", text }], fields);
|