@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
|
@@ -4,8 +4,8 @@ import { type AgentEntry, type ExternalRef } from "./agents-store.js";
|
|
|
4
4
|
import { ApiError, type InputIssue } from "./errors.js";
|
|
5
5
|
import { type LearningMode, type Seed, type Shown } from "./learning.js";
|
|
6
6
|
import { type Place } from "./place.js";
|
|
7
|
-
import { type RunLaunch } from "./run-launch.js";
|
|
8
|
-
import type
|
|
7
|
+
import { type LaunchDisk, type RunLaunch } from "./run-launch.js";
|
|
8
|
+
import { type ApprovalDecision, type RunMoment } from "./run-view.js";
|
|
9
9
|
import { type NewRevision, type RunOrigin, type RunRow, type Store } from "./store/index.js";
|
|
10
10
|
import { type ToolSettingsMap } from "./tool-plane.js";
|
|
11
11
|
import type { RunTrigger } from "./triggers.js";
|
|
@@ -51,13 +51,14 @@ export type MessageMode = "steer" | "answer" | "follow_up";
|
|
|
51
51
|
* and never a deny of an approval. The mode is the label the v2 answer reports, from the run's moment. `queue`: the steer's
|
|
52
52
|
* write when it is not this run's own (a trigger's: its firing marked with it, within its bound, store.triggers.message),
|
|
53
53
|
* which may skip it, in words. */
|
|
54
|
-
export declare function message(store: RunsStore, moment: RunMoment, content: string, { requestId, answers, origin, queue }?: {
|
|
54
|
+
export declare function message(store: RunsStore, moment: RunMoment, content: string, { requestId, answers, origin, queue, launchSealed }?: {
|
|
55
55
|
requestId?: string;
|
|
56
56
|
answers?: boolean;
|
|
57
57
|
origin?: unknown;
|
|
58
58
|
queue?: (command: SteerCommand) => Promise<{
|
|
59
59
|
skipped: string;
|
|
60
60
|
} | void>;
|
|
61
|
+
launchSealed?: Uint8Array;
|
|
61
62
|
}): Promise<{
|
|
62
63
|
mode: MessageMode;
|
|
63
64
|
messageId: string;
|
|
@@ -111,8 +112,18 @@ export interface StartDeps {
|
|
|
111
112
|
/** The uploaded files named by file_ids, ready to copy; throws when one is not ready (server.ts uploads.readyFiles). The
|
|
112
113
|
* copy into the run's work/ is the runner's at its claim; this only checks they are ready before the run starts. */
|
|
113
114
|
readyFiles(ids: readonly unknown[]): Promise<unknown>;
|
|
115
|
+
/** Holds the run's files for it (uploads.ts Uploads.hold) before its row is written, so a file deleted after the start
|
|
116
|
+
* is still the run's at its claim; `release` lets go of a hold whose run was never written (or was another's). */
|
|
117
|
+
readonly files?: {
|
|
118
|
+
hold(runId: string, ids: readonly string[]): Promise<void>;
|
|
119
|
+
release(runId: string): Promise<void>;
|
|
120
|
+
};
|
|
114
121
|
/** Where a revision naming these tools and no place runs here (server.ts fallbackPlace). */
|
|
115
122
|
fallbackPlace(kind: "agentic" | "workflow", tools: readonly unknown[]): Place;
|
|
123
|
+
/** The Archil disk the run's launch record keeps (server.ts launchDiskOf): the one its body's `archil_disk` names, else
|
|
124
|
+
* its agent's when it has one now; undefined for neither, or in Mode 1. A disk named in Mode 1 is refused. Absent, no
|
|
125
|
+
* disk is kept. */
|
|
126
|
+
launchDiskOf?(agentId: string, named: string | undefined): Promise<LaunchDisk | undefined>;
|
|
116
127
|
/** A run's title from its input (server.ts workflowTitle), for a workflow run's title. */
|
|
117
128
|
workflowTitle(name: string, input: Record<string, unknown>): string;
|
|
118
129
|
/** Every secret this server never shows, for the title's redaction (server.ts serverSecrets). */
|
|
@@ -159,6 +170,8 @@ export interface StartDeps {
|
|
|
159
170
|
* it must have a cap (a trigger's), and who its first message is from when the person did not write it. */
|
|
160
171
|
export interface StartOptions {
|
|
161
172
|
readonly trigger?: RunTrigger;
|
|
173
|
+
/** The run's launch secrets, sealed for its id once it has one (the create body's mcp_auth, server.ts). */
|
|
174
|
+
readonly sealed?: (runId: string) => Uint8Array;
|
|
162
175
|
/** The run's title when its starter names one (a trigger's: "<Source> <name>"), else it is made from its input. */
|
|
163
176
|
readonly title?: string;
|
|
164
177
|
readonly origin?: RunOrigin;
|
|
@@ -170,7 +183,7 @@ export interface StartOptions {
|
|
|
170
183
|
* (store.runs.create), which a runner reads at its claim. No process, no door, no setup file: where the run runs is the
|
|
171
184
|
* runner's. Under `origin`, a key that already started a run gets that run (the store's one-run-per-key), so a retry never
|
|
172
185
|
* starts a second. */
|
|
173
|
-
export declare function startRun(store: Pick<Store, "runs" | "runOfOrigin">, deps: StartDeps, entry: AgentEntry, body: Json, { trigger, origin, capped, from, title }?: StartOptions): Promise<RunRow>;
|
|
186
|
+
export declare function startRun(store: Pick<Store, "runs" | "runOfOrigin">, deps: StartDeps, entry: AgentEntry, body: Json, { trigger, origin, capped, from, title, sealed }?: StartOptions): Promise<RunRow>;
|
|
174
187
|
/** An agent given inline (POST /runs): its reference in its source with the version, its name and description, and the
|
|
175
188
|
* revision its checked definition makes (agents-store makeRevision), not yet stored. */
|
|
176
189
|
export interface InlineAgent {
|
|
@@ -189,9 +202,7 @@ export interface InlineAgent {
|
|
|
189
202
|
* agent already mapped to the reference is the run's (its id, its learning), so a run of a later version learns from the
|
|
190
203
|
* earlier ones. A different definition under a version already run is 409 external_body_conflict, nothing written; under
|
|
191
204
|
* `origin`, a key that already started a run gets that run, as startRun's. */
|
|
192
|
-
export declare function startInline(store: Pick<Store, "runs" | "runOfOrigin" | "agents">, deps: StartDeps, inline: InlineAgent, body: Json, { origin }?:
|
|
193
|
-
origin?: RunOrigin;
|
|
194
|
-
}): Promise<RunRow>;
|
|
205
|
+
export declare function startInline(store: Pick<Store, "runs" | "runOfOrigin" | "agents">, deps: StartDeps, inline: InlineAgent, body: Json, { origin, sealed }?: Pick<StartOptions, "origin" | "sealed">): Promise<RunRow>;
|
|
195
206
|
/** A run's launch from its create body, with every check the old start made before a run started, in the same order and
|
|
196
207
|
* words: the body's fields, the revision it pins, the input against its schema, the cap rules, the plane this host
|
|
197
208
|
* resolves, whether the revision can run here; then its title, plane, model and learning start. Nothing is written: the
|
package/dist/runs-over-store.js
CHANGED
|
@@ -15,12 +15,13 @@ import { CAP_TOLERANCE, money } from "./cap.js";
|
|
|
15
15
|
import { ApiError, invalid, unsupported } from "./errors.js";
|
|
16
16
|
import { harnessOfBody } from "./harness.js";
|
|
17
17
|
import { redacted, redactedOutput } from "./key-refusal.js";
|
|
18
|
-
import { LEARNING_BUDGET, learnedParts } from "./learning.js";
|
|
18
|
+
import { chooseWorkflows, LEARNING_BUDGET, learnedParts, learnsOf } from "./learning.js";
|
|
19
19
|
import { thinkingLevel } from "./model.js";
|
|
20
20
|
import { resolvePlace } from "./place.js";
|
|
21
21
|
import { launchBody } from "./run-launch.js";
|
|
22
|
+
import { raiseFollowUpId } from "./run-view.js";
|
|
22
23
|
import { sendCommand } from "./runner/commands.js";
|
|
23
|
-
import { ExternalBodyConflict, RunFinal, StoreConstraint } from "./store/index.js";
|
|
24
|
+
import { AnswerTaken, ExternalBodyConflict, RunFinal, StoreConstraint } from "./store/index.js";
|
|
24
25
|
import { toolingOf } from "./tools.js";
|
|
25
26
|
import { planeFor } from "./tool-plane.js";
|
|
26
27
|
import { clip } from "./web-fetch-direct.js";
|
|
@@ -37,6 +38,19 @@ function importedRefusal(moment) {
|
|
|
37
38
|
next_action: { type: "request", method: "POST", path: `/agents/${moment.agentId}/runs`, caller_supplies: ["input", "Idempotency-Key"] },
|
|
38
39
|
});
|
|
39
40
|
}
|
|
41
|
+
/** An archived run, or a run of an archived agent, takes no message: archiving closes it. Said as archived, never as
|
|
42
|
+
* finished, with the way back: unarchive it (or its agent), or start a new run. */
|
|
43
|
+
function archivedRefusal(moment) {
|
|
44
|
+
const own = moment.archived === "run";
|
|
45
|
+
const why = own ? "This run is archived" : "This run's agent is archived";
|
|
46
|
+
const back = own ? `unarchive it (POST /runs/${moment.id}/unarchive)` : `unarchive the agent (POST /agents/${moment.agentId}/unarchive)`;
|
|
47
|
+
return new ApiError("not_continuable", `${why}, so it takes no message: ${back} to go on, or start a new run of the agent.`, {
|
|
48
|
+
details: { reason: "archived", archived: moment.archived },
|
|
49
|
+
next_action: own
|
|
50
|
+
? { type: "request", method: "POST", path: `/runs/${moment.id}/unarchive`, caller_supplies: [] }
|
|
51
|
+
: { type: "request", method: "POST", path: `/agents/${moment.agentId}/unarchive`, caller_supplies: [] },
|
|
52
|
+
});
|
|
53
|
+
}
|
|
40
54
|
/** A run that has ended takes no further act: start a new run (runs.ts finished). */
|
|
41
55
|
function finished(moment) {
|
|
42
56
|
const status = moment.cancelled ? "cancelled" : moment.terminalKind;
|
|
@@ -112,9 +126,12 @@ export const resume = (store, moment) => pauseOrResume(store, moment, false);
|
|
|
112
126
|
* and never a deny of an approval. The mode is the label the v2 answer reports, from the run's moment. `queue`: the steer's
|
|
113
127
|
* write when it is not this run's own (a trigger's: its firing marked with it, within its bound, store.triggers.message),
|
|
114
128
|
* which may skip it, in words. */
|
|
115
|
-
export async function message(store, moment, content, { requestId, answers = true, origin, queue } = {}) {
|
|
129
|
+
export async function message(store, moment, content, { requestId, answers = true, origin, queue, launchSealed } = {}) {
|
|
116
130
|
if (moment.importedSource !== undefined)
|
|
117
131
|
throw importedRefusal(moment);
|
|
132
|
+
// Archiving closes a run: it, or a run of its archived agent, takes no message, said as archived (never as finished).
|
|
133
|
+
if (moment.archived !== undefined)
|
|
134
|
+
throw archivedRefusal(moment);
|
|
118
135
|
// A cancelled run takes no message, whether or not its end is written yet.
|
|
119
136
|
if (moment.cancelled)
|
|
120
137
|
throw finished(moment);
|
|
@@ -129,15 +146,17 @@ export async function message(store, moment, content, { requestId, answers = tru
|
|
|
129
146
|
// approval): the message is then a message like any other, below.
|
|
130
147
|
if (answers && moment.kind === "agentic" && moment.waitingApprovalId !== undefined) {
|
|
131
148
|
const messageId = newMessageId();
|
|
132
|
-
const declined = await sendCommand(store, moment.id, { kind: "deny", body: { approval: moment.waitingApprovalId, note: content, by: "message" } }).then(() => true, (error) => {
|
|
133
|
-
if (error instanceof
|
|
149
|
+
const declined = await sendCommand(store, moment.id, { kind: "deny", body: { approval: moment.waitingApprovalId, note: content, by: "message" } }, launchSealed ? { launchSealed } : undefined).then(() => true, (error) => {
|
|
150
|
+
if (error instanceof AnswerTaken)
|
|
134
151
|
return false;
|
|
135
152
|
throw error;
|
|
136
153
|
});
|
|
137
154
|
if (declined)
|
|
138
155
|
return { mode: "answer", messageId };
|
|
139
156
|
}
|
|
140
|
-
|
|
157
|
+
// A person's message puts no check of the run's end in front of its steer: the store's reopen alone says whether an ended
|
|
158
|
+
// run opens again with it (steerOrReopen). A trigger's message to an ended run is refused here, as before.
|
|
159
|
+
if (queue && moment.terminal)
|
|
141
160
|
throw finished(moment);
|
|
142
161
|
// Paused at its cap: a message would be refused for the same room, so the cap is raised first.
|
|
143
162
|
if (moment.pausedWords !== undefined) {
|
|
@@ -153,12 +172,50 @@ export async function message(store, moment, content, { requestId, answers = tru
|
|
|
153
172
|
const queued = await queue({ kind: "steer", body });
|
|
154
173
|
return { mode, messageId, ...(queued ? { skipped: queued.skipped } : {}) };
|
|
155
174
|
}
|
|
156
|
-
await
|
|
175
|
+
await steerOrReopen(store, moment, { kind: "steer", body }, launchSealed);
|
|
157
176
|
return { mode, messageId };
|
|
158
177
|
}
|
|
159
|
-
/** The
|
|
178
|
+
/** The message's steer row: one door. A run the store holds final takes no new row (RunFinal); the message then goes
|
|
179
|
+
* through runs.reopen, which opens the run again with the steer in one transaction when the store says it may
|
|
180
|
+
* (reopenableWhere: an agentic run that completed, or that a person stopped, as the console offers a follow-up to both).
|
|
181
|
+
* Any other (cancelled, failed, a workflow's, an imported or a learning run) answers 409 finished, nothing written. */
|
|
182
|
+
async function steerOrReopen(store, moment, command, launchSealed) {
|
|
183
|
+
// The message's launch secrets (its mcp_auth, sealed) ride in the same write as its steer, whichever door takes it.
|
|
184
|
+
const sealed = launchSealed ? { launchSealed } : undefined;
|
|
185
|
+
try {
|
|
186
|
+
await sendCommand(store, moment.id, command, sealed);
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
if (!(error instanceof RunFinal))
|
|
190
|
+
throw error;
|
|
191
|
+
try {
|
|
192
|
+
await store.runs.reopen(moment.id, command, sealed);
|
|
193
|
+
}
|
|
194
|
+
catch (again) {
|
|
195
|
+
if (!(again instanceof RunFinal))
|
|
196
|
+
throw again;
|
|
197
|
+
// Refused: another message may have opened the run again meanwhile, so the steer is sent once more, to the run now
|
|
198
|
+
// running. Refused that too, the run takes no message.
|
|
199
|
+
try {
|
|
200
|
+
await sendCommand(store, moment.id, command, sealed);
|
|
201
|
+
}
|
|
202
|
+
catch (last) {
|
|
203
|
+
if (!(last instanceof RunFinal))
|
|
204
|
+
throw last;
|
|
205
|
+
// Worded by the run's end as the store holds it now: the moment may have been read before that end (a race).
|
|
206
|
+
const state = (await store.runs.get(moment.id))?.state;
|
|
207
|
+
const terminalKind = state === "failed" ? "failed" : state === "stopped" ? "cancelled" : "completed";
|
|
208
|
+
throw finished({ ...moment, terminal: true, terminalKind });
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/** The raise command rows this run already has, newest last: the cap each names, and whether its runner has taken it. */
|
|
160
214
|
async function raiseRows(store, runId) {
|
|
161
|
-
return (await store.commands(runId, 0))
|
|
215
|
+
return (await store.commands(runId, 0))
|
|
216
|
+
.filter((c) => c.kind === "raise")
|
|
217
|
+
.map((c) => ({ capUsd: Number(c.body?.capUsd), taken: c.takenAt !== null }))
|
|
218
|
+
.filter((row) => Number.isFinite(row.capUsd));
|
|
162
219
|
}
|
|
163
220
|
/** Raises the cap of an agentic or workflow run that names one, to `cap`: above its own (by more than CAP_TOLERANCE), or the
|
|
164
221
|
* same as its newest raise (a retry, which changes nothing). A raise command row the run's runner reads: it resumes a run
|
|
@@ -174,9 +231,15 @@ export async function raiseCap(store, moment, cap) {
|
|
|
174
231
|
throw invalid([{ field: "max_cost_usd", reason: "not_allowed", message: "This run has no cap to raise: a cap is named when a run starts." }]);
|
|
175
232
|
const raises = await raiseRows(store, moment.id);
|
|
176
233
|
const last = raises.at(-1);
|
|
177
|
-
//
|
|
178
|
-
|
|
179
|
-
|
|
234
|
+
// An agentic run paused at its cap goes on with one follow-up turn the runner sends under its pause's id
|
|
235
|
+
// (raiseFollowUpId): the answer names it, so every raise of this pause (a retry, two sent at once) names the same message.
|
|
236
|
+
// A workflow run sends none (the step that waits is judged again), so its answer names no message.
|
|
237
|
+
const resumed = () => ({ resumed: true, ...(moment.kind === "agentic" && moment.pause !== undefined ? { messageId: raiseFollowUpId(moment.pause) } : {}) });
|
|
238
|
+
// The same raise again (a retry): what the first one did stands, no second row. It resumes the run only while that raise
|
|
239
|
+
// is still on its way (its row untaken): once taken, a pause the run stands at now is a new one, under the raised cap,
|
|
240
|
+
// which this retry does not raise (it answers resumed false, and the run stays paused).
|
|
241
|
+
if (Math.abs(cap - from) <= CAP_TOLERANCE && last !== undefined && Math.abs(last.capUsd - cap) <= CAP_TOLERANCE) {
|
|
242
|
+
return moment.paused && !last.taken ? resumed() : { resumed: false };
|
|
180
243
|
}
|
|
181
244
|
if (!(cap > from + CAP_TOLERANCE))
|
|
182
245
|
throw invalid([{ field: "max_cost_usd", reason: "invalid", message: `A cap is only raised: name more than the run's ${money(from)}.` }]);
|
|
@@ -193,7 +256,7 @@ export async function raiseCap(store, moment, cap) {
|
|
|
193
256
|
}
|
|
194
257
|
// A run paused at its cap is brought back by the raise (its runner claims it and sends its continuation).
|
|
195
258
|
if (moment.paused)
|
|
196
|
-
return
|
|
259
|
+
return resumed();
|
|
197
260
|
// A run its runner holds takes the raise as its next command: its next step is admitted under the raised cap (the
|
|
198
261
|
// runner's loop holds the run to its newest raise), and a step already under way keeps the cap it was admitted at.
|
|
199
262
|
return { resumed: false, ...(moment.live ? { note: `The ${money(cap)} cap holds from the run's next step; a step already under way keeps the ${money(from)} cap it was admitted at.` } : {}) };
|
|
@@ -209,7 +272,7 @@ function alreadyAnswered(id, decision, ended = false) {
|
|
|
209
272
|
* run could not resume) answers nothing, so the person may answer again. */
|
|
210
273
|
async function sentAnswer(store, runId, id) {
|
|
211
274
|
const row = (await store.commands(runId, 0)).find((command) => (command.kind === "approve" || command.kind === "deny") && command.refused === null && isObject(command.body) && command.body.approval === id);
|
|
212
|
-
return row && { decision: row.kind === "approve" ? "allow" : "deny" };
|
|
275
|
+
return row && { decision: row.kind === "approve" ? "allow" : "deny", at: row.id };
|
|
213
276
|
}
|
|
214
277
|
/** How a stop or cancel written to run `runId` before `before` (a command id; absent, any) answers every call still waiting:
|
|
215
278
|
* the runner reads commands in the order they were written, so it applies the stop first and withdraws (or, on a cancel,
|
|
@@ -232,9 +295,18 @@ export async function approve(store, moment, id, decision, note) {
|
|
|
232
295
|
if (given.decision !== decision)
|
|
233
296
|
throw alreadyAnswered(id, given.decision, given.ended === true);
|
|
234
297
|
};
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
298
|
+
const answered = moment.answeredApprovals?.[id];
|
|
299
|
+
if (answered)
|
|
300
|
+
return settle(answered);
|
|
301
|
+
const given = await sentAnswer(store, moment.id, id);
|
|
302
|
+
if (given) {
|
|
303
|
+
// The answer written before (this one's retry, or another) sits behind a stop or cancel the runner has not taken yet:
|
|
304
|
+
// it never runs, so it is told as any answer behind that stop is, never settled as taken.
|
|
305
|
+
const behind = await endBefore(store, moment.id, { before: given.at });
|
|
306
|
+
if (behind)
|
|
307
|
+
throw alreadyAnswered(id, behind.decision);
|
|
237
308
|
return settle(given);
|
|
309
|
+
}
|
|
238
310
|
if (!(moment.approvalIds?.has(id) ?? false))
|
|
239
311
|
throw new ApiError("not_found", `The run ${moment.id} has no tool call ${id} waiting for approval.`);
|
|
240
312
|
const ending = await endBefore(store, moment.id);
|
|
@@ -252,7 +324,8 @@ export async function approve(store, moment, id, decision, note) {
|
|
|
252
324
|
const end = await endBefore(store, moment.id, { taken: true });
|
|
253
325
|
throw alreadyAnswered(id, end?.decision ?? "withdrawn", end === undefined);
|
|
254
326
|
}
|
|
255
|
-
|
|
327
|
+
// Lost to an answer written first (the store's AnswerTaken, from its one-answer index alone): read the winner.
|
|
328
|
+
const won = error instanceof AnswerTaken ? await sentAnswer(store, moment.id, id) : undefined;
|
|
256
329
|
if (!won)
|
|
257
330
|
throw error;
|
|
258
331
|
return settle(won);
|
|
@@ -262,6 +335,14 @@ export async function approve(store, moment, id, decision, note) {
|
|
|
262
335
|
const raced = await endBefore(store, moment.id, { before: sent.id });
|
|
263
336
|
if (raced)
|
|
264
337
|
throw alreadyAnswered(id, raced.decision);
|
|
338
|
+
// That stop's end may already be written by this read: its runner took the stop and refused this answer in the same
|
|
339
|
+
// commit. Read the answer back: refused behind a stop or cancel, it never runs either.
|
|
340
|
+
const mine = (await store.commands(moment.id, 0)).find((command) => command.id === sent.id);
|
|
341
|
+
if (mine?.refused != null) {
|
|
342
|
+
const end = await endBefore(store, moment.id, { before: sent.id, taken: true });
|
|
343
|
+
if (end)
|
|
344
|
+
throw alreadyAnswered(id, end.decision);
|
|
345
|
+
}
|
|
265
346
|
}
|
|
266
347
|
// ---- start -----------------------------------------------------------------------------------------------------------
|
|
267
348
|
/** A UUIDv7 run id: time-ordered, so a listing by start time is stable, and unique per run. */
|
|
@@ -281,7 +362,9 @@ const noShown = { text: (text) => text, name: (name) => name, holds: () => false
|
|
|
281
362
|
* from and the count of all the seed's notes before the budget picked `given` (seedNotes) — or given empty, seed null and no
|
|
282
363
|
* seedNotes when its seed cannot be read (a learning fault never refuses a run). */
|
|
283
364
|
async function learningStartFor(deps, entry, revision, rbody, input) {
|
|
284
|
-
const learns = deps.learning !== undefined && deps.learning !== "off" && revision.kind === "agentic" && rbody.learning
|
|
365
|
+
const learns = deps.learning !== undefined && deps.learning !== "off" && revision.kind === "agentic" && learnsOf(rbody.learning);
|
|
366
|
+
// `learning: "notes"`: its notes and skills, never a learned workflow (none offered, none asked for at its end).
|
|
367
|
+
const notesOnly = rbody.learning === "notes" ? { notesOnly: true } : {};
|
|
285
368
|
if (!learns || !deps.seedFor)
|
|
286
369
|
return undefined;
|
|
287
370
|
const grade = deps.gradeModel ? { gradeModel: deps.gradeModel } : {};
|
|
@@ -289,7 +372,7 @@ async function learningStartFor(deps, entry, revision, rbody, input) {
|
|
|
289
372
|
// The folder could not be read (main's STOPPED.unreadable), or what it read could not be made into the start (main's
|
|
290
373
|
// copy that threw, STOPPED.notCopied): the run starts with nothing learned, and its learning end says which.
|
|
291
374
|
if (!("seed" in seeded))
|
|
292
|
-
return { given: [], seed: null, section: "", seedFailed: "unreadable", ...grade };
|
|
375
|
+
return { given: [], seed: null, section: "", seedFailed: "unreadable", ...notesOnly, ...grade };
|
|
293
376
|
try {
|
|
294
377
|
// The run's input goes to the note selector (learning.ts NoteSelector; byRelevance, the default, scores the notes by it).
|
|
295
378
|
const options = { budget: deps.learningBudget ?? LEARNING_BUDGET, read: Array.isArray(rbody.tools) && rbody.tools.includes("read"), shown: deps.shown ? deps.shown() : noShown, run: { input } };
|
|
@@ -301,10 +384,13 @@ async function learningStartFor(deps, entry, revision, rbody, input) {
|
|
|
301
384
|
// by its size and never laid) and no host secret in it, as chooseSkills leaves them out. The claim lays them; the
|
|
302
385
|
// end-of-run turn counts the runs each served (runner/learning-end.ts draftForOf).
|
|
303
386
|
const skills = (seeded.seed.skills ?? []).flatMap(({ name, files }) => (files && !options.shown.holds(name) && !Object.entries(files).some(([path, text]) => options.shown.holds(path) || options.shown.holds(text)) ? [name] : []));
|
|
304
|
-
|
|
387
|
+
// The learned workflows its learned_workflow tool runs, by name, as the claim chooses them (chooseWorkflows): what the
|
|
388
|
+
// agent's impact counts a run as started from, beside its notes and skills.
|
|
389
|
+
const workflows = notesOnly.notesOnly ? [] : chooseWorkflows(seeded.seed, options.shown).flows.map(({ name }) => name);
|
|
390
|
+
return { given: given.map(({ file, name }) => ({ file, name })), seed: seeded.seed.sha, section: section ?? "", seedNotes: Object.keys(seeded.seed.notes).length, ...(skills.length ? { skills } : {}), ...(workflows.length ? { workflows } : {}), ...notesOnly, ...grade };
|
|
305
391
|
}
|
|
306
392
|
catch {
|
|
307
|
-
return { given: [], seed: null, section: "", seedFailed: "not_copied", ...grade };
|
|
393
|
+
return { given: [], seed: null, section: "", seedFailed: "not_copied", ...notesOnly, ...grade };
|
|
308
394
|
}
|
|
309
395
|
}
|
|
310
396
|
/** Starts a run of `entry`'s agent from a create body, as POST /agents/{id}/runs starts it: every check the old start made
|
|
@@ -312,11 +398,11 @@ async function learningStartFor(deps, entry, revision, rbody, input) {
|
|
|
312
398
|
* (store.runs.create), which a runner reads at its claim. No process, no door, no setup file: where the run runs is the
|
|
313
399
|
* runner's. Under `origin`, a key that already started a run gets that run (the store's one-run-per-key), so a retry never
|
|
314
400
|
* starts a second. */
|
|
315
|
-
export async function startRun(store, deps, entry, body, { trigger, origin, capped = false, from, title } = {}) {
|
|
401
|
+
export async function startRun(store, deps, entry, body, { trigger, origin, capped = false, from, title, sealed } = {}) {
|
|
316
402
|
const { launch, revision } = await prepareLaunch(deps, entry, body, { ...(trigger ? { trigger } : {}), capped, ...(from ? { from } : {}), ...(title !== undefined ? { title } : {}) });
|
|
317
403
|
const runId = (deps.newRunId ?? uuidv7)();
|
|
318
404
|
try {
|
|
319
|
-
return await store.runs.create({ id: runId, agentId: entry.agent.id, revisionId: revision.id, ...(origin ? { origin } : {}) }, { body: launchBody(launch) });
|
|
405
|
+
return await withHeldFiles(deps, runId, launch, () => store.runs.create({ id: runId, agentId: entry.agent.id, revisionId: revision.id, ...(origin ? { origin } : {}) }, { body: launchBody(launch), ...(sealed ? { sealed: sealed(runId) } : {}) }));
|
|
320
406
|
}
|
|
321
407
|
catch (error) {
|
|
322
408
|
// Only another writer of the store got here first under the same origin key: its run is the one asked for.
|
|
@@ -329,31 +415,56 @@ export async function startRun(store, deps, entry, body, { trigger, origin, capp
|
|
|
329
415
|
throw error;
|
|
330
416
|
}
|
|
331
417
|
}
|
|
418
|
+
/** Writes run `runId` with `write`, its files (launch.files) held for it first (StartDeps.files): a hold that fails part
|
|
419
|
+
* way, a write that fails, or one that answers another run (an origin key's run started before), lets go of the hold. */
|
|
420
|
+
async function withHeldFiles(deps, runId, launch, write) {
|
|
421
|
+
const ids = launch.files ?? [];
|
|
422
|
+
if (!ids.length || !deps.files)
|
|
423
|
+
return await write();
|
|
424
|
+
try {
|
|
425
|
+
await deps.files.hold(runId, ids);
|
|
426
|
+
const row = await write();
|
|
427
|
+
if (row.id !== runId)
|
|
428
|
+
await deps.files.release(runId);
|
|
429
|
+
return row;
|
|
430
|
+
}
|
|
431
|
+
catch (error) {
|
|
432
|
+
await deps.files.release(runId).catch(() => undefined);
|
|
433
|
+
throw error;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
332
436
|
/** Starts a run of an agent given inline, as POST /agents/{id}/runs starts a run of a stored one: the same checks over the
|
|
333
437
|
* revision the definition makes (prepareLaunch), then ONE transaction (store.runs.createInline) that writes the agent on
|
|
334
438
|
* its reference's first run and the revision on its version's first run, or reads them, then the run and its launch. The
|
|
335
439
|
* agent already mapped to the reference is the run's (its id, its learning), so a run of a later version learns from the
|
|
336
440
|
* earlier ones. A different definition under a version already run is 409 external_body_conflict, nothing written; under
|
|
337
441
|
* `origin`, a key that already started a run gets that run, as startRun's. */
|
|
338
|
-
export async function startInline(store, deps, inline, body, { origin } = {}) {
|
|
442
|
+
export async function startInline(store, deps, inline, body, { origin, sealed } = {}) {
|
|
339
443
|
const { external, revision } = inline;
|
|
340
444
|
const ref = externalKey(external);
|
|
341
445
|
const mapped = await store.agents.byExternal(ref);
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
446
|
+
const stored = mapped ? await getAgent(store, mapped.id) : null;
|
|
447
|
+
// A version's first run brings the agent's name and description up to it, in the start's own transaction (createInline),
|
|
448
|
+
// so its launch is prepared under them: a workflow run's title names the version it runs. A run of a version already
|
|
449
|
+
// stored keeps the agent's as they are, as a run of any agent's earlier revision does.
|
|
450
|
+
const firstOfVersion = !stored || !(await store.agents.hasExternalVersion(stored.agent.id, external.version));
|
|
451
|
+
const entry = stored
|
|
452
|
+
? firstOfVersion ? { ...stored, agent: { ...stored.agent, name: inline.name, description: inline.description } } : stored
|
|
453
|
+
: {
|
|
454
|
+
agent: { id: uuidv7(), name: inline.name, description: inline.description, currentRevision: null, createdAt: Date.now(), archivedAt: null, externalRef: ref },
|
|
455
|
+
revision: null, version: 0, revisions: 0, sizes: new Map(),
|
|
456
|
+
};
|
|
346
457
|
// A store revision is the revision the run path reads as a pi Revision (its body is the revision body), as pinnedOf hands
|
|
347
458
|
// one across.
|
|
348
459
|
const { launch } = await prepareLaunch(deps, entry, body, { revision: revision });
|
|
349
460
|
const runId = (deps.newRunId ?? uuidv7)();
|
|
350
461
|
try {
|
|
351
|
-
return await store.runs.createInline({
|
|
462
|
+
return await withHeldFiles(deps, runId, launch, () => store.runs.createInline({
|
|
352
463
|
agent: { id: entry.agent.id, name: inline.name, description: inline.description, ref },
|
|
353
464
|
revision: { id: revision.id, version: external.version, kind: revision.kind, body: revision.body, skills: revision.skills, ...(revision.note !== undefined ? { note: revision.note } : {}) },
|
|
354
465
|
run: { id: runId, ...(origin ? { origin } : {}) },
|
|
355
|
-
launch: { body: launchBody(launch) },
|
|
356
|
-
});
|
|
466
|
+
launch: { body: launchBody(launch), ...(sealed ? { sealed: sealed(runId) } : {}) },
|
|
467
|
+
}));
|
|
357
468
|
}
|
|
358
469
|
catch (error) {
|
|
359
470
|
if (error instanceof ExternalBodyConflict) {
|
|
@@ -426,6 +537,12 @@ export async function prepareLaunch(deps, entry, body, { trigger, capped = false
|
|
|
426
537
|
// the one decision) are pinned in the launch for the runner to put in the prompt. A seed that cannot be read starts it with
|
|
427
538
|
// nothing (given empty, seed null); the end state is the runner's.
|
|
428
539
|
const learning = await learningStartFor(deps, entry, revision, rbody, input);
|
|
540
|
+
// The run's Archil disk, chosen now and kept in its launch (run-launch.ts archilDisk): the one the body names (a disk per
|
|
541
|
+
// customer), else its agent's when it has one; with neither, its claim makes the agent's.
|
|
542
|
+
const named = isObject(body.archil_disk) && typeof body.archil_disk.disk_id === "string" ? body.archil_disk.disk_id : undefined;
|
|
543
|
+
if (named !== undefined && !deps.launchDiskOf)
|
|
544
|
+
throw invalid([{ field: "archil_disk", reason: "not_allowed", message: "This server keeps no run on an Archil disk." }]);
|
|
545
|
+
const archilDisk = deps.launchDiskOf ? await deps.launchDiskOf(entry.agent.id, named) : undefined;
|
|
429
546
|
// The run's effort: its own, else its revision's saved thinking, else the host's AGENT_THINKING (each a thinking level,
|
|
430
547
|
// else none). Nothing set: none, so the run gets no effort note and its harness's own default. Kept in its launch, so
|
|
431
548
|
// its harness's thinking, its guidance and its metrics all read the one value.
|
|
@@ -448,6 +565,7 @@ export async function prepareLaunch(deps, entry, body, { trigger, capped = false
|
|
|
448
565
|
...(trigger ? { trigger } : {}),
|
|
449
566
|
...(from ? { inputOrigin: from } : {}),
|
|
450
567
|
...(model ? { model } : {}),
|
|
568
|
+
...(archilDisk ? { archilDisk } : {}),
|
|
451
569
|
};
|
|
452
570
|
return { launch, revision };
|
|
453
571
|
}
|
package/dist/seal-key.d.ts
CHANGED
|
@@ -26,8 +26,6 @@ export type SealKey = {
|
|
|
26
26
|
export type BootedSealKey = SealKey & {
|
|
27
27
|
readonly release: () => void;
|
|
28
28
|
};
|
|
29
|
-
/** Where the data directory `dataDir` keeps its seal key. */
|
|
30
|
-
export declare const sealKeyPath: (dataDir: string) => string;
|
|
31
29
|
/** The key file's rules alone, with no store to check against: `given` (AGENTRUN_SEAL_KEY as it was handed) when set,
|
|
32
30
|
* else the one kept in `dataDir`, made there when there is none. A start never calls this by itself: bootSealKey checks
|
|
33
31
|
* the key against the store first, and makes one only for a store that holds no secret. */
|
package/dist/seal-key.js
CHANGED
|
@@ -38,8 +38,6 @@ export class SealKeyRefused extends Error {
|
|
|
38
38
|
export class SealKeyNotTheStores extends SealKeyRefused {
|
|
39
39
|
name = "SealKeyNotTheStores";
|
|
40
40
|
}
|
|
41
|
-
/** Where the data directory `dataDir` keeps its seal key. */
|
|
42
|
-
export const sealKeyPath = (dataDir) => join(dataDir, SEAL_KEY_DIR, SEAL_KEY_FILE);
|
|
43
41
|
const HOW = `Hand the server ${SEAL_KEY_ENV} (32 random bytes in base64, e.g. \`openssl rand -base64 32\`), or let it keep one in ${SEAL_KEY_DIR}/${SEAL_KEY_FILE} in its data directory, made at the first start.`;
|
|
44
42
|
const refused = (why) => new SealKeyRefused(`No seal key: ${why}. ${HOW}`);
|
|
45
43
|
function lstatOf(path) {
|
package/dist/sealing.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
// AES-256-GCM sealing, the one primitive every secret this server keeps at rest is sealed with (
|
|
2
|
-
// @parcha/pi-durable-agent's vault.ts): the store's sealed columns (store/seal.ts), the
|
|
1
|
+
// AES-256-GCM sealing, the one primitive every secret this server keeps at rest is sealed with (the store's sealed columns (store/seal.ts), the
|
|
3
2
|
// trigger settings, the outbound webhook's secret, and what a runner opens under the server's seal key.
|
|
4
3
|
import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
|
|
5
4
|
const IV_BYTES = 12;
|
package/dist/secret-cut.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { keyShaped } from "./secret-name.js";
|
|
2
2
|
/** Whether a name is a secret's, whatever list names it or none does: one of its `_`-separated segments, in any case, is
|
|
3
3
|
* KEY, TOKEN, SECRET, PASSWORD, PASSWD, PASS, PAT, CREDENTIAL, CREDENTIALS or DSN, or its last is PWD after another.
|
|
4
|
-
* The one rule
|
|
4
|
+
* The one rule: this cut, the harness log's and a run's environment (secrets.ts' withoutSecrets)
|
|
5
5
|
* take it, so what one leaves out the others do. */
|
|
6
6
|
export { keyShaped };
|
|
7
7
|
export declare const REDACTED = "[redacted]";
|
package/dist/secret-cut.js
CHANGED
|
@@ -9,7 +9,7 @@ secretLintProfiler.setEnabled(false);
|
|
|
9
9
|
import { keyShaped } from "./secret-name.js";
|
|
10
10
|
/** Whether a name is a secret's, whatever list names it or none does: one of its `_`-separated segments, in any case, is
|
|
11
11
|
* KEY, TOKEN, SECRET, PASSWORD, PASSWD, PASS, PAT, CREDENTIAL, CREDENTIALS or DSN, or its last is PWD after another.
|
|
12
|
-
* The one rule
|
|
12
|
+
* The one rule: this cut, the harness log's and a run's environment (secrets.ts' withoutSecrets)
|
|
13
13
|
* take it, so what one leaves out the others do. */
|
|
14
14
|
export { keyShaped };
|
|
15
15
|
export const REDACTED = "[redacted]";
|
package/dist/server-lock.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
// One server per data root, written for AgentRun. A server takes <data>/server.lock
|
|
2
|
-
//
|
|
1
|
+
// One server per data root, written for AgentRun. A server takes <data>/server.lock once it holds its store (server.ts
|
|
2
|
+
// dataRootLock), and holds it until it closes; a second server on the same root is refused by name. The store's owner
|
|
3
|
+
// lock holds one store; this one holds the data root beside it (the token, the seal key, uploads, harness installs), which
|
|
4
|
+
// two servers on two stores (two Postgres schemas, or SQLite and Postgres) would otherwise share.
|
|
3
5
|
//
|
|
4
6
|
// The lock is SQLite's EXCLUSIVE lock, as a run's store holds it: held on one connection for the server's life,
|
|
5
7
|
// dropped by the kernel when the process dies (a crashed server's file is reused by the next start, never refused for
|
|
6
8
|
// existing), and refused to a second connection whether it is in another process or in this one. The file is opened by
|
|
7
9
|
// SQLite alone: a POSIX lock is dropped when any descriptor the process holds on the file is closed, so no other code
|
|
8
10
|
// may open it (its mode is set by path).
|
|
9
|
-
//
|
|
10
|
-
// pi-durable-disk forgets a command record written in another pid namespace only under the precondition this lock
|
|
11
|
-
// keeps: two servers never hold one data root at once.
|
|
12
11
|
import { chmodSync } from "node:fs";
|
|
13
12
|
import { join } from "node:path";
|
|
14
13
|
import { DatabaseSync } from "node:sqlite";
|