@parcha/agentrun-serve 0.1.0-beta.33 → 0.1.0-beta.35
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 +368 -0
- package/README.md +341 -208
- package/dist/adapters.d.ts +3 -4
- package/dist/adapters.js +18 -15
- package/dist/agent-rows.d.ts +99 -0
- package/dist/agent-rows.js +1 -0
- package/dist/agents-store.d.ts +6 -2
- package/dist/agents-store.js +75 -25
- package/dist/agents.d.ts +9 -125
- package/dist/agents.js +15 -305
- package/dist/answer-json.d.ts +23 -0
- package/dist/answer-json.js +58 -0
- package/dist/api-only.d.ts +1 -1
- package/dist/api-only.js +2 -2
- package/dist/archil-settings.d.ts +11 -1
- package/dist/archil-settings.js +10 -0
- package/dist/bash-read-only.d.ts +35 -0
- package/dist/bash-read-only.js +778 -0
- package/dist/box-settings.d.ts +3 -23
- package/dist/box-settings.js +7 -51
- package/dist/boxes.d.ts +17 -0
- package/dist/boxes.js +27 -20
- package/dist/browser-commands.d.ts +5 -2
- package/dist/browser-commands.js +4 -4
- package/dist/browser-computer.d.ts +5 -0
- package/dist/browser-computer.js +21 -0
- package/dist/browser-cost.d.ts +9 -6
- package/dist/browser-cost.js +95 -51
- package/dist/browser-live.d.ts +7 -20
- package/dist/browser-live.js +15 -93
- package/dist/browser-person.d.ts +18 -51
- package/dist/browser-person.js +94 -277
- package/dist/budget.d.ts +0 -5
- package/dist/budget.js +0 -5
- package/dist/cap.d.ts +14 -8
- package/dist/cap.js +19 -9
- package/dist/cli.js +71 -18
- package/dist/closed-pipes.d.ts +2 -0
- package/dist/closed-pipes.js +13 -0
- package/dist/computer-commands.d.ts +2 -0
- package/dist/computer-commands.js +2 -0
- package/dist/computer-keys.d.ts +20 -10
- package/dist/computer-keys.js +36 -54
- package/dist/computer-setting.d.ts +20 -3
- package/dist/computer-setting.js +58 -10
- package/dist/computers.d.ts +35 -2
- package/dist/computers.js +72 -11
- package/dist/confine.d.ts +120 -0
- package/dist/confine.js +436 -0
- package/dist/console/assets/index-B7NKTU8E.css +1 -0
- package/dist/console/assets/index-CXZMgJE7.js +550 -0
- package/dist/console/index.html +2 -2
- package/dist/content-filter.d.ts +7 -0
- package/dist/content-filter.js +23 -0
- package/dist/decision-cap.d.ts +7 -29
- package/dist/decision-cap.js +3 -94
- package/dist/decision-rows.d.ts +1 -1
- package/dist/decision-rows.js +1 -1
- package/dist/docker-daemon.d.ts +31 -0
- package/dist/docker-daemon.js +56 -0
- package/dist/effort-guidance.js +4 -3
- package/dist/environment.d.ts +0 -3
- package/dist/environment.js +3 -5
- package/dist/errors.d.ts +1 -2
- package/dist/errors.js +9 -9
- package/dist/explain.js +3 -1
- package/dist/filed-answer.d.ts +32 -0
- package/dist/filed-answer.js +160 -0
- package/dist/files.d.ts +1 -3
- package/dist/files.js +2 -4
- package/dist/github-connection.d.ts +1 -1
- package/dist/github-connection.js +25 -7
- package/dist/github-faux.d.ts +26 -0
- package/dist/github-faux.js +76 -0
- package/dist/github.d.ts +6 -2
- package/dist/github.js +5 -3
- package/dist/graph-served.d.ts +5 -3
- package/dist/graph-served.js +14 -6
- package/dist/graph-view.d.ts +3 -5
- package/dist/graph-view.js +9 -16
- package/dist/handed-values.d.ts +9 -0
- package/dist/handed-values.js +26 -0
- package/dist/harness-install.d.ts +1 -7
- package/dist/harness-install.js +1 -18
- package/dist/harness-opencode/adapter.d.ts +7 -0
- package/dist/harness-opencode/adapter.js +23 -6
- package/dist/harness-opencode/harness.js +0 -1
- package/dist/harness-opencode/host/policy.js +2 -2
- package/dist/harness-opencode/index.d.ts +1 -1
- package/dist/harness-opencode/index.js +1 -1
- package/dist/harness-opencode/verify.d.ts +17 -0
- package/dist/harness-opencode/verify.js +30 -10
- package/dist/harness-table.js +6 -1
- package/dist/heard.js +1 -1
- package/dist/held-fd.d.ts +5 -0
- package/dist/held-fd.js +14 -0
- package/dist/host-calls.d.ts +20 -0
- package/dist/host-calls.js +12 -0
- package/dist/host-tools.d.ts +4 -21
- package/dist/host-tools.js +4 -61
- package/dist/host.d.ts +2 -4
- package/dist/host.js +2 -7
- package/dist/import-summary.d.ts +1 -5
- package/dist/import-summary.js +0 -21
- package/dist/import.d.ts +6 -6
- package/dist/import.js +14 -15
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/key-refusal.d.ts +5 -1
- package/dist/key-refusal.js +19 -4
- package/dist/learn/check.d.ts +8 -2
- package/dist/learn/check.js +85 -31
- package/dist/learn/folder.d.ts +11 -4
- package/dist/learn/folder.js +17 -19
- package/dist/learn/grade.d.ts +18 -1
- package/dist/learn/grade.js +108 -14
- package/dist/learn/index.d.ts +5 -5
- package/dist/learn/index.js +5 -5
- package/dist/learn/learning.sh +1 -14
- package/dist/learn/notes.d.ts +14 -3
- package/dist/learn/notes.js +16 -6
- package/dist/learn/reflect.d.ts +31 -2
- package/dist/learn/reflect.js +83 -6
- package/dist/learn/relevance.d.ts +24 -0
- package/dist/learn/relevance.js +91 -0
- package/dist/learn/secrets.d.ts +7 -1
- package/dist/learn/secrets.js +86 -19
- package/dist/learn/skills.d.ts +159 -18
- package/dist/learn/skills.js +644 -64
- package/dist/learned-nodes.d.ts +14 -0
- package/dist/learned-nodes.js +8 -0
- package/dist/learned-workflow.d.ts +41 -6
- package/dist/learned-workflow.js +153 -18
- package/dist/learning-routes.d.ts +49 -4
- package/dist/learning-routes.js +113 -31
- package/dist/learning-run.d.ts +16 -31
- package/dist/learning-run.js +31 -38
- package/dist/learning-words.d.ts +12 -5
- package/dist/learning-words.js +18 -9
- package/dist/learning.d.ts +91 -97
- package/dist/learning.js +176 -320
- package/dist/live/stream.js +1 -1
- package/dist/live/translate.js +12 -2
- package/dist/llm.d.ts +4 -1
- package/dist/llm.js +4 -2
- package/dist/local-models.d.ts +11 -5
- package/dist/local-models.js +13 -8
- package/dist/mcp-gateway.d.ts +17 -49
- package/dist/mcp-gateway.js +55 -136
- package/dist/mcp-oauth.d.ts +10 -14
- package/dist/mcp-oauth.js +14 -32
- package/dist/mcp-probe.d.ts +0 -7
- package/dist/mcp-probe.js +4 -10
- package/dist/mcp-servers-store.d.ts +18 -18
- package/dist/mcp-servers-store.js +12 -14
- package/dist/mcp-store.js +3 -4
- package/dist/mcp.js +4 -3
- package/dist/model.d.ts +9 -7
- package/dist/model.js +51 -27
- package/dist/monid.d.ts +0 -2
- package/dist/monid.js +3 -6
- package/dist/openapi.d.ts +8 -1
- package/dist/openapi.js +156 -58
- package/dist/page.d.ts +1 -3
- package/dist/page.js +6 -18
- package/dist/paid-calls.d.ts +21 -27
- package/dist/paid-calls.js +26 -61
- package/dist/pause.d.ts +2 -19
- package/dist/pause.js +5 -74
- package/dist/port-models.d.ts +10 -3
- package/dist/port-models.js +26 -6
- package/dist/propose.d.ts +2 -0
- package/dist/propose.js +80 -45
- package/dist/push-handler.d.ts +1 -1
- package/dist/reflect-range.d.ts +25 -0
- package/dist/reflect-range.js +30 -0
- package/dist/refusal-words.d.ts +5 -1
- package/dist/refusal-words.js +5 -1
- package/dist/rows.d.ts +1 -1
- package/dist/run-cut.d.ts +0 -6
- package/dist/run-cut.js +0 -6
- package/dist/run-db.d.ts +2 -11
- package/dist/run-db.js +2 -37
- package/dist/run-launch.d.ts +21 -2
- package/dist/run-launch.js +14 -5
- package/dist/run-learning-served.d.ts +21 -4
- package/dist/run-learning-served.js +23 -13
- package/dist/run-reads-over-store.d.ts +5 -3
- package/dist/run-reads-over-store.js +25 -14
- package/dist/run-secrets.d.ts +1 -1
- package/dist/run-timeline-served.d.ts +5 -1
- package/dist/run-timeline-served.js +27 -6
- package/dist/run-view.d.ts +37 -22
- package/dist/run-view.js +85 -38
- package/dist/runnable.d.ts +21 -10
- package/dist/runnable.js +35 -12
- package/dist/runner/adapter-loop.d.ts +36 -5
- package/dist/runner/adapter-loop.js +663 -69
- package/dist/runner/adapter-run-spec.d.ts +42 -8
- package/dist/runner/adapter-run-spec.js +186 -52
- package/dist/runner/adapters/index.js +11 -1
- package/dist/runner/adapters/pi.d.ts +40 -2
- package/dist/runner/adapters/pi.js +110 -27
- package/dist/runner/beside.d.ts +38 -3
- package/dist/runner/beside.js +54 -5
- package/dist/runner/claim-secrets.d.ts +16 -1
- package/dist/runner/claim-secrets.js +62 -14
- package/dist/runner/cli-run-spec.d.ts +5 -0
- package/dist/runner/cli-run-spec.js +159 -41
- package/dist/runner/commands.js +1 -1
- package/dist/runner/computer-journal.d.ts +15 -2
- package/dist/runner/computer-journal.js +41 -5
- package/dist/runner/conformance/harness.d.ts +1 -0
- package/dist/runner/conformance/harness.js +123 -13
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/dispatch.d.ts +8 -1
- package/dist/runner/dispatch.js +81 -7
- package/dist/runner/end-of-run.d.ts +8 -2
- package/dist/runner/end-of-run.js +10 -4
- package/dist/runner/github-app.d.ts +7 -2
- package/dist/runner/github-app.js +47 -16
- package/dist/runner/harness-loops.d.ts +15 -2
- package/dist/runner/harness-loops.js +38 -2
- package/dist/runner/journal-kinds.d.ts +60 -6
- package/dist/runner/journal-kinds.js +43 -5
- package/dist/runner/journal-reader.d.ts +1 -1
- package/dist/runner/journal-reader.js +2 -2
- package/dist/runner/learning-ask.d.ts +4 -0
- package/dist/runner/learning-ask.js +15 -1
- package/dist/runner/learning-end.d.ts +18 -3
- package/dist/runner/learning-end.js +194 -20
- package/dist/runner/learning-loop.d.ts +7 -0
- package/dist/runner/learning-loop.js +36 -8
- package/dist/runner/learning-seed.d.ts +6 -0
- package/dist/runner/learning-seed.js +6 -0
- package/dist/runner/loop-contract.d.ts +4 -0
- package/dist/runner/main.d.ts +61 -9
- package/dist/runner/main.js +144 -20
- package/dist/runner/mcp-claim.d.ts +3 -0
- package/dist/runner/mcp-claim.js +7 -3
- package/dist/runner/mcp-github.d.ts +11 -2
- package/dist/runner/mcp-github.js +55 -4
- package/dist/runner/mcp-run.d.ts +2 -0
- package/dist/runner/mcp-run.js +16 -5
- package/dist/runner/memory-claim.d.ts +9 -0
- package/dist/runner/memory-claim.js +25 -0
- package/dist/runner/metrics.d.ts +46 -1
- package/dist/runner/metrics.js +156 -1
- package/dist/runner/model-route.d.ts +16 -0
- package/dist/runner/model-route.js +134 -10
- package/dist/runner/reflect-hook.d.ts +12 -1
- package/dist/runner/reflect-hook.js +33 -3
- package/dist/runner/runner.d.ts +20 -0
- package/dist/runner/runner.js +146 -18
- package/dist/runner/spec-holds.d.ts +7 -2
- package/dist/runner/spec-holds.js +4 -3
- package/dist/runner/store-port.d.ts +1 -1
- package/dist/runner/store-secrets.d.ts +3 -3
- package/dist/runner/store-secrets.js +8 -12
- package/dist/runner/text-tools.d.ts +44 -0
- package/dist/runner/text-tools.js +237 -0
- package/dist/runner/workflow-host.d.ts +7 -2
- package/dist/runner/workflow-host.js +3 -1
- package/dist/runner/workflow-loop.d.ts +10 -1
- package/dist/runner/workflow-loop.js +14 -6
- package/dist/runner/workflow-spec.d.ts +21 -0
- package/dist/runner/workflow-spec.js +217 -93
- package/dist/runs-over-store.d.ts +14 -3
- package/dist/runs-over-store.js +100 -23
- package/dist/seal-key.d.ts +0 -2
- package/dist/seal-key.js +5 -45
- package/dist/sealed-settings-store.d.ts +19 -4
- package/dist/sealed-settings-store.js +9 -9
- package/dist/sealing.d.ts +4 -0
- package/dist/sealing.js +20 -0
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/secret-name.d.ts +9 -0
- package/dist/secret-name.js +15 -0
- package/dist/secret-writes.d.ts +0 -1
- package/dist/secret-writes.js +0 -1
- package/dist/server-fs.d.ts +4 -0
- package/dist/server-fs.js +8 -2
- package/dist/server-lock.d.ts +0 -24
- package/dist/server-lock.js +5 -85
- package/dist/server-secrets-store.d.ts +4 -4
- package/dist/server-secrets-store.js +9 -31
- package/dist/server-secrets.d.ts +4 -9
- package/dist/server-secrets.js +12 -36
- package/dist/server.d.ts +37 -56
- package/dist/server.js +322 -134
- package/dist/sign-ins-store.d.ts +34 -36
- package/dist/sign-ins-store.js +27 -38
- package/dist/sign-ins.d.ts +2 -119
- package/dist/sign-ins.js +5 -311
- package/dist/standard-webhooks.d.ts +1 -1
- package/dist/standard-webhooks.js +1 -1
- package/dist/stats.d.ts +3 -2
- package/dist/stats.js +1 -1
- package/dist/stop-signals.d.ts +4 -2
- package/dist/stop-signals.js +5 -3
- package/dist/store/agent-body.d.ts +12 -2
- package/dist/store/agent-body.js +22 -4
- package/dist/store/deadline.d.ts +18 -0
- package/dist/store/deadline.js +45 -0
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +2 -2
- package/dist/store/open.d.ts +6 -3
- package/dist/store/open.js +2 -2
- package/dist/store/postgres/connection.d.ts +22 -2
- package/dist/store/postgres/connection.js +211 -41
- package/dist/store/postgres/migrate.d.ts +4 -0
- package/dist/store/postgres/migrate.js +9 -2
- package/dist/store/postgres/migrations/0003_commands_one_answer.check.sql +19 -0
- package/dist/store/postgres/migrations/0003_commands_one_answer.sql +13 -0
- package/dist/store/postgres/store.d.ts +9 -2
- package/dist/store/postgres/store.js +9 -0
- package/dist/store/schema.js +1 -1
- package/dist/store/seal.js +2 -2
- package/dist/store/sqlite/connection.js +14 -5
- package/dist/store/sqlite/run-patch.d.ts +3 -0
- package/dist/store/sqlite/run-patch.js +3 -0
- package/dist/store/sqlite/store.js +41 -12
- package/dist/store/store.d.ts +35 -6
- package/dist/store/store.js +12 -2
- package/dist/store-reads/cap.d.ts +1 -1
- package/dist/store-reads/cap.js +22 -4
- package/dist/store-reads/journal.d.ts +9 -6
- package/dist/store-reads/journal.js +129 -18
- package/dist/store-reads/learning.d.ts +82 -8
- package/dist/store-reads/learning.js +184 -11
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-reads/workflow.js +1 -1
- package/dist/store-view.d.ts +19 -1
- package/dist/store-view.js +95 -27
- package/dist/template-eval.d.ts +60 -4
- package/dist/template-eval.js +120 -54
- package/dist/templates.d.ts +33 -14
- package/dist/templates.js +82 -46
- package/dist/timeline/group.d.ts +33 -0
- package/dist/timeline/group.js +77 -0
- package/dist/timeline/index.d.ts +7 -0
- package/dist/timeline/index.js +7 -0
- package/dist/timeline/labels.d.ts +79 -0
- package/dist/timeline/labels.js +150 -0
- package/dist/timeline/origin.d.ts +56 -0
- package/dist/timeline/origin.js +92 -0
- package/dist/timeline/render-text.d.ts +11 -0
- package/dist/timeline/render-text.js +62 -0
- package/dist/timeline/timeline.d.ts +282 -0
- package/dist/timeline/timeline.js +1308 -0
- package/dist/timeline/util.d.ts +17 -0
- package/dist/timeline/util.js +49 -0
- package/dist/tool-budget.d.ts +18 -0
- package/dist/tool-budget.js +50 -0
- package/dist/tool-gate.d.ts +47 -218
- package/dist/tool-gate.js +87 -545
- package/dist/tool-keys-store.d.ts +11 -12
- package/dist/tool-keys-store.js +24 -31
- package/dist/tool-keys.d.ts +5 -101
- package/dist/tool-keys.js +8 -267
- package/dist/tool-plane.d.ts +23 -52
- package/dist/tool-plane.js +23 -81
- package/dist/tool-settings-store.d.ts +1 -2
- package/dist/tool-settings-store.js +5 -8
- package/dist/tools.d.ts +67 -25
- package/dist/tools.js +170 -119
- package/dist/trigger-adapter.d.ts +2 -2
- package/dist/trigger-targets.d.ts +13 -1
- package/dist/trigger-targets.js +31 -1
- package/dist/triggers.d.ts +2 -2
- package/dist/triggers.js +3 -3
- package/dist/turn-end.d.ts +1 -1
- package/dist/turn-end.js +1 -1
- package/dist/turns.d.ts +0 -6
- package/dist/turns.js +0 -19
- package/dist/uploads.d.ts +28 -5
- package/dist/uploads.js +83 -10
- package/dist/usage.d.ts +1 -49
- package/dist/usage.js +3 -84
- package/dist/validate.d.ts +4 -0
- package/dist/validate.js +33 -14
- package/dist/webhooks.d.ts +102 -76
- package/dist/webhooks.js +266 -233
- package/dist/workflow-run.d.ts +114 -0
- package/dist/workflow-run.js +144 -0
- package/dist/workspace/archil-claim.d.ts +2 -2
- package/dist/workspace/archil-claim.js +4 -3
- package/dist/workspace/archil-disk.d.ts +10 -1
- package/dist/workspace/archil-disk.js +4 -0
- package/dist/workspace/archil-exec.d.ts +12 -2
- package/dist/workspace/archil-exec.js +16 -0
- package/dist/workspace/archil.d.ts +2 -2
- package/dist/workspace/archil.js +25 -5
- package/dist/workspace/attach.js +2 -0
- package/dist/workspace/beneath.d.ts +19 -0
- package/dist/workspace/beneath.js +106 -0
- package/dist/workspace/computer-deps.d.ts +26 -9
- package/dist/workspace/computer-deps.js +144 -43
- package/dist/workspace/computer-for-claim.d.ts +17 -14
- package/dist/workspace/computer-for-claim.js +99 -26
- package/dist/workspace/computer-hold.d.ts +6 -1
- package/dist/workspace/computer-hold.js +6 -1
- package/dist/workspace/computer-janitor.d.ts +47 -0
- package/dist/workspace/computer-janitor.js +182 -0
- package/dist/workspace/computer-ledger.d.ts +1 -8
- package/dist/workspace/computer-ledger.js +0 -3
- package/dist/workspace/computer-providers.d.ts +5 -3
- package/dist/workspace/computer-providers.js +11 -9
- package/dist/workspace/grep-worker.d.ts +5 -0
- package/dist/workspace/grep-worker.js +9 -6
- package/dist/workspace/hands.d.ts +5 -2
- package/dist/workspace/hands.js +4 -3
- package/dist/workspace/index.d.ts +6 -5
- package/dist/workspace/index.js +4 -4
- package/dist/workspace/local.d.ts +14 -2
- package/dist/workspace/local.js +170 -43
- package/dist/workspace/paths.js +3 -2
- package/dist/workspace/pi-env.d.ts +4 -0
- package/dist/workspace/pi-env.js +3 -2
- package/dist/workspace/resolve-computer.d.ts +55 -10
- package/dist/workspace/resolve-computer.js +66 -14
- package/dist/workspace/run-tools.d.ts +15 -31
- package/dist/workspace/run-tools.js +19 -30
- package/dist/workspace/workspace.d.ts +5 -0
- package/dist/workspace-paths.d.ts +0 -17
- package/dist/workspace-paths.js +1 -41
- package/dist/workspace.d.ts +0 -17
- package/dist/workspace.js +4 -110
- package/package.json +14 -14
- package/skills/agentrun-serve/SKILL.md +1 -1
- package/templates/README.md +11 -5
- package/templates/code-review/evals/mentions-defused/case.yaml +15 -0
- package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +254 -0
- package/templates/code-review/evals/mentions-defused/graders/no-pings.md +16 -0
- package/templates/code-review/evals/mentions-defused/graders/posted-a-review.md +5 -0
- package/templates/code-review/evals/mentions-defused/graders/schema.md +5 -0
- package/templates/code-review/evals/mentions-defused/prompt.md +10 -0
- package/templates/kyb/evals/clean-public-company/graders/no-opensanctions.md +5 -0
- package/templates/kyb/evals/opensanctions-on/case.yaml +5 -0
- package/templates/kyb/evals/opensanctions-on/graders/licence-and-evidence.md +18 -0
- package/templates/kyb/evals/opensanctions-on/graders/schema.md +5 -0
- package/templates/kyb/evals/opensanctions-on/prompt.md +11 -0
- package/templates/market-monitor/agent.md +2 -2
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/templates/release-notes/agent.md +11 -0
- package/dist/bound-files.d.ts +0 -4
- package/dist/bound-files.js +0 -164
- package/dist/coding-tools.d.ts +0 -47
- package/dist/coding-tools.js +0 -189
- package/dist/computer-adb.d.ts +0 -12
- package/dist/computer-adb.js +0 -14
- package/dist/console/assets/index-Dn0ngwG9.js +0 -535
- package/dist/console/assets/index-DvW6Aled.css +0 -1
- package/dist/grade.d.ts +0 -63
- package/dist/grade.js +0 -150
- package/dist/mcp-servers.d.ts +0 -269
- package/dist/mcp-servers.js +0 -456
- package/dist/packs.d.ts +0 -71
- package/dist/packs.js +0 -180
- package/dist/sealed-settings.d.ts +0 -60
- package/dist/sealed-settings.js +0 -171
- package/dist/sessions.d.ts +0 -6
- package/dist/sessions.js +0 -109
- package/dist/workspace/computer-serves.d.ts +0 -12
- package/dist/workspace/computer-serves.js +0 -15
package/dist/browser-live.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { type IncomingMessage, type ServerResponse } from "node:http";
|
|
2
2
|
import type { Duplex } from "node:stream";
|
|
3
3
|
import type { Claim, Store, ViewerKind } from "./store/store.js";
|
|
4
|
-
/** The hand-over directory in the run's directory (never in work/): one file per open session. */
|
|
5
|
-
export declare const BROWSER_LIVE_DIR = "browser-live";
|
|
6
4
|
/** What the run's process hands the server for one session's viewer; `at`, when (the newest is the one shown). `kind`, the
|
|
7
|
-
* computer it views, as the store's row says it
|
|
5
|
+
* computer it views, as the store's row says it. */
|
|
8
6
|
export type LiveHandover = {
|
|
9
7
|
port: number;
|
|
10
8
|
id: string;
|
|
@@ -16,18 +14,6 @@ export type LiveHandover = {
|
|
|
16
14
|
/** 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
|
|
17
15
|
* a hand-over; undefined for any other shape (a vendor's own URL never is one). */
|
|
18
16
|
export declare function handoverOf(fullscreen: string, tag: string): LiveHandover | undefined;
|
|
19
|
-
/** Writes `handover` into `runDir` as its session's own file: whole, 0600, under a name of its own first, then renamed
|
|
20
|
-
* into place. The time it was handed over goes with it. */
|
|
21
|
-
export declare function writeHandover(runDir: string, handover: LiveHandover): Promise<void>;
|
|
22
|
-
/** Removes session `tag`'s hand-over, and no other's; with no tag, every one (the run's process let its sessions go). */
|
|
23
|
-
export declare function dropHandover(runDir: string, tag?: string): Promise<void>;
|
|
24
|
-
/** Every hand-over in `runDir`, newest first: each a plain file of this user's alone in a directory of this user's alone
|
|
25
|
-
* (not a link), and one; anything else is left out. */
|
|
26
|
-
export declare function readHandovers(runDir: string): Promise<LiveHandover[]>;
|
|
27
|
-
/** The newest hand-over in `runDir`, or undefined. */
|
|
28
|
-
export declare const readHandover: (runDir: string) => Promise<LiveHandover | undefined>;
|
|
29
|
-
/** The hand-over of the viewer whose path id is `id`, or undefined. */
|
|
30
|
-
export declare const handoverById: (runDir: string, id: string) => Promise<LiveHandover | undefined>;
|
|
31
17
|
/** The store's live viewers (store.liveViewers: put and drop under the runner's claim, of() for the server) carry the
|
|
32
18
|
* hand-over across processes, once serve and the runner share only the store. The token is never plaintext there: the
|
|
33
19
|
* runner seals it under the seal key it holds, and the server opens it for the owner's answer alone. */
|
|
@@ -75,11 +61,12 @@ export type ViewerSeam = {
|
|
|
75
61
|
put(handover: LiveHandover): Promise<unknown>;
|
|
76
62
|
drop(tag?: string): Promise<void>;
|
|
77
63
|
};
|
|
78
|
-
/** Where the browser tool hands its sessions' viewers over: through `seam`
|
|
79
|
-
* else
|
|
80
|
-
* released (its own hand-over dropped, never another's);
|
|
81
|
-
* restart; `released`: the run let its sessions go, every
|
|
82
|
-
|
|
64
|
+
/** Where the browser tool hands its sessions' viewers over: through `seam` (the store, under the run's claim), and nowhere
|
|
65
|
+
* else: with no seam no viewer is handed over, and nothing is written (never a file in the run's folder, the agent's
|
|
66
|
+
* workspace). `changed`: a session launched (its viewer put) or released (its own hand-over dropped, never another's);
|
|
67
|
+
* `reopened`: a kept session's viewer opened again after a restart; `released`: the run let its sessions go, every
|
|
68
|
+
* hand-over of it dropped. */
|
|
69
|
+
export declare function sessionHandovers(seam: ViewerSeam | undefined): {
|
|
83
70
|
changed: (row: {
|
|
84
71
|
session: {
|
|
85
72
|
tag: string;
|
package/dist/browser-live.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
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
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
|
|
4
|
-
//
|
|
5
|
-
// the
|
|
6
|
-
// and the token dies with it (pi-browser kills it then); a session's release
|
|
7
|
-
// session's release that crosses a new one's launch (a relaunch) leaves the new
|
|
3
|
+
// As each session launches, the run's runner hands its viewer to the server through the store, under the run's claim (a
|
|
4
|
+
// row of that session's own, its token sealed): the port, the viewer's path id, its token, the session's tag and when.
|
|
5
|
+
// No file holds it: on the runner the run's folder is its workspace, which the agent and the run's file list reach. Its
|
|
6
|
+
// own row goes when the session is released, and the token dies with it (pi-browser kills it then); a session's release
|
|
7
|
+
// never touches another's row, so an old session's release that crosses a new one's launch (a relaunch) leaves the new
|
|
8
|
+
// one handed over.
|
|
8
9
|
//
|
|
9
10
|
// The server reads the newest for the owner alone (GET /v2/runs/{id}/browser, and GET /v2/runs/{id}/computer, the computer
|
|
10
11
|
// family's, the browser as kind browser there) and answers the viewer under the run's path (/v2/runs/{id}/browser/live/*,
|
|
@@ -12,16 +13,10 @@
|
|
|
12
13
|
// the pi-browser it has installed, never anything a run's port answers: a run's port only ever carries the viewer's
|
|
13
14
|
// WebSocket, data and no code, proxied to that port alone and only from this server's own origin. The page is served
|
|
14
15
|
// 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
|
|
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";
|
|
16
|
+
// context, a home, an export or an archive: only its sealed row and the owner's answer hold it.
|
|
19
17
|
import { request as httpRequest } from "node:http";
|
|
20
18
|
import { connect } from "node:net";
|
|
21
|
-
import { join } from "node:path";
|
|
22
19
|
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
20
|
/** The computer kinds a store row may name. */
|
|
26
21
|
const VIEWER_KINDS = ["browser", "desktop", "phone"];
|
|
27
22
|
/** Where the run's own viewer listens: its process's loopback address alone. */
|
|
@@ -47,80 +42,6 @@ export function handoverOf(fullscreen, tag) {
|
|
|
47
42
|
return undefined;
|
|
48
43
|
return { port, id, token, tag };
|
|
49
44
|
}
|
|
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
45
|
/** The runner hands session `handover.tag`'s viewer over, under `claim`, its token sealed under `sealKey`: false when the
|
|
125
46
|
* claim is stale and nothing was written. The time is the store's. */
|
|
126
47
|
export async function putLiveViewer(store, sealKey, claim, handover) {
|
|
@@ -204,13 +125,14 @@ export async function computerViewerLink(store, sealKey, runId, answers = viewer
|
|
|
204
125
|
const handover = await answeringViewer(store, sealKey, runId, answers);
|
|
205
126
|
return handover && { kind: handover.kind ?? "browser", viewer: viewerLink(runId, handover, "computer") };
|
|
206
127
|
}
|
|
207
|
-
/** Where the browser tool hands its sessions' viewers over: through `seam`
|
|
208
|
-
* else
|
|
209
|
-
* released (its own hand-over dropped, never another's);
|
|
210
|
-
* restart; `released`: the run let its sessions go, every
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
const
|
|
128
|
+
/** Where the browser tool hands its sessions' viewers over: through `seam` (the store, under the run's claim), and nowhere
|
|
129
|
+
* else: with no seam no viewer is handed over, and nothing is written (never a file in the run's folder, the agent's
|
|
130
|
+
* workspace). `changed`: a session launched (its viewer put) or released (its own hand-over dropped, never another's);
|
|
131
|
+
* `reopened`: a kept session's viewer opened again after a restart; `released`: the run let its sessions go, every
|
|
132
|
+
* hand-over of it dropped. */
|
|
133
|
+
export function sessionHandovers(seam) {
|
|
134
|
+
const put = async (handover) => seam?.put(handover);
|
|
135
|
+
const drop = async (tag) => seam?.drop(tag);
|
|
214
136
|
return {
|
|
215
137
|
changed: async (row, change) => {
|
|
216
138
|
if (change === "released")
|
package/dist/browser-person.d.ts
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
/** The ask's directory in the run's directory (never in work/). */
|
|
2
|
-
export declare const BROWSER_ASK_DIR = "browser-ask";
|
|
3
1
|
/** 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. */
|
|
4
2
|
export declare const PERSON_HOLD_MS: number;
|
|
5
3
|
/** How long a take-over outlasts its viewer. */
|
|
6
4
|
export declare const PERSON_AWAY_MS: number;
|
|
7
5
|
/** Under `--faux` only (the tests, beside the fake browser's own FAUX_BROWSER_LOG): the two windows above, in ms, `<hold>,<away>`. */
|
|
8
6
|
export declare const FAUX_PERSON_MS_ENV = "FAUX_BROWSER_PERSON_MS";
|
|
9
|
-
/** For tests (under `--faux`): a file's path; the run's process dies once (making the file) right after it writes an ask's
|
|
10
|
-
* record and before it commits the ask's row, as a crash there would. */
|
|
11
|
-
export declare const FAUX_ASK_DIES_ENV = "FAUX_BROWSER_ASK_DIES";
|
|
12
7
|
export type AskOutcome = "done" | "cancelled" | "expired";
|
|
13
|
-
/** An ask
|
|
8
|
+
/** An ask, as its waiting entry in the run's journal holds it. */
|
|
14
9
|
export type PendingAsk = {
|
|
15
10
|
id: string;
|
|
16
11
|
tag: string;
|
|
@@ -25,46 +20,20 @@ export type Answer = {
|
|
|
25
20
|
at: string;
|
|
26
21
|
reason?: string;
|
|
27
22
|
};
|
|
28
|
-
/** The ask's id: pi-browser's request id is the model's, so the
|
|
23
|
+
/** The ask's id: pi-browser's request id is the model's, so the ask is named by a digest of it, never by it; and of the
|
|
29
24
|
* session's tag with it, since two conversations of one run (each its own session) may pick the same request id, and
|
|
30
25
|
* each ask is its session's own: its instruction, its answer, its take-over. */
|
|
31
26
|
export declare const askIdOf: (sessionTag: string, requestId: string) => string;
|
|
32
|
-
/** The ask the run waits on: the newest unanswered one that has not expired, or undefined. Read where a run's status is
|
|
33
|
-
* read (runs.ts statusOf), so a run with no ask costs one existence check. */
|
|
34
|
-
export declare function openAsk(runDir: string, now?: number): PendingAsk | undefined;
|
|
35
|
-
/** The newest unanswered ask, expired or not: one a process must still take up (answer it, or write its expiry), as a
|
|
36
|
-
* restarted run's process does. */
|
|
37
|
-
export declare function waitingAsk(runDir: string): PendingAsk | undefined;
|
|
38
|
-
/** Whether the run's directory still holds an ask's record, answered or not: one its agent's call may still be waiting
|
|
39
|
-
* on (the records go when the run ends, or when its process lets its sessions go). */
|
|
40
|
-
export declare function asked(runDir: string): boolean;
|
|
41
|
-
/** The ask the run waits on (`which`: "open", unexpired, as its status reads it; "waiting", expired or not, as a process
|
|
42
|
-
* must still take up) once its own waiting row is in `rows`: the run's process writes the record first, then commits the
|
|
43
|
-
* 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
|
|
44
|
-
* session has n waiting rows, whatever other asks (another conversation's, answered or not) wrote meanwhile. */
|
|
45
|
-
export declare function askShown(runDir: string, rows: readonly {
|
|
46
|
-
kind: string;
|
|
47
|
-
session?: string;
|
|
48
|
-
}[], which?: "open" | "waiting"): PendingAsk | undefined;
|
|
49
|
-
/** The owner's answer to the run's ask: the newest one still waiting, as `openAsk` reads it (two conversations may each
|
|
50
|
-
* ask), written when it is the first (`first`); with none waiting, the answer the newest one has. An ask past its expiry
|
|
51
|
-
* has `expired`. Undefined when the run has asked nothing. */
|
|
52
|
-
export declare function answerAsk(runDir: string, outcome: "done" | "cancelled", now?: number): {
|
|
53
|
-
outcome: AskOutcome;
|
|
54
|
-
first: boolean;
|
|
55
|
-
} | undefined;
|
|
56
|
-
/** Removes every ask: the run's process that made them is gone. */
|
|
57
|
-
export declare function dropAsks(runDir: string): void;
|
|
58
27
|
/** Why a take-over ended, as pi-browser's gate says it. */
|
|
59
28
|
type HoldEnd = "given" | "answered" | "cap" | "idle" | "away" | "released";
|
|
60
29
|
/** 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
|
|
61
30
|
* shows that time, not the time of the log before it (a model request's start, a call's result). */
|
|
62
31
|
type Note = (kind: string, data: Record<string, string | number>) => Promise<void>;
|
|
63
|
-
/** The run's process's side
|
|
64
|
-
*
|
|
65
|
-
*
|
|
32
|
+
/** The run's process's side: `take` for the live view's takeOver, `handoff` for pi-browser's HandoffPort. `gates` is the
|
|
33
|
+
* live view's registry (pi-browser's driving gates); `personTime` holds the person's time under the cap
|
|
34
|
+
* (browser-cost.ts); `note` commits a root entry, which reaches the run's timeline. Every ask and every answer is an
|
|
35
|
+
* entry of the run's journal, read back through `asks` and `answered`. */
|
|
66
36
|
export declare function personHands(options: {
|
|
67
|
-
root: string;
|
|
68
37
|
gates: (tag: string) => {
|
|
69
38
|
give?(why: "answered" | "cap", message?: string): boolean;
|
|
70
39
|
};
|
|
@@ -94,27 +63,25 @@ export declare function personHands(options: {
|
|
|
94
63
|
/** The person's time on a session that just ended, `seconds` of it, to hold until a charge books it (browser-cost.ts
|
|
95
64
|
* carry): the up-front holds go as it ends, the time it took stays counted. */
|
|
96
65
|
carry?(tag: string, seconds: number): void;
|
|
97
|
-
/**
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
* and those this process writes
|
|
102
|
-
*
|
|
103
|
-
answered
|
|
104
|
-
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
66
|
+
/** Every ask the run's journal holds: its waiting hand-over entries (each the ask's one record, committed through
|
|
67
|
+
* `note`), as asks. */
|
|
68
|
+
asks(): Promise<readonly PendingAsk[]>;
|
|
69
|
+
/** Ask `id`'s answer as the run's journal has it (its first answered hand-over entry), or undefined: the person's (a
|
|
70
|
+
* browser_hand_back row the runner applies), and those this process writes (the live view's hand-back, the ask's
|
|
71
|
+
* expiry at the expiry's time, its end at the cap). */
|
|
72
|
+
answered(id: string): Promise<Answer | undefined>;
|
|
73
|
+
/** Writes ask `id`'s answer (the hand-over entry `data`) unless the run's journal has one, read and written in one
|
|
74
|
+
* commit (runner/hand-back.ts answerOnce), and gives back the answer that stands, so an ask has exactly one answered
|
|
75
|
+
* entry whoever writes it (a person's hand-back row the runner applies, this process's give or expiry). Without it,
|
|
76
|
+
* the answer is written through `note` after a read. */
|
|
108
77
|
answer?(id: string, data: Record<string, string>): Promise<Answer>;
|
|
109
|
-
/** For tests: called between an ask's record and its row. */
|
|
110
|
-
afterRecord?: () => void;
|
|
111
78
|
}): {
|
|
112
79
|
/** The live view's take: the person's time held, unless an ask open on the same session holds it already (its answer
|
|
113
80
|
* ends the take); refused in the cap's words when there is no room. */
|
|
114
81
|
take(tag: string): Promise<{
|
|
115
82
|
refused: string;
|
|
116
83
|
} | {
|
|
117
|
-
end(why: HoldEnd): void
|
|
84
|
+
end(why: HoldEnd): Promise<void>;
|
|
118
85
|
started(): void;
|
|
119
86
|
cancel(): void;
|
|
120
87
|
}>;
|