@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/import.js
CHANGED
|
@@ -5,29 +5,34 @@
|
|
|
5
5
|
// Nothing leaves the machine, every string written has the environment's key values cut out, and every file written is
|
|
6
6
|
// the owner's only. Read again, it imports only the sessions it has not.
|
|
7
7
|
import { createHash, randomUUID } from "node:crypto";
|
|
8
|
-
import { existsSync
|
|
9
|
-
import {
|
|
8
|
+
import { existsSync } from "node:fs";
|
|
9
|
+
import { lstat, realpath, stat } from "node:fs/promises";
|
|
10
10
|
import { homedir, tmpdir } from "node:os";
|
|
11
11
|
import { basename, dirname, join, sep } from "node:path";
|
|
12
12
|
import { parseArgs } from "node:util";
|
|
13
13
|
import { BACKGROUND_CONTEXT as ctx } from "@earendil-works/chord/context";
|
|
14
|
-
import { AssistantEntry,
|
|
15
|
-
import { openNodeSqliteStorage } from "@earendil-works/pi-durable/storage/sqlite/node";
|
|
16
|
-
import { openStore, openStoreReader, STORE_FILE } from "@parcha/pi-durable-agent";
|
|
14
|
+
import { AssistantEntry, ROOT_CONVERSATION_ID, ToolResultEntry, UserEntry } from "@earendil-works/pi-durable";
|
|
17
15
|
import { REQUEST_COST, runMetricsOf } from "@parcha/pi-durable-agent/timeline";
|
|
18
|
-
import {
|
|
16
|
+
import { defaultData } from "./files.js";
|
|
19
17
|
import { childFiles, HARNESS_OF, mostEffortOf, readSession, SOURCES, sessionFiles } from "./import-sources.js";
|
|
20
|
-
import {
|
|
18
|
+
import { hoursOf, summaryLines } from "./import-summary.js";
|
|
21
19
|
import { catalogPrices } from "./model.js";
|
|
22
|
-
import { SESSION_SECRET_FILE } from "./owner.js";
|
|
23
20
|
import { logLine } from "./print.js";
|
|
21
|
+
import { launchBody } from "./run-launch.js";
|
|
24
22
|
import { DEFAULT_PORT } from "./server.js";
|
|
25
23
|
import { REDACTED, secretCut, secretsIn } from "./secret-cut.js";
|
|
26
|
-
import { SECRET_NAMES, withSecrets } from "./secrets.js";
|
|
27
|
-
import { SEAL_KEY_ENV
|
|
24
|
+
import { handedSecret, SECRET_NAMES, withSecrets } from "./secrets.js";
|
|
25
|
+
import { SEAL_KEY_ENV } from "./tool-keys.js";
|
|
26
|
+
import { bootSealKey, SealKeyRefused, withSealKey } from "./seal-key.js";
|
|
27
|
+
import { toolKeysOverStore } from "./tool-keys-store.js";
|
|
28
|
+
import { openServerSecretsOverStore } from "./server-secrets-store.js";
|
|
28
29
|
import { WEBHOOK_FILE, webhookSecretIn } from "./webhooks.js";
|
|
29
|
-
import {
|
|
30
|
+
import { TRIGGER_ADAPTERS } from "./trigger-adapters.js";
|
|
30
31
|
import { readWorkBytes, WorkRefused, walkWork } from "./workspace.js";
|
|
32
|
+
import { journalEntries } from "./runner/journal-reader.js";
|
|
33
|
+
import { bodyOf, openStore, SchemaVersionUnknown, StoreFromEarlierVersion, StoreOwned, storeTarget } from "./store/index.js";
|
|
34
|
+
import { STORE_FILE } from "./store/sqlite/store.js";
|
|
35
|
+
import { foundOverStore } from "./store-reads/import-summary.js";
|
|
31
36
|
/** In the data directory while an import the owner asked for at setup has not ended: the server's next start goes on with it. */
|
|
32
37
|
export const IMPORT_ASKED = ".import-at-setup";
|
|
33
38
|
/** A session file written to this recently may still be running: it is left for a later import. */
|
|
@@ -136,19 +141,16 @@ async function findKeys(plan, add, cut, held, signal) {
|
|
|
136
141
|
const projectText = (cwd, files) => [cwd, ...Object.values(files.instructions), ...Object.entries(files.skills).flat()].join("\n");
|
|
137
142
|
export const agentIdOf = (cwd) => `imp-${hash(`dir:${cwd}`).slice(0, 32)}`;
|
|
138
143
|
/** The sessions the store holds already, as `source:session`, to their run's id. */
|
|
139
|
-
const importedIn = (store) => new Map(store.
|
|
144
|
+
const importedIn = async (store) => new Map((await store.runs.list({})).flatMap((run) => (run.importedFrom ? [[`${run.importedFrom.source}:${run.importedFrom.session}`, run.id]] : [])));
|
|
140
145
|
const sameFile = (seen, stats) => seen !== undefined && seen.size === stats.size && seen.mtime_ms === stats.mtimeMs;
|
|
141
|
-
/** The session files the store's imports read whole, by their path's sha256, with their run:
|
|
142
|
-
*
|
|
146
|
+
/** The session files the store's imports read whole, by their path's sha256, with their run: the file stamp an import kept
|
|
147
|
+
* on the run's `imported_from`, so an unchanged file is not parsed again. */
|
|
143
148
|
async function filesIn(store) {
|
|
144
149
|
const out = new Map();
|
|
145
|
-
for (const run of store.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const seen = meta?.source_file;
|
|
150
|
-
if (seen && typeof seen.path_sha256 === "string" && typeof seen.size === "number" && typeof seen.mtime_ms === "number")
|
|
151
|
-
out.set(seen.path_sha256, { ...seen, run: run.id });
|
|
150
|
+
for (const run of await store.runs.list({})) {
|
|
151
|
+
const seen = run.importedFrom?.file;
|
|
152
|
+
if (seen)
|
|
153
|
+
out.set(seen.path_sha256, { path_sha256: seen.path_sha256, size: seen.size, mtime_ms: seen.mtime_ms, run: run.id });
|
|
152
154
|
}
|
|
153
155
|
return out;
|
|
154
156
|
}
|
|
@@ -259,7 +261,7 @@ export async function planImport({ home, sources = SOURCES, all = false, deleted
|
|
|
259
261
|
return plan;
|
|
260
262
|
const counting = secretCut(env, SECRET_NAMES);
|
|
261
263
|
// Every key the import would cut, found first, as the import finds it before it writes anything: then the counts.
|
|
262
|
-
const heldBy = store ? importedIn(store) : undefined;
|
|
264
|
+
const heldBy = store ? await importedIn(store) : undefined;
|
|
263
265
|
const foundKeys = (keys) => (counting.add(keys), onKeys?.(keys));
|
|
264
266
|
// This server's own secrets first, as the import takes them.
|
|
265
267
|
foundKeys(own);
|
|
@@ -299,7 +301,7 @@ export async function planImport({ home, sources = SOURCES, all = false, deleted
|
|
|
299
301
|
// skills) is the import's to cut too: counted here, after every key is known, as the import cuts it.
|
|
300
302
|
for (const project of plan.projects) {
|
|
301
303
|
const files = await projectFiles(project.cwd, skipped);
|
|
302
|
-
if (store
|
|
304
|
+
if (store && (await store.agents.get(project.agentId)))
|
|
303
305
|
continue;
|
|
304
306
|
counting.text(project.name);
|
|
305
307
|
counting.text(project.cwd);
|
|
@@ -425,26 +427,20 @@ const ownless = (session) => session.copies > 0 && !session.turns.some((turn) =>
|
|
|
425
427
|
async function seenIn(store, agentId) {
|
|
426
428
|
const bySource = new Map();
|
|
427
429
|
const seen = (source) => bySource.get(source) ?? bySource.set(source, new Set()).get(source);
|
|
428
|
-
if (!store
|
|
430
|
+
if (!store || !(await store.agents.get(agentId)))
|
|
429
431
|
return seen;
|
|
430
|
-
const
|
|
431
|
-
|
|
432
|
-
if (run.importedFrom?.source !== "claude-code" || !existsSync(store.runStorePath(run.id)))
|
|
432
|
+
for (const run of await store.runs.list({ agentId })) {
|
|
433
|
+
if (run.importedFrom?.source !== "claude-code")
|
|
433
434
|
continue;
|
|
434
|
-
const
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
seen("claude-code").add(`u:${uuid}`);
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
finally {
|
|
447
|
-
db.close();
|
|
435
|
+
for (const entry of (await journalEntries(store.readJournal(run.id), ctx))) {
|
|
436
|
+
const id = entry.model?.[0]?.responseId;
|
|
437
|
+
if (typeof id === "string" && id)
|
|
438
|
+
seen("claude-code").add(`m:${id}`);
|
|
439
|
+
const uuids = entry.data?.record_uuids;
|
|
440
|
+
if (Array.isArray(uuids))
|
|
441
|
+
for (const uuid of uuids)
|
|
442
|
+
if (typeof uuid === "string")
|
|
443
|
+
seen("claude-code").add(`u:${uuid}`);
|
|
448
444
|
}
|
|
449
445
|
}
|
|
450
446
|
return seen;
|
|
@@ -718,50 +714,30 @@ function measured(session, children = []) {
|
|
|
718
714
|
hours: hoursOf(session.turns.flatMap((turn) => (turn.role === "assistant" ? [turn.at] : []))),
|
|
719
715
|
};
|
|
720
716
|
}
|
|
721
|
-
/** The run's transcript
|
|
722
|
-
* subagents' requests after
|
|
723
|
-
*
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
const
|
|
727
|
-
|
|
728
|
-
const
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
});
|
|
738
|
-
}
|
|
739
|
-
for (const { kind, data } of subagentMarks(children))
|
|
740
|
-
await tx.appendEntry(ROOT_CONVERSATION_ID, { kind, data: cut(data) });
|
|
741
|
-
}, ctx);
|
|
742
|
-
}
|
|
743
|
-
finally {
|
|
744
|
-
await harness.close(ctx);
|
|
717
|
+
/** The run's transcript as pi-durable write batches for Store.importRun: the root conversation, then one entry per turn,
|
|
718
|
+
* its subagents' requests after them (subagentMarks), each string with the environment's key values cut out. Built
|
|
719
|
+
* directly (as the runner builds its own writes), so no run database is opened; the ids are a run's own, from the root.
|
|
720
|
+
* Returns the batches and the same entries the old per-run store read back, for the run's metrics and estimate. */
|
|
721
|
+
export function transcriptOf(session, cut, children = []) {
|
|
722
|
+
const root = ROOT_CONVERSATION_ID;
|
|
723
|
+
const writes = [{ type: "conversation", value: { id: root } }];
|
|
724
|
+
const entries = [];
|
|
725
|
+
let id = Number(root) + 1;
|
|
726
|
+
for (const turn of session.turns) {
|
|
727
|
+
const { entry, model, data } = message(turn, session.model);
|
|
728
|
+
const m = cut(model);
|
|
729
|
+
const d = data === undefined ? undefined : cut(data);
|
|
730
|
+
writes.push({ type: "entry", value: { id, conversationId: root, kind: entry.kind, model: [m], ...(d !== undefined ? { data: d } : {}) } });
|
|
731
|
+
entries.push({ kind: entry.kind, model: [m], ...(d !== undefined ? { data: d } : {}) });
|
|
732
|
+
id += 1;
|
|
745
733
|
}
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
try {
|
|
752
|
-
db.exec("PRAGMA journal_mode = DELETE");
|
|
753
|
-
entries = db.prepare("SELECT record FROM entries ORDER BY id").all().map((row) => JSON.parse(row.record));
|
|
734
|
+
for (const mark of subagentMarks(children)) {
|
|
735
|
+
const d = mark.data === undefined ? undefined : cut(mark.data);
|
|
736
|
+
writes.push({ type: "entry", value: { id, conversationId: root, kind: mark.kind, ...(d !== undefined ? { data: d } : {}) } });
|
|
737
|
+
entries.push({ kind: mark.kind, ...(d !== undefined ? { data: d } : {}) });
|
|
738
|
+
id += 1;
|
|
754
739
|
}
|
|
755
|
-
|
|
756
|
-
db.close();
|
|
757
|
-
}
|
|
758
|
-
// The owner's only, whatever the umask made it.
|
|
759
|
-
for (const file of [storePath, `${storePath}-wal`, `${storePath}-shm`])
|
|
760
|
-
await chmod(file, 0o600).catch((error) => {
|
|
761
|
-
if (error.code !== "ENOENT")
|
|
762
|
-
throw error;
|
|
763
|
-
});
|
|
764
|
-
return entries;
|
|
740
|
+
return { batches: [writes], entries };
|
|
765
741
|
}
|
|
766
742
|
/** What a run's requests cost at the catalog's list prices, each at its own provider's entry for its model: undefined when
|
|
767
743
|
* one request's tokens are unknown or its provider does not list its model (the request was served at a price no one
|
|
@@ -787,61 +763,42 @@ async function estimateOf(entries, catalog) {
|
|
|
787
763
|
}
|
|
788
764
|
return Math.round(total * 1e6) / 1e6;
|
|
789
765
|
}
|
|
790
|
-
/** The revision of `
|
|
791
|
-
|
|
766
|
+
/** The revision of `source`'s harness this agent keeps already (one per source, by its note), or a new one to write: its
|
|
767
|
+
* id, and the `NewRevision` the caller stores (through agents.create for the agent's first, agents.addRevision for the
|
|
768
|
+
* rest). The body is built and checked here (bodyOf), its instructions and skills cut. */
|
|
769
|
+
async function revisionFor(store, agentId, source, files, model, cut) {
|
|
792
770
|
const note = `imported from ${source}`;
|
|
793
|
-
const held = store.
|
|
771
|
+
const held = (await store.agents.revisions(agentId)).find((r) => r.note === note);
|
|
794
772
|
if (held)
|
|
795
|
-
return held;
|
|
773
|
+
return { id: held.id };
|
|
796
774
|
const harness = HARNESS_OF[source];
|
|
797
775
|
const instructions = INSTRUCTIONS[harness].map((name) => files.instructions[name]).find((text) => text !== undefined) ?? "";
|
|
798
|
-
const
|
|
776
|
+
const { body, skills } = bodyOf({
|
|
799
777
|
kind: "agentic",
|
|
800
778
|
instructions: cut(instructions),
|
|
801
779
|
skills: keptSkills(files.skills, cut),
|
|
802
780
|
tools: [],
|
|
803
781
|
...(model ? { model } : {}),
|
|
804
782
|
...(harness !== "pi" ? { harness } : {}),
|
|
805
|
-
note,
|
|
806
|
-
};
|
|
807
|
-
return store.commitRevision(agentId, revision, { setCurrent: current });
|
|
808
|
-
}
|
|
809
|
-
/** A run's serve.json: its title and input, and the session file it was read from, as read. */
|
|
810
|
-
async function writeMeta(dir, session, read, json) {
|
|
811
|
-
const meta = json({
|
|
812
|
-
// Cut before it is clipped: a key the clip cut short would match no rule.
|
|
813
|
-
title: clip(json(session.firstPrompt ?? `${session.source} session`), 120),
|
|
814
|
-
created_at: session.startedAt ?? new Date(0).toISOString(),
|
|
815
|
-
input: { content: session.firstPrompt ?? "" },
|
|
816
783
|
});
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
await chmod(metaPath, 0o600);
|
|
784
|
+
const id = randomUUID();
|
|
785
|
+
return { id, create: { id, kind: "agentic", body, skills, note } };
|
|
820
786
|
}
|
|
821
|
-
/** The secrets this server made and keeps
|
|
822
|
-
*
|
|
823
|
-
*
|
|
824
|
-
*
|
|
825
|
-
*
|
|
826
|
-
* from elsewhere).
|
|
827
|
-
* the import goes on, and does not cut it. */
|
|
828
|
-
export function ownSecrets(data, env, say = () => { }) {
|
|
829
|
-
const read = (name) => {
|
|
830
|
-
try {
|
|
831
|
-
return readFileSync(join(data, name), "utf8").trim();
|
|
832
|
-
}
|
|
833
|
-
catch {
|
|
834
|
-
return "";
|
|
835
|
-
}
|
|
836
|
-
};
|
|
787
|
+
/** The secrets this server made and keeps, by value: its API token and its sign-in sessions' secret (still files beside the
|
|
788
|
+
* store), its webhook's signing secret (`whsec_...`; webhooks.ts) and every value a trigger source keeps sealed, which the
|
|
789
|
+
* switch keeps as store rows (server-secrets-store.ts), opened with the seal key of `env`, so left out when that key is not
|
|
790
|
+
* there; each signing secret's key in every spelling too. One pasted into a session is this server's own, so an import cuts
|
|
791
|
+
* it wherever it is, as it cuts the environment's keys. Not among them: a key-shaped value this server did not make (a
|
|
792
|
+
* `whsec_` from elsewhere). The per-run door token is gone (the runner cutover deleted it). A webhook secret that does not
|
|
793
|
+
* open is said to `say`: the import goes on, and does not cut it. */
|
|
794
|
+
export async function ownSecrets(store, data, env, say = () => { }) {
|
|
837
795
|
const webhook = webhookSecretIn(data, env);
|
|
838
796
|
if (webhook && "signing" in webhook)
|
|
839
797
|
say({ condition: webhook.signing, name: SEAL_KEY_ENV, file: join(data, WEBHOOK_FILE), effect: "this server's webhook secret cannot be read, so the import does not cut it" });
|
|
840
|
-
|
|
841
|
-
return [...new Set(values)].filter((value) => value.length >= 8 && !/\s/.test(value));
|
|
798
|
+
return (await openServerSecretsOverStore(store, data, env, TRIGGER_ADAPTERS, say)).secrets.values();
|
|
842
799
|
}
|
|
843
|
-
/** The plan, into `store`: the agents it does not hold, and the runs it does not.
|
|
844
|
-
*
|
|
800
|
+
/** The plan, into `store`: the agents it does not hold, and the runs it does not. Each run is written whole in one atomic
|
|
801
|
+
* `importRun` (its row, its launch and its transcript's journal), so a stop between two runs leaves no partial run. */
|
|
845
802
|
export async function runImport(store, plan, options) {
|
|
846
803
|
const cut = secretCut([options.env, options.stored ?? {}], SECRET_NAMES);
|
|
847
804
|
const { text, json } = cut;
|
|
@@ -852,44 +809,57 @@ export async function runImport(store, plan, options) {
|
|
|
852
809
|
const report = { agents: [], skipped: [...plan.skipped], already: plan.already };
|
|
853
810
|
let prices;
|
|
854
811
|
const catalog = () => (prices ??= catalogPrices());
|
|
855
|
-
const held = importedIn(store);
|
|
812
|
+
const held = await importedIn(store);
|
|
856
813
|
// Every key of the import is known before anything of it is written.
|
|
857
|
-
const known = await findKeys(plan, add, text, (listed) => {
|
|
858
|
-
const run = held.get(`${listed.source}:${listed.id}`);
|
|
859
|
-
return run !== undefined && existsSync(store.runStorePath(run));
|
|
860
|
-
}, options.signal);
|
|
814
|
+
const known = await findKeys(plan, add, text, (listed) => held.get(`${listed.source}:${listed.id}`) !== undefined, options.signal);
|
|
861
815
|
const scannedAs = known.stamps;
|
|
816
|
+
const epoch0 = new Date(0).toISOString();
|
|
862
817
|
for (const project of plan.projects) {
|
|
863
818
|
if (options.signal?.aborted)
|
|
864
819
|
break;
|
|
865
|
-
const
|
|
820
|
+
const existing = await store.agents.get(project.agentId);
|
|
821
|
+
const created = !existing;
|
|
866
822
|
const files = await projectFiles(project.cwd, report.skipped);
|
|
867
823
|
// Its own text read through secretlint again only if it changed since the pass above.
|
|
868
824
|
const textNow = projectText(project.cwd, files);
|
|
869
825
|
if (hash(textNow) !== known.texts.get(project.agentId))
|
|
870
826
|
add(await secretsIn(textNow));
|
|
871
|
-
if (created)
|
|
872
|
-
store.createAgent({
|
|
873
|
-
id: project.agentId,
|
|
874
|
-
name: keptName(project, text),
|
|
875
|
-
description: text(project.cwd),
|
|
876
|
-
});
|
|
877
827
|
const byStart = [...project.sessions].sort((a, b) => (a.startedAt ?? "").localeCompare(b.startedAt ?? ""));
|
|
878
828
|
const latest = byStart.at(-1);
|
|
879
|
-
// The latest session's harness
|
|
880
|
-
|
|
829
|
+
// The latest session's harness names the agent's current revision; its model, each harness's latest. The latest source
|
|
830
|
+
// is last in the order, so it is the last revision written — created with the agent, or added current.
|
|
881
831
|
const order = [...new Set(project.sessions.map((s) => s.source))].sort((a, b) => (a === latest.source ? 1 : 0) - (b === latest.source ? 1 : 0));
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
const
|
|
832
|
+
const revisions = new Map();
|
|
833
|
+
const toWrite = [];
|
|
834
|
+
for (const source of order) {
|
|
835
|
+
const resolved = await revisionFor(store, project.agentId, source, files, byStart.findLast((s) => s.source === source && s.model)?.model, text);
|
|
836
|
+
revisions.set(source, resolved.id);
|
|
837
|
+
if (resolved.create)
|
|
838
|
+
toWrite.push(resolved.create);
|
|
839
|
+
}
|
|
840
|
+
if (created) {
|
|
841
|
+
// The agent and its first revision in one commit, the rest added; the latest is last, so the current one.
|
|
842
|
+
await store.agents.create({ id: project.agentId, name: keptName(project, text), description: text(project.cwd) }, toWrite[0]);
|
|
843
|
+
for (const revision of toWrite.slice(1))
|
|
844
|
+
await store.agents.addRevision({ agentId: project.agentId, ...revision });
|
|
845
|
+
}
|
|
846
|
+
else if (toWrite.length) {
|
|
847
|
+
// A held agent gains a revision only for a source it had none of; its current revision is left as it was.
|
|
848
|
+
const currentBefore = existing.currentRevision;
|
|
849
|
+
for (const revision of toWrite)
|
|
850
|
+
await store.agents.addRevision({ agentId: project.agentId, ...revision });
|
|
851
|
+
if (currentBefore)
|
|
852
|
+
await store.agents.setCurrent(project.agentId, currentBefore);
|
|
853
|
+
}
|
|
854
|
+
const line = { id: project.agentId, name: project.name, cwd: project.cwd, created, runs: 0, already: 0 };
|
|
885
855
|
// A record or response counted once across the import's files, those its runs here hold already included.
|
|
886
856
|
const seen = await seenIn(store, project.agentId);
|
|
887
857
|
for (const files of byRun(project.sessions)) {
|
|
888
858
|
if (options.signal?.aborted)
|
|
889
859
|
break;
|
|
890
860
|
const listed = files[0];
|
|
891
|
-
|
|
892
|
-
if (
|
|
861
|
+
// A run the store holds already is left as it is: importRun is atomic, so a held run is a whole run.
|
|
862
|
+
if (held.get(`${listed.source}:${listed.id}`) !== undefined) {
|
|
893
863
|
line.already += 1;
|
|
894
864
|
continue;
|
|
895
865
|
}
|
|
@@ -907,7 +877,7 @@ export async function runImport(store, plan, options) {
|
|
|
907
877
|
continue;
|
|
908
878
|
searched.push(part);
|
|
909
879
|
// A file of it holding only copies adds nothing to it.
|
|
910
|
-
if (
|
|
880
|
+
if (ownless(part)) {
|
|
911
881
|
report.skipped.push({ what: file, why: "holds only records of sessions imported already", kind: "copies" });
|
|
912
882
|
continue;
|
|
913
883
|
}
|
|
@@ -931,54 +901,32 @@ export async function runImport(store, plan, options) {
|
|
|
931
901
|
const moved = await Promise.all(subagents.map(async (child) => scannedAs.get(child.file) !== stampOf((await stat(child.file).catch(() => null)) ?? { size: -1, mtimeMs: -1 })));
|
|
932
902
|
if (moved.some(Boolean))
|
|
933
903
|
add(await keysInSessions(subagents));
|
|
934
|
-
// The transcript
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
...(session.costUsd !== undefined ? { costUsd: session.costUsd } : {}),
|
|
961
|
-
...((answer ?? session.firstPrompt) ? { summary: text(answer ?? session.firstPrompt) } : {}),
|
|
962
|
-
source: session.source,
|
|
963
|
-
session: session.id,
|
|
964
|
-
metrics,
|
|
965
|
-
});
|
|
966
|
-
}
|
|
967
|
-
if (started)
|
|
968
|
-
await rename(pending, started.storePath);
|
|
969
|
-
}
|
|
970
|
-
finally {
|
|
971
|
-
await rm(pending, { force: true });
|
|
972
|
-
}
|
|
973
|
-
if (!started) {
|
|
974
|
-
line.already += 1;
|
|
975
|
-
continue;
|
|
976
|
-
}
|
|
977
|
-
await writeMeta(started.dir, session, read, json);
|
|
978
|
-
if (heldRun !== undefined)
|
|
979
|
-
line.finished += 1;
|
|
980
|
-
else
|
|
981
|
-
line.runs += 1;
|
|
904
|
+
// The transcript as the store's own write batches, each string cut; its subagents' requests marked after its turns,
|
|
905
|
+
// so its timeline's usage row counts what its metrics do, one number for the run.
|
|
906
|
+
const { batches, entries } = transcriptOf(session, json, subagents);
|
|
907
|
+
const metrics = { ...withChildren(runMetricsOf(entries), subagents.map((child) => runMetricsOf(entriesOf(child)))), activeMs: session.activeMs, ...(session.effort ? { effort: session.effort } : {}) };
|
|
908
|
+
// A session its source did not price: the catalog's estimate, beside its cost (unknown), never written as it.
|
|
909
|
+
const estimate = session.costUsd === undefined ? await estimateOf([...entries, ...subagents.flatMap(entriesOf)], catalog) : undefined;
|
|
910
|
+
if (estimate !== undefined)
|
|
911
|
+
Object.assign(metrics, { costUsdEst: estimate, costBasis: "catalog" });
|
|
912
|
+
const answer = session.turns.findLast((t) => t.role === "assistant" && t.text)?.text;
|
|
913
|
+
const title = clip(text(session.firstPrompt ?? `${session.source} session`), 120);
|
|
914
|
+
await store.importRun({
|
|
915
|
+
id: randomUUID(),
|
|
916
|
+
agentId: project.agentId,
|
|
917
|
+
revisionId: revisions.get(session.source),
|
|
918
|
+
importedFrom: { source: session.source, session: session.id, file: read },
|
|
919
|
+
launch: { body: launchBody({ input: { content: text(session.firstPrompt ?? "") }, title, place: { mode: "runner" } }) },
|
|
920
|
+
// An imported session is ended as it ended: a plain completion reads as 'ended', a stop or a failure as its own.
|
|
921
|
+
state: session.state === "completed" ? "ended" : session.state,
|
|
922
|
+
...(session.costUsd !== undefined ? { costUsd: session.costUsd } : {}),
|
|
923
|
+
...((answer ?? session.firstPrompt) ? { summary: text(answer ?? session.firstPrompt) } : {}),
|
|
924
|
+
metrics,
|
|
925
|
+
startedAt: Date.parse(session.startedAt ?? epoch0),
|
|
926
|
+
endedAt: Date.parse(session.endedAt ?? session.startedAt ?? epoch0),
|
|
927
|
+
transcript: batches,
|
|
928
|
+
});
|
|
929
|
+
line.runs += 1;
|
|
982
930
|
}
|
|
983
931
|
report.agents.push(line);
|
|
984
932
|
}
|
|
@@ -1018,8 +966,8 @@ const BRING_IN = { gone: "--include-deleted", temp: "--all", "no-words": "--all"
|
|
|
1018
966
|
const leftOutLines = (skipped) => leftOutOf(skipped).map(({ kind, count, label }) => `left out: ${label}${BRING_IN[kind] ? ` (${BRING_IN[kind]} imports ${count === 1 ? "it" : "them"} too)` : ""}`);
|
|
1019
967
|
/** The plan as a person reads it: one line per project, its sessions counted as the import takes them, then (`verbose`)
|
|
1020
968
|
* each file left out and why. */
|
|
1021
|
-
export function describePlan(plan, store, { verbose = false } = {}) {
|
|
1022
|
-
const held = store ? importedIn(store) : undefined;
|
|
969
|
+
export async function describePlan(plan, store, { verbose = false } = {}) {
|
|
970
|
+
const held = store ? await importedIn(store) : undefined;
|
|
1023
971
|
const lines = plan.projects.map((project) => {
|
|
1024
972
|
const sessions = sessionsOf(project.sessions);
|
|
1025
973
|
const by = new Map();
|
|
@@ -1034,10 +982,16 @@ export function describePlan(plan, store, { verbose = false } = {}) {
|
|
|
1034
982
|
/** `agentrun-serve import ARGS`: its exit code. */
|
|
1035
983
|
export async function importCommand(args, usage, { home = homedir(),
|
|
1036
984
|
// The folder whose projects are left out as temporary (the OS's temp directory).
|
|
1037
|
-
temp = tmpdir(),
|
|
1038
|
-
// The server's own
|
|
1039
|
-
//
|
|
1040
|
-
|
|
985
|
+
temp = tmpdir(), env, out = console.log, } = {}) {
|
|
986
|
+
// The server's own secrets, which the switch keeps sealed in the store, open only under the server's seal key: it is
|
|
987
|
+
// booted the one way the server and runner boot it (seal-key.ts bootSealKey) once the store is open (keyed below), and
|
|
988
|
+
// checked against it. The key handed over wins (this process's, else a caller's own environment's: a test's), else the
|
|
989
|
+
// one in the data directory, as the server reads it.
|
|
990
|
+
const handedKey = handedSecret(SEAL_KEY_ENV) ?? env?.[SEAL_KEY_ENV];
|
|
991
|
+
const ownEnv = env === undefined;
|
|
992
|
+
// The server's own keys, which its start moved out of process.env (secrets.ts), read back in: the import cuts them out of
|
|
993
|
+
// what it keeps, as it cuts every other key in the environment.
|
|
994
|
+
env ??= withSecrets(process.env);
|
|
1041
995
|
// What it prints goes through the cut what it keeps does, with the keys secretlint finds in the lines themselves: a
|
|
1042
996
|
// file or project named after a key is printed cut. The lines are held until the end, then scanned and printed.
|
|
1043
997
|
const printed = secretCut(env, SECRET_NAMES);
|
|
@@ -1055,6 +1009,27 @@ env = withSecrets(process.env), out = console.log, } = {}) {
|
|
|
1055
1009
|
for (const line of lines.splice(0))
|
|
1056
1010
|
print(printed.text(line));
|
|
1057
1011
|
};
|
|
1012
|
+
let dir;
|
|
1013
|
+
/** The store's seal key, booted against `store` (seal-key.ts), and the environment the import reads given it, so the
|
|
1014
|
+
* store's sealed reads open under it. A dry run (`write` false) makes, moves and records nothing, and a store that holds
|
|
1015
|
+
* no secret and has no key is read with none. The key is cut from what is printed, as every key is. */
|
|
1016
|
+
let releaseKey = () => undefined;
|
|
1017
|
+
const keyed = async (store, write) => {
|
|
1018
|
+
const seal = await bootSealKey(store, dir, { given: handedKey, role: "import", write, say: (line) => void warnings.push(line.trimEnd()) });
|
|
1019
|
+
if (!seal)
|
|
1020
|
+
return;
|
|
1021
|
+
releaseKey = seal.release;
|
|
1022
|
+
printed.add([seal.text]);
|
|
1023
|
+
// The environment the import reads, this process's own or a caller's, with the key the boot checked as its seal key.
|
|
1024
|
+
env = withSealKey(ownEnv ? withSecrets(process.env) : env, seal.text);
|
|
1025
|
+
};
|
|
1026
|
+
/** A start the seal key refuses (seal-key.ts): said, in its words, and the import does not go on. */
|
|
1027
|
+
const sealRefused = (error) => {
|
|
1028
|
+
if (!(error instanceof SealKeyRefused))
|
|
1029
|
+
return false;
|
|
1030
|
+
warnings.push(`agentrun-serve import: ${error.message}`);
|
|
1031
|
+
return true;
|
|
1032
|
+
};
|
|
1058
1033
|
try {
|
|
1059
1034
|
let values;
|
|
1060
1035
|
try {
|
|
@@ -1087,39 +1062,64 @@ env = withSecrets(process.env), out = console.log, } = {}) {
|
|
|
1087
1062
|
console.error(`--from takes ${SOURCES.join(", ")}: not ${unknown.join(", ")}\n\n${usage}`);
|
|
1088
1063
|
return 2;
|
|
1089
1064
|
}
|
|
1090
|
-
|
|
1091
|
-
// The
|
|
1092
|
-
//
|
|
1093
|
-
// server says it at its start.
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1065
|
+
dir = values.data ?? defaultData({ ...env, HOME: home });
|
|
1066
|
+
// The import's options, built from the open store: the tool keys the server keeps as sealed rows (tool-keys-store.ts),
|
|
1067
|
+
// opened here with the seal key this process was handed, and this server's own secrets (server-secrets-store.ts). One
|
|
1068
|
+
// that does not open is not known here, so not cut: said, as the server says it at its start. A dry run on a data
|
|
1069
|
+
// directory with no store yet reads neither (none is there).
|
|
1070
|
+
const optionsFrom = async (store) => {
|
|
1071
|
+
// The environment as it is now: once the store's key is booted (keyed), it carries it.
|
|
1072
|
+
const keyEnv = env;
|
|
1073
|
+
const keys = store ? toolKeysOverStore(store, keyEnv, say("tool_keys")) : undefined;
|
|
1074
|
+
if (keys) {
|
|
1075
|
+
await keys.load();
|
|
1076
|
+
keys.view();
|
|
1077
|
+
}
|
|
1078
|
+
const options = {
|
|
1079
|
+
home,
|
|
1080
|
+
sources: sources,
|
|
1081
|
+
all: values.all === true,
|
|
1082
|
+
deleted: values["include-deleted"] === true,
|
|
1083
|
+
temp,
|
|
1084
|
+
env: keyEnv,
|
|
1085
|
+
stored: keys ? keys.values() : {},
|
|
1086
|
+
// With no key (a dry run over a store that keeps no secret: seal-key.ts) there is nothing of the server's to open.
|
|
1087
|
+
own: store && keyEnv[SEAL_KEY_ENV] !== undefined ? await ownSecrets(store, dir, keyEnv, say("webhook_secret")) : [],
|
|
1088
|
+
};
|
|
1089
|
+
// What it prints is cut with the saved keys too, and with every key the import (or the dry run) finds, as what it
|
|
1090
|
+
// keeps is.
|
|
1091
|
+
printed.add(Object.values(options.stored ?? {}));
|
|
1092
|
+
options.onKeys = (found) => printed.add(found);
|
|
1093
|
+
return options;
|
|
1105
1094
|
};
|
|
1106
|
-
// What it prints is cut with the saved keys too, and with every key the import (or the dry run) finds, as what it
|
|
1107
|
-
// keeps is.
|
|
1108
|
-
printed.add(Object.values(options.stored ?? {}));
|
|
1109
|
-
options.onKeys = (keys) => printed.add(keys);
|
|
1110
1095
|
if (values["dry-run"]) {
|
|
1111
|
-
// A dry run writes nothing
|
|
1112
|
-
|
|
1096
|
+
// A dry run writes nothing: a store there already is opened read-only (role runner), one that is not is left unmade
|
|
1097
|
+
// (on Postgres, when AGENTRUN_STORE_URL names one: a schema not set up yet).
|
|
1098
|
+
const reader = storeTarget(dir).kind === "postgres"
|
|
1099
|
+
? await openStore({ dataDir: dir, role: "runner" }).catch((error) => {
|
|
1100
|
+
if (error instanceof SchemaVersionUnknown && error.found === null)
|
|
1101
|
+
return undefined;
|
|
1102
|
+
throw error;
|
|
1103
|
+
})
|
|
1104
|
+
: existsSync(join(dir, STORE_FILE)) ? await openStore({ dataDir: dir, role: "runner" }) : undefined;
|
|
1113
1105
|
let plan;
|
|
1114
1106
|
let found;
|
|
1115
1107
|
try {
|
|
1108
|
+
if (reader)
|
|
1109
|
+
await keyed(reader, false);
|
|
1110
|
+
const options = await optionsFrom(reader);
|
|
1116
1111
|
plan = await planImport({ ...options, measure: true }, reader);
|
|
1117
|
-
for (const line of describePlan(plan, reader, { verbose: values.verbose === true }))
|
|
1112
|
+
for (const line of await describePlan(plan, reader, { verbose: values.verbose === true }))
|
|
1118
1113
|
out(line);
|
|
1119
1114
|
found = [...plan.found, ...(reader ? await foundAll(reader, plan.held) : []), ...(await untiedFound(plan))];
|
|
1120
1115
|
}
|
|
1116
|
+
catch (error) {
|
|
1117
|
+
if (sealRefused(error))
|
|
1118
|
+
return 1;
|
|
1119
|
+
throw error;
|
|
1120
|
+
}
|
|
1121
1121
|
finally {
|
|
1122
|
-
reader?.close();
|
|
1122
|
+
await reader?.close();
|
|
1123
1123
|
}
|
|
1124
1124
|
out(`${plan.projects.length} projects, ${sessionsOf(plan.projects.flatMap((p) => p.sessions)).length} sessions; nothing was written (dry run)`);
|
|
1125
1125
|
if (plan.secretsFound !== undefined)
|
|
@@ -1130,12 +1130,36 @@ env = withSecrets(process.env), out = console.log, } = {}) {
|
|
|
1130
1130
|
out(line);
|
|
1131
1131
|
return 0;
|
|
1132
1132
|
}
|
|
1133
|
-
|
|
1133
|
+
// A data directory an earlier version wrote (its store a file-era store.sqlite, or its settings files), or one a running
|
|
1134
|
+
// server holds: the import refuses it in the store's own words — which name the directory and what was found — writes
|
|
1135
|
+
// nothing into it (the refusal is before the store is opened or made), and does not wait on a running server.
|
|
1136
|
+
let store;
|
|
1134
1137
|
try {
|
|
1138
|
+
// The store AGENTRUN_STORE_URL names (store/open.ts), else SQLite in the directory; on Postgres a running server's
|
|
1139
|
+
// owner lock is the StoreOwned refused here.
|
|
1140
|
+
store = await openStore({ dataDir: dir, role: "server" });
|
|
1141
|
+
}
|
|
1142
|
+
catch (error) {
|
|
1143
|
+
if (error instanceof StoreFromEarlierVersion || error instanceof StoreOwned) {
|
|
1144
|
+
warnings.push(`agentrun-serve import: ${error.message}`);
|
|
1145
|
+
return 1;
|
|
1146
|
+
}
|
|
1147
|
+
throw error;
|
|
1148
|
+
}
|
|
1149
|
+
try {
|
|
1150
|
+
try {
|
|
1151
|
+
await keyed(store, true);
|
|
1152
|
+
}
|
|
1153
|
+
catch (error) {
|
|
1154
|
+
if (sealRefused(error))
|
|
1155
|
+
return 1;
|
|
1156
|
+
throw error;
|
|
1157
|
+
}
|
|
1158
|
+
const options = await optionsFrom(store);
|
|
1135
1159
|
const plan = await planImport(options, store);
|
|
1136
1160
|
const report = await runImport(store, plan, options);
|
|
1137
1161
|
for (const agent of report.agents)
|
|
1138
|
-
out(`${agent.cwd} ${agent.created ? "new agent" : "agent held"} ${agent.id} imported ${agent.runs}${agent.
|
|
1162
|
+
out(`${agent.cwd} ${agent.created ? "new agent" : "agent held"} ${agent.id} imported ${agent.runs}${agent.already ? `, already imported ${agent.already}` : ""}`);
|
|
1139
1163
|
if (report.already)
|
|
1140
1164
|
out(`already imported, unchanged: ${report.already} session files (not read again)`);
|
|
1141
1165
|
if (values.verbose)
|
|
@@ -1146,17 +1170,18 @@ env = withSecrets(process.env), out = console.log, } = {}) {
|
|
|
1146
1170
|
for (const line of leftOutLines(report.skipped))
|
|
1147
1171
|
out(line);
|
|
1148
1172
|
// Every session found: those imported now, those held before, and those whose file an earlier import read whole.
|
|
1149
|
-
const held = importedIn(store);
|
|
1173
|
+
const held = await importedIn(store);
|
|
1150
1174
|
const runs = [...plan.projects.flatMap((p) => p.sessions.flatMap((s) => held.get(`${s.source}:${s.id}`) ?? [])), ...plan.held];
|
|
1151
1175
|
for (const line of summaryLines([...(await foundAll(store, runs)), ...(await untiedFound(plan))], open))
|
|
1152
1176
|
out(line);
|
|
1153
1177
|
return 0;
|
|
1154
1178
|
}
|
|
1155
1179
|
finally {
|
|
1156
|
-
store.close();
|
|
1180
|
+
await store.close();
|
|
1157
1181
|
}
|
|
1158
1182
|
}
|
|
1159
1183
|
finally {
|
|
1184
|
+
releaseKey();
|
|
1160
1185
|
await flush();
|
|
1161
1186
|
}
|
|
1162
1187
|
}
|
|
@@ -1164,7 +1189,7 @@ env = withSecrets(process.env), out = console.log, } = {}) {
|
|
|
1164
1189
|
async function foundAll(store, runIds) {
|
|
1165
1190
|
const found = [];
|
|
1166
1191
|
for (const id of new Set(runIds)) {
|
|
1167
|
-
const run = await
|
|
1192
|
+
const run = await foundOverStore(store, id, ctx);
|
|
1168
1193
|
if (run)
|
|
1169
1194
|
found.push(run);
|
|
1170
1195
|
}
|