@parcha/agentrun-serve 0.1.0-beta.34 → 0.1.0-beta.36
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 +263 -0
- package/README.md +339 -179
- package/dist/adapters.d.ts +15 -2
- package/dist/adapters.js +34 -2
- package/dist/agent-rows.d.ts +3 -1
- package/dist/agents-store.d.ts +2 -0
- package/dist/agents-store.js +25 -5
- 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 +90 -8
- package/dist/archil-settings.js +150 -14
- 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/bash-read-only.d.ts +13 -0
- package/dist/bash-read-only.js +77 -0
- 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 +2 -2
- package/dist/browser-cost.js +6 -4
- 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 +19 -44
- package/dist/cap.js +31 -77
- package/dist/cli.js +36 -27
- package/dist/computer-keys.d.ts +20 -10
- package/dist/computer-keys.js +36 -57
- package/dist/computer-routes.d.ts +1 -4
- package/dist/computer-routes.js +3 -5
- package/dist/computer-setting.d.ts +8 -5
- package/dist/computer-setting.js +91 -26
- package/dist/computer-view.d.ts +11 -2
- package/dist/computer-view.js +2 -1
- package/dist/computers.d.ts +54 -8
- package/dist/computers.js +101 -22
- package/dist/console/assets/index-BI4Byidu.js +550 -0
- package/dist/console/assets/index-C19gUF2n.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/content-filter.d.ts +7 -0
- package/dist/content-filter.js +23 -0
- package/dist/decision-cap.d.ts +7 -29
- package/dist/decision-cap.js +3 -94
- package/dist/docker-daemon.d.ts +2 -2
- package/dist/docker-daemon.js +2 -2
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +8 -5
- package/dist/explain.js +3 -1
- package/dist/faux-computers.js +4 -0
- package/dist/files.d.ts +1 -9
- package/dist/files.js +1 -9
- package/dist/github-connection.js +25 -7
- package/dist/github-faux.d.ts +26 -0
- package/dist/github-faux.js +76 -0
- package/dist/github.d.ts +28 -4
- package/dist/github.js +46 -10
- package/dist/gpu-words.d.ts +14 -0
- package/dist/gpu-words.js +21 -0
- package/dist/graph-served.d.ts +5 -3
- package/dist/graph-served.js +14 -6
- package/dist/graph-view.d.ts +2 -0
- package/dist/graph-view.js +29 -2
- 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-opencode/harness.js +0 -1
- package/dist/harness-opencode/host/policy.js +2 -2
- package/dist/harness.js +1 -1
- package/dist/host-tools.d.ts +8 -9
- package/dist/host-tools.js +7 -7
- package/dist/index.d.ts +2 -3
- package/dist/index.js +2 -2
- package/dist/key-refusal.d.ts +1 -1
- package/dist/key-refusal.js +2 -2
- package/dist/learn/check.d.ts +10 -2
- package/dist/learn/check.js +126 -8
- package/dist/learn/commit.d.ts +40 -6
- package/dist/learn/commit.js +164 -20
- package/dist/learn/folder.d.ts +11 -3
- package/dist/learn/folder.js +40 -16
- package/dist/learn/grade.d.ts +22 -2
- package/dist/learn/grade.js +127 -19
- package/dist/learn/index.d.ts +2 -2
- package/dist/learn/index.js +2 -2
- package/dist/learn/learning.sh +11 -13
- package/dist/learn/notes.d.ts +17 -3
- package/dist/learn/notes.js +19 -6
- package/dist/learn/reflect.d.ts +5 -2
- package/dist/learn/reflect.js +48 -32
- package/dist/learn/skills.d.ts +52 -5
- package/dist/learn/skills.js +104 -21
- package/dist/learned-nodes.d.ts +18 -0
- package/dist/learned-nodes.js +8 -0
- package/dist/learned-workflow.d.ts +27 -13
- package/dist/learned-workflow.js +110 -38
- package/dist/learning-cost.d.ts +79 -0
- package/dist/learning-cost.js +69 -0
- package/dist/learning-routes.d.ts +48 -2
- package/dist/learning-routes.js +99 -28
- package/dist/learning-run.d.ts +7 -5
- package/dist/learning-run.js +9 -6
- package/dist/learning-words.d.ts +3 -0
- package/dist/learning-words.js +6 -2
- package/dist/learning.d.ts +13 -28
- package/dist/learning.js +4 -18
- package/dist/llm.d.ts +4 -1
- package/dist/llm.js +4 -2
- package/dist/mcp-gateway.d.ts +6 -0
- package/dist/mcp-gateway.js +11 -1
- package/dist/mcp-probe.d.ts +8 -1
- package/dist/mcp-probe.js +62 -20
- package/dist/mcp-secret-writes.js +4 -0
- package/dist/mcp-servers-store.d.ts +12 -12
- package/dist/mcp-servers-store.js +8 -3
- package/dist/model.d.ts +8 -5
- package/dist/model.js +14 -6
- package/dist/openapi.d.ts +2 -0
- package/dist/openapi.js +236 -55
- package/dist/owner.d.ts +0 -1
- package/dist/owner.js +0 -2
- package/dist/pause.d.ts +2 -19
- package/dist/pause.js +5 -74
- package/dist/place-offers.d.ts +97 -0
- package/dist/place-offers.js +206 -0
- package/dist/place.d.ts +9 -13
- package/dist/place.js +22 -32
- package/dist/port-models.d.ts +12 -4
- package/dist/port-models.js +31 -9
- package/dist/print.d.ts +1 -8
- package/dist/print.js +1 -14
- package/dist/propose.d.ts +3 -0
- package/dist/propose.js +25 -19
- package/dist/run-cut.d.ts +5 -0
- package/dist/run-cut.js +19 -0
- package/dist/run-db.js +3 -3
- package/dist/run-launch.d.ts +18 -3
- package/dist/run-launch.js +11 -5
- package/dist/run-learning-served.d.ts +12 -1
- package/dist/run-manifest.d.ts +2 -2
- package/dist/run-manifest.js +2 -2
- package/dist/run-reads-over-store.d.ts +4 -2
- package/dist/run-reads-over-store.js +10 -8
- package/dist/run-secrets.js +3 -3
- package/dist/run-timeline-served.js +60 -38
- package/dist/run-view.d.ts +35 -16
- package/dist/run-view.js +64 -35
- package/dist/runnable.d.ts +6 -3
- package/dist/runnable.js +20 -4
- package/dist/runner/adapter-loop.d.ts +46 -5
- package/dist/runner/adapter-loop.js +381 -56
- package/dist/runner/adapter-run-spec.d.ts +46 -4
- package/dist/runner/adapter-run-spec.js +200 -45
- package/dist/runner/adapters/pi.d.ts +39 -3
- package/dist/runner/adapters/pi.js +124 -29
- package/dist/runner/beside.d.ts +8 -0
- package/dist/runner/beside.js +24 -2
- package/dist/runner/claim-secrets.d.ts +6 -0
- package/dist/runner/claim-secrets.js +15 -1
- package/dist/runner/cli-run-spec.d.ts +10 -0
- package/dist/runner/cli-run-spec.js +207 -64
- package/dist/runner/commands.d.ts +5 -1
- package/dist/runner/commands.js +3 -3
- package/dist/runner/conformance/harness.d.ts +1 -1
- package/dist/runner/conformance/harness.js +13 -10
- package/dist/runner/github-app.d.ts +7 -2
- package/dist/runner/github-app.js +46 -15
- package/dist/runner/harness-loops.d.ts +6 -1
- package/dist/runner/harness-loops.js +24 -1
- package/dist/runner/journal-kinds.d.ts +53 -7
- package/dist/runner/journal-kinds.js +29 -1
- package/dist/runner/learning-end.d.ts +15 -0
- package/dist/runner/learning-end.js +113 -20
- package/dist/runner/learning-factory.js +6 -2
- package/dist/runner/learning-loop.d.ts +75 -1
- package/dist/runner/learning-loop.js +215 -22
- package/dist/runner/learning-seed.d.ts +8 -0
- package/dist/runner/learning-seed.js +7 -1
- package/dist/runner/loop-contract.d.ts +12 -0
- package/dist/runner/loop-contract.js +6 -0
- package/dist/runner/loop.d.ts +5 -1
- package/dist/runner/loop.js +20 -0
- package/dist/runner/main.d.ts +9 -4
- package/dist/runner/main.js +38 -13
- package/dist/runner/mcp-claim.d.ts +7 -0
- package/dist/runner/mcp-claim.js +35 -2
- package/dist/runner/mcp-github.d.ts +15 -4
- package/dist/runner/mcp-github.js +55 -11
- package/dist/runner/mcp-run.d.ts +2 -0
- package/dist/runner/mcp-run.js +2 -0
- package/dist/runner/metrics.d.ts +18 -1
- package/dist/runner/metrics.js +81 -1
- package/dist/runner/model-route.d.ts +6 -0
- package/dist/runner/model-route.js +5 -2
- package/dist/runner/pr-checkout.d.ts +59 -0
- package/dist/runner/pr-checkout.js +176 -0
- package/dist/runner/reflect-hook.d.ts +1 -0
- package/dist/runner/reflect-hook.js +3 -3
- package/dist/runner/runner.js +136 -19
- package/dist/runner/spec-holds.d.ts +13 -3
- package/dist/runner/spec-holds.js +13 -10
- package/dist/runner/store-port.d.ts +4 -1
- package/dist/runner/store-secrets.js +17 -1
- package/dist/runner/subagent.d.ts +44 -0
- package/dist/runner/subagent.js +188 -0
- package/dist/runner/workflow-host.d.ts +25 -4
- package/dist/runner/workflow-host.js +26 -4
- package/dist/runner/workflow-loop.d.ts +9 -3
- package/dist/runner/workflow-loop.js +17 -10
- package/dist/runner/workflow-spec.d.ts +28 -13
- package/dist/runner/workflow-spec.js +247 -102
- package/dist/runs-over-store.d.ts +18 -7
- package/dist/runs-over-store.js +149 -31
- package/dist/seal-key.d.ts +0 -2
- package/dist/seal-key.js +0 -2
- package/dist/sealing.js +1 -2
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/server-lock.js +4 -5
- package/dist/server.d.ts +49 -63
- package/dist/server.js +429 -230
- package/dist/stop-signals.d.ts +4 -2
- package/dist/stop-signals.js +5 -3
- package/dist/store/agent-body.d.ts +14 -3
- package/dist/store/agent-body.js +22 -8
- package/dist/store/deadline.d.ts +18 -0
- package/dist/store/deadline.js +49 -0
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +2 -2
- package/dist/store/journal/storage.js +2 -1
- package/dist/store/postgres/connection.d.ts +4 -0
- package/dist/store/postgres/connection.js +64 -13
- package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
- package/dist/store/schema.d.ts +2 -1
- package/dist/store/schema.js +11 -8
- 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 -82
- package/dist/store/sqlite/run-patch.d.ts +18 -2
- package/dist/store/sqlite/run-patch.js +31 -2
- package/dist/store/sqlite/store.js +65 -11
- package/dist/store/store.d.ts +62 -12
- package/dist/store/store.js +22 -1
- package/dist/store-reads/analytics.js +3 -2
- package/dist/store-reads/cap.d.ts +1 -3
- package/dist/store-reads/cap.js +8 -6
- package/dist/store-reads/decisions.d.ts +2 -2
- package/dist/store-reads/decisions.js +3 -6
- package/dist/store-reads/journal.js +83 -15
- package/dist/store-reads/learning.d.ts +73 -3
- package/dist/store-reads/learning.js +232 -9
- package/dist/store-reads/runs.d.ts +6 -4
- package/dist/store-reads/runs.js +17 -10
- package/dist/store-reads/stats.js +5 -1
- package/dist/store-view.d.ts +15 -1
- package/dist/store-view.js +88 -29
- package/dist/template-eval.js +2 -1
- package/dist/templates.d.ts +73 -4
- package/dist/templates.js +113 -23
- package/dist/timeline/timeline.d.ts +11 -1
- package/dist/timeline/timeline.js +19 -4
- package/dist/tool-blurbs.js +1 -0
- package/dist/tool-budget.d.ts +26 -0
- package/dist/tool-budget.js +56 -0
- package/dist/tool-gate.d.ts +13 -3
- package/dist/tool-gate.js +15 -7
- package/dist/tool-plane.d.ts +42 -29
- package/dist/tool-plane.js +64 -27
- package/dist/tools.d.ts +53 -39
- package/dist/tools.js +174 -79
- package/dist/trigger-signatures.d.ts +1 -0
- package/dist/trigger-signatures.js +3 -1
- package/dist/triggers.d.ts +3 -3
- package/dist/triggers.js +2 -2
- package/dist/turn-end.d.ts +0 -3
- package/dist/turn-end.js +0 -3
- package/dist/uploads.d.ts +28 -5
- package/dist/uploads.js +82 -9
- package/dist/usage-lines.d.ts +1 -1
- package/dist/usage.d.ts +1 -47
- package/dist/usage.js +3 -82
- package/dist/validate.d.ts +8 -0
- package/dist/validate.js +40 -3
- package/dist/webhooks.d.ts +2 -1
- package/dist/webhooks.js +5 -2
- 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 +112 -0
- package/dist/workflow/node-runner.js +270 -0
- package/dist/workflow/node.d.ts +88 -0
- package/dist/workflow/node.js +99 -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 +9 -0
- package/dist/workflow/pi-versions.js +8 -0
- package/dist/workflow/readers.d.ts +36 -0
- package/dist/workflow/readers.js +145 -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 +76 -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 +411 -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/wal.d.ts +11 -0
- package/dist/workflow/wal.js +106 -0
- package/dist/workflow-run.d.ts +1 -1
- package/dist/workspace/agent-computer.d.ts +137 -0
- package/dist/workspace/agent-computer.js +292 -0
- package/dist/workspace/archil-claim.d.ts +13 -2
- package/dist/workspace/archil-claim.js +22 -13
- package/dist/workspace/archil-disk.d.ts +10 -1
- package/dist/workspace/archil-disk.js +4 -0
- package/dist/workspace/archil-disks.d.ts +49 -0
- package/dist/workspace/archil-disks.js +185 -0
- package/dist/workspace/archil-exec.d.ts +12 -2
- package/dist/workspace/archil-exec.js +18 -3
- package/dist/workspace/archil-mount-credential.d.ts +20 -4
- package/dist/workspace/archil-mount-credential.js +13 -4
- package/dist/workspace/archil.d.ts +2 -2
- package/dist/workspace/archil.js +25 -5
- package/dist/workspace/attach.js +2 -0
- package/dist/workspace/computer-deps.d.ts +18 -11
- package/dist/workspace/computer-deps.js +64 -40
- package/dist/workspace/computer-for-claim.d.ts +47 -9
- package/dist/workspace/computer-for-claim.js +236 -24
- package/dist/workspace/computer-janitor.d.ts +3 -2
- package/dist/workspace/computer-janitor.js +43 -9
- package/dist/workspace/computer-ledger.d.ts +3 -8
- package/dist/workspace/computer-ledger.js +7 -3
- package/dist/workspace/computer-providers.d.ts +5 -3
- package/dist/workspace/computer-providers.js +11 -9
- package/dist/workspace/hands.d.ts +5 -2
- package/dist/workspace/hands.js +4 -3
- package/dist/workspace/index.d.ts +5 -4
- package/dist/workspace/index.js +2 -1
- package/dist/workspace/local.d.ts +3 -0
- package/dist/workspace/local.js +9 -0
- package/dist/workspace/paths.js +3 -2
- package/dist/workspace/pi-env.d.ts +4 -0
- package/dist/workspace/pi-env.js +3 -2
- package/dist/workspace/resolve-computer.d.ts +48 -12
- package/dist/workspace/resolve-computer.js +88 -19
- package/dist/workspace/run-disk.d.ts +34 -0
- package/dist/workspace/run-disk.js +91 -0
- package/dist/workspace/run-tools.d.ts +6 -4
- package/dist/workspace/run-tools.js +17 -9
- package/dist/workspace/server-run-workspace.d.ts +3 -2
- package/dist/workspace/server-run-workspace.js +17 -4
- package/dist/workspace/workspace.d.ts +5 -0
- package/dist/workspace.d.ts +0 -3
- package/dist/workspace.js +2 -15
- package/package.json +11 -16
- package/skills/agentrun-serve/SKILL.md +1 -1
- package/templates/README.md +11 -8
- 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/mentions-defused/case.yaml +15 -0
- package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +254 -0
- package/templates/code-review/evals/mentions-defused/graders/no-pings.md +16 -0
- package/templates/code-review/evals/mentions-defused/graders/posted-a-review.md +5 -0
- package/templates/code-review/evals/mentions-defused/graders/schema.md +5 -0
- package/templates/code-review/evals/mentions-defused/prompt.md +10 -0
- 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/kyb/evals/clean-public-company/graders/no-opensanctions.md +5 -0
- package/templates/kyb/evals/opensanctions-on/case.yaml +5 -0
- package/templates/kyb/evals/opensanctions-on/graders/licence-and-evidence.md +18 -0
- package/templates/kyb/evals/opensanctions-on/graders/schema.md +5 -0
- package/templates/kyb/evals/opensanctions-on/prompt.md +11 -0
- package/templates/release-notes/agent.md +11 -0
- 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 -76
- package/dist/budget.js +0 -204
- package/dist/console/assets/index-RPHGlXmM.js +0 -540
- package/dist/console/assets/index-opTN5Naq.css +0 -1
- 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/templates/code-review/rules/REVIEW.md +0 -41
|
@@ -13,19 +13,20 @@
|
|
|
13
13
|
// Shared with the pi spec: the run's Workspace and its uploaded files, a sandbox run's computer, the kernel registry's
|
|
14
14
|
// hands on them (runTools), the gate from the store's tool settings, the system prompt (environment line, instructions
|
|
15
15
|
// with what the agent learned and its skills, effort guidance), the first message, the end's metrics and the release.
|
|
16
|
-
import { mkdir } from "node:fs/promises";
|
|
16
|
+
import { mkdir, rm, rmdir } from "node:fs/promises";
|
|
17
17
|
import { join } from "node:path";
|
|
18
18
|
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
19
19
|
import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
20
20
|
import { checkRaise, followUpOf, parkOf } from "@parcha/agentrun-kernel/kernel/cap";
|
|
21
|
-
import { thinkingFor } from "../adapters.js";
|
|
22
|
-
import { installDirOf,
|
|
21
|
+
import { confineOf, noNewPrivsPrefix, standsIn, thinkingFor } from "../adapters.js";
|
|
22
|
+
import { claimSettled, installDirOf, installForClaim, installingWords } from "../harness-install.js";
|
|
23
23
|
import { HarnessUnavailable } from "../provider.js";
|
|
24
24
|
import { effortGuidance } from "../effort-guidance.js";
|
|
25
|
+
import { wireName } from "../catalog.js";
|
|
25
26
|
import { environmentLine } from "../environment.js";
|
|
26
27
|
import { harnessOf } from "../harness-table.js";
|
|
27
28
|
import { laidLearned, learningFolderOf, secretsShown } from "../learning.js";
|
|
28
|
-
import { layLearningSeed } from "./learning-seed.js";
|
|
29
|
+
import { laidOf, layLearningSeed } from "./learning-seed.js";
|
|
29
30
|
import { learningWorkspace } from "../learn/folder.js";
|
|
30
31
|
import { learningEndOfRun } from "./learning-end.js";
|
|
31
32
|
import { providerModels, runModels } from "../model.js";
|
|
@@ -33,7 +34,7 @@ import { firstMessage } from "../run-manifest.js";
|
|
|
33
34
|
import { learningStartOf, seedFailed } from "../run-launch.js";
|
|
34
35
|
import { readsFiles, systemOf } from "../skills.js";
|
|
35
36
|
import { DATA_ENV } from "../server-fs.js";
|
|
36
|
-
import {
|
|
37
|
+
import { copyRunFiles } from "../uploads.js";
|
|
37
38
|
import { isObject } from "../validate.js";
|
|
38
39
|
import { runFolder, scratchFolder } from "../workspace/paths.js";
|
|
39
40
|
import { openRunWorkspace } from "../workspace/run-workspace.js";
|
|
@@ -41,21 +42,25 @@ import { layOwnSkills } from "../workspace/revision-skills.js";
|
|
|
41
42
|
import { runTools, withKindTools } from "../workspace/run-tools.js";
|
|
42
43
|
import { archilClaim, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
|
|
43
44
|
import { loadArchilSettings } from "../archil-settings.js";
|
|
44
|
-
import { imageWaitWords } from "../workspace/computer-deps.js";
|
|
45
|
+
import { computerReadyWords, imageWaitWords } from "../workspace/computer-deps.js";
|
|
45
46
|
import { hostLifecycle } from "./adapter-loop.js";
|
|
46
|
-
import { adapterRunGate, answersCut, buildToolHost, hostToolCtxOf, learnedWorkflowHostTool, learnsWorkflows, modelAskOf, webHostTools, webToolNames } from "./adapter-run-spec.js";
|
|
47
|
+
import { adapterRunGate, answersCut, buildToolHost, capModelOf as capModelOfRoute, hostToolCtxOf, learnedTierRoutes, learnedTiers, learnedWorkflowHostTool, learnsWorkflows, modelAskOf, PI_WIRES, webHostTools, webToolNames } from "./adapter-run-spec.js";
|
|
48
|
+
import { openTierProxies } from "./adapters/pi.js";
|
|
47
49
|
import { signInReads } from "../sign-ins-store.js";
|
|
48
|
-
import {
|
|
50
|
+
import { mcpServersOf } from "../tool-gate.js";
|
|
51
|
+
import { claimSecrets, learnedDecisionKeys, tierModelKeys, withModelKeys } from "./claim-secrets.js";
|
|
49
52
|
import { mcpForClaim } from "./mcp-run.js";
|
|
50
53
|
import { TOOL_PLANE_ENV } from "../tool-plane.js";
|
|
51
54
|
import { resolveHarness } from "./adapters/index.js";
|
|
52
55
|
import { entriesOf } from "./loop.js";
|
|
53
|
-
import { bookedSpend,
|
|
56
|
+
import { bookedSpend, cliModelWorked, cliRunMetrics } from "./metrics.js";
|
|
54
57
|
import { journalEntries } from "./journal-reader.js";
|
|
55
58
|
import { specBuilt } from "./spec-holds.js";
|
|
56
59
|
import { heldRedactor, holdClaimed, runnerSecrets, secretRedactor } from "./redact.js";
|
|
57
60
|
import { githubAppAccess } from "./github-app.js";
|
|
61
|
+
import { prCheckoutForClaim } from "./pr-checkout.js";
|
|
58
62
|
import { holdStored, storeSecrets } from "./store-secrets.js";
|
|
63
|
+
import { bashPolicyOf } from "../bash-read-only.js";
|
|
59
64
|
/** What a CLI harness refuses of an agent's computer, in words: a browser, which only pi's browser tool drives. */
|
|
60
65
|
export const cliRefusesKind = (kind) => kind === "browser" ? "This agent's computer is a browser, which only the pi harness drives here: pick pi for this agent, or another kind of computer in Settings → Computers." : undefined;
|
|
61
66
|
/** The run's model and the catalog that prices it, as main chooses a CLI run's (app.ts wireModels and runModels): on the
|
|
@@ -102,6 +107,37 @@ function cliRunEnv(env, data, claimed = {}) {
|
|
|
102
107
|
Object.defineProperty(out, DATA_ENV, { value: data, enumerable: true, writable: true, configurable: true });
|
|
103
108
|
return out;
|
|
104
109
|
}
|
|
110
|
+
/** `tools` in the order the agent grants them (`granted`, catalog names; a tool is listed by its catalog name's wire
|
|
111
|
+
* name), as main listed a CLI run's tools to its harness: each granted tool where its grant is, and a tool the grant
|
|
112
|
+
* does not name (one a granted tool or the run's computer brings beside it) right after the tool listed before it. Ties
|
|
113
|
+
* keep the order given. */
|
|
114
|
+
export function inGrantOrder(tools, granted) {
|
|
115
|
+
const at = new Map(granted.map((name, index) => [wireName(name), index]));
|
|
116
|
+
let last = -1;
|
|
117
|
+
const keyed = tools.map((tool, given) => {
|
|
118
|
+
const index = at.get(tool.name);
|
|
119
|
+
if (index !== undefined)
|
|
120
|
+
last = index;
|
|
121
|
+
return { tool, key: index ?? last + 0.5, given };
|
|
122
|
+
});
|
|
123
|
+
return keyed.sort((a, b) => a.key - b.key || a.given - b.given).map(({ tool }) => tool);
|
|
124
|
+
}
|
|
125
|
+
/** A claim's private folder removed, then each of `parents` in order while it is empty: one another claim of the run has
|
|
126
|
+
* laid things in since (a follow-up's) stays, with what is in it. */
|
|
127
|
+
export async function sweepScratch(dir, parents) {
|
|
128
|
+
await rm(dir, { recursive: true, force: true });
|
|
129
|
+
for (const parent of parents) {
|
|
130
|
+
try {
|
|
131
|
+
await rmdir(parent);
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
const code = error.code;
|
|
135
|
+
if (code === "ENOTEMPTY" || code === "EEXIST" || code === "ENOENT")
|
|
136
|
+
return;
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
105
141
|
/**
|
|
106
142
|
* One claimed CLI run's AdapterRunSpec, built from its launch record and its revision.
|
|
107
143
|
*
|
|
@@ -134,12 +170,6 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
134
170
|
const body = (revisionRow.body ?? {});
|
|
135
171
|
const revision = { kind: revisionRow.kind, body };
|
|
136
172
|
const granted = body.tools ?? [];
|
|
137
|
-
// The run's MCP for this claim (mcp-run.ts mcpForClaim): its pin made at the first claim or read as written, its
|
|
138
|
-
// credentials opened under the runner's seal key (deps.sealKey) into this claim's memory, one gateway for the claim.
|
|
139
|
-
// First, before the session opens: a refusal (a pin that cannot be made, a pinned meta tool) ends the run in its words.
|
|
140
|
-
const mcp = await mcpForClaim({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, work: () => runFolder(deps.data, runRow.agentId, claim.runId), launchInput: launch.input, githubAppAccess: (store, key, input) => githubAppAccess(store, key, input, deps.githubApi ? { api: deps.githubApi } : {}), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}) });
|
|
141
|
-
// The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
|
|
142
|
-
holds.hold({ passed: mcp });
|
|
143
173
|
// The harness: the launch's, else the revision's. Its table entry (facts, model choice, adapter, skill check), read from
|
|
144
174
|
// the run's environment table as main does (harnessOf: the built-in entries, a test's module merged over them under a
|
|
145
175
|
// test runner; anywhere else it is the built-ins), and the runner's record mode for it.
|
|
@@ -152,10 +182,53 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
152
182
|
// The level the harness thinks at: the run's effort, else above its highest (codex stops at xhigh) its highest. The
|
|
153
183
|
// run's metrics name this level, the one it ran at, never a level the harness has not.
|
|
154
184
|
const thinking = launch.effort ? thinkingFor(facts, launch.effort) : undefined;
|
|
185
|
+
// A harness that installs on first use (claude-agent, codex) and is not installed whole in this server's data: the claim
|
|
186
|
+
// waits for the install running now (the server starts one at an agent's save), or, with none running (none started, or
|
|
187
|
+
// one cut short or failed before this claim), installs it itself. One install at a time on this data, which every claim
|
|
188
|
+
// that needs it waits for (harness-install.ts installForClaim), bounded by the install's own limit. The wait is said on
|
|
189
|
+
// the run's timeline as it starts, its root made first (a CLI run's root is its record's, which the loop would make once
|
|
190
|
+
// the session opens), so the row shows while it waits. First, before the run's MCP claim: its OAuth tokens are read
|
|
191
|
+
// after a wait that may outlive them. A stop of the run ends its wait at once; an install that fails fails the run in the
|
|
192
|
+
// install's own words. A test's stand-in that runs in place of the CLI (adapters.ts standsIn) loads nothing installed:
|
|
193
|
+
// its claim waits for an install that runs, as any claim does, but starts none of its own.
|
|
194
|
+
if (entry.installs && entry.pins) {
|
|
195
|
+
const installs = entry.installs;
|
|
196
|
+
const pins = entry.pins;
|
|
197
|
+
const dir = installDirOf(deps.data, name);
|
|
198
|
+
const waitOn = run.stopped ?? run.signal;
|
|
199
|
+
let saying;
|
|
200
|
+
const say = () => (saying ??= (async () => {
|
|
201
|
+
await run.harness.root(context);
|
|
202
|
+
run.phase?.(installingWords(installs.label));
|
|
203
|
+
})().catch((error) => log(`the run's install wait was not said on its timeline: ${error?.message ?? String(error)}`)));
|
|
204
|
+
let waited = false;
|
|
205
|
+
const settled = await (deps.installSettled ?? claimSettled)(installs, dir, await pins(), { ...(waitOn ? { signal: waitOn } : {}), onWait: () => void ((waited = true), say()) });
|
|
206
|
+
// The install it waited for failed: the run fails in its words. An earlier one that failed before this claim is tried again.
|
|
207
|
+
if (typeof settled === "object" && waited)
|
|
208
|
+
throw new HarnessUnavailable(settled.failed, "install");
|
|
209
|
+
if (settled !== "installed" && !standsIn(name, deps.env ?? {})) {
|
|
210
|
+
await say();
|
|
211
|
+
const lock = deps.harnessLocks?.[name];
|
|
212
|
+
await (deps.installForClaim ?? installForClaim)(installs, dir, pins, { ...(lock ? { lock } : {}), ...(waitOn ? { signal: waitOn } : {}) }).catch((error) => {
|
|
213
|
+
if (waitOn?.aborted)
|
|
214
|
+
throw error;
|
|
215
|
+
throw new HarnessUnavailable(error.message, "install");
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// The run's MCP for this claim (mcp-run.ts mcpForClaim): its pin made at the first claim or read as written, its
|
|
220
|
+
// credentials opened under the runner's seal key (deps.sealKey) into this claim's memory, one gateway for the claim.
|
|
221
|
+
// Before the session opens: a refusal (a pin that cannot be made, a pinned meta tool) ends the run in its words.
|
|
222
|
+
// A credential the claim opens mid-run (a GitHub App token, a per_run server's handed one) joins the run's redactors.
|
|
223
|
+
const hold = (values) => { for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut])
|
|
224
|
+
redact.hold(values); };
|
|
225
|
+
const mcp = await mcpForClaim({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, work: () => runFolder(deps.data, runRow.agentId, claim.runId), launchInput: launch.input, hold, githubAppAccess: (store, key, input) => githubAppAccess(store, key, input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub: launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github", hold }), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}) });
|
|
226
|
+
// The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
|
|
227
|
+
holds.hold({ passed: mcp });
|
|
155
228
|
// The run's mode is the server's: Mode 2 where its Archil settings are saved (archil-settings.ts), the run's folder then
|
|
156
229
|
// on the claim's Archil disk (archil-claim.ts: its keys from the store's sealed rows, under the runner's seal key, in
|
|
157
230
|
// this claim's memory only, dropped at the release); else Mode 1, the run's local folder.
|
|
158
|
-
const archilSettings = await loadArchilSettings(deps.store);
|
|
231
|
+
const archilSettings = await loadArchilSettings(deps.store, deps.env);
|
|
159
232
|
const mode = archilSettings === undefined ? 1 : 2;
|
|
160
233
|
const archil = archilSettings === undefined
|
|
161
234
|
? undefined
|
|
@@ -163,7 +236,8 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
163
236
|
// named for the run and this claim's epoch; revoke at the run's end (below). mountControl (a test's loopback control-plane
|
|
164
237
|
// fake) is spread into the mount, so no test reaches the real control plane. TODO(k2 lazy mint): the mint moves into
|
|
165
238
|
// computerForClaim (a mounting computer only), with the ttl the run's lifetime bound (not this fixed figure). As pi does.
|
|
166
|
-
|
|
239
|
+
// The disk is the run's (run-disk.ts): its launch record's, else its agent's, made on its first run that needs one.
|
|
240
|
+
: await archilClaim({ settings: archilSettings, keys: deps.store.sealedKeys, sealKey: deps.sealKey, signal: run.signal ?? new AbortController().signal, env: deps.env, mount: { runId: claim.runId, epoch: claim.epoch, ttlMs: MOUNT_TTL_MS, ...(deps.mountControl ?? {}) }, run: { agentId: runRow.agentId, ...(launch.archilDisk ? { launch: launch.archilDisk } : {}), store: deps.store }, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) });
|
|
167
241
|
// Each resource is held the moment it exists (spec-holds.ts): a throw after it lets it go. The claim's Archil keys go
|
|
168
242
|
// from memory last, once nothing more reads the disk.
|
|
169
243
|
holds.hold({ archil, keys: archil });
|
|
@@ -172,32 +246,44 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
172
246
|
? await openRunWorkspace({ mode: 1, agentId: runRow.agentId, runId: claim.runId, data: deps.data, log })
|
|
173
247
|
: await openRunWorkspace({ mode: 2, agentId: runRow.agentId, runId: claim.runId, archil, log });
|
|
174
248
|
holds.hold({ ws });
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
}
|
|
249
|
+
// The pull request's checkout, when the revision asks for one, as the pi spec makes it (pr-checkout.ts).
|
|
250
|
+
const checkout = body.checkout === "pull_request" ? await prCheckoutForClaim(deps, ws.workspace, launch, cut, run.stopped ?? run.signal, (part) => holds.hold({ checkout: part })) : undefined;
|
|
251
|
+
holds.hold({ checkout });
|
|
252
|
+
if (launch.files?.length)
|
|
253
|
+
await copyRunFiles(deps.data, claim.runId, ws.workspace, launch.files);
|
|
182
254
|
// The run's computer, from the one shared claim-time function (the pi spec takes the same): none for a runner place.
|
|
183
255
|
// It throws computer_unavailable (nothing made) when the computer cannot be had: the run fails in its words.
|
|
184
|
-
const computer = await deps.computerForClaim({ runId: claim.runId, epoch: claim.epoch, revisionId: runRow.revisionId, place: launch.place, ...(launch.computer !== undefined ? { computer: launch.computer } : {}) }, deps.store,
|
|
256
|
+
const computer = await deps.computerForClaim({ runId: claim.runId, epoch: claim.epoch, agentId: runRow.agentId, revisionId: runRow.revisionId, place: launch.place, ...(launch.computer !== undefined ? { computer: launch.computer } : {}) }, deps.store,
|
|
185
257
|
// revokeMount removes the run's Archil mount credential at the computer's release (and if a start fails after a mint); the
|
|
186
|
-
// run's end revokes it too, so it goes on every outcome even with no computer. Idempotent. As the pi spec does
|
|
258
|
+
// run's end revokes it too, so it goes on every outcome even with no computer. Idempotent. As the pi spec does, with
|
|
259
|
+
// what became of the agent's own computer said on the run's timeline.
|
|
187
260
|
// A browser computer is driven by the browser tool, which runs on pi's native route alone: a CLI's run of an agent
|
|
188
261
|
// whose computer is a browser is refused in words at its claim, before anything is made.
|
|
189
|
-
{ ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, refuseKind: cliRefusesKind, ...(archil ? { revokeMount: () => archil.revoke() } : {}), ...(run.phase ? { onImageWait: (making, image) => run.phase?.(imageWaitWords(making, image)) } : {}) });
|
|
262
|
+
{ ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, refuseKind: cliRefusesKind, ...(archil ? { revokeMount: () => archil.revoke() } : {}), ...(run.phase ? { onImageWait: (making, image) => run.phase?.(imageWaitWords(making, image)), onConnected: (said) => run.phase?.(computerReadyWords(said)), onComputerNote: (words) => run.phase?.(words) } : {}) });
|
|
190
263
|
holds.hold({ computer });
|
|
191
|
-
// The CLI works in the run's scratch folder on this machine (its working directory,
|
|
192
|
-
//
|
|
193
|
-
// folder for the run's file tools: a path the CLI builds from its working directory lands in the run's folder, and
|
|
194
|
-
// other absolute path is refused (workspace/paths.ts portPath).
|
|
264
|
+
// The CLI works in the run's scratch folder on this machine (its working directory), its own files (home, state, the
|
|
265
|
+
// skills laid for it) in this claim's private folder inside it, never on the run's disk. The scratch is an alias of the
|
|
266
|
+
// run's folder for the run's file tools: a path the CLI builds from its working directory lands in the run's folder, and
|
|
267
|
+
// any other absolute path is refused (workspace/paths.ts portPath).
|
|
268
|
+
// The private folder is swept at the spec's release, the claim's end, then the scratch folder if nothing else is in it:
|
|
269
|
+
// the next claim, here or on another runner, lays its own, its harness's session coming back from the run's journal.
|
|
270
|
+
// Its own per claim (by the claim's epoch), so a run reopened while this claim still lets go (its release follows the
|
|
271
|
+
// run's end commit) never has the next claim's folder swept from under it.
|
|
195
272
|
const scratch = scratchFolder(deps.data, runRow.agentId, claim.runId);
|
|
196
|
-
const
|
|
197
|
-
|
|
273
|
+
const harnesses = join(scratch, "harness");
|
|
274
|
+
const dir = join(harnesses, String(claim.epoch));
|
|
275
|
+
holds.hold({ scratch: { sweep: () => sweepScratch(dir, [harnesses, scratch]) } });
|
|
276
|
+
// Made again once if a parent went as it was made (the last claim's sweep removing the then empty scratch folder).
|
|
277
|
+
await mkdir(dir, { recursive: true, mode: 0o700 }).catch(async (error) => {
|
|
278
|
+
if (error.code !== "ENOENT")
|
|
279
|
+
throw error;
|
|
280
|
+
await mkdir(dir, { recursive: true, mode: 0o700 });
|
|
281
|
+
});
|
|
198
282
|
// The run's shell is its computer's (600 s) where one mounts its folder; with none, Archil's serverless exec in Mode 2
|
|
199
283
|
// (295 s), and in Mode 1 none at all: no bash family, its folder being one of this server's own (run-tools.ts).
|
|
200
|
-
|
|
284
|
+
// Under the agent's bash policy, its shell's environment is the policy's too (bash-read-only.ts policyEnv), as the pi spec does.
|
|
285
|
+
const bashPolicy = bashPolicyOf(body.toolSettings);
|
|
286
|
+
const tools = await runTools(ws.workspace, computer.computer, { mode, context, aliases: [scratch], ...(computer.hold ? { hold: computer.hold } : {}), ...(bashPolicy === undefined ? {} : { bashPolicy }) });
|
|
201
287
|
holds.hold({ tools });
|
|
202
288
|
const root = runFolder(deps.data, runRow.agentId, claim.runId);
|
|
203
289
|
// The system prompt, as main's harness branch builds it: the environment line, the instructions with what the agent
|
|
@@ -220,6 +306,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
220
306
|
own: Object.keys(revisionRow.skills ?? {}),
|
|
221
307
|
shown: async () => secretsShown(runnerSecrets(deps.env, await storeSecrets(deps.store, deps.sealKey, deps.data)), { local: true }),
|
|
222
308
|
log,
|
|
309
|
+
...(start.notesOnly ? { workflows: false } : {}),
|
|
223
310
|
})
|
|
224
311
|
: undefined;
|
|
225
312
|
const { system: instructions, native } = await systemOf(laid, [...Object.keys(body.skills ?? {}), ...(seedLaid?.skills ?? [])], ws.workspace, check, { onDemand: readsFiles(granted) });
|
|
@@ -236,31 +323,50 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
236
323
|
holdClaimed(redact, claimed);
|
|
237
324
|
const env = cliRunEnv(deps.env, deps.data, claimed);
|
|
238
325
|
const chosen = await modelsOf(entry, env, modelAskOf(launch.model, body.model));
|
|
239
|
-
//
|
|
240
|
-
//
|
|
241
|
-
//
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
const installs = entry.installs;
|
|
245
|
-
const waitOn = run.stopped ?? run.signal;
|
|
246
|
-
const settled = await (deps.installSettled ?? installSettled)(installs, installDirOf(deps.data, name), await entry.pins(), { ...(waitOn ? { signal: waitOn } : {}), onWait: () => run.phase?.(installingWords(installs.label)) });
|
|
247
|
-
if (typeof settled === "object")
|
|
248
|
-
throw new HarnessUnavailable(settled.failed, "install");
|
|
249
|
-
}
|
|
250
|
-
const built = await entry.adapter(env, { model: chosen.model, models: chosen.models, unpriced: chosen.unpriced, ...(native.length ? { skills: native } : {}) });
|
|
326
|
+
// The CLI's own process (the Claude CLI, Codex, OpenCode) starts under the no_new_privs pi's commands start under
|
|
327
|
+
// (adapters.ts' noNewPrivsPrefix): on Linux, setpriv --no-new-privs, so a setuid program or file capability it
|
|
328
|
+
// or a command it runs reaches grants nothing; none on macOS. Where setpriv is not usable the run is refused, in pi's words.
|
|
329
|
+
const confine = confineOf(noNewPrivsPrefix());
|
|
330
|
+
const built = await entry.adapter(env, { model: chosen.model, models: chosen.models, unpriced: chosen.unpriced, ...(confine ? { confine } : {}), ...(native.length ? { skills: native } : {}) });
|
|
251
331
|
// The harness's own session options, its private directory and its working directory (SessionIO's dir and cwd, which
|
|
252
332
|
// every CLI adapter reads), set on its open here, so the loop lends the session nothing of its own. A turn that ends on
|
|
253
333
|
// the CLI's own error names the harness first, as main words it (harness-app.ts: `<harness>: <error>`), so the run's
|
|
254
334
|
// error and its Timeline row say which CLI said it.
|
|
335
|
+
// The run's models of other tiers, for its learned workflows' nodes of a tier (learnedTierRoutes, filled once the seed's
|
|
336
|
+
// lay chose the workflows, below): each on a proxy of its own beside the CLI session's (openTierProxies, pi's), on the
|
|
337
|
+
// session's booking, reached through the session's port with a `tier`. The CLI never sees them.
|
|
338
|
+
const tierRoutes = new Map();
|
|
255
339
|
const adapter = {
|
|
256
340
|
...built,
|
|
257
341
|
open: async (spec, io) => {
|
|
258
342
|
const session = await built.open(spec, { ...io, dir, cwd: scratch });
|
|
343
|
+
let tiers;
|
|
344
|
+
try {
|
|
345
|
+
tiers = await openTierProxies(tierRoutes, io.models, cut);
|
|
346
|
+
}
|
|
347
|
+
catch (error) {
|
|
348
|
+
await session.close().catch(() => undefined);
|
|
349
|
+
throw error;
|
|
350
|
+
}
|
|
351
|
+
io.signal.addEventListener("abort", () => void tiers.close(), { once: true });
|
|
259
352
|
const turnEnd = session.turnEnd.bind(session);
|
|
260
|
-
|
|
353
|
+
const close = session.close.bind(session);
|
|
354
|
+
const port = session.port?.bind(session);
|
|
355
|
+
return Object.assign(session, {
|
|
356
|
+
turnEnd: async () => {
|
|
261
357
|
const end = await turnEnd();
|
|
262
358
|
return end.error ? { ...end, error: `${name}: ${end.error}` } : end;
|
|
263
|
-
}
|
|
359
|
+
},
|
|
360
|
+
close: async () => {
|
|
361
|
+
await close();
|
|
362
|
+
await tiers.close();
|
|
363
|
+
},
|
|
364
|
+
// The session's port; with a `tier`, that tier's proxy, while the session's own port is up (none once closed).
|
|
365
|
+
port: (label, tier) => {
|
|
366
|
+
const own = port?.(label);
|
|
367
|
+
return tier === undefined || own === undefined ? own : tiers.port(label, tier);
|
|
368
|
+
},
|
|
369
|
+
});
|
|
264
370
|
},
|
|
265
371
|
};
|
|
266
372
|
// The run's cap (its launch's maxCostUsd): the kernel's check before each paid request, at the catalog price of the
|
|
@@ -274,8 +380,15 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
274
380
|
// kernel runCap from these over the run's own sessions; the spec carries no beforeRequest of its own.
|
|
275
381
|
const runCap = {
|
|
276
382
|
capUsd: () => launch.maxCostUsd,
|
|
277
|
-
// One model per CLI session: every request it sends is the run's model, whatever id its provider names it by.
|
|
278
|
-
|
|
383
|
+
// One model per CLI session: every request it sends is the run's model, whatever id its provider names it by. A
|
|
384
|
+
// learned node's request on a tier's proxy names its tier (ModelRequest.route) and is priced as that route books it,
|
|
385
|
+
// even under an id the run's model shares.
|
|
386
|
+
modelOf: (id, by) => {
|
|
387
|
+
if (by === undefined)
|
|
388
|
+
return capModel;
|
|
389
|
+
const tierRoute = tierRoutes.get(by);
|
|
390
|
+
return tierRoute && tierRoute.model === id ? capModelOfRoute(tierRoute) : undefined;
|
|
391
|
+
},
|
|
279
392
|
...(launch.capMode === "strict" ? { mode: "strict" } : {}),
|
|
280
393
|
};
|
|
281
394
|
const cap = capUsd === undefined
|
|
@@ -289,8 +402,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
289
402
|
};
|
|
290
403
|
// The gate before a call's intent, the same as the pi spec: the revision's tool settings over the store's, read from the
|
|
291
404
|
// store at each decide — adapterRunGate (RunGate.decide: deny with its words, a pin, allow, ask). The end-of-run turn's
|
|
292
|
-
// refusal of writes under .learning/ is the adapter loop's own (it knows the turn), never a file's.
|
|
293
|
-
|
|
405
|
+
// refusal of writes under .learning/ is the adapter loop's own (it knows the turn), never a file's. The run's MCP servers
|
|
406
|
+
// (mcpServersOf its grants) hold a harness's own name for an MCP tool to that tool's settings.
|
|
407
|
+
const gate = await adapterRunGate(deps.store, claim, revision, ws.workspace, tools.shell, mcpServersOf(granted));
|
|
294
408
|
// The run's tools: the kernel registry's hands on its Workspace (and computer); the web host tools it is granted
|
|
295
409
|
// (web_fetch, web_search, monid), bound by the binding the pi spec uses (webHostTools) on the ToolHost the pi spec builds
|
|
296
410
|
// (buildToolHost); and the learned_workflow tool when the run has it (learnsWorkflows: its revision is agentic and the
|
|
@@ -337,19 +451,36 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
337
451
|
webTools = await webHostTools(host, granted, ctx);
|
|
338
452
|
}
|
|
339
453
|
if (learns) {
|
|
454
|
+
// A tier the learned workflows name that the host has a model of, routed as pi's are (learnedTierRoutes: the run's
|
|
455
|
+
// keys, pi's wires, since pi-ai's client sends these, never the CLI); one refused fails its node in its words.
|
|
456
|
+
// Their models' keys (tierModelKeys: a saved one too, which claimSecrets opened only for the run's own model), held by
|
|
457
|
+
// the redactors, on the tiers' route env alone (withModelKeys, never enumerable), never on the tools' (toolEnv).
|
|
458
|
+
const tierKeys = await tierModelKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, learnedTiers(workflows));
|
|
459
|
+
for (const redact of new Set([held, cut]))
|
|
460
|
+
holdClaimed(redact, tierKeys);
|
|
461
|
+
const modelEnv = withModelKeys(deps.env, { ...claimed, ...tierKeys });
|
|
462
|
+
const tiers = new Map();
|
|
463
|
+
for (const [tier, routed] of await learnedTierRoutes(workflows, modelEnv, (tier) => deps.routeOf(undefined, modelEnv, tier, PI_WIRES, undefined, cut))) {
|
|
464
|
+
if ("why" in routed)
|
|
465
|
+
tiers.set(tier, { why: routed.why });
|
|
466
|
+
else {
|
|
467
|
+
tierRoutes.set(tier, routed);
|
|
468
|
+
tiers.set(tier, { model: routed.model });
|
|
469
|
+
}
|
|
470
|
+
}
|
|
340
471
|
// The gate asks a learned_workflow call about its workflow's MCP nodes (adapterRunGate); they run through the run's
|
|
341
|
-
// own MCP as the loop wraps it.
|
|
472
|
+
// own MCP as the loop wraps it. Its model nodes run on the session's one model: what each node's trace says it ran on.
|
|
342
473
|
gate.learn(workflows);
|
|
343
|
-
learnedTool = await learnedWorkflowHostTool({ run, kind: revision.kind, granted, plane: launch.plane, env: toolEnv, work: root, workflows, permissions: gate.permissions, ctx, ...(mcp ? { mcp } : {}) });
|
|
474
|
+
learnedTool = await learnedWorkflowHostTool({ run, kind: revision.kind, granted, plane: launch.plane, env: toolEnv, work: root, workflows, permissions: gate.permissions, ctx, tiers, ...(mcp ? { mcp } : {}), modelName: () => chosen.model.modelId });
|
|
344
475
|
}
|
|
345
476
|
}
|
|
346
477
|
const session = {
|
|
347
478
|
key: `run:${claim.runId}`,
|
|
348
479
|
label: runRow.agentId,
|
|
349
|
-
system: [environmentLine(), instructions, guidance].filter((line) => Boolean(line)),
|
|
480
|
+
system: [environmentLine(), checkout?.note, instructions, guidance].filter((line) => Boolean(line)),
|
|
350
481
|
// The web tools and the learned workflow's call nodes run on the claim's keys: their answers pass the runner's one
|
|
351
|
-
// redactor, as pi's do.
|
|
352
|
-
tools: [...tools.hostTools(withKindTools(granted, tools), results), ...[...webTools, ...(learnedTool ? [learnedTool] : [])].map((tool) => answersCut(tool, held))],
|
|
482
|
+
// redactor, as pi's do. Listed in the order the agent grants them, as main lists a CLI run's tools.
|
|
483
|
+
tools: inGrantOrder([...tools.hostTools(withKindTools(granted, tools), results), ...[...webTools, ...(learnedTool ? [learnedTool] : [])].map((tool) => answersCut(tool, held))], granted),
|
|
353
484
|
context: "fresh",
|
|
354
485
|
...(thinking ? { thinking } : {}),
|
|
355
486
|
};
|
|
@@ -386,26 +517,38 @@ async function cliSpec(launch, run, deps, claim, holds) {
|
|
|
386
517
|
...(mcp ? { mcp } : {}),
|
|
387
518
|
// The run's end-of-run step, when it learns (the spec's, preferred over the loop's deps': adapter-loop.ts stepOf).
|
|
388
519
|
...(endOfRun ? { endOfRun } : {}),
|
|
520
|
+
...(start ? { learningLaid: laidOf(seedLaid) } : {}),
|
|
389
521
|
// The web tools' install lifecycle, run by the adapter loop, as the pi spec's (they register none today).
|
|
390
522
|
...(life ? { lifecycle: life } : {}),
|
|
391
523
|
agentId: runRow.agentId,
|
|
524
|
+
// The run's desktop or phone and the person's hold on it, as the claim made them (as the pi spec gives them).
|
|
525
|
+
...(computer.held ? { computer: computer.held } : {}),
|
|
392
526
|
workRoot: root,
|
|
393
|
-
//
|
|
394
|
-
//
|
|
395
|
-
|
|
527
|
+
// Where the CLI works (its working directory, the run's folder to its file tools): what its absolute paths are read
|
|
528
|
+
// against on the run's rows.
|
|
529
|
+
cwd: scratch,
|
|
530
|
+
// The end's metrics: its tools from the run's record, its tokens and model requests its booking's, at its model
|
|
531
|
+
// (metrics.ts cliRunMetrics). Its cost is its booking's too: the harness's own record carries no per-request cost or
|
|
532
|
+
// usage, so its model requests are counted at what the run's model proxy booked them at (bookedSpend over every
|
|
533
|
+
// session of its journal), as a pi run's are at its answers' costs and tokens.
|
|
396
534
|
endPatch: async () => {
|
|
397
535
|
const entries = await entriesOf(deps.journal(claim), ROOT_CONVERSATION_ID, context);
|
|
398
|
-
|
|
399
|
-
//
|
|
536
|
+
// Its tokens and model requests, and its model requests' cost, from one read of its booking (cliRunMetrics); its
|
|
537
|
+
// decisions (a learned workflow's) at what they were booked at too.
|
|
400
538
|
const all = (await journalEntries(deps.journal(claim), context));
|
|
401
|
-
const
|
|
539
|
+
const booked = bookedSpend(all, "model");
|
|
540
|
+
const metrics = cliRunMetrics(entries, booked, { ...(thinking ? { effort: thinking } : {}), model: `${chosen.model.provider}/${chosen.model.modelId}` });
|
|
541
|
+
// A run whose model answered or called a tool with no request booked (its requests went past its model proxy) spent
|
|
542
|
+
// what no booking read: unknown, never the $0 an empty booking sums to.
|
|
543
|
+
const model = booked.requests === 0 && cliModelWorked(entries) ? null : booked.usd;
|
|
402
544
|
const decisions = bookedSpend(all, "decisions").usd;
|
|
403
545
|
const costUsd = model === null || decisions === null ? null : model + decisions;
|
|
404
546
|
// Its paid tool calls (a Parallel extract or search, a monid call), booked on the run's one ledger in their own
|
|
405
547
|
// session, are the run's cost too, as the pi spec's.
|
|
406
548
|
const paid = run.ledger?.paid ? run.ledger.paid.spentUsd() : 0;
|
|
407
549
|
const total = costUsd === null || paid === null ? null : costUsd + paid;
|
|
408
|
-
|
|
550
|
+
// An unknown cost is written as null, never left out: a follow-up's end clears the cost an earlier end stored.
|
|
551
|
+
return { costUsd: total, metrics };
|
|
409
552
|
},
|
|
410
553
|
// The run's Archil mount credential is revoked at its end on every outcome, even with no computer (idempotent with
|
|
411
554
|
// the computer's release). A run that minted none revokes nothing.
|
|
@@ -13,11 +13,15 @@ export interface CommandSink {
|
|
|
13
13
|
command(runId: string, command: {
|
|
14
14
|
kind: string;
|
|
15
15
|
body: Record<string, unknown>;
|
|
16
|
+
}, options?: {
|
|
17
|
+
launchSealed?: Uint8Array;
|
|
16
18
|
}): Promise<Command>;
|
|
17
19
|
}
|
|
18
20
|
/** Inserts a command row for a run, after checking its kind and body. Rejects RunFinal (from the store) when the run is
|
|
19
21
|
* final, and a TypeError for a kind or body no runner would take. */
|
|
20
|
-
export declare function sendCommand(store: CommandSink, runId: string, input: CommandInput
|
|
22
|
+
export declare function sendCommand(store: CommandSink, runId: string, input: CommandInput, options?: {
|
|
23
|
+
launchSealed?: Uint8Array;
|
|
24
|
+
}): Promise<Command>;
|
|
21
25
|
/** The reason a command still untaken when its run ended is refused with: the store's own words (the write that makes a
|
|
22
26
|
* run final refuses such rows itself). */
|
|
23
27
|
export { endedReason } from "../store/store.js";
|
package/dist/runner/commands.js
CHANGED
|
@@ -17,7 +17,7 @@ function bodyProblem(kind, body) {
|
|
|
17
17
|
case "steer":
|
|
18
18
|
if (!text(body.text))
|
|
19
19
|
return "a steer needs its text";
|
|
20
|
-
// A trigger's message names who wrote it, as the Timeline shows it
|
|
20
|
+
// A trigger's message names who wrote it, as the Timeline shows it: never a person's.
|
|
21
21
|
return body.origin === undefined || originOf(body.origin) !== undefined ? undefined : "a steer's origin is a message origin (a trigger's, or the server's)";
|
|
22
22
|
case "approve":
|
|
23
23
|
case "deny":
|
|
@@ -52,7 +52,7 @@ function bodyProblem(kind, body) {
|
|
|
52
52
|
}
|
|
53
53
|
/** Inserts a command row for a run, after checking its kind and body. Rejects RunFinal (from the store) when the run is
|
|
54
54
|
* final, and a TypeError for a kind or body no runner would take. */
|
|
55
|
-
export async function sendCommand(store, runId, input) {
|
|
55
|
+
export async function sendCommand(store, runId, input, options) {
|
|
56
56
|
if (!COMMAND_KINDS.has(input.kind)) {
|
|
57
57
|
throw new TypeError(`a command's kind is one of ${[...COMMAND_KINDS].join(", ")}, not ${JSON.stringify(input.kind)}`);
|
|
58
58
|
}
|
|
@@ -60,7 +60,7 @@ export async function sendCommand(store, runId, input) {
|
|
|
60
60
|
const problem = bodyProblem(input.kind, body);
|
|
61
61
|
if (problem)
|
|
62
62
|
throw new TypeError(problem);
|
|
63
|
-
return store.command(runId, { kind: input.kind, body });
|
|
63
|
+
return store.command(runId, { kind: input.kind, body }, ...(options ? [options] : []));
|
|
64
64
|
}
|
|
65
65
|
/** The reason a command still untaken when its run ended is refused with: the store's own words (the write that makes a
|
|
66
66
|
* run final refuses such rows itself). */
|
|
@@ -26,6 +26,7 @@ export declare function suiteTools(countFile?: string): {
|
|
|
26
26
|
letSlowGo: () => void;
|
|
27
27
|
slowStarted: Promise<void>;
|
|
28
28
|
};
|
|
29
|
+
/** A store in a data directory of its own, one queued run, and runners started on it (each its own connection). */
|
|
29
30
|
/** The stores' clock skew a runner process reads (child.ts): the file holds the milliseconds the clock moved, so the
|
|
30
31
|
* process's store moves with the case's (runOut). */
|
|
31
32
|
export declare const storeClockOf: (file: string | undefined) => (() => number);
|
|
@@ -86,4 +87,3 @@ export declare function registerHarnessConformance(given: ConformanceSubject, {
|
|
|
86
87
|
test: TestFunction;
|
|
87
88
|
storeUrl?: string;
|
|
88
89
|
}): void;
|
|
89
|
-
export declare const CONFORMANCE_CASES: readonly ConformanceCase[];
|
|
@@ -16,7 +16,7 @@ import { fileURLToPath } from "node:url";
|
|
|
16
16
|
import { tmpdir } from "node:os";
|
|
17
17
|
import { join } from "node:path";
|
|
18
18
|
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
19
|
-
import { dropPostgresSchema, openPostgresStore, openStore, RunFinal,
|
|
19
|
+
import { AnswerTaken, dropPostgresSchema, openPostgresStore, openStore, RunFinal, storeTarget } from "../../store/index.js";
|
|
20
20
|
import { sendCommand } from "../commands.js";
|
|
21
21
|
import { callsOf, journalRecords, messagesOf } from "../journal-reader.js";
|
|
22
22
|
import { KINDS, MESSAGE_SENT_AGAIN } from "../journal-kinds.js";
|
|
@@ -129,9 +129,6 @@ const STORE_URLS = new WeakMap();
|
|
|
129
129
|
* today. */
|
|
130
130
|
const POSTGRES_PENDING = {};
|
|
131
131
|
/** A store in a data directory of its own, one queued run, and runners started on it (each its own connection). */
|
|
132
|
-
/** The suite's short lease, for the crash cases: a crashed runner's claim must run out for the second runner to take
|
|
133
|
-
* the run over. */
|
|
134
|
-
const TAKEOVER = {};
|
|
135
132
|
/** The stores' clock skew a runner process reads (child.ts): the file holds the milliseconds the clock moved, so the
|
|
136
133
|
* process's store moves with the case's (runOut). */
|
|
137
134
|
export const storeClockOf = (file) => {
|
|
@@ -727,6 +724,8 @@ const CASES = [
|
|
|
727
724
|
assert.equal(messages.some((message) => message.text === "never"), false, "the turn did not go on");
|
|
728
725
|
// Why it stopped is on the run row, staged in the end commit: one place for every harness.
|
|
729
726
|
assert.match(row.summary ?? "", /stopped/, `the run says why it stopped: ${JSON.stringify(row.summary)}`);
|
|
727
|
+
// A person's stop, told from a cancel in the store: its turn is over, not the run (a message reopens it).
|
|
728
|
+
assert.equal(row.outcome, "stopped", `the run's outcome says a person stopped it: ${JSON.stringify(row)}`);
|
|
730
729
|
assert.ok(row.endedAt !== null, "its end commit stamped ended_at");
|
|
731
730
|
assert.ok((await w.commandRow(stop.id)).takenAt !== null, "the stop row is taken");
|
|
732
731
|
// The live timeline: one row says the person stopped it, worded the same on every harness, and nothing a person
|
|
@@ -751,8 +750,9 @@ const CASES = [
|
|
|
751
750
|
const { calls, messages } = await w.read();
|
|
752
751
|
assert.ok(calls.every((call) => call.status !== "pending"), `no call left pending: ${JSON.stringify(calls)}`);
|
|
753
752
|
assert.equal(messages.some((message) => message.text === "never"), false, "the turn did not go on");
|
|
754
|
-
// The end main's cancel writes: stopped, its summary "cancelled", staged in the end commit.
|
|
753
|
+
// The end main's cancel writes: stopped, its summary "cancelled" and its outcome 'cancelled', staged in the end commit.
|
|
755
754
|
assert.equal(row.summary, CANCELLED, `the run says it was cancelled: ${JSON.stringify(row)}`);
|
|
755
|
+
assert.equal(row.outcome, "cancelled", `the run's outcome says it was cancelled: ${JSON.stringify(row)}`);
|
|
756
756
|
const taken = await w.commandRow(cancel.id);
|
|
757
757
|
assert.ok(taken.takenAt !== null && taken.refused === null, `the cancel row is taken, not refused: ${JSON.stringify(taken)}`);
|
|
758
758
|
await assert.rejects(sendCommand(w.server, RUN, { kind: "steer", body: { text: "go on" } }), RunFinal, "a cancelled run takes no more messages");
|
|
@@ -769,6 +769,7 @@ const CASES = [
|
|
|
769
769
|
const cancel = await sendCommand(w.server, RUN, { kind: "cancel" });
|
|
770
770
|
const row = await w.ended("stopped");
|
|
771
771
|
assert.equal(row.summary, CANCELLED, `the run says it was cancelled: ${JSON.stringify(row)}`);
|
|
772
|
+
assert.equal(row.outcome, "cancelled", `the run's outcome says it was cancelled: ${JSON.stringify(row)}`);
|
|
772
773
|
assert.equal(ran.asked, 0, "the asked call never ran");
|
|
773
774
|
const taken = await w.commandRow(cancel.id);
|
|
774
775
|
assert.ok(taken.takenAt !== null && taken.refused === null, `the cancel row is taken, not refused: ${JSON.stringify(taken)}`);
|
|
@@ -787,10 +788,13 @@ const CASES = [
|
|
|
787
788
|
await sendCommand(w.server, RUN, { kind: "deny", body: { approval: callId, note: "not on a Friday" } });
|
|
788
789
|
await w.ended("ended");
|
|
789
790
|
assert.equal(ran.asked, 0, "denied, it never ran");
|
|
790
|
-
const { answers, messages } = await w.read();
|
|
791
|
+
const { answers, messages, calls } = await w.read();
|
|
791
792
|
// The fields this case is about; its time is the loop's clock's (adapter-pi-approval-entries pins it).
|
|
792
793
|
assert.deepEqual(answers.map(({ callId: id, approved, decision, note }) => ({ callId: id, approved, decision, note })), [{ callId, approved: false, decision: "deny", note: "not on a Friday" }], "the answer is a deny that keeps the note");
|
|
793
|
-
|
|
794
|
+
// What the model said after the asked call: its answer to the refusal. What it said with the call, before the gate
|
|
795
|
+
// asked (a CLI's "Calling asked."), is on the record before the call's row, as pi keeps a call's text in its message.
|
|
796
|
+
const asked = calls.find((call) => call.callId === callId);
|
|
797
|
+
const said = messages.filter((message) => message.role === "model" && message.entry > (asked?.startEntry ?? -1)).map((message) => message.text);
|
|
794
798
|
assert.equal(said.length, 1, `the model answered once: ${JSON.stringify(messages)}`);
|
|
795
799
|
// Main's words for a call a person denied (tool-gate.ts refusedText), the note with them. The harness may frame a
|
|
796
800
|
// refusal its own way (pi: a blocked call's error) around them.
|
|
@@ -872,7 +876,7 @@ const CASES = [
|
|
|
872
876
|
await w.ended("parked");
|
|
873
877
|
const callId = await w.askedCall();
|
|
874
878
|
const first = await sendCommand(w.server, RUN, { kind: "approve", body: { approval: callId } });
|
|
875
|
-
await assert.rejects(sendCommand(w.server, RUN, { kind: "approve", body: { approval: callId } }),
|
|
879
|
+
await assert.rejects(sendCommand(w.server, RUN, { kind: "approve", body: { approval: callId } }), AnswerTaken, "a second answer to one approval is never written: the store says it is answered already");
|
|
876
880
|
await w.ended("ended");
|
|
877
881
|
assert.equal(ran.asked, 1, "the call ran once");
|
|
878
882
|
assert.equal((await w.commandRow(first.id)).refused, null, "the first approve answered it");
|
|
@@ -898,7 +902,7 @@ const CASES = [
|
|
|
898
902
|
const won = settled.filter((r) => r.status === "fulfilled");
|
|
899
903
|
const lost = settled.filter((r) => r.status === "rejected");
|
|
900
904
|
assert.equal(won.length, 1, `one answer is written, not both: ${JSON.stringify(settled.map((r) => r.status))}`);
|
|
901
|
-
assert.ok(lost[0]?.reason instanceof
|
|
905
|
+
assert.ok(lost[0]?.reason instanceof AnswerTaken, `the other is refused by the store as answered already (AnswerTaken), never a bare constraint: ${String(lost[0]?.reason)}`);
|
|
902
906
|
await w.ended("ended");
|
|
903
907
|
const winner = won[0].value;
|
|
904
908
|
assert.equal(ran.asked, winner.kind === "approve" ? 1 : 0, "the run acted on the answer written, never the other");
|
|
@@ -1035,4 +1039,3 @@ export function registerHarnessConformance(given, { test, storeUrl }) {
|
|
|
1035
1039
|
test(`${subject.name}: ${entry.title}`, { timeout: CASE_TIMEOUT_MS, ...(skip ? { skip } : {}) }, (t) => entry.body(subject, t));
|
|
1036
1040
|
}
|
|
1037
1041
|
}
|
|
1038
|
-
export const CONFORMANCE_CASES = CASES.map((entry) => entry.id);
|
|
@@ -7,10 +7,15 @@ export type GithubAppAccessAt = GithubAppAccess & {
|
|
|
7
7
|
/** The GitHub App access for one claim of a run whose first input is `firstInput` (run_launch's), or undefined when this
|
|
8
8
|
* server has no App the runner can open. Its mint goes to https://api.github.com (GITHUB_API): the App's JWT, signed
|
|
9
9
|
* with its key and good for every installation, goes nowhere else. `api` is a test runner's fake GitHub, given in the
|
|
10
|
-
* runner's own options (AdapterSpecDeps.githubApi); nothing kept, no environment variable and no flag reaches it.
|
|
10
|
+
* runner's own options (AdapterSpecDeps.githubApi); nothing kept, no environment variable and no flag reaches it.
|
|
11
|
+
* `fromGitHub`: the run's first input is a github trigger's firing (its launch's inputOrigin), whose payload tag names
|
|
12
|
+
* the repository and installation; any other run's tag is never read, only its owner's words. `hold`: each token minted
|
|
13
|
+
* joins the run's redactor (its `cut`), the first and every one after. */
|
|
11
14
|
export declare function githubAppAccess(store: {
|
|
12
15
|
readonly triggerSettings: Pick<TriggerSettings, "get">;
|
|
13
|
-
}, sealKey: Buffer | undefined, firstInput: unknown, { api, now }?: {
|
|
16
|
+
}, sealKey: Buffer | undefined, firstInput: unknown, { api, now, fromGitHub, hold }?: {
|
|
14
17
|
api?: string;
|
|
15
18
|
now?: () => number;
|
|
19
|
+
fromGitHub?: boolean;
|
|
20
|
+
hold?: (values: string[]) => void;
|
|
16
21
|
}): Promise<GithubAppAccessAt | undefined>;
|