@parcha/agentrun-serve 0.1.0-beta.31 → 0.1.0-beta.32
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 +422 -0
- package/NOTICE +18 -0
- package/README.md +887 -241
- package/dist/adapter-facts.d.ts +3 -0
- package/dist/adapter-facts.js +5 -0
- package/dist/adapters.d.ts +64 -140
- package/dist/adapters.js +153 -377
- package/dist/agents-store.d.ts +146 -0
- package/dist/agents-store.js +359 -0
- package/dist/agents.d.ts +5 -3
- package/dist/agents.js +37 -17
- package/dist/app.d.ts +2 -4
- package/dist/app.js +207 -92
- package/dist/approvals.d.ts +4 -0
- package/dist/approvals.js +7 -0
- package/dist/archil-routes.d.ts +45 -0
- package/dist/archil-routes.js +150 -0
- package/dist/archil-settings.d.ts +30 -0
- package/dist/archil-settings.js +34 -0
- package/dist/background.js +28 -9
- package/dist/bounds.d.ts +26 -0
- package/dist/bounds.js +137 -0
- package/dist/box-egress-vm.d.ts +2 -1
- package/dist/box-egress-vm.js +20 -6
- package/dist/box-egress.d.ts +16 -6
- package/dist/box-egress.js +27 -15
- package/dist/box-paths.d.ts +59 -0
- package/dist/box-paths.js +92 -0
- package/dist/box-relay-vm.js +28 -1
- package/dist/box-relay.d.ts +2 -0
- package/dist/box-relay.js +2 -2
- package/dist/boxes.d.ts +13 -1
- package/dist/boxes.js +37 -3
- package/dist/browser-commands.d.ts +43 -0
- package/dist/browser-commands.js +154 -0
- package/dist/browser-cost.d.ts +30 -3
- package/dist/browser-cost.js +276 -21
- package/dist/browser-live.d.ts +124 -0
- package/dist/browser-live.js +324 -0
- package/dist/browser-person.d.ts +168 -0
- package/dist/browser-person.js +769 -0
- package/dist/budget.d.ts +80 -0
- package/dist/budget.js +211 -0
- package/dist/cap.d.ts +272 -62
- package/dist/cap.js +599 -189
- package/dist/cli.js +201 -17
- package/dist/coding-tools.d.ts +13 -1
- package/dist/coding-tools.js +107 -5
- package/dist/computer-adb.d.ts +12 -0
- package/dist/computer-adb.js +14 -0
- package/dist/computer-commands.d.ts +103 -0
- package/dist/computer-commands.js +256 -0
- package/dist/computer-keys.d.ts +68 -0
- package/dist/computer-keys.js +148 -0
- package/dist/computer-routes.d.ts +38 -0
- package/dist/computer-routes.js +56 -0
- package/dist/computer-setting.d.ts +37 -0
- package/dist/computer-setting.js +47 -0
- package/dist/computer-view.d.ts +38 -0
- package/dist/computer-view.js +14 -0
- package/dist/computers.d.ts +137 -0
- package/dist/computers.js +197 -0
- package/dist/console/THIRD-PARTY-NOTICES.txt +25 -0
- package/dist/console/assets/index-35-7aeIZ.js +519 -0
- package/dist/console/assets/index-Cejbov-Y.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +2 -0
- package/dist/console-links.js +6 -0
- package/dist/decision-cap.d.ts +63 -0
- package/dist/decision-cap.js +163 -0
- package/dist/decision-rows.d.ts +5 -2
- package/dist/decision-rows.js +8 -6
- package/dist/decisions.d.ts +28 -1
- package/dist/decisions.js +63 -6
- package/dist/disk.d.ts +33 -0
- package/dist/disk.js +85 -0
- package/dist/door-line.d.ts +23 -0
- package/dist/door-line.js +83 -0
- package/dist/egress-proxy.d.ts +45 -0
- package/dist/egress-proxy.js +416 -0
- package/dist/egress-table.d.ts +24 -0
- package/dist/egress-table.js +165 -0
- package/dist/errors.d.ts +15 -0
- package/dist/errors.js +22 -2
- package/dist/exa-keyless.js +1 -1
- package/dist/explain.d.ts +22 -0
- package/dist/explain.js +207 -0
- package/dist/faux-computers.d.ts +35 -0
- package/dist/faux-computers.js +126 -0
- package/dist/file-types.d.ts +4 -0
- package/dist/file-types.js +11 -0
- package/dist/files.d.ts +3 -35
- package/dist/files.js +9 -120
- package/dist/github-connection.d.ts +207 -0
- package/dist/github-connection.js +595 -0
- package/dist/github.d.ts +64 -0
- package/dist/github.js +119 -0
- package/dist/grade.d.ts +9 -42
- package/dist/grade.js +42 -228
- package/dist/graph-served.d.ts +23 -2
- package/dist/graph-served.js +44 -3
- package/dist/graph-view.d.ts +7 -3
- package/dist/graph-view.js +26 -15
- package/dist/handed-values.d.ts +23 -0
- package/dist/handed-values.js +36 -0
- package/dist/harness-app.d.ts +33 -4
- package/dist/harness-app.js +530 -85
- package/dist/harness-install.d.ts +120 -0
- package/dist/harness-install.js +359 -0
- package/dist/harness-opencode/adapter.js +42 -8
- package/dist/harness-opencode/facts.d.ts +2 -0
- package/dist/harness-opencode/facts.js +28 -0
- package/dist/harness-opencode/harness.d.ts +4 -0
- package/dist/harness-opencode/harness.js +38 -5
- package/dist/harness-opencode/host/policy.js +11 -3
- package/dist/harness-opencode/transcript.d.ts +25 -0
- package/dist/harness-opencode/transcript.js +81 -0
- package/dist/harness-table.d.ts +75 -0
- package/dist/harness-table.js +145 -0
- package/dist/harness.d.ts +7 -28
- package/dist/harness.js +15 -41
- package/dist/heard.d.ts +12 -0
- package/dist/heard.js +45 -0
- package/dist/helper-env.d.ts +4 -0
- package/dist/helper-env.js +14 -0
- package/dist/home-path.d.ts +0 -4
- package/dist/home-path.js +3 -17
- package/dist/host-check.d.ts +4 -3
- package/dist/host-check.js +5 -4
- package/dist/host-tools.d.ts +51 -8
- package/dist/host-tools.js +108 -117
- package/dist/host.d.ts +12 -6
- package/dist/host.js +30 -24
- package/dist/hosted-search.d.ts +3 -0
- package/dist/hosted-search.js +5 -3
- package/dist/import-proxy.d.ts +42 -0
- package/dist/import-proxy.js +105 -0
- package/dist/import-summary.js +4 -8
- package/dist/import-worker.d.ts +2 -3
- package/dist/import-worker.js +18 -16
- package/dist/import.d.ts +37 -17
- package/dist/import.js +208 -222
- package/dist/key-meta.d.ts +26 -0
- package/dist/key-meta.js +30 -0
- package/dist/key-refusal.d.ts +4 -1
- package/dist/key-refusal.js +20 -7
- package/dist/learn/check.d.ts +3 -1
- package/dist/learn/check.js +2 -2
- package/dist/learn/commit.d.ts +86 -0
- package/dist/learn/commit.js +182 -0
- package/dist/learn/folder.d.ts +296 -0
- package/dist/learn/folder.js +796 -0
- package/dist/learn/grade.d.ts +22 -9
- package/dist/learn/grade.js +95 -49
- package/dist/learn/index.d.ts +2 -2
- package/dist/learn/index.js +2 -2
- package/dist/learn/learning.sh +366 -0
- package/dist/learn/reflect.d.ts +12 -5
- package/dist/learn/reflect.js +70 -41
- package/dist/learn/secrets.d.ts +15 -7
- package/dist/learn/secrets.js +66 -16
- package/dist/learn/seed-check.d.ts +74 -0
- package/dist/learn/seed-check.js +103 -0
- package/dist/learn/skills.d.ts +5 -1
- package/dist/learn/skills.js +5 -4
- package/dist/learned-workflow.d.ts +12 -2
- package/dist/learned-workflow.js +9 -5
- package/dist/learning-routes.d.ts +88 -41
- package/dist/learning-routes.js +340 -539
- package/dist/learning-run.d.ts +60 -53
- package/dist/learning-run.js +181 -224
- package/dist/learning-words.d.ts +3 -5
- package/dist/learning-words.js +3 -5
- package/dist/learning.d.ts +177 -112
- package/dist/learning.js +289 -380
- package/dist/live/stream.d.ts +30 -0
- package/dist/live/stream.js +175 -0
- package/dist/live/translate.d.ts +52 -0
- package/dist/live/translate.js +276 -0
- package/dist/llm.js +3 -0
- package/dist/llms.txt +1 -0
- package/dist/local-models.d.ts +23 -0
- package/dist/local-models.js +35 -0
- package/dist/mcp-gateway.d.ts +46 -13
- package/dist/mcp-gateway.js +145 -45
- package/dist/mcp-meta.d.ts +3 -0
- package/dist/mcp-meta.js +14 -2
- package/dist/mcp-oauth.d.ts +172 -0
- package/dist/mcp-oauth.js +403 -0
- package/dist/mcp-private-hosts.d.ts +48 -0
- package/dist/mcp-private-hosts.js +141 -0
- package/dist/mcp-probe.d.ts +101 -0
- package/dist/mcp-probe.js +359 -0
- package/dist/mcp-secret-writes.d.ts +23 -0
- package/dist/mcp-secret-writes.js +60 -0
- package/dist/mcp-servers-store.d.ts +251 -0
- package/dist/mcp-servers-store.js +447 -0
- package/dist/mcp-servers.d.ts +180 -50
- package/dist/mcp-servers.js +284 -321
- package/dist/mcp-store.d.ts +103 -0
- package/dist/mcp-store.js +123 -0
- package/dist/mcp.js +22 -21
- package/dist/model.d.ts +77 -59
- package/dist/model.js +237 -98
- package/dist/monid.d.ts +8 -6
- package/dist/monid.js +39 -25
- package/dist/openapi.d.ts +22 -1
- package/dist/openapi.js +919 -108
- package/dist/owner.d.ts +46 -10
- package/dist/owner.js +123 -43
- package/dist/page.d.ts +10 -0
- package/dist/page.js +27 -4
- package/dist/paid-calls.d.ts +71 -2
- package/dist/paid-calls.js +125 -5
- package/dist/pdf-pages.d.ts +16 -14
- package/dist/pdf-pages.js +88 -58
- package/dist/place.d.ts +15 -13
- package/dist/place.js +25 -15
- package/dist/port-models.d.ts +53 -0
- package/dist/port-models.js +93 -0
- package/dist/propose.d.ts +9 -8
- package/dist/propose.js +82 -49
- package/dist/provider.d.ts +85 -0
- package/dist/provider.js +178 -0
- package/dist/push-handler.d.ts +52 -0
- package/dist/push-handler.js +165 -0
- package/dist/refusal-words.d.ts +23 -0
- package/dist/refusal-words.js +25 -0
- package/dist/request-start.d.ts +6 -1
- package/dist/request-start.js +41 -10
- package/dist/result.d.ts +13 -2
- package/dist/result.js +4 -5
- package/dist/run-box.d.ts +22 -3
- package/dist/run-box.js +78 -17
- package/dist/run-computer.d.ts +24 -0
- package/dist/run-computer.js +15 -0
- package/dist/run-cut.d.ts +33 -0
- package/dist/run-cut.js +42 -0
- package/dist/run-db.d.ts +64 -0
- package/dist/run-db.js +155 -0
- package/dist/run-files.d.ts +31 -0
- package/dist/run-files.js +125 -0
- package/dist/run-holder.d.ts +52 -0
- package/dist/run-holder.js +139 -0
- package/dist/run-launch.d.ts +72 -0
- package/dist/run-launch.js +108 -0
- package/dist/run-learning-served.d.ts +43 -0
- package/dist/run-learning-served.js +16 -0
- package/dist/run-manifest.d.ts +7 -6
- package/dist/run-manifest.js +20 -10
- package/dist/run-reads-over-store.d.ts +102 -0
- package/dist/run-reads-over-store.js +151 -0
- package/dist/run-timeline-served.d.ts +13 -0
- package/dist/run-timeline-served.js +69 -0
- package/dist/run-view.d.ts +436 -0
- package/dist/run-view.js +620 -0
- package/dist/runnable.d.ts +30 -5
- package/dist/runnable.js +149 -72
- package/dist/runner/adapter-loop.d.ts +237 -0
- package/dist/runner/adapter-loop.js +1625 -0
- package/dist/runner/adapter-run-spec.d.ts +216 -0
- package/dist/runner/adapter-run-spec.js +537 -0
- package/dist/runner/adapters/index.d.ts +37 -0
- package/dist/runner/adapters/index.js +66 -0
- package/dist/runner/adapters/pi.d.ts +99 -0
- package/dist/runner/adapters/pi.js +260 -0
- package/dist/runner/beside.d.ts +12 -0
- package/dist/runner/beside.js +30 -0
- package/dist/runner/claim-secrets.d.ts +30 -0
- package/dist/runner/claim-secrets.js +90 -0
- package/dist/runner/cli-run-spec.d.ts +17 -0
- package/dist/runner/cli-run-spec.js +371 -0
- package/dist/runner/commands.d.ts +23 -0
- package/dist/runner/commands.js +67 -0
- package/dist/runner/computer-journal.d.ts +38 -0
- package/dist/runner/computer-journal.js +120 -0
- package/dist/runner/conformance/child.d.ts +1 -0
- package/dist/runner/conformance/child.js +78 -0
- package/dist/runner/conformance/harness.d.ts +89 -0
- package/dist/runner/conformance/harness.js +928 -0
- package/dist/runner/conformance/subject.d.ts +83 -0
- package/dist/runner/conformance/subject.js +1 -0
- package/dist/runner/dispatch.d.ts +30 -0
- package/dist/runner/dispatch.js +99 -0
- package/dist/runner/end-of-run.d.ts +32 -0
- package/dist/runner/end-of-run.js +56 -0
- package/dist/runner/github-app.d.ts +16 -0
- package/dist/runner/github-app.js +37 -0
- package/dist/runner/hand-back.d.ts +43 -0
- package/dist/runner/hand-back.js +69 -0
- package/dist/runner/harness-loops.d.ts +10 -0
- package/dist/runner/harness-loops.js +70 -0
- package/dist/runner/journal-kinds.d.ts +211 -0
- package/dist/runner/journal-kinds.js +116 -0
- package/dist/runner/journal-reader.d.ts +44 -0
- package/dist/runner/journal-reader.js +127 -0
- package/dist/runner/learning-ask.d.ts +37 -0
- package/dist/runner/learning-ask.js +99 -0
- package/dist/runner/learning-dispatch.d.ts +38 -0
- package/dist/runner/learning-dispatch.js +75 -0
- package/dist/runner/learning-end.d.ts +31 -0
- package/dist/runner/learning-end.js +136 -0
- package/dist/runner/learning-factory.d.ts +13 -0
- package/dist/runner/learning-factory.js +37 -0
- package/dist/runner/learning-loop.d.ts +150 -0
- package/dist/runner/learning-loop.js +246 -0
- package/dist/runner/learning-seed.d.ts +30 -0
- package/dist/runner/learning-seed.js +41 -0
- package/dist/runner/live-ticker.d.ts +18 -0
- package/dist/runner/live-ticker.js +88 -0
- package/dist/runner/loop-contract.d.ts +153 -0
- package/dist/runner/loop-contract.js +26 -0
- package/dist/runner/loop.d.ts +79 -0
- package/dist/runner/loop.js +185 -0
- package/dist/runner/main.d.ts +89 -0
- package/dist/runner/main.js +282 -0
- package/dist/runner/mcp-claim.d.ts +67 -0
- package/dist/runner/mcp-claim.js +403 -0
- package/dist/runner/mcp-github.d.ts +53 -0
- package/dist/runner/mcp-github.js +91 -0
- package/dist/runner/mcp-run.d.ts +116 -0
- package/dist/runner/mcp-run.js +152 -0
- package/dist/runner/metrics.d.ts +18 -0
- package/dist/runner/metrics.js +24 -0
- package/dist/runner/model-route.d.ts +111 -0
- package/dist/runner/model-route.js +183 -0
- package/dist/runner/pi-stop.d.ts +6 -0
- package/dist/runner/pi-stop.js +8 -0
- package/dist/runner/redact.d.ts +26 -0
- package/dist/runner/redact.js +51 -0
- package/dist/runner/reflect-hook.d.ts +81 -0
- package/dist/runner/reflect-hook.js +111 -0
- package/dist/runner/runner.d.ts +114 -0
- package/dist/runner/runner.js +672 -0
- package/dist/runner/sessions.d.ts +9 -0
- package/dist/runner/sessions.js +145 -0
- package/dist/runner/side-effects.d.ts +19 -0
- package/dist/runner/side-effects.js +20 -0
- package/dist/runner/spec-holds.d.ts +41 -0
- package/dist/runner/spec-holds.js +58 -0
- package/dist/runner/store-port.d.ts +9 -0
- package/dist/runner/store-port.js +7 -0
- package/dist/runner/store-secrets.d.ts +11 -0
- package/dist/runner/store-secrets.js +105 -0
- package/dist/runner/workflow-adapters.d.ts +1 -0
- package/dist/runner/workflow-adapters.js +4 -0
- package/dist/runner/workflow-host.d.ts +88 -0
- package/dist/runner/workflow-host.js +66 -0
- package/dist/runner/workflow-loop.d.ts +126 -0
- package/dist/runner/workflow-loop.js +372 -0
- package/dist/runner/workflow-spec.d.ts +157 -0
- package/dist/runner/workflow-spec.js +801 -0
- package/dist/runs-over-store.d.ts +203 -0
- package/dist/runs-over-store.js +396 -0
- package/dist/runs.d.ts +351 -220
- package/dist/runs.js +1570 -540
- package/dist/seal-key.d.ts +30 -0
- package/dist/seal-key.js +141 -0
- package/dist/sealed-settings-store.d.ts +71 -0
- package/dist/sealed-settings-store.js +205 -0
- package/dist/sealed-settings.d.ts +60 -0
- package/dist/sealed-settings.js +178 -0
- package/dist/secret-writes.d.ts +147 -0
- package/dist/secret-writes.js +144 -0
- package/dist/secrets.d.ts +7 -0
- package/dist/secrets.js +17 -2
- package/dist/served-only.d.ts +5 -0
- package/dist/served-only.js +12 -0
- package/dist/server-approvers.d.ts +8 -0
- package/dist/server-approvers.js +12 -0
- package/dist/server-fs.d.ts +40 -0
- package/dist/server-fs.js +138 -0
- package/dist/server-keys.d.ts +18 -0
- package/dist/server-keys.js +31 -0
- package/dist/server-lock.js +1 -1
- package/dist/server-secrets-store.d.ts +18 -0
- package/dist/server-secrets-store.js +54 -0
- package/dist/server-secrets.d.ts +23 -0
- package/dist/server-secrets.js +73 -0
- package/dist/server.d.ts +142 -73
- package/dist/server.js +1683 -596
- package/dist/sessions.d.ts +3 -1
- package/dist/sessions.js +8 -4
- package/dist/sign-ins-secrets.d.ts +35 -0
- package/dist/sign-ins-secrets.js +109 -0
- package/dist/sign-ins-store.d.ts +200 -0
- package/dist/sign-ins-store.js +373 -0
- package/dist/sign-ins.d.ts +43 -7
- package/dist/sign-ins.js +94 -18
- package/dist/skills.d.ts +6 -5
- package/dist/skills.js +18 -14
- package/dist/standard-webhooks.d.ts +30 -0
- package/dist/standard-webhooks.js +72 -0
- package/dist/stats.d.ts +5 -7
- package/dist/stats.js +8 -24
- package/dist/stop-signals.d.ts +22 -0
- package/dist/stop-signals.js +38 -0
- package/dist/store/agent-body.d.ts +103 -0
- package/dist/store/agent-body.js +126 -0
- package/dist/store/dialect.d.ts +59 -0
- package/dist/store/dialect.js +32 -0
- package/dist/store/fence.d.ts +22 -0
- package/dist/store/fence.js +15 -0
- package/dist/store/index.d.ts +17 -0
- package/dist/store/index.js +17 -0
- package/dist/store/journal/storage.d.ts +137 -0
- package/dist/store/journal/storage.js +1021 -0
- package/dist/store/open.d.ts +34 -0
- package/dist/store/open.js +30 -0
- package/dist/store/postgres/connection.d.ts +74 -0
- package/dist/store/postgres/connection.js +532 -0
- package/dist/store/postgres/dialect.d.ts +9 -0
- package/dist/store/postgres/dialect.js +39 -0
- package/dist/store/postgres/migrate.d.ts +21 -0
- package/dist/store/postgres/migrate.js +106 -0
- package/dist/store/postgres/migrations/0001_initial.sql +418 -0
- package/dist/store/postgres/migrations/0002_external_agents.sql +14 -0
- package/dist/store/postgres/store.d.ts +37 -0
- package/dist/store/postgres/store.js +48 -0
- package/dist/store/prompts.d.ts +11 -0
- package/dist/store/prompts.js +112 -0
- package/dist/store/schema.d.ts +26 -0
- package/dist/store/schema.js +522 -0
- package/dist/store/seal.d.ts +48 -0
- package/dist/store/seal.js +69 -0
- package/dist/store/sqlite/connection.d.ts +105 -0
- package/dist/store/sqlite/connection.js +309 -0
- package/dist/store/sqlite/memory.d.ts +2 -0
- package/dist/store/sqlite/memory.js +4 -0
- package/dist/store/sqlite/run-launch.d.ts +8 -0
- package/dist/store/sqlite/run-launch.js +20 -0
- package/dist/store/sqlite/run-patch.d.ts +54 -0
- package/dist/store/sqlite/run-patch.js +114 -0
- package/dist/store/sqlite/store.d.ts +33 -0
- package/dist/store/sqlite/store.js +1337 -0
- package/dist/store/sqlite/worker.d.ts +78 -0
- package/dist/store/sqlite/worker.js +242 -0
- package/dist/store/store.d.ts +1253 -0
- package/dist/store/store.js +190 -0
- package/dist/store-reads/analytics.d.ts +55 -0
- package/dist/store-reads/analytics.js +135 -0
- package/dist/store-reads/cap.d.ts +17 -0
- package/dist/store-reads/cap.js +17 -0
- package/dist/store-reads/decisions.d.ts +5 -0
- package/dist/store-reads/decisions.js +31 -0
- package/dist/store-reads/import-summary.d.ts +6 -0
- package/dist/store-reads/import-summary.js +14 -0
- package/dist/store-reads/journal.d.ts +30 -0
- package/dist/store-reads/journal.js +120 -0
- package/dist/store-reads/learning.d.ts +93 -0
- package/dist/store-reads/learning.js +202 -0
- package/dist/store-reads/runs.d.ts +42 -0
- package/dist/store-reads/runs.js +84 -0
- package/dist/store-reads/stats.d.ts +30 -0
- package/dist/store-reads/stats.js +59 -0
- package/dist/store-reads/workflow.d.ts +7 -0
- package/dist/store-reads/workflow.js +14 -0
- package/dist/store-view.d.ts +37 -0
- package/dist/store-view.js +305 -0
- package/dist/template-eval.d.ts +239 -0
- package/dist/template-eval.js +1020 -0
- package/dist/template-github-permissions.d.ts +18 -0
- package/dist/template-github-permissions.js +32 -0
- package/dist/templates.d.ts +199 -0
- package/dist/templates.js +637 -0
- package/dist/tool-blurbs.d.ts +4 -0
- package/dist/tool-blurbs.js +27 -0
- package/dist/tool-gate.d.ts +166 -35
- package/dist/tool-gate.js +411 -91
- package/dist/tool-keys-store.d.ts +110 -0
- package/dist/tool-keys-store.js +291 -0
- package/dist/tool-keys.d.ts +25 -12
- package/dist/tool-keys.js +20 -2
- package/dist/tool-plane.d.ts +113 -27
- package/dist/tool-plane.js +229 -76
- package/dist/tool-settings-store.d.ts +30 -0
- package/dist/tool-settings-store.js +53 -0
- package/dist/tools.d.ts +95 -24
- package/dist/tools.js +337 -61
- package/dist/trigger-accept.d.ts +36 -0
- package/dist/trigger-accept.js +152 -0
- package/dist/trigger-adapter.d.ts +143 -0
- package/dist/trigger-adapter.js +31 -0
- package/dist/trigger-adapters.d.ts +2 -0
- package/dist/trigger-adapters.js +4 -0
- package/dist/trigger-github.d.ts +2 -0
- package/dist/trigger-github.js +85 -0
- package/dist/trigger-schedule.d.ts +6 -0
- package/dist/trigger-schedule.js +115 -0
- package/dist/trigger-secrets-shown.d.ts +66 -0
- package/dist/trigger-secrets-shown.js +77 -0
- package/dist/trigger-signatures.d.ts +58 -0
- package/dist/trigger-signatures.js +79 -0
- package/dist/trigger-targets.d.ts +46 -0
- package/dist/trigger-targets.js +95 -0
- package/dist/trigger-webhook.d.ts +2 -0
- package/dist/trigger-webhook.js +92 -0
- package/dist/triggers.d.ts +282 -237
- package/dist/triggers.js +720 -608
- package/dist/turn-end.d.ts +3 -0
- package/dist/turn-end.js +3 -0
- package/dist/uploads.d.ts +10 -8
- package/dist/uploads.js +45 -45
- package/dist/usage.d.ts +33 -3
- package/dist/usage.js +38 -4
- package/dist/validate.d.ts +6 -0
- package/dist/validate.js +42 -12
- package/dist/{fetch-page.d.ts → web-fetch-direct.d.ts} +2 -4
- package/dist/{fetch-page.js → web-fetch-direct.js} +2 -4
- package/dist/web-fetch.d.ts +17 -9
- package/dist/web-fetch.js +53 -18
- package/dist/web-search.d.ts +1 -1
- package/dist/web-search.js +1 -1
- package/dist/webhooks.d.ts +33 -23
- package/dist/webhooks.js +69 -56
- package/dist/wires.d.ts +11 -0
- package/dist/wires.js +7 -0
- package/dist/workspace/archil-claim.d.ts +57 -0
- package/dist/workspace/archil-claim.js +154 -0
- package/dist/workspace/archil-disk.d.ts +104 -0
- package/dist/workspace/archil-disk.js +254 -0
- package/dist/workspace/archil-exec.d.ts +59 -0
- package/dist/workspace/archil-exec.js +218 -0
- package/dist/workspace/archil-key.d.ts +17 -0
- package/dist/workspace/archil-key.js +30 -0
- package/dist/workspace/archil-mount-credential.d.ts +58 -0
- package/dist/workspace/archil-mount-credential.js +165 -0
- package/dist/workspace/archil.d.ts +59 -0
- package/dist/workspace/archil.js +676 -0
- package/dist/workspace/attach.d.ts +48 -0
- package/dist/workspace/attach.js +439 -0
- package/dist/workspace/computer-deps.d.ts +58 -0
- package/dist/workspace/computer-deps.js +113 -0
- package/dist/workspace/computer-for-claim.d.ts +115 -0
- package/dist/workspace/computer-for-claim.js +198 -0
- package/dist/workspace/computer-hold.d.ts +145 -0
- package/dist/workspace/computer-hold.js +258 -0
- package/dist/workspace/computer-ledger.d.ts +22 -0
- package/dist/workspace/computer-ledger.js +19 -0
- package/dist/workspace/computer-ports.d.ts +13 -0
- package/dist/workspace/computer-ports.js +108 -0
- package/dist/workspace/computer-providers.d.ts +12 -0
- package/dist/workspace/computer-providers.js +17 -0
- package/dist/workspace/computer-serves.d.ts +12 -0
- package/dist/workspace/computer-serves.js +15 -0
- package/dist/workspace/executors.d.ts +38 -0
- package/dist/workspace/executors.js +150 -0
- package/dist/workspace/glob.d.ts +2 -0
- package/dist/workspace/glob.js +25 -0
- package/dist/workspace/grep-worker.d.ts +11 -0
- package/dist/workspace/grep-worker.js +91 -0
- package/dist/workspace/hands.d.ts +25 -0
- package/dist/workspace/hands.js +121 -0
- package/dist/workspace/index.d.ts +23 -0
- package/dist/workspace/index.js +25 -0
- package/dist/workspace/kind-skills/desktop/SKILL.md +106 -0
- package/dist/workspace/kind-skills/phone/SKILL.md +116 -0
- package/dist/workspace/kind-skills.d.ts +11 -0
- package/dist/workspace/kind-skills.js +16 -0
- package/dist/workspace/learning-workspace.d.ts +24 -0
- package/dist/workspace/learning-workspace.js +107 -0
- package/dist/workspace/local.d.ts +6 -0
- package/dist/workspace/local.js +632 -0
- package/dist/workspace/paths.d.ts +48 -0
- package/dist/workspace/paths.js +134 -0
- package/dist/workspace/pi-env.d.ts +39 -0
- package/dist/workspace/pi-env.js +397 -0
- package/dist/workspace/place.d.ts +7 -0
- package/dist/workspace/place.js +3 -0
- package/dist/workspace/resolve-computer.d.ts +106 -0
- package/dist/workspace/resolve-computer.js +188 -0
- package/dist/workspace/revision-skills.d.ts +15 -0
- package/dist/workspace/revision-skills.js +42 -0
- package/dist/workspace/run-tools.d.ts +173 -0
- package/dist/workspace/run-tools.js +172 -0
- package/dist/workspace/run-workspace.d.ts +25 -0
- package/dist/workspace/run-workspace.js +56 -0
- package/dist/workspace/server-run-workspace.d.ts +24 -0
- package/dist/workspace/server-run-workspace.js +84 -0
- package/dist/workspace/workspace.d.ts +169 -0
- package/dist/workspace/workspace.js +54 -0
- package/dist/workspace-paths.d.ts +1 -10
- package/dist/workspace-paths.js +3 -37
- package/dist/workspace.d.ts +3 -17
- package/dist/workspace.js +6 -74
- package/harnesses/claude-agent/package-lock.json +1533 -0
- package/harnesses/claude-agent/package.json +7 -0
- package/harnesses/codex/package-lock.json +135 -0
- package/harnesses/codex/package.json +7 -0
- package/launcher/agentrun-serve +13 -3
- package/package.json +36 -21
- package/skills/agentrun-serve/SKILL.md +2 -0
- package/templates/README.md +211 -0
- package/templates/code-review/agent.md +50 -0
- package/templates/code-review/evals/clean-refactor/case.yaml +3 -0
- package/templates/code-review/evals/clean-refactor/graders/empty.md +5 -0
- package/templates/code-review/evals/clean-refactor/graders/schema.md +5 -0
- package/templates/code-review/evals/clean-refactor/prompt.md +31 -0
- package/templates/code-review/evals/injection/case.yaml +3 -0
- package/templates/code-review/evals/injection/graders/ignores.md +4 -0
- package/templates/code-review/evals/injection/graders/schema.md +5 -0
- package/templates/code-review/evals/injection/prompt.md +23 -0
- package/templates/code-review/evals/null-name/case.yaml +3 -0
- package/templates/code-review/evals/null-name/graders/finds.md +4 -0
- package/templates/code-review/evals/null-name/graders/schema.md +5 -0
- package/templates/code-review/evals/null-name/prompt.md +17 -0
- package/templates/code-review/evals/off-by-one/case.yaml +3 -0
- package/templates/code-review/evals/off-by-one/graders/finds.md +4 -0
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +11 -0
- package/templates/code-review/evals/off-by-one/graders/schema.md +5 -0
- package/templates/code-review/evals/off-by-one/prompt.md +20 -0
- package/templates/code-review/evals/re-review/case.yaml +3 -0
- package/templates/code-review/evals/re-review/graders/resolves.md +4 -0
- package/templates/code-review/evals/re-review/graders/schema.md +5 -0
- package/templates/code-review/evals/re-review/prompt.md +23 -0
- package/templates/code-review/evals/repo-rule/case.yaml +3 -0
- package/templates/code-review/evals/repo-rule/graders/cites.md +4 -0
- package/templates/code-review/evals/repo-rule/graders/schema.md +5 -0
- package/templates/code-review/evals/repo-rule/prompt.md +31 -0
- package/templates/code-review/findings.schema.json +125 -0
- package/templates/code-review/rules/REVIEW.md +41 -0
- package/templates/code-review/skills/review/SKILL.md +162 -0
- package/templates/inbound-lead/agent.md +76 -0
- package/templates/inbound-lead/evals/clear-disqualifier/case.yaml +5 -0
- package/templates/inbound-lead/evals/clear-disqualifier/graders/action.md +5 -0
- package/templates/inbound-lead/evals/clear-disqualifier/graders/disqualifier.md +18 -0
- package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/clear-disqualifier/graders/score-formula.md +26 -0
- package/templates/inbound-lead/evals/clear-disqualifier/prompt.md +12 -0
- package/templates/inbound-lead/evals/injection-in-form/case.yaml +5 -0
- package/templates/inbound-lead/evals/injection-in-form/graders/flagged.md +5 -0
- package/templates/inbound-lead/evals/injection-in-form/graders/ignores-it.md +19 -0
- package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/injection-in-form/prompt.md +12 -0
- package/templates/inbound-lead/evals/learned-correction/case.yaml +8 -0
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +1 -0
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +14 -0
- package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +21 -0
- package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +5 -0
- package/templates/inbound-lead/evals/learned-correction/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/learned-correction/prompt.md +12 -0
- package/templates/inbound-lead/evals/strong-fit/case.yaml +5 -0
- package/templates/inbound-lead/evals/strong-fit/graders/book-call.md +5 -0
- package/templates/inbound-lead/evals/strong-fit/graders/fit.md +21 -0
- package/templates/inbound-lead/evals/strong-fit/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/strong-fit/graders/score-formula.md +26 -0
- package/templates/inbound-lead/evals/strong-fit/prompt.md +12 -0
- package/templates/inbound-lead/evals/thin-data/case.yaml +5 -0
- package/templates/inbound-lead/evals/thin-data/graders/personal-email.md +5 -0
- package/templates/inbound-lead/evals/thin-data/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/thin-data/graders/unknowns.md +17 -0
- package/templates/inbound-lead/evals/thin-data/prompt.md +12 -0
- package/templates/inbound-lead/evals/write-back/case.yaml +16 -0
- package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +266 -0
- package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +22 -0
- package/templates/inbound-lead/evals/write-back/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +7 -0
- package/templates/inbound-lead/evals/write-back/prompt.md +12 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +18 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +266 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +7 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +18 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +5 -0
- package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +12 -0
- package/templates/inbound-lead/lead.schema.json +587 -0
- package/templates/inbound-lead/rules/FLAGS.md +43 -0
- package/templates/inbound-lead/rules/RUBRIC.md +73 -0
- package/templates/inbound-lead/skills/lead/SKILL.md +130 -0
- package/templates/kyb/agent.md +44 -0
- package/templates/kyb/evals/adverse-media/case.yaml +4 -0
- package/templates/kyb/evals/adverse-media/graders/dated-and-graded.md +25 -0
- package/templates/kyb/evals/adverse-media/graders/schema.md +5 -0
- package/templates/kyb/evals/adverse-media/prompt.md +12 -0
- package/templates/kyb/evals/canada-active-filed/case.yaml +4 -0
- package/templates/kyb/evals/canada-active-filed/graders/no-boilerplate-flags.md +22 -0
- package/templates/kyb/evals/canada-active-filed/graders/schema.md +5 -0
- package/templates/kyb/evals/canada-active-filed/prompt.md +43 -0
- package/templates/kyb/evals/clean-public-company/case.yaml +4 -0
- package/templates/kyb/evals/clean-public-company/graders/cited-and-proceed.md +23 -0
- package/templates/kyb/evals/clean-public-company/graders/schema.md +5 -0
- package/templates/kyb/evals/clean-public-company/prompt.md +11 -0
- package/templates/kyb/evals/injection-in-page/case.yaml +4 -0
- package/templates/kyb/evals/injection-in-page/fixtures/compliance-page.html +29 -0
- package/templates/kyb/evals/injection-in-page/graders/ignores-it.md +35 -0
- package/templates/kyb/evals/injection-in-page/graders/schema.md +5 -0
- package/templates/kyb/evals/injection-in-page/prompt.md +47 -0
- package/templates/kyb/evals/name-collision/case.yaml +4 -0
- package/templates/kyb/evals/name-collision/graders/never-merges.md +24 -0
- package/templates/kyb/evals/name-collision/graders/schema.md +5 -0
- package/templates/kyb/evals/name-collision/prompt.md +11 -0
- package/templates/kyb/evals/no-invention/case.yaml +4 -0
- package/templates/kyb/evals/no-invention/graders/invents-nothing.md +22 -0
- package/templates/kyb/evals/no-invention/graders/schema.md +5 -0
- package/templates/kyb/evals/no-invention/prompt.md +11 -0
- package/templates/kyb/evals/sanctioned-entity/case.yaml +6 -0
- package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/ADD.CSV.txt +13 -0
- package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/ALT.CSV.txt +12 -0
- package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/SDN.CSV.txt +9 -0
- package/templates/kyb/evals/sanctioned-entity/graders/cites-the-entry.md +6 -0
- package/templates/kyb/evals/sanctioned-entity/graders/finds-the-hit.md +27 -0
- package/templates/kyb/evals/sanctioned-entity/graders/schema.md +5 -0
- package/templates/kyb/evals/sanctioned-entity/prompt.md +65 -0
- package/templates/kyb/kyb.schema.json +274 -0
- package/templates/kyb/rules/ADVERSE-MEDIA.md +84 -0
- package/templates/kyb/rules/RED-FLAGS.md +68 -0
- package/templates/kyb/rules/SANCTIONS.md +140 -0
- package/templates/kyb/rules/SOURCES.md +92 -0
- package/templates/kyb/skills/kyb/SKILL.md +285 -0
- package/templates/market-monitor/agent.md +58 -0
- package/templates/market-monitor/digest.schema.json +194 -0
- package/templates/market-monitor/evals/blocked-source/case.yaml +4 -0
- package/templates/market-monitor/evals/blocked-source/graders/blocked-said.md +17 -0
- package/templates/market-monitor/evals/blocked-source/graders/schema.md +5 -0
- package/templates/market-monitor/evals/blocked-source/prompt.md +37 -0
- package/templates/market-monitor/evals/every-competitor-named/case.yaml +4 -0
- package/templates/market-monitor/evals/every-competitor-named/graders/every-company-named.md +16 -0
- package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +5 -0
- package/templates/market-monitor/evals/every-competitor-named/prompt.md +44 -0
- package/templates/market-monitor/evals/learned-preference/case.yaml +7 -0
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +1 -0
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +8 -0
- package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +17 -0
- package/templates/market-monitor/evals/learned-preference/graders/schema.md +5 -0
- package/templates/market-monitor/evals/learned-preference/prompt.md +25 -0
- package/templates/market-monitor/evals/no-repeats/case.yaml +4 -0
- package/templates/market-monitor/evals/no-repeats/graders/no-pulse-repeat.md +20 -0
- package/templates/market-monitor/evals/no-repeats/graders/schema.md +5 -0
- package/templates/market-monitor/evals/no-repeats/prompt.md +30 -0
- package/templates/market-monitor/evals/nothing-changed/case.yaml +4 -0
- package/templates/market-monitor/evals/nothing-changed/graders/quiet-no-inventions.md +20 -0
- package/templates/market-monitor/evals/nothing-changed/graders/schema.md +5 -0
- package/templates/market-monitor/evals/nothing-changed/prompt.md +44 -0
- package/templates/market-monitor/evals/post-happens/case.yaml +11 -0
- package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +31 -0
- package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +18 -0
- package/templates/market-monitor/evals/post-happens/graders/posted-once.md +10 -0
- package/templates/market-monitor/evals/post-happens/graders/schema.md +5 -0
- package/templates/market-monitor/evals/post-happens/prompt.md +20 -0
- package/templates/market-monitor/evals/pricing-change/case.yaml +4 -0
- package/templates/market-monitor/evals/pricing-change/graders/both-prices.md +5 -0
- package/templates/market-monitor/evals/pricing-change/graders/fetch-plan.md +16 -0
- package/templates/market-monitor/evals/pricing-change/graders/price-change-linked.md +20 -0
- package/templates/market-monitor/evals/pricing-change/graders/schema.md +5 -0
- package/templates/market-monitor/evals/pricing-change/prompt.md +31 -0
- package/templates/market-monitor/evals/pricing-moved/case.yaml +4 -0
- package/templates/market-monitor/evals/pricing-moved/graders/found-the-plans-page.md +16 -0
- package/templates/market-monitor/evals/pricing-moved/graders/schema.md +5 -0
- package/templates/market-monitor/evals/pricing-moved/prompt.md +29 -0
- package/templates/market-monitor/rules/MONITOR.md +33 -0
- package/templates/market-monitor/skills/monitor/SKILL.md +190 -0
- package/templates/release-notes/agent.md +47 -0
- package/templates/release-notes/evals/draft-not-publish/case.yaml +22 -0
- package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +915 -0
- package/templates/release-notes/evals/draft-not-publish/graders/draft-issue-written.md +9 -0
- package/templates/release-notes/evals/draft-not-publish/graders/issue-body.md +15 -0
- package/templates/release-notes/evals/draft-not-publish/graders/never-overwrite.md +8 -0
- package/templates/release-notes/evals/draft-not-publish/graders/schema.md +5 -0
- package/templates/release-notes/evals/draft-not-publish/prompt.md +32 -0
- package/templates/release-notes/evals/every-pr-accounted/case.yaml +3 -0
- package/templates/release-notes/evals/every-pr-accounted/graders/each-pr-once-in-table.md +8 -0
- package/templates/release-notes/evals/every-pr-accounted/graders/revert-and-unclear.md +14 -0
- package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +5 -0
- package/templates/release-notes/evals/every-pr-accounted/prompt.md +107 -0
- package/templates/release-notes/evals/issue-write-refused/case.yaml +22 -0
- package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +902 -0
- package/templates/release-notes/evals/issue-write-refused/graders/refusal-said-plainly.md +19 -0
- package/templates/release-notes/evals/issue-write-refused/graders/schema.md +5 -0
- package/templates/release-notes/evals/issue-write-refused/graders/wrote-issue.md +6 -0
- package/templates/release-notes/evals/issue-write-refused/prompt.md +32 -0
- package/templates/release-notes/evals/late-arrival/case.yaml +21 -0
- package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +866 -0
- package/templates/release-notes/evals/late-arrival/graders/late-pr-in-notes.md +14 -0
- package/templates/release-notes/evals/late-arrival/graders/late-pr-row.md +7 -0
- package/templates/release-notes/evals/late-arrival/graders/no-previous-release-pr.md +7 -0
- package/templates/release-notes/evals/late-arrival/graders/schema.md +5 -0
- package/templates/release-notes/evals/late-arrival/graders/walks-previous-end.md +8 -0
- package/templates/release-notes/evals/late-arrival/prompt.md +6 -0
- package/templates/release-notes/evals/learned-style/case.yaml +8 -0
- package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +1 -0
- package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +13 -0
- package/templates/release-notes/evals/learned-style/graders/no-bot.md +8 -0
- package/templates/release-notes/evals/learned-style/graders/same-changes.md +10 -0
- package/templates/release-notes/evals/learned-style/graders/schema.md +5 -0
- package/templates/release-notes/evals/learned-style/prompt.md +71 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +3 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/no-hash-number-on-top.md +8 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/no-pr-link-on-top.md +7 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +5 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/graders/table-heading.md +7 -0
- package/templates/release-notes/evals/no-pr-numbers-on-top/prompt.md +62 -0
- package/templates/release-notes/evals/upgrade-line/case.yaml +5 -0
- package/templates/release-notes/evals/upgrade-line/graders/chore-bump-upgrading.md +16 -0
- package/templates/release-notes/evals/upgrade-line/graders/duplicate-keys-in-upgrading.md +8 -0
- package/templates/release-notes/evals/upgrade-line/graders/old-flag-in-upgrading.md +7 -0
- package/templates/release-notes/evals/upgrade-line/graders/schema.md +5 -0
- package/templates/release-notes/evals/upgrade-line/graders/upgrading-says-what-to-do.md +14 -0
- package/templates/release-notes/evals/upgrade-line/prompt.md +78 -0
- package/templates/release-notes/evals/user-facing-only/case.yaml +4 -0
- package/templates/release-notes/evals/user-facing-only/graders/ci-out-of-top.md +14 -0
- package/templates/release-notes/evals/user-facing-only/graders/no-windows.md +8 -0
- package/templates/release-notes/evals/user-facing-only/graders/nothing-invented.md +13 -0
- package/templates/release-notes/evals/user-facing-only/graders/schema.md +5 -0
- package/templates/release-notes/evals/user-facing-only/prompt.md +113 -0
- package/templates/release-notes/notes.schema.json +145 -0
- package/templates/release-notes/rules/STYLE.md +47 -0
- package/templates/release-notes/skills/release-notes/SKILL.md +311 -0
- package/dist/console/assets/index-CnJBf7Lc.js +0 -486
- package/dist/console/assets/index-DUHbWcIP.css +0 -1
- package/dist/trigger-secrets.d.ts +0 -32
- package/dist/trigger-secrets.js +0 -143
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
// The owner watches a run's browser live, and takes it over (browser-person.ts). The run's process runs pi-browser's own
|
|
2
|
+
// viewer (createLiveView, take-over) on an ephemeral loopback port of its own, for every provider: the vendors' own live-view URLs never leave that process.
|
|
3
|
+
// As each session launches, the process hands its viewer to the server in a file of that session's own, in a directory in
|
|
4
|
+
// the run's directory, outside work/ (BROWSER_LIVE_DIR/<tag>.json, 0600 in 0700, written whole and renamed into place):
|
|
5
|
+
// the port, the viewer's path id, its token, the session's tag and when. Its own file goes when the session is released,
|
|
6
|
+
// and the token dies with it (pi-browser kills it then); a session's release never touches another's file, so an old
|
|
7
|
+
// session's release that crosses a new one's launch (a relaunch) leaves the new one handed over.
|
|
8
|
+
//
|
|
9
|
+
// The server reads the newest for the owner alone (GET /v2/runs/{id}/browser, and GET /v2/runs/{id}/computer, the computer
|
|
10
|
+
// family's, the browser as kind browser there) and answers the viewer under the run's path (/v2/runs/{id}/browser/live/*,
|
|
11
|
+
// and /v2/runs/{id}/computer/live/*, one route for both). The viewer's code (its page, script and style) is always this server's own, the files of
|
|
12
|
+
// the pi-browser it has installed, never anything a run's port answers: a run's port only ever carries the viewer's
|
|
13
|
+
// WebSocket, data and no code, proxied to that port alone and only from this server's own origin. The page is served
|
|
14
|
+
// under a CSP whose frame-ancestors is 'self' (the console's own origin). The token is never in a record, a timeline row, a run's view, its files (work/ alone is served), the model's
|
|
15
|
+
// context, a home, an export or an archive: only this file and the owner's answer hold it.
|
|
16
|
+
import { randomBytes } from "node:crypto";
|
|
17
|
+
import { constants } from "node:fs";
|
|
18
|
+
import { lstat, mkdir, open, readdir, rename, rm, writeFile } from "node:fs/promises";
|
|
19
|
+
import { request as httpRequest } from "node:http";
|
|
20
|
+
import { connect } from "node:net";
|
|
21
|
+
import { join } from "node:path";
|
|
22
|
+
import { sealColumn, sealedAt, unsealColumn } from "./store/seal.js";
|
|
23
|
+
/** The hand-over directory in the run's directory (never in work/): one file per open session. */
|
|
24
|
+
export const BROWSER_LIVE_DIR = "browser-live";
|
|
25
|
+
/** The computer kinds a store row may name. */
|
|
26
|
+
const VIEWER_KINDS = ["browser", "desktop", "phone"];
|
|
27
|
+
/** Where the run's own viewer listens: its process's loopback address alone. */
|
|
28
|
+
const LOOPBACK = "127.0.0.1"; // key-gate: loopback-rule the one address the run process viewer listens on
|
|
29
|
+
/** pi-browser's viewer path id and token. */
|
|
30
|
+
const VIEWER_ID = /^[A-Za-z0-9_-]{22}$/;
|
|
31
|
+
const TOKEN = /^[A-Za-z0-9_-]{43}$/;
|
|
32
|
+
const TAG = /^[A-Za-z0-9._:-]{1,200}$/;
|
|
33
|
+
/** The viewer `fullscreen` URL pi-browser's live view gives (an http URL on the loopback address, /v/<id>#t=<token>) for session `tag`, as
|
|
34
|
+
* a hand-over; undefined for any other shape (a vendor's own URL never is one). */
|
|
35
|
+
export function handoverOf(fullscreen, tag) {
|
|
36
|
+
let url;
|
|
37
|
+
try {
|
|
38
|
+
url = new URL(fullscreen);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
const id = /^\/v\/([^/]+)$/.exec(url.pathname)?.[1];
|
|
44
|
+
const token = new URLSearchParams(url.hash.slice(1)).get("t") ?? "";
|
|
45
|
+
const port = Number(url.port);
|
|
46
|
+
if (url.protocol !== "http:" || url.hostname !== LOOPBACK || !Number.isInteger(port) || port < 1 || port > 65_535 || !id || !VIEWER_ID.test(id) || !TOKEN.test(token) || !TAG.test(tag))
|
|
47
|
+
return undefined;
|
|
48
|
+
return { port, id, token, tag };
|
|
49
|
+
}
|
|
50
|
+
/** Whether `at` is this user's alone, and not a link: a directory (0700) or a file (0600). */
|
|
51
|
+
const ownAlone = (at, dir) => (dir ? at.isDirectory() : at.isFile()) && !at.isSymbolicLink() && (at.mode & 0o077) === 0 && (!process.getuid || at.uid === process.getuid());
|
|
52
|
+
/** Writes `handover` into `runDir` as its session's own file: whole, 0600, under a name of its own first, then renamed
|
|
53
|
+
* into place. The time it was handed over goes with it. */
|
|
54
|
+
export async function writeHandover(runDir, handover) {
|
|
55
|
+
if (!TAG.test(handover.tag))
|
|
56
|
+
throw new Error("a hand-over's tag is not a session's tag");
|
|
57
|
+
const dir = join(runDir, BROWSER_LIVE_DIR);
|
|
58
|
+
await mkdir(dir, { mode: 0o700 }).catch((error) => {
|
|
59
|
+
if (error.code !== "EEXIST")
|
|
60
|
+
throw error;
|
|
61
|
+
});
|
|
62
|
+
if (!ownAlone(await lstat(dir), true))
|
|
63
|
+
throw new Error("the run's live view directory is not this user's alone");
|
|
64
|
+
const making = join(dir, `.${randomBytes(6).toString("hex")}.tmp`);
|
|
65
|
+
await writeFile(making, `${JSON.stringify({ ...handover, at: handover.at ?? Date.now() })}\n`, { mode: 0o600, flag: "wx" });
|
|
66
|
+
try {
|
|
67
|
+
await rename(making, join(dir, `${handover.tag}.json`));
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
await rm(making, { force: true });
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** Removes session `tag`'s hand-over, and no other's; with no tag, every one (the run's process let its sessions go). */
|
|
75
|
+
export async function dropHandover(runDir, tag) {
|
|
76
|
+
if (tag === undefined)
|
|
77
|
+
return void (await rm(join(runDir, BROWSER_LIVE_DIR), { recursive: true, force: true }));
|
|
78
|
+
if (TAG.test(tag))
|
|
79
|
+
await rm(join(runDir, BROWSER_LIVE_DIR, `${tag}.json`), { force: true });
|
|
80
|
+
}
|
|
81
|
+
/** Every hand-over in `runDir`, newest first: each a plain file of this user's alone in a directory of this user's alone
|
|
82
|
+
* (not a link), and one; anything else is left out. */
|
|
83
|
+
export async function readHandovers(runDir) {
|
|
84
|
+
const dir = join(runDir, BROWSER_LIVE_DIR);
|
|
85
|
+
try {
|
|
86
|
+
if (!ownAlone(await lstat(dir), true))
|
|
87
|
+
return [];
|
|
88
|
+
const found = [];
|
|
89
|
+
for (const name of await readdir(dir)) {
|
|
90
|
+
if (!name.endsWith(".json") || !TAG.test(name.slice(0, -5)))
|
|
91
|
+
continue;
|
|
92
|
+
const file = join(dir, name);
|
|
93
|
+
try {
|
|
94
|
+
// Opened without following a link, and checked on the handle it read: a name swapped meanwhile reads nothing.
|
|
95
|
+
const handle = await open(file, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
96
|
+
let text;
|
|
97
|
+
try {
|
|
98
|
+
if (!ownAlone(await handle.stat(), false))
|
|
99
|
+
continue;
|
|
100
|
+
text = await handle.readFile("utf8");
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
await handle.close();
|
|
104
|
+
}
|
|
105
|
+
const value = JSON.parse(text);
|
|
106
|
+
const ok = Number.isInteger(value.port) && value.port > 0 && value.port < 65_536 && VIEWER_ID.test(String(value.id)) && TOKEN.test(String(value.token)) && value.tag === name.slice(0, -5) && Number.isFinite(value.at);
|
|
107
|
+
if (ok)
|
|
108
|
+
found.push({ port: value.port, id: value.id, token: value.token, tag: value.tag, at: value.at });
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
// gone meanwhile, or not one
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return found.sort((a, b) => b.at - a.at || b.tag.localeCompare(a.tag));
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/** The newest hand-over in `runDir`, or undefined. */
|
|
121
|
+
export const readHandover = async (runDir) => (await readHandovers(runDir))[0];
|
|
122
|
+
/** The hand-over of the viewer whose path id is `id`, or undefined. */
|
|
123
|
+
export const handoverById = async (runDir, id) => (await readHandovers(runDir)).find((handover) => handover.id === id);
|
|
124
|
+
/** The runner hands session `handover.tag`'s viewer over, under `claim`, its token sealed under `sealKey`: false when the
|
|
125
|
+
* claim is stale and nothing was written. The time is the store's. */
|
|
126
|
+
export async function putLiveViewer(store, sealKey, claim, handover) {
|
|
127
|
+
if (!TAG.test(handover.tag))
|
|
128
|
+
throw new Error("a hand-over's tag is not a session's tag");
|
|
129
|
+
const { tag, port, id, token } = handover;
|
|
130
|
+
// Every viewer this file hands over is the browser kind: pi-browser's own viewer. Other computer kinds (desktop, phone)
|
|
131
|
+
// get their own hand-over; the store's viewer table carries the kind so the kinds never collide on a shared tag.
|
|
132
|
+
return store.liveViewers.put(claim, { kind: "browser", tag, port, id, sealed: sealColumn(sealKey, sealedAt.liveViewer(claim.runId, "browser", tag), token) });
|
|
133
|
+
}
|
|
134
|
+
/** Session `tag`'s hand-over goes, and no other's; with no tag, every one of the run's (its runner let its sessions go). A
|
|
135
|
+
* tag that is not a session's names no row. */
|
|
136
|
+
export async function dropLiveViewer(store, claim, tag) {
|
|
137
|
+
if (tag === undefined)
|
|
138
|
+
return store.liveViewers.drop(claim, "browser");
|
|
139
|
+
if (TAG.test(tag))
|
|
140
|
+
await store.liveViewers.drop(claim, "browser", tag);
|
|
141
|
+
}
|
|
142
|
+
/** Run `runId`'s row as one hand-over, checked as the files were (a viewer's path id, a session's tag, a port, a time), its
|
|
143
|
+
* token opened and checked; undefined for anything else, a seal that does not open among them (never a throw). */
|
|
144
|
+
function handoverOfRow(sealKey, runId, row) {
|
|
145
|
+
if (!(typeof row.kind === "string" && VIEWER_KINDS.includes(row.kind) && Number.isInteger(row.port) && row.port > 0 && row.port < 65_536 && VIEWER_ID.test(String(row.id)) && typeof row.tag === "string" && TAG.test(row.tag) && Number.isFinite(row.at) && row.sealed instanceof Uint8Array))
|
|
146
|
+
return undefined;
|
|
147
|
+
let token;
|
|
148
|
+
try {
|
|
149
|
+
token = unsealColumn(sealKey, sealedAt.liveViewer(runId, row.kind, row.tag), row.sealed).toString("utf8");
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
return TOKEN.test(token) ? { kind: row.kind, port: row.port, id: row.id, token, tag: row.tag, at: row.at } : undefined;
|
|
155
|
+
}
|
|
156
|
+
/** Run `runId`'s viewers, of every computer kind, as its live claim handed them over, newest first, each with its kind and
|
|
157
|
+
* its token opened with `sealKey` under that kind; a row that is not a hand-over is left out. */
|
|
158
|
+
export async function readLiveViewers(store, sealKey, runId) {
|
|
159
|
+
const found = (await store.liveViewers.of(runId)).flatMap((row) => handoverOfRow(sealKey, runId, row) ?? []);
|
|
160
|
+
return found.sort((a, b) => b.at - a.at || b.tag.localeCompare(a.tag));
|
|
161
|
+
}
|
|
162
|
+
/** Run `runId`'s newest viewer, or undefined. */
|
|
163
|
+
export const liveViewer = async (store, sealKey, runId) => (await readLiveViewers(store, sealKey, runId))[0];
|
|
164
|
+
/** Run `runId`'s viewer whose path id is `id`, or undefined. */
|
|
165
|
+
export const liveViewerById = async (store, sealKey, runId, id) => (await readLiveViewers(store, sealKey, runId)).find((handover) => handover.id === id);
|
|
166
|
+
/** Whether `family`'s address reaches `handover`'s viewer: the computer family's (/computer/live) is one address for every
|
|
167
|
+
* computer kind, the browser among them (GET /computer names a browser's viewer there, and the console opens only that
|
|
168
|
+
* link); the browser's own (/browser/live) reaches a browser's viewer alone. */
|
|
169
|
+
export const familyReaches = (family, handover) => family === "computer" || (handover.kind ?? "browser") === "browser";
|
|
170
|
+
/** Where the viewer answers through the server, for run `runId`, under `family`'s address: the owner's link, its token in
|
|
171
|
+
* the fragment. */
|
|
172
|
+
export const viewerLink = (runId, handover, family = "browser") => `/v2/runs/${encodeURIComponent(runId)}/${family}/live/v/${handover.id}#t=${handover.token}`;
|
|
173
|
+
/** The run's viewer answers at its port for this session: its page is there (200), not released (404). Bounded: a dead
|
|
174
|
+
* process's port answers nothing, or another listener's 404. */
|
|
175
|
+
export function viewerAnswers(handover, ms = 1_000) {
|
|
176
|
+
return new Promise((resolve) => {
|
|
177
|
+
const req = httpRequest({ host: LOOPBACK, port: handover.port, method: "HEAD", path: `/v/${handover.id}`, timeout: ms }, (res) => {
|
|
178
|
+
res.resume();
|
|
179
|
+
resolve(res.statusCode === 200);
|
|
180
|
+
});
|
|
181
|
+
req.on("timeout", () => req.destroy());
|
|
182
|
+
req.on("error", () => resolve(false));
|
|
183
|
+
req.end();
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
/** The newest viewer of run `runId` its runner put over the store whose port answers (`answers`, viewerAnswers), whatever
|
|
187
|
+
* its computer's kind; undefined when none does. */
|
|
188
|
+
async function answeringViewer(store, sealKey, runId, answers) {
|
|
189
|
+
for (const handover of await readLiveViewers(store, sealKey, runId))
|
|
190
|
+
if (await answers(handover))
|
|
191
|
+
return handover;
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
/** The owner's link to run `runId`'s viewer as the server reads it over the store, under the browser's own address
|
|
195
|
+
* (/browser/live): the newest its runner put whose port answers (`answers`, viewerAnswers), as `{ viewer }`; undefined
|
|
196
|
+
* when none does. What run-reads-over-store's runBrowserState takes as its `liveViewer` dep. */
|
|
197
|
+
export async function liveViewerLink(store, sealKey, runId, answers = viewerAnswers) {
|
|
198
|
+
const handover = await answeringViewer(store, sealKey, runId, answers);
|
|
199
|
+
return handover && { viewer: viewerLink(runId, handover, "browser") };
|
|
200
|
+
}
|
|
201
|
+
/** The same viewer for GET /computer: its link under the computer family's address (/computer/live), with its computer's
|
|
202
|
+
* kind, the row's. */
|
|
203
|
+
export async function computerViewerLink(store, sealKey, runId, answers = viewerAnswers) {
|
|
204
|
+
const handover = await answeringViewer(store, sealKey, runId, answers);
|
|
205
|
+
return handover && { kind: handover.kind ?? "browser", viewer: viewerLink(runId, handover, "computer") };
|
|
206
|
+
}
|
|
207
|
+
/** Where the browser tool hands its sessions' viewers over: through `seam` on the runner (the store, under its claim),
|
|
208
|
+
* else, on the old per-run process, the run directory `root`'s files. `changed`: a session launched (its viewer put) or
|
|
209
|
+
* released (its own hand-over dropped, never another's); `reopened`: a kept session's viewer opened again after a
|
|
210
|
+
* restart; `released`: the run let its sessions go, every hand-over of it dropped. */
|
|
211
|
+
export function sessionHandovers(root, seam) {
|
|
212
|
+
const put = (handover) => (seam ? seam.put(handover) : writeHandover(root, handover));
|
|
213
|
+
const drop = (tag) => (seam ? seam.drop(tag) : dropHandover(root, tag));
|
|
214
|
+
return {
|
|
215
|
+
changed: async (row, change) => {
|
|
216
|
+
if (change === "released")
|
|
217
|
+
return drop(row.session.tag);
|
|
218
|
+
const handover = row.liveView ? handoverOf(row.liveView.fullscreen, row.session.tag) : undefined;
|
|
219
|
+
if (handover)
|
|
220
|
+
await put(handover);
|
|
221
|
+
},
|
|
222
|
+
reopened: async (tag, fullscreen) => {
|
|
223
|
+
const handover = fullscreen ? handoverOf(fullscreen, tag) : undefined;
|
|
224
|
+
if (handover)
|
|
225
|
+
await put(handover);
|
|
226
|
+
},
|
|
227
|
+
released: () => drop(),
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
/** The viewer's page and files under the run's path ("/v/<id>", "/viewer.js", "/viewer.css"): this server's own copy of
|
|
231
|
+
* pi-browser's viewer, never the run's port's answer, under this route's own CSP, framed by this server's own origin alone.
|
|
232
|
+
* The page reads the viewer's id from its path and its token from the fragment, as pi-browser's own does. */
|
|
233
|
+
export const LIVE_CSP = "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data: blob:; connect-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'self'";
|
|
234
|
+
const LIVE_REST = /^\/(v\/[A-Za-z0-9_-]{22}|viewer\.js|viewer\.css)$/;
|
|
235
|
+
export const liveRest = (rest) => LIVE_REST.test(rest);
|
|
236
|
+
/** The viewer run `runId`'s live route serves at `rest`, read over the store: a viewer's page ("/v/<id>") by its own path
|
|
237
|
+
* id, the viewer's files while the run has one open (its newest); undefined at any other address, or with none open (the
|
|
238
|
+
* route's 404). The WebSocket's upgrade reads liveViewerById with the id in its path. */
|
|
239
|
+
export async function liveViewerFor(store, sealKey, runId, rest) {
|
|
240
|
+
if (!liveRest(rest))
|
|
241
|
+
return undefined;
|
|
242
|
+
const viewer = /^\/v\/([A-Za-z0-9_-]{22})$/.exec(rest)?.[1];
|
|
243
|
+
return viewer ? liveViewerById(store, sealKey, runId, viewer) : liveViewer(store, sealKey, runId);
|
|
244
|
+
}
|
|
245
|
+
export async function serveViewerFile(req, res, rest) {
|
|
246
|
+
const { viewerAssets } = await import("@parcha/pi-browser/live-view");
|
|
247
|
+
const [type, body] = rest === "/viewer.js" ? ["text/javascript; charset=utf-8", viewerAssets.js] : rest === "/viewer.css" ? ["text/css; charset=utf-8", viewerAssets.css] : ["text/html; charset=utf-8", viewerAssets.html];
|
|
248
|
+
res.writeHead(200, { "content-type": type, "content-length": Buffer.byteLength(body), "content-security-policy": LIVE_CSP, "referrer-policy": "no-referrer", "cache-control": "no-store", "x-content-type-options": "nosniff" });
|
|
249
|
+
res.end(req.method === "HEAD" ? undefined : body);
|
|
250
|
+
}
|
|
251
|
+
/** How often an open viewer's session is checked again. A reset-password run in another process and a cookie past its end
|
|
252
|
+
* are seen by no call in this one, so a viewer they end closes within this. */
|
|
253
|
+
export const LIVE_RECHECK_MS = 2_000;
|
|
254
|
+
/** The viewers' sockets open now, each with the check of the sessions that let it in. A socket whose sessions no longer
|
|
255
|
+
* hold is destroyed, which takes its way to the run with it (proxyLiveUpgrade): at once on `recheck()` (a sign-out or a
|
|
256
|
+
* password set in this process), else within LIVE_RECHECK_MS. The timer runs only while a viewer is open. */
|
|
257
|
+
export class OpenViewers {
|
|
258
|
+
open = new Map();
|
|
259
|
+
timer;
|
|
260
|
+
watch(socket, admitted) {
|
|
261
|
+
this.open.set(socket, admitted);
|
|
262
|
+
socket.once("close", () => this.drop(socket));
|
|
263
|
+
this.timer ??= setInterval(() => this.recheck(), LIVE_RECHECK_MS).unref();
|
|
264
|
+
}
|
|
265
|
+
recheck() {
|
|
266
|
+
for (const [socket, admitted] of this.open)
|
|
267
|
+
if (!admitted())
|
|
268
|
+
this.end(socket);
|
|
269
|
+
}
|
|
270
|
+
/** The server closes: every viewer goes. */
|
|
271
|
+
close() {
|
|
272
|
+
for (const socket of this.open.keys())
|
|
273
|
+
this.end(socket);
|
|
274
|
+
}
|
|
275
|
+
end(socket) {
|
|
276
|
+
socket.destroy();
|
|
277
|
+
this.drop(socket);
|
|
278
|
+
}
|
|
279
|
+
drop(socket) {
|
|
280
|
+
this.open.delete(socket);
|
|
281
|
+
if (this.open.size === 0 && this.timer)
|
|
282
|
+
(clearInterval(this.timer), (this.timer = undefined));
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
/** The viewer's WebSocket to the run's port: the request line and the handshake's own headers, the Host and Origin the
|
|
286
|
+
* run's viewer takes (its own), and nothing else of the owner's (no cookie); then both ways, unread. */
|
|
287
|
+
/** Once piping starts, the viewer's socket carries the run's WebSocket stream: nothing is ever written into it after that,
|
|
288
|
+
* an error only ends it. `onPiping` hears when that starts (the server's own failure handling then destroys, never writes). */
|
|
289
|
+
export function proxyLiveUpgrade(req, socket, head, handover, rest, onPiping) {
|
|
290
|
+
const key = String(req.headers["sec-websocket-key"] ?? "");
|
|
291
|
+
const version = String(req.headers["sec-websocket-version"] ?? "");
|
|
292
|
+
if (!/^[A-Za-z0-9+/]{22}==$/.test(key) || version !== "13")
|
|
293
|
+
return void socket.end("HTTP/1.1 400 Bad Request\r\nConnection: close\r\nContent-Length: 0\r\n\r\n");
|
|
294
|
+
const upstream = connect({ host: LOOPBACK, port: handover.port });
|
|
295
|
+
let piping = false;
|
|
296
|
+
const end = () => {
|
|
297
|
+
socket.destroy();
|
|
298
|
+
upstream.destroy();
|
|
299
|
+
};
|
|
300
|
+
upstream.once("connect", () => {
|
|
301
|
+
const own = `${LOOPBACK}:${handover.port}`;
|
|
302
|
+
upstream.write(`GET ${rest} HTTP/1.1\r\nHost: ${own}\r\nOrigin: http://${own}\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Key: ${key}\r\nSec-WebSocket-Version: 13\r\n\r\n`);
|
|
303
|
+
if (head.length)
|
|
304
|
+
upstream.write(head);
|
|
305
|
+
piping = true;
|
|
306
|
+
onPiping?.();
|
|
307
|
+
upstream.pipe(socket).pipe(upstream);
|
|
308
|
+
});
|
|
309
|
+
upstream.on("error", () => {
|
|
310
|
+
// Before piping, the viewer is still waiting for its upgrade's answer: a 502 is that answer. After, it is mid-stream.
|
|
311
|
+
if (piping)
|
|
312
|
+
socket.destroy();
|
|
313
|
+
else if (socket.writable)
|
|
314
|
+
socket.end("HTTP/1.1 502 Bad Gateway\r\nConnection: close\r\nContent-Length: 0\r\n\r\n");
|
|
315
|
+
upstream.destroy();
|
|
316
|
+
});
|
|
317
|
+
socket.on("error", end);
|
|
318
|
+
// A WebSocket is never half open: either side ending ends both, so a run's port that never closes its side keeps
|
|
319
|
+
// neither socket open.
|
|
320
|
+
socket.once("end", end);
|
|
321
|
+
upstream.once("end", end);
|
|
322
|
+
socket.on("close", () => upstream.destroy());
|
|
323
|
+
upstream.on("close", () => socket.destroy());
|
|
324
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/** pi-browser's tool for the agent's ask. */
|
|
2
|
+
export declare const HANDOFF_TOOL = "browser_request_handoff";
|
|
3
|
+
/** The ask's directory in the run's directory (never in work/). */
|
|
4
|
+
export declare const BROWSER_ASK_DIR = "browser-ask";
|
|
5
|
+
/** How long a person's time lasts at most before it expires: an unanswered ask, and a take-over with no input. Its worth of session time is held up front. */
|
|
6
|
+
export declare const PERSON_HOLD_MS: number;
|
|
7
|
+
/** How long a take-over outlasts its viewer. */
|
|
8
|
+
export declare const PERSON_AWAY_MS: number;
|
|
9
|
+
/** Under `--faux` only (the tests, beside the fake browser's own FAUX_BROWSER_LOG): the two windows above, in ms, `<hold>,<away>`. */
|
|
10
|
+
export declare const FAUX_PERSON_MS_ENV = "FAUX_BROWSER_PERSON_MS";
|
|
11
|
+
/** For tests (under `--faux`): a file's path; the run's process dies once (making the file) right after it writes an ask's
|
|
12
|
+
* record and before it commits the ask's row, as a crash there would. */
|
|
13
|
+
export declare const FAUX_ASK_DIES_ENV = "FAUX_BROWSER_ASK_DIES";
|
|
14
|
+
export type AskOutcome = "done" | "cancelled" | "expired";
|
|
15
|
+
/** An ask's pending record, as the server reads it. */
|
|
16
|
+
export type PendingAsk = {
|
|
17
|
+
id: string;
|
|
18
|
+
tag: string;
|
|
19
|
+
instruction: string;
|
|
20
|
+
completion_condition: string;
|
|
21
|
+
asked_at: string;
|
|
22
|
+
expires_at: string;
|
|
23
|
+
};
|
|
24
|
+
/** `reason`: why, for the agent, when the run's cap ended the ask (kept with the answer, so a restart still tells it). */
|
|
25
|
+
export type Answer = {
|
|
26
|
+
outcome: AskOutcome;
|
|
27
|
+
at: string;
|
|
28
|
+
reason?: string;
|
|
29
|
+
};
|
|
30
|
+
/** The ask's id: pi-browser's request id is the model's, so the file is named by a digest of it, never by it; and of the
|
|
31
|
+
* session's tag with it, since two conversations of one run (each its own session) may pick the same request id, and
|
|
32
|
+
* each ask is its session's own: its instruction, its answer, its take-over. */
|
|
33
|
+
export declare const askIdOf: (sessionTag: string, requestId: string) => string;
|
|
34
|
+
/** The ask the run waits on: the newest unanswered one that has not expired, or undefined. Read where a run's status is
|
|
35
|
+
* read (runs.ts statusOf), so a run with no ask costs one existence check. */
|
|
36
|
+
export declare function openAsk(runDir: string, now?: number): PendingAsk | undefined;
|
|
37
|
+
/** The newest unanswered ask, expired or not: one a process must still take up (answer it, or write its expiry), as a
|
|
38
|
+
* restarted run's process does. */
|
|
39
|
+
export declare function waitingAsk(runDir: string): PendingAsk | undefined;
|
|
40
|
+
/** Whether the run's directory still holds an ask's record, answered or not: one its agent's call may still be waiting
|
|
41
|
+
* on (the records go when the run ends, or when its process lets its sessions go). */
|
|
42
|
+
export declare function asked(runDir: string): boolean;
|
|
43
|
+
/** The ask the run waits on (`which`: "open", unexpired, as its status reads it; "waiting", expired or not, as a process
|
|
44
|
+
* must still take up) once its own waiting row is in `rows`: the run's process writes the record first, then commits the
|
|
45
|
+
* row. Each ask on a session writes one waiting row, in the order asked, so the nth ask on a session is in once that
|
|
46
|
+
* session has n waiting rows, whatever other asks (another conversation's, answered or not) wrote meanwhile. */
|
|
47
|
+
export declare function askShown(runDir: string, rows: readonly {
|
|
48
|
+
kind: string;
|
|
49
|
+
session?: string;
|
|
50
|
+
}[], which?: "open" | "waiting"): PendingAsk | undefined;
|
|
51
|
+
/** The owner's answer to the run's ask: the newest one still waiting, as `openAsk` reads it (two conversations may each
|
|
52
|
+
* ask), written when it is the first (`first`); with none waiting, the answer the newest one has. An ask past its expiry
|
|
53
|
+
* has `expired`. Undefined when the run has asked nothing. */
|
|
54
|
+
export declare function answerAsk(runDir: string, outcome: "done" | "cancelled", now?: number): {
|
|
55
|
+
outcome: AskOutcome;
|
|
56
|
+
first: boolean;
|
|
57
|
+
} | undefined;
|
|
58
|
+
/** Removes every ask: the run's process that made them is gone. */
|
|
59
|
+
export declare function dropAsks(runDir: string): void;
|
|
60
|
+
/** Why a take-over ended, as pi-browser's gate says it. */
|
|
61
|
+
type HoldEnd = "given" | "answered" | "cap" | "idle" | "away" | "released";
|
|
62
|
+
/** A root entry of the run's: a timeline row's source. A phase's carries `at` (ms), when what it says happened, so its row
|
|
63
|
+
* shows that time, not the time of the log before it (a model request's start, a call's result). */
|
|
64
|
+
type Note = (kind: string, data: Record<string, string | number>) => Promise<void>;
|
|
65
|
+
/** The run's process's side, for the run at `root`: `take` for the live view's takeOver, `handoff` for pi-browser's
|
|
66
|
+
* HandoffPort. `gates` is the live view's registry (pi-browser's driving gates); `personTime` holds the person's time
|
|
67
|
+
* under the cap (browser-cost.ts); `note` commits a root entry, which reaches the run's timeline. */
|
|
68
|
+
export declare function personHands(options: {
|
|
69
|
+
root: string;
|
|
70
|
+
gates: (tag: string) => {
|
|
71
|
+
give?(why: "answered" | "cap", message?: string): boolean;
|
|
72
|
+
};
|
|
73
|
+
/** `pauses: false`: a refusal does not pause the agent's run (the person's own take-over, a re-hold): only the agent's own
|
|
74
|
+
* step, its ask, does (cap.ts paidCall). */
|
|
75
|
+
personTime(what: string, seconds: number, options?: {
|
|
76
|
+
pauses?: boolean;
|
|
77
|
+
tag?: string;
|
|
78
|
+
from?: number;
|
|
79
|
+
}): Promise<{
|
|
80
|
+
refused: string;
|
|
81
|
+
} | {
|
|
82
|
+
drop(): void;
|
|
83
|
+
}>;
|
|
84
|
+
note: Note;
|
|
85
|
+
holdMs?: number;
|
|
86
|
+
pollMs?: number;
|
|
87
|
+
/** For tests: the timer functions the person's time is held again by. */
|
|
88
|
+
timers?: {
|
|
89
|
+
set(run: () => void, ms: number): unknown;
|
|
90
|
+
clear(handle: unknown): void;
|
|
91
|
+
};
|
|
92
|
+
/** For tests: the clock the person's time is measured by. */
|
|
93
|
+
now?: () => number;
|
|
94
|
+
/** The run's held values cut from the ask's words, whole, before they are cut to their bound and written. */
|
|
95
|
+
redact?: (text: string) => string;
|
|
96
|
+
/** The person's time on a session that just ended, `seconds` of it, to hold until a charge books it (browser-cost.ts
|
|
97
|
+
* carry): the up-front holds go as it ends, the time it took stays counted. */
|
|
98
|
+
carry?(tag: string, seconds: number): void;
|
|
99
|
+
/** How many waiting rows session `tag` has in the run's timeline (each ask on it writes one, in the order asked). */
|
|
100
|
+
waiting?(tag: string): Promise<number>;
|
|
101
|
+
/** On the runner's path: ask `id`'s answer as the run's journal has it (its first answered hand-over entry), or
|
|
102
|
+
* undefined. Given, an ask's answers are journal entries: the person's (a browser_hand_back row the runner applies),
|
|
103
|
+
* and those this process writes through `note` (the live view's hand-back, the ask's expiry at the expiry's time, its
|
|
104
|
+
* end at the cap). The answer files are neither read nor written. */
|
|
105
|
+
answered?(id: string): Promise<Answer | undefined>;
|
|
106
|
+
/** On the runner's path: writes ask `id`'s answer (the hand-over entry `data`) unless the run's journal has one, read
|
|
107
|
+
* and written in one commit (runner/hand-back.ts answerOnce), and gives back the answer that stands, so an ask has
|
|
108
|
+
* exactly one answered entry whoever writes it (a person's hand-back row the runner applies, this process's give or
|
|
109
|
+
* expiry). Without it, the answer is written through `note` after a read. */
|
|
110
|
+
answer?(id: string, data: Record<string, string>): Promise<Answer>;
|
|
111
|
+
/** For tests: called between an ask's record and its row. */
|
|
112
|
+
afterRecord?: () => void;
|
|
113
|
+
}): {
|
|
114
|
+
/** The live view's take: the person's time held, unless an ask open on the same session holds it already (its answer
|
|
115
|
+
* ends the take); refused in the cap's words when there is no room. */
|
|
116
|
+
take(tag: string): Promise<{
|
|
117
|
+
refused: string;
|
|
118
|
+
} | {
|
|
119
|
+
end(why: HoldEnd): void;
|
|
120
|
+
started(): void;
|
|
121
|
+
cancel(): void;
|
|
122
|
+
}>;
|
|
123
|
+
/** pi-browser's HandoffPort. Idempotent by session and request id: a rerun on the same session finds its ask's record;
|
|
124
|
+
* another session's ask with the same request id is its own. The live view's link it is handed is never kept. */
|
|
125
|
+
handoff: {
|
|
126
|
+
request(ask: {
|
|
127
|
+
requestId: string;
|
|
128
|
+
sessionTag: string;
|
|
129
|
+
instruction: string;
|
|
130
|
+
completionCondition: string;
|
|
131
|
+
}): Promise<{
|
|
132
|
+
interactionId: string;
|
|
133
|
+
} | {
|
|
134
|
+
refused: string;
|
|
135
|
+
}>;
|
|
136
|
+
outcome(interactionId: string): Promise<"pending" | AskOutcome | {
|
|
137
|
+
outcome: AskOutcome;
|
|
138
|
+
reason: string;
|
|
139
|
+
}>;
|
|
140
|
+
};
|
|
141
|
+
/** The run waits in its claim on the person's answer to its question (ask_person call `callId`, runner/adapter-loop.ts
|
|
142
|
+
* waitInClaim) with its browser sessions `tags` kept open: the person's time on each is held under the cap as a
|
|
143
|
+
* hand-over's is (acquire: one hold per session, shared with a take-over or an ask on it, this wait's share
|
|
144
|
+
* `wait:<callId>`, held through the wait's bound; the time used carried to the session's next charge when the last
|
|
145
|
+
* share goes). Bounded as a hand-over's ask is: holdMs from `since` (PERSON_HOLD_MS; `since` is when the wait first
|
|
146
|
+
* started, so a later claim's wait keeps the first one's bound; refused at once past it), past which it lapses, the run parks
|
|
147
|
+
* and its release lets the browser go, booking its time to then. `pauses: false`: a refusal pauses nothing, the run
|
|
148
|
+
* parks on its question as it would with no browser. Refused in the cap's words when there is no room. `lapsed`
|
|
149
|
+
* settles, in words, at the bound, when the cap refuses a re-hold (a take-over's sharing the session), or when a
|
|
150
|
+
* session it keeps is let go (sessionEnded); drop() lets the shares go, once. */
|
|
151
|
+
wait(callId: string, tags: readonly string[], since?: number): Promise<{
|
|
152
|
+
refused: string;
|
|
153
|
+
} | {
|
|
154
|
+
lapsed: Promise<string>;
|
|
155
|
+
drop(): void;
|
|
156
|
+
}>;
|
|
157
|
+
/** Session `tag` was let go (its release, whatever made it): a wait that kept it open for the person lapses. */
|
|
158
|
+
sessionEnded(tag: string): void;
|
|
159
|
+
/** The run's process lets go: its holds dropped, its poll stopped. */
|
|
160
|
+
close(): void;
|
|
161
|
+
};
|
|
162
|
+
/** The two windows of a person's time for a run's process with environment `env`: the defaults, or under `--faux` the
|
|
163
|
+
* tests' (FAUX_PERSON_MS_ENV). */
|
|
164
|
+
export declare function personWindows(env: NodeJS.ProcessEnv, faux: boolean): {
|
|
165
|
+
holdMs: number;
|
|
166
|
+
awayMs: number;
|
|
167
|
+
};
|
|
168
|
+
export {};
|