@parcha/agentrun-computer 0.1.0-beta.34 → 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/README.md +251 -46
- package/box/Dockerfile +3 -1
- package/box/agentrun-archil +59 -7
- package/box/build-daytona.py +20 -4
- package/dist/browser.d.ts +73 -23
- package/dist/browser.js +141 -17
- package/dist/browserbase.d.ts +48 -25
- package/dist/browserbase.js +176 -29
- package/dist/chrome.d.ts +3 -4
- package/dist/chrome.js +6 -11
- 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.d.ts +4 -0
- package/dist/conformance/daytona.js +7 -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 +16 -35
- package/dist/daytona.js +87 -95
- package/dist/descriptor.d.ts +116 -0
- package/dist/descriptor.js +92 -0
- package/dist/descriptors/browserbase.d.ts +25 -0
- package/dist/descriptors/browserbase.js +20 -0
- package/dist/descriptors/daytona.d.ts +83 -0
- package/dist/descriptors/daytona.js +81 -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 +256 -0
- package/dist/descriptors/index.js +19 -0
- package/dist/descriptors/kernel.d.ts +21 -0
- package/dist/descriptors/kernel.js +17 -0
- package/dist/descriptors/local-chrome.d.ts +17 -0
- package/dist/descriptors/local-chrome.js +21 -0
- package/dist/descriptors/modal.d.ts +54 -0
- package/dist/descriptors/modal.js +48 -0
- package/dist/descriptors/orgo.d.ts +99 -0
- package/dist/descriptors/orgo.js +49 -0
- package/dist/descriptors/phone-harness.d.ts +33 -0
- package/dist/descriptors/phone-harness.js +23 -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 +5 -4
- package/dist/docker/egress.js +7 -6
- 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 +53 -47
- package/dist/drift.d.ts +3 -145
- package/dist/drift.js +5 -334
- package/dist/e2b.d.ts +2 -8
- package/dist/e2b.js +17 -23
- package/dist/index.d.ts +9 -12
- package/dist/index.js +14 -12
- package/dist/isolation.js +2 -2
- package/dist/janitor.d.ts +20 -2
- package/dist/janitor.js +67 -19
- package/dist/kernel.d.ts +19 -29
- package/dist/kernel.js +110 -32
- package/dist/kinds.d.ts +59 -34
- package/dist/kinds.js +19 -117
- package/dist/labels.d.ts +20 -0
- package/dist/labels.js +62 -1
- package/dist/{local.d.ts → local-chrome.d.ts} +8 -9
- package/dist/{local.js → local-chrome.js} +26 -19
- package/dist/local-supervisor.d.ts +3 -3
- package/dist/local-supervisor.js +3 -3
- package/dist/modal.d.ts +6 -25
- package/dist/modal.js +86 -88
- package/dist/mount-archil.d.ts +25 -3
- package/dist/mount-archil.js +43 -12
- package/dist/orgo-channel.js +16 -13
- package/dist/orgo-desktop.d.ts +162 -0
- package/dist/orgo-desktop.js +1856 -0
- package/dist/orgo-names.d.ts +178 -0
- package/dist/orgo-names.js +287 -0
- package/dist/orgo.d.ts +34 -20
- package/dist/orgo.js +424 -173
- package/dist/phone-harness.d.ts +7 -12
- package/dist/phone-harness.js +70 -54
- package/dist/protocol.d.ts +5 -0
- package/dist/provider.d.ts +153 -10
- package/dist/provider.js +48 -1
- 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
package/dist/provider.d.ts
CHANGED
|
@@ -5,13 +5,38 @@ import type { ScreenWatch, ScreenWatchHandlers, WatchOptions } from "./screen-wa
|
|
|
5
5
|
export type NetworkSpec = "none" | "open" | {
|
|
6
6
|
allow: string[];
|
|
7
7
|
};
|
|
8
|
-
/** A network's form, as a provider declares the ones it makes (capabilities().network, its
|
|
9
|
-
* NetworkSpec's allowlist. */
|
|
8
|
+
/** A network's form, as a provider declares the ones it makes (capabilities().network, its descriptor's network): "allow"
|
|
9
|
+
* is NetworkSpec's allowlist. */
|
|
10
10
|
export type NetworkForm = "none" | "open" | "allow";
|
|
11
|
+
/** The agent a persistent computer belongs to (spec.owner): it outlives the agent's runs, which take it one at a time. */
|
|
12
|
+
export interface ComputerOwner {
|
|
13
|
+
/** The agent's id: a non-empty string with no NUL byte (ownerProblem). */
|
|
14
|
+
agent: string;
|
|
15
|
+
/**
|
|
16
|
+
* The server the agent is on, where more than one server shares a vendor account: two servers may each have an agent
|
|
17
|
+
* of one id, and each owns its own computer. A non-empty string with no NUL byte. Absent: the agent's id alone.
|
|
18
|
+
*/
|
|
19
|
+
server?: string;
|
|
20
|
+
/** How long the computer may stay detached before the janitor deletes it. Absent: it stays until it is deleted. */
|
|
21
|
+
idleTtlMs?: number;
|
|
22
|
+
}
|
|
23
|
+
/** The claim a run holds a computer under: the run, and the claim's epoch (labels.ts). */
|
|
24
|
+
export interface ComputerClaim {
|
|
25
|
+
run: string;
|
|
26
|
+
epoch: number;
|
|
27
|
+
}
|
|
11
28
|
export interface ComputerSpec {
|
|
12
29
|
image: string;
|
|
13
|
-
/**
|
|
14
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Required for a run's computer: one with no deadline is refused. An agent's computer (owner) has no run deadline and
|
|
32
|
+
* leaves it out (checkTenure).
|
|
33
|
+
*/
|
|
34
|
+
lifetimeMs?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Makes the computer the agent's, persistent across its runs, on a provider that declares persistence; refused in
|
|
37
|
+
* words by any other. It carries the owner's labels (ownerLabels).
|
|
38
|
+
*/
|
|
39
|
+
owner?: ComputerOwner;
|
|
15
40
|
network: NetworkSpec;
|
|
16
41
|
cpus?: number;
|
|
17
42
|
memoryMb?: number;
|
|
@@ -25,6 +50,11 @@ export interface ComputerSpec {
|
|
|
25
50
|
* refuses any other kind before a vendor call. An Archil token is never in a label, a read-back or an error.
|
|
26
51
|
*/
|
|
27
52
|
mount?: MountSpec;
|
|
53
|
+
/**
|
|
54
|
+
* A browser's own options, for a provider whose capabilities().browser declares what they ask; check() refuses, in
|
|
55
|
+
* words and before any vendor call, one it does not declare.
|
|
56
|
+
*/
|
|
57
|
+
browser?: BrowserSpec;
|
|
28
58
|
/**
|
|
29
59
|
* GPUs for the computer: a type the provider declares (capabilities().gpu.types, the vendor's own name, such as Modal's
|
|
30
60
|
* "A100-80GB" or Daytona's "H100") and how many, 1 up to capabilities().gpu.max. check() refuses one the provider does
|
|
@@ -60,6 +90,14 @@ export interface GpuCapability {
|
|
|
60
90
|
};
|
|
61
91
|
/** The mount kinds a GPU computer takes, where fewer than capabilities().mount: none yet proven on its GPU computers. */
|
|
62
92
|
mounts?: MountKind[];
|
|
93
|
+
/**
|
|
94
|
+
* Why a GPU computer takes none of the other mounts, in words naming no field: a fact of the vendor's runtime, or
|
|
95
|
+
* (yet) one not proven there. checkGpu's refusal of a mount gives it, and serve's refusal of the run's folder.
|
|
96
|
+
*/
|
|
97
|
+
unmounted?: {
|
|
98
|
+
why: string;
|
|
99
|
+
yet: boolean;
|
|
100
|
+
};
|
|
63
101
|
/**
|
|
64
102
|
* How init holds a GPU computer's programs off its network, where it is not the plain network namespace: on Modal's
|
|
65
103
|
* gVisor, "userns-netns", one made inside a user namespace, as root there may not make one (measured). The fence holds
|
|
@@ -67,6 +105,38 @@ export interface GpuCapability {
|
|
|
67
105
|
*/
|
|
68
106
|
fence?: NetworkFence;
|
|
69
107
|
}
|
|
108
|
+
/** A browser session's options beside the protocol's. A flag set false asks for nothing, so it is never refused. */
|
|
109
|
+
export interface BrowserSpec {
|
|
110
|
+
viewport?: {
|
|
111
|
+
width: number;
|
|
112
|
+
height: number;
|
|
113
|
+
};
|
|
114
|
+
/** A saved profile the session opens: the pointer profiles.create gave, and whether the session saves back to it. */
|
|
115
|
+
profile?: {
|
|
116
|
+
pointer: string;
|
|
117
|
+
save: boolean;
|
|
118
|
+
};
|
|
119
|
+
/** The vendor's anti-bot mode (Browserbase's Verified browser and its CAPTCHA solver). */
|
|
120
|
+
stealth?: boolean;
|
|
121
|
+
headless?: boolean;
|
|
122
|
+
}
|
|
123
|
+
/** What a browser provider's sessions offer beyond the protocol: each optional feature is there only when declared. */
|
|
124
|
+
export interface BrowserFeatures {
|
|
125
|
+
/** "wall-clock": the vendor ends a session lifetimeMs after create; "inactivity": that long after its last connection closes. */
|
|
126
|
+
timeout: "wall-clock" | "inactivity";
|
|
127
|
+
/** The shortest lifetimeMs a session takes (Kernel's shortest idle timeout); absent, any above 0. */
|
|
128
|
+
minLifetimeMs?: number;
|
|
129
|
+
/** settleMs: how long after a saving session ends the vendor may still be writing the profile back. */
|
|
130
|
+
profiles?: {
|
|
131
|
+
settleMs: number;
|
|
132
|
+
};
|
|
133
|
+
stealth?: true;
|
|
134
|
+
headless?: true;
|
|
135
|
+
/** path: the directory a driver points Browser.setDownloadBehavior at, so the vendor keeps what is saved there. */
|
|
136
|
+
downloads?: {
|
|
137
|
+
path: string;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
70
140
|
/** One kind of allowlist entry a provider takes: how many a list may hold, and the ports an entry opens. */
|
|
71
141
|
export interface AllowRule {
|
|
72
142
|
max: number;
|
|
@@ -91,7 +161,7 @@ export interface ComputerCapabilities {
|
|
|
91
161
|
kind: ComputerKind;
|
|
92
162
|
/** Who ends a computer at its deadline: the vendor, or our janitor by label. */
|
|
93
163
|
lifetime: "vendor" | "janitor";
|
|
94
|
-
/** The network forms it makes: its
|
|
164
|
+
/** The network forms it makes: of its descriptor's network (the forms all its configurations make), its own. */
|
|
95
165
|
network: NetworkForm[];
|
|
96
166
|
/** With network "allow": what an allowlist may hold and which ports it opens. */
|
|
97
167
|
allow?: AllowCapability;
|
|
@@ -126,6 +196,16 @@ export interface ComputerCapabilities {
|
|
|
126
196
|
release: Array<"stop" | "delete">;
|
|
127
197
|
/** The kinds of spec.mount this provider takes: bind (a host folder), archil (a folder of an Archil disk). Absent: none. */
|
|
128
198
|
mount?: MountKind[];
|
|
199
|
+
/**
|
|
200
|
+
* Present when the provider keeps computers for agents (spec.owner): release(ref, "detach") stops one with its state
|
|
201
|
+
* kept, and attach with a claim brings it back. keepsState: its files survive a detach. resume: true when it comes
|
|
202
|
+
* back as it was, its processes running; false when it boots again from its kept disk. Absent: spec.owner and detach
|
|
203
|
+
* are refused in words.
|
|
204
|
+
*/
|
|
205
|
+
persistence?: {
|
|
206
|
+
keepsState: true;
|
|
207
|
+
resume: boolean;
|
|
208
|
+
};
|
|
129
209
|
/**
|
|
130
210
|
* The TCP ports the vendor's own agent listens on inside the computer (Daytona's toolbox 2280, E2B's envd 49983), each
|
|
131
211
|
* the provider's own fact: an agent that runs commands as root or with sudo for whoever reaches it. The computer's
|
|
@@ -136,6 +216,8 @@ export interface ComputerCapabilities {
|
|
|
136
216
|
vendorAgentPorts?: number[];
|
|
137
217
|
/** The GPUs spec.gpu may ask for. Absent: none, and check() refuses any spec.gpu. */
|
|
138
218
|
gpu?: GpuCapability;
|
|
219
|
+
/** With kind browser: what its sessions offer beyond the protocol, which spec.browser asks for. */
|
|
220
|
+
browser?: BrowserFeatures;
|
|
139
221
|
}
|
|
140
222
|
/** The os and daemon modes each kind may have; no other pair is valid. */
|
|
141
223
|
export declare const KIND_SHAPES: Readonly<Record<ComputerKind, {
|
|
@@ -149,6 +231,22 @@ export declare function kindRefusals({ kind, os, daemon }: Pick<ComputerCapabili
|
|
|
149
231
|
* milliseconds above 0, and at most capabilities().maxLifetimeMs.
|
|
150
232
|
*/
|
|
151
233
|
export declare function checkLifetime(lifetimeMs: unknown, { lifetime, maxLifetimeMs }: Pick<ComputerCapabilities, "lifetime" | "maxLifetimeMs">): Refusal[];
|
|
234
|
+
/**
|
|
235
|
+
* A run's computer's lifetime, in a provider's create once check() passed the spec: its lifetimeMs, which
|
|
236
|
+
* checkLifetime requires of every spec with no owner. A spec without one is a caller's mistake past check(): a throw.
|
|
237
|
+
*/
|
|
238
|
+
export declare function runLifetimeMs(spec: Pick<ComputerSpec, "lifetimeMs">): number;
|
|
239
|
+
/** Why owner is not an agent's ownership, in words, or undefined when it is one. */
|
|
240
|
+
export declare function ownerProblem(owner: unknown): string | undefined;
|
|
241
|
+
/**
|
|
242
|
+
* The lifetime rule every provider's check() shares, with no vendor call. A run's computer (no owner) takes
|
|
243
|
+
* checkLifetime. An agent's computer (owner) needs a provider that declares persistence, an owner that is one
|
|
244
|
+
* (ownerProblem), and no lifetimeMs: it has no run deadline.
|
|
245
|
+
*/
|
|
246
|
+
export declare function checkTenure({ lifetimeMs, owner }: {
|
|
247
|
+
lifetimeMs?: unknown;
|
|
248
|
+
owner?: unknown;
|
|
249
|
+
}, capabilities: Pick<ComputerCapabilities, "lifetime" | "maxLifetimeMs" | "persistence">, provider?: string): Refusal[];
|
|
152
250
|
/**
|
|
153
251
|
* The one GPU rule every provider's check() shares, with no vendor call: no spec.gpu is no refusal; one given is an
|
|
154
252
|
* object of a declared type (capabilities().gpu.types) and a whole count from 1 to capabilities().gpu.max; a provider
|
|
@@ -188,6 +286,8 @@ export interface ReadBackSpec {
|
|
|
188
286
|
kind?: ComputerKind;
|
|
189
287
|
/** What is mounted at /workspace, never a token; absent when nothing is. */
|
|
190
288
|
mount?: MountReadBack;
|
|
289
|
+
/** An agent's computer: its owner, read back; absent for a run's computer. */
|
|
290
|
+
owner?: ComputerOwner;
|
|
191
291
|
/** The GPUs the computer was given, as the vendor reports them (Daytona) or as create recorded them (Modal); absent: none. */
|
|
192
292
|
gpu?: GpuSpec;
|
|
193
293
|
}
|
|
@@ -211,16 +311,43 @@ export interface AttachedComputer extends ComputerRef {
|
|
|
211
311
|
export interface ComputerInfo {
|
|
212
312
|
ref: ComputerRef;
|
|
213
313
|
labels: Record<string, string>;
|
|
214
|
-
/** undefined when the deadline label is missing or unreadable: the janitor deletes such a computer. */
|
|
314
|
+
/** undefined when the deadline label is missing or unreadable: the janitor deletes such a run's computer. An agent's has none. */
|
|
215
315
|
deadline: Date | undefined;
|
|
216
316
|
state: "running" | "stopped";
|
|
217
317
|
network: NetworkPolicy;
|
|
218
318
|
/** What is mounted at /workspace, read back, never a token; absent when nothing is. */
|
|
219
319
|
mount?: MountReadBack;
|
|
320
|
+
/**
|
|
321
|
+
* An agent's computer (spec.owner), as the provider knows it, owner label or not: true. The janitor never deletes one
|
|
322
|
+
* by a deadline. A provider whose listing carries the owner label need not set it.
|
|
323
|
+
*/
|
|
324
|
+
owned?: boolean;
|
|
325
|
+
/** An owned computer's owner, when the listing knows it (its labels, or the provider's own record). */
|
|
326
|
+
owner?: ComputerOwner;
|
|
327
|
+
/** An agent's computer that is detached now: when it was detached, the janitor's idle clock. Absent otherwise. */
|
|
328
|
+
detachedAt?: Date;
|
|
220
329
|
}
|
|
221
330
|
export interface CallContext {
|
|
222
331
|
signal?: AbortSignal;
|
|
223
332
|
}
|
|
333
|
+
/** attach's context: with a claim, an agent's computer is brought back and taken by that run, under that epoch. */
|
|
334
|
+
export interface AttachContext extends CallContext {
|
|
335
|
+
claim?: ComputerClaim;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* How release ends or lets go of a computer. stop: stopped and kept, until deleted. delete: gone. detach: an agent's
|
|
339
|
+
* computer stops with its state kept, still the agent's (a provider that declares persistence; refused otherwise).
|
|
340
|
+
*/
|
|
341
|
+
export type ReleaseHow = "stop" | "delete" | "detach";
|
|
342
|
+
/**
|
|
343
|
+
* release's context: with a claim (a provider that declares persistence), a delete of an agent's computer is that claim's
|
|
344
|
+
* alone: done only while the computer still carries exactly the claim's run and epoch and no attach or detach holds it,
|
|
345
|
+
* else refused in words (fenced, or busy) with the computer as it was. So a claim that made the computer and lost it
|
|
346
|
+
* deletes it only where no later claim has taken it. A provider with no persistence has no agent's computer to fence.
|
|
347
|
+
*/
|
|
348
|
+
export interface ReleaseContext extends CallContext {
|
|
349
|
+
claim?: ComputerClaim;
|
|
350
|
+
}
|
|
224
351
|
/** A live connection to a computer's daemon. */
|
|
225
352
|
export interface ComputerConnection {
|
|
226
353
|
client: ComputerClient;
|
|
@@ -244,21 +371,28 @@ export interface ComputerProvider {
|
|
|
244
371
|
}): Promise<Result<CreatedComputer>>;
|
|
245
372
|
/**
|
|
246
373
|
* Finds one computer this provider made, by its id or by labels, with the spec read back from it; none or several is
|
|
247
|
-
* an error in words.
|
|
374
|
+
* an error in words. With context.claim (a provider that declares persistence): the agent's computer is brought back
|
|
375
|
+
* (started, when detached) and taken under the claim, so it carries the claim's run and epoch labels. A claim of the
|
|
376
|
+
* same run below the epoch the computer carries is refused as fenced, and a claim on a run's computer (no owner) is
|
|
377
|
+
* refused; neither changes anything.
|
|
248
378
|
*/
|
|
249
379
|
attach(ref: {
|
|
250
380
|
id: string;
|
|
251
381
|
} | {
|
|
252
382
|
labels: Record<string, string>;
|
|
253
|
-
}, context?:
|
|
383
|
+
}, context?: AttachContext): Promise<Result<AttachedComputer>>;
|
|
254
384
|
/** Every computer this provider made that carries all of these labels: the janitor's view. */
|
|
255
385
|
list(labels: Record<string, string>, context?: CallContext): Promise<Result<ComputerInfo[]>>;
|
|
256
386
|
/** Reads the network back; with a policy, sets it, or refuses in words when it cannot. Never wider than asked. */
|
|
257
387
|
network(ref: ComputerRef, policy?: NetworkSpec, context?: CallContext): Promise<Result<NetworkPolicy>>;
|
|
258
388
|
/** Checks hello against this provider's version, kind and groups, and refuses on a mismatch. */
|
|
259
389
|
connect(ref: ComputerRef): Promise<Result<ComputerConnection>>;
|
|
260
|
-
/**
|
|
261
|
-
|
|
390
|
+
/**
|
|
391
|
+
* Idempotent: a computer already gone is ok. A "stop" capabilities().release does not declare is refused in words. A
|
|
392
|
+
* "detach" is refused in words, the computer as it was, on a provider with no persistence and on a run's computer.
|
|
393
|
+
* context.claim: a delete under that claim alone (ReleaseContext).
|
|
394
|
+
*/
|
|
395
|
+
release(ref: ComputerRef, how: ReleaseHow, context?: ReleaseContext): Promise<Result<void>>;
|
|
262
396
|
/**
|
|
263
397
|
* Sets the deadline to now + ttlMs: never earlier than the current deadline, never past created + maxLifetimeMs. A
|
|
264
398
|
* ttlMs that would move it earlier, or past that cap, is refused in words with the deadline unchanged: an extend
|
|
@@ -302,4 +436,13 @@ export interface ComputerProvider {
|
|
|
302
436
|
testConnection?(context?: CallContext): Promise<Result<{
|
|
303
437
|
detail: string;
|
|
304
438
|
}>>;
|
|
439
|
+
/**
|
|
440
|
+
* The image its computers start from, made ready on its engine before the first create: built from its recipe, or
|
|
441
|
+
* pulled by name, when the engine lacks it; ok with the tag to put in spec.image. `onWait` is told once, before a build
|
|
442
|
+
* or a pull it waits on, never when the image is there. A provider whose descriptor declares prepareImage has it;
|
|
443
|
+
* optional for every other.
|
|
444
|
+
*/
|
|
445
|
+
prepareImage?(context?: CallContext & {
|
|
446
|
+
onWait?: (making: "build" | "pull", tag: string) => void;
|
|
447
|
+
}): Promise<Result<string>>;
|
|
305
448
|
}
|
package/dist/provider.js
CHANGED
|
@@ -35,6 +35,52 @@ export function checkLifetime(lifetimeMs, { lifetime, maxLifetimeMs }) {
|
|
|
35
35
|
}
|
|
36
36
|
return [];
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* A run's computer's lifetime, in a provider's create once check() passed the spec: its lifetimeMs, which
|
|
40
|
+
* checkLifetime requires of every spec with no owner. A spec without one is a caller's mistake past check(): a throw.
|
|
41
|
+
*/
|
|
42
|
+
export function runLifetimeMs(spec) {
|
|
43
|
+
if (spec.lifetimeMs === undefined)
|
|
44
|
+
throw new TypeError("a run's computer needs lifetimeMs: check() refuses a spec with neither lifetimeMs nor owner");
|
|
45
|
+
return spec.lifetimeMs;
|
|
46
|
+
}
|
|
47
|
+
/** Why owner is not an agent's ownership, in words, or undefined when it is one. */
|
|
48
|
+
export function ownerProblem(owner) {
|
|
49
|
+
if (typeof owner !== "object" || owner === null || Array.isArray(owner))
|
|
50
|
+
return "owner is { agent, server?, idleTtlMs? }";
|
|
51
|
+
const { agent, server, idleTtlMs } = owner;
|
|
52
|
+
if (typeof agent !== "string" || agent === "")
|
|
53
|
+
return "owner.agent must be the agent's id, a non-empty string";
|
|
54
|
+
if (agent.includes("\0"))
|
|
55
|
+
return "owner.agent cannot hold a NUL byte: no provider takes one in a label";
|
|
56
|
+
if (server !== undefined && (typeof server !== "string" || server === ""))
|
|
57
|
+
return "owner.server, when given, is the server's id, a non-empty string";
|
|
58
|
+
if (typeof server === "string" && server.includes("\0"))
|
|
59
|
+
return "owner.server cannot hold a NUL byte: no provider takes one in a label";
|
|
60
|
+
if (idleTtlMs !== undefined && !(Number.isSafeInteger(idleTtlMs) && idleTtlMs > 0))
|
|
61
|
+
return `owner.idleTtlMs is a whole number of milliseconds above 0, not ${JSON.stringify(idleTtlMs)}`;
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The lifetime rule every provider's check() shares, with no vendor call. A run's computer (no owner) takes
|
|
66
|
+
* checkLifetime. An agent's computer (owner) needs a provider that declares persistence, an owner that is one
|
|
67
|
+
* (ownerProblem), and no lifetimeMs: it has no run deadline.
|
|
68
|
+
*/
|
|
69
|
+
export function checkTenure({ lifetimeMs, owner }, capabilities, provider = "this") {
|
|
70
|
+
if (owner === undefined)
|
|
71
|
+
return checkLifetime(lifetimeMs, capabilities);
|
|
72
|
+
if (capabilities.persistence === undefined) {
|
|
73
|
+
return [{ field: "owner", message: `the ${provider} provider keeps no computer for an agent (it declares no persistence), so spec.owner is refused: leave it out for a run's computer` }];
|
|
74
|
+
}
|
|
75
|
+
const refusals = [];
|
|
76
|
+
const problem = ownerProblem(owner);
|
|
77
|
+
if (problem !== undefined)
|
|
78
|
+
refusals.push({ field: "owner", message: problem });
|
|
79
|
+
if (lifetimeMs !== undefined) {
|
|
80
|
+
refusals.push({ field: "lifetimeMs", message: "an agent's computer has no run deadline: leave lifetimeMs out (owner.idleTtlMs bounds how long it stays detached)" });
|
|
81
|
+
}
|
|
82
|
+
return refusals;
|
|
83
|
+
}
|
|
38
84
|
/**
|
|
39
85
|
* The one GPU rule every provider's check() shares, with no vendor call: no spec.gpu is no refusal; one given is an
|
|
40
86
|
* object of a declared type (capabilities().gpu.types) and a whole count from 1 to capabilities().gpu.max; a provider
|
|
@@ -59,7 +105,8 @@ export function checkGpu(gpu, { gpu: offered }, mount) {
|
|
|
59
105
|
// A mount that is not an object with a kind (null among them) is checkMount's refusal; nothing is read from it here.
|
|
60
106
|
const kind = typeof mount === "object" && mount !== null ? mount.kind : undefined;
|
|
61
107
|
if (kind !== undefined && offered.mounts !== undefined && !offered.mounts.includes(kind)) {
|
|
62
|
-
|
|
108
|
+
const why = offered.unmounted?.why ?? "it is not proven on this provider's GPU computers yet";
|
|
109
|
+
return refuse(`a GPU computer here takes no ${String(kind)} mount: ${why}; ask for a GPU computer without a mount, or a mount without a GPU`);
|
|
63
110
|
}
|
|
64
111
|
return [];
|
|
65
112
|
}
|
package/dist/providers.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { RunFolder } from "./conformance/types.js";
|
|
2
|
+
import type { ProviderDescriptor } from "./descriptor.js";
|
|
3
|
+
import { DESCRIPTORS } from "./descriptors/index.js";
|
|
2
4
|
import type { KindCapabilities } from "./kinds.js";
|
|
3
5
|
import type { MountKind } from "./mount.js";
|
|
4
|
-
import type { ComputerProvider
|
|
6
|
+
import type { ComputerProvider } from "./provider.js";
|
|
5
7
|
/** Where the conformance side reads its settings: process.env, or a record of the same shape. */
|
|
6
8
|
export type ProviderEnv = Readonly<Record<string, string | undefined>>;
|
|
7
9
|
/**
|
|
@@ -29,11 +31,6 @@ export interface ProviderModule {
|
|
|
29
31
|
* provider binds a local folder from the registry alone, without building one.
|
|
30
32
|
*/
|
|
31
33
|
readonly MOUNT: readonly MountKind[];
|
|
32
|
-
/**
|
|
33
|
-
* The network forms its computers make, the same as its provider's capabilities().network: a caller tells which
|
|
34
|
-
* provider takes an allowlist, or runs only on the vendor's own network, from the registry alone.
|
|
35
|
-
*/
|
|
36
|
-
readonly NETWORK: readonly NetworkForm[];
|
|
37
34
|
/**
|
|
38
35
|
* The machine kind and groups of each configuration it offers, as its built providers' capabilities() declare them:
|
|
39
36
|
* the kind registry's entry for it (PROVIDERS in kinds.ts) holds the same, and derives its setting kinds from them.
|
|
@@ -51,24 +48,26 @@ export interface ProviderModule {
|
|
|
51
48
|
*/
|
|
52
49
|
conformance?(): Promise<ConformanceModule>;
|
|
53
50
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
export declare function
|
|
51
|
+
/** A provider's id: any descriptor's. The built-in ones are BuiltinProviderId. */
|
|
52
|
+
export type ProviderId = string;
|
|
53
|
+
type Builtin = (typeof DESCRIPTORS)[number];
|
|
54
|
+
/** The id of a provider this package holds. */
|
|
55
|
+
export type BuiltinProviderId = Builtin["id"];
|
|
56
|
+
/** Each built-in id's lazy import of its provider module: its descriptor's load(). */
|
|
57
|
+
export declare const providers: { readonly [D in Builtin as D["id"]]: D["load"]; };
|
|
58
|
+
/** The options a built-in id's create() takes. */
|
|
59
|
+
export type ProviderOptions<Id extends BuiltinProviderId> = Parameters<Awaited<ReturnType<Extract<Builtin, {
|
|
60
|
+
id: Id;
|
|
61
|
+
}>["load"]>>["create"]>[0];
|
|
62
|
+
/** Every built-in id, in the registry's order. */
|
|
63
|
+
export declare const providerIds: readonly BuiltinProviderId[];
|
|
64
|
+
/** Whether id names a provider this package holds. */
|
|
65
|
+
export declare function isProviderId(id: string): id is BuiltinProviderId;
|
|
66
|
+
/** A built-in provider's descriptor, or undefined for an id this package does not hold. */
|
|
67
|
+
export declare function descriptorOf(id: string): ProviderDescriptor | undefined;
|
|
71
68
|
/** The provider file's module for an id; an id the registry does not hold is refused, naming the ones it does. */
|
|
72
69
|
export declare function providerModule(id: string): Promise<ProviderModule>;
|
|
73
70
|
/** The provider for an id, built by the provider file's create() from the options given, and nothing else. */
|
|
74
|
-
export declare function providerFor<Id extends
|
|
71
|
+
export declare function providerFor<Id extends BuiltinProviderId>(id: Id, options: ProviderOptions<Id>): Promise<ComputerProvider>;
|
|
72
|
+
export declare function providerFor(id: ProviderId, options: object): Promise<ComputerProvider>;
|
|
73
|
+
export {};
|
package/dist/providers.js
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
kernel: () => import("./kernel.js"),
|
|
8
|
-
local: () => import("./local.js"),
|
|
9
|
-
"phone-harness": () => import("./phone-harness.js"),
|
|
10
|
-
orgo: () => import("./orgo.js"),
|
|
11
|
-
};
|
|
12
|
-
/** Every id, in the registry's order. */
|
|
13
|
-
export const providerIds = Object.keys(providers);
|
|
1
|
+
import { DESCRIPTORS } from "./descriptors/index.js";
|
|
2
|
+
/** Each built-in id's lazy import of its provider module: its descriptor's load(). */
|
|
3
|
+
export const providers = Object.fromEntries(DESCRIPTORS.map((descriptor) => [descriptor.id, descriptor.load]));
|
|
4
|
+
/** Every built-in id, in the registry's order. */
|
|
5
|
+
export const providerIds = DESCRIPTORS.map((descriptor) => descriptor.id);
|
|
6
|
+
/** Whether id names a provider this package holds. */
|
|
14
7
|
export function isProviderId(id) {
|
|
15
8
|
return Object.hasOwn(providers, id);
|
|
16
9
|
}
|
|
10
|
+
/** A built-in provider's descriptor, or undefined for an id this package does not hold. */
|
|
11
|
+
export function descriptorOf(id) {
|
|
12
|
+
return DESCRIPTORS.find((descriptor) => descriptor.id === id);
|
|
13
|
+
}
|
|
17
14
|
/** The provider file's module for an id; an id the registry does not hold is refused, naming the ones it does. */
|
|
18
15
|
export async function providerModule(id) {
|
|
19
|
-
|
|
16
|
+
const descriptor = descriptorOf(id);
|
|
17
|
+
if (descriptor === undefined)
|
|
20
18
|
throw new Error(`unknown computer provider ${JSON.stringify(id)}: the registry holds ${providerIds.join(", ")}`);
|
|
21
|
-
return
|
|
19
|
+
return descriptor.load();
|
|
22
20
|
}
|
|
23
|
-
/** The provider for an id, built by the provider file's create() from the options given, and nothing else. */
|
|
24
21
|
export async function providerFor(id, options) {
|
|
25
|
-
return (await providerModule(id)).create(options);
|
|
22
|
+
return (await providerModule(id)).create(options ?? {});
|
|
26
23
|
}
|
package/dist/result.d.ts
CHANGED
|
@@ -6,10 +6,20 @@ export type Result<T, E = ComputerError> = {
|
|
|
6
6
|
ok: false;
|
|
7
7
|
error: E;
|
|
8
8
|
};
|
|
9
|
-
export type ComputerErrorCode = "gone" | "refused" | "timeout" | "aborted" | "not_found" | "invalid" | "unsupported" | "denied" | "limit" | "exists" | "not_dir" | "is_dir" | "unauthorized" | "unreachable" | "
|
|
9
|
+
export type ComputerErrorCode = "gone" | "refused" | "timeout" | "aborted" | "not_found" | "invalid" | "unsupported" | "denied" | "limit" | "exists" | "not_dir" | "is_dir" | "unauthorized" | "unreachable" | "vendor";
|
|
10
10
|
export interface ComputerError {
|
|
11
11
|
code: ComputerErrorCode;
|
|
12
12
|
message: string;
|
|
13
|
+
/** With code vendor: the provider whose vendor failed (docker, daytona, ...), its descriptor's id. */
|
|
14
|
+
vendor?: string;
|
|
13
15
|
}
|
|
14
16
|
export declare const ok: <T>(value: T) => Result<T, never>;
|
|
15
17
|
export declare const fail: (code: ComputerErrorCode, message: string) => Result<never>;
|
|
18
|
+
/** A failure the vendor answered with: code vendor, the vendor named by its provider's id. */
|
|
19
|
+
export declare const vendorFail: (vendor: string, message: string) => Result<never>;
|
|
20
|
+
/** An error of a code a provider computed: with code vendor, vendor names it. */
|
|
21
|
+
export declare const errorOf: (code: ComputerErrorCode, message: string, vendor: string) => ComputerError;
|
|
22
|
+
/** A provider module's fail: an error with code vendor names `vendor`, the provider's id. */
|
|
23
|
+
export declare const failFor: (vendor: string) => (code: ComputerErrorCode, message: string) => Result<never>;
|
|
24
|
+
/** `error` passed up in new words: its code kept (or `code`), and while the code is vendor, its vendor with it. */
|
|
25
|
+
export declare const failAs: (error: ComputerError, message: string, code?: ComputerErrorCode) => Result<never>;
|
package/dist/result.js
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
1
|
export const ok = (value) => ({ ok: true, value });
|
|
2
2
|
export const fail = (code, message) => ({ ok: false, error: { code, message } });
|
|
3
|
+
/** A failure the vendor answered with: code vendor, the vendor named by its provider's id. */
|
|
4
|
+
export const vendorFail = (vendor, message) => ({ ok: false, error: { code: "vendor", vendor, message } });
|
|
5
|
+
/** An error of a code a provider computed: with code vendor, vendor names it. */
|
|
6
|
+
export const errorOf = (code, message, vendor) => (code === "vendor" ? { code, vendor, message } : { code, message });
|
|
7
|
+
/** A provider module's fail: an error with code vendor names `vendor`, the provider's id. */
|
|
8
|
+
export const failFor = (vendor) => (code, message) => ({ ok: false, error: errorOf(code, message, vendor) });
|
|
9
|
+
/** `error` passed up in new words: its code kept (or `code`), and while the code is vendor, its vendor with it. */
|
|
10
|
+
export const failAs = (error, message, code = error.code) => ({
|
|
11
|
+
ok: false,
|
|
12
|
+
error: code === "vendor" && error.vendor !== undefined ? { code, vendor: error.vendor, message } : { code, message },
|
|
13
|
+
});
|
package/dist/test-connection.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Settings' "test connection" (ComputerProvider.testConnection): what each provider's one account-level read means, in
|
|
2
2
|
// the same words. A key the vendor refused is unauthorized and a vendor not reached in time unreachable; any other
|
|
3
3
|
// error keeps its code. A message is the provider's own, which never carries a key.
|
|
4
|
-
import {
|
|
4
|
+
import { ok } from "./result.js";
|
|
5
5
|
/** An error of the read, as testConnection answers it. */
|
|
6
6
|
export function connectionError(error) {
|
|
7
7
|
if (error.code === "denied")
|
|
@@ -16,7 +16,7 @@ export function connectionError(error) {
|
|
|
16
16
|
*/
|
|
17
17
|
export function countTested(vendor, counted) {
|
|
18
18
|
if (!counted.ok)
|
|
19
|
-
return
|
|
19
|
+
return { ok: false, error: connectionError(counted.error) };
|
|
20
20
|
const { count, more = false } = counted.value;
|
|
21
21
|
return ok({ detail: `${vendor} answered: ${count}${more ? " or more" : ""} ${count === 1 && !more ? "computer" : "computers"} of this provider` });
|
|
22
22
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcha/agentrun-computer",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.36",
|
|
4
4
|
"description": "The open platform's computer protocol: a daemon in every computer, and one provisioner per vendor, starting with Docker.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentrun",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "Parcha Labs, Inc.",
|
|
15
15
|
"engines": {
|
|
16
|
-
"node": ">=24.
|
|
16
|
+
"node": ">=24.22.3"
|
|
17
17
|
},
|
|
18
18
|
"main": "./dist/index.js",
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
@@ -26,6 +26,46 @@
|
|
|
26
26
|
"types": "./dist/mount.d.ts",
|
|
27
27
|
"default": "./dist/mount.js"
|
|
28
28
|
},
|
|
29
|
+
"./docker": {
|
|
30
|
+
"types": "./dist/docker.d.ts",
|
|
31
|
+
"default": "./dist/docker.js"
|
|
32
|
+
},
|
|
33
|
+
"./daytona": {
|
|
34
|
+
"types": "./dist/daytona.d.ts",
|
|
35
|
+
"default": "./dist/daytona.js"
|
|
36
|
+
},
|
|
37
|
+
"./modal": {
|
|
38
|
+
"types": "./dist/modal.d.ts",
|
|
39
|
+
"default": "./dist/modal.js"
|
|
40
|
+
},
|
|
41
|
+
"./e2b": {
|
|
42
|
+
"types": "./dist/e2b.d.ts",
|
|
43
|
+
"default": "./dist/e2b.js"
|
|
44
|
+
},
|
|
45
|
+
"./orgo": {
|
|
46
|
+
"types": "./dist/orgo.d.ts",
|
|
47
|
+
"default": "./dist/orgo.js"
|
|
48
|
+
},
|
|
49
|
+
"./orgo-desktop": {
|
|
50
|
+
"types": "./dist/orgo-desktop.d.ts",
|
|
51
|
+
"default": "./dist/orgo-desktop.js"
|
|
52
|
+
},
|
|
53
|
+
"./phone-harness": {
|
|
54
|
+
"types": "./dist/phone-harness.d.ts",
|
|
55
|
+
"default": "./dist/phone-harness.js"
|
|
56
|
+
},
|
|
57
|
+
"./browserbase": {
|
|
58
|
+
"types": "./dist/browserbase.d.ts",
|
|
59
|
+
"default": "./dist/browserbase.js"
|
|
60
|
+
},
|
|
61
|
+
"./kernel": {
|
|
62
|
+
"types": "./dist/kernel.d.ts",
|
|
63
|
+
"default": "./dist/kernel.js"
|
|
64
|
+
},
|
|
65
|
+
"./local-chrome": {
|
|
66
|
+
"types": "./dist/local-chrome.d.ts",
|
|
67
|
+
"default": "./dist/local-chrome.js"
|
|
68
|
+
},
|
|
29
69
|
"./package.json": "./package.json"
|
|
30
70
|
},
|
|
31
71
|
"files": [
|