@parcha/agentrun-serve 0.1.0-beta.31 → 0.1.0-beta.33
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 +459 -0
- package/NOTICE +18 -0
- package/README.md +941 -263
- package/dist/adapter-facts.d.ts +3 -0
- package/dist/adapter-facts.js +5 -0
- package/dist/adapters.d.ts +64 -143
- package/dist/adapters.js +153 -384
- package/dist/agents-store.d.ts +146 -0
- package/dist/agents-store.js +359 -0
- package/dist/agents.d.ts +4 -2
- package/dist/agents.js +37 -17
- package/dist/api-only.d.ts +14 -0
- package/dist/api-only.js +33 -0
- 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.js +28 -9
- package/dist/box-egress-vm.d.ts +2 -9
- package/dist/box-egress-vm.js +20 -16
- package/dist/box-egress.d.ts +15 -9
- package/dist/box-egress.js +26 -29
- package/dist/box-paths.d.ts +82 -0
- package/dist/box-paths.js +160 -0
- package/dist/box-relay-vm.js +28 -1
- package/dist/box-relay.d.ts +1 -10
- package/dist/box-relay.js +1 -21
- package/dist/box-settings.d.ts +46 -0
- package/dist/box-settings.js +107 -0
- package/dist/boxes.d.ts +17 -2
- package/dist/boxes.js +37 -3
- 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 +277 -21
- package/dist/browser-live.d.ts +124 -0
- package/dist/browser-live.js +324 -0
- package/dist/browser-person.d.ts +166 -0
- package/dist/browser-person.js +767 -0
- package/dist/budget.d.ts +76 -0
- package/dist/budget.js +204 -0
- package/dist/cap.d.ts +267 -64
- package/dist/cap.js +587 -199
- package/dist/cli.js +220 -21
- 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-Dn0ngwG9.js +535 -0
- package/dist/console/assets/index-DvW6Aled.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/daytona-api.d.ts +0 -11
- package/dist/daytona-api.js +1 -82
- 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 +28 -1
- package/dist/decisions.js +63 -6
- package/dist/docker-host-addresses.d.ts +37 -0
- package/dist/docker-host-addresses.js +110 -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 -43
- package/dist/files.js +8 -136
- 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 +9 -42
- package/dist/grade.js +42 -228
- 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-install.d.ts +143 -0
- package/dist/harness-install.js +454 -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 +11 -31
- package/dist/harness.js +30 -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 +4 -3
- package/dist/host-check.js +5 -4
- 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 +249 -224
- 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/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 +22 -9
- package/dist/learn/grade.js +95 -49
- 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 +70 -41
- package/dist/learn/secrets.d.ts +16 -7
- package/dist/learn/secrets.js +80 -17
- package/dist/learn/seed-check.d.ts +74 -0
- package/dist/learn/seed-check.js +103 -0
- package/dist/learn/skills.d.ts +5 -1
- package/dist/learn/skills.js +5 -4
- package/dist/learned-workflow.d.ts +15 -4
- package/dist/learned-workflow.js +13 -6
- package/dist/learning-routes.d.ts +56 -46
- package/dist/learning-routes.js +350 -553
- package/dist/learning-run.d.ts +8 -228
- package/dist/learning-run.js +26 -713
- package/dist/learning-words.d.ts +3 -5
- package/dist/learning-words.js +3 -5
- package/dist/learning.d.ts +177 -112
- package/dist/learning.js +289 -380
- 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 +45 -15
- package/dist/mcp-gateway.js +140 -53
- package/dist/mcp-meta.d.ts +3 -0
- package/dist/mcp-meta.js +14 -2
- 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 +180 -50
- package/dist/mcp-servers.js +284 -321
- 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 +921 -110
- package/dist/owner.d.ts +46 -10
- package/dist/owner.js +123 -43
- package/dist/page.d.ts +10 -0
- package/dist/page.js +29 -4
- package/dist/paid-calls.d.ts +71 -2
- package/dist/paid-calls.js +127 -6
- package/dist/pause.d.ts +0 -2
- package/dist/pause.js +1 -8
- package/dist/pdf-pages.d.ts +16 -14
- package/dist/pdf-pages.js +88 -58
- package/dist/place.d.ts +15 -18
- package/dist/place.js +25 -25
- package/dist/port-models.d.ts +53 -0
- package/dist/port-models.js +93 -0
- package/dist/print.d.ts +2 -1
- package/dist/print.js +4 -2
- 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/result.d.ts +13 -2
- package/dist/result.js +4 -5
- 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 +62 -0
- package/dist/run-db.js +151 -0
- package/dist/run-files.d.ts +31 -0
- package/dist/run-files.js +125 -0
- package/dist/run-launch.d.ts +72 -0
- package/dist/run-launch.js +108 -0
- package/dist/run-learning-served.d.ts +81 -0
- package/dist/run-learning-served.js +25 -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-secrets.d.ts +33 -0
- package/dist/run-secrets.js +53 -0
- package/dist/run-timeline-served.d.ts +13 -0
- package/dist/run-timeline-served.js +72 -0
- package/dist/run-view.d.ts +432 -0
- package/dist/run-view.js +602 -0
- package/dist/runnable.d.ts +30 -5
- package/dist/runnable.js +149 -72
- package/dist/runner/adapter-loop.d.ts +243 -0
- package/dist/runner/adapter-loop.js +1657 -0
- package/dist/runner/adapter-run-spec.d.ts +224 -0
- package/dist/runner/adapter-run-spec.js +538 -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 +103 -0
- package/dist/runner/adapters/pi.js +263 -0
- package/dist/runner/beside.d.ts +12 -0
- package/dist/runner/beside.js +41 -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 +385 -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 +217 -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 +112 -0
- package/dist/runner/loop-contract.d.ts +154 -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 +96 -0
- package/dist/runner/main.js +311 -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 +202 -0
- package/dist/runner/pi-stop.d.ts +6 -0
- package/dist/runner/pi-stop.js +8 -0
- package/dist/runner/redact.d.ts +32 -0
- package/dist/runner/redact.js +60 -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 +797 -0
- package/dist/runs-over-store.d.ts +203 -0
- package/dist/runs-over-store.js +407 -0
- package/dist/seal-key.d.ts +69 -0
- package/dist/seal-key.js +329 -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 +171 -0
- package/dist/secret-writes.d.ts +147 -0
- package/dist/secret-writes.js +144 -0
- package/dist/secrets.d.ts +7 -8
- package/dist/secrets.js +24 -5
- 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 +76 -0
- package/dist/server.d.ts +148 -75
- package/dist/server.js +1740 -605
- 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 +44 -0
- package/dist/store/open.js +50 -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 +123 -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 +1352 -0
- package/dist/store/sqlite/worker.d.ts +78 -0
- package/dist/store/sqlite/worker.js +242 -0
- package/dist/store/store.d.ts +1256 -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 +46 -0
- package/dist/store-reads/journal.js +196 -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 +338 -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 +166 -35
- package/dist/tool-gate.js +411 -91
- package/dist/tool-keys-store.d.ts +110 -0
- package/dist/tool-keys-store.js +291 -0
- package/dist/tool-keys.d.ts +29 -15
- package/dist/tool-keys.js +27 -6
- package/dist/tool-plane.d.ts +113 -27
- package/dist/tool-plane.js +229 -76
- 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 +341 -62
- 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 +116 -0
- package/dist/trigger-secrets-shown.d.ts +66 -0
- package/dist/trigger-secrets-shown.js +81 -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 +53 -18
- 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 +87 -0
- package/dist/workspace/computer-deps.js +160 -0
- package/dist/workspace/computer-for-claim.d.ts +119 -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 +16 -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 +0 -17
- package/dist/workspace.js +3 -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 +10 -27
- package/package.json +37 -22
- 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/app.d.ts +0 -7
- package/dist/app.js +0 -399
- package/dist/console/assets/index-CnJBf7Lc.js +0 -486
- package/dist/console/assets/index-DUHbWcIP.css +0 -1
- package/dist/content-filter.d.ts +0 -7
- package/dist/content-filter.js +0 -23
- package/dist/harness-app.d.ts +0 -40
- package/dist/harness-app.js +0 -717
- package/dist/request-start.d.ts +0 -22
- package/dist/request-start.js +0 -350
- package/dist/run-box.d.ts +0 -186
- package/dist/run-box.js +0 -600
- package/dist/runs.d.ts +0 -1069
- package/dist/runs.js +0 -3073
- package/dist/trigger-secrets.d.ts +0 -32
- package/dist/trigger-secrets.js +0 -143
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import type { MessageOrigin } from "@parcha/pi-durable-agent/timeline";
|
|
2
|
+
export declare const KINDS: {
|
|
3
|
+
/** A tool call about to run: written before it runs (and before the flush that precedes a side effect). */
|
|
4
|
+
readonly callStart: "agentrun.call.start";
|
|
5
|
+
/** How it ended: written after it ran, or by recovery for a start with no end (replay-safe reruns and ends done;
|
|
6
|
+
* any other ends interrupted, and the model is told). */
|
|
7
|
+
readonly callEnd: "agentrun.call.end";
|
|
8
|
+
/** A message: the person's, a steer, or the model's. */
|
|
9
|
+
readonly message: "agentrun.message";
|
|
10
|
+
/** A pi input the person did not type (a trigger's message): pi's user entry under the host's kind, its `data.origin`
|
|
11
|
+
* the Timeline's attribution (pi-durable-agent's originMatcher reads a host's user entry's own origin). The model
|
|
12
|
+
* reads it as any message. */
|
|
13
|
+
readonly input: "agentrun.input";
|
|
14
|
+
/** A tool call the gate asked a person about: the run parks on it. */
|
|
15
|
+
readonly ask: "agentrun.ask";
|
|
16
|
+
/** The person's answer to an ask, written by the commit that takes the approve or deny row. */
|
|
17
|
+
readonly answer: "agentrun.answer";
|
|
18
|
+
/** On the root conversation: a CLI adapter's session key and the conversation that holds its resume log. */
|
|
19
|
+
readonly sessionKey: "agentrun.session.key";
|
|
20
|
+
/** The loop's end commit: how the run ended (ended, stopped, failed). Its commit carries the run row's patch and any
|
|
21
|
+
* command it takes; neither a call nor a message, so the reader passes over it. */
|
|
22
|
+
readonly end: "agentrun.end";
|
|
23
|
+
/** A run parked at its cap: the cap refused a request for room (a raise would let it fit). Its data is the pending
|
|
24
|
+
* budget the run waits on a raise with; its commit carries the run parked, in the cap's words. Neither a call nor a
|
|
25
|
+
* message, so the reader passes over it. */
|
|
26
|
+
readonly budget: "agentrun.budget";
|
|
27
|
+
/** A raise of the run's cap, taken: the cap it raised to, and the raise rows its commit takes (the kernel cap's
|
|
28
|
+
* takeRaises, all a claim found at once). A budget entry with a raise entry after it is answered. Neither a call nor a
|
|
29
|
+
* message, so the reader passes over it. */
|
|
30
|
+
readonly raise: "agentrun.raise";
|
|
31
|
+
/** A workflow run paused by its person (a `pause` row): its commit takes the pause rows and carries the run parked in
|
|
32
|
+
* the pause's words; a step a pause held was never sent. A pause entry with no resume entry after it is in force.
|
|
33
|
+
* Neither a call nor a message, so the reader passes over it. */
|
|
34
|
+
readonly pause: "agentrun.pause";
|
|
35
|
+
/** The resume of a paused workflow run (a `resume` row), taken: the workflow goes on from its journal. Neither a call nor
|
|
36
|
+
* a message, so the reader passes over it. */
|
|
37
|
+
readonly resume: "agentrun.resume";
|
|
38
|
+
/** A CLI run's end-of-run turn (the loop's record): its prompt (`role: "person"`) and its answer (`role: "model"`, the
|
|
39
|
+
* text in `model` as pi's answer carries it), the entry and the answer of the submission its request id names, the
|
|
40
|
+
* same submission pi's adapter writes, so the step reads both alike. Neither a call nor a message: the reader passes
|
|
41
|
+
* over it, and the turn is never on the run's visible record. */
|
|
42
|
+
readonly endOfRunTurn: "agentrun.end-of-run.turn";
|
|
43
|
+
/** A learning run's grade: the verdict and what it spent, written before its merge (a resumed run never asks again). */
|
|
44
|
+
readonly learningGraded: "agentrun.learning.graded";
|
|
45
|
+
/** A learning run's merge: the new main and its commit, with the run's end. */
|
|
46
|
+
readonly learningMerged: "agentrun.learning.merged";
|
|
47
|
+
/** Why a learning run merged nothing, with the run's end. */
|
|
48
|
+
readonly learningDropped: "agentrun.learning.dropped";
|
|
49
|
+
/** The learning folder could not be reached: the run parks and tries again after a backoff. */
|
|
50
|
+
readonly learningUnavailable: "agentrun.learning.unavailable";
|
|
51
|
+
/** A browser hand-over (pi-browser's browser_request_handoff), on the root. The run's browser host commits the ask, the
|
|
52
|
+
* whole of it (HandoverAsked); its answer is an entry too (HandoverAnswered): the person's (a browser_hand_back row
|
|
53
|
+
* the loop applies, taking the row in that commit), or the ask's expiry. The first answer for an ask is its answer. */
|
|
54
|
+
readonly handover: "agent.handover";
|
|
55
|
+
/** A run waiting on the person: ask_person ended its turn. Its data is the ask_person call's id; its commit carries the
|
|
56
|
+
* run parked. A person's message after it answers it. Neither a call nor a message, so the reader passes over it.
|
|
57
|
+
* `inClaim: true` with `at` (ms): the run waits for the answer in its claim instead (adapter-loop waitInClaim), from
|
|
58
|
+
* `at`, its commit carrying the row's ASK_PERSON_WAITING summary; `answered: true` clears that summary. */
|
|
59
|
+
readonly personAsked: "agentrun.person.asked";
|
|
60
|
+
};
|
|
61
|
+
/** The run row's summary while it waits on the person's answer to its question (ask_person), parked or in its claim: the
|
|
62
|
+
* view reads the question from the call, never from here, so the model's text is never copied into the row. The server
|
|
63
|
+
* tells run.needs_input for a run held in its claim by this summary (server.ts readEnds). */
|
|
64
|
+
export declare const ASK_PERSON_WAITING = "Waiting for your reply";
|
|
65
|
+
/** The run row's summary while its agent's browser hand-over (browser_request_handoff) waits on the person, its claim
|
|
66
|
+
* held: set by the ask's waiting entry's commit, cleared by its answer's (tools.ts, through AdapterRun.rowSummaryOn). */
|
|
67
|
+
export declare const HANDOVER_WAITING = "Waiting for you in the browser";
|
|
68
|
+
/** The summaries of a run held in its claim while it waits on its person: the server tells run.needs_input by them. */
|
|
69
|
+
export declare const HELD_WAITS: ReadonlySet<string>;
|
|
70
|
+
/** How a browser hand-over ended: the person's two answers, or its expiry. */
|
|
71
|
+
export type HandoverOutcome = "done" | "cancelled" | "expired";
|
|
72
|
+
/** A browser hand-over asked (KINDS.handover): the whole ask, as the server's reader needs it, the instruction again as
|
|
73
|
+
* `reason` (the timeline's words). */
|
|
74
|
+
export interface HandoverAsked {
|
|
75
|
+
readonly state: "waiting";
|
|
76
|
+
readonly id: string;
|
|
77
|
+
readonly session: string;
|
|
78
|
+
readonly instruction: string;
|
|
79
|
+
readonly completion_condition: string;
|
|
80
|
+
readonly asked_at: string;
|
|
81
|
+
readonly expires_at: string;
|
|
82
|
+
readonly reason?: string;
|
|
83
|
+
}
|
|
84
|
+
/** A browser hand-over answered (KINDS.handover): how, and when: the person's own time (their row's), or the expiry's
|
|
85
|
+
* when it lapsed first. `reason`: why, for the agent, when the run's cap ended it. */
|
|
86
|
+
export interface HandoverAnswered {
|
|
87
|
+
readonly state: HandoverOutcome;
|
|
88
|
+
readonly id: string;
|
|
89
|
+
readonly session?: string;
|
|
90
|
+
readonly at: string;
|
|
91
|
+
readonly reason?: string;
|
|
92
|
+
}
|
|
93
|
+
/** A raise taken (KINDS.raise): the cap the run goes on under, and the raise rows taken with it. */
|
|
94
|
+
export interface RaiseData {
|
|
95
|
+
readonly capUsd: number;
|
|
96
|
+
readonly takes: readonly number[];
|
|
97
|
+
}
|
|
98
|
+
/** What a run parked at its cap waits on (the kernel cap's parkOf): its cap, what the cap counted as taken, the least the
|
|
99
|
+
* refused request needs, the least cap that sends it and the raise offered, in the run's money units (dollars). */
|
|
100
|
+
export interface BudgetData {
|
|
101
|
+
/** `bound_usd`: the most a cache miss could have added to the refused step (the refusal's boundUsd; 0 when none), the
|
|
102
|
+
* budget card's overshoot bound. */
|
|
103
|
+
readonly pending: {
|
|
104
|
+
readonly kind: "budget";
|
|
105
|
+
readonly cap_usd: number;
|
|
106
|
+
readonly spent_usd: number;
|
|
107
|
+
readonly needs_usd: number;
|
|
108
|
+
readonly least_cap_usd: number;
|
|
109
|
+
readonly suggested_cap_usd: number;
|
|
110
|
+
readonly bound_usd: number;
|
|
111
|
+
};
|
|
112
|
+
/** The cap's words, as the run row's summary says them. */
|
|
113
|
+
readonly words: string;
|
|
114
|
+
}
|
|
115
|
+
export interface CallStartData {
|
|
116
|
+
readonly callId: string;
|
|
117
|
+
readonly tool: string;
|
|
118
|
+
readonly input: unknown;
|
|
119
|
+
/** May run again after a crash (it changes nothing outside the run): the tool registry's own flag. */
|
|
120
|
+
readonly replaySafe: boolean;
|
|
121
|
+
/** When it was written (ms, the loop's clock): the Timeline dates the call's row by it. */
|
|
122
|
+
readonly at?: number;
|
|
123
|
+
}
|
|
124
|
+
export type CallStatus = "done" | "failed" | "refused" | "interrupted";
|
|
125
|
+
export interface CallEndData {
|
|
126
|
+
readonly callId: string;
|
|
127
|
+
readonly status: CallStatus;
|
|
128
|
+
readonly output?: unknown;
|
|
129
|
+
/** When it was written (ms, the loop's clock): the Timeline dates the result's row by it. */
|
|
130
|
+
readonly at?: number;
|
|
131
|
+
}
|
|
132
|
+
/** What a call that already ended answers when it is asked for again (a parked call's resume, a CLI's re-issue of its id):
|
|
133
|
+
* its recorded output; for one a crash cut with none, the kernel's words for an outcome not known (INTERRUPTED_TEXT);
|
|
134
|
+
* else that `tool`'s call ended so. An error unless it ended done. */
|
|
135
|
+
export declare function endedAnswer(tool: string, end: {
|
|
136
|
+
status: CallStatus;
|
|
137
|
+
output?: unknown;
|
|
138
|
+
}): {
|
|
139
|
+
text: string;
|
|
140
|
+
isError: boolean;
|
|
141
|
+
};
|
|
142
|
+
export type MessageRole = "person" | "steer" | "model";
|
|
143
|
+
export interface MessageData {
|
|
144
|
+
readonly role: MessageRole;
|
|
145
|
+
readonly text: string;
|
|
146
|
+
/** Who wrote a message the person did not type (a trigger's): the steer row's body.origin. */
|
|
147
|
+
readonly origin?: MessageOrigin;
|
|
148
|
+
/** A model message that ends a CLI turn its model's output limit cut (its adapter's turn_end): "length", with the cut
|
|
149
|
+
* answer's output tokens when known. The loop reads it as pi's stopReason (loop.ts cutLast). */
|
|
150
|
+
readonly stopReason?: "length";
|
|
151
|
+
readonly outputTokens?: number;
|
|
152
|
+
/** When it was written (ms, the loop's clock): the Timeline dates the message's row by it. */
|
|
153
|
+
readonly at?: number;
|
|
154
|
+
}
|
|
155
|
+
/** What an approval costs, as main's card shows it (tool-gate.ts ApprovalPrice): dollars, or "not metered". */
|
|
156
|
+
export type ApprovalPrice = number | "not metered";
|
|
157
|
+
/** A call the gate asked a person about: what main's approval card shows (tool-gate.ts ApprovalRequest). A parked call
|
|
158
|
+
* has no call.start yet, so its input is here. Optional for an ask written before these fields. */
|
|
159
|
+
export interface AskData {
|
|
160
|
+
readonly callId: string;
|
|
161
|
+
readonly tool: string;
|
|
162
|
+
/** The call's input as the gate saw it; null when it had none. */
|
|
163
|
+
readonly args?: unknown;
|
|
164
|
+
/** When it was asked (ISO), from the loop's clock; a re-ask on a resume keeps the first. */
|
|
165
|
+
readonly requestedAt?: string;
|
|
166
|
+
/** Its approval price (the spec's approvalPrice); null when it has none. */
|
|
167
|
+
readonly price?: ApprovalPrice | null;
|
|
168
|
+
}
|
|
169
|
+
/** How an ask was answered: approved, denied, or withdrawn (a stop or cancel while the call waited). */
|
|
170
|
+
export type AnswerDecision = "allow" | "deny" | "withdrawn";
|
|
171
|
+
export interface AnswerData {
|
|
172
|
+
readonly callId: string;
|
|
173
|
+
readonly approved: boolean;
|
|
174
|
+
/** allow, deny, or withdrawn: main's resolved entry. Optional for an answer written before it. */
|
|
175
|
+
readonly decision?: AnswerDecision;
|
|
176
|
+
/** When it was answered (ISO), from the loop's clock (or the runner's, for an end it writes itself). */
|
|
177
|
+
readonly answeredAt?: string;
|
|
178
|
+
/** The person's words with their answer (a decline's reason): the model reads it with the refusal, and the resume row
|
|
179
|
+
* shows it. Absent when they gave none. */
|
|
180
|
+
readonly note?: string;
|
|
181
|
+
/** "message": a deny a person's message gave while the call waited (the message route's deny row), which its approval
|
|
182
|
+
* row reads as "Declined by your message". Absent for an answer given directly. */
|
|
183
|
+
readonly by?: "message";
|
|
184
|
+
/** The allow a stop overrode (main's ApprovalAnswer.superseded): the call was approved but had not finished when its
|
|
185
|
+
* run was stopped, so the stop withdrew it. Kept as it was given. */
|
|
186
|
+
readonly superseded?: {
|
|
187
|
+
readonly decision: "allow";
|
|
188
|
+
readonly answeredAt?: string;
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/** The withdrawn answers a stopped end writes in `entries`: for every call still waiting (an ask with no answer), and
|
|
192
|
+
* for every approved call that had not finished (no result, or one its abort wrote), which the stop overrides, keeping
|
|
193
|
+
* the allow it was given (main's supersede: an answer the run had not acted on to the end is withdrawn by the stop). A
|
|
194
|
+
* call that finished before the stop keeps its allow and its result. */
|
|
195
|
+
export declare function withdrawnAnswers(entries: readonly {
|
|
196
|
+
readonly kind: string;
|
|
197
|
+
readonly data?: unknown;
|
|
198
|
+
readonly model?: unknown;
|
|
199
|
+
}[], answeredAt: string): AnswerData[];
|
|
200
|
+
export interface EndData {
|
|
201
|
+
readonly state: "ended" | "stopped" | "failed";
|
|
202
|
+
readonly summary?: string;
|
|
203
|
+
/** How an ended run ended, set only for an escalation (the store's RunOutcome). */
|
|
204
|
+
readonly outcome?: "completed" | "escalated";
|
|
205
|
+
/** What the run cost, as its end knows it. */
|
|
206
|
+
readonly costUsd?: number;
|
|
207
|
+
/** The run's metrics (the old StoredMetrics JSON). */
|
|
208
|
+
readonly metrics?: unknown;
|
|
209
|
+
/** A completed workflow run's output: the value at its workflow's output path (readWorkflowRun's `output`, null when it
|
|
210
|
+
* has none), kept at its end as main's server kept it on the run (runs.ts workflowEnd), and served as result.output. */
|
|
211
|
+
readonly output?: unknown;
|
|
212
|
+
}
|
|
213
|
+
export interface SessionKeyData {
|
|
214
|
+
readonly key: string;
|
|
215
|
+
/** The conversation whose entries are this session's resume log. */
|
|
216
|
+
readonly conversation: number;
|
|
217
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { INTERRUPTED_TEXT } from "@parcha/agentrun-kernel/kernel";
|
|
2
|
+
export const KINDS = {
|
|
3
|
+
/** A tool call about to run: written before it runs (and before the flush that precedes a side effect). */
|
|
4
|
+
callStart: "agentrun.call.start",
|
|
5
|
+
/** How it ended: written after it ran, or by recovery for a start with no end (replay-safe reruns and ends done;
|
|
6
|
+
* any other ends interrupted, and the model is told). */
|
|
7
|
+
callEnd: "agentrun.call.end",
|
|
8
|
+
/** A message: the person's, a steer, or the model's. */
|
|
9
|
+
message: "agentrun.message",
|
|
10
|
+
/** A pi input the person did not type (a trigger's message): pi's user entry under the host's kind, its `data.origin`
|
|
11
|
+
* the Timeline's attribution (pi-durable-agent's originMatcher reads a host's user entry's own origin). The model
|
|
12
|
+
* reads it as any message. */
|
|
13
|
+
input: "agentrun.input",
|
|
14
|
+
/** A tool call the gate asked a person about: the run parks on it. */
|
|
15
|
+
ask: "agentrun.ask",
|
|
16
|
+
/** The person's answer to an ask, written by the commit that takes the approve or deny row. */
|
|
17
|
+
answer: "agentrun.answer",
|
|
18
|
+
/** On the root conversation: a CLI adapter's session key and the conversation that holds its resume log. */
|
|
19
|
+
sessionKey: "agentrun.session.key",
|
|
20
|
+
/** The loop's end commit: how the run ended (ended, stopped, failed). Its commit carries the run row's patch and any
|
|
21
|
+
* command it takes; neither a call nor a message, so the reader passes over it. */
|
|
22
|
+
end: "agentrun.end",
|
|
23
|
+
/** A run parked at its cap: the cap refused a request for room (a raise would let it fit). Its data is the pending
|
|
24
|
+
* budget the run waits on a raise with; its commit carries the run parked, in the cap's words. Neither a call nor a
|
|
25
|
+
* message, so the reader passes over it. */
|
|
26
|
+
budget: "agentrun.budget",
|
|
27
|
+
/** A raise of the run's cap, taken: the cap it raised to, and the raise rows its commit takes (the kernel cap's
|
|
28
|
+
* takeRaises, all a claim found at once). A budget entry with a raise entry after it is answered. Neither a call nor a
|
|
29
|
+
* message, so the reader passes over it. */
|
|
30
|
+
raise: "agentrun.raise",
|
|
31
|
+
/** A workflow run paused by its person (a `pause` row): its commit takes the pause rows and carries the run parked in
|
|
32
|
+
* the pause's words; a step a pause held was never sent. A pause entry with no resume entry after it is in force.
|
|
33
|
+
* Neither a call nor a message, so the reader passes over it. */
|
|
34
|
+
pause: "agentrun.pause",
|
|
35
|
+
/** The resume of a paused workflow run (a `resume` row), taken: the workflow goes on from its journal. Neither a call nor
|
|
36
|
+
* a message, so the reader passes over it. */
|
|
37
|
+
resume: "agentrun.resume",
|
|
38
|
+
/** A CLI run's end-of-run turn (the loop's record): its prompt (`role: "person"`) and its answer (`role: "model"`, the
|
|
39
|
+
* text in `model` as pi's answer carries it), the entry and the answer of the submission its request id names, the
|
|
40
|
+
* same submission pi's adapter writes, so the step reads both alike. Neither a call nor a message: the reader passes
|
|
41
|
+
* over it, and the turn is never on the run's visible record. */
|
|
42
|
+
endOfRunTurn: "agentrun.end-of-run.turn",
|
|
43
|
+
/** A learning run's grade: the verdict and what it spent, written before its merge (a resumed run never asks again). */
|
|
44
|
+
learningGraded: "agentrun.learning.graded",
|
|
45
|
+
/** A learning run's merge: the new main and its commit, with the run's end. */
|
|
46
|
+
learningMerged: "agentrun.learning.merged",
|
|
47
|
+
/** Why a learning run merged nothing, with the run's end. */
|
|
48
|
+
learningDropped: "agentrun.learning.dropped",
|
|
49
|
+
/** The learning folder could not be reached: the run parks and tries again after a backoff. */
|
|
50
|
+
learningUnavailable: "agentrun.learning.unavailable",
|
|
51
|
+
/** A browser hand-over (pi-browser's browser_request_handoff), on the root. The run's browser host commits the ask, the
|
|
52
|
+
* whole of it (HandoverAsked); its answer is an entry too (HandoverAnswered): the person's (a browser_hand_back row
|
|
53
|
+
* the loop applies, taking the row in that commit), or the ask's expiry. The first answer for an ask is its answer. */
|
|
54
|
+
handover: "agent.handover",
|
|
55
|
+
/** A run waiting on the person: ask_person ended its turn. Its data is the ask_person call's id; its commit carries the
|
|
56
|
+
* run parked. A person's message after it answers it. Neither a call nor a message, so the reader passes over it.
|
|
57
|
+
* `inClaim: true` with `at` (ms): the run waits for the answer in its claim instead (adapter-loop waitInClaim), from
|
|
58
|
+
* `at`, its commit carrying the row's ASK_PERSON_WAITING summary; `answered: true` clears that summary. */
|
|
59
|
+
personAsked: "agentrun.person.asked",
|
|
60
|
+
};
|
|
61
|
+
/** The run row's summary while it waits on the person's answer to its question (ask_person), parked or in its claim: the
|
|
62
|
+
* view reads the question from the call, never from here, so the model's text is never copied into the row. The server
|
|
63
|
+
* tells run.needs_input for a run held in its claim by this summary (server.ts readEnds). */
|
|
64
|
+
export const ASK_PERSON_WAITING = "Waiting for your reply";
|
|
65
|
+
/** The run row's summary while its agent's browser hand-over (browser_request_handoff) waits on the person, its claim
|
|
66
|
+
* held: set by the ask's waiting entry's commit, cleared by its answer's (tools.ts, through AdapterRun.rowSummaryOn). */
|
|
67
|
+
export const HANDOVER_WAITING = "Waiting for you in the browser";
|
|
68
|
+
/** The summaries of a run held in its claim while it waits on its person: the server tells run.needs_input by them. */
|
|
69
|
+
export const HELD_WAITS = new Set([ASK_PERSON_WAITING, HANDOVER_WAITING]);
|
|
70
|
+
/** What a call that already ended answers when it is asked for again (a parked call's resume, a CLI's re-issue of its id):
|
|
71
|
+
* its recorded output; for one a crash cut with none, the kernel's words for an outcome not known (INTERRUPTED_TEXT);
|
|
72
|
+
* else that `tool`'s call ended so. An error unless it ended done. */
|
|
73
|
+
export function endedAnswer(tool, end) {
|
|
74
|
+
const text = typeof end.output === "string" ? end.output : end.status === "interrupted" ? INTERRUPTED_TEXT : `The ${tool} call ended ${end.status}.`;
|
|
75
|
+
return { text, isError: end.status !== "done" };
|
|
76
|
+
}
|
|
77
|
+
/** Whether `entries` hold a call's finished result: an agentrun.call.end not cut (a CLI's call), or a pi.tool-result
|
|
78
|
+
* for it that pi did not write for an abort (pi's diagnostics code `aborted`). */
|
|
79
|
+
function finished(entries, callId) {
|
|
80
|
+
return entries.some((entry) => {
|
|
81
|
+
if (entry.kind === KINDS.callEnd)
|
|
82
|
+
return entry.data.callId === callId && entry.data.status !== "interrupted";
|
|
83
|
+
if (entry.kind !== "pi.tool-result")
|
|
84
|
+
return false;
|
|
85
|
+
const result = entry.model?.[0];
|
|
86
|
+
const diagnostics = entry.data?.diagnostics ?? [];
|
|
87
|
+
return result?.toolCallId === callId && !diagnostics.some((diagnostic) => diagnostic.code === "aborted");
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/** The withdrawn answers a stopped end writes in `entries`: for every call still waiting (an ask with no answer), and
|
|
91
|
+
* for every approved call that had not finished (no result, or one its abort wrote), which the stop overrides, keeping
|
|
92
|
+
* the allow it was given (main's supersede: an answer the run had not acted on to the end is withdrawn by the stop). A
|
|
93
|
+
* call that finished before the stop keeps its allow and its result. */
|
|
94
|
+
export function withdrawnAnswers(entries, answeredAt) {
|
|
95
|
+
const answers = new Map();
|
|
96
|
+
for (const entry of entries)
|
|
97
|
+
if (entry.kind === KINDS.answer)
|
|
98
|
+
answers.set(entry.data.callId, entry.data);
|
|
99
|
+
const out = [];
|
|
100
|
+
const seen = new Set();
|
|
101
|
+
for (const entry of entries) {
|
|
102
|
+
if (entry.kind !== KINDS.ask)
|
|
103
|
+
continue;
|
|
104
|
+
const { callId } = entry.data;
|
|
105
|
+
if (seen.has(callId))
|
|
106
|
+
continue;
|
|
107
|
+
seen.add(callId);
|
|
108
|
+
const given = answers.get(callId);
|
|
109
|
+
if (!given)
|
|
110
|
+
out.push({ callId, approved: false, decision: "withdrawn", answeredAt });
|
|
111
|
+
else if (given.approved && given.decision !== "withdrawn" && !finished(entries, callId)) {
|
|
112
|
+
out.push({ callId, approved: false, decision: "withdrawn", answeredAt, superseded: { decision: "allow", ...(given.answeredAt ? { answeredAt: given.answeredAt } : {}) } });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return out;
|
|
116
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Context } from "@earendil-works/chord";
|
|
2
|
+
import { type MessageOrigin } from "@parcha/pi-durable-agent/timeline";
|
|
3
|
+
import type { EntryRecord, SubmissionRecord, TaskRecord } from "@earendil-works/pi-durable";
|
|
4
|
+
import { type CallEndData, type MessageRole } from "./journal-kinds.js";
|
|
5
|
+
import type { JournalReads } from "../store/store.js";
|
|
6
|
+
export interface CallRecord {
|
|
7
|
+
readonly callId: string;
|
|
8
|
+
readonly tool: string;
|
|
9
|
+
/** Whether it may run again after a crash: the call's own flag (a pi tool says so only while it runs). */
|
|
10
|
+
readonly replaySafe?: boolean;
|
|
11
|
+
/** pending: started, not ended (a crash between them, until recovery ends it). */
|
|
12
|
+
readonly status: CallEndData["status"] | "pending";
|
|
13
|
+
readonly startEntry: number;
|
|
14
|
+
readonly endEntry?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface MessageRecord {
|
|
17
|
+
readonly role: MessageRole;
|
|
18
|
+
readonly text: string;
|
|
19
|
+
readonly entry: number;
|
|
20
|
+
/** The end-of-run turn's (end-of-run.ts reflectFrom): its message and its answer, never the run's own. */
|
|
21
|
+
readonly learning?: true;
|
|
22
|
+
/** Who wrote a message the person did not type (a trigger's): the Timeline's attribution, as the message carries it. */
|
|
23
|
+
readonly origin?: MessageOrigin;
|
|
24
|
+
}
|
|
25
|
+
/** What the reader reads: every entry and every task of the run, and its submissions (where its end-of-run turn began:
|
|
26
|
+
* end-of-run.ts reflectFrom). */
|
|
27
|
+
export interface JournalRecords {
|
|
28
|
+
readonly entries: readonly EntryRecord[];
|
|
29
|
+
readonly tasks: readonly TaskRecord<unknown, unknown, unknown>[];
|
|
30
|
+
readonly submissions?: readonly SubmissionRecord[];
|
|
31
|
+
}
|
|
32
|
+
/** Every entry and task of the run: conversations in id order, each one's entries oldest first; tasks in id order. */
|
|
33
|
+
export declare function journalRecords(journal: JournalReads, context: Context): Promise<JournalRecords>;
|
|
34
|
+
/** Every entry of the run (the CLI record and pi's entries alike). */
|
|
35
|
+
export declare function journalEntries(journal: JournalReads, context: Context): Promise<EntryRecord[]>;
|
|
36
|
+
/** The run's own record: every entry but those inside a CLI session's conversation (its resume log), whatever their kind. */
|
|
37
|
+
export declare function recordOf(entries: readonly EntryRecord[]): EntryRecord[];
|
|
38
|
+
/** The run's tool calls, in the order they started: pi's tool tasks and the CLI record's call starts. */
|
|
39
|
+
export declare function callsOf(from: readonly EntryRecord[] | JournalRecords): CallRecord[];
|
|
40
|
+
/** The run's messages, oldest first: the CLI record's, and pi's (a pi.user entry a running generation placed is a steer;
|
|
41
|
+
* a pi.assistant entry with no text, only tool calls, is no message). */
|
|
42
|
+
export declare function messagesOf(from: readonly EntryRecord[] | JournalRecords): MessageRecord[];
|
|
43
|
+
export declare function calls(journal: JournalReads, context: Context): Promise<CallRecord[]>;
|
|
44
|
+
export declare function messages(journal: JournalReads, context: Context): Promise<MessageRecord[]>;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { originOf } from "@parcha/pi-durable-agent/timeline";
|
|
2
|
+
import { reflectFrom } from "./end-of-run.js";
|
|
3
|
+
import { KINDS } from "./journal-kinds.js";
|
|
4
|
+
const PAGE = 500;
|
|
5
|
+
/** pi's kinds, as pi 1.5 writes them. */
|
|
6
|
+
const PI = { tool: "pi.tool", user: "pi.user", assistant: "pi.assistant" };
|
|
7
|
+
/** The diagnostic code pi's recovery puts on the result of a call it interrupted (not run again). */
|
|
8
|
+
const INTERRUPTED = "interrupted";
|
|
9
|
+
async function scanAll(scan) {
|
|
10
|
+
const items = [];
|
|
11
|
+
for (let cursor = undefined;;) {
|
|
12
|
+
const page = await scan(cursor);
|
|
13
|
+
items.push(...page.items);
|
|
14
|
+
if (page.next === undefined)
|
|
15
|
+
return items;
|
|
16
|
+
cursor = page.next;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Every entry and task of the run: conversations in id order, each one's entries oldest first; tasks in id order. */
|
|
20
|
+
export async function journalRecords(journal, context) {
|
|
21
|
+
const conversations = await scanAll((cursor) => journal.scanConversations({ order: "ascending" }, PAGE, cursor, context));
|
|
22
|
+
const entries = [];
|
|
23
|
+
for (const conversation of conversations) {
|
|
24
|
+
entries.push(...(await scanAll((cursor) => journal.scanEntries({ conversationId: conversation.id, order: "ascending" }, PAGE, cursor, context))));
|
|
25
|
+
}
|
|
26
|
+
const tasks = await scanAll((cursor) => journal.scanTasks({ order: "ascending" }, PAGE, cursor, context));
|
|
27
|
+
const submissions = await scanAll((cursor) => journal.scanSubmissions({ order: "ascending" }, PAGE, cursor, context));
|
|
28
|
+
return { entries, tasks, submissions };
|
|
29
|
+
}
|
|
30
|
+
/** Every entry of the run (the CLI record and pi's entries alike). */
|
|
31
|
+
export async function journalEntries(journal, context) {
|
|
32
|
+
return [...(await journalRecords(journal, context)).entries];
|
|
33
|
+
}
|
|
34
|
+
const entryNumber = (entry) => Number(entry.id);
|
|
35
|
+
const dataOf = (entry) => entry.data;
|
|
36
|
+
const asRecords = (from) => (Array.isArray(from) ? { entries: from, tasks: [] } : from);
|
|
37
|
+
/** The run's own record: every entry but those inside a CLI session's conversation (its resume log), whatever their kind. */
|
|
38
|
+
export function recordOf(entries) {
|
|
39
|
+
const sessions = new Set(entries.filter((entry) => entry.kind === KINDS.sessionKey).map((entry) => String(dataOf(entry).conversation)));
|
|
40
|
+
return entries.filter((entry) => !sessions.has(String(entry.conversationId)));
|
|
41
|
+
}
|
|
42
|
+
/** A pi tool task as a call: its name from the assistant entry's tool call, its status from the task's state. */
|
|
43
|
+
function piCall(task, byId) {
|
|
44
|
+
const input = task.input;
|
|
45
|
+
if (input?.callId === undefined || input.assistant === undefined)
|
|
46
|
+
return undefined;
|
|
47
|
+
const assistant = byId.get(String(input.assistant));
|
|
48
|
+
const block = assistant?.model?.[0]?.content?.find((part) => part.type === "toolCall" && part.id === input.callId);
|
|
49
|
+
const state = task.state;
|
|
50
|
+
const start = { callId: input.callId, tool: block?.name ?? "unknown", startEntry: input.assistant };
|
|
51
|
+
if (state.status !== "terminal" || !("outcome" in state)) {
|
|
52
|
+
const replay = "checkpoint" in state ? state.checkpoint?.replay : undefined;
|
|
53
|
+
return { ...start, status: "pending", ...(replay ? { replaySafe: replay === "safe" } : {}) };
|
|
54
|
+
}
|
|
55
|
+
const endId = state.outcome.result?.entryId;
|
|
56
|
+
const result = endId === undefined ? undefined : byId.get(String(endId));
|
|
57
|
+
const interrupted = (result?.data?.diagnostics ?? []).some((each) => each.code === INTERRUPTED);
|
|
58
|
+
const status = state.outcome.status === "completed" ? "done" : interrupted || state.outcome.status === "aborted" ? "interrupted" : "failed";
|
|
59
|
+
return { ...start, status, ...(endId === undefined ? {} : { endEntry: endId }) };
|
|
60
|
+
}
|
|
61
|
+
/** The run's tool calls, in the order they started: pi's tool tasks and the CLI record's call starts. */
|
|
62
|
+
export function callsOf(from) {
|
|
63
|
+
const { entries: all, tasks } = asRecords(from);
|
|
64
|
+
const entries = recordOf(all);
|
|
65
|
+
const byId = new Map(entries.map((entry) => [String(entry.id), entry]));
|
|
66
|
+
const ends = new Map();
|
|
67
|
+
for (const entry of entries)
|
|
68
|
+
if (entry.kind === KINDS.callEnd)
|
|
69
|
+
ends.set(dataOf(entry).callId, entry);
|
|
70
|
+
const cli = entries
|
|
71
|
+
.filter((entry) => entry.kind === KINDS.callStart)
|
|
72
|
+
.map((entry) => {
|
|
73
|
+
const start = dataOf(entry);
|
|
74
|
+
const end = ends.get(start.callId);
|
|
75
|
+
return {
|
|
76
|
+
callId: start.callId,
|
|
77
|
+
tool: start.tool,
|
|
78
|
+
replaySafe: start.replaySafe,
|
|
79
|
+
status: end ? dataOf(end).status : "pending",
|
|
80
|
+
startEntry: entryNumber(entry),
|
|
81
|
+
...(end ? { endEntry: entryNumber(end) } : {}),
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
const pi = tasks.filter((task) => task.kind === PI.tool).flatMap((task) => piCall(task, byId) ?? []);
|
|
85
|
+
return [...pi, ...cli].sort((a, b) => a.startEntry - b.startEntry);
|
|
86
|
+
}
|
|
87
|
+
/** The text of a pi message: a string, or its text blocks joined. */
|
|
88
|
+
function piText(entry) {
|
|
89
|
+
const content = entry.model?.[0]?.content;
|
|
90
|
+
if (typeof content === "string")
|
|
91
|
+
return content;
|
|
92
|
+
return Array.isArray(content) ? content.filter((part) => part.type === "text").map((part) => part.text ?? "").join("") : "";
|
|
93
|
+
}
|
|
94
|
+
/** The run's messages, oldest first: the CLI record's, and pi's (a pi.user entry a running generation placed is a steer;
|
|
95
|
+
* a pi.assistant entry with no text, only tool calls, is no message). */
|
|
96
|
+
export function messagesOf(from) {
|
|
97
|
+
const out = [];
|
|
98
|
+
const records = asRecords(from);
|
|
99
|
+
// The end-of-run turn's, from the entry its input placed on (the reader's tag, as the server's labelled() reads it).
|
|
100
|
+
const from_ = reflectFrom(records.submissions ?? []);
|
|
101
|
+
const turn = (entry) => (from_ !== undefined && entry >= from_ ? { learning: true } : {});
|
|
102
|
+
for (const entry of recordOf(records.entries)) {
|
|
103
|
+
const at = entryNumber(entry);
|
|
104
|
+
if (entry.kind === KINDS.message) {
|
|
105
|
+
const { origin, ...data } = dataOf(entry);
|
|
106
|
+
const known = originOf(origin);
|
|
107
|
+
out.push({ ...data, entry: at, ...(known ? { origin: known } : {}), ...turn(at) });
|
|
108
|
+
}
|
|
109
|
+
else if (entry.kind === PI.user || entry.kind === KINDS.input) {
|
|
110
|
+
// A pi input under the host's kind carries who wrote it (a trigger's message); pi's own user entry is the person's.
|
|
111
|
+
const known = entry.kind === KINDS.input ? originOf(entry.data?.origin) : undefined;
|
|
112
|
+
out.push({ role: entry.byTaskId === undefined ? "person" : "steer", text: piText(entry), entry: at, ...(known ? { origin: known } : {}), ...turn(at) });
|
|
113
|
+
}
|
|
114
|
+
else if (entry.kind === PI.assistant) {
|
|
115
|
+
const text = piText(entry);
|
|
116
|
+
if (text !== "")
|
|
117
|
+
out.push({ role: "model", text, entry: at, ...turn(at) });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return out.sort((a, b) => a.entry - b.entry);
|
|
121
|
+
}
|
|
122
|
+
export async function calls(journal, context) {
|
|
123
|
+
return callsOf(await journalRecords(journal, context));
|
|
124
|
+
}
|
|
125
|
+
export async function messages(journal, context) {
|
|
126
|
+
return messagesOf(await journalRecords(journal, context));
|
|
127
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type BeforeRequest, type Wire } from "@parcha/agentrun-kernel";
|
|
2
|
+
import type { LearningLoopDeps } from "./learning-loop.js";
|
|
3
|
+
/** The session the grader's requests are booked under, in the learning run's journal. */
|
|
4
|
+
export declare const GRADE_SESSION = "learning.grade";
|
|
5
|
+
/** Where the grader's request goes: the route's wire (`api`, Anthropic's Messages or OpenAI's Responses) at `origin`, for
|
|
6
|
+
* `model`, priced by `price`. A model on neither wire comes as the route's Messages translation (model-route.ts
|
|
7
|
+
* messagesFetch, its `fetch`). */
|
|
8
|
+
export interface GraderRoute {
|
|
9
|
+
readonly provider: {
|
|
10
|
+
readonly api: Wire;
|
|
11
|
+
readonly origin: string;
|
|
12
|
+
readonly credential: () => string | Promise<string>;
|
|
13
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
14
|
+
readonly auth?: "bearer" | "x-api-key";
|
|
15
|
+
};
|
|
16
|
+
readonly model: string;
|
|
17
|
+
/** The catalog's entry for the model (whether it reasons, its window), as pi's session takes it (model-route.ts). */
|
|
18
|
+
readonly like?: {
|
|
19
|
+
readonly reasoning?: boolean;
|
|
20
|
+
readonly contextWindow?: number;
|
|
21
|
+
readonly maxTokens?: number;
|
|
22
|
+
};
|
|
23
|
+
/** A request's price from its usage (the proxy's booking reads it). */
|
|
24
|
+
readonly price?: (model: string, usage: {
|
|
25
|
+
input: number;
|
|
26
|
+
output: number;
|
|
27
|
+
cacheRead: number;
|
|
28
|
+
cacheWrite: number;
|
|
29
|
+
}) => number | null;
|
|
30
|
+
/** The upstream fetch (a test's scripted origin). */
|
|
31
|
+
readonly fetch?: typeof fetch;
|
|
32
|
+
}
|
|
33
|
+
export interface BookedAskOptions extends GraderRoute {
|
|
34
|
+
/** The learning run's cap: the host's check before each paid request (the kernel cap's beforeRequestOf). */
|
|
35
|
+
readonly beforeRequest?: BeforeRequest;
|
|
36
|
+
}
|
|
37
|
+
export declare function bookedAsk(options: BookedAskOptions): LearningLoopDeps["ask"];
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// The learning run's grader call (learning-loop.ts LearningLoopDeps.ask): a paid model request like a pi turn, on the
|
|
2
|
+
// same path. Its session ("learning.grade") lives in the learning run's own journal (journalSessions); the host's check
|
|
3
|
+
// before it leaves is the learning run's cap, asked with the run's totals (runBooking, the run's one booking); its record
|
|
4
|
+
// is written and made durable before it leaves, and its cost booked when it answers (modelPortFor); and it reaches the
|
|
5
|
+
// provider only through the kernel's model proxy, which admits and books it (startModelProxy with the booking's port).
|
|
6
|
+
// What it spent is that booking's, and its tokens the answer's usage: the grade's cost_usd and tokens.
|
|
7
|
+
import { randomBytes } from "node:crypto";
|
|
8
|
+
import { BACKGROUND_CONTEXT, withAbortSignal } from "@earendil-works/chord/context";
|
|
9
|
+
import { createModels } from "@earendil-works/pi-ai/models";
|
|
10
|
+
import { createRegistry, Harness } from "@earendil-works/pi-durable";
|
|
11
|
+
import { modelPortFor, runBooking } from "@parcha/agentrun-kernel";
|
|
12
|
+
import { startModelProxy } from "@parcha/agentrun-kernel/host";
|
|
13
|
+
import { sessionProvider } from "../port-models.js";
|
|
14
|
+
import { policyFor } from "./adapters/pi.js";
|
|
15
|
+
import { journalSessions } from "./sessions.js";
|
|
16
|
+
/** The session the grader's requests are booked under, in the learning run's journal. */
|
|
17
|
+
export const GRADE_SESSION = "learning.grade";
|
|
18
|
+
const PROVIDER = "agentrun-grade";
|
|
19
|
+
/** `journal` as its Harness sees it: every method its own, but close, which is the claim's to do, not the ask's. */
|
|
20
|
+
function unclosed(journal) {
|
|
21
|
+
return new Proxy(journal, {
|
|
22
|
+
get(target, key) {
|
|
23
|
+
if (key === "close")
|
|
24
|
+
return async () => undefined;
|
|
25
|
+
const value = Reflect.get(target, key, target);
|
|
26
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export function bookedAsk(options) {
|
|
31
|
+
const { model } = options;
|
|
32
|
+
return async (request, signal, run) => {
|
|
33
|
+
const context = withAbortSignal(signal, BACKGROUND_CONTEXT);
|
|
34
|
+
// The claim's journal (a store hands one storage per claim, the loop's too) under a Harness of the ask's own, whose
|
|
35
|
+
// close leaves the storage open: the loop goes on writing its entries there after the grade.
|
|
36
|
+
const harness = await Harness.open(unclosed(run.journal()), { models: createModels(), registry: createRegistry(), onReport: () => { } }, context);
|
|
37
|
+
try {
|
|
38
|
+
const sessions = journalSessions(harness, context, { flush: () => run.flush() });
|
|
39
|
+
const writer = await sessions.open(GRADE_SESSION);
|
|
40
|
+
// The cap is the learning run's: asked with every session of the run summed, never this one's alone.
|
|
41
|
+
const hostCheck = options.beforeRequest ? runBooking(sessions, options.beforeRequest) : undefined;
|
|
42
|
+
let refused;
|
|
43
|
+
const booking = await modelPortFor(writer, {
|
|
44
|
+
key: GRADE_SESSION,
|
|
45
|
+
label: "grade",
|
|
46
|
+
...(hostCheck ? { beforeRequest: async (asked) => {
|
|
47
|
+
const answer = await hostCheck(asked);
|
|
48
|
+
if (answer && "refuse" in answer)
|
|
49
|
+
refused = answer;
|
|
50
|
+
return answer;
|
|
51
|
+
} } : {}),
|
|
52
|
+
// The rule before a side effect: the request's record is durable before the request leaves.
|
|
53
|
+
onEvent: async (event) => {
|
|
54
|
+
if (event.type === "request_start")
|
|
55
|
+
await run.flush();
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
// A grade request an earlier attempt sent and a crash cut is booked first, at its held figure.
|
|
59
|
+
await booking.bookCut();
|
|
60
|
+
const before = booking.spentUsd();
|
|
61
|
+
// The policy of the route's wire, as pi's session takes it (pi.ts policyFor: claude-agent's on Messages, codex's on
|
|
62
|
+
// Responses, no fork); the grade offers no tool.
|
|
63
|
+
const proxy = await startModelProxy({
|
|
64
|
+
policy: await policyFor(options.provider, model, []),
|
|
65
|
+
hooks: booking.models,
|
|
66
|
+
model,
|
|
67
|
+
origin: options.provider.origin,
|
|
68
|
+
credential: async () => (await options.provider.credential()) ?? "",
|
|
69
|
+
...(options.price ? { price: options.price } : {}),
|
|
70
|
+
...(options.provider.headers ? { headers: options.provider.headers } : {}),
|
|
71
|
+
...(options.fetch ? { fetch: options.fetch } : {}),
|
|
72
|
+
}, randomBytes(32).toString("base64url"));
|
|
73
|
+
try {
|
|
74
|
+
// pi-ai's client of the route's wire at the proxy (port-models.ts sessionProvider), as pi's session reaches its own.
|
|
75
|
+
const models = createModels();
|
|
76
|
+
models.setProvider(sessionProvider(options.provider.api, proxy, model, { provider: PROVIDER, keyName: "AGENTRUN_GRADE_KEY", like: { ...options.like, maxTokens: request.maxTokens }, reasoning: false }));
|
|
77
|
+
const target = models.getModel(PROVIDER, model);
|
|
78
|
+
const answer = (await models.completeSimple(target, { messages: [{ role: "user", content: request.prompt, timestamp: Date.now() }] }, { signal, maxTokens: request.maxTokens }));
|
|
79
|
+
if (refused)
|
|
80
|
+
throw new Error(refused.refuse);
|
|
81
|
+
if (answer.stopReason === "error" || answer.stopReason === "aborted")
|
|
82
|
+
throw new Error(`the grade's request failed: ${answer.errorMessage ?? answer.stopReason}`);
|
|
83
|
+
const text = answer.content.filter((part) => part.type === "text").map((part) => part.text ?? "").join("");
|
|
84
|
+
const after = booking.spentUsd();
|
|
85
|
+
const usd = before === null || after === null ? null : after - before;
|
|
86
|
+
// pi-ai counts cache reads and writes apart from input, as the grade's tokens do.
|
|
87
|
+
const used = answer.usage;
|
|
88
|
+
const tokens = used ? { input: used.input, cache_read: used.cacheRead ?? 0, cache_write: used.cacheWrite ?? 0, output: used.output } : null;
|
|
89
|
+
return { text, usd, tokens };
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
await proxy.close().catch(() => undefined);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
await harness.close(context).catch(() => undefined);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|