@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
package/dist/browser-cost.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
2
2
|
import { PROVIDERS } from "@parcha/agentrun-computer";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { paidStep } from "./paid-calls.js";
|
|
3
|
+
import { BROWSER_CHARGED, SPEND_CAP_REACHED } from "./cap.js";
|
|
4
|
+
import { paidStep, unbookedRefusal } from "./paid-calls.js";
|
|
6
5
|
import { logLine } from "./print.js";
|
|
7
6
|
import { forModel } from "./result.js";
|
|
8
7
|
/** The run journal's record of a browser session about to be created at its provider: its tag (pi-browser's, which a
|
|
@@ -47,26 +46,26 @@ const BROWSER_TOOL = "browser";
|
|
|
47
46
|
* a conversation's session (pi-browser's release, "close"). `log` takes the line that says a charge went uncounted
|
|
48
47
|
* (default: the server's stderr). */
|
|
49
48
|
export function browserSpend(provider, price, idleS, release, log = (line) => void process.stderr.write(`agentrun-serve: ${line}\n`), ledger = {}) {
|
|
50
|
-
/** The runner's one ledger (the kernel cap's paidCalls),
|
|
49
|
+
/** The runner's one ledger (the kernel cap's paidCalls); with none, every call and person's time is refused. Its holds
|
|
50
|
+
* are hold-only steps (`hold`:
|
|
51
51
|
* money reserved, never spent, given back when let go or when a claim is lost): each browser call's, held at the hold
|
|
52
52
|
* main takes for it, a session's reserve, a person's time. Its money is its charges: each one paid step of its own,
|
|
53
53
|
* owed (its time is spent at the provider: never refused, however the run's spend stands), settled at the charge,
|
|
54
54
|
* named by its session and time (`ref`) so it is booked once, and booked once its commit is in (booked); a reopen books
|
|
55
|
-
* any the root holds and the ledger lacks (reopened).
|
|
55
|
+
* any the root holds and the ledger lacks (reopened). Every step names its tool
|
|
56
56
|
* ("browser") and, where it has them, its call and session, so the run view folds it as main's charge. */
|
|
57
57
|
const paid = ledger.paid;
|
|
58
58
|
/** The ledger steps of charges and holds, until they are written (ledgerIdle). */
|
|
59
59
|
const pending = new Set();
|
|
60
60
|
let ledgerSeq = 0;
|
|
61
|
-
/** A hold of `usd` under `name
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* time, a session held from a reopen, a delayed release), held as main's keepHold holds it: never refused. A fresh
|
|
61
|
+
/** A hold of `usd` under `name` on the run's one ledger (a held paid step, given back when the hold is let go, the time
|
|
62
|
+
* it held being booked by the session's own charge). `admitted`: the ledger's answer (refused in the cap's words when
|
|
63
|
+
* it has no room; refused with no ledger, where nothing is held). `owed`: time its provider is already owed, run
|
|
64
|
+
* outside any call (a person's carried time, a session held from a reopen, a delayed release): never refused. A fresh
|
|
66
65
|
* session's reserve and a person's time to come (personTime) are not owed: the cap may refuse them. */
|
|
67
66
|
const holdOf = (name, usd, basis, options = {}) => {
|
|
68
67
|
if (!paid)
|
|
69
|
-
return { hold:
|
|
68
|
+
return { hold: { usd, drop: () => { } }, admitted: Promise.resolve({ refused: unbookedRefusal(name) }) };
|
|
70
69
|
const booking = paid;
|
|
71
70
|
const id = `browser:${name}#${(ledgerSeq += 1)}`;
|
|
72
71
|
const admitted = booking.admit({ id, name, holdUsd: usd, basis, chargedBy: provider, tool: BROWSER_TOOL, hold: true, ...(options.tag ? { tag: options.tag } : {}), ...(options.owed ? { owed: true } : {}) }).then(() => ({}), (error) => {
|
|
@@ -94,11 +93,6 @@ export function browserSpend(provider, price, idleS, release, log = (line) => vo
|
|
|
94
93
|
};
|
|
95
94
|
return { hold, admitted };
|
|
96
95
|
};
|
|
97
|
-
/** A charge joins this process's spend only off the ledger: on it, the charge is the ledger's (its own paid step). */
|
|
98
|
-
const spendIn = (usd) => {
|
|
99
|
-
if (!paid)
|
|
100
|
-
addSpend(usd);
|
|
101
|
-
};
|
|
102
96
|
const rate = price.usdPerHour;
|
|
103
97
|
const usdOf = (seconds) => ((rate ?? 0) * seconds) / 3600;
|
|
104
98
|
const stretchS = price.minimumS + idleS + RELEASE_ALLOWANCE_S;
|
|
@@ -147,18 +141,16 @@ export function browserSpend(provider, price, idleS, release, log = (line) => vo
|
|
|
147
141
|
/** Each call under way, by its id: its conversation and its hold. */
|
|
148
142
|
const calls = new Map();
|
|
149
143
|
const take = (hold, usd) => void (hold && (hold.usd = Math.max(0, hold.usd - usd)));
|
|
150
|
-
/**
|
|
151
|
-
* call
|
|
152
|
-
*
|
|
153
|
-
* nothing. */
|
|
144
|
+
/** Recorded in the commit that bills it: a BROWSER_CHARGED under the call that ran it (a release's, under its session's
|
|
145
|
+
* last call), its money the ledger step's (booked), what it cost or null when its time has no price, and the seconds it
|
|
146
|
+
* was for, with what `booked` needs. A free provider's time books nothing and holds nothing. */
|
|
154
147
|
async function onCharge(charge, tx, call) {
|
|
155
148
|
if (rate === 0)
|
|
156
149
|
return;
|
|
157
150
|
const usd = charge.state === "priced" ? charge.usd : null;
|
|
158
151
|
const data = { tool: "browser", charged_by: charge.provider, call: call?.callId ?? sessions.get(charge.tag)?.call ?? null, usd, seconds: charge.seconds, tag: charge.tag, conversation: charge.conversationId, at: charge.at, final: charge.final };
|
|
159
|
-
//
|
|
160
|
-
|
|
161
|
-
await tx.appendEntry(ROOT_CONVERSATION_ID, { kind: paid ? BROWSER_CHARGED : TOOL_COST, data });
|
|
152
|
+
// Its money is the ledger's, booked once this commit is in (booked): the root keeps the record under a kind no cost reads.
|
|
153
|
+
await tx.appendEntry(ROOT_CONVERSATION_ID, { kind: BROWSER_CHARGED, data });
|
|
162
154
|
}
|
|
163
155
|
/** A charge on the run's one ledger, once its commit is in: one paid step of its own, owed (its time is spent at the
|
|
164
156
|
* provider, so the cap never refuses it, however the run's spend stands), settled at the charge, under its call (the
|
|
@@ -174,14 +166,13 @@ export function browserSpend(provider, price, idleS, release, log = (line) => vo
|
|
|
174
166
|
void step.finally(() => pending.delete(step));
|
|
175
167
|
return step;
|
|
176
168
|
}
|
|
177
|
-
/** A charge whose commit is in (watch):
|
|
178
|
-
*
|
|
169
|
+
/** A charge whose commit is in (watch): booked on the ledger, and it moves the holds. Never inside the commit, so one
|
|
170
|
+
* that fails changes neither. */
|
|
179
171
|
function booked(data) {
|
|
180
172
|
if (paid)
|
|
181
173
|
bookOnLedger(paid, data);
|
|
182
174
|
const usd = data.usd ?? 0;
|
|
183
175
|
const session = sessions.get(data.tag);
|
|
184
|
-
spendIn(data.usd);
|
|
185
176
|
const through = Date.parse(data.at);
|
|
186
177
|
// The part of this charge that is a kept session's person time, run since its last charge up to the charge's own
|
|
187
178
|
// through: that part is held elsewhere already (carried, or still under way) and the call's hold left it out
|
|
@@ -279,18 +270,15 @@ export function browserSpend(provider, price, idleS, release, log = (line) => vo
|
|
|
279
270
|
* `inventory`), once the commit is in: the charges first, so a release billed and ended in one commit is billed from
|
|
280
271
|
* its reserve before it goes. */
|
|
281
272
|
function watch(harness, inventory = "browser.inventory") {
|
|
282
|
-
// pi 1.5 detaches an observer whose advance throws, for good: every later charge would then go
|
|
283
|
-
// So nothing leaves advance
|
|
284
|
-
//
|
|
285
|
-
//
|
|
286
|
-
//
|
|
287
|
-
//
|
|
288
|
-
//
|
|
289
|
-
// listener error, which only a throw out of advance could cause, is unknown at once.
|
|
273
|
+
// pi 1.5 detaches an observer whose advance throws, for good: every later charge would then go unbooked, silently.
|
|
274
|
+
// So nothing leaves advance; a charge it fails to book is said in one line, and the next claim's reopen books it from
|
|
275
|
+
// the root (bookRootCharges). pi ends a commit observer only when its Session closes (session.js close: a normal close
|
|
276
|
+
// ends it `failed` with "session closed", a failed Session `failed` with its error), and the Session's own end
|
|
277
|
+
// (`closed`, settled by that same close once its Storage closed) says which, tagged by kind: `closed` is said
|
|
278
|
+
// nothing, on every close path; `failed` (the store failed, or could not close) is said. A listener error, which only
|
|
279
|
+
// a throw out of advance could cause, is said at once.
|
|
290
280
|
let said = false;
|
|
291
281
|
const uncounted = (why) => {
|
|
292
|
-
// On the run's one ledger a charge is booked in the commit that bills it (onCharge), never from here.
|
|
293
|
-
spendIn(null);
|
|
294
282
|
if (said)
|
|
295
283
|
return;
|
|
296
284
|
said = true;
|
|
@@ -300,7 +288,7 @@ export function browserSpend(provider, price, idleS, release, log = (line) => vo
|
|
|
300
288
|
advance: (publication) => {
|
|
301
289
|
try {
|
|
302
290
|
for (const change of publication.changes) {
|
|
303
|
-
const data = change.type === "entry" &&
|
|
291
|
+
const data = change.type === "entry" && change.value.kind === BROWSER_CHARGED ? change.value.data : undefined;
|
|
304
292
|
if (data?.tool === "browser" && typeof data.tag === "string")
|
|
305
293
|
booked(data);
|
|
306
294
|
}
|
|
@@ -321,14 +309,13 @@ export function browserSpend(provider, price, idleS, release, log = (line) => vo
|
|
|
321
309
|
},
|
|
322
310
|
});
|
|
323
311
|
}
|
|
324
|
-
/** `tool` held under the run's cap before each call. */
|
|
312
|
+
/** `tool` held under the run's cap before each call, on the run's one ledger; with none, refused unsent. */
|
|
325
313
|
function capped(tool) {
|
|
326
314
|
return {
|
|
327
315
|
...tool,
|
|
328
316
|
execute: async (args, api, context) => {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
return refuse(`${SPEND_CAP_REACHED}: This browser call was not sent. ${provider}'s session time has no price here (${priceEnvOf(provider)} gives one), so the run's cap of $${cap} cannot be kept: the run is out of budget.`, api, context);
|
|
317
|
+
if (!paid)
|
|
318
|
+
return refuse(unbookedRefusal("this browser call"), api, context);
|
|
332
319
|
const now = Date.now();
|
|
333
320
|
const mine = [...sessions].filter(([, s]) => s.cid === api.conversationId);
|
|
334
321
|
const ranS = mine.reduce((sum, [, s]) => sum + Math.max(0, now - s.at) / 1000, 0);
|
|
@@ -338,33 +325,19 @@ export function browserSpend(provider, price, idleS, release, log = (line) => vo
|
|
|
338
325
|
// Up to the millionth of a dollar, so the cap's words name a figure never below the hold.
|
|
339
326
|
const usd = microUsd(Math.max(0, usdOf(ranS) - carriedUsd) + 2 * stretch);
|
|
340
327
|
const basis = `${provider}'s session time at $${rate} an hour: the ${Math.round(ranS)} s its session ran since its last charge, and twice the next stretch of ${stretchS} s (its ${price.minimumS} s minimum, the ${idleS} s idle window and ${RELEASE_ALLOWANCE_S} s for its release)`;
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
calls.set(api.callId, { cid: api.conversationId, hold: { usd, drop: () => { } } });
|
|
345
|
-
try {
|
|
346
|
-
// A provider whose time has no price is held at no figure: the cap's rule refuses it for good, as main does.
|
|
347
|
-
// One refused for room pauses the run (ledger.pause, the run's own: a native tool task runs in no host tool
|
|
348
|
-
// call's ledger), in the cap's words and figures, as an ask's person time does: its next request is refused
|
|
349
|
-
// and the run parks for a raise.
|
|
350
|
-
const stepped = await paidStep(ledger.paid, api.callId, { name: "this browser call", holdUsd: rate === null ? Number.NaN : usd, basis, by: provider, tool: BROWSER_TOOL, hold: true }, () => tool.execute(args, api, context), () => 0, ledger.pause);
|
|
351
|
-
return "refused" in stepped ? await refuse(stepped.refused, api, context) : stepped.result;
|
|
352
|
-
}
|
|
353
|
-
finally {
|
|
354
|
-
calls.delete(api.callId);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
const paid = await paidCall("this browser call", async () => keepHold(usd), () => undefined, { usd, basis });
|
|
358
|
-
if ("refused" in paid)
|
|
359
|
-
return refuse(paid.refused, api, context);
|
|
360
|
-
const hold = paid.result;
|
|
361
|
-
calls.set(api.callId, { cid: api.conversationId, hold });
|
|
328
|
+
// One hold-only step, held at that figure and given back when the call returns (or its claim is lost): the call's
|
|
329
|
+
// charges are each their own step (booked).
|
|
330
|
+
calls.set(api.callId, { cid: api.conversationId, hold: { usd, drop: () => { } } });
|
|
362
331
|
try {
|
|
363
|
-
|
|
332
|
+
// A provider whose time has no price is held at no figure: the cap's rule refuses it for good, as main does.
|
|
333
|
+
// One refused for room pauses the run (ledger.pause, the run's own: a native tool task runs in no host tool
|
|
334
|
+
// call's ledger), in the cap's words and figures, as an ask's person time does: its next request is refused
|
|
335
|
+
// and the run parks for a raise.
|
|
336
|
+
const stepped = await paidStep(paid, api.callId, { name: "this browser call", holdUsd: rate === null ? Number.NaN : usd, basis, by: provider, tool: BROWSER_TOOL, hold: true }, () => tool.execute(args, api, context), () => 0, ledger.pause);
|
|
337
|
+
return "refused" in stepped ? await refuse(stepped.refused, api, context) : stepped.result;
|
|
364
338
|
}
|
|
365
339
|
finally {
|
|
366
340
|
calls.delete(api.callId);
|
|
367
|
-
hold.drop();
|
|
368
341
|
}
|
|
369
342
|
},
|
|
370
343
|
};
|
|
@@ -391,37 +364,23 @@ export function browserSpend(provider, price, idleS, release, log = (line) => vo
|
|
|
391
364
|
* and `from` (ms, where the stretch it holds starts; now by default), the stretch is known while held: a call meanwhile
|
|
392
365
|
* leaves out what of it has run, and a charge that books it takes it off the hold. */
|
|
393
366
|
async function personTime(what, seconds, options = {}) {
|
|
394
|
-
const cap = runCap();
|
|
395
|
-
if (cap !== undefined && rate === null)
|
|
396
|
-
return { refused: `${SPEND_CAP_REACHED}: ${what} did not start. ${provider}'s session time has no price here (${priceEnvOf(provider)} gives one), so the run's cap of $${cap} cannot be kept.` };
|
|
397
367
|
// Up to the millionth of a dollar, so the cap's words name a figure never below the hold.
|
|
398
368
|
const usd = Math.ceil(Math.round(usdOf(seconds) * 1e12) / 1e6) / 1e6;
|
|
399
369
|
const basis = `${provider}'s session time at $${rate} an hour for the ${Math.round(seconds / 60)} minutes it may last`;
|
|
400
|
-
//
|
|
401
|
-
//
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
// the
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
if (
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
// nothing.
|
|
413
|
-
if (options.pauses !== false && answer.refusal && ledger.pause)
|
|
414
|
-
await ledger.pause(answer.refusal);
|
|
415
|
-
return { refused: answer.refused };
|
|
416
|
-
}
|
|
417
|
-
hold = held.hold;
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
420
|
-
const paidHere = await paidCall(what, async () => keepHold(usd), () => undefined, { usd, basis }, { pauses: options.pauses });
|
|
421
|
-
if ("refused" in paidHere)
|
|
422
|
-
return { refused: paidHere.refused };
|
|
423
|
-
hold = paidHere.result;
|
|
370
|
+
// Held on the run's one ledger up front, refused in the cap's words when it has no room (an unpriced provider's time
|
|
371
|
+
// held at no figure, which the rule refuses for good; with no ledger, refused); let go at its end, the time itself
|
|
372
|
+
// booked by the session's next charge.
|
|
373
|
+
const held = holdOf(what, rate === null ? Number.NaN : usd, basis);
|
|
374
|
+
const answer = await held.admitted;
|
|
375
|
+
if (answer.refused !== undefined) {
|
|
376
|
+
// The agent's own step (an ask) refused at the cap pauses the run, as main's paidCall pause does: its pause is
|
|
377
|
+
// journaled now and the run's next request is refused in its words. A person's take-over (pauses: false) pauses
|
|
378
|
+
// nothing.
|
|
379
|
+
if (options.pauses !== false && answer.refusal && ledger.pause)
|
|
380
|
+
await ledger.pause(answer.refusal);
|
|
381
|
+
return { refused: answer.refused };
|
|
424
382
|
}
|
|
383
|
+
const hold = held.hold;
|
|
425
384
|
const tag = options.tag;
|
|
426
385
|
if (tag === undefined || !rate)
|
|
427
386
|
return hold;
|
|
@@ -448,11 +407,11 @@ export function browserSpend(provider, price, idleS, release, log = (line) => vo
|
|
|
448
407
|
const from = Math.max(to - seconds * 1000, sessions.get(tag)?.at ?? -Infinity);
|
|
449
408
|
if (!(to > from))
|
|
450
409
|
return;
|
|
451
|
-
// Spent at the provider already: held on the run's ledger
|
|
410
|
+
// Spent at the provider already: held on the run's ledger until a charge books it.
|
|
452
411
|
const { hold } = holdOf("a person's time in the browser", microUsd(usdOf((to - from) / 1000)), `${provider}'s session time a person used, until the session's next charge books it`, { owed: true, tag });
|
|
453
412
|
carried.set(tag, [...(carried.get(tag) ?? []), { hold, from, to }]);
|
|
454
413
|
}
|
|
455
|
-
/** Once every ledger step of a charge under no call is written
|
|
414
|
+
/** Once every ledger step of a charge under no call is written. */
|
|
456
415
|
const ledgerIdle = async () => void (await Promise.all([...pending]));
|
|
457
416
|
return { onCharge, watch, reopened, capped, opening, personTime, carry, stretch, ledgerIdle };
|
|
458
417
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** What the warning reads of an agent's definition: its model, its thinking level, its instructions. */
|
|
2
|
+
export type CapShortRevision = {
|
|
3
|
+
readonly model?: string;
|
|
4
|
+
readonly thinking?: string;
|
|
5
|
+
readonly instructions: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The warning an agent saved with a cap of `capUsd` on `harness` reads when that cap is below what its model needs for one
|
|
9
|
+
* more step and an answer (wrap-up.ts capBelowWarning), else undefined. Never throws: a model or route that cannot be
|
|
10
|
+
* priced here says nothing (the save's other checks name it).
|
|
11
|
+
*/
|
|
12
|
+
export declare function capShortOf(env: NodeJS.ProcessEnv, harness: string, revision: CapShortRevision, capUsd: number): Promise<string | undefined>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// A cap saved below what an agent's model needs for one more step and an answer: its every run wraps up at its first tool
|
|
2
|
+
// call (wrap-up.ts). The save says so, as a warning, and never refuses it (a cap is the person's call). The figure is the
|
|
3
|
+
// wrap-up's own (stepAndAnswerFor over the cap's requestFigures), priced before any run on the first request the agent's
|
|
4
|
+
// harness would send: its own base input (AdapterFacts.baseInputTokens, measured on its pinned build; pi's beside its
|
|
5
|
+
// adapter), the agent's prompt counted with o200k_base where its model's tokenizer is that (no count otherwise: 0, a
|
|
6
|
+
// floor), and the least output its harness's policy reads of that request's reasoning settings at the agent's effort.
|
|
7
|
+
import { o200kModel, o200kTokens } from "@parcha/agentrun-kernel/host";
|
|
8
|
+
import { requestFigures } from "@parcha/agentrun-kernel/kernel/cap";
|
|
9
|
+
import { harnessOf } from "./harness-table.js";
|
|
10
|
+
import { thinkingLevel } from "./model.js";
|
|
11
|
+
import { capBelowWarning, stepAndAnswerFor } from "./wrap-up.js";
|
|
12
|
+
/** The model, policy, reasoning settings and base input of the first request `harness` would send for `revision` here;
|
|
13
|
+
* undefined when it cannot be said (the harness or its model does not run here: the save's other warnings say why). */
|
|
14
|
+
async function firstRequestOf(env, harness, revision) {
|
|
15
|
+
// The run's effort as a run without one of its own takes it (runs-over-store.ts prepareLaunch): its revision's thinking,
|
|
16
|
+
// else the host's AGENT_THINKING; none, none (its harness's own default, of which nothing is known here).
|
|
17
|
+
const level = thinkingLevel(revision.thinking) ?? thinkingLevel(env.AGENT_THINKING);
|
|
18
|
+
const entry = harnessOf(env, harness);
|
|
19
|
+
if (!entry)
|
|
20
|
+
return undefined;
|
|
21
|
+
if (entry.facts) {
|
|
22
|
+
const facts = entry.facts;
|
|
23
|
+
const { cliCapModel } = await import("./runner/cli-run-spec.js");
|
|
24
|
+
const { thinkingFor } = await import("./adapters.js");
|
|
25
|
+
const capModel = await cliCapModel({ ...entry, facts }, env, revision.model);
|
|
26
|
+
return { capModel, policy: facts.policy({ model: capModel.id, tools: [] }), reasoning: effortBody(capModel.api, level ? thinkingFor(facts, level) : undefined), baseTokens: facts.baseInputTokens ?? 0 };
|
|
27
|
+
}
|
|
28
|
+
// An entry with no adapter facts is pi's (harness-table.ts): it runs in the run's process on its route, and its first
|
|
29
|
+
// request's reasoning settings are the ones pi-ai builds for its session's model at that level.
|
|
30
|
+
const { routeOf } = await import("./runner/model-route.js");
|
|
31
|
+
const { capModelOf, PI_WIRES } = await import("./runner/adapter-run-spec.js");
|
|
32
|
+
const { PI_BASE_INPUT_TOKENS, piReasoningOf, policyFor } = await import("./runner/adapters/pi.js");
|
|
33
|
+
const route = await routeOf(revision.model, env, "default", PI_WIRES);
|
|
34
|
+
return { capModel: capModelOf(route), policy: await policyFor(route.provider, route.model, []), reasoning: await piReasoningOf(route, level), baseTokens: PI_BASE_INPUT_TOKENS };
|
|
35
|
+
}
|
|
36
|
+
/** The body a CLI harness's first request names its effort in, on `wire`, as its policy reads it: Responses'
|
|
37
|
+
* `reasoning.effort`, Messages' `output_config.effort`. */
|
|
38
|
+
const effortBody = (wire, effort) => effort === undefined ? {} : wire === "openai-responses" ? { reasoning: { effort } } : { output_config: { effort } };
|
|
39
|
+
/**
|
|
40
|
+
* The warning an agent saved with a cap of `capUsd` on `harness` reads when that cap is below what its model needs for one
|
|
41
|
+
* more step and an answer (wrap-up.ts capBelowWarning), else undefined. Never throws: a model or route that cannot be
|
|
42
|
+
* priced here says nothing (the save's other checks name it).
|
|
43
|
+
*/
|
|
44
|
+
export async function capShortOf(env, harness, revision, capUsd) {
|
|
45
|
+
try {
|
|
46
|
+
const first = await firstRequestOf(env, harness, revision);
|
|
47
|
+
if (!first || first.capModel.plan || first.capModel.price === null)
|
|
48
|
+
return undefined;
|
|
49
|
+
const { capModel, policy } = first;
|
|
50
|
+
const body = { model: capModel.id, ...first.reasoning };
|
|
51
|
+
const least = policy.outputLeast?.(body);
|
|
52
|
+
const effort = policy.effortOf?.(body);
|
|
53
|
+
const prompt = o200kModel(capModel.id) ? await o200kTokens(revision.instructions) : 0;
|
|
54
|
+
const figures = requestFigures({ kind: "model", id: "save", model: capModel, inputTokens: first.baseTokens + prompt, ...(typeof least === "number" ? { outputTokensLeast: least } : {}) });
|
|
55
|
+
return capBelowWarning(capUsd, capModel.id, effort, stepAndAnswerFor(figures, (step0Usd) => step0Usd));
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
}
|