@parcha/agentrun-computer 0.1.0-beta.58 → 0.1.0-beta.60
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 +285 -81
- package/box/Dockerfile +4 -3
- package/box/install.sh +57 -11
- package/dist/agent37.d.ts +11 -4
- package/dist/agent37.js +217 -19
- package/dist/attach.d.ts +24 -4
- package/dist/attach.js +50 -19
- package/dist/boxd.js +22 -9
- package/dist/browser.d.ts +56 -11
- package/dist/browser.js +76 -17
- package/dist/browserbase.d.ts +20 -5
- package/dist/browserbase.js +186 -21
- 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 +20 -40
- package/dist/conformance/agent37.js +31 -118
- 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/cases/provider.js +4 -1
- 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 +37 -0
- package/dist/descriptor.js +9 -0
- package/dist/descriptors/agent37.d.ts +4 -1
- package/dist/descriptors/agent37.js +5 -2
- package/dist/descriptors/browserbase.d.ts +3 -0
- package/dist/descriptors/browserbase.js +4 -0
- package/dist/descriptors/docker.d.ts +2 -0
- package/dist/descriptors/docker.js +5 -0
- package/dist/descriptors/env-names.d.ts +32 -0
- package/dist/descriptors/env-names.js +60 -0
- package/dist/descriptors/index.d.ts +14 -3
- 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 +52 -13
- package/dist/docker.js +166 -92
- 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/hosted/ssh-exec.d.ts +7 -1
- package/dist/hosted/ssh-exec.js +19 -14
- package/dist/hosted/ssh-key.d.ts +18 -0
- package/dist/hosted/ssh-key.js +36 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +4 -2
- package/dist/janitor.d.ts +7 -1
- package/dist/janitor.js +2 -2
- package/dist/kernel.d.ts +14 -4
- package/dist/kernel.js +141 -18
- package/dist/local-chrome.d.ts +12 -3
- package/dist/local-chrome.js +108 -10
- 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.d.ts +6 -0
- package/dist/orgo.js +158 -15
- 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/provider.d.ts
CHANGED
|
@@ -455,13 +455,17 @@ export interface ComputerProvider {
|
|
|
455
455
|
watch?(ref: ComputerRef, handlers: ScreenWatchHandlers, options?: WatchOptions): Promise<Result<ScreenWatch>>;
|
|
456
456
|
/**
|
|
457
457
|
* Removes what this provider's computers left behind outside the computers themselves (Docker: an egress proxy and its
|
|
458
|
-
* volume whose computer is
|
|
459
|
-
*
|
|
458
|
+
* volume whose computer is not there), with all of these labels, and returns what it removed, by name. Optional; the
|
|
459
|
+
* janitor's sweep calls it after the computers, which release their own parts. With `mine`, only a leftover whose
|
|
460
|
+
* labels (the computer's spec labels it carries) `mine` answers true for is removed: a host shared by several callers
|
|
461
|
+
* has each remove its own alone. `mine` is asked before the provider reads the leftover's computer, so a caller whose
|
|
462
|
+
* answer says no create of its own is under way makes that read the last word.
|
|
460
463
|
*/
|
|
461
464
|
sweepLeftovers?(context: {
|
|
462
465
|
labels: Record<string, string>;
|
|
463
466
|
now: Date;
|
|
464
467
|
signal?: AbortSignal;
|
|
468
|
+
mine?: (labels: Record<string, string>) => boolean | Promise<boolean>;
|
|
465
469
|
}): Promise<Result<string[]>>;
|
|
466
470
|
/**
|
|
467
471
|
* One account-level read with the provider's keys (a list by label, the vendor's whoami) that never creates a
|
package/dist/screen-watch.d.ts
CHANGED
|
@@ -58,9 +58,14 @@ export interface ScreenWatch {
|
|
|
58
58
|
/** Ends the watch: no frame and no ended() after it, and its connection is let go. Idempotent. */
|
|
59
59
|
close(): Promise<void>;
|
|
60
60
|
}
|
|
61
|
+
/** The characters redactWords' four scans read in its last call, for tests: a few per character. */
|
|
62
|
+
export declare let redactWordsReads: number;
|
|
61
63
|
/**
|
|
62
64
|
* Words with no URL and no secret: a URL of any scheme, a login, a bearer, a secret-named parameter, a key- or
|
|
63
|
-
* token-shaped value and an endpoint (a host or an IPv4 address with a port) are taken out.
|
|
65
|
+
* token-shaped value and an endpoint (a host or an IPv4 address with a port) are taken out. The URL, the login, the
|
|
66
|
+
* parameter and the endpoint with a DNS name are scans that read each character a few times: as regexes with no
|
|
67
|
+
* anchored start they read to the end of a long word run from every character in it. The JWT starts only at the first
|
|
68
|
+
* eyJ of its run, for the same reason.
|
|
64
69
|
*/
|
|
65
70
|
export declare function redactWords(words: string): string;
|
|
66
71
|
/** The code a watch ends with for an error the computer gave. */
|
package/dist/screen-watch.js
CHANGED
|
@@ -31,26 +31,180 @@ export class ScreenWatchError extends Error {
|
|
|
31
31
|
const MAX_FRAME_BYTES = 64 << 20;
|
|
32
32
|
/** The most input calls a watch has in flight at once: one more is refused as limit, never queued. */
|
|
33
33
|
const MAX_INPUTS_IN_FLIGHT = 8;
|
|
34
|
+
/** The characters of each part of a URL, a login, a secret-named parameter and an endpoint, one character at a time. */
|
|
35
|
+
const URL_SCHEME = /[A-Za-z0-9+.-]/;
|
|
36
|
+
const URL_REST = /[^\s"'<>]/;
|
|
37
|
+
const LOGIN_USER = /[\w.+-]/;
|
|
38
|
+
const LOGIN_PASSWORD = /[^\s@/'"]/;
|
|
39
|
+
const LOGIN_HOST = /[\w.-]/;
|
|
40
|
+
const PARAM_NAME = /[\w-]/;
|
|
41
|
+
const PARAM_VALUE = /[^\s&"';,]/;
|
|
42
|
+
const PARAM_SECRET = /token|password|passwd|secret|key|jwt|auth|code|signingKey|credential/i;
|
|
43
|
+
const ENDPOINT_NAME = /[A-Za-z0-9.-]/;
|
|
44
|
+
const LETTER = /[A-Za-z]/;
|
|
45
|
+
const DIGIT = /\d/;
|
|
46
|
+
const WORD = /\w/;
|
|
47
|
+
/** The characters redactWords' four scans read in its last call, for tests: a few per character. */
|
|
48
|
+
export let redactWordsReads = 0;
|
|
49
|
+
/** Whether a word character (\w) is at `at`; none is before the start or past the end. */
|
|
50
|
+
function wordAt(words, at) {
|
|
51
|
+
return at >= 0 && at < words.length && WORD.test(words[at]);
|
|
52
|
+
}
|
|
53
|
+
/** The end of the run of `part` characters that starts at `from`. */
|
|
54
|
+
function runEnd(words, from, part) {
|
|
55
|
+
let at = from;
|
|
56
|
+
while (at < words.length && part.test(words[at]))
|
|
57
|
+
at++;
|
|
58
|
+
redactWordsReads += at - from + 1;
|
|
59
|
+
return at;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A URL of any scheme: a letter where \b holds, more scheme characters, :// and one or more characters. Every start in
|
|
63
|
+
* a run of scheme characters meets the same :// at the run's end, so the run is read to that end once, and the cut
|
|
64
|
+
* starts at its first letter that follows no word character.
|
|
65
|
+
*/
|
|
66
|
+
function cutUrls(words) {
|
|
67
|
+
let cut = "";
|
|
68
|
+
let kept = 0;
|
|
69
|
+
let at = 0;
|
|
70
|
+
while (at < words.length) {
|
|
71
|
+
const schemeEnd = runEnd(words, at, URL_SCHEME);
|
|
72
|
+
if (schemeEnd + 3 < words.length && words.startsWith("://", schemeEnd) && URL_REST.test(words[schemeEnd + 3])) {
|
|
73
|
+
let start = at;
|
|
74
|
+
while (start < schemeEnd && !(LETTER.test(words[start]) && !wordAt(words, start - 1)))
|
|
75
|
+
start++;
|
|
76
|
+
redactWordsReads += start - at + 4;
|
|
77
|
+
if (start < schemeEnd) {
|
|
78
|
+
cut += `${words.slice(kept, start)}[a URL]`;
|
|
79
|
+
kept = at = runEnd(words, schemeEnd + 3, URL_REST);
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
at = schemeEnd + 1;
|
|
84
|
+
}
|
|
85
|
+
return cut + words.slice(kept);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* A login in a host's place, user:password@host, each part one or more characters. A user part runs to the end of its
|
|
89
|
+
* run, so every start in a run meets the same colon, password and @ host, and fails when the first does. The scan then
|
|
90
|
+
* goes on past the password: a user part that starts inside it ends at a colon whose password ends where this one
|
|
91
|
+
* did, or at that end itself, which is no colon. So each character is read about twice, where the regex this replaces
|
|
92
|
+
* read to the end of the run from every start in it.
|
|
93
|
+
*/
|
|
94
|
+
function cutLogins(words) {
|
|
95
|
+
let cut = "";
|
|
96
|
+
let kept = 0;
|
|
97
|
+
let at = 0;
|
|
98
|
+
while (at < words.length) {
|
|
99
|
+
const userEnd = runEnd(words, at, LOGIN_USER);
|
|
100
|
+
if (userEnd === at || words[userEnd] !== ":") {
|
|
101
|
+
at = userEnd + 1;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const passwordEnd = runEnd(words, userEnd + 1, LOGIN_PASSWORD);
|
|
105
|
+
if (passwordEnd > userEnd + 1 && words[passwordEnd] === "@") {
|
|
106
|
+
const hostEnd = runEnd(words, passwordEnd + 1, LOGIN_HOST);
|
|
107
|
+
if (hostEnd > passwordEnd + 1) {
|
|
108
|
+
cut += `${words.slice(kept, at)}[a login]`;
|
|
109
|
+
kept = at = hostEnd;
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
at = passwordEnd + 1;
|
|
114
|
+
}
|
|
115
|
+
return cut + words.slice(kept);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* A secret-named parameter, its name with a prefix or suffix too (api_key=, access_token=, client_secret=): a run of
|
|
119
|
+
* [\w-] holding a secret word, then = and a value. The cut starts at the run's first word character, where \b holds,
|
|
120
|
+
* so a leading dash is kept. The value is read only when it is cut, so a run that fails is read once.
|
|
121
|
+
*/
|
|
122
|
+
function cutSecretParams(words) {
|
|
123
|
+
let cut = "";
|
|
124
|
+
let kept = 0;
|
|
125
|
+
let at = 0;
|
|
126
|
+
while (at < words.length) {
|
|
127
|
+
const nameEnd = runEnd(words, at, PARAM_NAME);
|
|
128
|
+
if (nameEnd < words.length - 1 && words[nameEnd] === "=" && PARAM_VALUE.test(words[nameEnd + 1])) {
|
|
129
|
+
const name = words.slice(at, nameEnd);
|
|
130
|
+
redactWordsReads += name.length;
|
|
131
|
+
if (PARAM_SECRET.test(name)) {
|
|
132
|
+
const valueEnd = runEnd(words, nameEnd + 1, PARAM_VALUE);
|
|
133
|
+
cut += `${words.slice(kept, at + name.search(/\w/))}[a secret]`;
|
|
134
|
+
kept = at = valueEnd;
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
at = nameEnd + 1;
|
|
139
|
+
}
|
|
140
|
+
return cut + words.slice(kept);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* An endpoint with a DNS name, as adb names a phone's: labels of [A-Za-z0-9-], a dot after each, a top-level name of
|
|
144
|
+
* two or more letters, a colon and a port of one to five digits that no word character follows. The name runs to the
|
|
145
|
+
* end of its run of [A-Za-z0-9.-], so every start in a run meets the same top-level name, colon and port. The port is
|
|
146
|
+
* read six digits at most, so a run that fails is read once.
|
|
147
|
+
*/
|
|
148
|
+
function cutEndpoints(words) {
|
|
149
|
+
let cut = "";
|
|
150
|
+
let kept = 0;
|
|
151
|
+
let at = 0;
|
|
152
|
+
while (at < words.length) {
|
|
153
|
+
const nameEnd = runEnd(words, at, ENDPOINT_NAME);
|
|
154
|
+
if (words[nameEnd] === ":") {
|
|
155
|
+
let portEnd = nameEnd + 1;
|
|
156
|
+
while (portEnd < words.length && portEnd <= nameEnd + 6 && DIGIT.test(words[portEnd]))
|
|
157
|
+
portEnd++;
|
|
158
|
+
redactWordsReads += portEnd - nameEnd;
|
|
159
|
+
const digits = portEnd - nameEnd - 1;
|
|
160
|
+
const start = digits >= 1 && digits <= 5 && !wordAt(words, portEnd) ? endpointStart(words, at, nameEnd) : -1;
|
|
161
|
+
if (start >= 0) {
|
|
162
|
+
cut += `${words.slice(kept, start)}[an endpoint]`;
|
|
163
|
+
kept = at = portEnd;
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
at = nameEnd + 1;
|
|
168
|
+
}
|
|
169
|
+
return cut + words.slice(kept);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Where an endpoint's name in words[from, end) starts, or -1: the first place where \b holds, that is no dot, and
|
|
173
|
+
* that has no empty label between it and the last dot, which the top-level name follows.
|
|
174
|
+
*/
|
|
175
|
+
function endpointStart(words, from, end) {
|
|
176
|
+
let dot = end - 1;
|
|
177
|
+
while (dot >= from && LETTER.test(words[dot]))
|
|
178
|
+
dot--;
|
|
179
|
+
redactWordsReads += end - dot;
|
|
180
|
+
if (dot < from || words[dot] !== "." || end - dot - 1 < 2)
|
|
181
|
+
return -1;
|
|
182
|
+
let low = from;
|
|
183
|
+
for (let at = from + 1; at <= dot; at++)
|
|
184
|
+
if (words[at] === "." && words[at - 1] === ".")
|
|
185
|
+
low = at + 1;
|
|
186
|
+
redactWordsReads += 2 * (dot - from);
|
|
187
|
+
for (let at = low; at < dot; at++)
|
|
188
|
+
if (words[at] !== "." && wordAt(words, at - 1) !== wordAt(words, at))
|
|
189
|
+
return at;
|
|
190
|
+
return -1;
|
|
191
|
+
}
|
|
34
192
|
/**
|
|
35
193
|
* Words with no URL and no secret: a URL of any scheme, a login, a bearer, a secret-named parameter, a key- or
|
|
36
|
-
* token-shaped value and an endpoint (a host or an IPv4 address with a port) are taken out.
|
|
194
|
+
* token-shaped value and an endpoint (a host or an IPv4 address with a port) are taken out. The URL, the login, the
|
|
195
|
+
* parameter and the endpoint with a DNS name are scans that read each character a few times: as regexes with no
|
|
196
|
+
* anchored start they read to the end of a long word run from every character in it. The JWT starts only at the first
|
|
197
|
+
* eyJ of its run, for the same reason.
|
|
37
198
|
*/
|
|
38
199
|
export function redactWords(words) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
.replace(/[\w.+-]+:[^\s@/'"]+@[\w.-]+/g, "[a login]")
|
|
43
|
-
.replace(/\b(?:Bearer|Basic)\s+[A-Za-z0-9._~+/=-]+/gi, "[a secret]")
|
|
44
|
-
// A secret-named parameter, its name with a prefix or suffix too: api_key=, access_token=, client_secret=.
|
|
45
|
-
.replace(/\b[\w-]*(?:token|password|passwd|secret|key|jwt|auth|code|signingKey|credential)[\w-]*=[^\s&"';,]+/gi, "[a secret]")
|
|
200
|
+
redactWordsReads = 0;
|
|
201
|
+
const loginsCut = cutLogins(cutUrls(words));
|
|
202
|
+
return cutEndpoints(cutSecretParams(loginsCut.replace(/\b(?:Bearer|Basic)\s+[A-Za-z0-9._~+/=-]+/gi, "[a secret]"))
|
|
46
203
|
// A token from the first "eyJ" of its run, glued to a word ("id_eyJ...") too.
|
|
47
204
|
.replace(/eyJ(?<!eyJ[A-Za-z0-9_-]*?eyJ)[A-Za-z0-9_-]+\.[A-Za-z0-9._-]*/g, "[a secret]")
|
|
48
205
|
.replace(/\b(?:sk|pk|rk)-[A-Za-z0-9_-]{8,}/g, "[a secret]")
|
|
49
206
|
.replace(/\bgh[pousr]_[A-Za-z0-9]{16,}/g, "[a secret]")
|
|
50
|
-
.replace(/\b(?:sk|pk|pck|ph|tok|pw|jwt)_[A-Za-z0-9_-]{6,}/g, "[a secret]")
|
|
51
|
-
// An endpoint: a DNS name or an IPv4 address with a port, as adb names a phone's.
|
|
52
|
-
.replace(/\b(?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,}:\d{1,5}\b/g, "[an endpoint]")
|
|
53
|
-
.replace(/\b\d{1,3}(?:\.\d{1,3}){3}(?::\d{1,5})?\b/g, "[an endpoint]"));
|
|
207
|
+
.replace(/\b(?:sk|pk|pck|ph|tok|pw|jwt)_[A-Za-z0-9_-]{6,}/g, "[a secret]")).replace(/\b\d{1,3}(?:\.\d{1,3}){3}(?::\d{1,5})?\b/g, "[an endpoint]");
|
|
54
208
|
}
|
|
55
209
|
/** The code a watch ends with for an error the computer gave. */
|
|
56
210
|
export function watchEndCode(code) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The code of the error vendorSdk throws when the SDK is not installed: serve's Settings shows its words alone. */
|
|
2
|
+
export declare const SDK_MISSING = "sdk_missing";
|
|
3
|
+
/**
|
|
4
|
+
* The SDK package `name` that `vendor`'s provider calls. When it is not installed, an error with code SDK_MISSING whose
|
|
5
|
+
* words name the package and the install step at this package's pin, such as "E2B needs the e2b package: npm install
|
|
6
|
+
* e2b@2.63.0". "Not installed" is read from resolving `name` itself, before it loads: an installed SDK whose own import
|
|
7
|
+
* fails (a file or a dependency of its own missing) throws that failure as it is, naming the module that is missing.
|
|
8
|
+
*/
|
|
9
|
+
export declare function vendorSdk<T>(vendor: string, name: string): Promise<T>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// A vendor's SDK, loaded when its provider is made. Each is one of this package's optionalDependencies, pinned exactly
|
|
2
|
+
// (package.json), so a plain `npm install` brings it and `npm install --omit=optional` leaves it out. The name is an
|
|
3
|
+
// argument here, never an import literal, so no type checker resolves an SDK's types from this package: a provider names
|
|
4
|
+
// only the slice it calls. test/vendor-sdks.test.mjs finds every call and holds each name to a pinned optional
|
|
5
|
+
// dependency.
|
|
6
|
+
import { readFileSync } from "node:fs";
|
|
7
|
+
/** The code of the error vendorSdk throws when the SDK is not installed: serve's Settings shows its words alone. */
|
|
8
|
+
export const SDK_MISSING = "sdk_missing";
|
|
9
|
+
/**
|
|
10
|
+
* The SDK package `name` that `vendor`'s provider calls. When it is not installed, an error with code SDK_MISSING whose
|
|
11
|
+
* words name the package and the install step at this package's pin, such as "E2B needs the e2b package: npm install
|
|
12
|
+
* e2b@2.63.0". "Not installed" is read from resolving `name` itself, before it loads: an installed SDK whose own import
|
|
13
|
+
* fails (a file or a dependency of its own missing) throws that failure as it is, naming the module that is missing.
|
|
14
|
+
*/
|
|
15
|
+
export async function vendorSdk(vendor, name) {
|
|
16
|
+
try {
|
|
17
|
+
import.meta.resolve(name);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (error?.code !== "ERR_MODULE_NOT_FOUND")
|
|
21
|
+
throw error;
|
|
22
|
+
const pins = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).optionalDependencies;
|
|
23
|
+
throw Object.assign(new Error(`${vendor} needs the ${name} package: npm install ${name}@${pins?.[name]}`, { cause: error }), { code: SDK_MISSING });
|
|
24
|
+
}
|
|
25
|
+
return (await import(name));
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcha/agentrun-computer",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.60",
|
|
4
4
|
"description": "The open platform's computer protocol: a daemon in every computer, and one provisioner per vendor, starting with Docker.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentrun",
|
|
@@ -117,6 +117,13 @@
|
|
|
117
117
|
"NOTICE"
|
|
118
118
|
],
|
|
119
119
|
"sideEffects": false,
|
|
120
|
+
"optionalDependencies": {
|
|
121
|
+
"@boxd-sh/sdk": "0.3.1",
|
|
122
|
+
"disk": "1.12.0",
|
|
123
|
+
"e2b": "2.63.0",
|
|
124
|
+
"modal": "0.11.1",
|
|
125
|
+
"ssh2": "1.17.0"
|
|
126
|
+
},
|
|
120
127
|
"scripts": {
|
|
121
128
|
"build": "tsc -p tsconfig.json",
|
|
122
129
|
"build:daemon": "node scripts/build-daemon.mjs",
|