@parcha/agentrun-computer 0.1.0-beta.60 → 0.1.0-beta.62

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.
@@ -13,6 +13,7 @@ import { MODAL } from "./modal.js";
13
13
  import { MORPH } from "./morph.js";
14
14
  import { ORGO } from "./orgo.js";
15
15
  import { PHONE_HARNESS } from "./phone-harness.js";
16
+ import { RENDER } from "./render.js";
16
17
  import { SMOLCLOUD } from "./smolcloud.js";
17
18
  export declare const DESCRIPTORS: readonly [{
18
19
  readonly id: "docker";
@@ -288,6 +289,25 @@ export declare const DESCRIPTORS: readonly [{
288
289
  }];
289
290
  readonly prepareImage: true;
290
291
  readonly load: () => Promise<typeof import("../fly.js")>;
292
+ }, {
293
+ readonly id: "render";
294
+ readonly label: "Render";
295
+ readonly keys: readonly [{
296
+ readonly name: "RENDER_API_KEY";
297
+ readonly option: "apiKey";
298
+ readonly required: true;
299
+ }, {
300
+ readonly name: "RENDER_WORKSPACE_ID";
301
+ readonly option: "ownerId";
302
+ readonly required: true;
303
+ }];
304
+ readonly metered: true;
305
+ readonly connect: "dial";
306
+ readonly mounts: readonly [];
307
+ readonly network: readonly ["none", "open", "allow"];
308
+ readonly capabilities: readonly [import("../kinds.js").KindCapabilities];
309
+ readonly prepareImage: true;
310
+ readonly load: () => Promise<typeof import("../render.js")>;
291
311
  }, {
292
312
  readonly id: "orgo";
293
313
  readonly label: "Orgo";
@@ -529,7 +549,7 @@ export declare const DESCRIPTORS: readonly [{
529
549
  readonly prepareImage: true;
530
550
  readonly load: () => Promise<typeof import("../groundbox.js")>;
531
551
  }];
532
- export { AGENT37, BOXD, BROWSERBASE, CLOUDFLARE, DAYTONA, DOCKER, E2B, FLY, GROUNDBOX, KERNEL, LOCAL, MODAL, MORPH, ORGO, PHONE_HARNESS, SMOLCLOUD };
552
+ export { AGENT37, BOXD, BROWSERBASE, CLOUDFLARE, DAYTONA, DOCKER, E2B, FLY, GROUNDBOX, KERNEL, LOCAL, MODAL, MORPH, ORGO, PHONE_HARNESS, RENDER, SMOLCLOUD };
533
553
  export { AGENT37_BASE_TEMPLATE } from "./agent37.js";
534
554
  export { BOXD_DEFAULT_IMAGE } from "./boxd.js";
535
555
  export { GROUNDBOX_OWN_IMAGE } from "./groundbox.js";
@@ -15,9 +15,10 @@ import { MODAL } from "./modal.js";
15
15
  import { MORPH } from "./morph.js";
16
16
  import { ORGO } from "./orgo.js";
17
17
  import { PHONE_HARNESS } from "./phone-harness.js";
18
+ import { RENDER } from "./render.js";
18
19
  import { SMOLCLOUD } from "./smolcloud.js";
19
- export const DESCRIPTORS = [DOCKER, DAYTONA, MODAL, E2B, AGENT37, MORPH, CLOUDFLARE, FLY, ORGO, PHONE_HARNESS, BROWSERBASE, KERNEL, LOCAL, BOXD, SMOLCLOUD, GROUNDBOX];
20
- export { AGENT37, BOXD, BROWSERBASE, CLOUDFLARE, DAYTONA, DOCKER, E2B, FLY, GROUNDBOX, KERNEL, LOCAL, MODAL, MORPH, ORGO, PHONE_HARNESS, SMOLCLOUD };
20
+ export const DESCRIPTORS = [DOCKER, DAYTONA, MODAL, E2B, AGENT37, MORPH, CLOUDFLARE, FLY, RENDER, ORGO, PHONE_HARNESS, BROWSERBASE, KERNEL, LOCAL, BOXD, SMOLCLOUD, GROUNDBOX];
21
+ export { AGENT37, BOXD, BROWSERBASE, CLOUDFLARE, DAYTONA, DOCKER, E2B, FLY, GROUNDBOX, KERNEL, LOCAL, MODAL, MORPH, ORGO, PHONE_HARNESS, RENDER, SMOLCLOUD };
21
22
  export { AGENT37_BASE_TEMPLATE } from "./agent37.js";
22
23
  export { BOXD_DEFAULT_IMAGE } from "./boxd.js";
23
24
  export { GROUNDBOX_OWN_IMAGE } from "./groundbox.js";
@@ -0,0 +1,20 @@
1
+ export declare const RENDER: {
2
+ readonly id: "render";
3
+ readonly label: "Render";
4
+ readonly keys: readonly [{
5
+ readonly name: "RENDER_API_KEY";
6
+ readonly option: "apiKey";
7
+ readonly required: true;
8
+ }, {
9
+ readonly name: "RENDER_WORKSPACE_ID";
10
+ readonly option: "ownerId";
11
+ readonly required: true;
12
+ }];
13
+ readonly metered: true;
14
+ readonly connect: "dial";
15
+ readonly mounts: readonly [];
16
+ readonly network: readonly ["none", "open", "allow"];
17
+ readonly capabilities: readonly [import("../kinds.js").KindCapabilities];
18
+ readonly prepareImage: true;
19
+ readonly load: () => Promise<typeof import("../render.js")>;
20
+ };
@@ -0,0 +1,31 @@
1
+ // Render's descriptor: a Linux sandbox on a Render Sandbox (a microVM) in the operator's Render workspace, started from
2
+ // our box image, imported once into the workspace as a sandbox build by its prepareImage() (box-image.ts).
3
+ // Its machines dial the server (MachineHost facts.connect "dial"): Render's runs answer a command with no stdin, so
4
+ // nothing reaches into a sandbox from outside, and its computerd dials the server's attach route instead.
5
+ import { defineProvider } from "../descriptor.js";
6
+ import { SANDBOX } from "./shared.js";
7
+ export const RENDER = defineProvider({
8
+ id: "render",
9
+ label: "Render",
10
+ keys: [
11
+ { name: "RENDER_API_KEY", option: "apiKey", required: true },
12
+ // The workspace (owner) every sandbox is made in and listed from: Render's list needs it (tea-... or usr-...).
13
+ { name: "RENDER_WORKSPACE_ID", option: "ownerId", required: true },
14
+ ],
15
+ metered: true,
16
+ // Its machines dial the server: Render's runs take no stdin, so nothing reaches into one.
17
+ connect: "dial",
18
+ // None: a machine that dials takes no Archil mount (mountsOf).
19
+ mounts: [],
20
+ // None: its programs run in init's network of their own, their loopback alone (isolation.ts). Open and a list: their
21
+ // one way out is init's egress proxy, which reaches the public internet alone, and with a list its hosts alone
22
+ // (hosted/network.ts). The sandbox itself always reaches out (Render's allow-all): it fetches its daemon from the
23
+ // server and dials it.
24
+ network: ["none", "open", "allow"],
25
+ // A linux computer alone: no desktop yet.
26
+ capabilities: [SANDBOX],
27
+ // No default image: Render's base image has no agentrun-dial, so every computer starts from the box build its
28
+ // prepareImage() answers.
29
+ prepareImage: true,
30
+ load: () => import("../render.js"),
31
+ });
package/dist/host.d.ts CHANGED
@@ -266,13 +266,16 @@ export interface HostFacts {
266
266
  * value together, the adapter's at their longest. Past either, check() refuses, and so create, before any host call.
267
267
  * Absent: no bound. packed: the adapter packs the labels it gives create (packLabels, ./hosted/values.ts: one name to
268
268
  * list by, the map in parts of at most valueBytes each), unpacks those get and list answer, and asks list for that
269
- * name alone; the host stores and answers them as they are. count and bytes are then the packed labels'.
269
+ * name alone; the host stores and answers them as they are. count and bytes are then the packed labels'. unpacked:
270
+ * the host's machines may also carry their labels as given (made before it packed): one with no packed map reads as
271
+ * its stored labels, and a listing by name asks for the labels as given beside the packed name.
270
272
  */
271
273
  labels?: {
272
274
  count?: number;
273
275
  bytes?: number;
274
276
  packed?: {
275
277
  valueBytes?: number;
278
+ unpacked?: true;
276
279
  };
277
280
  };
278
281
  /**
@@ -184,7 +184,9 @@ export declare class HostedProvider implements ComputerProvider {
184
184
  /**
185
185
  * The host's listing by labels, bounded by ms: only the machines that carry every one of them, since a vendor's listing
186
186
  * may answer more (MachineHost.list). A packed host is asked for PACKED_NAME alone, the name's where one is asked, and
187
- * its machines' labels unpacked.
187
+ * its machines' labels unpacked. A listing by name on a host whose machines may also carry their labels as given
188
+ * (facts.labels.packed.unpacked) asks both ways, one after the other within ms together, and answers every machine
189
+ * either finds: across an upgrade one request can make one machine of each form, and convergence must see both.
188
190
  */
189
191
  export declare function listedBy(host: MachineHost, what: string, labels: Record<string, string>, ms: number, signal?: AbortSignal): Promise<Result<Machine[]>>;
190
192
  /**
@@ -29,7 +29,7 @@ import { countTested } from "../test-connection.js";
29
29
  import { waitUntil } from "../wait.js";
30
30
  import { bounded, CALL_SLACK_MS, hostCall, openBridge, pause, rootOf, runToExit, seconds, untilAborted, uploadThroughExec, words } from "./process.js";
31
31
  import { downloadingConnection } from "./download.js";
32
- import { isWhole, PACKED_NAME, packLabels, unpackLabels } from "./values.js";
32
+ import { isPackedKey, isWhole, PACKED_NAME, packLabels, unpackLabels } from "./values.js";
33
33
  import { EGRESS_POLICY, EGRESS_PROXY_USER, EGRESS_RELAY, HOSTED_ALLOW, NETWORK_LABEL, networkFormOf, networkOfForm, networkRefusal, throughProxy } from "./network.js";
34
34
  import { ARCHIL_GATE, closedSocketsOf, daemonDrift, hostedCommands, initFlags, installerOf } from "./scripts.js";
35
35
  const VERSION = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8")).version;
@@ -1772,18 +1772,38 @@ function packedRoom(host) {
1772
1772
  const room = host.facts.labels;
1773
1773
  return room?.packed ? room : undefined;
1774
1774
  }
1775
- /** A machine as the host read it, with a packed host's labels unpacked: none where it holds no packed map (not the adapter's). */
1776
- const unpacked = (host, machine) => (packedRoom(host) === undefined ? machine : { ...machine, labels: unpackLabels(machine.labels) ?? {} });
1775
+ /**
1776
+ * A machine as the host read it, with a packed host's labels unpacked. One that holds no packed map has none (not the
1777
+ * adapter's), or its stored labels on a host whose machines may carry them as given (facts.labels.packed.unpacked).
1778
+ */
1779
+ function unpacked(host, machine) {
1780
+ const room = packedRoom(host);
1781
+ if (room === undefined)
1782
+ return machine;
1783
+ return { ...machine, labels: unpackLabels(machine.labels) ?? (room.packed?.unpacked ? machine.labels : {}) };
1784
+ }
1777
1785
  /**
1778
1786
  * The host's listing by labels, bounded by ms: only the machines that carry every one of them, since a vendor's listing
1779
1787
  * may answer more (MachineHost.list). A packed host is asked for PACKED_NAME alone, the name's where one is asked, and
1780
- * its machines' labels unpacked.
1788
+ * its machines' labels unpacked. A listing by name on a host whose machines may also carry their labels as given
1789
+ * (facts.labels.packed.unpacked) asks both ways, one after the other within ms together, and answers every machine
1790
+ * either finds: across an upgrade one request can make one machine of each form, and convergence must see both.
1781
1791
  */
1782
1792
  export async function listedBy(host, what, labels, ms, signal) {
1783
1793
  const name = labels[NAME_LABEL];
1784
- const asked = packedRoom(host) === undefined ? labels : name === undefined ? {} : { [PACKED_NAME]: name };
1785
- const listed = await hostCall(host, what, (ctx) => host.list(asked, ctx), ms, signal);
1786
- return listed.ok ? ok(listed.value.map((machine) => unpacked(host, machine)).filter((machine) => carries(machine, labels))) : listed;
1794
+ const room = packedRoom(host);
1795
+ const asks = room === undefined ? [labels] : name === undefined ? [{}] : room.packed?.unpacked ? [{ [PACKED_NAME]: name }, labels] : [{ [PACKED_NAME]: name }];
1796
+ const until = Date.now() + ms;
1797
+ const found = new Map();
1798
+ for (const asked of asks) {
1799
+ const listed = await hostCall(host, what, (ctx) => host.list(asked, ctx), Math.max(1, until - Date.now()), signal);
1800
+ if (!listed.ok)
1801
+ return listed;
1802
+ for (const machine of listed.value)
1803
+ if (!found.has(machine.id))
1804
+ found.set(machine.id, unpacked(host, machine));
1805
+ }
1806
+ return ok([...found.values()].filter((machine) => carries(machine, labels)));
1787
1807
  }
1788
1808
  /** Whether a machine carries every one of these labels. */
1789
1809
  const carries = (machine, labels) => Object.entries(labels).every(([key, value]) => machine.labels?.[key] === value);
@@ -1942,6 +1962,9 @@ function labelProblem(key, value) {
1942
1962
  return `the label ${key} is in the provider's own namespace (${COMPUTER_LABEL})`;
1943
1963
  if (key === MOUNT_LABEL)
1944
1964
  return `the label ${key} is the provider's own: it records a computer's mount`;
1965
+ // Labels stored as given (an older server's, a host that doesn't pack) under one of these would read back as a packed map.
1966
+ if (isPackedKey(key))
1967
+ return `the label ${key} is reserved: ${PACKED_NAME} and ${PACKED_NAME}-<n> (${PACKED_NAME}-0, ${PACKED_NAME}-1 and on) hold a computer's packed labels`;
1945
1968
  return undefined;
1946
1969
  }
1947
1970
  /** "a" or "an" before a vendor's name, by its first letter. */
@@ -89,6 +89,12 @@ export interface Rest {
89
89
  * host name and Fly nothing, and each builds its https URL itself.
90
90
  */
91
91
  export declare function httpsBase(url: string, what: string): string;
92
+ /**
93
+ * httpsBase's rule over `schemes` (each as URL.protocol gives it, `https:`): the same refusals in the same words, the
94
+ * same normalized form. For a URL a key goes to whose own protocol allows another scheme: a socket's wss, or the http
95
+ * of an OpenTelemetry collector or of a server on loopback.
96
+ */
97
+ export declare function keyBase(url: string, what: string, schemes: readonly string[]): string;
92
98
  export declare function rest(options: RestOptions): Rest;
93
99
  /** The JSON value of each line of a body of newline-delimited JSON, as the lines come; a line that is not JSON throws. */
94
100
  export declare function ndjson(body: AsyncIterable<Uint8Array>): AsyncIterable<unknown>;
@@ -64,6 +64,14 @@ const NO_BODY = { async *[Symbol.asyncIterator]() { } };
64
64
  * host name and Fly nothing, and each builds its https URL itself.
65
65
  */
66
66
  export function httpsBase(url, what) {
67
+ return keyBase(url, what, ["https:"]);
68
+ }
69
+ /**
70
+ * httpsBase's rule over `schemes` (each as URL.protocol gives it, `https:`): the same refusals in the same words, the
71
+ * same normalized form. For a URL a key goes to whose own protocol allows another scheme: a socket's wss, or the http
72
+ * of an OpenTelemetry collector or of a server on loopback.
73
+ */
74
+ export function keyBase(url, what, schemes) {
67
75
  let parsed;
68
76
  try {
69
77
  parsed = new URL(url);
@@ -72,8 +80,9 @@ export function httpsBase(url, what) {
72
80
  // Nothing of the string is echoed: it may carry a key in its query.
73
81
  throw new Error(`${what} is not a URL`);
74
82
  }
75
- if (parsed.protocol !== "https:")
76
- throw new Error(`${what} must be https, so the key never crosses in the clear: ${parsed.protocol}`);
83
+ const clear = schemes.includes("http:") || schemes.includes("ws:") ? "" : ", so the key never crosses in the clear";
84
+ if (!schemes.includes(parsed.protocol))
85
+ throw new Error(`${what} must be ${schemes.map((scheme) => scheme.replace(/:$/, "")).join(" or ")}${clear}: ${parsed.protocol}`);
77
86
  // The words give the origin alone: a user, a password or a query may be a key.
78
87
  if (parsed.username !== "" || parsed.password !== "")
79
88
  throw new Error(`${what} takes no user or password, since the key goes to it: ${parsed.origin}`);
@@ -9,6 +9,8 @@ export declare function sizeRefusals(spec: Partial<ComputerSpec>, computer: stri
9
9
  export declare function dateOf(value: unknown, unit?: "ms" | "s"): Date | undefined;
10
10
  /** The label a packed machine is listed by (packLabels): its value is the machine's name, MachineRequest.name. */
11
11
  export declare const PACKED_NAME = "agentrun";
12
+ /** A key the packed map stores under: PACKED_NAME, or agentrun-<n>. A caller's label is refused under one (labelProblem). */
13
+ export declare function isPackedKey(key: string): boolean;
12
14
  /**
13
15
  * A machine's labels as a vendor whose labels can't hold them as they are stores them (facts.labels.packed): a cap of 5
14
16
  * tags, Kubernetes' values, Cloudflare's 16-byte names, a list of strings. PACKED_NAME, the one label a host's list
@@ -17,6 +17,10 @@ export function dateOf(value, unit = "ms") {
17
17
  export const PACKED_NAME = "agentrun";
18
18
  /** The packed map's parts: agentrun-0, agentrun-1, and on. */
19
19
  const PART = `${PACKED_NAME}-`;
20
+ /** A key the packed map stores under: PACKED_NAME, or agentrun-<n>. A caller's label is refused under one (labelProblem). */
21
+ export function isPackedKey(key) {
22
+ return key === PACKED_NAME || new RegExp(`^${PART}[0-9]+$`).test(key);
23
+ }
20
24
  /** The most bytes of a packed map's JSON: unpackLabels inflates no more. */
21
25
  const PACKED_JSON_MAX = 1 << 20;
22
26
  /**
package/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ export { listProcesses, readAll, type ReadAllResult } from "./processes.js";
14
14
  export { type ActionMapper, createActionMapper, daemonWatch, redactWords, type ScreenFrame, type ScreenFrames, type ScreenWatch, ScreenWatchError, type ScreenWatchHandlers, toAction, type ViewerEvent, type WatchEndCode, watchEndCode, type WatchOptions, watchScreen, } from "./screen-watch.js";
15
15
  export type { HostCall, HostFacts, Machine, MachineHost, MachineProcess, MachineRequest } from "./host.js";
16
16
  export { HostedProvider, type HostedDial, type HostedOptions, type HostedTimeouts, hostedDaemonPath } from "./hosted/provider.js";
17
+ export { httpsBase, keyBase } from "./hosted/rest.js";
17
18
  export { type DockerVolume, VOLUME_SUBPATH_ENGINE } from "./docker/volume.js";
18
19
  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";
19
20
  export { ADB_ENV_NAMES, adbEnv, BASE_ENV_NAMES, CHROME_ENV_NAMES, childEnv, chromeEnv, DOCKER_ENV_NAMES, dockerEnv, type HostEnv } from "./child-env.js";
package/dist/index.js CHANGED
@@ -13,6 +13,9 @@ export { TarReader, tarEntry, tarOf, tarStream, untar, untarStream } from "./tar
13
13
  export { listProcesses, readAll } from "./processes.js";
14
14
  export { createActionMapper, daemonWatch, redactWords, ScreenWatchError, toAction, watchEndCode, watchScreen, } from "./screen-watch.js";
15
15
  export { HostedProvider, hostedDaemonPath } from "./hosted/provider.js";
16
+ // The one rule for a URL a key is sent to, which serve applies to the URLs it reads from its environment too: httpsBase,
17
+ // and keyBase for one whose protocol allows another scheme (a socket's wss, a collector's or loopback's http).
18
+ export { httpsBase, keyBase } from "./hosted/rest.js";
16
19
  // The provider classes and their option types are not here: each provider loads by its id through the registry
17
20
  // (providerFor), or from its own subpath (@parcha/agentrun-computer/docker, /daytona, /modal, /e2b, /agent37, /morph, /orgo,
18
21
  // /phone-harness, /browserbase, /kernel, /local, /smolcloud, /groundbox: each the provider file's name).
package/dist/kernel.js CHANGED
@@ -173,7 +173,7 @@ export class KernelProvider {
173
173
  // The browser may have been made though its answer never came: found by this POST's attempt label and deleted,
174
174
  // and the request is ended, so it is never made again.
175
175
  this.#requests.end(request);
176
- return causedFail(failed.error.code, `${failed.error.message}; ${await this.#recover(attempt)}`, causeOf(failed), "kernel");
176
+ return causedFail(failed.error.code, `${failed.error.message}; ${await this.#recover(attempt, request)}`, causeOf(failed), "kernel");
177
177
  }
178
178
  const browser = (made.json ?? {});
179
179
  const id = text(browser.session_id);
@@ -185,7 +185,7 @@ export class KernelProvider {
185
185
  if (failed.ok)
186
186
  return failed;
187
187
  this.#requests.end(request);
188
- return fail(failed.error.code, `${failed.error.message}; ${await this.#recover(attempt)}`);
188
+ return fail(failed.error.code, `${failed.error.message}; ${await this.#recover(attempt, request)}`);
189
189
  }
190
190
  this.#requests.made(request);
191
191
  // Another process's create of this request may have made one too (#converge): the older is answered.
@@ -195,9 +195,9 @@ export class KernelProvider {
195
195
  this.#requestOf.set(id, request);
196
196
  const unusable = cdpUrlProblem(url, NAME, CDP_DOMAIN);
197
197
  if (unusable !== undefined) {
198
- // The browser is made and billed until its idle timeout: deleted here, not left to a later sweep.
199
- const released = await this.release(refOf(id), "delete");
200
- return vendorFail("kernel", `Kernel POST /browsers made a browser with no CDP URL to hand over: ${unusable}; ${released.ok ? "the browser was released" : `the browser was not released (${released.error.code}), and its tags let a sweep find it`}`);
198
+ // The browser is made and billed until its idle timeout: deleted here, under the cleanup's own bound.
199
+ const released = await boundedRelease("browser", id, this.#cleanupMs, (bound) => this.release(refOf(id), "delete", { signal: bound }));
200
+ return vendorFail("kernel", `Kernel POST /browsers made a browser with no CDP URL to hand over: ${unusable}; ${released.ok ? "the browser was released" : `the browser was not released (${released.error.message}), and its tags let a sweep find it`}`);
201
201
  }
202
202
  this.#urls.set(id, url);
203
203
  const live = text(browser.browser_live_view_url);
@@ -318,12 +318,18 @@ export class KernelProvider {
318
318
  * another, carries an attempt label of its own and is left alone, even one another instance has answered. #browsers
319
319
  * reads every state not deleted, so a browser still starting is found and released too.
320
320
  */
321
- #recover(labels) {
321
+ #recover(labels, request) {
322
322
  const find = async (signal) => {
323
323
  const found = await this.#browsers(labels, signal);
324
324
  return found.ok ? ok(found.value.map((b) => b.id)) : found;
325
325
  };
326
- return recoverCreate("browser", find, (id, signal) => this.release(refOf(id), "delete", { signal }), this.#sleep, this.#cleanupMs);
326
+ const made = (signal) => this.#requestBrowsers(request, signal);
327
+ return recoverCreate("browser", find, (id, signal) => this.release(refOf(id), "delete", { signal }), this.#sleep, this.#cleanupMs, made);
328
+ }
329
+ /** The request's browsers, deleted ones included, for a lost create's recovery (recoverCreate, leftToConverge). */
330
+ async #requestBrowsers(request, signal) {
331
+ const made = await this.#browsers({ [CREATE_LABEL]: request }, signal, true);
332
+ return made.ok ? ok(made.value.map((row) => ({ ...heldOf(row), live: row.deleted === undefined }))) : made;
327
333
  }
328
334
  /**
329
335
  * Settings' test: one page of the organization's active browsers (GET /browsers?status=active), which makes nothing.
@@ -403,17 +409,16 @@ export class KernelProvider {
403
409
  * browser still starting, which bills), and a row with deleted_at is dropped here; so list and attach show a starting
404
410
  * browser, as Browserbase lists a PENDING session, and a lost create's recovery misses none. The match is the
405
411
  * provider's own, so a lane that drops the filter never hands back another's. A page that cannot be read fails the
406
- * whole list: a release trusts it.
412
+ * whole list: a release trusts it. `withDeleted` keeps the deleted rows too, marked deleted (#requestBrowsers).
407
413
  */
408
- async #browsers(labels, signal) {
414
+ async #browsers(labels, signal, withDeleted = false) {
409
415
  const problem = labelsProblem(labels);
410
416
  if (problem)
411
417
  return fail("invalid", problem);
412
418
  if (Object.keys(labels).length === 0)
413
419
  return fail("invalid", "list and attach take at least one label: a Kernel organization holds browsers this provider did not make");
414
420
  const first = Object.entries(labels).find(queryable);
415
- const found = [];
416
- const seen = new Set();
421
+ const found = new Map();
417
422
  const call = "GET /browsers";
418
423
  for (let offset = 0, pages = 0; pages < MAX_PAGES; pages++) {
419
424
  const query = new URLSearchParams({ status: "all", ...(first === undefined ? {} : { [`tags[${first[0]}]`]: first[1] }), limit: "100", offset: String(offset) });
@@ -431,14 +436,21 @@ export class KernelProvider {
431
436
  return vendorFailure("kernel", NAME, call, new BrowserVendorError(NAME, call, page.status, "not_a_list"));
432
437
  for (const row of page.json) {
433
438
  const id = text(row?.session_id);
434
- if (id !== "" && !row.deleted_at && carries(row.tags, labels) && !seen.has(id)) {
435
- seen.add(id);
436
- const createdAt = text(row.created_at);
437
- found.push({ id, tags: withoutCreateLabel(labelsOf(row.tags)), ...(createdAt === "" ? {} : { createdAt }) });
439
+ if (id === "" || (!withDeleted && row.deleted_at) || !carries(row.tags, labels))
440
+ continue;
441
+ const before = found.get(id);
442
+ // A browser listed twice (pages shifted under the read) reads as deleted once either row says so: a delete is
443
+ // never undone.
444
+ if (before !== undefined) {
445
+ if (row.deleted_at && before.deleted === undefined)
446
+ found.set(id, { ...before, deleted: true });
447
+ continue;
438
448
  }
449
+ const createdAt = text(row.created_at);
450
+ found.set(id, { id, tags: withoutCreateLabel(labelsOf(row.tags)), ...(createdAt === "" ? {} : { createdAt }), ...(row.deleted_at ? { deleted: true } : {}) });
439
451
  }
440
452
  if (page.headers.get("x-has-more") !== "true")
441
- return ok(found);
453
+ return ok([...found.values()]);
442
454
  const next = Number(page.headers.get("x-next-offset"));
443
455
  if (!Number.isInteger(next) || next <= offset)
444
456
  return vendorFail("kernel", "Kernel reported more browsers without the next page's offset");
package/dist/modal.js CHANGED
@@ -143,7 +143,9 @@ class ModalHost {
143
143
  windowManager: true,
144
144
  // Never root: each connection is Modal's exec of the stdio bridge, as Modal's root, outside the daemon.
145
145
  user: ["uid"],
146
- labels: { count: MAX_TAGS, bytes: MAX_TAG_BYTES },
146
+ // Packed: the server's labels (a mount, a network list, an owner, a run and its deadlines) pass 512 bytes as they
147
+ // are. A value holds 64 KiB, so the map is one tag. Sandboxes made before packing carry their tags as given.
148
+ labels: { count: MAX_TAGS, bytes: MAX_TAG_BYTES, packed: { unpacked: true } },
147
149
  };
148
150
  if (connect === "exec")
149
151
  this.exec = (id, argv, ctx) => this.#exec(id, argv, ctx);
@@ -18,7 +18,8 @@ export declare function orgoWorkspaces(rest: OrgoRest, { timeoutMs, signal }: {
18
18
  }): Promise<Result<OrgoWorkspace[]>>;
19
19
  /**
20
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.
21
+ * words naming each and its id, pointing at Settings, where a person picks one, or at ORGO_WORKSPACE_ID; none is
22
+ * refused saying to make one.
22
23
  */
23
24
  export declare function soleWorkspace(rest: OrgoRest, context: {
24
25
  timeoutMs: number;
@@ -4,6 +4,8 @@ const fail = failFor("orgo");
4
4
  export const NO_WORKSPACE = "this Orgo key's account has no workspace: make one at orgo.ai";
5
5
  /** A workspace in words: its name, and its status when it is not active. */
6
6
  export const workspaceWords = (workspace) => (workspace.status === undefined ? workspace.name : `${workspace.name} (${workspace.status})`);
7
+ /** A workspace in words with its id, the value ORGO_WORKSPACE_ID takes: `name = id`, or the id alone when it is the name. */
8
+ const workspaceWithId = (workspace) => (workspace.name === workspace.id ? workspaceWords(workspace) : `${workspaceWords(workspace)} = ${workspace.id}`);
7
9
  /** Every workspace the key's account sees, deleted ones left out, in Orgo's order. An HTTP failure keeps its code. */
8
10
  export async function orgoWorkspaces(rest, { timeoutMs, signal }) {
9
11
  const read = await rest.request("GET", "/workspaces", { timeoutMs, ...(signal ? { signal } : {}) });
@@ -24,7 +26,8 @@ export async function orgoWorkspaces(rest, { timeoutMs, signal }) {
24
26
  }
25
27
  /**
26
28
  * 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.
29
+ * words naming each and its id, pointing at Settings, where a person picks one, or at ORGO_WORKSPACE_ID; none is
30
+ * refused saying to make one.
28
31
  */
29
32
  export async function soleWorkspace(rest, context) {
30
33
  const listed = await orgoWorkspaces(rest, context);
@@ -35,7 +38,7 @@ export async function soleWorkspace(rest, context) {
35
38
  return fail("not_found", NO_WORKSPACE);
36
39
  if (more.length === 0)
37
40
  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)`);
41
+ return fail("invalid", `this Orgo key's account has ${listed.value.length} workspaces (${listed.value.map(workspaceWithId).join(", ")}): pick one in Settings → Computers or set ORGO_WORKSPACE_ID to its id`);
39
42
  }
40
43
  /**
41
44
  * keyChoices for an Orgo provider: workspaceId's choices, every workspace the key's account sees, each its id and its
@@ -0,0 +1,34 @@
1
+ import { HostedProvider, type HostedOptions, type HostedTimeouts } from "./hosted/provider.js";
2
+ import type { CallContext } from "./provider.js";
3
+ import { type Result } from "./result.js";
4
+ /** The Render provider's options: the key and the workspace, then the shared adapter's (HostedOptions). */
5
+ export interface RenderProviderOptions extends Omit<HostedOptions, "desktop" | "maxLifetimeMs"> {
6
+ /** A Render API key that may make sandboxes in the workspace. The caller passes it; this provider reads no environment. */
7
+ apiKey: string;
8
+ /** The workspace (owner) its sandboxes are made in and listed from: tea-… for a team, usr-… for a person. */
9
+ ownerId: string;
10
+ /** The fetch every call goes through; default the global one. */
11
+ fetch?: typeof fetch;
12
+ /** The longest lifetime check takes, in ms: at most a day, the default. */
13
+ maxLifetimeMs?: number;
14
+ timeouts?: Partial<HostedTimeouts>;
15
+ }
16
+ /** A RenderProvider from its options alone; it reads no environment (serve passes the saved RENDER_API_KEY and RENDER_WORKSPACE_ID). */
17
+ export declare function create(options: RenderProviderOptions): RenderProvider;
18
+ /** The conformance CLI's module for Render: its settings, and its dialKit that refuses off the public server. */
19
+ export declare const conformance: () => Promise<typeof import("./conformance/render.js")>;
20
+ /**
21
+ * Computers that are Render Sandboxes, on the shared adapter, each dialing the server that made it: a server with no
22
+ * public https address (AGENTRUN_PUBLIC_URL) refuses a create in words before Render is called. Kind linux.
23
+ */
24
+ export declare class RenderProvider extends HostedProvider {
25
+ /**
26
+ * The provider contract's prepareImage (its descriptor declares it): the box image as a build of the workspace's
27
+ * default sandbox group (RenderHost.boxBuild), found or imported. ok with the build's name; onWait is told "build"
28
+ * once, before an import, never when the workspace has one.
29
+ */
30
+ prepareImage(context?: CallContext & {
31
+ onWait?: (making: "build" | "pull", tag: string) => void;
32
+ }): Promise<Result<string>>;
33
+ constructor(options: RenderProviderOptions);
34
+ }