@parcha/agentrun-serve 0.1.0-beta.36 → 0.1.0-beta.38
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 +452 -0
- package/README.md +311 -142
- package/dist/agent-rows.d.ts +1 -1
- package/dist/agents-store.d.ts +35 -3
- package/dist/agents-store.js +39 -14
- 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/attach-conformance-cli.d.ts +1 -0
- package/dist/attach-conformance-cli.js +18 -0
- package/dist/attach-conformance.d.ts +25 -0
- package/dist/attach-conformance.js +343 -0
- package/dist/browser-cost.d.ts +1 -1
- package/dist/browser-cost.js +52 -93
- package/dist/browser-live.d.ts +20 -8
- package/dist/browser-live.js +50 -27
- package/dist/cap.d.ts +0 -407
- package/dist/cap.js +4 -1028
- package/dist/catalog.d.ts +1 -12
- package/dist/catalog.js +4 -34
- package/dist/cli.js +13 -4
- package/dist/composio-preset.d.ts +53 -0
- package/dist/composio-preset.js +221 -0
- package/dist/computer-attach.d.ts +125 -0
- package/dist/computer-attach.js +330 -0
- package/dist/computer-calls.d.ts +60 -0
- package/dist/computer-calls.js +209 -0
- package/dist/computer-channel.d.ts +57 -0
- package/dist/computer-channel.js +115 -0
- package/dist/computer-commands.d.ts +1 -1
- package/dist/computer-held-routes.d.ts +35 -0
- package/dist/computer-held-routes.js +106 -0
- package/dist/computer-held.d.ts +48 -0
- package/dist/computer-held.js +87 -0
- package/dist/computer-keys.d.ts +21 -1
- package/dist/computer-keys.js +53 -11
- package/dist/computer-live.d.ts +165 -0
- package/dist/computer-live.js +655 -0
- package/dist/computer-setting.d.ts +15 -2
- package/dist/computer-setting.js +20 -4
- package/dist/computer-view.d.ts +14 -0
- package/dist/computer-view.js +51 -3
- package/dist/computer-viewer.d.ts +6 -0
- package/dist/computer-viewer.js +311 -0
- package/dist/computers.d.ts +37 -8
- package/dist/computers.js +62 -14
- package/dist/console/assets/index-CjqQirbo.css +1 -0
- package/dist/console/assets/index-b6-XY5A9.js +576 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +2 -0
- package/dist/console-links.js +3 -0
- package/dist/decisions.js +4 -0
- package/dist/faux-computers.d.ts +9 -20
- package/dist/faux-computers.js +56 -26
- package/dist/github-connection.d.ts +10 -2
- package/dist/github-connection.js +65 -2
- package/dist/github-faux.js +1 -1
- package/dist/graph-view.d.ts +1 -1
- package/dist/harness-opencode/adapter.js +7 -3
- package/dist/harness-opencode/facts.js +0 -2
- package/dist/harness-opencode/host/policy.d.ts +2 -5
- package/dist/harness-opencode/host/policy.js +8 -32
- package/dist/harness-table.d.ts +0 -2
- package/dist/harness-table.js +0 -2
- package/dist/harness.d.ts +1 -0
- package/dist/harness.js +35 -1
- package/dist/host-tools.d.ts +2 -6
- package/dist/host-tools.js +7 -10
- package/dist/hosted-search.d.ts +5 -6
- package/dist/hosted-search.js +2 -28
- package/dist/import-sources.d.ts +10 -0
- package/dist/import-sources.js +44 -2
- package/dist/import.d.ts +3 -3
- package/dist/import.js +37 -6
- package/dist/key-words.d.ts +3 -2
- package/dist/key-words.js +4 -2
- package/dist/learn/check.d.ts +10 -2
- package/dist/learn/check.js +13 -5
- package/dist/learn/commit.d.ts +14 -2
- package/dist/learn/commit.js +23 -9
- package/dist/learn/compile.d.ts +243 -0
- package/dist/learn/compile.js +471 -0
- package/dist/learn/folder.d.ts +6 -0
- package/dist/learn/folder.js +4 -1
- package/dist/learn/general.d.ts +69 -0
- package/dist/learn/general.js +75 -0
- package/dist/learn/grade.d.ts +5 -1
- package/dist/learn/grade.js +29 -7
- package/dist/learn/notes.d.ts +8 -0
- package/dist/learn/notes.js +18 -0
- package/dist/learn/promote.d.ts +253 -0
- package/dist/learn/promote.js +428 -0
- package/dist/learn/refit.d.ts +39 -0
- package/dist/learn/refit.js +236 -0
- package/dist/learn/reflect.d.ts +9 -20
- package/dist/learn/reflect.js +18 -125
- package/dist/learn/replay-calls.d.ts +63 -0
- package/dist/learn/replay-calls.js +158 -0
- package/dist/learn/skills.d.ts +50 -14
- package/dist/learn/skills.js +183 -47
- package/dist/learn/workflow-nodes.d.ts +15 -0
- package/dist/learn/workflow-nodes.js +44 -0
- package/dist/learned-nodes.d.ts +50 -2
- package/dist/learned-nodes.js +41 -2
- package/dist/learned-workflow.d.ts +43 -3
- package/dist/learned-workflow.js +170 -28
- package/dist/learning-batch.d.ts +283 -0
- package/dist/learning-batch.js +574 -0
- package/dist/learning-cost.d.ts +18 -6
- package/dist/learning-cost.js +15 -7
- package/dist/learning-evals.d.ts +33 -0
- package/dist/learning-evals.js +98 -0
- package/dist/learning-routes.d.ts +37 -2
- package/dist/learning-routes.js +52 -8
- package/dist/learning-words.d.ts +13 -0
- package/dist/learning-words.js +13 -0
- package/dist/learning.d.ts +55 -17
- package/dist/learning.js +91 -48
- package/dist/live/stream.js +6 -3
- package/dist/live/translate.d.ts +4 -3
- package/dist/live/translate.js +8 -4
- package/dist/live-reach.d.ts +37 -0
- package/dist/live-reach.js +62 -0
- package/dist/llm.js +0 -3
- package/dist/mcp-gateway.d.ts +21 -20
- package/dist/mcp-gateway.js +76 -55
- package/dist/mcp-oauth.d.ts +62 -7
- package/dist/mcp-oauth.js +134 -19
- package/dist/mcp-pin-first.d.ts +37 -0
- package/dist/mcp-pin-first.js +107 -0
- package/dist/mcp-private-hosts.d.ts +4 -4
- package/dist/mcp-private-hosts.js +20 -12
- package/dist/mcp-probe.d.ts +27 -11
- package/dist/mcp-probe.js +60 -42
- package/dist/mcp-secret-writes.js +4 -0
- package/dist/mcp-servers-store.d.ts +115 -25
- package/dist/mcp-servers-store.js +241 -43
- package/dist/mcp-sources.d.ts +39 -0
- package/dist/mcp-sources.js +74 -0
- package/dist/mcp-store.d.ts +21 -4
- package/dist/mcp-store.js +33 -8
- 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 +26 -0
- package/dist/model-form.js +80 -0
- package/dist/model.d.ts +13 -0
- package/dist/model.js +69 -25
- package/dist/monid.d.ts +51 -25
- package/dist/monid.js +226 -140
- package/dist/openapi.js +694 -59
- package/dist/page.d.ts +18 -0
- package/dist/page.js +48 -20
- package/dist/paid-calls.d.ts +26 -29
- package/dist/paid-calls.js +46 -102
- package/dist/place-offers.d.ts +2 -3
- package/dist/place-offers.js +3 -7
- package/dist/place.js +1 -2
- package/dist/print.d.ts +15 -1
- package/dist/print.js +14 -3
- package/dist/propose.d.ts +10 -1
- package/dist/propose.js +30 -10
- package/dist/provider.js +12 -4
- package/dist/reflect-range.d.ts +8 -1
- package/dist/reflect-range.js +3 -2
- package/dist/rows.d.ts +5 -3
- package/dist/rows.js +15 -4
- package/dist/run-launch.d.ts +27 -2
- package/dist/run-launch.js +15 -4
- package/dist/run-learning-served.d.ts +13 -2
- package/dist/run-manifest.d.ts +5 -0
- package/dist/run-manifest.js +20 -0
- package/dist/run-reads-over-store.d.ts +1 -1
- package/dist/run-repo.d.ts +20 -0
- package/dist/run-repo.js +63 -0
- package/dist/run-secrets.js +2 -3
- package/dist/run-timeline-served.d.ts +1 -1
- package/dist/run-timeline-served.js +5 -2
- package/dist/run-view.d.ts +19 -8
- package/dist/run-view.js +62 -26
- package/dist/runnable.d.ts +0 -3
- package/dist/runnable.js +37 -29
- package/dist/runner/adapter-loop.d.ts +47 -17
- package/dist/runner/adapter-loop.js +1427 -303
- package/dist/runner/adapter-run-spec.d.ts +23 -9
- package/dist/runner/adapter-run-spec.js +162 -56
- package/dist/runner/adapters/pi-computer.d.ts +9 -0
- package/dist/runner/adapters/pi-computer.js +51 -0
- package/dist/runner/adapters/pi.d.ts +25 -11
- package/dist/runner/adapters/pi.js +168 -45
- package/dist/runner/beside.d.ts +7 -3
- package/dist/runner/beside.js +21 -11
- package/dist/runner/claim-secrets.d.ts +4 -0
- package/dist/runner/claim-secrets.js +6 -1
- package/dist/runner/cli-run-spec.d.ts +20 -3
- package/dist/runner/cli-run-spec.js +174 -64
- package/dist/runner/commands.d.ts +3 -1
- package/dist/runner/commands.js +28 -3
- package/dist/runner/computer-channel.d.ts +34 -0
- package/dist/runner/computer-channel.js +62 -0
- package/dist/runner/conformance/harness.d.ts +3 -0
- package/dist/runner/conformance/harness.js +224 -17
- package/dist/runner/conformance/subject.d.ts +12 -5
- package/dist/runner/dispatch.js +3 -0
- package/dist/runner/end-of-run.d.ts +23 -12
- package/dist/runner/end-of-run.js +41 -16
- package/dist/runner/feedback-round.d.ts +52 -0
- package/dist/runner/feedback-round.js +79 -0
- package/dist/runner/github-app.d.ts +2 -1
- package/dist/runner/github-app.js +4 -2
- package/dist/runner/harness-loops.js +15 -1
- package/dist/runner/held-run.d.ts +65 -0
- package/dist/runner/held-run.js +158 -0
- package/dist/runner/journal-kinds.d.ts +44 -7
- package/dist/runner/journal-kinds.js +29 -0
- package/dist/runner/journal-reader.d.ts +5 -4
- package/dist/runner/journal-reader.js +12 -10
- package/dist/runner/learning-ask.d.ts +7 -1
- package/dist/runner/learning-ask.js +21 -6
- package/dist/runner/learning-dispatch.d.ts +22 -0
- package/dist/runner/learning-dispatch.js +77 -10
- package/dist/runner/learning-end.d.ts +69 -13
- package/dist/runner/learning-end.js +340 -87
- package/dist/runner/learning-factory.d.ts +1 -1
- package/dist/runner/learning-factory.js +11 -5
- package/dist/runner/learning-loop.d.ts +86 -8
- package/dist/runner/learning-loop.js +178 -23
- package/dist/runner/learning-seed.d.ts +11 -0
- package/dist/runner/learning-seed.js +27 -0
- package/dist/runner/live-ticker.js +1 -0
- package/dist/runner/loop-contract.d.ts +26 -3
- package/dist/runner/loop.d.ts +21 -2
- package/dist/runner/loop.js +23 -2
- package/dist/runner/main.d.ts +13 -1
- package/dist/runner/main.js +27 -5
- package/dist/runner/mcp-claim.d.ts +15 -8
- package/dist/runner/mcp-claim.js +176 -71
- package/dist/runner/mcp-github.js +1 -1
- package/dist/runner/mcp-run.d.ts +21 -57
- package/dist/runner/mcp-run.js +25 -85
- package/dist/runner/meta-tools.d.ts +37 -0
- package/dist/runner/meta-tools.js +268 -0
- package/dist/runner/metrics.d.ts +11 -2
- package/dist/runner/metrics.js +26 -5
- package/dist/runner/model-route.js +12 -3
- package/dist/runner/monid-run.d.ts +16 -0
- package/dist/runner/monid-run.js +96 -0
- package/dist/runner/pr-checkout.d.ts +1 -0
- package/dist/runner/pr-checkout.js +1 -1
- package/dist/runner/promotion.d.ts +80 -0
- package/dist/runner/promotion.js +562 -0
- package/dist/runner/reflect-hook.d.ts +46 -13
- package/dist/runner/reflect-hook.js +149 -48
- package/dist/runner/runner.d.ts +26 -0
- package/dist/runner/runner.js +208 -17
- package/dist/runner/scratch-sweep.d.ts +13 -0
- package/dist/runner/scratch-sweep.js +62 -0
- package/dist/runner/sessions.d.ts +9 -4
- package/dist/runner/sessions.js +5 -1
- package/dist/runner/step-guard.d.ts +62 -0
- package/dist/runner/step-guard.js +93 -0
- package/dist/runner/store-port.d.ts +4 -2
- package/dist/runner/store-secrets.js +4 -3
- package/dist/runner/subagent.d.ts +0 -3
- package/dist/runner/subagent.js +10 -13
- package/dist/runner/workflow-first.d.ts +216 -0
- package/dist/runner/workflow-first.js +303 -0
- package/dist/runner/workflow-host.d.ts +6 -1
- package/dist/runner/workflow-host.js +1 -1
- package/dist/runner/workflow-loop.d.ts +1 -1
- package/dist/runner/workflow-loop.js +17 -10
- package/dist/runner/workflow-spec.d.ts +15 -2
- package/dist/runner/workflow-spec.js +63 -23
- package/dist/runs-over-store.d.ts +17 -3
- package/dist/runs-over-store.js +59 -20
- package/dist/seal-key.js +3 -3
- package/dist/sealed-settings-store.d.ts +5 -2
- package/dist/sealed-settings-store.js +10 -4
- package/dist/secret-writes.d.ts +5 -4
- package/dist/secret-writes.js +5 -4
- package/dist/server-secrets-store.d.ts +4 -3
- package/dist/server-secrets-store.js +15 -9
- package/dist/server-secrets.js +3 -2
- package/dist/server.d.ts +119 -18
- package/dist/server.js +841 -202
- package/dist/settings-wake.d.ts +23 -0
- package/dist/settings-wake.js +65 -0
- package/dist/standard-webhooks.d.ts +4 -1
- package/dist/standard-webhooks.js +8 -4
- package/dist/store/agent-body.d.ts +14 -3
- package/dist/store/agent-body.js +14 -10
- package/dist/store/command-wake.d.ts +13 -0
- package/dist/store/command-wake.js +37 -0
- package/dist/store/dialect.d.ts +6 -0
- package/dist/store/dialect.js +5 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/journal/storage.d.ts +3 -2
- package/dist/store/journal/storage.js +13 -5
- package/dist/store/postgres/connection.js +3 -1
- package/dist/store/postgres/dialect.js +4 -0
- package/dist/store/postgres/migrations/0005_learning_rounds.sql +14 -0
- package/dist/store/postgres/migrations/0006_run_changes_channel_attempts.sql +57 -0
- package/dist/store/postgres/migrations/0007_viewer_host.sql +11 -0
- package/dist/store/postgres/migrations/0008_paired_computers.sql +30 -0
- package/dist/store/postgres/migrations/0009_commands_answer.sql +10 -0
- package/dist/store/postgres/migrations/0010_imported_templates.sql +18 -0
- package/dist/store/postgres/migrations/0011_revision_mcp_pin.sql +13 -0
- package/dist/store/schema.d.ts +10 -1
- package/dist/store/schema.js +104 -15
- 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 +7 -5
- package/dist/store/sqlite/run-patch.js +45 -18
- package/dist/store/sqlite/store.js +331 -72
- package/dist/store/store.d.ts +312 -21
- package/dist/store/store.js +12 -1
- package/dist/store-reads/cap.d.ts +1 -1
- package/dist/store-reads/cap.js +8 -1
- package/dist/store-reads/decisions.d.ts +2 -2
- package/dist/store-reads/decisions.js +1 -1
- package/dist/store-reads/import-summary.d.ts +1 -1
- package/dist/store-reads/journal.d.ts +30 -5
- package/dist/store-reads/journal.js +128 -56
- package/dist/store-reads/learning.d.ts +114 -12
- package/dist/store-reads/learning.js +238 -48
- package/dist/store-reads/loop.d.ts +61 -0
- package/dist/store-reads/loop.js +111 -0
- package/dist/store-reads/runs.d.ts +1 -1
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-view.d.ts +6 -0
- package/dist/store-view.js +59 -26
- package/dist/template-eval.d.ts +18 -9
- package/dist/template-eval.js +95 -68
- package/dist/template-github-permissions.d.ts +24 -10
- package/dist/template-github-permissions.js +36 -15
- 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 +218 -46
- package/dist/templates.js +493 -181
- package/dist/timeline/computer.d.ts +48 -0
- package/dist/timeline/computer.js +169 -0
- package/dist/timeline/index.d.ts +4 -3
- package/dist/timeline/index.js +4 -3
- package/dist/timeline/labels.d.ts +6 -2
- package/dist/timeline/labels.js +93 -2
- package/dist/timeline/origin.d.ts +19 -5
- package/dist/timeline/origin.js +11 -4
- package/dist/timeline/timeline.d.ts +22 -1
- package/dist/timeline/timeline.js +34 -18
- package/dist/timeline/util.d.ts +4 -0
- package/dist/timeline/util.js +14 -0
- package/dist/tool-gate.d.ts +84 -50
- package/dist/tool-gate.js +179 -101
- package/dist/tool-keys.d.ts +4 -1
- package/dist/tool-keys.js +8 -3
- package/dist/tool-list.d.ts +26 -0
- package/dist/tool-list.js +43 -0
- package/dist/tool-names.d.ts +71 -0
- package/dist/tool-names.js +99 -0
- package/dist/tool-plane.d.ts +33 -27
- package/dist/tool-plane.js +72 -39
- package/dist/tools.d.ts +32 -7
- package/dist/tools.js +37 -24
- package/dist/trigger-adapter.d.ts +4 -0
- package/dist/trigger-secrets-shown.d.ts +2 -2
- package/dist/trigger-secrets-shown.js +1 -1
- package/dist/trigger-signatures.d.ts +25 -6
- package/dist/trigger-signatures.js +41 -7
- package/dist/trigger-targets.d.ts +2 -0
- package/dist/trigger-targets.js +1 -0
- package/dist/trigger-webhook.js +5 -2
- package/dist/triggers.d.ts +7 -3
- package/dist/triggers.js +35 -5
- package/dist/turns.js +16 -1
- package/dist/validate.d.ts +15 -7
- package/dist/validate.js +102 -45
- package/dist/web-fetch.d.ts +2 -8
- package/dist/web-fetch.js +2 -22
- package/dist/web-search.d.ts +10 -5
- package/dist/web-search.js +7 -6
- package/dist/webhooks.d.ts +145 -102
- package/dist/webhooks.js +559 -322
- package/dist/workflow/decisions.d.ts +1 -1
- package/dist/workflow/node-runner.d.ts +2 -1
- package/dist/workflow/node.d.ts +2 -1
- package/dist/workflow/node.js +3 -1
- package/dist/workflow/pi-versions.d.ts +23 -0
- package/dist/workflow/pi-versions.js +57 -0
- package/dist/workflow/record-tool.d.ts +2 -1
- package/dist/workflow/store.d.ts +1 -1
- package/dist/workflow/task.js +3 -2
- package/dist/workflow-run.d.ts +1 -1
- package/dist/workspace/attached-computers.d.ts +41 -0
- package/dist/workspace/attached-computers.js +114 -0
- package/dist/workspace/computer-deps.d.ts +19 -9
- package/dist/workspace/computer-deps.js +24 -9
- package/dist/workspace/computer-for-claim.d.ts +23 -8
- package/dist/workspace/computer-for-claim.js +92 -33
- package/dist/workspace/computer-hold.d.ts +11 -27
- package/dist/workspace/computer-hold.js +41 -55
- package/dist/workspace/computer-ledger.d.ts +3 -1
- package/dist/workspace/computer-ledger.js +4 -0
- package/dist/workspace/computer-mcp.d.ts +25 -0
- package/dist/workspace/computer-mcp.js +41 -0
- package/dist/workspace/computer-ports.d.ts +4 -13
- package/dist/workspace/computer-ports.js +4 -107
- package/dist/workspace/computer-script.d.ts +53 -0
- package/dist/workspace/computer-script.js +172 -0
- package/dist/workspace/executors.d.ts +1 -1
- package/dist/workspace/index.d.ts +4 -2
- package/dist/workspace/index.js +3 -1
- package/dist/workspace/kind-skills/desktop/SKILL.md +132 -84
- package/dist/workspace/kind-skills/phone/SKILL.md +104 -85
- package/dist/workspace/local.js +2 -2
- package/dist/workspace/resolve-computer.d.ts +24 -1
- package/dist/workspace/resolve-computer.js +40 -16
- package/dist/workspace/run-tools.d.ts +56 -21
- package/dist/workspace/run-tools.js +55 -34
- package/dist/wrap-up.d.ts +21 -0
- package/dist/wrap-up.js +21 -0
- package/launcher/agentrun-serve +4 -2
- package/package.json +19 -16
- package/templates/README.md +111 -45
- package/templates/code-review/agent.md +30 -14
- 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 +2 -2
- 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/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/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 +3 -2
- package/templates/code-review/skills/review/REVIEWER.md +3 -2
- package/templates/code-review/skills/review/SKILL.md +4 -3
- 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 +4 -3
- 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 +4 -3
- 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-BI4Byidu.js +0 -550
- package/dist/console/assets/index-C19gUF2n.css +0 -1
- package/dist/run-db.d.ts +0 -53
- package/dist/run-db.js +0 -116
- package/dist/tool-blurbs.d.ts +0 -4
- package/dist/tool-blurbs.js +0 -28
- package/dist/tool-budget.d.ts +0 -26
- package/dist/tool-budget.js +0 -56
- package/dist/workflow/readers.d.ts +0 -36
- package/dist/workflow/readers.js +0 -145
- package/dist/workflow/wal.d.ts +0 -11
- package/dist/workflow/wal.js +0 -106
- 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
|
@@ -1,108 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return result.value;
|
|
6
|
-
throw Object.assign(new Error(result.error.message), { code: result.error.code });
|
|
7
|
-
}
|
|
8
|
-
/** The screen's shot: its first piece, then screen.read from where it ends until the end. */
|
|
9
|
-
async function shotOf(client, region) {
|
|
10
|
-
const first = await valueOf(client.call("screen.shot", region ? { region: [...region] } : {}));
|
|
11
|
-
const pieces = [Buffer.from(first.data, "base64")];
|
|
12
|
-
let offset = pieces[0].length;
|
|
13
|
-
for (let eof = first.eof; !eof;) {
|
|
14
|
-
const next = await valueOf(client.call("screen.read", { id: first.id, offset }));
|
|
15
|
-
const piece = Buffer.from(next.data, "base64");
|
|
16
|
-
if (piece.length === 0 && !next.eof)
|
|
17
|
-
throw Object.assign(new Error(`the computer's screenshot stopped at byte ${offset} of ${first.size}`), { code: "invalid" });
|
|
18
|
-
pieces.push(piece);
|
|
19
|
-
offset += piece.length;
|
|
20
|
-
eof = next.eof;
|
|
21
|
-
}
|
|
22
|
-
return { png: Buffer.concat(pieces), width: first.width, height: first.height };
|
|
23
|
-
}
|
|
24
|
-
/** input.actions: a batch that failed partway throws the computer's code and words, and how many ran. */
|
|
25
|
-
async function act(client, actions) {
|
|
26
|
-
const ran = await valueOf(client.call("input.actions", { actions: [...actions] }));
|
|
27
|
-
if (!ran.failed)
|
|
28
|
-
return;
|
|
29
|
-
const words = ran.done > 0 ? `${ran.failed.message} (${ran.done} of ${actions.length} actions ran)` : ran.failed.message;
|
|
30
|
-
throw Object.assign(new Error(words), { code: ran.failed.kind });
|
|
31
|
-
}
|
|
32
|
-
/** A desktop's screen: screen.shot, the whole screen or a region of it in the whole screen's pixels. */
|
|
33
|
-
export const screenOf = (client) => ({
|
|
34
|
-
shot: (options) => shotOf(client, options?.region ? [options.region.x, options.region.y, options.region.w, options.region.h] : undefined),
|
|
35
|
-
});
|
|
36
|
-
/** A desktop's input: input.actions, the batch as the kernel's port gives it (computerd's own actions). */
|
|
37
|
-
export const inputOf = (client) => ({
|
|
38
|
-
actions: (list) => act(client, list),
|
|
39
|
-
});
|
|
40
|
-
/** A node's platform class a model types into: Android's EditText (and its subclasses), iOS's text fields and views. */
|
|
41
|
-
const EDITABLE = /(?:EditText|AutoCompleteTextView)$|^XCUIElementType(?:Secure)?Text(?:Field|View)$|^XCUIElementTypeSearchField$/;
|
|
42
|
-
/** The first text among `node`'s descendants, in document order, else their first label: the name of a node that has
|
|
43
|
-
* none of its own (an Android list row: a clickable layout whose title sits on a child TextView). */
|
|
44
|
-
function innerName(node) {
|
|
45
|
-
let label;
|
|
46
|
-
const stack = [...(node.children ?? [])].reverse();
|
|
47
|
-
while (stack.length) {
|
|
48
|
-
const next = stack.pop();
|
|
49
|
-
if (next.text)
|
|
50
|
-
return next.text;
|
|
51
|
-
label ??= next.label || undefined;
|
|
52
|
-
for (const child of [...(next.children ?? [])].reverse())
|
|
53
|
-
stack.push(child);
|
|
54
|
-
}
|
|
55
|
-
return label;
|
|
56
|
-
}
|
|
57
|
-
/** The screen's structure (apps.ui_tree), flattened in document order, each node with whether a model can tap it or type
|
|
58
|
-
* into it; a node the phone says is not enabled is neither. A clickable node with no text or label of its own is named
|
|
59
|
-
* by its first inner text (else label), as phone_tree shows it, marked so. */
|
|
60
|
-
function flattened(root) {
|
|
61
|
-
const out = [];
|
|
62
|
-
const walk = (node) => {
|
|
63
|
-
const [x, y, w, h] = node.bounds;
|
|
64
|
-
const editable = node.enabled && EDITABLE.test(node.role);
|
|
65
|
-
const clickable = node.enabled && node.clickable === true;
|
|
66
|
-
const inner = clickable && !node.text && !node.label ? innerName(node) : undefined;
|
|
67
|
-
out.push({
|
|
68
|
-
role: node.role,
|
|
69
|
-
...(node.id ? { id: node.id } : {}),
|
|
70
|
-
...(node.text ? { text: node.text } : {}),
|
|
71
|
-
...(node.label ? { label: node.label } : {}),
|
|
72
|
-
bounds: { x, y, w, h },
|
|
73
|
-
clickable,
|
|
74
|
-
editable,
|
|
75
|
-
...(node.focused ? { focused: true } : {}),
|
|
76
|
-
...(inner ? { inner } : {}),
|
|
77
|
-
});
|
|
78
|
-
for (const child of node.children ?? [])
|
|
79
|
-
walk(child);
|
|
80
|
-
};
|
|
81
|
-
walk(root);
|
|
82
|
-
return out;
|
|
83
|
-
}
|
|
84
|
-
/** The keys a phone presses: back and home are its buttons (input.touch's button action), enter a key of the key table. */
|
|
85
|
-
const keyAction = (name) => (name === "enter" ? { type: "key", keys: ["enter"] } : { type: "button", name });
|
|
86
|
-
/** A phone: its screen's shot and structure (apps.ui_tree), a tap, a swipe, typing and its keys as input.actions, its apps.
|
|
87
|
-
* `offers`: whether the phone declares its structure (apps.ui_tree) and its keys (input.keys); one it does not declare
|
|
88
|
-
* is no method of the port (an iPhone offers neither until a live run proves them). Default both. */
|
|
89
|
-
export const phoneOf = (client, offers = {}) => ({
|
|
90
|
-
shot: () => shotOf(client),
|
|
91
|
-
...(offers.tree !== false ? {
|
|
92
|
-
async tree() {
|
|
93
|
-
const tree = await valueOf(client.call("apps.ui_tree", {}));
|
|
94
|
-
return { nodes: flattened(tree.root), total: tree.nodes, truncated: tree.truncated };
|
|
95
|
-
},
|
|
96
|
-
} : {}),
|
|
97
|
-
tap: (at) => act(client, [{ type: "tap", at: [at.x, at.y] }]),
|
|
98
|
-
swipe: ({ from, to, durationMs }) => act(client, [{ type: "swipe", path: [[from.x, from.y], [to.x, to.y]], ms: durationMs }]),
|
|
99
|
-
type: (text) => act(client, [{ type: "type", text }]),
|
|
100
|
-
...(offers.keys !== false ? { key: (name) => act(client, [keyAction(name)]) } : {}),
|
|
101
|
-
apps: {
|
|
102
|
-
async list() {
|
|
103
|
-
const listed = await valueOf(client.call("apps.list", {}));
|
|
104
|
-
return { apps: listed.apps.map((app) => (app.name === undefined ? { id: app.id } : { id: app.id, name: app.name })), foreground: listed.foreground };
|
|
105
|
-
},
|
|
106
|
-
open: async (id) => void (await valueOf(client.call("apps.launch", { id }))),
|
|
107
|
-
},
|
|
1
|
+
/** The port of a computer's surface. */
|
|
2
|
+
export const portOf = (surface) => ({
|
|
3
|
+
groups: surface.card.groups,
|
|
4
|
+
call: (op, args, signal) => surface.call(op, args, signal ? { signal } : {}),
|
|
108
5
|
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type Card } from "@parcha/agentrun-computer/surface";
|
|
2
|
+
import type { Executor } from "@parcha/agentrun-kernel/kernel";
|
|
3
|
+
/** A script's longest run by default, and at most, in ms. */
|
|
4
|
+
export declare const SCRIPT_DEFAULT_MS = 120000;
|
|
5
|
+
export declare const SCRIPT_MAX_MS = 600000;
|
|
6
|
+
/** The run's tool gate's decision of one call, as a script's computer call is held to it: decided as on the run's
|
|
7
|
+
* computer, where the call runs (adapterRunGate's script). */
|
|
8
|
+
export type ScriptDecide = (tool: string, args: unknown) => Promise<"allow" | "ask" | {
|
|
9
|
+
deny: string;
|
|
10
|
+
}>;
|
|
11
|
+
/** What a script's `computer.shell` and `computer.files` are held to: the run's gate, which a person's settings (a denied
|
|
12
|
+
* bash, a read-only bash policy, a denied write) reach through the one decision the run's own tools get. A script can't
|
|
13
|
+
* stop to ask, so a call the gate would ask about is refused in words that send the model to the tool itself. Until a
|
|
14
|
+
* gate is installed (the spec installs it once built) every one of those calls is refused. */
|
|
15
|
+
export declare class ScriptGuard {
|
|
16
|
+
#private;
|
|
17
|
+
private readonly shell;
|
|
18
|
+
private readonly kind?;
|
|
19
|
+
/** `shell`: what the run's bash adds under its bash policy (bash-read-only.ts policyEnv, policyPrelude): the environment
|
|
20
|
+
* that locks git's config down, set over any a script gives, and the line that runs git only at the floor version.
|
|
21
|
+
* `kind`: the run's computer's kind, which a refusal names (the phone, the desktop). */
|
|
22
|
+
constructor(shell?: {
|
|
23
|
+
readonly env: Readonly<Record<string, string>>;
|
|
24
|
+
readonly prelude: string;
|
|
25
|
+
}, kind?: string | undefined);
|
|
26
|
+
/** `op`'s arguments as the computer is sent them: a script's shell command with the policy's safeguards, as the bash
|
|
27
|
+
* tool's own command has them, which no option of the script's overrides. */
|
|
28
|
+
shaped(op: string, args: unknown): unknown;
|
|
29
|
+
install(decide: ScriptDecide): void;
|
|
30
|
+
/** Why `op` with `args` may not run now, or undefined when the gate lets it. The words start with what could not be
|
|
31
|
+
* done, on which computer ("could not run a shell command on the phone"), as the Timeline's row shows them; an ask
|
|
32
|
+
* says why in a person's words and what to do instead. A phone's instead is its screen, named as the script's
|
|
33
|
+
* `computer` (script.ts bindComputer) and the run's tools name it: the run's bash tool does not run on a phone, so it
|
|
34
|
+
* is never offered there. */
|
|
35
|
+
refusal(op: string, args: unknown): Promise<string | undefined>;
|
|
36
|
+
/** `call` of the computer's port with a script's computer call held to the gate first: the refusal throws in the
|
|
37
|
+
* script, where its `await` is. */
|
|
38
|
+
call(op: string, args: unknown, send: (args: unknown) => Promise<{
|
|
39
|
+
value?: unknown;
|
|
40
|
+
}>): Promise<unknown>;
|
|
41
|
+
}
|
|
42
|
+
/** What a script that reaches for a shell is told when its agent's computer has exec off. */
|
|
43
|
+
export declare const NO_PROGRAMS_WORDS = "this agent's computer runs no programs: its exec setting is off, so its scripts have no computer.shell and no computer.processes. Drive it through what it shows: its screen, its input and its apps.";
|
|
44
|
+
/** The one line that binds `computer` in a script for a computer that is `card` (the surface's scriptPrelude). With
|
|
45
|
+
* `exec: false` (the agent's setting, run-tools.ts AgentComputer) the card has no exec or processes group, so
|
|
46
|
+
* `computer.shell` and `computer.processes` are absent, and reaching for either throws NO_PROGRAMS_WORDS instead of a
|
|
47
|
+
* bare TypeError: `computer` is the surface's own object behind a Proxy whose get refuses those two names. */
|
|
48
|
+
export declare function scriptPreludeOf(card: Card, options?: {
|
|
49
|
+
readonly exec?: false;
|
|
50
|
+
}): string;
|
|
51
|
+
/** computer_script's executor over the script `prelude` (scriptPreludeOf): each script in its own isolate, its
|
|
52
|
+
* computer calls through the call's hands, the shell's and the files' held to `guard`. */
|
|
53
|
+
export declare function computerScriptExecutor(prelude: string, guard: ScriptGuard): Executor;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// computer_script's run: the model's JavaScript in a QuickJS isolate here in serve (pi-codemode's CodemodeSandbox, a
|
|
2
|
+
// worker thread per script), whose only binding is the claim's computer. The script sees `computer` (the surface's
|
|
3
|
+
// script prelude builds it inside the isolate over one host function, __computerCall) and pi-codemode's output helpers
|
|
4
|
+
// (text, image, console); no network, no keys, no timers, no modules, no file of this machine. Each call of the computer
|
|
5
|
+
// goes through the run's hands (Hands.computer), so a person's hold parks and refuses it as it does a per-step tool's.
|
|
6
|
+
//
|
|
7
|
+
// The answer: the script's text and images in the order it made them, then its returned value as JSON (its images'
|
|
8
|
+
// data left out: they are the answer's images); `structured` is the value. A script that threw answers its words, with
|
|
9
|
+
// what it showed before.
|
|
10
|
+
import { CodemodeSandbox } from "@earendil-works/pi-codemode";
|
|
11
|
+
import { COMPUTER_CALL_GLOBAL, scriptPrelude, withoutImageData } from "@parcha/agentrun-computer/surface";
|
|
12
|
+
/** A script's longest run by default, and at most, in ms. */
|
|
13
|
+
export const SCRIPT_DEFAULT_MS = 120_000;
|
|
14
|
+
export const SCRIPT_MAX_MS = 600_000;
|
|
15
|
+
/** The isolate's memory. */
|
|
16
|
+
const SCRIPT_MEMORY_BYTES = 256 * 1024 * 1024;
|
|
17
|
+
/** The tool a script's computer call is held to, as the run's own tool of that name is: the shell is bash's, a program
|
|
18
|
+
* started to run on (processes.start) bash_background's (bash's setting, and a read-only bash policy refuses it), a
|
|
19
|
+
* file's write is write's, a file's read, listing or stat is read's. The other ops (looking, acting) are the computer
|
|
20
|
+
* kind's, which the call of computer_script or codemode was already held to. */
|
|
21
|
+
const HELD_AS = Object.freeze({ "shell.run": "bash", "processes.start": "bash_background", "files.write": "write", "files.read": "read", "files.list": "read", "files.stat": "read" });
|
|
22
|
+
/** The ops whose command runs in the computer's shell: each gets the bash policy's safeguards. */
|
|
23
|
+
const SHELL_OPS = new Set(["shell.run", "processes.start"]);
|
|
24
|
+
/** What each held op does, as a refusal says it could not. */
|
|
25
|
+
const DOES = Object.freeze({ "shell.run": "run a shell command", "processes.start": "start a program", "files.write": "write a file", "files.read": "read a file", "files.list": "list a folder", "files.stat": "look a file up" });
|
|
26
|
+
/** The setting a person sees for each held tool: bash_background is bash's. */
|
|
27
|
+
const SETTING = Object.freeze({ bash: "bash", bash_background: "bash", write: "write", read: "read" });
|
|
28
|
+
/** What waits for a person's OK under each setting, in a person's words. */
|
|
29
|
+
const WAITS = Object.freeze({ bash: "shell commands", write: "file writes", read: "file reads" });
|
|
30
|
+
/** What a script's `computer.shell` and `computer.files` are held to: the run's gate, which a person's settings (a denied
|
|
31
|
+
* bash, a read-only bash policy, a denied write) reach through the one decision the run's own tools get. A script can't
|
|
32
|
+
* stop to ask, so a call the gate would ask about is refused in words that send the model to the tool itself. Until a
|
|
33
|
+
* gate is installed (the spec installs it once built) every one of those calls is refused. */
|
|
34
|
+
export class ScriptGuard {
|
|
35
|
+
shell;
|
|
36
|
+
kind;
|
|
37
|
+
#decide;
|
|
38
|
+
/** `shell`: what the run's bash adds under its bash policy (bash-read-only.ts policyEnv, policyPrelude): the environment
|
|
39
|
+
* that locks git's config down, set over any a script gives, and the line that runs git only at the floor version.
|
|
40
|
+
* `kind`: the run's computer's kind, which a refusal names (the phone, the desktop). */
|
|
41
|
+
constructor(shell = { env: {}, prelude: "" }, kind) {
|
|
42
|
+
this.shell = shell;
|
|
43
|
+
this.kind = kind;
|
|
44
|
+
}
|
|
45
|
+
/** `op`'s arguments as the computer is sent them: a script's shell command with the policy's safeguards, as the bash
|
|
46
|
+
* tool's own command has them, which no option of the script's overrides. */
|
|
47
|
+
shaped(op, args) {
|
|
48
|
+
if (!SHELL_OPS.has(op))
|
|
49
|
+
return args;
|
|
50
|
+
const given = (args ?? {});
|
|
51
|
+
const env = { ...(given.env ?? {}), ...this.shell.env };
|
|
52
|
+
return { ...given, ...(Object.keys(env).length > 0 ? { env } : {}), ...(this.shell.prelude !== "" && typeof given.command === "string" ? { command: `${this.shell.prelude}${given.command}` } : {}) };
|
|
53
|
+
}
|
|
54
|
+
install(decide) {
|
|
55
|
+
this.#decide = decide;
|
|
56
|
+
}
|
|
57
|
+
/** Why `op` with `args` may not run now, or undefined when the gate lets it. The words start with what could not be
|
|
58
|
+
* done, on which computer ("could not run a shell command on the phone"), as the Timeline's row shows them; an ask
|
|
59
|
+
* says why in a person's words and what to do instead. A phone's instead is its screen, named as the script's
|
|
60
|
+
* `computer` (script.ts bindComputer) and the run's tools name it: the run's bash tool does not run on a phone, so it
|
|
61
|
+
* is never offered there. */
|
|
62
|
+
async refusal(op, args) {
|
|
63
|
+
const tool = HELD_AS[op];
|
|
64
|
+
if (tool === undefined)
|
|
65
|
+
return undefined;
|
|
66
|
+
const on = this.kind === "phone" ? "the phone" : this.kind === "desktop" ? "the desktop" : "the computer";
|
|
67
|
+
const couldNot = `could not ${DOES[op] ?? op} on ${on}`;
|
|
68
|
+
if (!this.#decide)
|
|
69
|
+
return `${couldNot}: this run's tool settings are not attached to its scripts yet`;
|
|
70
|
+
const given = (args ?? {});
|
|
71
|
+
const decision = await this.#decide(tool, SHELL_OPS.has(op) ? { command: given.command, ...(given.cwd !== undefined ? { cwd: given.cwd } : {}) } : { path: given.path });
|
|
72
|
+
if (decision === "allow")
|
|
73
|
+
return undefined;
|
|
74
|
+
if (decision !== "ask")
|
|
75
|
+
return `${couldNot}: ${decision.deny}`;
|
|
76
|
+
const setting = SETTING[tool] ?? tool;
|
|
77
|
+
const why = `this agent's ${WAITS[setting] ?? `${setting} calls`} wait for a person's OK (its ${setting} setting is ask), and a script can't stop to ask.`;
|
|
78
|
+
const instead = this.kind === "phone"
|
|
79
|
+
? `Do it on the phone's screen instead: in a script, computer.app(id).observe() reads it and its press, type and click act on it (or call the computer_observe and computer_act tools), or ask the agent's owner to set ${setting} to allow.`
|
|
80
|
+
: `Call the ${tool} tool itself, which can ask, or ask the agent's owner to set ${setting} to allow.`;
|
|
81
|
+
return `${couldNot}: ${why} ${instead}`;
|
|
82
|
+
}
|
|
83
|
+
/** `call` of the computer's port with a script's computer call held to the gate first: the refusal throws in the
|
|
84
|
+
* script, where its `await` is. */
|
|
85
|
+
async call(op, args, send) {
|
|
86
|
+
const refused = await this.refusal(op, args);
|
|
87
|
+
if (refused !== undefined)
|
|
88
|
+
throw new Error(refused);
|
|
89
|
+
return (await send(this.shaped(op, args ?? {}))).value ?? null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** Every image in `value` (`{ type: "image", data }`), in the order withImageData puts data back into them. */
|
|
93
|
+
function imagesIn(value) {
|
|
94
|
+
if (Array.isArray(value))
|
|
95
|
+
return value.flatMap(imagesIn);
|
|
96
|
+
if (value === null || typeof value !== "object")
|
|
97
|
+
return [];
|
|
98
|
+
const record = value;
|
|
99
|
+
if (record.type === "image" && typeof record.data === "string")
|
|
100
|
+
return [{ data: record.data, mimeType: typeof record.mimeType === "string" ? record.mimeType : "image/png" }];
|
|
101
|
+
return Object.values(record).flatMap(imagesIn);
|
|
102
|
+
}
|
|
103
|
+
/** The script's own output and its value, as the model reads them. The images come as the structured value wants them
|
|
104
|
+
* back (withImageData fills its data-less image objects in order): the returned value's own first, then the ones the
|
|
105
|
+
* script showed with image(...), so a returned image keeps its own pixels whatever was shown. */
|
|
106
|
+
function answerOf(output, value) {
|
|
107
|
+
const words = [];
|
|
108
|
+
const shown = [];
|
|
109
|
+
for (const item of output) {
|
|
110
|
+
if (item.type === "text")
|
|
111
|
+
words.push(item.text);
|
|
112
|
+
else
|
|
113
|
+
shown.push({ data: item.data, mimeType: item.mimeType });
|
|
114
|
+
}
|
|
115
|
+
if (value !== undefined)
|
|
116
|
+
words.push(typeof value === "string" ? value : JSON.stringify(withoutImageData(value)));
|
|
117
|
+
return { text: words.join("\n") || "(the script returned nothing and showed nothing)", images: [...imagesIn(value), ...shown] };
|
|
118
|
+
}
|
|
119
|
+
/** What a script that reaches for a shell is told when its agent's computer has exec off. */
|
|
120
|
+
export const NO_PROGRAMS_WORDS = "this agent's computer runs no programs: its exec setting is off, so its scripts have no computer.shell and no computer.processes. Drive it through what it shows: its screen, its input and its apps.";
|
|
121
|
+
/** The one line that binds `computer` in a script for a computer that is `card` (the surface's scriptPrelude). With
|
|
122
|
+
* `exec: false` (the agent's setting, run-tools.ts AgentComputer) the card has no exec or processes group, so
|
|
123
|
+
* `computer.shell` and `computer.processes` are absent, and reaching for either throws NO_PROGRAMS_WORDS instead of a
|
|
124
|
+
* bare TypeError: `computer` is the surface's own object behind a Proxy whose get refuses those two names. */
|
|
125
|
+
export function scriptPreludeOf(card, options = {}) {
|
|
126
|
+
const prelude = scriptPrelude(card);
|
|
127
|
+
if (options.exec !== false)
|
|
128
|
+
return prelude;
|
|
129
|
+
return `const computer = ((bound) => new Proxy(bound, { get(target, key, receiver) { if (key === "shell" || key === "processes") throw new Error(${JSON.stringify(NO_PROGRAMS_WORDS)}); return Reflect.get(target, key, receiver); } }))((() => { ${prelude} return computer; })());`;
|
|
130
|
+
}
|
|
131
|
+
/** computer_script's executor over the script `prelude` (scriptPreludeOf): each script in its own isolate, its
|
|
132
|
+
* computer calls through the call's hands, the shell's and the files' held to `guard`. */
|
|
133
|
+
export function computerScriptExecutor(prelude, guard) {
|
|
134
|
+
return async (args, call) => {
|
|
135
|
+
const { code, timeoutMs } = (args ?? {});
|
|
136
|
+
if (typeof code !== "string" || code.trim() === "")
|
|
137
|
+
return { text: "", error: "computer_script needs code: the body of an async function, with `computer` bound" };
|
|
138
|
+
const port = call.hands.computer;
|
|
139
|
+
if (!port)
|
|
140
|
+
return { text: "", error: "computer_script needs a desktop or a phone computer: this run has none" };
|
|
141
|
+
const limit = typeof timeoutMs === "number" && Number.isFinite(timeoutMs) && timeoutMs > 0 ? Math.min(timeoutMs, SCRIPT_MAX_MS) : SCRIPT_DEFAULT_MS;
|
|
142
|
+
const sandbox = new CodemodeSandbox({
|
|
143
|
+
timeoutMs: limit,
|
|
144
|
+
memoryLimitBytes: SCRIPT_MEMORY_BYTES,
|
|
145
|
+
globals: [{
|
|
146
|
+
name: COMPUTER_CALL_GLOBAL,
|
|
147
|
+
spread: true,
|
|
148
|
+
// The value whole, images and all: a script shows one with image(...). The JSON round trip is the isolate's.
|
|
149
|
+
execute: async (given, context) => {
|
|
150
|
+
const [op, opArgs] = given;
|
|
151
|
+
return (await guard.call(String(op), opArgs, (sent) => port.call(String(op), sent ?? {}, AbortSignal.any([context.signal, ...(call.signal ? [call.signal] : [])]))));
|
|
152
|
+
},
|
|
153
|
+
}],
|
|
154
|
+
});
|
|
155
|
+
try {
|
|
156
|
+
// The prelude is one line, so the script's own line numbers hold.
|
|
157
|
+
const result = await sandbox.execute(`${prelude}\n${code}`, call.signal ? { signal: call.signal } : {});
|
|
158
|
+
if (!result.ok) {
|
|
159
|
+
if (result.error.kind === "aborted" && call.signal?.aborted)
|
|
160
|
+
throw call.signal.reason ?? new Error(result.error.message);
|
|
161
|
+
const shown = answerOf(result.output, undefined);
|
|
162
|
+
const why = result.error.kind === "timeout" ? `the script ran past its ${limit} ms: ${result.error.message}` : result.error.message;
|
|
163
|
+
return { text: result.output.length > 0 ? shown.text : "", error: why, ...(shown.images.length > 0 ? { images: shown.images } : {}) };
|
|
164
|
+
}
|
|
165
|
+
const shown = answerOf(result.output, result.value);
|
|
166
|
+
return { text: shown.text, ...(shown.images.length > 0 ? { images: shown.images } : {}), ...(result.value === undefined ? {} : { structured: withoutImageData(result.value) }) };
|
|
167
|
+
}
|
|
168
|
+
finally {
|
|
169
|
+
await sandbox.close();
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import type { ToolRegistration } from "@earendil-works/pi-durable";
|
|
3
3
|
import type { ExecutionEnv } from "@earendil-works/pi-durable/env";
|
|
4
4
|
import type { ToolAnswer, ToolCall } from "@parcha/agentrun-kernel/kernel";
|
|
@@ -13,8 +13,10 @@ export { readOnlyWorkspace, SERVER_READS_ONLY, serverRunWorkspace, type ServerRu
|
|
|
13
13
|
export { type LedgerEntry, type ProviderLedger, storeLedger } from "./computer-ledger.js";
|
|
14
14
|
export { type LearningPlace, type LearningWorkspace, learningWorkspace, type LearningWorkspaceOptions } from "./learning-workspace.js";
|
|
15
15
|
export { ARCHIL_MAX_EXEC_S, handsOf, MAX_EXEC_S, processesOf, shellEnv } from "./hands.js";
|
|
16
|
-
export { type RunComputer, type RunHold, runTools, type RunTools, withKindTools } from "./run-tools.js";
|
|
17
|
-
export {
|
|
16
|
+
export { type AgentComputer, type RunComputer, type RunHold, runTools, type RunTools, type ScriptComputer, withKindTools } from "./run-tools.js";
|
|
17
|
+
export { portOf } from "./computer-ports.js";
|
|
18
|
+
export { computerScriptExecutor, NO_PROGRAMS_WORDS, SCRIPT_DEFAULT_MS, SCRIPT_MAX_MS, ScriptGuard, type ScriptDecide, scriptPreludeOf } from "./computer-script.js";
|
|
19
|
+
export { COMPUTER_MCP_NAME, computerMcp, type ComputerMcpAnswer, mcpAnswerOf } from "./computer-mcp.js";
|
|
18
20
|
export { type ClaimSide, computerReadiness, type ComputerSetting, type KindRegistry, type LaunchedComputer, type Port, resolveComputer, type ResolvedComputer, runShellOf, type ShellPlace, shellPlaceOf, type StartedComputer, } from "./resolve-computer.js";
|
|
19
21
|
export { computerProviderFactories, computerProviderMakers, type ProviderLoad } from "./computer-providers.js";
|
|
20
22
|
export { claimComputer, claimKinds, type ComputerDeps, computerDepsFrom, type ComputerDepsOptions, computerSpecOf, DAEMON_CACHE_IN_VOLUME, DOCKER_HOST_ADDRESSES_ENV, type DockerComputerOptions, dockerHostAddressesOf, dockerVolumeOf, } from "./computer-deps.js";
|
package/dist/workspace/index.js
CHANGED
|
@@ -15,7 +15,9 @@ export { storeLedger } from "./computer-ledger.js";
|
|
|
15
15
|
export { learningWorkspace } from "./learning-workspace.js";
|
|
16
16
|
export { ARCHIL_MAX_EXEC_S, handsOf, MAX_EXEC_S, processesOf, shellEnv } from "./hands.js";
|
|
17
17
|
export { runTools, withKindTools } from "./run-tools.js";
|
|
18
|
-
export {
|
|
18
|
+
export { portOf } from "./computer-ports.js";
|
|
19
|
+
export { computerScriptExecutor, NO_PROGRAMS_WORDS, SCRIPT_DEFAULT_MS, SCRIPT_MAX_MS, ScriptGuard, scriptPreludeOf } from "./computer-script.js";
|
|
20
|
+
export { COMPUTER_MCP_NAME, computerMcp, mcpAnswerOf } from "./computer-mcp.js";
|
|
19
21
|
export { computerReadiness, resolveComputer, runShellOf, shellPlaceOf, } from "./resolve-computer.js";
|
|
20
22
|
export { computerProviderFactories, computerProviderMakers } from "./computer-providers.js";
|
|
21
23
|
export { claimComputer, claimKinds, computerDepsFrom, computerSpecOf, DAEMON_CACHE_IN_VOLUME, DOCKER_HOST_ADDRESSES_ENV, dockerHostAddressesOf, dockerVolumeOf, } from "./computer-deps.js";
|