@parcha/agentrun-serve 0.1.0-beta.32 → 0.1.0-beta.34
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 +270 -0
- package/README.md +343 -246
- package/dist/adapters.d.ts +0 -7
- package/dist/adapters.js +11 -22
- package/dist/agent-rows.d.ts +98 -0
- package/dist/agent-rows.js +1 -0
- package/dist/agents-store.d.ts +6 -2
- package/dist/agents-store.js +60 -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 +14 -0
- package/dist/api-only.js +33 -0
- package/dist/archil-routes.d.ts +1 -1
- package/dist/bash-read-only.d.ts +22 -0
- package/dist/bash-read-only.js +701 -0
- package/dist/box-egress-vm.d.ts +0 -8
- package/dist/box-egress-vm.js +0 -10
- package/dist/box-egress.d.ts +0 -4
- package/dist/box-egress.js +1 -16
- package/dist/box-paths.d.ts +25 -2
- package/dist/box-paths.js +79 -11
- package/dist/box-relay.d.ts +0 -11
- package/dist/box-relay.js +0 -20
- package/dist/box-settings.d.ts +26 -0
- package/dist/box-settings.js +63 -0
- package/dist/boxes.d.ts +21 -1
- 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 +94 -51
- package/dist/browser-live.d.ts +7 -20
- package/dist/browser-live.js +15 -93
- package/dist/browser-person.d.ts +18 -53
- package/dist/browser-person.js +94 -279
- package/dist/budget.d.ts +0 -4
- package/dist/budget.js +0 -7
- package/dist/cap.d.ts +8 -12
- package/dist/cap.js +12 -27
- package/dist/cli.js +61 -20
- 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.js +5 -2
- package/dist/computer-setting.d.ts +20 -4
- package/dist/computer-setting.js +25 -5
- package/dist/computers.d.ts +31 -3
- package/dist/computers.js +70 -11
- package/dist/confine.d.ts +120 -0
- package/dist/confine.js +436 -0
- package/dist/console/assets/index-RPHGlXmM.js +540 -0
- package/dist/console/assets/index-opTN5Naq.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/daytona-api.d.ts +0 -11
- package/dist/daytona-api.js +1 -82
- 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/docker-host-addresses.d.ts +37 -0
- package/dist/docker-host-addresses.js +110 -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 +0 -2
- package/dist/errors.js +6 -9
- package/dist/filed-answer.d.ts +32 -0
- package/dist/filed-answer.js +160 -0
- package/dist/files.d.ts +1 -11
- package/dist/files.js +2 -21
- package/dist/github-connection.d.ts +2 -2
- package/dist/github-connection.js +1 -1
- package/dist/graph-view.d.ts +3 -5
- package/dist/graph-view.js +4 -14
- package/dist/handed-values.d.ts +9 -0
- package/dist/handed-values.js +26 -0
- package/dist/harness-install.d.ts +22 -5
- package/dist/harness-install.js +98 -20
- package/dist/harness-opencode/adapter.d.ts +7 -0
- package/dist/harness-opencode/adapter.js +23 -6
- 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/harness.d.ts +4 -3
- package/dist/harness.js +16 -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 +62 -24
- package/dist/key-refusal.d.ts +5 -1
- package/dist/key-refusal.js +19 -4
- package/dist/learn/check.d.ts +6 -2
- package/dist/learn/check.js +83 -29
- package/dist/learn/folder.d.ts +5 -1
- package/dist/learn/folder.js +10 -3
- package/dist/learn/grade.d.ts +14 -0
- package/dist/learn/grade.js +68 -12
- package/dist/learn/index.d.ts +4 -4
- package/dist/learn/index.js +4 -4
- package/dist/learn/reflect.d.ts +31 -2
- package/dist/learn/reflect.js +79 -4
- package/dist/learn/relevance.d.ts +24 -0
- package/dist/learn/relevance.js +91 -0
- package/dist/learn/secrets.d.ts +8 -1
- package/dist/learn/secrets.js +95 -15
- package/dist/learn/skills.d.ts +112 -14
- package/dist/learn/skills.js +556 -52
- package/dist/learned-workflow.d.ts +37 -5
- package/dist/learned-workflow.js +106 -12
- package/dist/learning-routes.d.ts +16 -49
- package/dist/learning-routes.js +46 -36
- package/dist/learning-run.d.ts +6 -250
- package/dist/learning-run.js +11 -665
- package/dist/learning-words.d.ts +12 -5
- package/dist/learning-words.js +18 -9
- package/dist/learning.d.ts +93 -77
- package/dist/learning.js +176 -304
- package/dist/live/stream.js +1 -1
- package/dist/live/translate.js +13 -3
- package/dist/local-models.d.ts +11 -5
- package/dist/local-models.js +13 -8
- package/dist/mcp-gateway.d.ts +11 -52
- package/dist/mcp-gateway.js +44 -148
- 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 +6 -6
- package/dist/mcp-servers-store.js +13 -15
- package/dist/mcp-store.js +3 -4
- package/dist/mcp.js +4 -3
- package/dist/model.d.ts +6 -7
- package/dist/model.js +43 -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 +124 -50
- package/dist/page.d.ts +1 -3
- package/dist/page.js +9 -19
- package/dist/paid-calls.d.ts +21 -27
- package/dist/paid-calls.js +28 -62
- package/dist/pause.d.ts +0 -2
- package/dist/pause.js +1 -8
- package/dist/place.d.ts +0 -5
- package/dist/place.js +0 -10
- package/dist/print.d.ts +2 -1
- package/dist/print.js +4 -2
- package/dist/propose.js +83 -39
- 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 -13
- package/dist/run-db.js +2 -41
- package/dist/run-launch.d.ts +19 -2
- package/dist/run-launch.js +13 -5
- package/dist/run-learning-served.d.ts +46 -2
- package/dist/run-learning-served.js +26 -7
- package/dist/run-reads-over-store.d.ts +1 -1
- package/dist/run-reads-over-store.js +15 -6
- package/dist/run-secrets.d.ts +33 -0
- package/dist/run-secrets.js +53 -0
- package/dist/run-timeline-served.d.ts +5 -1
- package/dist/run-timeline-served.js +19 -5
- package/dist/run-view.d.ts +12 -17
- package/dist/run-view.js +29 -28
- package/dist/runnable.d.ts +18 -10
- package/dist/runnable.js +21 -10
- package/dist/runner/adapter-loop.d.ts +14 -3
- package/dist/runner/adapter-loop.js +464 -62
- package/dist/runner/adapter-run-spec.d.ts +29 -8
- package/dist/runner/adapter-run-spec.js +96 -37
- package/dist/runner/adapters/index.js +11 -1
- package/dist/runner/adapters/pi.d.ts +15 -1
- package/dist/runner/adapters/pi.js +19 -5
- package/dist/runner/beside.d.ts +30 -3
- package/dist/runner/beside.js +54 -12
- package/dist/runner/claim-secrets.d.ts +10 -1
- package/dist/runner/claim-secrets.js +49 -15
- package/dist/runner/cli-run-spec.d.ts +2 -0
- package/dist/runner/cli-run-spec.js +60 -17
- 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.js +118 -8
- 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.js +1 -1
- package/dist/runner/harness-loops.d.ts +9 -1
- package/dist/runner/harness-loops.js +15 -2
- package/dist/runner/journal-kinds.d.ts +30 -6
- package/dist/runner/journal-kinds.js +20 -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 +113 -11
- package/dist/runner/learning-loop.d.ts +5 -0
- package/dist/runner/learning-loop.js +26 -6
- package/dist/runner/live-ticker.d.ts +1 -1
- package/dist/runner/live-ticker.js +28 -4
- package/dist/runner/loop-contract.d.ts +3 -2
- package/dist/runner/main.d.ts +64 -10
- package/dist/runner/main.js +165 -27
- package/dist/runner/mcp-claim.d.ts +1 -1
- package/dist/runner/mcp-claim.js +2 -3
- package/dist/runner/mcp-run.d.ts +2 -0
- package/dist/runner/mcp-run.js +15 -5
- package/dist/runner/memory-claim.d.ts +9 -0
- package/dist/runner/memory-claim.js +25 -0
- package/dist/runner/metrics.d.ts +33 -1
- package/dist/runner/metrics.js +85 -1
- package/dist/runner/model-route.d.ts +13 -0
- package/dist/runner/model-route.js +154 -11
- package/dist/runner/redact.d.ts +8 -2
- package/dist/runner/redact.js +11 -2
- 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 +56 -10
- 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-loop.d.ts +6 -0
- package/dist/runner/workflow-loop.js +6 -4
- package/dist/runner/workflow-spec.d.ts +18 -0
- package/dist/runner/workflow-spec.js +68 -26
- package/dist/runs-over-store.d.ts +8 -3
- package/dist/runs-over-store.js +76 -19
- package/dist/seal-key.d.ts +54 -15
- package/dist/seal-key.js +232 -82
- 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/secrets.d.ts +2 -10
- package/dist/secrets.js +21 -17
- 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 +1 -80
- package/dist/server-secrets-store.d.ts +4 -4
- package/dist/server-secrets-store.js +10 -32
- package/dist/server-secrets.d.ts +4 -9
- package/dist/server-secrets.js +12 -33
- package/dist/server.d.ts +26 -44
- package/dist/server.js +229 -142
- 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/store/agent-body.d.ts +8 -2
- package/dist/store/agent-body.js +16 -4
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +3 -3
- package/dist/store/open.d.ts +18 -5
- package/dist/store/open.js +23 -3
- package/dist/store/postgres/connection.d.ts +18 -2
- package/dist/store/postgres/connection.js +156 -32
- package/dist/store/postgres/migrate.d.ts +4 -0
- package/dist/store/postgres/migrate.js +27 -3
- 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 +49 -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 +64 -20
- package/dist/store/store.d.ts +38 -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 +25 -6
- package/dist/store-reads/journal.js +173 -21
- package/dist/store-reads/learning.d.ts +26 -8
- package/dist/store-reads/learning.js +12 -4
- package/dist/store-reads/workflow.d.ts +1 -1
- package/dist/store-reads/workflow.js +1 -1
- package/dist/store-view.d.ts +5 -1
- package/dist/store-view.js +91 -23
- package/dist/template-eval.d.ts +60 -4
- package/dist/template-eval.js +120 -54
- package/dist/templates.d.ts +24 -10
- package/dist/templates.js +69 -38
- 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 +274 -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-gate.d.ts +41 -216
- package/dist/tool-gate.js +79 -540
- package/dist/tool-keys-store.d.ts +11 -12
- package/dist/tool-keys-store.js +24 -31
- package/dist/tool-keys.d.ts +9 -104
- package/dist/tool-keys.js +15 -271
- package/dist/tool-plane.d.ts +14 -42
- 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 +31 -19
- package/dist/tools.js +101 -108
- package/dist/trigger-adapter.d.ts +2 -2
- package/dist/trigger-schedule.js +2 -1
- package/dist/trigger-secrets-shown.js +5 -1
- 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.js +1 -1
- package/dist/usage.d.ts +0 -2
- package/dist/usage.js +0 -2
- package/dist/validate.d.ts +2 -0
- package/dist/validate.js +23 -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/beneath.d.ts +19 -0
- package/dist/workspace/beneath.js +106 -0
- package/dist/workspace/computer-deps.d.ts +52 -5
- package/dist/workspace/computer-deps.js +154 -19
- package/dist/workspace/computer-for-claim.d.ts +19 -14
- package/dist/workspace/computer-for-claim.js +77 -16
- 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-providers.d.ts +6 -2
- package/dist/workspace/computer-providers.js +1 -1
- package/dist/workspace/grep-worker.d.ts +5 -0
- package/dist/workspace/grep-worker.js +9 -6
- package/dist/workspace/index.d.ts +4 -3
- package/dist/workspace/index.js +4 -4
- package/dist/workspace/local.d.ts +11 -2
- package/dist/workspace/local.js +161 -43
- package/dist/workspace/resolve-computer.d.ts +50 -10
- package/dist/workspace/resolve-computer.js +46 -11
- package/dist/workspace/run-tools.d.ts +13 -31
- package/dist/workspace/run-tools.js +10 -27
- 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 +3 -99
- package/launcher/agentrun-serve +6 -33
- package/package.json +14 -14
- package/templates/README.md +9 -3
- package/templates/inbound-lead/agent.md +1 -1
- package/templates/kyb/agent.md +1 -1
- package/templates/market-monitor/agent.md +2 -2
- package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
- package/dist/app.d.ts +0 -5
- package/dist/app.js +0 -514
- package/dist/bound-files.d.ts +0 -4
- package/dist/bound-files.js +0 -164
- package/dist/bounds.d.ts +0 -26
- package/dist/bounds.js +0 -137
- 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-35-7aeIZ.js +0 -519
- package/dist/console/assets/index-Cejbov-Y.css +0 -1
- package/dist/content-filter.d.ts +0 -7
- package/dist/content-filter.js +0 -23
- package/dist/disk.d.ts +0 -33
- package/dist/disk.js +0 -85
- package/dist/door-line.d.ts +0 -23
- package/dist/door-line.js +0 -83
- package/dist/grade.d.ts +0 -63
- package/dist/grade.js +0 -150
- package/dist/harness-app.d.ts +0 -69
- package/dist/harness-app.js +0 -1162
- 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/request-start.d.ts +0 -27
- package/dist/request-start.js +0 -381
- package/dist/run-box.d.ts +0 -205
- package/dist/run-box.js +0 -661
- package/dist/run-holder.d.ts +0 -52
- package/dist/run-holder.js +0 -139
- package/dist/runs.d.ts +0 -1200
- package/dist/runs.js +0 -4103
- package/dist/sealed-settings.d.ts +0 -60
- package/dist/sealed-settings.js +0 -178
- package/dist/served-only.d.ts +0 -5
- package/dist/served-only.js +0 -12
- 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/run-holder.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { type ProcessTable } from "@parcha/pi-durable-disk/internals";
|
|
2
|
-
/** Tests' seam: a process table read in place of this machine's (pi-durable-disk processTable: /proc on Linux, ps on
|
|
3
|
-
* macOS, where a process's environment is read with `ps -E`). */
|
|
4
|
-
export declare const runHolderTestHooks: {
|
|
5
|
-
table?: ProcessTable;
|
|
6
|
-
};
|
|
7
|
-
/** What a launch's claim names until its process is spawned and named in its place. */
|
|
8
|
-
export declare const LAUNCH_HOLDER = "launching";
|
|
9
|
-
/** The mark a launch puts in its process's environment, `<run id>:<epoch>`: how a row that still names LAUNCH_HOLDER (its
|
|
10
|
-
* server went, or its store was held, before the process was named) finds the process that launch started. */
|
|
11
|
-
export declare const RUN_LAUNCH_ENV = "AGENTRUN_RUN_LAUNCH";
|
|
12
|
-
/** The epoch of the run's claim its process was launched under (runs.ts launch): a run process reads it here to label the
|
|
13
|
-
* box it makes (run-box.ts EPOCH_LABEL). */
|
|
14
|
-
export declare const RUN_EPOCH_ENV = "AGENTRUN_RUN_EPOCH";
|
|
15
|
-
/** A run's process as its row names it. */
|
|
16
|
-
export type RunHolder = {
|
|
17
|
-
pid: number;
|
|
18
|
-
start: number;
|
|
19
|
-
boot: string | null;
|
|
20
|
-
door?: string;
|
|
21
|
-
nonce?: string;
|
|
22
|
-
};
|
|
23
|
-
/** The holder a row's claim names, or undefined for none, the server (a take-back) or anything that is not one. */
|
|
24
|
-
export declare function holderOf(claim: string | null | undefined): RunHolder | undefined;
|
|
25
|
-
/** Process `pid` as a holder: its start and this boot, read now; undefined once it is gone, or when the process listing
|
|
26
|
-
* cannot be read (its identity is then not known, and nothing is named for it). */
|
|
27
|
-
export declare function holderOfProcess(pid: number): RunHolder | undefined;
|
|
28
|
-
/** The live processes run `runId`'s launch at `epoch` started, by their mark (RUN_LAUNCH_ENV). Throws when the processes
|
|
29
|
-
* cannot be listed: a process is never taken for gone on a failed look. */
|
|
30
|
-
export declare function launchedProcesses(runId: string, epoch: number): RunHolder[];
|
|
31
|
-
/** The process a row's claim (`holder` at `epoch`) names: the one it names outright, or for a launch not yet named, the
|
|
32
|
-
* one that launch started; undefined for none or the server. */
|
|
33
|
-
export declare function holderOfClaim(runId: string, claim: {
|
|
34
|
-
epoch: number;
|
|
35
|
-
holder: string | null;
|
|
36
|
-
}): RunHolder | undefined;
|
|
37
|
-
/** What can be told of `holder`'s process: `alive` (its pid names a process of the same start, on this boot), `gone`, or
|
|
38
|
-
* `unknown` (the process listing, or this boot's id, cannot be read). Unknown is never taken for gone, nor for a
|
|
39
|
-
* process that may be killed, however long it lasts. */
|
|
40
|
-
export type HolderState = "alive" | "gone" | "unknown";
|
|
41
|
-
export declare function holderState(holder: RunHolder): HolderState;
|
|
42
|
-
/** Whether `holder`'s process may live: alive, or unknown (never taken over on a look that failed). */
|
|
43
|
-
export declare function holderLives(holder: RunHolder): boolean;
|
|
44
|
-
/** Kills `holder`'s process with SIGKILL when it is confirmed alive, without waiting: true when it was. Never this
|
|
45
|
-
* process. An identity that cannot be checked throws: nothing is killed unidentified, and its caller claims nothing. */
|
|
46
|
-
export declare function killHolder(holder: RunHolder): boolean;
|
|
47
|
-
/** Sends `name` to `pid`: true when it was sent. ESRCH (it exited since the look) and EPERM (the pid is another user's
|
|
48
|
-
* now, so not the holder's) are no error and send nothing: false, and no kill is tried again on either. */
|
|
49
|
-
export declare function signal(pid: number, name: NodeJS.Signals): boolean;
|
|
50
|
-
/** Kills `holder`'s process when it lives and waits until it is gone (at most `waitMs`, else it throws): what a claim
|
|
51
|
-
* over a holder does first. */
|
|
52
|
-
export declare function fenceHolder(holder: RunHolder | undefined, waitMs?: number): Promise<void>;
|
package/dist/run-holder.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
// Who holds a run, as its row's claim names it (store.sqlite claim_holder): the run's process by its pid, the start of
|
|
2
|
-
// that process (so a pid a later process reuses is never taken for it) and this machine's boot, its launch's door nonce,
|
|
3
|
-
// and, once its door has proven that nonce (door-line.ts), its door. The row's epoch is the whole lock: the server claims a run only from the epoch it read, and kills a holder that
|
|
4
|
-
// still lives before it claims over it, so no process of a lower epoch runs (or commits to the run's store) after the
|
|
5
|
-
// bump. The server writes the holder (launch, then the door its process names on stdout); the run's process never
|
|
6
|
-
// opens store.sqlite.
|
|
7
|
-
import { processTable } from "@parcha/pi-durable-disk/internals";
|
|
8
|
-
/** Tests' seam: a process table read in place of this machine's (pi-durable-disk processTable: /proc on Linux, ps on
|
|
9
|
-
* macOS, where a process's environment is read with `ps -E`). */
|
|
10
|
-
export const runHolderTestHooks = {};
|
|
11
|
-
const tableOf = () => runHolderTestHooks.table ?? processTable();
|
|
12
|
-
/** What a launch's claim names until its process is spawned and named in its place. */
|
|
13
|
-
export const LAUNCH_HOLDER = "launching";
|
|
14
|
-
/** The mark a launch puts in its process's environment, `<run id>:<epoch>`: how a row that still names LAUNCH_HOLDER (its
|
|
15
|
-
* server went, or its store was held, before the process was named) finds the process that launch started. */
|
|
16
|
-
export const RUN_LAUNCH_ENV = "AGENTRUN_RUN_LAUNCH";
|
|
17
|
-
/** The epoch of the run's claim its process was launched under (runs.ts launch): a run process reads it here to label the
|
|
18
|
-
* box it makes (run-box.ts EPOCH_LABEL). */
|
|
19
|
-
export const RUN_EPOCH_ENV = "AGENTRUN_RUN_EPOCH";
|
|
20
|
-
/** The holder a row's claim names, or undefined for none, the server (a take-back) or anything that is not one. */
|
|
21
|
-
export function holderOf(claim) {
|
|
22
|
-
if (typeof claim !== "string" || !claim.startsWith("{"))
|
|
23
|
-
return undefined;
|
|
24
|
-
let value;
|
|
25
|
-
try {
|
|
26
|
-
value = JSON.parse(claim);
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
const holder = value;
|
|
32
|
-
if (!Number.isSafeInteger(holder.pid) || holder.pid <= 0 || !Number.isSafeInteger(holder.start))
|
|
33
|
-
return undefined;
|
|
34
|
-
if (holder.boot !== null && typeof holder.boot !== "string")
|
|
35
|
-
return undefined;
|
|
36
|
-
if (holder.door !== undefined && typeof holder.door !== "string")
|
|
37
|
-
return undefined;
|
|
38
|
-
if (holder.nonce !== undefined && typeof holder.nonce !== "string")
|
|
39
|
-
return undefined;
|
|
40
|
-
return { pid: holder.pid, start: holder.start, boot: holder.boot ?? null, ...(holder.door === undefined ? {} : { door: holder.door }), ...(holder.nonce === undefined ? {} : { nonce: holder.nonce }) };
|
|
41
|
-
}
|
|
42
|
-
/** Process `pid` as a holder: its start and this boot, read now; undefined once it is gone, or when the process listing
|
|
43
|
-
* cannot be read (its identity is then not known, and nothing is named for it). */
|
|
44
|
-
export function holderOfProcess(pid) {
|
|
45
|
-
const table = tableOf();
|
|
46
|
-
try {
|
|
47
|
-
const start = table.snapshot().info(pid)?.start;
|
|
48
|
-
return start === undefined ? undefined : { pid, start, boot: table.bootId() ?? null };
|
|
49
|
-
}
|
|
50
|
-
catch {
|
|
51
|
-
return undefined;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
/** The live processes run `runId`'s launch at `epoch` started, by their mark (RUN_LAUNCH_ENV). Throws when the processes
|
|
55
|
-
* cannot be listed: a process is never taken for gone on a failed look. */
|
|
56
|
-
export function launchedProcesses(runId, epoch) {
|
|
57
|
-
const table = tableOf();
|
|
58
|
-
let look;
|
|
59
|
-
let marked;
|
|
60
|
-
try {
|
|
61
|
-
look = table.snapshot();
|
|
62
|
-
marked = look.withMark(RUN_LAUNCH_ENV, `${runId}:${epoch}`);
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
// Never a kill on a look that failed: whoever asked waits and tries again.
|
|
66
|
-
throw new Error(`the process its launch started cannot be looked for (${error.message}); it is never killed unidentified`, { cause: error });
|
|
67
|
-
}
|
|
68
|
-
const boot = table.bootId() ?? null;
|
|
69
|
-
// The run's process, not a command of it that inherited the mark: a marked process whose parent is not marked. A
|
|
70
|
-
// process whose environment cannot be read (another user's, or one inside an exec) carries no mark here, so it is
|
|
71
|
-
// never killed; the run's store, which such a process would hold, refuses a second writer by its own lock.
|
|
72
|
-
return marked.flatMap((pid) => {
|
|
73
|
-
const info = look.info(pid);
|
|
74
|
-
return info === undefined || marked.includes(info.ppid) ? [] : [{ pid, start: info.start, boot }];
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
/** The process a row's claim (`holder` at `epoch`) names: the one it names outright, or for a launch not yet named, the
|
|
78
|
-
* one that launch started; undefined for none or the server. */
|
|
79
|
-
export function holderOfClaim(runId, claim) {
|
|
80
|
-
const named = holderOf(claim.holder);
|
|
81
|
-
if (named !== undefined || claim.holder !== LAUNCH_HOLDER)
|
|
82
|
-
return named;
|
|
83
|
-
return launchedProcesses(runId, claim.epoch)[0];
|
|
84
|
-
}
|
|
85
|
-
export function holderState(holder) {
|
|
86
|
-
const table = tableOf();
|
|
87
|
-
let boot;
|
|
88
|
-
let start;
|
|
89
|
-
try {
|
|
90
|
-
boot = table.bootId() ?? null;
|
|
91
|
-
if (holder.boot !== null && boot !== null && holder.boot !== boot)
|
|
92
|
-
return "gone";
|
|
93
|
-
start = table.snapshot().info(holder.pid)?.start;
|
|
94
|
-
}
|
|
95
|
-
catch {
|
|
96
|
-
return "unknown";
|
|
97
|
-
}
|
|
98
|
-
return start === holder.start ? "alive" : "gone";
|
|
99
|
-
}
|
|
100
|
-
/** Whether `holder`'s process may live: alive, or unknown (never taken over on a look that failed). */
|
|
101
|
-
export function holderLives(holder) {
|
|
102
|
-
return holderState(holder) !== "gone";
|
|
103
|
-
}
|
|
104
|
-
/** Kills `holder`'s process with SIGKILL when it is confirmed alive, without waiting: true when it was. Never this
|
|
105
|
-
* process. An identity that cannot be checked throws: nothing is killed unidentified, and its caller claims nothing. */
|
|
106
|
-
export function killHolder(holder) {
|
|
107
|
-
if (holder.pid === process.pid)
|
|
108
|
-
return false;
|
|
109
|
-
const state = holderState(holder);
|
|
110
|
-
if (state === "gone")
|
|
111
|
-
return false;
|
|
112
|
-
if (state === "unknown")
|
|
113
|
-
throw new Error(`the run's holder ${holder.pid} cannot be checked (the process listing failed): it is never killed unidentified, and nothing is claimed over it`);
|
|
114
|
-
return signal(holder.pid, "SIGKILL");
|
|
115
|
-
}
|
|
116
|
-
/** Sends `name` to `pid`: true when it was sent. ESRCH (it exited since the look) and EPERM (the pid is another user's
|
|
117
|
-
* now, so not the holder's) are no error and send nothing: false, and no kill is tried again on either. */
|
|
118
|
-
export function signal(pid, name) {
|
|
119
|
-
try {
|
|
120
|
-
process.kill(pid, name);
|
|
121
|
-
return true;
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
const code = error.code;
|
|
125
|
-
if (code === "ESRCH" || code === "EPERM")
|
|
126
|
-
return false;
|
|
127
|
-
throw error;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
/** Kills `holder`'s process when it lives and waits until it is gone (at most `waitMs`, else it throws): what a claim
|
|
131
|
-
* over a holder does first. */
|
|
132
|
-
export async function fenceHolder(holder, waitMs = 10_000) {
|
|
133
|
-
if (holder === undefined || !killHolder(holder))
|
|
134
|
-
return;
|
|
135
|
-
for (const end = Date.now() + waitMs; holderState(holder) !== "gone"; await new Promise((resolve) => setTimeout(resolve, 20))) {
|
|
136
|
-
if (Date.now() > end)
|
|
137
|
-
throw new Error(`the run's holder ${holder.pid} still lives ${waitMs / 1000} s after SIGKILL`);
|
|
138
|
-
}
|
|
139
|
-
}
|