@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/sign-ins-store.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare const SIGN_IN_NAME = "default";
|
|
|
6
6
|
* pointer. */
|
|
7
7
|
export declare const pointerHash: (pointer: string) => string;
|
|
8
8
|
/** A saved sign-in as the owner sees it: its name and when it was saved, and its state. `ready`: its pointer opens under
|
|
9
|
-
* this server's seal key. `unreadable`: it does not (
|
|
9
|
+
* this server's seal key. `unreadable`: it does not (another key, or a damaged row); the owner may
|
|
10
10
|
* forget it or save again, and no run starts from it. Never the pointer. */
|
|
11
11
|
export type SavedSignIn = {
|
|
12
12
|
name: string;
|
|
@@ -22,11 +22,10 @@ export type SignInVendors = {
|
|
|
22
22
|
/** The store slice this module needs. */
|
|
23
23
|
export type SignInsStore = Pick<Store, "signIns">;
|
|
24
24
|
/** Saves the one live sign-in for the agent and provider: its pointer sealed, its name (default SIGN_IN_NAME), inserted or
|
|
25
|
-
* replaced in place
|
|
25
|
+
* replaced in place, sealed under the server's seal key: a pointer is never kept in the clear. */
|
|
26
26
|
/** Saves the agent's first sign-in for the provider only when it has none, in the store's one atomic step (saveIfAbsent):
|
|
27
|
-
* `saved` true with the row it inserted, or false with the live row another save left, never the one asked for.
|
|
28
|
-
|
|
29
|
-
export declare function saveSignInIfAbsent(store: SignInsStore, sealKey: Buffer | undefined, signIn: {
|
|
27
|
+
* `saved` true with the row it inserted, or false with the live row another save left, never the one asked for. */
|
|
28
|
+
export declare function saveSignInIfAbsent(store: SignInsStore, sealKey: Buffer, signIn: {
|
|
30
29
|
agentId: string;
|
|
31
30
|
provider: string;
|
|
32
31
|
pointer: string;
|
|
@@ -35,7 +34,7 @@ export declare function saveSignInIfAbsent(store: SignInsStore, sealKey: Buffer
|
|
|
35
34
|
saved: boolean;
|
|
36
35
|
row: SignInRow;
|
|
37
36
|
}>;
|
|
38
|
-
export declare function saveSignIn(store: SignInsStore, sealKey: Buffer
|
|
37
|
+
export declare function saveSignIn(store: SignInsStore, sealKey: Buffer, signIn: {
|
|
39
38
|
agentId: string;
|
|
40
39
|
provider: string;
|
|
41
40
|
pointer: string;
|
|
@@ -43,11 +42,11 @@ export declare function saveSignIn(store: SignInsStore, sealKey: Buffer | undefi
|
|
|
43
42
|
}): Promise<SavedSignIn>;
|
|
44
43
|
/** The agent's saved sign-ins, as the owner sees them (never a pointer): each with its name, when it was saved, and whether
|
|
45
44
|
* it opens under this server's seal key (ready) or not (unreadable). */
|
|
46
|
-
export declare function savedSignIns(store: SignInsStore, sealKey: Buffer
|
|
45
|
+
export declare function savedSignIns(store: SignInsStore, sealKey: Buffer, agentId: string): Promise<SavedSignIn[]>;
|
|
47
46
|
/** The pointer of the agent's sign-in for the provider, read only: for a run's launch to hand it (E2). `unreadable` when
|
|
48
|
-
* the agent keeps one that does not open under this server's seal key (
|
|
47
|
+
* the agent keeps one that does not open under this server's seal key (another key, or damaged); undefined when it
|
|
49
48
|
* has none. No lease is taken, nothing is written. */
|
|
50
|
-
export declare function openSavedPointer(store: SignInsStore, sealKey: Buffer
|
|
49
|
+
export declare function openSavedPointer(store: SignInsStore, sealKey: Buffer, agentId: string, provider: string): Promise<{
|
|
51
50
|
pointer: string;
|
|
52
51
|
} | "unreadable" | undefined>;
|
|
53
52
|
/** A run's handed sign-in, as the browser binding takes it: the vendor, the pointer, and whether the run saves to it. */
|
|
@@ -66,10 +65,10 @@ export type RunSignIn = {
|
|
|
66
65
|
* before it is handed it, so a forget sees the run: one it could not keep (a stale or lost claim: Fenced) is handed none.
|
|
67
66
|
* The pointer is read again after that write: a forget that landed between the two moved it to a tombstone, and the run
|
|
68
67
|
* is handed none. It saves to it as the store answers that same write (the save lease, in its transaction: never two
|
|
69
|
-
* runs of one sign-in at once, a Browserbase one held for its settle window past a run that left running). None, too,
|
|
68
|
+
* runs of one sign-in at once, a Browserbase one held for its settle window past a run that left running). None, too, for a pointer that does not open, a browser that keeps none, or
|
|
70
69
|
* an agent that saved none for the vendor. Never throws, and never names the pointer.
|
|
71
70
|
*/
|
|
72
|
-
export declare function runSignIn(store: Pick<Store, "runs" | "signIns">, sealKey: Buffer
|
|
71
|
+
export declare function runSignIn(store: Pick<Store, "runs" | "signIns">, sealKey: Buffer, claim: Claim, resolution: string, options?: RunSignInOptions): Promise<RunSignIn | undefined>;
|
|
73
72
|
/** Where a run's first sign-in is made (the vendors' REST APIs, over the run's own claim keys: sign-ins.ts vendorsOver)
|
|
74
73
|
* and where a create that fails is said (the run's log). Absent, none is made. */
|
|
75
74
|
export type RunSignInOptions = {
|
|
@@ -83,7 +82,7 @@ export type RunSignInOptions = {
|
|
|
83
82
|
* a kept tombstone of one, that opens under `sealKey` to a pointer of that hash. One that does not (its seal does not open
|
|
84
83
|
* here, or nothing of it is kept) means the run's text could hold a pointer nothing can cut, so the run must not go on:
|
|
85
84
|
* main's UNREADABLE_SIGN_IN (runs.ts). A run handed none reads back. */
|
|
86
|
-
export declare function handedSignInReadsBack(store: Pick<Store, "signIns">, sealKey: Buffer
|
|
85
|
+
export declare function handedSignInReadsBack(store: Pick<Store, "signIns">, sealKey: Buffer, run: {
|
|
87
86
|
readonly agentId: string;
|
|
88
87
|
readonly signInHanded: readonly string[] | null;
|
|
89
88
|
}): Promise<boolean>;
|
|
@@ -95,11 +94,11 @@ export declare function handedSignInReadsBack(store: Pick<Store, "signIns">, sea
|
|
|
95
94
|
* stamp is conditioned on the save read with the pointer (its number, ifSave), so a sign-in saved afresh meanwhile is never
|
|
96
95
|
* marked by this save. True when the store stamped. Never throws, and never names the pointer.
|
|
97
96
|
*/
|
|
98
|
-
export declare function verifyRunSignIn(store: Pick<Store, "runs" | "signIns">, sealKey: Buffer
|
|
97
|
+
export declare function verifyRunSignIn(store: Pick<Store, "runs" | "signIns">, sealKey: Buffer, claim: Claim, signIn: RunSignIn, at: number): Promise<boolean>;
|
|
99
98
|
/** The pointers of the agent's forgotten sign-ins for the provider that open under this server's seal key, and whether any
|
|
100
99
|
* does not: for cutting a handed pointer from what a run still going shows, after its sign-in was forgotten (E3/the
|
|
101
100
|
* runner). Never a live sign-in. */
|
|
102
|
-
export declare function forgottenPointers(store: SignInsStore, sealKey: Buffer
|
|
101
|
+
export declare function forgottenPointers(store: SignInsStore, sealKey: Buffer, agentId: string, provider: string): Promise<{
|
|
103
102
|
pointers: string[];
|
|
104
103
|
unreadable: boolean;
|
|
105
104
|
}>;
|
|
@@ -112,22 +111,21 @@ export type Forgotten = {
|
|
|
112
111
|
/** Forgets the agent's live sign-in for the provider. In one store transaction (the lock a launch shares): refused with
|
|
113
112
|
* SignInHandedTo while a running run holds this pointer's hash in its sign_in_handed (or, when the pointer does not open,
|
|
114
113
|
* while any running run was handed a sign-in at all — any such run may hold it); otherwise the sealed pointer moves to a
|
|
115
|
-
* tombstone (
|
|
114
|
+
* tombstone (every one kept) and the live row goes. The vendor's object is then deleted, best effort (what failed is
|
|
116
115
|
* said; this server no longer points to it either way). SignInMissing when the agent has no sign-in for the provider. */
|
|
117
|
-
export declare function forgetSignIn(store: SignInsStore, sealKey: Buffer
|
|
116
|
+
export declare function forgetSignIn(store: SignInsStore, sealKey: Buffer, vendors: SignInVendors, agentId: string, provider: string): Promise<Forgotten>;
|
|
118
117
|
/** Which run still going was handed the sign-in whose pointer hashes to `hash`, if one was: the check the runner makes
|
|
119
118
|
* before it serves a run's output. Exposes store.signIns.handedHolder. */
|
|
120
119
|
export declare function handedTo(store: SignInsStore, hash: string): Promise<string | undefined>;
|
|
121
120
|
export { SignInHandedTo, SignInMissing };
|
|
122
121
|
/** Browserbase writes a saved context back after its session ends (pi-browser waits for it), so the saver's save lease must
|
|
123
|
-
* outlast its run leaving 'running' by this long, or the next run saves over a write-back in flight.
|
|
124
|
-
*
|
|
122
|
+
* outlast its run leaving 'running' by this long, or the next run saves over a write-back in flight. A bound this server
|
|
123
|
+
* chose (Browserbase publishes none); the serve layer's policy, passed to the store as signInSettleMs. Kernel and others keep none. */
|
|
125
124
|
export declare const BROWSERBASE_SETTLE_MS = 10000;
|
|
126
|
-
/** A browser the server keeps a sign-in for; a local Chrome keeps none.
|
|
127
|
-
* does not depend on the file store the switch deletes. */
|
|
125
|
+
/** A browser the server keeps a sign-in for; a local Chrome keeps none. */
|
|
128
126
|
export type Vendor = "browserbase" | "kernel";
|
|
129
|
-
/** A saved sign-in as GET /agents/{id} shows it (the v2 SignIn), never its pointer:
|
|
130
|
-
* one secret's metadata under `secret` (sign-ins-secrets.ts signInSecretMeta). */
|
|
127
|
+
/** A saved sign-in as GET /agents/{id} shows it (the v2 SignIn), never its pointer: its key, provider, state, holder and
|
|
128
|
+
* verified_at, and its one secret's metadata under `secret` (sign-ins-secrets.ts signInSecretMeta). */
|
|
131
129
|
export type SignInView = {
|
|
132
130
|
key: string;
|
|
133
131
|
provider: Vendor;
|
|
@@ -137,29 +135,29 @@ export type SignInView = {
|
|
|
137
135
|
secret: SecretMeta;
|
|
138
136
|
};
|
|
139
137
|
/** The vendor a run's browser resolves to keeps a sign-in for: Browserbase's and Kernel's; a local Chrome is refused by
|
|
140
|
-
* name; an unavailable browser has none.
|
|
138
|
+
* name; an unavailable browser has none. */
|
|
141
139
|
export declare function vendorOf(resolution: string): Vendor | undefined;
|
|
142
|
-
/** The agent's sign-ins as the v2 API shows them
|
|
140
|
+
/** The agent's sign-ins as the v2 API shows them, never a pointer. Per sign-in: `held`/`held_by`
|
|
143
141
|
* when a live run holds its pointer's hash (store.signIns.handedHolder), a Browserbase one for its settle window past the
|
|
144
142
|
* run's end too (settleFor, so the view matches the save lease); `unreadable` when its pointer does not open under this
|
|
145
143
|
* server's seal key (then held_by is null — no hash to match a run by); `verified_at` from the store; and `secret`, its
|
|
146
144
|
* secret's metadata, changed_at being its saved_at. */
|
|
147
|
-
export declare function signInViews(store: SignInsStore, sealKey: Buffer
|
|
148
|
-
/** The pointer of the agent's sign-in for `resolution`'s vendor
|
|
145
|
+
export declare function signInViews(store: SignInsStore, sealKey: Buffer, agentId: string): Promise<SignInView[]>;
|
|
146
|
+
/** The pointer of the agent's sign-in for `resolution`'s vendor `{ ref }`, `unreadable` when it
|
|
149
147
|
* does not open, or undefined when there is none or the browser keeps none. */
|
|
150
|
-
export declare function peekSignIn(store: SignInsStore, sealKey: Buffer
|
|
148
|
+
export declare function peekSignIn(store: SignInsStore, sealKey: Buffer, agentId: string, resolution: string): Promise<{
|
|
151
149
|
ref: string;
|
|
152
150
|
} | "unreadable" | undefined>;
|
|
153
|
-
/** The agent's forgotten pointers for `resolution`'s vendor that open here, and whether any does not
|
|
154
|
-
*
|
|
155
|
-
export declare function forgottenSignIns(store: SignInsStore, sealKey: Buffer
|
|
151
|
+
/** The agent's forgotten pointers for `resolution`'s vendor that open here, and whether any does not:
|
|
152
|
+
* `{ refs, unreadable }`, or `{ refs: [], unreadable: false }` for a browser that keeps none. */
|
|
153
|
+
export declare function forgottenSignIns(store: SignInsStore, sealKey: Buffer, agentId: string, resolution: string): Promise<{
|
|
156
154
|
refs: string[];
|
|
157
155
|
unreadable: boolean;
|
|
158
156
|
}>;
|
|
159
|
-
/** Forgets the agent's sign-in named `key`, across every provider that keeps it
|
|
157
|
+
/** Forgets the agent's sign-in named `key`, across every provider that keeps it: each held check
|
|
160
158
|
* runs first, so one held refuses the whole forget (409 sign_in_held) and removes none; then each is moved to a tombstone
|
|
161
159
|
* and deleted at its vendor best effort. 404 when the agent has no sign-in named `key`. */
|
|
162
|
-
export declare function forgetSignInView(store: SignInsStore, sealKey: Buffer
|
|
160
|
+
export declare function forgetSignInView(store: SignInsStore, sealKey: Buffer, vendors: SignInVendors, agentId: string, key: string): Promise<{
|
|
163
161
|
key: string;
|
|
164
162
|
removed: Array<{
|
|
165
163
|
provider: Vendor;
|
|
@@ -169,7 +167,7 @@ export declare function forgetSignInView(store: SignInsStore, sealKey: Buffer |
|
|
|
169
167
|
}>;
|
|
170
168
|
/** The reads that find what a run was handed (handed-values.ts handedValuesOf): an agent's live pointer and its
|
|
171
169
|
* forgotten ones, opened under `sealKey`. Read-only: what the runner's learning end holds to refuse a run's pointer. */
|
|
172
|
-
export declare function signInReads(store: SignInsStore, sealKey: Buffer
|
|
170
|
+
export declare function signInReads(store: SignInsStore, sealKey: Buffer): {
|
|
173
171
|
peek: (agentId: string, resolution: string) => Promise<"unreadable" | {
|
|
174
172
|
ref: string;
|
|
175
173
|
} | undefined>;
|
|
@@ -178,9 +176,9 @@ export declare function signInReads(store: SignInsStore, sealKey: Buffer | undef
|
|
|
178
176
|
unreadable: boolean;
|
|
179
177
|
}>;
|
|
180
178
|
};
|
|
181
|
-
/** The
|
|
182
|
-
*
|
|
183
|
-
export declare function signInsOverStore(store: SignInsStore, sealKey: Buffer
|
|
179
|
+
/** The sign-ins' read and forget surface over the store (view, peek, forgotten, forget), as the server's routes and a run's
|
|
180
|
+
* view use it. */
|
|
181
|
+
export declare function signInsOverStore(store: SignInsStore, sealKey: Buffer, vendors: SignInVendors): {
|
|
184
182
|
forget: (agentId: string, key: string) => Promise<{
|
|
185
183
|
key: string;
|
|
186
184
|
removed: Array<{
|
package/dist/sign-ins-store.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
// An agent's saved browser sign-ins, over the one store (
|
|
2
|
-
// file store (the browser sign-in rules, the E1 store half of the E1/E2/E3 split). The cookies stay at the browser's vendor (a
|
|
1
|
+
// An agent's saved browser sign-ins, over the one store (store.signIns). The cookies stay at the browser's vendor (a
|
|
3
2
|
// Browserbase context, a Kernel profile); this server keeps one sealed pointer per agent and provider, sealed with the
|
|
4
3
|
// store's one rule (store/seal.ts, AAD sign_ins|<agent>:<provider>|pointer), never served, never written to a run in the
|
|
5
4
|
// clear. Only the owner reads a sign-in's name ("default") and state. A run gets the pointer only at its launch, over its
|
|
6
5
|
// secrets' pipe (E2's run path), and its served output is cut by every handed pointer (E3's readers).
|
|
7
6
|
//
|
|
8
|
-
// Forgetting a sign-in moves its pointer into a sealed tombstone (kept only to cut it from what a run it was
|
|
9
|
-
// and is refused while a running run holds the pointer's hash in its
|
|
10
|
-
// transaction, which is the per-agent lock a launch shares: the store's one
|
|
11
|
-
// writes sign_in_handed.
|
|
7
|
+
// Forgetting a sign-in moves its pointer into a sealed tombstone (every one kept, only to cut it from what a run it was
|
|
8
|
+
// handed shows and from what its agent learned), and is refused while a running run holds the pointer's hash in its
|
|
9
|
+
// sign_in_handed list. The forget is one store transaction, which is the per-agent lock a launch shares: the store's one
|
|
10
|
+
// writer serializes it with the launch that writes sign_in_handed.
|
|
12
11
|
import { createHash } from "node:crypto";
|
|
13
12
|
import { ApiError } from "./errors.js";
|
|
14
13
|
import { signInSecretMeta } from "./sign-ins-secrets.js";
|
|
@@ -25,11 +24,9 @@ function checkParts(agentId, provider) {
|
|
|
25
24
|
if (part.includes(":"))
|
|
26
25
|
throw new Error(`a sign-in's agent and provider never hold ":": ${JSON.stringify(part)}`);
|
|
27
26
|
}
|
|
28
|
-
/** Opens a sealed pointer under this server's seal key and binding; undefined when it does not open (
|
|
29
|
-
*
|
|
27
|
+
/** Opens a sealed pointer under this server's seal key and binding; undefined when it does not open (another key, or
|
|
28
|
+
* damaged). */
|
|
30
29
|
function open(sealKey, agentId, provider, pointerSealed) {
|
|
31
|
-
if (!sealKey)
|
|
32
|
-
return undefined;
|
|
33
30
|
try {
|
|
34
31
|
return unsealColumn(sealKey, sealedAt.signIn(agentId, provider), pointerSealed).toString("utf8");
|
|
35
32
|
}
|
|
@@ -38,20 +35,15 @@ function open(sealKey, agentId, provider, pointerSealed) {
|
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
37
|
/** Saves the one live sign-in for the agent and provider: its pointer sealed, its name (default SIGN_IN_NAME), inserted or
|
|
41
|
-
* replaced in place
|
|
38
|
+
* replaced in place, sealed under the server's seal key: a pointer is never kept in the clear. */
|
|
42
39
|
/** Saves the agent's first sign-in for the provider only when it has none, in the store's one atomic step (saveIfAbsent):
|
|
43
|
-
* `saved` true with the row it inserted, or false with the live row another save left, never the one asked for.
|
|
44
|
-
* with no seal key, as saveSignIn is. */
|
|
40
|
+
* `saved` true with the row it inserted, or false with the live row another save left, never the one asked for. */
|
|
45
41
|
export async function saveSignInIfAbsent(store, sealKey, signIn) {
|
|
46
|
-
if (!sealKey)
|
|
47
|
-
throw new Error("this server keeps no sign-in without a seal key, never in the clear");
|
|
48
42
|
checkParts(signIn.agentId, signIn.provider);
|
|
49
43
|
const pointerSealed = sealColumn(sealKey, sealedAt.signIn(signIn.agentId, signIn.provider), signIn.pointer);
|
|
50
44
|
return store.signIns.saveIfAbsent({ agentId: signIn.agentId, provider: signIn.provider, name: signIn.name ?? SIGN_IN_NAME, pointerSealed });
|
|
51
45
|
}
|
|
52
46
|
export async function saveSignIn(store, sealKey, signIn) {
|
|
53
|
-
if (!sealKey)
|
|
54
|
-
throw new Error("this server keeps no sign-in without a seal key, never in the clear");
|
|
55
47
|
checkParts(signIn.agentId, signIn.provider);
|
|
56
48
|
const pointerSealed = sealColumn(sealKey, sealedAt.signIn(signIn.agentId, signIn.provider), signIn.pointer);
|
|
57
49
|
const row = await store.signIns.save({ agentId: signIn.agentId, provider: signIn.provider, name: signIn.name ?? SIGN_IN_NAME, pointerSealed });
|
|
@@ -69,7 +61,7 @@ export async function savedSignIns(store, sealKey, agentId) {
|
|
|
69
61
|
}));
|
|
70
62
|
}
|
|
71
63
|
/** The pointer of the agent's sign-in for the provider, read only: for a run's launch to hand it (E2). `unreadable` when
|
|
72
|
-
* the agent keeps one that does not open under this server's seal key (
|
|
64
|
+
* the agent keeps one that does not open under this server's seal key (another key, or damaged); undefined when it
|
|
73
65
|
* has none. No lease is taken, nothing is written. */
|
|
74
66
|
export async function openSavedPointer(store, sealKey, agentId, provider) {
|
|
75
67
|
const row = await store.signIns.get(agentId, provider);
|
|
@@ -88,7 +80,7 @@ export async function openSavedPointer(store, sealKey, agentId, provider) {
|
|
|
88
80
|
* before it is handed it, so a forget sees the run: one it could not keep (a stale or lost claim: Fenced) is handed none.
|
|
89
81
|
* The pointer is read again after that write: a forget that landed between the two moved it to a tombstone, and the run
|
|
90
82
|
* is handed none. It saves to it as the store answers that same write (the save lease, in its transaction: never two
|
|
91
|
-
* runs of one sign-in at once, a Browserbase one held for its settle window past a run that left running). None, too,
|
|
83
|
+
* runs of one sign-in at once, a Browserbase one held for its settle window past a run that left running). None, too, for a pointer that does not open, a browser that keeps none, or
|
|
92
84
|
* an agent that saved none for the vendor. Never throws, and never names the pointer.
|
|
93
85
|
*/
|
|
94
86
|
export async function runSignIn(store, sealKey, claim, resolution, options = {}) {
|
|
@@ -98,7 +90,7 @@ export async function runSignIn(store, sealKey, claim, resolution, options = {})
|
|
|
98
90
|
catch {
|
|
99
91
|
return undefined;
|
|
100
92
|
} })();
|
|
101
|
-
if (!vendor
|
|
93
|
+
if (!vendor)
|
|
102
94
|
return undefined;
|
|
103
95
|
try {
|
|
104
96
|
const run = await store.runs.get(claim.runId);
|
|
@@ -179,8 +171,6 @@ export async function handedSignInReadsBack(store, sealKey, run) {
|
|
|
179
171
|
const handed = run.signInHanded ?? [];
|
|
180
172
|
if (handed.length === 0)
|
|
181
173
|
return true;
|
|
182
|
-
if (!sealKey)
|
|
183
|
-
return false;
|
|
184
174
|
const known = new Set();
|
|
185
175
|
for (const row of await store.signIns.list(run.agentId)) {
|
|
186
176
|
const pointer = open(sealKey, run.agentId, row.provider, row.pointerSealed);
|
|
@@ -205,7 +195,7 @@ export async function handedSignInReadsBack(store, sealKey, run) {
|
|
|
205
195
|
* marked by this save. True when the store stamped. Never throws, and never names the pointer.
|
|
206
196
|
*/
|
|
207
197
|
export async function verifyRunSignIn(store, sealKey, claim, signIn, at) {
|
|
208
|
-
if (!signIn.save || !
|
|
198
|
+
if (!signIn.save || !Number.isFinite(at))
|
|
209
199
|
return false;
|
|
210
200
|
try {
|
|
211
201
|
const run = await store.runs.get(claim.runId);
|
|
@@ -234,7 +224,7 @@ export async function forgottenPointers(store, sealKey, agentId, provider) {
|
|
|
234
224
|
/** Forgets the agent's live sign-in for the provider. In one store transaction (the lock a launch shares): refused with
|
|
235
225
|
* SignInHandedTo while a running run holds this pointer's hash in its sign_in_handed (or, when the pointer does not open,
|
|
236
226
|
* while any running run was handed a sign-in at all — any such run may hold it); otherwise the sealed pointer moves to a
|
|
237
|
-
* tombstone (
|
|
227
|
+
* tombstone (every one kept) and the live row goes. The vendor's object is then deleted, best effort (what failed is
|
|
238
228
|
* said; this server no longer points to it either way). SignInMissing when the agent has no sign-in for the provider. */
|
|
239
229
|
export async function forgetSignIn(store, sealKey, vendors, agentId, provider) {
|
|
240
230
|
checkParts(agentId, provider);
|
|
@@ -260,18 +250,17 @@ export async function handedTo(store, hash) {
|
|
|
260
250
|
}
|
|
261
251
|
export { SignInHandedTo, SignInMissing };
|
|
262
252
|
// ---------------------------------------------------------------------------------------------------------------------
|
|
263
|
-
//
|
|
264
|
-
//
|
|
265
|
-
// run
|
|
266
|
-
// last verified it (store column, written by E2's run path through store.signIns.verify).
|
|
253
|
+
// The v2 API's view of the sign-ins: a sign-in is "held" when a live run (running, not final) was handed its pointer's
|
|
254
|
+
// hash (store.signIns.handedHolder), and verified_at is the time a run last verified it (store column, written by the
|
|
255
|
+
// run path through store.signIns.verify).
|
|
267
256
|
/** Browserbase writes a saved context back after its session ends (pi-browser waits for it), so the saver's save lease must
|
|
268
|
-
* outlast its run leaving 'running' by this long, or the next run saves over a write-back in flight.
|
|
269
|
-
*
|
|
257
|
+
* outlast its run leaving 'running' by this long, or the next run saves over a write-back in flight. A bound this server
|
|
258
|
+
* chose (Browserbase publishes none); the serve layer's policy, passed to the store as signInSettleMs. Kernel and others keep none. */
|
|
270
259
|
export const BROWSERBASE_SETTLE_MS = 10_000;
|
|
271
260
|
/** The settle window a provider's save lease outlives its run leaving 'running' by: Browserbase's, and none for the rest. */
|
|
272
261
|
const settleFor = (provider) => (provider === "browserbase" ? BROWSERBASE_SETTLE_MS : 0);
|
|
273
262
|
/** The vendor a run's browser resolves to keeps a sign-in for: Browserbase's and Kernel's; a local Chrome is refused by
|
|
274
|
-
* name; an unavailable browser has none.
|
|
263
|
+
* name; an unavailable browser has none. */
|
|
275
264
|
export function vendorOf(resolution) {
|
|
276
265
|
if (resolution === "browserbase" || resolution === "kernel")
|
|
277
266
|
return resolution;
|
|
@@ -280,7 +269,7 @@ export function vendorOf(resolution) {
|
|
|
280
269
|
return undefined;
|
|
281
270
|
}
|
|
282
271
|
const isoOf = (ms) => (ms === null ? null : new Date(ms).toISOString());
|
|
283
|
-
/** The agent's sign-ins as the v2 API shows them
|
|
272
|
+
/** The agent's sign-ins as the v2 API shows them, never a pointer. Per sign-in: `held`/`held_by`
|
|
284
273
|
* when a live run holds its pointer's hash (store.signIns.handedHolder), a Browserbase one for its settle window past the
|
|
285
274
|
* run's end too (settleFor, so the view matches the save lease); `unreadable` when its pointer does not open under this
|
|
286
275
|
* server's seal key (then held_by is null — no hash to match a run by); `verified_at` from the store; and `secret`, its
|
|
@@ -297,7 +286,7 @@ export async function signInViews(store, sealKey, agentId) {
|
|
|
297
286
|
return { ...base, state: heldBy ? "held" : "ready", secret };
|
|
298
287
|
}));
|
|
299
288
|
}
|
|
300
|
-
/** The pointer of the agent's sign-in for `resolution`'s vendor
|
|
289
|
+
/** The pointer of the agent's sign-in for `resolution`'s vendor `{ ref }`, `unreadable` when it
|
|
301
290
|
* does not open, or undefined when there is none or the browser keeps none. */
|
|
302
291
|
export async function peekSignIn(store, sealKey, agentId, resolution) {
|
|
303
292
|
const vendor = (() => { try {
|
|
@@ -311,8 +300,8 @@ export async function peekSignIn(store, sealKey, agentId, resolution) {
|
|
|
311
300
|
const opened = await openSavedPointer(store, sealKey, agentId, vendor);
|
|
312
301
|
return opened === undefined ? undefined : opened === "unreadable" ? "unreadable" : { ref: opened.pointer };
|
|
313
302
|
}
|
|
314
|
-
/** The agent's forgotten pointers for `resolution`'s vendor that open here, and whether any does not
|
|
315
|
-
*
|
|
303
|
+
/** The agent's forgotten pointers for `resolution`'s vendor that open here, and whether any does not:
|
|
304
|
+
* `{ refs, unreadable }`, or `{ refs: [], unreadable: false }` for a browser that keeps none. */
|
|
316
305
|
export async function forgottenSignIns(store, sealKey, agentId, resolution) {
|
|
317
306
|
const vendor = (() => { try {
|
|
318
307
|
return vendorOf(resolution);
|
|
@@ -325,7 +314,7 @@ export async function forgottenSignIns(store, sealKey, agentId, resolution) {
|
|
|
325
314
|
const { pointers, unreadable } = await forgottenPointers(store, sealKey, agentId, vendor);
|
|
326
315
|
return { refs: pointers, unreadable };
|
|
327
316
|
}
|
|
328
|
-
/** Forgets the agent's sign-in named `key`, across every provider that keeps it
|
|
317
|
+
/** Forgets the agent's sign-in named `key`, across every provider that keeps it: each held check
|
|
329
318
|
* runs first, so one held refuses the whole forget (409 sign_in_held) and removes none; then each is moved to a tombstone
|
|
330
319
|
* and deleted at its vendor best effort. 404 when the agent has no sign-in named `key`. */
|
|
331
320
|
export async function forgetSignInView(store, sealKey, vendors, agentId, key) {
|
|
@@ -362,8 +351,8 @@ export function signInReads(store, sealKey) {
|
|
|
362
351
|
forgotten: (agentId, resolution) => forgottenSignIns(store, sealKey, agentId, resolution),
|
|
363
352
|
};
|
|
364
353
|
}
|
|
365
|
-
/** The
|
|
366
|
-
*
|
|
354
|
+
/** The sign-ins' read and forget surface over the store (view, peek, forgotten, forget), as the server's routes and a run's
|
|
355
|
+
* view use it. */
|
|
367
356
|
export function signInsOverStore(store, sealKey, vendors) {
|
|
368
357
|
return {
|
|
369
358
|
view: (agentId) => signInViews(store, sealKey, agentId),
|
package/dist/sign-ins.d.ts
CHANGED
|
@@ -1,130 +1,13 @@
|
|
|
1
|
+
import type { Vendor } from "./sign-ins-store.js";
|
|
2
|
+
/** The folder a sign-in was kept in under an agent's home: never served or written by the home API. */
|
|
1
3
|
export declare const SIGN_INS_DIR = "sign-ins";
|
|
2
4
|
/** The one saved profile an agent keeps per vendor. */
|
|
3
5
|
export declare const SIGN_IN_KEY = "default";
|
|
4
|
-
/** The file a run's process writes in its run directory when a session that saved to its sign-in let go: when the
|
|
5
|
-
* lease ends, its time is the sign-in's `verified_at`. A time, never a pointer. */
|
|
6
|
-
export declare const SIGN_IN_SAVED = "sign-in-saved";
|
|
7
|
-
export type Vendor = "browserbase" | "kernel";
|
|
8
|
-
/** What a run's process is handed: the vendor, the pointer it opens (a context id, a profile name), and whether it saves. */
|
|
9
|
-
export type HandedSignIn = {
|
|
10
|
-
provider: Vendor;
|
|
11
|
-
ref: string;
|
|
12
|
-
save: boolean;
|
|
13
|
-
};
|
|
14
|
-
/** A sign-in as GET /agents/{id} shows it (the contract's SignIn): never its ref. `unreadable` (this server's own state):
|
|
15
|
-
* its pointer does not open under this server's seal key (none now, or another), so no run starts from it and none is
|
|
16
|
-
* made in its place until it is forgotten (DELETE); `held_by` names a run that still holds its lease. */
|
|
17
|
-
export type SignInView = {
|
|
18
|
-
key: string;
|
|
19
|
-
provider: Vendor;
|
|
20
|
-
state: "ready" | "held" | "unreadable";
|
|
21
|
-
held_by: string | null;
|
|
22
|
-
verified_at: string | null;
|
|
23
|
-
};
|
|
24
6
|
/** The vendor's side: make an agent's object (its pointer), and delete one. */
|
|
25
7
|
export type Vendors = {
|
|
26
8
|
create(vendor: Vendor): Promise<string>;
|
|
27
9
|
remove(vendor: Vendor, ref: string): Promise<void>;
|
|
28
10
|
};
|
|
29
|
-
/** Browserbase writes a saved context back after its session ends (pi-browser waits profileSettleMs, 5 s, for it), so
|
|
30
|
-
* its saver's lease outlasts the run's end by twice that: a run started meanwhile neither saves over it. A bound this
|
|
31
|
-
* server chose; Browserbase publishes none. */
|
|
32
|
-
export declare const BROWSERBASE_SETTLE_MS = 10000;
|
|
33
|
-
/** How long a lease outlives its holder's process: pi-browser's default session timeout (DEFAULT_BROWSER_POLICY's
|
|
34
|
-
* sessionTimeoutS, 1800 s), which every session a run opens is created under, so none it opened before its process
|
|
35
|
-
* went can still write back after it. A holder that comes back (its relaunch) holds the lease again from then on. */
|
|
36
|
-
export declare const GONE_LEASE_MS = 1800000;
|
|
37
|
-
/** How many forgotten pointers an agent keeps, the oldest dropped first. A run handed one dropped since is withheld, as
|
|
38
|
-
* one whose sign-in does not open is (runs.ts): its pointer could no longer be cut. */
|
|
39
|
-
export declare const MAX_FORGOTTEN = 32;
|
|
40
|
-
/** What a run's serve.json keeps of the sign-in pointer it was handed (runs.ts `sign_in_handed`), and what forget asks
|
|
41
|
-
* after: its SHA-256, never the pointer. */
|
|
42
|
-
export declare const pointerHash: (ref: string) => string;
|
|
43
|
-
/** Which run still going was handed the sign-in whose pointer hashes to `hash` (runs.ts handedTo), if one was; `hash`
|
|
44
|
-
* undefined for a pointer that does not open here, which any run handed a sign-in may hold. */
|
|
45
|
-
export type HandedTo = (agentId: string, hash: string | undefined) => Promise<string | undefined>;
|
|
46
|
-
/** The vendor a run's browser resolves to (its plane's `browser`) keeps a sign-in for: Browserbase's and Kernel's; local
|
|
47
|
-
* Chrome is refused by name; an unavailable browser has none. */
|
|
48
|
-
export declare function vendorOf(resolution: string): Vendor | undefined;
|
|
49
|
-
export declare class SignIns {
|
|
50
|
-
private readonly data;
|
|
51
|
-
private readonly key;
|
|
52
|
-
private readonly vendors;
|
|
53
|
-
private readonly holds;
|
|
54
|
-
/** One read-modify-write at a time per agent; an agent's queue goes once it is empty. In this process alone: it, and
|
|
55
|
-
* forget's ordering against a launch handing a pointer (forRun's keep), assume one server per data directory, which
|
|
56
|
-
* the data directory's lock holds (server-lock.ts). */
|
|
57
|
-
private readonly chains;
|
|
58
|
-
private readonly now;
|
|
59
|
-
private readonly writeFile;
|
|
60
|
-
private readonly sleep;
|
|
61
|
-
private readonly handedTo;
|
|
62
|
-
/** `holds(run)`: whether that run has not ended, so a lease it names still holds; `handedTo`, which run still going
|
|
63
|
-
* was handed a pointer (runs.ts), so forget waits for it; `now` and `sleep`, the clock, and `write`, the durable
|
|
64
|
-
* write (writeDurable), the tests'. */
|
|
65
|
-
constructor(data: string, key: Buffer | undefined, vendors: Vendors, holds: (runId: string) => Promise<boolean>, options?: {
|
|
66
|
-
handedTo?: HandedTo;
|
|
67
|
-
now?: () => number;
|
|
68
|
-
sleep?: (ms: number) => Promise<void>;
|
|
69
|
-
write?: (path: string, text: string) => Promise<unknown>;
|
|
70
|
-
});
|
|
71
|
-
/** Whether sign-ins are kept here: never without a seal key, never in the clear. */
|
|
72
|
-
get available(): boolean;
|
|
73
|
-
private file;
|
|
74
|
-
private stored;
|
|
75
|
-
private read;
|
|
76
|
-
/** `forgotten`: the agent's forgotten pointers as they are to be kept; absent, those the file keeps now (every write is
|
|
77
|
-
* under the agent's lock, so none comes between). */
|
|
78
|
-
private write;
|
|
79
|
-
private locked;
|
|
80
|
-
/** Whether `entry`'s lease still holds: it names a run that has not ended; or, once its process was found gone, that
|
|
81
|
-
* went less than GONE_LEASE_MS ago, ended or not (a run waiting on its person with no process, or one that crashed and
|
|
82
|
-
* ended, is never let go otherwise, or let go too soon). */
|
|
83
|
-
private held;
|
|
84
|
-
/** `entry`'s pointer, opened under this server's seal key; undefined when it does not open (none now, or another). A
|
|
85
|
-
* forgotten one opens under the same binding, read only by `forgotten`, never as a sign-in. */
|
|
86
|
-
private open;
|
|
87
|
-
/** The agent's sign-ins, as the contract shows them: never a ref. */
|
|
88
|
-
view(agentId: string): Promise<SignInView[]>;
|
|
89
|
-
/** The pointer of `agentId`'s sign-in for `resolution`, read only: no lease taken, nothing made or written. For a run
|
|
90
|
-
* this server loads (after a restart), whose rows, errors and answers must never show it: `{ ref }`; `unreadable`
|
|
91
|
-
* when the agent keeps one that does not open under this server's seal key (none now, or another), or its sign-ins
|
|
92
|
-
* file cannot be read or parsed, told apart from none at all (undefined: no file, or no entry for the vendor). */
|
|
93
|
-
peek(agentId: string, resolution: string): Promise<{
|
|
94
|
-
ref: string;
|
|
95
|
-
} | "unreadable" | undefined>;
|
|
96
|
-
/** The pointers of `agentId`'s forgotten sign-ins for `resolution`'s vendor, read only, for a run this server loads that
|
|
97
|
-
* may have been handed one (runs.ts peekSignIn): never a sign-in. `refs`, each that opens under this server's seal
|
|
98
|
-
* key; `unreadable`, whether one does not (none now, or another). `unreadable` alone when the sign-ins file can't be
|
|
99
|
-
* read or parsed. */
|
|
100
|
-
forgotten(agentId: string, resolution: string): Promise<{
|
|
101
|
-
refs: string[];
|
|
102
|
-
unreadable: boolean;
|
|
103
|
-
} | "unreadable">;
|
|
104
|
-
/** The sign-in run `runId` of `agentId` starts from on `resolution` (its plane's browser): made at the vendor when the
|
|
105
|
-
* agent has none, then leased to this run to save, unless another run of the agent holds the lease. None for a
|
|
106
|
-
* browser that keeps none, or with no seal key. `keep`: the run keeps that it was handed it (its serve.json), before
|
|
107
|
-
* any forget of the agent's can look (forget's handedTo, under the same lock); one it could not keep is handed none. */
|
|
108
|
-
forRun(agentId: string, runId: string, resolution: string, keep?: (handed: HandedSignIn) => Promise<boolean>): Promise<HandedSignIn | undefined>;
|
|
109
|
-
/** Run `runId`'s process was found gone: a lease it holds counts from now, while it does not come back (held). */
|
|
110
|
-
markGone(agentId: string, runId: string): Promise<void>;
|
|
111
|
-
/** Ends the lease run `runId` holds, if it holds one: it ended, or let go to wait for its person; one whose process did
|
|
112
|
-
* not let its sessions go (`clean` false) keeps it until the gone rule ends it. A session of it that saved (its
|
|
113
|
-
* run directory's SIGN_IN_SAVED) makes that the sign-in's `verified_at`. */
|
|
114
|
-
release(agentId: string, runId: string, runDir: string, clean?: boolean): Promise<void>;
|
|
115
|
-
/** DELETE /agents/{id}/sign-ins/{key}: each vendor's object deleted (best effort: what failed is said), then the
|
|
116
|
-
* pointer. 404 for a key the agent has none of; 409 while a run holds its lease, or while a run it was handed is still
|
|
117
|
-
* going (handedTo), its lease let go or not: what that run says could repeat the pointer, and a server started after
|
|
118
|
-
* the pointer is gone could no longer read it back to cut it (runs.ts peekSignIn). */
|
|
119
|
-
forget(agentId: string, signInKey: string): Promise<{
|
|
120
|
-
key: string;
|
|
121
|
-
removed: Array<{
|
|
122
|
-
provider: Vendor;
|
|
123
|
-
at_vendor: "deleted" | "not_deleted";
|
|
124
|
-
message?: string;
|
|
125
|
-
}>;
|
|
126
|
-
}>;
|
|
127
|
-
}
|
|
128
11
|
/** The vendors over their REST APIs, with the server's keys (`env`, read at each call) through `fetchFor` (the tests'
|
|
129
12
|
* fakes under faux). Browserbase: a context made for the agent (POST /v1/contexts, which opens no session; Browserbase
|
|
130
13
|
* bills a session's browser time and proxy data), deleted with DELETE /v1/contexts/{id}. Kernel: a profile made under a
|