@parcha/agentrun-serve 0.1.0-beta.35 → 0.1.0-beta.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +298 -0
- package/README.md +417 -219
- package/dist/adapters.d.ts +12 -2
- package/dist/adapters.js +27 -2
- package/dist/agent-rows.d.ts +2 -1
- package/dist/agents-store.d.ts +2 -0
- package/dist/agents-store.js +9 -4
- package/dist/api-only.d.ts +2 -1
- package/dist/api-only.js +3 -1
- package/dist/archil-routes.d.ts +40 -7
- package/dist/archil-routes.js +167 -54
- package/dist/archil-settings.d.ts +79 -7
- package/dist/archil-settings.js +140 -14
- package/dist/attach-conformance-cli.d.ts +1 -0
- package/dist/attach-conformance-cli.js +18 -0
- package/dist/attach-conformance.d.ts +25 -0
- package/dist/attach-conformance.js +343 -0
- package/dist/attach-images.d.ts +15 -0
- package/dist/attach-images.js +59 -0
- package/dist/background.d.ts +0 -6
- package/dist/background.js +0 -28
- package/dist/box-image.d.ts +1 -97
- package/dist/box-image.js +4 -284
- package/dist/box-paths.d.ts +2 -7
- package/dist/box-paths.js +7 -13
- package/dist/box-settings.d.ts +0 -11
- package/dist/box-settings.js +4 -29
- package/dist/browser-commands.js +1 -1
- package/dist/browser-computer.d.ts +47 -3
- package/dist/browser-computer.js +286 -18
- package/dist/browser-cost.d.ts +1 -1
- package/dist/browser-live.d.ts +20 -8
- package/dist/browser-live.js +50 -27
- package/dist/browser-person.d.ts +19 -2
- package/dist/browser-person.js +55 -6
- package/dist/browser-wait-ended.d.ts +23 -0
- package/dist/browser-wait-ended.js +42 -0
- package/dist/cap.d.ts +12 -57
- package/dist/cap.js +20 -160
- package/dist/catalog.d.ts +1 -12
- package/dist/catalog.js +3 -33
- package/dist/cli.js +17 -26
- package/dist/composio-preset.d.ts +36 -0
- package/dist/composio-preset.js +179 -0
- package/dist/computer-attach.d.ts +125 -0
- package/dist/computer-attach.js +330 -0
- package/dist/computer-calls.d.ts +48 -0
- package/dist/computer-calls.js +126 -0
- package/dist/computer-channel.d.ts +57 -0
- package/dist/computer-channel.js +115 -0
- package/dist/computer-commands.d.ts +1 -1
- package/dist/computer-held-routes.d.ts +35 -0
- package/dist/computer-held-routes.js +106 -0
- package/dist/computer-held.d.ts +48 -0
- package/dist/computer-held.js +87 -0
- package/dist/computer-keys.d.ts +21 -1
- package/dist/computer-keys.js +53 -11
- package/dist/computer-live.d.ts +160 -0
- package/dist/computer-live.js +643 -0
- package/dist/computer-routes.d.ts +1 -4
- package/dist/computer-routes.js +3 -5
- package/dist/computer-setting.d.ts +2 -0
- package/dist/computer-setting.js +38 -1
- package/dist/computer-view.d.ts +24 -2
- package/dist/computer-view.js +51 -3
- package/dist/computer-viewer.d.ts +6 -0
- package/dist/computer-viewer.js +297 -0
- package/dist/computers.d.ts +79 -12
- package/dist/computers.js +147 -28
- package/dist/console/assets/index-Cn6JX1uH.js +563 -0
- package/dist/console/assets/index-DRN62V5v.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/docker-daemon.d.ts +2 -2
- package/dist/docker-daemon.js +2 -2
- package/dist/errors.js +5 -5
- package/dist/faux-computers.d.ts +9 -20
- package/dist/faux-computers.js +56 -24
- package/dist/files.d.ts +1 -9
- package/dist/files.js +1 -9
- package/dist/github-connection.d.ts +10 -2
- package/dist/github-connection.js +65 -2
- package/dist/github-faux.js +1 -1
- package/dist/github.d.ts +22 -2
- package/dist/github.js +42 -8
- package/dist/gpu-words.d.ts +14 -0
- package/dist/gpu-words.js +21 -0
- package/dist/graph-view.d.ts +3 -1
- package/dist/graph-view.js +25 -1
- package/dist/handed-values.d.ts +1 -1
- package/dist/handed-values.js +1 -1
- package/dist/harness-install.d.ts +60 -3
- package/dist/harness-install.js +322 -34
- package/dist/harness.d.ts +1 -0
- package/dist/harness.js +36 -2
- package/dist/host-tools.d.ts +9 -10
- package/dist/host-tools.js +7 -7
- package/dist/hosted-search.d.ts +5 -4
- package/dist/hosted-search.js +2 -7
- package/dist/import-sources.d.ts +10 -0
- package/dist/import-sources.js +44 -2
- package/dist/import.d.ts +3 -3
- package/dist/import.js +37 -6
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -2
- package/dist/key-refusal.d.ts +1 -1
- package/dist/key-refusal.js +2 -2
- package/dist/learn/check.d.ts +11 -2
- package/dist/learn/check.js +124 -6
- package/dist/learn/commit.d.ts +43 -7
- package/dist/learn/commit.js +166 -22
- package/dist/learn/folder.d.ts +11 -0
- package/dist/learn/folder.js +37 -1
- package/dist/learn/general.d.ts +66 -0
- package/dist/learn/general.js +73 -0
- package/dist/learn/grade.d.ts +22 -1
- package/dist/learn/grade.js +107 -16
- package/dist/learn/index.d.ts +1 -1
- package/dist/learn/index.js +1 -1
- package/dist/learn/learning.sh +12 -1
- package/dist/learn/notes.d.ts +3 -0
- package/dist/learn/notes.js +3 -0
- package/dist/learn/reflect.d.ts +14 -2
- package/dist/learn/reflect.js +54 -30
- package/dist/learn/skills.d.ts +37 -5
- package/dist/learn/skills.js +60 -7
- package/dist/learned-nodes.d.ts +6 -2
- package/dist/learned-workflow.d.ts +43 -9
- package/dist/learned-workflow.js +128 -37
- package/dist/learning-batch.d.ts +283 -0
- package/dist/learning-batch.js +574 -0
- package/dist/learning-cost.d.ts +79 -0
- package/dist/learning-cost.js +69 -0
- package/dist/learning-evals.d.ts +33 -0
- package/dist/learning-evals.js +98 -0
- package/dist/learning-routes.d.ts +32 -4
- package/dist/learning-routes.js +48 -12
- package/dist/learning-words.d.ts +9 -0
- package/dist/learning-words.js +12 -2
- package/dist/learning.d.ts +39 -19
- package/dist/learning.js +88 -46
- package/dist/live/stream.js +6 -3
- package/dist/live/translate.d.ts +4 -3
- package/dist/live/translate.js +8 -4
- package/dist/live-reach.d.ts +37 -0
- package/dist/live-reach.js +62 -0
- package/dist/mcp-gateway.d.ts +9 -0
- package/dist/mcp-gateway.js +60 -11
- package/dist/mcp-oauth.d.ts +57 -7
- package/dist/mcp-oauth.js +133 -18
- package/dist/mcp-private-hosts.d.ts +4 -4
- package/dist/mcp-private-hosts.js +20 -12
- package/dist/mcp-probe.d.ts +27 -3
- package/dist/mcp-probe.js +106 -29
- package/dist/mcp-secret-writes.js +8 -0
- package/dist/mcp-servers-store.d.ts +38 -15
- package/dist/mcp-servers-store.js +120 -23
- package/dist/mcp-store.d.ts +10 -4
- package/dist/mcp-store.js +17 -6
- package/dist/model-form.d.ts +26 -0
- package/dist/model-form.js +80 -0
- package/dist/model.d.ts +5 -5
- package/dist/model.js +29 -16
- package/dist/openapi.d.ts +2 -0
- package/dist/openapi.js +586 -64
- package/dist/owner.d.ts +0 -1
- package/dist/owner.js +0 -2
- package/dist/page.d.ts +18 -0
- package/dist/page.js +48 -20
- package/dist/paid-calls.d.ts +1 -1
- package/dist/paid-calls.js +1 -1
- package/dist/place-offers.d.ts +96 -0
- package/dist/place-offers.js +202 -0
- package/dist/place.d.ts +9 -13
- package/dist/place.js +21 -32
- package/dist/port-models.d.ts +2 -1
- package/dist/port-models.js +5 -3
- package/dist/print.d.ts +16 -9
- package/dist/print.js +15 -17
- package/dist/propose.d.ts +4 -0
- package/dist/propose.js +34 -11
- package/dist/provider.js +3 -2
- package/dist/reflect-range.d.ts +8 -1
- package/dist/reflect-range.js +1 -1
- package/dist/run-cut.d.ts +5 -0
- package/dist/run-cut.js +19 -0
- package/dist/run-launch.d.ts +28 -3
- package/dist/run-launch.js +14 -4
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-manifest.d.ts +2 -2
- package/dist/run-manifest.js +2 -2
- package/dist/run-reads-over-store.d.ts +1 -1
- package/dist/run-repo.d.ts +20 -0
- package/dist/run-repo.js +63 -0
- package/dist/run-secrets.js +3 -3
- package/dist/run-timeline-served.d.ts +1 -1
- package/dist/run-timeline-served.js +56 -44
- package/dist/run-view.d.ts +8 -5
- package/dist/run-view.js +18 -10
- package/dist/runnable.d.ts +2 -2
- package/dist/runnable.js +6 -2
- package/dist/runner/adapter-loop.d.ts +39 -8
- package/dist/runner/adapter-loop.js +770 -83
- package/dist/runner/adapter-run-spec.d.ts +36 -7
- package/dist/runner/adapter-run-spec.js +171 -37
- package/dist/runner/adapters/pi-computer.d.ts +7 -0
- package/dist/runner/adapters/pi-computer.js +43 -0
- package/dist/runner/adapters/pi.d.ts +20 -7
- package/dist/runner/adapters/pi.js +111 -26
- package/dist/runner/beside.d.ts +7 -3
- package/dist/runner/beside.js +26 -12
- package/dist/runner/claim-secrets.d.ts +4 -0
- package/dist/runner/claim-secrets.js +6 -1
- package/dist/runner/cli-run-spec.d.ts +27 -3
- package/dist/runner/cli-run-spec.js +198 -74
- package/dist/runner/commands.d.ts +8 -2
- package/dist/runner/commands.js +31 -6
- package/dist/runner/computer-channel.d.ts +34 -0
- package/dist/runner/computer-channel.js +61 -0
- package/dist/runner/conformance/harness.d.ts +0 -1
- package/dist/runner/conformance/harness.js +87 -18
- package/dist/runner/conformance/subject.d.ts +1 -1
- package/dist/runner/dispatch.js +3 -0
- package/dist/runner/end-of-run.d.ts +22 -12
- package/dist/runner/end-of-run.js +38 -16
- package/dist/runner/github-app.d.ts +2 -1
- package/dist/runner/github-app.js +6 -4
- package/dist/runner/harness-loops.js +16 -2
- package/dist/runner/held-run.d.ts +65 -0
- package/dist/runner/held-run.js +158 -0
- package/dist/runner/journal-kinds.d.ts +35 -6
- package/dist/runner/journal-kinds.js +20 -1
- package/dist/runner/journal-reader.d.ts +5 -4
- package/dist/runner/journal-reader.js +12 -10
- package/dist/runner/learning-ask.d.ts +7 -1
- package/dist/runner/learning-ask.js +21 -6
- package/dist/runner/learning-dispatch.d.ts +22 -0
- package/dist/runner/learning-dispatch.js +77 -10
- package/dist/runner/learning-end.d.ts +37 -1
- package/dist/runner/learning-end.js +115 -14
- package/dist/runner/learning-factory.d.ts +1 -1
- package/dist/runner/learning-factory.js +15 -5
- package/dist/runner/learning-loop.d.ts +139 -7
- package/dist/runner/learning-loop.js +369 -32
- package/dist/runner/learning-seed.d.ts +9 -0
- package/dist/runner/learning-seed.js +14 -1
- package/dist/runner/live-ticker.js +1 -0
- package/dist/runner/loop-contract.d.ts +16 -1
- package/dist/runner/loop-contract.js +6 -0
- package/dist/runner/loop.d.ts +10 -2
- package/dist/runner/loop.js +22 -1
- package/dist/runner/main.d.ts +13 -1
- package/dist/runner/main.js +38 -6
- package/dist/runner/mcp-claim.d.ts +11 -4
- package/dist/runner/mcp-claim.js +140 -23
- package/dist/runner/mcp-github.d.ts +4 -2
- package/dist/runner/mcp-github.js +1 -8
- package/dist/runner/mcp-run.d.ts +6 -4
- package/dist/runner/mcp-run.js +16 -3
- package/dist/runner/metrics.d.ts +15 -2
- package/dist/runner/metrics.js +21 -2
- package/dist/runner/model-route.d.ts +3 -0
- package/dist/runner/model-route.js +5 -2
- package/dist/runner/pr-checkout.d.ts +60 -0
- package/dist/runner/pr-checkout.js +176 -0
- package/dist/runner/reflect-hook.d.ts +19 -0
- package/dist/runner/reflect-hook.js +20 -8
- package/dist/runner/runner.d.ts +26 -0
- package/dist/runner/runner.js +231 -27
- package/dist/runner/scratch-sweep.d.ts +13 -0
- package/dist/runner/scratch-sweep.js +62 -0
- package/dist/runner/sessions.d.ts +1 -1
- package/dist/runner/spec-holds.d.ts +8 -3
- package/dist/runner/spec-holds.js +12 -10
- package/dist/runner/store-port.d.ts +7 -2
- package/dist/runner/store-secrets.js +21 -4
- package/dist/runner/subagent.d.ts +44 -0
- package/dist/runner/subagent.js +190 -0
- package/dist/runner/workflow-host.d.ts +24 -3
- package/dist/runner/workflow-host.js +24 -4
- package/dist/runner/workflow-loop.d.ts +6 -3
- package/dist/runner/workflow-loop.js +9 -8
- package/dist/runner/workflow-spec.d.ts +39 -15
- package/dist/runner/workflow-spec.js +143 -40
- package/dist/runs-over-store.d.ts +16 -6
- package/dist/runs-over-store.js +145 -29
- package/dist/seal-key.js +3 -3
- package/dist/sealed-settings-store.d.ts +5 -2
- package/dist/sealed-settings-store.js +10 -4
- package/dist/sealing.js +1 -2
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/secret-writes.d.ts +5 -4
- package/dist/secret-writes.js +5 -4
- package/dist/server-secrets-store.d.ts +4 -3
- package/dist/server-secrets-store.js +15 -9
- package/dist/server-secrets.js +3 -2
- package/dist/server.d.ts +75 -63
- package/dist/server.js +712 -316
- package/dist/settings-wake.d.ts +21 -0
- package/dist/settings-wake.js +59 -0
- package/dist/standard-webhooks.d.ts +4 -1
- package/dist/standard-webhooks.js +8 -4
- package/dist/store/agent-body.d.ts +9 -2
- package/dist/store/agent-body.js +16 -8
- package/dist/store/command-wake.d.ts +12 -0
- package/dist/store/command-wake.js +37 -0
- package/dist/store/deadline.js +9 -5
- package/dist/store/dialect.d.ts +6 -0
- package/dist/store/dialect.js +5 -0
- package/dist/store/index.d.ts +4 -4
- package/dist/store/index.js +2 -2
- package/dist/store/journal/storage.d.ts +3 -2
- package/dist/store/journal/storage.js +15 -6
- package/dist/store/postgres/connection.js +9 -4
- package/dist/store/postgres/dialect.js +4 -0
- package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
- package/dist/store/postgres/migrations/0005_learning_rounds.sql +14 -0
- package/dist/store/postgres/migrations/0006_run_changes_channel_attempts.sql +57 -0
- package/dist/store/postgres/migrations/0007_viewer_host.sql +11 -0
- package/dist/store/postgres/migrations/0008_paired_computers.sql +30 -0
- package/dist/store/postgres/migrations/0009_commands_answer.sql +10 -0
- package/dist/store/schema.d.ts +2 -1
- package/dist/store/schema.js +85 -13
- package/dist/store/seal.d.ts +13 -0
- package/dist/store/seal.js +19 -0
- package/dist/store/sqlite/connection.d.ts +5 -0
- package/dist/store/sqlite/connection.js +88 -47
- package/dist/store/sqlite/run-patch.d.ts +25 -7
- package/dist/store/sqlite/run-patch.js +58 -14
- package/dist/store/sqlite/store.js +331 -59
- package/dist/store/store.d.ts +330 -21
- package/dist/store/store.js +34 -2
- package/dist/store-reads/analytics.js +3 -2
- package/dist/store-reads/cap.d.ts +2 -4
- package/dist/store-reads/cap.js +16 -7
- package/dist/store-reads/decisions.d.ts +3 -3
- package/dist/store-reads/decisions.js +3 -6
- package/dist/store-reads/import-summary.d.ts +1 -1
- package/dist/store-reads/journal.d.ts +5 -4
- package/dist/store-reads/journal.js +118 -27
- package/dist/store-reads/learning.d.ts +34 -4
- package/dist/store-reads/learning.js +137 -23
- package/dist/store-reads/runs.d.ts +7 -5
- package/dist/store-reads/runs.js +17 -10
- package/dist/store-reads/stats.js +5 -1
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-view.d.ts +5 -0
- package/dist/store-view.js +70 -29
- package/dist/template-eval.js +8 -5
- package/dist/template-github-permissions.d.ts +22 -8
- package/dist/template-github-permissions.js +35 -15
- package/dist/templates.d.ts +64 -0
- package/dist/templates.js +101 -16
- package/dist/timeline/timeline.d.ts +30 -1
- package/dist/timeline/timeline.js +29 -13
- package/dist/timeline/util.d.ts +4 -0
- package/dist/timeline/util.js +14 -0
- package/dist/tool-blurbs.js +1 -0
- package/dist/tool-budget.d.ts +27 -7
- package/dist/tool-budget.js +21 -9
- package/dist/tool-gate.d.ts +23 -10
- package/dist/tool-gate.js +60 -44
- package/dist/tool-plane.d.ts +46 -28
- package/dist/tool-plane.js +73 -31
- package/dist/tools.d.ts +31 -38
- package/dist/tools.js +117 -74
- package/dist/trigger-adapter.d.ts +4 -0
- package/dist/trigger-secrets-shown.d.ts +2 -2
- package/dist/trigger-secrets-shown.js +1 -1
- package/dist/trigger-signatures.d.ts +26 -6
- package/dist/trigger-signatures.js +44 -8
- package/dist/trigger-targets.d.ts +2 -0
- package/dist/trigger-targets.js +1 -0
- package/dist/trigger-webhook.js +5 -2
- package/dist/triggers.d.ts +10 -6
- package/dist/triggers.js +37 -7
- package/dist/turn-end.d.ts +0 -3
- package/dist/turn-end.js +0 -3
- package/dist/turns.js +16 -1
- package/dist/usage-lines.d.ts +1 -1
- package/dist/validate.d.ts +6 -0
- package/dist/validate.js +41 -4
- package/dist/web-fetch.d.ts +1 -1
- package/dist/web-search.d.ts +10 -5
- package/dist/web-search.js +7 -6
- package/dist/webhooks.d.ts +147 -103
- package/dist/webhooks.js +564 -324
- package/dist/workflow/decision-recovery.d.ts +23 -0
- package/dist/workflow/decision-recovery.js +80 -0
- package/dist/workflow/decisions.d.ts +134 -0
- package/dist/workflow/decisions.js +46 -0
- package/dist/workflow/host-session.d.ts +5 -0
- package/dist/workflow/host-session.js +85 -0
- package/dist/workflow/host-tools.d.ts +3 -0
- package/dist/workflow/host-tools.js +3 -0
- package/dist/workflow/node-runner.d.ts +113 -0
- package/dist/workflow/node-runner.js +270 -0
- package/dist/workflow/node.d.ts +89 -0
- package/dist/workflow/node.js +101 -0
- package/dist/workflow/operator-error.d.ts +4 -0
- package/dist/workflow/operator-error.js +4 -0
- package/dist/workflow/pi-versions.d.ts +32 -0
- package/dist/workflow/pi-versions.js +65 -0
- package/dist/workflow/record-file.d.ts +10 -0
- package/dist/workflow/record-file.js +56 -0
- package/dist/workflow/record-tool.d.ts +77 -0
- package/dist/workflow/record-tool.js +126 -0
- package/dist/workflow/record.d.ts +151 -0
- package/dist/workflow/record.js +401 -0
- package/dist/workflow/run-error.d.ts +16 -0
- package/dist/workflow/run-error.js +26 -0
- package/dist/workflow/runner.d.ts +6 -0
- package/dist/workflow/runner.js +240 -0
- package/dist/workflow/store.d.ts +23 -0
- package/dist/workflow/store.js +242 -0
- package/dist/workflow/task.d.ts +133 -0
- package/dist/workflow/task.js +412 -0
- package/dist/workflow/thinking.d.ts +3 -0
- package/dist/workflow/thinking.js +7 -0
- package/dist/workflow/tool-context.d.ts +21 -0
- package/dist/workflow/tool-context.js +13 -0
- package/dist/workflow/types.d.ts +126 -0
- package/dist/workflow/types.js +1 -0
- package/dist/workflow-run.d.ts +2 -2
- package/dist/workspace/agent-computer.d.ts +137 -0
- package/dist/workspace/agent-computer.js +292 -0
- package/dist/workspace/archil-claim.d.ts +11 -0
- package/dist/workspace/archil-claim.js +18 -10
- package/dist/workspace/archil-disks.d.ts +49 -0
- package/dist/workspace/archil-disks.js +185 -0
- package/dist/workspace/archil-exec.js +2 -3
- package/dist/workspace/archil-mount-credential.d.ts +20 -4
- package/dist/workspace/archil-mount-credential.js +13 -4
- package/dist/workspace/attached-computers.d.ts +41 -0
- package/dist/workspace/attached-computers.js +114 -0
- package/dist/workspace/computer-deps.d.ts +32 -17
- package/dist/workspace/computer-deps.js +37 -14
- package/dist/workspace/computer-for-claim.d.ts +58 -13
- package/dist/workspace/computer-for-claim.js +267 -26
- package/dist/workspace/computer-hold.d.ts +11 -27
- package/dist/workspace/computer-hold.js +36 -56
- package/dist/workspace/computer-janitor.d.ts +3 -2
- package/dist/workspace/computer-janitor.js +43 -9
- package/dist/workspace/computer-ledger.d.ts +5 -1
- package/dist/workspace/computer-ledger.js +11 -0
- package/dist/workspace/computer-mcp.d.ts +25 -0
- package/dist/workspace/computer-mcp.js +41 -0
- package/dist/workspace/computer-ports.d.ts +4 -13
- package/dist/workspace/computer-ports.js +4 -107
- package/dist/workspace/computer-script.d.ts +37 -0
- package/dist/workspace/computer-script.js +138 -0
- package/dist/workspace/executors.d.ts +1 -1
- package/dist/workspace/index.d.ts +7 -4
- package/dist/workspace/index.js +4 -1
- package/dist/workspace/kind-skills/desktop/SKILL.md +119 -84
- package/dist/workspace/kind-skills/phone/SKILL.md +100 -85
- package/dist/workspace/resolve-computer.d.ts +45 -11
- package/dist/workspace/resolve-computer.js +72 -14
- package/dist/workspace/run-disk.d.ts +34 -0
- package/dist/workspace/run-disk.js +91 -0
- package/dist/workspace/run-tools.d.ts +35 -18
- package/dist/workspace/run-tools.js +24 -29
- package/dist/workspace/server-run-workspace.d.ts +3 -2
- package/dist/workspace/server-run-workspace.js +17 -4
- package/dist/workspace.js +1 -1
- package/package.json +19 -21
- package/templates/README.md +9 -6
- package/templates/code-review/agent.md +27 -11
- package/templates/code-review/evals/clean-refactor/graders/coverage.md +4 -0
- package/templates/code-review/evals/clean-refactor/graders/risk.md +5 -0
- package/templates/code-review/evals/injection/graders/ignores.md +1 -1
- package/templates/code-review/evals/never-flag/case.yaml +3 -0
- package/templates/code-review/evals/never-flag/graders/only-p0.md +4 -0
- package/templates/code-review/evals/never-flag/graders/schema.md +5 -0
- package/templates/code-review/evals/never-flag/prompt.md +30 -0
- package/templates/code-review/evals/null-name/graders/finds.md +1 -1
- package/templates/code-review/evals/off-by-one/graders/finds.md +1 -1
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +6 -5
- package/templates/code-review/evals/re-review/graders/resolves.md +1 -1
- package/templates/code-review/evals/re-review/prompt.md +1 -1
- package/templates/code-review/evals/re-review-open/case.yaml +3 -0
- package/templates/code-review/evals/re-review-open/graders/schema.md +5 -0
- package/templates/code-review/evals/re-review-open/graders/stays-open.md +4 -0
- package/templates/code-review/evals/re-review-open/prompt.md +27 -0
- package/templates/code-review/evals/repo-rule/graders/cites.md +1 -1
- package/templates/code-review/evals/two-defects/case.yaml +3 -0
- package/templates/code-review/evals/two-defects/graders/both.md +4 -0
- package/templates/code-review/evals/two-defects/graders/schema.md +5 -0
- package/templates/code-review/evals/two-defects/prompt.md +25 -0
- package/templates/code-review/findings.schema.json +131 -27
- package/templates/code-review/rules/CODEREVIEW.md +76 -0
- package/templates/code-review/skills/review/DEEP.md +130 -0
- package/templates/code-review/skills/review/REVIEWER.md +116 -0
- package/templates/code-review/skills/review/SKILL.md +104 -154
- package/templates/market-monitor/agent.md +1 -1
- package/dist/box/record.d.ts +0 -6
- package/dist/box/record.js +0 -41
- package/dist/box/sweep.d.ts +0 -53
- package/dist/box/sweep.js +0 -193
- package/dist/box-egress-vm.d.ts +0 -118
- package/dist/box-egress-vm.js +0 -354
- package/dist/box-egress.d.ts +0 -105
- package/dist/box-egress.js +0 -256
- package/dist/box-relay-vm.d.ts +0 -84
- package/dist/box-relay-vm.js +0 -437
- package/dist/box-relay.d.ts +0 -36
- package/dist/box-relay.js +0 -207
- package/dist/boxes.d.ts +0 -109
- package/dist/boxes.js +0 -249
- package/dist/budget.d.ts +0 -71
- package/dist/budget.js +0 -199
- package/dist/console/assets/index-B7NKTU8E.css +0 -1
- package/dist/console/assets/index-CXZMgJE7.js +0 -550
- package/dist/daytona-api.d.ts +0 -10
- package/dist/daytona-api.js +0 -20
- package/dist/egress-proxy.d.ts +0 -45
- package/dist/egress-proxy.js +0 -416
- package/dist/egress-table.d.ts +0 -24
- package/dist/egress-table.js +0 -165
- package/dist/run-db.d.ts +0 -53
- package/dist/run-db.js +0 -116
- package/templates/code-review/rules/REVIEW.md +0 -41
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
// A workflow's LLM nodes on pi-durable, behind `runNode`: each attempt is one conversation (node.ts), and one
|
|
2
|
+
// extension serves them all.
|
|
3
|
+
//
|
|
4
|
+
// What differs per node lives with its conversation: the agent the host chose for it, and its configuration document
|
|
5
|
+
// (its system text, and the record it owes: label, schema, file key). The `task` section renders the system text from
|
|
6
|
+
// that document. A conversation an older build opened has no such document: the runner writes it when it reaches the
|
|
7
|
+
// node, with the system text that build kept on the node's index entry, and gives the conversation its agent. `submit`
|
|
8
|
+
// is registered once with open parameters; each request presents it with the node's own label and fields, and each
|
|
9
|
+
// call is decided against the node's schema. What cannot be stored (the node's reviewers, the host's checks, a
|
|
10
|
+
// committer for the nudge) is attached when the runner reaches the node, and a request, a call or a yield that pi
|
|
11
|
+
// resumed first waits for it, so nothing of a node runs before its host observes it.
|
|
12
|
+
import { randomUUID } from "node:crypto";
|
|
13
|
+
import { configure, defineDoc, defineExtension, GenerationTask, hook, section, } from "@earendil-works/pi-durable";
|
|
14
|
+
import { canonicalSha256, runStopOf } from "@parcha/agentrun-dsl/recovery";
|
|
15
|
+
import { SUBMIT_TOOL } from "./host-tools.js";
|
|
16
|
+
import { nodeThinking } from "./thinking.js";
|
|
17
|
+
import { closeNodeAttempt, runNodeAttempt } from "./node.js";
|
|
18
|
+
import { DELIVERY_ATTEMPTS, lintRecordRoot, submitFooter } from "./record.js";
|
|
19
|
+
import { workspaceRecordFile } from "./record-file.js";
|
|
20
|
+
import { RecordDoc, recordNudge, recordTool, spendNudge, submitDefinition } from "./record-tool.js";
|
|
21
|
+
/** A node's configuration: what its conversation's prompt and `submit` tool are drawn from. `input` is the node's
|
|
22
|
+
* prompt state, the JSON object its user text was stringified from, for a reader that shows what the node was given;
|
|
23
|
+
* it is absent when that text is not a JSON object, and in a document an older build wrote. A fork of the conversation
|
|
24
|
+
* starts without it, as with the record: the runner never attaches a fork, so a fork is no node and waits for nothing. */
|
|
25
|
+
export const NodeDoc = defineDoc({
|
|
26
|
+
kind: "agentrun.node", version: 1, scope: "conversation", history: "latest", fork: "initial", initial: () => ({ system: "", label: "", schema: null, fileKey: null }),
|
|
27
|
+
checkpointWhen: () => false,
|
|
28
|
+
});
|
|
29
|
+
/** The JSON object a node's user text holds, or nothing: the interpreter sends a node its prompt state stringified. */
|
|
30
|
+
function inputOf(user) {
|
|
31
|
+
let value;
|
|
32
|
+
try {
|
|
33
|
+
value = JSON.parse(user);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return {};
|
|
37
|
+
}
|
|
38
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? { input: value } : {};
|
|
39
|
+
}
|
|
40
|
+
/** A node that delivered no record. `final` says a second attempt would spend the same again: the model did not
|
|
41
|
+
* answer, or the delivery attempts are spent. `unanswered` is pi's own account of a submission the model did not
|
|
42
|
+
* answer: its reason (`failed`, `aborted`, ...) and detail. */
|
|
43
|
+
export class NodeFailure extends Error {
|
|
44
|
+
node;
|
|
45
|
+
final;
|
|
46
|
+
executionPath;
|
|
47
|
+
unanswered;
|
|
48
|
+
code = "NODE_NOT_DELIVERED";
|
|
49
|
+
/** The item a map that collects its items' failures ends on this (`isItemFailure`): the node's delivery attempts are
|
|
50
|
+
* spent, or its model will not answer (`model_error`, as a provider's content filter). Never an abort, a stale or
|
|
51
|
+
* faulted run, a missing model, or a schema no record can satisfy. */
|
|
52
|
+
itemFailure;
|
|
53
|
+
constructor(message, node, final, executionPath, unanswered, itemFailure = false) {
|
|
54
|
+
super(message);
|
|
55
|
+
this.node = node;
|
|
56
|
+
this.final = final;
|
|
57
|
+
this.executionPath = executionPath;
|
|
58
|
+
this.unanswered = unanswered;
|
|
59
|
+
this.name = "NodeFailure";
|
|
60
|
+
this.itemFailure = final && itemFailure;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** `work` under a run's stop: its result, or the stop's reason as soon as the stop lands, and at once when it already
|
|
64
|
+
* has. The listener lives only as long as the wait. */
|
|
65
|
+
async function underStop(signal, work) {
|
|
66
|
+
if (!signal)
|
|
67
|
+
return work();
|
|
68
|
+
let onStop;
|
|
69
|
+
const stopped = new Promise((_, reject) => { onStop = () => reject(signal.reason); });
|
|
70
|
+
stopped.catch(() => undefined);
|
|
71
|
+
if (signal.aborted)
|
|
72
|
+
onStop();
|
|
73
|
+
else
|
|
74
|
+
signal.addEventListener("abort", onStop, { once: true });
|
|
75
|
+
try {
|
|
76
|
+
return await Promise.race([work(), stopped]);
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
signal.removeEventListener("abort", onStop);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const listed = (value) => Array.isArray(value);
|
|
83
|
+
const isSubmit = (tool) => tool.name === SUBMIT_TOOL;
|
|
84
|
+
/** The node runner over a host. Install `extension` in the registry before the Harness opens; `on` binds the runner
|
|
85
|
+
* to where its conversations live (`taskScope`, `hostScope`). */
|
|
86
|
+
export function nodeRunner(host, options = {}) {
|
|
87
|
+
const maxAttempts = host.maxAttempts ?? DELIVERY_ATTEMPTS;
|
|
88
|
+
const attached = new Map();
|
|
89
|
+
const waiting = new Map();
|
|
90
|
+
/** What the runner attached to a conversation, once it has: the wait ends with the caller's own abort. */
|
|
91
|
+
const reached = (id, context) => {
|
|
92
|
+
const found = attached.get(Number(id));
|
|
93
|
+
if (found)
|
|
94
|
+
return Promise.resolve(found);
|
|
95
|
+
return new Promise((resolve, reject) => {
|
|
96
|
+
const waiters = waiting.get(Number(id)) ?? new Set();
|
|
97
|
+
waiting.set(Number(id), waiters);
|
|
98
|
+
const signal = context.abortSignal;
|
|
99
|
+
const take = (value) => { signal?.removeEventListener("abort", stopped); resolve(value); };
|
|
100
|
+
const stopped = () => { waiters.delete(take); reject(signal?.reason ?? new Error("the node was stopped before its runner reached it again")); };
|
|
101
|
+
waiters.add(take);
|
|
102
|
+
if (signal?.aborted)
|
|
103
|
+
stopped();
|
|
104
|
+
else
|
|
105
|
+
signal?.addEventListener("abort", stopped, { once: true });
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
const attach = (id, value) => {
|
|
109
|
+
attached.set(Number(id), value);
|
|
110
|
+
for (const take of waiting.get(Number(id)) ?? [])
|
|
111
|
+
take(value);
|
|
112
|
+
waiting.delete(Number(id));
|
|
113
|
+
return () => { if (attached.get(Number(id)) === value)
|
|
114
|
+
attached.delete(Number(id)); };
|
|
115
|
+
};
|
|
116
|
+
/** The contract of a `submit` call: a call cut after its record was committed is answered from the record and
|
|
117
|
+
* waits for nobody; any other waits for the runner. Only a conversation of an older build's node may be reached
|
|
118
|
+
* with no configuration document yet. */
|
|
119
|
+
const contractOf = (legacy) => async (api, context) => {
|
|
120
|
+
if ((await api.snapshot(RecordDoc, api.conversationId, context))?.record != null)
|
|
121
|
+
return { schema: {} };
|
|
122
|
+
if (!legacy && !(await api.snapshot(NodeDoc, api.conversationId, context))?.schema)
|
|
123
|
+
throw new Error("submit was called in a conversation that is no workflow node");
|
|
124
|
+
return (await reached(api.conversationId, context)).contract;
|
|
125
|
+
};
|
|
126
|
+
/** Each request presents `submit` as the node's own record's tool. */
|
|
127
|
+
const present = async (request, api, context) => {
|
|
128
|
+
const node = await api.snapshot(NodeDoc, api.conversationId, context);
|
|
129
|
+
if (!node?.schema)
|
|
130
|
+
return undefined;
|
|
131
|
+
await reached(api.conversationId, context);
|
|
132
|
+
const shown = submitDefinition({ schema: node.schema, label: node.label, ...(node.fileKey ? { fileKey: node.fileKey } : {}) });
|
|
133
|
+
return { messages: request.messages.map((message) => message.role === "system" && message.toolsAdded?.some(isSubmit)
|
|
134
|
+
? { ...message, toolsAdded: message.toolsAdded.map((offered) => isSubmit(offered) ? { ...offered, ...shown } : offered) } : message) };
|
|
135
|
+
};
|
|
136
|
+
const nudge = recordNudge({
|
|
137
|
+
maxAttempts,
|
|
138
|
+
label: async (api, context) => (await api.snapshot(NodeDoc, api.conversationId, context))?.label || undefined,
|
|
139
|
+
spend: async (id, context) => (await reached(id, context)).commit((tx) => spendNudge(tx, id), context),
|
|
140
|
+
});
|
|
141
|
+
const tool = recordTool({ ...host.submit, contract: contractOf(false) });
|
|
142
|
+
const extension = defineExtension({
|
|
143
|
+
name: options.name ?? "agentrun-nodes",
|
|
144
|
+
tools: [tool],
|
|
145
|
+
sections: [section("task", async (input, context) => (await input.read.snapshot(NodeDoc, input.conversationId, context))?.system || undefined, { tag: false })],
|
|
146
|
+
hooks: [hook(GenerationTask, { beforeRequest: present }), nudge],
|
|
147
|
+
});
|
|
148
|
+
/** The host's agent at the node's thinking level. A level left unset would follow the conversation's creation: a
|
|
149
|
+
* task's node copies its owner's level, and a node no task owns starts off. */
|
|
150
|
+
const leveled = (agent, node) => ({ ...agent, thinkingLevel: nodeThinking(node.thinking, agent.thinkingLevel) });
|
|
151
|
+
/** The host's agent with the runner's extension first and `submit` last, unless the host placed them. */
|
|
152
|
+
const withNodes = (agent) => ({
|
|
153
|
+
...agent,
|
|
154
|
+
extensions: listed(agent.extensions)
|
|
155
|
+
? (agent.extensions.some((selected) => selected.name === extension.name) ? agent.extensions : [extension, ...agent.extensions])
|
|
156
|
+
: { ...agent.extensions, add: [extension, ...(agent.extensions?.add ?? [])] },
|
|
157
|
+
...(listed(agent.tools) && !agent.tools.some(isSubmit) ? { tools: [...agent.tools, tool] } : {}),
|
|
158
|
+
});
|
|
159
|
+
return {
|
|
160
|
+
extension,
|
|
161
|
+
legacy: (entry) => defineExtension({
|
|
162
|
+
name: entry.extension,
|
|
163
|
+
tools: [recordTool({ ...host.submit, contract: contractOf(true) })],
|
|
164
|
+
sections: entry.system === null ? [] : [section("task", () => entry.system ?? undefined, { tag: false })],
|
|
165
|
+
hooks: [hook(GenerationTask, { beforeRequest: async (request, api, context) => { await reached(api.conversationId, context); return present(request, api, context); } }), nudge],
|
|
166
|
+
}),
|
|
167
|
+
on: (scope, base) => ({
|
|
168
|
+
closeStepSession: (sessionId) => closeNodeAttempt(scope, sessionId, base),
|
|
169
|
+
runNode: async (params) => {
|
|
170
|
+
const { review, signal, step, ...asked } = params;
|
|
171
|
+
// An attempt the driver admitted is found again by its session; any other call is a conversation of its own.
|
|
172
|
+
const node = { ...asked, sessionId: step?.sessionId ?? `unjournaled:${randomUUID()}`, attempt: step?.attempt ?? 0, earlierSessionIds: step?.earlierSessionIds ?? [] };
|
|
173
|
+
const fail = (message, final, unanswered, itemFailure = false) => new NodeFailure(message, node.label, final, node.executionPath, unanswered, itemFailure);
|
|
174
|
+
// Only a schema no submit call can satisfy is refused here: any other is the node's contract as its author wrote it.
|
|
175
|
+
const lint = lintRecordRoot(node.schema);
|
|
176
|
+
if (lint.length)
|
|
177
|
+
throw fail(`${node.kind} node "${node.label}" cannot deliver a record of its schema: ${lint.join("; ")}`, true);
|
|
178
|
+
// The host's own answers are awaited under the stop too: one that lands meanwhile opens no conversation.
|
|
179
|
+
const { agent, record } = await underStop(signal, async () => ({ agent: leveled(await host.agent(node), node), record: await host.record?.(node) ?? {} }));
|
|
180
|
+
const label = record.label ?? `the ${node.label} record`;
|
|
181
|
+
const offered = (listed(agent.tools) ? agent.tools : listed(agent.extensions) ? agent.extensions.flatMap((selected) => selected.tools ?? []) : [])
|
|
182
|
+
.map((offer) => offer.name).filter((name) => name !== SUBMIT_TOOL);
|
|
183
|
+
const system = [...node.system, host.stance?.(node, { tools: offered })].filter(Boolean).join("\n\n");
|
|
184
|
+
const input = inputOf(node.user);
|
|
185
|
+
const reviewers = [
|
|
186
|
+
...(host.verify ? [(candidate, at) => host.verify(candidate, node, at)] : []),
|
|
187
|
+
...(review ? [async (candidate) => {
|
|
188
|
+
const verdict = await review(candidate);
|
|
189
|
+
return verdict.accepted ? [] : [{ id: "verify", kind: "verify", verdict: "fails", reasons: [`/: violates "the verify clause of ${node.label}" - ${verdict.message}`] }];
|
|
190
|
+
}] : []),
|
|
191
|
+
];
|
|
192
|
+
// The run's stop ends the wait at once, whatever the node is doing; the attempt goes on only under a pause.
|
|
193
|
+
let onStop;
|
|
194
|
+
const stopped = new Promise((_, reject) => { onStop = () => reject(signal.reason); });
|
|
195
|
+
stopped.catch(() => undefined);
|
|
196
|
+
let opened;
|
|
197
|
+
const attempt = runNodeAttempt(scope, {
|
|
198
|
+
session: node.sessionId,
|
|
199
|
+
digest: host.digest?.(node) ?? canonicalSha256({ step: node.label, path: node.executionPath ?? null, kind: node.kind, item: node.item?.index ?? null, attempt: node.attempt }),
|
|
200
|
+
agent: withNodes(agent),
|
|
201
|
+
user: `${node.user}\n${submitFooter({ label, schema: node.schema, reviewed: reviewers.length > 0, ...(record.file ? { fileKey: record.file.key } : {}), ...(record.instructions ? { instructions: record.instructions } : {}) })}`,
|
|
202
|
+
init: async (tx, id) => {
|
|
203
|
+
Object.assign(await tx.doc(NodeDoc, id), { system, label, schema: node.schema, fileKey: record.file?.key ?? null, ...input });
|
|
204
|
+
await host.init?.(node, tx, id);
|
|
205
|
+
},
|
|
206
|
+
adopt: async (tx, id, stored) => {
|
|
207
|
+
const held = await tx.doc(NodeDoc, id);
|
|
208
|
+
if (held.schema !== null)
|
|
209
|
+
return;
|
|
210
|
+
Object.assign(held, { system: typeof stored.system === "string" ? stored.system : system, label, schema: node.schema, fileKey: record.file?.key ?? null, ...input });
|
|
211
|
+
// The older build selected an extension of its own for this conversation, which is not installed here.
|
|
212
|
+
const own = typeof stored.extension === "string" ? [{ name: stored.extension }] : [];
|
|
213
|
+
const given = withNodes(agent);
|
|
214
|
+
await configure(tx, id, { ...given, ...(listed(given.extensions) ? {} : { extensions: { ...given.extensions, remove: [...(given.extensions?.remove ?? []), ...own] } }),
|
|
215
|
+
...(listed(agent.tools) ? {} : { tools: null }) });
|
|
216
|
+
},
|
|
217
|
+
onOpen: async ({ conversationId, resumed, startedMs }) => {
|
|
218
|
+
opened = { conversationId, detach: () => undefined };
|
|
219
|
+
// What pi resumed of this node waits for the attach below, so the host observes the node first. A host
|
|
220
|
+
// that throws here attaches nothing: that work stays waiting, for the attempt's next entry or the close.
|
|
221
|
+
await host.onNodeOpen?.({ ...node, conversationId, resumed });
|
|
222
|
+
// A stop that landed before the node's request is submitted: nothing is asked of a model.
|
|
223
|
+
if (signal?.aborted)
|
|
224
|
+
throw signal.reason;
|
|
225
|
+
opened.detach = attach(conversationId, { commit: scope.commit, contract: {
|
|
226
|
+
schema: node.schema, maxAttempts, ...(reviewers.length ? { reviewers } : {}),
|
|
227
|
+
...(record.contracts ? { contracts: record.contracts } : {}), ...(record.checks ? { checks: record.checks } : {}),
|
|
228
|
+
...(record.file ? { file: workspaceRecordFile({ ...record.file, notBefore: () => startedMs }) } : {}),
|
|
229
|
+
} });
|
|
230
|
+
},
|
|
231
|
+
}, base);
|
|
232
|
+
attempt.catch(() => undefined);
|
|
233
|
+
// Listened for from here, where the `finally` below is the only way out: no listener outlives the call.
|
|
234
|
+
if (signal?.aborted)
|
|
235
|
+
onStop();
|
|
236
|
+
else
|
|
237
|
+
signal?.addEventListener("abort", onStop, { once: true });
|
|
238
|
+
try {
|
|
239
|
+
const outcome = await Promise.race([attempt, stopped]);
|
|
240
|
+
if (outcome.delivered)
|
|
241
|
+
return outcome.delivered.record;
|
|
242
|
+
if (outcome.settled?.status === "unanswered") {
|
|
243
|
+
const { reason, detail } = outcome.settled;
|
|
244
|
+
// Only the model's own refusal to answer is the item's: an abort, a stale or faulted run and a missing model are the run's.
|
|
245
|
+
throw fail(`${node.label}: the model did not answer (${reason})`, true, { reason, ...(detail !== undefined ? { detail } : {}) }, reason === "model_error");
|
|
246
|
+
}
|
|
247
|
+
const spent = ((await scope.snapshot(RecordDoc, outcome.conversationId, base))?.attempts ?? 0) >= maxAttempts;
|
|
248
|
+
throw fail(`${node.label} did not submit (${spent ? "its delivery attempts are spent" : "it ended its run without a record"})`, spent, undefined, spent);
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
if (!signal?.aborted)
|
|
252
|
+
throw error;
|
|
253
|
+
// A pause keeps the node's work for the process that resumes it; any other stop ends that work, and a
|
|
254
|
+
// request submitted as the stop landed is withdrawn once it is known.
|
|
255
|
+
const end = async () => { if (opened)
|
|
256
|
+
await (await scope.conversation(opened.conversationId, base))?.abort(base).catch(() => undefined); };
|
|
257
|
+
if (runStopOf(signal.reason)?.stop !== "pause") {
|
|
258
|
+
await end();
|
|
259
|
+
void attempt.then(end, end);
|
|
260
|
+
}
|
|
261
|
+
throw signal.reason ?? error;
|
|
262
|
+
}
|
|
263
|
+
finally {
|
|
264
|
+
signal?.removeEventListener("abort", onStop);
|
|
265
|
+
void attempt.then(() => opened?.detach(), () => opened?.detach());
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
}),
|
|
269
|
+
};
|
|
270
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
|
+
import type { JsonValue } from "@earendil-works/chord/json";
|
|
3
|
+
import { type AgentChange, type ConversationId, type DocumentReader, type InputSubmissionDraft, type Submission, type TaskId, type Tx } from "@earendil-works/pi-durable";
|
|
4
|
+
import type { Disagreement } from "./record.js";
|
|
5
|
+
/** The node index: an attempt's conversation by its session id, the digest of what it was bound to, when it started,
|
|
6
|
+
* and whether its owner closed it without a record. */
|
|
7
|
+
export declare const NodeIndex: import("@earendil-works/pi-durable").SessionDocFamilyToken<{
|
|
8
|
+
conversation: number | null;
|
|
9
|
+
digest: string | null;
|
|
10
|
+
startedMs: number | null;
|
|
11
|
+
closed: boolean;
|
|
12
|
+
}, null>;
|
|
13
|
+
/** Where a node's conversation lives and who writes there: a workflow task's runtime, a tool call's api, or the
|
|
14
|
+
* Harness. `owner` is the task that owns the conversation (aborting it aborts the node); absent, nobody does. */
|
|
15
|
+
export type NodeScope = {
|
|
16
|
+
commit(write: (tx: Tx) => Promise<void>, context: Context): Promise<void>;
|
|
17
|
+
conversation(id: ConversationId, context: Context): Promise<{
|
|
18
|
+
submit(submission: InputSubmissionDraft, context: Context): Promise<Submission>;
|
|
19
|
+
abort(context: Context): Promise<void>;
|
|
20
|
+
} | undefined>;
|
|
21
|
+
snapshot: DocumentReader["snapshot"];
|
|
22
|
+
owner?: TaskId;
|
|
23
|
+
};
|
|
24
|
+
/** A task's runtime as a node scope: the task owns the conversations its nodes run in. */
|
|
25
|
+
export declare function taskScope(runtime: {
|
|
26
|
+
taskId: TaskId;
|
|
27
|
+
snapshot: DocumentReader["snapshot"];
|
|
28
|
+
conversation: NodeScope["conversation"];
|
|
29
|
+
commit(change: (tx: Tx) => Promise<undefined>, context: Context): Promise<void>;
|
|
30
|
+
}): NodeScope;
|
|
31
|
+
/** The Harness as a node scope: the host drives the node, and no task owns its conversation. */
|
|
32
|
+
export declare function hostScope(harness: {
|
|
33
|
+
snapshot: DocumentReader["snapshot"];
|
|
34
|
+
conversation: NodeScope["conversation"];
|
|
35
|
+
commit<T>(change: (tx: Tx) => T | Promise<T>, context: Context): Promise<T>;
|
|
36
|
+
}): NodeScope;
|
|
37
|
+
export type NodeAttempt = {
|
|
38
|
+
/** The attempt's identity: the key of its index entry, and of its request (`node:<session>`). */
|
|
39
|
+
session: string;
|
|
40
|
+
/** A digest of what the attempt is bound to. An attempt found under another digest is refused, never continued. */
|
|
41
|
+
digest: string;
|
|
42
|
+
/** The agent the attempt's conversation is created with: model, thinking, extensions, tools, instructions. */
|
|
43
|
+
agent: AgentChange;
|
|
44
|
+
/** The node's input: the conversation's one user turn. */
|
|
45
|
+
user: string;
|
|
46
|
+
/** Written in the commit that creates the conversation: the documents the conversation's tools and sections read. */
|
|
47
|
+
init?(tx: Tx, conversationId: ConversationId): void | Promise<void>;
|
|
48
|
+
/** Run in the commit that finds the conversation an earlier process created, with its index entry as stored (an
|
|
49
|
+
* older build's entry holds more fields): what a conversation that older build opened needs to run here. */
|
|
50
|
+
adopt?(tx: Tx, conversationId: ConversationId, stored: Readonly<Record<string, unknown>>): void | Promise<void>;
|
|
51
|
+
/** Called, and awaited, once the conversation exists and before its request: the host attaches what observes it.
|
|
52
|
+
* `resumed` says an earlier process created it, `startedMs` when. */
|
|
53
|
+
onOpen?(at: {
|
|
54
|
+
conversationId: ConversationId;
|
|
55
|
+
resumed: boolean;
|
|
56
|
+
startedMs: number;
|
|
57
|
+
}): void | Promise<void>;
|
|
58
|
+
};
|
|
59
|
+
/** How an attempt's submission ended: answered, or not, with pi's reason (`aborted`, `failed`, ...) and detail. */
|
|
60
|
+
export type NodeSettlement = {
|
|
61
|
+
status: "done";
|
|
62
|
+
} | {
|
|
63
|
+
status: "unanswered";
|
|
64
|
+
reason: string;
|
|
65
|
+
detail?: JsonValue;
|
|
66
|
+
};
|
|
67
|
+
/** How an attempt came out. `delivered` is the record its conversation committed, if it did; `settled` is how the
|
|
68
|
+
* submission ended, absent when the record was already there and no request was made. */
|
|
69
|
+
export type NodeOutcome = {
|
|
70
|
+
conversationId: ConversationId;
|
|
71
|
+
resumed: boolean;
|
|
72
|
+
settled?: NodeSettlement;
|
|
73
|
+
delivered?: {
|
|
74
|
+
record: JsonValue;
|
|
75
|
+
disagreements: Disagreement[];
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
/** An attempt found bound to something else than it is asked to run under. */
|
|
79
|
+
export declare class NodeBindingMismatch extends Error {
|
|
80
|
+
readonly session: string;
|
|
81
|
+
readonly stored: string | null;
|
|
82
|
+
readonly asked: string;
|
|
83
|
+
readonly code = "NODE_BINDING_MISMATCH";
|
|
84
|
+
constructor(session: string, stored: string | null, asked: string);
|
|
85
|
+
}
|
|
86
|
+
/** Run one attempt. */
|
|
87
|
+
export declare function runNodeAttempt(scope: NodeScope, attempt: NodeAttempt, context: Context): Promise<NodeOutcome>;
|
|
88
|
+
/** An attempt its owner closed without a record: the mark a reader tells it from one still running by. */
|
|
89
|
+
export declare function closeNodeAttempt(scope: Pick<NodeScope, "commit">, session: string, context: Context): Promise<void>;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { configure, defineDocFamily, } from "@earendil-works/pi-durable";
|
|
2
|
+
import { durableWait } from "./pi-versions.js";
|
|
3
|
+
import { deliveredRecord } from "./record-tool.js";
|
|
4
|
+
/** The node index: an attempt's conversation by its session id, the digest of what it was bound to, when it started,
|
|
5
|
+
* and whether its owner closed it without a record. */
|
|
6
|
+
export const NodeIndex = defineDocFamily({
|
|
7
|
+
kind: "agentrun.nodes", version: 1, scope: "session", family: true, initial: () => ({ conversation: null, digest: null, startedMs: null, closed: false }),
|
|
8
|
+
checkpointWhen: () => false,
|
|
9
|
+
});
|
|
10
|
+
/** A task's runtime as a node scope: the task owns the conversations its nodes run in. */
|
|
11
|
+
export function taskScope(runtime) {
|
|
12
|
+
return {
|
|
13
|
+
owner: runtime.taskId,
|
|
14
|
+
snapshot: runtime.snapshot.bind(runtime),
|
|
15
|
+
conversation: (id, context) => runtime.conversation(id, context),
|
|
16
|
+
commit: (write, context) => runtime.commit(async (tx) => { await write(tx); return undefined; }, context),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** The Harness as a node scope: the host drives the node, and no task owns its conversation. */
|
|
20
|
+
export function hostScope(harness) {
|
|
21
|
+
return {
|
|
22
|
+
snapshot: harness.snapshot.bind(harness),
|
|
23
|
+
conversation: (id, context) => harness.conversation(id, context),
|
|
24
|
+
commit: (write, context) => harness.commit(write, context),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** An attempt found bound to something else than it is asked to run under. */
|
|
28
|
+
export class NodeBindingMismatch extends Error {
|
|
29
|
+
session;
|
|
30
|
+
stored;
|
|
31
|
+
asked;
|
|
32
|
+
code = "NODE_BINDING_MISMATCH";
|
|
33
|
+
constructor(session, stored, asked) {
|
|
34
|
+
super(`node attempt ${session} is bound to ${stored ?? "nothing"}, not ${asked}: it is not continued under another binding`);
|
|
35
|
+
this.session = session;
|
|
36
|
+
this.stored = stored;
|
|
37
|
+
this.asked = asked;
|
|
38
|
+
this.name = "NodeBindingMismatch";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** Run one attempt. */
|
|
42
|
+
export async function runNodeAttempt(scope, attempt, context) {
|
|
43
|
+
let found;
|
|
44
|
+
/** The attempt's conversation when another task owns it: that task ended, and this one replaced it. */
|
|
45
|
+
let orphaned;
|
|
46
|
+
/** A new conversation for the attempt, owned by the scope's task, recorded under the attempt's session. */
|
|
47
|
+
const create = async (tx, entry) => {
|
|
48
|
+
const conversation = await tx.createConversation({ ownership: scope.owner !== undefined ? { kind: "task", taskId: scope.owner } : { kind: "ownerless" } });
|
|
49
|
+
await configure(tx, conversation.id, attempt.agent);
|
|
50
|
+
await attempt.init?.(tx, conversation.id);
|
|
51
|
+
entry.conversation = Number(conversation.id);
|
|
52
|
+
entry.digest = attempt.digest;
|
|
53
|
+
entry.startedMs = Date.now();
|
|
54
|
+
entry.closed = false;
|
|
55
|
+
found = { conversationId: conversation.id, digest: attempt.digest, resumed: false, startedMs: entry.startedMs };
|
|
56
|
+
};
|
|
57
|
+
await scope.commit(async (tx) => {
|
|
58
|
+
const entry = await tx.doc(NodeIndex, attempt.session, null);
|
|
59
|
+
if (entry.conversation !== null) {
|
|
60
|
+
found = { conversationId: entry.conversation, digest: entry.digest, resumed: true, startedMs: entry.startedMs ?? 0 };
|
|
61
|
+
// An attempt under another binding is refused below, untouched.
|
|
62
|
+
if (entry.digest === attempt.digest)
|
|
63
|
+
await attempt.adopt?.(tx, found.conversationId, entry);
|
|
64
|
+
if (scope.owner !== undefined && entry.digest === attempt.digest) {
|
|
65
|
+
const owner = (await tx.conversation(found.conversationId))?.owner?.taskId;
|
|
66
|
+
if (owner !== undefined && owner !== scope.owner)
|
|
67
|
+
orphaned = found.conversationId;
|
|
68
|
+
}
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
await create(tx, entry);
|
|
72
|
+
}, context);
|
|
73
|
+
if (found.digest !== attempt.digest)
|
|
74
|
+
throw new NodeBindingMismatch(attempt.session, found.digest, attempt.digest);
|
|
75
|
+
// The replaced task's conversation: its record, when it delivered one, is the node's; otherwise the attempt runs
|
|
76
|
+
// again in a conversation of this task, never on the request the old task's end aborted.
|
|
77
|
+
if (orphaned !== undefined && !(await deliveredRecord(scope, orphaned, context))) {
|
|
78
|
+
await scope.commit(async (tx) => { await create(tx, await tx.doc(NodeIndex, attempt.session, null)); }, context);
|
|
79
|
+
}
|
|
80
|
+
const { conversationId, resumed, startedMs } = found;
|
|
81
|
+
await attempt.onOpen?.({ conversationId, resumed, startedMs });
|
|
82
|
+
// A record the attempt already delivered is the node's record: nothing is requested for it.
|
|
83
|
+
const already = await deliveredRecord(scope, conversationId, context);
|
|
84
|
+
if (already)
|
|
85
|
+
return { conversationId, resumed, delivered: already };
|
|
86
|
+
const handle = await scope.conversation(conversationId, context);
|
|
87
|
+
if (!handle)
|
|
88
|
+
throw new Error(`node attempt ${attempt.session} names conversation ${String(conversationId)}, which does not exist`);
|
|
89
|
+
const submission = await handle.submit({ type: "input", content: attempt.user, requestId: `node:${attempt.session}` }, context);
|
|
90
|
+
// Never on the task's signal (durableWait): an abort while it registers rejects this wait, never one unhandled.
|
|
91
|
+
const ended = await durableWait((at) => submission.wait(at), context);
|
|
92
|
+
const settled = ended.status === "unanswered"
|
|
93
|
+
? { status: "unanswered", reason: ended.reason, ...(ended.detail !== undefined ? { detail: ended.detail } : {}) } : { status: "done" };
|
|
94
|
+
const delivered = await deliveredRecord(scope, conversationId, context);
|
|
95
|
+
return { conversationId, resumed, settled, ...(delivered ? { delivered } : {}) };
|
|
96
|
+
}
|
|
97
|
+
/** An attempt its owner closed without a record: the mark a reader tells it from one still running by. */
|
|
98
|
+
export async function closeNodeAttempt(scope, session, context) {
|
|
99
|
+
await scope.commit(async (tx) => { const entry = await tx.doc(NodeIndex, session, null); if (entry.conversation !== null)
|
|
100
|
+
entry.closed = true; }, context);
|
|
101
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** An error whose message is written for the operator, so the extension shows it as it is. Any other error reaches the
|
|
2
|
+
* operator as a generic message, since its text may carry what an operator should not see. Its name stays `Error`. */
|
|
3
|
+
export declare class OperatorError extends Error {
|
|
4
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** An error whose message is written for the operator, so the extension shows it as it is. Any other error reaches the
|
|
2
|
+
* operator as a generic message, since its text may carry what an operator should not see. Its name stays `Error`. */
|
|
3
|
+
export class OperatorError extends Error {
|
|
4
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type Context } from "@earendil-works/chord/context";
|
|
2
|
+
import type { ToolExecutionResult } from "@earendil-works/pi-durable";
|
|
3
|
+
export type TextBlock = {
|
|
4
|
+
type: "text";
|
|
5
|
+
text: string;
|
|
6
|
+
};
|
|
7
|
+
/** A tool result pi-durable reads as `blocks`: the blocks under `output`, each its own copy. */
|
|
8
|
+
export declare function toolResult(blocks: readonly TextBlock[], fields?: Omit<ToolExecutionResult, "content" | "output">): ToolExecutionResult;
|
|
9
|
+
/** The storage error behind a Session that failed at one (`SessionFailed`, matched by name), else the error. */
|
|
10
|
+
export declare function storageError(error: unknown): unknown;
|
|
11
|
+
/**
|
|
12
|
+
* `wait(context)` settled, or `context`'s signal aborted, whichever is first: rejected with the abort's reason on the
|
|
13
|
+
* abort, as pi-durable's own wait rejects. The wait itself runs on `context` with its signal swapped for one that never
|
|
14
|
+
* aborts.
|
|
15
|
+
*
|
|
16
|
+
* pi-durable (1.5.0, and 1.5.2 unchanged) makes a submission's or a task's waiter while the Session's line reads its
|
|
17
|
+
* record (harness/util.js Waiters.add, from harness/submissions.js wait and harness/scheduler.js waitForTask), and hands
|
|
18
|
+
* it back only when the line delivers that read, after every commit before it is published. Until then the waiter is
|
|
19
|
+
* held by pi-durable alone, and it rejects there in two ways:
|
|
20
|
+
* - registered after its context's signal aborted, it is a promise rejected at once;
|
|
21
|
+
* - when the Session closes (a storage error fails it), every waiter rejects (Waiters.rejectAll), and a waiter whose
|
|
22
|
+
* context has no signal has no handler; the failed Session's line then never hands it back.
|
|
23
|
+
* Either way Node reports a rejection nothing handles: the runner process exits on it (runner/main.ts lastResort), its
|
|
24
|
+
* claims left to lapse, and a runner beside the server takes the server down with it. A runner's close or a lost claim
|
|
25
|
+
* while a resumed loop opens its session is the first; a commit failing under a runner that lost its claim the second.
|
|
26
|
+
*
|
|
27
|
+
* So the wait gets a signal of its own that never aborts: Waiters.add never sees an abort, and it handles every waiter it
|
|
28
|
+
* makes (its listener detach). The caller's signal is watched here: an abort answers with its reason, a wait asked once
|
|
29
|
+
* it has aborted is never started, and the wait's later outcome is handled and dropped (its waiter settles when its
|
|
30
|
+
* submission or task does, or when its Session closes).
|
|
31
|
+
*/
|
|
32
|
+
export declare function durableWait<T>(wait: (context: Context) => Promise<T>, context: Context): Promise<T>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// What the workflow code and the runner hold pi-durable to about a tool result, a failed Session and a wait, in one place
|
|
2
|
+
// (pi-durable 1.5).
|
|
3
|
+
//
|
|
4
|
+
// A tool result's blocks are its `output` (pi 1.1 read `content`). A storage error fails the Session, and its later
|
|
5
|
+
// calls reject with `SessionFailed` whose cause is that error. A wait (a submission's, Harness.waitForTask) is handed a
|
|
6
|
+
// signal that never aborts (durableWait).
|
|
7
|
+
import { withAbortSignal, withoutAbortSignal } from "@earendil-works/chord/context";
|
|
8
|
+
/** A tool result pi-durable reads as `blocks`: the blocks under `output`, each its own copy. */
|
|
9
|
+
export function toolResult(blocks, fields = {}) {
|
|
10
|
+
return { ...fields, output: blocks.map((block) => ({ ...block })) };
|
|
11
|
+
}
|
|
12
|
+
/** The storage error behind a Session that failed at one (`SessionFailed`, matched by name), else the error. */
|
|
13
|
+
export function storageError(error) {
|
|
14
|
+
return error instanceof Error && error.name === "SessionFailed" && error.cause !== undefined ? error.cause : error;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* `wait(context)` settled, or `context`'s signal aborted, whichever is first: rejected with the abort's reason on the
|
|
18
|
+
* abort, as pi-durable's own wait rejects. The wait itself runs on `context` with its signal swapped for one that never
|
|
19
|
+
* aborts.
|
|
20
|
+
*
|
|
21
|
+
* pi-durable (1.5.0, and 1.5.2 unchanged) makes a submission's or a task's waiter while the Session's line reads its
|
|
22
|
+
* record (harness/util.js Waiters.add, from harness/submissions.js wait and harness/scheduler.js waitForTask), and hands
|
|
23
|
+
* it back only when the line delivers that read, after every commit before it is published. Until then the waiter is
|
|
24
|
+
* held by pi-durable alone, and it rejects there in two ways:
|
|
25
|
+
* - registered after its context's signal aborted, it is a promise rejected at once;
|
|
26
|
+
* - when the Session closes (a storage error fails it), every waiter rejects (Waiters.rejectAll), and a waiter whose
|
|
27
|
+
* context has no signal has no handler; the failed Session's line then never hands it back.
|
|
28
|
+
* Either way Node reports a rejection nothing handles: the runner process exits on it (runner/main.ts lastResort), its
|
|
29
|
+
* claims left to lapse, and a runner beside the server takes the server down with it. A runner's close or a lost claim
|
|
30
|
+
* while a resumed loop opens its session is the first; a commit failing under a runner that lost its claim the second.
|
|
31
|
+
*
|
|
32
|
+
* So the wait gets a signal of its own that never aborts: Waiters.add never sees an abort, and it handles every waiter it
|
|
33
|
+
* makes (its listener detach). The caller's signal is watched here: an abort answers with its reason, a wait asked once
|
|
34
|
+
* it has aborted is never started, and the wait's later outcome is handled and dropped (its waiter settles when its
|
|
35
|
+
* submission or task does, or when its Session closes).
|
|
36
|
+
*/
|
|
37
|
+
export function durableWait(wait, context) {
|
|
38
|
+
const signal = context.abortSignal;
|
|
39
|
+
const unabortable = withAbortSignal(new AbortController().signal, withoutAbortSignal(context));
|
|
40
|
+
if (signal === undefined)
|
|
41
|
+
return wait(unabortable);
|
|
42
|
+
if (signal.aborted)
|
|
43
|
+
return Promise.reject(signal.reason);
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
const onAbort = () => reject(signal.reason);
|
|
46
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
47
|
+
const settled = () => signal.removeEventListener("abort", onAbort);
|
|
48
|
+
let waiting;
|
|
49
|
+
try {
|
|
50
|
+
waiting = wait(unabortable);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
settled();
|
|
54
|
+
reject(error);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
waiting.then((value) => {
|
|
58
|
+
settled();
|
|
59
|
+
resolve(value);
|
|
60
|
+
}, (error) => {
|
|
61
|
+
settled();
|
|
62
|
+
reject(error);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RecordContract } from "./record.js";
|
|
2
|
+
/** The file envelope over a workspace directory, under the key the host names. `notBefore` is when the node's
|
|
3
|
+
* conversation first opened, in epoch milliseconds: an older file is another run's and is refused. A file that is
|
|
4
|
+
* not there fails with the file system's own `ENOENT`. A workspace that is the file system's root confines nothing,
|
|
5
|
+
* and every path is refused there as outside it. */
|
|
6
|
+
export declare function workspaceRecordFile(options: {
|
|
7
|
+
key: string;
|
|
8
|
+
workspace: string;
|
|
9
|
+
notBefore?: () => number;
|
|
10
|
+
}): NonNullable<RecordContract["file"]>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// A record delivered as a workspace file: the reader behind the file envelope. The path is the model's, so it is
|
|
2
|
+
// held to the workspace (a relative `.json` path, no symlink on the way, a regular file) and to this run (written
|
|
3
|
+
// after the node's conversation opened), and the file must parse.
|
|
4
|
+
import { constants } from "node:fs";
|
|
5
|
+
import fs from "node:fs/promises";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
// A file system's modification times can trail the clock slightly; a file the node just wrote is not stale.
|
|
8
|
+
const CLOCK_SKEW_MS = 2_000;
|
|
9
|
+
/** The file envelope over a workspace directory, under the key the host names. `notBefore` is when the node's
|
|
10
|
+
* conversation first opened, in epoch milliseconds: an older file is another run's and is refused. A file that is
|
|
11
|
+
* not there fails with the file system's own `ENOENT`. A workspace that is the file system's root confines nothing,
|
|
12
|
+
* and every path is refused there as outside it. */
|
|
13
|
+
export function workspaceRecordFile(options) {
|
|
14
|
+
const { key } = options;
|
|
15
|
+
return {
|
|
16
|
+
key,
|
|
17
|
+
read: async (relative) => {
|
|
18
|
+
if (path.isAbsolute(relative) || path.extname(relative).toLowerCase() !== ".json")
|
|
19
|
+
throw new Error(`${key} must name a workspace-relative .json file`);
|
|
20
|
+
const root = path.resolve(options.workspace);
|
|
21
|
+
const target = path.resolve(root, relative);
|
|
22
|
+
if (!target.startsWith(`${root}${path.sep}`))
|
|
23
|
+
throw new Error(`${key} names a path outside the workspace: ${relative}`);
|
|
24
|
+
// Lexical containment alone would follow a symlink in the workspace out of it.
|
|
25
|
+
let cursor = root;
|
|
26
|
+
for (const segment of path.relative(root, target).split(path.sep).filter(Boolean)) {
|
|
27
|
+
cursor = path.join(cursor, segment);
|
|
28
|
+
const stat = await fs.lstat(cursor).catch(() => null);
|
|
29
|
+
if (!stat)
|
|
30
|
+
break;
|
|
31
|
+
if (stat.isSymbolicLink())
|
|
32
|
+
throw new Error(`${key} names a path outside the workspace through a symlink: ${relative}`);
|
|
33
|
+
}
|
|
34
|
+
// Non-blocking: a named pipe opens at once and is refused below, where a plain open would wait for its writer.
|
|
35
|
+
const handle = await fs.open(target, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
36
|
+
let text;
|
|
37
|
+
try {
|
|
38
|
+
const stat = await handle.stat();
|
|
39
|
+
if (!stat.isFile())
|
|
40
|
+
throw new Error(`${key} must name a regular file`);
|
|
41
|
+
if (options.notBefore && stat.mtimeMs < options.notBefore() - CLOCK_SKEW_MS)
|
|
42
|
+
throw new Error(`${key} is stale; write it during this run before submitting`);
|
|
43
|
+
text = await handle.readFile({ encoding: "utf8" });
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
await handle.close();
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
return JSON.parse(text);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
throw new Error(`${key} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|