@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
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Store } from "../store/store.js";
|
|
2
|
+
import { type LiveEvent } from "./translate.js";
|
|
3
|
+
export type { LiveEvent } from "./translate.js";
|
|
4
|
+
/** Where a batch came from: a stored commit (its seq), or the run's held state. */
|
|
5
|
+
export type LiveBatchMeta = {
|
|
6
|
+
readonly seq: number;
|
|
7
|
+
readonly held?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
readonly held: true;
|
|
10
|
+
readonly seq?: undefined;
|
|
11
|
+
};
|
|
12
|
+
export type LiveEnd = {
|
|
13
|
+
readonly reason: "stopped" | "ended" | "failed";
|
|
14
|
+
};
|
|
15
|
+
export interface LiveStream {
|
|
16
|
+
readonly snapshot: LiveEvent;
|
|
17
|
+
start(listener: (events: LiveEvent[], meta: LiveBatchMeta) => void | Promise<void>): void;
|
|
18
|
+
stop(): Promise<LiveEnd>;
|
|
19
|
+
readonly closed: Promise<LiveEnd>;
|
|
20
|
+
}
|
|
21
|
+
export interface WatchRunOptions {
|
|
22
|
+
/** Resume after this commit: the snapshot holds the run as of it, and only later commits follow. Default: the newest
|
|
23
|
+
* commit when the stream is opened. */
|
|
24
|
+
readonly fromSeq?: number;
|
|
25
|
+
/** How often the store is read. Default 250 ms. */
|
|
26
|
+
readonly pollMs?: number;
|
|
27
|
+
}
|
|
28
|
+
type LiveStore = Pick<Store, "runs" | "journal" | "live">;
|
|
29
|
+
/** Opens `runId`'s live view on `store`. */
|
|
30
|
+
export declare function watchRun(store: LiveStore, runId: string, options?: WatchRunOptions): Promise<LiveStream>;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// One run's live view, read from the one store (design: the server reads everything from the store; a runner shares
|
|
2
|
+
// nothing with it but the store). The replacement for the door's GET /events: a snapshot, then the events of each
|
|
3
|
+
// stored commit (live/translate.ts), in commit order, each batch naming its commit's seq so a reader that comes back
|
|
4
|
+
// resumes from it; and beside them, never inside a commit's batch, what the runner holds before pi stores it (the run's
|
|
5
|
+
// run_live row: a running tool, a partial answer), in the same vocabulary.
|
|
6
|
+
import { RUN_RESUMED } from "@parcha/pi-durable-agent/timeline";
|
|
7
|
+
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
8
|
+
import { FINAL_STATES } from "../store/store.js";
|
|
9
|
+
import { emptyState, snapshotOf, translate } from "./translate.js";
|
|
10
|
+
/** The events delivered to a live reader, with a runner-lost resume note (RUN_RESUMED) dropped. The note joins the run's
|
|
11
|
+
* record — translate still appends it to the state the snapshot reads (snapshotOf), and the timeline renders its phase
|
|
12
|
+
* row — but it is not a live stream event: a takeover ends the door's watch, so a reader meets the note only in a
|
|
13
|
+
* reconnect's snapshot, never as a commit on the open stream. The live view polls across a takeover, so without this it
|
|
14
|
+
* would stream the note's entry_appended; dropping it keeps a run taken over mid-turn streaming the same events as one
|
|
15
|
+
* that was not. The note stays in state.entries (translate pushed it before returning), so the next snapshot carries it. */
|
|
16
|
+
const delivered = (events) => events.filter((event) => !(event.type === "entry_appended" && event.entry?.kind === RUN_RESUMED));
|
|
17
|
+
const PAGE = 500;
|
|
18
|
+
/** The journals each store's watches read, by (run, epoch), with how many watches hold each. store.journal hands out one
|
|
19
|
+
* journal per (run, epoch) and keeps it until it is closed: two watches of one run share it, and the last one to end
|
|
20
|
+
* closes it, so the store keeps no journal of a watch that ended. */
|
|
21
|
+
const watched = new WeakMap();
|
|
22
|
+
/** `runId`'s journal at `epoch` for one watch, and its release: the last watch's closes the journal. */
|
|
23
|
+
function watchJournal(store, runId, epoch, from) {
|
|
24
|
+
let byRun = watched.get(store);
|
|
25
|
+
if (!byRun)
|
|
26
|
+
watched.set(store, (byRun = new Map()));
|
|
27
|
+
const key = `${runId}\u0000${epoch}`;
|
|
28
|
+
let held = byRun.get(key);
|
|
29
|
+
// A reader's view of the journal: reads only, so its claim fences nothing.
|
|
30
|
+
if (!held)
|
|
31
|
+
byRun.set(key, (held = { journal: store.journal({ runId, runner: "live-view", epoch, until: 0, from }), watches: 0 }));
|
|
32
|
+
held.watches += 1;
|
|
33
|
+
const it = held;
|
|
34
|
+
let released = false;
|
|
35
|
+
return {
|
|
36
|
+
journal: it.journal,
|
|
37
|
+
async release() {
|
|
38
|
+
if (released)
|
|
39
|
+
return;
|
|
40
|
+
released = true;
|
|
41
|
+
it.watches -= 1;
|
|
42
|
+
if (it.watches > 0)
|
|
43
|
+
return;
|
|
44
|
+
if (byRun.get(key) === it)
|
|
45
|
+
byRun.delete(key);
|
|
46
|
+
await it.journal.close(BACKGROUND_CONTEXT);
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** Opens `runId`'s live view on `store`. */
|
|
51
|
+
export async function watchRun(store, runId, options = {}) {
|
|
52
|
+
const pollMs = options.pollMs ?? 250;
|
|
53
|
+
const context = BACKGROUND_CONTEXT;
|
|
54
|
+
const row = await store.runs.get(runId);
|
|
55
|
+
if (!row)
|
|
56
|
+
throw new Error(`run ${runId} does not exist`);
|
|
57
|
+
const { journal, release } = watchJournal(store, runId, row.epoch, row.state);
|
|
58
|
+
const state = emptyState();
|
|
59
|
+
let seq = 0;
|
|
60
|
+
// The snapshot: every commit up to `fromSeq` (all of them when it is not given) folded into the state; their events
|
|
61
|
+
// are the snapshot's, not sent.
|
|
62
|
+
const upTo = options.fromSeq;
|
|
63
|
+
try {
|
|
64
|
+
fold: for (;;) {
|
|
65
|
+
const page = await journal.commitsAfter(seq, PAGE, context);
|
|
66
|
+
for (const commit of page.commits) {
|
|
67
|
+
if (upTo !== undefined && commit.seq > upTo)
|
|
68
|
+
break fold;
|
|
69
|
+
translate(state, commit);
|
|
70
|
+
seq = commit.seq;
|
|
71
|
+
}
|
|
72
|
+
if (page.next === undefined || page.commits.length === 0)
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
await release();
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
if (upTo !== undefined)
|
|
81
|
+
seq = upTo;
|
|
82
|
+
let listener;
|
|
83
|
+
let ended;
|
|
84
|
+
let endIt;
|
|
85
|
+
const closed = new Promise((resolve) => (endIt = (end) => { if (!ended) {
|
|
86
|
+
ended = end;
|
|
87
|
+
resolve(end);
|
|
88
|
+
} }));
|
|
89
|
+
let timer;
|
|
90
|
+
let polling = Promise.resolve();
|
|
91
|
+
// However the watch ends (stopped, its run ended, a failed read), its journal is let go once its last poll settled.
|
|
92
|
+
const released = closed.then(() => polling.catch(() => undefined)).then(release);
|
|
93
|
+
/** The held state's events the stored ones have not said yet: a running tool's start, a partial's update. */
|
|
94
|
+
const heldEvents = (held) => {
|
|
95
|
+
if (!held || !state.run)
|
|
96
|
+
return [];
|
|
97
|
+
const events = [];
|
|
98
|
+
for (const tool of held.tools) {
|
|
99
|
+
if (state.started_calls.has(tool.callId))
|
|
100
|
+
continue;
|
|
101
|
+
state.started_calls.add(tool.callId);
|
|
102
|
+
state.calls.set(tool.callId, { name: tool.name, ...(tool.args !== undefined ? { args: tool.args } : {}) });
|
|
103
|
+
events.push({ type: "tool_execution_start", toolCallId: tool.callId, toolName: tool.name, ...(tool.args !== undefined ? { args: tool.args } : {}) });
|
|
104
|
+
}
|
|
105
|
+
if (held.partial?.text) {
|
|
106
|
+
const message = { role: "assistant", content: [{ type: "text", text: held.partial.text }] };
|
|
107
|
+
if (!state.partial)
|
|
108
|
+
events.push({ type: "message_start", message });
|
|
109
|
+
else
|
|
110
|
+
events.push({ type: "message_update", changes: [{ type: "message", message }] });
|
|
111
|
+
state.partial = true;
|
|
112
|
+
}
|
|
113
|
+
return events;
|
|
114
|
+
};
|
|
115
|
+
const poll = async () => {
|
|
116
|
+
if (ended || !listener)
|
|
117
|
+
return;
|
|
118
|
+
const to = listener;
|
|
119
|
+
// The row before the commits: a row final here was made final in its end commit's own transaction, so the drain
|
|
120
|
+
// below reads that commit. Read after the drain, the row could be final from a commit the drain missed, and the
|
|
121
|
+
// stream would end without what that commit holds (a CLI run's answer).
|
|
122
|
+
const now = await store.runs.get(runId);
|
|
123
|
+
const final = now !== undefined && FINAL_STATES.includes(now.state);
|
|
124
|
+
for (;;) {
|
|
125
|
+
const page = await journal.commitsAfter(seq, PAGE, context);
|
|
126
|
+
for (const commit of page.commits) {
|
|
127
|
+
// translate moves `state` (its entries feed the snapshot) and returns the commit's events; a resume note is dropped
|
|
128
|
+
// from what the stream delivers, never from the state the snapshot reads.
|
|
129
|
+
const events = delivered(translate(state, commit));
|
|
130
|
+
seq = commit.seq;
|
|
131
|
+
if (events.length > 0)
|
|
132
|
+
await to(events, { seq: commit.seq });
|
|
133
|
+
if (ended)
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (page.next === undefined || page.commits.length === 0)
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
if (!final) {
|
|
140
|
+
const [held] = await store.live.read([runId]);
|
|
141
|
+
const events = heldEvents(held?.state);
|
|
142
|
+
if (events.length > 0)
|
|
143
|
+
await to(events, { held: true });
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
// Final, and its commits drained: nothing more can land (the end released the claim, and a released claim's commits
|
|
147
|
+
// are refused). Ended whether or not pi settled its input: a run failed because its stop did not settle never does.
|
|
148
|
+
endIt({ reason: "ended" });
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
const schedule = () => {
|
|
152
|
+
if (ended)
|
|
153
|
+
return;
|
|
154
|
+
timer = setTimeout(() => {
|
|
155
|
+
polling = poll()
|
|
156
|
+
.catch(() => endIt({ reason: "failed" }))
|
|
157
|
+
.finally(schedule);
|
|
158
|
+
}, pollMs);
|
|
159
|
+
};
|
|
160
|
+
return {
|
|
161
|
+
snapshot: snapshotOf(state),
|
|
162
|
+
start(given) {
|
|
163
|
+
listener = given;
|
|
164
|
+
polling = poll().catch(() => endIt({ reason: "failed" })).finally(schedule);
|
|
165
|
+
},
|
|
166
|
+
async stop() {
|
|
167
|
+
endIt({ reason: "stopped" });
|
|
168
|
+
clearTimeout(timer);
|
|
169
|
+
await polling.catch(() => undefined);
|
|
170
|
+
await released;
|
|
171
|
+
return ended;
|
|
172
|
+
},
|
|
173
|
+
closed,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { JsonValue } from "@earendil-works/chord";
|
|
2
|
+
import { type EntryRecord, type SubmissionRecord } from "@earendil-works/pi-durable";
|
|
3
|
+
import type { JournalCommit } from "../store/journal/storage.js";
|
|
4
|
+
export type LiveEvent = {
|
|
5
|
+
readonly type: string;
|
|
6
|
+
} & Record<string, unknown>;
|
|
7
|
+
type Task = JournalCommit["tasks"][number];
|
|
8
|
+
/** What the stream knows of the run after the commits it has read. */
|
|
9
|
+
export interface LiveState {
|
|
10
|
+
/** The run's root conversation (the input's, or the CLI entries'): only its records are streamed. */
|
|
11
|
+
root?: number;
|
|
12
|
+
/** Conversations that hold a CLI session's resume log: never streamed. */
|
|
13
|
+
readonly sessions: Set<number>;
|
|
14
|
+
/** Events begin with the first commit that carries an input or a kernel entry; earlier ones (the root's set-up) fold
|
|
15
|
+
* into the snapshot. */
|
|
16
|
+
started: boolean;
|
|
17
|
+
readonly entries: EntryRecord[];
|
|
18
|
+
readonly tasks: Map<number, Task>;
|
|
19
|
+
readonly submissions: Map<number, SubmissionRecord>;
|
|
20
|
+
/** Each conversation's documents by kind, as last written. */
|
|
21
|
+
readonly docs: Map<number, Map<string, JsonValue | undefined>>;
|
|
22
|
+
/** The run in progress: the inputs it answers. */
|
|
23
|
+
run?: {
|
|
24
|
+
inputs: number[];
|
|
25
|
+
};
|
|
26
|
+
/** Generation tasks whose turn started, and those whose turn ended. */
|
|
27
|
+
readonly turns: Set<number>;
|
|
28
|
+
readonly turnsEnded: Set<number>;
|
|
29
|
+
/** Calls whose start, and whose end, the stream has said (a held start counts). */
|
|
30
|
+
readonly started_calls: Set<string>;
|
|
31
|
+
readonly ended_calls: Set<string>;
|
|
32
|
+
/** The call names and arguments the assistant's stored tool calls give, by call id. */
|
|
33
|
+
readonly calls: Map<string, {
|
|
34
|
+
name: string;
|
|
35
|
+
args?: unknown;
|
|
36
|
+
}>;
|
|
37
|
+
/** An answer streamed as a partial (held): its stored message is only its end. */
|
|
38
|
+
partial: boolean;
|
|
39
|
+
/** Where the run's end-of-run turn began (end-of-run.ts reflectFrom), once its input is placed: its messages from there
|
|
40
|
+
* on carry the learning label, a tag the reader puts on (the run writes nothing for it). */
|
|
41
|
+
reflectFrom?: number;
|
|
42
|
+
}
|
|
43
|
+
export declare function emptyState(): LiveState;
|
|
44
|
+
/** The one row a person's stop gives, the same on every harness: from the loop's end entry, stopped. */
|
|
45
|
+
export declare const STOPPED_BY_YOU = "Stopped by you";
|
|
46
|
+
/** What a call a person's stop cut says, in its result. */
|
|
47
|
+
export declare const CUT_BY_YOU = "stopped by you";
|
|
48
|
+
/** The run as the snapshot gives it: the entries so far, the calls running now and the documents' values. */
|
|
49
|
+
export declare function snapshotOf(state: LiveState): LiveEvent;
|
|
50
|
+
/** The events one commit causes, from its own records; `state` moves to after it. */
|
|
51
|
+
export declare function translate(state: LiveState, commit: JournalCommit): LiveEvent[];
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { AgentDoc, UsageDoc } from "@earendil-works/pi-durable";
|
|
2
|
+
import { HOST_PHASE, RUN_RESUMED } from "@parcha/pi-durable-agent/timeline";
|
|
3
|
+
import { REFLECT_LABEL, reflectFrom } from "../runner/end-of-run.js";
|
|
4
|
+
import { KINDS } from "../runner/journal-kinds.js";
|
|
5
|
+
import { PI_STOP } from "../runner/pi-stop.js";
|
|
6
|
+
export function emptyState() {
|
|
7
|
+
return {
|
|
8
|
+
sessions: new Set(),
|
|
9
|
+
started: false,
|
|
10
|
+
entries: [],
|
|
11
|
+
tasks: new Map(),
|
|
12
|
+
submissions: new Map(),
|
|
13
|
+
docs: new Map(),
|
|
14
|
+
turns: new Set(),
|
|
15
|
+
turnsEnded: new Set(),
|
|
16
|
+
started_calls: new Set(),
|
|
17
|
+
ended_calls: new Set(),
|
|
18
|
+
calls: new Map(),
|
|
19
|
+
partial: false,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const KERNEL = new Set(Object.values(KINDS));
|
|
23
|
+
const PI_TOOL = "pi.tool";
|
|
24
|
+
const PI_GENERATION = "pi.generation";
|
|
25
|
+
const ROLE = { person: "user", steer: "user", model: "assistant" };
|
|
26
|
+
const dataOf = (entry) => entry.data;
|
|
27
|
+
const modelOf = (entry) => entry.model?.[0];
|
|
28
|
+
/** The one row a person's stop gives, the same on every harness: from the loop's end entry, stopped. */
|
|
29
|
+
export const STOPPED_BY_YOU = "Stopped by you";
|
|
30
|
+
/** What a call a person's stop cut says, in its result. */
|
|
31
|
+
export const CUT_BY_YOU = "stopped by you";
|
|
32
|
+
/** The message of a result that is only pi's diagnostics block (`<harness>`, then `[error] …` lines, then `</harness>`
|
|
33
|
+
* and nothing after it): its first error's, else its first line's, without the severity or the markup. Undefined for any
|
|
34
|
+
* other text, a tool's own output after such a block included: that is kept whole. */
|
|
35
|
+
function diagnosticOf(text) {
|
|
36
|
+
const lines = text.trim().split("\n").map((line) => line.trim());
|
|
37
|
+
if (lines[0] !== "<harness>")
|
|
38
|
+
return undefined;
|
|
39
|
+
const end = lines.indexOf("</harness>");
|
|
40
|
+
if (end !== lines.length - 1)
|
|
41
|
+
return undefined;
|
|
42
|
+
const inner = lines.slice(1, end).filter(Boolean);
|
|
43
|
+
const said = inner.map((line) => /^\[(\w+)\]\s*(.*)$/.exec(line)).filter((match) => match !== null);
|
|
44
|
+
const first = said.find((match) => match[1] === "error") ?? said[0];
|
|
45
|
+
return first ? (first[2] ?? "") : (inner[0] ?? "");
|
|
46
|
+
}
|
|
47
|
+
/** A tool result as a person reads it. One an abort cut says CUT_BY_YOU: on the kernel's journal only a person's stop
|
|
48
|
+
* writes one (a lost claim or a shutdown seals the journal before its abort). One that is only pi's diagnostics block
|
|
49
|
+
* says that block's message. Neither ever shows the block's markup. Any other entry as it is. */
|
|
50
|
+
function shownResult(entry) {
|
|
51
|
+
const message = modelOf(entry);
|
|
52
|
+
if (message?.role !== "toolResult")
|
|
53
|
+
return entry;
|
|
54
|
+
const diagnostics = entry.data?.diagnostics;
|
|
55
|
+
const aborted = Array.isArray(diagnostics) && diagnostics.some((diagnostic) => diagnostic?.code === PI_STOP.aborted);
|
|
56
|
+
const blocks = Array.isArray(message.content) ? message.content : [];
|
|
57
|
+
const text = typeof message.content === "string" ? message.content : blocks.filter((block) => block?.type === "text" && typeof block.text === "string").map((block) => block.text).join("\n");
|
|
58
|
+
const said = aborted ? CUT_BY_YOU : diagnosticOf(text);
|
|
59
|
+
if (said === undefined)
|
|
60
|
+
return entry;
|
|
61
|
+
const model = entry.model;
|
|
62
|
+
return { ...entry, model: [{ ...message, content: [{ type: "text", text: said }] }, ...model.slice(1)] };
|
|
63
|
+
}
|
|
64
|
+
const doc = (state, kind) => (state.root === undefined ? undefined : state.docs.get(state.root)?.get(kind));
|
|
65
|
+
/** The run as the snapshot gives it: the entries so far, the calls running now and the documents' values. */
|
|
66
|
+
export function snapshotOf(state) {
|
|
67
|
+
const inbox = doc(state, "pi.inbox");
|
|
68
|
+
// The calls started and not ended in the commits read so far, as the door's snapshot lists pi.live's running tool
|
|
69
|
+
// slots: a stream opened while one runs shows it (its held start is skipped after, since its start is folded here).
|
|
70
|
+
const running = [...state.started_calls].filter((callId) => !state.ended_calls.has(callId)).map((callId) => ({ callId, name: state.calls.get(callId)?.name ?? "", status: "running" }));
|
|
71
|
+
return {
|
|
72
|
+
type: "snapshot",
|
|
73
|
+
entries: state.entries,
|
|
74
|
+
...(state.run ? { run: { inputs: state.run.inputs } } : {}),
|
|
75
|
+
tools: running,
|
|
76
|
+
compactions: [],
|
|
77
|
+
inbox: (inbox?.items ?? []).map((item) => ({ id: item.id, mode: item.mode })),
|
|
78
|
+
agent: doc(state, "pi.agent") ?? AgentDoc.definition.initial(),
|
|
79
|
+
usage: doc(state, "pi.usage") ?? UsageDoc.definition.initial(),
|
|
80
|
+
// The end-of-run turn under way: where it began, as the server's Reflect names it (`after`, the entry before its input).
|
|
81
|
+
...(state.reflectFrom !== undefined ? { reflect: { after: state.reflectFrom - 1 } } : {}),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/** The events one commit causes, from its own records; `state` moves to after it. */
|
|
85
|
+
export function translate(state, commit) {
|
|
86
|
+
for (const entry of commit.entries)
|
|
87
|
+
if (entry.kind === KINDS.sessionKey)
|
|
88
|
+
state.sessions.add(Number(dataOf(entry).conversation));
|
|
89
|
+
const own = (record) => !state.sessions.has(Number(record.conversationId));
|
|
90
|
+
const input = commit.submissions.find((record) => record.type === "input" && own(record));
|
|
91
|
+
// A run record the kernel writes: a call, a message, a takeover's note or the loop's end. A run taken over, or stopped,
|
|
92
|
+
// before its first call or message has no other record yet (a stop waiting when the loop could not open writes its end
|
|
93
|
+
// first), and neither is root set-up to fold into the snapshot.
|
|
94
|
+
const kernelEntry = commit.entries.find((entry) => own(entry) && (entry.kind === KINDS.callStart || entry.kind === KINDS.callEnd || entry.kind === KINDS.message || entry.kind === RUN_RESUMED || entry.kind === KINDS.end));
|
|
95
|
+
state.root ??= input ? Number(input.conversationId) : kernelEntry ? Number(kernelEntry.conversationId) : undefined;
|
|
96
|
+
const mine = (record) => own(record) && state.root !== undefined && Number(record.conversationId) === state.root;
|
|
97
|
+
// Documents: each conversation's newest value of each kind this commit wrote.
|
|
98
|
+
const docsBefore = new Map([...["pi.inbox", "pi.agent", "pi.usage"]].map((kind) => [kind, doc(state, kind)]));
|
|
99
|
+
for (const document of commit.documents) {
|
|
100
|
+
if (document.conversationId === undefined)
|
|
101
|
+
continue;
|
|
102
|
+
const of = state.docs.get(Number(document.conversationId)) ?? new Map();
|
|
103
|
+
of.set(document.kind, document.retired ? undefined : document.value);
|
|
104
|
+
state.docs.set(Number(document.conversationId), of);
|
|
105
|
+
}
|
|
106
|
+
const entries = commit.entries.filter(mine);
|
|
107
|
+
const tasks = commit.tasks.filter(mine);
|
|
108
|
+
const submissions = commit.submissions.filter(mine);
|
|
109
|
+
// The end-of-run turn's input placed in this commit: its messages from there on are the turn's.
|
|
110
|
+
state.reflectFrom ??= reflectFrom(submissions);
|
|
111
|
+
const tag = (entry) => (state.reflectFrom !== undefined && Number(entry.id) >= state.reflectFrom ? { agent_label: REFLECT_LABEL } : {});
|
|
112
|
+
for (const entry of entries) {
|
|
113
|
+
const message = modelOf(entry);
|
|
114
|
+
if (message?.role === "assistant" && Array.isArray(message.content)) {
|
|
115
|
+
for (const block of message.content) {
|
|
116
|
+
if (block.type === "toolCall" && block.id)
|
|
117
|
+
state.calls.set(block.id, { name: block.name ?? "", ...(block.arguments !== undefined ? { args: block.arguments } : {}) });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (entry.kind === KINDS.callStart) {
|
|
121
|
+
const start = dataOf(entry);
|
|
122
|
+
state.calls.set(start.callId, { name: start.tool, args: start.input });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const begins = !state.started && (input !== undefined || kernelEntry !== undefined);
|
|
126
|
+
if (!state.started && !begins) {
|
|
127
|
+
// The root's set-up, before the run: into the snapshot, no events.
|
|
128
|
+
state.entries.push(...entries.filter((entry) => !KERNEL.has(entry.kind)));
|
|
129
|
+
for (const task of tasks)
|
|
130
|
+
state.tasks.set(Number(task.id), task);
|
|
131
|
+
for (const record of submissions)
|
|
132
|
+
state.submissions.set(Number(record.id), record);
|
|
133
|
+
return [];
|
|
134
|
+
}
|
|
135
|
+
state.started = true;
|
|
136
|
+
const events = [];
|
|
137
|
+
const callName = (callId) => state.calls.get(callId)?.name ?? "";
|
|
138
|
+
const startCall = (callId) => {
|
|
139
|
+
if (state.started_calls.has(callId))
|
|
140
|
+
return;
|
|
141
|
+
state.started_calls.add(callId);
|
|
142
|
+
const call = state.calls.get(callId);
|
|
143
|
+
events.push({ type: "tool_execution_start", toolCallId: callId, toolName: callName(callId), ...(call?.args !== undefined ? { args: call.args } : {}) });
|
|
144
|
+
};
|
|
145
|
+
// A call that never ran (blocked, denied, never offered) ends with no start, as the door's stream says it.
|
|
146
|
+
const endCall = (callId, entry) => {
|
|
147
|
+
if (state.ended_calls.has(callId))
|
|
148
|
+
return;
|
|
149
|
+
state.ended_calls.add(callId);
|
|
150
|
+
events.push({ type: "tool_execution_end", toolCallId: callId, toolName: callName(callId), ...(entry ? { entry } : {}) });
|
|
151
|
+
};
|
|
152
|
+
const toolCallId = (task) => String(task.input?.callId ?? "");
|
|
153
|
+
// Calls running now: pi's tool tasks whose intent this commit stored (the execute checkpoint pi writes before it runs
|
|
154
|
+
// the tool). A task merely started is not a call that runs: the gate may still block it, and it never runs.
|
|
155
|
+
for (const task of tasks) {
|
|
156
|
+
if (task.kind !== PI_TOOL)
|
|
157
|
+
continue;
|
|
158
|
+
const taskState = task.state;
|
|
159
|
+
if (taskState.status === "running" && taskState.checkpoint?.phase === "execute")
|
|
160
|
+
startCall(toolCallId(task));
|
|
161
|
+
}
|
|
162
|
+
// Entries in order, each call's end before the message that carries its result.
|
|
163
|
+
for (const entry of entries) {
|
|
164
|
+
if (entry.kind === KINDS.callStart) {
|
|
165
|
+
startCall(dataOf(entry).callId);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (entry.kind === KINDS.callEnd) {
|
|
169
|
+
endCall(dataOf(entry).callId);
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (entry.kind === KINDS.message) {
|
|
173
|
+
const said = dataOf(entry);
|
|
174
|
+
const message = { role: ROLE[said.role] ?? "user", content: said.role === "model" ? [{ type: "text", text: said.text }] : said.text };
|
|
175
|
+
const synthetic = { ...entry, model: [message] };
|
|
176
|
+
state.entries.push(synthetic);
|
|
177
|
+
events.push({ type: "message_start", message, ...tag(entry) }, { type: "message_end", entry: synthetic, ...tag(entry) });
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (entry.kind === KINDS.end) {
|
|
181
|
+
// A person's stop (the only stop a loop ends a run on: a lost claim or a shutdown writes no end): one phase row,
|
|
182
|
+
// worded the same on every harness, from the loop's own end entry.
|
|
183
|
+
if (dataOf(entry).state === "stopped") {
|
|
184
|
+
const stopped = { ...entry, kind: HOST_PHASE, data: { summary: STOPPED_BY_YOU } };
|
|
185
|
+
state.entries.push(stopped);
|
|
186
|
+
events.push({ type: "entry_appended", entry: stopped });
|
|
187
|
+
}
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (KERNEL.has(entry.kind))
|
|
191
|
+
continue;
|
|
192
|
+
const shown = shownResult(entry);
|
|
193
|
+
state.entries.push(shown);
|
|
194
|
+
const message = modelOf(shown);
|
|
195
|
+
if (message === undefined) {
|
|
196
|
+
events.push({ type: "entry_appended", entry: shown });
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
if (message.role === "toolResult" && message.toolCallId)
|
|
200
|
+
endCall(message.toolCallId, shown);
|
|
201
|
+
const streamed = message.role === "assistant" && state.partial;
|
|
202
|
+
if (message.role === "assistant")
|
|
203
|
+
state.partial = false;
|
|
204
|
+
if (!streamed)
|
|
205
|
+
events.push({ type: "message_start", message, ...tag(entry) });
|
|
206
|
+
events.push({ type: "message_end", entry: shown, ...tag(entry) });
|
|
207
|
+
}
|
|
208
|
+
// Calls that ended without a result entry (aborted, cut off): their end.
|
|
209
|
+
for (const task of tasks) {
|
|
210
|
+
if (task.kind !== PI_TOOL || task.state.status !== "terminal")
|
|
211
|
+
continue;
|
|
212
|
+
endCall(toolCallId(task));
|
|
213
|
+
}
|
|
214
|
+
// Turns that ended, and the tasks that failed.
|
|
215
|
+
let turnEnded = false;
|
|
216
|
+
for (const task of tasks) {
|
|
217
|
+
const taskState = task.state;
|
|
218
|
+
const id = Number(task.id);
|
|
219
|
+
if (task.kind === PI_GENERATION && (taskState.status === "completing" || taskState.status === "terminal") && !state.turnsEnded.has(id)) {
|
|
220
|
+
state.turnsEnded.add(id);
|
|
221
|
+
turnEnded = true;
|
|
222
|
+
}
|
|
223
|
+
const outcome = taskState.outcome;
|
|
224
|
+
if (taskState.status === "terminal" && (outcome?.status === "faulted" || outcome?.status === "orphaned")) {
|
|
225
|
+
events.push({ type: "task_failed", taskId: id, kind: task.kind, message: outcome.status === "faulted" ? outcome.error?.message : outcome.reason });
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (turnEnded)
|
|
229
|
+
events.push({ type: "turn_end" });
|
|
230
|
+
// The run's end: its inputs settled.
|
|
231
|
+
const settling = [];
|
|
232
|
+
for (const record of submissions) {
|
|
233
|
+
const settled = record.status === "done" || record.status === "unanswered";
|
|
234
|
+
if (record.type === "input" && settled && state.run?.inputs.includes(Number(record.id)))
|
|
235
|
+
settling.push(record);
|
|
236
|
+
}
|
|
237
|
+
if (state.run && settling.length > 0 && state.run.inputs.every((id) => settling.some((record) => Number(record.id) === id) || isSettled(state.submissions.get(id)))) {
|
|
238
|
+
events.push({ type: "run_end", inputs: state.run.inputs });
|
|
239
|
+
state.run = undefined;
|
|
240
|
+
}
|
|
241
|
+
// Submissions this commit wrote, each in the state it wrote.
|
|
242
|
+
const placed = [];
|
|
243
|
+
for (const record of [...submissions].sort((a, b) => Number(a.id) - Number(b.id))) {
|
|
244
|
+
const before = state.submissions.get(Number(record.id));
|
|
245
|
+
events.push({ type: "submission", record });
|
|
246
|
+
state.submissions.set(Number(record.id), record);
|
|
247
|
+
if (record.type === "input" && before === undefined)
|
|
248
|
+
placed.push(record);
|
|
249
|
+
}
|
|
250
|
+
// The documents that keep no history: only their own changes.
|
|
251
|
+
const inbox = doc(state, "pi.inbox");
|
|
252
|
+
if (inbox !== docsBefore.get("pi.inbox"))
|
|
253
|
+
events.push({ type: "inbox_update", items: (inbox?.items ?? []).map((item) => ({ id: item.id, mode: item.mode })) });
|
|
254
|
+
const agent = doc(state, "pi.agent");
|
|
255
|
+
if (agent !== docsBefore.get("pi.agent"))
|
|
256
|
+
events.push({ type: "agent_changed", agent: agent ?? AgentDoc.definition.initial() });
|
|
257
|
+
const usage = doc(state, "pi.usage");
|
|
258
|
+
if (usage !== docsBefore.get("pi.usage"))
|
|
259
|
+
events.push({ type: "usage_changed", usage: usage ?? UsageDoc.definition.initial() });
|
|
260
|
+
// The run's start, with the inputs placed in it, then its first turn; a later turn's start.
|
|
261
|
+
if (!state.run && placed.length > 0) {
|
|
262
|
+
state.run = { inputs: placed.map((record) => Number(record.id)) };
|
|
263
|
+
events.push({ type: "run_start", inputs: state.run.inputs });
|
|
264
|
+
}
|
|
265
|
+
for (const task of tasks) {
|
|
266
|
+
const id = Number(task.id);
|
|
267
|
+
if (task.kind !== PI_GENERATION || state.turns.has(id))
|
|
268
|
+
continue;
|
|
269
|
+
state.turns.add(id);
|
|
270
|
+
events.push({ type: "turn_start" });
|
|
271
|
+
}
|
|
272
|
+
for (const task of tasks)
|
|
273
|
+
state.tasks.set(Number(task.id), task);
|
|
274
|
+
return events;
|
|
275
|
+
}
|
|
276
|
+
const isSettled = (record) => record !== undefined && (record.status === "done" || record.status === "unanswered");
|
package/dist/llm.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sideRequests } from "./cap.js";
|
|
1
2
|
export const LLM_TOOL = "llm";
|
|
2
3
|
const MAX_PROMPT = 400_000;
|
|
3
4
|
/** The completer over `models`, each call on `pick(tier)`'s model at `thinking`. */
|
|
@@ -23,6 +24,8 @@ export function completer(models, pick, thinking) {
|
|
|
23
24
|
if (!model)
|
|
24
25
|
throw new Error(`llm: the model ${ref.provider}/${ref.modelId} is not known here`);
|
|
25
26
|
const context = { ...(system ? { systemPrompt: system } : {}), messages: [{ role: "user", content: prompt, timestamp: Date.now() }] };
|
|
27
|
+
// A side request of its own (request-start.ts): its marks name it "llm", never the default a compaction's summary takes.
|
|
28
|
+
sideRequests.set(context, { label: LLM_TOOL, extraInputTokens: 0, maxFeeUsd: 0, feeUsd: () => 0 });
|
|
26
29
|
const message = await models.completeSimple(model, context, { signal, reasoning: thinking, ...(maxTokens ? { maxTokens } : {}) });
|
|
27
30
|
if (message.stopReason === "error" || message.stopReason === "aborted")
|
|
28
31
|
throw new Error(`llm: ${message.errorMessage ?? message.stopReason}`);
|
package/dist/llms.txt
CHANGED
|
@@ -34,4 +34,5 @@ Auth: the API's routes take `Authorization: Bearer <token>`, all but `GET /v2/he
|
|
|
34
34
|
## Optional
|
|
35
35
|
|
|
36
36
|
- [Skill for coding agents](https://github.com/Parcha-ai/agentrun/blob/main/packages/serve/skills/agentrun-serve/SKILL.md): check the server, the token, connect over MCP, create an agent, run it and answer it, step by step.
|
|
37
|
+
- [CLI skill for coding agents](https://github.com/Parcha-ai/agentrun/blob/main/packages/agentrun/skills/agentrun-cli/SKILL.md): the `agentrun` CLI (`npx @parcha/agentrun skill install`) for everything the MCP tools do not cover: tool keys, triggers, webhooks, files, revisions, waiting on a run.
|
|
37
38
|
- [README](https://github.com/Parcha-ai/agentrun/blob/main/packages/serve/README.md): every flag, model, tool and route.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Api, Model, MutableModels } from "@earendil-works/pi-ai";
|
|
2
|
+
/** Particle-1's price, USD per million tokens: Particle's own list price, from https://docs.particle.ai/models (read
|
|
3
|
+
* 2026-11-07: $0.25 input, $0.03 cached input, $1.00 output; no cache-write price, so $0). */
|
|
4
|
+
export declare const PARTICLE_1_PRICE: {
|
|
5
|
+
readonly input: 0.25;
|
|
6
|
+
readonly output: 1;
|
|
7
|
+
readonly cacheRead: 0.03;
|
|
8
|
+
readonly cacheWrite: 0;
|
|
9
|
+
};
|
|
10
|
+
/** Prices serve sets over pi-ai's own catalog entries, by provider and id. pi-ai 1.5.0 lists particle-ai/particle-1 at
|
|
11
|
+
* OpenRouter's current promotional price ($0.05 input, $0.003 cache read, $0.50 output). A run's cap holds each request
|
|
12
|
+
* at its worst case, priced from the catalog, before it is sent, and a hold must never price below what can be billed:
|
|
13
|
+
* the promotion can end before the catalog follows. So the hold takes Particle's list price. What a request is booked
|
|
14
|
+
* at once it answers stays pi-ai's: OpenRouter's billed total (Usage.cost.totalFromProvider), and this price only
|
|
15
|
+
* where OpenRouter reports none. */
|
|
16
|
+
export declare const PRICE_OVERRIDES: readonly {
|
|
17
|
+
readonly provider: string;
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly cost: Model<Api>["cost"];
|
|
20
|
+
}[];
|
|
21
|
+
/** `models` (pi-ai's built-in catalog, or one built on it) with PRICE_OVERRIDES set on their providers' own entries, in
|
|
22
|
+
* place: a request, a price and a capability read find the catalog's entry at the overridden price. */
|
|
23
|
+
export declare function withLocalModels<M extends MutableModels>(models: M): M;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Particle-1's price, USD per million tokens: Particle's own list price, from https://docs.particle.ai/models (read
|
|
2
|
+
* 2026-11-07: $0.25 input, $0.03 cached input, $1.00 output; no cache-write price, so $0). */
|
|
3
|
+
export const PARTICLE_1_PRICE = { input: 0.25, output: 1, cacheRead: 0.03, cacheWrite: 0 };
|
|
4
|
+
/** Prices serve sets over pi-ai's own catalog entries, by provider and id. pi-ai 1.5.0 lists particle-ai/particle-1 at
|
|
5
|
+
* OpenRouter's current promotional price ($0.05 input, $0.003 cache read, $0.50 output). A run's cap holds each request
|
|
6
|
+
* at its worst case, priced from the catalog, before it is sent, and a hold must never price below what can be billed:
|
|
7
|
+
* the promotion can end before the catalog follows. So the hold takes Particle's list price. What a request is booked
|
|
8
|
+
* at once it answers stays pi-ai's: OpenRouter's billed total (Usage.cost.totalFromProvider), and this price only
|
|
9
|
+
* where OpenRouter reports none. */
|
|
10
|
+
export const PRICE_OVERRIDES = [
|
|
11
|
+
{ provider: "openrouter", id: "particle-ai/particle-1", cost: { ...PARTICLE_1_PRICE } },
|
|
12
|
+
];
|
|
13
|
+
/** `list` with each overridden model's price in place of the catalog's, whole: a field of the catalog's cost the override
|
|
14
|
+
* does not name (its price `tiers`, which pi-ai's calculateCost prices a request at once its input passes one) never
|
|
15
|
+
* survives, so a later catalog's promotional tier cannot price a hold below the list price. */
|
|
16
|
+
const priced = (list, overrides) => list.map((model) => {
|
|
17
|
+
const override = overrides.find((entry) => entry.id === model.id);
|
|
18
|
+
return override ? { ...model, cost: { ...override.cost } } : model;
|
|
19
|
+
});
|
|
20
|
+
/** `models` (pi-ai's built-in catalog, or one built on it) with PRICE_OVERRIDES set on their providers' own entries, in
|
|
21
|
+
* place: a request, a price and a capability read find the catalog's entry at the overridden price. */
|
|
22
|
+
export function withLocalModels(models) {
|
|
23
|
+
for (const providerId of new Set(PRICE_OVERRIDES.map((entry) => entry.provider))) {
|
|
24
|
+
const own = models.getProvider(providerId);
|
|
25
|
+
if (!own)
|
|
26
|
+
continue;
|
|
27
|
+
const overrides = PRICE_OVERRIDES.filter((entry) => entry.provider === providerId);
|
|
28
|
+
const listed = Object.assign(Object.create(own), {
|
|
29
|
+
getModels: () => priced(own.getModels(), overrides),
|
|
30
|
+
...(own.getAllModels ? { getAllModels: () => priced(own.getAllModels(), overrides) } : {}),
|
|
31
|
+
});
|
|
32
|
+
models.setProvider(listed);
|
|
33
|
+
}
|
|
34
|
+
return models;
|
|
35
|
+
}
|