@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
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { type Store } from "../store/store.js";
|
|
2
|
-
export type RunnerStore = Pick<Store, "claim" | "renew" | "renewMany" | "release" | "journal" | "flush" | "commands" | "commandsOf" | "take" | "retry"> & {
|
|
3
|
-
readonly runs: Pick<Store["runs"], "claimMany" | "claimable" | "update"
|
|
2
|
+
export type RunnerStore = Pick<Store, "claim" | "renew" | "renewMany" | "release" | "journal" | "flush" | "commands" | "commandsOf" | "take" | "retry" | "watchCommands"> & {
|
|
3
|
+
readonly runs: Pick<Store["runs"], "claimMany" | "claimable" | "claimsOf" | "update"> & Partial<Pick<Store["runs"], "launch" | "get">>;
|
|
4
|
+
/** The revision's kind, read for a run's start line (runner.ts). A store without it (a test's) says no start or end line. */
|
|
5
|
+
readonly agents?: Pick<Store["agents"], "revision">;
|
|
4
6
|
/** The runs' live view (run_live): the runner's live ticker writes each run's held state there. A store without it (a
|
|
5
7
|
* test's) has no live view. */
|
|
6
8
|
readonly live?: Store["live"];
|
|
9
|
+
/** The server's settings, for the one the runner removes at a run's end (browser-wait-ended.ts). A store without it (a
|
|
10
|
+
* test's) keeps none. */
|
|
11
|
+
readonly settings?: Store["settings"];
|
|
7
12
|
};
|
|
8
13
|
/** The store's fence: a write under an epoch that moved. */
|
|
9
14
|
export declare function isFenced(error: unknown): boolean;
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
// echoes it back. One read of the store across all its planes (store.sealedSecrets): tool, model, computer and Archil keys
|
|
6
6
|
// (sealed_keys); MCP credentials, their headers' values and OAuth tokens and client secret (mcp_servers), and a sign-in in
|
|
7
7
|
// flight (mcp_oauth_pending); each trigger source's settings, a webhook trigger's signing secret and the GitHub App's key
|
|
8
|
-
// and webhook secret among them, and the outbound webhook's signing secret
|
|
9
|
-
// and forgotten; live viewer tokens; a launch's sealed
|
|
10
|
-
//
|
|
8
|
+
// and webhook secret among them, and the outbound webhook's signing secret, each it held before too (trigger_settings),
|
|
9
|
+
// but a field its source marks public; browser sign-in pointers, live and forgotten; live viewer tokens; a launch's sealed
|
|
10
|
+
// part. Beside the store, what the data directory keeps where the runner shares it (server-secrets.ts besideTheStore: the
|
|
11
|
+
// owner's API token and the sign-in session secret). Each value in every spelling the server's list has
|
|
11
12
|
// (standard-webhooks.ts secretForms), a PEM key whole and line by line. A value that does not open under the runner's key
|
|
12
13
|
// is left out: the store never holds one in the clear, and nothing of this runner can be handed it.
|
|
13
14
|
import { unseal } from "../sealing.js";
|
|
@@ -50,6 +51,22 @@ function jsonSecrets(text) {
|
|
|
50
51
|
walk(value);
|
|
51
52
|
return out;
|
|
52
53
|
}
|
|
54
|
+
/** A launch's sealed JSON: its own listed values (jsonSecrets), and each handed MCP credential's headers (store/seal.ts
|
|
55
|
+
* sealRunMcpAuth: `{"mcp": {"<server>": {"headers": {...}}}}`), as a saved server's are listed. */
|
|
56
|
+
function launchSecrets(text) {
|
|
57
|
+
const out = jsonSecrets(text);
|
|
58
|
+
let mcp;
|
|
59
|
+
try {
|
|
60
|
+
mcp = JSON.parse(text)?.mcp;
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
if (mcp && typeof mcp === "object")
|
|
66
|
+
for (const entry of Object.values(mcp))
|
|
67
|
+
out.push(...jsonSecrets(JSON.stringify(entry)));
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
53
70
|
/** A PEM key whole, and each of its base64 lines (the short last one too), as the server lists one (sealed-settings-store.ts). */
|
|
54
71
|
const pemForms = (value) => [value, ...value.split(/\r?\n/).map((line) => line.trim()).filter((line) => line && !line.startsWith("-----"))];
|
|
55
72
|
/** What of one opened sealed value is a secret to hold, by its plane: `listed` with the server list's floor and spellings,
|
|
@@ -66,7 +83,7 @@ function secretsOf(row, plain, adapters) {
|
|
|
66
83
|
case "mcp_oauth_pending":
|
|
67
84
|
return { listed: jsonSecrets(plain), whole: [] };
|
|
68
85
|
case "run_launch":
|
|
69
|
-
return { listed: plain.trimStart().startsWith("{") ?
|
|
86
|
+
return { listed: plain.trimStart().startsWith("{") ? launchSecrets(plain) : [plain], whole: [] };
|
|
70
87
|
default:
|
|
71
88
|
return { listed: [plain], whole: [] };
|
|
72
89
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type ModelRef, type ToolRegistration } from "@earendil-works/pi-durable";
|
|
2
|
+
export declare const SUBAGENT_TOOL = "subagent";
|
|
3
|
+
/** The tiers a call may name for its child (its definition's model_tiers, else this server's tier); a call that names
|
|
4
|
+
* none runs its child on the agent's own model. */
|
|
5
|
+
export declare const SUBAGENT_TIERS: readonly ["fast", "strong"];
|
|
6
|
+
export type SubagentTier = (typeof SUBAGENT_TIERS)[number];
|
|
7
|
+
/** How many of a run's children work at once; a call past it waits for a slot. */
|
|
8
|
+
export declare const SUBAGENT_PARALLEL = 4;
|
|
9
|
+
/** A child's instructions: the call's prompt is its whole task. Nothing of the parent's prompt is carried over. */
|
|
10
|
+
export declare const SUBAGENT_INSTRUCTIONS = "You are a subagent. The message you are given is your whole task: do it with the tools you have, then answer. Your last message is returned, as it is, to the agent that called you.";
|
|
11
|
+
/** The thinking levels a call may give its child (`effort`); absent, the child thinks at the agent's own level. */
|
|
12
|
+
export declare const SUBAGENT_EFFORTS: readonly ["low", "medium", "high"];
|
|
13
|
+
/** A tier's model in this run: its ref in the run's models (adapters/pi.ts tierProvider), or why the tier has none here. */
|
|
14
|
+
export type TierModel = {
|
|
15
|
+
readonly ref: ModelRef;
|
|
16
|
+
} | {
|
|
17
|
+
readonly why: string;
|
|
18
|
+
};
|
|
19
|
+
export type SubagentOptions = {
|
|
20
|
+
/** The tools the agent was granted, by catalog name (`read`, `mcp:github/get_file_contents`): a call's subset of them. */
|
|
21
|
+
readonly granted: readonly string[];
|
|
22
|
+
/** A granted tool's names in the run's session (catalog.ts wireName; the browser's registrations for `browser`). */
|
|
23
|
+
readonly sessionNames: (catalog: string) => readonly string[];
|
|
24
|
+
/** The tier's model, resolved at the claim. */
|
|
25
|
+
readonly tier: (tier: SubagentTier) => TierModel;
|
|
26
|
+
/** Words before a child's own instructions (the environment line), when the host has any. */
|
|
27
|
+
readonly preamble?: string;
|
|
28
|
+
/** The agent's tool-call budget (definition.max_tool_calls, tool-budget.ts), per conversation: a call's own narrows it
|
|
29
|
+
* for its child, never widens it. */
|
|
30
|
+
readonly toolCalls?: number;
|
|
31
|
+
};
|
|
32
|
+
/** `text` within the host's bound on a tool result (HOST_RESULT_MAX_CHARS), saying where it was cut. */
|
|
33
|
+
export declare function boundedAnswer(text: string): string;
|
|
34
|
+
/** The catalog names of `asked` (each a catalog or session name of a granted tool) and the session names the child gets,
|
|
35
|
+
* or what is wrong with them. A catalog name gives every session name of its tool (`browser`: each browser tool); a
|
|
36
|
+
* session name gives that one alone (`browser_read`: never the rest of the browser's). */
|
|
37
|
+
export declare function chosenTools(asked: readonly string[], options: Pick<SubagentOptions, "granted" | "sessionNames">): {
|
|
38
|
+
catalog: string[];
|
|
39
|
+
names: string[];
|
|
40
|
+
} | {
|
|
41
|
+
refused: string;
|
|
42
|
+
};
|
|
43
|
+
/** The subagent tool: one of the session's own tools (adapters/pi.ts `tools`), so it needs no extension of its own. */
|
|
44
|
+
export declare function subagentTool(options: SubagentOptions): ToolRegistration;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { configure, defineTool, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
2
|
+
import { HOST_RESULT_MAX_CHARS } from "@parcha/agentrun-kernel";
|
|
3
|
+
import { ASK_TOOL } from "../tools.js";
|
|
4
|
+
import { durableWait } from "../workflow/pi-versions.js";
|
|
5
|
+
import { HOST_TOOL_OUTPUT } from "./adapters/pi.js";
|
|
6
|
+
import { cutAtLimit } from "./loop-contract.js";
|
|
7
|
+
import { PI_STOP } from "./pi-stop.js";
|
|
8
|
+
import { budgetOf, ConversationToolBudget } from "../tool-budget.js";
|
|
9
|
+
export const SUBAGENT_TOOL = "subagent";
|
|
10
|
+
/** The tiers a call may name for its child (its definition's model_tiers, else this server's tier); a call that names
|
|
11
|
+
* none runs its child on the agent's own model. */
|
|
12
|
+
export const SUBAGENT_TIERS = ["fast", "strong"];
|
|
13
|
+
/** How many of a run's children work at once; a call past it waits for a slot. */
|
|
14
|
+
export const SUBAGENT_PARALLEL = 4;
|
|
15
|
+
/** Tools no child is given: a subagent of its own (depth 1), and the person, whom only the run's own conversation asks. */
|
|
16
|
+
const NEVER_GIVEN = [SUBAGENT_TOOL, ASK_TOOL];
|
|
17
|
+
/** A child's instructions: the call's prompt is its whole task. Nothing of the parent's prompt is carried over. */
|
|
18
|
+
export const SUBAGENT_INSTRUCTIONS = "You are a subagent. The message you are given is your whole task: do it with the tools you have, then answer. Your last message is returned, as it is, to the agent that called you.";
|
|
19
|
+
/** The thinking levels a call may give its child (`effort`); absent, the child thinks at the agent's own level. */
|
|
20
|
+
export const SUBAGENT_EFFORTS = ["low", "medium", "high"];
|
|
21
|
+
/** One counter of free slots for the run's children (SUBAGENT_PARALLEL), handed out in call order. */
|
|
22
|
+
function slots(count) {
|
|
23
|
+
let free = count;
|
|
24
|
+
const waiting = [];
|
|
25
|
+
return {
|
|
26
|
+
async take(signal) {
|
|
27
|
+
if (free > 0)
|
|
28
|
+
free -= 1;
|
|
29
|
+
else {
|
|
30
|
+
await new Promise((resolve, reject) => {
|
|
31
|
+
const go = () => {
|
|
32
|
+
signal?.removeEventListener("abort", stop);
|
|
33
|
+
resolve();
|
|
34
|
+
};
|
|
35
|
+
const stop = () => {
|
|
36
|
+
const at = waiting.indexOf(go);
|
|
37
|
+
if (at >= 0)
|
|
38
|
+
waiting.splice(at, 1);
|
|
39
|
+
reject(signal?.reason ?? new Error("aborted"));
|
|
40
|
+
};
|
|
41
|
+
waiting.push(go);
|
|
42
|
+
signal?.addEventListener("abort", stop, { once: true });
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
let given = false;
|
|
46
|
+
return () => {
|
|
47
|
+
if (given)
|
|
48
|
+
return;
|
|
49
|
+
given = true;
|
|
50
|
+
const next = waiting.shift();
|
|
51
|
+
if (next)
|
|
52
|
+
next();
|
|
53
|
+
else
|
|
54
|
+
free += 1;
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** The text of an assistant message: its text parts, joined. */
|
|
60
|
+
const textOf = (message) => Array.isArray(message?.content) ? message.content.map((part) => (part?.type === "text" ? (part.text ?? "") : "")).join("") : typeof message?.content === "string" ? message.content : "";
|
|
61
|
+
/** `text` within the host's bound on a tool result (HOST_RESULT_MAX_CHARS), saying where it was cut. */
|
|
62
|
+
export function boundedAnswer(text) {
|
|
63
|
+
if (text.length <= HOST_RESULT_MAX_CHARS)
|
|
64
|
+
return text;
|
|
65
|
+
const note = `\n[the subagent's answer was cut at ${HOST_RESULT_MAX_CHARS.toLocaleString("en-US")} of its ${text.length.toLocaleString("en-US")} characters]`;
|
|
66
|
+
return text.slice(0, HOST_RESULT_MAX_CHARS - note.length) + note;
|
|
67
|
+
}
|
|
68
|
+
/** The catalog names of `asked` (each a catalog or session name of a granted tool) and the session names the child gets,
|
|
69
|
+
* or what is wrong with them. A catalog name gives every session name of its tool (`browser`: each browser tool); a
|
|
70
|
+
* session name gives that one alone (`browser_read`: never the rest of the browser's). */
|
|
71
|
+
export function chosenTools(asked, options) {
|
|
72
|
+
const catalog = [];
|
|
73
|
+
const names = [];
|
|
74
|
+
const offered = options.granted.filter((name) => !NEVER_GIVEN.includes(name));
|
|
75
|
+
for (const name of asked) {
|
|
76
|
+
if (NEVER_GIVEN.includes(name))
|
|
77
|
+
return { refused: `subagent: a subagent is never given ${name}${name === SUBAGENT_TOOL ? " (subagents go one level deep)" : " (only the run itself asks its person)"}. Nothing ran.` };
|
|
78
|
+
const found = options.granted.find((granted) => granted === name || options.sessionNames(granted).includes(name));
|
|
79
|
+
if (found === undefined)
|
|
80
|
+
return { refused: `subagent: ${name} is not one of this agent's tools, so no subagent may have it. A subagent may be given ${offered.length ? offered.join(", ") : "no tool here"}. Nothing ran.` };
|
|
81
|
+
if (!catalog.includes(found))
|
|
82
|
+
catalog.push(found);
|
|
83
|
+
for (const session of found === name ? options.sessionNames(found) : [name])
|
|
84
|
+
if (!names.includes(session))
|
|
85
|
+
names.push(session);
|
|
86
|
+
}
|
|
87
|
+
return { catalog, names };
|
|
88
|
+
}
|
|
89
|
+
/** The subagent tool: one of the session's own tools (adapters/pi.ts `tools`), so it needs no extension of its own. */
|
|
90
|
+
export function subagentTool(options) {
|
|
91
|
+
const free = slots(SUBAGENT_PARALLEL);
|
|
92
|
+
return defineTool({
|
|
93
|
+
name: SUBAGENT_TOOL,
|
|
94
|
+
description: `Run a subagent: a fresh conversation that starts with nothing but your prompt, on your own model (or the model tier you name: ${SUBAGENT_TIERS.join(" or ")}), with only the tools you list (a subset of your own), and get its final answer back as text. Write the prompt self-contained: the subagent sees none of your conversation. Several calls in one turn run at once, at most ${SUBAGENT_PARALLEL} at a time; more wait their turn. A subagent cannot start subagents of its own.`,
|
|
95
|
+
parameters: {
|
|
96
|
+
type: "object",
|
|
97
|
+
additionalProperties: false,
|
|
98
|
+
properties: {
|
|
99
|
+
prompt: { type: "string", minLength: 1, description: "The subagent's whole task, self-contained: it sees nothing else." },
|
|
100
|
+
tools: { type: "array", items: { type: "string" }, uniqueItems: true, description: "The tools it may use, each one of your own tools by name. Absent or empty: none." },
|
|
101
|
+
model: { enum: [...SUBAGENT_TIERS], description: "The model tier it runs on, one of this agent's own tiers. Absent: your own model." },
|
|
102
|
+
max_tool_calls: { type: "integer", minimum: 1, description: "The most tool calls it may make. It narrows your own budget for it, never widens it. Absent: your budget." },
|
|
103
|
+
effort: { enum: [...SUBAGENT_EFFORTS], description: "How hard it thinks: low, medium or high. Absent: as you do." },
|
|
104
|
+
},
|
|
105
|
+
required: ["prompt"],
|
|
106
|
+
},
|
|
107
|
+
// A rerun after a crash finds the same child (it is owned by this call's task) and the same submission (its request
|
|
108
|
+
// id), so the child's work is never started twice.
|
|
109
|
+
replay: "safe",
|
|
110
|
+
executionMode: "parallel",
|
|
111
|
+
outputLimits: HOST_TOOL_OUTPUT,
|
|
112
|
+
execute: async (given, api, context) => {
|
|
113
|
+
const args = given;
|
|
114
|
+
const fail = (text) => ({ output: [{ type: "text", text }], isError: true });
|
|
115
|
+
// Depth 1: a child is never offered subagent (its tools are the call's subset, NEVER_GIVEN aside); and only the run's
|
|
116
|
+
// own conversation calls it.
|
|
117
|
+
if (Number(api.conversationId) !== Number(ROOT_CONVERSATION_ID))
|
|
118
|
+
return fail("subagent: a subagent cannot start subagents of its own. Nothing ran.");
|
|
119
|
+
const model = args.model === undefined ? undefined : options.tier(args.model);
|
|
120
|
+
if (model && "why" in model)
|
|
121
|
+
return fail(`subagent: the ${args.model} tier has no model here: ${model.why} Nothing ran.`);
|
|
122
|
+
if (args.max_tool_calls !== undefined && !(Number.isSafeInteger(args.max_tool_calls) && args.max_tool_calls > 0))
|
|
123
|
+
return fail("subagent: max_tool_calls is a whole number above 0. Nothing ran.");
|
|
124
|
+
if (args.effort !== undefined && !SUBAGENT_EFFORTS.includes(args.effort))
|
|
125
|
+
return fail(`subagent: effort is one of ${SUBAGENT_EFFORTS.join(", ")}. Nothing ran.`);
|
|
126
|
+
// The child's own budget: the call's, held under the agent's (never wider); absent, the agent's holds it as it holds
|
|
127
|
+
// every conversation of the run.
|
|
128
|
+
const toolCalls = args.max_tool_calls === undefined ? undefined : budgetOf(options.toolCalls, args.max_tool_calls);
|
|
129
|
+
const chosen = chosenTools(args.tools ?? [], options);
|
|
130
|
+
if ("refused" in chosen)
|
|
131
|
+
return fail(chosen.refused);
|
|
132
|
+
// The registrations the parent's agent enables, by session name: exactly the ones the call named are the child's.
|
|
133
|
+
const names = new Set(chosen.names);
|
|
134
|
+
const parent = await api.agent(context);
|
|
135
|
+
const tools = parent.tools.filter((registration) => names.has(registration.name));
|
|
136
|
+
const missing = [...names].filter((name) => !tools.some((registration) => registration.name === name));
|
|
137
|
+
if (missing.length)
|
|
138
|
+
return fail(`subagent: ${missing.join(", ")} ${missing.length === 1 ? "is" : "are"} not bound in this run, so no subagent may have ${missing.length === 1 ? "it" : "them"}. Nothing ran.`);
|
|
139
|
+
const release = await free.take(context.abortSignal);
|
|
140
|
+
try {
|
|
141
|
+
const child = await api.commit(async (tx) => {
|
|
142
|
+
// The ownership index remembers the child: a rerun of this call reuses it.
|
|
143
|
+
const existing = (await tx.scanConversations({ ownerTaskId: api.taskId }, 1)).items[0];
|
|
144
|
+
if (existing !== undefined)
|
|
145
|
+
return existing.id;
|
|
146
|
+
const created = await tx.createConversation({ ownership: { kind: "task", taskId: api.taskId } });
|
|
147
|
+
await configure(tx, created.id, {
|
|
148
|
+
// The tier's model, else the parent's own (its route through the session's proxy and booking).
|
|
149
|
+
// The child keeps the session's extension (its gate); its tools are exactly the call's subset.
|
|
150
|
+
model: model?.ref ?? parent.model,
|
|
151
|
+
// The call's effort, else the agent's own level (a task-owned conversation copies its owner's agent).
|
|
152
|
+
...(args.effort ? { thinkingLevel: args.effort } : {}),
|
|
153
|
+
tools: tools,
|
|
154
|
+
modelTools: null,
|
|
155
|
+
instructions: [options.preamble, SUBAGENT_INSTRUCTIONS].filter(Boolean).join("\n\n"),
|
|
156
|
+
});
|
|
157
|
+
if (toolCalls !== undefined)
|
|
158
|
+
Object.assign(await tx.doc(ConversationToolBudget, created.id), { toolCalls });
|
|
159
|
+
return created.id;
|
|
160
|
+
}, context);
|
|
161
|
+
// The call's details name its child: the run's timeline nests the child's rows under this call.
|
|
162
|
+
const details = { conversationId: Number(child), ...(args.model ? { model: args.model } : {}), tools: chosen.catalog, ...(toolCalls !== undefined ? { max_tool_calls: toolCalls } : {}), ...(args.effort ? { effort: args.effort } : {}) };
|
|
163
|
+
await api.details(details, context);
|
|
164
|
+
const handle = await api.conversation(child, context);
|
|
165
|
+
if (!handle)
|
|
166
|
+
return { ...fail("subagent: its conversation could not be opened. Nothing ran."), details };
|
|
167
|
+
const submission = await handle.submit({ type: "input", content: args.prompt, requestId: `subagent:${String(api.taskId)}` }, context);
|
|
168
|
+
// Never on the call's signal (durableWait): a stop while it registers rejects this wait, never one unhandled.
|
|
169
|
+
const settled = await durableWait((at) => submission.wait(at), context);
|
|
170
|
+
if (settled.status === "done" && settled.answer !== undefined) {
|
|
171
|
+
const answer = await api.commit((tx) => tx.entry(settled.answer), context);
|
|
172
|
+
const message = answer?.model?.findLast((each) => each.role === "assistant");
|
|
173
|
+
const text = textOf(message);
|
|
174
|
+
// An answer cut at the model's output limit is unfinished (as the run's own is: loop.ts cutLast): an error the
|
|
175
|
+
// parent reads, with what the child said before the cut.
|
|
176
|
+
if (message?.stopReason === PI_STOP.length)
|
|
177
|
+
return { ...fail(boundedAnswer(`subagent: its answer is unfinished: ${cutAtLimit(message.usage?.output)}${text ? `\nWhat it wrote before the cut:\n${text}` : ""}`)), details };
|
|
178
|
+
return { output: [{ type: "text", text: boundedAnswer(text || "(the subagent answered with no text)") }], details };
|
|
179
|
+
}
|
|
180
|
+
// Unanswered: its own words for why (a request the cap refused, a provider's error), from its last answer.
|
|
181
|
+
const last = await api.commit(async (tx) => (await tx.scanEntries({ conversationId: child, order: "descending" }, 20)).items.flatMap((entry) => entry.model ?? []).find((each) => each.role === "assistant"), context);
|
|
182
|
+
const why = last?.errorMessage ?? settled.reason ?? "it stopped";
|
|
183
|
+
return { ...fail(boundedAnswer(`subagent: it stopped before it answered: ${why}`)), details };
|
|
184
|
+
}
|
|
185
|
+
finally {
|
|
186
|
+
release();
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Extension } from "@earendil-works/pi-durable";
|
|
2
|
-
import { type WorkflowTaskHost } from "
|
|
2
|
+
import { type WorkflowTaskHost } from "../workflow/task.js";
|
|
3
3
|
/** A model node's tier, as the DSL names it. */
|
|
4
4
|
export type NodeTier = string | undefined;
|
|
5
5
|
/** A node tool's bindings for a model node's agent (its pi extensions and tools), as the node-tool table binds them. */
|
|
@@ -33,6 +33,11 @@ export interface DecisionDriver {
|
|
|
33
33
|
/** Resolves once the driver's commits so far are durable (a request it ended, before the run parks on it). */
|
|
34
34
|
flush(): Promise<void>;
|
|
35
35
|
}
|
|
36
|
+
/** What a held call's wrapper asks of the DSL driver: its poll window moved back by the time the run was held for a raise
|
|
37
|
+
* of its cap (dsl recovery/driver.ts holdPoll). */
|
|
38
|
+
export interface PollDriver {
|
|
39
|
+
holdPoll?(executionPath: unknown, ms: number, hold: string): void;
|
|
40
|
+
}
|
|
36
41
|
/** The run's spend cap over the workflow's adapters (app.ts's budget: stepped/failing/capStopped and the decision cap),
|
|
37
42
|
* injected so this module holds no money of its own. Each wrapper is applied to its adapter where app.ts applied it; a run
|
|
38
43
|
* with no cap (a test, or before the cap is wired) passes none and the adapters run unwrapped. `held` is a call node's
|
|
@@ -40,8 +45,12 @@ export interface DecisionDriver {
|
|
|
40
45
|
export interface WorkflowCap {
|
|
41
46
|
/** stepped(gate(capStopped(·)), true): a model node, counted in flight, failing as a cap stop where no raise fixes it. */
|
|
42
47
|
node<F>(fn: F): F;
|
|
43
|
-
/** stepped(failing(·)): a call node,
|
|
44
|
-
|
|
48
|
+
/** stepped(failing(·)): a call node, before the driver admits its effect: it waits for a raise on a held effect and
|
|
49
|
+
* goes again. */
|
|
50
|
+
effect<F>(fn: F, driver?: PollDriver): F;
|
|
51
|
+
/** A call node's effect once the driver has admitted it: held through the kernel cap, run, and settled. Absent: the
|
|
52
|
+
* effect runs as given. */
|
|
53
|
+
admittedEffect?<F>(fn: F): F;
|
|
45
54
|
/** A decision, before the driver admits its request: priced, or parked by a pause. The driver tells a replayed request,
|
|
46
55
|
* which holds nothing. */
|
|
47
56
|
judge<F>(fn: F, driver?: DecisionDriver): F;
|
|
@@ -59,6 +68,12 @@ export interface WorkflowHostDeps {
|
|
|
59
68
|
readonly provider: string;
|
|
60
69
|
readonly modelId: string;
|
|
61
70
|
};
|
|
71
|
+
/** Told as each model node's execution starts, before it runs: its execution path and the tier it asked for (the graph
|
|
72
|
+
* keeps what each execution ran on). Absent: nothing told. */
|
|
73
|
+
readonly onModelNode?: (node: {
|
|
74
|
+
readonly executionPath: string;
|
|
75
|
+
readonly tier?: string;
|
|
76
|
+
}) => Promise<void>;
|
|
62
77
|
/** The thinking level every node agent runs at. */
|
|
63
78
|
readonly thinkingLevel?: unknown;
|
|
64
79
|
/** The extensions every model node's agent shares (the coding extension and the gate), installed in the registry too. */
|
|
@@ -80,6 +95,12 @@ export interface WorkflowHostDeps {
|
|
|
80
95
|
readonly flush: () => Promise<void>;
|
|
81
96
|
/** The node log's node.start/node.end lines; absent: no log. */
|
|
82
97
|
readonly log?: (line: Record<string, unknown>) => void;
|
|
98
|
+
/** Told each workflow step's start and end, by its label (the workflow's node.start/node.end): what a cap's pause reads
|
|
99
|
+
* to name the node whose step it held (workflow-spec.ts openSteps). */
|
|
100
|
+
readonly steps?: {
|
|
101
|
+
start(label: string): void;
|
|
102
|
+
end(label: string): void;
|
|
103
|
+
};
|
|
83
104
|
/** What a decision's receipt is shown as, as it is recorded (the live view); absent: not shown. */
|
|
84
105
|
readonly onReceipt?: (receipt: Record<string, unknown>) => void;
|
|
85
106
|
/** The run's spend cap over the adapters; absent: the workflow runs with no cap. */
|
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import { decisionRecovery
|
|
1
|
+
import { decisionRecovery } from "../workflow/decision-recovery.js";
|
|
2
|
+
import { nodeRunner } from "../workflow/node-runner.js";
|
|
3
|
+
import { taskScope } from "../workflow/node.js";
|
|
2
4
|
import { judgeFromProviders } from "@parcha/agentrun-dsl";
|
|
3
5
|
import { withRecovery, workspaceFiles } from "@parcha/agentrun-dsl/recovery";
|
|
4
6
|
const identityCap = { node: (fn) => fn, effect: (fn) => fn, judge: (fn) => fn };
|
|
7
|
+
/** `runNode` that tells `told` of each model node's execution (its path and tier) before it runs it. */
|
|
8
|
+
function withModelNode(runNode, told) {
|
|
9
|
+
if (!told)
|
|
10
|
+
return runNode;
|
|
11
|
+
return async (params) => {
|
|
12
|
+
if (typeof params.executionPath === "string")
|
|
13
|
+
await told({ executionPath: params.executionPath, ...(typeof params.tier === "string" ? { tier: params.tier } : {}) });
|
|
14
|
+
return runNode(params);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
5
17
|
/** The workflow task's host and the extensions to install before the Harness opens, as the per-run process built them.
|
|
6
18
|
* Pass the result to createWorkflowLoop's spec.build. */
|
|
7
19
|
export function workflowHost(deps) {
|
|
@@ -20,6 +32,13 @@ export function workflowHost(deps) {
|
|
|
20
32
|
const nodes = nodeRunner({ agent: (node) => nodeAgent(node) });
|
|
21
33
|
/** The node log's starts and ends, from the workflow's events (app.ts onEvent). */
|
|
22
34
|
const onEvent = (event) => {
|
|
35
|
+
// A nested `workflow` step stays open while its own steps run and sends no request itself: the steps open are the ones
|
|
36
|
+
// that can, so a pause inside it names its step, never nothing.
|
|
37
|
+
const enclosing = event.detail?.kind === "workflow";
|
|
38
|
+
if (typeof event.label === "string" && event.type === "node.start" && !enclosing)
|
|
39
|
+
deps.steps?.start(event.label);
|
|
40
|
+
if (typeof event.label === "string" && event.type === "node.end" && !enclosing)
|
|
41
|
+
deps.steps?.end(event.label);
|
|
23
42
|
if (!deps.log || (event.type !== "node.start" && event.type !== "node.end") || typeof event.executionPath !== "string")
|
|
24
43
|
return;
|
|
25
44
|
const detail = (event.detail ?? {});
|
|
@@ -37,8 +56,9 @@ export function workflowHost(deps) {
|
|
|
37
56
|
run: ({ key, runtime, context, driver }) => {
|
|
38
57
|
const decisions = decisionRecovery({ key, runtime: runtime, context });
|
|
39
58
|
const recovered = withRecovery(driver, {
|
|
40
|
-
runNode: nodes.on(taskScope(runtime), context).runNode,
|
|
41
|
-
|
|
59
|
+
runNode: withModelNode(nodes.on(taskScope(runtime), context).runNode, deps.onModelNode),
|
|
60
|
+
// The effect the driver runs once it has admitted it: the cap holds and settles a paid call there (admittedEffect).
|
|
61
|
+
runEffect: (cap.admittedEffect ? cap.admittedEffect(deps.runEffect) : deps.runEffect),
|
|
42
62
|
// The judge the driver asks once it has admitted a request: the cap holds, sends and settles it there (admitted).
|
|
43
63
|
...(deps.decisionProviders ? { runJudge: admitted(judgeFromProviders({ ...deps.decisionProviders, loadImage: deps.loadImage })), decisionProviders: deps.decisionProviders } : {}),
|
|
44
64
|
recordDecision: async (receipt, exchange) => {
|
|
@@ -54,7 +74,7 @@ export function workflowHost(deps) {
|
|
|
54
74
|
return { deps: {
|
|
55
75
|
...recovered,
|
|
56
76
|
runNode: cap.node(recovered.runNode),
|
|
57
|
-
runEffect: cap.effect(recovered.runEffect),
|
|
77
|
+
runEffect: cap.effect(recovered.runEffect, driver),
|
|
58
78
|
...(recovered.runJudge ? { runJudge: cap.judge(recovered.runJudge, driver) } : {}),
|
|
59
79
|
onEvent,
|
|
60
80
|
...(cap.held ? { held: (path) => cap.held(path) } : {}),
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import { type Extension, Harness } from "@earendil-works/pi-durable";
|
|
3
3
|
import type { Models } from "@earendil-works/pi-ai";
|
|
4
4
|
import type { Workflow } from "@parcha/agentrun-dsl";
|
|
5
|
-
import { type WorkflowTaskHost } from "
|
|
5
|
+
import { type WorkflowTaskHost } from "../workflow/task.js";
|
|
6
6
|
import { type BudgetData, type EndData } from "./journal-kinds.js";
|
|
7
7
|
import { type Claim, type Journal, type LoopFactory } from "./loop-contract.js";
|
|
8
8
|
/** A cap refusal, as the kernel cap hands one to parkOf/checkRaise (the loop never imports the cap; its rule is handed in
|
|
9
9
|
* via the spec, so flat or tiered pricing is the cap's, not this loop's). */
|
|
10
|
+
/** `node`: the label of the workflow node whose step the cap held (a model node's request, a call node's call, a
|
|
11
|
+
* decision), which the run's pending budget names; absent when the step's node is not known. */
|
|
10
12
|
export type CapRefusal = {
|
|
11
13
|
readonly message: string;
|
|
12
14
|
readonly forGood: boolean;
|
|
13
15
|
readonly figures?: unknown;
|
|
16
|
+
readonly node?: string;
|
|
14
17
|
};
|
|
15
18
|
/** A raise's state as the cap's checkRaise reads it (the kernel cap's RaiseState). */
|
|
16
19
|
export type RaiseState = {
|
|
@@ -105,7 +108,7 @@ export interface WorkflowRunSpec {
|
|
|
105
108
|
export interface WorkflowHostHooks {
|
|
106
109
|
/** A step the cap holds for a raise lets go here, with the cap's refusal: the loop parks the run (parkOf's pending
|
|
107
110
|
* budget, in the cap's words) and a later claim resumes the workflow from its journal (the held step was never admitted,
|
|
108
|
-
* so nothing is half done), with the raised cap. The caller must let the node's signal, which the loop aborts, end the
|
|
111
|
+
* or ended held with nothing sent, so nothing is half done), with the raised cap. The caller must let the node's signal, which the loop aborts, end the
|
|
109
112
|
* step's wait. */
|
|
110
113
|
park(refusal: CapRefusal): void;
|
|
111
114
|
/** Whether a person's pause is in force (POST /runs/{id}/pause: a `pause` command taken with no `resume` after it). The
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The workflow loop on the runner (design: "Runners carry many loops"; the lead's ruling, workflow agents keep running
|
|
2
2
|
// after the cutover). A run of a workflow revision, which the runner claims like any run: this loop is its driver, so the
|
|
3
3
|
// claim, the fence, a cancel and the end commit are its. The DSL's durable runner (workflow-run.ts
|
|
4
|
-
// startWorkflowRevision over
|
|
4
|
+
// startWorkflowRevision over the workflow task, workflow/task.ts) runs the revision's workflow UNCHANGED — the same nodes,
|
|
5
5
|
// decisions, call tools and cap it ran with in the per-run process — on the run's journal in the one store (A,
|
|
6
6
|
// deps.journal(claim)) in place of a per-run store file. The interpreter's host (model nodes on the run's models, call
|
|
7
7
|
// nodes on the tool table, decisions, the cap) is built by the caller (WorkflowRunSpec.build), exactly as the per-run
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
// shutdown writes nothing more and the next claim resumes.
|
|
20
20
|
import { BACKGROUND_CONTEXT, withAbortSignal } from "@earendil-works/chord/context";
|
|
21
21
|
import { createRegistry, Harness, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
22
|
-
import { createWorkflowExtension } from "
|
|
22
|
+
import { createWorkflowExtension } from "../workflow/task.js";
|
|
23
23
|
import { readWorkflowRun, startWorkflowRevision, workflowCarry } from "../workflow-run.js";
|
|
24
24
|
import { KINDS } from "./journal-kinds.js";
|
|
25
|
-
import {
|
|
25
|
+
import { stopEnd } from "./loop-contract.js";
|
|
26
26
|
/** The most the end's patch (cost and metrics) may take before the end is written without it (the pi loop's CUT_STEP_MS). */
|
|
27
27
|
const CUT_STEP_MS = 2_000;
|
|
28
28
|
/** A paused run's words, its row's summary while it waits for a resume. */
|
|
@@ -270,10 +270,10 @@ function workflowLoop(specOf, deps) {
|
|
|
270
270
|
await closeHarness();
|
|
271
271
|
const endJournal = deps.journal(claim);
|
|
272
272
|
// A person stopped or cancelled: the run ends stopped whatever the workflow's own outcome (its last node may have
|
|
273
|
-
// completed as the stop landed, since the engine cancels by aborting the task), in the words that say
|
|
274
|
-
// with the stop row taken in the end commit.
|
|
273
|
+
// completed as the stop landed, since the engine cancels by aborting the task), in the words and the outcome that say
|
|
274
|
+
// which (stopEnd), with the stop row taken in the end commit. A workflow run is never reopened, either way.
|
|
275
275
|
if (stopReason?.kind === "command")
|
|
276
|
-
return await writeEnd(endJournal, context,
|
|
276
|
+
return await writeEnd(endJournal, context, stopEnd(stopReason.cancel));
|
|
277
277
|
const carry = await workflowCarry({ runId: claim.runId, storage: endJournal, revision }, outcome, { context });
|
|
278
278
|
// A completed run's output, read as main's server read it once the workflow completed (runs.ts workflowEnd:
|
|
279
279
|
// readWorkflowRun's `output`, null when it has none), kept on its end for result.output.
|
|
@@ -304,13 +304,14 @@ function workflowLoop(specOf, deps) {
|
|
|
304
304
|
return { state: "interrupted" };
|
|
305
305
|
if (parked.outcome === "failed")
|
|
306
306
|
return await writeEnd(journal, BACKGROUND_CONTEXT, { state: "failed", summary: parked.error });
|
|
307
|
-
|
|
307
|
+
// A workflow's pause names the node whose step waits at the cap (null when it is not known), as its pending budget shows.
|
|
308
|
+
const budget = { pending: parked.pending, words: parked.words, node: refusal.node ?? null };
|
|
308
309
|
await append(journal, BACKGROUND_CONTEXT, KINDS.budget, budget, { run: { state: "parked", summary: parked.words } });
|
|
309
310
|
return { state: "parked" };
|
|
310
311
|
}
|
|
311
312
|
async function writeEnd(journal, context, carry) {
|
|
312
313
|
const state = carry.state === "failed" ? "failed" : carry.state === "stopped" ? "stopped" : "ended";
|
|
313
|
-
const outcome = carry.state === "escalated" ? "escalated" : undefined;
|
|
314
|
+
const outcome = carry.state === "escalated" ? "escalated" : carry.state === "stopped" ? carry.outcome : undefined;
|
|
314
315
|
const base = { state, summary: carry.summary, ...(outcome ? { outcome } : {}), ...(carry.output !== undefined ? { output: carry.output } : {}), ...(carry.review ? { review: carry.review } : {}) };
|
|
315
316
|
const patch = await endPatchOf(spec, base);
|
|
316
317
|
const data = { ...base, ...(patch.costUsd !== undefined ? { costUsd: patch.costUsd } : {}), ...(patch.metrics !== undefined ? { metrics: patch.metrics } : {}) };
|
|
@@ -2,7 +2,7 @@ import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
|
2
2
|
import { type DecisionProvider, type LoadImage, type Workflow } from "@parcha/agentrun-dsl";
|
|
3
3
|
import { type BeforeRequest, type Wire } from "@parcha/agentrun-kernel";
|
|
4
4
|
import { type ProviderPolicy, type ProxyUsage } from "@parcha/agentrun-kernel/host";
|
|
5
|
-
import { type CapModel } from "@parcha/agentrun-kernel/kernel/cap";
|
|
5
|
+
import { type CapModel, type RunDecisions } from "@parcha/agentrun-kernel/kernel/cap";
|
|
6
6
|
import { type Tier } from "../model.js";
|
|
7
7
|
import { deniedText } from "../refusal-words.js";
|
|
8
8
|
import { type PaidBooking } from "../paid-calls.js";
|
|
@@ -11,10 +11,6 @@ import { type ModelRoute } from "./model-route.js";
|
|
|
11
11
|
import { type CapRefusal, type WorkflowHostHooks, type WorkflowRunSpec, type WorkflowSpecRun } from "./workflow-loop.js";
|
|
12
12
|
import { type WorkflowCap } from "./workflow-host.js";
|
|
13
13
|
import type { Store } from "../store/store.js";
|
|
14
|
-
/** A model node's submit tool, by name: pi's SUBMIT_TOOL (packages/pi/src/host-tools.ts). Named here, not imported from
|
|
15
|
-
* @parcha/agentrun-pi, whose root loads its runner and with it pi-coding-agent, an optional peer an installed server
|
|
16
|
-
* does not have: importing it here stopped the runner from starting. workflow-submit-name.test.mjs holds the two equal. */
|
|
17
|
-
export declare const SUBMIT_TOOL = "submit";
|
|
18
14
|
/** How a tier's model is reached and priced, resolved by the caller for each tier the workflow names: the proxy's provider
|
|
19
15
|
* (its API, origin, credential and policy), the catalog price the proxy books an answered request at (calculateCost,
|
|
20
16
|
* tiered), and the cap's model (its price the catalog's cost as given). A test gives a scripted origin and fetch. */
|
|
@@ -87,7 +83,15 @@ export declare function workflowSpecOf(deps: WorkflowSpecDeps): (claim: {
|
|
|
87
83
|
/** The run's rule with a park on a refusal: `before` (runCap's one rule for the model session) is asked, and on a refusal
|
|
88
84
|
* the run parks through the loop's hook (parkOf decides room vs for good from the refusal), the same as the pi adapter's
|
|
89
85
|
* parkAtCap. It still returns the refusal, so the proxy refuses the request and the node's turn ends. */
|
|
90
|
-
export declare function parkOnRefusal(before: BeforeRequest, hooks: Pick<WorkflowHostHooks, "park" | "paused" | "pause">, flight?: EffectsInFlight): BeforeRequest;
|
|
86
|
+
export declare function parkOnRefusal(before: BeforeRequest, hooks: Pick<WorkflowHostHooks, "park" | "paused" | "pause">, flight?: EffectsInFlight, steps?: OpenSteps): BeforeRequest;
|
|
87
|
+
/** The workflow's steps under way, by label (the workflow's node.start/node.end, through the host): `only` is the label
|
|
88
|
+
* of the one step open (a map's several items open at once are one label), else undefined (none, or different steps at once). */
|
|
89
|
+
export interface OpenSteps {
|
|
90
|
+
start(label: string): void;
|
|
91
|
+
end(label: string): void;
|
|
92
|
+
only(): string | undefined;
|
|
93
|
+
}
|
|
94
|
+
export declare function openSteps(): OpenSteps;
|
|
91
95
|
/** How many call nodes' effects are in flight (pauseAtEffects counts them; parkOnRefusal reads it). */
|
|
92
96
|
export interface EffectsInFlight {
|
|
93
97
|
count: number;
|
|
@@ -101,7 +105,7 @@ export declare function pauseAtEffects(cap: WorkflowCap, hooks: Pick<WorkflowHos
|
|
|
101
105
|
/** A call node `via: "tool"`: the node-tool table's effect (toolOf(tool).effect) with the run's ctx, as app.ts ran it. Its
|
|
102
106
|
* paid requests (its `llm` call) book through the run's models under the cap. A cap-held request ends the effect held
|
|
103
107
|
* (CAP_HELD), a tool failure as the tool's own (TOOL_FAILED); the loop's `failing` reads both. */
|
|
104
|
-
/** What a call node's request may cost at most, judged
|
|
108
|
+
/** What a call node's request may cost at most, judged once the engine has admitted it (holdAtEffects): a Parallel search's
|
|
105
109
|
* or extract's fee as paidRequest prices it (a fixed fee, what it may charge at most); an `llm` call's request at the
|
|
106
110
|
* cap's worst price for it (its model's tiered rates over an input bound of one token per UTF-8 byte of its prompt and
|
|
107
111
|
* system plus LLM_FRAMING_BYTES for the request's own framing, and the output it asks for, else its model's most);
|
|
@@ -110,7 +114,6 @@ export declare function pauseAtEffects(cap: WorkflowCap, hooks: Pick<WorkflowHos
|
|
|
110
114
|
export type CallHold = {
|
|
111
115
|
readonly usd: number;
|
|
112
116
|
readonly name: string;
|
|
113
|
-
readonly tool?: string;
|
|
114
117
|
readonly basis: string;
|
|
115
118
|
readonly chargedBy?: string;
|
|
116
119
|
readonly llm?: {
|
|
@@ -122,16 +125,25 @@ export declare const LLM_FRAMING_BYTES = 2048;
|
|
|
122
125
|
/** The output an `llm` call that names none is sent asking for at most (port-models.ts sessionModel's maxTokens). */
|
|
123
126
|
export declare const LLM_DEFAULT_OUTPUT = 32000;
|
|
124
127
|
export declare function callHoldOf(tool: string, input: Record<string, unknown>, env: NodeJS.ProcessEnv, modelOfTier: (tier: string | undefined) => CapModel | undefined): CallHold;
|
|
125
|
-
/** `cap` with each call node's most cost held on the run's one ledger
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
128
|
+
/** `cap` with each call node's most cost held on the run's one ledger, in two halves around the DSL driver's admission of
|
|
129
|
+
* its effect (dsl recovery/driver.ts wrapEffect: the effect is committed admitted before it is dispatched, and one
|
|
130
|
+
* admitted and never completed is never dispatched again):
|
|
131
|
+
* - `admittedEffect`, the effect the driver runs once it has admitted it: the call is priced (`holdOf`) and its hold
|
|
132
|
+
* taken (its record made durable before anything is sent), so a hold is never kept for an effect the driver did not
|
|
133
|
+
* admit: a process that dies before the admission leaves nothing for the next claim to count beside running the call
|
|
134
|
+
* again, and one that dies after it leaves the effect admitted, which the next claim never runs again, under the one
|
|
135
|
+
* hold it counts. Held, the effect runs with the hold as its reservation; what is not taken is given back at its end.
|
|
136
|
+
* A hold the cap refuses ends the effect completed with nothing sent: refused for room, as held (CAP_HELD); refused
|
|
137
|
+
* for good, as the call's failure in the cap's words (TOOL_FAILED). So does the net: a call whose answer cost more
|
|
138
|
+
* than its hold (an `llm` answer priced at its usage).
|
|
139
|
+
* - `effect`, outside the driver: an effect this process ended held parks the run (`park`, as a model request's refusal
|
|
140
|
+
* does) once that end is durable (`flush`), and waits on the node's signal. One an earlier claim ended held (its
|
|
141
|
+
* receipt, replayed) is the park that claim made: the call goes again, a new effect judged at this claim's cap. */
|
|
131
142
|
export declare function holdAtEffects(cap: WorkflowCap, deps: {
|
|
132
143
|
readonly paid: () => RunTools | undefined;
|
|
133
144
|
readonly holdOf: (tool: string, input: Record<string, unknown>) => CallHold;
|
|
134
145
|
readonly park: (refusal: CapRefusal) => void;
|
|
146
|
+
readonly flush: () => Promise<void>;
|
|
135
147
|
}): WorkflowCap;
|
|
136
148
|
/** The reservation of the call node this request runs under, given back as the request is judged on its own (an `llm`
|
|
137
149
|
* call's model request): its hold is the request's from here. */
|
|
@@ -157,6 +169,18 @@ type CallPolicy = (tool: string) => Promise<{
|
|
|
157
169
|
* as an EffectFailure in those words, so the call node fails and the run with it in the tool's words. Applied outside
|
|
158
170
|
* the cap's own effect wrapper, on the outcome it returns. */
|
|
159
171
|
export declare function failingEffects(cap: WorkflowCap): WorkflowCap;
|
|
172
|
+
/** A decision under the run's cap with no DSL driver around it (no request committed, none asked again): both halves of
|
|
173
|
+
* decisionJudging in one, `before` over `admitted`. It prices the request as main does (holdOf), admits it through the
|
|
174
|
+
* kernel cap, asks the judge and settles the hold at what the answer charged; a refusal for room parks the run through
|
|
175
|
+
* the hook, one for no price fails it, and a price the catalog could not read fails the decision node unsent.
|
|
176
|
+
* learned-workflow.ts wraps a learned workflow's decisions in it (LS-07), over the agent run's ledger.decisions: a
|
|
177
|
+
* learned_workflow call is never run again. */
|
|
178
|
+
export declare function decisionJudge<F>(inner: F, deps: {
|
|
179
|
+
getCap: () => RunDecisions | undefined;
|
|
180
|
+
providers: DecisionProviders;
|
|
181
|
+
park: (refusal: CapRefusal) => void;
|
|
182
|
+
hooks?: Pick<WorkflowHostHooks, "paused" | "pause">;
|
|
183
|
+
}): F;
|
|
160
184
|
/** The tools the workflow may call, for the host to register. */
|
|
161
185
|
/** The tools a workflow's model node takes on the runner: main's NODE_TOOLS (tools.ts) that bind through a ToolHost alone.
|
|
162
186
|
* Its file tools (read, write, edit) need the run's Workspace and its browser a computer, which the workflow loop does not
|
|
@@ -172,7 +196,7 @@ type GatedExecute = (args: never, api: never, context: never) => Promise<unknown
|
|
|
172
196
|
* was sent) and the tool is now denied or set to ask, the refusal says that whether it took effect is not known
|
|
173
197
|
* (RAN_UNKNOWN), never that it was not run or that nothing was sent and nothing was charged. */
|
|
174
198
|
export declare function gatedNodeCall(name: string, policy: CallPolicy, execute: GatedExecute): GatedExecute;
|
|
175
|
-
/** The tool names a workflow's model node offers its model: the node's `submit` (
|
|
199
|
+
/** The tool names a workflow's model node offers its model: the node's `submit` (SUBMIT_TOOL) and every tool the
|
|
176
200
|
* workflow's model nodes name. */
|
|
177
201
|
export declare function nodeOffer(workflow: Workflow): string[];
|
|
178
202
|
export { BACKGROUND_CONTEXT };
|