@parcha/agentrun-serve 0.1.0-beta.35 → 0.1.0-beta.36
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 +128 -0
- package/README.md +260 -168
- package/dist/adapters.d.ts +12 -2
- package/dist/adapters.js +27 -2
- package/dist/agent-rows.d.ts +2 -1
- package/dist/agents-store.d.ts +2 -0
- package/dist/agents-store.js +9 -4
- package/dist/api-only.d.ts +2 -1
- package/dist/api-only.js +3 -1
- package/dist/archil-routes.d.ts +40 -7
- package/dist/archil-routes.js +167 -54
- package/dist/archil-settings.d.ts +79 -7
- package/dist/archil-settings.js +140 -14
- package/dist/attach-images.d.ts +15 -0
- package/dist/attach-images.js +59 -0
- package/dist/background.d.ts +0 -6
- package/dist/background.js +0 -28
- package/dist/box-image.d.ts +1 -97
- package/dist/box-image.js +4 -284
- package/dist/box-paths.d.ts +2 -7
- package/dist/box-paths.js +7 -13
- package/dist/box-settings.d.ts +0 -11
- package/dist/box-settings.js +4 -29
- package/dist/browser-commands.js +1 -1
- package/dist/browser-computer.d.ts +47 -3
- package/dist/browser-computer.js +286 -18
- package/dist/browser-person.d.ts +19 -2
- package/dist/browser-person.js +55 -6
- package/dist/browser-wait-ended.d.ts +23 -0
- package/dist/browser-wait-ended.js +42 -0
- package/dist/cap.d.ts +13 -41
- package/dist/cap.js +24 -73
- package/dist/cli.js +4 -22
- package/dist/computer-routes.d.ts +1 -4
- package/dist/computer-routes.js +3 -5
- package/dist/computer-setting.d.ts +2 -0
- package/dist/computer-setting.js +38 -1
- package/dist/computer-view.d.ts +11 -2
- package/dist/computer-view.js +2 -1
- package/dist/computers.d.ts +48 -7
- package/dist/computers.js +100 -23
- package/dist/console/assets/index-BI4Byidu.js +550 -0
- package/dist/console/assets/index-C19gUF2n.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/docker-daemon.d.ts +2 -2
- package/dist/docker-daemon.js +2 -2
- package/dist/errors.js +5 -5
- package/dist/faux-computers.js +4 -0
- package/dist/files.d.ts +1 -9
- package/dist/files.js +1 -9
- package/dist/github.d.ts +22 -2
- package/dist/github.js +42 -8
- package/dist/gpu-words.d.ts +14 -0
- package/dist/gpu-words.js +21 -0
- package/dist/graph-view.d.ts +2 -0
- package/dist/graph-view.js +25 -1
- package/dist/handed-values.d.ts +1 -1
- package/dist/handed-values.js +1 -1
- package/dist/harness-install.d.ts +60 -3
- package/dist/harness-install.js +322 -34
- package/dist/harness.js +1 -1
- package/dist/host-tools.d.ts +8 -9
- package/dist/host-tools.js +7 -7
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -2
- package/dist/key-refusal.d.ts +1 -1
- package/dist/key-refusal.js +2 -2
- package/dist/learn/check.d.ts +7 -1
- package/dist/learn/check.js +123 -5
- package/dist/learn/commit.d.ts +40 -6
- package/dist/learn/commit.js +164 -20
- package/dist/learn/folder.d.ts +5 -0
- package/dist/learn/folder.js +33 -0
- package/dist/learn/grade.d.ts +18 -1
- package/dist/learn/grade.js +86 -16
- package/dist/learn/index.d.ts +1 -1
- package/dist/learn/index.js +1 -1
- package/dist/learn/learning.sh +12 -1
- package/dist/learn/notes.d.ts +3 -0
- package/dist/learn/notes.js +3 -0
- package/dist/learn/reflect.d.ts +5 -2
- package/dist/learn/reflect.js +43 -29
- package/dist/learn/skills.d.ts +4 -0
- package/dist/learn/skills.js +7 -0
- package/dist/learned-nodes.d.ts +6 -2
- package/dist/learned-workflow.d.ts +19 -9
- package/dist/learned-workflow.js +62 -34
- package/dist/learning-cost.d.ts +79 -0
- package/dist/learning-cost.js +69 -0
- package/dist/learning-routes.d.ts +8 -3
- package/dist/learning-routes.js +9 -6
- package/dist/learning-words.d.ts +3 -0
- package/dist/learning-words.js +6 -2
- package/dist/learning.d.ts +13 -6
- package/dist/learning.js +4 -2
- package/dist/mcp-probe.d.ts +8 -1
- package/dist/mcp-probe.js +62 -20
- package/dist/mcp-secret-writes.js +4 -0
- package/dist/mcp-servers-store.js +8 -3
- package/dist/model.d.ts +5 -5
- package/dist/model.js +6 -6
- package/dist/openapi.d.ts +2 -0
- package/dist/openapi.js +204 -47
- package/dist/owner.d.ts +0 -1
- package/dist/owner.js +0 -2
- package/dist/paid-calls.js +1 -1
- package/dist/place-offers.d.ts +97 -0
- package/dist/place-offers.js +206 -0
- package/dist/place.d.ts +9 -13
- package/dist/place.js +22 -32
- package/dist/port-models.d.ts +2 -1
- package/dist/port-models.js +5 -3
- package/dist/print.d.ts +1 -8
- package/dist/print.js +1 -14
- package/dist/propose.d.ts +1 -0
- package/dist/propose.js +25 -10
- package/dist/run-cut.d.ts +5 -0
- package/dist/run-cut.js +19 -0
- package/dist/run-db.js +3 -3
- package/dist/run-launch.d.ts +14 -1
- package/dist/run-launch.js +7 -2
- package/dist/run-learning-served.d.ts +1 -1
- package/dist/run-manifest.d.ts +2 -2
- package/dist/run-manifest.js +2 -2
- package/dist/run-secrets.js +3 -3
- package/dist/run-timeline-served.js +56 -44
- package/dist/run-view.d.ts +5 -2
- package/dist/run-view.js +4 -3
- package/dist/runnable.d.ts +2 -2
- package/dist/runnable.js +6 -2
- package/dist/runner/adapter-loop.d.ts +16 -1
- package/dist/runner/adapter-loop.js +131 -30
- package/dist/runner/adapter-run-spec.d.ts +25 -4
- package/dist/runner/adapter-run-spec.js +103 -24
- package/dist/runner/adapters/pi.d.ts +11 -3
- package/dist/runner/adapters/pi.js +35 -12
- package/dist/runner/beside.js +6 -2
- package/dist/runner/cli-run-spec.d.ts +7 -0
- package/dist/runner/cli-run-spec.js +92 -38
- package/dist/runner/commands.d.ts +5 -1
- package/dist/runner/commands.js +3 -3
- package/dist/runner/conformance/harness.d.ts +0 -1
- package/dist/runner/conformance/harness.js +8 -5
- package/dist/runner/github-app.js +2 -2
- package/dist/runner/harness-loops.js +1 -1
- package/dist/runner/journal-kinds.d.ts +15 -5
- package/dist/runner/journal-kinds.js +6 -1
- package/dist/runner/learning-end.d.ts +15 -0
- package/dist/runner/learning-end.js +26 -5
- package/dist/runner/learning-factory.js +6 -2
- package/dist/runner/learning-loop.d.ts +73 -1
- package/dist/runner/learning-loop.js +203 -18
- package/dist/runner/learning-seed.d.ts +2 -0
- package/dist/runner/learning-seed.js +1 -1
- package/dist/runner/loop-contract.d.ts +8 -0
- package/dist/runner/loop-contract.js +6 -0
- package/dist/runner/loop.d.ts +5 -1
- package/dist/runner/loop.js +20 -0
- package/dist/runner/main.js +12 -2
- package/dist/runner/mcp-claim.d.ts +4 -0
- package/dist/runner/mcp-claim.js +29 -1
- package/dist/runner/mcp-github.d.ts +4 -2
- package/dist/runner/mcp-github.js +0 -7
- package/dist/runner/mcp-run.d.ts +2 -0
- package/dist/runner/mcp-run.js +1 -0
- package/dist/runner/metrics.d.ts +4 -0
- package/dist/runner/metrics.js +9 -0
- package/dist/runner/model-route.d.ts +3 -0
- package/dist/runner/model-route.js +5 -2
- package/dist/runner/pr-checkout.d.ts +59 -0
- package/dist/runner/pr-checkout.js +176 -0
- package/dist/runner/reflect-hook.d.ts +1 -0
- package/dist/runner/reflect-hook.js +3 -3
- package/dist/runner/runner.js +47 -12
- package/dist/runner/spec-holds.d.ts +8 -3
- package/dist/runner/spec-holds.js +12 -10
- package/dist/runner/store-port.d.ts +4 -1
- package/dist/runner/store-secrets.js +17 -1
- package/dist/runner/subagent.d.ts +44 -0
- package/dist/runner/subagent.js +188 -0
- package/dist/runner/workflow-host.d.ts +18 -2
- package/dist/runner/workflow-host.js +23 -3
- package/dist/runner/workflow-loop.d.ts +5 -2
- package/dist/runner/workflow-loop.js +9 -8
- package/dist/runner/workflow-spec.d.ts +26 -14
- package/dist/runner/workflow-spec.js +97 -30
- package/dist/runs-over-store.d.ts +11 -6
- package/dist/runs-over-store.js +111 -24
- package/dist/sealing.js +1 -2
- package/dist/secret-cut.d.ts +1 -1
- package/dist/secret-cut.js +1 -1
- package/dist/server.d.ts +32 -49
- package/dist/server.js +249 -199
- package/dist/store/agent-body.d.ts +9 -2
- package/dist/store/agent-body.js +16 -8
- package/dist/store/deadline.js +9 -5
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +2 -2
- package/dist/store/journal/storage.js +2 -1
- package/dist/store/postgres/connection.js +9 -4
- package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
- package/dist/store/schema.d.ts +2 -1
- package/dist/store/schema.js +11 -8
- package/dist/store/seal.d.ts +13 -0
- package/dist/store/seal.js +19 -0
- package/dist/store/sqlite/connection.d.ts +5 -0
- package/dist/store/sqlite/connection.js +88 -47
- package/dist/store/sqlite/run-patch.d.ts +18 -2
- package/dist/store/sqlite/run-patch.js +31 -2
- package/dist/store/sqlite/store.js +65 -11
- package/dist/store/store.d.ts +62 -12
- package/dist/store/store.js +22 -1
- package/dist/store-reads/analytics.js +3 -2
- package/dist/store-reads/cap.d.ts +1 -3
- package/dist/store-reads/cap.js +8 -6
- package/dist/store-reads/decisions.d.ts +2 -2
- package/dist/store-reads/decisions.js +3 -6
- package/dist/store-reads/journal.js +45 -12
- package/dist/store-reads/learning.d.ts +15 -1
- package/dist/store-reads/learning.js +68 -10
- package/dist/store-reads/runs.d.ts +6 -4
- package/dist/store-reads/runs.js +17 -10
- package/dist/store-reads/stats.js +5 -1
- package/dist/store-view.js +45 -19
- package/dist/template-eval.js +2 -1
- package/dist/templates.d.ts +64 -0
- package/dist/templates.js +101 -16
- package/dist/timeline/timeline.d.ts +3 -1
- package/dist/timeline/timeline.js +19 -4
- package/dist/tool-blurbs.js +1 -0
- package/dist/tool-budget.d.ts +8 -0
- package/dist/tool-budget.js +7 -1
- package/dist/tool-gate.d.ts +7 -1
- package/dist/tool-gate.js +7 -2
- package/dist/tool-plane.d.ts +33 -19
- package/dist/tool-plane.js +64 -27
- package/dist/tools.d.ts +18 -34
- package/dist/tools.js +104 -70
- package/dist/trigger-signatures.d.ts +1 -0
- package/dist/trigger-signatures.js +3 -1
- package/dist/triggers.d.ts +3 -3
- package/dist/triggers.js +2 -2
- package/dist/turn-end.d.ts +0 -3
- package/dist/turn-end.js +0 -3
- package/dist/usage-lines.d.ts +1 -1
- package/dist/validate.d.ts +6 -0
- package/dist/validate.js +30 -3
- package/dist/webhooks.d.ts +2 -1
- package/dist/webhooks.js +5 -2
- package/dist/workflow/decision-recovery.d.ts +23 -0
- package/dist/workflow/decision-recovery.js +80 -0
- package/dist/workflow/decisions.d.ts +134 -0
- package/dist/workflow/decisions.js +46 -0
- package/dist/workflow/host-session.d.ts +5 -0
- package/dist/workflow/host-session.js +85 -0
- package/dist/workflow/host-tools.d.ts +3 -0
- package/dist/workflow/host-tools.js +3 -0
- package/dist/workflow/node-runner.d.ts +112 -0
- package/dist/workflow/node-runner.js +270 -0
- package/dist/workflow/node.d.ts +88 -0
- package/dist/workflow/node.js +99 -0
- package/dist/workflow/operator-error.d.ts +4 -0
- package/dist/workflow/operator-error.js +4 -0
- package/dist/workflow/pi-versions.d.ts +9 -0
- package/dist/workflow/pi-versions.js +8 -0
- package/dist/workflow/readers.d.ts +36 -0
- package/dist/workflow/readers.js +145 -0
- package/dist/workflow/record-file.d.ts +10 -0
- package/dist/workflow/record-file.js +56 -0
- package/dist/workflow/record-tool.d.ts +76 -0
- package/dist/workflow/record-tool.js +126 -0
- package/dist/workflow/record.d.ts +151 -0
- package/dist/workflow/record.js +401 -0
- package/dist/workflow/run-error.d.ts +16 -0
- package/dist/workflow/run-error.js +26 -0
- package/dist/workflow/runner.d.ts +6 -0
- package/dist/workflow/runner.js +240 -0
- package/dist/workflow/store.d.ts +23 -0
- package/dist/workflow/store.js +242 -0
- package/dist/workflow/task.d.ts +133 -0
- package/dist/workflow/task.js +411 -0
- package/dist/workflow/thinking.d.ts +3 -0
- package/dist/workflow/thinking.js +7 -0
- package/dist/workflow/tool-context.d.ts +21 -0
- package/dist/workflow/tool-context.js +13 -0
- package/dist/workflow/types.d.ts +126 -0
- package/dist/workflow/types.js +1 -0
- package/dist/workflow/wal.d.ts +11 -0
- package/dist/workflow/wal.js +106 -0
- package/dist/workflow-run.d.ts +1 -1
- package/dist/workspace/agent-computer.d.ts +137 -0
- package/dist/workspace/agent-computer.js +292 -0
- package/dist/workspace/archil-claim.d.ts +11 -0
- package/dist/workspace/archil-claim.js +18 -10
- package/dist/workspace/archil-disks.d.ts +49 -0
- package/dist/workspace/archil-disks.js +185 -0
- package/dist/workspace/archil-exec.js +2 -3
- package/dist/workspace/archil-mount-credential.d.ts +20 -4
- package/dist/workspace/archil-mount-credential.js +13 -4
- package/dist/workspace/computer-deps.d.ts +16 -8
- package/dist/workspace/computer-deps.js +18 -7
- package/dist/workspace/computer-for-claim.d.ts +42 -6
- package/dist/workspace/computer-for-claim.js +209 -9
- package/dist/workspace/computer-janitor.d.ts +3 -2
- package/dist/workspace/computer-janitor.js +43 -9
- package/dist/workspace/computer-ledger.d.ts +3 -1
- package/dist/workspace/computer-ledger.js +7 -0
- package/dist/workspace/index.d.ts +3 -2
- package/dist/workspace/index.js +1 -0
- package/dist/workspace/resolve-computer.d.ts +42 -11
- package/dist/workspace/resolve-computer.js +65 -13
- package/dist/workspace/run-disk.d.ts +34 -0
- package/dist/workspace/run-disk.js +91 -0
- package/dist/workspace/run-tools.d.ts +4 -4
- package/dist/workspace/run-tools.js +8 -6
- package/dist/workspace/server-run-workspace.d.ts +3 -2
- package/dist/workspace/server-run-workspace.js +17 -4
- package/dist/workspace.js +1 -1
- package/package.json +10 -15
- package/templates/README.md +9 -6
- package/templates/code-review/agent.md +27 -11
- package/templates/code-review/evals/clean-refactor/graders/coverage.md +4 -0
- package/templates/code-review/evals/clean-refactor/graders/risk.md +5 -0
- package/templates/code-review/evals/injection/graders/ignores.md +1 -1
- package/templates/code-review/evals/never-flag/case.yaml +3 -0
- package/templates/code-review/evals/never-flag/graders/only-p0.md +4 -0
- package/templates/code-review/evals/never-flag/graders/schema.md +5 -0
- package/templates/code-review/evals/never-flag/prompt.md +30 -0
- package/templates/code-review/evals/null-name/graders/finds.md +1 -1
- package/templates/code-review/evals/off-by-one/graders/finds.md +1 -1
- package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +6 -5
- package/templates/code-review/evals/re-review/graders/resolves.md +1 -1
- package/templates/code-review/evals/re-review/prompt.md +1 -1
- package/templates/code-review/evals/re-review-open/case.yaml +3 -0
- package/templates/code-review/evals/re-review-open/graders/schema.md +5 -0
- package/templates/code-review/evals/re-review-open/graders/stays-open.md +4 -0
- package/templates/code-review/evals/re-review-open/prompt.md +27 -0
- package/templates/code-review/evals/repo-rule/graders/cites.md +1 -1
- package/templates/code-review/evals/two-defects/case.yaml +3 -0
- package/templates/code-review/evals/two-defects/graders/both.md +4 -0
- package/templates/code-review/evals/two-defects/graders/schema.md +5 -0
- package/templates/code-review/evals/two-defects/prompt.md +25 -0
- package/templates/code-review/findings.schema.json +131 -27
- package/templates/code-review/rules/CODEREVIEW.md +76 -0
- package/templates/code-review/skills/review/DEEP.md +130 -0
- package/templates/code-review/skills/review/REVIEWER.md +116 -0
- package/templates/code-review/skills/review/SKILL.md +104 -154
- package/dist/box/record.d.ts +0 -6
- package/dist/box/record.js +0 -41
- package/dist/box/sweep.d.ts +0 -53
- package/dist/box/sweep.js +0 -193
- package/dist/box-egress-vm.d.ts +0 -118
- package/dist/box-egress-vm.js +0 -354
- package/dist/box-egress.d.ts +0 -105
- package/dist/box-egress.js +0 -256
- package/dist/box-relay-vm.d.ts +0 -84
- package/dist/box-relay-vm.js +0 -437
- package/dist/box-relay.d.ts +0 -36
- package/dist/box-relay.js +0 -207
- package/dist/boxes.d.ts +0 -109
- package/dist/boxes.js +0 -249
- package/dist/budget.d.ts +0 -71
- package/dist/budget.js +0 -199
- package/dist/console/assets/index-B7NKTU8E.css +0 -1
- package/dist/console/assets/index-CXZMgJE7.js +0 -550
- package/dist/daytona-api.d.ts +0 -10
- package/dist/daytona-api.js +0 -20
- package/dist/egress-proxy.d.ts +0 -45
- package/dist/egress-proxy.js +0 -416
- package/dist/egress-table.d.ts +0 -24
- package/dist/egress-table.js +0 -165
- package/templates/code-review/rules/REVIEW.md +0 -41
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type ArchilControlOptions } from "./archil-mount-credential.js";
|
|
2
|
+
/** A call to Archil's disks refused or not answered, in words with no secret in them. */
|
|
3
|
+
export declare class ArchilDiskError extends Error {
|
|
4
|
+
name: string;
|
|
5
|
+
readonly status: number | undefined;
|
|
6
|
+
readonly code: string | undefined;
|
|
7
|
+
constructor(message: string, status?: number, code?: string);
|
|
8
|
+
}
|
|
9
|
+
/** The plan's disk limit reached: `limit` when Archil's words say how many disks it allows. */
|
|
10
|
+
export declare class ArchilDiskLimit extends ArchilDiskError {
|
|
11
|
+
name: string;
|
|
12
|
+
readonly limit: number | undefined;
|
|
13
|
+
constructor(message: string, limit: number | undefined);
|
|
14
|
+
}
|
|
15
|
+
/** A disk as Archil reads it back. */
|
|
16
|
+
export interface ArchilDiskInfo {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly region: string;
|
|
20
|
+
readonly status: string;
|
|
21
|
+
}
|
|
22
|
+
type Context = {
|
|
23
|
+
readonly signal?: AbortSignal;
|
|
24
|
+
};
|
|
25
|
+
/** Disk `id` as Archil reads it, or undefined when the account has none of that id (404). */
|
|
26
|
+
export declare function getDisk(options: ArchilControlOptions, id: string, context?: Context): Promise<ArchilDiskInfo | undefined>;
|
|
27
|
+
/** The account's disk named `name`, or undefined when there is none. */
|
|
28
|
+
export declare function diskNamed(options: ArchilControlOptions, name: string, context?: Context): Promise<ArchilDiskInfo | undefined>;
|
|
29
|
+
/** How many disks a plan allows, when Archil's words for its refusal say. */
|
|
30
|
+
export declare function limitOf(words: string): number | undefined;
|
|
31
|
+
/** Makes the disk `name` (Archil-managed storage, the control plane's region), or finds it when it is there already: its
|
|
32
|
+
* id, and whether this call made it. A disk this call made has its default token user removed before it is answered; a
|
|
33
|
+
* disk found there already has every token user that is not a run's removed (an earlier call's default token, when its
|
|
34
|
+
* removal failed). The plan's limit is an ArchilDiskLimit. */
|
|
35
|
+
export declare function ensureDisk(options: ArchilControlOptions, name: string, context?: Context): Promise<{
|
|
36
|
+
readonly id: string;
|
|
37
|
+
readonly made: boolean;
|
|
38
|
+
}>;
|
|
39
|
+
/** Waits until disk `id` reads `available` (a disk just made reads `creating` for a while), up to `timeoutMs`. */
|
|
40
|
+
export declare function availableDisk(options: ArchilControlOptions, id: string, { timeoutMs, everyMs, signal }?: {
|
|
41
|
+
timeoutMs?: number;
|
|
42
|
+
everyMs?: number;
|
|
43
|
+
signal?: AbortSignal;
|
|
44
|
+
}): Promise<ArchilDiskInfo>;
|
|
45
|
+
/** Removes disk `id` and everything on it. Idempotent: one already gone (404) is removed. */
|
|
46
|
+
export declare function deleteDisk(options: ArchilControlOptions, id: string, context?: Context): Promise<void>;
|
|
47
|
+
/** One page of the account's disks, at most one: what the Archil settings' test reads to know the key works. */
|
|
48
|
+
export declare function listOneDisk(options: ArchilControlOptions, context?: Context): Promise<number>;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// The account's disks at Archil's control plane: what makes each agent's own disk, reads a disk a launch names, and
|
|
2
|
+
// removes an agent's own disk. With the account API key as `Authorization: Bearer <key>`, on the region's control plane
|
|
3
|
+
// (archil-mount-credential.ts controlOf), as Archil's API (`@archildata/api-types` 0.0.81) has them:
|
|
4
|
+
// - create: POST {control}/api/disks {"name"}: Archil-managed storage (no mounts), in the control plane's region. 201
|
|
5
|
+
// made it; 200 when a disk of that name is there already with this configuration (idempotent); 409 when one
|
|
6
|
+
// of that name is there with another, which is found by listing that name; 403 `disk_limit_reached` when the
|
|
7
|
+
// plan's per-region disk limit is reached (`organization_plan_required`: a free organization makes none). A
|
|
8
|
+
// made disk comes with a default token user, which is removed at once: no standing token is kept anywhere. A
|
|
9
|
+
// disk found there already (200, 409) loses every token user that is not a run's, so a default token whose
|
|
10
|
+
// removal failed on an earlier try is removed on the next.
|
|
11
|
+
// - read: GET {control}/api/disks/{id}: its name, region and status; 404 when the account has none of that id.
|
|
12
|
+
// - list: GET {control}/api/disks?name=<name>: the disks of that exact name.
|
|
13
|
+
// - remove: DELETE {control}/api/disks/{id}: the disk and everything on it. Idempotent: a 404 is already gone.
|
|
14
|
+
// Neither the key nor a token is ever in an error: an error carries the status and Archil's own words, scrubbed.
|
|
15
|
+
import { controlOf, errorOf, isRunNickname, listTokenUsers, scrub } from "./archil-mount-credential.js";
|
|
16
|
+
/** A call to Archil's disks refused or not answered, in words with no secret in them. */
|
|
17
|
+
export class ArchilDiskError extends Error {
|
|
18
|
+
name = "ArchilDiskError";
|
|
19
|
+
status;
|
|
20
|
+
code;
|
|
21
|
+
constructor(message, status, code) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.status = status;
|
|
24
|
+
this.code = code;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** The plan's disk limit reached: `limit` when Archil's words say how many disks it allows. */
|
|
28
|
+
export class ArchilDiskLimit extends ArchilDiskError {
|
|
29
|
+
name = "ArchilDiskLimit";
|
|
30
|
+
limit;
|
|
31
|
+
constructor(message, limit) {
|
|
32
|
+
super(message, 403, "disk_limit_reached");
|
|
33
|
+
this.limit = limit;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** One call to the control plane: its answer, or an ArchilDiskError naming `what` when it could not be reached. */
|
|
37
|
+
async function call(options, method, path, what, context, body) {
|
|
38
|
+
const key = await options.key();
|
|
39
|
+
try {
|
|
40
|
+
const response = await (options.fetch ?? fetch)(`${controlOf(options)}${path}`, {
|
|
41
|
+
method,
|
|
42
|
+
headers: { Authorization: `Bearer ${key}`, ...(body !== undefined ? { "Content-Type": "application/json" } : {}) },
|
|
43
|
+
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
|
|
44
|
+
redirect: "error",
|
|
45
|
+
...(context.signal ? { signal: context.signal } : {}),
|
|
46
|
+
});
|
|
47
|
+
return { response, key };
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
throw new ArchilDiskError(`Archil's control plane could not be reached to ${what}: ${scrub(error instanceof Error ? error.message : String(error), [key])}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** A refusal as an ArchilDiskError, Archil's words and code in it. */
|
|
54
|
+
async function refused(response, key, what) {
|
|
55
|
+
const { words, code } = await errorOf(response, [key]);
|
|
56
|
+
return new ArchilDiskError(`Archil refused to ${what} (${response.status}): ${words}`, response.status, code);
|
|
57
|
+
}
|
|
58
|
+
const infoOf = (value) => {
|
|
59
|
+
const disk = value;
|
|
60
|
+
return typeof disk?.id === "string" ? { id: disk.id, name: typeof disk.name === "string" ? disk.name : "", region: typeof disk.region === "string" ? disk.region : "", status: typeof disk.status === "string" ? disk.status : "" } : undefined;
|
|
61
|
+
};
|
|
62
|
+
/** Disk `id` as Archil reads it, or undefined when the account has none of that id (404). */
|
|
63
|
+
export async function getDisk(options, id, context = {}) {
|
|
64
|
+
const { response, key } = await call(options, "GET", `/api/disks/${encodeURIComponent(id)}`, `read the disk ${id}`, context);
|
|
65
|
+
if (response.status === 404) {
|
|
66
|
+
await response.body?.cancel().catch(() => undefined);
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
if (!response.ok)
|
|
70
|
+
throw await refused(response, key, `read the disk ${id}`);
|
|
71
|
+
const disk = infoOf((await response.json().catch(() => undefined))?.data);
|
|
72
|
+
if (disk === undefined)
|
|
73
|
+
throw new ArchilDiskError(`Archil answered the read of the disk ${id} with no disk`);
|
|
74
|
+
return disk;
|
|
75
|
+
}
|
|
76
|
+
/** The account's disk named `name`, or undefined when there is none. */
|
|
77
|
+
export async function diskNamed(options, name, context = {}) {
|
|
78
|
+
const { response, key } = await call(options, "GET", `/api/disks?name=${encodeURIComponent(name)}`, `find the disk ${name}`, context);
|
|
79
|
+
if (!response.ok)
|
|
80
|
+
throw await refused(response, key, `find the disk ${name}`);
|
|
81
|
+
const data = (await response.json().catch(() => undefined))?.data;
|
|
82
|
+
return (Array.isArray(data) ? data : []).map(infoOf).find((disk) => disk?.name === name);
|
|
83
|
+
}
|
|
84
|
+
/** How many disks a plan allows, when Archil's words for its refusal say. */
|
|
85
|
+
export function limitOf(words) {
|
|
86
|
+
const match = /\b(?:limit(?:\s+of)?|allows?|maximum(?:\s+of)?|max(?:imum)?)\s+(\d+)\b/i.exec(words) ?? /\b(\d+)\s+disks?\b/i.exec(words);
|
|
87
|
+
return match ? Number(match[1]) : undefined;
|
|
88
|
+
}
|
|
89
|
+
/** Removes token user `identifier` of disk `diskId`. Idempotent: one already gone (404) is removed. */
|
|
90
|
+
async function removeToken(options, diskId, identifier, what, context) {
|
|
91
|
+
const removed = await call(options, "DELETE", `/api/disks/${encodeURIComponent(diskId)}/users/token?identifier=${encodeURIComponent(identifier)}`, what, context);
|
|
92
|
+
if (!removed.response.ok && removed.response.status !== 404)
|
|
93
|
+
throw await refused(removed.response, removed.key, what);
|
|
94
|
+
await removed.response.body?.cancel().catch(() => undefined);
|
|
95
|
+
}
|
|
96
|
+
/** Removes every token user of disk `diskId` that is not a run's (isRunNickname): the default one Archil made with it,
|
|
97
|
+
* left standing when an earlier call's removal failed or its answer was lost. A run's token is the run's to revoke. */
|
|
98
|
+
async function removeStrayTokens(options, diskId, name, context) {
|
|
99
|
+
const what = `remove the disk ${name}'s default token`;
|
|
100
|
+
let users;
|
|
101
|
+
try {
|
|
102
|
+
users = await listTokenUsers({ ...options, disk: diskId }, context);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
throw new ArchilDiskError(`Archil's token users of the disk ${name} could not be read to ${what}: ${error.message}`, error.status);
|
|
106
|
+
}
|
|
107
|
+
for (const user of users)
|
|
108
|
+
if (!isRunNickname(user.nickname))
|
|
109
|
+
await removeToken(options, diskId, user.identifier, what, context);
|
|
110
|
+
}
|
|
111
|
+
/** Makes the disk `name` (Archil-managed storage, the control plane's region), or finds it when it is there already: its
|
|
112
|
+
* id, and whether this call made it. A disk this call made has its default token user removed before it is answered; a
|
|
113
|
+
* disk found there already has every token user that is not a run's removed (an earlier call's default token, when its
|
|
114
|
+
* removal failed). The plan's limit is an ArchilDiskLimit. */
|
|
115
|
+
export async function ensureDisk(options, name, context = {}) {
|
|
116
|
+
const { response, key } = await call(options, "POST", "/api/disks", `make the disk ${name}`, context, { name });
|
|
117
|
+
if (response.status === 409) {
|
|
118
|
+
await response.body?.cancel().catch(() => undefined);
|
|
119
|
+
const there = await diskNamed(options, name, context);
|
|
120
|
+
if (there === undefined)
|
|
121
|
+
throw new ArchilDiskError(`Archil said a disk named ${name} is there with another configuration, and no disk of that name is listed`, 409);
|
|
122
|
+
await removeStrayTokens(options, there.id, name, context);
|
|
123
|
+
return { id: there.id, made: false };
|
|
124
|
+
}
|
|
125
|
+
if (response.status === 403) {
|
|
126
|
+
const { words, code } = await errorOf(response, [key]);
|
|
127
|
+
if (code === "disk_limit_reached")
|
|
128
|
+
throw new ArchilDiskLimit(`Archil refused to make the disk ${name}: ${words}`, limitOf(words));
|
|
129
|
+
throw new ArchilDiskError(`Archil refused to make the disk ${name} (403): ${words}`, 403, code);
|
|
130
|
+
}
|
|
131
|
+
if (!response.ok)
|
|
132
|
+
throw await refused(response, key, `make the disk ${name}`);
|
|
133
|
+
const data = (await response.json().catch(() => undefined))?.data;
|
|
134
|
+
if (typeof data?.diskId !== "string" || data.diskId === "")
|
|
135
|
+
throw new ArchilDiskError(`Archil answered the making of the disk ${name} with no disk id`);
|
|
136
|
+
const made = response.status === 201;
|
|
137
|
+
if (made) {
|
|
138
|
+
// The default token user Archil makes with a disk: no one holds it, and none is kept standing.
|
|
139
|
+
const users = Array.isArray(data.authorizedUsers) ? data.authorizedUsers : [];
|
|
140
|
+
for (const user of users) {
|
|
141
|
+
if (user?.type !== "token" || typeof user.identifier !== "string")
|
|
142
|
+
continue;
|
|
143
|
+
await removeToken(options, data.diskId, user.identifier, `remove the new disk ${name}'s default token`, context);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
await removeStrayTokens(options, data.diskId, name, context);
|
|
148
|
+
}
|
|
149
|
+
return { id: data.diskId, made };
|
|
150
|
+
}
|
|
151
|
+
/** Waits until disk `id` reads `available` (a disk just made reads `creating` for a while), up to `timeoutMs`. */
|
|
152
|
+
export async function availableDisk(options, id, { timeoutMs = 120_000, everyMs = 1_000, signal } = {}) {
|
|
153
|
+
const until = Date.now() + timeoutMs;
|
|
154
|
+
for (;;) {
|
|
155
|
+
// Each read is bounded by the time left, so a stalled response cannot outwait the deadline.
|
|
156
|
+
const left = AbortSignal.timeout(Math.max(1, until - Date.now()));
|
|
157
|
+
const disk = await getDisk(options, id, { signal: signal ? AbortSignal.any([signal, left]) : left });
|
|
158
|
+
if (disk === undefined)
|
|
159
|
+
throw new ArchilDiskError(`Archil has no disk ${id} in ${options.region}`, 404);
|
|
160
|
+
if (disk.status === "available")
|
|
161
|
+
return disk;
|
|
162
|
+
if (disk.status === "failed" || disk.status === "deleting" || disk.status === "deleted")
|
|
163
|
+
throw new ArchilDiskError(`the disk ${id} is ${disk.status} at Archil`);
|
|
164
|
+
if (Date.now() >= until)
|
|
165
|
+
throw new ArchilDiskError(`the disk ${id} was still ${disk.status || "not ready"} at Archil after ${Math.round(timeoutMs / 1000)} s`);
|
|
166
|
+
await new Promise((done) => setTimeout(done, everyMs));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/** Removes disk `id` and everything on it. Idempotent: one already gone (404) is removed. */
|
|
170
|
+
export async function deleteDisk(options, id, context = {}) {
|
|
171
|
+
const { response, key } = await call(options, "DELETE", `/api/disks/${encodeURIComponent(id)}`, `remove the disk ${id}`, context);
|
|
172
|
+
if (response.ok || response.status === 404) {
|
|
173
|
+
await response.body?.cancel().catch(() => undefined);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
throw await refused(response, key, `remove the disk ${id}`);
|
|
177
|
+
}
|
|
178
|
+
/** One page of the account's disks, at most one: what the Archil settings' test reads to know the key works. */
|
|
179
|
+
export async function listOneDisk(options, context = {}) {
|
|
180
|
+
const { response, key } = await call(options, "GET", "/api/disks?short=true&limit=1", "list the account's disks", context);
|
|
181
|
+
if (!response.ok)
|
|
182
|
+
throw await refused(response, key, "list the account's disks");
|
|
183
|
+
const body = (await response.json().catch(() => undefined));
|
|
184
|
+
return typeof body?.total === "number" ? body.total : Array.isArray(body?.data) ? body.data.length : 0;
|
|
185
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Workspace exec on an Archil disk: one serverless exec call (archil-disk.ts) that mounts the workspace's folder and
|
|
2
|
-
// its exec spill folder, and nothing else of the disk
|
|
3
|
-
//
|
|
4
|
-
// The rest (boxes, records, sweeps) is not.
|
|
2
|
+
// its exec spill folder, and nothing else of the disk: the call, its 300 s cut, the hold on the folder with a queue, and
|
|
3
|
+
// the mapping of the exit and of the deadline.
|
|
5
4
|
//
|
|
6
5
|
// Archil runs one shell line in a fresh container with two folders of the disk, each a mount's `subdirectory`, held for
|
|
7
6
|
// the line (no other client writes in them meanwhile; a second one waits up to queueMs):
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/** The control plane of each Archil region, as Archil's SDK (`disk` 1.12.0, src/regions.ts) names them. */
|
|
2
2
|
export declare const ARCHIL_CONTROL_URLS: Readonly<Record<string, string>>;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/** Its region: it names the control plane. */
|
|
3
|
+
/** Archil's control plane, for the account's calls (archil-disks.ts) as for a disk's. */
|
|
4
|
+
export interface ArchilControlOptions {
|
|
5
|
+
/** The region: it names the control plane. */
|
|
7
6
|
readonly region: string;
|
|
8
7
|
/** The account API key, asked for on each call. */
|
|
9
8
|
readonly key: () => string | Promise<string>;
|
|
@@ -12,6 +11,10 @@ export interface ArchilMountCredentialOptions {
|
|
|
12
11
|
/** The fetch to call it with (default the global one). */
|
|
13
12
|
readonly fetch?: typeof fetch;
|
|
14
13
|
}
|
|
14
|
+
export interface ArchilMountCredentialOptions extends ArchilControlOptions {
|
|
15
|
+
/** The disk's id, dsk-<16 hex digits>. */
|
|
16
|
+
readonly disk: string;
|
|
17
|
+
}
|
|
15
18
|
/** A minted mount credential: the token a computer's mount takes, and the identifier it is removed by. */
|
|
16
19
|
export interface MountCredential {
|
|
17
20
|
readonly token: string;
|
|
@@ -23,11 +26,24 @@ export declare class ArchilMountCredentialError extends Error {
|
|
|
23
26
|
readonly status: number | undefined;
|
|
24
27
|
constructor(message: string, status?: number);
|
|
25
28
|
}
|
|
29
|
+
/** The control plane's base URL: the region's, or the loopback one given. */
|
|
30
|
+
export declare function controlOf(options: ArchilControlOptions): string;
|
|
26
31
|
/** A ttl as Archil reads it (a Go duration): whole seconds, at least one, at most Archil's 365 days. */
|
|
27
32
|
export declare const ttlOf: (ms: number) => string;
|
|
28
33
|
/** The nickname of run `run`'s token user under claim epoch `epoch`: the run and the epoch, so a later claim finds an
|
|
29
34
|
* earlier one's (its runner died before removing it). */
|
|
30
35
|
export declare const nicknameOf: (run: string, epoch: number) => string;
|
|
36
|
+
/** Whether a token user's nickname is a run's (nicknameOf): every token this server mints is one. */
|
|
37
|
+
export declare const isRunNickname: (nickname: unknown) => boolean;
|
|
38
|
+
/** `text` with each secret replaced. */
|
|
39
|
+
export declare const scrub: (text: string, secrets: readonly string[]) => string;
|
|
40
|
+
/** Archil's words for a failed call, from its error envelope ({error, code}), cut short and scrubbed. */
|
|
41
|
+
export declare function wordsOf(response: Response, secrets: readonly string[]): Promise<string>;
|
|
42
|
+
/** Archil's error envelope ({error, code}): its words, cut short and scrubbed, and its code when it gives one. */
|
|
43
|
+
export declare function errorOf(response: Response, secrets: readonly string[]): Promise<{
|
|
44
|
+
words: string;
|
|
45
|
+
code?: string;
|
|
46
|
+
}>;
|
|
31
47
|
/** Mints the run's mount credential on the disk: a token user named `nickname`, which Archil ends after `ttlMs`. */
|
|
32
48
|
export declare function mintMountToken(options: ArchilMountCredentialOptions, run: {
|
|
33
49
|
readonly nickname: string;
|
|
@@ -28,7 +28,7 @@ export class ArchilMountCredentialError extends Error {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
/** The control plane's base URL: the region's, or the loopback one given. */
|
|
31
|
-
function controlOf(options) {
|
|
31
|
+
export function controlOf(options) {
|
|
32
32
|
if (options.baseUrl !== undefined) {
|
|
33
33
|
const url = new URL(options.baseUrl);
|
|
34
34
|
if (url.protocol !== "https:" && !(url.protocol === "http:" && LOOPBACK.test(url.hostname)))
|
|
@@ -54,20 +54,29 @@ function claimOfNickname(nickname) {
|
|
|
54
54
|
const match = /^agentrun:(.+):(0|[1-9][0-9]*)$/.exec(nickname);
|
|
55
55
|
return match ? { run: match[1], epoch: Number(match[2]) } : undefined;
|
|
56
56
|
}
|
|
57
|
+
/** Whether a token user's nickname is a run's (nicknameOf): every token this server mints is one. */
|
|
58
|
+
export const isRunNickname = (nickname) => claimOfNickname(nickname) !== undefined;
|
|
57
59
|
/** `text` with each secret replaced. */
|
|
58
|
-
const scrub = (text, secrets) => secrets.filter((one) => one.length >= 4).reduce((out, one) => out.split(one).join("[redacted]"), text);
|
|
60
|
+
export const scrub = (text, secrets) => secrets.filter((one) => one.length >= 4).reduce((out, one) => out.split(one).join("[redacted]"), text);
|
|
59
61
|
/** Archil's words for a failed call, from its error envelope ({error, code}), cut short and scrubbed. */
|
|
60
|
-
async function wordsOf(response, secrets) {
|
|
62
|
+
export async function wordsOf(response, secrets) {
|
|
63
|
+
return (await errorOf(response, secrets)).words;
|
|
64
|
+
}
|
|
65
|
+
/** Archil's error envelope ({error, code}): its words, cut short and scrubbed, and its code when it gives one. */
|
|
66
|
+
export async function errorOf(response, secrets) {
|
|
61
67
|
const text = await response.text().catch(() => "");
|
|
62
68
|
let said = text;
|
|
69
|
+
let code;
|
|
63
70
|
try {
|
|
64
71
|
const body = JSON.parse(text);
|
|
65
72
|
said = typeof body.error === "string" ? body.error : typeof body.message === "string" ? body.message : text;
|
|
73
|
+
if (typeof body.code === "string")
|
|
74
|
+
code = body.code;
|
|
66
75
|
}
|
|
67
76
|
catch {
|
|
68
77
|
// not JSON: its text
|
|
69
78
|
}
|
|
70
|
-
return scrub(said.trim().slice(0, 300), secrets);
|
|
79
|
+
return { words: scrub(said.trim().slice(0, 300), secrets), ...(code !== undefined ? { code } : {}) };
|
|
71
80
|
}
|
|
72
81
|
/** Mints the run's mount credential on the disk: a token user named `nickname`, which Archil ends after `ttlMs`. */
|
|
73
82
|
export async function mintMountToken(options, run) {
|
|
@@ -5,7 +5,7 @@ import type { ProviderFactories } from "../computer-keys.js";
|
|
|
5
5
|
import type { FauxComputers } from "../faux-computers.js";
|
|
6
6
|
import { type KeyEnv } from "../key-meta.js";
|
|
7
7
|
import type { Store } from "../store/index.js";
|
|
8
|
-
import { type ClaimComputer, type ClaimLaunch, computerForClaim, type ComputerForClaimDeps, type OpenComputerView } from "./computer-for-claim.js";
|
|
8
|
+
import { type ClaimComputer, type ClaimLaunch, computerForClaim, type ComputerForClaimDeps, type ComputerSaid, type OpenComputerView } from "./computer-for-claim.js";
|
|
9
9
|
import { type ProviderLoad } from "./computer-providers.js";
|
|
10
10
|
import { type KindRegistry } from "./resolve-computer.js";
|
|
11
11
|
/** How long a run's computer lives whatever happens to the server: a bound on a leaked one, never its clean end (the old
|
|
@@ -68,6 +68,9 @@ export interface ComputerDepsOptions {
|
|
|
68
68
|
/** This machine's Docker daemon, asked when a Docker launch fails (docker-daemon.ts dockerDaemonCheck over `env`
|
|
69
69
|
* unless given; none under --faux, whose launch is its own). */
|
|
70
70
|
readonly daemon?: ComputerForClaimDeps["daemon"];
|
|
71
|
+
/** Why this machine cannot run a provider's computers, by its id (computers.ts hostCommandRefusals over this process's
|
|
72
|
+
* PATH): the claim refuses such a computer before it rents anything. Absent: not asked. */
|
|
73
|
+
readonly hostWhy?: Readonly<Record<string, string>>;
|
|
71
74
|
/** The live view's registration for a desktop or a phone (proxy-only): absent, no view is opened. */
|
|
72
75
|
readonly openComputerView?: OpenComputerView;
|
|
73
76
|
/** --faux's computers (faux-computers.ts), in place of the computer package's: their kind registry, key table, launch
|
|
@@ -76,17 +79,22 @@ export interface ComputerDepsOptions {
|
|
|
76
79
|
}
|
|
77
80
|
/** The spec a computer of `kind` on `entry` is made with, besides its labels and its mount: its image (a provider that
|
|
78
81
|
* prepares its own image, its descriptor's prepareImage: the owner's AGENTRUN_DOCKER_IMAGE when set, else for a sandbox
|
|
79
|
-
* the package's recipe, which its prepareImage() builds;
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
82
|
+
* the package's recipe, which its prepareImage() builds; a provider whose descriptor declares imageEnv (Daytona's
|
|
83
|
+
* AGENTRUN_DAYTONA_SNAPSHOT): that variable's value in `env` when set; any other provider's, and such a one's while it
|
|
84
|
+
* is unset: its descriptor's defaultImage for the kind, the computer package's
|
|
85
|
+
* PROVIDERS[].defaultImage; a kind with none refused in words, a prepared desktop's saying it needs an image with an X
|
|
86
|
+
* server, which the recipe lacks), the leak bound for its lifetime (its clean end is the run's release), and its
|
|
87
|
+
* network (networkOf): the run's box_allow, or this server's own (AGENTRUN_BOX_ALLOW, read from `env`) for a launch
|
|
88
|
+
* that names none; and the size of a computer on this machine's container engine (its descriptor's `local`),
|
|
89
|
+
* AGENTRUN_BOX_CPUS, _MEMORY and _PIDS (dockerLimitsOf, read once here): a vendor's computer sizes itself. No key and
|
|
90
|
+
* no environment. */
|
|
86
91
|
export declare function computerSpecOf(env: KeyEnv): ComputerForClaimDeps["spec"];
|
|
87
92
|
/** The run's timeline phase while its claim waits on its computer's image (computerForClaim's onImageWait): main's box
|
|
88
93
|
* image row, the computer's noun for the box's. */
|
|
89
94
|
export declare const imageWaitWords: (making: "build" | "pull", image: string) => string;
|
|
95
|
+
/** The run's timeline phase once its claim's computer is connected (computerForClaim's onConnected): what it says it
|
|
96
|
+
* is, in its hello's own facts, such as "The phone is ready: Android 15 (arm64), from Phone harness." */
|
|
97
|
+
export declare const computerReadyWords: ({ provider, kind, hello }: ComputerSaid) => string;
|
|
90
98
|
/** The claim's computer as the runner's specs call it: what the run's launch lets the computer reach (its box_allow),
|
|
91
99
|
* read from the launch row when the store has one and the claim does not say, then computerForClaim. */
|
|
92
100
|
export declare const claimComputer: (launch: ClaimLaunch, store: Parameters<typeof computerForClaim>[1] & {
|
|
@@ -108,13 +108,15 @@ export function dockerVolumeOf(paths) {
|
|
|
108
108
|
}
|
|
109
109
|
/** The spec a computer of `kind` on `entry` is made with, besides its labels and its mount: its image (a provider that
|
|
110
110
|
* prepares its own image, its descriptor's prepareImage: the owner's AGENTRUN_DOCKER_IMAGE when set, else for a sandbox
|
|
111
|
-
* the package's recipe, which its prepareImage() builds;
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
111
|
+
* the package's recipe, which its prepareImage() builds; a provider whose descriptor declares imageEnv (Daytona's
|
|
112
|
+
* AGENTRUN_DAYTONA_SNAPSHOT): that variable's value in `env` when set; any other provider's, and such a one's while it
|
|
113
|
+
* is unset: its descriptor's defaultImage for the kind, the computer package's
|
|
114
|
+
* PROVIDERS[].defaultImage; a kind with none refused in words, a prepared desktop's saying it needs an image with an X
|
|
115
|
+
* server, which the recipe lacks), the leak bound for its lifetime (its clean end is the run's release), and its
|
|
116
|
+
* network (networkOf): the run's box_allow, or this server's own (AGENTRUN_BOX_ALLOW, read from `env`) for a launch
|
|
117
|
+
* that names none; and the size of a computer on this machine's container engine (its descriptor's `local`),
|
|
118
|
+
* AGENTRUN_BOX_CPUS, _MEMORY and _PIDS (dockerLimitsOf, read once here): a vendor's computer sizes itself. No key and
|
|
119
|
+
* no environment. */
|
|
118
120
|
export function computerSpecOf(env) {
|
|
119
121
|
const named = envValue(env, DOCKER_IMAGE_ENV);
|
|
120
122
|
// This server's allow setting, as a launch is stamped with it (box-settings.ts boxAllowOf; its start checks the setting).
|
|
@@ -123,6 +125,9 @@ export function computerSpecOf(env) {
|
|
|
123
125
|
const imageOf = (entry, kind) => {
|
|
124
126
|
if (entry.prepareImage && named !== undefined)
|
|
125
127
|
return named;
|
|
128
|
+
const chosen = entry.imageEnv === undefined ? undefined : envValue(env, entry.imageEnv)?.trim();
|
|
129
|
+
if (chosen !== undefined)
|
|
130
|
+
return chosen;
|
|
126
131
|
// A sandbox whose provider prepares its image: the package's own recipe, which its prepareImage() builds (the
|
|
127
132
|
// descriptor gives it no default).
|
|
128
133
|
if (entry.prepareImage && kind === "sandbox")
|
|
@@ -174,6 +179,11 @@ function networkOf(entry, kind, run, current, currentSet) {
|
|
|
174
179
|
/** The run's timeline phase while its claim waits on its computer's image (computerForClaim's onImageWait): main's box
|
|
175
180
|
* image row, the computer's noun for the box's. */
|
|
176
181
|
export const imageWaitWords = (making, image) => making === "build" ? `Preparing the computer's image: building it (${DOCKER_RECIPE_HAS})…` : `Preparing the computer's image: pulling ${image}…`;
|
|
182
|
+
/** An OS as people write its name. */
|
|
183
|
+
const OS_NAMES = { linux: "Linux", windows: "Windows", macos: "macOS", android: "Android", ios: "iOS" };
|
|
184
|
+
/** The run's timeline phase once its claim's computer is connected (computerForClaim's onConnected): what it says it
|
|
185
|
+
* is, in its hello's own facts, such as "The phone is ready: Android 15 (arm64), from Phone harness." */
|
|
186
|
+
export const computerReadyWords = ({ provider, kind, hello }) => `The ${kind} is ready: ${[OS_NAMES[hello.os] ?? hello.os, hello.osVersion].filter(Boolean).join(" ")} (${hello.arch}), from ${provider}.`;
|
|
177
187
|
/** The claim's computer as the runner's specs call it: what the run's launch lets the computer reach (its box_allow),
|
|
178
188
|
* read from the launch row when the store has one and the claim does not say, then computerForClaim. */
|
|
179
189
|
export const claimComputer = async (launch, store, deps) => {
|
|
@@ -253,6 +263,7 @@ export function computerDepsFrom(options) {
|
|
|
253
263
|
// Under --faux, its launch makes the computer, with its key table: no provider of the package is built.
|
|
254
264
|
...(faux ? { keyTable: faux.keyTable, launch: (entry, spec) => faux.launch(entry, spec) } : {}),
|
|
255
265
|
...(options.answers ? { answers: options.answers } : {}),
|
|
266
|
+
...(options.hostWhy ? { hostWhy: (provider) => (Object.hasOwn(options.hostWhy, provider) ? options.hostWhy[provider] : undefined) } : {}),
|
|
256
267
|
...(options.daemon ? { daemon: options.daemon } : faux ? {} : { daemon: dockerDaemonOf(env) }),
|
|
257
268
|
...(options.openComputerView ? { openComputerView: options.openComputerView } : {}),
|
|
258
269
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { ComputerProvider, ComputerSpec } from "@parcha/agentrun-computer";
|
|
1
|
+
import type { ComputerProvider, ComputerSpec, HelloResult } from "@parcha/agentrun-computer";
|
|
2
2
|
import { type PlaceView } from "../computer-setting.js";
|
|
3
3
|
import { type KeyTable, type ProviderSettings } from "../computer-keys.js";
|
|
4
4
|
import type { Store } from "../store/index.js";
|
|
5
5
|
import type { MountCheck } from "./attach.js";
|
|
6
|
+
import { type HeldComputer } from "./computer-hold.js";
|
|
6
7
|
import { type ProviderLedger } from "./computer-ledger.js";
|
|
7
|
-
import { type ClaimSide, type ComputerSetting, type ComputerSettingKind, type KindRegistry, type ProviderEntry } from "./resolve-computer.js";
|
|
8
|
+
import { type ClaimBrowser, type ClaimSide, type ComputerSetting, type ComputerSettingKind, type KindRegistry, type ProviderEntry } from "./resolve-computer.js";
|
|
8
9
|
import type { RunComputer, RunHold } from "./run-tools.js";
|
|
9
10
|
import type { Workspace } from "./workspace.js";
|
|
10
11
|
/** What the claim knows of the run: its id, the claim's epoch, and where its computer setting is (the launch's own, else
|
|
@@ -12,6 +13,8 @@ import type { Workspace } from "./workspace.js";
|
|
|
12
13
|
export interface ClaimLaunch {
|
|
13
14
|
readonly runId: string;
|
|
14
15
|
readonly epoch: number;
|
|
16
|
+
/** The run's agent: the owner of its own computer where its setting is persistent (agent-computer.ts). */
|
|
17
|
+
readonly agentId?: string;
|
|
15
18
|
/** The claim itself, as the live view's registration fences on it (absent: its run and epoch). */
|
|
16
19
|
readonly claim?: unknown;
|
|
17
20
|
readonly revisionId?: string;
|
|
@@ -101,22 +104,55 @@ export interface ComputerForClaimDeps {
|
|
|
101
104
|
* a host that lacks it, or a named image pulled); never when the host has it. The run's caller says it on the run's
|
|
102
105
|
* timeline. Absent: nothing is said. */
|
|
103
106
|
readonly onImageWait?: ImageWait;
|
|
107
|
+
/** Told once a computer the claim made through its provider is connected, with what it says it is (its hello's OS,
|
|
108
|
+
* the OS's version and its architecture): the run's caller says it on the run's timeline. A browser session, made
|
|
109
|
+
* by the run's tool, is never told. Absent: nothing is said. */
|
|
110
|
+
readonly onConnected?: (said: ComputerSaid) => void;
|
|
111
|
+
/** Why this machine cannot run a provider's computers, by its provider id (computers.ts hostCommandRefusals: the
|
|
112
|
+
* phone's adb not on PATH), in words that say how to fix it, or undefined: refused with code computer_unavailable
|
|
113
|
+
* before anything is rented. Absent: not asked. */
|
|
114
|
+
readonly hostWhy?: (provider: string) => string | undefined;
|
|
104
115
|
/** Why this run's harness takes no computer of `kind`, in words (a CLI harness's of a browser), or undefined: a kind
|
|
105
116
|
* it refuses is refused with code computer_unavailable before anything is made. Absent: every kind. */
|
|
106
117
|
readonly refuseKind?: (kind: Exclude<ComputerSettingKind, "none">) => string | undefined;
|
|
118
|
+
/** Told what became of the agent's own computer at the claim (a persistent setting): made, attached from an earlier
|
|
119
|
+
* run, or made again because the one this server kept is gone. The run's caller says it on the run's timeline. */
|
|
120
|
+
readonly onComputerNote?: (words: string) => void;
|
|
107
121
|
readonly signal?: AbortSignal;
|
|
108
122
|
}
|
|
109
|
-
/** The run's computer at its claim: what runTools takes, the person's hold on a desktop's or phone's ports,
|
|
110
|
-
*
|
|
111
|
-
* run's
|
|
123
|
+
/** The run's computer at its claim: what runTools takes, the person's hold on a desktop's or phone's ports, the hold
|
|
124
|
+
* itself with the computer's kind (`held`, what the adapter loop takes as AdapterRunSpec.computer: it commits the hold's
|
|
125
|
+
* changes to the run's journal and applies the person's take-over and hand-back to it), and its release (idempotent):
|
|
126
|
+
* the live view closed ("released" when the computer goes before the run's end, "ended" at the run's end), the
|
|
127
|
+
* owner's view let go, then the computer. */
|
|
112
128
|
export interface ClaimComputer {
|
|
113
129
|
readonly computer?: RunComputer;
|
|
114
130
|
readonly hold?: RunHold;
|
|
131
|
+
readonly held?: HeldComputer;
|
|
115
132
|
release(why?: ViewEnd): Promise<void>;
|
|
116
133
|
}
|
|
117
134
|
/** The provider's watch of a computer's screen (ComputerProvider.watch), where it has one. */
|
|
118
135
|
/** Told once, before the claim waits on its computer's image being built or pulled; never when the host has it. */
|
|
119
136
|
export type ImageWait = (making: "build" | "pull", tag: string) => void;
|
|
137
|
+
/** What a computer the claim made says it is, once it is connected: the provider's name in words, the agent's setting
|
|
138
|
+
* kind, and its hello's own facts (its OS, the OS's version where it says one, its architecture). */
|
|
139
|
+
export type ComputerSaid = {
|
|
140
|
+
readonly provider: string;
|
|
141
|
+
readonly kind: Exclude<ComputerSettingKind, "none">;
|
|
142
|
+
readonly hello: Pick<HelloResult, "os" | "osVersion" | "arch">;
|
|
143
|
+
};
|
|
144
|
+
/** A browser computer's provider as the run's browser tool opens its sessions through it (ClaimBrowser): nothing is made
|
|
145
|
+
* at the claim. A session's computer is made at the tool's call, under the run's labels (`spec`'s) and the tool's tag,
|
|
146
|
+
* with the session's own options (spec.browser) where the provider declares them (capabilities().browser); its release
|
|
147
|
+
* lets go of every one the tool left open. The claim's browser (the agent's computer) and the tool plane's vendor's
|
|
148
|
+
* (browser-computer.ts planeBrowser) are each one of these. */
|
|
149
|
+
export declare function claimBrowser(provider: ComputerProvider, spec: ComputerSpec): {
|
|
150
|
+
readonly browser: ClaimBrowser;
|
|
151
|
+
release(): Promise<void>;
|
|
152
|
+
};
|
|
120
153
|
/** The run's computer for this claim, started and registered; `{ computer: undefined }` for none. Throws with code
|
|
121
154
|
* computer_unavailable and the server's words when the agent's computer cannot be had here. */
|
|
122
|
-
export declare function computerForClaim(launch: ClaimLaunch, store: Pick<Store, "agents" | "sealedKeys" | "computerLedger"
|
|
155
|
+
export declare function computerForClaim(launch: ClaimLaunch, store: Pick<Store, "agents" | "sealedKeys" | "computerLedger"> & {
|
|
156
|
+
readonly settings?: Store["settings"];
|
|
157
|
+
readonly runs?: Pick<Store["runs"], "get">;
|
|
158
|
+
}, deps: ComputerForClaimDeps): Promise<ClaimComputer>;
|