@parcha/agentrun-computer 0.1.0-beta.36 → 0.1.0-beta.38
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/NOTICE +2 -0
- package/README.md +547 -478
- package/box/Dockerfile +18 -1
- package/box/README.md +13 -0
- package/box/build-agent37.mjs +158 -0
- package/box/build-daytona.py +2 -2
- package/box/build-e2b.mjs +41 -18
- package/box/recipe.mjs +43 -0
- package/dist/agent37-ssh.d.ts +89 -0
- package/dist/agent37-ssh.js +445 -0
- package/dist/agent37.d.ts +104 -0
- package/dist/agent37.js +402 -0
- package/dist/attach.d.ts +146 -0
- package/dist/attach.js +469 -0
- package/dist/browserbase.d.ts +2 -10
- package/dist/browserbase.js +3 -6
- package/dist/client.d.ts +45 -4
- package/dist/client.js +92 -4
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/computerd.json +4 -0
- package/dist/conformance/agent37.d.ts +96 -0
- package/dist/conformance/agent37.js +154 -0
- package/dist/conformance/cases/apps.d.ts +11 -0
- package/dist/conformance/cases/apps.js +173 -73
- package/dist/conformance/cases/health.js +14 -0
- package/dist/conformance/cases/index.js +2 -0
- package/dist/conformance/cases/isolation.d.ts +7 -5
- package/dist/conformance/cases/isolation.js +44 -14
- package/dist/conformance/cases/mount.js +1 -1
- package/dist/conformance/cases/provider.js +27 -1
- package/dist/conformance/cases/screen.d.ts +3 -0
- package/dist/conformance/cases/screen.js +18 -0
- package/dist/conformance/cases/settings.d.ts +29 -23
- package/dist/conformance/cases/settings.js +76 -58
- package/dist/conformance/cases/touch.js +19 -17
- package/dist/conformance/cases/ui.d.ts +2 -0
- package/dist/conformance/cases/ui.js +475 -0
- package/dist/conformance/cli.d.ts +9 -0
- package/dist/conformance/cli.js +94 -9
- package/dist/conformance/daytona.d.ts +9 -20
- package/dist/conformance/daytona.js +12 -21
- package/dist/conformance/e2b.d.ts +6 -0
- package/dist/conformance/e2b.js +9 -2
- package/dist/conformance/exec-stream.d.ts +45 -0
- package/dist/conformance/exec-stream.js +486 -0
- package/dist/conformance/fixture.d.ts +1 -1
- package/dist/conformance/fixture.js +25 -1
- package/dist/conformance/modal.d.ts +17 -13
- package/dist/conformance/modal.js +18 -9
- package/dist/conformance/orgo.d.ts +3 -3
- package/dist/conformance/orgo.js +6 -8
- package/dist/conformance/phone-harness.d.ts +6 -2
- package/dist/conformance/phone-harness.js +21 -4
- package/dist/conformance/report.js +1 -1
- package/dist/conformance/runner.js +23 -4
- package/dist/conformance/sweep.d.ts +50 -0
- package/dist/conformance/sweep.js +187 -0
- package/dist/conformance/types.d.ts +13 -5
- package/dist/conformance/ui-fixture.d.ts +56 -0
- package/dist/conformance/ui-fixture.js +43 -0
- package/dist/create-requests.d.ts +51 -0
- package/dist/create-requests.js +121 -0
- package/dist/daytona.d.ts +20 -133
- package/dist/daytona.js +405 -1449
- package/dist/descriptor.d.ts +11 -1
- package/dist/descriptor.js +9 -0
- package/dist/descriptors/agent37.d.ts +41 -0
- package/dist/descriptors/agent37.js +28 -0
- package/dist/descriptors/daytona.d.ts +6 -5
- package/dist/descriptors/daytona.js +9 -5
- package/dist/descriptors/index.d.ts +42 -7
- package/dist/descriptors/index.js +4 -2
- package/dist/descriptors/orgo.d.ts +2 -1
- package/dist/descriptors/orgo.js +3 -2
- package/dist/descriptors/phone-harness.d.ts +1 -1
- package/dist/descriptors/phone-harness.js +2 -2
- package/dist/descriptors/shared.d.ts +1 -1
- package/dist/descriptors/shared.js +2 -2
- package/dist/desktop.d.ts +18 -4
- package/dist/desktop.js +89 -9
- package/dist/docker.d.ts +7 -10
- package/dist/docker.js +272 -34
- package/dist/drift.js +4 -4
- package/dist/e2b.d.ts +16 -290
- package/dist/e2b.js +230 -1393
- package/dist/fake-ui-driver.d.ts +97 -0
- package/dist/fake-ui-driver.js +717 -0
- package/dist/host.d.ts +201 -0
- package/dist/host.js +8 -0
- package/dist/hosted/process.d.ts +81 -0
- package/dist/hosted/process.js +259 -0
- package/dist/hosted/provider.d.ts +160 -0
- package/dist/hosted/provider.js +1415 -0
- package/dist/hosted/rest.d.ts +66 -0
- package/dist/hosted/rest.js +121 -0
- package/dist/hosted/scripts.d.ts +82 -0
- package/dist/{child.js → hosted/scripts.js} +118 -12
- package/dist/hosted/values.d.ts +5 -0
- package/dist/hosted/values.js +8 -0
- package/dist/index.d.ts +7 -3
- package/dist/index.js +7 -4
- package/dist/kernel.d.ts +2 -10
- package/dist/kernel.js +3 -6
- package/dist/kinds.d.ts +11 -2
- package/dist/kinds.js +20 -4
- package/dist/local-chrome.d.ts +2 -10
- package/dist/local-chrome.js +3 -6
- package/dist/modal.d.ts +22 -257
- package/dist/modal.js +183 -1280
- package/dist/mount-archil.d.ts +8 -4
- package/dist/mount-archil.js +22 -11
- package/dist/mount.d.ts +10 -4
- package/dist/mount.js +8 -4
- package/dist/orgo-channel.d.ts +3 -2
- package/dist/orgo-channel.js +5 -2
- package/dist/orgo-desktop.d.ts +9 -4
- package/dist/orgo-desktop.js +33 -13
- package/dist/orgo-workspaces.d.ts +47 -0
- package/dist/orgo-workspaces.js +94 -0
- package/dist/orgo.d.ts +10 -13
- package/dist/orgo.js +32 -21
- package/dist/phone-harness.d.ts +31 -28
- package/dist/phone-harness.js +510 -702
- package/dist/png.d.ts +4 -0
- package/dist/png.js +27 -0
- package/dist/protocol.d.ts +339 -33
- package/dist/protocol.js +97 -3
- package/dist/provider.d.ts +36 -8
- package/dist/provider.js +16 -0
- package/dist/providers.d.ts +11 -12
- package/dist/result.d.ts +1 -1
- package/dist/screen-watch.js +34 -6
- package/dist/surface/api.d.ts +260 -0
- package/dist/surface/api.js +1 -0
- package/dist/surface/core.d.ts +55 -0
- package/dist/surface/core.js +475 -0
- package/dist/surface/index.d.ts +5 -0
- package/dist/surface/index.js +3 -0
- package/dist/surface/outline.d.ts +10 -0
- package/dist/surface/outline.js +51 -0
- package/dist/surface/script.d.ts +10 -0
- package/dist/surface/script.js +94 -0
- package/dist/ui-engine.d.ts +114 -0
- package/dist/ui-engine.js +814 -0
- package/package.json +18 -3
- package/dist/child.d.ts +0 -42
- package/dist/conformance/daytona-sweep.d.ts +0 -18
- package/dist/conformance/daytona-sweep.js +0 -126
- package/dist/conformance/e2b-diagnose.d.ts +0 -16
- package/dist/conformance/e2b-diagnose.js +0 -61
- package/dist/conformance/e2b-sweep.d.ts +0 -18
- package/dist/conformance/e2b-sweep.js +0 -132
- package/dist/conformance/modal-sweep.d.ts +0 -22
- package/dist/conformance/modal-sweep.js +0 -213
package/dist/mount-archil.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export declare const ARCHIL_TOOL_UID = 2510;
|
|
|
13
13
|
export declare const ARCHIL_SYNC_SOCKET = "/run/agentrun-archil/archil.sock";
|
|
14
14
|
/** The archil client the image pins, the version the live checks ran. */
|
|
15
15
|
export declare const ARCHIL_VERSION = "0.10.1-1793222256";
|
|
16
|
-
/** The label (Daytona) or metadata (E2B) an Archil computer carries its mount in:
|
|
16
|
+
/** The label (Daytona) or metadata (E2B) an Archil computer carries its mount in: never the token (archilLabels). */
|
|
17
17
|
export declare const ARCHIL_MOUNT_LABEL = "agentrun.mount";
|
|
18
18
|
/** An Archil mount, as a spec gives it. */
|
|
19
19
|
export type ArchilMount = Extract<MountSpec, {
|
|
@@ -118,14 +118,18 @@ export declare function archilMount({ root, mount, self: computer, releaseOlder,
|
|
|
118
118
|
* process.start, which makes its log and the folders above it; process.write and signal; a process seen
|
|
119
119
|
* ended, by process.wait or a process.read that says so) syncs before it answers, through mount.sync, coalesced: a
|
|
120
120
|
* call during a sync in flight waits for it, then shares one more. A failed sync fails the call in words; a call that
|
|
121
|
-
* failed still syncs, and answers its own error
|
|
121
|
+
* failed still syncs, and answers its own error (one the client timed out with no answer from the daemon does so at
|
|
122
|
+
* once, not waiting for the sync, which rides the same transport; a timeout the daemon answered waits). A caller whose signal fires stops waiting, answered "aborted" in words
|
|
122
123
|
* (or its own error), while the shared sync goes on for every other caller. A tar.push.begin answered with such an error
|
|
123
124
|
* instead of its id first ends the push it began, so no push slot is held by a push its caller cannot name.
|
|
124
125
|
*/
|
|
125
126
|
export declare function syncingClient(client: ComputerClient): ComputerClient;
|
|
126
|
-
/**
|
|
127
|
+
/**
|
|
128
|
+
* The label an Archil computer carries its mount in: kind, disk, region and the folder's agent as JSON, never the token.
|
|
129
|
+
* The folder's run is the computer's agentrun.run label (check holds them equal), so the label does not repeat it.
|
|
130
|
+
*/
|
|
127
131
|
export declare function archilLabels(mount: ArchilMount): Record<string, string>;
|
|
128
|
-
/** The mount a computer's
|
|
132
|
+
/** The mount a computer's labels record, its folder from the agent and agentrun.run; undefined when there is none, or it is not one. */
|
|
129
133
|
export declare function recordedMount(labels: Record<string, string> | undefined): Omit<ArchilMount, "token"> | undefined;
|
|
130
134
|
/**
|
|
131
135
|
* What is mounted at /workspace, read back from the computer's mount table (`mounts`, its /proc/self/mounts): an Archil
|
package/dist/mount-archil.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
// a read-back or an error. Whatever a computer prints is scrubbed of it before it reaches an error's words.
|
|
10
10
|
import { createHash } from "node:crypto";
|
|
11
11
|
import { readFileSync } from "node:fs";
|
|
12
|
+
import { unanswered } from "./client.js";
|
|
12
13
|
import { EPOCH_LABEL, epochOf, RUN_LABEL, runProblem } from "./labels.js";
|
|
13
14
|
import { readBackOf, WORKSPACE } from "./mount.js";
|
|
14
15
|
import { fail, failAs, ok } from "./result.js";
|
|
@@ -23,7 +24,7 @@ export const ARCHIL_TOOL_UID = 2510;
|
|
|
23
24
|
export const ARCHIL_SYNC_SOCKET = "/run/agentrun-archil/archil.sock";
|
|
24
25
|
/** The archil client the image pins, the version the live checks ran. */
|
|
25
26
|
export const ARCHIL_VERSION = "0.10.1-1793222256";
|
|
26
|
-
/** The label (Daytona) or metadata (E2B) an Archil computer carries its mount in:
|
|
27
|
+
/** The label (Daytona) or metadata (E2B) an Archil computer carries its mount in: never the token (archilLabels). */
|
|
27
28
|
export const ARCHIL_MOUNT_LABEL = "agentrun.mount";
|
|
28
29
|
// The shapes the helper itself checks (box/agentrun-archil), so a spec it would refuse is refused before any vendor call.
|
|
29
30
|
const DISK = /^(?:dsk-[0-9a-f]{16}|[A-Za-z0-9][A-Za-z0-9._@+-]{0,127}\/[A-Za-z0-9][A-Za-z0-9._-]{0,127})$/;
|
|
@@ -33,7 +34,7 @@ const DISK = /^(?:dsk-[0-9a-f]{16}|[A-Za-z0-9][A-Za-z0-9._@+-]{0,127}\/[A-Za-z0-
|
|
|
33
34
|
*/
|
|
34
35
|
export const ARCHIL_REGION = "[a-z0-9]+-[a-z0-9][a-z0-9-]{0,62}";
|
|
35
36
|
const REGION = new RegExp(`^${ARCHIL_REGION}$`);
|
|
36
|
-
const FOLDER = /^agents\/[A-Za-z0-9][A-Za-z0-9_-]{0,127}\/runs\/([A-Za-z0-9][A-Za-z0-9_-]{0,127})\/work$/;
|
|
37
|
+
const FOLDER = /^agents\/([A-Za-z0-9][A-Za-z0-9_-]{0,127})\/runs\/([A-Za-z0-9][A-Za-z0-9_-]{0,127})\/work$/;
|
|
37
38
|
const TOKEN = /^[A-Za-z0-9._~+/=-]{16,4096}$/;
|
|
38
39
|
/**
|
|
39
40
|
* The Archil rule every provider's check() adds to checkMount's, with no vendor call: network "none" (the tools have no
|
|
@@ -65,8 +66,8 @@ export function archilRefusals(spec) {
|
|
|
65
66
|
const folder = FOLDER.exec(text(mount.folder));
|
|
66
67
|
if (folder === null)
|
|
67
68
|
refuse("mount", "mount.folder is agents/<agent>/runs/<run>/work, nothing else");
|
|
68
|
-
else if (runWrong === undefined && folder[
|
|
69
|
-
refuse("mount", `mount.folder is run ${folder[
|
|
69
|
+
else if (runWrong === undefined && folder[2] !== run)
|
|
70
|
+
refuse("mount", `mount.folder is run ${folder[2]}'s folder, not the run this computer is labelled for (${RUN_LABEL})`);
|
|
70
71
|
if (!TOKEN.test(text(mount.token)))
|
|
71
72
|
refuse("mount", "mount.token is not a disk token: 16 to 4096 of letters, digits and ._~+/=-");
|
|
72
73
|
return found;
|
|
@@ -271,7 +272,8 @@ const MUTATING = new Set(["files.write", "files.move", "files.remove", "files.mk
|
|
|
271
272
|
* process.start, which makes its log and the folders above it; process.write and signal; a process seen
|
|
272
273
|
* ended, by process.wait or a process.read that says so) syncs before it answers, through mount.sync, coalesced: a
|
|
273
274
|
* call during a sync in flight waits for it, then shares one more. A failed sync fails the call in words; a call that
|
|
274
|
-
* failed still syncs, and answers its own error
|
|
275
|
+
* failed still syncs, and answers its own error (one the client timed out with no answer from the daemon does so at
|
|
276
|
+
* once, not waiting for the sync, which rides the same transport; a timeout the daemon answered waits). A caller whose signal fires stops waiting, answered "aborted" in words
|
|
275
277
|
* (or its own error), while the shared sync goes on for every other caller. A tar.push.begin answered with such an error
|
|
276
278
|
* instead of its id first ends the push it began, so no push slot is held by a push its caller cannot name.
|
|
277
279
|
*/
|
|
@@ -340,6 +342,11 @@ export function syncingClient(client) {
|
|
|
340
342
|
};
|
|
341
343
|
if (signal?.aborted)
|
|
342
344
|
return result.ok ? stopped() : result;
|
|
345
|
+
// A call the client gave up on at its own timeoutMs got no answer over the transport, and a sync rides that same
|
|
346
|
+
// transport: the caller gets its timeout now, and the sync it asked for goes on for the others. A timeout the
|
|
347
|
+
// daemon answered came over a live transport, after the call may have run in part: that one waits for the sync.
|
|
348
|
+
if (!result.ok && unanswered(result.error))
|
|
349
|
+
return result;
|
|
343
350
|
const synced = signal === undefined ? await shared : await new Promise((resolve) => {
|
|
344
351
|
const onAbort = () => resolve("stopped");
|
|
345
352
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
@@ -358,19 +365,23 @@ export function syncingClient(client) {
|
|
|
358
365
|
close: () => client.close(),
|
|
359
366
|
};
|
|
360
367
|
}
|
|
361
|
-
/**
|
|
368
|
+
/**
|
|
369
|
+
* The label an Archil computer carries its mount in: kind, disk, region and the folder's agent as JSON, never the token.
|
|
370
|
+
* The folder's run is the computer's agentrun.run label (check holds them equal), so the label does not repeat it.
|
|
371
|
+
*/
|
|
362
372
|
export function archilLabels(mount) {
|
|
363
|
-
return { [ARCHIL_MOUNT_LABEL]: JSON.stringify({ kind: "archil", disk: mount.disk, region: mount.region,
|
|
373
|
+
return { [ARCHIL_MOUNT_LABEL]: JSON.stringify({ kind: "archil", disk: mount.disk, region: mount.region, agent: FOLDER.exec(mount.folder)?.[1] ?? "" }) };
|
|
364
374
|
}
|
|
365
|
-
/** The mount a computer's
|
|
375
|
+
/** The mount a computer's labels record, its folder from the agent and agentrun.run; undefined when there is none, or it is not one. */
|
|
366
376
|
export function recordedMount(labels) {
|
|
367
377
|
const text = labels?.[ARCHIL_MOUNT_LABEL];
|
|
368
378
|
if (text === undefined)
|
|
369
379
|
return undefined;
|
|
370
380
|
try {
|
|
371
|
-
const
|
|
372
|
-
const
|
|
373
|
-
|
|
381
|
+
const { kind, disk, region, agent, ...rest } = (JSON.parse(text) ?? {});
|
|
382
|
+
const run = labels?.[RUN_LABEL];
|
|
383
|
+
const folder = `agents/${String(agent)}/runs/${String(run)}/work`;
|
|
384
|
+
if (kind !== "archil" || typeof disk !== "string" || typeof region !== "string" || typeof agent !== "string" || typeof run !== "string" || Object.keys(rest).length > 0 || !FOLDER.test(folder))
|
|
374
385
|
return undefined;
|
|
375
386
|
return { kind, disk, region, folder };
|
|
376
387
|
}
|
package/dist/mount.d.ts
CHANGED
|
@@ -42,13 +42,19 @@ export type MountReadBack = {
|
|
|
42
42
|
} | {
|
|
43
43
|
other: string;
|
|
44
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* Mount kinds a provider's computers don't take though a caller would ask for them, each with why, in the one sentence
|
|
47
|
+
* its refusal gives (Daytona's archil: Archil's client hangs on its sandboxes).
|
|
48
|
+
*/
|
|
49
|
+
export type Unmounted = Readonly<Partial<Record<MountKind, string>>>;
|
|
45
50
|
/**
|
|
46
51
|
* The one mount rule, with no vendor call: no mount is no refusal; a kind the provider does not declare is refused in
|
|
47
|
-
* words
|
|
48
|
-
* existing directory on the host, with no NUL; an Archil
|
|
49
|
-
* NUL, the folder relative to the disk's root and
|
|
52
|
+
* words (the provider's own reason, `unmounted`, where it gives one); a bind's path is absolute, canonical (its own
|
|
53
|
+
* realpath: what a provider reads back is what is bound), an existing directory on the host, with no NUL; an Archil
|
|
54
|
+
* mount's disk, region, folder and token are non-empty strings with no NUL, the folder relative to the disk's root and
|
|
55
|
+
* never above it. Each refusal names a field, never an Archil value.
|
|
50
56
|
*/
|
|
51
|
-
export declare function checkMount(mount: unknown, declared: readonly MountKind[] | undefined): Refusal[];
|
|
57
|
+
export declare function checkMount(mount: unknown, declared: readonly MountKind[] | undefined, unmounted?: Unmounted): Refusal[];
|
|
52
58
|
/**
|
|
53
59
|
* What a provider reads back of a mount it made as asked: its kind and source, never the token. An Archil mount is
|
|
54
60
|
* always exclusive, and is read back under `epoch`, the computer's claim epoch. With no epoch, or a value that is not
|
package/dist/mount.js
CHANGED
|
@@ -19,11 +19,12 @@ const NUL = "a NUL byte cannot be passed to a mount";
|
|
|
19
19
|
const filled = (value) => typeof value === "string" && value !== "";
|
|
20
20
|
/**
|
|
21
21
|
* The one mount rule, with no vendor call: no mount is no refusal; a kind the provider does not declare is refused in
|
|
22
|
-
* words
|
|
23
|
-
* existing directory on the host, with no NUL; an Archil
|
|
24
|
-
* NUL, the folder relative to the disk's root and
|
|
22
|
+
* words (the provider's own reason, `unmounted`, where it gives one); a bind's path is absolute, canonical (its own
|
|
23
|
+
* realpath: what a provider reads back is what is bound), an existing directory on the host, with no NUL; an Archil
|
|
24
|
+
* mount's disk, region, folder and token are non-empty strings with no NUL, the folder relative to the disk's root and
|
|
25
|
+
* never above it. Each refusal names a field, never an Archil value.
|
|
25
26
|
*/
|
|
26
|
-
export function checkMount(mount, declared) {
|
|
27
|
+
export function checkMount(mount, declared, unmounted = {}) {
|
|
27
28
|
if (mount === undefined)
|
|
28
29
|
return [];
|
|
29
30
|
const refuse = (message) => [{ field: "mount", message }];
|
|
@@ -33,6 +34,9 @@ export function checkMount(mount, declared) {
|
|
|
33
34
|
return refuse(SHAPE);
|
|
34
35
|
const takes = declared ?? [];
|
|
35
36
|
if (!takes.includes(kind)) {
|
|
37
|
+
const why = unmounted[kind];
|
|
38
|
+
if (why !== undefined)
|
|
39
|
+
return refuse(why);
|
|
36
40
|
return refuse(takes.length === 0
|
|
37
41
|
? `this provider declares no mount kind, so it mounts no run folder (capabilities().mount)`
|
|
38
42
|
: `this provider does not take a mount of kind ${kind}; it takes ${takes.join(" or ")}`);
|
package/dist/orgo-channel.d.ts
CHANGED
|
@@ -87,9 +87,10 @@ export type OrgoWebSocketFactory = (url: string) => OrgoSocket;
|
|
|
87
87
|
* line (the prompt, the typed line's echo) is dropped. The marker is printed from two words, so the echo of the line
|
|
88
88
|
* that prints it never holds it.
|
|
89
89
|
*/
|
|
90
|
-
export declare function orgoTerminalChannel({ rest,
|
|
90
|
+
export declare function orgoTerminalChannel({ rest, workspace, webSocket, echoMs, }: {
|
|
91
91
|
rest: OrgoRest;
|
|
92
|
-
|
|
92
|
+
/** The workspace the computers live in, which an upload names: the provider's, read when first needed. */
|
|
93
|
+
workspace: (signal?: AbortSignal) => Promise<Result<string>>;
|
|
93
94
|
webSocket?: OrgoWebSocketFactory;
|
|
94
95
|
/** How long a typed line waits for the shell's echo before it is typed again. */
|
|
95
96
|
echoMs?: number;
|
package/dist/orgo-channel.js
CHANGED
|
@@ -126,7 +126,7 @@ function frameText(data) {
|
|
|
126
126
|
* line (the prompt, the typed line's echo) is dropped. The marker is printed from two words, so the echo of the line
|
|
127
127
|
* that prints it never holds it.
|
|
128
128
|
*/
|
|
129
|
-
export function orgoTerminalChannel({ rest,
|
|
129
|
+
export function orgoTerminalChannel({ rest, workspace, webSocket = defaultWebSocket, echoMs = 3_000, }) {
|
|
130
130
|
const bash = async (computer, command, timeoutMs, signal) => {
|
|
131
131
|
const timeout = Math.min(BASH_MAX_S, Math.max(1, Math.ceil(timeoutMs / 1000)));
|
|
132
132
|
const ran = await rest.request("POST", `/computers/${encodeURIComponent(computer)}/bash`, { body: { command, timeout }, timeoutMs: timeout * 1000 + BASH_PROXY_MS, ...(signal ? { signal } : {}) });
|
|
@@ -298,9 +298,12 @@ export function orgoTerminalChannel({ rest, workspaceId, webSocket = defaultWebS
|
|
|
298
298
|
const at = path.lastIndexOf("/");
|
|
299
299
|
if (at < 0 || path.slice(at + 1) === "")
|
|
300
300
|
return fail("invalid", `an upload goes to an absolute file path, not ${JSON.stringify(path)}`);
|
|
301
|
+
const workspaceId = await workspace(signal);
|
|
302
|
+
if (!workspaceId.ok)
|
|
303
|
+
return workspaceId;
|
|
301
304
|
const form = new FormData();
|
|
302
305
|
form.set("file", new Blob([new Uint8Array(bytes)]), path.slice(at + 1));
|
|
303
|
-
form.set("workspaceId", workspaceId);
|
|
306
|
+
form.set("workspaceId", workspaceId.value);
|
|
304
307
|
form.set("desktopId", computer);
|
|
305
308
|
form.set("destPath", path.slice(0, at) || "/");
|
|
306
309
|
const put = await rest.request("POST", "/files/upload", { form, timeoutMs, ...(signal ? { signal } : {}) });
|
package/dist/orgo-desktop.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type OrgoRest } from "./orgo-channel.js";
|
|
2
2
|
import { type OrgoLedger } from "./orgo-names.js";
|
|
3
3
|
import { type ComputerClient, type DaemonMethod, type DaemonMethods, type Group, type HelloResult } from "./protocol.js";
|
|
4
|
-
import { type AttachContext, type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type CreatedComputer, type NetworkPolicy, type NetworkSpec, type Refusal, type ReleaseContext, type ReleaseHow } from "./provider.js";
|
|
4
|
+
import { type AttachContext, type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type CreateContext, type CreatedComputer, type KeyChoice, type NetworkPolicy, type NetworkSpec, type Refusal, type ReleaseContext, type ReleaseHow } from "./provider.js";
|
|
5
5
|
import { type Result } from "./result.js";
|
|
6
6
|
import { type ScreenWatch, type ScreenWatchHandlers, type WatchOptions } from "./screen-watch.js";
|
|
7
7
|
export type OrgoDesktopOs = "windows" | "macos";
|
|
@@ -25,8 +25,11 @@ export interface OrgoDesktopOptions {
|
|
|
25
25
|
os: OrgoDesktopOs;
|
|
26
26
|
/** The Orgo API key. Serve passes ORGO_API_KEY's value; the provider never reads the environment or logs it. */
|
|
27
27
|
apiKey: string;
|
|
28
|
-
/**
|
|
29
|
-
|
|
28
|
+
/**
|
|
29
|
+
* The workspace this deployment's computers live in; the provider lists, attaches and releases only there. Absent:
|
|
30
|
+
* the key's account's one workspace, read from Orgo when first needed (orgo-workspaces.ts soleWorkspace).
|
|
31
|
+
*/
|
|
32
|
+
workspaceId?: string;
|
|
30
33
|
/** Orgo's API, https; default https://www.orgo.ai/api. */
|
|
31
34
|
apiUrl?: string;
|
|
32
35
|
/** For tests: every REST call goes through it. Default the global fetch. */
|
|
@@ -93,7 +96,7 @@ export declare class OrgoDesktopProvider implements ComputerProvider {
|
|
|
93
96
|
*/
|
|
94
97
|
capabilities(): ComputerCapabilities;
|
|
95
98
|
check(spec: ComputerSpec): Refusal[];
|
|
96
|
-
create(spec: ComputerSpec,
|
|
99
|
+
create(spec: ComputerSpec, context: CreateContext): Promise<Result<CreatedComputer>>;
|
|
97
100
|
/** The live view: screen.watch on a connection of the watch's own (daemonWatch), the client's polled screenshots. */
|
|
98
101
|
watch(ref: ComputerRef, handlers: ScreenWatchHandlers, options?: WatchOptions): Promise<Result<ScreenWatch>>;
|
|
99
102
|
/**
|
|
@@ -118,6 +121,8 @@ export declare class OrgoDesktopProvider implements ComputerProvider {
|
|
|
118
121
|
testConnection(context?: CallContext): Promise<Result<{
|
|
119
122
|
detail: string;
|
|
120
123
|
}>>;
|
|
124
|
+
/** Settings' pick of ORGO_WORKSPACE_ID (workspaceId): every workspace the key's account sees, by name. Makes nothing. */
|
|
125
|
+
keyChoices(option: string, { signal }?: CallContext): Promise<Result<KeyChoice[]>>;
|
|
121
126
|
/** open: what Orgo gives, the one network here; never read from inside, and a change is refused. */
|
|
122
127
|
network(ref: ComputerRef, policy?: NetworkSpec, { signal }?: CallContext): Promise<Result<NetworkPolicy>>;
|
|
123
128
|
/**
|
package/dist/orgo-desktop.js
CHANGED
|
@@ -36,8 +36,9 @@ import { MACOS_GROUPS, ORGO_MACOS_IMAGE, ORGO_WINDOWS_IMAGE, WINDOWS_GROUPS } fr
|
|
|
36
36
|
import { EPOCH_LABEL, OWNER_LABEL, OWNER_SERVER_LABEL, ownerLabels, RUN_HASH_LABEL, RUN_LABEL, runHash } from "./labels.js";
|
|
37
37
|
import { checkMount } from "./mount.js";
|
|
38
38
|
import { ORGO_API_URL, orgoRest } from "./orgo-channel.js";
|
|
39
|
+
import { workspaceChoices, workspaceHolder } from "./orgo-workspaces.js";
|
|
39
40
|
import { COMPUTER_ID, claimProblem, andSettled, inTurn, filterProblem, labelProblem, labelsOf, NAME_MAX, NO_DEADLINE, nameParts, orgoMemoryLedger, orgoName, ownedListing, ownerHashOfLabels, ownerReadBack, refProblem, sameComputer, settleEntry, show, renewEntry, takeEntry, withDeadline, } from "./orgo-names.js";
|
|
40
|
-
import { encodePng } from "./
|
|
41
|
+
import { encodePng } from "./png.js";
|
|
41
42
|
import { MAX_CHUNK_BYTES, MAX_LIST_ENTRIES, MAX_OUTPUT_BYTES, PROTOCOL_VERSION, } from "./protocol.js";
|
|
42
43
|
import { checkGpu, checkTenure, runLifetimeMs, } from "./provider.js";
|
|
43
44
|
import { failFor, ok, vendorFail } from "./result.js";
|
|
@@ -333,7 +334,7 @@ export class OrgoDesktopProvider {
|
|
|
333
334
|
id = "orgo";
|
|
334
335
|
version = VERSION;
|
|
335
336
|
#rest;
|
|
336
|
-
#
|
|
337
|
+
#workspace;
|
|
337
338
|
#profile;
|
|
338
339
|
#maxLifetimeMs;
|
|
339
340
|
#timeouts;
|
|
@@ -353,8 +354,8 @@ export class OrgoDesktopProvider {
|
|
|
353
354
|
throw new Error(`os is "windows" or "macos" for an Orgo desktop Orgo's API answers, not ${JSON.stringify(os)}`);
|
|
354
355
|
if (typeof apiKey !== "string" || apiKey === "")
|
|
355
356
|
throw new Error("options.apiKey, an Orgo API key, is required");
|
|
356
|
-
if (typeof workspaceId !== "string" || !WORKSPACE_ID.test(workspaceId))
|
|
357
|
-
throw new Error("options.workspaceId, the Orgo workspace this deployment's computers live in, is
|
|
357
|
+
if (workspaceId !== undefined && (typeof workspaceId !== "string" || !WORKSPACE_ID.test(workspaceId)))
|
|
358
|
+
throw new Error("options.workspaceId, the Orgo workspace this deployment's computers live in, is an Orgo workspace id when given");
|
|
358
359
|
let url;
|
|
359
360
|
try {
|
|
360
361
|
url = new URL(apiUrl);
|
|
@@ -372,7 +373,7 @@ export class OrgoDesktopProvider {
|
|
|
372
373
|
throw new Error(`timeouts.${key} must be a whole number of ms above 0`);
|
|
373
374
|
}
|
|
374
375
|
this.#rest = orgoRest({ apiKey, apiUrl: url.href, ...(fetch ? { fetch } : {}) });
|
|
375
|
-
this.#
|
|
376
|
+
this.#workspace = workspaceHolder(workspaceId, this.#rest, merged.requestMs);
|
|
376
377
|
this.#profile = PROFILES[os];
|
|
377
378
|
this.#maxLifetimeMs = maxLifetimeMs;
|
|
378
379
|
this.#timeouts = merged;
|
|
@@ -384,7 +385,10 @@ export class OrgoDesktopProvider {
|
|
|
384
385
|
let pointer = this.#pointers.get(ref.id);
|
|
385
386
|
if (pointer === undefined)
|
|
386
387
|
this.#pointers.set(ref.id, (pointer = {}));
|
|
387
|
-
const
|
|
388
|
+
const workspace = await this.#workspace.read(signal);
|
|
389
|
+
if (!workspace.ok)
|
|
390
|
+
return workspace;
|
|
391
|
+
const client = new OrgoDesktopClient(this.#rest, ref.id, this.#profile, workspace.value, this.#timeouts.requestMs, pointer);
|
|
388
392
|
const hello = await client.open(this.#daemonVersion, signal);
|
|
389
393
|
if (!hello.ok) {
|
|
390
394
|
client.close();
|
|
@@ -455,12 +459,16 @@ export class OrgoDesktopProvider {
|
|
|
455
459
|
}
|
|
456
460
|
return refusals;
|
|
457
461
|
}
|
|
458
|
-
async create(spec,
|
|
462
|
+
async create(spec, context) {
|
|
463
|
+
const signal = context?.signal;
|
|
459
464
|
const refusals = this.check(spec);
|
|
460
465
|
if (refusals.length > 0)
|
|
461
466
|
return fail("refused", refusals.map(({ field, message }) => `${field}: ${message}`).join("; "));
|
|
462
467
|
if (signal?.aborted)
|
|
463
468
|
return fail("aborted", "create was aborted before Orgo was called");
|
|
469
|
+
const workspace = await this.#workspace.read(signal);
|
|
470
|
+
if (!workspace.ok)
|
|
471
|
+
return workspace;
|
|
464
472
|
const profile = this.#profile;
|
|
465
473
|
// An agent's own computer outlives the run: no deadline, no Orgo end, the owner in its name and its labels.
|
|
466
474
|
const owner = spec.owner;
|
|
@@ -474,7 +482,7 @@ export class OrgoDesktopProvider {
|
|
|
474
482
|
const ram = spec.memoryMb === undefined ? profile.ram[0] : spec.memoryMb / 1024;
|
|
475
483
|
const cpu = profile.cpus ? (spec.cpus ?? CPU_FOR_RAM[ram]) : undefined;
|
|
476
484
|
const body = {
|
|
477
|
-
workspace_id:
|
|
485
|
+
workspace_id: workspace.value,
|
|
478
486
|
name,
|
|
479
487
|
os: profile.os,
|
|
480
488
|
ram,
|
|
@@ -572,8 +580,11 @@ export class OrgoDesktopProvider {
|
|
|
572
580
|
return written;
|
|
573
581
|
return written.value.exitCode === 0 ? ok(undefined) : fail("refused", `writing ${this.#profile.labels} in ${ref.name} failed (exit ${written.value.exitCode})`);
|
|
574
582
|
}
|
|
575
|
-
/** Orgo's record of a computer; not_found once Orgo no longer has it. */
|
|
583
|
+
/** Orgo's record of a computer; not_found once Orgo no longer has it. The workspace is read first, so #ours knows it. */
|
|
576
584
|
async #get(id, signal) {
|
|
585
|
+
const workspace = await this.#workspace.read(signal);
|
|
586
|
+
if (!workspace.ok)
|
|
587
|
+
return workspace;
|
|
577
588
|
const read = await this.#rest.request("GET", `/computers/${encodeURIComponent(id)}`, { timeoutMs: this.#timeouts.requestMs, ...(signal ? { signal } : {}) });
|
|
578
589
|
if (!read.ok)
|
|
579
590
|
return read;
|
|
@@ -587,7 +598,8 @@ export class OrgoDesktopProvider {
|
|
|
587
598
|
*/
|
|
588
599
|
#ours(record, name) {
|
|
589
600
|
return (nameParts(record.name) !== undefined &&
|
|
590
|
-
|
|
601
|
+
this.#workspace.id !== undefined &&
|
|
602
|
+
(record.workspace_id ?? record.project_id) === this.#workspace.id &&
|
|
591
603
|
(name === undefined || sameComputer(record.name, name)) &&
|
|
592
604
|
record.status !== "deleted" &&
|
|
593
605
|
(record.os === undefined || record.os === this.#profile.os));
|
|
@@ -702,13 +714,17 @@ export class OrgoDesktopProvider {
|
|
|
702
714
|
}
|
|
703
715
|
/** The workspace's computers, as Orgo lists them. */
|
|
704
716
|
async #desktops(signal) {
|
|
705
|
-
const
|
|
717
|
+
const workspace = await this.#workspace.read(signal);
|
|
718
|
+
if (!workspace.ok)
|
|
719
|
+
return workspace;
|
|
720
|
+
const id = workspace.value;
|
|
721
|
+
const read = await this.#rest.request("GET", `/workspaces/${encodeURIComponent(id)}`, { timeoutMs: this.#timeouts.listMs, ...(signal ? { signal } : {}) });
|
|
706
722
|
if (!read.ok)
|
|
707
723
|
return read;
|
|
708
724
|
const desktops = read.value?.desktops;
|
|
709
725
|
if (!Array.isArray(desktops))
|
|
710
|
-
return fail("vendor", `Orgo's workspace ${
|
|
711
|
-
return ok(desktops.filter((one) => typeof one?.id === "string" && typeof one.name === "string").map((one) => ({ ...one, workspace_id:
|
|
726
|
+
return fail("vendor", `Orgo's workspace ${id} lists no computers array`);
|
|
727
|
+
return ok(desktops.filter((one) => typeof one?.id === "string" && typeof one.name === "string").map((one) => ({ ...one, workspace_id: id })));
|
|
712
728
|
}
|
|
713
729
|
/** The live view: screen.watch on a connection of the watch's own (daemonWatch), the client's polled screenshots. */
|
|
714
730
|
watch(ref, handlers, options) {
|
|
@@ -991,6 +1007,10 @@ export class OrgoDesktopProvider {
|
|
|
991
1007
|
async testConnection(context = {}) {
|
|
992
1008
|
return listTested("Orgo", await this.list({}, context));
|
|
993
1009
|
}
|
|
1010
|
+
/** Settings' pick of ORGO_WORKSPACE_ID (workspaceId): every workspace the key's account sees, by name. Makes nothing. */
|
|
1011
|
+
keyChoices(option, { signal } = {}) {
|
|
1012
|
+
return workspaceChoices(this.#rest, option, { timeoutMs: this.#timeouts.requestMs, ...(signal ? { signal } : {}) });
|
|
1013
|
+
}
|
|
994
1014
|
/** open: what Orgo gives, the one network here; never read from inside, and a change is refused. */
|
|
995
1015
|
async network(ref, policy, { signal } = {}) {
|
|
996
1016
|
const problem = refProblem(ref);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { OrgoRest } from "./orgo-channel.js";
|
|
2
|
+
import type { KeyChoice } from "./provider.js";
|
|
3
|
+
import { type Result } from "./result.js";
|
|
4
|
+
/** One workspace a key's account sees: its id, its name, and its status where Orgo says one other than active. */
|
|
5
|
+
export interface OrgoWorkspace {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly status?: string;
|
|
9
|
+
}
|
|
10
|
+
/** What a person reads for a key whose account has no workspace. */
|
|
11
|
+
export declare const NO_WORKSPACE = "this Orgo key's account has no workspace: make one at orgo.ai";
|
|
12
|
+
/** A workspace in words: its name, and its status when it is not active. */
|
|
13
|
+
export declare const workspaceWords: (workspace: OrgoWorkspace) => string;
|
|
14
|
+
/** Every workspace the key's account sees, deleted ones left out, in Orgo's order. An HTTP failure keeps its code. */
|
|
15
|
+
export declare function orgoWorkspaces(rest: OrgoRest, { timeoutMs, signal }: {
|
|
16
|
+
timeoutMs: number;
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
}): Promise<Result<OrgoWorkspace[]>>;
|
|
19
|
+
/**
|
|
20
|
+
* The workspace a provider whose settings name none uses: the key's account's one workspace. Several are refused in
|
|
21
|
+
* words naming them and pointing at Settings, where a person picks one; none is refused saying to make one.
|
|
22
|
+
*/
|
|
23
|
+
export declare function soleWorkspace(rest: OrgoRest, context: {
|
|
24
|
+
timeoutMs: number;
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
}): Promise<Result<string>>;
|
|
27
|
+
/**
|
|
28
|
+
* keyChoices for an Orgo provider: workspaceId's choices, every workspace the key's account sees, each its id and its
|
|
29
|
+
* name; none is refused saying to make one. Orgo's descriptor picks no other option.
|
|
30
|
+
*/
|
|
31
|
+
export declare function workspaceChoices(rest: OrgoRest, option: string, context: {
|
|
32
|
+
timeoutMs: number;
|
|
33
|
+
signal?: AbortSignal;
|
|
34
|
+
}): Promise<Result<KeyChoice[]>>;
|
|
35
|
+
/** A provider's workspace: `read()` the one its computers live in, and `id`, that id once a read found it. */
|
|
36
|
+
export interface WorkspaceHolder {
|
|
37
|
+
read(signal?: AbortSignal): Promise<Result<string>>;
|
|
38
|
+
readonly id: string | undefined;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The workspace a provider's computers live in: `given` when its settings name one; else the key's account's sole one
|
|
42
|
+
* (soleWorkspace), read on the first call that needs it and kept. A read that fails is not kept: the next call reads again.
|
|
43
|
+
* Calls that come while a read is under way share it. The shared read is bounded by timeoutMs alone, never by one
|
|
44
|
+
* caller's signal, so one caller giving up never fails the others: a caller whose signal fires stops waiting, answered
|
|
45
|
+
* "aborted", and the read goes on for the rest.
|
|
46
|
+
*/
|
|
47
|
+
export declare function workspaceHolder(given: string | undefined, rest: OrgoRest, timeoutMs: number): WorkspaceHolder;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { failAs, failFor, ok } from "./result.js";
|
|
2
|
+
const fail = failFor("orgo");
|
|
3
|
+
/** What a person reads for a key whose account has no workspace. */
|
|
4
|
+
export const NO_WORKSPACE = "this Orgo key's account has no workspace: make one at orgo.ai";
|
|
5
|
+
/** A workspace in words: its name, and its status when it is not active. */
|
|
6
|
+
export const workspaceWords = (workspace) => (workspace.status === undefined ? workspace.name : `${workspace.name} (${workspace.status})`);
|
|
7
|
+
/** Every workspace the key's account sees, deleted ones left out, in Orgo's order. An HTTP failure keeps its code. */
|
|
8
|
+
export async function orgoWorkspaces(rest, { timeoutMs, signal }) {
|
|
9
|
+
const read = await rest.request("GET", "/workspaces", { timeoutMs, ...(signal ? { signal } : {}) });
|
|
10
|
+
if (!read.ok)
|
|
11
|
+
return failAs(read.error, `Orgo's workspaces could not be read: ${read.error.message}`);
|
|
12
|
+
const listed = read.value?.workspaces;
|
|
13
|
+
if (!Array.isArray(listed))
|
|
14
|
+
return fail("vendor", "Orgo's GET /workspaces answered no workspaces list");
|
|
15
|
+
const workspaces = [];
|
|
16
|
+
for (const one of listed) {
|
|
17
|
+
if (typeof one?.id !== "string" || one.id === "" || (one.deleted_at !== null && one.deleted_at !== undefined))
|
|
18
|
+
continue;
|
|
19
|
+
const name = typeof one.name === "string" && one.name.trim() !== "" ? one.name.trim() : one.id;
|
|
20
|
+
const status = typeof one.status === "string" && one.status !== "active" ? one.status : undefined;
|
|
21
|
+
workspaces.push({ id: one.id, name, ...(status === undefined ? {} : { status }) });
|
|
22
|
+
}
|
|
23
|
+
return ok(workspaces);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The workspace a provider whose settings name none uses: the key's account's one workspace. Several are refused in
|
|
27
|
+
* words naming them and pointing at Settings, where a person picks one; none is refused saying to make one.
|
|
28
|
+
*/
|
|
29
|
+
export async function soleWorkspace(rest, context) {
|
|
30
|
+
const listed = await orgoWorkspaces(rest, context);
|
|
31
|
+
if (!listed.ok)
|
|
32
|
+
return listed;
|
|
33
|
+
const [only, ...more] = listed.value;
|
|
34
|
+
if (only === undefined)
|
|
35
|
+
return fail("not_found", NO_WORKSPACE);
|
|
36
|
+
if (more.length === 0)
|
|
37
|
+
return ok(only.id);
|
|
38
|
+
return fail("invalid", `this Orgo key's account has ${listed.value.length} workspaces (${listed.value.map(workspaceWords).join(", ")}): pick the one its computers live in, in Settings → Computers (ORGO_WORKSPACE_ID)`);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* keyChoices for an Orgo provider: workspaceId's choices, every workspace the key's account sees, each its id and its
|
|
42
|
+
* name; none is refused saying to make one. Orgo's descriptor picks no other option.
|
|
43
|
+
*/
|
|
44
|
+
export async function workspaceChoices(rest, option, context) {
|
|
45
|
+
if (option !== "workspaceId")
|
|
46
|
+
return fail("unsupported", `an Orgo provider offers choices for workspaceId alone, not ${JSON.stringify(option)}`);
|
|
47
|
+
const listed = await orgoWorkspaces(rest, context);
|
|
48
|
+
if (!listed.ok)
|
|
49
|
+
return listed;
|
|
50
|
+
if (listed.value.length === 0)
|
|
51
|
+
return fail("not_found", NO_WORKSPACE);
|
|
52
|
+
return ok(listed.value.map((workspace) => ({ value: workspace.id, label: workspaceWords(workspace) })));
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The workspace a provider's computers live in: `given` when its settings name one; else the key's account's sole one
|
|
56
|
+
* (soleWorkspace), read on the first call that needs it and kept. A read that fails is not kept: the next call reads again.
|
|
57
|
+
* Calls that come while a read is under way share it. The shared read is bounded by timeoutMs alone, never by one
|
|
58
|
+
* caller's signal, so one caller giving up never fails the others: a caller whose signal fires stops waiting, answered
|
|
59
|
+
* "aborted", and the read goes on for the rest.
|
|
60
|
+
*/
|
|
61
|
+
export function workspaceHolder(given, rest, timeoutMs) {
|
|
62
|
+
let id = given;
|
|
63
|
+
let reading;
|
|
64
|
+
const shared = () => (reading ??= soleWorkspace(rest, { timeoutMs }).then((found) => {
|
|
65
|
+
reading = undefined;
|
|
66
|
+
if (found.ok)
|
|
67
|
+
id = found.value;
|
|
68
|
+
return found;
|
|
69
|
+
}));
|
|
70
|
+
return {
|
|
71
|
+
get id() {
|
|
72
|
+
return id;
|
|
73
|
+
},
|
|
74
|
+
async read(signal) {
|
|
75
|
+
if (id !== undefined)
|
|
76
|
+
return ok(id);
|
|
77
|
+
if (signal?.aborted)
|
|
78
|
+
return fail("aborted", "the Orgo workspace read was aborted before it was sent");
|
|
79
|
+
if (!signal)
|
|
80
|
+
return shared();
|
|
81
|
+
let stop = () => { };
|
|
82
|
+
const stopped = new Promise((resolve) => {
|
|
83
|
+
stop = () => resolve(fail("aborted", "the Orgo workspace read was aborted; it goes on for other callers"));
|
|
84
|
+
signal.addEventListener("abort", stop, { once: true });
|
|
85
|
+
});
|
|
86
|
+
try {
|
|
87
|
+
return await Promise.race([shared(), stopped]);
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
signal.removeEventListener("abort", stop);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
package/dist/orgo.d.ts
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
import type { KindCapabilities } from "./kinds.js";
|
|
2
|
-
import { type MountKind } from "./mount.js";
|
|
3
1
|
import { type OrgoChannel, type OrgoStart, type OrgoWebSocketFactory } from "./orgo-channel.js";
|
|
4
2
|
import { OrgoDesktopProvider, type OrgoDesktopOptions } from "./orgo-desktop.js";
|
|
5
3
|
import { type OrgoLedger } from "./orgo-names.js";
|
|
6
|
-
import { type AttachContext, type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type CreatedComputer, type NetworkPolicy, type NetworkSpec, type Refusal, type ReleaseContext, type ReleaseHow } from "./provider.js";
|
|
4
|
+
import { type AttachContext, type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type CreateContext, type CreatedComputer, type KeyChoice, type NetworkPolicy, type NetworkSpec, type Refusal, type ReleaseContext, type ReleaseHow } from "./provider.js";
|
|
7
5
|
import { type Result } from "./result.js";
|
|
8
6
|
import { type ScreenWatch, type ScreenWatchHandlers, type WatchOptions } from "./screen-watch.js";
|
|
9
|
-
/** The mount kinds an Orgo computer takes: none yet (an Archil mount needs an Orgo template that bakes the helper). */
|
|
10
|
-
export declare const MOUNT: readonly MountKind[];
|
|
11
|
-
/**
|
|
12
|
-
* What a built provider declares, known without building one, per configuration (its descriptor's): the Linux desktop
|
|
13
|
-
* with computerd (the default), then the Windows and the macOS desktops Orgo's own API answers (options.os).
|
|
14
|
-
*/
|
|
15
|
-
export declare const CAPABILITIES: readonly KindCapabilities[];
|
|
16
7
|
/** The conformance CLI's module for Orgo: its live switch, the run's 1 h cap and the drifted twin. */
|
|
17
8
|
export declare const conformance: () => Promise<typeof import("./conformance/orgo.js")>;
|
|
18
9
|
/** The longest each kind of call may take, and the pause between two polls. */
|
|
@@ -39,8 +30,12 @@ export interface OrgoTimeouts {
|
|
|
39
30
|
export interface OrgoProviderOptions {
|
|
40
31
|
/** The Orgo API key. Serve passes ORGO_API_KEY's value; the provider never reads the environment or logs it. */
|
|
41
32
|
apiKey: string;
|
|
42
|
-
/**
|
|
43
|
-
|
|
33
|
+
/**
|
|
34
|
+
* The workspace this deployment's computers live in; the provider lists, attaches and releases only there. Absent:
|
|
35
|
+
* the key's account's one workspace, read from Orgo when first needed; with several or none, every call that needs
|
|
36
|
+
* it is refused in words (orgo-workspaces.ts soleWorkspace).
|
|
37
|
+
*/
|
|
38
|
+
workspaceId?: string;
|
|
44
39
|
/** Orgo's API, https; default https://www.orgo.ai/api. */
|
|
45
40
|
apiUrl?: string;
|
|
46
41
|
/** For tests: every REST call goes through it. Default the global fetch. */
|
|
@@ -99,7 +94,7 @@ export declare class OrgoProvider implements ComputerProvider {
|
|
|
99
94
|
*/
|
|
100
95
|
capabilities(): ComputerCapabilities;
|
|
101
96
|
check(spec: ComputerSpec): Refusal[];
|
|
102
|
-
create(spec: ComputerSpec,
|
|
97
|
+
create(spec: ComputerSpec, context: CreateContext): Promise<Result<CreatedComputer>>;
|
|
103
98
|
/** The live view: screen.watch on a connection of the watch's own (daemonWatch), never Orgo's VNC (proxy only). */
|
|
104
99
|
watch(ref: ComputerRef, handlers: ScreenWatchHandlers, options?: WatchOptions): Promise<Result<ScreenWatch>>;
|
|
105
100
|
connect(ref: ComputerRef): Promise<Result<ComputerConnection>>;
|
|
@@ -119,6 +114,8 @@ export declare class OrgoProvider implements ComputerProvider {
|
|
|
119
114
|
testConnection(context?: CallContext): Promise<Result<{
|
|
120
115
|
detail: string;
|
|
121
116
|
}>>;
|
|
117
|
+
/** Settings' pick of ORGO_WORKSPACE_ID (workspaceId): every workspace the key's account sees, by name. Makes nothing. */
|
|
118
|
+
keyChoices(option: string, { signal }?: CallContext): Promise<Result<KeyChoice[]>>;
|
|
122
119
|
network(ref: ComputerRef, policy?: NetworkSpec, { signal }?: CallContext): Promise<Result<NetworkPolicy>>;
|
|
123
120
|
/**
|
|
124
121
|
* delete: idempotent, a computer Orgo no longer has is done; it waits until Orgo no longer has it. detach, for an
|