@parcha/agentrun-computer 0.1.0-beta.43 → 0.1.0-beta.45
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 +98 -12
- package/box/Dockerfile +2 -1
- package/box/build-daytona.py +12 -2
- package/box/install.sh +19 -5
- package/box/recipe.mjs +1 -1
- package/dist/attach.d.ts +13 -3
- package/dist/attach.js +182 -15
- package/dist/cloudflare.d.ts +4 -2
- package/dist/cloudflare.js +7 -3
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/computerd.json +2 -2
- package/dist/conformance/cases/files.js +7 -1
- package/dist/conformance/cases/isolation.js +4 -0
- package/dist/conformance/cases/mount.js +155 -2
- package/dist/conformance/cases/provider.js +3 -1
- package/dist/conformance/daytona.d.ts +15 -1
- package/dist/conformance/daytona.js +19 -4
- package/dist/conformance/types.d.ts +1 -1
- package/dist/daytona.d.ts +11 -2
- package/dist/daytona.js +47 -15
- package/dist/descriptor.d.ts +34 -4
- package/dist/descriptor.js +40 -6
- package/dist/descriptors/cloudflare.d.ts +14 -1
- package/dist/descriptors/cloudflare.js +7 -3
- package/dist/descriptors/daytona.d.ts +21 -3
- package/dist/descriptors/daytona.js +15 -8
- package/dist/descriptors/e2b.d.ts +1 -0
- package/dist/descriptors/e2b.js +2 -1
- package/dist/descriptors/fly.d.ts +14 -1
- package/dist/descriptors/fly.js +6 -3
- package/dist/descriptors/index.d.ts +64 -2
- package/dist/descriptors/modal.d.ts +16 -2
- package/dist/descriptors/modal.js +10 -6
- package/dist/descriptors/orgo.d.ts +3 -0
- package/dist/descriptors/orgo.js +3 -1
- package/dist/e2b.d.ts +9 -4
- package/dist/e2b.js +8 -8
- package/dist/env-proxy.d.ts +26 -0
- package/dist/env-proxy.js +97 -0
- package/dist/fly.d.ts +4 -3
- package/dist/fly.js +7 -4
- package/dist/hosted/provider.d.ts +2 -1
- package/dist/hosted/provider.js +133 -54
- package/dist/hosted/scripts.d.ts +3 -2
- package/dist/hosted/scripts.js +12 -7
- package/dist/hosted/values.d.ts +2 -5
- package/dist/hosted/values.js +2 -9
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/kinds.d.ts +4 -2
- package/dist/kinds.js +10 -1
- package/dist/modal.d.ts +5 -2
- package/dist/modal.js +8 -2
- package/dist/morph.js +15 -7
- package/dist/mount-archil.d.ts +33 -17
- package/dist/mount-archil.js +83 -36
- package/dist/mount.d.ts +16 -7
- package/dist/mount.js +13 -8
- package/dist/orgo.js +1 -1
- package/dist/provider.d.ts +1 -1
- package/dist/sync-folder.d.ts +82 -0
- package/dist/sync-folder.js +494 -0
- package/dist/tar.d.ts +34 -0
- package/dist/tar.js +203 -0
- package/package.json +1 -1
- package/dist/conformance/tar.d.ts +0 -13
- package/dist/conformance/tar.js +0 -105
package/dist/descriptors/e2b.js
CHANGED
|
@@ -7,8 +7,9 @@ export const E2B = defineProvider({
|
|
|
7
7
|
label: "E2B",
|
|
8
8
|
keys: [{ name: "E2B_API_KEY", option: "apiKey", required: true }],
|
|
9
9
|
// How the server reaches its machines: exec (the provider's default, when the server's settings name none), a bridge
|
|
10
|
-
// through envd per connection, or dial, the machine dials the server (a sandbox
|
|
10
|
+
// through envd per connection, or dial, the machine dials the server (a sandbox or a desktop, as on exec).
|
|
11
11
|
settings: [{ name: "e2bConnect", option: "connect" }],
|
|
12
|
+
connect: "either",
|
|
12
13
|
metered: true,
|
|
13
14
|
mounts: ["archil"],
|
|
14
15
|
// None: its programs run in a network of their own, their loopback alone (isolation.ts), and the sandbox is made with
|
|
@@ -11,9 +11,22 @@ export declare const FLY: {
|
|
|
11
11
|
readonly required: true;
|
|
12
12
|
}];
|
|
13
13
|
readonly metered: true;
|
|
14
|
+
readonly connect: "dial";
|
|
14
15
|
readonly mounts: readonly [];
|
|
15
16
|
readonly network: readonly ["none", "open", "allow"];
|
|
16
|
-
readonly capabilities: readonly [import("../kinds.js").KindCapabilities
|
|
17
|
+
readonly capabilities: readonly [import("../kinds.js").KindCapabilities, {
|
|
18
|
+
readonly options: {
|
|
19
|
+
readonly kind: "desktop";
|
|
20
|
+
};
|
|
21
|
+
readonly kind: import("../protocol.js").ComputerKind;
|
|
22
|
+
readonly groups: import("../protocol.js").Group[];
|
|
23
|
+
readonly gpu?: import("../provider.js").GpuCapability;
|
|
24
|
+
readonly persistence?: {
|
|
25
|
+
keepsState: true;
|
|
26
|
+
resume: boolean;
|
|
27
|
+
};
|
|
28
|
+
readonly image?: string;
|
|
29
|
+
}];
|
|
17
30
|
readonly prepareImage: true;
|
|
18
31
|
readonly load: () => Promise<typeof import("../fly.js")>;
|
|
19
32
|
};
|
package/dist/descriptors/fly.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Its machines dial the server (MachineHost facts.connect "dial"): Fly's exec answers only once the command ends, so
|
|
4
4
|
// nothing reaches into a machine from outside, and its computerd dials the server's attach route instead.
|
|
5
5
|
import { defineProvider } from "../descriptor.js";
|
|
6
|
-
import { SANDBOX } from "./shared.js";
|
|
6
|
+
import { LINUX_DESKTOP, SANDBOX } from "./shared.js";
|
|
7
7
|
export const FLY = defineProvider({
|
|
8
8
|
id: "fly",
|
|
9
9
|
label: "Fly Machines",
|
|
@@ -14,14 +14,17 @@ export const FLY = defineProvider({
|
|
|
14
14
|
{ name: "FLY_APP", option: "app", required: true },
|
|
15
15
|
],
|
|
16
16
|
metered: true,
|
|
17
|
+
// Its machines dial the server: Fly's exec answers only once the command ends, so nothing reaches into one.
|
|
18
|
+
connect: "dial",
|
|
17
19
|
// None: a machine that dials takes no Archil mount yet (its helper's root steps run through exec, which it has none of).
|
|
18
20
|
mounts: [],
|
|
19
21
|
// None: its programs run in init's network of their own, their loopback alone (isolation.ts). Open and a list: their
|
|
20
22
|
// one way out is init's egress proxy, which reaches the public internet alone, and with a list its hosts alone
|
|
21
23
|
// (hosted/network.ts). The machine itself always reaches out: it fetches its daemon from the server and dials it.
|
|
22
24
|
network: ["none", "open", "allow"],
|
|
23
|
-
// A linux computer
|
|
24
|
-
|
|
25
|
+
// A linux computer, or a desktop: the box image's X server and xfwm4, started through computerd over the socket the
|
|
26
|
+
// machine dialed. A desktop's size is the sandbox's, the adapter's default of 2 shared CPUs and 4 GiB (fly.ts).
|
|
27
|
+
capabilities: [SANDBOX, { ...LINUX_DESKTOP, options: { kind: "desktop" } }],
|
|
25
28
|
// No default image: every computer starts from the box image its prepareImage() answers.
|
|
26
29
|
prepareImage: true,
|
|
27
30
|
load: () => import("../fly.js"),
|
|
@@ -55,6 +55,11 @@ export declare const DESCRIPTORS: readonly [{
|
|
|
55
55
|
readonly option: "archilEgress";
|
|
56
56
|
readonly required: false;
|
|
57
57
|
}];
|
|
58
|
+
readonly settings: readonly [{
|
|
59
|
+
readonly name: "daytonaConnect";
|
|
60
|
+
readonly option: "connect";
|
|
61
|
+
}];
|
|
62
|
+
readonly connect: "either";
|
|
58
63
|
readonly metered: true;
|
|
59
64
|
readonly mounts: readonly [];
|
|
60
65
|
readonly unmounted: {
|
|
@@ -74,6 +79,19 @@ export declare const DESCRIPTORS: readonly [{
|
|
|
74
79
|
};
|
|
75
80
|
readonly image?: string;
|
|
76
81
|
readonly options?: Readonly<Record<string, unknown>>;
|
|
82
|
+
}, {
|
|
83
|
+
readonly options: {
|
|
84
|
+
readonly kind: "desktop";
|
|
85
|
+
readonly connect: "dial";
|
|
86
|
+
};
|
|
87
|
+
readonly kind: import("../protocol.js").ComputerKind;
|
|
88
|
+
readonly groups: import("../protocol.js").Group[];
|
|
89
|
+
readonly gpu?: import("../provider.js").GpuCapability;
|
|
90
|
+
readonly persistence?: {
|
|
91
|
+
keepsState: true;
|
|
92
|
+
resume: boolean;
|
|
93
|
+
};
|
|
94
|
+
readonly image?: string;
|
|
77
95
|
}];
|
|
78
96
|
readonly defaultImage: {
|
|
79
97
|
readonly sandbox: "default";
|
|
@@ -100,6 +118,7 @@ export declare const DESCRIPTORS: readonly [{
|
|
|
100
118
|
readonly name: "modalConnect";
|
|
101
119
|
readonly option: "connect";
|
|
102
120
|
}];
|
|
121
|
+
readonly connect: "either";
|
|
103
122
|
readonly metered: true;
|
|
104
123
|
readonly mounts: readonly ["archil"];
|
|
105
124
|
readonly network: readonly ["none", "open", "allow"];
|
|
@@ -113,6 +132,19 @@ export declare const DESCRIPTORS: readonly [{
|
|
|
113
132
|
};
|
|
114
133
|
readonly image?: string;
|
|
115
134
|
readonly options?: Readonly<Record<string, unknown>>;
|
|
135
|
+
}, {
|
|
136
|
+
readonly options: {
|
|
137
|
+
readonly kind: "desktop";
|
|
138
|
+
readonly connect: "dial";
|
|
139
|
+
};
|
|
140
|
+
readonly kind: import("../protocol.js").ComputerKind;
|
|
141
|
+
readonly groups: import("../protocol.js").Group[];
|
|
142
|
+
readonly gpu?: import("../provider.js").GpuCapability;
|
|
143
|
+
readonly persistence?: {
|
|
144
|
+
keepsState: true;
|
|
145
|
+
resume: boolean;
|
|
146
|
+
};
|
|
147
|
+
readonly image?: string;
|
|
116
148
|
}];
|
|
117
149
|
readonly prepareImage: true;
|
|
118
150
|
readonly load: () => Promise<typeof import("../modal.js")>;
|
|
@@ -128,6 +160,7 @@ export declare const DESCRIPTORS: readonly [{
|
|
|
128
160
|
readonly name: "e2bConnect";
|
|
129
161
|
readonly option: "connect";
|
|
130
162
|
}];
|
|
163
|
+
readonly connect: "either";
|
|
131
164
|
readonly metered: true;
|
|
132
165
|
readonly mounts: readonly ["archil"];
|
|
133
166
|
readonly network: readonly ["none", "open", "allow"];
|
|
@@ -191,9 +224,22 @@ export declare const DESCRIPTORS: readonly [{
|
|
|
191
224
|
readonly required: true;
|
|
192
225
|
}];
|
|
193
226
|
readonly metered: true;
|
|
227
|
+
readonly connect: "dial";
|
|
194
228
|
readonly mounts: readonly [];
|
|
195
229
|
readonly network: readonly ["none", "open", "allow"];
|
|
196
|
-
readonly capabilities: readonly [import("../kinds.js").KindCapabilities
|
|
230
|
+
readonly capabilities: readonly [import("../kinds.js").KindCapabilities, {
|
|
231
|
+
readonly options: {
|
|
232
|
+
readonly kind: "desktop";
|
|
233
|
+
};
|
|
234
|
+
readonly kind: import("../protocol.js").ComputerKind;
|
|
235
|
+
readonly groups: import("../protocol.js").Group[];
|
|
236
|
+
readonly gpu?: import("../provider.js").GpuCapability;
|
|
237
|
+
readonly persistence?: {
|
|
238
|
+
keepsState: true;
|
|
239
|
+
resume: boolean;
|
|
240
|
+
};
|
|
241
|
+
readonly image?: string;
|
|
242
|
+
}];
|
|
197
243
|
readonly prepareImage: true;
|
|
198
244
|
readonly load: () => Promise<typeof import("../cloudflare.js")>;
|
|
199
245
|
}, {
|
|
@@ -209,9 +255,22 @@ export declare const DESCRIPTORS: readonly [{
|
|
|
209
255
|
readonly required: true;
|
|
210
256
|
}];
|
|
211
257
|
readonly metered: true;
|
|
258
|
+
readonly connect: "dial";
|
|
212
259
|
readonly mounts: readonly [];
|
|
213
260
|
readonly network: readonly ["none", "open", "allow"];
|
|
214
|
-
readonly capabilities: readonly [import("../kinds.js").KindCapabilities
|
|
261
|
+
readonly capabilities: readonly [import("../kinds.js").KindCapabilities, {
|
|
262
|
+
readonly options: {
|
|
263
|
+
readonly kind: "desktop";
|
|
264
|
+
};
|
|
265
|
+
readonly kind: import("../protocol.js").ComputerKind;
|
|
266
|
+
readonly groups: import("../protocol.js").Group[];
|
|
267
|
+
readonly gpu?: import("../provider.js").GpuCapability;
|
|
268
|
+
readonly persistence?: {
|
|
269
|
+
keepsState: true;
|
|
270
|
+
resume: boolean;
|
|
271
|
+
};
|
|
272
|
+
readonly image?: string;
|
|
273
|
+
}];
|
|
215
274
|
readonly prepareImage: true;
|
|
216
275
|
readonly load: () => Promise<typeof import("../fly.js")>;
|
|
217
276
|
}, {
|
|
@@ -229,6 +288,9 @@ export declare const DESCRIPTORS: readonly [{
|
|
|
229
288
|
}];
|
|
230
289
|
readonly metered: true;
|
|
231
290
|
readonly mounts: readonly [];
|
|
291
|
+
readonly unmounted: {
|
|
292
|
+
readonly sync: "Orgo's provider makes no /workspace for a synced folder yet";
|
|
293
|
+
};
|
|
232
294
|
readonly network: readonly ["none"];
|
|
233
295
|
readonly capabilities: readonly [{
|
|
234
296
|
readonly image: "linux";
|
|
@@ -9,8 +9,8 @@ export declare const MODAL_GPU_TYPES: readonly ["T4", "L4", "A10", "L40S", "A100
|
|
|
9
9
|
export declare const MODAL_GPU_MAX = 8;
|
|
10
10
|
/**
|
|
11
11
|
* The GPUs Modal offers, as capabilities().gpu and its configuration declare them: on gVisor, Modal's one GPU runtime;
|
|
12
|
-
* preemptible, as Modal may end a GPU container to free capacity;
|
|
13
|
-
* being proven on gVisor; and the loopback fence made inside a user namespace, as gVisor's root may not make a network
|
|
12
|
+
* preemptible, as Modal may end a GPU container to free capacity; a synced folder alone, the Archil client's FUSE mount
|
|
13
|
+
* not being proven on gVisor; and the loopback fence made inside a user namespace, as gVisor's root may not make a network
|
|
14
14
|
* namespace itself (a live probe, 11-11: unshare -n refused, unshare -Urn allowed).
|
|
15
15
|
*/
|
|
16
16
|
export declare const MODAL_GPU: Readonly<GpuCapability>;
|
|
@@ -34,6 +34,7 @@ export declare const MODAL: {
|
|
|
34
34
|
readonly name: "modalConnect";
|
|
35
35
|
readonly option: "connect";
|
|
36
36
|
}];
|
|
37
|
+
readonly connect: "either";
|
|
37
38
|
readonly metered: true;
|
|
38
39
|
readonly mounts: readonly ["archil"];
|
|
39
40
|
readonly network: readonly ["none", "open", "allow"];
|
|
@@ -47,6 +48,19 @@ export declare const MODAL: {
|
|
|
47
48
|
};
|
|
48
49
|
readonly image?: string;
|
|
49
50
|
readonly options?: Readonly<Record<string, unknown>>;
|
|
51
|
+
}, {
|
|
52
|
+
readonly options: {
|
|
53
|
+
readonly kind: "desktop";
|
|
54
|
+
readonly connect: "dial";
|
|
55
|
+
};
|
|
56
|
+
readonly kind: import("../protocol.js").ComputerKind;
|
|
57
|
+
readonly groups: import("../protocol.js").Group[];
|
|
58
|
+
readonly gpu?: GpuCapability;
|
|
59
|
+
readonly persistence?: {
|
|
60
|
+
keepsState: true;
|
|
61
|
+
resume: boolean;
|
|
62
|
+
};
|
|
63
|
+
readonly image?: string;
|
|
50
64
|
}];
|
|
51
65
|
readonly prepareImage: true;
|
|
52
66
|
readonly load: () => Promise<typeof import("../modal.js")>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Modal's descriptor: a sandbox in a Modal app, the run's folder on an Archil disk, with GPUs when asked. It starts from
|
|
2
2
|
// our box image, the public registry tag its prepareImage() answers (box-image.ts), which Modal pulls at the first create.
|
|
3
3
|
import { defineProvider } from "../descriptor.js";
|
|
4
|
-
import { SANDBOX } from "./shared.js";
|
|
4
|
+
import { LINUX_DESKTOP, SANDBOX } from "./shared.js";
|
|
5
5
|
/**
|
|
6
6
|
* The GPU types Modal takes, by its own names (guide/gpu, 11-10): "A100" is the 40 GB one, "A100-40GB" its explicit
|
|
7
7
|
* name. Its "H100!" and "B200+" variants (no upgrade to an H200; a B200 or B300) are not offered: what a computer gets
|
|
@@ -12,8 +12,8 @@ export const MODAL_GPU_TYPES = ["T4", "L4", "A10", "L40S", "A100", "A100-40GB",
|
|
|
12
12
|
export const MODAL_GPU_MAX = 8;
|
|
13
13
|
/**
|
|
14
14
|
* The GPUs Modal offers, as capabilities().gpu and its configuration declare them: on gVisor, Modal's one GPU runtime;
|
|
15
|
-
* preemptible, as Modal may end a GPU container to free capacity;
|
|
16
|
-
* being proven on gVisor; and the loopback fence made inside a user namespace, as gVisor's root may not make a network
|
|
15
|
+
* preemptible, as Modal may end a GPU container to free capacity; a synced folder alone, the Archil client's FUSE mount
|
|
16
|
+
* not being proven on gVisor; and the loopback fence made inside a user namespace, as gVisor's root may not make a network
|
|
17
17
|
* namespace itself (a live probe, 11-11: unshare -n refused, unshare -Urn allowed).
|
|
18
18
|
*/
|
|
19
19
|
export const MODAL_GPU = Object.freeze({
|
|
@@ -21,7 +21,7 @@ export const MODAL_GPU = Object.freeze({
|
|
|
21
21
|
max: MODAL_GPU_MAX,
|
|
22
22
|
isolation: "gvisor",
|
|
23
23
|
preemptible: true,
|
|
24
|
-
mounts: [],
|
|
24
|
+
mounts: ["sync"],
|
|
25
25
|
// Its gVisor runtime gives /dev/fuse (modal-6, 11-11: a character device 10:229 that opens), but Archil's FUSE mount
|
|
26
26
|
// under gVisor is not proven safe for the Archil client.
|
|
27
27
|
unmounted: Object.freeze({ why: "Archil's FUSE mount isn't proven on Modal's gVisor runtime (#2279)", yet: true }),
|
|
@@ -41,14 +41,18 @@ export const MODAL = defineProvider({
|
|
|
41
41
|
{ name: "modalApp", option: "app", default: "agentrun" },
|
|
42
42
|
{ name: "modalConnect", option: "connect" },
|
|
43
43
|
],
|
|
44
|
+
connect: "either",
|
|
44
45
|
metered: true,
|
|
45
46
|
mounts: ["archil"],
|
|
46
47
|
// None: its programs run in a network of their own, their loopback alone (isolation.ts), and the sandbox is made with
|
|
47
48
|
// its network blocked. Open and a list: the sandbox's network is not blocked, and its programs' one way out is init's
|
|
48
49
|
// egress proxy, which reaches the public internet alone, and with a list its hosts alone (hosted/network.ts).
|
|
49
50
|
network: ["none", "open", "allow"],
|
|
50
|
-
// A linux computer, with GPUs when asked
|
|
51
|
-
|
|
51
|
+
// A linux computer, with GPUs when asked; or, on connect dial alone, a desktop with none: the box image's X server and
|
|
52
|
+
// xfwm4, started through computerd over the socket the sandbox dialed, at the adapter's default size of 2 CPUs and
|
|
53
|
+
// 4 GiB (modal.ts). The desktop's configuration selects dial itself, whatever modalConnect says: a provider on connect
|
|
54
|
+
// exec refuses kind desktop when it is made.
|
|
55
|
+
capabilities: [{ ...SANDBOX, gpu: MODAL_GPU }, { ...LINUX_DESKTOP, options: { kind: "desktop", connect: "dial" } }],
|
|
52
56
|
// No default image: every computer starts from the box image its prepareImage() answers.
|
|
53
57
|
prepareImage: true,
|
|
54
58
|
load: () => import("../modal.js"),
|
|
@@ -61,6 +61,9 @@ export declare const ORGO: {
|
|
|
61
61
|
}];
|
|
62
62
|
readonly metered: true;
|
|
63
63
|
readonly mounts: readonly [];
|
|
64
|
+
readonly unmounted: {
|
|
65
|
+
readonly sync: "Orgo's provider makes no /workspace for a synced folder yet";
|
|
66
|
+
};
|
|
64
67
|
readonly network: readonly ["none"];
|
|
65
68
|
readonly capabilities: readonly [{
|
|
66
69
|
readonly image: "linux";
|
package/dist/descriptors/orgo.js
CHANGED
|
@@ -37,8 +37,10 @@ export const ORGO = defineProvider({
|
|
|
37
37
|
{ name: "ORGO_WORKSPACE_ID", option: "workspaceId", required: false, picked: true },
|
|
38
38
|
],
|
|
39
39
|
metered: true,
|
|
40
|
-
// None yet: an Archil mount needs an Orgo template that bakes the helper
|
|
40
|
+
// None yet: an Archil mount needs an Orgo template that bakes the helper, and a synced folder a /workspace its create
|
|
41
|
+
// makes, which the shared hosted adapter's does and Orgo's own does not.
|
|
41
42
|
mounts: [],
|
|
43
|
+
unmounted: { sync: "Orgo's provider makes no /workspace for a synced folder yet" },
|
|
42
44
|
// The Linux desktop's: none (computerd holds its programs to loopback). Not open or a list: Orgo's own adapter starts
|
|
43
45
|
// no egress proxy, the one way out of that loopback the shared hosted adapter has (hosted/network.ts).
|
|
44
46
|
network: ["none"],
|
package/dist/e2b.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { type ProxyEnv } from "./env-proxy.js";
|
|
1
2
|
import { HostedProvider, type HostedOptions, type HostedTimeouts } from "./hosted/provider.js";
|
|
2
3
|
import { type Result } from "./result.js";
|
|
3
4
|
/**
|
|
4
|
-
* What every SDK call is given: the key, the domain and the API URL explicitly, and debug false (index.mjs:1126-1152)
|
|
5
|
+
* What every SDK call is given: the key, the domain and the API URL explicitly, and debug false (index.mjs:1126-1152);
|
|
6
|
+
* and the proxy the process installed into Node (env-proxy.ts): the SDK's fetch is its own undici Agent, which the
|
|
7
|
+
* process-wide proxy doesn't reach, and it sends every call, the API's and each sandbox's envd's, through the one `proxy`
|
|
8
|
+
* it is given. So it is given that one unless its NO_PROXY exempts the whole domain (proxyForDomain).
|
|
5
9
|
* The SDK's types below are `import type`: erased at build, so nothing loads the SDK from here and the published types
|
|
6
10
|
* name none of it (the package declares no dependency on e2b).
|
|
7
11
|
*/
|
|
@@ -10,6 +14,7 @@ export interface E2BConnectionOptions {
|
|
|
10
14
|
domain: string;
|
|
11
15
|
apiUrl: string;
|
|
12
16
|
debug: false;
|
|
17
|
+
proxy?: string;
|
|
13
18
|
requestTimeoutMs?: number;
|
|
14
19
|
signal?: AbortSignal;
|
|
15
20
|
}
|
|
@@ -23,7 +28,7 @@ export interface E2BProviderOptions extends Omit<HostedOptions, "maxLifetimeMs">
|
|
|
23
28
|
Sandbox: E2BSandboxClass;
|
|
24
29
|
/** E2B's domain: the API is https://api.<domain>. Default e2b.app. */
|
|
25
30
|
domain?: string;
|
|
26
|
-
/** desktop (default
|
|
31
|
+
/** desktop (default): a template with an X server, started through the daemon; linux: no screen. */
|
|
27
32
|
kind?: "desktop" | "linux";
|
|
28
33
|
/** The longest lifetime check takes: E2B Hobby's 1 h by default, Pro's 24 h at most. */
|
|
29
34
|
maxLifetimeMs?: number;
|
|
@@ -31,7 +36,7 @@ export interface E2BProviderOptions extends Omit<HostedOptions, "maxLifetimeMs">
|
|
|
31
36
|
/**
|
|
32
37
|
* exec (default): the daemon goes in through envd's file API and each connection is a bridge through envd's process
|
|
33
38
|
* stream. dial: create starts the box template's agentrun-dial once, and the machine dials the server (options.dial),
|
|
34
|
-
* which every connection goes over
|
|
39
|
+
* which every connection goes over.
|
|
35
40
|
*/
|
|
36
41
|
connect?: "exec" | "dial";
|
|
37
42
|
}
|
|
@@ -47,7 +52,7 @@ export interface E2BOptions extends Omit<E2BProviderOptions, "Sandbox"> {
|
|
|
47
52
|
export declare function connectionOptions({ apiKey, domain }: {
|
|
48
53
|
apiKey: string;
|
|
49
54
|
domain: string;
|
|
50
|
-
}): E2BConnectionOptions;
|
|
55
|
+
}, env?: ProxyEnv): E2BConnectionOptions;
|
|
51
56
|
/**
|
|
52
57
|
* An E2BProvider from its options alone; it reads no environment but the guard ambientProblem keeps. The key is
|
|
53
58
|
* options.apiKey and nowhere else (serve passes its E2B_API_KEY, the conformance module the key it reads), and the
|
package/dist/e2b.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { boxE2bTemplate } from "./box-image.js";
|
|
2
2
|
import { E2B } from "./descriptors/e2b.js";
|
|
3
3
|
import { DEADLINE_LABEL, show } from "./drift.js";
|
|
4
|
+
import { installedProxy, proxyForDomain } from "./env-proxy.js";
|
|
4
5
|
import { HostError } from "./host.js";
|
|
5
6
|
import { deadlineOf, HostedProvider, isoOf, MAX_LABEL, timeoutsOf } from "./hosted/provider.js";
|
|
6
7
|
import { AGENTRUN_DIAL, hostedCommands, shellLine } from "./hosted/scripts.js";
|
|
7
|
-
import { connectOf
|
|
8
|
+
import { connectOf } from "./descriptor.js";
|
|
9
|
+
import { dateOf, DOMAIN, isWhole, sizeRefusals } from "./hosted/values.js";
|
|
8
10
|
import { PassThrough } from "node:stream";
|
|
9
11
|
import { ok } from "./result.js";
|
|
10
12
|
/** Not a literal, so no type checker or bundler resolves the SDK from this package. */
|
|
11
13
|
const E2B_PACKAGE = "e2b";
|
|
12
14
|
const DEFAULT_DOMAIN = "e2b.app";
|
|
13
15
|
/** The connection options every SDK call is given. Exported for the test that hands them to the real SDK. */
|
|
14
|
-
export function connectionOptions({ apiKey, domain }) {
|
|
15
|
-
|
|
16
|
+
export function connectionOptions({ apiKey, domain }, env = installedProxy()) {
|
|
17
|
+
const proxy = proxyForDomain(domain, env);
|
|
18
|
+
return { apiKey, domain, apiUrl: `https://api.${domain}`, debug: false, ...(proxy ? { proxy: proxy.href } : {}) };
|
|
16
19
|
}
|
|
17
20
|
/**
|
|
18
21
|
* The SDK takes sandboxUrl from E2B_SANDBOX_URL when it is given none (index.mjs:1152, 1183-1185), and no option can
|
|
@@ -396,11 +399,8 @@ export class E2BProvider extends HostedProvider {
|
|
|
396
399
|
// A caller who still names the option is told it is gone, whatever its value: it once let public traffic in.
|
|
397
400
|
if (typeof options === "object" && options !== null && Object.hasOwn(options, "publicStream"))
|
|
398
401
|
throw new Error(PUBLIC);
|
|
399
|
-
const { apiKey, Sandbox, domain = DEFAULT_DOMAIN, kind
|
|
400
|
-
const via = connectOf(
|
|
401
|
-
// A server names connect alone (its e2bConnect setting): on dial the kind is linux unless named, since agentrun-dial
|
|
402
|
-
// starts init with no display; a desktop named on dial is the adapter's refusal.
|
|
403
|
-
const kind = named ?? (via === "dial" ? "linux" : "desktop");
|
|
402
|
+
const { apiKey, Sandbox, domain = DEFAULT_DOMAIN, kind = "desktop", maxLifetimeMs = HOBBY_MAX_MS, connect, ...rest } = options;
|
|
403
|
+
const via = connectOf(E2B, { connect });
|
|
404
404
|
if (typeof apiKey !== "string" || apiKey === "")
|
|
405
405
|
throw new Error("options.apiKey, the E2B API key, is required: the provider reads no environment, so the caller passes it");
|
|
406
406
|
const lacks = ["create", "connect", "getInfo", "setTimeout", "kill", "list"].filter((name) => typeof Sandbox?.[name] !== "function");
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type Socket } from "node:net";
|
|
2
|
+
/** The proxy variables as the process installed them into Node. */
|
|
3
|
+
export type ProxyEnv = Readonly<Record<string, string | undefined>>;
|
|
4
|
+
/**
|
|
5
|
+
* The proxy variables Node's https global agent holds when the process installed a proxy; none when it didn't. Read
|
|
6
|
+
* from the module object at each call: installing replaces https.globalAgent, and a named import keeps the old one.
|
|
7
|
+
*/
|
|
8
|
+
export declare function installedProxy(): ProxyEnv;
|
|
9
|
+
/** The proxy a call to target goes through, or undefined when it goes direct. */
|
|
10
|
+
export declare function proxyFor(target: URL, env?: ProxyEnv): URL | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* The one proxy for a client that sends every call under domain (domain and each name below it) through the same one,
|
|
13
|
+
* as E2B's SDK does: undefined only when NO_PROXY exempts them all ("*", or a .suffix entry covering domain). A list
|
|
14
|
+
* that exempts some of them (api.<domain> alone) leaves the proxy on for all, since the hosts it doesn't exempt may
|
|
15
|
+
* have no other way out.
|
|
16
|
+
*/
|
|
17
|
+
export declare function proxyForDomain(domain: string, env?: ProxyEnv): URL | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* A socket to host:port through proxy's CONNECT tunnel: the socket at once (it is the proxy's), and opened, which
|
|
20
|
+
* resolves once the proxy answered 200 and rejects with the proxy's words otherwise. Bytes after the proxy's answer stay
|
|
21
|
+
* in the socket for its next reader. The proxy's own login, when its URL has one, goes as Proxy-Authorization.
|
|
22
|
+
*/
|
|
23
|
+
export declare function tunnelThrough(proxy: URL, host: string, port: number): {
|
|
24
|
+
socket: Socket;
|
|
25
|
+
opened: Promise<void>;
|
|
26
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// The process's proxy for the two vendor clients Node's own proxy support never reaches: E2B's SDK, whose fetch is its
|
|
2
|
+
// own undici Agent (it takes a `proxy` URL instead), and Morph's SSH gateway, plain TCP to port 22, which rides an HTTP
|
|
3
|
+
// CONNECT tunnel. The library reads no environment (README, Settings): the proxy is the one the process installed into
|
|
4
|
+
// Node, by --use-env-proxy / NODE_USE_ENV_PROXY or http.setGlobalProxyFromEnv (serve calls it,
|
|
5
|
+
// packages/serve/src/env-proxy.ts), which Node keeps as https.globalAgent's proxyEnv and which global fetch, Node's
|
|
6
|
+
// WebSocket and https already use. Nothing installed: no proxy, the path as it was. Its variables are read as Node
|
|
7
|
+
// reads them: https_proxy or HTTPS_PROXY for a TLS target, http_proxy or HTTP_PROXY for a plain one, lowercase first;
|
|
8
|
+
// no_proxy or NO_PROXY lists the hosts that go direct (a host, host:port, .suffix, *.suffix, or * for all), and so
|
|
9
|
+
// does this machine's loopback, always.
|
|
10
|
+
import https from "node:https";
|
|
11
|
+
import { connect as tcp } from "node:net";
|
|
12
|
+
import { connect as tls } from "node:tls";
|
|
13
|
+
const LOOPBACK = /^(?:localhost|127(?:\.\d{1,3}){3}|\[::1\]|::1)$/;
|
|
14
|
+
/** The most a proxy's answer to CONNECT may hold before its headers end; more is refused. */
|
|
15
|
+
const MAX_ANSWER_BYTES = 16 * 1024;
|
|
16
|
+
/**
|
|
17
|
+
* The proxy variables Node's https global agent holds when the process installed a proxy; none when it didn't. Read
|
|
18
|
+
* from the module object at each call: installing replaces https.globalAgent, and a named import keeps the old one.
|
|
19
|
+
*/
|
|
20
|
+
export function installedProxy() {
|
|
21
|
+
return https.globalAgent.options?.proxyEnv ?? {};
|
|
22
|
+
}
|
|
23
|
+
/** The proxy URL the variables name for a TLS target, or a plain one. */
|
|
24
|
+
const proxyOf = (secure, env) => {
|
|
25
|
+
const given = secure ? env.https_proxy || env.HTTPS_PROXY : env.http_proxy || env.HTTP_PROXY;
|
|
26
|
+
return given && URL.canParse(given) ? new URL(given) : undefined;
|
|
27
|
+
};
|
|
28
|
+
/** NO_PROXY's entries, lowercase. */
|
|
29
|
+
const noProxy = (env) => (env.no_proxy || env.NO_PROXY || "").split(",").map((entry) => entry.trim().toLowerCase());
|
|
30
|
+
/** Whether a .suffix or *.suffix entry covers host (the suffix's own name included). */
|
|
31
|
+
const covers = (entry, host) => {
|
|
32
|
+
const suffix = entry.startsWith("*.") ? entry.slice(1) : entry.startsWith(".") ? entry : undefined;
|
|
33
|
+
return suffix !== undefined && (host.endsWith(suffix) || host === suffix.slice(1));
|
|
34
|
+
};
|
|
35
|
+
/** The proxy a call to target goes through, or undefined when it goes direct. */
|
|
36
|
+
export function proxyFor(target, env = installedProxy()) {
|
|
37
|
+
const secure = target.protocol === "https:" || target.protocol === "wss:";
|
|
38
|
+
const host = target.hostname.toLowerCase();
|
|
39
|
+
const hostPort = `${host}:${target.port || (secure ? "443" : "80")}`;
|
|
40
|
+
if (LOOPBACK.test(host) || noProxy(env).some((entry) => entry === "*" || entry === host || entry === hostPort || covers(entry, host)))
|
|
41
|
+
return undefined;
|
|
42
|
+
return proxyOf(secure, env);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The one proxy for a client that sends every call under domain (domain and each name below it) through the same one,
|
|
46
|
+
* as E2B's SDK does: undefined only when NO_PROXY exempts them all ("*", or a .suffix entry covering domain). A list
|
|
47
|
+
* that exempts some of them (api.<domain> alone) leaves the proxy on for all, since the hosts it doesn't exempt may
|
|
48
|
+
* have no other way out.
|
|
49
|
+
*/
|
|
50
|
+
export function proxyForDomain(domain, env = installedProxy()) {
|
|
51
|
+
const host = domain.toLowerCase();
|
|
52
|
+
if (LOOPBACK.test(host) || noProxy(env).some((entry) => entry === "*" || covers(entry, host)))
|
|
53
|
+
return undefined;
|
|
54
|
+
return proxyOf(true, env);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A socket to host:port through proxy's CONNECT tunnel: the socket at once (it is the proxy's), and opened, which
|
|
58
|
+
* resolves once the proxy answered 200 and rejects with the proxy's words otherwise. Bytes after the proxy's answer stay
|
|
59
|
+
* in the socket for its next reader. The proxy's own login, when its URL has one, goes as Proxy-Authorization.
|
|
60
|
+
*/
|
|
61
|
+
export function tunnelThrough(proxy, host, port) {
|
|
62
|
+
const proxyHost = proxy.hostname.replace(/^\[|\]$/g, "");
|
|
63
|
+
const proxyPort = Number(proxy.port) || (proxy.protocol === "https:" ? 443 : 80);
|
|
64
|
+
const socket = proxy.protocol === "https:" ? tls({ host: proxyHost, port: proxyPort, servername: proxyHost }) : tcp(proxyPort, proxyHost);
|
|
65
|
+
const login = proxy.username ? `Proxy-Authorization: Basic ${Buffer.from(`${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`).toString("base64")}\r\n` : "";
|
|
66
|
+
const opened = new Promise((resolve, reject) => {
|
|
67
|
+
let head = Buffer.alloc(0);
|
|
68
|
+
const settle = (error) => {
|
|
69
|
+
socket.off("readable", read).off("error", settle).off("end", ended);
|
|
70
|
+
if (error === undefined)
|
|
71
|
+
return resolve();
|
|
72
|
+
socket.destroy();
|
|
73
|
+
reject(error);
|
|
74
|
+
};
|
|
75
|
+
const ended = () => settle(new Error(`the proxy ${proxy.host} closed the connection before it answered CONNECT ${host}:${port}`));
|
|
76
|
+
const read = () => {
|
|
77
|
+
for (let chunk; (chunk = socket.read()) !== null;) {
|
|
78
|
+
head = Buffer.concat([head, chunk]);
|
|
79
|
+
const end = head.indexOf("\r\n\r\n");
|
|
80
|
+
if (end < 0 && head.length > MAX_ANSWER_BYTES)
|
|
81
|
+
return settle(new Error(`the proxy ${proxy.host} answered CONNECT ${host}:${port} with more than ${MAX_ANSWER_BYTES} bytes and no end of its headers`));
|
|
82
|
+
if (end < 0)
|
|
83
|
+
continue;
|
|
84
|
+
const status = /^HTTP\/1\.[01] (\d{3})/.exec(head.subarray(0, end).toString("latin1"))?.[1];
|
|
85
|
+
if (status !== "200")
|
|
86
|
+
return settle(new Error(`the proxy ${proxy.host} answered ${status ?? "no HTTP status"} to CONNECT ${host}:${port}`));
|
|
87
|
+
settle();
|
|
88
|
+
if (end + 4 < head.length)
|
|
89
|
+
socket.unshift(head.subarray(end + 4));
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
socket.once(proxy.protocol === "https:" ? "secureConnect" : "connect", () => socket.write(`CONNECT ${host}:${port} HTTP/1.1\r\nHost: ${host}:${port}\r\n${login}\r\n`));
|
|
94
|
+
socket.on("readable", read).on("error", settle).on("end", ended);
|
|
95
|
+
});
|
|
96
|
+
return { socket, opened };
|
|
97
|
+
}
|
package/dist/fly.d.ts
CHANGED
|
@@ -13,8 +13,8 @@ export interface FlyMachine {
|
|
|
13
13
|
metadata?: Record<string, string> | null;
|
|
14
14
|
} | null;
|
|
15
15
|
}
|
|
16
|
-
/** The Fly provider's options: the token and the app, then the shared adapter's (HostedOptions). */
|
|
17
|
-
export interface FlyProviderOptions extends Omit<HostedOptions, "
|
|
16
|
+
/** The Fly provider's options: the token and the app, then the shared adapter's (HostedOptions), kind among them. */
|
|
17
|
+
export interface FlyProviderOptions extends Omit<HostedOptions, "desktop" | "maxLifetimeMs"> {
|
|
18
18
|
/** A Fly API token that may make machines in the app. The caller passes it; this provider reads no environment. */
|
|
19
19
|
apiToken: string;
|
|
20
20
|
/** The Fly app the machines live in, made by the operator beforehand (fly apps create). */
|
|
@@ -31,7 +31,8 @@ export declare function create(options: FlyProviderOptions): FlyProvider;
|
|
|
31
31
|
export declare const conformance: () => Promise<typeof import("./conformance/fly.js")>;
|
|
32
32
|
/**
|
|
33
33
|
* Computers that are Fly Machines, on the shared adapter, each dialing the server that made it: a server with no public
|
|
34
|
-
* https address (AGENTRUN_PUBLIC_URL) refuses a create in words before Fly is called. Kind linux
|
|
34
|
+
* https address (AGENTRUN_PUBLIC_URL) refuses a create in words before Fly is called. Kind linux (default) or desktop,
|
|
35
|
+
* whose X server and window manager start through computerd over the socket the machine dialed.
|
|
35
36
|
*/
|
|
36
37
|
export declare class FlyProvider extends HostedProvider {
|
|
37
38
|
/**
|
package/dist/fly.js
CHANGED
|
@@ -101,9 +101,11 @@ class FlyHost {
|
|
|
101
101
|
// Unverified: Fly's init runs hallpass, the SSH server `fly ssh console` reaches, on port 22 of the machine's private
|
|
102
102
|
// address. Declared, so isolation.vendor-agent checks the computer's programs reach none of it.
|
|
103
103
|
vendorAgentPorts: [22],
|
|
104
|
+
// The box image has xfwm4 (box/install.sh's desktop step): a desktop's apps are framed and focused.
|
|
105
|
+
windowManager: true,
|
|
104
106
|
// The machine dials the server: Fly's exec answers once the command ends (docs.machines.dev, Machines_exec), so
|
|
105
|
-
// there is no exec and no upload here.
|
|
106
|
-
connect:
|
|
107
|
+
// there is no exec and no upload here. Its descriptor's (connectOf).
|
|
108
|
+
connect: FLY.connect,
|
|
107
109
|
};
|
|
108
110
|
#client;
|
|
109
111
|
#app;
|
|
@@ -222,7 +224,8 @@ export function create(options) {
|
|
|
222
224
|
export const conformance = () => import("./conformance/fly.js");
|
|
223
225
|
/**
|
|
224
226
|
* Computers that are Fly Machines, on the shared adapter, each dialing the server that made it: a server with no public
|
|
225
|
-
* https address (AGENTRUN_PUBLIC_URL) refuses a create in words before Fly is called. Kind linux
|
|
227
|
+
* https address (AGENTRUN_PUBLIC_URL) refuses a create in words before Fly is called. Kind linux (default) or desktop,
|
|
228
|
+
* whose X server and window manager start through computerd over the socket the machine dialed.
|
|
226
229
|
*/
|
|
227
230
|
export class FlyProvider extends HostedProvider {
|
|
228
231
|
/**
|
|
@@ -240,6 +243,6 @@ export class FlyProvider extends HostedProvider {
|
|
|
240
243
|
throw new Error(`options.app is the name of the Fly app its machines live in (lowercase letters, digits and hyphens), not ${JSON.stringify(app)}`);
|
|
241
244
|
if (typeof fetcher !== "function")
|
|
242
245
|
throw new Error("options.fetch must be a function, as the global fetch is");
|
|
243
|
-
super(new FlyHost({ apiToken, app, fetch: fetcher }), { ...rest,
|
|
246
|
+
super(new FlyHost({ apiToken, app, fetch: fetcher }), { ...rest, timeouts: { ...FLY_TIMEOUTS, ...timeouts } });
|
|
244
247
|
}
|
|
245
248
|
}
|
|
@@ -66,7 +66,8 @@ export interface HostedOptions {
|
|
|
66
66
|
* Given to the helper's mount and revoke. Unset or empty, the client reaches Archil as the machine's network allows.
|
|
67
67
|
*/
|
|
68
68
|
archilEgress?: string;
|
|
69
|
-
/** What a host whose facts.connect is "dial" needs: create refuses without it, before any call to the vendor
|
|
69
|
+
/** What a host whose facts.connect is "dial" needs: create refuses without it, before any call to the vendor, in words
|
|
70
|
+
* that name serve's one-process start (a runner apart from the server has none). */
|
|
70
71
|
dial?: HostedDial;
|
|
71
72
|
}
|
|
72
73
|
/** The server a dial host's machines reach, and what it holds of them (MachineHost facts.connect "dial"). */
|