@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/computer-calls.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
// A computer protocol call as a run's record keeps it: its method, whether it answered, how long it
|
|
2
|
-
// code, and for ui.act each step's kind,
|
|
3
|
-
//
|
|
1
|
+
// A computer protocol call as a run's record keeps it: its method, when it started, whether it answered, how long it
|
|
2
|
+
// took, its error's code, the app it named, and for ui.act each step's kind, what it acted on as a person reads it, the
|
|
3
|
+
// route it ran by and whether a readback showed it took. Never a typed or set value and never an answer's bytes: no
|
|
4
|
+
// screenshot is in it, and no text a step set or typed (a secure field's included). What a step acted on is the element's
|
|
5
|
+
// role and name as the run's own ui.observe answers showed them (the words on the screen, never a field's value), a key
|
|
6
|
+
// step's chord (one with a modifier, or a named key: never a lone character, which may be a password's), a nav step's
|
|
7
|
+
// place.
|
|
4
8
|
//
|
|
5
9
|
// The record has two homes. The owner's calls (the computer call channel, computer-channel.ts) are `computer.call`
|
|
6
10
|
// entries on the run's journal. The agent's calls are the `computer_calls` of the tool call that made them, on its
|
|
7
|
-
// tool_result row (timeline/timeline.ts): the adapter loop runs each tool call inside recordingCalls
|
|
8
|
-
// computer
|
|
11
|
+
// tool_result row (timeline/timeline.ts): the adapter loop runs each tool call inside recordingCalls (a pi-native tool's
|
|
12
|
+
// through the session's io: pi.ts; a codemode script's computer call is a call of its own, on its own row), and the run's computer client (recordedClient, made at the
|
|
13
|
+
// claim) records each call made inside one.
|
|
9
14
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
15
|
+
import { stepOf } from "./timeline/computer.js";
|
|
10
16
|
/** The most calls one tool call's record keeps (a code-mode script may make many); past it, `dropped` counts the rest. */
|
|
11
17
|
export const MAX_RECORDED_CALLS = 200;
|
|
12
18
|
/** The journal entry kind of one tool call's computer calls, kept beside the call on the run's root: `{ call, calls,
|
|
@@ -18,14 +24,25 @@ function recordOf(value) {
|
|
|
18
24
|
const one = obj(value);
|
|
19
25
|
if (!one || typeof one.method !== "string" || typeof one.ok !== "boolean" || typeof one.ms !== "number")
|
|
20
26
|
return undefined;
|
|
27
|
+
if (typeof one.started_at !== "string")
|
|
28
|
+
return undefined;
|
|
21
29
|
const steps = Array.isArray(one.steps) ? one.steps.flatMap((step) => {
|
|
22
30
|
const s = obj(step);
|
|
23
31
|
if (!s || typeof s.do !== "string")
|
|
24
32
|
return [];
|
|
25
|
-
|
|
33
|
+
const on = targetOf(s.on);
|
|
34
|
+
return [{
|
|
35
|
+
do: s.do,
|
|
36
|
+
...(on ? { on } : {}),
|
|
37
|
+
...(typeof s.keys === "string" ? { keys: s.keys } : {}),
|
|
38
|
+
...(typeof s.nav === "string" ? { nav: s.nav } : {}),
|
|
39
|
+
...(typeof s.route === "string" ? { route: s.route } : {}),
|
|
40
|
+
...(typeof s.verified === "boolean" ? { verified: s.verified } : {}),
|
|
41
|
+
...(typeof s.error === "string" ? { error: s.error } : {}),
|
|
42
|
+
}];
|
|
26
43
|
}) : undefined;
|
|
27
44
|
return {
|
|
28
|
-
method: one.method, ok: one.ok, ms: one.ms,
|
|
45
|
+
method: one.method, started_at: one.started_at, ...(typeof one.app === "string" ? { app: one.app } : {}), ok: one.ok, ms: one.ms,
|
|
29
46
|
...(typeof one.code === "string" ? { code: one.code } : {}),
|
|
30
47
|
...(steps ? { steps } : {}),
|
|
31
48
|
...(one.expect === "met" || one.expect === "unmet" ? { expect: one.expect } : {}),
|
|
@@ -46,24 +63,50 @@ export function computerCallsOf(entries) {
|
|
|
46
63
|
}
|
|
47
64
|
return out;
|
|
48
65
|
}
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
66
|
+
/** A ComputerTarget as an entry kept it. */
|
|
67
|
+
function targetOf(value) {
|
|
68
|
+
const one = obj(value);
|
|
69
|
+
if (!one || typeof one.role !== "string")
|
|
70
|
+
return undefined;
|
|
71
|
+
return { role: one.role, ...(typeof one.name === "string" ? { name: one.name } : {}) };
|
|
72
|
+
}
|
|
73
|
+
/** The longest element name a row shows: past it, cut with "…" (shownName), after the run's redaction read it whole. */
|
|
74
|
+
export const MAX_TARGET_NAME = 60;
|
|
75
|
+
/** The longest element name a record keeps, whole. A longer one (no control's name on a screen is that long) is kept as
|
|
76
|
+
* no name at all: a part of it could hold part of a secret the redaction no longer recognizes. */
|
|
77
|
+
export const MAX_KEPT_NAME = 1000;
|
|
78
|
+
/** An element's name as a row shows it: through the run's redaction whole, then cut at MAX_TARGET_NAME. Cut first, a
|
|
79
|
+
* held secret across the cut would show its first part. */
|
|
80
|
+
export function shownName(name, redact) {
|
|
81
|
+
const said = redact ? redact(name) : name;
|
|
82
|
+
return said.length > MAX_TARGET_NAME ? `${said.slice(0, MAX_TARGET_NAME - 1)}…` : said;
|
|
83
|
+
}
|
|
84
|
+
/** A ui.act step's record: what it acted on from its params (stepOf, the element by `names`), how it ran from its
|
|
85
|
+
* result. */
|
|
86
|
+
function stepRecord(step, result, names) {
|
|
87
|
+
const what = stepOf(step, names);
|
|
55
88
|
const ran = obj(result);
|
|
56
89
|
const error = obj(ran?.error);
|
|
57
90
|
if (error)
|
|
58
|
-
return {
|
|
59
|
-
return {
|
|
91
|
+
return { ...what, error: typeof error.kind === "string" ? error.kind : "error" };
|
|
92
|
+
return { ...what, ...(typeof ran?.route === "string" ? { route: ran.route } : {}), ...(typeof ran?.verified === "boolean" ? { verified: ran.verified } : {}) };
|
|
93
|
+
}
|
|
94
|
+
/** The app a call of `method` names: apps.launch's and apps.terminate's id, a ui call's target app. */
|
|
95
|
+
function appOf(method, params) {
|
|
96
|
+
const given = obj(params);
|
|
97
|
+
const app = method.startsWith("apps.") ? given?.id : method.startsWith("ui.") ? obj(given?.target)?.app : undefined;
|
|
98
|
+
return typeof app === "string" && app ? app : undefined;
|
|
60
99
|
}
|
|
61
|
-
/** The record of a call of `method` with `params
|
|
62
|
-
* after `ms`. Reads the params only for a ui.act's
|
|
63
|
-
|
|
100
|
+
/** The record of a call of `method` with `params`, started at `startedAt` (ms since the epoch), that answered `answer`
|
|
101
|
+
* (`{ ok, value }` or `{ ok: false, error }`) after `ms`. Reads the params only for the app they name and a ui.act's
|
|
102
|
+
* steps (each step's element by `names`); keeps no typed or set value. */
|
|
103
|
+
export function callRecordOf(method, params, answer, ms, startedAt, names = () => undefined) {
|
|
64
104
|
const said = obj(answer);
|
|
65
105
|
const ok = said?.ok === true;
|
|
66
|
-
|
|
106
|
+
// A look that names no app looks at the one in front: the answer names it.
|
|
107
|
+
const shown = method === "ui.observe" && ok ? obj(obj(said?.value)?.app)?.id : undefined;
|
|
108
|
+
const app = appOf(method, params) ?? (typeof shown === "string" && shown ? shown : undefined);
|
|
109
|
+
const base = { method, started_at: new Date(startedAt).toISOString(), ...(app ? { app } : {}), ok, ms: Math.max(0, Math.round(ms)) };
|
|
67
110
|
if (!ok) {
|
|
68
111
|
const code = obj(said?.error)?.code;
|
|
69
112
|
return { ...base, code: typeof code === "string" ? code : "error" };
|
|
@@ -75,10 +118,37 @@ export function callRecordOf(method, params, answer, ms) {
|
|
|
75
118
|
const asked = Array.isArray(obj(params)?.steps) ? obj(params).steps : [];
|
|
76
119
|
return {
|
|
77
120
|
...base,
|
|
78
|
-
steps: results.map((result, index) => stepRecord(asked[index], result)),
|
|
121
|
+
steps: results.map((result, index) => stepRecord(asked[index], result, names)),
|
|
79
122
|
...(value?.expect === "met" || value?.expect === "unmet" ? { expect: value.expect } : {}),
|
|
80
123
|
};
|
|
81
124
|
}
|
|
125
|
+
/** The most refs a client keeps the names of: past it, the ones learned first go. */
|
|
126
|
+
const MAX_NAMED_REFS = 10_000;
|
|
127
|
+
/** The names a client's ui.observe answers gave each ref: role and name (never a value), the name whole up to
|
|
128
|
+
* MAX_KEPT_NAME (the row cuts it, after the redaction: shownName).
|
|
129
|
+
* Each observe's nodes are learned again (a ref's element keeps its ref across states, so its newest name wins). */
|
|
130
|
+
export class RefNames {
|
|
131
|
+
#byRef = new Map();
|
|
132
|
+
learn(answer) {
|
|
133
|
+
const nodes = obj(obj(answer)?.value)?.nodes;
|
|
134
|
+
if (!Array.isArray(nodes))
|
|
135
|
+
return;
|
|
136
|
+
for (const node of nodes) {
|
|
137
|
+
const one = obj(node);
|
|
138
|
+
if (typeof one?.ref !== "string" || typeof one.role !== "string")
|
|
139
|
+
continue;
|
|
140
|
+
const name = typeof one.name === "string" ? one.name.replace(/\s+/g, " ").trim() : "";
|
|
141
|
+
this.#byRef.delete(one.ref);
|
|
142
|
+
this.#byRef.set(one.ref, { role: one.role, ...(name && name.length <= MAX_KEPT_NAME ? { name } : {}) });
|
|
143
|
+
}
|
|
144
|
+
for (const ref of this.#byRef.keys()) {
|
|
145
|
+
if (this.#byRef.size <= MAX_NAMED_REFS)
|
|
146
|
+
break;
|
|
147
|
+
this.#byRef.delete(ref);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
of = (ref) => this.#byRef.get(ref);
|
|
151
|
+
}
|
|
82
152
|
const scope = new AsyncLocalStorage();
|
|
83
153
|
/** Runs `work` with every call a recordedClient makes inside it recorded, in the order the calls were made, and hands
|
|
84
154
|
* the records (with how many past MAX_RECORDED_CALLS were dropped) to `keep` once it settled, thrown or not, when it
|
|
@@ -99,26 +169,39 @@ export function unrecorded(work) {
|
|
|
99
169
|
return scope.exit(work);
|
|
100
170
|
}
|
|
101
171
|
/** `client`, with each call made inside a recordingCalls scope recorded there when it settles. A call outside any scope
|
|
102
|
-
* (the owner's, through the channel, or the runner's own) is recorded nowhere
|
|
172
|
+
* (the owner's, through the channel, or the runner's own) is recorded nowhere; its ui.observe answer still names the
|
|
173
|
+
* refs a later recorded step acts on. */
|
|
103
174
|
export function recordedClient(client) {
|
|
175
|
+
const names = new RefNames();
|
|
176
|
+
// Bound: a provider's DaemonClient reads its own fields through `this`.
|
|
177
|
+
const send = client.call.bind(client);
|
|
104
178
|
return {
|
|
105
179
|
call: (async (method, params, options) => {
|
|
106
180
|
const into = scope.getStore();
|
|
107
|
-
if (!into)
|
|
108
|
-
|
|
181
|
+
if (!into) {
|
|
182
|
+
const answer = await send(method, params, options);
|
|
183
|
+
if (method === "ui.observe")
|
|
184
|
+
names.learn(answer);
|
|
185
|
+
return answer;
|
|
186
|
+
}
|
|
109
187
|
// Its place is kept when it starts, so calls made together read in the order they were made, and the bound keeps
|
|
110
188
|
// the first ones made. A call still going when its tool call ended reads unfinished.
|
|
111
|
-
const
|
|
189
|
+
const startedAt = Date.now();
|
|
190
|
+
const app = appOf(method, params);
|
|
191
|
+
const open = { method, started_at: new Date(startedAt).toISOString(), ...(app ? { app } : {}), ok: false };
|
|
192
|
+
const slot = into.calls.length < MAX_RECORDED_CALLS ? into.calls.push({ ...open, ms: 0, code: "unfinished" }) - 1 : undefined;
|
|
112
193
|
if (slot === undefined)
|
|
113
194
|
into.dropped += 1;
|
|
114
195
|
const started = performance.now();
|
|
115
|
-
const answer = await
|
|
196
|
+
const answer = await send(method, params, options).catch((error) => {
|
|
116
197
|
if (slot !== undefined)
|
|
117
|
-
into.calls[slot] = {
|
|
198
|
+
into.calls[slot] = { ...open, ms: Math.round(performance.now() - started), code: "gone" };
|
|
118
199
|
throw error;
|
|
119
200
|
});
|
|
201
|
+
if (method === "ui.observe")
|
|
202
|
+
names.learn(answer);
|
|
120
203
|
if (slot !== undefined)
|
|
121
|
-
into.calls[slot] = callRecordOf(method, params, answer, performance.now() - started);
|
|
204
|
+
into.calls[slot] = callRecordOf(method, params, answer, performance.now() - started, startedAt, names.of);
|
|
122
205
|
return answer;
|
|
123
206
|
}),
|
|
124
207
|
close: () => client.close(),
|
|
@@ -83,6 +83,8 @@ export type ComputerHoldAnswer = {
|
|
|
83
83
|
readonly hold: HoldState;
|
|
84
84
|
readonly outcome?: AskOutcome;
|
|
85
85
|
};
|
|
86
|
+
/** The kind of computer run `runId`'s revision asks for (its `computer` or `place`); undefined where it says neither. */
|
|
87
|
+
export declare function runComputerKind(store: Pick<Store, "runs" | "agents">, runId: string): Promise<string | undefined>;
|
|
86
88
|
/** The kind of computer run `runId`'s revision asks for, when it is one a person watches and takes (a desktop or a phone). */
|
|
87
89
|
export declare function runViewedKind(store: Pick<Store, "runs" | "agents">, runId: string): Promise<ViewedKind | undefined>;
|
|
88
90
|
/** Whether run `runId` is over: no computer of an ended run is up. */
|
|
@@ -202,13 +202,17 @@ export async function handBackCommand(store, runId, computer, read, outcome, fre
|
|
|
202
202
|
return {};
|
|
203
203
|
throw new ApiError("handoff_answered", takeEndedWords(computer, "given"), { details: { ended: "given" } });
|
|
204
204
|
}
|
|
205
|
-
/** The kind of computer run `runId`'s revision asks for
|
|
206
|
-
export async function
|
|
205
|
+
/** The kind of computer run `runId`'s revision asks for (its `computer` or `place`); undefined where it says neither. */
|
|
206
|
+
export async function runComputerKind(store, runId) {
|
|
207
207
|
const run = await store.runs.get(runId);
|
|
208
208
|
const revision = run ? await store.agents.revision(run.revisionId) : undefined;
|
|
209
209
|
const body = revision?.body;
|
|
210
210
|
const setting = body && typeof body === "object" ? settingOfDefinition(body) : undefined;
|
|
211
|
-
|
|
211
|
+
return setting?.computer.kind;
|
|
212
|
+
}
|
|
213
|
+
/** The kind of computer run `runId`'s revision asks for, when it is one a person watches and takes (a desktop or a phone). */
|
|
214
|
+
export async function runViewedKind(store, runId) {
|
|
215
|
+
const kind = await runComputerKind(store, runId);
|
|
212
216
|
return kind === "desktop" || kind === "phone" ? kind : undefined;
|
|
213
217
|
}
|
|
214
218
|
/** Whether run `runId` is over: no computer of an ended run is up. */
|
package/dist/computer-live.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { type ComputerCallStore } from "./computer-commands.js";
|
|
|
7
7
|
import { type ComputerHoldChange } from "./runner/computer-journal.js";
|
|
8
8
|
import type { Claim } from "./store/store.js";
|
|
9
9
|
import type { ComputerHold, HoldState } from "./workspace/computer-hold.js";
|
|
10
|
+
import { type ParkedEnd } from "./workspace/computer-kept.js";
|
|
10
11
|
export type { HoldEnd, HoldState } from "./workspace/computer-hold.js";
|
|
11
12
|
/** The bounds a viewer is held to (pi-browser's server.ts keeps the same): how long a connection may stay silent before
|
|
12
13
|
* its hello and how many may wait for one; past `slowViewerBytes` unsent no frame is sent (nor the watch acked) until the
|
|
@@ -74,9 +75,13 @@ export declare const PLACES: PlacesHold<ComputerCallStore>;
|
|
|
74
75
|
export declare function viewerHoldOf<S>(places: PlacesHold<S>, store: S, runId: string, local: RunnersHold): ViewerHold;
|
|
75
76
|
/** The computer's live frames and input: its provider's watch on the computer's ref (provider.watch(ref, ...)). */
|
|
76
77
|
export type ComputerWatchOf = (handlers: ScreenWatchHandlers, options: WatchOptions) => Promise<Result<ScreenWatch>>;
|
|
78
|
+
/** Why a view closes: its computer was released, its run ended, or its run parked with the computer kept (ParkedEnd: why
|
|
79
|
+
* it parked and until when it is kept), said to its viewer as the run's wait (parkedWords), never as an end. */
|
|
80
|
+
export type ViewClose = "released" | "ended" | ParkedEnd;
|
|
77
81
|
export interface ComputerView {
|
|
78
|
-
/** The computer's session is over: the row is dropped under the claim, the token dies, an open socket gets "ended"
|
|
79
|
-
|
|
82
|
+
/** The computer's session is over: the row is dropped under the claim, the token dies, an open socket gets "ended"
|
|
83
|
+
* with why, in words. */
|
|
84
|
+
close(why: ViewClose): Promise<void>;
|
|
80
85
|
}
|
|
81
86
|
export type OpenComputerView = {
|
|
82
87
|
store: LiveViewerStore;
|
|
@@ -89,6 +94,10 @@ export type OpenComputerView = {
|
|
|
89
94
|
tag: string;
|
|
90
95
|
watch: ComputerWatchOf;
|
|
91
96
|
hold: ViewerHold;
|
|
97
|
+
/** Whether the computer is gone now: its provider no longer has it. Asked when its watch ends gone or does not start
|
|
98
|
+
* for want of the computer (not found, gone); a gone one's view closes "released", so the run's Screen reads it
|
|
99
|
+
* released. A stream that ended with the computer still there keeps its view. Absent: never asked. */
|
|
100
|
+
gone?: () => Promise<boolean>;
|
|
92
101
|
/** The frames' width at most, and their JPEG quality (the computer's defaults when absent). */
|
|
93
102
|
maxWidth?: number;
|
|
94
103
|
quality?: number;
|
|
@@ -127,6 +136,7 @@ export type ClaimViewArgs = {
|
|
|
127
136
|
readonly tag: string;
|
|
128
137
|
readonly watch: ComputerWatchOf;
|
|
129
138
|
readonly hold: unknown;
|
|
139
|
+
readonly gone?: () => Promise<boolean>;
|
|
130
140
|
};
|
|
131
141
|
/** The runner's opener for computerForClaim's openComputerView dep (runner/main.ts runnerComputers): the view of a run's
|
|
132
142
|
* desktop or phone under its claim, on the store the claim was given, held through viewerHoldOf over tl-places' calls on
|
package/dist/computer-live.js
CHANGED
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
// vendor's flag.
|
|
18
18
|
//
|
|
19
19
|
// One viewer per computer: a second socket is refused viewer_in_use. The viewer closing or losing its socket mid-take is
|
|
20
|
-
// the hold's away (again once a take it was waiting for lands, if it lands after). close("released" | "ended"
|
|
21
|
-
// row under the claim, ends the socket, the watch and the endpoint
|
|
20
|
+
// the hold's away (again once a take it was waiting for lands, if it lands after). close("released" | "ended" | a park's
|
|
21
|
+
// ParkedEnd) drops the row under the claim, ends the socket, the watch and the endpoint; a park's tells the viewer what
|
|
22
|
+
// the run waits for and how long its computer is kept, never that it ended. Re-registering the same tag (a relaunch) replaces the
|
|
22
23
|
// row, and the old viewer is ended. Every frame the watch hands over is acked once: drawn, replaced, or let go with its
|
|
23
24
|
// viewer. The token is in no log, no error and no row in plaintext.
|
|
24
25
|
import { randomBytes } from "node:crypto";
|
|
@@ -29,6 +30,7 @@ import { provenFor } from "./live-reach.js";
|
|
|
29
30
|
import { computerHoldOf, handBackComputer, takeOverComputer } from "./computer-commands.js";
|
|
30
31
|
import { onComputerHold } from "./runner/computer-journal.js";
|
|
31
32
|
import { sealColumn, sealedAt } from "./store/seal.js";
|
|
33
|
+
import { lapsedWords, parkedWords } from "./workspace/computer-kept.js";
|
|
32
34
|
/** Where the viewer's endpoint listens: the runner's loopback address alone. */
|
|
33
35
|
const LOOPBACK = "127.0.0.1"; // key-gate: loopback-rule the one address the run-side computer viewer listens on
|
|
34
36
|
const TAG = /^[A-Za-z0-9._:-]{1,200}$/;
|
|
@@ -81,6 +83,7 @@ export const claimViewOpener = (at) => (args) => {
|
|
|
81
83
|
return openComputerView({
|
|
82
84
|
store, sealKey: args.sealKey, claim, kind: args.kind, input: args.input, tag: args.tag, watch: args.watch,
|
|
83
85
|
hold: viewerHoldOf(PLACES, store, claim.runId, args.hold),
|
|
86
|
+
...(args.gone ? { gone: args.gone } : {}),
|
|
84
87
|
...(at ? { at } : {}),
|
|
85
88
|
});
|
|
86
89
|
};
|
|
@@ -379,6 +382,13 @@ async function openOne(input, key) {
|
|
|
379
382
|
void Promise.resolve().then(() => hold.away()).catch(() => undefined);
|
|
380
383
|
}
|
|
381
384
|
};
|
|
385
|
+
/** The watch ended (or never started) for want of its computer: a computer its provider no longer has (deleted under
|
|
386
|
+
* the run) is released, and its view closes; one still there (its stream ended) keeps its view. */
|
|
387
|
+
const goneAsked = () => {
|
|
388
|
+
if (!input.gone || closed)
|
|
389
|
+
return;
|
|
390
|
+
void input.gone().then((gone) => (gone ? view.close("released") : undefined), () => undefined);
|
|
391
|
+
};
|
|
382
392
|
const startWatch = async (conn) => {
|
|
383
393
|
const current = viewer;
|
|
384
394
|
const handlers = {
|
|
@@ -390,6 +400,8 @@ async function openOne(input, key) {
|
|
|
390
400
|
return;
|
|
391
401
|
send(conn, { type: "ended", reason: error.code, message: redactWords(error.message) });
|
|
392
402
|
conn.close(CLOSE_CODES.browser_closed, "ended");
|
|
403
|
+
if (error.code === "gone")
|
|
404
|
+
goneAsked();
|
|
393
405
|
},
|
|
394
406
|
};
|
|
395
407
|
const started = await watch(handlers, { signal: current.abort.signal, ...(input.maxWidth ? { maxWidth: input.maxWidth } : {}), ...(input.quality ? { quality: input.quality } : {}) }).catch((error) => ({ ok: false, error: { code: "unreachable", message: error?.message ?? String(error) } }));
|
|
@@ -398,6 +410,8 @@ async function openOne(input, key) {
|
|
|
398
410
|
const code = started.error.code === "gone" || started.error.code === "unsupported" || started.error.code === "refused" ? started.error.code : "unreachable";
|
|
399
411
|
send(conn, { type: "ended", reason: code, message: redactWords(started.error.message) });
|
|
400
412
|
conn.close(CLOSE_CODES.browser_closed, "ended");
|
|
413
|
+
if (started.error.code === "gone" || started.error.code === "not_found")
|
|
414
|
+
goneAsked();
|
|
401
415
|
}
|
|
402
416
|
return;
|
|
403
417
|
}
|
|
@@ -616,10 +630,12 @@ async function openOne(input, key) {
|
|
|
616
630
|
const row = (await store.liveViewers.of(claim.runId).catch(() => [])).find((each) => each.kind === kind && each.tag === tag);
|
|
617
631
|
if (row?.id === id)
|
|
618
632
|
await store.liveViewers.drop(claim, kind, tag).catch(() => undefined);
|
|
619
|
-
const
|
|
633
|
+
const said = typeof why === "object"
|
|
634
|
+
? { type: "ended", reason: "parked", message: parkedWords(kind, why.parked), keptMs: Math.max(0, why.until - Date.now()), lapsed: lapsedWords(kind) }
|
|
635
|
+
: { type: "ended", reason: why, message: ENDED[why] };
|
|
620
636
|
for (const conn of [...pending, ...(viewer ? [viewer.conn] : [])]) {
|
|
621
|
-
send(conn,
|
|
622
|
-
conn.close(CLOSE_CODES.released,
|
|
637
|
+
send(conn, said);
|
|
638
|
+
conn.close(CLOSE_CODES.released, typeof why === "object" ? "parked" : why);
|
|
623
639
|
}
|
|
624
640
|
pending.clear();
|
|
625
641
|
if (viewer) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type ComputerHoldAnswer, type ComputerCallOptions, type ComputerCallStore, computerAsk, computerHoldOf, handBackComputer, runViewedKind, takeOverComputer, type ViewedKind } from "./computer-commands.js";
|
|
1
|
+
import { type ComputerHoldAnswer, type ComputerCallOptions, type ComputerCallStore, computerAsk, computerHoldOf, handBackComputer, runComputerKind, runViewedKind, takeOverComputer, type ViewedKind } from "./computer-commands.js";
|
|
2
2
|
import { type HoldState } from "./workspace/computer-hold.js";
|
|
3
3
|
export type { ViewedKind } from "./computer-commands.js";
|
|
4
|
-
export { computerAsk, computerHoldOf, handBackComputer, runViewedKind, takeOverComputer };
|
|
4
|
+
export { computerAsk, computerHoldOf, handBackComputer, runComputerKind, runViewedKind, takeOverComputer };
|
|
5
5
|
/** The run's desktop or phone, as the store has it: for tl-browser's GET /v2/runs/{id}/computer to build on. */
|
|
6
6
|
export type ComputerViewRead = {
|
|
7
7
|
readonly kind: ViewedKind | null;
|
package/dist/computer-routes.js
CHANGED
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
// runner committed them to the run's journal; a take-over or hand-back is a command row the runner applies to the run's
|
|
9
9
|
// hold (workspace/computer-hold.ts). Nothing is kept in this process, so any server answers the same, and a take-over
|
|
10
10
|
// outlives the server that took it.
|
|
11
|
-
import { computerAsk, computerHoldOf, entriesOf, handBackComputer, holdIn, holdShown, runOver, runViewedKind, takeOverComputer, } from "./computer-commands.js";
|
|
11
|
+
import { computerAsk, computerHoldOf, entriesOf, handBackComputer, holdIn, holdShown, runComputerKind, runOver, runViewedKind, takeOverComputer, } from "./computer-commands.js";
|
|
12
12
|
import { ApiError, invalid } from "./errors.js";
|
|
13
13
|
import { unknownFields } from "./validate.js";
|
|
14
14
|
import { HOLD_IDLE_MS } from "./workspace/computer-hold.js";
|
|
15
|
-
export { computerAsk, computerHoldOf, handBackComputer, runViewedKind, takeOverComputer };
|
|
15
|
+
export { computerAsk, computerHoldOf, handBackComputer, runComputerKind, runViewedKind, takeOverComputer };
|
|
16
16
|
/** Our routes' names in serve's route table: each takes the owner's password session, never a token. */
|
|
17
17
|
export const COMPUTER_ROUTES = new Set(["takeOverRunComputer", "handBackRunComputer"]);
|
|
18
18
|
/** How long a take-over lasts with no input from the owner, in minutes, for the API's words. */
|
|
@@ -7,8 +7,14 @@ export type GpuSetting = {
|
|
|
7
7
|
readonly type: string;
|
|
8
8
|
readonly count: number;
|
|
9
9
|
};
|
|
10
|
+
/** How an agent drives a desktop or a phone: "code", by scripts alone (codemode, or its harness's own code mode, whose
|
|
11
|
+
* nested calls reach computer_observe, computer_act and computer_screenshot, which are not listed); "tools", by those
|
|
12
|
+
* step tools, listed. The hand-over is listed in both; absent, as "tools" (run-tools.ts scriptsOnly). */
|
|
13
|
+
export declare const COMPUTER_SURFACES: readonly ["code", "tools"];
|
|
14
|
+
export type ComputerSurface = (typeof COMPUTER_SURFACES)[number];
|
|
10
15
|
/** The setting as a revision keeps it. `image`: one the provider's descriptor offers for the kind (Orgo's `windows`);
|
|
11
|
-
* absent, the kind's default. A sandbox may ask for GPUs; whether its provider gives them is the claim's check.
|
|
16
|
+
* absent, the kind's default. A sandbox may ask for GPUs; whether its provider gives them is the claim's check. A
|
|
17
|
+
* desktop or a phone may say its surface, and `exec: false`: the agent gets no shell and starts no program on it. */
|
|
12
18
|
export type ComputerSetting = {
|
|
13
19
|
readonly kind: "none";
|
|
14
20
|
} | {
|
|
@@ -18,7 +24,14 @@ export type ComputerSetting = {
|
|
|
18
24
|
readonly gpu?: GpuSetting;
|
|
19
25
|
readonly persistent?: boolean;
|
|
20
26
|
} | {
|
|
21
|
-
readonly kind:
|
|
27
|
+
readonly kind: "desktop" | "phone";
|
|
28
|
+
readonly provider: string;
|
|
29
|
+
readonly image?: string;
|
|
30
|
+
readonly persistent?: boolean;
|
|
31
|
+
readonly surface?: ComputerSurface;
|
|
32
|
+
readonly exec?: boolean;
|
|
33
|
+
} | {
|
|
34
|
+
readonly kind: "browser";
|
|
22
35
|
readonly provider: string;
|
|
23
36
|
readonly image?: string;
|
|
24
37
|
readonly persistent?: boolean;
|
package/dist/computer-setting.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// An agent's computer, its one setting for where its tools run (Settings → Computers): `computer: { kind, provider?,
|
|
2
|
-
// image?, gpu?, persistent? }` on its revision. kind is none, sandbox, desktop, phone or browser;
|
|
3
|
-
// the computer providers (the computer package's kind registry), and is absent for none; image
|
|
4
|
-
// offers for the kind, and absent is the kind's default; a sandbox's gpu is { type, count };
|
|
5
|
-
// agent's own computer between its runs, where the configuration declares persistence.
|
|
2
|
+
// image?, gpu?, persistent?, surface?, exec? }` on its revision. kind is none, sandbox, desktop, phone or browser;
|
|
3
|
+
// provider names one of the computer providers (the computer package's kind registry), and is absent for none; image
|
|
4
|
+
// names one the provider offers for the kind, and absent is the kind's default; a sandbox's gpu is { type, count };
|
|
5
|
+
// persistent: true keeps the agent's own computer between its runs, where the configuration declares persistence. A
|
|
6
|
+
// desktop's or a phone's surface ("code" or "tools") is how the agent drives it, and exec: false gives the agent no
|
|
7
|
+
// shell and no program start on it (run-tools.ts); the owner's own computer calls keep everything. The v2 API's `place` is this
|
|
6
8
|
// setting's view, one to one where it can say it: {mode: "runner"} is {kind: "none"}, and {mode: "sandbox", box: X} is
|
|
7
9
|
// {kind: "sandbox", provider: X}. Writing either sets both. A desktop, phone or browser computer leaves the run's folder
|
|
8
10
|
// on the runner, so its place reads runner.
|
|
@@ -10,6 +12,10 @@ import { configurationOf, PROVIDERS, serves } from "@parcha/agentrun-computer";
|
|
|
10
12
|
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11
13
|
/** The kinds of computer an agent can be given. */
|
|
12
14
|
export const COMPUTER_KINDS = ["none", "sandbox", "desktop", "phone", "browser"];
|
|
15
|
+
/** How an agent drives a desktop or a phone: "code", by scripts alone (codemode, or its harness's own code mode, whose
|
|
16
|
+
* nested calls reach computer_observe, computer_act and computer_screenshot, which are not listed); "tools", by those
|
|
17
|
+
* step tools, listed. The hand-over is listed in both; absent, as "tools" (run-tools.ts scriptsOnly). */
|
|
18
|
+
export const COMPUTER_SURFACES = ["code", "tools"];
|
|
13
19
|
/** A GPU type's name as a setting keeps it: the vendor's own ("T4", "A100-80GB", "RTX-PRO-6000"); store/agent-body.ts
|
|
14
20
|
* keeps the same. */
|
|
15
21
|
const GPU_TYPE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
@@ -30,6 +36,16 @@ const OPTIONAL = {
|
|
|
30
36
|
persistent: {
|
|
31
37
|
check: (value, field) => (typeof value === "boolean" ? [] : [{ field, reason: "wrong_type", message: `${field} is true (this agent keeps its own computer between runs) or false (a fresh one for each run)` }]),
|
|
32
38
|
},
|
|
39
|
+
// How the agent drives its desktop or phone (run-tools.ts scriptsOnly): by scripts alone, or by the step tools.
|
|
40
|
+
surface: {
|
|
41
|
+
kinds: ["desktop", "phone"],
|
|
42
|
+
check: (value, field) => (COMPUTER_SURFACES.includes(value) ? [] : [{ field, reason: "not_an_option", message: `${field} is "code" (the agent drives the computer by codemode scripts alone) or "tools" (by its step tools, listed); absent, as "tools"` }]),
|
|
43
|
+
},
|
|
44
|
+
// false: the agent's computer runs no program of its own (run-tools.ts runHands): no shell, no processes, no bash.
|
|
45
|
+
exec: {
|
|
46
|
+
kinds: ["desktop", "phone"],
|
|
47
|
+
check: (value, field) => (typeof value === "boolean" ? [] : [{ field, reason: "wrong_type", message: `${field} is false (the agent gets no shell and starts no program on its computer) or true (as absent)` }]),
|
|
48
|
+
},
|
|
33
49
|
gpu: {
|
|
34
50
|
kinds: ["sandbox"],
|
|
35
51
|
check: (gpu, field) => {
|
package/dist/computer-view.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { JournalEntry } from "./computer-commands.js";
|
|
2
2
|
import type { ViewerKind } from "./store/store.js";
|
|
3
|
+
import { type Kept } from "./workspace/computer-kept.js";
|
|
3
4
|
export type { JournalEntry };
|
|
4
5
|
/** A run's computer: its agent's computer kind (`browser` for the browser tool), the store's viewer kind. */
|
|
5
6
|
export type ComputerKind = ViewerKind;
|
|
@@ -34,6 +35,14 @@ export type ComputerAnswer = {
|
|
|
34
35
|
viewer: string;
|
|
35
36
|
hold: ComputerHold;
|
|
36
37
|
};
|
|
38
|
+
/** Why a parked run's kept computer of `kind` is not kept any more, from its keep's row (computer-kept.ts): its time
|
|
39
|
+
* passed or its end began, in the timeout's words, at that time; nothing while it is kept, with no row, or with one of
|
|
40
|
+
* another kind (a sandbox's: it has no screen). Only for a run still parked: a resumed run's row, taken or left ended,
|
|
41
|
+
* says nothing. */
|
|
42
|
+
export declare function lapsedOf(kind: ComputerKind, kept: Kept | undefined, now: number): {
|
|
43
|
+
at: string;
|
|
44
|
+
why: string;
|
|
45
|
+
} | undefined;
|
|
37
46
|
export declare function computerView(deps: {
|
|
38
47
|
/** The run's open viewer, the owner's link to it (its token in the fragment) and its computer's kind; none, undefined. */
|
|
39
48
|
viewer(): Promise<{
|
|
@@ -52,9 +61,16 @@ export declare function computerView(deps: {
|
|
|
52
61
|
at: string;
|
|
53
62
|
why: string;
|
|
54
63
|
} | undefined>;
|
|
64
|
+
/** Why a parked run's desktop or phone kept at its park is not kept any more (lapsedOf), read only for a `none` desktop
|
|
65
|
+
* or phone; undefined while it is kept or the run is not parked. */
|
|
66
|
+
lapsed?(kind: ComputerKind): Promise<{
|
|
67
|
+
at: string;
|
|
68
|
+
why: string;
|
|
69
|
+
} | undefined>;
|
|
55
70
|
}): Promise<ComputerAnswer>;
|
|
56
71
|
/** Where the run's computer of `kind` is, read from the run's journal `entries` (in order), for a run with no viewer
|
|
57
72
|
* open. A desktop or a phone is opened by the run's claim at its start and held to its end: opening until its viewer
|
|
58
73
|
* answers. A browser is opened by the agent's browser steps (OPENS): unopened with no such call in the run; opening
|
|
59
|
-
* while one has no result yet; closed otherwise (released, or let go with its process).
|
|
60
|
-
|
|
74
|
+
* while one has no result yet; closed otherwise (released, or let go with its process). An `ended` run's computer is
|
|
75
|
+
* opening nothing: a desktop or a phone closed with the run, and a browser step it ended under is closed. */
|
|
76
|
+
export declare function sessionIn(kind: ComputerKind, entries: readonly JournalEntry[], ended?: boolean): ComputerSession;
|
package/dist/computer-view.js
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
// GET /v2/runs/{run_id}/computer's answer: the run's computer live view, one family for every kind (browser, desktop,
|
|
2
2
|
// phone). The viewer comes first: a run's open viewer is served even when its computer would resolve off here now (the
|
|
3
3
|
// run holds the keys it started with). With none open, the run's computer says `none` with its kind and where its session
|
|
4
|
-
// is (never opened, opening, closed), or `off` with why there is no computer here. `hold` is who drives now.
|
|
4
|
+
// is (never opened, opening, closed), or `off` with why there is no computer here. `hold` is who drives now. A parked
|
|
5
|
+
// run's desktop or phone kept at its park is `closed` (the run's timeline says until when), then `ended` in the timeout's
|
|
6
|
+
// words once its time passed.
|
|
5
7
|
import { KINDS } from "./runner/journal-kinds.js";
|
|
6
8
|
import { BROWSER_STEPS } from "./timeline/labels.js";
|
|
9
|
+
import { lapsedWords } from "./workspace/computer-kept.js";
|
|
10
|
+
/** Why a parked run's kept computer of `kind` is not kept any more, from its keep's row (computer-kept.ts): its time
|
|
11
|
+
* passed or its end began, in the timeout's words, at that time; nothing while it is kept, with no row, or with one of
|
|
12
|
+
* another kind (a sandbox's: it has no screen). Only for a run still parked: a resumed run's row, taken or left ended,
|
|
13
|
+
* says nothing. */
|
|
14
|
+
export function lapsedOf(kind, kept, now) {
|
|
15
|
+
if (!kept || kept.kind !== kind)
|
|
16
|
+
return undefined;
|
|
17
|
+
if (kept.ended || kept.ending || now >= kept.until)
|
|
18
|
+
return { at: new Date(kept.until).toISOString(), why: lapsedWords(kind) };
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
7
21
|
export async function computerView(deps) {
|
|
8
22
|
const hold = deps.hold?.() ?? "agent";
|
|
9
23
|
const open = await deps.viewer();
|
|
@@ -12,7 +26,7 @@ export async function computerView(deps) {
|
|
|
12
26
|
const computer = deps.computer();
|
|
13
27
|
if ("off" in computer)
|
|
14
28
|
return { state: "off", hold: "agent", why: computer.off };
|
|
15
|
-
const ended = computer.kind === "browser" ? await deps.ended?.() :
|
|
29
|
+
const ended = computer.kind === "browser" ? await deps.ended?.() : await deps.lapsed?.(computer.kind);
|
|
16
30
|
if (ended)
|
|
17
31
|
return { state: "none", kind: computer.kind, hold, session: "closed", ended };
|
|
18
32
|
return { state: "none", kind: computer.kind, hold, session: deps.session(computer.kind) };
|
|
@@ -29,10 +43,11 @@ const messageOf = (entry) => {
|
|
|
29
43
|
/** Where the run's computer of `kind` is, read from the run's journal `entries` (in order), for a run with no viewer
|
|
30
44
|
* open. A desktop or a phone is opened by the run's claim at its start and held to its end: opening until its viewer
|
|
31
45
|
* answers. A browser is opened by the agent's browser steps (OPENS): unopened with no such call in the run; opening
|
|
32
|
-
* while one has no result yet; closed otherwise (released, or let go with its process).
|
|
33
|
-
|
|
46
|
+
* while one has no result yet; closed otherwise (released, or let go with its process). An `ended` run's computer is
|
|
47
|
+
* opening nothing: a desktop or a phone closed with the run, and a browser step it ended under is closed. */
|
|
48
|
+
export function sessionIn(kind, entries, ended = false) {
|
|
34
49
|
if (kind !== "browser")
|
|
35
|
-
return "opening";
|
|
50
|
+
return ended ? "closed" : "opening";
|
|
36
51
|
let asked = false;
|
|
37
52
|
const waiting = new Set();
|
|
38
53
|
const called = (id, name) => {
|
|
@@ -58,5 +73,5 @@ export function sessionIn(kind, entries) {
|
|
|
58
73
|
else if (entry.kind === KINDS.callEnd && typeof data?.callId === "string")
|
|
59
74
|
waiting.delete(data.callId);
|
|
60
75
|
}
|
|
61
|
-
return !asked ? "unopened" : waiting.size ? "opening" : "closed";
|
|
76
|
+
return !asked ? "unopened" : waiting.size && !ended ? "opening" : "closed";
|
|
62
77
|
}
|