@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
package/dist/run-db.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { DatabaseSync } from "node:sqlite";
|
|
2
|
+
/** One open of a run's database, as observeRunDbOpens reports it: `held`, whether a process held the run at the open. */
|
|
3
|
+
/** `dropped`: a read of the file alone whose file changed during it, made again (readRunDbSync). */
|
|
4
|
+
export type RunDbOpen = {
|
|
5
|
+
file: string;
|
|
6
|
+
mode: "read" | "checkpoint" | "dropped";
|
|
7
|
+
held: boolean;
|
|
8
|
+
};
|
|
9
|
+
/** Tells `observer` of every open of a run's database from here on (tests); the returned call stops it. */
|
|
10
|
+
export declare function observeRunDbOpens(observer: (open: RunDbOpen) => void): () => void;
|
|
11
|
+
/** Tests' seams: `afterPlan`, called between a read's choice of how to open the file and its open; `madeReads`, called
|
|
12
|
+
* with each MonotonicReads made; `beforeCheckpoint`, called with the take-back's connection just before its close. */
|
|
13
|
+
export declare const runDbTestHooks: {
|
|
14
|
+
afterPlan?: (file: string) => void;
|
|
15
|
+
madeReads?: (reads: MonotonicReads) => void;
|
|
16
|
+
beforeCheckpoint?: (db: DatabaseSync) => void;
|
|
17
|
+
};
|
|
18
|
+
/** A read of a run's database file alone whose file changed during it (a run's process wrote and a take-back checkpointed
|
|
19
|
+
* meanwhile), every try: none of them is shown. */
|
|
20
|
+
export declare class ChangedReadError extends Error {
|
|
21
|
+
constructor(file: string, tries: number);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* One read of run database `file`: `read(db)` on a fresh read-only, lock-free connection, closed after it. A WAL that
|
|
25
|
+
* holds a commit SQLite's recovery takes (walHasCommit): opened with no locking (`vfs=unix-none`), the WAL read too. No
|
|
26
|
+
* WAL, or one with no verified commit yet (a fresh WAL's first transaction, its frames written and no commit): the
|
|
27
|
+
* database file alone, as an immutable file, which is whole then; its read is kept only when the file did not change
|
|
28
|
+
* during it (fileMark), else it is dropped and made again. SQLite's lock-free reader of a WAL with no commit recovers no
|
|
29
|
+
* frame, and its close, a checkpoint with nothing to copy, removes the WAL (sqlite3WalClose) under the writer still
|
|
30
|
+
* writing it, whose commits are then lost; with a commit, that close's checkpoint must write the database file, which
|
|
31
|
+
* this read-only connection cannot, so it fails and removes nothing. Every read and the take-back's checkpoint run in one
|
|
32
|
+
* turn of this process's event loop, and the run's process only appends to its WAL, so the WAL a read opens holds at
|
|
33
|
+
* least the commit its check saw. A read-only close checkpoints nothing it can write. `held`: whether a process holds the
|
|
34
|
+
* run now (reported to observers).
|
|
35
|
+
*/
|
|
36
|
+
export declare function readRunDbSync<T>(file: string, held: boolean, read: (db: DatabaseSync) => T): T;
|
|
37
|
+
/** A read of a run's database whose last entry is below one already seen for that run: an older view of the file, which a
|
|
38
|
+
* read must never show (the monotonic guard). The caller keeps what it read before. */
|
|
39
|
+
export declare class BehindReadError extends Error {
|
|
40
|
+
readonly seen: number;
|
|
41
|
+
readonly read: number;
|
|
42
|
+
constructor(seen: number, read: number);
|
|
43
|
+
}
|
|
44
|
+
/** The highest entry id each run's reads have seen: a read below it is refused (BehindReadError). */
|
|
45
|
+
export declare class MonotonicReads {
|
|
46
|
+
#private;
|
|
47
|
+
constructor();
|
|
48
|
+
/** How many runs' reads it keeps. */
|
|
49
|
+
get size(): number;
|
|
50
|
+
/** Accepts run `runId`'s read that ends at entry `last` (0 for none), or throws BehindReadError. */
|
|
51
|
+
accept(runId: string, last: number): void;
|
|
52
|
+
/** Forgets run `runId`'s reads: a run that is gone, or whose store was replaced. */
|
|
53
|
+
forget(runId: string): void;
|
|
54
|
+
}
|
|
55
|
+
/** A read-write open of a run's database while a process holds the run: refused, never made. */
|
|
56
|
+
export declare class HeldRunDbError extends Error {
|
|
57
|
+
constructor(file: string);
|
|
58
|
+
}
|
|
59
|
+
/** Checkpoints the run database at `file` into its database file and removes its WAL, once no process holds the run
|
|
60
|
+
* (`held` false; true throws HeldRunDbError before any open). A database with no WAL left is untouched but for the
|
|
61
|
+
* open. The one read-write open the server makes of a run's database. */
|
|
62
|
+
export declare function checkpointRunDb(file: string, held: boolean, platform?: NodeJS.Platform): Promise<void>;
|
package/dist/run-db.js
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// How the server opens a run's database, run.sqlite, which the run's own process writes: in WAL, under an exclusive lock,
|
|
2
|
+
// with no automatic checkpoint, and ended by process.exit with no close (pi-durable-disk's exclusive profile, keepWal),
|
|
3
|
+
// so its WAL stays until whoever takes the run back checkpoints it. The server never opens it read-write while a
|
|
4
|
+
// process holds the run: every read is a fresh read-only open with no locking (`vfs=unix-none`) and an exclusive
|
|
5
|
+
// locking mode (the WAL index in heap, no -shm), kept for that read alone, since a connection kept open falls behind
|
|
6
|
+
// the WAL; and a read whose last entry is below one already seen for that run is refused, never shown (the monotonic
|
|
7
|
+
// guard). The one read-write open is the checkpoint when the server takes the run back (runs.ts), with no process left.
|
|
8
|
+
import { closeSync, openSync, readSync, statSync } from "node:fs";
|
|
9
|
+
import { DatabaseSync } from "node:sqlite";
|
|
10
|
+
import { forgetWalWalk, walHasCommit } from "@parcha/agentrun-pi/durable";
|
|
11
|
+
import { profilePragmas } from "@parcha/pi-durable-disk/internals";
|
|
12
|
+
const observers = new Set();
|
|
13
|
+
/** Tells `observer` of every open of a run's database from here on (tests); the returned call stops it. */
|
|
14
|
+
export function observeRunDbOpens(observer) {
|
|
15
|
+
observers.add(observer);
|
|
16
|
+
return () => void observers.delete(observer);
|
|
17
|
+
}
|
|
18
|
+
/** `file` as a SQLite URI path: each segment percent-encoded, so a `?`, `#` or `%` in it is never read as a parameter. */
|
|
19
|
+
const uriPath = (file) => file.split("/").map(encodeURIComponent).join("/");
|
|
20
|
+
/** What says run database `file` changed: its inode, size and modification time, and its header's file change counter and
|
|
21
|
+
* page count (bytes 24 to 31). In WAL mode SQLite does not bump the counter at each commit, but a checkpoint writes the
|
|
22
|
+
* database file, so its time and size move; a reader of the file alone compares this before and after its read. */
|
|
23
|
+
function fileMark(file) {
|
|
24
|
+
const at = statSync(file, { bigint: true });
|
|
25
|
+
const header = Buffer.alloc(8);
|
|
26
|
+
const fd = openSync(file, "r");
|
|
27
|
+
try {
|
|
28
|
+
readSync(fd, header, 0, 8, 24);
|
|
29
|
+
}
|
|
30
|
+
finally {
|
|
31
|
+
closeSync(fd);
|
|
32
|
+
}
|
|
33
|
+
return `${at.ino}:${at.size}:${at.mtimeNs}:${header.toString("hex")}`;
|
|
34
|
+
}
|
|
35
|
+
/** Tests' seams: `afterPlan`, called between a read's choice of how to open the file and its open; `madeReads`, called
|
|
36
|
+
* with each MonotonicReads made; `beforeCheckpoint`, called with the take-back's connection just before its close. */
|
|
37
|
+
export const runDbTestHooks = {};
|
|
38
|
+
/** A read of a run's database file alone whose file changed during it (a run's process wrote and a take-back checkpointed
|
|
39
|
+
* meanwhile), every try: none of them is shown. */
|
|
40
|
+
export class ChangedReadError extends Error {
|
|
41
|
+
constructor(file, tries) {
|
|
42
|
+
super(`the run's database ${file} changed during each of ${tries} reads`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/** How many times a read whose file changed during it is made again before ChangedReadError. */
|
|
46
|
+
const READ_TRIES = 3;
|
|
47
|
+
/**
|
|
48
|
+
* One read of run database `file`: `read(db)` on a fresh read-only, lock-free connection, closed after it. A WAL that
|
|
49
|
+
* holds a commit SQLite's recovery takes (walHasCommit): opened with no locking (`vfs=unix-none`), the WAL read too. No
|
|
50
|
+
* WAL, or one with no verified commit yet (a fresh WAL's first transaction, its frames written and no commit): the
|
|
51
|
+
* database file alone, as an immutable file, which is whole then; its read is kept only when the file did not change
|
|
52
|
+
* during it (fileMark), else it is dropped and made again. SQLite's lock-free reader of a WAL with no commit recovers no
|
|
53
|
+
* frame, and its close, a checkpoint with nothing to copy, removes the WAL (sqlite3WalClose) under the writer still
|
|
54
|
+
* writing it, whose commits are then lost; with a commit, that close's checkpoint must write the database file, which
|
|
55
|
+
* this read-only connection cannot, so it fails and removes nothing. Every read and the take-back's checkpoint run in one
|
|
56
|
+
* turn of this process's event loop, and the run's process only appends to its WAL, so the WAL a read opens holds at
|
|
57
|
+
* least the commit its check saw. A read-only close checkpoints nothing it can write. `held`: whether a process holds the
|
|
58
|
+
* run now (reported to observers).
|
|
59
|
+
*/
|
|
60
|
+
export function readRunDbSync(file, held, read) {
|
|
61
|
+
for (let attempt = 1;; attempt++) {
|
|
62
|
+
for (const observer of observers)
|
|
63
|
+
observer({ file, mode: "read", held });
|
|
64
|
+
// A WAL is opened only once it holds a commit SQLite's recovery takes (agentrun-pi walHasCommit).
|
|
65
|
+
const immutable = !walHasCommit(`${file}-wal`);
|
|
66
|
+
const before = immutable ? fileMark(file) : undefined;
|
|
67
|
+
runDbTestHooks.afterPlan?.(file);
|
|
68
|
+
const db = new DatabaseSync(immutable ? `file:${uriPath(file)}?mode=ro&immutable=1` : `file:${uriPath(file)}?mode=ro&vfs=unix-none`, { readOnly: true });
|
|
69
|
+
let result;
|
|
70
|
+
try {
|
|
71
|
+
db.exec("PRAGMA locking_mode = EXCLUSIVE");
|
|
72
|
+
result = read(db);
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
db.close();
|
|
76
|
+
}
|
|
77
|
+
if (!immutable || fileMark(file) === before)
|
|
78
|
+
return result;
|
|
79
|
+
for (const observer of observers)
|
|
80
|
+
observer({ file, mode: "dropped", held });
|
|
81
|
+
if (attempt >= READ_TRIES)
|
|
82
|
+
throw new ChangedReadError(file, attempt);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/** A read of a run's database whose last entry is below one already seen for that run: an older view of the file, which a
|
|
86
|
+
* read must never show (the monotonic guard). The caller keeps what it read before. */
|
|
87
|
+
export class BehindReadError extends Error {
|
|
88
|
+
seen;
|
|
89
|
+
read;
|
|
90
|
+
constructor(seen, read) {
|
|
91
|
+
super(`the run's database read ends at entry ${read}, behind entry ${seen} read before`);
|
|
92
|
+
this.seen = seen;
|
|
93
|
+
this.read = read;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/** The highest entry id each run's reads have seen: a read below it is refused (BehindReadError). */
|
|
97
|
+
export class MonotonicReads {
|
|
98
|
+
#seen = new Map();
|
|
99
|
+
constructor() {
|
|
100
|
+
runDbTestHooks.madeReads?.(this);
|
|
101
|
+
}
|
|
102
|
+
/** How many runs' reads it keeps. */
|
|
103
|
+
get size() {
|
|
104
|
+
return this.#seen.size;
|
|
105
|
+
}
|
|
106
|
+
/** Accepts run `runId`'s read that ends at entry `last` (0 for none), or throws BehindReadError. */
|
|
107
|
+
accept(runId, last) {
|
|
108
|
+
const seen = this.#seen.get(runId) ?? 0;
|
|
109
|
+
if (last < seen)
|
|
110
|
+
throw new BehindReadError(seen, last);
|
|
111
|
+
this.#seen.set(runId, last);
|
|
112
|
+
}
|
|
113
|
+
/** Forgets run `runId`'s reads: a run that is gone, or whose store was replaced. */
|
|
114
|
+
forget(runId) {
|
|
115
|
+
this.#seen.delete(runId);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/** A read-write open of a run's database while a process holds the run: refused, never made. */
|
|
119
|
+
export class HeldRunDbError extends Error {
|
|
120
|
+
constructor(file) {
|
|
121
|
+
super(`the server never opens a run's database read-write while a process holds the run (${file})`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/** Checkpoints the run database at `file` into its database file and removes its WAL, once no process holds the run
|
|
125
|
+
* (`held` false; true throws HeldRunDbError before any open). A database with no WAL left is untouched but for the
|
|
126
|
+
* open. The one read-write open the server makes of a run's database. */
|
|
127
|
+
export async function checkpointRunDb(file, held, platform = process.platform) {
|
|
128
|
+
for (const observer of observers)
|
|
129
|
+
observer({ file, mode: "checkpoint", held });
|
|
130
|
+
if (held)
|
|
131
|
+
throw new HeldRunDbError(file);
|
|
132
|
+
const db = new DatabaseSync(file, { timeout: 0 });
|
|
133
|
+
try {
|
|
134
|
+
// As its writer opened it (pi-durable-disk's exclusive profile): the WAL index in heap, so no -shm is made; and on
|
|
135
|
+
// macOS F_FULLFSYNC (`fullfsync`, `checkpoint_fullfsync`), as fsync there leaves the drive's cache unflushed. And
|
|
136
|
+
// synchronous FULL whatever level the run's journal runs at, so the checkpoint's copy is synced into the database file
|
|
137
|
+
// before the WAL that held it is removed (pi-durable-disk barriers.ts lists this store as FULL).
|
|
138
|
+
for (const [pragma, value] of Object.entries(profilePragmas("exclusive", platform, "FULL")))
|
|
139
|
+
db.exec(`PRAGMA ${pragma} = ${value}`);
|
|
140
|
+
db.prepare("SELECT count(*) FROM sqlite_schema").get();
|
|
141
|
+
runDbTestHooks.beforeCheckpoint?.(db);
|
|
142
|
+
}
|
|
143
|
+
finally {
|
|
144
|
+
// The close checkpoints: it copies into the database file only pages the WAL holds too, so a lock-free reader still
|
|
145
|
+
// reading the WAL reads the same bytes either way; then it removes the WAL, which a reader that holds it open goes on
|
|
146
|
+
// reading. Never wal_checkpoint(TRUNCATE): that cuts the WAL under such a reader, whose read then fails.
|
|
147
|
+
db.close();
|
|
148
|
+
// The WAL is gone, and with it what was kept of its walk (walHasCommit).
|
|
149
|
+
forgetWalWalk(`${file}-wal`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import { type Entry, type Workspace } from "./workspace/index.js";
|
|
3
|
+
/** How many folders deep the list goes: a folder below it is not entered, and the list says it is not whole. */
|
|
4
|
+
export declare const WALK_DEPTH = 16;
|
|
5
|
+
/** The CSP a served HTML file runs under: an opaque origin, no scripts, no network. */
|
|
6
|
+
export declare const FILE_CSP = "default-src 'none'; style-src 'unsafe-inline'; img-src data:; sandbox; form-action 'none'";
|
|
7
|
+
export type FileView = {
|
|
8
|
+
path: string;
|
|
9
|
+
size_bytes: number;
|
|
10
|
+
modified_at: string;
|
|
11
|
+
content_type: string | null;
|
|
12
|
+
unreadable?: true;
|
|
13
|
+
};
|
|
14
|
+
/** File `path` as the API lists it, from its Workspace listing entry. */
|
|
15
|
+
export declare const viewOf: (path: string, entry: Entry) => FileView;
|
|
16
|
+
/** The files of `workspace`, walked from its root: each file's own size and time, a dot-name and all below it left
|
|
17
|
+
* out. It stops past `cap` files. `deep` when a folder more than WALK_DEPTH deep was there and not entered. A name at
|
|
18
|
+
* the root that `owned` says is the host's (an agent home's learning/) is named in `owned`, and nothing below it read. */
|
|
19
|
+
export declare function listFiles(workspace: Workspace, cap: number, { owned: isOwned }?: {
|
|
20
|
+
owned?: (name: string) => boolean;
|
|
21
|
+
}): Promise<{
|
|
22
|
+
files: FileView[];
|
|
23
|
+
deep: boolean;
|
|
24
|
+
owned: string[];
|
|
25
|
+
}>;
|
|
26
|
+
/** The listing entry at `rel`, a file's or a folder's, or undefined when there is none: not there, or a link (never
|
|
27
|
+
* listed). */
|
|
28
|
+
export declare function entryAt(workspace: Workspace, rel: string): Promise<Entry | undefined>;
|
|
29
|
+
/** File `rel` of `workspace`, raw, in reads of SEND_CHUNK: its length from the listing, so HEAD reads no byte. `who`
|
|
30
|
+
* names who makes a file private, in the words of a 403. */
|
|
31
|
+
export declare function sendFile(req: IncomingMessage, res: ServerResponse, url: URL, workspace: Workspace, rel: string, who: string): Promise<void>;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { ApiError } from "./errors.js";
|
|
2
|
+
import { INLINE_TYPES, typeOf } from "./file-types.js";
|
|
3
|
+
import { isWorkspaceError } from "./workspace/index.js";
|
|
4
|
+
/** How many folders deep the list goes: a folder below it is not entered, and the list says it is not whole. */
|
|
5
|
+
export const WALK_DEPTH = 16;
|
|
6
|
+
/** How much one read of a file being sent takes. */
|
|
7
|
+
const SEND_CHUNK = 4 * 1024 * 1024;
|
|
8
|
+
/** The CSP a served HTML file runs under: an opaque origin, no scripts, no network. */
|
|
9
|
+
export const FILE_CSP = "default-src 'none'; style-src 'unsafe-inline'; img-src data:; sandbox; form-action 'none'";
|
|
10
|
+
/** File `path` as the API lists it, from its Workspace listing entry. */
|
|
11
|
+
export const viewOf = (path, entry) => ({
|
|
12
|
+
path, size_bytes: entry.size, modified_at: new Date(entry.mtimeMs).toISOString(), content_type: typeOf(path) ?? null, ...(entry.unreadable ? { unreadable: true } : {}),
|
|
13
|
+
});
|
|
14
|
+
/** A folder the list skips, saying nothing: not there, a link on the way, or one this server may not enter. A backend
|
|
15
|
+
* that cannot answer (UNAVAILABLE, TIMEOUT) fails the list. */
|
|
16
|
+
const skipped = (error) => isWorkspaceError(error) && (error.code === "NOT_FOUND" || error.code === "ESCAPE" || error.code === "REFUSED");
|
|
17
|
+
/** The files of `workspace`, walked from its root: each file's own size and time, a dot-name and all below it left
|
|
18
|
+
* out. It stops past `cap` files. `deep` when a folder more than WALK_DEPTH deep was there and not entered. A name at
|
|
19
|
+
* the root that `owned` says is the host's (an agent home's learning/) is named in `owned`, and nothing below it read. */
|
|
20
|
+
export async function listFiles(workspace, cap, { owned: isOwned } = {}) {
|
|
21
|
+
const files = [];
|
|
22
|
+
const owned = [];
|
|
23
|
+
let deep = false;
|
|
24
|
+
const into = async (dir, level) => {
|
|
25
|
+
let entries;
|
|
26
|
+
try {
|
|
27
|
+
entries = await workspace.list(dir);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (skipped(error))
|
|
31
|
+
return true;
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
for (const entry of entries) {
|
|
35
|
+
if (entry.name.startsWith("."))
|
|
36
|
+
continue;
|
|
37
|
+
if (dir === "" && isOwned?.(entry.name)) {
|
|
38
|
+
owned.push(entry.name);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const path = dir === "" ? entry.name : `${dir}/${entry.name}`;
|
|
42
|
+
if (entry.kind === "file") {
|
|
43
|
+
files.push(viewOf(path, entry));
|
|
44
|
+
if (files.length > cap)
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
else if (level + 1 > WALK_DEPTH)
|
|
48
|
+
deep = true;
|
|
49
|
+
else if (!(await into(path, level + 1)))
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
};
|
|
54
|
+
await into("", 0);
|
|
55
|
+
return { files, deep, owned };
|
|
56
|
+
}
|
|
57
|
+
/** The listing entry at `rel`, a file's or a folder's, or undefined when there is none: not there, or a link (never
|
|
58
|
+
* listed). */
|
|
59
|
+
export async function entryAt(workspace, rel) {
|
|
60
|
+
const cut = rel.lastIndexOf("/");
|
|
61
|
+
const name = rel.slice(cut + 1);
|
|
62
|
+
try {
|
|
63
|
+
return (await workspace.list(cut < 0 ? "" : rel.slice(0, cut))).find((entry) => entry.name === name);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
if (skipped(error))
|
|
67
|
+
return undefined;
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** The listing entry of file `rel`, or undefined when there is none: not there, a link (never listed), a folder. */
|
|
72
|
+
const fileEntry = async (workspace, rel) => {
|
|
73
|
+
const entry = await entryAt(workspace, rel);
|
|
74
|
+
return entry?.kind === "file" ? entry : undefined;
|
|
75
|
+
};
|
|
76
|
+
/** File `rel` of `workspace`, raw, in reads of SEND_CHUNK: its length from the listing, so HEAD reads no byte. `who`
|
|
77
|
+
* names who makes a file private, in the words of a 403. */
|
|
78
|
+
export async function sendFile(req, res, url, workspace, rel, who) {
|
|
79
|
+
const unreadable = () => new ApiError("system_file_forbidden", `This file was created private by ${who}: this server cannot read it.`, { details: { reason: "unreadable" } });
|
|
80
|
+
const entry = await fileEntry(workspace, rel);
|
|
81
|
+
if (!entry)
|
|
82
|
+
throw new ApiError("not_found", "no such file");
|
|
83
|
+
if (entry.unreadable)
|
|
84
|
+
throw unreadable();
|
|
85
|
+
// A GET reads its first chunk before the head: a file gone, or swapped for a link, since the listing is a 404, not a
|
|
86
|
+
// broken 200. A HEAD reads none.
|
|
87
|
+
const first = req.method === "HEAD" ? new Uint8Array(0) : await workspace.read(rel, { offset: 0, length: Math.min(SEND_CHUNK, entry.size) }).catch((error) => {
|
|
88
|
+
if (isWorkspaceError(error, "REFUSED"))
|
|
89
|
+
throw unreadable();
|
|
90
|
+
if (skipped(error))
|
|
91
|
+
throw new ApiError("not_found", "no such file");
|
|
92
|
+
throw error;
|
|
93
|
+
});
|
|
94
|
+
const type = typeOf(rel) ?? "application/octet-stream";
|
|
95
|
+
const download = url.searchParams.get("download") === "1" || !INLINE_TYPES.has(type);
|
|
96
|
+
const name = rel.split("/").at(-1).replace(/[^\w.-]/g, "_");
|
|
97
|
+
res.writeHead(200, {
|
|
98
|
+
"content-type": type,
|
|
99
|
+
"content-length": entry.size,
|
|
100
|
+
"x-content-type-options": "nosniff",
|
|
101
|
+
"cache-control": "no-store",
|
|
102
|
+
...(type.startsWith("text/html") ? { "content-security-policy": FILE_CSP } : {}),
|
|
103
|
+
...(download ? { "content-disposition": `attachment; filename="${name}"` } : {}),
|
|
104
|
+
});
|
|
105
|
+
if (req.method === "HEAD")
|
|
106
|
+
return void res.end();
|
|
107
|
+
// The length said is the listing's: a file that changes while it is sent is cut there, or the answer ends short.
|
|
108
|
+
try {
|
|
109
|
+
let sent = 0;
|
|
110
|
+
for (let chunk = first;; chunk = await workspace.read(rel, { offset: sent, length: Math.min(SEND_CHUNK, entry.size - sent) })) {
|
|
111
|
+
if (chunk.length === 0 || res.destroyed)
|
|
112
|
+
break;
|
|
113
|
+
if (!res.write(chunk))
|
|
114
|
+
await new Promise((resolve) => { res.once("drain", resolve); res.once("close", resolve); });
|
|
115
|
+
sent += chunk.length;
|
|
116
|
+
if (sent >= entry.size)
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
// Mid-answer there is no status left to give: the answer ends, short of its length, which the client sees.
|
|
122
|
+
return void res.destroy();
|
|
123
|
+
}
|
|
124
|
+
res.end();
|
|
125
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { type MessageOrigin } from "@parcha/pi-durable-agent/timeline";
|
|
2
|
+
import type { Plane } from "./tool-plane.js";
|
|
3
|
+
import type { RunTrigger } from "./triggers.js";
|
|
4
|
+
import { type Json } from "./validate.js";
|
|
5
|
+
import type { Place } from "./workspace/place.js";
|
|
6
|
+
/** What a run is launched with: everything its runner needs to build the run's spec at its claim, nothing derived later.
|
|
7
|
+
* The server writes it once at start; the runner reads it at each claim (its claim rebuilds the run from the store, this
|
|
8
|
+
* body included). `harness` picks the loop's adapter (a built-in learning run names "learning"; absent, the revision's
|
|
9
|
+
* harness is used); `input` is the start request's body for a person's or a trigger's run, or an object a built-in run
|
|
10
|
+
* names (a learning run's `{ runId }`). `model`, `plane`, `approvers`, `documents` and `boxAllow` are the per-run choices
|
|
11
|
+
* the old path recomputed; here they are pinned at start, and optional (a built-in run may name none). */
|
|
12
|
+
export interface RunLaunch {
|
|
13
|
+
/** The start request's body, as the person or trigger gave it, or an object a built-in run names. */
|
|
14
|
+
readonly input: unknown;
|
|
15
|
+
readonly title: string;
|
|
16
|
+
readonly place: Place;
|
|
17
|
+
/** The loop's adapter, when not the revision's: a built-in learning run names "learning". */
|
|
18
|
+
readonly harness?: string;
|
|
19
|
+
/** The run's model, pinned at start. */
|
|
20
|
+
readonly model?: {
|
|
21
|
+
readonly provider: string;
|
|
22
|
+
readonly modelId: string;
|
|
23
|
+
};
|
|
24
|
+
readonly effort?: string;
|
|
25
|
+
readonly maxCostUsd?: number;
|
|
26
|
+
readonly capMode?: string;
|
|
27
|
+
/** The tool plane as the server resolved it at start (tool-plane.ts). */
|
|
28
|
+
readonly plane?: Plane;
|
|
29
|
+
/** Whether a person can answer a tool call's approval for this run. */
|
|
30
|
+
readonly approvers?: boolean;
|
|
31
|
+
/** The documents directory a workflow's reads are rooted at, when the server gives one. */
|
|
32
|
+
readonly documents?: string;
|
|
33
|
+
/** What a run's box may reach, as the server resolved it: the list, or "none". */
|
|
34
|
+
readonly boxAllow?: readonly string[] | "none";
|
|
35
|
+
/** The uploaded file ids the run was started with, in order (the create body's file_ids, already checked ready): the
|
|
36
|
+
* runner copies them into the run's work/inputs/ at its claim, as the old start copied them before the process ran. */
|
|
37
|
+
readonly files?: readonly string[];
|
|
38
|
+
/** The run's learning start, when its agent learns and the server's learning is on, decided once here so the runner reads
|
|
39
|
+
* no learning folder or git: `given`, the notes its # Learned section names (each `{file, name}`, as /runs/{id}/learning
|
|
40
|
+
* shows them); `seed`, the learning commit's sha (or null when the seed could not be read); and `section`, the exact
|
|
41
|
+
* # Learned text to lay into the prompt for those notes (what the old layLearned laid), within the learning budget; and
|
|
42
|
+
* `seedNotes`, the count of all notes in the seed before the budget picked `given` (present with a read seed; absent when
|
|
43
|
+
* the seed could not be read). Absent when the run does not learn. */
|
|
44
|
+
readonly learning?: {
|
|
45
|
+
readonly given: readonly {
|
|
46
|
+
readonly file: string;
|
|
47
|
+
readonly name: string;
|
|
48
|
+
}[];
|
|
49
|
+
readonly seed: string | null;
|
|
50
|
+
readonly section: string;
|
|
51
|
+
readonly seedNotes?: number;
|
|
52
|
+
};
|
|
53
|
+
/** The trigger and firing that started the run, or none for a person's run. */
|
|
54
|
+
readonly trigger?: RunTrigger;
|
|
55
|
+
/** Who the first message is from, when not the person: kept only through the fail-safe below. */
|
|
56
|
+
readonly inputOrigin?: MessageOrigin;
|
|
57
|
+
/** A run that re-asks its agent after it ends (a trigger's follow-up). */
|
|
58
|
+
readonly followUp?: boolean;
|
|
59
|
+
}
|
|
60
|
+
/** The input's origin kept through the fail-safe (#1856): the stored one only if it names `trigger` with
|
|
61
|
+
* owner === (its source is a schedule), else that trigger's own with owner false (its source a best-effort label: the
|
|
62
|
+
* stored one when it is a known source other than a schedule's, else "webhook"). A run with no trigger keeps none. */
|
|
63
|
+
export declare function keepInputOrigin(stored: unknown, trigger: RunTrigger | null): MessageOrigin | undefined;
|
|
64
|
+
/** The JSON body the server stores for a run's launch. `harness` is a top-level field, so the loop factory reads it from the
|
|
65
|
+
* stored body without parsing the rest. */
|
|
66
|
+
export declare function launchBody(launch: RunLaunch): Json;
|
|
67
|
+
/** A launch body read back into a `RunLaunch`, with the input-origin fail-safe applied through the body's own trigger, or
|
|
68
|
+
* undefined when the body is not one (not an object, or it names no place: a damaged or hand-edited body). */
|
|
69
|
+
export declare function readLaunchBody(stored: unknown): RunLaunch | undefined;
|
|
70
|
+
/** The run's learning start (its given notes, its seed sha and its # Learned section), read from one place by learning's
|
|
71
|
+
* routes and the runner; undefined when the run does not learn. */
|
|
72
|
+
export declare const learningStartOf: (launch: RunLaunch) => RunLaunch["learning"];
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// A run's launch record: the one JSON body the server writes when it starts a run (start = INSERT run, design 2.1), and
|
|
2
|
+
// the runner reads at its claim to build the run's spec. It replaces the per-run `serve.json` the old per-run process read
|
|
3
|
+
// (app.ts meta.input, place, effort, cap): no process, no door, no marker file, one body written once. What a person sees
|
|
4
|
+
// (the v2 start request) is unchanged; this is only where its fields live.
|
|
5
|
+
//
|
|
6
|
+
// The input's origin keeps its fail-safe on read (#1856): a run started by a trigger keeps an origin only when it names
|
|
7
|
+
// the run's own trigger with owner === (the source is a schedule, whose words its owner wrote when they set it up), else
|
|
8
|
+
// that trigger's own with owner false, so a forged or lost origin never reads as the person's or the owner's.
|
|
9
|
+
import { originOf } from "@parcha/pi-durable-agent/timeline";
|
|
10
|
+
import { isObject } from "./validate.js";
|
|
11
|
+
/** The trigger a launch body names, as read back: `{ id, firing_key }`, or null (triggerOf of the old serve.json). */
|
|
12
|
+
function readTrigger(value) {
|
|
13
|
+
return isObject(value) && typeof value.id === "string" && typeof value.firing_key === "string" ? { id: value.id, firing_key: value.firing_key } : null;
|
|
14
|
+
}
|
|
15
|
+
/** Where a run runs, as read back from a launch body, or undefined when it names none. */
|
|
16
|
+
function readPlace(value) {
|
|
17
|
+
if (!isObject(value))
|
|
18
|
+
return undefined;
|
|
19
|
+
if (value.mode === "runner")
|
|
20
|
+
return { mode: "runner" };
|
|
21
|
+
if (value.mode === "sandbox" && typeof value.box === "string")
|
|
22
|
+
return { mode: "sandbox", box: value.box };
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
/** The run's model as read back, or undefined when the body names none. */
|
|
26
|
+
const readModel = (value) => isObject(value) && typeof value.provider === "string" && typeof value.modelId === "string" ? { provider: value.provider, modelId: value.modelId } : undefined;
|
|
27
|
+
/** What a box may reach as read back: a list of strings or "none", else undefined. */
|
|
28
|
+
const readBoxAllow = (value) => value === "none" ? "none" : Array.isArray(value) && value.every((host) => typeof host === "string") ? value : undefined;
|
|
29
|
+
/** The input's origin kept through the fail-safe (#1856): the stored one only if it names `trigger` with
|
|
30
|
+
* owner === (its source is a schedule), else that trigger's own with owner false (its source a best-effort label: the
|
|
31
|
+
* stored one when it is a known source other than a schedule's, else "webhook"). A run with no trigger keeps none. */
|
|
32
|
+
export function keepInputOrigin(stored, trigger) {
|
|
33
|
+
if (trigger === null)
|
|
34
|
+
return undefined;
|
|
35
|
+
const origin = originOf(stored);
|
|
36
|
+
if (origin?.kind === "trigger" && origin.trigger_id === trigger.id && origin.owner === (origin.source === "schedule"))
|
|
37
|
+
return origin;
|
|
38
|
+
const source = origin?.kind === "trigger" && origin.source !== "schedule" ? origin.source : "webhook";
|
|
39
|
+
return { kind: "trigger", trigger_id: trigger.id, source, owner: false };
|
|
40
|
+
}
|
|
41
|
+
/** The JSON body the server stores for a run's launch. `harness` is a top-level field, so the loop factory reads it from the
|
|
42
|
+
* stored body without parsing the rest. */
|
|
43
|
+
export function launchBody(launch) {
|
|
44
|
+
return {
|
|
45
|
+
input: launch.input,
|
|
46
|
+
title: launch.title,
|
|
47
|
+
place: launch.place,
|
|
48
|
+
...(launch.harness !== undefined ? { harness: launch.harness } : {}),
|
|
49
|
+
...(launch.model ? { model: launch.model } : {}),
|
|
50
|
+
...(launch.effort !== undefined ? { effort: launch.effort } : {}),
|
|
51
|
+
...(launch.maxCostUsd !== undefined ? { max_cost_usd: launch.maxCostUsd } : {}),
|
|
52
|
+
...(launch.capMode !== undefined ? { cap_mode: launch.capMode } : {}),
|
|
53
|
+
...(launch.plane ? { plane: launch.plane } : {}),
|
|
54
|
+
...(launch.approvers !== undefined ? { approvers: launch.approvers } : {}),
|
|
55
|
+
...(launch.documents !== undefined ? { documents: launch.documents } : {}),
|
|
56
|
+
...(launch.boxAllow !== undefined ? { box_allow: launch.boxAllow } : {}),
|
|
57
|
+
...(launch.files?.length ? { files: launch.files } : {}),
|
|
58
|
+
...(launch.learning ? { learning: { given: launch.learning.given.map((note) => ({ file: note.file, name: note.name })), seed: launch.learning.seed, section: launch.learning.section, ...(launch.learning.seedNotes !== undefined ? { seedNotes: launch.learning.seedNotes } : {}) } } : {}),
|
|
59
|
+
...(launch.trigger ? { trigger: launch.trigger } : {}),
|
|
60
|
+
...(launch.inputOrigin ? { input_origin: launch.inputOrigin } : {}),
|
|
61
|
+
...(launch.followUp ? { follow_up: true } : {}),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/** The learning start a launch body names, as read back: its given notes (each {file, name}), its seed sha and its # Learned
|
|
65
|
+
* section text, or undefined when the body names none (a run that does not learn). */
|
|
66
|
+
function readLearning(value) {
|
|
67
|
+
if (!isObject(value))
|
|
68
|
+
return undefined;
|
|
69
|
+
const given = Array.isArray(value.given) ? value.given.flatMap((note) => (isObject(note) && typeof note.file === "string" && typeof note.name === "string" ? [{ file: note.file, name: note.name }] : [])) : [];
|
|
70
|
+
const seed = typeof value.seed === "string" ? value.seed : null;
|
|
71
|
+
const section = typeof value.section === "string" ? value.section : "";
|
|
72
|
+
return { given, seed, section, ...(typeof value.seedNotes === "number" ? { seedNotes: value.seedNotes } : {}) };
|
|
73
|
+
}
|
|
74
|
+
/** A launch body read back into a `RunLaunch`, with the input-origin fail-safe applied through the body's own trigger, or
|
|
75
|
+
* undefined when the body is not one (not an object, or it names no place: a damaged or hand-edited body). */
|
|
76
|
+
export function readLaunchBody(stored) {
|
|
77
|
+
if (!isObject(stored))
|
|
78
|
+
return undefined;
|
|
79
|
+
const place = readPlace(stored.place);
|
|
80
|
+
if (!place)
|
|
81
|
+
return undefined;
|
|
82
|
+
const trigger = readTrigger(stored.trigger);
|
|
83
|
+
const inputOrigin = keepInputOrigin(stored.input_origin, trigger);
|
|
84
|
+
const model = readModel(stored.model);
|
|
85
|
+
const boxAllow = readBoxAllow(stored.box_allow);
|
|
86
|
+
return {
|
|
87
|
+
input: stored.input,
|
|
88
|
+
title: typeof stored.title === "string" ? stored.title : "",
|
|
89
|
+
place,
|
|
90
|
+
...(typeof stored.harness === "string" ? { harness: stored.harness } : {}),
|
|
91
|
+
...(model ? { model } : {}),
|
|
92
|
+
...(typeof stored.effort === "string" ? { effort: stored.effort } : {}),
|
|
93
|
+
...(typeof stored.max_cost_usd === "number" ? { maxCostUsd: stored.max_cost_usd } : {}),
|
|
94
|
+
...(typeof stored.cap_mode === "string" ? { capMode: stored.cap_mode } : {}),
|
|
95
|
+
...(isObject(stored.plane) ? { plane: stored.plane } : {}),
|
|
96
|
+
...(typeof stored.approvers === "boolean" ? { approvers: stored.approvers } : {}),
|
|
97
|
+
...(typeof stored.documents === "string" ? { documents: stored.documents } : {}),
|
|
98
|
+
...(boxAllow !== undefined ? { boxAllow } : {}),
|
|
99
|
+
...(Array.isArray(stored.files) && stored.files.every((id) => typeof id === "string") ? { files: stored.files } : {}),
|
|
100
|
+
...(stored.learning !== undefined ? { learning: readLearning(stored.learning) ?? { given: [], seed: null, section: "" } } : {}),
|
|
101
|
+
...(trigger ? { trigger } : {}),
|
|
102
|
+
...(inputOrigin ? { inputOrigin } : {}),
|
|
103
|
+
...(stored.follow_up === true ? { followUp: true } : {}),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/** The run's learning start (its given notes, its seed sha and its # Learned section), read from one place by learning's
|
|
107
|
+
* routes and the runner; undefined when the run does not learn. */
|
|
108
|
+
export const learningStartOf = (launch) => launch.learning;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type SignInReader } from "./run-view.js";
|
|
2
|
+
import type { Store } from "./store/store.js";
|
|
3
|
+
/** Run `runId`'s learning as GET /runs/{id}/learning serves it, or ApiError forbidden for a withheld run. */
|
|
4
|
+
export declare function servedRunLearning(deps: {
|
|
5
|
+
serverSecrets: () => string[];
|
|
6
|
+
signIns?: SignInReader;
|
|
7
|
+
}, store: Store, runId: string): Promise<{
|
|
8
|
+
seed: string | null;
|
|
9
|
+
merged: string | null;
|
|
10
|
+
pending: {
|
|
11
|
+
file: string;
|
|
12
|
+
name: string;
|
|
13
|
+
}[];
|
|
14
|
+
verdict: {
|
|
15
|
+
merge: boolean;
|
|
16
|
+
reason: string;
|
|
17
|
+
items: {
|
|
18
|
+
why: string;
|
|
19
|
+
question?: string | undefined;
|
|
20
|
+
origin?: "run" | "you" | undefined;
|
|
21
|
+
pending?: boolean | undefined;
|
|
22
|
+
file: string;
|
|
23
|
+
keep: boolean;
|
|
24
|
+
}[];
|
|
25
|
+
} | null;
|
|
26
|
+
problems: import("./learn/check.js").Problem[];
|
|
27
|
+
cost_usd: {
|
|
28
|
+
grade: number | null;
|
|
29
|
+
};
|
|
30
|
+
tokens: {
|
|
31
|
+
grade: import("./learning.js").Tokens | null;
|
|
32
|
+
};
|
|
33
|
+
given?: import("./learning.js").NoteUsed[];
|
|
34
|
+
read?: import("./learning.js").NoteUsed[];
|
|
35
|
+
learned?: import("./learning.js").NoteLearned[];
|
|
36
|
+
skills?: import("./learning.js").LearnedFile[];
|
|
37
|
+
workflows?: import("./learning.js").LearnedFile[];
|
|
38
|
+
run: string;
|
|
39
|
+
state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
|
|
40
|
+
reason: "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "cancelled" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
|
|
41
|
+
detail: string | null;
|
|
42
|
+
at: string;
|
|
43
|
+
} | null>;
|
|
44
|
+
/** Run `runId`'s learning diff as GET /runs/{id}/learning/diff serves it (learning-routes.ts runDiffOverStore), cut by the
|
|
45
|
+
* run's one cut, or ApiError forbidden for a withheld run. */
|
|
46
|
+
export declare function servedRunDiff(deps: {
|
|
47
|
+
serverSecrets: () => string[];
|
|
48
|
+
signIns?: SignInReader;
|
|
49
|
+
}, store: Store, data: string, runId: string): Promise<{
|
|
50
|
+
base: string;
|
|
51
|
+
head: string;
|
|
52
|
+
files: ({
|
|
53
|
+
path: string;
|
|
54
|
+
status: string;
|
|
55
|
+
withheld: string;
|
|
56
|
+
patch?: undefined;
|
|
57
|
+
} | {
|
|
58
|
+
path: string;
|
|
59
|
+
status: string;
|
|
60
|
+
patch: string;
|
|
61
|
+
withheld?: undefined;
|
|
62
|
+
})[];
|
|
63
|
+
} | {
|
|
64
|
+
base: string;
|
|
65
|
+
head: null;
|
|
66
|
+
files: ({
|
|
67
|
+
path: string;
|
|
68
|
+
status: string;
|
|
69
|
+
withheld: string;
|
|
70
|
+
patch?: undefined;
|
|
71
|
+
} | {
|
|
72
|
+
path: string;
|
|
73
|
+
status: string;
|
|
74
|
+
patch: string;
|
|
75
|
+
withheld?: undefined;
|
|
76
|
+
})[];
|
|
77
|
+
} | {
|
|
78
|
+
base: string | null;
|
|
79
|
+
head: null;
|
|
80
|
+
files: never[];
|
|
81
|
+
}>;
|