@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
|
@@ -65,10 +65,15 @@ export type ComputerHold = {
|
|
|
65
65
|
/** The current take's name, while one is pending or held. */
|
|
66
66
|
current(): string | undefined;
|
|
67
67
|
/** The person takes it: pending while an agent call is in flight, then theirs. False (nothing changes) when a take is
|
|
68
|
-
* pending or held already, or the hold is closed. `by`: the command row that asked. */
|
|
68
|
+
* pending or held already, or the run is ending, or the hold is closed. `by`: the command row that asked. */
|
|
69
69
|
take(options?: {
|
|
70
70
|
readonly by?: number;
|
|
71
71
|
}): boolean;
|
|
72
|
+
/** The run is ending (its agent is done): nothing new is taken from now, and a take in force goes on until it ends, so
|
|
73
|
+
* the run's end can wait for it and no later take is cut by the release (#2134). */
|
|
74
|
+
finish(): void;
|
|
75
|
+
/** Whether the run is ending (finish). */
|
|
76
|
+
finishing(): boolean;
|
|
72
77
|
/** The take ends (`given` by default): false when there was none. A hand-back while the agent's ask is open answers it
|
|
73
78
|
* done, and the take ends `answered`. */
|
|
74
79
|
give(why?: HoldEnd, options?: {
|
|
@@ -38,6 +38,7 @@ export function computerHold(options = {}) {
|
|
|
38
38
|
let inFlight = 0;
|
|
39
39
|
let epoch = 0;
|
|
40
40
|
let closed = false;
|
|
41
|
+
let ending = false;
|
|
41
42
|
let open;
|
|
42
43
|
const waiters = new Set();
|
|
43
44
|
const listeners = new Set();
|
|
@@ -93,7 +94,7 @@ export function computerHold(options = {}) {
|
|
|
93
94
|
state: () => state,
|
|
94
95
|
current: () => take,
|
|
95
96
|
take({ by } = {}) {
|
|
96
|
-
if (closed || state !== "agent")
|
|
97
|
+
if (closed || ending || state !== "agent")
|
|
97
98
|
return false;
|
|
98
99
|
take = by !== undefined ? `c${by}` : `v${now()}-${randomBytes(3).toString("hex")}`;
|
|
99
100
|
epoch++;
|
|
@@ -105,6 +106,10 @@ export function computerHold(options = {}) {
|
|
|
105
106
|
toPerson(by);
|
|
106
107
|
return true;
|
|
107
108
|
},
|
|
109
|
+
finish() {
|
|
110
|
+
ending = true;
|
|
111
|
+
},
|
|
112
|
+
finishing: () => ending,
|
|
108
113
|
give,
|
|
109
114
|
away: () => void give("away"),
|
|
110
115
|
touched() {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type Result, type Swept } from "@parcha/agentrun-computer";
|
|
2
|
+
import { type KeyTable, type ProviderSettings } from "../computer-keys.js";
|
|
3
|
+
import type { Store } from "../store/index.js";
|
|
4
|
+
import type { ComputerDeps } from "./computer-deps.js";
|
|
5
|
+
/** How often the janitor sweeps after its first sweep at the runner's start. */
|
|
6
|
+
export declare const JANITOR_EVERY_MS: number;
|
|
7
|
+
/** The longest close() waits for a sweep it cut: a vendor call that ignores the cut is left to finish on its own. */
|
|
8
|
+
export declare const JANITOR_CLOSE_MS = 5000;
|
|
9
|
+
/** The longest one provider's sweep may take: past it the sweep is cut and left, said as a timeout, and the next provider
|
|
10
|
+
* is swept, so a stuck vendor (a Docker command has no timeout of its own) never stops the others or later sweeps. */
|
|
11
|
+
export declare const JANITOR_PROVIDER_MS: number;
|
|
12
|
+
export interface JanitorDeps {
|
|
13
|
+
/** The store: whose runs a computer's run label names, and the phone provider's ledger. */
|
|
14
|
+
readonly store: Pick<Store, "runs" | "computerLedger">;
|
|
15
|
+
/** The run's computers as the runner composed them (computer-deps.ts computerDepsFrom): the registry, the provider
|
|
16
|
+
* makers and the key reader. */
|
|
17
|
+
readonly computers: Pick<ComputerDeps, "kinds" | "providers" | "keyOf"> & {
|
|
18
|
+
readonly settings?: ProviderSettings;
|
|
19
|
+
readonly keyTable?: KeyTable;
|
|
20
|
+
};
|
|
21
|
+
/** The runs' environment: under --faux (AGENTRUN_SERVE_FAUX) the janitor never starts. */
|
|
22
|
+
readonly env: NodeJS.ProcessEnv;
|
|
23
|
+
/** Where a sweep's outcome and a provider's failure are said. */
|
|
24
|
+
readonly log: (line: string) => void;
|
|
25
|
+
readonly everyMs?: number;
|
|
26
|
+
/** The longest close() waits for a sweep it cut. Default JANITOR_CLOSE_MS. */
|
|
27
|
+
readonly closeMs?: number;
|
|
28
|
+
/** The longest one provider's sweep may take. Default JANITOR_PROVIDER_MS. */
|
|
29
|
+
readonly providerMs?: number;
|
|
30
|
+
/** The clock a computer's deadline is read by. Default Date.now. */
|
|
31
|
+
readonly now?: () => number;
|
|
32
|
+
}
|
|
33
|
+
/** One provider's sweep: what it ended, or why it could not sweep, in words. */
|
|
34
|
+
export type ProviderSweep = {
|
|
35
|
+
readonly provider: string;
|
|
36
|
+
readonly swept: Result<Swept>;
|
|
37
|
+
};
|
|
38
|
+
/** One sweep of every provider this server can list: each provider whose keys it has and whose computers the janitor
|
|
39
|
+
* ends, its computers past their deadline that are this server's and unheld ended. A provider that fails is answered
|
|
40
|
+
* in its words; nothing throws. */
|
|
41
|
+
export declare function sweepServerComputers(deps: Pick<JanitorDeps, "store" | "computers" | "now" | "providerMs">, signal?: AbortSignal): Promise<ProviderSweep[]>;
|
|
42
|
+
/** The janitor: one sweep now, then one every `everyMs`, never two at once. `close()` stops it, cuts a sweep under way
|
|
43
|
+
* and waits for it at most `closeMs`. Under --faux it does nothing. */
|
|
44
|
+
export declare function startJanitor(deps: JanitorDeps): {
|
|
45
|
+
readonly first: Promise<void>;
|
|
46
|
+
close(): Promise<void>;
|
|
47
|
+
};
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// The computer janitor of this server: at the runner's start, then every JANITOR_EVERY_MS, each computer this server made
|
|
2
|
+
// that is past its deadline is ended. A run's release ends its computer; the janitor is for the ones a crashed runner
|
|
3
|
+
// left, on a provider whose vendor never ends them itself (capabilities().lifetime "janitor": Docker, Orgo).
|
|
4
|
+
//
|
|
5
|
+
// Which computers it may end:
|
|
6
|
+
// - a provider's whose keys this server has (saved, or in its environment); Docker takes none, so it is always asked;
|
|
7
|
+
// - one whose agentrun.run label names a run in this server's store (or, where the provider keeps only the run's hash,
|
|
8
|
+
// agentrun.run.hash is the hash of one): a vendor account or a Docker host shared with another server lists that
|
|
9
|
+
// server's computers too, and they are never touched;
|
|
10
|
+
// - never one a claim holds, at the computer's own epoch: whether a claim holds the run now is the store's to say
|
|
11
|
+
// (runs.heldAt), by its own clock, never this process's. A claim that ran out holds nothing, so a run a crashed runner
|
|
12
|
+
// left parked under its name still has its computer swept at the deadline;
|
|
13
|
+
// - past its deadline, by the computer package's sweep (janitor.ts): the deadline label, or over the provider's cap.
|
|
14
|
+
// What a computer leaves outside itself (Docker's egress parts) goes with its release; the provider's sweepLeftovers is
|
|
15
|
+
// not asked, since it reads labels alone and can't tell this server's parts from another's.
|
|
16
|
+
//
|
|
17
|
+
// A provider whose sweep fails is logged, once per distinct failure, and the others are swept. It runs only where its
|
|
18
|
+
// start asks for it (the CLI's runner and the runner subcommand), never under --faux, and never two sweeps at once. Its
|
|
19
|
+
// close cuts a sweep under way and waits for it on a bound of its own (JANITOR_CLOSE_MS), so a stuck vendor call never
|
|
20
|
+
// holds up the runner's stop.
|
|
21
|
+
import { epochOf, ok, RUN_HASH_LABEL, RUN_LABEL, runHash, sweep } from "@parcha/agentrun-computer";
|
|
22
|
+
import { KEY_TABLE, providerOptions } from "../computer-keys.js";
|
|
23
|
+
import { FAUX_ENV } from "../model.js";
|
|
24
|
+
import { storeLedger } from "./computer-ledger.js";
|
|
25
|
+
import { providerKeys } from "./resolve-computer.js";
|
|
26
|
+
/** How often the janitor sweeps after its first sweep at the runner's start. */
|
|
27
|
+
export const JANITOR_EVERY_MS = 10 * 60_000;
|
|
28
|
+
/** The longest close() waits for a sweep it cut: a vendor call that ignores the cut is left to finish on its own. */
|
|
29
|
+
export const JANITOR_CLOSE_MS = 5_000;
|
|
30
|
+
/** The longest one provider's sweep may take: past it the sweep is cut and left, said as a timeout, and the next provider
|
|
31
|
+
* is swept, so a stuck vendor (a Docker command has no timeout of its own) never stops the others or later sweeps. */
|
|
32
|
+
export const JANITOR_PROVIDER_MS = 5 * 60_000;
|
|
33
|
+
const runsByHash = (store) => {
|
|
34
|
+
let read;
|
|
35
|
+
return () => (read ??= store.runs.list({}).then((rows) => new Map(rows.map((row) => [runHash(row.id), row.id]))));
|
|
36
|
+
};
|
|
37
|
+
/** Whether a listed computer is this server's and no claim holds it: its run (by its label, or its hash's) is in this
|
|
38
|
+
* store, and no claim holds the run now (by the store's clock), or one holds it at a later epoch than the computer's. */
|
|
39
|
+
async function sweepable(store, labels, byHash) {
|
|
40
|
+
const named = labels[RUN_LABEL];
|
|
41
|
+
const hash = labels[RUN_HASH_LABEL];
|
|
42
|
+
const runId = typeof named === "string" && named !== "" ? named : typeof hash === "string" && hash !== "" ? (await byHash()).get(hash) : undefined;
|
|
43
|
+
if (runId === undefined)
|
|
44
|
+
return false;
|
|
45
|
+
const run = await store.runs.get(runId);
|
|
46
|
+
// No such run here: another server's computer.
|
|
47
|
+
if (!run)
|
|
48
|
+
return false;
|
|
49
|
+
const held = await store.runs.heldAt(run.id);
|
|
50
|
+
if (held === undefined)
|
|
51
|
+
return true;
|
|
52
|
+
// A claim holds its own epoch's computer; one of an older epoch is a lost claim's (releaseOlder's too).
|
|
53
|
+
const epoch = epochOf(labels);
|
|
54
|
+
return epoch.ok && epoch.value < held;
|
|
55
|
+
}
|
|
56
|
+
/** `provider` as the sweep sees it: its list cut to this server's computers that no claim holds, and no leftovers pass.
|
|
57
|
+
* Each call goes to the provider itself, so its own state is used as it is. */
|
|
58
|
+
function thisServers(provider, store, byHash) {
|
|
59
|
+
return {
|
|
60
|
+
id: provider.id,
|
|
61
|
+
version: provider.version,
|
|
62
|
+
capabilities: () => provider.capabilities(),
|
|
63
|
+
check: (spec) => provider.check(spec),
|
|
64
|
+
create: (spec, context) => provider.create(spec, context),
|
|
65
|
+
attach: (target, context) => provider.attach(target, context),
|
|
66
|
+
network: (ref, policy, context) => provider.network(ref, policy, context),
|
|
67
|
+
connect: (ref) => provider.connect(ref),
|
|
68
|
+
release: (ref, how) => provider.release(ref, how),
|
|
69
|
+
async list(labels, context) {
|
|
70
|
+
const listed = await provider.list(labels, context);
|
|
71
|
+
if (!listed.ok)
|
|
72
|
+
return listed;
|
|
73
|
+
const kept = [];
|
|
74
|
+
for (const info of listed.value)
|
|
75
|
+
if (await sweepable(store, info.labels, byHash))
|
|
76
|
+
kept.push(info);
|
|
77
|
+
return ok(kept);
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/** `work` given a signal cut at `ms` (or with `signal`), answered at the cut whether or not `work` heeds it: a call that
|
|
82
|
+
* ignores it is left to finish on its own, and the answer is a timeout (or aborted) in words. */
|
|
83
|
+
async function bounded(ms, signal, work) {
|
|
84
|
+
const timer = AbortSignal.timeout(ms);
|
|
85
|
+
const cut = signal ? AbortSignal.any([signal, timer]) : timer;
|
|
86
|
+
let stop = () => { };
|
|
87
|
+
const given = new Promise((resolve) => {
|
|
88
|
+
stop = () => resolve(timer.aborted ? { ok: false, error: { code: "timeout", message: `its sweep took longer than ${ms / 1000} s and was left` } } : { ok: false, error: { code: "aborted", message: "the sweep was cut" } });
|
|
89
|
+
cut.addEventListener("abort", stop, { once: true });
|
|
90
|
+
});
|
|
91
|
+
try {
|
|
92
|
+
return await Promise.race([work(cut), given]);
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
cut.removeEventListener("abort", stop);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/** One sweep of every provider this server can list: each provider whose keys it has and whose computers the janitor
|
|
99
|
+
* ends, its computers past their deadline that are this server's and unheld ended. A provider that fails is answered
|
|
100
|
+
* in its words; nothing throws. */
|
|
101
|
+
export async function sweepServerComputers(deps, signal) {
|
|
102
|
+
const { store, computers } = deps;
|
|
103
|
+
const at = (deps.now ?? Date.now)();
|
|
104
|
+
const keysOf = providerKeys(computers.kinds, computers.keyOf ?? (async () => undefined));
|
|
105
|
+
const byHash = runsByHash(store);
|
|
106
|
+
const out = [];
|
|
107
|
+
for (const entry of computers.kinds.PROVIDERS) {
|
|
108
|
+
if (signal?.aborted)
|
|
109
|
+
break;
|
|
110
|
+
const make = Object.hasOwn(computers.providers, entry.id) ? computers.providers[entry.id] : undefined;
|
|
111
|
+
if (!make)
|
|
112
|
+
continue;
|
|
113
|
+
try {
|
|
114
|
+
// Its keys not here: nothing of this server's can be listed there. A key that can't be read is this provider's
|
|
115
|
+
// failure alone.
|
|
116
|
+
const options = providerOptions(entry.id, await keysOf(entry.id), computers.settings ?? {}, computers.keyTable ?? KEY_TABLE);
|
|
117
|
+
if (!options.ok)
|
|
118
|
+
continue;
|
|
119
|
+
const provider = await make(options.options, { ledger: storeLedger(store.computerLedger, entry.id) });
|
|
120
|
+
// A vendor that ends its own computers needs no janitor.
|
|
121
|
+
if (provider.capabilities().lifetime !== "janitor")
|
|
122
|
+
continue;
|
|
123
|
+
out.push({ provider: entry.id, swept: await bounded(deps.providerMs ?? JANITOR_PROVIDER_MS, signal, (cut) => sweep(thisServers(provider, store, byHash), { now: new Date(at), signal: cut })) });
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
out.push({ provider: entry.id, swept: { ok: false, error: { code: "refused", message: error instanceof Error ? error.message : String(error) } } });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return out;
|
|
130
|
+
}
|
|
131
|
+
/** The janitor: one sweep now, then one every `everyMs`, never two at once. `close()` stops it, cuts a sweep under way
|
|
132
|
+
* and waits for it at most `closeMs`. Under --faux it does nothing. */
|
|
133
|
+
export function startJanitor(deps) {
|
|
134
|
+
if (deps.env[FAUX_ENV])
|
|
135
|
+
return { first: Promise.resolve(), close: async () => { } };
|
|
136
|
+
/** The last failure said per provider: a failure is said once, until it changes or the provider sweeps again. */
|
|
137
|
+
const said = new Map();
|
|
138
|
+
const cut = new AbortController();
|
|
139
|
+
let running;
|
|
140
|
+
const once = () => (running ??= (async () => {
|
|
141
|
+
try {
|
|
142
|
+
for (const { provider, swept } of await sweepServerComputers(deps, cut.signal)) {
|
|
143
|
+
// A sweep the close cut says nothing more.
|
|
144
|
+
if (cut.signal.aborted)
|
|
145
|
+
break;
|
|
146
|
+
if (!swept.ok) {
|
|
147
|
+
const words = `${swept.error.code}: ${swept.error.message}`;
|
|
148
|
+
if (said.get(provider) !== words)
|
|
149
|
+
deps.log(`the computer janitor could not sweep ${provider}'s computers: ${swept.error.message}`);
|
|
150
|
+
said.set(provider, words);
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
said.delete(provider);
|
|
154
|
+
if (swept.value.deleted.length > 0)
|
|
155
|
+
deps.log(`the computer janitor ended ${provider}'s computers past their deadline: ${swept.value.deleted.join(", ")}`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
if (!cut.signal.aborted)
|
|
160
|
+
deps.log(`the computer janitor's sweep failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
161
|
+
}
|
|
162
|
+
finally {
|
|
163
|
+
running = undefined;
|
|
164
|
+
}
|
|
165
|
+
})());
|
|
166
|
+
const first = once();
|
|
167
|
+
const timer = setInterval(() => void (cut.signal.aborted || running || once()), deps.everyMs ?? JANITOR_EVERY_MS);
|
|
168
|
+
timer.unref();
|
|
169
|
+
return {
|
|
170
|
+
first,
|
|
171
|
+
async close() {
|
|
172
|
+
cut.abort();
|
|
173
|
+
clearInterval(timer);
|
|
174
|
+
if (!running)
|
|
175
|
+
return;
|
|
176
|
+
// A vendor call that ignores the cut (a release takes no signal) is left to finish on its own after this bound.
|
|
177
|
+
let bound;
|
|
178
|
+
await Promise.race([running, new Promise((resolve) => (bound = setTimeout(resolve, deps.closeMs ?? JANITOR_CLOSE_MS)))]);
|
|
179
|
+
clearTimeout(bound);
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import type { ProviderOptions } from "@parcha/agentrun-computer";
|
|
2
1
|
import type { ComputerLedger } from "../store/store.js";
|
|
3
|
-
/** The phone provider's `ledger` option, and one entry of it, as the computer package's provider registry types them. */
|
|
4
|
-
export type PhoneLedger = NonNullable<ProviderOptions<"phone-harness">["ledger"]>;
|
|
5
|
-
export type PhoneLedgerEntry = Awaited<ReturnType<PhoneLedger["list"]>>[number];
|
|
6
2
|
/** A session's entry as a provider keeps it: its id, our labels, and the provider's own fields. */
|
|
7
3
|
export interface LedgerEntry {
|
|
8
4
|
id: string;
|
|
9
5
|
labels: Record<string, string>;
|
|
10
6
|
}
|
|
11
|
-
/** One provider's ledger, in the shape
|
|
7
|
+
/** One provider's ledger, in the shape a descriptor's `ledger` option takes: put, get, list and remove of its entries. */
|
|
12
8
|
export interface ProviderLedger<E extends LedgerEntry = LedgerEntry> {
|
|
13
9
|
put(entry: E): Promise<void>;
|
|
14
10
|
get(id: string): Promise<E | undefined>;
|
|
@@ -17,6 +13,3 @@ export interface ProviderLedger<E extends LedgerEntry = LedgerEntry> {
|
|
|
17
13
|
}
|
|
18
14
|
/** `provider`'s ledger over the store's computer ledger. */
|
|
19
15
|
export declare function storeLedger<E extends LedgerEntry = LedgerEntry>(ledger: ComputerLedger, provider: string): ProviderLedger<E>;
|
|
20
|
-
/** The phone provider's ledger over the store's computer ledger: what its create() takes as `ledger`. Typed by the
|
|
21
|
-
* provider's own option, so a change to its ledger interface fails this build. */
|
|
22
|
-
export declare const phoneLedger: (ledger: ComputerLedger) => PhoneLedger;
|
|
@@ -14,6 +14,3 @@ export function storeLedger(ledger, provider) {
|
|
|
14
14
|
remove: (id) => ledger.remove(provider, id),
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
/** The phone provider's ledger over the store's computer ledger: what its create() takes as `ledger`. Typed by the
|
|
18
|
-
* provider's own option, so a change to its ledger interface fails this build. */
|
|
19
|
-
export const phoneLedger = (ledger) => storeLedger(ledger, "phone-harness");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ComputerProvider } from "@parcha/agentrun-computer";
|
|
1
|
+
import { type ComputerProvider, type ProviderEntry } from "@parcha/agentrun-computer";
|
|
2
2
|
import type { ProviderFactories } from "../computer-keys.js";
|
|
3
3
|
import type { ProviderMakers } from "./computer-for-claim.js";
|
|
4
4
|
/** How a provider is built from its id and options: the computer package's providerFor, or a test's stand-in. `claim`:
|
|
@@ -10,7 +10,9 @@ export type ProviderLoad = (id: string, options: Record<string, unknown>, claim?
|
|
|
10
10
|
/** Settings → Computers' factories (createComputerRoutes' `factories`, its account test) from the same makers, so serve
|
|
11
11
|
* builds a provider in one place: each made with its options and `ledgerOf` its id's ledger. */
|
|
12
12
|
export declare function computerProviderFactories(makers: ProviderMakers, ledgerOf: (id: string) => unknown): ProviderFactories;
|
|
13
|
-
/** Every provider the computer package
|
|
14
|
-
|
|
13
|
+
/** Every provider in `entries` (the computer package's PROVIDERS, each from its descriptor), made through `load`
|
|
14
|
+
* (providerFor) from its options, plus the server's ledger as the option its descriptor names, when it declares one. */
|
|
15
|
+
export declare function computerProviderMakers({ load, entries }?: {
|
|
15
16
|
readonly load?: ProviderLoad;
|
|
17
|
+
readonly entries?: readonly Pick<ProviderEntry, "id" | "ledger">[];
|
|
16
18
|
}): ProviderMakers;
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
// The provider makers computerForClaim is handed at the claim (its `providers`): each
|
|
2
|
-
//
|
|
3
|
-
// names), and nothing else.
|
|
4
|
-
//
|
|
5
|
-
|
|
1
|
+
// The provider makers computerForClaim is handed at the claim (its `providers`): each provider the computer package
|
|
2
|
+
// declares, built by its providerFor from the options its saved keys fill (computer-keys.ts providerOptions, by its
|
|
3
|
+
// descriptor's key names), and nothing else. A provider whose descriptor declares a ledger (its sessions carry no labels
|
|
4
|
+
// of their own) is given the store's computer ledger, as the option its descriptor names. No key reaches a provider any
|
|
5
|
+
// other way, and nothing here reads the environment or names a vendor.
|
|
6
|
+
import { PROVIDERS, providerFor } from "@parcha/agentrun-computer";
|
|
6
7
|
/** Settings → Computers' factories (createComputerRoutes' `factories`, its account test) from the same makers, so serve
|
|
7
8
|
* builds a provider in one place: each made with its options and `ledgerOf` its id's ledger. */
|
|
8
9
|
export function computerProviderFactories(makers, ledgerOf) {
|
|
9
10
|
return Object.fromEntries(Object.entries(makers).map(([id, make]) => [id, (options) => make(options, { ledger: ledgerOf(id) })]));
|
|
10
11
|
}
|
|
11
|
-
/** Every provider the computer package
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
/** Every provider in `entries` (the computer package's PROVIDERS, each from its descriptor), made through `load`
|
|
13
|
+
* (providerFor) from its options, plus the server's ledger as the option its descriptor names, when it declares one. */
|
|
14
|
+
export function computerProviderMakers({ load = providerFor, entries = PROVIDERS } = {}) {
|
|
15
|
+
return Object.fromEntries(entries.map(({ id, ledger }) => [
|
|
14
16
|
id,
|
|
15
|
-
(options, extras) => load(id, { ...options, ...(
|
|
17
|
+
(options, extras) => load(id, { ...options, ...(ledger === undefined ? {} : { [ledger.option]: extras.ledger }) }, extras.boxAllow === undefined ? {} : { boxAllow: extras.boxAllow }),
|
|
16
18
|
]));
|
|
17
19
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
export type GrepJob = {
|
|
2
2
|
readonly dir: string;
|
|
3
|
+
/** `dir`'s path below the root (or the file's, with `only`): each match's path starts with it. */
|
|
3
4
|
readonly rel: string;
|
|
5
|
+
/** Whether `dir` is /proc/self/fd/<fd> (Linux): else a path, and every entry is opened by `rel` below `root`. */
|
|
6
|
+
readonly procFd: boolean;
|
|
7
|
+
/** The workspace's root, its real path. */
|
|
8
|
+
readonly root: string;
|
|
4
9
|
readonly only?: string;
|
|
5
10
|
readonly pattern: string;
|
|
6
11
|
readonly glob?: string;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
// LocalWorkspace's grep, in a worker thread: the caller's regex runs here, so one that backtracks without end blocks
|
|
2
2
|
// this thread, never the runner's, and local.ts terminates it at the deadline. It searches the folder `dir` names (on
|
|
3
3
|
// Linux, /proc/self/fd/<fd> of a folder local.ts holds open for it), or the one file `only` in it, opening every entry
|
|
4
|
-
// with O_NOFOLLOW: a link is skipped, never followed.
|
|
5
|
-
// `
|
|
4
|
+
// with O_NOFOLLOW: a link is skipped, never followed. Off /proc/self/fd (macOS), where `dir` is a path the box can swap
|
|
5
|
+
// for a link mid-search, each entry is opened by its path below `root` through no link anywhere on the way (beneath.ts:
|
|
6
|
+
// macOS's O_NOFOLLOW_ANY), so a link swapped in fails the open and the entry is skipped: no byte from outside is read.
|
|
7
|
+
// Each match is posted as it is found; the last message is `{ done: false | "max" }`.
|
|
6
8
|
import { closeSync, constants, fstatSync, openSync, readdirSync, readSync } from "node:fs";
|
|
7
9
|
import { parentPort, workerData } from "node:worker_threads";
|
|
10
|
+
import { openBeneathSync } from "./beneath.js";
|
|
8
11
|
import { globRegex } from "./glob.js";
|
|
9
12
|
const { O_NOFOLLOW, O_NONBLOCK, O_RDONLY } = constants;
|
|
10
|
-
const LINUX = process.platform === "linux";
|
|
11
13
|
const sorted = (names) => names.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
12
14
|
function run(job, post) {
|
|
13
15
|
const regex = new RegExp(job.pattern);
|
|
@@ -43,11 +45,12 @@ function run(job, post) {
|
|
|
43
45
|
post({ matches: [match] });
|
|
44
46
|
}
|
|
45
47
|
};
|
|
46
|
-
/** Entry `name` of folder `dir
|
|
48
|
+
/** Entry `name` of folder `dir` (`rel` below the root), opened without following a link (off /proc/self/fd, none on
|
|
49
|
+
* the way either), searched if it is a file or a folder. */
|
|
47
50
|
const searchEntry = (dir, name, rel) => {
|
|
48
51
|
let fd;
|
|
49
52
|
try {
|
|
50
|
-
fd = openSync(`${dir}/${name}`, O_RDONLY | O_NOFOLLOW | O_NONBLOCK);
|
|
53
|
+
fd = job.procFd ? openSync(`${dir}/${name}`, O_RDONLY | O_NOFOLLOW | O_NONBLOCK) : openBeneathSync(job.root, rel, O_RDONLY | O_NONBLOCK);
|
|
51
54
|
}
|
|
52
55
|
catch {
|
|
53
56
|
return;
|
|
@@ -55,7 +58,7 @@ function run(job, post) {
|
|
|
55
58
|
try {
|
|
56
59
|
const stats = fstatSync(fd);
|
|
57
60
|
if (stats.isDirectory())
|
|
58
|
-
searchDir(
|
|
61
|
+
searchDir(job.procFd ? `/proc/self/fd/${fd}` : `${dir}/${name}`, rel);
|
|
59
62
|
else if (stats.isFile())
|
|
60
63
|
searchFile(fd, stats.size, rel, name);
|
|
61
64
|
}
|
|
@@ -17,9 +17,12 @@ export declare function shellEnv(options?: {
|
|
|
17
17
|
* output goes to its log (the "log" stream is what a read reads); a listing is read to its last page. */
|
|
18
18
|
export declare function processesOf(processes: Processes): KernelProcesses;
|
|
19
19
|
/** The run's hands over `workspace`: its files, its shell with `env` for at most `maxExecS` a command, and the
|
|
20
|
-
* computer's processes when it has one (`processes`, the attached Workspace's)
|
|
20
|
+
* computer's processes when it has one (`processes`, the attached Workspace's); `prelude`, shell text each command runs
|
|
21
|
+
* after (a bash policy's). */
|
|
21
22
|
export declare function handsOf(workspace: Workspace, options: {
|
|
22
23
|
readonly maxExecS: number;
|
|
23
24
|
readonly env: Readonly<Record<string, string>>;
|
|
24
|
-
readonly processes?: Processes;
|
|
25
|
+
readonly processes?: Processes; /** Shell text run before each command (a bash policy's, bash-read-only.ts policyPrelude). */
|
|
26
|
+
readonly prelude?: string; /** Each command's network (a bash policy's on Archil's exec: run-tools.ts). */
|
|
27
|
+
readonly network?: "deny";
|
|
25
28
|
}): Hands;
|
package/dist/workspace/hands.js
CHANGED
|
@@ -71,7 +71,8 @@ export function processesOf(processes) {
|
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
/** The run's hands over `workspace`: its files, its shell with `env` for at most `maxExecS` a command, and the
|
|
74
|
-
* computer's processes when it has one (`processes`, the attached Workspace's)
|
|
74
|
+
* computer's processes when it has one (`processes`, the attached Workspace's); `prelude`, shell text each command runs
|
|
75
|
+
* after (a bash policy's). */
|
|
75
76
|
export function handsOf(workspace, options) {
|
|
76
77
|
return {
|
|
77
78
|
maxExecS: options.maxExecS,
|
|
@@ -100,8 +101,8 @@ export function handsOf(workspace, options) {
|
|
|
100
101
|
if (data !== "" && onOutput)
|
|
101
102
|
onOutput({ stream, data });
|
|
102
103
|
};
|
|
103
|
-
const run = (shell) => workspace.exec([shell, "-c", command], {
|
|
104
|
-
env: options.env, timeoutMs, maxOutput: 0, ...(signal ? { signal } : {}),
|
|
104
|
+
const run = (shell) => workspace.exec([shell, "-c", `${options.prelude ?? ""}${command}`], {
|
|
105
|
+
env: options.env, timeoutMs, maxOutput: 0, ...(signal ? { signal } : {}), ...(options.network ? { network: options.network } : {}),
|
|
105
106
|
onOutput: ({ stream, data }) => emit(stream, decoders[stream].write(Buffer.from(data.buffer, data.byteOffset, data.byteLength))),
|
|
106
107
|
});
|
|
107
108
|
let ran;
|
|
@@ -10,14 +10,15 @@ export { ARCHIL_CONTROL_URLS, type ArchilMountCredentialOptions, ArchilMountCred
|
|
|
10
10
|
export { ARCHIL_API_KEY_ENV, archilApiKey, type ArchilKeyOptions } from "./archil-key.js";
|
|
11
11
|
export { openRunWorkspace, type RunWorkspace, type RunWorkspaceOptions } from "./run-workspace.js";
|
|
12
12
|
export { readOnlyWorkspace, SERVER_READS_ONLY, serverRunWorkspace, type ServerRunWorkspaceOptions } from "./server-run-workspace.js";
|
|
13
|
-
export { type LedgerEntry, type
|
|
13
|
+
export { type LedgerEntry, type ProviderLedger, storeLedger } from "./computer-ledger.js";
|
|
14
14
|
export { type LearningPlace, type LearningWorkspace, learningWorkspace, type LearningWorkspaceOptions } from "./learning-workspace.js";
|
|
15
|
-
export { ARCHIL_MAX_EXEC_S,
|
|
16
|
-
export { type
|
|
15
|
+
export { ARCHIL_MAX_EXEC_S, handsOf, MAX_EXEC_S, processesOf, shellEnv } from "./hands.js";
|
|
16
|
+
export { type RunComputer, type RunHold, runTools, type RunTools, withKindTools } from "./run-tools.js";
|
|
17
17
|
export { inputOf, phoneOf, screenOf } from "./computer-ports.js";
|
|
18
|
-
export { type ClaimSide, computerReadiness, type ComputerSetting, type
|
|
18
|
+
export { type ClaimSide, computerReadiness, type ComputerSetting, type KindRegistry, type LaunchedComputer, type Port, resolveComputer, type ResolvedComputer, runShellOf, shellPlaceOf, type StartedComputer, } from "./resolve-computer.js";
|
|
19
19
|
export { computerProviderFactories, computerProviderMakers, type ProviderLoad } from "./computer-providers.js";
|
|
20
20
|
export { claimComputer, claimKinds, type ComputerDeps, computerDepsFrom, type ComputerDepsOptions, computerSpecOf, DAEMON_CACHE_IN_VOLUME, DOCKER_HOST_ADDRESSES_ENV, type DockerComputerOptions, dockerHostAddressesOf, dockerVolumeOf, } from "./computer-deps.js";
|
|
21
|
-
export { type ClaimComputer, type ClaimLaunch, computerForClaim, type ComputerForClaimDeps, type ComputerRun, type ImageWait, type OpenComputerView, type ProviderMakers,
|
|
21
|
+
export { type ClaimComputer, type ClaimLaunch, computerForClaim, type ComputerForClaimDeps, type ComputerRun, type ImageWait, type OpenComputerView, type ProviderMakers, type ViewEnd } from "./computer-for-claim.js";
|
|
22
|
+
export { JANITOR_EVERY_MS, type JanitorDeps, type ProviderSweep, startJanitor, sweepServerComputers } from "./computer-janitor.js";
|
|
22
23
|
export { layOwnSkills, RUN_SKILLS_DIR } from "./revision-skills.js";
|
|
23
24
|
export { KIND_SKILLS, type KindSkill, kindSkillOf, type SkillKind } from "./kind-skills.js";
|
package/dist/workspace/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// The Workspace port (workspace.ts), its folder layout (paths.ts), attach to a computer (attach.ts), where a run's
|
|
2
|
-
// tools run (place.ts), the local backend and the Archil one.
|
|
3
|
-
// that moves every writer onto it.
|
|
2
|
+
// tools run (place.ts), the local backend and the Archil one.
|
|
4
3
|
export * from "./workspace.js";
|
|
5
4
|
export { attachedWorkspace, checkReadBack, COMPUTER_CHUNK, NO_COMPUTER, noProcesses, } from "./attach.js";
|
|
6
5
|
export { agentDirName, agentFolder, agentHomeFolder, agentLearningFolder, COMPUTER_ROOT, DISK_DIR, homeKey, learningKey, portPath, relativePath, relativeSegments, runFolder, runKey, scratchFolder, } from "./paths.js";
|
|
@@ -12,7 +11,7 @@ export { ARCHIL_CONTROL_URLS, ArchilMountCredentialError, listTokenUsers, mintMo
|
|
|
12
11
|
export { ARCHIL_API_KEY_ENV, archilApiKey } from "./archil-key.js";
|
|
13
12
|
export { openRunWorkspace } from "./run-workspace.js";
|
|
14
13
|
export { readOnlyWorkspace, SERVER_READS_ONLY, serverRunWorkspace } from "./server-run-workspace.js";
|
|
15
|
-
export {
|
|
14
|
+
export { storeLedger } from "./computer-ledger.js";
|
|
16
15
|
export { learningWorkspace } from "./learning-workspace.js";
|
|
17
16
|
export { ARCHIL_MAX_EXEC_S, handsOf, MAX_EXEC_S, processesOf, shellEnv } from "./hands.js";
|
|
18
17
|
export { runTools, withKindTools } from "./run-tools.js";
|
|
@@ -20,6 +19,7 @@ export { inputOf, phoneOf, screenOf } from "./computer-ports.js";
|
|
|
20
19
|
export { computerReadiness, resolveComputer, runShellOf, shellPlaceOf, } from "./resolve-computer.js";
|
|
21
20
|
export { computerProviderFactories, computerProviderMakers } from "./computer-providers.js";
|
|
22
21
|
export { claimComputer, claimKinds, computerDepsFrom, computerSpecOf, DAEMON_CACHE_IN_VOLUME, DOCKER_HOST_ADDRESSES_ENV, dockerHostAddressesOf, dockerVolumeOf, } from "./computer-deps.js";
|
|
23
|
-
export { computerForClaim
|
|
22
|
+
export { computerForClaim } from "./computer-for-claim.js";
|
|
23
|
+
export { JANITOR_EVERY_MS, startJanitor, sweepServerComputers } from "./computer-janitor.js";
|
|
24
24
|
export { layOwnSkills, RUN_SKILLS_DIR } from "./revision-skills.js";
|
|
25
25
|
export { KIND_SKILLS, kindSkillOf } from "./kind-skills.js";
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { type Workspace } from "./workspace.js";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
export type LocalWorkspaceOptions = {
|
|
3
|
+
/** A name below a held folder resolves through /proc/self/fd/<fd> (default: on Linux, where it is there). false takes
|
|
4
|
+
* the branch every other platform (macOS) takes, which resolves paths again and checks each one (the file's head). */
|
|
5
|
+
readonly procFd?: boolean;
|
|
6
|
+
/** A test's hook: called each time a folder below the root is held, with its path, before anything is done in it:
|
|
7
|
+
* where another process's swap of that folder for a link would land. */
|
|
8
|
+
readonly onHeld?: (abs: string) => void | Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
/** A Workspace on folder `root` of this machine. The folder must be there when it is first used (else UNAVAILABLE).
|
|
11
|
+
* `options` are a test's: the path-resolving branch forced, and a hook where a swap would land. */
|
|
12
|
+
export declare const localWorkspace: (root: string, options?: LocalWorkspaceOptions) => Workspace;
|
|
13
|
+
/** The folder of this machine that `work` is, by its path: a LocalWorkspace's root; undefined for any other Workspace (a
|
|
14
|
+
* Mode 2 run's folder on its disk, one attached to a computer), whose files no local path reaches. */
|
|
15
|
+
export declare const localFolderOf: (work: Workspace) => string | undefined;
|
|
4
16
|
/** `work` as a Workspace: a folder of this machine, by its path, becomes its LocalWorkspace. For the callers that still
|
|
5
17
|
* hand a run's folder by its path (the run's start and its process), until they hand the run's Workspace. */
|
|
6
18
|
export declare const workspaceAt: (work: string | Workspace) => Workspace;
|