@parcha/agentrun-computer 0.1.0-beta.57 → 0.1.0-beta.59
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 +187 -62
- package/box/Dockerfile +4 -3
- package/box/install.sh +57 -11
- package/dist/agent37.js +6 -9
- package/dist/attach.d.ts +24 -4
- package/dist/attach.js +50 -19
- package/dist/boxd.js +22 -9
- package/dist/browserbase.d.ts +6 -2
- package/dist/browserbase.js +50 -7
- package/dist/child-env.d.ts +11 -0
- package/dist/child-env.js +22 -0
- package/dist/chrome.d.ts +5 -2
- package/dist/chrome.js +5 -2
- package/dist/cloudflare.d.ts +2 -0
- package/dist/cloudflare.js +5 -3
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/computerd.json +1 -1
- package/dist/conformance/agent37.d.ts +10 -38
- package/dist/conformance/agent37.js +25 -113
- package/dist/conformance/archil.d.ts +13 -3
- package/dist/conformance/archil.js +22 -17
- package/dist/conformance/boxd.d.ts +8 -31
- package/dist/conformance/boxd.js +19 -74
- package/dist/conformance/browserbase.d.ts +3 -6
- package/dist/conformance/browserbase.js +6 -17
- package/dist/conformance/cases/health.js +6 -3
- package/dist/conformance/cli.d.ts +3 -1
- package/dist/conformance/cli.js +69 -9
- package/dist/conformance/cloudflare.d.ts +3 -6
- package/dist/conformance/cloudflare.js +7 -15
- package/dist/conformance/daytona.d.ts +6 -20
- package/dist/conformance/daytona.js +22 -57
- package/dist/conformance/dial-only.d.ts +4 -3
- package/dist/conformance/dial-only.js +3 -3
- package/dist/conformance/docker.d.ts +4 -5
- package/dist/conformance/docker.js +8 -14
- package/dist/conformance/e2b.d.ts +10 -36
- package/dist/conformance/e2b.js +27 -84
- package/dist/conformance/fly.d.ts +3 -6
- package/dist/conformance/fly.js +2 -6
- package/dist/conformance/groundbox.d.ts +7 -23
- package/dist/conformance/groundbox.js +16 -56
- package/dist/conformance/index.d.ts +1 -0
- package/dist/conformance/index.js +1 -0
- package/dist/conformance/kernel.d.ts +3 -6
- package/dist/conformance/kernel.js +5 -15
- package/dist/conformance/kind.d.ts +0 -6
- package/dist/conformance/kind.js +0 -4
- package/dist/conformance/local-chrome.d.ts +5 -7
- package/dist/conformance/local-chrome.js +7 -11
- package/dist/conformance/modal.d.ts +10 -38
- package/dist/conformance/modal.js +27 -74
- package/dist/conformance/module-kit.d.ts +87 -0
- package/dist/conformance/module-kit.js +88 -0
- package/dist/conformance/morph.d.ts +7 -23
- package/dist/conformance/morph.js +20 -66
- package/dist/conformance/orgo.d.ts +5 -10
- package/dist/conformance/orgo.js +15 -27
- package/dist/conformance/phone-harness.d.ts +3 -5
- package/dist/conformance/phone-harness.js +3 -11
- package/dist/conformance/runner.d.ts +13 -3
- package/dist/conformance/runner.js +32 -11
- package/dist/conformance/smolcloud.d.ts +7 -23
- package/dist/conformance/smolcloud.js +16 -49
- package/dist/conformance/sweep.d.ts +10 -5
- package/dist/conformance/sweep.js +91 -38
- package/dist/conformance/tti.d.ts +69 -0
- package/dist/conformance/tti.js +205 -0
- package/dist/conformance/types.d.ts +9 -2
- package/dist/daytona.js +60 -20
- package/dist/descriptor.d.ts +10 -0
- package/dist/descriptor.js +7 -0
- package/dist/descriptors/browserbase.d.ts +3 -0
- package/dist/descriptors/browserbase.js +4 -0
- package/dist/descriptors/docker.d.ts +1 -0
- package/dist/descriptors/docker.js +3 -0
- package/dist/descriptors/env-names.d.ts +32 -0
- package/dist/descriptors/env-names.js +60 -0
- package/dist/descriptors/index.d.ts +9 -2
- package/dist/descriptors/kernel.d.ts +3 -0
- package/dist/descriptors/kernel.js +2 -0
- package/dist/descriptors/local-chrome.d.ts +1 -1
- package/dist/descriptors/local-chrome.js +5 -3
- package/dist/descriptors/phone-harness.d.ts +1 -1
- package/dist/descriptors/phone-harness.js +4 -2
- package/dist/docker/egress.d.ts +7 -0
- package/dist/docker/egress.js +8 -0
- package/dist/docker/image.d.ts +5 -1
- package/dist/docker/image.js +12 -8
- package/dist/docker.d.ts +63 -15
- package/dist/docker.js +181 -98
- package/dist/drift.js +6 -6
- package/dist/e2b.d.ts +2 -2
- package/dist/e2b.js +2 -3
- package/dist/groundbox.js +6 -6
- package/dist/host.d.ts +23 -0
- package/dist/hosted/download.d.ts +23 -0
- package/dist/hosted/download.js +144 -0
- package/dist/hosted/process.d.ts +5 -0
- package/dist/hosted/process.js +20 -0
- package/dist/hosted/provider.js +120 -48
- package/dist/hosted/rest.d.ts +19 -8
- package/dist/hosted/rest.js +47 -14
- package/dist/hosted/scripts.d.ts +10 -0
- package/dist/hosted/scripts.js +23 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/janitor.d.ts +7 -1
- package/dist/janitor.js +2 -2
- package/dist/kernel.js +1 -1
- package/dist/local-chrome.d.ts +5 -2
- package/dist/local-chrome.js +4 -2
- package/dist/local-supervisor.js +1 -0
- package/dist/modal.d.ts +6 -5
- package/dist/modal.js +7 -7
- package/dist/morph.js +5 -8
- package/dist/orgo-channel.d.ts +3 -2
- package/dist/orgo-channel.js +3 -3
- package/dist/orgo-desktop.js +2 -4
- package/dist/orgo.js +2 -4
- package/dist/phone-harness.d.ts +7 -5
- package/dist/phone-harness.js +60 -61
- package/dist/protocol.d.ts +10 -0
- package/dist/protocol.js +17 -0
- package/dist/provider.d.ts +6 -2
- package/dist/screen-watch.d.ts +6 -1
- package/dist/screen-watch.js +166 -12
- package/dist/vendor-sdk.d.ts +9 -0
- package/dist/vendor-sdk.js +26 -0
- package/package.json +8 -1
package/dist/hosted/rest.js
CHANGED
|
@@ -40,12 +40,28 @@ function redirected(cause) {
|
|
|
40
40
|
const inner = cause?.cause;
|
|
41
41
|
return /redirect/i.test(`${cause?.message ?? ""} ${inner?.message ?? ""}`);
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* An answer's body. One that is not a 2xx keeps its status when its words break off, unless the bound or the caller cut
|
|
45
|
+
* them: the status is the vendor's answer, the words only explain it.
|
|
46
|
+
*/
|
|
47
|
+
async function bytesOf(response, cut) {
|
|
48
|
+
try {
|
|
49
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
if (response.ok || cut.aborted)
|
|
53
|
+
throw error;
|
|
54
|
+
return new Uint8Array();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
43
57
|
const NO_BODY = { async *[Symbol.asyncIterator]() { } };
|
|
44
58
|
/**
|
|
45
|
-
* An API's https base URL
|
|
46
|
-
* loopback http included
|
|
47
|
-
*
|
|
48
|
-
*
|
|
59
|
+
* An API's https base URL: its origin and path, normalized, with no trailing slash. Throws in words on another scheme,
|
|
60
|
+
* loopback http included, so a key never crosses in the clear, and on a user or password, a query or a fragment, which
|
|
61
|
+
* no provider's API takes. Every provider that takes a URL from its caller and sends a key to it takes the URL through
|
|
62
|
+
* it: Agent37, boxd, Browserbase, the Cloudflare relay, Daytona (and the toolbox URL Daytona answers with), Groundbox,
|
|
63
|
+
* Kernel, Modal, Morph, Orgo, the phone harness and smol cloud, and so does each sweep scope that names one. E2B takes a
|
|
64
|
+
* host name and Fly nothing, and each builds its https URL itself.
|
|
49
65
|
*/
|
|
50
66
|
export function httpsBase(url, what) {
|
|
51
67
|
let parsed;
|
|
@@ -53,11 +69,19 @@ export function httpsBase(url, what) {
|
|
|
53
69
|
parsed = new URL(url);
|
|
54
70
|
}
|
|
55
71
|
catch {
|
|
56
|
-
|
|
72
|
+
// Nothing of the string is echoed: it may carry a key in its query.
|
|
73
|
+
throw new Error(`${what} is not a URL`);
|
|
57
74
|
}
|
|
58
75
|
if (parsed.protocol !== "https:")
|
|
59
76
|
throw new Error(`${what} must be https, so the key never crosses in the clear: ${parsed.protocol}`);
|
|
60
|
-
|
|
77
|
+
// The words give the origin alone: a user, a password or a query may be a key.
|
|
78
|
+
if (parsed.username !== "" || parsed.password !== "")
|
|
79
|
+
throw new Error(`${what} takes no user or password, since the key goes to it: ${parsed.origin}`);
|
|
80
|
+
if (parsed.search !== "" || parsed.hash !== "")
|
|
81
|
+
throw new Error(`${what} takes no query or fragment: ${parsed.origin}`);
|
|
82
|
+
// The normalized form (lower-case scheme and host, a default port dropped), so a consumer that reads the scheme
|
|
83
|
+
// case-sensitively, as nice-grpc does for Modal's server, sees https.
|
|
84
|
+
return `${parsed.origin}${parsed.pathname}`.replace(/\/+$/, "");
|
|
61
85
|
}
|
|
62
86
|
export function rest(options) {
|
|
63
87
|
const base = options.base.replace(/\/+$/, "");
|
|
@@ -74,22 +98,28 @@ export function rest(options) {
|
|
|
74
98
|
return fail("aborted", `${what} was aborted`);
|
|
75
99
|
// A bound that lets go once the answer is taken, so a body read after it (a stream's) is never cut by it.
|
|
76
100
|
const timeout = new AbortController();
|
|
77
|
-
const
|
|
101
|
+
const cut = () => timeout.abort();
|
|
102
|
+
const bound = options.timeout?.(timeoutMs);
|
|
103
|
+
const timer = bound === undefined ? setTimeout(cut, timeoutMs) : undefined;
|
|
104
|
+
if (bound?.aborted)
|
|
105
|
+
cut();
|
|
106
|
+
bound?.addEventListener("abort", cut, { once: true });
|
|
78
107
|
let failure;
|
|
79
108
|
let retryable;
|
|
80
109
|
try {
|
|
81
110
|
const headers = init.json === undefined ? options.headers() : { ...options.headers(), "Content-Type": "application/json" };
|
|
111
|
+
const either = signal ? AbortSignal.any([signal, timeout.signal]) : timeout.signal;
|
|
82
112
|
// Never a redirect: a followed one keeps the key, and could carry a call to another host.
|
|
83
113
|
const response = await fetcher(url, {
|
|
84
114
|
method,
|
|
85
115
|
headers,
|
|
86
116
|
body: init.json === undefined ? (init.bytes ?? init.form) : JSON.stringify(init.json),
|
|
87
117
|
redirect: "error",
|
|
88
|
-
signal:
|
|
118
|
+
signal: either,
|
|
89
119
|
});
|
|
90
120
|
if (accepted(response.status))
|
|
91
|
-
return ok(await take(response));
|
|
92
|
-
const bytes =
|
|
121
|
+
return ok(await take(response, either));
|
|
122
|
+
const bytes = await bytesOf(response, either);
|
|
93
123
|
const own = typeof init.retry === "function";
|
|
94
124
|
retryable = own ? init.retry(response.status, bytes) : init.retry === true && (response.status === 429 || response.status >= 500);
|
|
95
125
|
const text = decoder.decode(bytes).replace(/\s+/g, " ").slice(0, 300);
|
|
@@ -102,21 +132,24 @@ export function rest(options) {
|
|
|
102
132
|
// No answer: the request may have reached the vendor, so only a call that may run twice is sent again.
|
|
103
133
|
retryable = init.retry === true;
|
|
104
134
|
if (timeout.signal.aborted)
|
|
105
|
-
failure = { code: "timeout", message: `${what} did not answer within ${timeoutMs /
|
|
106
|
-
else if (redirected(cause))
|
|
107
|
-
|
|
135
|
+
failure = { code: "timeout", message: `${what} did not answer within ${Math.round(timeoutMs / 100) / 10} s` };
|
|
136
|
+
else if (redirected(cause)) {
|
|
137
|
+
const message = `${what}: the API answered with a redirect, which is never followed: it would carry the key`;
|
|
138
|
+
return { ok: false, error: { code: "vendor", vendor: options.vendor, message, redirect: true } };
|
|
139
|
+
}
|
|
108
140
|
else
|
|
109
141
|
failure = { code: "vendor", vendor: options.vendor, message: `${what}: ${cause.message}` };
|
|
110
142
|
}
|
|
111
143
|
finally {
|
|
112
144
|
clearTimeout(timer);
|
|
145
|
+
bound?.removeEventListener("abort", cut);
|
|
113
146
|
}
|
|
114
147
|
if (!retryable || attempt >= attempts)
|
|
115
148
|
return { ok: false, error: failure };
|
|
116
149
|
await wait((options.retry?.baseMs ?? 0) * 2 ** (attempt - 1), signal);
|
|
117
150
|
}
|
|
118
151
|
}
|
|
119
|
-
const call = (method, url, init = {}, signal) => exchange(method, url, init, signal, async (response) => ({ status: response.status, bytes:
|
|
152
|
+
const call = (method, url, init = {}, signal) => exchange(method, url, init, signal, async (response, cut) => ({ status: response.status, bytes: await bytesOf(response, cut) }));
|
|
120
153
|
return {
|
|
121
154
|
url: (path) => `${base}${path}`,
|
|
122
155
|
call,
|
package/dist/hosted/scripts.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { PassThrough } from "node:stream";
|
|
2
2
|
import type { ComputerCapabilities, ComputerConnection } from "../provider.js";
|
|
3
3
|
import { type Result } from "../result.js";
|
|
4
|
+
/** Root for what follows: the command's own user when it is root, else passwordless sudo, which the install checked. */
|
|
5
|
+
export declare const ROOT = "p=; [ \"$(id -u)\" = 0 ] || p=\"sudo -n\"";
|
|
4
6
|
/** Who ran install, from its output's `installer <uid> <name>[ sudo]` line, in words; undefined when it has none. */
|
|
5
7
|
export declare function installerOf(output: string): string | undefined;
|
|
6
8
|
/** One word for a shell, single-quoted. */
|
|
@@ -13,6 +15,12 @@ export declare const shellLine: (argv: readonly string[]) => string;
|
|
|
13
15
|
export declare const AGENTRUN_DIAL = "/usr/local/bin/agentrun-dial";
|
|
14
16
|
/** Where start leaves what init writes, root's alone: the words a create that never hears the daemon gives back. */
|
|
15
17
|
export declare const INIT_LOG = "/run/agentrun-init.log";
|
|
18
|
+
/** Where read-stage leaves its copies: a directory root's alone (0700) in /run, which no other user can write. */
|
|
19
|
+
export declare const READ_COPIES = "/run/agentrun-read";
|
|
20
|
+
/** The read-stage argv: path copied to copy, read as uid:gid. */
|
|
21
|
+
export declare const readStage: (uid: string, gid: string, path: string, copy: string) => string[];
|
|
22
|
+
/** The read-unstage argv: copy removed. */
|
|
23
|
+
export declare const readUnstage: (copy: string) => string[];
|
|
16
24
|
/**
|
|
17
25
|
* The session buses a vendor's own processes leave in /tmp (Daytona's D-Bus, /tmp/dbus-Y8OW6E3FDx), which no network
|
|
18
26
|
* namespace cuts: every child host's create closes them to the computer's user before init starts. The window
|
|
@@ -119,6 +127,8 @@ export interface DaemonExpected {
|
|
|
119
127
|
* working directory and binary. Each read is bounded by timeoutMs and the caller's signal.
|
|
120
128
|
*/
|
|
121
129
|
export declare function daemonDrift(connection: ComputerConnection, expected: DaemonExpected, timeoutMs: number, signal?: AbortSignal): Promise<Result<string[]>>;
|
|
130
|
+
/** The echo of the running sh's pid and start time: PID_WRAPPER's line on stderr, and Groundbox's pid record in a file. */
|
|
131
|
+
export declare const PID_ECHO = "echo \"$$ $(s=$(cat /proc/$$/stat) && set -- ${s##*\") \"} && echo \"${20}\")\"";
|
|
122
132
|
/**
|
|
123
133
|
* The sh a process starts under where the vendor has no kill that ends it (framedExec with no kill, SSH, Modal): one
|
|
124
134
|
* line on stderr, its pid and its start time (field 22 of /proc/<pid>/stat, counted past the command's name in
|
package/dist/hosted/scripts.js
CHANGED
|
@@ -12,7 +12,7 @@ import { fail, ok } from "../result.js";
|
|
|
12
12
|
const PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
|
|
13
13
|
const CAPS = ["CapInh", "CapPrm", "CapEff", "CapBnd", "CapAmb"];
|
|
14
14
|
/** Root for what follows: the command's own user when it is root, else passwordless sudo, which the install checked. */
|
|
15
|
-
const ROOT = 'p=; [ "$(id -u)" = 0 ] || p="sudo -n"';
|
|
15
|
+
export const ROOT = 'p=; [ "$(id -u)" = 0 ] || p="sudo -n"';
|
|
16
16
|
/** Whether the daemon at d is root's alone: the binary and every directory above it owned by root and writable by no
|
|
17
17
|
* group or other user (and so no symbolic link, no ACL). Else a user who could rename an entry on the path could put
|
|
18
18
|
* another binary there, which init and every bridge would run as root. Only root can change an owner or a mode, so a
|
|
@@ -101,6 +101,25 @@ export const INIT_LOG = `${SOCKET_DIR}-init.log`;
|
|
|
101
101
|
* umask 077, so the log is root's alone whatever the vendor's umask.
|
|
102
102
|
*/
|
|
103
103
|
const START_SCRIPT = ["# agentrun-computer: start", "l=$1; shift", ROOT, `exec $p sh -c 'umask 077; exec >"$0" 2>&1 </dev/null; setsid "$@" &' "$l" "$@"`].join("\n");
|
|
104
|
+
/** Where read-stage leaves its copies: a directory root's alone (0700) in /run, which no other user can write. */
|
|
105
|
+
export const READ_COPIES = `${SOCKET_DIR}-read`;
|
|
106
|
+
/**
|
|
107
|
+
* read-stage: [uid, gid, path, copy]. Copies path to copy, the file opened as uid:gid with no supplementary groups, as
|
|
108
|
+
* the daemon opens it (setpriv, util-linux), so the copy holds only what the daemon's user can read; root writes the copy
|
|
109
|
+
* under umask 077 in its directory, READ_COPIES. A copy that fails is removed, and the script fails: where setpriv is
|
|
110
|
+
* missing or takes no --reuid, every copy fails, and the daemon reads the file.
|
|
111
|
+
*/
|
|
112
|
+
const READ_STAGE_SCRIPT = [
|
|
113
|
+
"# agentrun-computer: read-stage",
|
|
114
|
+
ROOT,
|
|
115
|
+
`exec $p sh -c 'umask 077; mkdir -p "\${3%/*}" && chmod 0700 "\${3%/*}" && setpriv --reuid="$0" --regid="$1" --clear-groups -- cat -- "$2" >"$3" || { rm -f -- "$3"; exit 1; }' "$@"`,
|
|
116
|
+
].join("\n");
|
|
117
|
+
/** read-unstage: [copy]. Removes a copy read-stage made. */
|
|
118
|
+
const READ_UNSTAGE_SCRIPT = ["# agentrun-computer: read-unstage", ROOT, 'exec $p rm -f -- "$1"'].join("\n");
|
|
119
|
+
/** The read-stage argv: path copied to copy, read as uid:gid. */
|
|
120
|
+
export const readStage = (uid, gid, path, copy) => argvOf(READ_STAGE_SCRIPT, [uid, gid, path, copy]);
|
|
121
|
+
/** The read-unstage argv: copy removed. */
|
|
122
|
+
export const readUnstage = (copy) => argvOf(READ_UNSTAGE_SCRIPT, [copy]);
|
|
104
123
|
/**
|
|
105
124
|
* The session buses a vendor's own processes leave in /tmp (Daytona's D-Bus, /tmp/dbus-Y8OW6E3FDx), which no network
|
|
106
125
|
* namespace cuts: every child host's create closes them to the computer's user before init starts. The window
|
|
@@ -327,12 +346,14 @@ export async function daemonDrift(connection, expected, timeoutMs, signal) {
|
|
|
327
346
|
}
|
|
328
347
|
return ok(found);
|
|
329
348
|
}
|
|
349
|
+
/** The echo of the running sh's pid and start time: PID_WRAPPER's line on stderr, and Groundbox's pid record in a file. */
|
|
350
|
+
export const PID_ECHO = 'echo "$$ $(s=$(cat /proc/$$/stat) && set -- ${s##*") "} && echo "${20}")"';
|
|
330
351
|
/**
|
|
331
352
|
* The sh a process starts under where the vendor has no kill that ends it (framedExec with no kill, SSH, Modal): one
|
|
332
353
|
* line on stderr, its pid and its start time (field 22 of /proc/<pid>/stat, counted past the command's name in
|
|
333
354
|
* parentheses, which may hold spaces), then the command in its place, which keeps both. pidLine takes the line off.
|
|
334
355
|
*/
|
|
335
|
-
export const PID_WRAPPER = ["sh", "-c",
|
|
356
|
+
export const PID_WRAPPER = ["sh", "-c", `${PID_ECHO} >&2; exec "$@"`, "sh"];
|
|
336
357
|
/**
|
|
337
358
|
* The sh pidKill starts, given the pid and start time: a pid whose process has ended, and may be another's now, is let
|
|
338
359
|
* be. Otherwise it kills the process and every process under it (an upload's head and base64 would wait on the open
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./provider.js";
|
|
|
4
4
|
export * from "./ui-engine.js";
|
|
5
5
|
export * from "./attach.js";
|
|
6
6
|
export * from "./mount.js";
|
|
7
|
+
export { SDK_MISSING } from "./vendor-sdk.js";
|
|
7
8
|
export { type CallOptions, DaemonClient, type DaemonStream, findNodes, refusedStep, type UiActOptions, type UiQuery, UiSession } from "./client.js";
|
|
8
9
|
export { type ActionFailure, type CheckActionsOptions, checkActions, isKey } from "./actions.js";
|
|
9
10
|
export { pullTar, pullTarStream, pushTar, readFile, writeFile, type PulledTar } from "./files.js";
|
|
@@ -15,7 +16,8 @@ export type { HostCall, HostFacts, Machine, MachineHost, MachineProcess, Machine
|
|
|
15
16
|
export { HostedProvider, type HostedDial, type HostedOptions, type HostedTimeouts, hostedDaemonPath } from "./hosted/provider.js";
|
|
16
17
|
export { type DockerVolume, VOLUME_SUBPATH_ENGINE } from "./docker/volume.js";
|
|
17
18
|
export { DEFAULT_DOCKER_IMAGE, DOCKER_BASE, DOCKER_RECIPE, DOCKER_RECIPE_HAS, ensureImage, type EnsureImageOptions, IMAGE_REPOSITORY, IMAGE_TIMEOUT_MS, type ImageSource, imageSourceProblem, type Making, RECIPE_LABEL, recipeHash, recipeTag, } from "./docker/image.js";
|
|
18
|
-
export {
|
|
19
|
+
export { ADB_ENV_NAMES, adbEnv, BASE_ENV_NAMES, CHROME_ENV_NAMES, childEnv, chromeEnv, DOCKER_ENV_NAMES, dockerEnv, type HostEnv } from "./child-env.js";
|
|
20
|
+
export { containerSigns, EGRESS_IMAGE, EGRESS_LABEL, EGRESS_MOUNT, EGRESS_SOCKET } from "./docker/egress.js";
|
|
19
21
|
export { ARCHIL_HELPER, ARCHIL_SYNC_SOCKET, ARCHIL_TOOL_UID, ARCHIL_TOOL_USER, ARCHIL_VERSION, type ArchilMount, type ArchilEgress, type ArchilMountOptions, type ArchilRoot, type ProviderNote, archilEgressOf, archilLabels, archilMount, archilReadBack, archilRefusals, archilRelease, archilSync, claimEpoch, helperSha256, MOUNT_LABEL, mountDrift, mountWords, type RecordedFolder, type RecordedSource, readMount, recordedFolder, recordedMount, SYNC_LABELS, syncingClient, } from "./mount-archil.js";
|
|
20
22
|
export { type BrowserComputerProvider, type BrowserDownloads, type BrowserFile, type BrowserProfiles, type BrowserSessionUsage, browserSpecRefusals, type BrowserStream, isBrowserProvider, BrowserVendorError, CREATE_LABEL, causeOf, memoryUrls, RECOVER_MS, type ReleaseConfirm, type RestReply, type UrlStore, } from "./browser.js";
|
|
21
23
|
export { CHROME_ENV, CHROME_FLAGS, checkChrome, chromeFence, findChrome, killTree, NO_CHROME } from "./chrome.js";
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./provider.js";
|
|
|
4
4
|
export * from "./ui-engine.js";
|
|
5
5
|
export * from "./attach.js";
|
|
6
6
|
export * from "./mount.js";
|
|
7
|
+
export { SDK_MISSING } from "./vendor-sdk.js";
|
|
7
8
|
export { DaemonClient, findNodes, refusedStep, UiSession } from "./client.js";
|
|
8
9
|
export { checkActions, isKey } from "./actions.js";
|
|
9
10
|
export { pullTar, pullTarStream, pushTar, readFile, writeFile } from "./files.js";
|
|
@@ -17,7 +18,8 @@ export { HostedProvider, hostedDaemonPath } from "./hosted/provider.js";
|
|
|
17
18
|
// /phone-harness, /browserbase, /kernel, /local, /smolcloud, /groundbox: each the provider file's name).
|
|
18
19
|
export { VOLUME_SUBPATH_ENGINE } from "./docker/volume.js";
|
|
19
20
|
export { DEFAULT_DOCKER_IMAGE, DOCKER_BASE, DOCKER_RECIPE, DOCKER_RECIPE_HAS, ensureImage, IMAGE_REPOSITORY, IMAGE_TIMEOUT_MS, imageSourceProblem, RECIPE_LABEL, recipeHash, recipeTag, } from "./docker/image.js";
|
|
20
|
-
export {
|
|
21
|
+
export { ADB_ENV_NAMES, adbEnv, BASE_ENV_NAMES, CHROME_ENV_NAMES, childEnv, chromeEnv, DOCKER_ENV_NAMES, dockerEnv } from "./child-env.js";
|
|
22
|
+
export { containerSigns, EGRESS_IMAGE, EGRESS_LABEL, EGRESS_MOUNT, EGRESS_SOCKET } from "./docker/egress.js";
|
|
21
23
|
export { ARCHIL_HELPER, ARCHIL_SYNC_SOCKET, ARCHIL_TOOL_UID, ARCHIL_TOOL_USER, ARCHIL_VERSION, archilEgressOf, archilLabels, archilMount, archilReadBack, archilRefusals, archilRelease, archilSync, claimEpoch, helperSha256, MOUNT_LABEL, mountDrift, mountWords, readMount, recordedFolder, recordedMount, SYNC_LABELS, syncingClient, } from "./mount-archil.js";
|
|
22
24
|
export { browserSpecRefusals, isBrowserProvider, BrowserVendorError, CREATE_LABEL, causeOf, memoryUrls, RECOVER_MS, } from "./browser.js";
|
|
23
25
|
// Local Chrome's provider class is on its provider id's subpath (@parcha/agentrun-computer/local-chrome), as every
|
package/dist/janitor.d.ts
CHANGED
|
@@ -11,6 +11,12 @@ export interface SweepOptions {
|
|
|
11
11
|
* agent's computer whose owner is gone is deleted; without this, no owner counts as gone.
|
|
12
12
|
*/
|
|
13
13
|
ownerGone?: (owner: ComputerOwner) => boolean | Promise<boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* Whether a leftover (sweepLeftovers: a part a computer left behind), by the labels it carries, is the caller's to
|
|
16
|
+
* remove; default every one with `labels`. A caller that shares the provider's host with another (serve: a run of
|
|
17
|
+
* this store) answers true for its own alone.
|
|
18
|
+
*/
|
|
19
|
+
mine?: (labels: Record<string, string>) => boolean | Promise<boolean>;
|
|
14
20
|
signal?: AbortSignal;
|
|
15
21
|
}
|
|
16
22
|
export interface Swept {
|
|
@@ -36,7 +42,7 @@ export interface Swept {
|
|
|
36
42
|
* provider that declares persistence is swept for its agents' computers alone under lifetime "vendor", since no vendor
|
|
37
43
|
* ends them.
|
|
38
44
|
*/
|
|
39
|
-
export declare function sweep(provider: ComputerProvider, { labels, now, ownerGone, signal }?: SweepOptions): Promise<Result<Swept>>;
|
|
45
|
+
export declare function sweep(provider: ComputerProvider, { labels, now, ownerGone, mine, signal }?: SweepOptions): Promise<Result<Swept>>;
|
|
40
46
|
export interface ReleasedOlder {
|
|
41
47
|
/** The run's computers deleted: each with a lower epoch, and each that carries no epoch it can read. */
|
|
42
48
|
released: ComputerRef[];
|
package/dist/janitor.js
CHANGED
|
@@ -49,7 +49,7 @@ async function ownerEnds(info, owner, at, ownerGone) {
|
|
|
49
49
|
* provider that declares persistence is swept for its agents' computers alone under lifetime "vendor", since no vendor
|
|
50
50
|
* ends them.
|
|
51
51
|
*/
|
|
52
|
-
export async function sweep(provider, { labels = {}, now, ownerGone, signal } = {}) {
|
|
52
|
+
export async function sweep(provider, { labels = {}, now, ownerGone, mine, signal } = {}) {
|
|
53
53
|
const { lifetime, maxLifetimeMs, persistence } = provider.capabilities();
|
|
54
54
|
if (lifetime !== "janitor" && persistence === undefined) {
|
|
55
55
|
return fail("refused", `the ${provider.id} provider declares lifetime "${lifetime}": its vendor ends its computers itself, so the janitor does not sweep them`);
|
|
@@ -95,7 +95,7 @@ export async function sweep(provider, { labels = {}, now, ownerGone, signal } =
|
|
|
95
95
|
if (provider.sweepLeftovers) {
|
|
96
96
|
if (signal?.aborted)
|
|
97
97
|
return fail("aborted", `the sweep was aborted; it had deleted ${deleted.join(", ") || "none"}`);
|
|
98
|
-
const left = await provider.sweepLeftovers({ labels, now: new Date(at), signal });
|
|
98
|
+
const left = await provider.sweepLeftovers({ labels, now: new Date(at), signal, ...(mine === undefined ? {} : { mine }) });
|
|
99
99
|
if (left.ok)
|
|
100
100
|
leftovers = left.value;
|
|
101
101
|
else {
|
package/dist/kernel.js
CHANGED
|
@@ -49,7 +49,7 @@ const text = (value) => (typeof value === "string" ? value.trim() : "");
|
|
|
49
49
|
const refOf = (id) => ({ id, name: id });
|
|
50
50
|
const statusOf = (error) => error?.status;
|
|
51
51
|
/** What a Kernel browser offers beyond the protocol, a fresh copy each time. */
|
|
52
|
-
const KERNEL_BROWSER = () => ({ timeout: "inactivity", minLifetimeMs: KERNEL_MIN_LIFETIME_MS, profiles: { settleMs:
|
|
52
|
+
const KERNEL_BROWSER = () => ({ timeout: "inactivity", minLifetimeMs: KERNEL_MIN_LIFETIME_MS, profiles: { settleMs: KERNEL.profiles.settleMs }, headless: true });
|
|
53
53
|
/** Computers that are Kernel browsers. */
|
|
54
54
|
export class KernelProvider {
|
|
55
55
|
id = "kernel";
|
package/dist/local-chrome.d.ts
CHANGED
|
@@ -12,8 +12,11 @@ export interface LocalBrowserOptions {
|
|
|
12
12
|
/** The Chrome or Chromium to run; default the one findChrome finds in `env`, then in the usual places. */
|
|
13
13
|
executablePath?: string;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* The host's environment, which it passes (serve passes its own values of the descriptor's hostEnv): where
|
|
16
|
+
* CHROME_PATH, PI_BROWSER_CHROME and PATH are read when no executablePath is given, and what the supervisor and the
|
|
17
|
+
* Chrome it starts, and the sandbox check's Chrome, hold of it: the names Chrome reads (CHROME_ENV_NAMES: PATH, HOME,
|
|
18
|
+
* the display, locale, fonts and temp directory) and nothing else, so no key the host holds reaches Chrome. The
|
|
19
|
+
* library reads none: without env, Chrome starts with none.
|
|
17
20
|
*/
|
|
18
21
|
env?: Readonly<Record<string, string | undefined>>;
|
|
19
22
|
/** Shows the window, for a person watching on this machine; default headless. */
|
package/dist/local-chrome.js
CHANGED
|
@@ -30,6 +30,7 @@ import { fileURLToPath } from "node:url";
|
|
|
30
30
|
import { browserClient, browserHello, browserSpecRefusals, carries, labelsProblem } from "./browser.js";
|
|
31
31
|
import { alive, answeringPath, CHROME_FLAGS, checkChrome, findChrome, killTree, NO_CHROME, AS_ROOT, runsWith, singletonDir } from "./chrome.js";
|
|
32
32
|
import { LOCAL } from "./descriptors/local-chrome.js";
|
|
33
|
+
import { chromeEnv } from "./child-env.js";
|
|
33
34
|
import { BROWSER_IMAGE } from "./descriptors/shared.js";
|
|
34
35
|
import { parseAllow } from "./docker/egress-proxy.js";
|
|
35
36
|
import { BROWSER_FILE, CHROME_PID_FILE, EGRESS_SOCKET_FILE, PROFILE_DIR, READY_MS, STATE_FILE, SUPERVISOR_FILE } from "./local-supervisor.js";
|
|
@@ -224,7 +225,8 @@ export class LocalBrowserProvider {
|
|
|
224
225
|
}
|
|
225
226
|
let child;
|
|
226
227
|
try {
|
|
227
|
-
|
|
228
|
+
// Its environment is Chrome's (chromeEnv), which the Chrome it starts inherits: no key the host holds.
|
|
229
|
+
child = spawn(process.execPath, [SUPERVISOR, dir], { detached: true, env: chromeEnv(this.#env), stdio: ["ignore", "pipe", "ignore"] });
|
|
228
230
|
}
|
|
229
231
|
catch (error) {
|
|
230
232
|
await rm(dir, { recursive: true, force: true }).catch(() => undefined);
|
|
@@ -290,7 +292,7 @@ export class LocalBrowserProvider {
|
|
|
290
292
|
if (refused.length > 0)
|
|
291
293
|
return fail(refused[0]?.field === "host" ? "refused" : "not_found", refused[0].message);
|
|
292
294
|
// A Chrome found or named is started once with its sandbox on: what a create would do, with nothing kept.
|
|
293
|
-
const checked = await checkChrome(this.executable(), this.#uid === undefined ? {} : { uid: this.#uid });
|
|
295
|
+
const checked = await checkChrome(this.executable(), { env: this.#env, ...(this.#uid === undefined ? {} : { uid: this.#uid }) });
|
|
294
296
|
if (!checked.ok)
|
|
295
297
|
return checked;
|
|
296
298
|
return ok({ detail: `${checked.value} starts here with its sandbox on: no key is needed` });
|
package/dist/local-supervisor.js
CHANGED
|
@@ -141,6 +141,7 @@ export async function supervise(dir, out) {
|
|
|
141
141
|
const stderr = openSync(join(dir, CHROME_LOG), "a", 0o600);
|
|
142
142
|
try {
|
|
143
143
|
const args = [...record.args, ...chromeFence(`http://${RELAY_HOST}:${relayPort}`), `--user-data-dir=${profile}`, "--remote-debugging-port=0", "--remote-debugging-address=127.0.0.1", "about:blank"]; // key-gate: loopback-rule the local Chrome's DevTools socket listens on loopback alone
|
|
144
|
+
// Chrome inherits this process's environment, which the provider cut to what Chrome reads (local-chrome.ts chromeEnv).
|
|
144
145
|
child = spawn(record.executablePath, args, {
|
|
145
146
|
stdio: ["ignore", "ignore", stderr],
|
|
146
147
|
detached: true,
|
package/dist/modal.d.ts
CHANGED
|
@@ -24,8 +24,9 @@ export interface ModalProviderOptions extends Omit<HostedOptions, "desktop" | "m
|
|
|
24
24
|
*/
|
|
25
25
|
connect?: "exec" | "dial";
|
|
26
26
|
}
|
|
27
|
-
/** The SDK's default server (modal-client@64880502:js/src/config.ts:143)
|
|
28
|
-
|
|
27
|
+
/** The SDK's default server (modal-client@64880502:js/src/config.ts:143, which writes https's own port, :443), as
|
|
28
|
+
* httpsBase hands it to the client. */
|
|
29
|
+
export declare const MODAL_DEFAULT_SERVER_URL = "https://api.modal.com";
|
|
29
30
|
/** What modalClient gives the SDK's ModalClient: the token, explicitly, so the SDK fills none of it in. */
|
|
30
31
|
export interface ModalClientParams {
|
|
31
32
|
tokenId: string;
|
|
@@ -38,7 +39,7 @@ export interface ModalClientOptions {
|
|
|
38
39
|
/** The Modal token's id and secret. Serve passes its MODAL_TOKEN_ID and MODAL_TOKEN_SECRET; the conformance module the token it reads. */
|
|
39
40
|
tokenId: string;
|
|
40
41
|
tokenSecret: string;
|
|
41
|
-
/** The server the token goes to, https alone; default the SDK's, https://api.modal.com
|
|
42
|
+
/** The server the token goes to, https alone; default the SDK's, https://api.modal.com. */
|
|
42
43
|
serverUrl?: string;
|
|
43
44
|
/** The SDK's ModalClient; imported from the host's modal package by default. */
|
|
44
45
|
ModalClient?: ModalClientConstructor;
|
|
@@ -58,8 +59,8 @@ export interface ModalCreateOptions extends Omit<ModalProviderOptions, "sdk">, M
|
|
|
58
59
|
* So this is the library's one touch of the environment, a guard and not a setting (README, Settings): an ambient
|
|
59
60
|
* MODAL_SERVER_URL is refused, and MODAL_SERVER_URL is set to the chosen server only while the client is constructed,
|
|
60
61
|
* and put back after, so no profile can redirect the key. process.env is the whole process's: constructions run one at a
|
|
61
|
-
* time, each waiting for the last, so none sees another's server. The modal package
|
|
62
|
-
* here.
|
|
62
|
+
* time, each waiting for the last, so none sees another's server. The modal package, an optional dependency, is loaded
|
|
63
|
+
* only here.
|
|
63
64
|
*/
|
|
64
65
|
export declare function modalClient({ tokenId, tokenSecret, serverUrl, ModalClient }: ModalClientOptions): Promise<ModalSdk>;
|
|
65
66
|
/**
|
package/dist/modal.js
CHANGED
|
@@ -8,12 +8,12 @@ import { AGENTRUN_DIAL, PID_WRAPPER, pidKill, pidStderr } from "./hosted/scripts
|
|
|
8
8
|
import { connectOf, kindRefusal } from "./descriptor.js";
|
|
9
9
|
import { isWhole } from "./hosted/values.js";
|
|
10
10
|
import { ok } from "./result.js";
|
|
11
|
+
import { vendorSdk } from "./vendor-sdk.js";
|
|
11
12
|
/** A GPU as the SDK takes it: the type, then :count past one ("T4", "H100:8"). */
|
|
12
13
|
const modalGpu = ({ type, count }) => (count === 1 ? type : `${type}:${count}`);
|
|
13
|
-
/** The SDK's default server (modal-client@64880502:js/src/config.ts:143)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const MODAL_PACKAGE = "modal";
|
|
14
|
+
/** The SDK's default server (modal-client@64880502:js/src/config.ts:143, which writes https's own port, :443), as
|
|
15
|
+
* httpsBase hands it to the client. */
|
|
16
|
+
export const MODAL_DEFAULT_SERVER_URL = "https://api.modal.com";
|
|
17
17
|
/** The construction now running, or the last one: the next waits for it, so two never overlap. */
|
|
18
18
|
let constructing = Promise.resolve();
|
|
19
19
|
/**
|
|
@@ -28,8 +28,8 @@ let constructing = Promise.resolve();
|
|
|
28
28
|
* So this is the library's one touch of the environment, a guard and not a setting (README, Settings): an ambient
|
|
29
29
|
* MODAL_SERVER_URL is refused, and MODAL_SERVER_URL is set to the chosen server only while the client is constructed,
|
|
30
30
|
* and put back after, so no profile can redirect the key. process.env is the whole process's: constructions run one at a
|
|
31
|
-
* time, each waiting for the last, so none sees another's server. The modal package
|
|
32
|
-
* here.
|
|
31
|
+
* time, each waiting for the last, so none sees another's server. The modal package, an optional dependency, is loaded
|
|
32
|
+
* only here.
|
|
33
33
|
*/
|
|
34
34
|
export async function modalClient({ tokenId, tokenSecret, serverUrl = MODAL_DEFAULT_SERVER_URL, ModalClient }) {
|
|
35
35
|
if (typeof tokenId !== "string" || tokenId === "" || typeof tokenSecret !== "string" || tokenSecret === "") {
|
|
@@ -39,7 +39,7 @@ export async function modalClient({ tokenId, tokenSecret, serverUrl = MODAL_DEFA
|
|
|
39
39
|
const ambient = `the Modal provider refuses to start while MODAL_SERVER_URL is set: the SDK would send the key there. Unset it, and pass the server as options.serverUrl if it is not ${MODAL_DEFAULT_SERVER_URL}`;
|
|
40
40
|
if (process.env.MODAL_SERVER_URL)
|
|
41
41
|
throw new Error(ambient);
|
|
42
|
-
const Client = ModalClient ?? (await
|
|
42
|
+
const Client = ModalClient ?? (await vendorSdk(MODAL.label, "modal")).ModalClient;
|
|
43
43
|
// getProfile reads MODAL_SERVER_URL from process.env when the client is constructed (client.ts:123), and the
|
|
44
44
|
// control-plane client is made then (client.ts:175); afterwards process.env is as it was. One construction at a time.
|
|
45
45
|
const turn = constructing.then(() => {
|
package/dist/morph.js
CHANGED
|
@@ -26,8 +26,7 @@ import { httpsBase, jsonOf, rest } from "./hosted/rest.js";
|
|
|
26
26
|
import { pemOf, SshExec, SshTunnelError } from "./hosted/ssh-exec.js";
|
|
27
27
|
import { DOMAIN, dateOf, sizeRefusals } from "./hosted/values.js";
|
|
28
28
|
import { failFor, ok } from "./result.js";
|
|
29
|
-
|
|
30
|
-
const SSH2_PACKAGE = "ssh2";
|
|
29
|
+
import { vendorSdk } from "./vendor-sdk.js";
|
|
31
30
|
/** The SDKs' base (api.ts:11 MORPH_BASE_URL) and SSH gateway (api.ts:12-13). */
|
|
32
31
|
const DEFAULT_API_URL = "https://cloud.morph.so/api";
|
|
33
32
|
const DEFAULT_SSH_HOST = "ssh.cloud.morph.so";
|
|
@@ -447,7 +446,7 @@ class MorphHost {
|
|
|
447
446
|
export async function create(options) {
|
|
448
447
|
const { ssh2: given, ...rest } = options ?? {};
|
|
449
448
|
// ssh2 is CommonJS: its Client is a named export of the module, and of its default.
|
|
450
|
-
const loaded = given ?? (await
|
|
449
|
+
const loaded = given ?? (await vendorSdk(MORPH.label, "ssh2"));
|
|
451
450
|
const ssh2 = typeof loaded.Client === "function" ? loaded : loaded.default;
|
|
452
451
|
return new MorphProvider({ ...rest, ssh2: ssh2 });
|
|
453
452
|
}
|
|
@@ -481,17 +480,15 @@ export class MorphProvider extends HostedProvider {
|
|
|
481
480
|
throw new Error("options.ssh2 must be the ssh2 package (its Client class): the host installs it, as it does for Agent37");
|
|
482
481
|
if (typeof fetcher !== "function")
|
|
483
482
|
throw new Error("options.fetch must be a function, as the global fetch is");
|
|
484
|
-
const api =
|
|
485
|
-
if (api.search !== "" || api.hash !== "")
|
|
486
|
-
throw new Error(`the Morph API URL takes no query or fragment, as ${DEFAULT_API_URL} has none: ${JSON.stringify(apiUrl)}`);
|
|
483
|
+
const api = httpsBase(apiUrl, "the Morph API URL");
|
|
487
484
|
if (typeof sshHost !== "string" || !(DOMAIN.test(sshHost) || isIP(sshHost) !== 0))
|
|
488
485
|
throw new Error(`sshHost must be a host name such as ${DEFAULT_SSH_HOST}, not ${JSON.stringify(sshHost)}`);
|
|
489
486
|
if (!Number.isSafeInteger(sshPort) || sshPort < 1 || sshPort > 65_535)
|
|
490
487
|
throw new Error(`sshPort must be a TCP port, not ${JSON.stringify(sshPort)}`);
|
|
491
|
-
super(new MorphHost({ apiKey, ssh2, fetch: fetcher, apiUrl: api
|
|
488
|
+
super(new MorphHost({ apiKey, ssh2, fetch: fetcher, apiUrl: api, sshHost, sshPort }), { ...rest, timeouts });
|
|
492
489
|
}
|
|
493
490
|
}
|
|
494
491
|
/** The account a key reaches, in words, for the sweep's scope: the key's sha256 prefix, never the key. */
|
|
495
492
|
export function accountOf(apiKey, apiUrl = DEFAULT_API_URL) {
|
|
496
|
-
return `the Morph account of the key sha256:${createHash("sha256").update(apiKey, "utf8").digest("hex").slice(0, 12)} at ${apiUrl
|
|
493
|
+
return `the Morph account of the key sha256:${createHash("sha256").update(apiKey, "utf8").digest("hex").slice(0, 12)} at ${httpsBase(apiUrl, "the Morph API URL")}`;
|
|
497
494
|
}
|
package/dist/orgo-channel.d.ts
CHANGED
|
@@ -26,8 +26,9 @@ export interface OrgoRest {
|
|
|
26
26
|
signal?: AbortSignal;
|
|
27
27
|
}): Promise<Result<T> | OrgoFailure>;
|
|
28
28
|
}
|
|
29
|
-
/** Orgo's REST API with a key: every call bounded, every failure a code and words that never hold the key.
|
|
30
|
-
|
|
29
|
+
/** Orgo's REST API with a key: every call bounded, every failure a code and words that never hold the key. `apiUrl` is
|
|
30
|
+
* httpsBase's answer, as the providers pass it. */
|
|
31
|
+
export declare function orgoRest({ apiKey, apiUrl: base, fetch: fetcher }: {
|
|
31
32
|
apiKey: string;
|
|
32
33
|
apiUrl?: string;
|
|
33
34
|
fetch?: typeof fetch;
|
package/dist/orgo-channel.js
CHANGED
|
@@ -34,9 +34,9 @@ export const quote = (word) => `'${word.replaceAll("'", "'\\''")}'`;
|
|
|
34
34
|
/** An argv as one bash command line. */
|
|
35
35
|
export const commandLine = (argv) => argv.map(quote).join(" ");
|
|
36
36
|
const codeOfStatus = (status) => status === 401 || status === 403 ? "denied" : status === 404 ? "not_found" : status === 429 ? "limit" : status === 400 || status === 422 ? "invalid" : status === 409 ? "refused" : "vendor";
|
|
37
|
-
/** Orgo's REST API with a key: every call bounded, every failure a code and words that never hold the key.
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
/** Orgo's REST API with a key: every call bounded, every failure a code and words that never hold the key. `apiUrl` is
|
|
38
|
+
* httpsBase's answer, as the providers pass it. */
|
|
39
|
+
export function orgoRest({ apiKey, apiUrl: base = ORGO_API_URL, fetch: fetcher = globalThis.fetch }) {
|
|
40
40
|
const scrub = (text) => text.replaceAll(apiKey, "[key]").replace(/\s+/g, " ").slice(0, 300);
|
|
41
41
|
return {
|
|
42
42
|
origin: new URL(base).origin,
|
package/dist/orgo-desktop.js
CHANGED
|
@@ -357,9 +357,7 @@ export class OrgoDesktopProvider {
|
|
|
357
357
|
throw new Error("options.apiKey, an Orgo API key, is required");
|
|
358
358
|
if (workspaceId !== undefined && (typeof workspaceId !== "string" || !WORKSPACE_ID.test(workspaceId)))
|
|
359
359
|
throw new Error("options.workspaceId, the Orgo workspace this deployment's computers live in, is an Orgo workspace id when given");
|
|
360
|
-
const
|
|
361
|
-
if (url.username !== "" || url.password !== "")
|
|
362
|
-
throw new Error("the Orgo API URL holds no credentials: the key goes to it");
|
|
360
|
+
const base = httpsBase(apiUrl, "the Orgo API URL");
|
|
363
361
|
if (!Number.isSafeInteger(maxLifetimeMs) || maxLifetimeMs <= 0 || maxLifetimeMs > MAX_LIFETIME_MS)
|
|
364
362
|
throw new Error(`maxLifetimeMs must be a whole number of ms above 0 and at most 720 h (${MAX_LIFETIME_MS} ms)`);
|
|
365
363
|
const merged = { ...DEFAULTS, ...timeouts };
|
|
@@ -367,7 +365,7 @@ export class OrgoDesktopProvider {
|
|
|
367
365
|
if (!Number.isSafeInteger(value) || value <= 0 || value > 2 ** 31 - 1)
|
|
368
366
|
throw new Error(`timeouts.${key} must be a whole number of ms above 0`);
|
|
369
367
|
}
|
|
370
|
-
this.#rest = orgoRest({ apiKey, apiUrl:
|
|
368
|
+
this.#rest = orgoRest({ apiKey, apiUrl: base, ...(fetch ? { fetch } : {}) });
|
|
371
369
|
this.#workspace = workspaceHolder(workspaceId, this.#rest, merged.requestMs);
|
|
372
370
|
this.#profile = PROFILES[os];
|
|
373
371
|
this.#maxLifetimeMs = maxLifetimeMs;
|
package/dist/orgo.js
CHANGED
|
@@ -197,9 +197,7 @@ export class OrgoProvider {
|
|
|
197
197
|
throw new Error("options.apiKey, an Orgo API key, is required");
|
|
198
198
|
if (workspaceId !== undefined && (typeof workspaceId !== "string" || !WORKSPACE_ID.test(workspaceId)))
|
|
199
199
|
throw new Error("options.workspaceId, the Orgo workspace this deployment's computers live in, is an Orgo workspace id when given");
|
|
200
|
-
const
|
|
201
|
-
if (url.username !== "" || url.password !== "")
|
|
202
|
-
throw new Error("the Orgo API URL holds no credentials: the key goes to it");
|
|
200
|
+
const base = httpsBase(apiUrl, "the Orgo API URL");
|
|
203
201
|
if (!Number.isSafeInteger(maxLifetimeMs) || maxLifetimeMs <= 0 || maxLifetimeMs > MAX_LIFETIME_MS)
|
|
204
202
|
throw new Error(`maxLifetimeMs must be a whole number of ms above 0 and at most Orgo's 720 h (${MAX_LIFETIME_MS} ms)`);
|
|
205
203
|
const ids = USER.exec(user);
|
|
@@ -219,7 +217,7 @@ export class OrgoProvider {
|
|
|
219
217
|
if (!Array.isArray(probeTargets) || probeTargets.length === 0 || probeTargets.some((target) => typeof target !== "string" || !TARGET.test(target))) {
|
|
220
218
|
throw new Error("probeTargets must name at least one address for the probe, each host:port or host:port/udp");
|
|
221
219
|
}
|
|
222
|
-
this.#rest = orgoRest({ apiKey, apiUrl:
|
|
220
|
+
this.#rest = orgoRest({ apiKey, apiUrl: base, ...(fetch ? { fetch } : {}) });
|
|
223
221
|
this.#workspace = workspaceHolder(workspaceId, this.#rest, merged.requestMs);
|
|
224
222
|
this.#channel = channel ?? orgoTerminalChannel({ rest: this.#rest, workspace: (signal) => this.#workspace.read(signal), ...(webSocket ? { webSocket } : {}) });
|
|
225
223
|
this.#daemonPath = daemonPath;
|
package/dist/phone-harness.d.ts
CHANGED
|
@@ -91,10 +91,11 @@ export declare const ADB_SERVER_PORT = 5037;
|
|
|
91
91
|
* The adb CLI (Android platform-tools) at path, by execFile, never a shell, and the adb server it starts, on the
|
|
92
92
|
* loopback at port (adb's own default), spoken to by its socket protocol.
|
|
93
93
|
*
|
|
94
|
-
* env is the environment a spawned adb
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* conformance module
|
|
94
|
+
* env is the environment the host passes: a spawned adb, and the adb server it starts, hold its ADB_ENV_NAMES alone
|
|
95
|
+
* (adbEnv), never a key, and none of the variables that point adb at another server or device (ADB_SERVER_SOCKET,
|
|
96
|
+
* ANDROID_ADB_SERVER_ADDRESS, ANDROID_SERIAL, ...) than its socket requests reach. The library reads no environment of
|
|
97
|
+
* its own: the provider passes its env, the conformance module process.env. Without env, adb starts with none, and a
|
|
98
|
+
* bare "adb" is found only on the default path: pass env, or adb's absolute path.
|
|
98
99
|
*/
|
|
99
100
|
export declare function adbCli(path?: string, { port, env }?: {
|
|
100
101
|
port?: number;
|
|
@@ -144,7 +145,8 @@ export interface PhoneProviderOptions {
|
|
|
144
145
|
* PHONE_HARNESS_APKS, else none. A connect that cannot install one fails in words.
|
|
145
146
|
*/
|
|
146
147
|
apks?: readonly PinnedApk[];
|
|
147
|
-
/** The host's own variables its descriptor declares (hostEnv): PHONE_HARNESS_APKS
|
|
148
|
+
/** The host's own variables its descriptor declares (hostEnv): PHONE_HARNESS_APKS, the server's apks, and what adb
|
|
149
|
+
* reads (ADB_ENV_NAMES), the only environment an adb this provider runs starts with. */
|
|
148
150
|
env?: Readonly<Record<string, string | undefined>>;
|
|
149
151
|
}
|
|
150
152
|
/** An APK the provider installs: its file's absolute path, and the sha256 of its bytes (64 lowercase hex digits). */
|