@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.js
CHANGED
|
@@ -1,318 +1,12 @@
|
|
|
1
1
|
// An agent's saved sign-ins: the browser it signed in with stays signed in for its later runs. The cookies stay at the
|
|
2
|
-
// browser's vendor (a Browserbase context, a Kernel profile); this server keeps only a pointer to that object per
|
|
3
|
-
// in
|
|
4
|
-
// run's
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// environment: the run's process never gets the seal key. Local Chrome keeps none (its cookies would sit on this disk).
|
|
8
|
-
//
|
|
9
|
-
// Saving is leased across runs: each run is its own process, so pi-browser's one-saver rule (per process) cannot see
|
|
10
|
-
// two runs of one agent. The first run of the agent to start with the browser holds the lease and its sessions save;
|
|
11
|
-
// a run started while another holds it starts from the same sign-in and saves nothing. The lease ends when its run
|
|
12
|
-
// ends, or lets go cleanly to wait for its person (runs.ts); a relaunch or a restart keeps it, since a session the run
|
|
13
|
-
// opened before its process went may still write back. One whose run has ended since (a server down first) is stale.
|
|
14
|
-
import { createHash, randomBytes } from "node:crypto";
|
|
15
|
-
import { lstat, mkdir, readFile, rm } from "node:fs/promises";
|
|
16
|
-
import { join } from "node:path";
|
|
17
|
-
import { seal, unseal } from "@parcha/pi-durable-agent";
|
|
18
|
-
import { ApiError } from "./errors.js";
|
|
19
|
-
import { homeOf } from "./files.js";
|
|
20
|
-
import { serialBy, writeDurable } from "./server-fs.js";
|
|
2
|
+
// browser's vendor (a Browserbase context, a Kernel profile); this server keeps only a sealed pointer to that object per
|
|
3
|
+
// agent and vendor, in the one store (sign-ins-store.ts), and a run on the runner reads it under its own claim. Here: the
|
|
4
|
+
// names a run and an agent's home use for it, and the vendors' own calls.
|
|
5
|
+
import { randomBytes } from "node:crypto";
|
|
6
|
+
/** The folder a sign-in was kept in under an agent's home: never served or written by the home API. */
|
|
21
7
|
export const SIGN_INS_DIR = "sign-ins";
|
|
22
|
-
const FILE = "sign-ins.json";
|
|
23
|
-
const FORMAT = "sign-ins/1";
|
|
24
8
|
/** The one saved profile an agent keeps per vendor. */
|
|
25
9
|
export const SIGN_IN_KEY = "default";
|
|
26
|
-
/** The file a run's process writes in its run directory when a session that saved to its sign-in let go: when the
|
|
27
|
-
* lease ends, its time is the sign-in's `verified_at`. A time, never a pointer. */
|
|
28
|
-
export const SIGN_IN_SAVED = "sign-in-saved";
|
|
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 const BROWSERBASE_SETTLE_MS = 10_000;
|
|
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 const GONE_LEASE_MS = 1_800_000;
|
|
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 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 const pointerHash = (ref) => createHash("sha256").update(ref, "utf8").digest("hex");
|
|
43
|
-
/** The vendor a run's browser resolves to (its plane's `browser`) keeps a sign-in for: Browserbase's and Kernel's; local
|
|
44
|
-
* Chrome is refused by name; an unavailable browser has none. */
|
|
45
|
-
export function vendorOf(resolution) {
|
|
46
|
-
if (resolution === "browserbase" || resolution === "kernel")
|
|
47
|
-
return resolution;
|
|
48
|
-
if (resolution === "chrome" || resolution === "cdp")
|
|
49
|
-
throw new Error("a local Chrome keeps no saved sign-in: its cookies would sit on this server's disk");
|
|
50
|
-
return undefined;
|
|
51
|
-
}
|
|
52
|
-
const aad = (agentId, entry) => `${FORMAT}|${agentId}|${entry.key}|${entry.provider}`;
|
|
53
|
-
export class SignIns {
|
|
54
|
-
data;
|
|
55
|
-
key;
|
|
56
|
-
vendors;
|
|
57
|
-
holds;
|
|
58
|
-
/** One read-modify-write at a time per agent; an agent's queue goes once it is empty. In this process alone: it, and
|
|
59
|
-
* forget's ordering against a launch handing a pointer (forRun's keep), assume one server per data directory, which
|
|
60
|
-
* the data directory's lock holds (server-lock.ts). */
|
|
61
|
-
chains = new Map();
|
|
62
|
-
now;
|
|
63
|
-
writeFile;
|
|
64
|
-
sleep;
|
|
65
|
-
handedTo;
|
|
66
|
-
/** `holds(run)`: whether that run has not ended, so a lease it names still holds; `handedTo`, which run still going
|
|
67
|
-
* was handed a pointer (runs.ts), so forget waits for it; `now` and `sleep`, the clock, and `write`, the durable
|
|
68
|
-
* write (writeDurable), the tests'. */
|
|
69
|
-
constructor(data, key, vendors, holds, options = {}) {
|
|
70
|
-
this.data = data;
|
|
71
|
-
this.key = key;
|
|
72
|
-
this.vendors = vendors;
|
|
73
|
-
this.holds = holds;
|
|
74
|
-
this.handedTo = options.handedTo;
|
|
75
|
-
this.now = options.now ?? Date.now;
|
|
76
|
-
this.sleep = options.sleep ?? ((ms) => new Promise((done) => setTimeout(done, ms)));
|
|
77
|
-
this.writeFile = options.write ?? writeDurable;
|
|
78
|
-
}
|
|
79
|
-
/** Whether sign-ins are kept here: never without a seal key, never in the clear. */
|
|
80
|
-
get available() {
|
|
81
|
-
return this.key !== undefined;
|
|
82
|
-
}
|
|
83
|
-
file(agentId) {
|
|
84
|
-
return join(homeOf(this.data, agentId), SIGN_INS_DIR, FILE);
|
|
85
|
-
}
|
|
86
|
-
async stored(agentId) {
|
|
87
|
-
const text = await readFile(this.file(agentId), "utf8").catch((error) => (error.code === "ENOENT" ? null : Promise.reject(error)));
|
|
88
|
-
if (text === null)
|
|
89
|
-
return { sign_ins: [], forgotten: [] };
|
|
90
|
-
const stored = JSON.parse(text);
|
|
91
|
-
if (stored?.format !== FORMAT || !Array.isArray(stored.sign_ins) || (stored.forgotten !== undefined && !Array.isArray(stored.forgotten)))
|
|
92
|
-
throw new Error(`${FILE} is not a ${FORMAT} file, so it was left as it is`);
|
|
93
|
-
return { sign_ins: stored.sign_ins, forgotten: stored.forgotten ?? [] };
|
|
94
|
-
}
|
|
95
|
-
async read(agentId) {
|
|
96
|
-
return (await this.stored(agentId)).sign_ins;
|
|
97
|
-
}
|
|
98
|
-
/** `forgotten`: the agent's forgotten pointers as they are to be kept; absent, those the file keeps now (every write is
|
|
99
|
-
* under the agent's lock, so none comes between). */
|
|
100
|
-
async write(agentId, entries, forgotten) {
|
|
101
|
-
const dir = join(homeOf(this.data, agentId), SIGN_INS_DIR);
|
|
102
|
-
const kept = forgotten ?? (await this.stored(agentId)).forgotten;
|
|
103
|
-
if (!entries.length && !kept.length)
|
|
104
|
-
return void (await rm(this.file(agentId), { force: true }));
|
|
105
|
-
await mkdir(dir, { recursive: true, mode: 0o700 });
|
|
106
|
-
if ((await lstat(dir)).isSymbolicLink())
|
|
107
|
-
throw new Error(`${SIGN_INS_DIR}/ is a link, which this server never follows`);
|
|
108
|
-
// Synced before it answers: a pointer to a vendor object just made survives a crash of the machine.
|
|
109
|
-
await this.writeFile(this.file(agentId), `${JSON.stringify({ format: FORMAT, sign_ins: entries, ...(kept.length ? { forgotten: kept } : {}) })}\n`);
|
|
110
|
-
}
|
|
111
|
-
locked(agentId, work) {
|
|
112
|
-
return serialBy(this.chains, agentId, work);
|
|
113
|
-
}
|
|
114
|
-
/** Whether `entry`'s lease still holds: it names a run that has not ended; or, once its process was found gone, that
|
|
115
|
-
* went less than GONE_LEASE_MS ago, ended or not (a run waiting on its person with no process, or one that crashed and
|
|
116
|
-
* ended, is never let go otherwise, or let go too soon). */
|
|
117
|
-
async held(entry) {
|
|
118
|
-
if (entry.held_by === null)
|
|
119
|
-
return false;
|
|
120
|
-
if (entry.held_until)
|
|
121
|
-
return this.now() < Date.parse(entry.held_until);
|
|
122
|
-
// A Browserbase session that lived out the timeout still writes its context back after it ends; Kernel's browser
|
|
123
|
-
// ends at its idle timeout and saves as it ends, so it needs no margin.
|
|
124
|
-
// Once its process is found gone, that alone decides, whether its run has ended since or not: a session it left
|
|
125
|
-
// live may still write back until then.
|
|
126
|
-
if (entry.gone_at)
|
|
127
|
-
return this.now() - Date.parse(entry.gone_at) < GONE_LEASE_MS + (entry.provider === "browserbase" ? BROWSERBASE_SETTLE_MS : 0);
|
|
128
|
-
return this.holds(entry.held_by).catch(() => true);
|
|
129
|
-
}
|
|
130
|
-
/** `entry`'s pointer, opened under this server's seal key; undefined when it does not open (none now, or another). A
|
|
131
|
-
* forgotten one opens under the same binding, read only by `forgotten`, never as a sign-in. */
|
|
132
|
-
open(agentId, entry) {
|
|
133
|
-
if (!this.key)
|
|
134
|
-
return undefined;
|
|
135
|
-
try {
|
|
136
|
-
return unseal(this.key, Buffer.from(entry.ref, "base64"), aad(agentId, entry)).toString("utf8");
|
|
137
|
-
}
|
|
138
|
-
catch {
|
|
139
|
-
return undefined;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
/** The agent's sign-ins, as the contract shows them: never a ref. */
|
|
143
|
-
async view(agentId) {
|
|
144
|
-
const entries = await this.read(agentId).catch(() => []);
|
|
145
|
-
return Promise.all(entries.map(async (entry) => {
|
|
146
|
-
const held = await this.held(entry);
|
|
147
|
-
// Unreadable or not, a run that holds its lease is named: forget is refused until it ends.
|
|
148
|
-
if (this.open(agentId, entry) === undefined)
|
|
149
|
-
return { key: entry.key, provider: entry.provider, state: "unreadable", held_by: held ? entry.held_by : null, verified_at: entry.verified_at };
|
|
150
|
-
return { key: entry.key, provider: entry.provider, state: held ? "held" : "ready", held_by: held ? entry.held_by : null, verified_at: entry.verified_at };
|
|
151
|
-
}));
|
|
152
|
-
}
|
|
153
|
-
/** The pointer of `agentId`'s sign-in for `resolution`, read only: no lease taken, nothing made or written. For a run
|
|
154
|
-
* this server loads (after a restart), whose rows, errors and answers must never show it: `{ ref }`; `unreadable`
|
|
155
|
-
* when the agent keeps one that does not open under this server's seal key (none now, or another), or its sign-ins
|
|
156
|
-
* file cannot be read or parsed, told apart from none at all (undefined: no file, or no entry for the vendor). */
|
|
157
|
-
async peek(agentId, resolution) {
|
|
158
|
-
const vendor = (() => { try {
|
|
159
|
-
return vendorOf(resolution);
|
|
160
|
-
}
|
|
161
|
-
catch {
|
|
162
|
-
return undefined;
|
|
163
|
-
} })();
|
|
164
|
-
if (!vendor)
|
|
165
|
-
return undefined;
|
|
166
|
-
// Only a file that is not there means none: one this server may not read, or that does not parse, is unreadable.
|
|
167
|
-
const entries = await this.read(agentId).catch(() => null);
|
|
168
|
-
if (entries === null)
|
|
169
|
-
return "unreadable";
|
|
170
|
-
const entry = entries.find((e) => e.key === SIGN_IN_KEY && e.provider === vendor);
|
|
171
|
-
if (!entry)
|
|
172
|
-
return undefined;
|
|
173
|
-
const ref = this.open(agentId, entry);
|
|
174
|
-
return ref === undefined ? "unreadable" : { ref };
|
|
175
|
-
}
|
|
176
|
-
/** The pointers of `agentId`'s forgotten sign-ins for `resolution`'s vendor, read only, for a run this server loads that
|
|
177
|
-
* may have been handed one (runs.ts peekSignIn): never a sign-in. `refs`, each that opens under this server's seal
|
|
178
|
-
* key; `unreadable`, whether one does not (none now, or another). `unreadable` alone when the sign-ins file can't be
|
|
179
|
-
* read or parsed. */
|
|
180
|
-
async forgotten(agentId, resolution) {
|
|
181
|
-
const vendor = (() => { try {
|
|
182
|
-
return vendorOf(resolution);
|
|
183
|
-
}
|
|
184
|
-
catch {
|
|
185
|
-
return undefined;
|
|
186
|
-
} })();
|
|
187
|
-
if (!vendor)
|
|
188
|
-
return { refs: [], unreadable: false };
|
|
189
|
-
const stored = await this.stored(agentId).catch(() => null);
|
|
190
|
-
if (stored === null)
|
|
191
|
-
return "unreadable";
|
|
192
|
-
const opened = stored.forgotten.filter((gone) => gone.provider === vendor).map((gone) => this.open(agentId, gone));
|
|
193
|
-
return { refs: opened.filter((ref) => ref !== undefined), unreadable: opened.some((ref) => ref === undefined) };
|
|
194
|
-
}
|
|
195
|
-
/** The sign-in run `runId` of `agentId` starts from on `resolution` (its plane's browser): made at the vendor when the
|
|
196
|
-
* agent has none, then leased to this run to save, unless another run of the agent holds the lease. None for a
|
|
197
|
-
* browser that keeps none, or with no seal key. `keep`: the run keeps that it was handed it (its serve.json), before
|
|
198
|
-
* any forget of the agent's can look (forget's handedTo, under the same lock); one it could not keep is handed none. */
|
|
199
|
-
async forRun(agentId, runId, resolution, keep) {
|
|
200
|
-
const vendor = vendorOf(resolution);
|
|
201
|
-
if (!vendor || !this.key)
|
|
202
|
-
return undefined;
|
|
203
|
-
const key = this.key;
|
|
204
|
-
// The Browserbase saver itself, resumed while its last save is still being written back (held_until): it waits that
|
|
205
|
-
// out, at most BROWSERBASE_SETTLE_MS, before it is handed save again, so no session of it opens on a context in flux.
|
|
206
|
-
const mine = (await this.read(agentId).catch(() => [])).find((e) => e.key === SIGN_IN_KEY && e.provider === vendor && e.held_by === runId && e.held_until);
|
|
207
|
-
const rest = mine ? Date.parse(mine.held_until) - this.now() : 0;
|
|
208
|
-
if (rest > 0)
|
|
209
|
-
await this.sleep(Math.min(rest, BROWSERBASE_SETTLE_MS));
|
|
210
|
-
return this.locked(agentId, async () => {
|
|
211
|
-
const entries = await this.read(agentId);
|
|
212
|
-
let entry = entries.find((e) => e.key === SIGN_IN_KEY && e.provider === vendor);
|
|
213
|
-
let ref;
|
|
214
|
-
let made = false;
|
|
215
|
-
if (entry) {
|
|
216
|
-
// Never replaced by itself: the vendor's object it points to would be left behind, holding the agent's cookies.
|
|
217
|
-
ref = this.open(agentId, entry);
|
|
218
|
-
if (ref === undefined)
|
|
219
|
-
throw new Error(`its saved sign-in does not open under this server's seal key: forget it (DELETE /v2/agents/${agentId}/sign-ins/${SIGN_IN_KEY}) and its next run signs in afresh`);
|
|
220
|
-
}
|
|
221
|
-
else {
|
|
222
|
-
ref = await this.vendors.create(vendor);
|
|
223
|
-
made = true;
|
|
224
|
-
entry = { key: SIGN_IN_KEY, provider: vendor, ref: "", verified_at: null, held_by: null };
|
|
225
|
-
entry.ref = seal(key, Buffer.from(ref, "utf8"), aad(agentId, entry)).toString("base64");
|
|
226
|
-
entries.push(entry);
|
|
227
|
-
}
|
|
228
|
-
const save = entry.held_by === runId || !(await this.held(entry));
|
|
229
|
-
if (save)
|
|
230
|
-
Object.assign(entry, { held_by: runId, gone_at: null, held_until: null });
|
|
231
|
-
try {
|
|
232
|
-
await this.write(agentId, entries);
|
|
233
|
-
}
|
|
234
|
-
catch (error) {
|
|
235
|
-
// Never kept, so never forgotten: the object just made goes at the vendor now, as far as it answers. Unless the
|
|
236
|
-
// write landed and only what follows it failed (the folder's sync): then the pointer is kept, and so is its object.
|
|
237
|
-
const sealed = entry.ref;
|
|
238
|
-
const kept = await this.read(agentId).then((now) => now.some((e) => e.ref === sealed), () => false);
|
|
239
|
-
if (made && !kept)
|
|
240
|
-
await this.vendors.remove(vendor, ref).catch(() => undefined);
|
|
241
|
-
throw error;
|
|
242
|
-
}
|
|
243
|
-
const handed = { provider: vendor, ref, save };
|
|
244
|
-
return !keep || (await keep(handed)) ? handed : undefined;
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
/** Run `runId`'s process was found gone: a lease it holds counts from now, while it does not come back (held). */
|
|
248
|
-
markGone(agentId, runId) {
|
|
249
|
-
return this.locked(agentId, async () => {
|
|
250
|
-
const entries = await this.read(agentId);
|
|
251
|
-
const mine = entries.filter((entry) => entry.held_by === runId && !entry.gone_at && !entry.held_until);
|
|
252
|
-
if (!mine.length)
|
|
253
|
-
return;
|
|
254
|
-
for (const entry of mine)
|
|
255
|
-
entry.gone_at = new Date(this.now()).toISOString();
|
|
256
|
-
await this.write(agentId, entries);
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
/** Ends the lease run `runId` holds, if it holds one: it ended, or let go to wait for its person; one whose process did
|
|
260
|
-
* not let its sessions go (`clean` false) keeps it until the gone rule ends it. A session of it that saved (its
|
|
261
|
-
* run directory's SIGN_IN_SAVED) makes that the sign-in's `verified_at`. */
|
|
262
|
-
release(agentId, runId, runDir, clean = true) {
|
|
263
|
-
return this.locked(agentId, async () => {
|
|
264
|
-
const marker = join(runDir, SIGN_IN_SAVED);
|
|
265
|
-
const saved = await readFile(marker, "utf8").then((text) => text.trim(), () => undefined);
|
|
266
|
-
const entries = await this.read(agentId);
|
|
267
|
-
const mine = entries.filter((entry) => entry.held_by === runId && !entry.held_until);
|
|
268
|
-
if (mine.length) {
|
|
269
|
-
const when = saved && !Number.isNaN(Date.parse(saved)) ? new Date(saved).toISOString() : undefined;
|
|
270
|
-
const now = new Date(this.now()).toISOString();
|
|
271
|
-
// `clean`: its process let its sessions go. One that crashed may have left a session live at the vendor, which
|
|
272
|
-
// writes back when it ends: the lease stays named for it, and the gone rule (held) ends it.
|
|
273
|
-
// A Browserbase session that saved is still being written back: the lease waits that out, named for this run.
|
|
274
|
-
for (const entry of mine)
|
|
275
|
-
Object.assign(entry, !clean ? { gone_at: entry.gone_at ?? now } : { gone_at: null, ...(when && entry.provider === "browserbase" ? { held_until: new Date(this.now() + BROWSERBASE_SETTLE_MS).toISOString() } : { held_by: null, held_until: null }) }, when ? { verified_at: when } : {});
|
|
276
|
-
await this.write(agentId, entries);
|
|
277
|
-
}
|
|
278
|
-
await rm(marker, { force: true });
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
/** DELETE /agents/{id}/sign-ins/{key}: each vendor's object deleted (best effort: what failed is said), then the
|
|
282
|
-
* 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
|
|
283
|
-
* going (handedTo), its lease let go or not: what that run says could repeat the pointer, and a server started after
|
|
284
|
-
* the pointer is gone could no longer read it back to cut it (runs.ts peekSignIn). */
|
|
285
|
-
forget(agentId, signInKey) {
|
|
286
|
-
return this.locked(agentId, async () => {
|
|
287
|
-
const entries = await this.read(agentId);
|
|
288
|
-
const named = entries.filter((entry) => entry.key === signInKey);
|
|
289
|
-
if (!named.length)
|
|
290
|
-
throw new ApiError("not_found", `The agent ${agentId} has no sign-in ${signInKey}.`);
|
|
291
|
-
for (const entry of named)
|
|
292
|
-
if (await this.held(entry))
|
|
293
|
-
throw new ApiError("sign_in_held", `The sign-in ${signInKey} is held by the run ${entry.held_by}, which may still save to it: forget it once that run ends.`, { details: { held_by: entry.held_by } });
|
|
294
|
-
// Asked under the lock a launch hands a pointer under (forRun's keep): a run handed it now is one this sees.
|
|
295
|
-
for (const entry of named) {
|
|
296
|
-
const ref = this.open(agentId, entry);
|
|
297
|
-
const runId = await this.handedTo?.(agentId, ref === undefined ? undefined : pointerHash(ref));
|
|
298
|
-
if (runId)
|
|
299
|
-
throw new ApiError("sign_in_held", `The sign-in ${signInKey} was handed to the run ${runId}, which is still going: what it says could repeat it, and once it is forgotten a restarted server could no longer cut it from what that run shows. Forget it once that run ends.`, { details: { handed_to: runId } });
|
|
300
|
-
}
|
|
301
|
-
const removed = [];
|
|
302
|
-
for (const entry of named) {
|
|
303
|
-
const ref = this.open(agentId, entry);
|
|
304
|
-
const gone = ref === undefined ? new Error("its pointer does not open under this server's seal key") : await this.vendors.remove(entry.provider, ref).then(() => undefined, (error) => error);
|
|
305
|
-
removed.push({ provider: entry.provider, at_vendor: gone ? "not_deleted" : "deleted", ...(gone ? { message: `Not deleted at ${entry.provider}: ${gone.message}. This server no longer points to it.` } : {}) });
|
|
306
|
-
}
|
|
307
|
-
// Each forgotten pointer is kept sealed as it was, for cutting alone (Forgotten), the newest MAX_FORGOTTEN of them.
|
|
308
|
-
const { forgotten } = await this.stored(agentId);
|
|
309
|
-
const at = new Date(this.now()).toISOString();
|
|
310
|
-
const kept = [...forgotten, ...named.map((entry) => ({ key: entry.key, provider: entry.provider, ref: entry.ref, forgotten_at: at }))].slice(-MAX_FORGOTTEN);
|
|
311
|
-
await this.write(agentId, entries.filter((entry) => entry.key !== signInKey), kept);
|
|
312
|
-
return { key: signInKey, removed };
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
10
|
const base = (set, fallback) => (set?.trim() || fallback).replace(/\/+$/, "");
|
|
317
11
|
/** The vendors over their REST APIs, with the server's keys (`env`, read at each call) through `fetchFor` (the tests'
|
|
318
12
|
* fakes under faux). Browserbase: a context made for the agent (POST /v1/contexts, which opens no session; Browserbase
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const HOOK_TOLERANCE_S = 300;
|
|
3
3
|
/** The fewest bytes a verification key may have (the spec's secrets are 24 to 64; this server makes 32): a shorter one,
|
|
4
4
|
* an empty one above all, signs nothing. It is the floor for keys a request is verified with alone: a sealed setting
|
|
5
|
-
* that is such a key declares `minBytes: MIN_KEY_BYTES` (sealed-settings.ts); a token that is no HMAC key (a bot's)
|
|
5
|
+
* that is such a key declares `minBytes: MIN_KEY_BYTES` (sealed-settings-store.ts); a token that is no HMAC key (a bot's)
|
|
6
6
|
* sets its own floor, or none. */
|
|
7
7
|
export declare const MIN_KEY_BYTES = 24;
|
|
8
8
|
/** A webhook-id: printable ASCII with no space, as the spec's `msg_...` ids are; it goes into a firing's key and history. */
|
|
@@ -7,7 +7,7 @@ import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
|
|
|
7
7
|
export const HOOK_TOLERANCE_S = 300;
|
|
8
8
|
/** The fewest bytes a verification key may have (the spec's secrets are 24 to 64; this server makes 32): a shorter one,
|
|
9
9
|
* an empty one above all, signs nothing. It is the floor for keys a request is verified with alone: a sealed setting
|
|
10
|
-
* that is such a key declares `minBytes: MIN_KEY_BYTES` (sealed-settings.ts); a token that is no HMAC key (a bot's)
|
|
10
|
+
* that is such a key declares `minBytes: MIN_KEY_BYTES` (sealed-settings-store.ts); a token that is no HMAC key (a bot's)
|
|
11
11
|
* sets its own floor, or none. */
|
|
12
12
|
export const MIN_KEY_BYTES = 24;
|
|
13
13
|
/** A webhook-id: printable ASCII with no space, as the spec's `msg_...` ids are; it goes into a firing's key and history. */
|
package/dist/stats.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { StoreStats } from "./store-reads/stats.js";
|
|
2
|
+
import type { AnalyticsFilter, PendingEnd, StoreAnalytics } from "./store-reads/analytics.js";
|
|
2
3
|
import { type Status } from "./run-view.js";
|
|
3
4
|
/** GET /stats's counts, from the store's aggregates (StoreStats) and each running row's status read over the store
|
|
4
5
|
* (`statusOf`, viewOverStore): the runner writes a run's end to the store before it lets it go, so this server holds no
|
|
@@ -91,7 +92,7 @@ export declare function analyticsView(a: StoreAnalytics, filter: AnalyticsFilter
|
|
|
91
92
|
tokens: number;
|
|
92
93
|
cost_usd: number | null;
|
|
93
94
|
unknown_cost_runs: number;
|
|
94
|
-
source: "live" | import("
|
|
95
|
+
source: "live" | import("./store-reads/analytics.js").ImportSource;
|
|
95
96
|
}[];
|
|
96
97
|
tools: {
|
|
97
98
|
tool: string;
|
package/dist/stats.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { nameOf } from "
|
|
1
|
+
import { nameOf } from "./timeline/index.js";
|
|
2
2
|
import { ApiError } from "./errors.js";
|
|
3
3
|
import { ID } from "./validate.js";
|
|
4
4
|
/** Where a running row is counted, by its status (a paused workflow run is active). Over the store a run's status is its
|
package/dist/stop-signals.d.ts
CHANGED
|
@@ -15,8 +15,10 @@ export type StopDeps = {
|
|
|
15
15
|
export declare const REPEAT_MS = 1000;
|
|
16
16
|
/** How long past its runs' drain bound a stop may take before it stops at once. */
|
|
17
17
|
export declare const DEADLINE_MARGIN_MS = 15000;
|
|
18
|
-
/** The handler for SIGINT and SIGTERM. It exits once: 0 when the close ends, 130 when it stops at once.
|
|
18
|
+
/** The handler for SIGINT and SIGTERM. It exits once: 0 when the close ends, 130 when it stops at once. `askedAt`: when
|
|
19
|
+
* the stop was asked, when earlier than this call (a signal during the start, cli.ts), so a second signal is timed from
|
|
20
|
+
* the first. */
|
|
19
21
|
export declare function stopOnSignals(deps: StopDeps, { repeatMs, marginMs }?: {
|
|
20
22
|
repeatMs?: number | undefined;
|
|
21
23
|
marginMs?: number | undefined;
|
|
22
|
-
}): () => void;
|
|
24
|
+
}): (askedAt?: number) => void;
|
package/dist/stop-signals.js
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
export const REPEAT_MS = 1_000;
|
|
8
8
|
/** How long past its runs' drain bound a stop may take before it stops at once. */
|
|
9
9
|
export const DEADLINE_MARGIN_MS = 15_000;
|
|
10
|
-
/** The handler for SIGINT and SIGTERM. It exits once: 0 when the close ends, 130 when it stops at once.
|
|
10
|
+
/** The handler for SIGINT and SIGTERM. It exits once: 0 when the close ends, 130 when it stops at once. `askedAt`: when
|
|
11
|
+
* the stop was asked, when earlier than this call (a signal during the start, cli.ts), so a second signal is timed from
|
|
12
|
+
* the first. */
|
|
11
13
|
export function stopOnSignals(deps, { repeatMs = REPEAT_MS, marginMs = DEADLINE_MARGIN_MS } = {}) {
|
|
12
14
|
const now = deps.now ?? Date.now;
|
|
13
15
|
const setTimer = deps.setTimer ?? ((run, ms) => void setTimeout(run, ms).unref());
|
|
@@ -25,13 +27,13 @@ export function stopOnSignals(deps, { repeatMs = REPEAT_MS, marginMs = DEADLINE_
|
|
|
25
27
|
const { runs } = deps.stopping();
|
|
26
28
|
end(130, `${why}; runs resume on the next start${runs > 0 ? ` (${runs} ${runs === 1 ? "was" : "were"} running)` : ""}`);
|
|
27
29
|
};
|
|
28
|
-
return () => {
|
|
30
|
+
return (askedAt) => {
|
|
29
31
|
if (stopAt !== undefined) {
|
|
30
32
|
if (now() - stopAt >= repeatMs)
|
|
31
33
|
stopNow("stopping now");
|
|
32
34
|
return;
|
|
33
35
|
}
|
|
34
|
-
stopAt = now();
|
|
36
|
+
stopAt = askedAt ?? now();
|
|
35
37
|
setTimer(() => stopNow("the stop passed its deadline, stopping now"), deps.stopping().boundMs + marginMs);
|
|
36
38
|
void deps.close().then(() => end(0));
|
|
37
39
|
};
|
|
@@ -26,11 +26,17 @@ export type RevisionPlace = {
|
|
|
26
26
|
mode: string;
|
|
27
27
|
box?: string;
|
|
28
28
|
};
|
|
29
|
-
/** A revision's computer (computer-setting.ts): its kind and the provider that serves it, ids its host knows
|
|
30
|
-
* its v2 view.
|
|
29
|
+
/** A revision's computer (computer-setting.ts): its kind and the provider that serves it, ids its host knows, and a
|
|
30
|
+
* sandbox's GPUs, a type its provider names and how many; `place` is its v2 view. `image`: one the provider offers for
|
|
31
|
+
* the kind, absent for its default. */
|
|
31
32
|
export type RevisionComputer = {
|
|
32
33
|
kind: string;
|
|
33
34
|
provider?: string;
|
|
35
|
+
image?: string;
|
|
36
|
+
gpu?: {
|
|
37
|
+
type: string;
|
|
38
|
+
count: number;
|
|
39
|
+
};
|
|
34
40
|
};
|
|
35
41
|
/** A revision's tool settings as its body keeps them: a map of a tool's key to its settings ({provider?, permission?,
|
|
36
42
|
* pin?}), checked and made canonical by the caller (agents-store.ts, through tool-plane's settingsIssues +
|
|
@@ -51,6 +57,8 @@ export type AgenticBody = {
|
|
|
51
57
|
maxCostUsd?: number;
|
|
52
58
|
capMode?: string;
|
|
53
59
|
approvals?: "ask" | "never";
|
|
60
|
+
outputSchema?: Record<string, unknown>;
|
|
61
|
+
maxToolCalls?: number;
|
|
54
62
|
};
|
|
55
63
|
export type WorkflowBody = {
|
|
56
64
|
workflow: Record<string, unknown>;
|
|
@@ -82,6 +90,8 @@ export type RevisionBodyInput = {
|
|
|
82
90
|
maxCostUsd?: number;
|
|
83
91
|
capMode?: string;
|
|
84
92
|
approvals?: "ask" | "never";
|
|
93
|
+
outputSchema?: Record<string, unknown>;
|
|
94
|
+
maxToolCalls?: number;
|
|
85
95
|
} | {
|
|
86
96
|
kind: "workflow";
|
|
87
97
|
workflow: unknown;
|
package/dist/store/agent-body.js
CHANGED
|
@@ -42,12 +42,22 @@ function placeOf(place) {
|
|
|
42
42
|
const ok = place;
|
|
43
43
|
return { mode: ok.mode, ...(ok.box !== undefined ? { box: ok.box } : {}) };
|
|
44
44
|
}
|
|
45
|
-
/** A
|
|
45
|
+
/** A GPU type as a body keeps it: the vendor's own name ("T4", "A100-80GB", "RTX-PRO-6000"). */
|
|
46
|
+
const GPU_TYPE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
47
|
+
/** A computer as a body keeps it: `{kind, provider?, image?, gpu?}`, nothing else: kind and provider ids, image a name
|
|
48
|
+
* with no spaces around it, and gpu `{type, count}`, a GPU type name and a whole count from 1. */
|
|
46
49
|
function computerOf(computer) {
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
const image = isObject(computer) ? computer.image : undefined;
|
|
51
|
+
const named = (value) => typeof value === "string" && value !== "" && value === value.trim();
|
|
52
|
+
if (!isObject(computer) || !hostId(computer.kind) || (computer.provider !== undefined && !hostId(computer.provider)) || (image !== undefined && !named(image)) || Object.keys(computer).some((key) => key !== "kind" && key !== "provider" && key !== "image" && key !== "gpu"))
|
|
53
|
+
invalid("the computer is not {kind, provider?, image?, gpu?}, kind and provider each an id (lowercase letters, digits and dashes), image a name");
|
|
49
54
|
const ok = computer;
|
|
50
|
-
|
|
55
|
+
const gpu = ok.gpu;
|
|
56
|
+
if (gpu !== undefined && (!isObject(gpu) || Object.keys(gpu).some((key) => key !== "type" && key !== "count") || typeof gpu.type !== "string" || !GPU_TYPE.test(gpu.type) || !Number.isSafeInteger(gpu.count) || gpu.count < 1)) {
|
|
57
|
+
invalid("the computer's gpu is not {type, count}: a GPU type name (letters, digits, dots, underscores and dashes) and a whole count from 1");
|
|
58
|
+
}
|
|
59
|
+
const kept = gpu;
|
|
60
|
+
return { kind: ok.kind, ...(ok.provider !== undefined ? { provider: ok.provider } : {}), ...(ok.image !== undefined ? { image: ok.image } : {}), ...(kept !== undefined ? { gpu: { type: kept.type, count: kept.count } } : {}) };
|
|
51
61
|
}
|
|
52
62
|
/** The body of a new revision and the text of each skill it names (path to text), everything checked here, before any
|
|
53
63
|
* write. The body keeps each skill path to its text's SHA-256; `skills` is the texts, for the revision's row. */
|
|
@@ -101,6 +111,10 @@ export function bodyOf(input) {
|
|
|
101
111
|
invalid(`the ${field} is not a non-empty string`);
|
|
102
112
|
if (input.learning !== undefined && typeof input.learning !== "boolean")
|
|
103
113
|
invalid("learning is not true or false");
|
|
114
|
+
if (input.outputSchema !== undefined && !isObject(input.outputSchema))
|
|
115
|
+
invalid("the outputSchema is not a JSON object");
|
|
116
|
+
if (input.maxToolCalls !== undefined && !(Number.isSafeInteger(input.maxToolCalls) && input.maxToolCalls > 0))
|
|
117
|
+
invalid("the maxToolCalls is not a whole number above 0");
|
|
104
118
|
const body = {
|
|
105
119
|
instructions: input.instructions,
|
|
106
120
|
skills: skillShas,
|
|
@@ -110,6 +124,10 @@ export function bodyOf(input) {
|
|
|
110
124
|
...(input.prompts !== undefined ? { prompts: structuredClone(input.prompts) } : {}),
|
|
111
125
|
...host,
|
|
112
126
|
...(input.learning !== undefined ? { learning: input.learning } : {}),
|
|
127
|
+
// The JSON Schema its final answer's structured part meets (definition.output_schema): a completed run's result.output.
|
|
128
|
+
...(input.outputSchema !== undefined ? { outputSchema: structuredClone(input.outputSchema) } : {}),
|
|
129
|
+
// The tool calls each conversation of its runs may make (tool-budget.ts).
|
|
130
|
+
...(input.maxToolCalls !== undefined ? { maxToolCalls: input.maxToolCalls } : {}),
|
|
113
131
|
// The agent's unattended policy (PR #2003): the runner's gate reads it from the revision body at claim (`unattended`
|
|
114
132
|
// below: "never" alone is kept).
|
|
115
133
|
...capped,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** How often an open transaction's deadline looks at the process's event loop, and how far past its look a look may
|
|
2
|
+
* come before the gap counts as the process held up (runnableDeadline). */
|
|
3
|
+
export declare const TICK_MS = 50;
|
|
4
|
+
export declare const STALL_MS = 50;
|
|
5
|
+
/** A running deadline: `clear()` stops it; `held()` is the time it gave back so far, the process held up, so a bound
|
|
6
|
+
* reckoned from the deadline's due time (a Postgres commit's) moves with it. A hold that ended since the last look is
|
|
7
|
+
* counted as `held()` reads it, never left for a look that would come after the bound was reckoned. */
|
|
8
|
+
export type RunnableDeadline = {
|
|
9
|
+
clear(): void;
|
|
10
|
+
held(): number;
|
|
11
|
+
};
|
|
12
|
+
/** Calls `expire` once `ms` of the time this process could run have passed, counted from now on the monotonic clock
|
|
13
|
+
* (performance.now: the host's clock set forward or back is never counted). A look every TICK_MS measures the event
|
|
14
|
+
* loop: a gap more than STALL_MS past its look was the process held up by other work (a harness binary hashed, a
|
|
15
|
+
* command run synchronously, the machine holding the process), wherever in the transaction it fell, before its
|
|
16
|
+
* deadline or across it, and is not counted. A wait of the transaction's own (a call awaited inside it) leaves the
|
|
17
|
+
* loop free, so it counts in full and is refused on time. */
|
|
18
|
+
export declare function runnableDeadline(ms: number, expire: () => void): RunnableDeadline;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// A store transaction's deadline counted from its begin, the one rule both connections keep (sqlite/connection.ts,
|
|
2
|
+
// postgres/connection.ts): only the time this process could run counts. One counted from its call (a lease's renew, a
|
|
3
|
+
// fromCall transaction) stays each connection's wall-clock timer.
|
|
4
|
+
/** How often an open transaction's deadline looks at the process's event loop, and how far past its look a look may
|
|
5
|
+
* come before the gap counts as the process held up (runnableDeadline). */
|
|
6
|
+
export const TICK_MS = 50;
|
|
7
|
+
export const STALL_MS = 50;
|
|
8
|
+
/** Calls `expire` once `ms` of the time this process could run have passed, counted from now on the monotonic clock
|
|
9
|
+
* (performance.now: the host's clock set forward or back is never counted). A look every TICK_MS measures the event
|
|
10
|
+
* loop: a gap more than STALL_MS past its look was the process held up by other work (a harness binary hashed, a
|
|
11
|
+
* command run synchronously, the machine holding the process), wherever in the transaction it fell, before its
|
|
12
|
+
* deadline or across it, and is not counted. A wait of the transaction's own (a call awaited inside it) leaves the
|
|
13
|
+
* loop free, so it counts in full and is refused on time. */
|
|
14
|
+
export function runnableDeadline(ms, expire) {
|
|
15
|
+
const start = performance.now();
|
|
16
|
+
let last = start;
|
|
17
|
+
let held = 0;
|
|
18
|
+
const look = () => {
|
|
19
|
+
const now = performance.now();
|
|
20
|
+
const gap = now - last - TICK_MS;
|
|
21
|
+
if (gap > STALL_MS)
|
|
22
|
+
held += gap;
|
|
23
|
+
last = now;
|
|
24
|
+
return now;
|
|
25
|
+
};
|
|
26
|
+
const ticks = setInterval(look, TICK_MS);
|
|
27
|
+
let timer;
|
|
28
|
+
const check = () => {
|
|
29
|
+
const left = ms - (look() - start - held);
|
|
30
|
+
if (left <= 0)
|
|
31
|
+
return expire();
|
|
32
|
+
timer = setTimeout(check, Math.ceil(left));
|
|
33
|
+
};
|
|
34
|
+
timer = setTimeout(check, ms);
|
|
35
|
+
return {
|
|
36
|
+
clear: () => {
|
|
37
|
+
clearInterval(ticks);
|
|
38
|
+
clearTimeout(timer);
|
|
39
|
+
},
|
|
40
|
+
held: () => {
|
|
41
|
+
look();
|
|
42
|
+
return held;
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
package/dist/store/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AgentArchived, CommandTaken, endedReason, ExternalBodyConflict, FINAL_STATES, Fenced, MCP_REFRESH_CALL_MS, MCP_REFRESH_LEASE_MS, RunFinal, SchemaVersionUnknown,
|
|
1
|
+
export { AgentArchived, CommandTaken, endedReason, ExternalBodyConflict, FINAL_STATES, Fenced, MCP_REFRESH_CALL_MS, MCP_REFRESH_LEASE_MS, RevisionMoved, RunFinal, SchemaVersionUnknown, SignInHandedTo, SignInMissing, StoreBusy, StoreClosed, StoreConstraint, StoreDeadline, StoreFromEarlierVersion, StoreLaunchMissing, StoreOwned, StoreWorkerLost, STORE_WRITE_DEADLINE_MS, TriggerFull } from "./store.js";
|
|
2
2
|
export type { ConstraintRule, AgentRow, Agents, AlsoRow, ChannelPost, Claim, Command, ComputerLedger, ComputerLedgerRow, Firing, FiringChange, FiringRow, FiringStatus, FiringStreak, Journal, Live, LiveRow, Mcp, McpCredentialMark, McpOauth, McpOauthPendingRow, McpPinRow, McpServerRow, McpServerWrite, NewFiring, NewRevision, NewTrigger, ReleasedState, RevisionRow, RunPatch, RunRow, Runs, RunState, SealedKeyRow, SealedKeys, SealedPlane, SealedSecretRow, SealedSecrets, SettingRow, Settings, Staged, StagedTake, Store, StoreRole, TemplatePackage, Templates, TriggerDef, TriggerPatch, TriggerRow, Triggers, TriggerScope, TriggerSettingRow, TriggerSettings, ImportedFrom, ImportSource, ImportRunInput, JournalReads, RunOrigin, RunOutcome, RunLaunchInput, RunLaunchRow, Learning, LearningProposal, LiveViewerRow, LiveViewers, SignIns, SignInRow, SignInTombstoneRow, UpdatedRun, ViewerKind, } from "./store.js";
|
|
3
3
|
export { aadOf, type McpCredential, type OpenedMcpCredential, openMcpCredential, sealColumn, type SealedAt, sealedAt, sealMcpCredential, unsealColumn } from "./seal.js";
|
|
4
4
|
export { AgentBodyInvalid, type AgenticBody, bodyOf, canonical, isObject, isSkillPath, type PromptVariant, type RevisionBodyInput, type RevisionComputer, type RevisionPlace, sha256, type ToolSettings, type WorkflowBody, } from "./agent-body.js";
|
|
@@ -11,7 +11,7 @@ export { Connection, DEFAULT_TRANSACTION_DEADLINE_MS, type SqliteDatabase, type
|
|
|
11
11
|
export { cleanText, type Dialect, SQLITE } from "./dialect.js";
|
|
12
12
|
export { DEFAULT_STORE_POOL_SIZE, MAX_STORE_POOL_SIZE, openStore, type OpenStoreOptions, storePlace, storePoolSize, storeTarget, type StoreTarget } from "./open.js";
|
|
13
13
|
export { CLOCK_WARN_MS, DEFAULT_SCHEMA, openPostgresStore, type PostgresStoreOptions, postgresWhere } from "./postgres/store.js";
|
|
14
|
-
export { LEASE_DEADLINE_MS, PgConnection, SCHEMA_NAME, STORE_CONNECT_TIMEOUT_MS, Unanswered } from "./postgres/connection.js";
|
|
14
|
+
export { LEASE_DEADLINE_MS, OWNER_WAIT_MS, PgConnection, SCHEMA_NAME, STORE_CONNECT_TIMEOUT_MS, Unanswered } from "./postgres/connection.js";
|
|
15
15
|
export { dropPostgresSchema, migrate, migrationsIn, versionOf as postgresVersionOf } from "./postgres/migrate.js";
|
|
16
16
|
export { applyRunPatch, RUN_COLUMNS, runOf, type RunRecord } from "./sqlite/run-patch.js";
|
|
17
17
|
export { readLaunch, writeLaunch } from "./sqlite/run-launch.js";
|
package/dist/store/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// The one store (design 2.1), for the cutover: nothing on main imports it until then.
|
|
2
|
-
export { AgentArchived, CommandTaken, endedReason, ExternalBodyConflict, FINAL_STATES, Fenced, MCP_REFRESH_CALL_MS, MCP_REFRESH_LEASE_MS, RunFinal, SchemaVersionUnknown,
|
|
2
|
+
export { AgentArchived, CommandTaken, endedReason, ExternalBodyConflict, FINAL_STATES, Fenced, MCP_REFRESH_CALL_MS, MCP_REFRESH_LEASE_MS, RevisionMoved, RunFinal, SchemaVersionUnknown, SignInHandedTo, SignInMissing, StoreBusy, StoreClosed, StoreConstraint, StoreDeadline, StoreFromEarlierVersion, StoreLaunchMissing, StoreOwned, StoreWorkerLost, STORE_WRITE_DEADLINE_MS, TriggerFull } from "./store.js";
|
|
3
3
|
export { aadOf, openMcpCredential, sealColumn, sealedAt, sealMcpCredential, unsealColumn } from "./seal.js";
|
|
4
4
|
export { AgentBodyInvalid, bodyOf, canonical, isObject, isSkillPath, sha256, } from "./agent-body.js";
|
|
5
5
|
export { checkPrompts, OTHER_OPTION, PromptsInvalid } from "./prompts.js";
|
|
@@ -11,7 +11,7 @@ export { Connection, DEFAULT_TRANSACTION_DEADLINE_MS } from "./sqlite/connection
|
|
|
11
11
|
export { cleanText, SQLITE } from "./dialect.js";
|
|
12
12
|
export { DEFAULT_STORE_POOL_SIZE, MAX_STORE_POOL_SIZE, openStore, storePlace, storePoolSize, storeTarget } from "./open.js";
|
|
13
13
|
export { CLOCK_WARN_MS, DEFAULT_SCHEMA, openPostgresStore, postgresWhere } from "./postgres/store.js";
|
|
14
|
-
export { LEASE_DEADLINE_MS, PgConnection, SCHEMA_NAME, STORE_CONNECT_TIMEOUT_MS, Unanswered } from "./postgres/connection.js";
|
|
14
|
+
export { LEASE_DEADLINE_MS, OWNER_WAIT_MS, PgConnection, SCHEMA_NAME, STORE_CONNECT_TIMEOUT_MS, Unanswered } from "./postgres/connection.js";
|
|
15
15
|
export { dropPostgresSchema, migrate, migrationsIn, versionOf as postgresVersionOf } from "./postgres/migrate.js";
|
|
16
16
|
export { applyRunPatch, RUN_COLUMNS, runOf } from "./sqlite/run-patch.js";
|
|
17
17
|
export { readLaunch, writeLaunch } from "./sqlite/run-launch.js";
|
package/dist/store/open.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Store, StoreRole } from "./store.js";
|
|
1
|
+
import type { Store, StoreOwned, StoreRole } from "./store.js";
|
|
2
2
|
/** Where a store is: SQLite's file in a data directory, or a schema on a Postgres. */
|
|
3
3
|
export type StoreTarget = {
|
|
4
4
|
readonly kind: "sqlite";
|
|
@@ -36,9 +36,12 @@ export interface OpenStoreOptions {
|
|
|
36
36
|
readonly url?: string;
|
|
37
37
|
/** The environment AGENTRUN_STORE_SCHEMA and AGENTRUN_STORE_POOL_SIZE are read from (process.env). Neither is a secret. */
|
|
38
38
|
readonly env?: NodeJS.ProcessEnv;
|
|
39
|
-
/** Told what a person should know at the open (a runner's clock far from Postgres's
|
|
39
|
+
/** Told what a person should know at the open (a runner's clock far from Postgres's; a server waiting for another to
|
|
40
|
+
* let the Postgres schema go). */
|
|
40
41
|
readonly warn?: (message: string) => void;
|
|
42
|
+
/** A server's, on Postgres: told when its owner lock is lost for good (PostgresStoreOptions.onOwnerLost). */
|
|
43
|
+
readonly onOwnerLost?: (error: StoreOwned) => void;
|
|
41
44
|
}
|
|
42
45
|
/** Opens the store `options` names (storeTarget): the server's and the runner's one way in. On Postgres its pool holds at
|
|
43
46
|
* most storePoolSize(env) connections; a pool size that is no size is refused on either store. */
|
|
44
|
-
export declare function openStore({ dataDir, role, now, url, env, warn }: OpenStoreOptions): Promise<Store>;
|
|
47
|
+
export declare function openStore({ dataDir, role, now, url, env, warn, onOwnerLost }: OpenStoreOptions): Promise<Store>;
|