@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/runner/mcp-run.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { HostTool, SessionMcp } from "@parcha/agentrun-kernel";
|
|
2
2
|
import type { Harness } from "@earendil-works/pi-durable";
|
|
3
3
|
import { type McpGatewayOptions } from "../mcp-gateway.js";
|
|
4
|
-
import type
|
|
4
|
+
import { type OAuthNetwork } from "../mcp-oauth.js";
|
|
5
5
|
import type { Store, TriggerSettings } from "../store/index.js";
|
|
6
6
|
import { type ApprovalPrice } from "../tool-gate.js";
|
|
7
7
|
import { type AnswerData } from "./journal-kinds.js";
|
|
@@ -35,6 +35,9 @@ export interface McpForClaimOptions {
|
|
|
35
35
|
/** A test's fake GitHub MCP origin, handed to the claim step (mcpClaim's githubMcpOrigin): for tests only: no environment variable, flag or setting maps onto it; absent, GitHub's hosted MCP
|
|
36
36
|
* (github.ts GITHUB_MCP_ORIGIN). */
|
|
37
37
|
readonly githubMcpOrigin?: string;
|
|
38
|
+
/** Whether this runner may reach an MCP server whose URL is on loopback (AdapterSpecDeps.mcpLoopback): only a runner
|
|
39
|
+
* beside a local-install server is. Absent, never. */
|
|
40
|
+
readonly loopback?: boolean;
|
|
38
41
|
/** For tests: the authorization servers' network, a refresh's bound, the gateway's upstream fetch and bounds, and the
|
|
39
42
|
* timer a github_app token's refresh is armed on. */
|
|
40
43
|
readonly network?: OAuthNetwork;
|
|
@@ -48,6 +51,8 @@ export interface McpForClaimOptions {
|
|
|
48
51
|
connectMs?: number;
|
|
49
52
|
};
|
|
50
53
|
readonly githubTimer?: GithubTimer;
|
|
54
|
+
/** Each credential value the claim opens, refreshes or mints, for the run's redactors (mcp-claim.ts `hold`). */
|
|
55
|
+
readonly hold?: (values: string[]) => void;
|
|
51
56
|
}
|
|
52
57
|
/** A call as the loop's gate is asked about it: the tool by its catalog name. */
|
|
53
58
|
export type McpGateCall = {
|
|
@@ -75,9 +80,6 @@ export interface ClaimMcp {
|
|
|
75
80
|
* sent; or parked, answered the gate's waiting words marked parked, nothing sent), then its host tool from `wrapped`,
|
|
76
81
|
* as the loop wrapped it. */
|
|
77
82
|
session(wrapped: ReadonlyMap<string, HostTool>, gate: (call: McpGateCall) => Promise<McpGateAnswer>): SessionMcp;
|
|
78
|
-
/** The credential values the gateway's calls in flight hold, for a redaction: each call's for as long as it is out,
|
|
79
|
-
* with any token refreshed while it was; none when idle. */
|
|
80
|
-
redactions(): string[];
|
|
81
83
|
/** The claim step's credentials opened again on the same pin (an expired OAuth token refreshed), then the claim
|
|
82
84
|
* confirmed: before a resumed loop's next model request. */
|
|
83
85
|
fresh(): Promise<void>;
|
package/dist/runner/mcp-run.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
2
2
|
import { wireName } from "../catalog.js";
|
|
3
3
|
import { mcpGateway, noCallId } from "../mcp-gateway.js";
|
|
4
|
-
import {
|
|
4
|
+
import { dialAt, mcpServerAt, systemNetwork } from "../mcp-oauth.js";
|
|
5
|
+
import { privateOAuthHosts } from "../mcp-private-hosts.js";
|
|
6
|
+
import { argsPreview, mcpToolName, RESUME_GO_ON, resumeText, RESUME_PREFIX, waitingText } from "../tool-gate.js";
|
|
5
7
|
import { deniedText } from "./loop-contract.js";
|
|
6
8
|
import { STOPPED_WHILE_WAITING } from "../refusal-words.js";
|
|
7
9
|
import { endedAnswer, KINDS } from "./journal-kinds.js";
|
|
@@ -26,9 +28,11 @@ export async function mcpForClaim(options) {
|
|
|
26
28
|
signal: held.signal,
|
|
27
29
|
...(options.bounds ? { bounds: options.bounds } : {}),
|
|
28
30
|
...(options.network ? { network: options.network } : {}),
|
|
31
|
+
...(options.loopback ? { loopback: true } : {}),
|
|
29
32
|
...(githubApp ? { githubApp } : {}),
|
|
30
33
|
...(options.githubMcpOrigin ? { githubMcpOrigin: options.githubMcpOrigin } : {}),
|
|
31
34
|
...(options.githubTimer ? { githubTimer: options.githubTimer } : {}),
|
|
35
|
+
...(options.hold ? { hold: options.hold } : {}),
|
|
32
36
|
});
|
|
33
37
|
}
|
|
34
38
|
catch (error) {
|
|
@@ -40,9 +44,19 @@ export async function mcpForClaim(options) {
|
|
|
40
44
|
held.abort();
|
|
41
45
|
return undefined;
|
|
42
46
|
}
|
|
47
|
+
const network = options.network ?? systemNetwork;
|
|
43
48
|
const gateway = mcpGateway({
|
|
44
49
|
pin,
|
|
45
50
|
credentials: step.credentials,
|
|
51
|
+
// Each request's address checked as the server checks it at a save (mcp-oauth.ts mcpServerAt), with the owner's
|
|
52
|
+
// private-network hosts read now, and dialled at the address checked: a name that resolves somewhere private since the
|
|
53
|
+
// save, or a host the owner no longer allows, is refused unsent. A URL on loopback is reached only by a runner told
|
|
54
|
+
// so by the local-install server beside it, in its own process (options.loopback): never by what a store says, so
|
|
55
|
+
// one host's local install never opens loopback for another host's runner on a shared store.
|
|
56
|
+
reach: async (url, signal) => {
|
|
57
|
+
const at = await mcpServerAt(new URL(url), signal, network, { allowed: await privateOAuthHosts(options.store), loopback: options.loopback === true });
|
|
58
|
+
return "refused" in at ? { refused: at.refused } : { send: dialAt(network, at.address, options.fetch ?? fetch) };
|
|
59
|
+
},
|
|
46
60
|
beforeCall: step.beforeCall,
|
|
47
61
|
work: options.work,
|
|
48
62
|
commit: () => (change) => options.harness.commit(change, BACKGROUND_CONTEXT),
|
|
@@ -100,7 +114,6 @@ export async function mcpForClaim(options) {
|
|
|
100
114
|
return said(result.text, result.isError === true);
|
|
101
115
|
},
|
|
102
116
|
}),
|
|
103
|
-
redactions: () => gateway.heldValues(),
|
|
104
117
|
fresh: () => step.fresh(),
|
|
105
118
|
release: () => held.abort(),
|
|
106
119
|
};
|
|
@@ -159,5 +172,5 @@ export async function parkedFollowUp(mcp, options) {
|
|
|
159
172
|
texts.push(resumeText({ tool: call.tool, call_id: call.callId }, argsPreview(call.args), answer.approved ? "allow" : "deny", { text: result.text, isError: result.isError === true }));
|
|
160
173
|
callIds.push(call.callId);
|
|
161
174
|
}
|
|
162
|
-
return texts.length ? { text: texts.join("\n\n")
|
|
175
|
+
return texts.length ? { text: `${texts.join("\n\n")}\n\n${RESUME_GO_ON}`, callIds } : undefined;
|
|
163
176
|
}
|
package/dist/runner/metrics.d.ts
CHANGED
|
@@ -25,8 +25,21 @@ export type BookedSpend = {
|
|
|
25
25
|
* or with no runner.turn yet (in flight, or cut off by a crash before its answer was booked), makes the sum unknown
|
|
26
26
|
* (null), its known part kept, as sessionSpendOf counts it. A CLI harness's own record carries no per-request cost, nor do
|
|
27
27
|
* a workflow's model nodes (pi-ai's $0 for a model it has no price for): their model requests' cost is this, the
|
|
28
|
-
* booking's.
|
|
29
|
-
|
|
28
|
+
* booking's. `side`: of the model requests, those booked as side calls (another model than the session's, or the host's
|
|
29
|
+
* own, as a learned workflow's node is: the proxy's `side`/`host`), which no answer of a pi run carries. */
|
|
30
|
+
export declare function bookedSpend(entries: readonly EntryLike[], which: "model" | "paid" | "decisions" | "side"): BookedSpend;
|
|
31
|
+
/** An agent run's cost as its end commit stores it: its model requests' (`model`), its paid tool calls' (`paid`, the
|
|
32
|
+
* run's ledger.paid) and its decisions' (`decisions`, a learned workflow's decision nodes, LS-07: bookedSpend over
|
|
33
|
+
* their own session's records, so one that reported no cost is unknown, never the cap's hold for it), summed; null (unknown) when any of them is. Never a known figure that leaves an unknown part out. */
|
|
34
|
+
export declare function runEndCost(parts: {
|
|
35
|
+
readonly model: number | null;
|
|
36
|
+
readonly paid: number | null;
|
|
37
|
+
readonly decisions: number | null;
|
|
38
|
+
}): number | null;
|
|
39
|
+
/** Whether a CLI harness's record (`entries`, its root's) shows the model at work: a model message, a tool call it made, or
|
|
40
|
+
* its end-of-run turn's answer. Each took a model request, so a run that shows one and booked none (its requests went
|
|
41
|
+
* past its model proxy) spent what no booking read: its cost is unknown, never $0. */
|
|
42
|
+
export declare function cliModelWorked(entries: readonly EntryLike[]): boolean;
|
|
30
43
|
/** Whether a run's record carries no cost of its own, so its usage row and its live spend are its booking's: a CLI
|
|
31
44
|
* harness's record (`cli`), or a workflow's (its model nodes' answers carry pi-ai's $0). A pi run's answers carry their
|
|
32
45
|
* booking (adapters/pi.ts afterResponse). */
|
package/dist/runner/metrics.js
CHANGED
|
@@ -32,14 +32,18 @@ function sessionConversations(entries) {
|
|
|
32
32
|
* or with no runner.turn yet (in flight, or cut off by a crash before its answer was booked), makes the sum unknown
|
|
33
33
|
* (null), its known part kept, as sessionSpendOf counts it. A CLI harness's own record carries no per-request cost, nor do
|
|
34
34
|
* a workflow's model nodes (pi-ai's $0 for a model it has no price for): their model requests' cost is this, the
|
|
35
|
-
* booking's.
|
|
35
|
+
* booking's. `side`: of the model requests, those booked as side calls (another model than the session's, or the host's
|
|
36
|
+
* own, as a learned workflow's node is: the proxy's `side`/`host`), which no answer of a pi run carries. */
|
|
36
37
|
export function bookedSpend(entries, which) {
|
|
37
38
|
const keyed = sessionConversations(entries);
|
|
38
39
|
const paidConv = keyed.get(TOOL_SESSION);
|
|
39
40
|
const decisionsConv = keyed.get(DECISION_SESSION);
|
|
40
41
|
const conv = (e) => Number(e.conversationId);
|
|
41
|
-
const chosen = (e) => (which === "paid" ? conv(e) === paidConv : which === "decisions" ? conv(e) === decisionsConv : conv(e) !== paidConv && conv(e) !== decisionsConv);
|
|
42
42
|
const turnOf = (e) => `${String(e.conversationId)}:${String(e.data?.turn)}`;
|
|
43
|
+
const model = (e) => conv(e) !== paidConv && conv(e) !== decisionsConv;
|
|
44
|
+
// The side calls among the model requests: each request that says so, by its conversation and turn.
|
|
45
|
+
const sides = new Set(entries.filter((e) => e.kind === RUNNER_RECORDS.request && model(e) && (e.data?.side === true || typeof e.data?.host === "string")).map(turnOf));
|
|
46
|
+
const chosen = (e) => (which === "paid" ? conv(e) === paidConv : which === "decisions" ? conv(e) === decisionsConv : which === "side" ? model(e) && sides.has(turnOf(e)) : model(e));
|
|
43
47
|
const answered = new Set(entries.filter((e) => e.kind === RUNNER_RECORDS.turn && chosen(e)).map(turnOf));
|
|
44
48
|
// The model each request was sent on, by its turn (its runner.request's `model`).
|
|
45
49
|
const sentOn = new Map(entries.filter((e) => e.kind === RUNNER_RECORDS.request && chosen(e)).map((e) => [turnOf(e), e.data?.model]));
|
|
@@ -86,6 +90,21 @@ export function bookedSpend(entries, which) {
|
|
|
86
90
|
}
|
|
87
91
|
return { usd: unpriced ? null : known, known, unpriced, requests, unmetered, models, tokens };
|
|
88
92
|
}
|
|
93
|
+
/** An agent run's cost as its end commit stores it: its model requests' (`model`), its paid tool calls' (`paid`, the
|
|
94
|
+
* run's ledger.paid) and its decisions' (`decisions`, a learned workflow's decision nodes, LS-07: bookedSpend over
|
|
95
|
+
* their own session's records, so one that reported no cost is unknown, never the cap's hold for it), summed; null (unknown) when any of them is. Never a known figure that leaves an unknown part out. */
|
|
96
|
+
export function runEndCost(parts) {
|
|
97
|
+
return parts.model === null || parts.paid === null || parts.decisions === null ? null : parts.model + parts.paid + parts.decisions;
|
|
98
|
+
}
|
|
99
|
+
/** Whether a CLI harness's record (`entries`, its root's) shows the model at work: a model message, a tool call it made, or
|
|
100
|
+
* its end-of-run turn's answer. Each took a model request, so a run that shows one and booked none (its requests went
|
|
101
|
+
* past its model proxy) spent what no booking read: its cost is unknown, never $0. */
|
|
102
|
+
export function cliModelWorked(entries) {
|
|
103
|
+
return entries.some((e) => {
|
|
104
|
+
const role = e.data?.role;
|
|
105
|
+
return e.kind === KINDS.callStart || ((e.kind === KINDS.message || e.kind === KINDS.endOfRunTurn) && role === "model");
|
|
106
|
+
});
|
|
107
|
+
}
|
|
89
108
|
/** Whether a run's record carries no cost of its own, so its usage row and its live spend are its booking's: a CLI
|
|
90
109
|
* harness's record (`cli`), or a workflow's (its model nodes' answers carry pi-ai's $0). A pi run's answers carry their
|
|
91
110
|
* booking (adapters/pi.ts afterResponse). */
|
|
@@ -55,6 +55,9 @@ export interface ModelRoute {
|
|
|
55
55
|
readonly fetch?: typeof fetch;
|
|
56
56
|
/** The catalog's cost of the model, tiers included: what the cap prices a request at before it leaves. */
|
|
57
57
|
readonly cost?: RouteCost;
|
|
58
|
+
/** True when serve has no price for the model (runModels' `unpriced`): `cost` is then a placeholder of zeros, which the
|
|
59
|
+
* cap never reads as a price (capModelOf: price unknown, never $0). */
|
|
60
|
+
readonly unpriced?: boolean;
|
|
58
61
|
/** The model's most output tokens (its catalog ceiling): the cap's output bound, null when the catalog names none. */
|
|
59
62
|
readonly outputCeiling?: number | null;
|
|
60
63
|
}
|
|
@@ -33,7 +33,10 @@ export async function routeOf(model, env = process.env, tier = "default", wires
|
|
|
33
33
|
const chosen = await chooseModel(env, model, tier);
|
|
34
34
|
if ("why" in chosen)
|
|
35
35
|
throw new Error(chosen.why);
|
|
36
|
-
|
|
36
|
+
// A tier's own model, when one is named (a subagent's model_tiers), is the one registered, at the tier's price: a gateway
|
|
37
|
+
// lists only the models it is given, so the host's model for the tier in its place would leave this one unknown.
|
|
38
|
+
const named = tier !== "default" && typeof model === "string" ? { [tier]: model } : {};
|
|
39
|
+
const { models, unpriced } = await runModels(env, tier === "default" ? model : undefined, [tier], undefined, named);
|
|
37
40
|
const target = models.getModel(chosen.model.provider, chosen.model.modelId);
|
|
38
41
|
if (!target)
|
|
39
42
|
throw new Error(`no model ${chosen.model.provider}/${chosen.model.modelId} here`);
|
|
@@ -43,7 +46,7 @@ export async function routeOf(model, env = process.env, tier = "default", wires
|
|
|
43
46
|
// What the model takes as input and its input limits, on every wire: pi's session sends a model that takes no images
|
|
44
47
|
// pi-ai's placeholder in place of one, and pi's read holds an image to the model's limits (port-models.ts sessionModel).
|
|
45
48
|
const sees = { ...(target.input ? { input: target.input } : {}), ...(target.inputLimits ? { inputLimits: target.inputLimits } : {}) };
|
|
46
|
-
const route = { model: chosen.model.modelId, named: `${chosen.model.provider}/${chosen.model.modelId}`, price, cost: target.cost, outputCeiling: target.maxTokens ?? null, like: sees };
|
|
49
|
+
const route = { model: chosen.model.modelId, named: `${chosen.model.provider}/${chosen.model.modelId}`, price, cost: target.cost, ...(unpriced.has(chosen.model.modelId) ? { unpriced: true } : {}), outputCeiling: target.maxTokens ?? null, like: sees };
|
|
47
50
|
// An Anthropic model speaks Messages itself: the network, at its catalog origin, its key read by name per request.
|
|
48
51
|
if (chosen.model.provider === "anthropic") {
|
|
49
52
|
return { ...route, provider: { api: "anthropic-messages", origin: target.baseUrl ?? "https://api.anthropic.com", credential: () => env.ANTHROPIC_API_KEY ?? env.ANTHROPIC_AUTH_TOKEN ?? "" } };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Workspace } from "../workspace/workspace.js";
|
|
2
|
+
import type { GithubAppMint } from "./mcp-github.js";
|
|
3
|
+
import type { AdapterSpecDeps } from "./adapter-run-spec.js";
|
|
4
|
+
/** What an agent's revision keeps of its definition's `checkout` (validate.ts CHECKOUTS; `none` keeps nothing). */
|
|
5
|
+
export type Checkout = "pull_request";
|
|
6
|
+
/** The folder, in the run's own, the checkout lands in. */
|
|
7
|
+
export declare const CHECKOUT_DIR = "repo";
|
|
8
|
+
/** How long the whole checkout may take: inside Archil's exec bound, on either mode. */
|
|
9
|
+
export declare const CHECKOUT_MS = 295000;
|
|
10
|
+
/** What the checkout gives the run's claim: the line its system prompt carries, and its removal. */
|
|
11
|
+
export interface PrCheckout {
|
|
12
|
+
/** One line for the run's system prompt: where the checkout is and what it holds, or why there is none. */
|
|
13
|
+
readonly note: string;
|
|
14
|
+
/** The checkout removed from the run's folder: at the claim's release. A failure throws, for the release to log. */
|
|
15
|
+
end(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export interface PrCheckoutOptions {
|
|
18
|
+
/** The run's Workspace, whose exec runs the fetch. */
|
|
19
|
+
readonly workspace: Workspace;
|
|
20
|
+
/** The run's first input (its launch's): its payload tag names the pull request. */
|
|
21
|
+
readonly input: unknown;
|
|
22
|
+
/** Whether a github trigger started the run (its launch's inputOrigin): only then is its payload tag the server's own,
|
|
23
|
+
* and read. Anyone may write the tag's text into a run of their own. */
|
|
24
|
+
readonly fromGitHub?: boolean;
|
|
25
|
+
/** The server's GitHub App mint, when it has an App the runner can open: none, the fetch is anonymous. */
|
|
26
|
+
readonly mint?: GithubAppMint;
|
|
27
|
+
/** The token revoked at GitHub once the fetch is done: best effort, a failure leaves it to its hour. */
|
|
28
|
+
readonly revoke?: (token: string) => Promise<void>;
|
|
29
|
+
/** Each secret the checkout holds (the token, its header), handed to the run's redactor before it is used. */
|
|
30
|
+
readonly hold?: (secrets: readonly string[]) => void;
|
|
31
|
+
/** GitHub's site, where the repository is fetched from: a test's own (a folder of bare repositories, or a git server
|
|
32
|
+
* on loopback). Absent, https://github.com. */
|
|
33
|
+
readonly web?: string;
|
|
34
|
+
/** Ends the fetch at once: the claim's signal, aborted by a person's stop too. The checkout's removal is handed to
|
|
35
|
+
* `held` before the fetch starts, so a fetch cut short leaves its folder to the claim's release. */
|
|
36
|
+
readonly signal?: AbortSignal;
|
|
37
|
+
/** The checkout's removal, given the moment the fetch starts (the spec's holds), so whatever ends the claim removes it. */
|
|
38
|
+
readonly held?: (part: {
|
|
39
|
+
end(): Promise<void>;
|
|
40
|
+
}) => void;
|
|
41
|
+
readonly timeoutMs?: number;
|
|
42
|
+
}
|
|
43
|
+
/** The pull request `options.input` names, checked out in the run's folder at its head. Never throws for a checkout that
|
|
44
|
+
* could not be made: the run is told why, and reads the change some other way. */
|
|
45
|
+
export declare function prCheckout(options: PrCheckoutOptions): Promise<PrCheckout>;
|
|
46
|
+
/** The checkout a claim's spec makes (the pi and the CLI spec alike) for its launch: the server's GitHub App opened as the
|
|
47
|
+
* MCP step opens it (github-app.ts, its payload tag read only for a github trigger's run), its secrets held by the run's redactor `redact`, its removal by the spec's holds (`held`) from the
|
|
48
|
+
* moment the fetch starts, and `signal` (the claim's, a person's stop included) ending the fetch. */
|
|
49
|
+
export declare function prCheckoutForClaim(deps: Pick<AdapterSpecDeps, "store" | "sealKey" | "githubApi" | "githubWeb">, workspace: Workspace, launch: {
|
|
50
|
+
readonly input: unknown;
|
|
51
|
+
readonly repo?: string | undefined;
|
|
52
|
+
readonly inputOrigin?: {
|
|
53
|
+
readonly kind: string;
|
|
54
|
+
readonly source?: string;
|
|
55
|
+
} | undefined;
|
|
56
|
+
}, redact: {
|
|
57
|
+
hold(values: readonly string[]): void;
|
|
58
|
+
}, signal?: AbortSignal, held?: (part: {
|
|
59
|
+
end(): Promise<void>;
|
|
60
|
+
}) => void): Promise<PrCheckout>;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
// A run's checkout of the pull request it was started for, made by the server before the first turn when the agent's
|
|
2
|
+
// definition says `checkout: pull_request` (a template's manifest sets it). The agent then starts with the repository at
|
|
3
|
+
// the pull request's head in `repo/` of its folder, its base and their merge base fetched beside it, and never holds a
|
|
4
|
+
// GitHub token: the fetch is the server's own, one exec on the run's Workspace (Mode 1 a process on this machine, Mode 2
|
|
5
|
+
// Archil's serverless exec over the run's folder), never a command of the agent's.
|
|
6
|
+
//
|
|
7
|
+
// What it reads of the run: its first message's payload tag alone (github.ts githubPullOf), which the server wrote from a
|
|
8
|
+
// signed GitHub delivery: the repository, the pull request's number, its head and its base. Nothing else names a
|
|
9
|
+
// repository to fetch.
|
|
10
|
+
//
|
|
11
|
+
// The credential: an installation token of the server's GitHub App, minted for that one repository with
|
|
12
|
+
// {contents: "read"} alone, handed to the exec on its stdin (Archil's: a spill file deleted on every path), turned there
|
|
13
|
+
// into an Authorization header in git's environment (GIT_CONFIG_COUNT), scoped to GitHub's site. It is never in argv,
|
|
14
|
+
// .git/config, the remote's URL, the run's folder, an env the agent's commands get, or the log (it joins the run's
|
|
15
|
+
// redactor). No App, or one not installed on the repository: the fetch is anonymous, which a public repository answers.
|
|
16
|
+
// The token is revoked once the fetch is done (GitHub's DELETE /installation/token), and is never kept.
|
|
17
|
+
//
|
|
18
|
+
// Git there reads no system or global config (no filter, textconv or fsmonitor a machine's config could attach), fetches
|
|
19
|
+
// no tags and no submodules, and checks out with the repository's own config alone, which this exec wrote.
|
|
20
|
+
//
|
|
21
|
+
// What the run is told: one line in its system prompt, the checkout's facts, or why there is none and that the GitHub
|
|
22
|
+
// tools can read the change instead. The checkout is removed when the claim lets go (spec-holds.ts), and made again by
|
|
23
|
+
// the next claim of the same run.
|
|
24
|
+
import { randomUUID } from "node:crypto";
|
|
25
|
+
import { GITHUB_WEB, githubPullOf } from "../github.js";
|
|
26
|
+
import { isObject } from "../validate.js";
|
|
27
|
+
import { COMMAND_MAX_MS } from "../workspace/archil-exec.js";
|
|
28
|
+
import { shellEnv } from "../workspace/hands.js";
|
|
29
|
+
import { githubAppAccess } from "./github-app.js";
|
|
30
|
+
/** The folder, in the run's own, the checkout lands in. */
|
|
31
|
+
export const CHECKOUT_DIR = "repo";
|
|
32
|
+
/** How long the whole checkout may take: inside Archil's exec bound, on either mode. */
|
|
33
|
+
export const CHECKOUT_MS = COMMAND_MAX_MS;
|
|
34
|
+
/** The commits each side is first fetched with, then deepened by (doubling) until the merge base is in: about 3,200
|
|
35
|
+
* commits back at most, past which the run is told there is no merge base and the base's diff is the two-dot one. A merge
|
|
36
|
+
* base found is taken only when no shallow edge lies outside its ancestry: a history cut short can show an older common
|
|
37
|
+
* commit (a long branch that merged an old side branch) while the path to the true merge base is cut off, so the fetch
|
|
38
|
+
* deepens until every edge is at or behind the merge base it found. Each fetch runs with git's auto maintenance off: a
|
|
39
|
+
* fetch otherwise starts a detached gc that writes into .git/objects while the checkout's removal deletes it. */
|
|
40
|
+
const DEPTH = 50;
|
|
41
|
+
const DEEPENS = 6;
|
|
42
|
+
/** The file in the checkout's .git naming the claim that made it: a removal takes only its own claim's checkout. */
|
|
43
|
+
const OWNER_FILE = "agentrun-claim";
|
|
44
|
+
/** The exec's script: $1 the remote's URL (no credential), $2 the head, $3 the base (or empty), $4 the folder, $5 the
|
|
45
|
+
* URL prefix the header is for, $6 this claim's checkout id (written to .git/${OWNER_FILE}). Its stdin's first line is
|
|
46
|
+
* an Authorization header, or empty for an anonymous fetch. Its exit codes name the step that failed (10 the folder, 11 the fetch, 12 the checkout); on success it prints the merge
|
|
47
|
+
* base, empty when none was found. */
|
|
48
|
+
const SCRIPT = `set -u
|
|
49
|
+
url=$1 head=$2 base=$3 dir=$4 scope=$5 claim=$6
|
|
50
|
+
IFS= read -r auth || true
|
|
51
|
+
export GIT_TERMINAL_PROMPT=0 GIT_CONFIG_NOSYSTEM=1 GIT_CONFIG_GLOBAL=/dev/null
|
|
52
|
+
if [ -n "\${auth:-}" ]; then export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0="http.$scope.extraheader" GIT_CONFIG_VALUE_0="$auth"; fi
|
|
53
|
+
auth=
|
|
54
|
+
rm -rf "\${dir:?}"
|
|
55
|
+
git init -q "$dir" >/dev/null 2>&1 && cd "$dir" && printf '%s\\n' "$claim" > .git/${OWNER_FILE} && git remote add origin "$url" || exit 10
|
|
56
|
+
fetch() { git -c maintenance.auto=false -c gc.auto=0 fetch -q --no-tags --no-recurse-submodules origin "$@" "$head" \${base:+"$base"}; }
|
|
57
|
+
fetch --depth=${DEPTH} || exit 11
|
|
58
|
+
mb=
|
|
59
|
+
settled() {
|
|
60
|
+
[ -n "$mb" ] || return 1
|
|
61
|
+
[ -s .git/shallow ] || return 0
|
|
62
|
+
while IFS= read -r edge; do git merge-base --is-ancestor "$edge" "$mb" 2>/dev/null || return 1; done < .git/shallow
|
|
63
|
+
}
|
|
64
|
+
if [ -n "$base" ]; then
|
|
65
|
+
n=${DEPTH} i=0
|
|
66
|
+
while :; do
|
|
67
|
+
mb=$(git merge-base "$base" "$head" 2>/dev/null) || mb=
|
|
68
|
+
settled && break
|
|
69
|
+
[ "$i" -lt ${DEEPENS} ] || { mb=; break; }
|
|
70
|
+
fetch --deepen=$n || exit 11
|
|
71
|
+
n=$((n * 2)) i=$((i + 1))
|
|
72
|
+
done
|
|
73
|
+
fi
|
|
74
|
+
git update-ref refs/pr/head "$head" || exit 12
|
|
75
|
+
if [ -n "$base" ]; then git update-ref refs/pr/base "$base" || exit 12; fi
|
|
76
|
+
if [ -n "$mb" ]; then git update-ref refs/pr/merge-base "$mb" || exit 12; fi
|
|
77
|
+
git -c advice.detachedHead=false checkout -q --detach "$head" || exit 12
|
|
78
|
+
printf '%s\\n' "$mb"
|
|
79
|
+
`;
|
|
80
|
+
const noCheckout = (note) => ({ note, end: async () => { } });
|
|
81
|
+
/** The words of a failed exec, with the secrets cut and its last lines kept. */
|
|
82
|
+
const tail = (text, secrets) => {
|
|
83
|
+
let cut = text;
|
|
84
|
+
for (const secret of secrets)
|
|
85
|
+
cut = cut.split(secret).join("[redacted]");
|
|
86
|
+
const lines = cut.trim().split("\n").filter(Boolean);
|
|
87
|
+
return lines.slice(-3).join(" / ").slice(0, 400);
|
|
88
|
+
};
|
|
89
|
+
/** The pull request `options.input` names, checked out in the run's folder at its head. Never throws for a checkout that
|
|
90
|
+
* could not be made: the run is told why, and reads the change some other way. */
|
|
91
|
+
export async function prCheckout(options) {
|
|
92
|
+
const { workspace } = options;
|
|
93
|
+
const pull = githubPullOf(isObject(options.input) ? options.input.content : options.input, { payload: options.fromGitHub === true });
|
|
94
|
+
if (!pull)
|
|
95
|
+
return noCheckout("No checkout was made: this run was not started by a GitHub pull request event, so there is no repo/ folder. Read the change through the GitHub tools if you have them.");
|
|
96
|
+
const web = (options.web ?? GITHUB_WEB).replace(/\/+$/, "");
|
|
97
|
+
const name = `${pull.repo}#${pull.number}`;
|
|
98
|
+
// The token: the App's, for this repository alone, contents read alone. None (no App, not installed, GitHub said no):
|
|
99
|
+
// the fetch is anonymous, and the words say which, in case the repository turns out to be private.
|
|
100
|
+
let token;
|
|
101
|
+
let anonymous = "";
|
|
102
|
+
if (options.mint) {
|
|
103
|
+
try {
|
|
104
|
+
const got = await options.mint({ repo: pull.repo, ...(pull.installation !== undefined ? { installation: pull.installation } : {}) }, { contents: "read" });
|
|
105
|
+
if (got.ok)
|
|
106
|
+
token = got.token;
|
|
107
|
+
else
|
|
108
|
+
anonymous = got.reason === "not_installed" ? `the GitHub App is not installed on ${pull.repo}` : got.message;
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
anonymous = `GitHub did not make a token (${error?.message ?? error})`;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else
|
|
115
|
+
anonymous = "this server has no GitHub App";
|
|
116
|
+
const header = token ? `Authorization: Basic ${Buffer.from(`x-access-token:${token}`, "utf8").toString("base64")}` : "";
|
|
117
|
+
const secrets = token ? [token, header, header.slice("Authorization: Basic ".length)] : [];
|
|
118
|
+
if (secrets.length)
|
|
119
|
+
options.hold?.(secrets);
|
|
120
|
+
// This claim's checkout, by an id of its own: a claim that lost its lease and lets go late removes only the folder it
|
|
121
|
+
// made, never the one a later claim of the run is fetching or reading (that claim's fetch replaces a stale one itself).
|
|
122
|
+
const claim = randomUUID();
|
|
123
|
+
const removal = async () => {
|
|
124
|
+
const result = await workspace.exec(["sh", "-c", `[ "$(cat "\${1:?}/.git/${OWNER_FILE}" 2>/dev/null)" = "$2" ] || exit 0; rm -rf -- "\${1:?}"`, "sh", CHECKOUT_DIR, claim], { env: shellEnv(), timeoutMs: CHECKOUT_MS });
|
|
125
|
+
if (result.code !== 0)
|
|
126
|
+
throw new Error(`the run's ${CHECKOUT_DIR}/ checkout could not be removed (exit ${result.code ?? result.signal}): ${tail(result.stderr, secrets)}`);
|
|
127
|
+
};
|
|
128
|
+
const failed = async (why) => {
|
|
129
|
+
// What a failed fetch left (a half folder) goes now: the run is told there is none.
|
|
130
|
+
await removal().catch(() => { });
|
|
131
|
+
return noCheckout(`The pull request ${name} could not be checked out (${why}), so there is no ${CHECKOUT_DIR}/ folder: read the change through the GitHub tools (its diff, and each file at the head sha ${pull.head}).`);
|
|
132
|
+
};
|
|
133
|
+
// From here a folder may exist: its removal is the claim's to run, whatever ends it.
|
|
134
|
+
options.held?.({ end: removal });
|
|
135
|
+
let result;
|
|
136
|
+
try {
|
|
137
|
+
result = await workspace.exec(["sh", "-c", SCRIPT, "sh", `${web}/${pull.repo}.git`, pull.head, pull.base ?? "", CHECKOUT_DIR, `${web}/`, claim], { env: shellEnv(), stdin: Buffer.from(`${header}\n`, "utf8"), timeoutMs: options.timeoutMs ?? CHECKOUT_MS, ...(options.signal ? { signal: options.signal } : {}) });
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
// Cut short (a stop, a lost claim): the claim's release removes what the fetch made (`held`).
|
|
141
|
+
if (options.signal?.aborted)
|
|
142
|
+
throw error;
|
|
143
|
+
return failed(`the fetch could not run: ${tail(String(error?.message ?? error), secrets)}`);
|
|
144
|
+
}
|
|
145
|
+
finally {
|
|
146
|
+
// The fetch is the token's one use: it goes now, not in an hour.
|
|
147
|
+
if (token && options.revoke)
|
|
148
|
+
await options.revoke(token).catch(() => { });
|
|
149
|
+
}
|
|
150
|
+
if (result.timedOut)
|
|
151
|
+
return failed(`the fetch took more than ${Math.round((options.timeoutMs ?? CHECKOUT_MS) / 1000)} s`);
|
|
152
|
+
if (result.code !== 0) {
|
|
153
|
+
const step = result.code === 10 ? "its folder could not be made" : result.code === 11 ? `${web}/${pull.repo} did not give its commits${token ? "" : `, fetched with no token: ${anonymous}`}` : result.code === 12 ? "its head could not be checked out" : `git ended with ${result.code ?? result.signal}`;
|
|
154
|
+
const said = tail(result.stderr, secrets);
|
|
155
|
+
return failed(said ? `${step}: ${said}` : step);
|
|
156
|
+
}
|
|
157
|
+
const mergeBase = Buffer.from(result.stdout).toString("utf8").trim();
|
|
158
|
+
return { note: checkoutNote(pull, /^[0-9a-f]{40}$/.test(mergeBase) ? mergeBase : undefined), end: removal };
|
|
159
|
+
}
|
|
160
|
+
/** The line a run with a checkout is told. */
|
|
161
|
+
function checkoutNote(pull, mergeBase) {
|
|
162
|
+
const base = pull.base === undefined
|
|
163
|
+
? "Its base was not named by the event, so only the head is there."
|
|
164
|
+
: mergeBase === undefined
|
|
165
|
+
? `Its base ${pull.base} is fetched too (ref pr/base), but no merge base was found within ${DEPTH * 2 ** DEEPENS} commits: diff against pr/base.`
|
|
166
|
+
: `Its base ${pull.base} (ref pr/base) and their merge base ${mergeBase} (ref pr/merge-base) are fetched too: read the change with \`git diff pr/merge-base pr/head\`.`;
|
|
167
|
+
return `The pull request ${pull.repo}#${pull.number} is checked out in ${CHECKOUT_DIR}/, detached at its head ${pull.head} (ref pr/head), by the server before this run began. ${base} It is a shallow clone, and no credential is kept in it.`;
|
|
168
|
+
}
|
|
169
|
+
/** The checkout a claim's spec makes (the pi and the CLI spec alike) for its launch: the server's GitHub App opened as the
|
|
170
|
+
* MCP step opens it (github-app.ts, its payload tag read only for a github trigger's run), its secrets held by the run's redactor `redact`, its removal by the spec's holds (`held`) from the
|
|
171
|
+
* moment the fetch starts, and `signal` (the claim's, a person's stop included) ending the fetch. */
|
|
172
|
+
export async function prCheckoutForClaim(deps, workspace, launch, redact, signal, held) {
|
|
173
|
+
const fromGitHub = launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github";
|
|
174
|
+
const access = await githubAppAccess(deps.store, deps.sealKey, launch.input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub, hold: (values) => redact.hold(values), ...(launch.repo !== undefined ? { repo: launch.repo } : {}) });
|
|
175
|
+
return prCheckout({ workspace, input: launch.input, fromGitHub, ...(access ? { mint: access.mint } : {}), ...(access?.revoke ? { revoke: access.revoke } : {}), hold: (secrets) => redact.hold(secrets), ...(deps.githubWeb ? { web: deps.githubWeb } : {}), ...(signal ? { signal } : {}), ...(held ? { held } : {}) });
|
|
176
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DraftDecisions } from "../learn/skills.js";
|
|
1
2
|
import type { EndOfRunTurn } from "./loop-contract.js";
|
|
2
3
|
/** How long a run's end-of-run turn may take before it is aborted and the run ends without it. */
|
|
3
4
|
export declare const REFLECT_TIMEOUT_MS: number;
|
|
@@ -55,11 +56,13 @@ export interface ReflectDeps {
|
|
|
55
56
|
readonly promptFacts: (runId: string, agentId: string) => Promise<{
|
|
56
57
|
active: number;
|
|
57
58
|
tools: readonly string[];
|
|
59
|
+
decisions?: DraftDecisions;
|
|
58
60
|
draftFor?: readonly string[];
|
|
59
61
|
described?: readonly {
|
|
60
62
|
readonly name: string;
|
|
61
63
|
readonly does: string;
|
|
62
64
|
}[];
|
|
65
|
+
workflows?: false;
|
|
63
66
|
}>;
|
|
64
67
|
/** What the person said in the run, and a trigger's input, as the checks and the grader read them. */
|
|
65
68
|
readonly asked: (runId: string) => Promise<{
|
|
@@ -83,6 +86,22 @@ export interface ReflectDeps {
|
|
|
83
86
|
/** The grade model the server names (learning.ts gradeModelOf: --grade-model, AGENTRUN_SERVE_GRADE_MODEL, else
|
|
84
87
|
* AGENT_MODEL_STRONG), carried on the learning run's launch; none, the agent's own model grades it, as main's. */
|
|
85
88
|
readonly gradeModel?: string;
|
|
89
|
+
/** The cap the learning run's grade runs under, read once the turn closed (learning-end.ts gradeCapOf): what the run's
|
|
90
|
+
* cap leaves once everything the run spent is counted, carried on the learning run's launch as its own cap, so the
|
|
91
|
+
* grade never takes the run past its cap. Undefined for an uncapped run: its grade is capped by nothing. */
|
|
92
|
+
readonly gradeCap?: (runId: string) => Promise<number | undefined>;
|
|
93
|
+
/** Which end of the run this is: 1, its first (the default); an end after a follow-up opened the run again is the next
|
|
94
|
+
* round, asked anew (its prompt says it looked back before), kept as a proposal of its own beside the earlier rounds'
|
|
95
|
+
* (every row the hook gives carries it), graded and merged by a learning run of its own. */
|
|
96
|
+
readonly round?: number;
|
|
97
|
+
/** A later round's: what the round before it kept of the run's spend (its job's and its look-back's), so the follow-up's
|
|
98
|
+
* own share, between that look-back and this one, is kept apart (`follow_up_usd`); and whether it was asked its turn
|
|
99
|
+
* (`looked`: a round cut before it was asked says nothing of looking back before). */
|
|
100
|
+
readonly before?: {
|
|
101
|
+
readonly job_cost_usd?: number | null;
|
|
102
|
+
readonly look_back_usd?: number | null;
|
|
103
|
+
readonly looked?: boolean;
|
|
104
|
+
};
|
|
86
105
|
/** The turn's deadline. Default REFLECT_TIMEOUT_MS. Its re-ask is inside it. */
|
|
87
106
|
readonly deadlineMs?: number;
|
|
88
107
|
/** For tests: the clock the turn's deadline is measured by. Default Date.now. */
|
|
@@ -28,9 +28,12 @@ function dryRunFailure(checked) {
|
|
|
28
28
|
const found = problems.find((problem) => problem?.rule === "workflow" && typeof problem.path === "string" && typeof problem.detail === "string" && problem.detail.startsWith(DRY_RUN_FAILED));
|
|
29
29
|
return found ? { path: found.path, detail: found.detail } : undefined;
|
|
30
30
|
}
|
|
31
|
+
/** `rows` with round `round` on each learning row (none on a run's first, round 1). */
|
|
32
|
+
const roundOf = (rows, round) => !rows || round === 1 ? rows : { also: rows.also.map((row) => (row.table === "learning_proposals" || row.table === "learning_run" ? { ...row, row: { ...row.row, round } } : row)) };
|
|
31
33
|
/** The end-of-run turn for runs that learn. */
|
|
32
34
|
export function createReflectHook(deps) {
|
|
33
|
-
|
|
35
|
+
const round = deps.round ?? 1;
|
|
36
|
+
const hook = async (input) => {
|
|
34
37
|
const facts = await deps.facts(input.runId);
|
|
35
38
|
if (!facts.learns)
|
|
36
39
|
return undefined;
|
|
@@ -54,18 +57,22 @@ export function createReflectHook(deps) {
|
|
|
54
57
|
// spend so far is the job's.
|
|
55
58
|
const answeredAt = new Date(now()).toISOString();
|
|
56
59
|
const job = facts.costUsd;
|
|
60
|
+
// A later round's: the follow-up's own spend, the run's spend now less what the round before it kept (its job's and
|
|
61
|
+
// its look-back's), unknown when any is.
|
|
62
|
+
const earlier = deps.before;
|
|
63
|
+
const followUp = round === 1 ? {} : { follow_up_usd: job === null || typeof earlier?.job_cost_usd !== "number" || typeof earlier.look_back_usd !== "number" ? null : Math.max(0, Math.round((job - earlier.job_cost_usd - earlier.look_back_usd) * 1e9) / 1e9) };
|
|
57
64
|
// closeLearning: what looking back cost, the run's spend once the turn closed (its re-ask included) less the job's,
|
|
58
65
|
// unknown when either is. Kept with every end the turn reaches from here, beside when the job answered and its cost.
|
|
59
66
|
const looked = async (rows) => {
|
|
60
67
|
const total = (await deps.facts(input.runId)).costUsd;
|
|
61
|
-
const answered = { answered_at: answeredAt, job_cost_usd: job, look_back_usd: total === null || job === null ? null : Math.max(0, Math.round((total - job) * 1e9) / 1e9) };
|
|
68
|
+
const answered = { answered_at: answeredAt, job_cost_usd: job, look_back_usd: total === null || job === null ? null : Math.max(0, Math.round((total - job) * 1e9) / 1e9), ...followUp };
|
|
62
69
|
return { also: rows.also.map((row) => (row.table === "learning_proposals" ? { ...row, row: { ...row.row, proposal: { ...row.row.proposal, ...answered } } } : row)) };
|
|
63
70
|
};
|
|
64
71
|
// A job that only ran its learned workflows, each answering, with nothing said after its first message, gave nothing
|
|
65
72
|
// new to learn: it is not asked (no model request), and looking back cost nothing, $0 whether or not the job's own
|
|
66
73
|
// cost is known. Its words are the server's own.
|
|
67
74
|
if (input.outcome === "completed" && deps.nothingNew && (await deps.nothingNew(input.runId).catch(() => false))) {
|
|
68
|
-
return { also: [droppedRow(null, "empty", said.onlyWorkflow, { answered_at: answeredAt, job_cost_usd: job, look_back_usd: 0 })] };
|
|
75
|
+
return { also: [droppedRow(null, "empty", said.onlyWorkflow, { answered_at: answeredAt, job_cost_usd: job, look_back_usd: 0, ...followUp })] };
|
|
69
76
|
}
|
|
70
77
|
// What the run must never learn, read once, before it is asked anything: a run whose list can't be read learns
|
|
71
78
|
// nothing, never over a shorter one.
|
|
@@ -76,10 +83,11 @@ export function createReflectHook(deps) {
|
|
|
76
83
|
const close = async (rows) => ({ also: (await looked({ also: rows })).also.map((row) => cutRow(row, refuse)) });
|
|
77
84
|
if (read === "unreadable")
|
|
78
85
|
return close([droppedRow(null, "propose_failed", said.stopped(STOPPED.refuseUnread))]);
|
|
79
|
-
const { active, tools, draftFor, described } = await deps.promptFacts(input.runId, input.agentId);
|
|
86
|
+
const { active, tools, draftFor, described, decisions, workflows } = await deps.promptFacts(input.runId, input.agentId);
|
|
80
87
|
const deadlineMs = deps.deadlineMs ?? REFLECT_TIMEOUT_MS;
|
|
81
88
|
const started = now();
|
|
82
|
-
const
|
|
89
|
+
const ask = { origin: "reflect", ...(round > 1 ? { round } : {}) };
|
|
90
|
+
const end = await input.ask(reflectPrompt({ dir: LEARNED_DIR, active, tools, ...(decisions ? { decisions } : {}), ...(workflows === false ? { workflows: false } : draftFor?.length ? { draftFor, ...(described?.length ? { described } : {}) } : {}), ...(round > 1 && deps.before?.looked !== false ? { later: true } : {}) }), { ...ask, deadlineMs });
|
|
83
91
|
// closeLearning: how the turn ended.
|
|
84
92
|
if ("timedOut" in end)
|
|
85
93
|
return close([droppedRow(null, "reflect_timeout", said.stopped(STOPPED.timedOut))]);
|
|
@@ -104,7 +112,7 @@ export function createReflectHook(deps) {
|
|
|
104
112
|
// within the turn's own deadline; a re-ask that times out or fails leaves the first answer's drop.
|
|
105
113
|
if (checked.state === "dropped" && checked.reason === "unparsed") {
|
|
106
114
|
const left = deadlineMs - (now() - started);
|
|
107
|
-
const again = left > 0 ? await input.ask(reflectAgain(checked.detail
|
|
115
|
+
const again = left > 0 ? await input.ask(reflectAgain(checked.detail, ...(workflows === false ? [false] : [])), { ...ask, deadlineMs: left, again: true }) : undefined;
|
|
108
116
|
if (again && "ended" in again) {
|
|
109
117
|
turn = turnOf(again.answer);
|
|
110
118
|
checked = await checkOf(turn);
|
|
@@ -119,7 +127,7 @@ export function createReflectHook(deps) {
|
|
|
119
127
|
// never costs a note the first answer kept). Never a third time (a turn asks again once, for either reason).
|
|
120
128
|
const dry = dryRunFailure(checked);
|
|
121
129
|
const left = deadlineMs - (now() - started);
|
|
122
|
-
const again = dry && left > 0 ? await input.ask(reflectDryRun(dry.path, dry.detail), {
|
|
130
|
+
const again = dry && left > 0 ? await input.ask(reflectDryRun(dry.path, dry.detail), { ...ask, deadlineMs: left, again: true }) : undefined;
|
|
123
131
|
if (again && "ended" in again) {
|
|
124
132
|
const second = turnOf(again.answer);
|
|
125
133
|
const kept = await checkOf(second);
|
|
@@ -133,9 +141,13 @@ export function createReflectHook(deps) {
|
|
|
133
141
|
const detail = checked.reason === "empty" ? said.empty : checked.reason === "unparsed" ? said.unparsed : said.checker(checked.problems);
|
|
134
142
|
return close([droppedRow(turn, checked.reason, detail, checked)]);
|
|
135
143
|
}
|
|
144
|
+
// The learning run's cap: what the run's cap leaves now its look-back is spent, read after the checks (a read that
|
|
145
|
+
// fails is no room, never no cap: the grade is then skipped, never run past the cap).
|
|
146
|
+
const capUsd = deps.gradeCap ? await deps.gradeCap(input.runId).catch(() => 0) : undefined;
|
|
136
147
|
return close([
|
|
137
148
|
{ table: "learning_proposals", row: { turn, proposal: { ...checked, detail: said.proposed(checked.notes, checked.skills, checked.workflows) } } },
|
|
138
|
-
{ table: "learning_run", row: { id: deps.newRunId(), ...(deps.gradeModel ? { model: deps.gradeModel } : {}) } },
|
|
149
|
+
{ table: "learning_run", row: { id: deps.newRunId(), ...(deps.gradeModel ? { model: deps.gradeModel } : {}), ...(capUsd !== undefined ? { capUsd } : {}) } },
|
|
139
150
|
]);
|
|
140
151
|
};
|
|
152
|
+
return async (input) => roundOf(await hook(input), round);
|
|
141
153
|
}
|
package/dist/runner/runner.d.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { type Claim, type LoopEnd, type LoopFactory } from "./loop-contract.js";
|
|
2
2
|
import { type RunnerStore } from "./store-port.js";
|
|
3
|
+
import { type RunState } from "../store/store.js";
|
|
3
4
|
import { type Redact } from "./redact.js";
|
|
4
5
|
import { type LiveTickerOptions } from "./live-ticker.js";
|
|
5
6
|
/** Most runs a runner holds at once, unless told (RunnerOptions.loops). */
|
|
7
|
+
/** A final run's status as its end line says it: the store holds a cancel as state 'stopped' with outcome 'cancelled', so
|
|
8
|
+
* the outcome tells a cancel from a person's resumable stop. */
|
|
9
|
+
export declare const endedStatus: (run: {
|
|
10
|
+
state: RunState;
|
|
11
|
+
outcome?: string | null;
|
|
12
|
+
}) => RunState | "cancelled";
|
|
6
13
|
export declare const RUNNER_LOOPS = 300;
|
|
7
14
|
/** How long a claim lasts unless renewed, unless told (RunnerOptions.leaseMs). */
|
|
8
15
|
export declare const RUNNER_LEASE_MS = 30000;
|
|
@@ -53,6 +60,10 @@ export interface RunnerOptions {
|
|
|
53
60
|
/** The wait before a run whose loop ended interrupted on its own (no stop asked of it: its Session closed itself) is
|
|
54
61
|
* claimable again; each such end of the run in a row waits twice the one before, up to 64 times this. */
|
|
55
62
|
interruptBackoffMs?: number;
|
|
63
|
+
/** After a claim or release commit answered Unanswered (it may have landed), the wait before the first re-read of what
|
|
64
|
+
* this runner holds; each retry of that re-read waits twice the one before, up to UNKNOWN_READS tries, then the lease
|
|
65
|
+
* settles it. */
|
|
66
|
+
unknownBackoffMs?: number;
|
|
56
67
|
/** How long a run's end waits for a command still with its loop before it writes its end; an answer after that is
|
|
57
68
|
* dropped (nothing written, nothing said). */
|
|
58
69
|
endWaitMs?: number;
|
|
@@ -100,6 +111,21 @@ export interface RunnerMemory {
|
|
|
100
111
|
export type RunnerEvent = {
|
|
101
112
|
type: "claimed";
|
|
102
113
|
claim: Claim;
|
|
114
|
+
}
|
|
115
|
+
/** A run's start, once: its first claim (from queued). `agent` and `kind` are ids, never a secret. */
|
|
116
|
+
| {
|
|
117
|
+
type: "started";
|
|
118
|
+
runId: string;
|
|
119
|
+
agent: string;
|
|
120
|
+
kind: string;
|
|
121
|
+
}
|
|
122
|
+
/** A run's end, once it is final (ended, stopped, failed): its state and the cost its row holds. */
|
|
123
|
+
| {
|
|
124
|
+
type: "ended";
|
|
125
|
+
runId: string;
|
|
126
|
+
agent: string;
|
|
127
|
+
status: RunState | "cancelled";
|
|
128
|
+
costUsd: number | null;
|
|
103
129
|
} | {
|
|
104
130
|
type: "claim-lost";
|
|
105
131
|
runId: string;
|