@parcha/agentrun-serve 0.1.0-beta.37 → 0.1.0-beta.39
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 +700 -0
- package/README.md +441 -177
- package/dist/adapters.d.ts +4 -1
- package/dist/adapters.js +4 -2
- package/dist/agent-rows.d.ts +1 -3
- package/dist/agents-store.d.ts +35 -3
- package/dist/agents-store.js +48 -23
- package/dist/answer-json.d.ts +34 -1
- package/dist/answer-json.js +91 -9
- package/dist/api-only.d.ts +1 -1
- package/dist/api-only.js +2 -2
- package/dist/bash-read-only.js +2 -1
- package/dist/browser-cost.js +52 -93
- package/dist/cap-short.d.ts +12 -0
- package/dist/cap-short.js +60 -0
- package/dist/cap.d.ts +3 -400
- package/dist/cap.js +6 -942
- package/dist/catalog.d.ts +0 -5
- package/dist/catalog.js +2 -6
- package/dist/chatgpt-plan.d.ts +163 -0
- package/dist/chatgpt-plan.js +549 -0
- package/dist/cli.js +26 -6
- package/dist/composio-preset.d.ts +25 -0
- package/dist/composio-preset.js +51 -8
- package/dist/composio-triggers.d.ts +113 -0
- package/dist/composio-triggers.js +411 -0
- package/dist/computer-calls.d.ts +36 -24
- package/dist/computer-calls.js +110 -27
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +7 -3
- package/dist/computer-live.d.ts +12 -2
- package/dist/computer-live.js +21 -5
- package/dist/computer-routes.d.ts +2 -2
- package/dist/computer-routes.js +2 -2
- package/dist/computer-setting.d.ts +15 -2
- package/dist/computer-setting.js +20 -4
- package/dist/computer-view.d.ts +18 -2
- package/dist/computer-view.js +21 -6
- package/dist/computer-viewer.js +40 -13
- package/dist/computers.d.ts +8 -2
- package/dist/computers.js +18 -8
- package/dist/console/assets/index-BNhZs-jp.css +1 -0
- package/dist/console/assets/index-BQv5aOGB.js +700 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +2 -0
- package/dist/console-links.js +6 -3
- package/dist/decision-cap.d.ts +2 -5
- package/dist/decision-cap.js +3 -6
- package/dist/decision-rows.js +11 -11
- package/dist/decisions.js +4 -0
- package/dist/email/account.d.ts +84 -0
- package/dist/email/account.js +159 -0
- package/dist/email/answer.d.ts +10 -0
- package/dist/email/answer.js +182 -0
- package/dist/email/email-faux.d.ts +95 -0
- package/dist/email/email-faux.js +849 -0
- package/dist/email/labels.d.ts +1 -0
- package/dist/email/labels.js +84 -0
- package/dist/email/mail.d.ts +186 -0
- package/dist/email/mail.js +380 -0
- package/dist/email/names.d.ts +20 -0
- package/dist/email/names.js +40 -0
- package/dist/email/routes.d.ts +9 -0
- package/dist/email/routes.js +50 -0
- package/dist/email/tools.d.ts +20 -0
- package/dist/email/tools.js +517 -0
- package/dist/environment.d.ts +17 -2
- package/dist/environment.js +36 -8
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +12 -0
- package/dist/eval-mailbox.d.ts +103 -0
- package/dist/eval-mailbox.js +236 -0
- package/dist/faux-computers.js +4 -2
- package/dist/graph-view.d.ts +9 -2
- package/dist/graph-view.js +6 -2
- package/dist/harness-install.d.ts +28 -2
- package/dist/harness-install.js +147 -59
- package/dist/harness-opencode/adapter.js +2 -22
- package/dist/harness-opencode/facts.js +5 -4
- package/dist/harness-opencode/host/policy.d.ts +4 -5
- package/dist/harness-opencode/host/policy.js +14 -33
- package/dist/harness-opencode/index.d.ts +1 -1
- package/dist/harness-opencode/index.js +1 -1
- package/dist/harness-opencode/versions.d.ts +6 -0
- package/dist/harness-opencode/versions.js +6 -0
- package/dist/harness-table.d.ts +0 -2
- package/dist/harness-table.js +8 -7
- package/dist/harness.d.ts +12 -0
- package/dist/harness.js +15 -3
- package/dist/host-tools.d.ts +1 -5
- package/dist/host-tools.js +7 -10
- package/dist/hosted-search.d.ts +3 -3
- package/dist/hosted-search.js +51 -32
- package/dist/import-sources.d.ts +1 -1
- package/dist/import-sources.js +3 -3
- package/dist/import.d.ts +21 -0
- package/dist/import.js +186 -1
- package/dist/key-check.d.ts +0 -2
- package/dist/key-check.js +3 -4
- package/dist/key-refusal.d.ts +8 -2
- package/dist/key-refusal.js +16 -13
- package/dist/key-words.d.ts +3 -2
- package/dist/key-words.js +4 -2
- package/dist/learn/check.d.ts +24 -4
- package/dist/learn/check.js +340 -7
- package/dist/learn/commit.d.ts +10 -0
- package/dist/learn/commit.js +18 -4
- package/dist/learn/compile.d.ts +250 -0
- package/dist/learn/compile.js +507 -0
- package/dist/learn/general.d.ts +3 -0
- package/dist/learn/general.js +4 -2
- package/dist/learn/grade.d.ts +5 -1
- package/dist/learn/grade.js +11 -7
- package/dist/learn/notes.d.ts +8 -0
- package/dist/learn/notes.js +18 -0
- package/dist/learn/promote.d.ts +308 -0
- package/dist/learn/promote.js +321 -0
- package/dist/learn/refit.d.ts +48 -0
- package/dist/learn/refit.js +264 -0
- package/dist/learn/reflect.d.ts +5 -25
- package/dist/learn/reflect.js +14 -131
- package/dist/learn/replay-calls.d.ts +63 -0
- package/dist/learn/replay-calls.js +158 -0
- package/dist/learn/skills.d.ts +19 -16
- package/dist/learn/skills.js +157 -53
- package/dist/learn/workflow-nodes.d.ts +15 -0
- package/dist/learn/workflow-nodes.js +44 -0
- package/dist/learned-nodes.d.ts +58 -2
- package/dist/learned-nodes.js +68 -5
- package/dist/learned-workflow.d.ts +58 -32
- package/dist/learned-workflow.js +215 -77
- package/dist/learning-batch.d.ts +2 -2
- package/dist/learning-batch.js +4 -4
- package/dist/learning-cost.d.ts +41 -11
- package/dist/learning-cost.js +31 -13
- package/dist/learning-routes.d.ts +12 -2
- package/dist/learning-routes.js +34 -6
- package/dist/learning-words.d.ts +8 -1
- package/dist/learning-words.js +11 -1
- package/dist/learning.d.ts +26 -1
- package/dist/learning.js +7 -4
- package/dist/link-check.d.ts +27 -0
- package/dist/link-check.js +164 -0
- package/dist/llm.js +0 -3
- package/dist/local-models.d.ts +33 -2
- package/dist/local-models.js +43 -5
- package/dist/mcp-gateway.d.ts +12 -20
- package/dist/mcp-gateway.js +16 -44
- package/dist/mcp-oauth.d.ts +5 -0
- package/dist/mcp-oauth.js +1 -1
- package/dist/mcp-pin-first.d.ts +37 -0
- package/dist/mcp-pin-first.js +113 -0
- package/dist/mcp-probe.d.ts +8 -9
- package/dist/mcp-probe.js +16 -33
- package/dist/mcp-secret-writes.js +3 -0
- package/dist/mcp-servers-store.d.ts +102 -26
- package/dist/mcp-servers-store.js +151 -25
- package/dist/mcp-sources.d.ts +39 -0
- package/dist/mcp-sources.js +74 -0
- package/dist/mcp-store.d.ts +11 -0
- package/dist/mcp-store.js +16 -2
- package/dist/mcp-wire.d.ts +22 -0
- package/dist/mcp-wire.js +36 -0
- package/dist/mcp.js +3 -3
- package/dist/meta-tool-names.d.ts +1 -0
- package/dist/meta-tool-names.js +3 -0
- package/dist/model-form.d.ts +11 -0
- package/dist/model-form.js +17 -1
- package/dist/model.d.ts +39 -6
- package/dist/model.js +171 -32
- package/dist/monid.d.ts +50 -29
- package/dist/monid.js +234 -143
- package/dist/native/binding.d.ts +13 -0
- package/dist/native/binding.js +57 -0
- package/dist/native/cli.d.ts +2 -0
- package/dist/native/cli.js +48 -0
- package/dist/native/connection.d.ts +8 -0
- package/dist/native/connection.js +94 -0
- package/dist/native/context.d.ts +6 -0
- package/dist/native/context.js +22 -0
- package/dist/native/discovery.d.ts +27 -0
- package/dist/native/discovery.js +404 -0
- package/dist/native/environment.d.ts +4 -0
- package/dist/native/environment.js +18 -0
- package/dist/native/history.d.ts +20 -0
- package/dist/native/history.js +147 -0
- package/dist/native/instructions.d.ts +21 -0
- package/dist/native/instructions.js +173 -0
- package/dist/native/remote-worker-bridge.d.ts +3 -0
- package/dist/native/remote-worker-bridge.js +278 -0
- package/dist/native/remote.d.ts +187 -0
- package/dist/native/remote.js +492 -0
- package/dist/native/runtime.d.ts +17 -0
- package/dist/native/runtime.js +316 -0
- package/dist/native/runtimes.d.ts +66 -0
- package/dist/native/runtimes.js +41 -0
- package/dist/native/schema.d.ts +46 -0
- package/dist/native/schema.js +41 -0
- package/dist/native/types.d.ts +87 -0
- package/dist/native/types.js +1 -0
- package/dist/observation/http.d.ts +4 -0
- package/dist/observation/http.js +140 -0
- package/dist/observation/observer.d.ts +301 -0
- package/dist/observation/observer.js +919 -0
- package/dist/observation/schema.d.ts +52 -0
- package/dist/observation/schema.js +154 -0
- package/dist/openapi.d.ts +1 -0
- package/dist/openapi.js +705 -126
- package/dist/paid-calls.d.ts +34 -32
- package/dist/paid-calls.js +52 -104
- package/dist/place-offers.d.ts +4 -8
- package/dist/place-offers.js +4 -9
- package/dist/port-models.d.ts +7 -2
- package/dist/port-models.js +5 -2
- package/dist/print.d.ts +4 -2
- package/dist/print.js +4 -3
- package/dist/propose.d.ts +8 -3
- package/dist/propose.js +28 -7
- package/dist/provider.d.ts +5 -1
- package/dist/provider.js +17 -2
- package/dist/push-handler.d.ts +3 -2
- package/dist/push-handler.js +20 -6
- package/dist/reflect-range.js +2 -1
- package/dist/refusal-words.d.ts +11 -0
- package/dist/refusal-words.js +13 -2
- package/dist/rows.d.ts +5 -3
- package/dist/rows.js +15 -4
- package/dist/run-launch.d.ts +23 -1
- package/dist/run-launch.js +17 -4
- package/dist/run-learning-served.d.ts +84 -0
- package/dist/run-manifest.d.ts +8 -0
- package/dist/run-manifest.js +33 -1
- package/dist/run-reads-over-store.d.ts +3 -3
- package/dist/run-reads-over-store.js +13 -10
- package/dist/run-secrets.js +2 -3
- package/dist/run-timeline-served.d.ts +3 -2
- package/dist/run-timeline-served.js +12 -10
- package/dist/run-view.d.ts +59 -41
- package/dist/run-view.js +128 -64
- package/dist/runnable.d.ts +13 -8
- package/dist/runnable.js +77 -60
- package/dist/runner/adapter-loop.d.ts +60 -15
- package/dist/runner/adapter-loop.js +1406 -464
- package/dist/runner/adapter-run-spec.d.ts +45 -14
- package/dist/runner/adapter-run-spec.js +200 -116
- package/dist/runner/adapters/pi.d.ts +40 -7
- package/dist/runner/adapters/pi.js +149 -38
- package/dist/runner/beside.d.ts +3 -1
- package/dist/runner/beside.js +24 -8
- package/dist/runner/claim-secrets.d.ts +3 -1
- package/dist/runner/claim-secrets.js +28 -4
- package/dist/runner/cli-run-spec.d.ts +30 -0
- package/dist/runner/cli-run-spec.js +150 -66
- package/dist/runner/computer-channel.d.ts +5 -2
- package/dist/runner/computer-channel.js +5 -3
- package/dist/runner/computer-journal.d.ts +6 -0
- package/dist/runner/computer-journal.js +8 -10
- package/dist/runner/conformance/harness.d.ts +3 -0
- package/dist/runner/conformance/harness.js +149 -5
- package/dist/runner/conformance/subject.d.ts +11 -4
- package/dist/runner/end-of-run.d.ts +8 -5
- package/dist/runner/end-of-run.js +11 -6
- package/dist/runner/feedback-round.d.ts +79 -0
- package/dist/runner/feedback-round.js +127 -0
- package/dist/runner/harness-loops.js +17 -0
- package/dist/runner/journal-kinds.d.ts +55 -13
- package/dist/runner/journal-kinds.js +19 -0
- package/dist/runner/learning-dispatch.d.ts +3 -2
- package/dist/runner/learning-dispatch.js +6 -6
- package/dist/runner/learning-end.d.ts +58 -19
- package/dist/runner/learning-end.js +316 -115
- package/dist/runner/learning-factory.d.ts +3 -0
- package/dist/runner/learning-factory.js +8 -2
- package/dist/runner/learning-loop.d.ts +21 -1
- package/dist/runner/learning-loop.js +24 -6
- package/dist/runner/learning-seed.d.ts +4 -0
- package/dist/runner/learning-seed.js +14 -0
- package/dist/runner/loop-contract.d.ts +19 -3
- package/dist/runner/loop.d.ts +34 -1
- package/dist/runner/loop.js +55 -1
- package/dist/runner/main.d.ts +6 -1
- package/dist/runner/main.js +26 -4
- package/dist/runner/mcp-claim.d.ts +5 -1
- package/dist/runner/mcp-claim.js +66 -50
- package/dist/runner/mcp-run.d.ts +20 -53
- package/dist/runner/mcp-run.js +22 -88
- package/dist/runner/meta-tools.d.ts +44 -0
- package/dist/runner/meta-tools.js +344 -0
- package/dist/runner/metrics.d.ts +80 -21
- package/dist/runner/metrics.js +128 -42
- package/dist/runner/model-route.d.ts +12 -3
- package/dist/runner/model-route.js +149 -19
- package/dist/runner/monid-run.d.ts +18 -0
- package/dist/runner/monid-run.js +170 -0
- package/dist/runner/native-loop.d.ts +11 -0
- package/dist/runner/native-loop.js +438 -0
- package/dist/runner/promotion.d.ts +146 -0
- package/dist/runner/promotion.js +803 -0
- package/dist/runner/redact.js +3 -0
- package/dist/runner/reflect-hook.d.ts +36 -21
- package/dist/runner/reflect-hook.js +147 -49
- package/dist/runner/runner.d.ts +7 -1
- package/dist/runner/runner.js +34 -8
- package/dist/runner/sdk-loop.d.ts +7 -0
- package/dist/runner/sdk-loop.js +470 -0
- package/dist/runner/sessions.d.ts +8 -3
- package/dist/runner/sessions.js +5 -1
- package/dist/runner/spec-holds.d.ts +16 -2
- package/dist/runner/spec-holds.js +42 -14
- package/dist/runner/step-guard.d.ts +62 -0
- package/dist/runner/step-guard.js +93 -0
- package/dist/runner/store-secrets.js +17 -2
- package/dist/runner/subagent.d.ts +0 -3
- package/dist/runner/subagent.js +7 -12
- package/dist/runner/workflow-first.d.ts +226 -0
- package/dist/runner/workflow-first.js +293 -0
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +32 -19
- package/dist/runner/workflow-spec.d.ts +5 -1
- package/dist/runner/workflow-spec.js +63 -48
- package/dist/runs-over-store.d.ts +41 -4
- package/dist/runs-over-store.js +64 -22
- package/dist/sdk/runs.d.ts +115 -0
- package/dist/sdk/runs.js +422 -0
- package/dist/sdk/schema.d.ts +175 -0
- package/dist/sdk/schema.js +138 -0
- package/dist/sdk/workflows.d.ts +22 -0
- package/dist/sdk/workflows.js +39 -0
- package/dist/secrets.d.ts +2 -0
- package/dist/secrets.js +19 -1
- package/dist/server.d.ts +108 -20
- package/dist/server.js +874 -157
- package/dist/settings-wake.d.ts +8 -6
- package/dist/settings-wake.js +13 -7
- package/dist/skill-route.d.ts +3 -0
- package/dist/skill-route.js +16 -0
- package/dist/skills/agentrun-serve/SKILL.md +368 -0
- package/dist/stats.d.ts +10 -10
- package/dist/store/agent-body.d.ts +22 -7
- package/dist/store/agent-body.js +23 -14
- package/dist/store/command-wake.d.ts +3 -2
- package/dist/store/command-wake.js +4 -4
- package/dist/store/index.d.ts +1 -1
- package/dist/store/native-command-owner.d.ts +10 -0
- package/dist/store/native-command-owner.js +47 -0
- package/dist/store/postgres/connection.js +3 -1
- package/dist/store/postgres/migrations/0010_imported_templates.sql +18 -0
- package/dist/store/postgres/migrations/0011_revision_mcp_pin.sql +13 -0
- package/dist/store/postgres/migrations/0012_revision_monid_pin.sql +4 -0
- package/dist/store/postgres/migrations/0013_native_command_owner.sql +6 -0
- package/dist/store/postgres/migrations/0014_run_cost_upper_bound.sql +6 -0
- package/dist/store/postgres/store.js +3 -0
- package/dist/store/schema.d.ts +16 -0
- package/dist/store/schema.js +47 -8
- package/dist/store/sqlite/connection.d.ts +2 -2
- package/dist/store/sqlite/connection.js +2 -2
- package/dist/store/sqlite/run-patch.d.ts +8 -1
- package/dist/store/sqlite/run-patch.js +33 -10
- package/dist/store/sqlite/store.js +184 -28
- package/dist/store/store.d.ts +98 -21
- package/dist/store-reads/analytics.d.ts +7 -7
- package/dist/store-reads/analytics.js +23 -5
- package/dist/store-reads/cap.js +8 -6
- package/dist/store-reads/journal.d.ts +30 -1
- package/dist/store-reads/journal.js +141 -83
- package/dist/store-reads/learning.d.ts +179 -13
- package/dist/store-reads/learning.js +230 -68
- package/dist/store-reads/loop.d.ts +61 -0
- package/dist/store-reads/loop.js +111 -0
- package/dist/store-reads/runs.d.ts +5 -0
- package/dist/store-reads/runs.js +3 -2
- package/dist/store-view.d.ts +3 -2
- package/dist/store-view.js +109 -37
- package/dist/template-eval.d.ts +87 -16
- package/dist/template-eval.js +605 -120
- package/dist/template-github-permissions.d.ts +2 -2
- package/dist/template-github-permissions.js +2 -1
- package/dist/template-import.d.ts +31 -0
- package/dist/template-import.js +121 -0
- package/dist/template-source.d.ts +51 -0
- package/dist/template-source.js +371 -0
- package/dist/templates.d.ts +274 -52
- package/dist/templates.js +670 -201
- package/dist/text-urls.d.ts +38 -0
- package/dist/text-urls.js +170 -0
- package/dist/timeline/computer.d.ts +48 -0
- package/dist/timeline/computer.js +169 -0
- package/dist/timeline/index.d.ts +7 -5
- package/dist/timeline/index.js +7 -5
- package/dist/timeline/labels.d.ts +11 -4
- package/dist/timeline/labels.js +122 -8
- package/dist/timeline/origin.d.ts +20 -6
- package/dist/timeline/origin.js +13 -6
- package/dist/timeline/render-text.js +1 -1
- package/dist/timeline/timeline.d.ts +76 -20
- package/dist/timeline/timeline.js +184 -39
- package/dist/timeline/util.d.ts +5 -0
- package/dist/timeline/util.js +44 -8
- package/dist/timeline/web-calls.d.ts +17 -0
- package/dist/timeline/web-calls.js +106 -0
- package/dist/tool-gate.d.ts +103 -76
- package/dist/tool-gate.js +200 -127
- package/dist/tool-keys.d.ts +4 -1
- package/dist/tool-keys.js +8 -3
- package/dist/tool-list.d.ts +29 -0
- package/dist/tool-list.js +50 -0
- package/dist/tool-names.d.ts +76 -0
- package/dist/tool-names.js +101 -0
- package/dist/tool-plane.d.ts +34 -28
- package/dist/tool-plane.js +72 -37
- package/dist/tools.d.ts +59 -15
- package/dist/tools.js +46 -42
- package/dist/trigger-adapter.d.ts +85 -5
- package/dist/trigger-adapter.js +6 -0
- package/dist/trigger-adapters.js +3 -1
- package/dist/trigger-composio.d.ts +10 -0
- package/dist/trigger-composio.js +122 -0
- package/dist/trigger-email.d.ts +4 -0
- package/dist/trigger-email.js +228 -0
- package/dist/trigger-signatures.d.ts +6 -10
- package/dist/trigger-signatures.js +16 -16
- package/dist/trigger-targets.d.ts +1 -1
- package/dist/trigger-targets.js +4 -3
- package/dist/trigger-webhook.js +6 -4
- package/dist/triggers.d.ts +94 -9
- package/dist/triggers.js +263 -62
- package/dist/uploads.d.ts +9 -0
- package/dist/uploads.js +27 -0
- package/dist/validate.d.ts +15 -7
- package/dist/validate.js +91 -50
- package/dist/web-fake.d.ts +56 -0
- package/dist/web-fake.js +102 -0
- package/dist/web-fetch-direct.d.ts +3 -0
- package/dist/web-fetch-direct.js +4 -1
- package/dist/web-fetch.d.ts +6 -8
- package/dist/web-fetch.js +10 -53
- package/dist/web-search.d.ts +51 -2
- package/dist/web-search.js +116 -18
- package/dist/webhooks.d.ts +2 -1
- package/dist/webhooks.js +5 -1
- package/dist/workflow/node-runner.js +10 -2
- package/dist/workspace/archil-claim.d.ts +3 -0
- package/dist/workspace/archil-claim.js +9 -2
- package/dist/workspace/computer-deps.d.ts +25 -9
- package/dist/workspace/computer-deps.js +82 -38
- package/dist/workspace/computer-for-claim.d.ts +60 -4
- package/dist/workspace/computer-for-claim.js +203 -45
- package/dist/workspace/computer-hold.js +7 -1
- package/dist/workspace/computer-janitor.d.ts +10 -3
- package/dist/workspace/computer-janitor.js +96 -29
- package/dist/workspace/computer-kept.d.ts +82 -0
- package/dist/workspace/computer-kept.js +147 -0
- package/dist/workspace/computer-mcp.js +4 -3
- package/dist/workspace/computer-ports.d.ts +23 -3
- package/dist/workspace/computer-ports.js +115 -5
- package/dist/workspace/index.d.ts +2 -3
- package/dist/workspace/index.js +1 -2
- package/dist/workspace/kind-skills/desktop/SKILL.md +31 -11
- package/dist/workspace/kind-skills/phone/SKILL.md +29 -14
- package/dist/workspace/local.js +2 -2
- package/dist/workspace/resolve-computer.d.ts +33 -1
- package/dist/workspace/resolve-computer.js +37 -16
- package/dist/workspace/revision-skills.d.ts +6 -2
- package/dist/workspace/revision-skills.js +12 -5
- package/dist/workspace/run-end-computers.d.ts +30 -0
- package/dist/workspace/run-end-computers.js +137 -0
- package/dist/workspace/run-tools.d.ts +40 -23
- package/dist/workspace/run-tools.js +46 -19
- package/dist/wrap-up.d.ts +35 -0
- package/dist/wrap-up.js +48 -0
- package/launcher/agentrun-serve +4 -2
- package/package.json +13 -9
- package/skills/agentrun-serve/SKILL.md +248 -10
- package/templates/README.md +220 -60
- package/templates/TOOLS.md +168 -0
- package/templates/code-review/agent.md +46 -16
- package/templates/code-review/evals/clean-refactor/case.yaml +2 -1
- package/templates/code-review/evals/clean-refactor/graders/head-sha.md +6 -0
- package/templates/code-review/evals/injection/case.yaml +2 -1
- package/templates/code-review/evals/injection/graders/head-sha.md +6 -0
- package/templates/code-review/evals/mentions-defused/case.yaml +3 -3
- package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -23
- package/templates/code-review/evals/mentions-defused/graders/head-sha.md +6 -0
- package/templates/code-review/evals/never-flag/case.yaml +2 -1
- package/templates/code-review/evals/never-flag/graders/head-sha.md +6 -0
- package/templates/code-review/evals/null-name/case.yaml +2 -1
- package/templates/code-review/evals/null-name/graders/head-sha.md +6 -0
- package/templates/code-review/evals/off-by-one/case.yaml +2 -1
- package/templates/code-review/evals/off-by-one/graders/head-sha.md +6 -0
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +2 -1
- package/templates/code-review/evals/other-repo/case.yaml +16 -0
- package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +130 -0
- package/templates/code-review/evals/other-repo/graders/head-sha.md +6 -0
- package/templates/code-review/evals/other-repo/graders/no-canary.md +6 -0
- package/templates/code-review/evals/other-repo/graders/no-other-repo.md +8 -0
- package/templates/code-review/evals/other-repo/graders/refused-not-quoted.md +18 -0
- package/templates/code-review/evals/other-repo/prompt.md +10 -0
- package/templates/code-review/evals/pasted-by-reference/case.yaml +5 -0
- package/templates/code-review/evals/pasted-by-reference/graders/by-reference.md +15 -0
- package/templates/code-review/evals/pasted-by-reference/graders/head-sha.md +6 -0
- package/templates/code-review/evals/pasted-by-reference/prompt.md +31 -0
- package/templates/code-review/evals/re-review/case.yaml +2 -1
- package/templates/code-review/evals/re-review/graders/head-sha.md +6 -0
- package/templates/code-review/evals/re-review-open/case.yaml +2 -1
- package/templates/code-review/evals/re-review-open/graders/head-sha.md +6 -0
- package/templates/code-review/evals/repo-rule/case.yaml +2 -1
- package/templates/code-review/evals/repo-rule/graders/head-sha.md +6 -0
- package/templates/code-review/evals/two-defects/case.yaml +2 -1
- package/templates/code-review/evals/two-defects/graders/head-sha.md +6 -0
- package/templates/code-review/rules/CODEREVIEW.md +1 -1
- package/templates/code-review/skills/review/DEEP.md +5 -4
- package/templates/code-review/skills/review/REVIEWER.md +5 -4
- package/templates/code-review/skills/review/SKILL.md +11 -6
- package/templates/code-review/{findings.schema.json → skills/review/findings.schema.json} +1 -0
- package/templates/inbound-lead/agent.md +26 -16
- package/templates/inbound-lead/evals/injection-in-form/graders/no-exfil.md +16 -0
- package/templates/inbound-lead/evals/injection-in-form/prompt.md +2 -2
- package/templates/inbound-lead/evals/write-back/case.yaml +2 -6
- package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +34 -225
- package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +10 -14
- package/templates/inbound-lead/evals/write-back/graders/writes-once.md +7 -0
- package/templates/inbound-lead/evals/write-back/prompt.md +1 -1
- package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +3 -7
- package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +34 -225
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/form-id.md +17 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +3 -3
- package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +2 -2
- package/templates/inbound-lead/skills/lead/SKILL.md +23 -27
- package/templates/kyb/agent.md +15 -5
- package/templates/kyb/evals/adverse-media/prompt.md +2 -7
- package/templates/kyb/evals/canada-active-filed/prompt.md +2 -6
- package/templates/kyb/evals/clean-public-company/prompt.md +2 -6
- package/templates/kyb/evals/injection-in-page/prompt.md +3 -7
- package/templates/kyb/evals/name-collision/prompt.md +2 -6
- package/templates/kyb/evals/no-invention/prompt.md +2 -6
- package/templates/kyb/evals/opensanctions-on/prompt.md +2 -6
- package/templates/kyb/evals/sanctioned-entity/prompt.md +2 -6
- package/templates/kyb/kyb.schema.json +8 -7
- package/templates/kyb/skills/kyb/SKILL.md +9 -6
- package/templates/market-monitor/agent.md +19 -12
- package/templates/market-monitor/evals/post-happens/case.yaml +4 -4
- package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +13 -9
- package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +1 -1
- package/templates/market-monitor/evals/post-happens/graders/posted-once.md +3 -3
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/templates/release-notes/agent.md +32 -10
- package/templates/release-notes/evals/draft-not-publish/case.yaml +5 -4
- package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/every-pr-accounted/case.yaml +2 -1
- package/templates/release-notes/evals/issue-write-refused/case.yaml +5 -4
- package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/late-arrival/case.yaml +6 -5
- package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +29 -51
- package/templates/release-notes/evals/learned-style/case.yaml +2 -1
- package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +2 -1
- package/templates/release-notes/evals/other-repo/case.yaml +24 -0
- package/templates/release-notes/evals/other-repo/fixtures/github-mcp.json +907 -0
- package/templates/release-notes/evals/other-repo/graders/no-canary.md +7 -0
- package/templates/release-notes/evals/other-repo/graders/no-other-repo.md +8 -0
- package/templates/release-notes/evals/other-repo/graders/refused-not-quoted.md +18 -0
- package/templates/release-notes/evals/other-repo/prompt.md +32 -0
- package/templates/release-notes/evals/upgrade-line/case.yaml +2 -1
- package/templates/release-notes/evals/user-facing-only/case.yaml +2 -1
- package/templates/release-notes/notes.schema.json +1 -1
- package/templates/release-notes/skills/release-notes/SKILL.md +26 -17
- package/dist/console/assets/index-Cn6JX1uH.js +0 -563
- package/dist/console/assets/index-DRN62V5v.css +0 -1
- package/dist/host-calls.d.ts +0 -20
- package/dist/host-calls.js +0 -12
- package/dist/runner/adapters/pi-computer.d.ts +0 -7
- package/dist/runner/adapters/pi-computer.js +0 -43
- package/dist/tool-blurbs.d.ts +0 -4
- package/dist/tool-blurbs.js +0 -28
- package/dist/tool-budget.d.ts +0 -38
- package/dist/tool-budget.js +0 -62
- package/dist/workspace/computer-script.d.ts +0 -37
- package/dist/workspace/computer-script.js +0 -138
- package/templates/code-review/evals/clean-refactor/graders/schema.md +0 -5
- package/templates/code-review/evals/injection/graders/schema.md +0 -5
- package/templates/code-review/evals/mentions-defused/graders/schema.md +0 -5
- package/templates/code-review/evals/never-flag/graders/schema.md +0 -5
- package/templates/code-review/evals/null-name/graders/schema.md +0 -5
- package/templates/code-review/evals/off-by-one/graders/schema.md +0 -5
- package/templates/code-review/evals/re-review/graders/schema.md +0 -5
- package/templates/code-review/evals/re-review-open/graders/schema.md +0 -5
- package/templates/code-review/evals/repo-rule/graders/schema.md +0 -5
- package/templates/code-review/evals/two-defects/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/learned-correction/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/strong-fit/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/thin-data/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/write-back/graders/schema.md +0 -5
- package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +0 -7
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +0 -18
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +0 -5
- package/templates/kyb/evals/adverse-media/graders/schema.md +0 -5
- package/templates/kyb/evals/canada-active-filed/graders/schema.md +0 -5
- package/templates/kyb/evals/clean-public-company/graders/schema.md +0 -5
- package/templates/kyb/evals/injection-in-page/graders/schema.md +0 -5
- package/templates/kyb/evals/name-collision/graders/schema.md +0 -5
- package/templates/kyb/evals/no-invention/graders/schema.md +0 -5
- package/templates/kyb/evals/opensanctions-on/graders/schema.md +0 -5
- package/templates/kyb/evals/sanctioned-entity/graders/schema.md +0 -5
- package/templates/market-monitor/evals/blocked-source/graders/schema.md +0 -5
- package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +0 -5
- package/templates/market-monitor/evals/learned-preference/graders/schema.md +0 -5
- package/templates/market-monitor/evals/no-repeats/graders/schema.md +0 -5
- package/templates/market-monitor/evals/nothing-changed/graders/schema.md +0 -5
- package/templates/market-monitor/evals/post-happens/graders/schema.md +0 -5
- package/templates/market-monitor/evals/pricing-change/graders/schema.md +0 -5
- package/templates/market-monitor/evals/pricing-moved/graders/schema.md +0 -5
- package/templates/release-notes/evals/draft-not-publish/graders/schema.md +0 -5
- package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +0 -5
- package/templates/release-notes/evals/issue-write-refused/graders/schema.md +0 -5
- package/templates/release-notes/evals/late-arrival/graders/schema.md +0 -5
- package/templates/release-notes/evals/learned-style/graders/schema.md +0 -5
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +0 -5
- package/templates/release-notes/evals/upgrade-line/graders/schema.md +0 -5
- package/templates/release-notes/evals/user-facing-only/graders/schema.md +0 -5
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
// Three host tools over the run's own tools, on every harness: tools_search finds the run's tools by what they do,
|
|
2
|
+
// tools_call calls one by name, and codemode runs a script that calls them (not on Codex, which keeps its own code mode).
|
|
3
|
+
//
|
|
4
|
+
// None of them is a door around the gate. Each call they make is a call of its own nested in theirs (NestedCalls, which
|
|
5
|
+
// each harness gives a tool that `nests`): asked about at the gate as the tool it calls, by that tool's name, its intent
|
|
6
|
+
// and outcome recorded under `<callId>/<key>`, its paid requests booked under that id as a call the model made would be.
|
|
7
|
+
// A call the record finished answers from the record and never runs twice, across a park, a resume or a crash: a rerun
|
|
8
|
+
// of the calling tool replays them.
|
|
9
|
+
//
|
|
10
|
+
// A script follows Codex's rule for an ask inside it: the nested call the gate parks parks the run; once a person
|
|
11
|
+
// answers, the script runs again from its start, its recorded calls answered from their records, the parked call runs
|
|
12
|
+
// once (or is refused), its outcome is the script's output, and the rest of the script does not run. A refusal of any
|
|
13
|
+
// nested call ends the script with the refusal's words. The script sees the tools and the answers its calls get, nothing
|
|
14
|
+
// else of the run: no environment, no key, no file.
|
|
15
|
+
//
|
|
16
|
+
// On a run with a desktop or a phone, a script has `computer` too (the computer package's bindComputer over its card,
|
|
17
|
+
// its declarations in codemode's description): each of its calls is a nested call of the run's computer tools
|
|
18
|
+
// (computer_observe, computer_act, computer_screenshot, computer_op), so the gate holds a command it runs to bash's
|
|
19
|
+
// setting and a file it touches to write's or read's (tool-gate.ts heldAs), and a rerun answers it from its record.
|
|
20
|
+
import { randomBytes } from "node:crypto";
|
|
21
|
+
import { CodemodeSandbox, toCodemodeIdentifier } from "@earendil-works/pi-codemode";
|
|
22
|
+
import { computerOver, withoutImageData } from "@parcha/agentrun-computer/surface";
|
|
23
|
+
import { COMPUTER_OP_TOOL, computerDeclarations, STEP_TOOL_OPS } from "@parcha/agentrun-kernel/kernel";
|
|
24
|
+
import { CODEMODE, META_TOOLS, TOOLS_CALL, TOOLS_SEARCH } from "../meta-tool-names.js";
|
|
25
|
+
import { NO_PROGRAMS_WORDS } from "../workspace/computer-ports.js";
|
|
26
|
+
export { CODEMODE, META_TOOLS, TOOLS_CALL, TOOLS_SEARCH };
|
|
27
|
+
/** How many tools a search answers with when its call names no limit, and the most it may name. */
|
|
28
|
+
export const SEARCH_DEFAULT_LIMIT = 8;
|
|
29
|
+
export const SEARCH_MAX_LIMIT = 25;
|
|
30
|
+
/** A script's whole run, its nested calls' time included, and the memory its VM may take. */
|
|
31
|
+
export const CODEMODE_MS = 600_000;
|
|
32
|
+
const CODEMODE_MEMORY_BYTES = 256 * 1024 * 1024;
|
|
33
|
+
/** pi-durable's BM25 ranking (its tool_search's and code mode's searchTools'), the same file its own tools rank with: the
|
|
34
|
+
* package exports its tools but not the ranker, so it is read from beside the package's entry. */
|
|
35
|
+
const rankDocuments = (await import(new URL("./search.js", import.meta.resolve("@earendil-works/pi-durable")).href)).rankDocuments;
|
|
36
|
+
/** The words of a tool's schema a search reads beside its description: its arguments' names and their descriptions. */
|
|
37
|
+
function schemaWords(schema) {
|
|
38
|
+
const properties = (schema.properties ?? {});
|
|
39
|
+
return Object.entries(properties).map(([name, property]) => `${name} ${typeof property?.description === "string" ? property.description : ""}`).join(" ");
|
|
40
|
+
}
|
|
41
|
+
/** The tools of `tools` (the run's own, none of the three here) whose names `granted` holds, ranked for `query`. */
|
|
42
|
+
export async function searchTools(query, tools, granted, limit = SEARCH_DEFAULT_LIMIT) {
|
|
43
|
+
const searched = [];
|
|
44
|
+
for (const tool of tools)
|
|
45
|
+
if (!META_TOOLS.has(tool.name) && (await granted(tool.name)))
|
|
46
|
+
searched.push(tool);
|
|
47
|
+
const byName = new Map(searched.map((tool) => [tool.name, tool]));
|
|
48
|
+
const names = rankDocuments(query, searched.map((tool) => ({ name: tool.name, text: `${tool.description} ${schemaWords(tool.inputSchema)}` })), limit);
|
|
49
|
+
return names.flatMap((name) => {
|
|
50
|
+
const tool = byName.get(name);
|
|
51
|
+
return tool ? [{ name: tool.name, description: tool.description, input_schema: tool.inputSchema }] : [];
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/** The run's tool a model's name for it names: its own name, or one a harness gives it on its tool channel (claude-agent's
|
|
55
|
+
* `mcp__hands__<name>`, OpenCode's `hands_<name>`, Codex's `mcp_<server>__<tool>` for an MCP tool): `hostName` is the
|
|
56
|
+
* harness's own map from that name to the host's (AdapterFacts.hostName). */
|
|
57
|
+
export function toolNamed(name, tools, hostName = (given) => given) {
|
|
58
|
+
const host = hostName(name);
|
|
59
|
+
return tools.find((one) => one.name === name) ?? tools.find((one) => one.name === host);
|
|
60
|
+
}
|
|
61
|
+
/** Why `name` can't be called through tools_call or a script, or undefined: one of the three, or no tool of this run. */
|
|
62
|
+
export function refusedName(caller, name, tools, hostName = (given) => given) {
|
|
63
|
+
const own = hostName(name);
|
|
64
|
+
if (META_TOOLS.has(own))
|
|
65
|
+
return `${caller} can't call ${own}: ${TOOLS_SEARCH}, ${TOOLS_CALL} and ${CODEMODE} are called by the model itself, never through each other. Nothing was run.`;
|
|
66
|
+
if (!toolNamed(name, tools, hostName))
|
|
67
|
+
return `${caller} can't call ${JSON.stringify(name).slice(0, 120)}: this run has no tool by that name. Find the run's tools with ${TOOLS_SEARCH}. Nothing was run.`;
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
const NO_NESTED = (caller) => `${caller} can't run here: this harness gives it no way to call the run's tools. Nothing was run.`;
|
|
71
|
+
/** A nested answer as a tool's answer. */
|
|
72
|
+
const answered = (result) => ({ text: result.text, ...(result.isError ? { isError: true } : {}), ...(result.images?.length ? { images: result.images } : {}), ...(result.structured !== undefined ? { structured: result.structured } : {}) });
|
|
73
|
+
/** A script's `computer` (the computer package's bindComputer, over its card) as one expression of the script's isolate
|
|
74
|
+
* over its `tools`: an observe, an act or a screenshot calls its own step tool, every other op computer_op, so each is a
|
|
75
|
+
* nested call of the run's tool, asked about and recorded as that tool's. On an agent whose exec is off, reaching for
|
|
76
|
+
* computer.shell or computer.processes throws NO_PROGRAMS_WORDS rather than reading undefined. */
|
|
77
|
+
function scriptComputer(computer, tools) {
|
|
78
|
+
const ident = (name) => `${tools}[${JSON.stringify(toCodemodeIdentifier(name))}]`;
|
|
79
|
+
const steps = Object.entries(STEP_TOOL_OPS).map(([op, tool]) => `op === ${JSON.stringify(op)} ? ${ident(tool)}(args) : `).join("");
|
|
80
|
+
const bound = computerOver(computer.card, `(op, args) => (${steps}${ident(COMPUTER_OP_TOOL)}({ op, args }))`);
|
|
81
|
+
if (computer.exec !== false)
|
|
82
|
+
return bound;
|
|
83
|
+
return `new Proxy(${bound}, { get(target, key, receiver) { if (key === "shell" || key === "processes") throw new Error(${JSON.stringify(NO_PROGRAMS_WORDS)}); return Reflect.get(target, key, receiver); } })`;
|
|
84
|
+
}
|
|
85
|
+
/** What codemode's description adds for a run with a computer: the script's `computer`, and the declarations of what its
|
|
86
|
+
* card offers. */
|
|
87
|
+
function computerWords(computer) {
|
|
88
|
+
return [
|
|
89
|
+
`The script has this run's computer as \`computer\`, typed by the declarations below. Each of its calls is a call of the run's own computer tools, asked about and recorded as that tool's: a command it runs is held to bash's setting, a file it writes to write's, a file it reads, lists or stats to read's.`,
|
|
90
|
+
computerDeclarations(computer.card.groups),
|
|
91
|
+
].join("\n");
|
|
92
|
+
}
|
|
93
|
+
/** The three tools for a session: each `nests` (but the search, which calls nothing). */
|
|
94
|
+
export function metaTools(options) {
|
|
95
|
+
const own = () => options.tools().filter((tool) => !META_TOOLS.has(tool.name));
|
|
96
|
+
const search = {
|
|
97
|
+
name: TOOLS_SEARCH,
|
|
98
|
+
description: `This run lists only some of its tools. Search all of them by what they do, and get each match's name, description and input schema, best match first. Call a match with ${options.discovery.call ? TOOLS_CALL : "its name"}${options.codemode ? `, or from a ${CODEMODE} script` : ""}.`,
|
|
99
|
+
inputSchema: { type: "object", properties: { query: { type: "string", description: "What the tool should do, in a few words, or its name." }, limit: { type: "integer", minimum: 1, maximum: SEARCH_MAX_LIMIT, description: `How many tools to answer with (default ${SEARCH_DEFAULT_LIMIT}).` } }, required: ["query"], additionalProperties: false },
|
|
100
|
+
replay: "safe",
|
|
101
|
+
call: async (args) => {
|
|
102
|
+
const { query, limit } = (args ?? {});
|
|
103
|
+
if (typeof query !== "string" || query.trim() === "")
|
|
104
|
+
return { text: `${TOOLS_SEARCH} needs a query: what the tool should do.`, isError: true };
|
|
105
|
+
const most = typeof limit === "number" && Number.isInteger(limit) ? Math.min(Math.max(limit, 1), SEARCH_MAX_LIMIT) : SEARCH_DEFAULT_LIMIT;
|
|
106
|
+
const found = await searchTools(query, own(), options.granted, most);
|
|
107
|
+
return { text: found.length ? JSON.stringify(found) : `No tool of this run matches ${JSON.stringify(query)}.`, structured: found };
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
const call = {
|
|
111
|
+
name: TOOLS_CALL,
|
|
112
|
+
description: `Call one of this run's tools by its name (as ${TOOLS_SEARCH} gives it) with its arguments. The call is asked about and recorded as that tool's own: a tool that needs a person's approval waits for it.`,
|
|
113
|
+
inputSchema: { type: "object", properties: { name: { type: "string", description: "The tool's name." }, args: { type: "object", description: "The tool's arguments, as its input schema says.", additionalProperties: true } }, required: ["name"], additionalProperties: false },
|
|
114
|
+
replay: "safe",
|
|
115
|
+
nests: true,
|
|
116
|
+
call: async (args, context) => {
|
|
117
|
+
const { name, args: given } = (args ?? {});
|
|
118
|
+
if (typeof name !== "string" || name === "")
|
|
119
|
+
return { text: `${TOOLS_CALL} needs the name of the tool to call.`, isError: true };
|
|
120
|
+
if (given !== undefined && (given === null || typeof given !== "object" || Array.isArray(given)))
|
|
121
|
+
return { text: `${TOOLS_CALL}'s args must be an object of the tool's arguments.`, isError: true };
|
|
122
|
+
const tools = own();
|
|
123
|
+
const refused = refusedName(TOOLS_CALL, name, tools, options.hostName);
|
|
124
|
+
if (refused)
|
|
125
|
+
return { text: refused, isError: true };
|
|
126
|
+
if (!context.nested)
|
|
127
|
+
return { text: NO_NESTED(TOOLS_CALL), isError: true };
|
|
128
|
+
return answered(await context.nested.call(toolNamed(name, tools, options.hostName).name, (given ?? {}), "call"));
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
// A few of the run's tools as the script writes them (`tools.<name>`): names that resolve, as the model's own tool list
|
|
132
|
+
// may show them under a harness's prefix, which a script's `tools` has no property for.
|
|
133
|
+
const examples = own().slice(0, 3).map((tool) => `\`tools.${toCodemodeIdentifier(tool.name)}\``);
|
|
134
|
+
const codemode = {
|
|
135
|
+
name: CODEMODE,
|
|
136
|
+
description: [
|
|
137
|
+
`Run a JavaScript script (the body of an async function: top-level await and return work) that calls this run's tools as \`await tools.<name>(args)\`; ${options.discovery.search ? `find them with ${TOOLS_SEARCH}, and ` : ""}\`ALL_TOOLS\` lists them. A call answers its value, and a call that fails throws. A tool is called by its own name, exactly as \`ALL_TOOLS\`${options.discovery.search ? ` and ${TOOLS_SEARCH}` : ""} give it${examples.length ? ` (here: ${examples.join(", ")})` : ""}, never by the name your own tool list may show for it with a harness's prefix (\`hands_\`, \`mcp__hands__\`): leave the prefix off.`,
|
|
138
|
+
"The script's text(...) and console output, and its returned value, are the answer. It has no timers, network or files of its own: only the tools.",
|
|
139
|
+
"Each call is asked about and recorded as that tool's own. A call that needs a person's approval stops the script: once they answer, that call runs (or is refused), its outcome is the answer, and the rest of the script does not run. A refused call ends the script with the refusal.",
|
|
140
|
+
].join(" ") + (options.computer ? `\n${computerWords(options.computer)}` : ""),
|
|
141
|
+
inputSchema: { type: "object", properties: { script: { type: "string", description: "The script: the body of an async function." } }, required: ["script"], additionalProperties: false },
|
|
142
|
+
replay: "safe",
|
|
143
|
+
nests: true,
|
|
144
|
+
call: async (args, context) => {
|
|
145
|
+
const { script } = (args ?? {});
|
|
146
|
+
if (typeof script !== "string" || script.trim() === "")
|
|
147
|
+
return { text: `${CODEMODE} needs a script: the body of an async function.`, isError: true };
|
|
148
|
+
if (!context.nested)
|
|
149
|
+
return { text: NO_NESTED(CODEMODE), isError: true };
|
|
150
|
+
return runScript(script, own(), context.nested, context.signal, options.hostName, options.computer);
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
return [...(options.discovery.search ? [search] : []), ...(options.discovery.call ? [call] : []), ...(options.codemode ? [codemode] : [])];
|
|
154
|
+
}
|
|
155
|
+
/** One nested call's line in a script's stopped answer, as Codex's code mode words its recovered calls. A completed call's
|
|
156
|
+
* result is its value as the script read it (scriptValue): JSON as itself where it parsed, so it reads as the object it
|
|
157
|
+
* is, never as a string holding it, and an image in it named without its data; else that string, quoted. A call whose
|
|
158
|
+
* value is null (an op that answers none: a computer's files.write) is told by its answer's words ("wrote <path>"), as
|
|
159
|
+
* it answered, never as null. */
|
|
160
|
+
function lineOf(index, name, result) {
|
|
161
|
+
const quoted = (text) => JSON.stringify(text.length > 2_000 ? `${text.slice(0, 2_000)}…` : text);
|
|
162
|
+
const label = `${index}. ${name}`;
|
|
163
|
+
if (result.refused)
|
|
164
|
+
return `${label} was refused: ${quoted(result.text)}. It did not run.`;
|
|
165
|
+
if (result.interrupted)
|
|
166
|
+
return `${label} was started and did not report a result, so it may have taken effect: check before calling it again. It was not run again.`;
|
|
167
|
+
if (result.isError)
|
|
168
|
+
return `${label} failed: ${quoted(result.text)}. It was not run again.`;
|
|
169
|
+
const value = result.structured === null ? result.text : scriptValue(result);
|
|
170
|
+
const json = typeof value === "string" ? undefined : JSON.stringify(withoutImageData(value));
|
|
171
|
+
const said = json === undefined ? quoted(value) : json.length > 2_000 ? `${json.slice(0, 2_000)}…` : json;
|
|
172
|
+
return `${label} completed: ${said}. Its effect is done; it was not run again.`;
|
|
173
|
+
}
|
|
174
|
+
/** The script's output and value, as the model reads them, and the images: the returned value's own first, then the ones
|
|
175
|
+
* it showed with image(...). The text names an image without its data. */
|
|
176
|
+
function shownOf(output, value) {
|
|
177
|
+
const words = [];
|
|
178
|
+
const shown = [];
|
|
179
|
+
for (const item of output) {
|
|
180
|
+
if (item.type === "text")
|
|
181
|
+
words.push(item.text);
|
|
182
|
+
else
|
|
183
|
+
shown.push({ data: item.data, mimeType: item.mimeType });
|
|
184
|
+
}
|
|
185
|
+
if (value !== undefined)
|
|
186
|
+
words.push(typeof value === "string" ? value : JSON.stringify(withoutImageData(value)));
|
|
187
|
+
return { text: words.join("\n"), images: [...imagesIn(value), ...shown] };
|
|
188
|
+
}
|
|
189
|
+
/** Every image in `value` (`{ type: "image", data }`), in order. */
|
|
190
|
+
function imagesIn(value) {
|
|
191
|
+
if (Array.isArray(value))
|
|
192
|
+
return value.flatMap(imagesIn);
|
|
193
|
+
if (value === null || typeof value !== "object")
|
|
194
|
+
return [];
|
|
195
|
+
const record = value;
|
|
196
|
+
if (record.type === "image" && typeof record.data === "string")
|
|
197
|
+
return [{ data: record.data, mimeType: typeof record.mimeType === "string" ? record.mimeType : "image/png" }];
|
|
198
|
+
return Object.values(record).flatMap(imagesIn);
|
|
199
|
+
}
|
|
200
|
+
/** `value` with each image in it that has no data (`{ type: "image" }`, as a tool's structured value keeps an image whose
|
|
201
|
+
* data travels in the answer's images) given the data of the next of `images`, in order. */
|
|
202
|
+
function withImageData(value, images) {
|
|
203
|
+
let next = 0;
|
|
204
|
+
const fill = (entry) => {
|
|
205
|
+
if (Array.isArray(entry))
|
|
206
|
+
return entry.map(fill);
|
|
207
|
+
if (entry === null || typeof entry !== "object")
|
|
208
|
+
return entry;
|
|
209
|
+
const record = entry;
|
|
210
|
+
if (record.type === "image" && record.data === undefined && next < images.length) {
|
|
211
|
+
const image = images[next++];
|
|
212
|
+
return { ...record, mimeType: record.mimeType ?? image.mimeType, data: image.data };
|
|
213
|
+
}
|
|
214
|
+
return Object.fromEntries(Object.entries(record).map(([key, inner]) => [key, fill(inner)]));
|
|
215
|
+
};
|
|
216
|
+
return fill(value);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* What the sandbox runs for `script`: the script as the body of a function whose `tools` answers `undefined` for a name the
|
|
220
|
+
* run has no tool by (pi-codemode's own `tools` throws on it), so `typeof tools.<name>` and `"<name>" in tools` work. Each
|
|
221
|
+
* such name the script reads is kept, and when the script then fails with a TypeError, or an error naming one, the error
|
|
222
|
+
* gets one line saying so and listing the run's tools. The script is never read: it stays line 1 on, and its declarations
|
|
223
|
+
* can't reach the names around it. With the run's `computer`, the function gets it too (scriptComputer), over `tools`.
|
|
224
|
+
*/
|
|
225
|
+
function scriptBody(script, toolNames, computer) {
|
|
226
|
+
const known = JSON.stringify(` Its tools are: ${toolNames.join(", ")}.`);
|
|
227
|
+
const params = computer ? "tools, console, computer" : "tools, console";
|
|
228
|
+
const bound = computer ? `, ${scriptComputer(computer, "tools")}` : "";
|
|
229
|
+
return `const read = new Set(), get = Reflect.get, proto = Object.prototype; try { return await (async (${params}) => {${script}\n})(new Proxy(tools, { get(target, key, receiver) { if (typeof key !== "string" || key in target || key in proto || key === "then" || key === "toJSON") return get(target, key, receiver); read.add(key); } }), console${bound}); } catch (error) { const names = [...read]; if (names.length && error !== null && typeof error === "object" && (error.name === "TypeError" || names.some((name) => String(error.message).includes(name)))) error.message += "\\nThe script read " + names.map((name) => "tools." + name).join(", ") + ", which this run doesn't have." + ${known}; throw error; }`;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Run `script` deterministically (pi-codemode's `start`: its clock, its randomness and its tools fixed by the call's first
|
|
233
|
+
* run, memoized), each of its tool calls a nested call, answered one at a time in the order the script made them. A rerun
|
|
234
|
+
* of the call (after a park or a crash) makes the same calls: the recorded ones are answered from their records, and the
|
|
235
|
+
* first one that runs now ends the script with its outcome (Codex's rule), as does any refusal or interrupted call.
|
|
236
|
+
*/
|
|
237
|
+
async function runScript(script, tools, nested, signal, hostName, computer) {
|
|
238
|
+
const nonce = randomBytes(8).toString("hex");
|
|
239
|
+
const first = await nested.memo("start", { startedAt: Date.now(), seed: randomBytes(4).readUInt32BE(0), nonce, tools: tools.map((tool) => [tool.name, toCodemodeIdentifier(tool.name)]) });
|
|
240
|
+
const start = first;
|
|
241
|
+
const rerun = start.nonce !== nonce;
|
|
242
|
+
const declared = new Map(tools.map((tool) => [tool.name, tool]));
|
|
243
|
+
const stop = new AbortController();
|
|
244
|
+
const sandbox = new CodemodeSandbox({ memoryLimitBytes: CODEMODE_MEMORY_BYTES });
|
|
245
|
+
const calls = [];
|
|
246
|
+
const told = [];
|
|
247
|
+
let ended;
|
|
248
|
+
let failed;
|
|
249
|
+
let wake = () => { };
|
|
250
|
+
try {
|
|
251
|
+
// The tools the first run declared, by the names it gave them, that this run still has.
|
|
252
|
+
const kept = start.tools.filter(([name]) => declared.has(name)).map(([name, jsName]) => ({ name, jsName, description: declared.get(name).description }));
|
|
253
|
+
const run = sandbox.start(scriptBody(script, kept.map((tool) => tool.jsName), computer), {
|
|
254
|
+
startedAt: start.startedAt,
|
|
255
|
+
seed: start.seed,
|
|
256
|
+
tools: kept,
|
|
257
|
+
signal: AbortSignal.any([signal, stop.signal]),
|
|
258
|
+
timeoutMs: CODEMODE_MS,
|
|
259
|
+
onCall: (call) => {
|
|
260
|
+
calls.push(call);
|
|
261
|
+
wake();
|
|
262
|
+
},
|
|
263
|
+
});
|
|
264
|
+
// The calls answered one at a time, in the order the script made them: the same order, and the same keys, in a rerun.
|
|
265
|
+
let seq = 0;
|
|
266
|
+
const answering = (async () => {
|
|
267
|
+
while (!run.finished && !ended) {
|
|
268
|
+
const call = calls.shift();
|
|
269
|
+
if (!call) {
|
|
270
|
+
await new Promise((resolve) => {
|
|
271
|
+
wake = resolve;
|
|
272
|
+
void run.result.then(() => resolve(), () => resolve());
|
|
273
|
+
});
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
const tool = toolNamed(call.name, tools, hostName);
|
|
277
|
+
const refused = call.target !== "tool" ? `${call.name} is no tool of this run.` : refusedName(CODEMODE, call.name, tools, hostName);
|
|
278
|
+
const args = call.args && typeof call.args === "object" && !Array.isArray(call.args) ? call.args : {};
|
|
279
|
+
const result = refused || !tool ? { text: refused ?? `${call.name} is no tool of this run.`, isError: true, refused: true, fresh: true } : await nested.call(tool.name, args, `s${call.id}`);
|
|
280
|
+
told.push({ name: tool?.name ?? call.name, result });
|
|
281
|
+
// A refusal, a call cut by a crash, or (in a rerun) the first call that ran now: the script ends with it.
|
|
282
|
+
if (result.refused || result.interrupted || (rerun && result.fresh)) {
|
|
283
|
+
ended = endedWith(told, result, rerun && result.fresh && !result.refused);
|
|
284
|
+
stop.abort();
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
seq += 1;
|
|
288
|
+
const outcome = result.isError ? { ok: false, message: result.text } : { ok: true, value: scriptValue(result) };
|
|
289
|
+
if (!run.finished)
|
|
290
|
+
run.deliver(seq, start.startedAt, call.id, outcome);
|
|
291
|
+
}
|
|
292
|
+
})().catch((error) => {
|
|
293
|
+
failed = error;
|
|
294
|
+
stop.abort();
|
|
295
|
+
});
|
|
296
|
+
const result = await run.result;
|
|
297
|
+
await answering;
|
|
298
|
+
// A nested call that parked (the session let go) or a drive that halted: the call has no answer here.
|
|
299
|
+
if (failed !== undefined)
|
|
300
|
+
throw failed;
|
|
301
|
+
if (signal.aborted)
|
|
302
|
+
throw signal.reason ?? new Error(`${CODEMODE} was stopped`);
|
|
303
|
+
if (ended)
|
|
304
|
+
return ended;
|
|
305
|
+
const shown = shownOf(result.output, result.ok ? result.value : undefined);
|
|
306
|
+
if (!result.ok) {
|
|
307
|
+
const why = result.error.kind === "timeout" ? `the script ran past ${CODEMODE_MS} ms: ${result.error.message}` : result.error.message;
|
|
308
|
+
return { text: [shown.text, `The script failed: ${why}`].filter(Boolean).join("\n"), isError: true, ...(shown.images.length ? { images: shown.images } : {}) };
|
|
309
|
+
}
|
|
310
|
+
return { text: shown.text || "(the script returned nothing and showed nothing)", ...(shown.images.length ? { images: shown.images } : {}), ...(result.value !== undefined ? { structured: withoutImageData(result.value) } : {}) };
|
|
311
|
+
}
|
|
312
|
+
finally {
|
|
313
|
+
await sandbox.close();
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
/** A nested call's value in a script: its structured value (an MCP result's structuredContent; a computer tool's value)
|
|
317
|
+
* when it has one, each image in it given its data back from the answer's images, so a screenshot is pixels the script
|
|
318
|
+
* can show; else, when its answer is one text part (no image beside it) whose text parses as a JSON object or array,
|
|
319
|
+
* that value (a Composio answer comes as one); else its text. The text the model reads of the call is its text either way. */
|
|
320
|
+
function scriptValue(result) {
|
|
321
|
+
if (result.structured !== undefined)
|
|
322
|
+
return result.images?.length ? withImageData(result.structured, result.images) : result.structured;
|
|
323
|
+
const text = result.text.trim();
|
|
324
|
+
if (result.images?.length || !(text.startsWith("{") || text.startsWith("[")))
|
|
325
|
+
return result.text;
|
|
326
|
+
try {
|
|
327
|
+
const value = JSON.parse(text);
|
|
328
|
+
return value !== null && typeof value === "object" ? value : result.text;
|
|
329
|
+
}
|
|
330
|
+
catch {
|
|
331
|
+
return result.text;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
/** The answer of a script that ended at `last`: a refusal's words, or (`ranNow`: the first call that ran on the script's
|
|
335
|
+
* rerun, after a person's answer or a crash) that call's outcome, with every call before it as recorded. */
|
|
336
|
+
function endedWith(told, last, ranNow) {
|
|
337
|
+
const lines = told.map(({ name, result }, i) => lineOf(i + 1, name, result));
|
|
338
|
+
if (last.refused)
|
|
339
|
+
return { text: `${last.text}\nThe script stopped at this refused call, and nothing after it ran. Its calls, in order:\n${lines.join("\n")}`, isError: true };
|
|
340
|
+
if (!ranNow)
|
|
341
|
+
return { text: `The script stopped at a call cut off before it reported a result, and nothing after it ran. Its calls, in order:\n${lines.join("\n")}`, isError: true };
|
|
342
|
+
const head = `The script was stopped (it waited for a person's answer, or the session stopped), and run again only as far as its next call, which ran once: ${last.isError ? "it failed" : "its outcome is below"}. The rest of the script did not run; run what is still needed again.`;
|
|
343
|
+
return { text: `${head}\nIts calls, in order:\n${lines.join("\n")}`, isError: Boolean(last.isError), ...(last.images?.length ? { images: last.images } : {}) };
|
|
344
|
+
}
|
package/dist/runner/metrics.d.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { type DecisionLike, type EntryLike, type RunMetrics } from "../timeline/index.js";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { type CostParts } from "@parcha/agentrun-kernel";
|
|
3
|
+
/** What a run's booking says one of its sessions spent: its requests (a hold given back unused is none), its cost's parts
|
|
4
|
+
* (the kernel's CostParts: `known`, the sum of the requests' own figures; `bounded` and `atMost`, the sum and count of
|
|
5
|
+
* cut requests booked at their hold, each the most it can have cost; `unpriced`, how many have no figure), `usd` their
|
|
6
|
+
* sum (null while one is unpriced), their tokens, and how many of the requests have no known tokens (`unmetered`: booked
|
|
4
7
|
* with no usage, or sent and never answered), in no token sum; and its requests by the model each was sent on (`models`:
|
|
5
|
-
* its runner.request's model, "" for one that names none).
|
|
8
|
+
* its runner.request's model, "" for one that names none). `free`: it booked requests, every one on a free model (its
|
|
9
|
+
* runner.turn's `free`: its known price $0 for every token), so its $0 says why. A reader that joins sessions, or says
|
|
10
|
+
* what is known of an unknown cost, takes the parts through costOfParts, never `usd` and `known` alone. */
|
|
6
11
|
export type BookedSpend = {
|
|
7
12
|
readonly usd: number | null;
|
|
8
13
|
readonly known: number;
|
|
14
|
+
readonly bounded: number;
|
|
9
15
|
readonly unpriced: number;
|
|
16
|
+
readonly atMost: number;
|
|
10
17
|
readonly requests: number;
|
|
11
18
|
readonly unmetered: number;
|
|
12
19
|
readonly models: Readonly<Record<string, number>>;
|
|
@@ -16,6 +23,7 @@ export type BookedSpend = {
|
|
|
16
23
|
cacheRead: number;
|
|
17
24
|
cacheWrite: number;
|
|
18
25
|
};
|
|
26
|
+
readonly free?: true;
|
|
19
27
|
};
|
|
20
28
|
/** What the run's booking (the kernel's runner.request and runner.turn records, the model proxy's own) says its requests
|
|
21
29
|
* cost, over `entries`, every conversation of the run's journal: its model requests (`model`: every session but the
|
|
@@ -28,14 +36,63 @@ export type BookedSpend = {
|
|
|
28
36
|
* booking's. `side`: of the model requests, those booked as side calls (another model than the session's, or the host's
|
|
29
37
|
* own, as a learned workflow's node is: the proxy's `side`/`host`), which no answer of a pi run carries. */
|
|
30
38
|
export declare function bookedSpend(entries: readonly EntryLike[], which: "model" | "paid" | "decisions" | "side"): BookedSpend;
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
/** A cost of charges as a usage row or a run's cost block says it (costsofar/1, cutathold/1), by the kernel's one rule
|
|
40
|
+
* (costOfParts) over `parts`, its float noise rounded off (floatNoiseOff): `usd` their sum, `upper_bound` when it counts
|
|
41
|
+
* a cut request at its hold, with `so_far_usd` the charges' own figures alone and `unpriced` how many it counts at their
|
|
42
|
+
* hold beside it; or, while one has no known cost, `usd` null, `so_far_usd` the charges' own figures alone and `unpriced`
|
|
43
|
+
* how many have none, held ones included. A bound always says its exact part, so whatever joins these words with more
|
|
44
|
+
* charges (usageParts, then this again) never has to take the bound for spend. A part that is null is a cost no one
|
|
45
|
+
* knows that says nothing of itself (a usage row of an older run with no costsofar/1 fields, decisions that could not be
|
|
46
|
+
* read): the cost is unknown and nothing is said beside it. `extraUnpriced`: charges with no figure beside the parts' (a
|
|
47
|
+
* CLI's model work no booking read). This is the one join: every reader that combines a usage row with more charges
|
|
48
|
+
* goes through it. */
|
|
49
|
+
export type CostWords = {
|
|
50
|
+
readonly usd: number | null;
|
|
51
|
+
readonly so_far_usd?: number;
|
|
52
|
+
readonly unpriced?: number;
|
|
53
|
+
readonly upper_bound?: true;
|
|
54
|
+
};
|
|
55
|
+
export declare function costWordsOf(parts: readonly (CostParts | null)[], extraUnpriced?: number): CostWords;
|
|
56
|
+
/** A usage row's cost (TimelineEvent.usage, or a cost block in the same words) as the kernel's parts, for a join
|
|
57
|
+
* (costWordsOf): an exact figure is `known`; a bound is its exact part (`so_far_usd`) known and the rest bounded over its
|
|
58
|
+
* `unpriced` holds, or, from a row that says no exact part, the whole bounded over one hold, never spend; an unknown cost
|
|
59
|
+
* is its known part and its unpriced count. Null: an unknown cost that says neither. No row (undefined): nothing spent. */
|
|
60
|
+
export declare function usageParts(usage: {
|
|
61
|
+
readonly usd: number | null;
|
|
62
|
+
readonly so_far_usd?: number;
|
|
63
|
+
readonly unpriced?: number;
|
|
64
|
+
readonly upper_bound?: true;
|
|
65
|
+
} | undefined): CostParts | null;
|
|
66
|
+
/** A run's cost, by the one rule every reader of it takes (the end's stored cost_usd, GET /runs/{id} and the runs list of
|
|
67
|
+
* an ended run): from its booking alone, over `entries`, every conversation of its journal: its model requests, its paid
|
|
68
|
+
* tool calls and its decisions, each request at what it was booked at (bookedSpend), joined by the kernel's costOfParts.
|
|
69
|
+
* `usd` is their sum, its float noise rounded off (floatNoiseOff); null (unknown) when any request has no known cost, with what is known of
|
|
70
|
+
* it (`known`: the requests' own figures alone, never a cut request's hold) and how many have none (`unpriced`, held ones
|
|
71
|
+
* included) beside it. `atMost`, while `usd` is known: how many of its figures are a cut request's hold, so the cost is at
|
|
72
|
+
* most `usd`. `requests`: how many requests the run booked (0: it booked none, and its cost is not this booking's to say).
|
|
73
|
+
* `unbooked`: a CLI harness's model worked with no request booked (cliModelWorked: its requests went past its model
|
|
74
|
+
* proxy), one charge with no price, so the cost is unknown, never the $0 an empty booking sums to. */
|
|
75
|
+
export type RunCost = CostParts & {
|
|
76
|
+
readonly usd: number | null;
|
|
77
|
+
readonly requests: number;
|
|
78
|
+
};
|
|
79
|
+
export declare function runCostOf(entries: readonly EntryLike[], { unbooked }?: {
|
|
80
|
+
readonly unbooked?: boolean;
|
|
81
|
+
}): RunCost;
|
|
82
|
+
/** A run's cost as its end stores it (the run row's cost_usd and cost_upper_bound): its figure, and whether that is the most
|
|
83
|
+
* it can have cost (a request cut at its hold counted in it). An unknown cost is never a bound. */
|
|
84
|
+
export type EndCost = {
|
|
85
|
+
readonly costUsd: number | null;
|
|
86
|
+
readonly costUpperBound: boolean;
|
|
87
|
+
};
|
|
88
|
+
export declare const endCostOf: (cost: RunCost) => EndCost;
|
|
89
|
+
/** The run's model requests billed to a ChatGPT plan (runner.turn `billing` "plan", booked at no price, chatgpt-plan.ts):
|
|
90
|
+
* how many and their tokens (input, output and cache, as each booking reported them). Each is $0 to the run by the
|
|
91
|
+
* kernel's one rule (turnCostOf), however it ended: the plan pays for it, so no reader counts it unpriced. */
|
|
92
|
+
export declare function planSpend(entries: readonly EntryLike[]): {
|
|
93
|
+
readonly requests: number;
|
|
94
|
+
readonly tokens: number;
|
|
95
|
+
};
|
|
39
96
|
/** Whether a CLI harness's record (`entries`, its root's) shows the model at work: a model message, a tool call it made, or
|
|
40
97
|
* its end-of-run turn's answer. Each took a model request, so a run that shows one and booked none (its requests went
|
|
41
98
|
* past its model proxy) spent what no booking read: its cost is unknown, never $0. */
|
|
@@ -44,15 +101,14 @@ export declare function cliModelWorked(entries: readonly EntryLike[]): boolean;
|
|
|
44
101
|
* harness's record (`cli`), or a workflow's (its model nodes' answers carry pi-ai's $0). A pi run's answers carry their
|
|
45
102
|
* booking (adapters/pi.ts afterResponse). */
|
|
46
103
|
export declare function costIsBooked(entries: readonly EntryLike[], cli: boolean): boolean;
|
|
47
|
-
/** What the run has spent as its cap reads it (the kernel's sessionSpendOf over every session's records: a
|
|
48
|
-
* out at its hold and bound), for a run whose cost is its booking: the
|
|
49
|
-
* session's is unknown, never 0 for it. */
|
|
104
|
+
/** What the run has spent and holds as its cap reads it (the kernel's sessionSpendOf over every session's records: a
|
|
105
|
+
* request still out at its hold and bound), for a run whose cost is its booking: the figure a gate holds it to (the
|
|
106
|
+
* runs list says bookedListSpend). Null when one session's is unknown, never 0 for it. */
|
|
50
107
|
export declare function bookedCapSpend(entries: readonly EntryLike[]): number | null;
|
|
51
|
-
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
|
|
55
|
-
export declare function overCapBound(entries: readonly EntryLike[], capUsd: number): number;
|
|
108
|
+
/** What a run whose cost is its booking has spent, as the runs list says it while the run goes on: every booked request at
|
|
109
|
+
* what it was booked at, never the hold of a request still out (a hold is no spend: the request settles at what it cost,
|
|
110
|
+
* which the cap's own reading, bookedCapSpend, holds it to meanwhile). Null when a booked request's figure is unknown. */
|
|
111
|
+
export declare function bookedListSpend(entries: readonly EntryLike[]): number | null;
|
|
56
112
|
/** A run's metrics as the end commit writes them (the StoredMetrics JSON on the run row): the timeline's count, with the
|
|
57
113
|
* effort the run ran at and, on a harness other than pi, the model its revision named. */
|
|
58
114
|
export type RunMetricsStored = RunMetrics & {
|
|
@@ -60,12 +116,14 @@ export type RunMetricsStored = RunMetrics & {
|
|
|
60
116
|
model?: string;
|
|
61
117
|
};
|
|
62
118
|
/** The run's metrics and cost from its journal `entries`. `decisions`: a workflow run's receipts (none for pi).
|
|
63
|
-
* `effort`/`model`: the enrichment the old storedMetrics added. `
|
|
64
|
-
*
|
|
119
|
+
* `effort`/`model`: the enrichment the old storedMetrics added. `catalog`: the run's MCP tools called by a hashed wire
|
|
120
|
+
* name, each counted under its catalog name (catalogKeyed). `costUsd` is the usage row's cost: null when a response's
|
|
121
|
+
* cost is unknown, 0 before any request (costOf). */
|
|
65
122
|
export declare function runMetrics(entries: readonly EntryLike[], options?: {
|
|
66
123
|
readonly decisions?: readonly DecisionLike[];
|
|
67
124
|
readonly effort?: string;
|
|
68
125
|
readonly model?: string;
|
|
126
|
+
readonly catalog?: ReadonlyMap<string, string>;
|
|
69
127
|
}): {
|
|
70
128
|
metrics: RunMetricsStored;
|
|
71
129
|
costUsd: number | null;
|
|
@@ -73,4 +131,5 @@ export declare function runMetrics(entries: readonly EntryLike[], options?: {
|
|
|
73
131
|
export declare function cliRunMetrics(rootEntries: readonly EntryLike[], booked: BookedSpend, options: {
|
|
74
132
|
readonly effort?: string;
|
|
75
133
|
readonly model: string;
|
|
134
|
+
readonly catalog?: ReadonlyMap<string, string>;
|
|
76
135
|
}): RunMetricsStored;
|