@parcha/agentrun-serve 0.1.0-beta.35 → 0.1.0-beta.37
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 +298 -0
- package/README.md +417 -219
- package/dist/adapters.d.ts +12 -2
- package/dist/adapters.js +27 -2
- package/dist/agent-rows.d.ts +2 -1
- package/dist/agents-store.d.ts +2 -0
- package/dist/agents-store.js +9 -4
- package/dist/api-only.d.ts +2 -1
- package/dist/api-only.js +3 -1
- package/dist/archil-routes.d.ts +40 -7
- package/dist/archil-routes.js +167 -54
- package/dist/archil-settings.d.ts +79 -7
- package/dist/archil-settings.js +140 -14
- package/dist/attach-conformance-cli.d.ts +1 -0
- package/dist/attach-conformance-cli.js +18 -0
- package/dist/attach-conformance.d.ts +25 -0
- package/dist/attach-conformance.js +343 -0
- package/dist/attach-images.d.ts +15 -0
- package/dist/attach-images.js +59 -0
- package/dist/background.d.ts +0 -6
- package/dist/background.js +0 -28
- package/dist/box-image.d.ts +1 -97
- package/dist/box-image.js +4 -284
- package/dist/box-paths.d.ts +2 -7
- package/dist/box-paths.js +7 -13
- package/dist/box-settings.d.ts +0 -11
- package/dist/box-settings.js +4 -29
- package/dist/browser-commands.js +1 -1
- package/dist/browser-computer.d.ts +47 -3
- package/dist/browser-computer.js +286 -18
- package/dist/browser-cost.d.ts +1 -1
- package/dist/browser-live.d.ts +20 -8
- package/dist/browser-live.js +50 -27
- package/dist/browser-person.d.ts +19 -2
- package/dist/browser-person.js +55 -6
- package/dist/browser-wait-ended.d.ts +23 -0
- package/dist/browser-wait-ended.js +42 -0
- package/dist/cap.d.ts +12 -57
- package/dist/cap.js +20 -160
- package/dist/catalog.d.ts +1 -12
- package/dist/catalog.js +3 -33
- package/dist/cli.js +17 -26
- package/dist/composio-preset.d.ts +36 -0
- package/dist/composio-preset.js +179 -0
- package/dist/computer-attach.d.ts +125 -0
- package/dist/computer-attach.js +330 -0
- package/dist/computer-calls.d.ts +48 -0
- package/dist/computer-calls.js +126 -0
- package/dist/computer-channel.d.ts +57 -0
- package/dist/computer-channel.js +115 -0
- package/dist/computer-commands.d.ts +1 -1
- package/dist/computer-held-routes.d.ts +35 -0
- package/dist/computer-held-routes.js +106 -0
- package/dist/computer-held.d.ts +48 -0
- package/dist/computer-held.js +87 -0
- package/dist/computer-keys.d.ts +21 -1
- package/dist/computer-keys.js +53 -11
- package/dist/computer-live.d.ts +160 -0
- package/dist/computer-live.js +643 -0
- package/dist/computer-routes.d.ts +1 -4
- package/dist/computer-routes.js +3 -5
- package/dist/computer-setting.d.ts +2 -0
- package/dist/computer-setting.js +38 -1
- package/dist/computer-view.d.ts +24 -2
- package/dist/computer-view.js +51 -3
- package/dist/computer-viewer.d.ts +6 -0
- package/dist/computer-viewer.js +297 -0
- package/dist/computers.d.ts +79 -12
- package/dist/computers.js +147 -28
- package/dist/console/assets/index-Cn6JX1uH.js +563 -0
- package/dist/console/assets/index-DRN62V5v.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/docker-daemon.d.ts +2 -2
- package/dist/docker-daemon.js +2 -2
- package/dist/errors.js +5 -5
- package/dist/faux-computers.d.ts +9 -20
- package/dist/faux-computers.js +56 -24
- package/dist/files.d.ts +1 -9
- package/dist/files.js +1 -9
- package/dist/github-connection.d.ts +10 -2
- package/dist/github-connection.js +65 -2
- package/dist/github-faux.js +1 -1
- package/dist/github.d.ts +22 -2
- package/dist/github.js +42 -8
- package/dist/gpu-words.d.ts +14 -0
- package/dist/gpu-words.js +21 -0
- package/dist/graph-view.d.ts +3 -1
- package/dist/graph-view.js +25 -1
- package/dist/handed-values.d.ts +1 -1
- package/dist/handed-values.js +1 -1
- package/dist/harness-install.d.ts +60 -3
- package/dist/harness-install.js +322 -34
- package/dist/harness.d.ts +1 -0
- package/dist/harness.js +36 -2
- package/dist/host-tools.d.ts +9 -10
- package/dist/host-tools.js +7 -7
- package/dist/hosted-search.d.ts +5 -4
- package/dist/hosted-search.js +2 -7
- package/dist/import-sources.d.ts +10 -0
- package/dist/import-sources.js +44 -2
- package/dist/import.d.ts +3 -3
- package/dist/import.js +37 -6
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -2
- package/dist/key-refusal.d.ts +1 -1
- package/dist/key-refusal.js +2 -2
- package/dist/learn/check.d.ts +11 -2
- package/dist/learn/check.js +124 -6
- package/dist/learn/commit.d.ts +43 -7
- package/dist/learn/commit.js +166 -22
- package/dist/learn/folder.d.ts +11 -0
- package/dist/learn/folder.js +37 -1
- package/dist/learn/general.d.ts +66 -0
- package/dist/learn/general.js +73 -0
- package/dist/learn/grade.d.ts +22 -1
- package/dist/learn/grade.js +107 -16
- package/dist/learn/index.d.ts +1 -1
- package/dist/learn/index.js +1 -1
- package/dist/learn/learning.sh +12 -1
- package/dist/learn/notes.d.ts +3 -0
- package/dist/learn/notes.js +3 -0
- package/dist/learn/reflect.d.ts +14 -2
- package/dist/learn/reflect.js +54 -30
- package/dist/learn/skills.d.ts +37 -5
- package/dist/learn/skills.js +60 -7
- package/dist/learned-nodes.d.ts +6 -2
- package/dist/learned-workflow.d.ts +43 -9
- package/dist/learned-workflow.js +128 -37
- package/dist/learning-batch.d.ts +283 -0
- package/dist/learning-batch.js +574 -0
- package/dist/learning-cost.d.ts +79 -0
- package/dist/learning-cost.js +69 -0
- package/dist/learning-evals.d.ts +33 -0
- package/dist/learning-evals.js +98 -0
- package/dist/learning-routes.d.ts +32 -4
- package/dist/learning-routes.js +48 -12
- package/dist/learning-words.d.ts +9 -0
- package/dist/learning-words.js +12 -2
- package/dist/learning.d.ts +39 -19
- package/dist/learning.js +88 -46
- package/dist/live/stream.js +6 -3
- package/dist/live/translate.d.ts +4 -3
- package/dist/live/translate.js +8 -4
- package/dist/live-reach.d.ts +37 -0
- package/dist/live-reach.js +62 -0
- package/dist/mcp-gateway.d.ts +9 -0
- package/dist/mcp-gateway.js +60 -11
- package/dist/mcp-oauth.d.ts +57 -7
- package/dist/mcp-oauth.js +133 -18
- package/dist/mcp-private-hosts.d.ts +4 -4
- package/dist/mcp-private-hosts.js +20 -12
- package/dist/mcp-probe.d.ts +27 -3
- package/dist/mcp-probe.js +106 -29
- package/dist/mcp-secret-writes.js +8 -0
- package/dist/mcp-servers-store.d.ts +38 -15
- package/dist/mcp-servers-store.js +120 -23
- package/dist/mcp-store.d.ts +10 -4
- package/dist/mcp-store.js +17 -6
- package/dist/model-form.d.ts +26 -0
- package/dist/model-form.js +80 -0
- package/dist/model.d.ts +5 -5
- package/dist/model.js +29 -16
- package/dist/openapi.d.ts +2 -0
- package/dist/openapi.js +586 -64
- package/dist/owner.d.ts +0 -1
- package/dist/owner.js +0 -2
- package/dist/page.d.ts +18 -0
- package/dist/page.js +48 -20
- package/dist/paid-calls.d.ts +1 -1
- package/dist/paid-calls.js +1 -1
- package/dist/place-offers.d.ts +96 -0
- package/dist/place-offers.js +202 -0
- package/dist/place.d.ts +9 -13
- package/dist/place.js +21 -32
- package/dist/port-models.d.ts +2 -1
- package/dist/port-models.js +5 -3
- package/dist/print.d.ts +16 -9
- package/dist/print.js +15 -17
- package/dist/propose.d.ts +4 -0
- package/dist/propose.js +34 -11
- package/dist/provider.js +3 -2
- package/dist/reflect-range.d.ts +8 -1
- package/dist/reflect-range.js +1 -1
- package/dist/run-cut.d.ts +5 -0
- package/dist/run-cut.js +19 -0
- package/dist/run-launch.d.ts +28 -3
- package/dist/run-launch.js +14 -4
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-manifest.d.ts +2 -2
- package/dist/run-manifest.js +2 -2
- package/dist/run-reads-over-store.d.ts +1 -1
- package/dist/run-repo.d.ts +20 -0
- package/dist/run-repo.js +63 -0
- package/dist/run-secrets.js +3 -3
- package/dist/run-timeline-served.d.ts +1 -1
- package/dist/run-timeline-served.js +56 -44
- package/dist/run-view.d.ts +8 -5
- package/dist/run-view.js +18 -10
- package/dist/runnable.d.ts +2 -2
- package/dist/runnable.js +6 -2
- package/dist/runner/adapter-loop.d.ts +39 -8
- package/dist/runner/adapter-loop.js +770 -83
- package/dist/runner/adapter-run-spec.d.ts +36 -7
- package/dist/runner/adapter-run-spec.js +171 -37
- package/dist/runner/adapters/pi-computer.d.ts +7 -0
- package/dist/runner/adapters/pi-computer.js +43 -0
- package/dist/runner/adapters/pi.d.ts +20 -7
- package/dist/runner/adapters/pi.js +111 -26
- package/dist/runner/beside.d.ts +7 -3
- package/dist/runner/beside.js +26 -12
- package/dist/runner/claim-secrets.d.ts +4 -0
- package/dist/runner/claim-secrets.js +6 -1
- package/dist/runner/cli-run-spec.d.ts +27 -3
- package/dist/runner/cli-run-spec.js +198 -74
- package/dist/runner/commands.d.ts +8 -2
- package/dist/runner/commands.js +31 -6
- package/dist/runner/computer-channel.d.ts +34 -0
- package/dist/runner/computer-channel.js +61 -0
- package/dist/runner/conformance/harness.d.ts +0 -1
- package/dist/runner/conformance/harness.js +87 -18
- package/dist/runner/conformance/subject.d.ts +1 -1
- package/dist/runner/dispatch.js +3 -0
- package/dist/runner/end-of-run.d.ts +22 -12
- package/dist/runner/end-of-run.js +38 -16
- package/dist/runner/github-app.d.ts +2 -1
- package/dist/runner/github-app.js +6 -4
- package/dist/runner/harness-loops.js +16 -2
- package/dist/runner/held-run.d.ts +65 -0
- package/dist/runner/held-run.js +158 -0
- package/dist/runner/journal-kinds.d.ts +35 -6
- package/dist/runner/journal-kinds.js +20 -1
- package/dist/runner/journal-reader.d.ts +5 -4
- package/dist/runner/journal-reader.js +12 -10
- package/dist/runner/learning-ask.d.ts +7 -1
- package/dist/runner/learning-ask.js +21 -6
- package/dist/runner/learning-dispatch.d.ts +22 -0
- package/dist/runner/learning-dispatch.js +77 -10
- package/dist/runner/learning-end.d.ts +37 -1
- package/dist/runner/learning-end.js +115 -14
- package/dist/runner/learning-factory.d.ts +1 -1
- package/dist/runner/learning-factory.js +15 -5
- package/dist/runner/learning-loop.d.ts +139 -7
- package/dist/runner/learning-loop.js +369 -32
- package/dist/runner/learning-seed.d.ts +9 -0
- package/dist/runner/learning-seed.js +14 -1
- package/dist/runner/live-ticker.js +1 -0
- package/dist/runner/loop-contract.d.ts +16 -1
- package/dist/runner/loop-contract.js +6 -0
- package/dist/runner/loop.d.ts +10 -2
- package/dist/runner/loop.js +22 -1
- package/dist/runner/main.d.ts +13 -1
- package/dist/runner/main.js +38 -6
- package/dist/runner/mcp-claim.d.ts +11 -4
- package/dist/runner/mcp-claim.js +140 -23
- package/dist/runner/mcp-github.d.ts +4 -2
- package/dist/runner/mcp-github.js +1 -8
- package/dist/runner/mcp-run.d.ts +6 -4
- package/dist/runner/mcp-run.js +16 -3
- package/dist/runner/metrics.d.ts +15 -2
- package/dist/runner/metrics.js +21 -2
- package/dist/runner/model-route.d.ts +3 -0
- package/dist/runner/model-route.js +5 -2
- package/dist/runner/pr-checkout.d.ts +60 -0
- package/dist/runner/pr-checkout.js +176 -0
- package/dist/runner/reflect-hook.d.ts +19 -0
- package/dist/runner/reflect-hook.js +20 -8
- package/dist/runner/runner.d.ts +26 -0
- package/dist/runner/runner.js +231 -27
- package/dist/runner/scratch-sweep.d.ts +13 -0
- package/dist/runner/scratch-sweep.js +62 -0
- package/dist/runner/sessions.d.ts +1 -1
- package/dist/runner/spec-holds.d.ts +8 -3
- package/dist/runner/spec-holds.js +12 -10
- package/dist/runner/store-port.d.ts +7 -2
- package/dist/runner/store-secrets.js +21 -4
- package/dist/runner/subagent.d.ts +44 -0
- package/dist/runner/subagent.js +190 -0
- package/dist/runner/workflow-host.d.ts +24 -3
- package/dist/runner/workflow-host.js +24 -4
- package/dist/runner/workflow-loop.d.ts +6 -3
- package/dist/runner/workflow-loop.js +9 -8
- package/dist/runner/workflow-spec.d.ts +39 -15
- package/dist/runner/workflow-spec.js +143 -40
- package/dist/runs-over-store.d.ts +16 -6
- package/dist/runs-over-store.js +145 -29
- package/dist/seal-key.js +3 -3
- package/dist/sealed-settings-store.d.ts +5 -2
- package/dist/sealed-settings-store.js +10 -4
- package/dist/sealing.js +1 -2
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/secret-writes.d.ts +5 -4
- package/dist/secret-writes.js +5 -4
- package/dist/server-secrets-store.d.ts +4 -3
- package/dist/server-secrets-store.js +15 -9
- package/dist/server-secrets.js +3 -2
- package/dist/server.d.ts +75 -63
- package/dist/server.js +712 -316
- package/dist/settings-wake.d.ts +21 -0
- package/dist/settings-wake.js +59 -0
- package/dist/standard-webhooks.d.ts +4 -1
- package/dist/standard-webhooks.js +8 -4
- package/dist/store/agent-body.d.ts +9 -2
- package/dist/store/agent-body.js +16 -8
- package/dist/store/command-wake.d.ts +12 -0
- package/dist/store/command-wake.js +37 -0
- package/dist/store/deadline.js +9 -5
- package/dist/store/dialect.d.ts +6 -0
- package/dist/store/dialect.js +5 -0
- package/dist/store/index.d.ts +4 -4
- package/dist/store/index.js +2 -2
- package/dist/store/journal/storage.d.ts +3 -2
- package/dist/store/journal/storage.js +15 -6
- package/dist/store/postgres/connection.js +9 -4
- package/dist/store/postgres/dialect.js +4 -0
- package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
- package/dist/store/postgres/migrations/0005_learning_rounds.sql +14 -0
- package/dist/store/postgres/migrations/0006_run_changes_channel_attempts.sql +57 -0
- package/dist/store/postgres/migrations/0007_viewer_host.sql +11 -0
- package/dist/store/postgres/migrations/0008_paired_computers.sql +30 -0
- package/dist/store/postgres/migrations/0009_commands_answer.sql +10 -0
- package/dist/store/schema.d.ts +2 -1
- package/dist/store/schema.js +85 -13
- package/dist/store/seal.d.ts +13 -0
- package/dist/store/seal.js +19 -0
- package/dist/store/sqlite/connection.d.ts +5 -0
- package/dist/store/sqlite/connection.js +88 -47
- package/dist/store/sqlite/run-patch.d.ts +25 -7
- package/dist/store/sqlite/run-patch.js +58 -14
- package/dist/store/sqlite/store.js +331 -59
- package/dist/store/store.d.ts +330 -21
- package/dist/store/store.js +34 -2
- package/dist/store-reads/analytics.js +3 -2
- package/dist/store-reads/cap.d.ts +2 -4
- package/dist/store-reads/cap.js +16 -7
- package/dist/store-reads/decisions.d.ts +3 -3
- package/dist/store-reads/decisions.js +3 -6
- package/dist/store-reads/import-summary.d.ts +1 -1
- package/dist/store-reads/journal.d.ts +5 -4
- package/dist/store-reads/journal.js +118 -27
- package/dist/store-reads/learning.d.ts +34 -4
- package/dist/store-reads/learning.js +137 -23
- package/dist/store-reads/runs.d.ts +7 -5
- package/dist/store-reads/runs.js +17 -10
- package/dist/store-reads/stats.js +5 -1
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-view.d.ts +5 -0
- package/dist/store-view.js +70 -29
- package/dist/template-eval.js +8 -5
- package/dist/template-github-permissions.d.ts +22 -8
- package/dist/template-github-permissions.js +35 -15
- package/dist/templates.d.ts +64 -0
- package/dist/templates.js +101 -16
- package/dist/timeline/timeline.d.ts +30 -1
- package/dist/timeline/timeline.js +29 -13
- package/dist/timeline/util.d.ts +4 -0
- package/dist/timeline/util.js +14 -0
- package/dist/tool-blurbs.js +1 -0
- package/dist/tool-budget.d.ts +27 -7
- package/dist/tool-budget.js +21 -9
- package/dist/tool-gate.d.ts +23 -10
- package/dist/tool-gate.js +60 -44
- package/dist/tool-plane.d.ts +46 -28
- package/dist/tool-plane.js +73 -31
- package/dist/tools.d.ts +31 -38
- package/dist/tools.js +117 -74
- package/dist/trigger-adapter.d.ts +4 -0
- package/dist/trigger-secrets-shown.d.ts +2 -2
- package/dist/trigger-secrets-shown.js +1 -1
- package/dist/trigger-signatures.d.ts +26 -6
- package/dist/trigger-signatures.js +44 -8
- package/dist/trigger-targets.d.ts +2 -0
- package/dist/trigger-targets.js +1 -0
- package/dist/trigger-webhook.js +5 -2
- package/dist/triggers.d.ts +10 -6
- package/dist/triggers.js +37 -7
- package/dist/turn-end.d.ts +0 -3
- package/dist/turn-end.js +0 -3
- package/dist/turns.js +16 -1
- package/dist/usage-lines.d.ts +1 -1
- package/dist/validate.d.ts +6 -0
- package/dist/validate.js +41 -4
- package/dist/web-fetch.d.ts +1 -1
- package/dist/web-search.d.ts +10 -5
- package/dist/web-search.js +7 -6
- package/dist/webhooks.d.ts +147 -103
- package/dist/webhooks.js +564 -324
- package/dist/workflow/decision-recovery.d.ts +23 -0
- package/dist/workflow/decision-recovery.js +80 -0
- package/dist/workflow/decisions.d.ts +134 -0
- package/dist/workflow/decisions.js +46 -0
- package/dist/workflow/host-session.d.ts +5 -0
- package/dist/workflow/host-session.js +85 -0
- package/dist/workflow/host-tools.d.ts +3 -0
- package/dist/workflow/host-tools.js +3 -0
- package/dist/workflow/node-runner.d.ts +113 -0
- package/dist/workflow/node-runner.js +270 -0
- package/dist/workflow/node.d.ts +89 -0
- package/dist/workflow/node.js +101 -0
- package/dist/workflow/operator-error.d.ts +4 -0
- package/dist/workflow/operator-error.js +4 -0
- package/dist/workflow/pi-versions.d.ts +32 -0
- package/dist/workflow/pi-versions.js +65 -0
- package/dist/workflow/record-file.d.ts +10 -0
- package/dist/workflow/record-file.js +56 -0
- package/dist/workflow/record-tool.d.ts +77 -0
- package/dist/workflow/record-tool.js +126 -0
- package/dist/workflow/record.d.ts +151 -0
- package/dist/workflow/record.js +401 -0
- package/dist/workflow/run-error.d.ts +16 -0
- package/dist/workflow/run-error.js +26 -0
- package/dist/workflow/runner.d.ts +6 -0
- package/dist/workflow/runner.js +240 -0
- package/dist/workflow/store.d.ts +23 -0
- package/dist/workflow/store.js +242 -0
- package/dist/workflow/task.d.ts +133 -0
- package/dist/workflow/task.js +412 -0
- package/dist/workflow/thinking.d.ts +3 -0
- package/dist/workflow/thinking.js +7 -0
- package/dist/workflow/tool-context.d.ts +21 -0
- package/dist/workflow/tool-context.js +13 -0
- package/dist/workflow/types.d.ts +126 -0
- package/dist/workflow/types.js +1 -0
- package/dist/workflow-run.d.ts +2 -2
- package/dist/workspace/agent-computer.d.ts +137 -0
- package/dist/workspace/agent-computer.js +292 -0
- package/dist/workspace/archil-claim.d.ts +11 -0
- package/dist/workspace/archil-claim.js +18 -10
- package/dist/workspace/archil-disks.d.ts +49 -0
- package/dist/workspace/archil-disks.js +185 -0
- package/dist/workspace/archil-exec.js +2 -3
- package/dist/workspace/archil-mount-credential.d.ts +20 -4
- package/dist/workspace/archil-mount-credential.js +13 -4
- package/dist/workspace/attached-computers.d.ts +41 -0
- package/dist/workspace/attached-computers.js +114 -0
- package/dist/workspace/computer-deps.d.ts +32 -17
- package/dist/workspace/computer-deps.js +37 -14
- package/dist/workspace/computer-for-claim.d.ts +58 -13
- package/dist/workspace/computer-for-claim.js +267 -26
- package/dist/workspace/computer-hold.d.ts +11 -27
- package/dist/workspace/computer-hold.js +36 -56
- package/dist/workspace/computer-janitor.d.ts +3 -2
- package/dist/workspace/computer-janitor.js +43 -9
- package/dist/workspace/computer-ledger.d.ts +5 -1
- package/dist/workspace/computer-ledger.js +11 -0
- package/dist/workspace/computer-mcp.d.ts +25 -0
- package/dist/workspace/computer-mcp.js +41 -0
- package/dist/workspace/computer-ports.d.ts +4 -13
- package/dist/workspace/computer-ports.js +4 -107
- package/dist/workspace/computer-script.d.ts +37 -0
- package/dist/workspace/computer-script.js +138 -0
- package/dist/workspace/executors.d.ts +1 -1
- package/dist/workspace/index.d.ts +7 -4
- package/dist/workspace/index.js +4 -1
- package/dist/workspace/kind-skills/desktop/SKILL.md +119 -84
- package/dist/workspace/kind-skills/phone/SKILL.md +100 -85
- package/dist/workspace/resolve-computer.d.ts +45 -11
- package/dist/workspace/resolve-computer.js +72 -14
- package/dist/workspace/run-disk.d.ts +34 -0
- package/dist/workspace/run-disk.js +91 -0
- package/dist/workspace/run-tools.d.ts +35 -18
- package/dist/workspace/run-tools.js +24 -29
- package/dist/workspace/server-run-workspace.d.ts +3 -2
- package/dist/workspace/server-run-workspace.js +17 -4
- package/dist/workspace.js +1 -1
- package/package.json +19 -21
- package/templates/README.md +9 -6
- package/templates/code-review/agent.md +27 -11
- package/templates/code-review/evals/clean-refactor/graders/coverage.md +4 -0
- package/templates/code-review/evals/clean-refactor/graders/risk.md +5 -0
- package/templates/code-review/evals/injection/graders/ignores.md +1 -1
- package/templates/code-review/evals/never-flag/case.yaml +3 -0
- package/templates/code-review/evals/never-flag/graders/only-p0.md +4 -0
- package/templates/code-review/evals/never-flag/graders/schema.md +5 -0
- package/templates/code-review/evals/never-flag/prompt.md +30 -0
- package/templates/code-review/evals/null-name/graders/finds.md +1 -1
- package/templates/code-review/evals/off-by-one/graders/finds.md +1 -1
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +6 -5
- package/templates/code-review/evals/re-review/graders/resolves.md +1 -1
- package/templates/code-review/evals/re-review/prompt.md +1 -1
- package/templates/code-review/evals/re-review-open/case.yaml +3 -0
- package/templates/code-review/evals/re-review-open/graders/schema.md +5 -0
- package/templates/code-review/evals/re-review-open/graders/stays-open.md +4 -0
- package/templates/code-review/evals/re-review-open/prompt.md +27 -0
- package/templates/code-review/evals/repo-rule/graders/cites.md +1 -1
- package/templates/code-review/evals/two-defects/case.yaml +3 -0
- package/templates/code-review/evals/two-defects/graders/both.md +4 -0
- package/templates/code-review/evals/two-defects/graders/schema.md +5 -0
- package/templates/code-review/evals/two-defects/prompt.md +25 -0
- package/templates/code-review/findings.schema.json +131 -27
- package/templates/code-review/rules/CODEREVIEW.md +76 -0
- package/templates/code-review/skills/review/DEEP.md +130 -0
- package/templates/code-review/skills/review/REVIEWER.md +116 -0
- package/templates/code-review/skills/review/SKILL.md +104 -154
- package/templates/market-monitor/agent.md +1 -1
- package/dist/box/record.d.ts +0 -6
- package/dist/box/record.js +0 -41
- package/dist/box/sweep.d.ts +0 -53
- package/dist/box/sweep.js +0 -193
- package/dist/box-egress-vm.d.ts +0 -118
- package/dist/box-egress-vm.js +0 -354
- package/dist/box-egress.d.ts +0 -105
- package/dist/box-egress.js +0 -256
- package/dist/box-relay-vm.d.ts +0 -84
- package/dist/box-relay-vm.js +0 -437
- package/dist/box-relay.d.ts +0 -36
- package/dist/box-relay.js +0 -207
- package/dist/boxes.d.ts +0 -109
- package/dist/boxes.js +0 -249
- package/dist/budget.d.ts +0 -71
- package/dist/budget.js +0 -199
- package/dist/console/assets/index-B7NKTU8E.css +0 -1
- package/dist/console/assets/index-CXZMgJE7.js +0 -550
- package/dist/daytona-api.d.ts +0 -10
- package/dist/daytona-api.js +0 -20
- package/dist/egress-proxy.d.ts +0 -45
- package/dist/egress-proxy.js +0 -416
- package/dist/egress-table.d.ts +0 -24
- package/dist/egress-table.js +0 -165
- package/dist/run-db.d.ts +0 -53
- package/dist/run-db.js +0 -116
- package/templates/code-review/rules/REVIEW.md +0 -41
package/dist/harness-install.js
CHANGED
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
// that directory, never a half install, and the next install removes it; a tree that is not whole (an install by hand
|
|
21
21
|
// cut short) is never loaded, and the next install replaces it.
|
|
22
22
|
import { spawn } from "node:child_process";
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
23
|
+
import { randomUUID } from "node:crypto";
|
|
24
|
+
import { existsSync, readFileSync, readlinkSync, realpathSync, statSync } from "node:fs";
|
|
25
|
+
import { chmod, copyFile, link, lstat, mkdir, mkdtemp, readdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
26
26
|
import { hostname } from "node:os";
|
|
27
27
|
import { basename, dirname, join, sep } from "node:path";
|
|
28
28
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
@@ -50,22 +50,97 @@ export function installLine(dir, lock) {
|
|
|
50
50
|
return `rm -rf ${next} && mkdir -p ${next} && cp ${shellWord(join(dirname(lock), "package.json"))} ${shellWord(lock)} ${next}/ && npm ci --prefix ${next} --ignore-scripts --include=optional && (chmod -R u+w ${at} 2>/dev/null || true) && rm -rf ${at} && mv ${next} ${at}`;
|
|
51
51
|
}
|
|
52
52
|
/** Where `specifier` (a package, or a file of one) resolves from `dir`'s node_modules, only when it is that package's own
|
|
53
|
-
* file there: undefined when the package is not in `dir`, or its file resolves outside it (a
|
|
54
|
-
*
|
|
53
|
+
* file there: undefined when the package is not in `dir`, does not export it, or its file resolves outside it (a link to
|
|
54
|
+
* a file elsewhere). A package linked into `dir` counts by where its link points. Its real path, as Node's resolver gives.
|
|
55
|
+
*
|
|
56
|
+
* Read from the tree as it is now, never through Node's resolver: a long-lived process (a runner) keeps what that
|
|
57
|
+
* resolver read for its whole life (its path cache, and the real path of each link it walked), so a package once linked
|
|
58
|
+
* into the tree, then replaced at the same path by an install, would read as the link's old target until the process
|
|
59
|
+
* restarts. The package's own package.json is read here, and real paths taken with no cache. */
|
|
55
60
|
export function inTree(dir, specifier) {
|
|
56
61
|
const parts = specifier.split("/");
|
|
57
62
|
const name = parts.slice(0, specifier.startsWith("@") ? 2 : 1).join("/");
|
|
58
63
|
const home = join(dir, "node_modules", name);
|
|
59
|
-
if (!existsSync(join(home, "package.json")))
|
|
60
|
-
return undefined;
|
|
61
64
|
try {
|
|
62
|
-
const
|
|
63
|
-
|
|
65
|
+
const manifest = JSON.parse(readFileSync(join(home, "package.json"), "utf8"));
|
|
66
|
+
const subpath = `.${specifier.slice(name.length)}`;
|
|
67
|
+
const target = manifest.exports !== undefined ? exportsTarget(manifest.exports, subpath) : (subpath === "." ? (typeof manifest.main === "string" ? manifest.main : "index.js") : subpath);
|
|
68
|
+
if (target === undefined)
|
|
69
|
+
return undefined;
|
|
70
|
+
const found = [target, `${target}.js`, join(target, "index.js")].map((path) => join(home, path)).find(statFile);
|
|
71
|
+
if (!found)
|
|
72
|
+
return undefined;
|
|
73
|
+
const real = realpathSync(found);
|
|
74
|
+
return real.startsWith(realpathSync(home) + sep) ? real : undefined;
|
|
64
75
|
}
|
|
65
76
|
catch {
|
|
66
77
|
return undefined;
|
|
67
78
|
}
|
|
68
79
|
}
|
|
80
|
+
/** Whether `path` is a file (a link to one counts). */
|
|
81
|
+
const statFile = (path) => {
|
|
82
|
+
try {
|
|
83
|
+
return statSync(path).isFile();
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
/** The conditions Node's require() matches a package's exports by; a package's own key order decides among them. */
|
|
90
|
+
const REQUIRE_CONDITIONS = new Set(["require", "node", "node-addons", "module-sync", "default"]);
|
|
91
|
+
/** The file `exports` maps `subpath` (".", "./server/mcp.js") to, as Node's require() reads it: the subpath's own key,
|
|
92
|
+
* else the pattern ("./*") whose part before its "*" is longest, its "*" given the rest; within it, the first condition
|
|
93
|
+
* require() matches, in the package's own order (an array: its first target that is one). Undefined when the package
|
|
94
|
+
* does not export it. */
|
|
95
|
+
function exportsTarget(exportsField, subpath) {
|
|
96
|
+
const isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
97
|
+
const map = isObject(exportsField) && Object.keys(exportsField).some((key) => key.startsWith(".")) ? exportsField : { ".": exportsField };
|
|
98
|
+
let target = Object.hasOwn(map, subpath) ? map[subpath] : undefined;
|
|
99
|
+
let star;
|
|
100
|
+
if (target === undefined) {
|
|
101
|
+
let best;
|
|
102
|
+
for (const key of Object.keys(map)) {
|
|
103
|
+
const at = key.indexOf("*");
|
|
104
|
+
if (at < 0 || key.indexOf("*", at + 1) >= 0)
|
|
105
|
+
continue;
|
|
106
|
+
const [before, after] = [key.slice(0, at), key.slice(at + 1)];
|
|
107
|
+
if (subpath.length < key.length - 1 || !subpath.startsWith(before) || !subpath.endsWith(after))
|
|
108
|
+
continue;
|
|
109
|
+
if (!best || before.length > best.before || (before.length === best.before && key.length > best.key.length))
|
|
110
|
+
best = { key, before: before.length };
|
|
111
|
+
}
|
|
112
|
+
if (!best)
|
|
113
|
+
return undefined;
|
|
114
|
+
const at = best.key.indexOf("*");
|
|
115
|
+
star = subpath.slice(at, subpath.length - (best.key.length - at - 1));
|
|
116
|
+
target = map[best.key];
|
|
117
|
+
}
|
|
118
|
+
const chosen = (function pick(value) {
|
|
119
|
+
if (typeof value === "string" || value === null)
|
|
120
|
+
return value;
|
|
121
|
+
if (Array.isArray(value)) {
|
|
122
|
+
for (const one of value) {
|
|
123
|
+
const got = pick(one);
|
|
124
|
+
if (typeof got === "string")
|
|
125
|
+
return got;
|
|
126
|
+
}
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
if (isObject(value)) {
|
|
130
|
+
for (const [condition, inner] of Object.entries(value)) {
|
|
131
|
+
if (!REQUIRE_CONDITIONS.has(condition))
|
|
132
|
+
continue;
|
|
133
|
+
const got = pick(inner);
|
|
134
|
+
if (got !== undefined)
|
|
135
|
+
return got;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return undefined;
|
|
139
|
+
})(target);
|
|
140
|
+
if (typeof chosen !== "string" || !chosen.startsWith("./"))
|
|
141
|
+
return undefined;
|
|
142
|
+
return star === undefined ? chosen : chosen.replaceAll("*", star);
|
|
143
|
+
}
|
|
69
144
|
/** The file at `path` inside `dir`'s package `name`, when it is that package's own file (where a link points counts). */
|
|
70
145
|
function fileInPackage(dir, name, ...path) {
|
|
71
146
|
const home = join(dir, "node_modules", ...name.split("/"));
|
|
@@ -331,8 +406,9 @@ export async function installSettled(entry, dir, pins, { signal, onWait, pollMs
|
|
|
331
406
|
if (entry.lacking(dir, pins) === undefined)
|
|
332
407
|
return "installed";
|
|
333
408
|
const mark = await readMark(dir);
|
|
409
|
+
// No mark: an install that landed since the look above (its tree whole, then its mark gone) is installed, not none.
|
|
334
410
|
if (mark === undefined)
|
|
335
|
-
return "none";
|
|
411
|
+
return entry.lacking(dir, pins) === undefined ? "installed" : "none";
|
|
336
412
|
if ("failed" in mark)
|
|
337
413
|
return { failed: mark.failed };
|
|
338
414
|
if (Date.now() - mark.startedAt > timeoutMs || (mark.host === host && !isAlive(mark.pid)))
|
|
@@ -356,8 +432,144 @@ export async function installSettled(entry, dir, pins, { signal, onWait, pollMs
|
|
|
356
432
|
});
|
|
357
433
|
}
|
|
358
434
|
}
|
|
435
|
+
/** The file an installer holds while it installs into `dir`, beside the install's mark: made exclusively, so of every
|
|
436
|
+
* process on this data (the server, a runner beside it, one of its own) one installs at a time, and the others wait for
|
|
437
|
+
* that install. npm's staging directories beside `dir` are each install's own, and an install removes what an earlier one
|
|
438
|
+
* left there, so two at once would undo each other. */
|
|
439
|
+
export const installHoldOf = (dir) => `${installMarkOf(dir)}.hold`;
|
|
440
|
+
/** How young a hold that cannot be read is still taken as held (none is ever written part way: one left unreadable is a
|
|
441
|
+
* copy cut short, or a file of another's that this bound lets go of in time). */
|
|
442
|
+
const HOLD_WRITING_MS = 10_000;
|
|
443
|
+
/** How long past the install's timeout another host's hold is still taken as held: its npm's own timer starts after the
|
|
444
|
+
* hold is taken, then npm is given its grace to stop and to exit once killed (runNpm). A minute covers what comes
|
|
445
|
+
* before npm starts. */
|
|
446
|
+
const HOLD_STOP_MS = 60_000 + NPM_STOP_GRACE_MS + NPM_KILLED_WAIT_MS;
|
|
447
|
+
/** Process `pid`'s identity beyond its pid, where this system shows one (Linux's /proc): the boot it runs in and its start
|
|
448
|
+
* time in clock ticks since that boot. A pid reused by another process (a restarted container's, which may well be
|
|
449
|
+
* given the same one) never reads as the one that wrote a hold. Undefined where it can't be read (no such process, or
|
|
450
|
+
* no /proc). */
|
|
451
|
+
/** This process's pid namespace, where this system shows one (Linux's /proc/self/ns/pid: `pid:[<inode>]`): two
|
|
452
|
+
* containers on one data directory may share a hostname but not their pids, so a pid is asked of this process table only
|
|
453
|
+
* for a hold written in this namespace. Undefined where it can't be read. */
|
|
454
|
+
export function pidNamespace() {
|
|
455
|
+
try {
|
|
456
|
+
const ns = readlinkSync("/proc/self/ns/pid");
|
|
457
|
+
return /^pid:\[\d+\]$/.test(ns) ? ns : undefined;
|
|
458
|
+
}
|
|
459
|
+
catch {
|
|
460
|
+
return undefined;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
export function processIdentity(pid) {
|
|
464
|
+
try {
|
|
465
|
+
const stat = readFileSync(`/proc/${pid}/stat`, "utf8");
|
|
466
|
+
// The fields after the command (in parentheses, which may hold spaces): the state is the 3rd field, the start the 22nd.
|
|
467
|
+
const start = stat.slice(stat.lastIndexOf(")") + 2).split(" ")[19];
|
|
468
|
+
const boot = readFileSync("/proc/sys/kernel/random/boot_id", "utf8").trim();
|
|
469
|
+
return start && /^\d+$/.test(start) && boot ? `${boot}:${start}` : undefined;
|
|
470
|
+
}
|
|
471
|
+
catch {
|
|
472
|
+
return undefined;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
/** The hold at `at` as written, or undefined when it cannot be read (gone, cut short, not one). */
|
|
476
|
+
async function readHold(at) {
|
|
477
|
+
try {
|
|
478
|
+
const held = JSON.parse(await readFile(at, "utf8"));
|
|
479
|
+
return held !== null && typeof held === "object" ? held : undefined;
|
|
480
|
+
}
|
|
481
|
+
catch {
|
|
482
|
+
return undefined;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
/** Takes the hold on installs into `dir` for this process: its token when it holds it now, undefined while another
|
|
486
|
+
* installer does. One of this host's (and of this pid namespace, where it names one) is held while the process that wrote it lives, whatever its age (its npm may still
|
|
487
|
+
* be stopping): its pid alive and, where the system shows it, the same process (processIdentity), so a pid another
|
|
488
|
+
* process was given since never keeps it; where the identity can't be read, while its pid lives within INSTALL_TIMEOUT_MS
|
|
489
|
+
* and the time npm takes to stop (HOLD_STOP_MS). Another host's, whose process can't be asked, within that bound. The hold
|
|
490
|
+
* is written whole beside its place and linked into it, which fails when a hold is there, so no reader sees one part
|
|
491
|
+
* way. A hold its installer left (gone, or past that bound, or unreadable and older than HOLD_WRITING_MS) is taken over
|
|
492
|
+
* by one taker alone: the one that links it to a name of that very file's removes it, and only while it is still that
|
|
493
|
+
* file, so a hold another taker made meanwhile is never removed. */
|
|
494
|
+
export async function takeHold(dir, { isAlive = alive, identity = processIdentity, host = hostname(), pidns = pidNamespace(), timeoutMs = INSTALL_TIMEOUT_MS } = {}) {
|
|
495
|
+
const at = installHoldOf(dir);
|
|
496
|
+
await mkdir(dirname(at), { recursive: true });
|
|
497
|
+
const token = randomUUID();
|
|
498
|
+
const draft = `${at}.${token}`;
|
|
499
|
+
const own = identity(process.pid);
|
|
500
|
+
await writeFile(draft, JSON.stringify({ host, ...(pidns ? { pidns } : {}), pid: process.pid, ...(own ? { identity: own } : {}), startedAt: Date.now(), token }));
|
|
501
|
+
/** Whether a hold's pid can be asked of this process table: written on this host, in this pid namespace where both
|
|
502
|
+
* name one. Another namespace's (another container's on the same data, with the same hostname) is judged as another
|
|
503
|
+
* host's. */
|
|
504
|
+
const local = (held) => held.host === host && (typeof held.pidns !== "string" || pidns === undefined || held.pidns === pidns);
|
|
505
|
+
/** Whether a hold of this host's is still its installer's: that process alive, by its identity where both are known. */
|
|
506
|
+
const installing = (held) => {
|
|
507
|
+
if (!isAlive(held.pid))
|
|
508
|
+
return false;
|
|
509
|
+
const now = typeof held.identity === "string" ? identity(held.pid) : undefined;
|
|
510
|
+
return now !== undefined ? now === held.identity : Date.now() - held.startedAt <= timeoutMs + HOLD_STOP_MS;
|
|
511
|
+
};
|
|
512
|
+
try {
|
|
513
|
+
for (let tries = 0; tries < 3; tries++) {
|
|
514
|
+
try {
|
|
515
|
+
await link(draft, at);
|
|
516
|
+
return token;
|
|
517
|
+
}
|
|
518
|
+
catch (error) {
|
|
519
|
+
if (error.code !== "EEXIST")
|
|
520
|
+
throw error;
|
|
521
|
+
}
|
|
522
|
+
const judged = await lstat(at).catch(() => undefined);
|
|
523
|
+
if (!judged)
|
|
524
|
+
continue;
|
|
525
|
+
const held = await readHold(at);
|
|
526
|
+
const live = typeof held?.pid === "number" && typeof held.startedAt === "number"
|
|
527
|
+
? local(held) ? installing(held) : Date.now() - held.startedAt <= timeoutMs + HOLD_STOP_MS
|
|
528
|
+
: Date.now() - judged.mtimeMs <= HOLD_WRITING_MS;
|
|
529
|
+
if (live)
|
|
530
|
+
return undefined;
|
|
531
|
+
// Left by its installer: reaped by one taker alone. The hold is never moved; a taker links it to a name of that very
|
|
532
|
+
// file's (its device and inode), which only one can make, and that one removes the hold, once the link shows it is
|
|
533
|
+
// still the hold judged left: its device, inode and token. An inode alone is not enough: once another taker removes
|
|
534
|
+
// the hold, a fresh hold can be given the same inode, and only its token tells it apart. The others wait. A reap a
|
|
535
|
+
// taker cut short left long ago is cleared for the next look.
|
|
536
|
+
const reap = `${at}.reap-${judged.dev}-${judged.ino}`;
|
|
537
|
+
try {
|
|
538
|
+
await link(at, reap);
|
|
539
|
+
}
|
|
540
|
+
catch (error) {
|
|
541
|
+
const code = error.code;
|
|
542
|
+
if (code === "ENOENT")
|
|
543
|
+
continue;
|
|
544
|
+
if (code !== "EEXIST")
|
|
545
|
+
throw error;
|
|
546
|
+
const since = (await lstat(reap).catch(() => undefined))?.ctimeMs;
|
|
547
|
+
if (since !== undefined && Date.now() - since > HOLD_WRITING_MS)
|
|
548
|
+
await rm(reap, { force: true });
|
|
549
|
+
return undefined;
|
|
550
|
+
}
|
|
551
|
+
const reaped = await lstat(reap);
|
|
552
|
+
const same = reaped.ino === judged.ino && reaped.dev === judged.dev && (await readHold(reap))?.token === held?.token;
|
|
553
|
+
if (same)
|
|
554
|
+
await rm(at, { force: true });
|
|
555
|
+
await rm(reap, { force: true });
|
|
556
|
+
}
|
|
557
|
+
return undefined;
|
|
558
|
+
}
|
|
559
|
+
finally {
|
|
560
|
+
await rm(draft, { force: true }).catch(() => undefined);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
/** Lets go of the hold on installs into `dir` that `token` took; a hold of another's (one that took over this one past
|
|
564
|
+
* its bound) stays. */
|
|
565
|
+
export async function releaseHold(dir, token) {
|
|
566
|
+
const at = installHoldOf(dir);
|
|
567
|
+
if ((await readHold(at))?.token === token)
|
|
568
|
+
await rm(at, { force: true });
|
|
569
|
+
}
|
|
359
570
|
/** The server's one installer of a harness into `dir`: `ensure()` resolves once it is installed whole, installing it first
|
|
360
|
-
* when it is not, and every caller while an install runs waits for that one.
|
|
571
|
+
* when it is not, and every caller while an install runs waits for that one. While another process installs it (it holds
|
|
572
|
+
* installHoldOf), this one waits for that install instead of starting its own. A failed install is not kept: the next call
|
|
361
573
|
* tries again. `stop()` stops an install that runs (its npm) and waits, bounded, for it to end. `onInstalled` hears of an
|
|
362
574
|
* install this server made, and how long it took. */
|
|
363
575
|
export class HarnessInstall {
|
|
@@ -399,33 +611,54 @@ export class HarnessInstall {
|
|
|
399
611
|
if (this.stopping.signal.aborted)
|
|
400
612
|
return Promise.reject(new Error("the server is stopping"));
|
|
401
613
|
this.running ??= (async () => {
|
|
402
|
-
//
|
|
403
|
-
//
|
|
404
|
-
//
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
await
|
|
412
|
-
|
|
614
|
+
// One installer at a time on this data: while another process holds the install, wait for it to settle, then look
|
|
615
|
+
// again (installed: done; failed while this waited on it: so is this; let go with nothing in: take the hold). A
|
|
616
|
+
// failure read at once, with no wait, is the last install's: its holder may be retrying it and not yet have written
|
|
617
|
+
// its own mark, so this looks again rather than failing in that old install's words.
|
|
618
|
+
let token;
|
|
619
|
+
while (!(token = await takeHold(this.dir))) {
|
|
620
|
+
if (this.stopping.signal.aborted)
|
|
621
|
+
throw new Error("the server is stopping");
|
|
622
|
+
let waited = false;
|
|
623
|
+
const settled = await installSettled(this.entry, this.dir, await this.pins(), { signal: this.stopping.signal, onWait: () => (waited = true) });
|
|
624
|
+
if (settled === "installed")
|
|
625
|
+
return void (this.done = true);
|
|
626
|
+
if (typeof settled === "object" && waited)
|
|
627
|
+
throw new Error(settled.failed);
|
|
628
|
+
await new Promise((resolve) => setTimeout(resolve, 250));
|
|
413
629
|
}
|
|
414
|
-
const started = performance.now();
|
|
415
630
|
try {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
631
|
+
// The mark a run's claim reads, in this process or a runner's own (installSettled): installing now, then gone once
|
|
632
|
+
// it is in, or why it failed. Written first, before anything is read, so a claim made as this install starts (a run
|
|
633
|
+
// started just after the save that started it) finds it; gone at once when the harness is installed already.
|
|
634
|
+
await writeMark(this.dir, { host: hostname(), pid: process.pid, startedAt: Date.now() });
|
|
635
|
+
const pins = await this.pins().catch(async (error) => {
|
|
421
636
|
await rm(installMarkOf(this.dir), { force: true }).catch(() => undefined);
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
637
|
+
throw error;
|
|
638
|
+
});
|
|
639
|
+
if (this.entry.lacking(this.dir, pins) === undefined) {
|
|
640
|
+
await rm(installMarkOf(this.dir), { force: true });
|
|
641
|
+
return void (this.done = true);
|
|
642
|
+
}
|
|
643
|
+
const started = performance.now();
|
|
644
|
+
try {
|
|
645
|
+
await this.install(this.entry, this.dir, pins, this.stopping.signal);
|
|
646
|
+
}
|
|
647
|
+
catch (error) {
|
|
648
|
+
// Why it failed, for the runs that waited on it; a server that stops leaves no mark (its npm was stopped, not refused).
|
|
649
|
+
if (this.stopping.signal.aborted)
|
|
650
|
+
await rm(installMarkOf(this.dir), { force: true }).catch(() => undefined);
|
|
651
|
+
else
|
|
652
|
+
await writeMark(this.dir, { failed: error.message, at: Date.now() }).catch(() => undefined);
|
|
653
|
+
throw error;
|
|
654
|
+
}
|
|
655
|
+
await rm(installMarkOf(this.dir), { force: true });
|
|
656
|
+
this.done = true;
|
|
657
|
+
this.onInstalled?.(Math.round(performance.now() - started));
|
|
658
|
+
}
|
|
659
|
+
finally {
|
|
660
|
+
await releaseHold(this.dir, token).catch(() => undefined);
|
|
425
661
|
}
|
|
426
|
-
await rm(installMarkOf(this.dir), { force: true });
|
|
427
|
-
this.done = true;
|
|
428
|
-
this.onInstalled?.(Math.round(performance.now() - started));
|
|
429
662
|
})().finally(() => (this.running = undefined));
|
|
430
663
|
return this.running;
|
|
431
664
|
}
|
|
@@ -435,3 +668,58 @@ export class HarnessInstall {
|
|
|
435
668
|
await this.running?.catch(() => undefined);
|
|
436
669
|
}
|
|
437
670
|
}
|
|
671
|
+
/** A runner's installs, by the directory each goes into: one HarnessInstall per directory in this process, which every
|
|
672
|
+
* claim that needs it waits on, and how many wait now. */
|
|
673
|
+
const claimInstalls = new Map();
|
|
674
|
+
/** Where a run's claim stands on the install into `dir`, as installSettled says, except that an install this process's
|
|
675
|
+
* claims run (installForClaim) is never waited on from outside: it reads "none", so the claim joins it by installForClaim
|
|
676
|
+
* and counts among those that wait for it. Waited on from outside, it would stop once the claim that started it let go,
|
|
677
|
+
* though this one still needed it, and start again. An install the server runs is waited on as before. */
|
|
678
|
+
export function claimSettled(entry, dir, pins, options = {}) {
|
|
679
|
+
const isAlive = options.isAlive ?? alive;
|
|
680
|
+
return installSettled(entry, dir, pins, { ...options, isAlive: (pid) => !(pid === process.pid && claimInstalls.has(dir)) && isAlive(pid) });
|
|
681
|
+
}
|
|
682
|
+
/** Installs `entry` into `dir` for a run's claim when nothing installs it (no install runs, or the last one failed before
|
|
683
|
+
* this claim): the claim installs it itself, by `lock` (default the one AgentRun ships), or waits for the install this
|
|
684
|
+
* process or another runs for it already; it resolves once it is in and rejects with the install's own words when it
|
|
685
|
+
* fails. `signal` aborted (the run stopped, its claim lost, the runner closing): this claim stops waiting at once, and the
|
|
686
|
+
* install's npm is stopped once no claim waits for it. `install`: what runs the install in place of npm (a test's). */
|
|
687
|
+
export async function installForClaim(entry, dir, pins, { lock, signal, install } = {}) {
|
|
688
|
+
let held = claimInstalls.get(dir);
|
|
689
|
+
if (!held) {
|
|
690
|
+
held = { install: new HarnessInstall(entry, dir, pins, install ?? ((entry, dir, pins, stop) => npmInstall(entry, dir, pins, { signal: stop, ...(lock ? { lock } : {}) }))), waiting: 0 };
|
|
691
|
+
claimInstalls.set(dir, held);
|
|
692
|
+
}
|
|
693
|
+
const mine = held;
|
|
694
|
+
mine.waiting += 1;
|
|
695
|
+
try {
|
|
696
|
+
const installing = mine.install.ensure();
|
|
697
|
+
installing.catch(() => undefined);
|
|
698
|
+
if (!signal)
|
|
699
|
+
return await installing;
|
|
700
|
+
signal.throwIfAborted();
|
|
701
|
+
await new Promise((resolve, reject) => {
|
|
702
|
+
const stop = () => reject(signal.reason);
|
|
703
|
+
signal.addEventListener("abort", stop, { once: true });
|
|
704
|
+
installing.then(resolve, reject).finally(() => signal.removeEventListener("abort", stop));
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
finally {
|
|
708
|
+
mine.waiting -= 1;
|
|
709
|
+
if (mine.waiting === 0 && claimInstalls.get(dir) === mine) {
|
|
710
|
+
claimInstalls.delete(dir);
|
|
711
|
+
// Nothing waits for it any more: its npm stops (nothing to stop once it is in or has failed). The claim goes on at
|
|
712
|
+
// once; the stop is kept until it ends, for the runner's close to wait on (claimInstallsStopped).
|
|
713
|
+
const stopping = mine.install.stop();
|
|
714
|
+
claimStops.add(stopping);
|
|
715
|
+
void stopping.finally(() => claimStops.delete(stopping));
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
/** The stops of the claims' installs under way (installForClaim). */
|
|
720
|
+
const claimStops = new Set();
|
|
721
|
+
/** Resolves once every install a claim let go of has stopped (its npm ended, SIGTERM then SIGKILL past its grace, its
|
|
722
|
+
* staging directory and hold gone): a runner's close waits for it before the process can end, so no npm outlives it. */
|
|
723
|
+
export async function claimInstallsStopped() {
|
|
724
|
+
await Promise.all([...claimStops]);
|
|
725
|
+
}
|
package/dist/harness.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export type HarnessOffer = {
|
|
|
23
23
|
* the memory a run of it reserves (`run_memory_mib`). */
|
|
24
24
|
export type HarnessCapability = HarnessOffer & {
|
|
25
25
|
default_model: string | null;
|
|
26
|
+
models: string[];
|
|
26
27
|
run_memory_mib: number;
|
|
27
28
|
};
|
|
28
29
|
/** What this server offers of each harness, checked once per environment: each one's entry in the harness table says
|
package/dist/harness.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// The harness that runs a revision: pi (
|
|
1
|
+
// The harness that runs a revision: pi (the default and the one a revision that names none gets) or
|
|
2
2
|
// one of the run adapters. A revision keeps the harness it names; the default is never stored, so a revision written
|
|
3
3
|
// before this field existed and one that names pi are the same revision. Which harnesses this server runs is said in
|
|
4
4
|
// capabilities, and a revision naming one it does not run saves with a warning and is refused at run time.
|
|
@@ -53,9 +53,43 @@ export function harnessOffers(env) {
|
|
|
53
53
|
// Each harness's model when a definition names none, as a save and a run resolve it (runnable.ts): none for a
|
|
54
54
|
// harness that does not run here, or that no model here would run on.
|
|
55
55
|
const { harnessModel } = await import("./runnable.js");
|
|
56
|
+
const { pickerCandidates } = await import("./model-form.js");
|
|
56
57
|
return Promise.all(base.map(async (offer) => {
|
|
57
58
|
const resolved = offer.available ? await harnessModel(env, offer.id, undefined, true) : undefined;
|
|
58
|
-
|
|
59
|
+
// The models a person may pick for it (model-form.ts), each in the form it takes: those its entry's own choice
|
|
60
|
+
// takes (the catalog it runs on knows the id, a key may still be missing: a save warns of that, never refuses),
|
|
61
|
+
// so the picker never offers one a save would refuse. None for a harness that does not run here.
|
|
62
|
+
const entry = harnessOf(env, offer.id);
|
|
63
|
+
const models = [];
|
|
64
|
+
if (offer.available) {
|
|
65
|
+
// Each choice passes what a save and a run ask, by construction: the save's own shape check (MODEL_REF), the
|
|
66
|
+
// harness's own choice of it, and, on an adapter's wire, providerFor, the function a run starts with. A model
|
|
67
|
+
// the wire cannot take (a vendor it does not run, an endpoint a key may not go to) is not offered; one that
|
|
68
|
+
// lacks only a key is (a save warns of that, never refuses).
|
|
69
|
+
const { MODEL_REF } = await import("./validate.js");
|
|
70
|
+
const { providerFor, HarnessUnavailable } = await import("./provider.js");
|
|
71
|
+
const { ADAPTER_FACTS } = await import("./adapter-facts.js");
|
|
72
|
+
const { FAUX_ENV } = await import("./model.js");
|
|
73
|
+
const facts = ADAPTER_FACTS.find((f) => f.id === offer.id);
|
|
74
|
+
for (const id of pickerCandidates(env, offer.id)) {
|
|
75
|
+
if (!MODEL_REF.test(id))
|
|
76
|
+
continue;
|
|
77
|
+
const chosen = await entry.model(env, id, true);
|
|
78
|
+
if (!chosen || !("model" in chosen || chosen.needs === "key"))
|
|
79
|
+
continue;
|
|
80
|
+
if (facts && "model" in chosen && !env[FAUX_ENV]) {
|
|
81
|
+
try {
|
|
82
|
+
providerFor(facts.wire, env, chosen.model, offer.id);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
if (!(error instanceof HarnessUnavailable && error.keys?.length))
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
models.push(id);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return { ...offer, default_model: resolved && "model" in resolved ? `${resolved.model.provider}/${resolved.model.modelId}` : null, models, run_memory_mib: entry.runMib };
|
|
59
93
|
}));
|
|
60
94
|
})();
|
|
61
95
|
offered.set(env, offers);
|
package/dist/host-tools.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import { type ToolExecutionApi, type ToolRegistration } from "@earendil-works/pi-durable";
|
|
3
3
|
import type { HostTool } from "@parcha/agentrun-kernel";
|
|
4
4
|
export { workspaceRelative } from "./workspace-paths.js";
|
|
@@ -18,14 +18,14 @@ export type ToolResults = Map<string, {
|
|
|
18
18
|
* nested-tool members) belongs to the tool task pi runs a tool in, which a host tool, called by another harness, has
|
|
19
19
|
* none of: the full type cannot be built here, so a read of any other member throws, naming it, rather than reading as
|
|
20
20
|
* "is not a function". `conversationId` is the run's root conversation, where a host tool's calls are made: serve's
|
|
21
|
-
* browser-cost `capped` reads it, now that the browser binds as a host tool on the runner. `snapshot
|
|
22
|
-
*
|
|
23
|
-
* document
|
|
24
|
-
* piExecutor) has no run Harness and gives none of these
|
|
21
|
+
* browser-cost `capped` reads it, now that the browser binds as a host tool on the runner. `snapshot` and
|
|
22
|
+
* `waitForTask` are the run's own Harness's (run.harness, the claim's journal on the runner), as `commit` is: a
|
|
23
|
+
* document or a task of this run, never another's. A remote executor (workspace/executors.ts
|
|
24
|
+
* piExecutor) has no run Harness and gives none of these three (RUN_ONLY_MEMBERS); the coding tools it runs read none.
|
|
25
25
|
* `memo` and `taskId` are a pi tool task's own, which a host tool runs in none of: they are not given here. */
|
|
26
|
-
export declare const HOST_API_MEMBERS: readonly ["env", "callId", "commit", "output", "outputWindow", "retainedOutput", "diagnostic", "agent", "models", "conversationId", "snapshot", "
|
|
26
|
+
export declare const HOST_API_MEMBERS: readonly ["env", "callId", "commit", "output", "outputWindow", "retainedOutput", "diagnostic", "agent", "models", "conversationId", "snapshot", "waitForTask"];
|
|
27
27
|
/** The members a host tool's api gives only on a run's Harness: a remote executor's api has none of them. */
|
|
28
|
-
export declare const RUN_ONLY_MEMBERS: readonly ["conversationId", "snapshot", "
|
|
28
|
+
export declare const RUN_ONLY_MEMBERS: readonly ["conversationId", "snapshot", "waitForTask"];
|
|
29
29
|
/** What one host tool's call reads of the run: the run's environment (its file environment, the api's `env`), its
|
|
30
30
|
* harness's commit and its root agent (a paid call's booking and pi's read), the context and the results map, and the
|
|
31
31
|
* paid-call money seam, over the runner's claim Harness (runner/adapter-run-spec.ts). */
|
|
@@ -36,10 +36,9 @@ export interface HostToolCtx {
|
|
|
36
36
|
env(): Promise<ToolExecutionApi["env"]>;
|
|
37
37
|
readonly commit: ToolExecutionApi["commit"];
|
|
38
38
|
readonly agent: ToolExecutionApi["agent"];
|
|
39
|
-
/** The run's own Harness's snapshot
|
|
40
|
-
* `commit` is: a document
|
|
39
|
+
/** The run's own Harness's snapshot and waitForTask (run.harness, the claim's journal on the runner), as
|
|
40
|
+
* `commit` is: a document or task of this run only. */
|
|
41
41
|
readonly snapshot: ToolExecutionApi["snapshot"];
|
|
42
|
-
readonly conversation: ToolExecutionApi["conversation"];
|
|
43
42
|
readonly waitForTask: ToolExecutionApi["waitForTask"];
|
|
44
43
|
/** A gate for a tool that cannot be run on the runner yet: undefined to run the call, else the refusal that is its answer,
|
|
45
44
|
* so the tool is listed but never run as a stub. No tool sets it now (learned_workflow runs for real on every session's
|
package/dist/host-tools.js
CHANGED
|
@@ -18,14 +18,14 @@ export { cutUtf8, MAX_BYTES, MAX_LINES } from "./workspace/executors.js";
|
|
|
18
18
|
* nested-tool members) belongs to the tool task pi runs a tool in, which a host tool, called by another harness, has
|
|
19
19
|
* none of: the full type cannot be built here, so a read of any other member throws, naming it, rather than reading as
|
|
20
20
|
* "is not a function". `conversationId` is the run's root conversation, where a host tool's calls are made: serve's
|
|
21
|
-
* browser-cost `capped` reads it, now that the browser binds as a host tool on the runner. `snapshot
|
|
22
|
-
*
|
|
23
|
-
* document
|
|
24
|
-
* piExecutor) has no run Harness and gives none of these
|
|
21
|
+
* browser-cost `capped` reads it, now that the browser binds as a host tool on the runner. `snapshot` and
|
|
22
|
+
* `waitForTask` are the run's own Harness's (run.harness, the claim's journal on the runner), as `commit` is: a
|
|
23
|
+
* document or a task of this run, never another's. A remote executor (workspace/executors.ts
|
|
24
|
+
* piExecutor) has no run Harness and gives none of these three (RUN_ONLY_MEMBERS); the coding tools it runs read none.
|
|
25
25
|
* `memo` and `taskId` are a pi tool task's own, which a host tool runs in none of: they are not given here. */
|
|
26
|
-
export const HOST_API_MEMBERS = ["env", "callId", "commit", "output", "outputWindow", "retainedOutput", "diagnostic", "agent", "models", "conversationId", "snapshot", "
|
|
26
|
+
export const HOST_API_MEMBERS = ["env", "callId", "commit", "output", "outputWindow", "retainedOutput", "diagnostic", "agent", "models", "conversationId", "snapshot", "waitForTask"];
|
|
27
27
|
/** The members a host tool's api gives only on a run's Harness: a remote executor's api has none of them. */
|
|
28
|
-
export const RUN_ONLY_MEMBERS = ["conversationId", "snapshot", "
|
|
28
|
+
export const RUN_ONLY_MEMBERS = ["conversationId", "snapshot", "waitForTask"];
|
|
29
29
|
const hostApi = (given) => new Proxy(given, {
|
|
30
30
|
get: (target, key) => {
|
|
31
31
|
if (typeof key === "symbol" || key === "then" || Object.hasOwn(target, key))
|
|
@@ -68,7 +68,7 @@ export function hostToolOf(name, tool, ctx) {
|
|
|
68
68
|
agent: ctx.agent,
|
|
69
69
|
models: createModels(),
|
|
70
70
|
conversationId: ROOT_CONVERSATION_ID,
|
|
71
|
-
snapshot: ctx.snapshot,
|
|
71
|
+
snapshot: ctx.snapshot, waitForTask: ctx.waitForTask,
|
|
72
72
|
});
|
|
73
73
|
// A tool that throws (bash on a non-zero exit or a timeout) still answers with its output, as pi's harness does;
|
|
74
74
|
// monid's answer a failure as an error result, which is kept as it is.
|
package/dist/hosted-search.d.ts
CHANGED
|
@@ -23,8 +23,9 @@ export declare const OPENAI_SEARCH_LIMIT: Readonly<{
|
|
|
23
23
|
}>;
|
|
24
24
|
/** $10 per 1,000 searches (Anthropic) or calls (OpenAI). */
|
|
25
25
|
export declare const SEARCH_USD = 0.01;
|
|
26
|
-
/**
|
|
27
|
-
|
|
26
|
+
/** What a hosted search asks: the run's models a search request goes through (on the runner, the session's port: its
|
|
27
|
+
* proxy, policy, key, price and cap), handed to each search by its run, never kept per process. */
|
|
28
|
+
export type SearchModels = Pick<Models, "getModel" | "completeSimple">;
|
|
28
29
|
/** `query` searched by `ref`'s provider (`provider/model-id`, the model the server resolved web_search on) through the
|
|
29
|
-
* run's models, at most `n` results: a Search.
|
|
30
|
-
export declare function hostedSearch(query: string, n: number, ref: string | undefined, signal
|
|
30
|
+
* run's models (`models`: its own, handed by the run; none, no model to search on), at most `n` results: a Search. */
|
|
31
|
+
export declare function hostedSearch(query: string, n: number, ref: string | undefined, signal: AbortSignal | undefined, models: SearchModels | undefined): Promise<Search>;
|
package/dist/hosted-search.js
CHANGED
|
@@ -21,11 +21,6 @@ const BLOCK_BILLED = /^gpt-(?:4o|4\.1)-mini(?:-|$)/;
|
|
|
21
21
|
const ANSWER_TOKENS = 2_048;
|
|
22
22
|
/** As Exa's and Parallel's searches stop. */
|
|
23
23
|
const TIMEOUT_MS = 60_000;
|
|
24
|
-
let runModels;
|
|
25
|
-
/** The run's models, marked and capped, handed over by the run's app before its tools are bound. */
|
|
26
|
-
export function searchOn(models) {
|
|
27
|
-
runModels = models;
|
|
28
|
-
}
|
|
29
24
|
const list = (value) => (Array.isArray(value) ? value.filter((item) => typeof item === "object" && item !== null) : []);
|
|
30
25
|
const text = (value) => (typeof value === "string" ? value : undefined);
|
|
31
26
|
/** What a provider's events say of the search: its results by URL, first seen first, and how many searches it ran. */
|
|
@@ -90,8 +85,8 @@ function reader(anthropic) {
|
|
|
90
85
|
};
|
|
91
86
|
}
|
|
92
87
|
/** `query` searched by `ref`'s provider (`provider/model-id`, the model the server resolved web_search on) through the
|
|
93
|
-
* run's models, at most `n` results: a Search.
|
|
94
|
-
export async function hostedSearch(query, n, ref, signal, models
|
|
88
|
+
* run's models (`models`: its own, handed by the run; none, no model to search on), at most `n` results: a Search. */
|
|
89
|
+
export async function hostedSearch(query, n, ref, signal, models) {
|
|
95
90
|
const slash = ref?.indexOf("/") ?? -1;
|
|
96
91
|
const provider = ref && slash > 0 ? ref.slice(0, slash) : undefined;
|
|
97
92
|
const id = ref && slash > 0 ? ref.slice(slash + 1) : undefined;
|
package/dist/import-sources.d.ts
CHANGED
|
@@ -69,6 +69,12 @@ export type Session = {
|
|
|
69
69
|
/** The whole session's cost, when the source records it; absent is unknown. */
|
|
70
70
|
costUsd?: number;
|
|
71
71
|
firstPrompt?: string;
|
|
72
|
+
/** The source's own title for the session, as Claude Code shows it: the person's (/rename's custom-title), else the one
|
|
73
|
+
* it wrote itself (ai-title; summary in older files, the one whose last message this session holds), the latest. */
|
|
74
|
+
sourceTitle?: string;
|
|
75
|
+
/** The first of the person's own words (personsWords): the first user text that is not a CLI's command, its output or
|
|
76
|
+
* its preamble. The run's title when the source wrote none. */
|
|
77
|
+
titleText?: string;
|
|
72
78
|
/** A subagent's or another session's child: not imported as a run; its usage is its parent's. */
|
|
73
79
|
child: boolean;
|
|
74
80
|
/** A child's parent session, when its file names it (Codex's parent thread). */
|
|
@@ -102,3 +108,7 @@ export declare function readSession(file: string, source: Source, { turns: keep,
|
|
|
102
108
|
}): Promise<Session>;
|
|
103
109
|
/** The effort most of `turns`' requests ran at, as the model of most requests is a run's model: the first seen of a tie. */
|
|
104
110
|
export declare function mostEffortOf(turns: readonly Turn[]): string | undefined;
|
|
111
|
+
/** The person's own words in a user message's text, as they wrote them (spaces and lines kept, so a cut still matches
|
|
112
|
+
* a secret in them): none when the CLI wrote all of it (a slash command, its output, its preamble), or when there are
|
|
113
|
+
* no words at all. */
|
|
114
|
+
export declare function personsWords(text: string): string | undefined;
|