@parcha/agentrun-computer 0.1.0-beta.34 → 0.1.0-beta.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +144 -26
- package/dist/browser.d.ts +12 -13
- package/dist/browser.js +16 -14
- package/dist/browserbase.d.ts +3 -5
- package/dist/browserbase.js +16 -13
- package/dist/chrome.js +1 -1
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/conformance/browserbase.js +1 -1
- package/dist/conformance/cases/provider.js +78 -3
- package/dist/conformance/daytona.js +2 -1
- package/dist/conformance/e2b.js +2 -1
- package/dist/conformance/fixture.js +24 -2
- package/dist/conformance/kernel.js +1 -1
- package/dist/conformance/kind.js +2 -1
- package/dist/conformance/{local.d.ts → local-chrome.d.ts} +7 -7
- package/dist/conformance/{local.js → local-chrome.js} +11 -11
- package/dist/conformance/orgo.d.ts +11 -5
- package/dist/conformance/orgo.js +37 -8
- package/dist/conformance/phone-harness.js +2 -1
- package/dist/conformance/report.js +3 -2
- package/dist/conformance/runner.js +25 -7
- package/dist/conformance/types.d.ts +21 -8
- package/dist/conformance/types.js +10 -0
- package/dist/conformance/windows-fixture.d.ts +1 -0
- package/dist/conformance/windows-fixture.js +37 -0
- package/dist/daytona.d.ts +3 -34
- package/dist/daytona.js +34 -61
- package/dist/descriptor.d.ts +94 -0
- package/dist/descriptor.js +81 -0
- package/dist/descriptors/browserbase.d.ts +24 -0
- package/dist/descriptors/browserbase.js +18 -0
- package/dist/descriptors/daytona.d.ts +62 -0
- package/dist/descriptors/daytona.js +49 -0
- package/dist/descriptors/docker.d.ts +12 -0
- package/dist/descriptors/docker.js +17 -0
- package/dist/descriptors/e2b.d.ts +22 -0
- package/dist/descriptors/e2b.js +19 -0
- package/dist/descriptors/index.d.ts +229 -0
- package/dist/descriptors/index.js +19 -0
- package/dist/descriptors/kernel.d.ts +20 -0
- package/dist/descriptors/kernel.js +15 -0
- package/dist/descriptors/local-chrome.d.ts +17 -0
- package/dist/descriptors/local-chrome.js +21 -0
- package/dist/descriptors/modal.d.ts +50 -0
- package/dist/descriptors/modal.js +38 -0
- package/dist/descriptors/orgo.d.ts +88 -0
- package/dist/descriptors/orgo.js +44 -0
- package/dist/descriptors/phone-harness.d.ts +28 -0
- package/dist/descriptors/phone-harness.js +20 -0
- package/dist/descriptors/shared.d.ts +7 -0
- package/dist/descriptors/shared.js +6 -0
- package/dist/desktop.d.ts +4 -4
- package/dist/desktop.js +4 -4
- package/dist/docker/egress.d.ts +1 -1
- package/dist/docker/image.js +17 -15
- package/dist/docker/inspect.d.ts +147 -0
- package/dist/docker/inspect.js +335 -0
- package/dist/docker.d.ts +6 -6
- package/dist/docker.js +46 -42
- package/dist/drift.d.ts +3 -145
- package/dist/drift.js +5 -334
- package/dist/e2b.d.ts +2 -8
- package/dist/e2b.js +16 -22
- package/dist/index.d.ts +8 -11
- package/dist/index.js +13 -11
- package/dist/isolation.js +2 -2
- package/dist/janitor.d.ts +18 -1
- package/dist/janitor.js +67 -19
- package/dist/kernel.d.ts +3 -5
- package/dist/kernel.js +19 -16
- package/dist/kinds.d.ts +54 -34
- package/dist/kinds.js +19 -117
- package/dist/labels.d.ts +12 -0
- package/dist/labels.js +39 -1
- package/dist/{local.d.ts → local-chrome.d.ts} +5 -8
- package/dist/{local.js → local-chrome.js} +19 -16
- package/dist/local-supervisor.d.ts +3 -3
- package/dist/local-supervisor.js +3 -3
- package/dist/modal.d.ts +3 -22
- package/dist/modal.js +15 -31
- package/dist/mount-archil.js +4 -4
- package/dist/orgo-channel.js +16 -13
- package/dist/orgo-desktop.d.ts +153 -0
- package/dist/orgo-desktop.js +1614 -0
- package/dist/orgo-names.d.ts +52 -0
- package/dist/orgo-names.js +84 -0
- package/dist/orgo.d.ts +18 -15
- package/dist/orgo.js +46 -107
- package/dist/phone-harness.d.ts +4 -10
- package/dist/phone-harness.js +45 -46
- package/dist/provider.d.ts +91 -10
- package/dist/provider.js +42 -0
- package/dist/providers.d.ts +23 -24
- package/dist/providers.js +14 -17
- package/dist/result.d.ts +11 -1
- package/dist/result.js +11 -0
- package/dist/test-connection.js +2 -2
- package/package.json +42 -2
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { Group } from "../protocol.js";
|
|
2
|
+
/** Orgo's Linux image: a desktop computer when its setting names none. */
|
|
3
|
+
export declare const ORGO_BASE_IMAGE = "linux";
|
|
4
|
+
/** The image a spec names for an Orgo Windows desktop (Windows Server 2019, Orgo's own). */
|
|
5
|
+
export declare const ORGO_WINDOWS_IMAGE = "windows";
|
|
6
|
+
/** The image a spec names for an Orgo macOS desktop. */
|
|
7
|
+
export declare const ORGO_MACOS_IMAGE = "macos";
|
|
8
|
+
/** What a Windows desktop offers: PowerShell for exec and files, and the screen, the pointer and the keys. */
|
|
9
|
+
export declare const WINDOWS_GROUPS: readonly Group[];
|
|
10
|
+
/** What a macOS desktop offers: the shell for exec, and the screen, the pointer and the keys. */
|
|
11
|
+
export declare const MACOS_GROUPS: readonly Group[];
|
|
12
|
+
/**
|
|
13
|
+
* Orgo's offered configuration, naming the image an agent's setting selects it by and the create() options that build
|
|
14
|
+
* it (KindCapabilities; serve passes the options to providerFor beside the keys'): the Linux desktop with computerd.
|
|
15
|
+
*
|
|
16
|
+
* Windows and macOS are parked (ORGO_PARKED): create({ os }) still builds them, for the conformance suite and their
|
|
17
|
+
* tests, but no agent's setting selects one, and a setting that names one is refused in words saying so.
|
|
18
|
+
*/
|
|
19
|
+
export declare const ORGO_CONFIGURATIONS: readonly [{
|
|
20
|
+
readonly image: "linux";
|
|
21
|
+
readonly options: {};
|
|
22
|
+
readonly kind: import("../protocol.js").ComputerKind;
|
|
23
|
+
readonly groups: Group[];
|
|
24
|
+
readonly gpu?: import("../provider.js").GpuCapability;
|
|
25
|
+
}];
|
|
26
|
+
/** Orgo's desktops not offered yet, each as its module builds it (create()'s os), and why, in the words a setting naming
|
|
27
|
+
* one is refused in. */
|
|
28
|
+
export declare const ORGO_PARKED: readonly [{
|
|
29
|
+
readonly kind: "desktop";
|
|
30
|
+
readonly groups: Group[];
|
|
31
|
+
readonly image: "windows";
|
|
32
|
+
readonly options: {
|
|
33
|
+
readonly os: "windows";
|
|
34
|
+
};
|
|
35
|
+
readonly why: "Orgo's Windows desktops are parked for now: Orgo offers Linux desktops";
|
|
36
|
+
}, {
|
|
37
|
+
readonly kind: "desktop";
|
|
38
|
+
readonly groups: Group[];
|
|
39
|
+
readonly image: "macos";
|
|
40
|
+
readonly options: {
|
|
41
|
+
readonly os: "macos";
|
|
42
|
+
};
|
|
43
|
+
readonly why: "Orgo's macOS desktops are parked for now: Orgo offers Linux desktops";
|
|
44
|
+
}];
|
|
45
|
+
export declare const ORGO: {
|
|
46
|
+
readonly id: "orgo";
|
|
47
|
+
readonly label: "Orgo";
|
|
48
|
+
readonly keys: readonly [{
|
|
49
|
+
readonly name: "ORGO_API_KEY";
|
|
50
|
+
readonly option: "apiKey";
|
|
51
|
+
readonly required: true;
|
|
52
|
+
}, {
|
|
53
|
+
readonly name: "ORGO_WORKSPACE_ID";
|
|
54
|
+
readonly option: "workspaceId";
|
|
55
|
+
readonly required: true;
|
|
56
|
+
}];
|
|
57
|
+
readonly metered: true;
|
|
58
|
+
readonly mounts: readonly [];
|
|
59
|
+
readonly network: readonly ["none"];
|
|
60
|
+
readonly capabilities: readonly [{
|
|
61
|
+
readonly image: "linux";
|
|
62
|
+
readonly options: {};
|
|
63
|
+
readonly kind: import("../protocol.js").ComputerKind;
|
|
64
|
+
readonly groups: Group[];
|
|
65
|
+
readonly gpu?: import("../provider.js").GpuCapability;
|
|
66
|
+
}];
|
|
67
|
+
readonly parked: readonly [{
|
|
68
|
+
readonly kind: "desktop";
|
|
69
|
+
readonly groups: Group[];
|
|
70
|
+
readonly image: "windows";
|
|
71
|
+
readonly options: {
|
|
72
|
+
readonly os: "windows";
|
|
73
|
+
};
|
|
74
|
+
readonly why: "Orgo's Windows desktops are parked for now: Orgo offers Linux desktops";
|
|
75
|
+
}, {
|
|
76
|
+
readonly kind: "desktop";
|
|
77
|
+
readonly groups: Group[];
|
|
78
|
+
readonly image: "macos";
|
|
79
|
+
readonly options: {
|
|
80
|
+
readonly os: "macos";
|
|
81
|
+
};
|
|
82
|
+
readonly why: "Orgo's macOS desktops are parked for now: Orgo offers Linux desktops";
|
|
83
|
+
}];
|
|
84
|
+
readonly defaultImage: {
|
|
85
|
+
readonly desktop: "linux";
|
|
86
|
+
};
|
|
87
|
+
readonly load: () => Promise<typeof import("../orgo.js")>;
|
|
88
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { defineProvider } from "../descriptor.js";
|
|
2
|
+
import { LINUX_DESKTOP } from "./shared.js";
|
|
3
|
+
/** Orgo's Linux image: a desktop computer when its setting names none. */
|
|
4
|
+
export const ORGO_BASE_IMAGE = "linux";
|
|
5
|
+
/** The image a spec names for an Orgo Windows desktop (Windows Server 2019, Orgo's own). */
|
|
6
|
+
export const ORGO_WINDOWS_IMAGE = "windows";
|
|
7
|
+
/** The image a spec names for an Orgo macOS desktop. */
|
|
8
|
+
export const ORGO_MACOS_IMAGE = "macos";
|
|
9
|
+
/** What a Windows desktop offers: PowerShell for exec and files, and the screen, the pointer and the keys. */
|
|
10
|
+
export const WINDOWS_GROUPS = ["exec", "files", "screen", "input.pointer", "input.keys"];
|
|
11
|
+
/** What a macOS desktop offers: the shell for exec, and the screen, the pointer and the keys. */
|
|
12
|
+
export const MACOS_GROUPS = ["exec", "screen", "input.pointer", "input.keys"];
|
|
13
|
+
/**
|
|
14
|
+
* Orgo's offered configuration, naming the image an agent's setting selects it by and the create() options that build
|
|
15
|
+
* it (KindCapabilities; serve passes the options to providerFor beside the keys'): the Linux desktop with computerd.
|
|
16
|
+
*
|
|
17
|
+
* Windows and macOS are parked (ORGO_PARKED): create({ os }) still builds them, for the conformance suite and their
|
|
18
|
+
* tests, but no agent's setting selects one, and a setting that names one is refused in words saying so.
|
|
19
|
+
*/
|
|
20
|
+
export const ORGO_CONFIGURATIONS = [{ ...LINUX_DESKTOP, image: ORGO_BASE_IMAGE, options: {} }];
|
|
21
|
+
/** Orgo's desktops not offered yet, each as its module builds it (create()'s os), and why, in the words a setting naming
|
|
22
|
+
* one is refused in. */
|
|
23
|
+
export const ORGO_PARKED = [
|
|
24
|
+
{ kind: "desktop", groups: [...WINDOWS_GROUPS], image: ORGO_WINDOWS_IMAGE, options: { os: "windows" }, why: "Orgo's Windows desktops are parked for now: Orgo offers Linux desktops" },
|
|
25
|
+
{ kind: "desktop", groups: [...MACOS_GROUPS], image: ORGO_MACOS_IMAGE, options: { os: "macos" }, why: "Orgo's macOS desktops are parked for now: Orgo offers Linux desktops" },
|
|
26
|
+
];
|
|
27
|
+
export const ORGO = defineProvider({
|
|
28
|
+
id: "orgo",
|
|
29
|
+
label: "Orgo",
|
|
30
|
+
// The workspace this server's computers live in: every Orgo provider is built in one, and lists only it.
|
|
31
|
+
keys: [
|
|
32
|
+
{ name: "ORGO_API_KEY", option: "apiKey", required: true },
|
|
33
|
+
{ name: "ORGO_WORKSPACE_ID", option: "workspaceId", required: true },
|
|
34
|
+
],
|
|
35
|
+
metered: true,
|
|
36
|
+
// None yet: an Archil mount needs an Orgo template that bakes the helper.
|
|
37
|
+
mounts: [],
|
|
38
|
+
// The Linux desktop's: none (computerd holds its programs to loopback).
|
|
39
|
+
network: ["none"],
|
|
40
|
+
capabilities: ORGO_CONFIGURATIONS,
|
|
41
|
+
parked: ORGO_PARKED,
|
|
42
|
+
defaultImage: { desktop: ORGO_BASE_IMAGE },
|
|
43
|
+
load: () => import("../orgo.js"),
|
|
44
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Group } from "../protocol.js";
|
|
2
|
+
/** The groups a phone harness phone offers. */
|
|
3
|
+
export declare const PHONE_GROUPS: readonly Group[];
|
|
4
|
+
/** The phone harness's Android: a phone computer when its setting names no image. */
|
|
5
|
+
export declare const PHONE_IMAGE = "android";
|
|
6
|
+
export declare const PHONE_HARNESS: {
|
|
7
|
+
readonly id: "phone-harness";
|
|
8
|
+
readonly label: "Phone harness";
|
|
9
|
+
readonly keys: readonly [{
|
|
10
|
+
readonly name: "PHONE_HARNESS_API_KEY";
|
|
11
|
+
readonly option: "apiKey";
|
|
12
|
+
readonly required: true;
|
|
13
|
+
}];
|
|
14
|
+
readonly metered: true;
|
|
15
|
+
readonly mounts: readonly [];
|
|
16
|
+
readonly network: readonly ["open"];
|
|
17
|
+
readonly capabilities: readonly [{
|
|
18
|
+
readonly kind: "android";
|
|
19
|
+
readonly groups: Group[];
|
|
20
|
+
}];
|
|
21
|
+
readonly defaultImage: {
|
|
22
|
+
readonly phone: "android";
|
|
23
|
+
};
|
|
24
|
+
readonly ledger: {
|
|
25
|
+
readonly option: "ledger";
|
|
26
|
+
};
|
|
27
|
+
readonly load: () => Promise<typeof import("../phone-harness.js")>;
|
|
28
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// The phone harness's descriptor: a cloud Android over adb, its sessions in a ledger the server keeps.
|
|
2
|
+
import { defineProvider } from "../descriptor.js";
|
|
3
|
+
/** The groups a phone harness phone offers. */
|
|
4
|
+
export const PHONE_GROUPS = ["screen", "input.touch", "input.keys", "apps", "apps.ui_tree"];
|
|
5
|
+
/** The phone harness's Android: a phone computer when its setting names no image. */
|
|
6
|
+
export const PHONE_IMAGE = "android";
|
|
7
|
+
export const PHONE_HARNESS = defineProvider({
|
|
8
|
+
id: "phone-harness",
|
|
9
|
+
label: "Phone harness",
|
|
10
|
+
keys: [{ name: "PHONE_HARNESS_API_KEY", option: "apiKey", required: true }],
|
|
11
|
+
metered: true,
|
|
12
|
+
mounts: [],
|
|
13
|
+
// The vendor's own network, open: it cannot be closed or narrowed.
|
|
14
|
+
network: ["open"],
|
|
15
|
+
capabilities: [{ kind: "android", groups: [...PHONE_GROUPS] }],
|
|
16
|
+
defaultImage: { phone: PHONE_IMAGE },
|
|
17
|
+
// The phones it rents, by session: the server's store backs this ledger, so a phone is never lost across restarts.
|
|
18
|
+
ledger: { option: "ledger" },
|
|
19
|
+
load: () => import("../phone-harness.js"),
|
|
20
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { KindCapabilities } from "../kinds.js";
|
|
2
|
+
/** A Linux shell: exec, files and processes. */
|
|
3
|
+
export declare const SANDBOX: KindCapabilities;
|
|
4
|
+
/** A Linux desktop: a shell, and the screen, pointer and keys of an X display. */
|
|
5
|
+
export declare const LINUX_DESKTOP: KindCapabilities;
|
|
6
|
+
/** The image every browser computer runs: its vendor's own Chromium. */
|
|
7
|
+
export declare const BROWSER_IMAGE = "chromium";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** A Linux shell: exec, files and processes. */
|
|
2
|
+
export const SANDBOX = { kind: "linux", groups: ["exec", "files", "processes"] };
|
|
3
|
+
/** A Linux desktop: a shell, and the screen, pointer and keys of an X display. */
|
|
4
|
+
export const LINUX_DESKTOP = { kind: "desktop", groups: ["exec", "files", "processes", "screen", "input.pointer", "input.keys"] };
|
|
5
|
+
/** The image every browser computer runs: its vendor's own Chromium. */
|
|
6
|
+
export const BROWSER_IMAGE = "chromium";
|
package/dist/desktop.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComputerClient } from "./protocol.js";
|
|
2
|
-
import { type
|
|
2
|
+
import { type Result } from "./result.js";
|
|
3
3
|
export interface DesktopOptions {
|
|
4
4
|
/** The display the daemon and the X server use, given to the daemon as DISPLAY. Default ":0". */
|
|
5
5
|
display?: string;
|
|
@@ -14,11 +14,11 @@ export declare const DESKTOP_GROUPS: readonly ["screen", "input.pointer", "input
|
|
|
14
14
|
export declare function desktopOf({ display, server, timeoutMs }: DesktopOptions): Required<DesktopOptions>;
|
|
15
15
|
/**
|
|
16
16
|
* Starts the desktop's X server through the daemon (process.start) and waits until hello declares the display: the
|
|
17
|
-
* server ending first, or the bound passing, is a failure in words, with the server's own last words,
|
|
18
|
-
* vendor's
|
|
17
|
+
* server ending first, or the bound passing, is a failure in words, with the server's own last words, as the vendor's
|
|
18
|
+
* (code vendor, vendor the provider's id). version is the client's, sent with each hello.
|
|
19
19
|
*/
|
|
20
20
|
export declare function startDisplay(client: ComputerClient, desktop: Required<DesktopOptions>, { version, vendor, signal }: {
|
|
21
21
|
version: string;
|
|
22
|
-
vendor:
|
|
22
|
+
vendor: string;
|
|
23
23
|
signal?: AbortSignal | undefined;
|
|
24
24
|
}): Promise<Result<void>>;
|
package/dist/desktop.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// The daemon reaches the display once it answers, and hello declares screen, input.pointer and input.keys from then on
|
|
4
4
|
// (hello re-checks the display on each call). Docker's desktops and E2B's start the display this way.
|
|
5
5
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
6
|
-
import { fail, ok } from "./result.js";
|
|
6
|
+
import { fail, ok, vendorFail } from "./result.js";
|
|
7
7
|
/** The groups a desktop declares besides exec, files and processes. */
|
|
8
8
|
export const DESKTOP_GROUPS = ["screen", "input.pointer", "input.keys"];
|
|
9
9
|
const DISPLAY = /^:\d{1,5}(\.\d{1,5})?$/;
|
|
@@ -28,8 +28,8 @@ export function desktopOf({ display = ":0", server, timeoutMs = 30_000 }) {
|
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Starts the desktop's X server through the daemon (process.start) and waits until hello declares the display: the
|
|
31
|
-
* server ending first, or the bound passing, is a failure in words, with the server's own last words,
|
|
32
|
-
* vendor's
|
|
31
|
+
* server ending first, or the bound passing, is a failure in words, with the server's own last words, as the vendor's
|
|
32
|
+
* (code vendor, vendor the provider's id). version is the client's, sent with each hello.
|
|
33
33
|
*/
|
|
34
34
|
export async function startDisplay(client, desktop, { version, vendor, signal }) {
|
|
35
35
|
const server = desktop.server.join(" ");
|
|
@@ -55,7 +55,7 @@ export async function startDisplay(client, desktop, { version, vendor, signal })
|
|
|
55
55
|
const read = await client.call("process.read", { id, stream: "stderr", offset: 0 }, { signal: either });
|
|
56
56
|
const words = read.ok ? Buffer.from(read.value.data, "base64").toString("utf8").trim().split("\n").slice(-5).join("; ") : "";
|
|
57
57
|
const how = waited.value.signal ? `signal ${waited.value.signal}` : `exit code ${waited.value.exitCode}`;
|
|
58
|
-
return
|
|
58
|
+
return vendorFail(vendor, `the X server (${server}) ended with ${how} before the display ${desktop.display} was up${words ? `: ${words}` : ""}`);
|
|
59
59
|
}
|
|
60
60
|
if (timedOut())
|
|
61
61
|
return late();
|
package/dist/docker/egress.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { DockerInspect } from "./inspect.js";
|
|
2
2
|
import type { NetworkPolicy } from "../provider.js";
|
|
3
3
|
/** The proxy container's image: node:22.23.4-bookworm-slim, pinned to its multi-arch index digest (as serve pins its
|
|
4
4
|
* own), so every host runs the same Node. The provider's `egress.image` replaces it. */
|
package/dist/docker/image.js
CHANGED
|
@@ -18,7 +18,9 @@
|
|
|
18
18
|
// recipe's own failing step, or the line Docker could not parse, which the caller wrote.
|
|
19
19
|
import { execFile } from "node:child_process";
|
|
20
20
|
import { createHash } from "node:crypto";
|
|
21
|
-
import {
|
|
21
|
+
import { failFor, ok, vendorFail } from "../result.js";
|
|
22
|
+
/** This module's failures: one with code vendor names Docker. */
|
|
23
|
+
const fail = failFor("docker");
|
|
22
24
|
/** The repository every recipe's image is tagged in. */
|
|
23
25
|
export const IMAGE_REPOSITORY = "agentrun-computer";
|
|
24
26
|
/** The label a recipe's image carries: the recipe's whole sha256. A computer made from the image carries it too. */
|
|
@@ -243,7 +245,7 @@ function labelsOf(stdout) {
|
|
|
243
245
|
/** The failures every docker call shares: no CLI, the bound (in the words given), the last caller gone. */
|
|
244
246
|
function common(docker, answer, timedOut) {
|
|
245
247
|
if (answer.code === "ENOENT")
|
|
246
|
-
return
|
|
248
|
+
return vendorFail("docker", `the docker CLI (${docker}) was not found`);
|
|
247
249
|
if (answer.code === "timeout")
|
|
248
250
|
return fail("timeout", timedOut);
|
|
249
251
|
if (answer.code === "aborted")
|
|
@@ -255,8 +257,8 @@ function inspectFailure(docker, tag, answer, timeoutMs) {
|
|
|
255
257
|
if (shared)
|
|
256
258
|
return shared;
|
|
257
259
|
if (NOT_RUNNING.test(answer.stderr))
|
|
258
|
-
return
|
|
259
|
-
return
|
|
260
|
+
return vendorFail("docker", `Docker did not answer docker image inspect ${tag}: is it running, and may this user reach it?`);
|
|
261
|
+
return vendorFail("docker", `docker image inspect ${tag} failed (${exitOf(answer)}): run it on this machine as this process's user to see why`);
|
|
260
262
|
}
|
|
261
263
|
function buildFailure(docker, source, answer, timeoutMs) {
|
|
262
264
|
const { tag, base } = source;
|
|
@@ -265,26 +267,26 @@ function buildFailure(docker, source, answer, timeoutMs) {
|
|
|
265
267
|
return shared;
|
|
266
268
|
const said = answer.stderr;
|
|
267
269
|
if (/no space left on device/i.test(said))
|
|
268
|
-
return
|
|
270
|
+
return vendorFail("docker", `the build of ${tag} ran out of disk space: free some, then call again`);
|
|
269
271
|
// A base that could not be fetched for want of a network says so in both ways: the network is the cause.
|
|
270
272
|
if (UNREACHABLE.test(said))
|
|
271
|
-
return
|
|
273
|
+
return vendorFail("docker", `the build of ${tag} could not reach the network (it pulls ${base}): call again once this machine can reach it`);
|
|
272
274
|
if (NO_BASE.test(said))
|
|
273
|
-
return
|
|
275
|
+
return vendorFail("docker", `the build of ${tag} could not pull its base, ${base}: name a base the registry has, or pull it on this machine first`);
|
|
274
276
|
if (NO_PACKAGE.test(said))
|
|
275
|
-
return
|
|
277
|
+
return vendorFail("docker", `the recipe of ${tag} names a package its base's package manager could not install: check the names, then call again`);
|
|
276
278
|
const line = PARSE.exec(said)?.[1];
|
|
277
279
|
if (line !== undefined)
|
|
278
|
-
return
|
|
280
|
+
return vendorFail("docker", `Docker could not parse the recipe of ${tag} at line ${line}: fix that line`);
|
|
279
281
|
for (const pattern of STEP) {
|
|
280
282
|
const step = pattern.exec(said);
|
|
281
283
|
if (step === null)
|
|
282
284
|
continue;
|
|
283
285
|
// The step is the recipe's own words, which the caller wrote: the shell's prefix off, BuildKit's quoting undone.
|
|
284
286
|
const command = (step[1] ?? "").replace(/\\(.)/g, "$1").replace(/^\/bin\/sh -c /, "").slice(0, 200);
|
|
285
|
-
return
|
|
287
|
+
return vendorFail("docker", `the recipe of ${tag} failed at the step \`RUN ${command}\` with exit code ${step[2]}: fix that step`);
|
|
286
288
|
}
|
|
287
|
-
return
|
|
289
|
+
return vendorFail("docker", `docker build of ${tag} failed (${exitOf(answer)}): run docker build with the recipe on this machine to see why`);
|
|
288
290
|
}
|
|
289
291
|
function pullFailure(docker, image, answer, timeoutMs) {
|
|
290
292
|
const see = `run docker pull ${image} on this machine to see why`;
|
|
@@ -293,10 +295,10 @@ function pullFailure(docker, image, answer, timeoutMs) {
|
|
|
293
295
|
return shared;
|
|
294
296
|
const said = answer.stderr;
|
|
295
297
|
if (DENIED.test(said))
|
|
296
|
-
return
|
|
298
|
+
return vendorFail("docker", `the registry refused the pull of ${image} (no such repository, or it needs a docker login): ${see}`);
|
|
297
299
|
if (NO_MANIFEST.test(said))
|
|
298
|
-
return
|
|
300
|
+
return vendorFail("docker", `the registry has no ${image}: name an image it has`);
|
|
299
301
|
if (UNREACHABLE.test(said))
|
|
300
|
-
return
|
|
301
|
-
return
|
|
302
|
+
return vendorFail("docker", `the registry could not be reached to pull ${image}: ${see}`);
|
|
303
|
+
return vendorFail("docker", `docker pull ${image} failed (${exitOf(answer)}): ${see}`);
|
|
302
304
|
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { type HelloExpected } from "../drift.js";
|
|
2
|
+
import { type MountReadBack } from "../mount.js";
|
|
3
|
+
import type { HelloResult } from "../protocol.js";
|
|
4
|
+
import type { ComputerSpec, NetworkPolicy, NetworkSpec } from "../provider.js";
|
|
5
|
+
import { type EgressCode } from "./egress.js";
|
|
6
|
+
import { type DockerVolume } from "./volume.js";
|
|
7
|
+
/** With the Docker provider's volume option, where the daemon's staged directory is mounted read-only: its computerd is
|
|
8
|
+
* DAEMON_IN_COMPUTER (stage.ts). */
|
|
9
|
+
export declare const DAEMON_DIR_IN_COMPUTER = "/opt/agentrun";
|
|
10
|
+
/** CPUs are a CFS quota of each 100 ms, as serve gives them: Docker refuses a --cpus above its own CPU count. */
|
|
11
|
+
export declare const CPU_PERIOD_US = 100000;
|
|
12
|
+
/**
|
|
13
|
+
* The --tmpfs options of each tmpfs a computer gets, owned by its uid:gid. A tmpfs's pages count against the
|
|
14
|
+
* computer's memory, so /work holds half of it: a full /work is ENOSPC before the memory limit could OOM-kill a
|
|
15
|
+
* process. /run/agentrun holds only init's socket.
|
|
16
|
+
*/
|
|
17
|
+
export declare function tmpfsOf(user: string, memoryMb: number): Record<string, string>;
|
|
18
|
+
/** The parts of `docker inspect` a computer is checked by; HostConfig and Config are checked whole. */
|
|
19
|
+
export interface DockerInspect {
|
|
20
|
+
Id?: string;
|
|
21
|
+
Name?: string;
|
|
22
|
+
State?: {
|
|
23
|
+
Running?: boolean;
|
|
24
|
+
Status?: string;
|
|
25
|
+
ExitCode?: number;
|
|
26
|
+
Error?: string;
|
|
27
|
+
};
|
|
28
|
+
AppArmorProfile?: string;
|
|
29
|
+
ProcessLabel?: string;
|
|
30
|
+
Config?: {
|
|
31
|
+
User?: string;
|
|
32
|
+
Image?: string;
|
|
33
|
+
WorkingDir?: string;
|
|
34
|
+
Env?: string[] | null;
|
|
35
|
+
Entrypoint?: string[] | null;
|
|
36
|
+
Cmd?: string[] | null;
|
|
37
|
+
Labels?: Record<string, string> | null;
|
|
38
|
+
[field: string]: unknown;
|
|
39
|
+
};
|
|
40
|
+
HostConfig?: {
|
|
41
|
+
NetworkMode?: string;
|
|
42
|
+
CapDrop?: string[] | null;
|
|
43
|
+
CapAdd?: string[] | null;
|
|
44
|
+
Privileged?: boolean;
|
|
45
|
+
SecurityOpt?: string[] | null;
|
|
46
|
+
PidsLimit?: number | null;
|
|
47
|
+
Memory?: number;
|
|
48
|
+
MemorySwap?: number;
|
|
49
|
+
CpuPeriod?: number;
|
|
50
|
+
CpuQuota?: number;
|
|
51
|
+
Tmpfs?: Record<string, string> | null;
|
|
52
|
+
Mounts?: Array<Record<string, unknown>> | null;
|
|
53
|
+
MaskedPaths?: string[] | null;
|
|
54
|
+
ReadonlyPaths?: string[] | null;
|
|
55
|
+
[field: string]: unknown;
|
|
56
|
+
};
|
|
57
|
+
Mounts?: Array<{
|
|
58
|
+
Type?: string;
|
|
59
|
+
Name?: string;
|
|
60
|
+
Source?: string;
|
|
61
|
+
Destination?: string;
|
|
62
|
+
RW?: boolean;
|
|
63
|
+
Propagation?: string;
|
|
64
|
+
}> | null;
|
|
65
|
+
NetworkSettings?: {
|
|
66
|
+
Networks?: Record<string, unknown> | null;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/** What `docker info` reports of the host's enforcement, as the provider reads it. */
|
|
70
|
+
export interface DockerInfo {
|
|
71
|
+
Architecture?: string;
|
|
72
|
+
SecurityOptions?: string[] | null;
|
|
73
|
+
MemoryLimit?: boolean;
|
|
74
|
+
SwapLimit?: boolean;
|
|
75
|
+
PidsLimit?: boolean;
|
|
76
|
+
CPUCfsQuota?: boolean;
|
|
77
|
+
CPUCfsPeriod?: boolean;
|
|
78
|
+
ServerVersion?: string;
|
|
79
|
+
}
|
|
80
|
+
/** A Docker host as the provider reads it: its architecture in Go's names, its security modules, and what it lacks. */
|
|
81
|
+
export interface DockerHost {
|
|
82
|
+
arch: string;
|
|
83
|
+
/** The Docker Engine's major version (docker info's ServerVersion), when it reads as one. */
|
|
84
|
+
engine?: number;
|
|
85
|
+
apparmor: boolean;
|
|
86
|
+
selinux: boolean;
|
|
87
|
+
/** Each enforcement the host lacks, in words; a computer is refused on a host with any. */
|
|
88
|
+
problems: string[];
|
|
89
|
+
/**
|
|
90
|
+
* Present when the host remaps user ids (docker info's name=userns: userns-remap; name=rootless: rootless Docker): a
|
|
91
|
+
* computer's uid is then another uid on the host. No problem for a computer, but a bind of the run folder is refused.
|
|
92
|
+
*/
|
|
93
|
+
remap?: "userns" | "rootless";
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The host's enforcement, from docker info. A computer's sizes are cgroup limits, so a host that does not enforce one
|
|
97
|
+
* makes it configuration only; seccomp is required, since a computer's only syscall filter is Docker's default
|
|
98
|
+
* profile. AppArmor and SELinux are read, not required: a host has the one its distribution ships or neither, and a
|
|
99
|
+
* computer must then carry the profile or label Docker gives every container (the drift check).
|
|
100
|
+
*/
|
|
101
|
+
export declare function hostOf(info: DockerInfo | null | undefined): DockerHost;
|
|
102
|
+
export interface DriftExpected extends HelloExpected {
|
|
103
|
+
/** The daemon file on the host the computer binds, as it was mounted: for DockerProvider, its copy of the daemon. */
|
|
104
|
+
daemonPath: string;
|
|
105
|
+
/** The deadline label's value, as it was set. */
|
|
106
|
+
deadline: string;
|
|
107
|
+
/** The uid:gid the computer was asked to run as. */
|
|
108
|
+
user: string;
|
|
109
|
+
/** Whether the host's Docker gives every container an AppArmor profile, or an SELinux label (hostOf). */
|
|
110
|
+
apparmor: boolean;
|
|
111
|
+
selinux: boolean;
|
|
112
|
+
/** For a computer with an allowlist: its proxy container's inspect (none when it is gone), and where the proxy's code
|
|
113
|
+
* is on the host, as it was bound. */
|
|
114
|
+
proxy?: DockerInspect | null;
|
|
115
|
+
egressCode?: EgressCode;
|
|
116
|
+
/** For a computer with an allowlist: the Docker host's own addresses its proxy must refuse (its --local holds each). */
|
|
117
|
+
hostAddresses?: readonly string[];
|
|
118
|
+
/** The provider's volume option: the daemon and the run's folder are then that volume's subpaths, not binds. */
|
|
119
|
+
volume?: DockerVolume;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* How create mounts a path of this host at `target`: a bind of it, or, with the provider's volume option, the volume's
|
|
123
|
+
* subpath, as HostConfig.Mounts records it (Docker keeps `volume-nocopy` and the subpath under VolumeOptions). Undefined
|
|
124
|
+
* for a path outside the volume, which create never mounts.
|
|
125
|
+
*/
|
|
126
|
+
export declare function mountAsked(path: string, target: string, readonly: boolean, volume: DockerVolume | undefined): Record<string, unknown> | undefined;
|
|
127
|
+
/** Whether a computer's inspect shows any part of an allowlist: the egress volume at its path, or init's relay. */
|
|
128
|
+
export declare function egressShaped(inspected: DockerInspect | null | undefined): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* The network a computer is on, read back from inspect: `none` is network mode none on no network but Docker's own
|
|
131
|
+
* `none`, `open` is the default bridge alone. An allowlist is network mode none with the computer's egress volume
|
|
132
|
+
* mounted read-only at EGRESS_MOUNT and init relaying to its socket, and the list read back from `proxy`, the
|
|
133
|
+
* computer's proxy container's inspect (egressOf: none when it is gone), which must refuse each of `local`, the Docker
|
|
134
|
+
* host's own addresses. Anything else is reported in words, never as a policy it might widen to.
|
|
135
|
+
*/
|
|
136
|
+
export declare function networkOf(inspected: DockerInspect | null | undefined, proxy?: DockerInspect | null, code?: EgressCode, local?: readonly string[]): NetworkPolicy;
|
|
137
|
+
/** Whether a policy read back is the one declared: the same string, or an allowlist with the same entries, normalized. */
|
|
138
|
+
export declare function samePolicy(declared: NetworkSpec, read: NetworkPolicy): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* What is mounted at /workspace, read back from inspect: a read-write bind is the run's folder; nothing is undefined;
|
|
141
|
+
* anything else (read-only, a volume, two mounts) is reported in words, never as a bind it might be.
|
|
142
|
+
*/
|
|
143
|
+
export declare function mountOf(inspected: DockerInspect | null | undefined, volume?: DockerVolume): MountReadBack | undefined;
|
|
144
|
+
/** Every way a created computer differs from its spec, from inspect and hello. */
|
|
145
|
+
export declare function drift(spec: ComputerSpec, inspected: DockerInspect | null | undefined, hello: HelloResult | null | undefined, expected: DriftExpected): string[];
|
|
146
|
+
/** Every way a computer's docker inspect differs from its spec: the fields create asks for, and the closed check. */
|
|
147
|
+
export declare function inspectDrift(spec: ComputerSpec, inspected: DockerInspect | null | undefined, expected: DriftExpected): string[];
|