@parcha/agentrun-serve 0.1.0-beta.57 → 0.1.0-beta.59
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 +376 -0
- package/README.md +393 -118
- package/dist/acp-package.d.ts +5 -1
- package/dist/acp-package.js +19 -2
- package/dist/adapters.d.ts +23 -2
- package/dist/adapters.js +106 -33
- package/dist/agents-store.js +1 -1
- package/dist/answer-text.d.ts +3 -0
- package/dist/answer-text.js +22 -0
- package/dist/api-only.d.ts +2 -4
- package/dist/api-only.js +2 -4
- package/dist/attach-conformance.js +5 -4
- package/dist/box-paths.d.ts +7 -5
- package/dist/box-paths.js +12 -8
- package/dist/browser-computer.d.ts +3 -8
- package/dist/browser-computer.js +12 -35
- package/dist/browser-cost.js +94 -20
- package/dist/capacity.d.ts +1 -1
- package/dist/capacity.js +3 -3
- package/dist/chatgpt-plan.d.ts +5 -0
- package/dist/chatgpt-plan.js +25 -11
- package/dist/claude-login-token.d.ts +121 -0
- package/dist/claude-login-token.js +797 -0
- package/dist/claude-login.d.ts +119 -34
- package/dist/claude-login.js +551 -79
- package/dist/claude-sign-in.d.ts +3 -0
- package/dist/claude-sign-in.js +10 -1
- package/dist/cli.js +325 -328
- package/dist/composio-made.d.ts +1 -6
- package/dist/composio-made.js +1 -6
- package/dist/composio-owners.d.ts +26 -0
- package/dist/composio-owners.js +36 -0
- package/dist/composio-preset.d.ts +56 -23
- package/dist/composio-preset.js +173 -77
- package/dist/composio-triggers.d.ts +4 -4
- package/dist/composio-triggers.js +6 -7
- package/dist/compute-cost.js +11 -2
- package/dist/computer-attach.d.ts +40 -19
- package/dist/computer-attach.js +326 -62
- package/dist/computer-held-routes.d.ts +1 -1
- package/dist/computer-held-routes.js +9 -4
- package/dist/computer-keys.d.ts +11 -1
- package/dist/computer-keys.js +26 -1
- package/dist/computer-record.js +3 -1
- package/dist/computer-view.d.ts +5 -3
- package/dist/computer-view.js +10 -6
- package/dist/computer-viewer.js +36 -7
- package/dist/computers.d.ts +12 -11
- package/dist/computers.js +11 -8
- package/dist/console/THIRD-PARTY-NOTICES.txt +50 -0
- package/dist/console/assets/backend-BztxEAvb.js +166 -0
- package/dist/console/assets/index-LwNL4L9q.js +619 -0
- package/dist/console/assets/share-L84tlUDW.js +6 -0
- package/dist/console/assets/styles-CaRKlHke.js +291 -0
- package/dist/console/assets/styles-DQo8rzY-.css +1 -0
- package/dist/console/index.html +4 -3
- package/dist/console/share.html +17 -0
- package/dist/decisions.d.ts +17 -7
- package/dist/decisions.js +41 -15
- package/dist/dial-relay.d.ts +25 -4
- package/dist/dial-relay.js +139 -5
- package/dist/docker-daemon.js +4 -5
- package/dist/docker-host-addresses.js +29 -11
- package/dist/email/account.d.ts +6 -0
- package/dist/email/account.js +6 -0
- package/dist/email/authentication.d.ts +21 -0
- package/dist/email/authentication.js +106 -0
- package/dist/email/email-faux.d.ts +11 -2
- package/dist/email/email-faux.js +21 -5
- package/dist/email/mail.d.ts +25 -0
- package/dist/email/mail.js +58 -2
- package/dist/email/names.js +2 -2
- package/dist/email/tools.d.ts +9 -4
- package/dist/email/tools.js +95 -13
- package/dist/env-switch.d.ts +13 -5
- package/dist/env-switch.js +24 -6
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/fal-price.d.ts +12 -4
- package/dist/fal-price.js +110 -26
- package/dist/faux-computers.js +1 -1
- package/dist/filed-answer.d.ts +2 -2
- package/dist/filed-answer.js +2 -2
- package/dist/graph-served.d.ts +10 -5
- package/dist/graph-served.js +40 -10
- package/dist/handed-values.js +1 -2
- package/dist/harness-check.d.ts +2 -1
- package/dist/harness-check.js +45 -12
- package/dist/harness-keys.js +9 -6
- package/dist/harness-opencode/facts.js +2 -0
- package/dist/harness-recipe-entry.d.ts +9 -3
- package/dist/harness-recipe-entry.js +18 -9
- package/dist/harness-recipe.d.ts +21 -0
- package/dist/harness-recipe.js +25 -3
- package/dist/harness-table.d.ts +8 -0
- package/dist/harness-table.js +17 -6
- package/dist/helper-env.d.ts +4 -1
- package/dist/helper-env.js +4 -1
- package/dist/host-check.d.ts +2 -3
- package/dist/host-check.js +13 -7
- package/dist/hosted-search.js +1 -1
- package/dist/import.d.ts +11 -8
- package/dist/import.js +437 -186
- package/dist/key-refusal.d.ts +9 -2
- package/dist/key-refusal.js +86 -32
- package/dist/learn/audit.d.ts +8 -5
- package/dist/learn/audit.js +15 -7
- package/dist/learn/compile.d.ts +5 -2
- package/dist/learn/compile.js +45 -21
- package/dist/learn/field-check.d.ts +111 -0
- package/dist/learn/field-check.js +174 -0
- package/dist/learn/ledger.d.ts +173 -0
- package/dist/learn/ledger.js +225 -0
- package/dist/learn/promote.d.ts +82 -39
- package/dist/learn/promote.js +61 -66
- package/dist/learn/secrets.d.ts +4 -0
- package/dist/learn/secrets.js +12 -0
- package/dist/learned-nodes.d.ts +8 -5
- package/dist/learned-nodes.js +8 -5
- package/dist/learned-workflow.d.ts +2 -1
- package/dist/learned-workflow.js +13 -10
- package/dist/learning-cost.d.ts +40 -21
- package/dist/learning-cost.js +30 -21
- package/dist/learning-setting.d.ts +6 -0
- package/dist/learning-setting.js +11 -1
- package/dist/listen-first.d.ts +5 -4
- package/dist/listen-first.js +4 -5
- package/dist/live-reach.d.ts +9 -0
- package/dist/live-reach.js +9 -0
- package/dist/mcp-api-only-origins.d.ts +23 -3
- package/dist/mcp-api-only-origins.js +57 -17
- package/dist/mcp-gateway.d.ts +16 -2
- package/dist/mcp-gateway.js +41 -3
- package/dist/mcp-oauth.d.ts +1 -1
- package/dist/mcp-oauth.js +3 -2
- package/dist/mcp-probe.d.ts +3 -0
- package/dist/mcp-probe.js +3 -0
- package/dist/mcp-secret-writes.d.ts +24 -2
- package/dist/mcp-secret-writes.js +30 -2
- package/dist/mcp-servers-store.d.ts +52 -14
- package/dist/mcp-servers-store.js +165 -61
- package/dist/mcp-sources.d.ts +1 -2
- package/dist/mcp-sources.js +1 -2
- package/dist/mcp-store.d.ts +5 -5
- package/dist/mcp-store.js +3 -3
- package/dist/mcp.js +1 -1
- package/dist/micro.d.ts +2 -0
- package/dist/micro.js +2 -0
- package/dist/model-gateway.d.ts +1 -1
- package/dist/model-gateway.js +20 -36
- package/dist/model.d.ts +5 -4
- package/dist/model.js +7 -6
- package/dist/monid.d.ts +14 -1
- package/dist/monid.js +103 -26
- package/dist/ollama-provider.d.ts +23 -9
- package/dist/ollama-provider.js +49 -20
- package/dist/openapi.js +234 -61
- package/dist/otel/genai.d.ts +83 -7
- package/dist/otel/genai.js +69 -9
- package/dist/otel/tracer.d.ts +42 -13
- package/dist/otel/tracer.js +241 -56
- package/dist/page.d.ts +7 -1
- package/dist/page.js +76 -22
- package/dist/paid-calls.d.ts +6 -4
- package/dist/paid-calls.js +15 -7
- package/dist/place-offers.d.ts +59 -34
- package/dist/place-offers.js +100 -58
- package/dist/place.d.ts +13 -14
- package/dist/place.js +56 -41
- package/dist/print.js +1 -1
- package/dist/provider.d.ts +5 -4
- package/dist/provider.js +26 -13
- package/dist/redact/match.d.ts +27 -9
- package/dist/redact/match.js +266 -57
- package/dist/run-census.d.ts +1 -1
- package/dist/run-census.js +4 -5
- package/dist/run-cut.js +4 -5
- package/dist/run-export-store.d.ts +15 -0
- package/dist/run-export-store.js +30 -0
- package/dist/run-export.d.ts +139 -0
- package/dist/run-export.js +379 -0
- package/dist/run-file-cut.d.ts +5 -0
- package/dist/run-file-cut.js +13 -0
- package/dist/run-launch.js +16 -3
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-model-key.d.ts +15 -6
- package/dist/run-model-key.js +30 -31
- package/dist/run-reads-over-store.js +4 -4
- package/dist/run-secrets.js +3 -5
- package/dist/run-timeline-served.js +3 -1
- package/dist/run-view.d.ts +1 -2
- package/dist/run-view.js +2 -1
- package/dist/runnable.js +2 -2
- package/dist/runner/adapter-loop.d.ts +35 -18
- package/dist/runner/adapter-loop.js +97 -63
- package/dist/runner/adapter-run-spec.d.ts +34 -14
- package/dist/runner/adapter-run-spec.js +120 -75
- package/dist/runner/adapters/pi.js +4 -2
- package/dist/runner/audit.d.ts +8 -5
- package/dist/runner/audit.js +37 -17
- package/dist/runner/beside.d.ts +9 -2
- package/dist/runner/beside.js +29 -13
- package/dist/runner/claim-secrets.d.ts +27 -18
- package/dist/runner/claim-secrets.js +61 -47
- package/dist/runner/cli-run-spec.d.ts +18 -0
- package/dist/runner/cli-run-spec.js +93 -46
- package/dist/runner/compare-end.d.ts +2 -1
- package/dist/runner/compare-end.js +25 -10
- package/dist/runner/conformance/harness.js +2 -3
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/harness-loops.js +3 -3
- package/dist/runner/held.d.ts +19 -4
- package/dist/runner/journal-kinds.d.ts +4 -1
- package/dist/runner/journal-kinds.js +22 -4
- package/dist/runner/learned-first.js +20 -4
- package/dist/runner/learning-end.d.ts +2 -8
- package/dist/runner/learning-end.js +11 -19
- package/dist/runner/live-ticker.js +7 -5
- package/dist/runner/loop-contract.d.ts +0 -2
- package/dist/runner/loop.d.ts +7 -0
- package/dist/runner/loop.js +1 -0
- package/dist/runner/main.d.ts +11 -6
- package/dist/runner/main.js +24 -18
- package/dist/runner/mcp-claim.js +24 -7
- package/dist/runner/mcp-run.d.ts +3 -6
- package/dist/runner/mcp-run.js +3 -4
- package/dist/runner/meta-tools.js +3 -2
- package/dist/runner/metrics.d.ts +7 -0
- package/dist/runner/metrics.js +19 -0
- package/dist/runner/model-route.d.ts +10 -7
- package/dist/runner/model-route.js +79 -15
- package/dist/runner/native-loop.js +10 -8
- package/dist/runner/presence.d.ts +11 -4
- package/dist/runner/presence.js +11 -6
- package/dist/runner/promotion.d.ts +25 -13
- package/dist/runner/promotion.js +125 -50
- package/dist/runner/redact.d.ts +3 -1
- package/dist/runner/redact.js +5 -3
- package/dist/runner/reflect-hook.js +1 -1
- package/dist/runner/responses-fetch.d.ts +36 -0
- package/dist/runner/responses-fetch.js +511 -0
- package/dist/runner/run-child-host.d.ts +38 -12
- package/dist/runner/run-child-host.js +231 -83
- package/dist/runner/run-child.js +11 -4
- package/dist/runner/runner-check.js +5 -1
- package/dist/runner/runner.d.ts +5 -3
- package/dist/runner/runner.js +14 -10
- package/dist/runner/save-slots.js +2 -1
- package/dist/runner/sdk-loop.js +8 -8
- package/dist/runner/spec-holds.d.ts +8 -1
- package/dist/runner/spec-holds.js +9 -4
- package/dist/runner/subagent.d.ts +11 -0
- package/dist/runner/subagent.js +17 -3
- package/dist/runner/workflow-calls.d.ts +9 -0
- package/dist/runner/workflow-calls.js +150 -0
- package/dist/runner/workflow-first.d.ts +138 -37
- package/dist/runner/workflow-first.js +230 -99
- package/dist/runner/workflow-spec.js +2 -2
- package/dist/runs-over-store.js +8 -7
- package/dist/save-once.d.ts +14 -0
- package/dist/save-once.js +31 -0
- package/dist/scrub-command.d.ts +34 -31
- package/dist/scrub-command.js +116 -147
- package/dist/sdk/runs.d.ts +6 -0
- package/dist/sdk/runs.js +89 -10
- package/dist/seal-key.js +4 -4
- package/dist/secret-cut.d.ts +3 -0
- package/dist/secret-cut.js +7 -1
- package/dist/secret-rules.d.ts +8 -1
- package/dist/secret-rules.js +482 -53
- package/dist/secrets.d.ts +51 -9
- package/dist/secrets.js +311 -21
- package/dist/server-keys.d.ts +4 -3
- package/dist/server-keys.js +4 -3
- package/dist/server-secrets-store.js +2 -4
- package/dist/server.d.ts +33 -10
- package/dist/server.js +454 -136
- package/dist/share-context.d.ts +22 -0
- package/dist/share-context.js +76 -0
- package/dist/shell-lex.d.ts +105 -0
- package/dist/shell-lex.js +646 -0
- package/dist/sign-ins-store.d.ts +5 -7
- package/dist/sign-ins-store.js +12 -16
- package/dist/sign-ins.d.ts +7 -11
- package/dist/sign-ins.js +40 -41
- package/dist/skills/agentrun-serve/SKILL.md +5 -2
- package/dist/slots.d.ts +9 -0
- package/dist/slots.js +45 -0
- package/dist/start-switches.d.ts +6 -5
- package/dist/start-switches.js +8 -4
- package/dist/stats.d.ts +5 -1
- package/dist/stats.js +1 -1
- package/dist/store/agent-body.js +2 -2
- package/dist/store/dialect.d.ts +4 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/mcp-record-keys.d.ts +10 -0
- package/dist/store/mcp-record-keys.js +13 -0
- package/dist/store/postgres/dialect.js +2 -0
- package/dist/store/postgres/migrations/0028_learning_ledger.sql +44 -0
- package/dist/store/postgres/migrations/0029_run_launch_census_settle.sql +28 -0
- package/dist/store/postgres/migrations/0030_learning_ledger_epoch.sql +40 -0
- package/dist/store/postgres/migrations/0031_learning_ledger_calls.sql +12 -0
- package/dist/store/postgres/store.js +4 -0
- package/dist/store/schema.d.ts +44 -4
- package/dist/store/schema.js +111 -11
- package/dist/store/seal.d.ts +4 -1
- package/dist/store/sqlite/run-launch.d.ts +3 -10
- package/dist/store/sqlite/run-launch.js +12 -23
- package/dist/store/sqlite/run-patch.d.ts +19 -2
- package/dist/store/sqlite/run-patch.js +67 -2
- package/dist/store/sqlite/store.d.ts +3 -0
- package/dist/store/sqlite/store.js +177 -32
- package/dist/store/store-schema.js +3 -4
- package/dist/store/store.d.ts +74 -25
- package/dist/store/store.js +14 -11
- package/dist/store-reads/analytics.d.ts +2 -1
- package/dist/store-reads/analytics.js +7 -5
- package/dist/store-reads/learning.d.ts +102 -136
- package/dist/store-reads/learning.js +251 -302
- package/dist/store-reads/stats.d.ts +2 -2
- package/dist/store-reads/stats.js +13 -7
- package/dist/store-view.js +10 -7
- package/dist/suggestions.d.ts +1 -1
- package/dist/suggestions.js +29 -13
- package/dist/template-eval.d.ts +91 -9
- package/dist/template-eval.js +448 -105
- package/dist/template-import.d.ts +0 -10
- package/dist/template-import.js +5 -10
- package/dist/timeline/labels.d.ts +1 -1
- package/dist/timeline/labels.js +4 -3
- package/dist/timeline/timeline.d.ts +23 -11
- package/dist/timeline/timeline.js +115 -31
- package/dist/timeline/web-calls.d.ts +14 -14
- package/dist/timeline/web-calls.js +18 -30
- package/dist/tool-gate.d.ts +13 -1
- package/dist/tool-gate.js +43 -3
- package/dist/tool-keys-store.js +2 -4
- package/dist/tool-keys.d.ts +11 -0
- package/dist/tool-keys.js +16 -0
- package/dist/tool-plane.d.ts +50 -11
- package/dist/tool-plane.js +94 -30
- package/dist/tools.d.ts +5 -1
- package/dist/tools.js +7 -7
- package/dist/trigger-email.js +12 -6
- package/dist/triggers.d.ts +15 -34
- package/dist/triggers.js +119 -126
- package/dist/validate.d.ts +8 -1
- package/dist/validate.js +163 -23
- package/dist/web-fake.d.ts +2 -1
- package/dist/web-fake.js +8 -6
- package/dist/web-fetch.d.ts +8 -6
- package/dist/web-fetch.js +13 -11
- package/dist/web-holds.d.ts +32 -0
- package/dist/web-holds.js +86 -0
- package/dist/web-run.d.ts +32 -5
- package/dist/web-run.js +75 -28
- package/dist/web-save.d.ts +4 -9
- package/dist/web-save.js +27 -55
- package/dist/web-search.js +14 -25
- package/dist/wires.d.ts +4 -3
- package/dist/wires.js +5 -4
- package/dist/workspace/archil-claim.d.ts +12 -5
- package/dist/workspace/archil-claim.js +45 -5
- package/dist/workspace/attach.js +52 -19
- package/dist/workspace/attached-computers.d.ts +38 -11
- package/dist/workspace/attached-computers.js +81 -16
- package/dist/workspace/computer-deps.d.ts +29 -7
- package/dist/workspace/computer-deps.js +36 -18
- package/dist/workspace/computer-for-claim.d.ts +21 -4
- package/dist/workspace/computer-for-claim.js +166 -57
- package/dist/workspace/computer-intervals.d.ts +2 -0
- package/dist/workspace/computer-intervals.js +1 -1
- package/dist/workspace/computer-janitor.d.ts +48 -14
- package/dist/workspace/computer-janitor.js +153 -44
- package/dist/workspace/computer-kept.d.ts +158 -32
- package/dist/workspace/computer-kept.js +288 -63
- package/dist/workspace/computer-providers.d.ts +8 -3
- package/dist/workspace/computer-providers.js +12 -5
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/local.js +41 -1
- package/dist/workspace/mount-revoke-left.d.ts +31 -0
- package/dist/workspace/mount-revoke-left.js +72 -0
- package/dist/workspace/paired-route.d.ts +91 -0
- package/dist/workspace/paired-route.js +152 -0
- package/dist/workspace/resolve-computer.d.ts +5 -2
- package/dist/workspace/resolve-computer.js +9 -3
- package/dist/workspace/run-end-computers.d.ts +11 -5
- package/dist/workspace/run-end-computers.js +153 -28
- package/dist/workspace/run-tools.d.ts +22 -3
- package/dist/workspace/run-tools.js +17 -5
- package/dist/workspace/run-workspace.d.ts +14 -1
- package/dist/workspace/run-workspace.js +34 -1
- package/dist/workspace/workspace.d.ts +6 -0
- package/dist/wrapped.d.ts +8 -2
- package/dist/wrapped.js +21 -6
- package/package.json +12 -13
- package/skills/agentrun-serve/SKILL.md +5 -2
- package/templates/README.md +25 -9
- package/dist/console/assets/backend-DVhHzJX2.js +0 -166
- package/dist/console/assets/index-Bwn1oTem.css +0 -1
- package/dist/console/assets/index-okP-y8PK.js +0 -747
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Settings } from "../store/index.js";
|
|
2
|
+
/** The settings prefix of the left removes. */
|
|
3
|
+
export declare const MOUNT_REVOKE_PREFIX = "archil_revoke:";
|
|
4
|
+
/** The settings key of run `runId`'s left remove. */
|
|
5
|
+
export declare const mountRevokeKeyOf: (runId: string) => string;
|
|
6
|
+
/** A remove left: the claim epoch it reaches up to, the disk its credentials are on, and when it was left (ms, the
|
|
7
|
+
* store's clock), which the janitor reads as a kept row's `until`. */
|
|
8
|
+
export type LeftRevoke = {
|
|
9
|
+
readonly epoch: number;
|
|
10
|
+
readonly disk: string;
|
|
11
|
+
readonly until: number;
|
|
12
|
+
};
|
|
13
|
+
/** A row's value as a LeftRevoke, or undefined for anything else. */
|
|
14
|
+
export declare function leftRevokeOf(value: unknown): LeftRevoke | undefined;
|
|
15
|
+
/** Leaves run `runId`'s remove for the janitor. A row already there for a later or the same epoch is kept: its remove
|
|
16
|
+
* reaches this one's credentials too. One for an earlier epoch is replaced, by compare-and-set. */
|
|
17
|
+
export declare function leaveMountRevoke(settings: Pick<Settings, "get" | "putIfAbsent" | "replaceIf">, runId: string, left: LeftRevoke): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* The janitor's pass over the left removes: each asked of `revoke` (the kept pass's revokeMount, which asks nothing past
|
|
20
|
+
* the row's time plus MOUNT_TTL_MS), bounded by `deleteMs` (KEPT_DELETE_MS) as a kept computer's delete is, its Archil
|
|
21
|
+
* calls cut at the bound by the signal it is handed; and its row removed once that answers, only while it still reads as
|
|
22
|
+
* read (a later claim's left since stays). One that throws or passes its bound is left for the next pass, said in
|
|
23
|
+
* `failed`, and the pass goes on. Never throws.
|
|
24
|
+
*/
|
|
25
|
+
export declare function sweepMountRevokes(deps: {
|
|
26
|
+
readonly settings: Pick<Settings, "all" | "removeIf">;
|
|
27
|
+
readonly revoke: (runId: string, left: LeftRevoke, signal: AbortSignal) => Promise<void>;
|
|
28
|
+
readonly deleteMs?: number;
|
|
29
|
+
}): Promise<{
|
|
30
|
+
readonly failed: readonly string[];
|
|
31
|
+
}>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { bounded, KEPT_DELETE_MS } from "./computer-kept.js";
|
|
2
|
+
/** The settings prefix of the left removes. */
|
|
3
|
+
export const MOUNT_REVOKE_PREFIX = "archil_revoke:";
|
|
4
|
+
/** The settings key of run `runId`'s left remove. */
|
|
5
|
+
export const mountRevokeKeyOf = (runId) => `${MOUNT_REVOKE_PREFIX}${runId}`;
|
|
6
|
+
/** A row's value as a LeftRevoke, or undefined for anything else. */
|
|
7
|
+
export function leftRevokeOf(value) {
|
|
8
|
+
if (!value || typeof value !== "object")
|
|
9
|
+
return undefined;
|
|
10
|
+
const { epoch, disk, until } = value;
|
|
11
|
+
if (typeof epoch !== "number" || !Number.isSafeInteger(epoch) || typeof disk !== "string" || disk === "" || typeof until !== "number" || !Number.isFinite(until))
|
|
12
|
+
return undefined;
|
|
13
|
+
return { epoch, disk, until };
|
|
14
|
+
}
|
|
15
|
+
/** How many times a write reads the row again after losing it to another between its read and its write. */
|
|
16
|
+
const LEAVE_TRIES = 3;
|
|
17
|
+
/** Leaves run `runId`'s remove for the janitor. A row already there for a later or the same epoch is kept: its remove
|
|
18
|
+
* reaches this one's credentials too. One for an earlier epoch is replaced, by compare-and-set. */
|
|
19
|
+
export async function leaveMountRevoke(settings, runId, left) {
|
|
20
|
+
const key = mountRevokeKeyOf(runId);
|
|
21
|
+
const row = { epoch: left.epoch, disk: left.disk, until: left.until };
|
|
22
|
+
for (let tries = 0; tries < LEAVE_TRIES; tries += 1) {
|
|
23
|
+
const was = await settings.get(key);
|
|
24
|
+
if (was === undefined) {
|
|
25
|
+
const kept = leftRevokeOf(await settings.putIfAbsent(key, row));
|
|
26
|
+
if (kept && kept.epoch >= row.epoch)
|
|
27
|
+
return;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const other = leftRevokeOf(was);
|
|
31
|
+
if (other && other.epoch >= row.epoch)
|
|
32
|
+
return;
|
|
33
|
+
if (await settings.replaceIf(key, was, row))
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
throw new Error(`run ${runId}'s Archil mount credential remove could not be left for the janitor: its row kept changing`);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The janitor's pass over the left removes: each asked of `revoke` (the kept pass's revokeMount, which asks nothing past
|
|
40
|
+
* the row's time plus MOUNT_TTL_MS), bounded by `deleteMs` (KEPT_DELETE_MS) as a kept computer's delete is, its Archil
|
|
41
|
+
* calls cut at the bound by the signal it is handed; and its row removed once that answers, only while it still reads as
|
|
42
|
+
* read (a later claim's left since stays). One that throws or passes its bound is left for the next pass, said in
|
|
43
|
+
* `failed`, and the pass goes on. Never throws.
|
|
44
|
+
*/
|
|
45
|
+
export async function sweepMountRevokes(deps) {
|
|
46
|
+
const failed = [];
|
|
47
|
+
let rows;
|
|
48
|
+
try {
|
|
49
|
+
rows = await deps.settings.all({ prefix: MOUNT_REVOKE_PREFIX });
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
return { failed: [`the left Archil mount credential removes could not be read: ${error?.message ?? String(error)}`] };
|
|
53
|
+
}
|
|
54
|
+
for (const row of rows) {
|
|
55
|
+
const runId = row.key.slice(MOUNT_REVOKE_PREFIX.length);
|
|
56
|
+
const cut = new AbortController();
|
|
57
|
+
try {
|
|
58
|
+
const left = leftRevokeOf(row.value);
|
|
59
|
+
if (left)
|
|
60
|
+
await bounded(deps.deleteMs ?? KEPT_DELETE_MS, deps.revoke(runId, left, cut.signal));
|
|
61
|
+
await deps.settings.removeIf(row.key, row.value);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
failed.push(`the Archil mount credential of run ${runId}: ${error?.message ?? String(error)}`);
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
// Its Archil calls cut, where the bound passed first.
|
|
68
|
+
cut.abort(new Error("the janitor's bound on the remove passed"));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return { failed };
|
|
72
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { type Claim, type Runners, type Runs, type Settings } from "../store/index.js";
|
|
2
|
+
/** The settings key prefix of the paired computers' routes, one row per computer. */
|
|
3
|
+
export declare const ROUTE_PREFIX = "paired_route:";
|
|
4
|
+
/** The settings key of computer `id`'s route. */
|
|
5
|
+
export declare const routeKeyOf: (id: string) => string;
|
|
6
|
+
/** How often the server compares each route with where the box's socket is (server.ts, computer-attach.ts tick). */
|
|
7
|
+
export declare const PAIRED_ROUTE_MS = 1000;
|
|
8
|
+
/** How long a run's claim waits for its box to reach its runner: one tick of the server's, the driver's longest wait
|
|
9
|
+
* between dials (it backs off after quick reconnects), the relay's connect and the hub's hello. */
|
|
10
|
+
export declare const PAIRED_BRING_MS: number;
|
|
11
|
+
/** How often the claim reads the route while it waits. */
|
|
12
|
+
export declare const PAIRED_BRING_POLL_MS = 500;
|
|
13
|
+
/** A paired computer's route: the runner whose hub holds the box for `run` (and that runner's incarnation), the hold's
|
|
14
|
+
* end (ms), and the server's note of why a route was refused or dropped. All null: no route, the server's hub. */
|
|
15
|
+
export type Route = {
|
|
16
|
+
readonly runner: string | null;
|
|
17
|
+
readonly incarnation: string | null;
|
|
18
|
+
readonly run: string | null;
|
|
19
|
+
readonly until: number | null;
|
|
20
|
+
readonly refused: string | null;
|
|
21
|
+
};
|
|
22
|
+
/** No route and no note. */
|
|
23
|
+
export declare const EMPTY_ROUTE: Route;
|
|
24
|
+
/** What a run's claim asks: its runner and incarnation, the run, and its hold's end (ms). */
|
|
25
|
+
export type RouteWant = {
|
|
26
|
+
readonly runner: string;
|
|
27
|
+
readonly incarnation: string;
|
|
28
|
+
readonly run: string;
|
|
29
|
+
readonly until: number;
|
|
30
|
+
};
|
|
31
|
+
/** The settings the routes live in. */
|
|
32
|
+
export type RouteSettings = Pick<Settings, "get" | "putIfAbsent" | "replaceIf" | "removeIf" | "remove" | "all">;
|
|
33
|
+
/** What a take reads: the routes, the runners (is the route's runner live), and the runs (is the route's run final). */
|
|
34
|
+
export type RouteDeps = {
|
|
35
|
+
readonly settings: Pick<RouteSettings, "get" | "putIfAbsent" | "replaceIf" | "removeIf">;
|
|
36
|
+
readonly runners: Pick<Runners, "live">;
|
|
37
|
+
readonly runs?: Pick<Runs, "get">;
|
|
38
|
+
};
|
|
39
|
+
/** A row's value as a Route; anything else reads as EMPTY_ROUTE. */
|
|
40
|
+
export declare function routeOf(value: unknown): Route;
|
|
41
|
+
/** Computer `id`'s route as its row reads now: EMPTY_ROUTE when there is none. */
|
|
42
|
+
export declare function readRoute(settings: Pick<RouteSettings, "get">, id: string): Promise<Route>;
|
|
43
|
+
/** Computer `id`'s route and its row's value as read (undefined: no row), for a compare-and-set on it. */
|
|
44
|
+
export declare function seeRoute(settings: Pick<RouteSettings, "get">, id: string): Promise<{
|
|
45
|
+
readonly seen: unknown;
|
|
46
|
+
readonly route: Route;
|
|
47
|
+
}>;
|
|
48
|
+
/** Every route row, as the server's tick reads them: one read of the prefix, a range on the settings' primary key. */
|
|
49
|
+
export declare function allRoutes(settings: Pick<RouteSettings, "all">): Promise<{
|
|
50
|
+
readonly id: string;
|
|
51
|
+
readonly seen: unknown;
|
|
52
|
+
readonly route: Route;
|
|
53
|
+
}[]>;
|
|
54
|
+
/** Writes `next` over computer `id`'s row while it still holds `seen` (as read): one compare-and-set. An empty `next` (no
|
|
55
|
+
* route, no note) removes the row. False when the row changed since. */
|
|
56
|
+
export declare function replaceRoute(settings: Pick<RouteSettings, "putIfAbsent" | "replaceIf" | "removeIf">, id: string, seen: unknown, next: Route, claim?: Claim): Promise<boolean>;
|
|
57
|
+
/** `name` held by another run, on a live runner. */
|
|
58
|
+
export declare const heldWords: (name: string, run: string, runner: string) => string;
|
|
59
|
+
/** How a stale route's words end (the server's 503 and the box's note): where the box goes, and when. */
|
|
60
|
+
export declare const ROUTE_COMES_BACK = "it comes back to this server at its next dial, within 60 s, and the run's next claim takes it again";
|
|
61
|
+
/** What a route says once its runner restarted. The words for a runner gone are the relay's own (computer-attach.ts
|
|
62
|
+
* relayDial), ending in ROUTE_COMES_BACK. */
|
|
63
|
+
export declare const routeRestartedWords: (runner: string) => string;
|
|
64
|
+
/** A box routed to a run's runner, attached nowhere: the claim's wait ends in these words. */
|
|
65
|
+
export declare const notAttachedWords: (name: string) => string;
|
|
66
|
+
/** A box that did not reach its run's runner within PAIRED_BRING_MS. */
|
|
67
|
+
export declare const lateWords: (name: string, runner: string) => string;
|
|
68
|
+
/** What a take came to: the route taken (as written), or why not, with the route as it is. */
|
|
69
|
+
export type Took = {
|
|
70
|
+
readonly taken: true;
|
|
71
|
+
readonly route: Route;
|
|
72
|
+
} | {
|
|
73
|
+
readonly taken: false;
|
|
74
|
+
readonly why: string;
|
|
75
|
+
readonly route: Route;
|
|
76
|
+
};
|
|
77
|
+
/** Routes computer `id` to `want`'s runner for its run, where holdsAgainst lets it: the run's claim, before it waits for
|
|
78
|
+
* the box (dial-relay.ts bring). With `claim`, the write checks the claim's epoch and lease in its transaction, so a
|
|
79
|
+
* claim another runner superseded throws Fenced and writes nothing. `name` is the computer's, for the words. */
|
|
80
|
+
export declare function takeRoute(deps: RouteDeps, id: string, want: RouteWant, { claim, name }?: {
|
|
81
|
+
readonly claim?: Claim;
|
|
82
|
+
readonly name?: string;
|
|
83
|
+
}): Promise<Took>;
|
|
84
|
+
/** Drops computer `id`'s route where it is `mine` (its runner and incarnation, and its run where given): the runner
|
|
85
|
+
* that holds it, once its hold ended. `note` is kept on the row (why the run let it go); none: the row goes. False when
|
|
86
|
+
* the route is not mine (another's, or none). */
|
|
87
|
+
export declare function dropRoute(settings: Pick<RouteSettings, "get" | "putIfAbsent" | "replaceIf" | "removeIf">, id: string, mine: {
|
|
88
|
+
readonly runner: string;
|
|
89
|
+
readonly incarnation: string;
|
|
90
|
+
readonly run?: string;
|
|
91
|
+
}, note?: string): Promise<boolean>;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// Where a paired computer's socket goes on a server whose runner runs in a process of its own (the image's
|
|
2
|
+
// server-and-runner, `agentrun-serve runner`): its route. The box's driver dials the server's one public address, and
|
|
3
|
+
// keeps that one socket. While no run holds the box, the server's own hub takes it; while a run holds it, the server
|
|
4
|
+
// relays the same socket to the attach listener of the runner that holds the run (computer-attach.ts, the relay of
|
|
5
|
+
// dial-relay.ts), where that runner's hub takes it and the run's hold lives. A move is the server closing the socket with
|
|
6
|
+
// 1001 and the box's own redial landing where the route now says; nothing changes on the box.
|
|
7
|
+
//
|
|
8
|
+
// One server setting per paired computer holds it (`paired_route:<computer id>`): the runner, its incarnation, the run,
|
|
9
|
+
// the hold's end (shown, never judged), and a note the server keeps of why a route was refused or dropped. It is written
|
|
10
|
+
// by compare-and-set, as computer_kept:<run id> is (computer-kept.ts), the same calls on SQLite and Postgres: the run's
|
|
11
|
+
// claim takes it (takeRoute, with the claim, so a superseded claim's take is Fenced), the runner that holds it drops it
|
|
12
|
+
// once its hold ended (dropRoute), and the server notes and drops a stale one (replaceRoute). A row exists only while it
|
|
13
|
+
// holds a route or a note, so the server's tick reads only rows that matter (one indexed read of the prefix).
|
|
14
|
+
//
|
|
15
|
+
// The runner beside the server, in its process, takes a route the same way for a box its run holds in the server's own
|
|
16
|
+
// hub (runner/beside.ts, under the name and incarnation Serve.beside gives it): the box stays where it is, and a runner
|
|
17
|
+
// apart's take for another run is refused while that hold lasts.
|
|
18
|
+
//
|
|
19
|
+
// A route is stale only when its runner is not live (runner/presence.ts: no word of it for RUNNER_STALE_MS; a runner
|
|
20
|
+
// beside its server says it is there with no relay) or names another incarnation (that runner restarted since, or the
|
|
21
|
+
// server it ran beside did); or when its run is final, so a runner's release that never dropped its route (its write
|
|
22
|
+
// failed) keeps the box from no other run. A route of another run, on a live runner, refuses the take: one run at a time.
|
|
23
|
+
import { ATTACH_HELLO_MS, ATTACH_REDIAL_MAX_MS } from "@parcha/agentrun-computer";
|
|
24
|
+
import { RELAY_CONNECT_MS } from "../live-reach.js";
|
|
25
|
+
import { FINAL_STATES, RUNNER_STALE_MS } from "../store/index.js";
|
|
26
|
+
/** The settings key prefix of the paired computers' routes, one row per computer. */
|
|
27
|
+
export const ROUTE_PREFIX = "paired_route:";
|
|
28
|
+
/** The settings key of computer `id`'s route. */
|
|
29
|
+
export const routeKeyOf = (id) => `${ROUTE_PREFIX}${id}`;
|
|
30
|
+
/** How often the server compares each route with where the box's socket is (server.ts, computer-attach.ts tick). */
|
|
31
|
+
export const PAIRED_ROUTE_MS = 1_000;
|
|
32
|
+
/** How long a run's claim waits for its box to reach its runner: one tick of the server's, the driver's longest wait
|
|
33
|
+
* between dials (it backs off after quick reconnects), the relay's connect and the hub's hello. */
|
|
34
|
+
export const PAIRED_BRING_MS = PAIRED_ROUTE_MS + ATTACH_REDIAL_MAX_MS + RELAY_CONNECT_MS + ATTACH_HELLO_MS;
|
|
35
|
+
/** How often the claim reads the route while it waits. */
|
|
36
|
+
export const PAIRED_BRING_POLL_MS = 500;
|
|
37
|
+
/** How many times a take or a drop reads the row again after another writer changed it between its read and its write. */
|
|
38
|
+
const ROUTE_TRIES = 5;
|
|
39
|
+
/** No route and no note. */
|
|
40
|
+
export const EMPTY_ROUTE = { runner: null, incarnation: null, run: null, until: null, refused: null };
|
|
41
|
+
const text = (value) => (typeof value === "string" && value !== "" ? value : null);
|
|
42
|
+
/** A row's value as a Route; anything else reads as EMPTY_ROUTE. */
|
|
43
|
+
export function routeOf(value) {
|
|
44
|
+
if (!value || typeof value !== "object")
|
|
45
|
+
return EMPTY_ROUTE;
|
|
46
|
+
const row = value;
|
|
47
|
+
const runner = text(row.runner);
|
|
48
|
+
const incarnation = text(row.incarnation);
|
|
49
|
+
const refused = text(row.refused);
|
|
50
|
+
// A route names its runner, its incarnation and its run together, or none of them.
|
|
51
|
+
const run = text(row.run);
|
|
52
|
+
if (runner === null || incarnation === null || run === null)
|
|
53
|
+
return { ...EMPTY_ROUTE, refused };
|
|
54
|
+
const until = typeof row.until === "number" && Number.isFinite(row.until) ? row.until : null;
|
|
55
|
+
return { runner, incarnation, run, until, refused };
|
|
56
|
+
}
|
|
57
|
+
/** The row as written: its fields in one order, so a compare-and-set reads the same text. */
|
|
58
|
+
const rowOf = (route) => ({ runner: route.runner, incarnation: route.incarnation, run: route.run, until: route.until, refused: route.refused });
|
|
59
|
+
const isEmpty = (route) => route.runner === null && route.refused === null;
|
|
60
|
+
/** Computer `id`'s route as its row reads now: EMPTY_ROUTE when there is none. */
|
|
61
|
+
export async function readRoute(settings, id) {
|
|
62
|
+
return routeOf(await settings.get(routeKeyOf(id)));
|
|
63
|
+
}
|
|
64
|
+
/** Computer `id`'s route and its row's value as read (undefined: no row), for a compare-and-set on it. */
|
|
65
|
+
export async function seeRoute(settings, id) {
|
|
66
|
+
const seen = await settings.get(routeKeyOf(id));
|
|
67
|
+
return { seen, route: routeOf(seen) };
|
|
68
|
+
}
|
|
69
|
+
/** Every route row, as the server's tick reads them: one read of the prefix, a range on the settings' primary key. */
|
|
70
|
+
export async function allRoutes(settings) {
|
|
71
|
+
return (await settings.all({ prefix: ROUTE_PREFIX })).map((row) => ({ id: row.key.slice(ROUTE_PREFIX.length), seen: row.value, route: routeOf(row.value) }));
|
|
72
|
+
}
|
|
73
|
+
/** Writes `next` over computer `id`'s row while it still holds `seen` (as read): one compare-and-set. An empty `next` (no
|
|
74
|
+
* route, no note) removes the row. False when the row changed since. */
|
|
75
|
+
export async function replaceRoute(settings, id, seen, next, claim) {
|
|
76
|
+
const key = routeKeyOf(id);
|
|
77
|
+
if (seen === undefined) {
|
|
78
|
+
if (isEmpty(next))
|
|
79
|
+
return true;
|
|
80
|
+
const there = await settings.putIfAbsent(key, rowOf(EMPTY_ROUTE));
|
|
81
|
+
// Another writer's row landed between the read and this put (a route, or a note): the row changed since, so the
|
|
82
|
+
// caller reads it again and judges it, never writes over it unread. Only the empty placeholder goes on to the
|
|
83
|
+
// compare-and-set.
|
|
84
|
+
if (!isEmpty(routeOf(there)))
|
|
85
|
+
return false;
|
|
86
|
+
return replaceRoute(settings, id, there, next, claim);
|
|
87
|
+
}
|
|
88
|
+
if (isEmpty(next) && claim === undefined)
|
|
89
|
+
return settings.removeIf(key, seen);
|
|
90
|
+
return settings.replaceIf(key, seen, rowOf(next), claim);
|
|
91
|
+
}
|
|
92
|
+
/** `name` held by another run, on a live runner. */
|
|
93
|
+
export const heldWords = (name, run, runner) => `${name} is held by run ${run} on runner ${runner}: one run at a time`;
|
|
94
|
+
/** How a stale route's words end (the server's 503 and the box's note): where the box goes, and when. */
|
|
95
|
+
export const ROUTE_COMES_BACK = `it comes back to this server at its next dial, within ${ATTACH_REDIAL_MAX_MS / 1000} s, and the run's next claim takes it again`;
|
|
96
|
+
/** What a route says once its runner restarted. The words for a runner gone are the relay's own (computer-attach.ts
|
|
97
|
+
* relayDial), ending in ROUTE_COMES_BACK. */
|
|
98
|
+
export const routeRestartedWords = (runner) => `runner ${runner}, which holds it, restarted since, and the hold was its earlier process's: ${ROUTE_COMES_BACK}`;
|
|
99
|
+
/** A box routed to a run's runner, attached nowhere: the claim's wait ends in these words. */
|
|
100
|
+
export const notAttachedWords = (name) => `${name} is not attached now: open its driver on that computer, which dials this server`;
|
|
101
|
+
/** A box that did not reach its run's runner within PAIRED_BRING_MS. */
|
|
102
|
+
export const lateWords = (name, runner) => `${name} did not reach runner ${runner} within ${PAIRED_BRING_MS / 1000} s: its driver waits up to ${ATTACH_REDIAL_MAX_MS / 1000} s between dials after quick reconnects, so the run's next claim may find it there`;
|
|
103
|
+
/** A take or a drop that lost every compare-and-set to another writer. */
|
|
104
|
+
const changedWords = (name) => `${name}'s route changed while this run took it: its next claim tries again`;
|
|
105
|
+
/** Why `route` keeps computer `name` from `want`'s run, or undefined where the run may take it: no route, the run's own
|
|
106
|
+
* (a resume on another runner), a route whose runner is not live or restarted since, or one whose run is final. A
|
|
107
|
+
* live runner is any runner's row seen within RUNNER_STALE_MS, with a relay or without one: the runner beside its
|
|
108
|
+
* server keeps none, and its route holds the same. */
|
|
109
|
+
async function holdsAgainst(deps, route, want, name) {
|
|
110
|
+
if (route.runner === null || route.run === want.run)
|
|
111
|
+
return undefined;
|
|
112
|
+
const at = (await deps.runners.live(RUNNER_STALE_MS)).find((row) => row.runner === route.runner);
|
|
113
|
+
if (at === undefined || at.incarnation !== route.incarnation)
|
|
114
|
+
return undefined;
|
|
115
|
+
// A run that ended, stopped or failed holds nothing: its runner's release dropped the route, or that write failed. It
|
|
116
|
+
// fails closed: a run the store has no row of (purged included), or a read that throws, is not final, so the route
|
|
117
|
+
// stands. One read per refusal, no retry.
|
|
118
|
+
const run = deps.runs === undefined ? undefined : await deps.runs.get(route.run).catch(() => undefined);
|
|
119
|
+
if (run !== undefined && FINAL_STATES.includes(run.state))
|
|
120
|
+
return undefined;
|
|
121
|
+
return heldWords(name, route.run, route.runner);
|
|
122
|
+
}
|
|
123
|
+
/** Routes computer `id` to `want`'s runner for its run, where holdsAgainst lets it: the run's claim, before it waits for
|
|
124
|
+
* the box (dial-relay.ts bring). With `claim`, the write checks the claim's epoch and lease in its transaction, so a
|
|
125
|
+
* claim another runner superseded throws Fenced and writes nothing. `name` is the computer's, for the words. */
|
|
126
|
+
export async function takeRoute(deps, id, want, { claim, name = id } = {}) {
|
|
127
|
+
const mine = rowOf({ runner: want.runner, incarnation: want.incarnation, run: want.run, until: want.until, refused: null });
|
|
128
|
+
let route = EMPTY_ROUTE;
|
|
129
|
+
for (let tried = 0; tried < ROUTE_TRIES; tried++) {
|
|
130
|
+
const read = await seeRoute(deps.settings, id);
|
|
131
|
+
route = read.route;
|
|
132
|
+
const why = await holdsAgainst(deps, route, want, name);
|
|
133
|
+
if (why !== undefined)
|
|
134
|
+
return { taken: false, why, route };
|
|
135
|
+
if (await replaceRoute(deps.settings, id, read.seen, mine, claim))
|
|
136
|
+
return { taken: true, route: mine };
|
|
137
|
+
}
|
|
138
|
+
return { taken: false, why: changedWords(name), route };
|
|
139
|
+
}
|
|
140
|
+
/** Drops computer `id`'s route where it is `mine` (its runner and incarnation, and its run where given): the runner
|
|
141
|
+
* that holds it, once its hold ended. `note` is kept on the row (why the run let it go); none: the row goes. False when
|
|
142
|
+
* the route is not mine (another's, or none). */
|
|
143
|
+
export async function dropRoute(settings, id, mine, note) {
|
|
144
|
+
for (let tried = 0; tried < ROUTE_TRIES; tried++) {
|
|
145
|
+
const { seen, route } = await seeRoute(settings, id);
|
|
146
|
+
if (route.runner !== mine.runner || route.incarnation !== mine.incarnation || (mine.run !== undefined && route.run !== mine.run))
|
|
147
|
+
return false;
|
|
148
|
+
if (await replaceRoute(settings, id, seen, { ...EMPTY_ROUTE, refused: note ?? null }))
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
@@ -261,9 +261,12 @@ export declare function runFolderOf(setting: ComputerSetting, mode: 1 | 2, regis
|
|
|
261
261
|
* runs nothing: "none". The setting is the agent's as saved; where it has none, the caller gives the server's default.
|
|
262
262
|
*/
|
|
263
263
|
export declare function runShellOf(setting: ComputerSetting, mode: 1 | 2, registry: Pick<KindRegistry, "SETTING_KINDS" | "servingRefusals" | "PROVIDERS">): ShellPlace;
|
|
264
|
-
/** What a choice of computer leaves out of the shell, in plain words: shown beside it (GET /v2/computers shell_note)
|
|
265
|
-
*
|
|
264
|
+
/** What a choice of no computer leaves out of the shell, in plain words: shown beside it (GET /v2/computers shell_note).
|
|
265
|
+
* A computer that mounts the folder leaves nothing out; one that doesn't says so in its own words (APART_SHELL_NOTES). */
|
|
266
266
|
export declare const SHELL_NOTES: Readonly<Record<Exclude<ShellPlace, "computer">, string>>;
|
|
267
|
+
/** What a computer that gives the run no shell of its own leaves out (it doesn't mount the run's folder, or runs no
|
|
268
|
+
* programs): a computer all the same, so never "no computer". */
|
|
269
|
+
export declare const APART_SHELL_NOTES: Readonly<Record<Exclude<ShellPlace, "computer">, string>>;
|
|
267
270
|
/** The host tools a run with its shell at `shell` gets, by name: the kernel registry's own list (hostToolDefs), never a
|
|
268
271
|
* second one: the file tools always, bash with a shell, the five background tools on a computer. */
|
|
269
272
|
export declare const hostToolsOf: (shell: ShellPlace) => string[];
|
|
@@ -224,12 +224,18 @@ export function runShellOf(setting, mode, registry) {
|
|
|
224
224
|
return "none";
|
|
225
225
|
return shellPlaceOf(mounts, mode);
|
|
226
226
|
}
|
|
227
|
-
/** What a choice of computer leaves out of the shell, in plain words: shown beside it (GET /v2/computers shell_note)
|
|
228
|
-
*
|
|
227
|
+
/** What a choice of no computer leaves out of the shell, in plain words: shown beside it (GET /v2/computers shell_note).
|
|
228
|
+
* A computer that mounts the folder leaves nothing out; one that doesn't says so in its own words (APART_SHELL_NOTES). */
|
|
229
229
|
export const SHELL_NOTES = Object.freeze({
|
|
230
230
|
local: "No computer: bash runs in a fresh container on the folder's own storage; background commands need a computer.",
|
|
231
231
|
none: "No computer on this server: the agent gets the file tools only, no shell. Pick a computer to run commands.",
|
|
232
232
|
});
|
|
233
|
+
/** What a computer that gives the run no shell of its own leaves out (it doesn't mount the run's folder, or runs no
|
|
234
|
+
* programs): a computer all the same, so never "no computer". */
|
|
235
|
+
export const APART_SHELL_NOTES = Object.freeze({
|
|
236
|
+
local: "This computer doesn't mount the run's folder: bash runs in a fresh container on the folder's own storage; background commands need a computer that mounts it.",
|
|
237
|
+
none: "This computer gives the run no shell: the agent gets the file tools only. Pick a computer that mounts the run's folder to run commands.",
|
|
238
|
+
});
|
|
233
239
|
/** The host tools a run with its shell at `shell` gets, by name: the kernel registry's own list (hostToolDefs), never a
|
|
234
240
|
* second one: the file tools always, bash with a shell, the five background tools on a computer. */
|
|
235
241
|
export const hostToolsOf = (shell) => hostToolDefs({ maxExecS: 600, shell }).map((def) => def.name);
|
|
@@ -237,7 +243,7 @@ export const hostToolsOf = (shell) => hostToolDefs({ maxExecS: 600, shell }).map
|
|
|
237
243
|
* gives, and what it leaves out, in words (none for a computer that mounts the folder). */
|
|
238
244
|
export function shellChoiceOf(setting, mode, registry) {
|
|
239
245
|
const shell = runShellOf(setting, mode, registry);
|
|
240
|
-
return { shell, host_tools: hostToolsOf(shell), ...(shell === "computer" ? {} : { shell_note: SHELL_NOTES[shell] }) };
|
|
246
|
+
return { shell, host_tools: hostToolsOf(shell), ...(shell === "computer" ? {} : { shell_note: (setting.kind === "none" ? SHELL_NOTES : APART_SHELL_NOTES)[shell] }) };
|
|
241
247
|
}
|
|
242
248
|
/** The server's default where an agent has no computer setting: in Mode 1 a sandbox on the first provider that binds a
|
|
243
249
|
* folder of this machine and answers here (Docker), else none; in Mode 2 none. */
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Store } from "../store/index.js";
|
|
2
2
|
import type { ComputerDeps } from "./computer-deps.js";
|
|
3
|
-
import { type KeptHolder } from "./computer-kept.js";
|
|
4
3
|
/** The longest a run's end may spend on its computers, every try with its pauses: past it the provider's calls are cut
|
|
5
4
|
* (one that takes no signal, a release, left to finish on its own) and the run's end goes on, said in the log. */
|
|
6
5
|
export declare const RUN_END_COMPUTERS_MS = 120000;
|
|
@@ -9,18 +8,25 @@ export declare const RUN_END_RETRY_MS = 5000;
|
|
|
9
8
|
export interface RunEndComputersDeps {
|
|
10
9
|
/** The run's row and launch (its revision and place) and the agent's revision, where its computer setting is; the
|
|
11
10
|
* computer ledger, for a provider that keeps one. */
|
|
12
|
-
readonly store: Pick<Store, "agents" | "computerLedger" | "settings"> & {
|
|
11
|
+
readonly store: Pick<Store, "agents" | "computerLedger" | "settings" | "sealedKeys"> & {
|
|
13
12
|
readonly runs: Pick<Store["runs"], "get" | "launch">;
|
|
14
13
|
readonly computerIntervals?: Store["computerIntervals"];
|
|
15
14
|
};
|
|
15
|
+
/** The runs' environment and the server's seal key, as the janitor is handed them: with them, a machine kept on Archil
|
|
16
|
+
* that this end deletes has its park's mount credential removed (computer-janitor.ts keptMountRevoke) before its row
|
|
17
|
+
* is marked ended. Absent `env`: that row is left ending, for the janitor's kept pass. */
|
|
18
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
19
|
+
readonly sealKey?: Buffer | undefined;
|
|
20
|
+
/** Archil's control plane for that remove: a test's fake. Absent: the region's own. */
|
|
21
|
+
readonly mountControl?: {
|
|
22
|
+
readonly baseUrl?: string;
|
|
23
|
+
readonly fetch?: typeof fetch;
|
|
24
|
+
};
|
|
16
25
|
/** The run's computers as the runner composed them (computer-deps.ts computerDepsFrom): the registry, the provider
|
|
17
26
|
* makers, the key reader, and --faux's launch with the providers it takes. */
|
|
18
27
|
readonly computers: Pick<ComputerDeps, "kinds" | "providers" | "keyOf" | "keyTable" | "settings" | "launch" | "launches">;
|
|
19
28
|
/** Where what was let go, and a provider that failed, are said. */
|
|
20
29
|
readonly log: (line: string) => void;
|
|
21
|
-
/** The runner this end runs in (its name and presence incarnation), read at each end: a computer kept pinned to it is
|
|
22
|
-
* its own to let go here. Absent: every kept row that names a runner is another's. */
|
|
23
|
-
readonly self?: () => KeptHolder | undefined;
|
|
24
30
|
/** The bound on every try. Default RUN_END_COMPUTERS_MS. */
|
|
25
31
|
readonly timeoutMs?: number;
|
|
26
32
|
/** The pause between tries. Default RUN_END_RETRY_MS. */
|