@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/computers.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { type GpuCapability } from "@parcha/agentrun-computer";
|
|
1
2
|
import { type KeyTable, type OptionsAnswer, type ProviderFactories, type ProviderSettings } from "./computer-keys.js";
|
|
2
3
|
import { type ComputerKind, type ComputerSetting } from "./computer-setting.js";
|
|
4
|
+
import { type DockerDaemon } from "./docker-daemon.js";
|
|
3
5
|
import { type KeyEnv, type KeyMeta } from "./key-meta.js";
|
|
4
6
|
import type { Store } from "./store/index.js";
|
|
5
7
|
/** A setting kind as the kind registry's SETTING_KINDS gives it. */
|
|
@@ -8,10 +10,13 @@ export interface SettingKindSpec {
|
|
|
8
10
|
readonly required: readonly string[];
|
|
9
11
|
readonly optional: readonly string[];
|
|
10
12
|
}
|
|
11
|
-
/** A provider configuration's machine kind and groups,
|
|
13
|
+
/** A provider configuration's machine kind and groups, the GPUs it gives where it declares them, and the image a setting
|
|
14
|
+
* selects it by, where it names one, as the kind registry gives them. */
|
|
12
15
|
export type KindCapabilities = {
|
|
13
16
|
readonly kind: string;
|
|
14
17
|
readonly groups: readonly string[];
|
|
18
|
+
readonly gpu?: GpuCapability;
|
|
19
|
+
readonly image?: string;
|
|
15
20
|
};
|
|
16
21
|
/** A provider as the kind registry's PROVIDERS gives it. */
|
|
17
22
|
export interface ProviderEntry {
|
|
@@ -24,8 +29,13 @@ export interface ProviderEntry {
|
|
|
24
29
|
}[];
|
|
25
30
|
/** The mounts its computers take; none means it cannot mount the run's folder. */
|
|
26
31
|
readonly mounts: readonly string[];
|
|
32
|
+
/** The network forms its computers make ("none", "open", "allow"), as its descriptor declares them. Absent (a
|
|
33
|
+
* test's fixture): nothing is said of its network. */
|
|
34
|
+
readonly network?: readonly string[];
|
|
27
35
|
readonly metered: boolean;
|
|
28
36
|
readonly capabilities: readonly KindCapabilities[];
|
|
37
|
+
/** The image a computer of each kind starts from when its setting names none. */
|
|
38
|
+
readonly defaultImage?: Partial<Record<ComputerKind, string>>;
|
|
29
39
|
}
|
|
30
40
|
/** The kind registry, by its own names: the computer package's module (SETTING_KINDS, PROVIDERS, servingRefusals). */
|
|
31
41
|
export interface KindRegistry {
|
|
@@ -54,10 +64,14 @@ export interface ComputerRoutesOptions {
|
|
|
54
64
|
readonly mode: FolderMode | (() => FolderMode | Promise<FolderMode>);
|
|
55
65
|
/** The server's environment: a variable named as a provider's key overrides the saved one (source "env"). */
|
|
56
66
|
readonly env?: KeyEnv;
|
|
67
|
+
/** Whether a provider that binds a folder of this machine (Docker) answers here now, or why not (the server's daemon
|
|
68
|
+
* check, docker-daemon.ts, which keeps its answer a while). Absent: taken as answering. */
|
|
69
|
+
readonly answers?: (provider: string) => Promise<DockerDaemon>;
|
|
57
70
|
}
|
|
58
71
|
/** A provider as Settings shows it: `metered` straight from the kind registry (its computers are billed by the vendor);
|
|
59
72
|
* its keys as SecretMeta under `secrets`, each named "computer:<provider>:<KEY>", and `required`, the names of the ones
|
|
60
|
-
* it needs.
|
|
73
|
+
* it needs. `network`: what this server's allow-list means for a vendor-hosted computer, in words (networkWords).
|
|
74
|
+
* `images`: the images it offers for the kind, by name, where it offers any to choose. */
|
|
61
75
|
export type ProviderView = {
|
|
62
76
|
id: string;
|
|
63
77
|
name: string;
|
|
@@ -66,7 +80,26 @@ export type ProviderView = {
|
|
|
66
80
|
required: string[];
|
|
67
81
|
ready: boolean;
|
|
68
82
|
why?: string;
|
|
83
|
+
network?: string;
|
|
84
|
+
images?: string[];
|
|
85
|
+
gpu?: GpuView;
|
|
69
86
|
};
|
|
87
|
+
/** A sandbox provider's GPUs as Settings shows them: what its configuration declares (the types an agent's
|
|
88
|
+
* `computer.gpu.type` names, the most one computer gets, and the limits it states), and why a run here cannot have
|
|
89
|
+
* them, when it cannot: a GPU computer of it that takes no mount of this server's folder mode. */
|
|
90
|
+
export type GpuView = GpuCapability & {
|
|
91
|
+
why?: string;
|
|
92
|
+
};
|
|
93
|
+
/** A computer with no network: its programs run in a network of their own, so a run's allow-list is never offered it. */
|
|
94
|
+
export declare const NO_NETWORK_WORDS = "no network, so this server's allow-list isn't offered";
|
|
95
|
+
/** A computer on the vendor's own network: open, which this server's allow-list doesn't reach. */
|
|
96
|
+
export declare const VENDOR_NETWORK_WORDS = "the vendor's own network; this server's allow-list doesn't apply";
|
|
97
|
+
/** A browser behind its own egress proxy (Local Chrome): every public host, unless the operator set a list. */
|
|
98
|
+
export declare const OPERATOR_LIST_WORDS = "open unless this server sets AGENTRUN_BOX_ALLOW; then only those hosts";
|
|
99
|
+
/** What this server's allow-list means for a provider's computers, by the network forms it declares: words for one that
|
|
100
|
+
* makes "none" alone, "open" alone, or "open" and "allow" but no "none" (a browser behind its own proxy); none where
|
|
101
|
+
* the allow-list applies as it is (Docker), or nothing is declared. */
|
|
102
|
+
export declare function networkWords(network: readonly string[] | undefined): string | undefined;
|
|
70
103
|
export type KindView = {
|
|
71
104
|
kind: ComputerKind;
|
|
72
105
|
offered: boolean;
|
package/dist/computers.js
CHANGED
|
@@ -6,10 +6,13 @@
|
|
|
6
6
|
// their names only: a provider declares them, Settings takes only those, and the store keeps each sealed under the
|
|
7
7
|
// server's seal key (server-keys.ts); a provider is handed its keys only at the claim, or for its test, both through
|
|
8
8
|
// computer-keys.ts (providerOptions, testConnection), which maps a key's name onto the option it fills.
|
|
9
|
+
import { checkGpu, imagesOf } from "@parcha/agentrun-computer";
|
|
9
10
|
import { KEY_TABLE, providerOptions, testConnection } from "./computer-keys.js";
|
|
10
|
-
import { COMPUTER_KINDS } from "./computer-setting.js";
|
|
11
|
+
import { COMPUTER_KINDS, gpuOf } from "./computer-setting.js";
|
|
11
12
|
import { inArchilMode } from "./archil-settings.js";
|
|
13
|
+
import { daemonUp, noDockerWords } from "./docker-daemon.js";
|
|
12
14
|
import { ApiError, invalid } from "./errors.js";
|
|
15
|
+
import { redacted } from "./key-refusal.js";
|
|
13
16
|
import { keyMetaOf, envValue } from "./key-meta.js";
|
|
14
17
|
import { registerNotSecretWrite, registerSecretWrite, secretName } from "./secret-writes.js";
|
|
15
18
|
import { getSealedKey, putSealedKey, removeSealedKey, sealedKeyNames } from "./server-keys.js";
|
|
@@ -18,6 +21,24 @@ import { getSealedKey, putSealedKey, removeSealedKey, sealedKeyNames } from "./s
|
|
|
18
21
|
// is looked up, so a token learns nothing of which providers exist. The view and the connection test write none.
|
|
19
22
|
registerSecretWrite("saveComputerKeys", () => true);
|
|
20
23
|
registerNotSecretWrite("testComputer", "A connection test reads the saved keys and writes none.");
|
|
24
|
+
/** A computer with no network: its programs run in a network of their own, so a run's allow-list is never offered it. */
|
|
25
|
+
export const NO_NETWORK_WORDS = "no network, so this server's allow-list isn't offered";
|
|
26
|
+
/** A computer on the vendor's own network: open, which this server's allow-list doesn't reach. */
|
|
27
|
+
export const VENDOR_NETWORK_WORDS = "the vendor's own network; this server's allow-list doesn't apply";
|
|
28
|
+
/** A browser behind its own egress proxy (Local Chrome): every public host, unless the operator set a list. */
|
|
29
|
+
export const OPERATOR_LIST_WORDS = "open unless this server sets AGENTRUN_BOX_ALLOW; then only those hosts";
|
|
30
|
+
/** What this server's allow-list means for a provider's computers, by the network forms it declares: words for one that
|
|
31
|
+
* makes "none" alone, "open" alone, or "open" and "allow" but no "none" (a browser behind its own proxy); none where
|
|
32
|
+
* the allow-list applies as it is (Docker), or nothing is declared. */
|
|
33
|
+
export function networkWords(network) {
|
|
34
|
+
if (network?.length === 1 && network[0] === "none")
|
|
35
|
+
return NO_NETWORK_WORDS;
|
|
36
|
+
if (network?.length === 1 && network[0] === "open")
|
|
37
|
+
return VENDOR_NETWORK_WORDS;
|
|
38
|
+
if (network?.length === 2 && network.includes("open") && network.includes("allow"))
|
|
39
|
+
return OPERATOR_LIST_WORDS;
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
21
42
|
/** Why a key save is refused, before anything is saved: a name the provider does not declare, or a value that is not text. */
|
|
22
43
|
export class KeysRefused extends Error {
|
|
23
44
|
fields;
|
|
@@ -43,16 +64,43 @@ export function modeRefusal(kind, provider, mode) {
|
|
|
43
64
|
return `${provider.label} can't mount the owner's disk this server keeps run folders on: set this agent's computer to a sandbox that mounts it, or none (Settings → Computers)`;
|
|
44
65
|
return undefined;
|
|
45
66
|
}
|
|
67
|
+
/** The GPUs a sandbox of `provider` gives, as its configuration that serves a sandbox declares them, or undefined. */
|
|
68
|
+
const sandboxGpu = (kinds, provider) => provider.capabilities.find((one) => one.gpu !== undefined && kinds.servingRefusals(one, "sandbox").length === 0)?.gpu;
|
|
69
|
+
/** The mount a sandbox takes in `mode`: the run's folder, a bind of this machine or the owner's Archil disk. */
|
|
70
|
+
const folderMount = (mode) => ({ kind: mode === "local" ? "bind" : "archil" });
|
|
71
|
+
/** A sandbox provider's GPUs as Settings shows them, with why a run here cannot have them (checkGpu's words for its
|
|
72
|
+
* smallest ask, one of its first type, with this mode's mount). */
|
|
73
|
+
function gpuView(gpu, mode) {
|
|
74
|
+
const [refusal] = gpu.types.length ? checkGpu({ type: gpu.types[0], count: 1 }, { gpu }, folderMount(mode)) : [];
|
|
75
|
+
return { ...structuredClone(gpu), ...(refusal ? { why: refusal.message } : {}) };
|
|
76
|
+
}
|
|
77
|
+
/** Why `computer`'s GPUs cannot be had on `provider` in `mode`, in checkGpu's words; undefined when they can, or it asks
|
|
78
|
+
* for none (only a sandbox does). */
|
|
79
|
+
function gpuRefusal(kinds, computer, provider, mode) {
|
|
80
|
+
const asked = gpuOf(computer);
|
|
81
|
+
if (!asked)
|
|
82
|
+
return undefined;
|
|
83
|
+
const gpu = sandboxGpu(kinds, provider);
|
|
84
|
+
const [refusal] = checkGpu(asked, gpu ? { gpu } : {}, folderMount(mode));
|
|
85
|
+
return refusal ? `${provider.label} can't give this agent's computer its GPUs: ${refusal.message} (Settings → Computers)` : undefined;
|
|
86
|
+
}
|
|
46
87
|
/** The required keys `provider` has no saved value for, by name. */
|
|
47
88
|
const missingKeys = (provider, saved) => provider.keys.filter((key) => key.required && !saved.has(key.name)).map((key) => key.name);
|
|
48
|
-
/** Why a provider with keys missing is not ready, naming the setting to fill
|
|
49
|
-
|
|
89
|
+
/** Why a provider with keys missing is not ready, naming the setting to fill: a person reads it (the view, the test), so
|
|
90
|
+
* it ends at the setting. A caller's refusal (the claim's) adds the route that saves them (`route`). */
|
|
91
|
+
const keysWhy = (provider, missing, route = false) => `${provider.label} needs ${missing.join(" and ")} saved: save ${missing.length > 1 ? "them" : "it"} in Settings → Computers${route ? ` (PUT /v2/computers/${provider.id}/keys)` : ""}`;
|
|
92
|
+
/** Whether `provider` binds a folder of this machine, so its computers need this machine's Docker daemon. */
|
|
93
|
+
const local = (provider) => provider.mounts.includes("bind");
|
|
50
94
|
/** The routes' work over the server's store: GET /v2/computers (view), PUT /v2/computers/{provider}/keys (saveKeys), POST
|
|
51
95
|
* /v2/computers/{provider}/test (test), and the claim's refusal (claimRefusal). */
|
|
52
96
|
export function createComputerRoutes(options) {
|
|
53
|
-
const { store, sealKey, kinds, factories, settings = {}, keyTable = KEY_TABLE, tools, env = {} } = options;
|
|
97
|
+
const { store, sealKey, kinds, factories, settings = {}, keyTable = KEY_TABLE, tools, env = {}, answers = daemonUp } = options;
|
|
54
98
|
const providerOf = (id) => kinds.PROVIDERS.find((one) => one.id === id);
|
|
55
99
|
const modeNow = async () => (typeof options.mode === "function" ? options.mode() : options.mode);
|
|
100
|
+
/** Why a computer of `kind` on `provider` can't be had for its daemon (a provider that binds a folder of this machine,
|
|
101
|
+
* `said` its answer, in folder `mode`): none answering is the one wording (docker-daemon.ts noDockerWords); else its
|
|
102
|
+
* reason. */
|
|
103
|
+
const daemonWhy = (kind, said, mode) => said.up ? undefined : said.absent ? noDockerWords(kind, kinds.PROVIDERS, mode === "disk" ? 2 : 1) : said.reason;
|
|
56
104
|
/** Each kind, whether this server offers it and why not, the capability groups and tools it brings, and each provider
|
|
57
105
|
* that serves it, with its keys (saved or not, never a value) and whether a run could have it now. */
|
|
58
106
|
async function view() {
|
|
@@ -62,14 +110,22 @@ export function createComputerRoutes(options) {
|
|
|
62
110
|
const slots = kinds.PROVIDERS.flatMap((provider) => provider.keys.map((key) => ({ secret: secretName("computer", provider.id, key.name), env: key.name, row: key.name })));
|
|
63
111
|
const metas = new Map((await keyMetaOf(store, slots, env)).map((meta) => [meta.name, meta]));
|
|
64
112
|
const saved = new Set(slots.filter((slot) => metas.get(slot.secret).set).map((slot) => slot.env));
|
|
113
|
+
// Each provider that binds a folder of this machine asked once for the view: its daemon answers, or why not.
|
|
114
|
+
const daemons = new Map(await Promise.all(kinds.PROVIDERS.filter(local).map(async (provider) => [provider.id, await answers(provider.id)])));
|
|
65
115
|
return {
|
|
66
116
|
kinds: COMPUTER_KINDS.map((kind) => {
|
|
67
117
|
const spec = kinds.SETTING_KINDS[kind];
|
|
68
118
|
const serving = kinds.PROVIDERS.filter((provider) => provider.kinds.includes(kind));
|
|
69
119
|
const providers = serving.map((provider) => {
|
|
70
120
|
const missing = missingKeys(provider, saved);
|
|
71
|
-
const
|
|
72
|
-
|
|
121
|
+
const daemon = daemons.get(provider.id);
|
|
122
|
+
const why = modeRefusal(kind, provider, mode) ?? (daemon ? daemonWhy(kind, daemon, mode) : undefined) ?? (missing.length ? keysWhy(provider, missing) : undefined);
|
|
123
|
+
// The images an agent's computer.image may name for this kind: those of its configurations that serve it.
|
|
124
|
+
const images = imagesOf(provider.capabilities.filter((one) => kinds.servingRefusals(one, kind).length === 0), provider.defaultImage?.[kind]);
|
|
125
|
+
const network = networkWords(provider.network);
|
|
126
|
+
// A sandbox's GPUs: only a sandbox takes them (computer-setting.ts computerIssues).
|
|
127
|
+
const gpu = kind === "sandbox" ? sandboxGpu(kinds, provider) : undefined;
|
|
128
|
+
return { id: provider.id, name: provider.label, metered: provider.metered, secrets: provider.keys.map((key) => metas.get(secretName("computer", provider.id, key.name))), required: provider.keys.filter((key) => key.required).map((key) => secretName("computer", provider.id, key.name)), ready: why === undefined, ...(why ? { why } : {}), ...(network ? { network } : {}), ...(images.length > 0 ? { images } : {}), ...(gpu ? { gpu: gpuView(gpu, mode) } : {}) };
|
|
73
129
|
});
|
|
74
130
|
const offered = kind === "none" || serving.some((provider) => modeRefusal(kind, provider, mode) === undefined);
|
|
75
131
|
const why = offered ? undefined : serving.length ? `no provider of a ${kind} computer can reach this server's run folders` : `no provider serves a ${kind} computer`;
|
|
@@ -109,7 +165,9 @@ export function createComputerRoutes(options) {
|
|
|
109
165
|
return keys;
|
|
110
166
|
}
|
|
111
167
|
/** The account test of a provider with its saved keys (computer-keys.ts testConnection): one account-level read, never a
|
|
112
|
-
* create. Its words are the answer's why. Undefined for a provider this server does not have.
|
|
168
|
+
* create. Its words are the answer's why. Undefined for a provider this server does not have. What the provider said
|
|
169
|
+
* passes serve's one redactor (key-refusal.ts redacted) over the keys this test used: a vendor's error can quote a key
|
|
170
|
+
* in a form testConnection's plain cut misses (base64 in an Authorization header, JSON-escaped, percent-encoded). */
|
|
113
171
|
async function test(providerId, signal) {
|
|
114
172
|
const provider = providerOf(providerId);
|
|
115
173
|
if (!provider)
|
|
@@ -119,11 +177,13 @@ export function createComputerRoutes(options) {
|
|
|
119
177
|
if (missing.length)
|
|
120
178
|
return { ok: false, why: keysWhy(provider, missing) };
|
|
121
179
|
const answer = await testConnection(providerId, { keys, ...(signal ? { signal } : {}) }, factories, settings, keyTable);
|
|
122
|
-
|
|
180
|
+
const cut = (text) => redacted(text, Object.values(keys));
|
|
181
|
+
return answer.ok ? { ok: true, detail: cut(answer.value.detail) } : { ok: false, why: cut(answer.error.message) };
|
|
123
182
|
}
|
|
124
183
|
/** Why a run of an agent whose computer is `computer` cannot have it here, in words naming the setting to fill;
|
|
125
184
|
* undefined when it can. Checked at the claim: the provider must serve the kind (servingRefusals' words), fit this
|
|
126
|
-
* server's folder mode,
|
|
185
|
+
* server's folder mode, give a sandbox the GPUs it asks for (checkGpu's words), have its daemon answer where it binds
|
|
186
|
+
* a folder of this machine (Docker), and have every required key saved; a key refusal names the route that saves them. */
|
|
127
187
|
async function claimRefusal(computer) {
|
|
128
188
|
if (computer.kind === "none")
|
|
129
189
|
return undefined;
|
|
@@ -134,11 +194,12 @@ export function createComputerRoutes(options) {
|
|
|
134
194
|
const words = [...new Set(provider.capabilities.flatMap((capabilities) => kinds.servingRefusals(capabilities, computer.kind)))];
|
|
135
195
|
return `${provider.label} does not serve a ${computer.kind} computer${words.length ? ` (${words.join("; ")})` : ""}: set this agent's computer to one it serves (Settings → Computers)`;
|
|
136
196
|
}
|
|
137
|
-
const
|
|
197
|
+
const mode = await modeNow();
|
|
198
|
+
const refused = modeRefusal(computer.kind, provider, mode) ?? gpuRefusal(kinds, computer, provider, mode) ?? (local(provider) ? daemonWhy(computer.kind, await answers(provider.id), mode) : undefined);
|
|
138
199
|
if (refused)
|
|
139
200
|
return refused;
|
|
140
201
|
const missing = missingKeys(provider, new Set([...(await sealedKeyNames(store)), ...provider.keys.filter((key) => envValue(env, key.name) !== undefined).map((key) => key.name)]));
|
|
141
|
-
return missing.length ? keysWhy(provider, missing) : undefined;
|
|
202
|
+
return missing.length ? keysWhy(provider, missing, true) : undefined;
|
|
142
203
|
}
|
|
143
204
|
/** What the claim makes a run's computer with: the options its provider's create() takes, from its saved keys and the
|
|
144
205
|
* server's settings (computer-keys.ts providerOptions); refused with computer_unavailable and claimRefusal's words when
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { FileHandle } from "node:fs/promises";
|
|
2
|
+
import { FileError } from "@earendil-works/pi-durable/env";
|
|
3
|
+
import type { BinaryReader, DirReader, Result } from "@earendil-works/pi-durable/env";
|
|
4
|
+
export type RefusalReason = "outside_work" | "changed";
|
|
5
|
+
/**
|
|
6
|
+
* A file operation named a path that is not under the workspace (`outside_work`), or one whose components changed
|
|
7
|
+
* while it was being resolved (`changed`). pi turns it into a failed tool result whose text is the message, and the
|
|
8
|
+
* message names no path: pi's tools resolve a path against the workspace before they ask for it, so the path asked
|
|
9
|
+
* for, the workspace and where a link resolves to are all the host's own, which a model on a server must not read.
|
|
10
|
+
* `path` keeps the path asked for. An app that shows a refusal names the path its caller gave, telling the refusal by
|
|
11
|
+
* its type and `reason`, never by the message's text. Its `code` is pi's `permission_denied`.
|
|
12
|
+
*/
|
|
13
|
+
export declare class PathOutsideWorkError extends FileError {
|
|
14
|
+
readonly reason: RefusalReason;
|
|
15
|
+
constructor(path: string, reason: RefusalReason, message: string);
|
|
16
|
+
}
|
|
17
|
+
/** Test seam: runs after a path was resolved and checked, before anything is opened. */
|
|
18
|
+
export declare const confineHooks: {
|
|
19
|
+
afterCheck?: (canonical: string) => Promise<void> | void;
|
|
20
|
+
/** After `createTempDir` made a directory and before it is granted (a command may act in between). */
|
|
21
|
+
afterTempDir?: (dir: string) => Promise<void> | void;
|
|
22
|
+
};
|
|
23
|
+
/** pi's mapping from a Node error to its `FileError` codes (pi does not export it). */
|
|
24
|
+
export declare function fileError(error: unknown, path: string): FileError;
|
|
25
|
+
/**
|
|
26
|
+
* The path the kernel would reach for `path` (absolute, lexically normalized): every existing component resolved,
|
|
27
|
+
* symlinks included, dangling ones followed to where they would create; a missing tail is appended as it is.
|
|
28
|
+
*/
|
|
29
|
+
export declare function canonicalize(path: string): Promise<string>;
|
|
30
|
+
export declare const inside: (path: string, root: string) => boolean;
|
|
31
|
+
export interface PinSpec {
|
|
32
|
+
readonly access: "read" | "write";
|
|
33
|
+
/** Whether the last component is followed when it is a symlink; `false` for operations on the link itself. */
|
|
34
|
+
readonly follow: boolean;
|
|
35
|
+
/** Create the missing directories above the target. */
|
|
36
|
+
readonly parents?: boolean;
|
|
37
|
+
/** Refuse the root itself as the target (remove, rename). */
|
|
38
|
+
readonly strict?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A resolved target held open. `dir` and `entry` are `/proc/self/fd/...` paths (by path, the real ones) to hand to pi's
|
|
42
|
+
* own implementation; every path and message it returns is mapped back to the real one with `restore`. Close it when
|
|
43
|
+
* the operation is done.
|
|
44
|
+
*/
|
|
45
|
+
export declare class Pin {
|
|
46
|
+
#private;
|
|
47
|
+
readonly canonical: string;
|
|
48
|
+
/** The last component, or "" when the target is the root itself. */
|
|
49
|
+
readonly name: string;
|
|
50
|
+
/** The held directory: the target itself for a directory pin, the directory holding the target for an entry pin. */
|
|
51
|
+
readonly dir: string;
|
|
52
|
+
/** The target below `dir`, for operations that do not follow a last symlink. */
|
|
53
|
+
readonly entry: string;
|
|
54
|
+
/**
|
|
55
|
+
* `held` is the walk's: whether it went by path, and then the held directory's real path; and the names of the
|
|
56
|
+
* confinement's roots (`Confinement`'s `names`).
|
|
57
|
+
*/
|
|
58
|
+
constructor(handle: FileHandle, canonical: string, name: string, dirMode: boolean, held?: {
|
|
59
|
+
byPath: boolean;
|
|
60
|
+
path: string;
|
|
61
|
+
names?: readonly RootName[];
|
|
62
|
+
});
|
|
63
|
+
/** `text` with the held paths replaced by the real ones, and a root named as the caller names it. */
|
|
64
|
+
translate(text: string): string;
|
|
65
|
+
/** An error pi or Node raised on a held path, as a FileError that names the real one. */
|
|
66
|
+
error(error: unknown, path: string): FileError;
|
|
67
|
+
restore<T>(result: Result<T, FileError>): Result<T, FileError>;
|
|
68
|
+
/**
|
|
69
|
+
* Opens the target's last component, which is never followed, and returns its handle; the caller closes it. By path,
|
|
70
|
+
* the directory's path must still name the directory held once the file is open.
|
|
71
|
+
*/
|
|
72
|
+
openFile(flags: number, mode?: number): Promise<FileHandle>;
|
|
73
|
+
binaryReader(reader: BinaryReader): BinaryReader;
|
|
74
|
+
/** The reader keeps the pin open: pi's reader names each entry through `dir` as it pages. */
|
|
75
|
+
dirReader(reader: DirReader): DirReader;
|
|
76
|
+
close(): Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
/** A root's canonical path, as a pattern that matches it whole in a path or a message, and the name the caller gave it. */
|
|
79
|
+
export interface RootName {
|
|
80
|
+
readonly canonical: RegExp;
|
|
81
|
+
readonly named: string;
|
|
82
|
+
}
|
|
83
|
+
export declare class Confinement {
|
|
84
|
+
#private;
|
|
85
|
+
readonly work: string;
|
|
86
|
+
readonly readOnly: readonly string[];
|
|
87
|
+
/** Whether the walk goes by path (macOS, which has no `/proc/self/fd`; see the top of this file). */
|
|
88
|
+
readonly byPath: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Canonical directories: `work` may be read and written, `readOnly` only read. `byPath` defaults to true on macOS only.
|
|
91
|
+
* `names` maps a canonical root to the path the caller names it by, where they differ (a root under a symlinked
|
|
92
|
+
* directory, as `/tmp` and `/var` are on macOS): results name paths under it as the caller does, as pi's own do.
|
|
93
|
+
*/
|
|
94
|
+
constructor(work: string, readOnly: readonly string[], options?: {
|
|
95
|
+
readonly byPath?: boolean;
|
|
96
|
+
readonly names?: ReadonlyMap<string, string>;
|
|
97
|
+
});
|
|
98
|
+
/**
|
|
99
|
+
* Lets file operations write inside `dir` too: a directory this process just created (`createTempDir`) directly in a
|
|
100
|
+
* read-only root, for the tool it is handed to. `dir` is that root joined with the new name, never resolved: if the
|
|
101
|
+
* directory is later swapped for a link, a path through it resolves elsewhere and is refused.
|
|
102
|
+
*/
|
|
103
|
+
allowWrites(dir: string): void;
|
|
104
|
+
/** `dir` was removed: writes inside it, or inside any handed directory below it, are no longer allowed. */
|
|
105
|
+
forgetWrites(dir: string): void;
|
|
106
|
+
/** Resolves `abs` and refuses it unless it lies under an allowed root; returns the root that holds it. */
|
|
107
|
+
locate(abs: string, original: string, access: "read" | "write", follow: boolean): Promise<{
|
|
108
|
+
canonical: string;
|
|
109
|
+
root: string;
|
|
110
|
+
}>;
|
|
111
|
+
/** Pins the directory holding the target (or the root, when it is the target). */
|
|
112
|
+
pinEntry(abs: string, original: string, spec: PinSpec): Promise<Pin>;
|
|
113
|
+
/** Pins the target directory itself; `create` makes it and the directories above it when they are missing. */
|
|
114
|
+
pinDir(abs: string, original: string, spec: {
|
|
115
|
+
access: "read" | "write";
|
|
116
|
+
create?: boolean;
|
|
117
|
+
}): Promise<Pin>;
|
|
118
|
+
}
|
|
119
|
+
/** Whether `path` still names the directory `held` holds (same device and inode); false when it cannot be read. */
|
|
120
|
+
export declare function namesHeld(path: string, held: FileHandle): Promise<boolean>;
|