@parcha/agentrun-serve 0.1.0-beta.35 → 0.1.0-beta.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +298 -0
- package/README.md +417 -219
- package/dist/adapters.d.ts +12 -2
- package/dist/adapters.js +27 -2
- package/dist/agent-rows.d.ts +2 -1
- package/dist/agents-store.d.ts +2 -0
- package/dist/agents-store.js +9 -4
- package/dist/api-only.d.ts +2 -1
- package/dist/api-only.js +3 -1
- package/dist/archil-routes.d.ts +40 -7
- package/dist/archil-routes.js +167 -54
- package/dist/archil-settings.d.ts +79 -7
- package/dist/archil-settings.js +140 -14
- package/dist/attach-conformance-cli.d.ts +1 -0
- package/dist/attach-conformance-cli.js +18 -0
- package/dist/attach-conformance.d.ts +25 -0
- package/dist/attach-conformance.js +343 -0
- package/dist/attach-images.d.ts +15 -0
- package/dist/attach-images.js +59 -0
- package/dist/background.d.ts +0 -6
- package/dist/background.js +0 -28
- package/dist/box-image.d.ts +1 -97
- package/dist/box-image.js +4 -284
- package/dist/box-paths.d.ts +2 -7
- package/dist/box-paths.js +7 -13
- package/dist/box-settings.d.ts +0 -11
- package/dist/box-settings.js +4 -29
- package/dist/browser-commands.js +1 -1
- package/dist/browser-computer.d.ts +47 -3
- package/dist/browser-computer.js +286 -18
- package/dist/browser-cost.d.ts +1 -1
- package/dist/browser-live.d.ts +20 -8
- package/dist/browser-live.js +50 -27
- package/dist/browser-person.d.ts +19 -2
- package/dist/browser-person.js +55 -6
- package/dist/browser-wait-ended.d.ts +23 -0
- package/dist/browser-wait-ended.js +42 -0
- package/dist/cap.d.ts +12 -57
- package/dist/cap.js +20 -160
- package/dist/catalog.d.ts +1 -12
- package/dist/catalog.js +3 -33
- package/dist/cli.js +17 -26
- package/dist/composio-preset.d.ts +36 -0
- package/dist/composio-preset.js +179 -0
- package/dist/computer-attach.d.ts +125 -0
- package/dist/computer-attach.js +330 -0
- package/dist/computer-calls.d.ts +48 -0
- package/dist/computer-calls.js +126 -0
- package/dist/computer-channel.d.ts +57 -0
- package/dist/computer-channel.js +115 -0
- package/dist/computer-commands.d.ts +1 -1
- package/dist/computer-held-routes.d.ts +35 -0
- package/dist/computer-held-routes.js +106 -0
- package/dist/computer-held.d.ts +48 -0
- package/dist/computer-held.js +87 -0
- package/dist/computer-keys.d.ts +21 -1
- package/dist/computer-keys.js +53 -11
- package/dist/computer-live.d.ts +160 -0
- package/dist/computer-live.js +643 -0
- package/dist/computer-routes.d.ts +1 -4
- package/dist/computer-routes.js +3 -5
- package/dist/computer-setting.d.ts +2 -0
- package/dist/computer-setting.js +38 -1
- package/dist/computer-view.d.ts +24 -2
- package/dist/computer-view.js +51 -3
- package/dist/computer-viewer.d.ts +6 -0
- package/dist/computer-viewer.js +297 -0
- package/dist/computers.d.ts +79 -12
- package/dist/computers.js +147 -28
- package/dist/console/assets/index-Cn6JX1uH.js +563 -0
- package/dist/console/assets/index-DRN62V5v.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/docker-daemon.d.ts +2 -2
- package/dist/docker-daemon.js +2 -2
- package/dist/errors.js +5 -5
- package/dist/faux-computers.d.ts +9 -20
- package/dist/faux-computers.js +56 -24
- package/dist/files.d.ts +1 -9
- package/dist/files.js +1 -9
- package/dist/github-connection.d.ts +10 -2
- package/dist/github-connection.js +65 -2
- package/dist/github-faux.js +1 -1
- package/dist/github.d.ts +22 -2
- package/dist/github.js +42 -8
- package/dist/gpu-words.d.ts +14 -0
- package/dist/gpu-words.js +21 -0
- package/dist/graph-view.d.ts +3 -1
- package/dist/graph-view.js +25 -1
- package/dist/handed-values.d.ts +1 -1
- package/dist/handed-values.js +1 -1
- package/dist/harness-install.d.ts +60 -3
- package/dist/harness-install.js +322 -34
- package/dist/harness.d.ts +1 -0
- package/dist/harness.js +36 -2
- package/dist/host-tools.d.ts +9 -10
- package/dist/host-tools.js +7 -7
- package/dist/hosted-search.d.ts +5 -4
- package/dist/hosted-search.js +2 -7
- package/dist/import-sources.d.ts +10 -0
- package/dist/import-sources.js +44 -2
- package/dist/import.d.ts +3 -3
- package/dist/import.js +37 -6
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -2
- package/dist/key-refusal.d.ts +1 -1
- package/dist/key-refusal.js +2 -2
- package/dist/learn/check.d.ts +11 -2
- package/dist/learn/check.js +124 -6
- package/dist/learn/commit.d.ts +43 -7
- package/dist/learn/commit.js +166 -22
- package/dist/learn/folder.d.ts +11 -0
- package/dist/learn/folder.js +37 -1
- package/dist/learn/general.d.ts +66 -0
- package/dist/learn/general.js +73 -0
- package/dist/learn/grade.d.ts +22 -1
- package/dist/learn/grade.js +107 -16
- package/dist/learn/index.d.ts +1 -1
- package/dist/learn/index.js +1 -1
- package/dist/learn/learning.sh +12 -1
- package/dist/learn/notes.d.ts +3 -0
- package/dist/learn/notes.js +3 -0
- package/dist/learn/reflect.d.ts +14 -2
- package/dist/learn/reflect.js +54 -30
- package/dist/learn/skills.d.ts +37 -5
- package/dist/learn/skills.js +60 -7
- package/dist/learned-nodes.d.ts +6 -2
- package/dist/learned-workflow.d.ts +43 -9
- package/dist/learned-workflow.js +128 -37
- package/dist/learning-batch.d.ts +283 -0
- package/dist/learning-batch.js +574 -0
- package/dist/learning-cost.d.ts +79 -0
- package/dist/learning-cost.js +69 -0
- package/dist/learning-evals.d.ts +33 -0
- package/dist/learning-evals.js +98 -0
- package/dist/learning-routes.d.ts +32 -4
- package/dist/learning-routes.js +48 -12
- package/dist/learning-words.d.ts +9 -0
- package/dist/learning-words.js +12 -2
- package/dist/learning.d.ts +39 -19
- package/dist/learning.js +88 -46
- package/dist/live/stream.js +6 -3
- package/dist/live/translate.d.ts +4 -3
- package/dist/live/translate.js +8 -4
- package/dist/live-reach.d.ts +37 -0
- package/dist/live-reach.js +62 -0
- package/dist/mcp-gateway.d.ts +9 -0
- package/dist/mcp-gateway.js +60 -11
- package/dist/mcp-oauth.d.ts +57 -7
- package/dist/mcp-oauth.js +133 -18
- package/dist/mcp-private-hosts.d.ts +4 -4
- package/dist/mcp-private-hosts.js +20 -12
- package/dist/mcp-probe.d.ts +27 -3
- package/dist/mcp-probe.js +106 -29
- package/dist/mcp-secret-writes.js +8 -0
- package/dist/mcp-servers-store.d.ts +38 -15
- package/dist/mcp-servers-store.js +120 -23
- package/dist/mcp-store.d.ts +10 -4
- package/dist/mcp-store.js +17 -6
- package/dist/model-form.d.ts +26 -0
- package/dist/model-form.js +80 -0
- package/dist/model.d.ts +5 -5
- package/dist/model.js +29 -16
- package/dist/openapi.d.ts +2 -0
- package/dist/openapi.js +586 -64
- package/dist/owner.d.ts +0 -1
- package/dist/owner.js +0 -2
- package/dist/page.d.ts +18 -0
- package/dist/page.js +48 -20
- package/dist/paid-calls.d.ts +1 -1
- package/dist/paid-calls.js +1 -1
- package/dist/place-offers.d.ts +96 -0
- package/dist/place-offers.js +202 -0
- package/dist/place.d.ts +9 -13
- package/dist/place.js +21 -32
- package/dist/port-models.d.ts +2 -1
- package/dist/port-models.js +5 -3
- package/dist/print.d.ts +16 -9
- package/dist/print.js +15 -17
- package/dist/propose.d.ts +4 -0
- package/dist/propose.js +34 -11
- package/dist/provider.js +3 -2
- package/dist/reflect-range.d.ts +8 -1
- package/dist/reflect-range.js +1 -1
- package/dist/run-cut.d.ts +5 -0
- package/dist/run-cut.js +19 -0
- package/dist/run-launch.d.ts +28 -3
- package/dist/run-launch.js +14 -4
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-manifest.d.ts +2 -2
- package/dist/run-manifest.js +2 -2
- package/dist/run-reads-over-store.d.ts +1 -1
- package/dist/run-repo.d.ts +20 -0
- package/dist/run-repo.js +63 -0
- package/dist/run-secrets.js +3 -3
- package/dist/run-timeline-served.d.ts +1 -1
- package/dist/run-timeline-served.js +56 -44
- package/dist/run-view.d.ts +8 -5
- package/dist/run-view.js +18 -10
- package/dist/runnable.d.ts +2 -2
- package/dist/runnable.js +6 -2
- package/dist/runner/adapter-loop.d.ts +39 -8
- package/dist/runner/adapter-loop.js +770 -83
- package/dist/runner/adapter-run-spec.d.ts +36 -7
- package/dist/runner/adapter-run-spec.js +171 -37
- package/dist/runner/adapters/pi-computer.d.ts +7 -0
- package/dist/runner/adapters/pi-computer.js +43 -0
- package/dist/runner/adapters/pi.d.ts +20 -7
- package/dist/runner/adapters/pi.js +111 -26
- package/dist/runner/beside.d.ts +7 -3
- package/dist/runner/beside.js +26 -12
- package/dist/runner/claim-secrets.d.ts +4 -0
- package/dist/runner/claim-secrets.js +6 -1
- package/dist/runner/cli-run-spec.d.ts +27 -3
- package/dist/runner/cli-run-spec.js +198 -74
- package/dist/runner/commands.d.ts +8 -2
- package/dist/runner/commands.js +31 -6
- package/dist/runner/computer-channel.d.ts +34 -0
- package/dist/runner/computer-channel.js +61 -0
- package/dist/runner/conformance/harness.d.ts +0 -1
- package/dist/runner/conformance/harness.js +87 -18
- package/dist/runner/conformance/subject.d.ts +1 -1
- package/dist/runner/dispatch.js +3 -0
- package/dist/runner/end-of-run.d.ts +22 -12
- package/dist/runner/end-of-run.js +38 -16
- package/dist/runner/github-app.d.ts +2 -1
- package/dist/runner/github-app.js +6 -4
- package/dist/runner/harness-loops.js +16 -2
- package/dist/runner/held-run.d.ts +65 -0
- package/dist/runner/held-run.js +158 -0
- package/dist/runner/journal-kinds.d.ts +35 -6
- package/dist/runner/journal-kinds.js +20 -1
- package/dist/runner/journal-reader.d.ts +5 -4
- package/dist/runner/journal-reader.js +12 -10
- package/dist/runner/learning-ask.d.ts +7 -1
- package/dist/runner/learning-ask.js +21 -6
- package/dist/runner/learning-dispatch.d.ts +22 -0
- package/dist/runner/learning-dispatch.js +77 -10
- package/dist/runner/learning-end.d.ts +37 -1
- package/dist/runner/learning-end.js +115 -14
- package/dist/runner/learning-factory.d.ts +1 -1
- package/dist/runner/learning-factory.js +15 -5
- package/dist/runner/learning-loop.d.ts +139 -7
- package/dist/runner/learning-loop.js +369 -32
- package/dist/runner/learning-seed.d.ts +9 -0
- package/dist/runner/learning-seed.js +14 -1
- package/dist/runner/live-ticker.js +1 -0
- package/dist/runner/loop-contract.d.ts +16 -1
- package/dist/runner/loop-contract.js +6 -0
- package/dist/runner/loop.d.ts +10 -2
- package/dist/runner/loop.js +22 -1
- package/dist/runner/main.d.ts +13 -1
- package/dist/runner/main.js +38 -6
- package/dist/runner/mcp-claim.d.ts +11 -4
- package/dist/runner/mcp-claim.js +140 -23
- package/dist/runner/mcp-github.d.ts +4 -2
- package/dist/runner/mcp-github.js +1 -8
- package/dist/runner/mcp-run.d.ts +6 -4
- package/dist/runner/mcp-run.js +16 -3
- package/dist/runner/metrics.d.ts +15 -2
- package/dist/runner/metrics.js +21 -2
- package/dist/runner/model-route.d.ts +3 -0
- package/dist/runner/model-route.js +5 -2
- package/dist/runner/pr-checkout.d.ts +60 -0
- package/dist/runner/pr-checkout.js +176 -0
- package/dist/runner/reflect-hook.d.ts +19 -0
- package/dist/runner/reflect-hook.js +20 -8
- package/dist/runner/runner.d.ts +26 -0
- package/dist/runner/runner.js +231 -27
- package/dist/runner/scratch-sweep.d.ts +13 -0
- package/dist/runner/scratch-sweep.js +62 -0
- package/dist/runner/sessions.d.ts +1 -1
- package/dist/runner/spec-holds.d.ts +8 -3
- package/dist/runner/spec-holds.js +12 -10
- package/dist/runner/store-port.d.ts +7 -2
- package/dist/runner/store-secrets.js +21 -4
- package/dist/runner/subagent.d.ts +44 -0
- package/dist/runner/subagent.js +190 -0
- package/dist/runner/workflow-host.d.ts +24 -3
- package/dist/runner/workflow-host.js +24 -4
- package/dist/runner/workflow-loop.d.ts +6 -3
- package/dist/runner/workflow-loop.js +9 -8
- package/dist/runner/workflow-spec.d.ts +39 -15
- package/dist/runner/workflow-spec.js +143 -40
- package/dist/runs-over-store.d.ts +16 -6
- package/dist/runs-over-store.js +145 -29
- package/dist/seal-key.js +3 -3
- package/dist/sealed-settings-store.d.ts +5 -2
- package/dist/sealed-settings-store.js +10 -4
- package/dist/sealing.js +1 -2
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/secret-writes.d.ts +5 -4
- package/dist/secret-writes.js +5 -4
- package/dist/server-secrets-store.d.ts +4 -3
- package/dist/server-secrets-store.js +15 -9
- package/dist/server-secrets.js +3 -2
- package/dist/server.d.ts +75 -63
- package/dist/server.js +712 -316
- package/dist/settings-wake.d.ts +21 -0
- package/dist/settings-wake.js +59 -0
- package/dist/standard-webhooks.d.ts +4 -1
- package/dist/standard-webhooks.js +8 -4
- package/dist/store/agent-body.d.ts +9 -2
- package/dist/store/agent-body.js +16 -8
- package/dist/store/command-wake.d.ts +12 -0
- package/dist/store/command-wake.js +37 -0
- package/dist/store/deadline.js +9 -5
- package/dist/store/dialect.d.ts +6 -0
- package/dist/store/dialect.js +5 -0
- package/dist/store/index.d.ts +4 -4
- package/dist/store/index.js +2 -2
- package/dist/store/journal/storage.d.ts +3 -2
- package/dist/store/journal/storage.js +15 -6
- package/dist/store/postgres/connection.js +9 -4
- package/dist/store/postgres/dialect.js +4 -0
- package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
- package/dist/store/postgres/migrations/0005_learning_rounds.sql +14 -0
- package/dist/store/postgres/migrations/0006_run_changes_channel_attempts.sql +57 -0
- package/dist/store/postgres/migrations/0007_viewer_host.sql +11 -0
- package/dist/store/postgres/migrations/0008_paired_computers.sql +30 -0
- package/dist/store/postgres/migrations/0009_commands_answer.sql +10 -0
- package/dist/store/schema.d.ts +2 -1
- package/dist/store/schema.js +85 -13
- package/dist/store/seal.d.ts +13 -0
- package/dist/store/seal.js +19 -0
- package/dist/store/sqlite/connection.d.ts +5 -0
- package/dist/store/sqlite/connection.js +88 -47
- package/dist/store/sqlite/run-patch.d.ts +25 -7
- package/dist/store/sqlite/run-patch.js +58 -14
- package/dist/store/sqlite/store.js +331 -59
- package/dist/store/store.d.ts +330 -21
- package/dist/store/store.js +34 -2
- package/dist/store-reads/analytics.js +3 -2
- package/dist/store-reads/cap.d.ts +2 -4
- package/dist/store-reads/cap.js +16 -7
- package/dist/store-reads/decisions.d.ts +3 -3
- package/dist/store-reads/decisions.js +3 -6
- package/dist/store-reads/import-summary.d.ts +1 -1
- package/dist/store-reads/journal.d.ts +5 -4
- package/dist/store-reads/journal.js +118 -27
- package/dist/store-reads/learning.d.ts +34 -4
- package/dist/store-reads/learning.js +137 -23
- package/dist/store-reads/runs.d.ts +7 -5
- package/dist/store-reads/runs.js +17 -10
- package/dist/store-reads/stats.js +5 -1
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-view.d.ts +5 -0
- package/dist/store-view.js +70 -29
- package/dist/template-eval.js +8 -5
- package/dist/template-github-permissions.d.ts +22 -8
- package/dist/template-github-permissions.js +35 -15
- package/dist/templates.d.ts +64 -0
- package/dist/templates.js +101 -16
- package/dist/timeline/timeline.d.ts +30 -1
- package/dist/timeline/timeline.js +29 -13
- package/dist/timeline/util.d.ts +4 -0
- package/dist/timeline/util.js +14 -0
- package/dist/tool-blurbs.js +1 -0
- package/dist/tool-budget.d.ts +27 -7
- package/dist/tool-budget.js +21 -9
- package/dist/tool-gate.d.ts +23 -10
- package/dist/tool-gate.js +60 -44
- package/dist/tool-plane.d.ts +46 -28
- package/dist/tool-plane.js +73 -31
- package/dist/tools.d.ts +31 -38
- package/dist/tools.js +117 -74
- package/dist/trigger-adapter.d.ts +4 -0
- package/dist/trigger-secrets-shown.d.ts +2 -2
- package/dist/trigger-secrets-shown.js +1 -1
- package/dist/trigger-signatures.d.ts +26 -6
- package/dist/trigger-signatures.js +44 -8
- package/dist/trigger-targets.d.ts +2 -0
- package/dist/trigger-targets.js +1 -0
- package/dist/trigger-webhook.js +5 -2
- package/dist/triggers.d.ts +10 -6
- package/dist/triggers.js +37 -7
- package/dist/turn-end.d.ts +0 -3
- package/dist/turn-end.js +0 -3
- package/dist/turns.js +16 -1
- package/dist/usage-lines.d.ts +1 -1
- package/dist/validate.d.ts +6 -0
- package/dist/validate.js +41 -4
- package/dist/web-fetch.d.ts +1 -1
- package/dist/web-search.d.ts +10 -5
- package/dist/web-search.js +7 -6
- package/dist/webhooks.d.ts +147 -103
- package/dist/webhooks.js +564 -324
- package/dist/workflow/decision-recovery.d.ts +23 -0
- package/dist/workflow/decision-recovery.js +80 -0
- package/dist/workflow/decisions.d.ts +134 -0
- package/dist/workflow/decisions.js +46 -0
- package/dist/workflow/host-session.d.ts +5 -0
- package/dist/workflow/host-session.js +85 -0
- package/dist/workflow/host-tools.d.ts +3 -0
- package/dist/workflow/host-tools.js +3 -0
- package/dist/workflow/node-runner.d.ts +113 -0
- package/dist/workflow/node-runner.js +270 -0
- package/dist/workflow/node.d.ts +89 -0
- package/dist/workflow/node.js +101 -0
- package/dist/workflow/operator-error.d.ts +4 -0
- package/dist/workflow/operator-error.js +4 -0
- package/dist/workflow/pi-versions.d.ts +32 -0
- package/dist/workflow/pi-versions.js +65 -0
- package/dist/workflow/record-file.d.ts +10 -0
- package/dist/workflow/record-file.js +56 -0
- package/dist/workflow/record-tool.d.ts +77 -0
- package/dist/workflow/record-tool.js +126 -0
- package/dist/workflow/record.d.ts +151 -0
- package/dist/workflow/record.js +401 -0
- package/dist/workflow/run-error.d.ts +16 -0
- package/dist/workflow/run-error.js +26 -0
- package/dist/workflow/runner.d.ts +6 -0
- package/dist/workflow/runner.js +240 -0
- package/dist/workflow/store.d.ts +23 -0
- package/dist/workflow/store.js +242 -0
- package/dist/workflow/task.d.ts +133 -0
- package/dist/workflow/task.js +412 -0
- package/dist/workflow/thinking.d.ts +3 -0
- package/dist/workflow/thinking.js +7 -0
- package/dist/workflow/tool-context.d.ts +21 -0
- package/dist/workflow/tool-context.js +13 -0
- package/dist/workflow/types.d.ts +126 -0
- package/dist/workflow/types.js +1 -0
- package/dist/workflow-run.d.ts +2 -2
- package/dist/workspace/agent-computer.d.ts +137 -0
- package/dist/workspace/agent-computer.js +292 -0
- package/dist/workspace/archil-claim.d.ts +11 -0
- package/dist/workspace/archil-claim.js +18 -10
- package/dist/workspace/archil-disks.d.ts +49 -0
- package/dist/workspace/archil-disks.js +185 -0
- package/dist/workspace/archil-exec.js +2 -3
- package/dist/workspace/archil-mount-credential.d.ts +20 -4
- package/dist/workspace/archil-mount-credential.js +13 -4
- package/dist/workspace/attached-computers.d.ts +41 -0
- package/dist/workspace/attached-computers.js +114 -0
- package/dist/workspace/computer-deps.d.ts +32 -17
- package/dist/workspace/computer-deps.js +37 -14
- package/dist/workspace/computer-for-claim.d.ts +58 -13
- package/dist/workspace/computer-for-claim.js +267 -26
- package/dist/workspace/computer-hold.d.ts +11 -27
- package/dist/workspace/computer-hold.js +36 -56
- package/dist/workspace/computer-janitor.d.ts +3 -2
- package/dist/workspace/computer-janitor.js +43 -9
- package/dist/workspace/computer-ledger.d.ts +5 -1
- package/dist/workspace/computer-ledger.js +11 -0
- package/dist/workspace/computer-mcp.d.ts +25 -0
- package/dist/workspace/computer-mcp.js +41 -0
- package/dist/workspace/computer-ports.d.ts +4 -13
- package/dist/workspace/computer-ports.js +4 -107
- package/dist/workspace/computer-script.d.ts +37 -0
- package/dist/workspace/computer-script.js +138 -0
- package/dist/workspace/executors.d.ts +1 -1
- package/dist/workspace/index.d.ts +7 -4
- package/dist/workspace/index.js +4 -1
- package/dist/workspace/kind-skills/desktop/SKILL.md +119 -84
- package/dist/workspace/kind-skills/phone/SKILL.md +100 -85
- package/dist/workspace/resolve-computer.d.ts +45 -11
- package/dist/workspace/resolve-computer.js +72 -14
- package/dist/workspace/run-disk.d.ts +34 -0
- package/dist/workspace/run-disk.js +91 -0
- package/dist/workspace/run-tools.d.ts +35 -18
- package/dist/workspace/run-tools.js +24 -29
- package/dist/workspace/server-run-workspace.d.ts +3 -2
- package/dist/workspace/server-run-workspace.js +17 -4
- package/dist/workspace.js +1 -1
- package/package.json +19 -21
- package/templates/README.md +9 -6
- package/templates/code-review/agent.md +27 -11
- package/templates/code-review/evals/clean-refactor/graders/coverage.md +4 -0
- package/templates/code-review/evals/clean-refactor/graders/risk.md +5 -0
- package/templates/code-review/evals/injection/graders/ignores.md +1 -1
- package/templates/code-review/evals/never-flag/case.yaml +3 -0
- package/templates/code-review/evals/never-flag/graders/only-p0.md +4 -0
- package/templates/code-review/evals/never-flag/graders/schema.md +5 -0
- package/templates/code-review/evals/never-flag/prompt.md +30 -0
- package/templates/code-review/evals/null-name/graders/finds.md +1 -1
- package/templates/code-review/evals/off-by-one/graders/finds.md +1 -1
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +6 -5
- package/templates/code-review/evals/re-review/graders/resolves.md +1 -1
- package/templates/code-review/evals/re-review/prompt.md +1 -1
- package/templates/code-review/evals/re-review-open/case.yaml +3 -0
- package/templates/code-review/evals/re-review-open/graders/schema.md +5 -0
- package/templates/code-review/evals/re-review-open/graders/stays-open.md +4 -0
- package/templates/code-review/evals/re-review-open/prompt.md +27 -0
- package/templates/code-review/evals/repo-rule/graders/cites.md +1 -1
- package/templates/code-review/evals/two-defects/case.yaml +3 -0
- package/templates/code-review/evals/two-defects/graders/both.md +4 -0
- package/templates/code-review/evals/two-defects/graders/schema.md +5 -0
- package/templates/code-review/evals/two-defects/prompt.md +25 -0
- package/templates/code-review/findings.schema.json +131 -27
- package/templates/code-review/rules/CODEREVIEW.md +76 -0
- package/templates/code-review/skills/review/DEEP.md +130 -0
- package/templates/code-review/skills/review/REVIEWER.md +116 -0
- package/templates/code-review/skills/review/SKILL.md +104 -154
- package/templates/market-monitor/agent.md +1 -1
- package/dist/box/record.d.ts +0 -6
- package/dist/box/record.js +0 -41
- package/dist/box/sweep.d.ts +0 -53
- package/dist/box/sweep.js +0 -193
- package/dist/box-egress-vm.d.ts +0 -118
- package/dist/box-egress-vm.js +0 -354
- package/dist/box-egress.d.ts +0 -105
- package/dist/box-egress.js +0 -256
- package/dist/box-relay-vm.d.ts +0 -84
- package/dist/box-relay-vm.js +0 -437
- package/dist/box-relay.d.ts +0 -36
- package/dist/box-relay.js +0 -207
- package/dist/boxes.d.ts +0 -109
- package/dist/boxes.js +0 -249
- package/dist/budget.d.ts +0 -71
- package/dist/budget.js +0 -199
- package/dist/console/assets/index-B7NKTU8E.css +0 -1
- package/dist/console/assets/index-CXZMgJE7.js +0 -550
- package/dist/daytona-api.d.ts +0 -10
- package/dist/daytona-api.js +0 -20
- package/dist/egress-proxy.d.ts +0 -45
- package/dist/egress-proxy.js +0 -416
- package/dist/egress-table.d.ts +0 -24
- package/dist/egress-table.js +0 -165
- package/dist/run-db.d.ts +0 -53
- package/dist/run-db.js +0 -116
- package/templates/code-review/rules/REVIEW.md +0 -41
package/dist/computer-routes.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// A run's desktop or phone, as its owner takes it: POST /v2/runs/{id}/computer/take-over and POST .../computer/hand-back
|
|
2
2
|
// (the hand-back for every kind: a browser's answers its agent's ask, as POST .../browser/hand-back does). Owner-only, as
|
|
3
|
-
// a run's browser is: the owner's password session in the console, never a token. GET /v2/runs/{id}/computer
|
|
4
|
-
//
|
|
3
|
+
// a run's browser is: the owner's password session in the console, never a token. GET /v2/runs/{id}/computer is answered by
|
|
4
|
+
// server.ts from computerView (computer-view.ts) over computerHoldOf; computerViewOf is the store-backed read of the run's
|
|
5
|
+
// computer the take-over tests check against.
|
|
5
6
|
//
|
|
6
7
|
// Everything is read from the one store (computer-commands.ts): the run's computer is up, and who drives it, as the run's
|
|
7
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
|
|
@@ -26,9 +27,6 @@ export async function computerViewOf(store, runId, options = {}) {
|
|
|
26
27
|
return { kind, state: "none", hold: "agent", why: `this run's ${kind} is not up now` };
|
|
27
28
|
return { kind, state: "live", hold: holdShown(hold, await store.commands(runId, 0)).state };
|
|
28
29
|
}
|
|
29
|
-
/** Whether the run's computer is taken over now, for the run read's computer field (run-computer.ts ComputerStateOf):
|
|
30
|
-
* from the run's journal and its rows. */
|
|
31
|
-
export const takenOverIn = (entries, commands) => holdShown(holdIn(entries), commands).state === "person";
|
|
32
30
|
/**
|
|
33
31
|
* One of our routes (COMPUTER_ROUTES, by its name in serve's route table) for run `runId`: { hold, outcome? }, or an
|
|
34
32
|
* ApiError. A token is refused (forbidden): a take-over drives the computer, so it takes the owner's signed-in page, as a
|
|
@@ -16,10 +16,12 @@ export type ComputerSetting = {
|
|
|
16
16
|
readonly provider: string;
|
|
17
17
|
readonly image?: string;
|
|
18
18
|
readonly gpu?: GpuSetting;
|
|
19
|
+
readonly persistent?: boolean;
|
|
19
20
|
} | {
|
|
20
21
|
readonly kind: Exclude<ComputerKind, "none" | "sandbox">;
|
|
21
22
|
readonly provider: string;
|
|
22
23
|
readonly image?: string;
|
|
24
|
+
readonly persistent?: boolean;
|
|
23
25
|
};
|
|
24
26
|
/** The GPUs a setting asks for, or undefined. */
|
|
25
27
|
export declare const gpuOf: (computer: {
|
package/dist/computer-setting.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
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; provider names one of
|
|
3
|
+
// the computer providers (the computer package's kind registry), and is absent for none; image names one the provider
|
|
4
|
+
// offers for the kind, and absent is the kind's default; a sandbox's gpu is { type, count }; persistent: true keeps the
|
|
5
|
+
// agent's own computer between its runs, where the configuration declares persistence. The v2 API's `place` is this
|
|
6
|
+
// setting's view, one to one where it can say it: {mode: "runner"} is {kind: "none"}, and {mode: "sandbox", box: X} is
|
|
7
|
+
// {kind: "sandbox", provider: X}. Writing either sets both. A desktop, phone or browser computer leaves the run's folder
|
|
8
|
+
// on the runner, so its place reads runner.
|
|
9
|
+
import { configurationOf, PROVIDERS, serves } from "@parcha/agentrun-computer";
|
|
1
10
|
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2
11
|
/** The kinds of computer an agent can be given. */
|
|
3
12
|
export const COMPUTER_KINDS = ["none", "sandbox", "desktop", "phone", "browser"];
|
|
@@ -16,6 +25,11 @@ const OPTIONAL = {
|
|
|
16
25
|
image: {
|
|
17
26
|
check: (value, field) => (typeof value === "string" && value.trim() !== "" && value === value.trim() ? [] : [{ field, reason: "invalid", message: `${field} is the name of an image the provider offers for the kind (GET /computers lists them), with no spaces around it` }]),
|
|
18
27
|
},
|
|
28
|
+
// An agent's own computer, kept between its runs (workspace/agent-computer.ts): true asks for it, where the provider's
|
|
29
|
+
// configuration keeps one (persistenceIssues); false or absent is a fresh computer for each run.
|
|
30
|
+
persistent: {
|
|
31
|
+
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
|
+
},
|
|
19
33
|
gpu: {
|
|
20
34
|
kinds: ["sandbox"],
|
|
21
35
|
check: (gpu, field) => {
|
|
@@ -67,7 +81,30 @@ export function computerIssues(value, field) {
|
|
|
67
81
|
}
|
|
68
82
|
if (typeof value.provider !== "string" || value.provider === "")
|
|
69
83
|
return bad("missing", `a ${kind} computer names its provider (Settings → Computers lists them)`);
|
|
70
|
-
|
|
84
|
+
const issues = Object.entries(OPTIONAL).flatMap(([key, { check }]) => (value[key] === undefined ? [] : check(value[key], `${field}.${key}`)));
|
|
85
|
+
if (issues.length > 0 || value.persistent !== true)
|
|
86
|
+
return issues;
|
|
87
|
+
return persistenceIssues(kind, value.provider, typeof value.image === "string" ? value.image : undefined, `${field}.persistent`);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Why `persistent: true` is refused, at `field`: the configuration the setting selects keeps no computer for an agent.
|
|
91
|
+
* Read from the computer package's registry, each configuration's declared persistence (kinds.test holds it equal to the
|
|
92
|
+
* built provider's), so a save needs no vendor call. A provider the registry does not list (a --faux one, or one the
|
|
93
|
+
* readiness check names as unknown) is left to the claim's refusal.
|
|
94
|
+
*/
|
|
95
|
+
function persistenceIssues(kind, provider, image, field) {
|
|
96
|
+
const entry = PROVIDERS.find((one) => one.id === provider);
|
|
97
|
+
if (!entry)
|
|
98
|
+
return [];
|
|
99
|
+
const configuration = configurationOf(entry.capabilities.filter((one) => serves(one, kind)), image, entry.defaultImage?.[kind]);
|
|
100
|
+
if (!configuration || configuration.persistence !== undefined)
|
|
101
|
+
return [];
|
|
102
|
+
return [{
|
|
103
|
+
field,
|
|
104
|
+
reason: "not_allowed",
|
|
105
|
+
message: `${entry.label}'s ${image === undefined ? "default" : JSON.stringify(image)} ${kind} keeps no computer for an agent between runs: it declares no persistence`,
|
|
106
|
+
fix: `Remove ${field}, or pick a computer that keeps one (GET /v2/computers shows which do).`,
|
|
107
|
+
}];
|
|
71
108
|
}
|
|
72
109
|
/** The setting and its place a definition says, from `computer` or `place` (both: they must agree), or undefined when
|
|
73
110
|
* it says neither. Each is checked already (computerIssues, placeIssues). */
|
package/dist/computer-view.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import type { JournalEntry } from "./computer-commands.js";
|
|
1
2
|
import type { ViewerKind } from "./store/store.js";
|
|
3
|
+
export type { JournalEntry };
|
|
2
4
|
/** A run's computer: its agent's computer kind (`browser` for the browser tool), the store's viewer kind. */
|
|
3
5
|
export type ComputerKind = ViewerKind;
|
|
4
6
|
/** Who drives the run's computer now: the agent; `pending`, the person's Take over waits for the agent's step; the person. */
|
|
5
7
|
export type ComputerHold = "agent" | "pending" | "person";
|
|
8
|
+
/** Where a run's computer with no viewer open is: `unopened`, the run hasn't opened it so far; `opening`, it is being
|
|
9
|
+
* opened now; `closed`, the run opened one, which is not up now. */
|
|
10
|
+
export type ComputerSession = "unopened" | "opening" | "closed";
|
|
6
11
|
/** The run's computer as the server reads it: its kind, or why there is none here (in plain words). */
|
|
7
12
|
export type ComputerOf = {
|
|
8
13
|
kind: ComputerKind;
|
|
@@ -18,6 +23,11 @@ export type ComputerAnswer = {
|
|
|
18
23
|
state: "none";
|
|
19
24
|
kind: ComputerKind;
|
|
20
25
|
hold: ComputerHold;
|
|
26
|
+
session: ComputerSession;
|
|
27
|
+
ended?: {
|
|
28
|
+
at: string;
|
|
29
|
+
why: string;
|
|
30
|
+
};
|
|
21
31
|
} | {
|
|
22
32
|
state: "live";
|
|
23
33
|
kind: ComputerKind;
|
|
@@ -32,7 +42,19 @@ export declare function computerView(deps: {
|
|
|
32
42
|
} | undefined>;
|
|
33
43
|
/** The run's computer, read only when no viewer is open. */
|
|
34
44
|
computer(): ComputerOf;
|
|
35
|
-
/**
|
|
36
|
-
|
|
45
|
+
/** Where the run's computer of `kind` is with no viewer open (sessionIn over the run's journal). */
|
|
46
|
+
session(kind: ComputerKind): ComputerSession;
|
|
47
|
+
/** Who drives now. */
|
|
37
48
|
hold?(): ComputerHold;
|
|
49
|
+
/** Why the run's browser is not up, read only for a `none` browser: let go while the run waited for its person, and none
|
|
50
|
+
* opened since (browser-wait-ended.ts), with when; undefined otherwise. */
|
|
51
|
+
ended?(): Promise<{
|
|
52
|
+
at: string;
|
|
53
|
+
why: string;
|
|
54
|
+
} | undefined>;
|
|
38
55
|
}): Promise<ComputerAnswer>;
|
|
56
|
+
/** Where the run's computer of `kind` is, read from the run's journal `entries` (in order), for a run with no viewer
|
|
57
|
+
* 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
|
+
* 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
|
+
export declare function sessionIn(kind: ComputerKind, entries: readonly JournalEntry[]): ComputerSession;
|
package/dist/computer-view.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
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
|
-
// run holds the keys it started with). With none open, the run's computer says `none` with its kind
|
|
4
|
-
// there is no computer here. `hold` is who drives now.
|
|
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.
|
|
5
|
+
import { KINDS } from "./runner/journal-kinds.js";
|
|
6
|
+
import { BROWSER_STEPS } from "./timeline/labels.js";
|
|
5
7
|
export async function computerView(deps) {
|
|
6
8
|
const hold = deps.hold?.() ?? "agent";
|
|
7
9
|
const open = await deps.viewer();
|
|
@@ -10,5 +12,51 @@ export async function computerView(deps) {
|
|
|
10
12
|
const computer = deps.computer();
|
|
11
13
|
if ("off" in computer)
|
|
12
14
|
return { state: "off", hold: "agent", why: computer.off };
|
|
13
|
-
|
|
15
|
+
const ended = computer.kind === "browser" ? await deps.ended?.() : undefined;
|
|
16
|
+
if (ended)
|
|
17
|
+
return { state: "none", kind: computer.kind, hold, session: "closed", ended };
|
|
18
|
+
return { state: "none", kind: computer.kind, hold, session: deps.session(computer.kind) };
|
|
19
|
+
}
|
|
20
|
+
/** The browser's steps that open a session when none is open: every one of them but its release and its hand-over to a
|
|
21
|
+
* person, which is refused with no session open (a run, a snapshot, an upload or a relaunch alike goes through the
|
|
22
|
+
* session, which the first call launches). */
|
|
23
|
+
const OPENS = new Set([...BROWSER_STEPS].filter((name) => name !== "browser_release" && name !== "browser_request_handoff"));
|
|
24
|
+
const objOf = (value) => (value && typeof value === "object" && !Array.isArray(value) ? value : undefined);
|
|
25
|
+
const messageOf = (entry) => {
|
|
26
|
+
const model = entry.model;
|
|
27
|
+
return Array.isArray(model) ? objOf(model[0]) : undefined;
|
|
28
|
+
};
|
|
29
|
+
/** Where the run's computer of `kind` is, read from the run's journal `entries` (in order), for a run with no viewer
|
|
30
|
+
* 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
|
+
* 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
|
+
export function sessionIn(kind, entries) {
|
|
34
|
+
if (kind !== "browser")
|
|
35
|
+
return "opening";
|
|
36
|
+
let asked = false;
|
|
37
|
+
const waiting = new Set();
|
|
38
|
+
const called = (id, name) => {
|
|
39
|
+
if (typeof id !== "string" || typeof name !== "string" || !OPENS.has(name))
|
|
40
|
+
return;
|
|
41
|
+
asked = true;
|
|
42
|
+
waiting.add(id);
|
|
43
|
+
};
|
|
44
|
+
for (const entry of entries) {
|
|
45
|
+
const message = messageOf(entry);
|
|
46
|
+
const data = objOf(entry.data);
|
|
47
|
+
// A pi run's calls are its assistant entries' toolCall blocks, answered by tool-result entries; a CLI harness's (Claude,
|
|
48
|
+
// Codex) are its record's call start and end entries.
|
|
49
|
+
if (entry.kind === "pi.assistant" && message && message.stopReason !== "error" && message.stopReason !== "aborted" && Array.isArray(message.content)) {
|
|
50
|
+
for (const block of message.content.map(objOf))
|
|
51
|
+
if (block?.type === "toolCall")
|
|
52
|
+
called(block.id, block.name);
|
|
53
|
+
}
|
|
54
|
+
else if (entry.kind === "pi.tool-result" && typeof message?.toolCallId === "string")
|
|
55
|
+
waiting.delete(message.toolCallId);
|
|
56
|
+
else if (entry.kind === KINDS.callStart)
|
|
57
|
+
called(data?.callId, data?.tool);
|
|
58
|
+
else if (entry.kind === KINDS.callEnd && typeof data?.callId === "string")
|
|
59
|
+
waiting.delete(data.callId);
|
|
60
|
+
}
|
|
61
|
+
return !asked ? "unopened" : waiting.size ? "opening" : "closed";
|
|
14
62
|
}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
// The computer viewer's page (a desktop's or a phone's screen), as three strings this server serves under the run's live
|
|
2
|
+
// path: the page at /v2/runs/{id}/computer/live/v/<id>, its script and style at computer-viewer.js and computer-viewer.css
|
|
3
|
+
// beside it, under LIVE_CSP (browser-live.ts), which allows no inline script or style. It is pi-browser's viewer
|
|
4
|
+
// generalized to a computer: one canvas, one WebSocket to this server's own origin, the token read from the fragment and
|
|
5
|
+
// sent once, in the hello (computer-live.ts has the protocol). Frames are drawn by their format (JPEG or PNG, told by their
|
|
6
|
+
// bytes) and acked once drawn, so the next comes only then. The bar has Take over and Hand back; no address bar, back or
|
|
7
|
+
// reload (a browser's). A desktop gets the mouse, the wheel and keys; a phone gets taps, swipes, its back, home and
|
|
8
|
+
// recents buttons, and keys (a soft keyboard's too, through beforeinput). Coordinates are the screen's real pixels, the w and h each frame carries. A swipe lasts 1,000 ms
|
|
9
|
+
// at most, as the computer takes it (createActionMapper's bound). Losing focus tells the endpoint ("blur"), which lets go of
|
|
10
|
+
// the buttons held.
|
|
11
|
+
const html = `<!doctype html>
|
|
12
|
+
<html lang="en">
|
|
13
|
+
<head>
|
|
14
|
+
<meta charset="utf-8">
|
|
15
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
16
|
+
<title>Live view</title>
|
|
17
|
+
<link rel="stylesheet" href="../computer-viewer.css">
|
|
18
|
+
</head>
|
|
19
|
+
<body>
|
|
20
|
+
<header id="bar">
|
|
21
|
+
<button id="hands" type="button" hidden>Take over</button>
|
|
22
|
+
<span id="phone" hidden>
|
|
23
|
+
<button id="back" type="button" title="Back" aria-label="Back">◀</button>
|
|
24
|
+
<button id="home" type="button" title="Home" aria-label="Home">●</button>
|
|
25
|
+
<button id="recents" type="button" title="Recents" aria-label="Recents">■</button>
|
|
26
|
+
</span>
|
|
27
|
+
<span id="spacer"></span>
|
|
28
|
+
<span id="drive" aria-live="polite"></span>
|
|
29
|
+
</header>
|
|
30
|
+
<div id="notice" role="status" hidden></div>
|
|
31
|
+
<main id="stage"><canvas id="screen" tabindex="0" aria-label="The computer's screen"></canvas><textarea id="sink" rows="1" autocapitalize="off" autocomplete="off" autocorrect="off" spellcheck="false" aria-label="Keyboard input for the computer"></textarea></main>
|
|
32
|
+
<script src="../computer-viewer.js"></script>
|
|
33
|
+
</body>
|
|
34
|
+
</html>
|
|
35
|
+
`;
|
|
36
|
+
const css = `* { box-sizing: border-box; }
|
|
37
|
+
html, body { margin: 0; height: 100%; background: #111; color: #eee; font: 14px system-ui, sans-serif; }
|
|
38
|
+
body { display: flex; flex-direction: column; }
|
|
39
|
+
#bar { display: flex; gap: 6px; align-items: center; padding: 6px 8px; background: #222; border-bottom: 1px solid #333; }
|
|
40
|
+
#bar button { background: #333; color: #eee; border: 1px solid #444; border-radius: 4px; padding: 4px 10px; cursor: pointer; }
|
|
41
|
+
#bar button:hover { background: #444; }
|
|
42
|
+
#bar button:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
43
|
+
#bar #hands { background: #1f4d2b; border-color: #2f6b3d; }
|
|
44
|
+
#bar #hands.holding { background: #5a3b00; border-color: #7a5410; }
|
|
45
|
+
#hands[hidden], #phone[hidden], #notice[hidden] { display: none; }
|
|
46
|
+
#phone { display: inline-flex; gap: 6px; }
|
|
47
|
+
#spacer { flex: 1; }
|
|
48
|
+
#drive { min-width: 9em; text-align: right; color: #aaa; }
|
|
49
|
+
#drive.agent, #drive.pending { color: #f0b429; }
|
|
50
|
+
#drive.person { color: #6cc070; }
|
|
51
|
+
.not-held #screen { cursor: not-allowed; }
|
|
52
|
+
#notice { padding: 6px 10px; background: #5a3b00; color: #ffe2a8; }
|
|
53
|
+
#notice.fatal { background: #5a1a1a; color: #ffc4c4; font-size: 18px; font-weight: 600; text-align: center; padding: 18px 16px; }
|
|
54
|
+
body.over #stage { opacity: 0.35; }
|
|
55
|
+
#stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; }
|
|
56
|
+
#screen { display: block; background: #000; outline: none; cursor: default; touch-action: none; }
|
|
57
|
+
#screen:focus, #stage:focus-within #screen { box-shadow: 0 0 0 2px #3b82f6; }
|
|
58
|
+
#sink { position: fixed; left: 0; bottom: 0; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; resize: none; overflow: hidden; pointer-events: none; font-size: 16px; }
|
|
59
|
+
`;
|
|
60
|
+
const js = `"use strict";
|
|
61
|
+
(function () {
|
|
62
|
+
var params = new URLSearchParams(location.hash.slice(1));
|
|
63
|
+
var token = params.get("t");
|
|
64
|
+
// The fragment never stays in the address bar, the history or a screenshot of it.
|
|
65
|
+
history.replaceState(null, "", location.pathname + location.search);
|
|
66
|
+
|
|
67
|
+
var $ = function (id) { return document.getElementById(id); };
|
|
68
|
+
var canvas = $("screen");
|
|
69
|
+
var sink = $("sink");
|
|
70
|
+
var ctx = canvas.getContext("2d");
|
|
71
|
+
var stage = $("stage");
|
|
72
|
+
var notice = $("notice");
|
|
73
|
+
var drive = $("drive");
|
|
74
|
+
var handsEl = $("hands");
|
|
75
|
+
function focusScreen() { try { sink.focus({ preventScroll: true }); } catch (e) { canvas.focus(); } }
|
|
76
|
+
function fit() {
|
|
77
|
+
if (!canvas.width || !canvas.height) return;
|
|
78
|
+
var box = stage.getBoundingClientRect();
|
|
79
|
+
var scale = Math.min(box.width / canvas.width, box.height / canvas.height);
|
|
80
|
+
if (!(scale > 0)) return;
|
|
81
|
+
canvas.style.width = Math.floor(canvas.width * scale) + "px";
|
|
82
|
+
canvas.style.height = Math.floor(canvas.height * scale) + "px";
|
|
83
|
+
}
|
|
84
|
+
if (typeof ResizeObserver === "function") new ResizeObserver(fit).observe(stage); else window.addEventListener("resize", fit);
|
|
85
|
+
|
|
86
|
+
var fatal = false;
|
|
87
|
+
function say(text, isFatal) {
|
|
88
|
+
if (!text) { notice.hidden = true; notice.textContent = ""; return; }
|
|
89
|
+
notice.hidden = false;
|
|
90
|
+
notice.textContent = text;
|
|
91
|
+
notice.className = isFatal ? "fatal" : "";
|
|
92
|
+
document.body.classList.toggle("over", !!isFatal);
|
|
93
|
+
}
|
|
94
|
+
var holding = false;
|
|
95
|
+
var kind = "";
|
|
96
|
+
var input = "";
|
|
97
|
+
var DRIVE = { agent: "the agent has the computer", pending: "taking over: the agent's step is ending", person: "you have the computer" };
|
|
98
|
+
function setDrive(state) { drive.className = state || ""; drive.textContent = DRIVE[state] || ""; }
|
|
99
|
+
function showHands() {
|
|
100
|
+
handsEl.hidden = false;
|
|
101
|
+
handsEl.textContent = holding ? "Hand back" : "Take over";
|
|
102
|
+
handsEl.className = holding ? "holding" : "";
|
|
103
|
+
document.body.classList.toggle("not-held", !holding);
|
|
104
|
+
["back", "home", "recents"].forEach(function (id) { $(id).disabled = !holding; });
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!token) { fatal = true; say("This link has no token. Open the live view from the run's page.", true); return; }
|
|
108
|
+
var proto = location.protocol === "https:" ? "wss://" : "ws://";
|
|
109
|
+
var ws = new WebSocket(proto + location.host + location.pathname.replace(/\\/$/, "") + "/ws");
|
|
110
|
+
ws.binaryType = "arraybuffer";
|
|
111
|
+
var ready = false;
|
|
112
|
+
var closed = false;
|
|
113
|
+
say("Connecting to the computer.");
|
|
114
|
+
ws.onopen = function () { ws.send(JSON.stringify({ type: "hello", token: token })); token = null; };
|
|
115
|
+
function raw(message) { if (ws.readyState === 1) ws.send(JSON.stringify(message)); }
|
|
116
|
+
var NOT_TAKEN = "Take over to drive.";
|
|
117
|
+
function send(message) {
|
|
118
|
+
if (!ready) return;
|
|
119
|
+
if (!holding) { if (!(message.type === "mouse" && message.action === "move")) say(NOT_TAKEN); return; }
|
|
120
|
+
raw(message);
|
|
121
|
+
}
|
|
122
|
+
handsEl.addEventListener("click", function () {
|
|
123
|
+
if (!ready) return;
|
|
124
|
+
raw({ type: holding ? "give" : "take" });
|
|
125
|
+
if (!holding) say("Taking over the computer...");
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// Frames: one at a time; each is acked once drawn, and only then does the computer send the next.
|
|
129
|
+
var frame = { w: 0, h: 0 };
|
|
130
|
+
function formatOf(bytes) { return bytes.length > 3 && bytes[0] === 0x89 && bytes[1] === 0x50 && bytes[2] === 0x4e && bytes[3] === 0x47 ? "image/png" : "image/jpeg"; }
|
|
131
|
+
function draw(buffer) {
|
|
132
|
+
if (buffer.byteLength <= 4) { raw({ type: "ack" }); return; }
|
|
133
|
+
var view = new DataView(buffer);
|
|
134
|
+
var w = view.getUint16(0);
|
|
135
|
+
var h = view.getUint16(2);
|
|
136
|
+
var bytes = new Uint8Array(buffer, 4);
|
|
137
|
+
createImageBitmap(new Blob([bytes], { type: formatOf(bytes) })).then(function (bitmap) {
|
|
138
|
+
if (canvas.width !== bitmap.width || canvas.height !== bitmap.height) { canvas.width = bitmap.width; canvas.height = bitmap.height; fit(); }
|
|
139
|
+
ctx.drawImage(bitmap, 0, 0);
|
|
140
|
+
if (bitmap.close) bitmap.close();
|
|
141
|
+
frame = { w: w || bitmap.width, h: h || bitmap.height };
|
|
142
|
+
document.body.dataset.frames = String(Number(document.body.dataset.frames || "0") + 1);
|
|
143
|
+
}, function () {}).then(function () { raw({ type: "ack" }); });
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
var HOLD_ENDED = { given: "You handed the computer back to the agent.", answered: "The agent's request was answered, so the computer went back to the agent.", idle: "The computer went back to the agent: no input came from you for 15 minutes.", away: "The computer went back to the agent: the live view was closed.", released: "The computer's session ended while you had it." };
|
|
147
|
+
var REFUSED = { unauthorized: "This link's token was not accepted.", viewer_in_use: "Another viewer already has this computer.", released: "This computer has been released.", bad_message: "The host did not understand this viewer.", slow_viewer: "This view fell too far behind the computer's screen: open the live view again." };
|
|
148
|
+
var ENDED = { gone: "This computer has ended.", released: "This computer has been released.", ended: "This computer's session has ended.", unreachable: "The computer can't be reached right now.", refused: "The computer refused its live view.", unsupported: "This computer has no screen to show." };
|
|
149
|
+
ws.onmessage = function (event) {
|
|
150
|
+
if (typeof event.data !== "string") { draw(event.data); return; }
|
|
151
|
+
var m;
|
|
152
|
+
try { m = JSON.parse(event.data); } catch (e) { return; }
|
|
153
|
+
if (m.type === "ready") {
|
|
154
|
+
ready = true; kind = m.kind; input = m.input; holding = m.held === true;
|
|
155
|
+
$("phone").hidden = kind !== "phone";
|
|
156
|
+
document.body.dataset.kind = kind;
|
|
157
|
+
showHands(); setDrive(m.drive); say(""); focusScreen();
|
|
158
|
+
}
|
|
159
|
+
else if (m.type === "hold") {
|
|
160
|
+
holding = m.held === true;
|
|
161
|
+
showHands(); setDrive(holding ? "person" : "agent");
|
|
162
|
+
var extra = typeof m.message === "string" && m.message ? " " + m.message : "";
|
|
163
|
+
say(holding ? "" : (HOLD_ENDED[m.reason] || "The computer went back to the agent.") + extra);
|
|
164
|
+
if (holding) focusScreen();
|
|
165
|
+
}
|
|
166
|
+
else if (m.type === "status") { setDrive(m.drive); if (m.drive === "pending") say("Taking over: the agent's step is ending."); }
|
|
167
|
+
else if (m.type === "take_refused") say(m.message || "The computer could not be handed to you.");
|
|
168
|
+
else if (m.type === "held") say(m.message || "That input was held.");
|
|
169
|
+
else if (m.type === "refused") { fatal = true; ready = false; say(REFUSED[m.reason] || "The host refused this viewer.", true); }
|
|
170
|
+
else if (m.type === "ended") { fatal = true; ready = false; holding = false; handsEl.disabled = true; say(ENDED[m.reason] || "This computer has ended.", true); }
|
|
171
|
+
};
|
|
172
|
+
ws.onclose = function () { closed = true; ready = false; holding = false; handsEl.disabled = true; setDrive(""); if (!fatal) say("Disconnected. Open the live view again.", true); };
|
|
173
|
+
|
|
174
|
+
// Input, in the screen's real pixels: from the canvas's box and the latest frame's w and h.
|
|
175
|
+
function point(e) {
|
|
176
|
+
var rect = canvas.getBoundingClientRect();
|
|
177
|
+
if (!frame.w || !rect.width) return null;
|
|
178
|
+
var x = Math.round((e.clientX - rect.left) * (frame.w / rect.width));
|
|
179
|
+
var y = Math.round((e.clientY - rect.top) * (frame.h / rect.height));
|
|
180
|
+
return { x: Math.max(0, Math.min(frame.w - 1, x)), y: Math.max(0, Math.min(frame.h - 1, y)) };
|
|
181
|
+
}
|
|
182
|
+
function mods(e) { return (e.altKey ? 1 : 0) | (e.ctrlKey ? 2 : 0) | (e.metaKey ? 4 : 0) | (e.shiftKey ? 8 : 0); }
|
|
183
|
+
|
|
184
|
+
// A desktop: the mouse and the wheel. A button pressed on the screen is released wherever the mouse goes up (the bar
|
|
185
|
+
// around it, the empty stage): the release is heard on the window, at the screen's nearest point.
|
|
186
|
+
var pressed = {};
|
|
187
|
+
canvas.addEventListener("mousedown", function (e) {
|
|
188
|
+
focusScreen();
|
|
189
|
+
if (input !== "desktop") return;
|
|
190
|
+
var p = point(e); if (!p) return;
|
|
191
|
+
e.preventDefault();
|
|
192
|
+
pressed[e.button] = true;
|
|
193
|
+
send({ type: "mouse", action: "down", x: p.x, y: p.y, button: e.button, buttons: e.buttons, clickCount: Math.max(1, Math.min(3, e.detail || 1)), modifiers: mods(e) });
|
|
194
|
+
});
|
|
195
|
+
window.addEventListener("mouseup", function (e) {
|
|
196
|
+
if (input !== "desktop" || !pressed[e.button]) return;
|
|
197
|
+
delete pressed[e.button];
|
|
198
|
+
var p = point(e); if (!p) return;
|
|
199
|
+
if (e.target === canvas) e.preventDefault();
|
|
200
|
+
send({ type: "mouse", action: "up", x: p.x, y: p.y, button: e.button, buttons: e.buttons, clickCount: Math.max(1, Math.min(3, e.detail || 1)), modifiers: mods(e) });
|
|
201
|
+
});
|
|
202
|
+
var moved = null, scheduled = false;
|
|
203
|
+
canvas.addEventListener("mousemove", function (e) {
|
|
204
|
+
if (input !== "desktop" || !holding) return;
|
|
205
|
+
var p = point(e); if (!p) return;
|
|
206
|
+
moved = { type: "mouse", action: "move", x: p.x, y: p.y, button: 0, buttons: e.buttons, clickCount: 0, modifiers: mods(e) };
|
|
207
|
+
if (!scheduled) { scheduled = true; requestAnimationFrame(function () { scheduled = false; if (moved) { send(moved); moved = null; } }); }
|
|
208
|
+
});
|
|
209
|
+
canvas.addEventListener("contextmenu", function (e) { e.preventDefault(); });
|
|
210
|
+
// The viewer losing focus (another window, or the run's page around it) lets go of what the person holds down: the
|
|
211
|
+
// computer would never see its release.
|
|
212
|
+
window.addEventListener("blur", function () { if (holding) raw({ type: "blur" }); });
|
|
213
|
+
canvas.addEventListener("wheel", function (e) {
|
|
214
|
+
if (input !== "desktop") return;
|
|
215
|
+
var p = point(e); if (!p) return;
|
|
216
|
+
e.preventDefault();
|
|
217
|
+
var unit = e.deltaMode === 1 ? 40 : e.deltaMode === 2 ? frame.h : 1;
|
|
218
|
+
send({ type: "wheel", x: p.x, y: p.y, dx: Math.round(e.deltaX * unit), dy: Math.round(e.deltaY * unit) });
|
|
219
|
+
}, { passive: false });
|
|
220
|
+
|
|
221
|
+
// A phone: a short touch that stays put is a tap, anything else a swipe; and its three buttons.
|
|
222
|
+
var touchStart = null;
|
|
223
|
+
canvas.addEventListener("pointerdown", function (e) {
|
|
224
|
+
if (input === "desktop") return;
|
|
225
|
+
focusScreen();
|
|
226
|
+
var p = point(e); if (!p) return;
|
|
227
|
+
e.preventDefault();
|
|
228
|
+
// Captured: a mouse drag released outside the screen still ends here, as a swipe.
|
|
229
|
+
try { canvas.setPointerCapture(e.pointerId); } catch (_) { /* a pointer that is gone */ }
|
|
230
|
+
touchStart = { x: p.x, y: p.y, at: Date.now() };
|
|
231
|
+
});
|
|
232
|
+
canvas.addEventListener("pointerup", function (e) {
|
|
233
|
+
if (input === "desktop" || !touchStart) return;
|
|
234
|
+
var p = point(e); var from = touchStart; touchStart = null;
|
|
235
|
+
if (!p) return;
|
|
236
|
+
e.preventDefault();
|
|
237
|
+
var far = Math.abs(p.x - from.x) + Math.abs(p.y - from.y) > 12;
|
|
238
|
+
if (far) send({ type: "swipe", x1: from.x, y1: from.y, x2: p.x, y2: p.y, ms: Math.max(50, Math.min(1000, Date.now() - from.at)) });
|
|
239
|
+
else send({ type: "tap", x: p.x, y: p.y });
|
|
240
|
+
});
|
|
241
|
+
["back", "home", "recents"].forEach(function (name) { $(name).addEventListener("click", function () { send({ type: "button", name: name }); focusScreen(); }); });
|
|
242
|
+
|
|
243
|
+
// Keys, for both: a printable character typed goes as its char, everything else as its key. AltGr's character (which
|
|
244
|
+
// Windows reports with Ctrl and Alt held) is text, not a shortcut; a dead key is left to finish as the composition or
|
|
245
|
+
// the input it makes (compositionend, beforeinput).
|
|
246
|
+
var justComposed = null;
|
|
247
|
+
function onKeyDown(e) {
|
|
248
|
+
justComposed = null;
|
|
249
|
+
if (e.isComposing || e.keyCode === 229 || e.key === "Dead") return;
|
|
250
|
+
if ((e.ctrlKey || e.metaKey) && (e.key === "v" || e.key === "V")) return;
|
|
251
|
+
e.preventDefault();
|
|
252
|
+
var altGraph = !!(e.getModifierState && e.getModifierState("AltGraph"));
|
|
253
|
+
var printable = e.key.length === 1 && (altGraph ? !e.metaKey : !e.ctrlKey && !e.metaKey && !e.altKey);
|
|
254
|
+
if (printable) send({ type: "key", action: "char", key: e.key, code: e.code || "", text: e.key, modifiers: altGraph ? (e.shiftKey ? 8 : 0) : mods(e) });
|
|
255
|
+
else send({ type: "key", action: "down", key: e.key, code: e.code || "", modifiers: mods(e) });
|
|
256
|
+
}
|
|
257
|
+
function onPaste(e) {
|
|
258
|
+
var text = e.clipboardData ? e.clipboardData.getData("text/plain") : "";
|
|
259
|
+
e.preventDefault();
|
|
260
|
+
if (text) send({ type: "text", text: text });
|
|
261
|
+
}
|
|
262
|
+
[canvas, sink].forEach(function (el) { el.addEventListener("keydown", onKeyDown); el.addEventListener("paste", onPaste); });
|
|
263
|
+
sink.addEventListener("compositionend", function (e) { justComposed = e.data || null; if (e.data) send({ type: "text", text: e.data }); sink.value = ""; });
|
|
264
|
+
// A soft keyboard (a phone's, a tablet's) sends keydown with keyCode 229 and no key, so its edits come as the sink's
|
|
265
|
+
// beforeinput alone. A desktop's typed key never reaches here: onKeyDown's preventDefault cancels the beforeinput it
|
|
266
|
+
// would have made. A composition's own steps are compositionend's, a paste the paste handler's.
|
|
267
|
+
function sendKey(key) { send({ type: "key", action: "down", key: key, code: "", modifiers: 0 }); }
|
|
268
|
+
var EDITS = {
|
|
269
|
+
// Some browsers follow compositionend with an insertText of the same word, with no key between: that repeat is the
|
|
270
|
+
// composition's, already sent; a key since (onKeyDown) or any other edit makes the same text a new one.
|
|
271
|
+
insertText: function (e) { if (e.data && e.data !== justComposed) send({ type: "text", text: e.data }); },
|
|
272
|
+
// Autocorrect swapping a word the computer already has: as many Backspaces as the replaced range, then the new word.
|
|
273
|
+
insertReplacementText: function (e) {
|
|
274
|
+
var text = e.data || (e.dataTransfer ? e.dataTransfer.getData("text/plain") : "");
|
|
275
|
+
var range = e.getTargetRanges ? e.getTargetRanges()[0] : null;
|
|
276
|
+
var gone = range && range.startContainer === range.endContainer ? Math.max(0, range.endOffset - range.startOffset) : 0;
|
|
277
|
+
for (var i = 0; i < gone; i++) sendKey("Backspace");
|
|
278
|
+
if (text) send({ type: "text", text: text });
|
|
279
|
+
},
|
|
280
|
+
insertLineBreak: function () { sendKey("Enter"); },
|
|
281
|
+
insertParagraph: function () { sendKey("Enter"); },
|
|
282
|
+
deleteContentBackward: function () { sendKey("Backspace"); },
|
|
283
|
+
deleteContentForward: function () { sendKey("Delete"); },
|
|
284
|
+
};
|
|
285
|
+
sink.addEventListener("beforeinput", function (e) {
|
|
286
|
+
var edit = Object.prototype.hasOwnProperty.call(EDITS, e.inputType) ? EDITS[e.inputType] : null;
|
|
287
|
+
if (!edit || e.isComposing) return;
|
|
288
|
+
e.preventDefault();
|
|
289
|
+
edit(e);
|
|
290
|
+
justComposed = null;
|
|
291
|
+
});
|
|
292
|
+
// Whatever a keyboard put in the sink that no beforeinput took (one it could not cancel) is let go, never sent twice.
|
|
293
|
+
sink.addEventListener("input", function (e) { if (!e.isComposing) sink.value = ""; });
|
|
294
|
+
})();
|
|
295
|
+
`;
|
|
296
|
+
/** The computer viewer's page and its two files, served by this server under LIVE_CSP. */
|
|
297
|
+
export const computerViewerAssets = Object.freeze({ html, js, css });
|