@parcha/agentrun-computer 0.1.0-beta.36 → 0.1.0-beta.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +2 -0
- package/README.md +321 -308
- package/box/build-agent37.mjs +177 -0
- package/dist/agent37.d.ts +165 -0
- package/dist/agent37.js +759 -0
- package/dist/attach.d.ts +146 -0
- package/dist/attach.js +469 -0
- package/dist/browserbase.d.ts +2 -4
- package/dist/browserbase.js +2 -1
- package/dist/client.d.ts +33 -1
- package/dist/client.js +53 -0
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/conformance/agent37.d.ts +96 -0
- package/dist/conformance/agent37.js +154 -0
- package/dist/conformance/cases/apps.d.ts +5 -0
- package/dist/conformance/cases/apps.js +160 -73
- package/dist/conformance/cases/health.js +14 -0
- package/dist/conformance/cases/index.js +2 -0
- package/dist/conformance/cases/provider.js +27 -1
- package/dist/conformance/cases/screen.d.ts +3 -0
- package/dist/conformance/cases/screen.js +18 -0
- package/dist/conformance/cases/settings.d.ts +29 -23
- package/dist/conformance/cases/settings.js +76 -58
- package/dist/conformance/cases/touch.js +19 -17
- package/dist/conformance/cases/ui.d.ts +2 -0
- package/dist/conformance/cases/ui.js +475 -0
- package/dist/conformance/cli.d.ts +9 -0
- package/dist/conformance/cli.js +28 -3
- package/dist/conformance/e2b.d.ts +6 -0
- package/dist/conformance/e2b.js +9 -2
- package/dist/conformance/fixture.d.ts +1 -1
- package/dist/conformance/fixture.js +25 -1
- package/dist/conformance/modal.d.ts +17 -13
- package/dist/conformance/modal.js +18 -9
- package/dist/conformance/orgo.d.ts +3 -3
- package/dist/conformance/orgo.js +6 -8
- package/dist/conformance/phone-harness.d.ts +6 -2
- package/dist/conformance/phone-harness.js +21 -4
- package/dist/conformance/report.js +1 -1
- package/dist/conformance/runner.js +23 -4
- package/dist/conformance/sweep.d.ts +50 -0
- package/dist/conformance/sweep.js +187 -0
- package/dist/conformance/types.d.ts +11 -3
- package/dist/conformance/ui-fixture.d.ts +56 -0
- package/dist/conformance/ui-fixture.js +43 -0
- package/dist/create-requests.d.ts +51 -0
- package/dist/create-requests.js +121 -0
- package/dist/daytona.d.ts +2 -4
- package/dist/daytona.js +3 -2
- package/dist/descriptor.d.ts +5 -0
- package/dist/descriptor.js +2 -0
- package/dist/descriptors/agent37.d.ts +41 -0
- package/dist/descriptors/agent37.js +28 -0
- package/dist/descriptors/index.d.ts +38 -2
- package/dist/descriptors/index.js +4 -2
- package/dist/descriptors/orgo.d.ts +2 -1
- package/dist/descriptors/orgo.js +3 -2
- package/dist/descriptors/phone-harness.d.ts +1 -1
- package/dist/descriptors/phone-harness.js +2 -2
- package/dist/docker.d.ts +7 -4
- package/dist/docker.js +271 -29
- package/dist/e2b.d.ts +9 -165
- package/dist/e2b.js +282 -1342
- package/dist/fake-ui-driver.d.ts +97 -0
- package/dist/fake-ui-driver.js +717 -0
- package/dist/host.d.ts +182 -0
- package/dist/host.js +1 -0
- package/dist/hosted/process.d.ts +67 -0
- package/dist/hosted/process.js +228 -0
- package/dist/hosted/provider.d.ts +146 -0
- package/dist/hosted/provider.js +1364 -0
- package/dist/hosted/scripts.d.ts +76 -0
- package/dist/{child.js → hosted/scripts.js} +93 -12
- package/dist/index.d.ts +7 -3
- package/dist/index.js +7 -4
- package/dist/kernel.d.ts +2 -4
- package/dist/kernel.js +2 -1
- package/dist/kinds.d.ts +8 -1
- package/dist/kinds.js +20 -4
- package/dist/local-chrome.d.ts +2 -4
- package/dist/local-chrome.js +2 -1
- package/dist/modal.d.ts +23 -181
- package/dist/modal.js +271 -1244
- package/dist/orgo-channel.d.ts +3 -2
- package/dist/orgo-channel.js +5 -2
- package/dist/orgo-desktop.d.ts +9 -4
- package/dist/orgo-desktop.js +33 -13
- package/dist/orgo-workspaces.d.ts +47 -0
- package/dist/orgo-workspaces.js +94 -0
- package/dist/orgo.d.ts +10 -4
- package/dist/orgo.js +30 -12
- package/dist/phone-harness.d.ts +31 -22
- package/dist/phone-harness.js +510 -698
- package/dist/png.d.ts +4 -0
- package/dist/png.js +27 -0
- package/dist/protocol.d.ts +335 -32
- package/dist/protocol.js +96 -3
- package/dist/provider.d.ts +34 -6
- package/dist/provider.js +16 -0
- package/dist/result.d.ts +1 -1
- package/dist/surface/api.d.ts +248 -0
- package/dist/surface/api.js +1 -0
- package/dist/surface/core.d.ts +42 -0
- package/dist/surface/core.js +393 -0
- package/dist/surface/index.d.ts +5 -0
- package/dist/surface/index.js +3 -0
- package/dist/surface/outline.d.ts +8 -0
- package/dist/surface/outline.js +50 -0
- package/dist/surface/script.d.ts +10 -0
- package/dist/surface/script.js +92 -0
- package/dist/ui-engine.d.ts +114 -0
- package/dist/ui-engine.js +798 -0
- package/package.json +17 -1
- package/dist/child.d.ts +0 -42
- package/dist/conformance/e2b-diagnose.d.ts +0 -16
- package/dist/conformance/e2b-diagnose.js +0 -61
- package/dist/conformance/e2b-sweep.d.ts +0 -18
- package/dist/conformance/e2b-sweep.js +0 -132
- package/dist/conformance/modal-sweep.d.ts +0 -22
- package/dist/conformance/modal-sweep.js +0 -213
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Rect, UiFlag, UiRole, UiRoute } from "../protocol.js";
|
|
2
|
+
/**
|
|
3
|
+
* What pressing an element does, `after` ms later: go opens a screen in its window (through a transition of
|
|
4
|
+
* animateMs), open opens a new window of the app on that screen, in front, and close closes the window it is in.
|
|
5
|
+
*/
|
|
6
|
+
export interface FakeEffect {
|
|
7
|
+
go?: string;
|
|
8
|
+
open?: string;
|
|
9
|
+
close?: true;
|
|
10
|
+
after?: number;
|
|
11
|
+
animateMs?: number;
|
|
12
|
+
}
|
|
13
|
+
/** One element of a scripted app. The same key on two screens is the same element (its ref survives the change). */
|
|
14
|
+
export interface FakeElement {
|
|
15
|
+
key: string;
|
|
16
|
+
role: UiRole;
|
|
17
|
+
name?: string;
|
|
18
|
+
value?: string;
|
|
19
|
+
desc?: string;
|
|
20
|
+
id?: string;
|
|
21
|
+
/** In window points. */
|
|
22
|
+
bounds: Rect;
|
|
23
|
+
/** The key of the element above it, which comes before it. */
|
|
24
|
+
parent?: string;
|
|
25
|
+
flags?: UiFlag[];
|
|
26
|
+
actions?: string[];
|
|
27
|
+
press?: FakeEffect;
|
|
28
|
+
/** What enter does while this element has the focus. */
|
|
29
|
+
enter?: FakeEffect;
|
|
30
|
+
/** The best route that reaches it; default semantic. Only foreground input reaches a foreground element. */
|
|
31
|
+
route?: UiRoute;
|
|
32
|
+
/** Its value is the number of clicks that reached it, so a driver can read back whether one landed. */
|
|
33
|
+
counts?: boolean;
|
|
34
|
+
/** A set into it is taken back this many ms later: its value returns to what it was. */
|
|
35
|
+
takesBack?: number;
|
|
36
|
+
}
|
|
37
|
+
export interface FakeScreen {
|
|
38
|
+
title?: string;
|
|
39
|
+
elements: FakeElement[];
|
|
40
|
+
}
|
|
41
|
+
/** A scripted app: its screens, the first one shown, and its window's size in points. */
|
|
42
|
+
export interface FakeApp {
|
|
43
|
+
id: string;
|
|
44
|
+
name: string;
|
|
45
|
+
start: string;
|
|
46
|
+
size: [number, number];
|
|
47
|
+
screens: Record<string, FakeScreen>;
|
|
48
|
+
}
|
|
49
|
+
export declare const SAVED_MS = 300;
|
|
50
|
+
export declare const NEXT_MS = 200;
|
|
51
|
+
export declare const NEXT_ANIMATE_MS = 300;
|
|
52
|
+
export declare const NEW_WINDOW_MS = 300;
|
|
53
|
+
/** Well inside SET_HOLD_MS, so an act that set the Code field reads it taken back before it answers. */
|
|
54
|
+
export declare const TAKES_BACK_MS = 150;
|
|
55
|
+
/** The fixture's app, as the fake ui driver runs it. */
|
|
56
|
+
export declare const UI_FIXTURE: FakeApp;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export const SAVED_MS = 300;
|
|
2
|
+
export const NEXT_MS = 200;
|
|
3
|
+
export const NEXT_ANIMATE_MS = 300;
|
|
4
|
+
export const NEW_WINDOW_MS = 300;
|
|
5
|
+
/** Well inside SET_HOLD_MS, so an act that set the Code field reads it taken back before it answers. */
|
|
6
|
+
export const TAKES_BACK_MS = 150;
|
|
7
|
+
const home = [
|
|
8
|
+
{ key: "title", role: "heading", name: "UI fixture", bounds: [16, 16, 300, 24] },
|
|
9
|
+
{ key: "name", role: "textbox", name: "Name", value: "", id: "name", bounds: [16, 56, 200, 28], actions: ["AXConfirm"] },
|
|
10
|
+
{ key: "wifi", role: "switch", name: "Wi-Fi", desc: "Networks nearby", id: "wifi", bounds: [16, 96, 60, 28], actions: ["AXPress"] },
|
|
11
|
+
{ key: "save", role: "button", name: "Save", id: "save", bounds: [16, 136, 80, 28], actions: ["AXPress"], press: { go: "saved", after: SAVED_MS } },
|
|
12
|
+
{ key: "next", role: "button", name: "Next", id: "next", bounds: [112, 136, 80, 28], actions: ["AXPress"], press: { go: "second", after: NEXT_MS, animateMs: NEXT_ANIMATE_MS } },
|
|
13
|
+
{ key: "canvas", role: "image", name: "Canvas", id: "canvas", value: "0", bounds: [16, 180, 200, 100], route: "foreground", counts: true },
|
|
14
|
+
{ key: "open", role: "button", name: "New window", id: "open", bounds: [92, 96, 104, 28], actions: ["AXPress"], press: { open: "another", after: NEW_WINDOW_MS } },
|
|
15
|
+
{ key: "close", role: "button", name: "Close", id: "close", bounds: [208, 96, 80, 28], actions: ["AXPress"], press: { close: true } },
|
|
16
|
+
{ key: "code", role: "textbox", name: "Code", value: "", id: "code", bounds: [228, 56, 76, 28], takesBack: TAKES_BACK_MS },
|
|
17
|
+
];
|
|
18
|
+
/** The fixture's app, as the fake ui driver runs it. */
|
|
19
|
+
export const UI_FIXTURE = {
|
|
20
|
+
// A valid Android package name and macOS bundle id alike (no hyphen), in a window that fits a small phone's portrait.
|
|
21
|
+
id: "ai.agentrun.uifixture",
|
|
22
|
+
name: "UI fixture",
|
|
23
|
+
start: "home",
|
|
24
|
+
size: [320, 320],
|
|
25
|
+
screens: {
|
|
26
|
+
home: { title: "UI fixture", elements: home },
|
|
27
|
+
saved: { title: "UI fixture", elements: [...home, { key: "saved", role: "text", name: "Saved", bounds: [208, 136, 80, 28] }] },
|
|
28
|
+
second: {
|
|
29
|
+
title: "Second page",
|
|
30
|
+
elements: [
|
|
31
|
+
{ key: "title2", role: "heading", name: "Second page", bounds: [16, 16, 300, 24] },
|
|
32
|
+
{ key: "back", role: "button", name: "Back", id: "back", bounds: [16, 56, 80, 28], actions: ["AXPress"], press: { go: "home" } },
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
another: {
|
|
36
|
+
title: "Another window",
|
|
37
|
+
elements: [
|
|
38
|
+
{ key: "title3", role: "heading", name: "Another window", bounds: [16, 16, 300, 24] },
|
|
39
|
+
{ key: "close", role: "button", name: "Close", id: "close", bounds: [16, 56, 80, 28], actions: ["AXPress"], press: { close: true } },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type ComputerSpec, type CreateContext, type CreatedComputer, type ReadBackSpec } from "./provider.js";
|
|
2
|
+
import type { ComputerErrorCode, Result } from "./result.js";
|
|
3
|
+
/** How a provider refuses, in its own words and with its own vendor. */
|
|
4
|
+
export type Refuse = (code: ComputerErrorCode, message: string) => Result<never>;
|
|
5
|
+
/** The words of a request whose computer has ended (provider.md). */
|
|
6
|
+
export declare const endedWords: (name: string) => string;
|
|
7
|
+
/** The words of a request whose computer is another spec's. */
|
|
8
|
+
export declare const otherSpecWords: (name: string, seen: "is being made" | "was made", differ: string[]) => string;
|
|
9
|
+
/** How two label sets differ, in words: each key asked with another value or none, and each key have holds that was never asked. Empty when they match. */
|
|
10
|
+
export declare function labelsDiffer(asked: Record<string, string>, have: Record<string, string>, seen: string): string[];
|
|
11
|
+
/**
|
|
12
|
+
* How asked differs from have, the spec of another create of the same request, in words: every field but lifetimeMs
|
|
13
|
+
* (each create counts its own lifetime from its start), the labels exactly, and the user as the provider resolves it
|
|
14
|
+
* (userOf: an unset user is the provider's default). seen says where have is from: "in flight" for a create still
|
|
15
|
+
* running, "read back" for a computer whose vendor holds its whole spec (the fake's). Empty when they are the same.
|
|
16
|
+
*/
|
|
17
|
+
export declare function specDiffer(asked: ComputerSpec, have: ComputerSpec, { userOf, seen }?: {
|
|
18
|
+
userOf?: (spec: ComputerSpec) => string | undefined;
|
|
19
|
+
seen?: string;
|
|
20
|
+
}): string[];
|
|
21
|
+
/**
|
|
22
|
+
* How asked differs from what the vendor reads back of its request's computer (attach's spec), in words, over the
|
|
23
|
+
* fields this provider reads back as they were asked: each one asked, or read back, with another value. A size the
|
|
24
|
+
* spec left out is the vendor's default, so it differs from none. Labels are the provider's to compare, by its own.
|
|
25
|
+
*/
|
|
26
|
+
export declare function readBackDiffer(asked: ComputerSpec, have: ReadBackSpec, fields: ReadonlyArray<"image" | "network" | "user" | "cpus" | "memoryMb" | "pids">): string[];
|
|
27
|
+
export interface CreateOnce {
|
|
28
|
+
refuse: Refuse;
|
|
29
|
+
/** Why the provider does not serve the spec, in words, when it does not: refused once the request id is checked. */
|
|
30
|
+
refused?: string;
|
|
31
|
+
/** The user a spec's computer runs as, as the provider resolves it (its default for none): what specDiffer compares. */
|
|
32
|
+
userOf?(spec: ComputerSpec): string | undefined;
|
|
33
|
+
/** The provider's create by the request's name: it finds the computer a vendor holds under it, or makes one. */
|
|
34
|
+
make(name: string): Promise<Result<CreatedComputer>>;
|
|
35
|
+
}
|
|
36
|
+
export declare class CreateRequests {
|
|
37
|
+
#private;
|
|
38
|
+
/**
|
|
39
|
+
* Makes a computer once per request: a request id that is none is invalid; a create of a request already in flight
|
|
40
|
+
* waits for the first and answers what it does when it asks the same, and is refused exists when it asks another
|
|
41
|
+
* spec (specDiffer); a request whose computer this provider ended is refused exists; anything else is make's, under
|
|
42
|
+
* the name.
|
|
43
|
+
*/
|
|
44
|
+
create(spec: ComputerSpec, context: CreateContext, { refuse, refused, userOf, make }: CreateOnce): Promise<Result<CreatedComputer>>;
|
|
45
|
+
/** A request's computer given up on or deleted: its name remembered, the oldest let go past ENDED_MAX. */
|
|
46
|
+
end(name: string): void;
|
|
47
|
+
/** A computer made under the name: its request is no longer ended. */
|
|
48
|
+
made(name: string): void;
|
|
49
|
+
/** Whether this provider ended the computer of the request with this name. */
|
|
50
|
+
ended(name: string): boolean;
|
|
51
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// Idempotent create's in-process half (spec/computer/provider.md, Idempotent create), one per provider instance and the
|
|
2
|
+
// same for every provider: the request id checked, the computer's name from it (computerNameFor), a second create of a
|
|
3
|
+
// request still in flight sharing the first's answer, and the names of the computers this provider ended, refused as
|
|
4
|
+
// exists once the vendor forgets them. What a vendor can still show (a machine by that name, starting, up or stopped) is
|
|
5
|
+
// the provider's own to read, in the make it passes.
|
|
6
|
+
import { isDeepStrictEqual } from "node:util";
|
|
7
|
+
import { computerNameFor, requestIdProblem } from "./provider.js";
|
|
8
|
+
/** The most request names one provider remembers as ended, the oldest let go first: a bound, not a ledger. */
|
|
9
|
+
const ENDED_MAX = 4_096;
|
|
10
|
+
/** The words of a request whose computer has ended (provider.md). */
|
|
11
|
+
export const endedWords = (name) => `${name} was made for this request and has ended: create with a new request id`;
|
|
12
|
+
/** The words of a request whose computer is another spec's. */
|
|
13
|
+
export const otherSpecWords = (name, seen, differ) => `${name} ${seen} for this request with another spec, so it is not returned: ${differ.join("; ")}; create with a new request id`;
|
|
14
|
+
/** How two label sets differ, in words: each key asked with another value or none, and each key have holds that was never asked. Empty when they match. */
|
|
15
|
+
export function labelsDiffer(asked, have, seen) {
|
|
16
|
+
const differ = Object.entries(asked)
|
|
17
|
+
.filter(([key, value]) => have[key] !== value)
|
|
18
|
+
.map(([key, value]) => `label ${key}: asked ${JSON.stringify(value)}, ${seen} ${have[key] === undefined ? "nothing" : JSON.stringify(have[key])}`);
|
|
19
|
+
const unasked = Object.keys(have).filter((key) => !Object.hasOwn(asked, key));
|
|
20
|
+
if (unasked.length > 0)
|
|
21
|
+
differ.push(`labels ${unasked.join(", ")}: ${seen}, never asked for`);
|
|
22
|
+
return differ;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* How asked differs from have, the spec of another create of the same request, in words: every field but lifetimeMs
|
|
26
|
+
* (each create counts its own lifetime from its start), the labels exactly, and the user as the provider resolves it
|
|
27
|
+
* (userOf: an unset user is the provider's default). seen says where have is from: "in flight" for a create still
|
|
28
|
+
* running, "read back" for a computer whose vendor holds its whole spec (the fake's). Empty when they are the same.
|
|
29
|
+
*/
|
|
30
|
+
export function specDiffer(asked, have, { userOf = (spec) => spec.user, seen = "in flight" } = {}) {
|
|
31
|
+
const differ = labelsDiffer(asked.labels ?? {}, have.labels ?? {}, seen);
|
|
32
|
+
const fields = new Set([...Object.keys(asked), ...Object.keys(have)]);
|
|
33
|
+
for (const field of fields) {
|
|
34
|
+
if (field === "lifetimeMs" || field === "labels" || field === "user")
|
|
35
|
+
continue;
|
|
36
|
+
if (!isDeepStrictEqual(asked[field], have[field]))
|
|
37
|
+
differ.push(`${field}: asked ${show(asked[field])}, ${seen} ${show(have[field])}`);
|
|
38
|
+
}
|
|
39
|
+
const [user, held] = [userOf(asked), userOf(have)];
|
|
40
|
+
if (user !== held)
|
|
41
|
+
differ.push(`user: asked ${user ?? "the default"}, ${seen} ${held ?? "the default"}`);
|
|
42
|
+
return differ;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* How asked differs from what the vendor reads back of its request's computer (attach's spec), in words, over the
|
|
46
|
+
* fields this provider reads back as they were asked: each one asked, or read back, with another value. A size the
|
|
47
|
+
* spec left out is the vendor's default, so it differs from none. Labels are the provider's to compare, by its own.
|
|
48
|
+
*/
|
|
49
|
+
export function readBackDiffer(asked, have, fields) {
|
|
50
|
+
const sized = new Set(["cpus", "memoryMb", "pids"]);
|
|
51
|
+
return fields
|
|
52
|
+
.filter((field) => !(sized.has(field) && asked[field] === undefined) && !isDeepStrictEqual(asked[field], have[field]))
|
|
53
|
+
.map((field) => `${field}: asked ${show(asked[field])}, read back ${show(have[field])}`);
|
|
54
|
+
}
|
|
55
|
+
const show = (value) => (value === undefined ? "nothing" : JSON.stringify(value));
|
|
56
|
+
export class CreateRequests {
|
|
57
|
+
#creating = new Map();
|
|
58
|
+
#ended = new Set();
|
|
59
|
+
/**
|
|
60
|
+
* Makes a computer once per request: a request id that is none is invalid; a create of a request already in flight
|
|
61
|
+
* waits for the first and answers what it does when it asks the same, and is refused exists when it asks another
|
|
62
|
+
* spec (specDiffer); a request whose computer this provider ended is refused exists; anything else is make's, under
|
|
63
|
+
* the name.
|
|
64
|
+
*/
|
|
65
|
+
async create(spec, context, { refuse, refused, userOf, make }) {
|
|
66
|
+
const problem = requestIdProblem(context?.requestId);
|
|
67
|
+
if (problem !== undefined)
|
|
68
|
+
return refuse("invalid", problem);
|
|
69
|
+
if (refused !== undefined)
|
|
70
|
+
return refuse("refused", refused);
|
|
71
|
+
const name = computerNameFor(context.requestId);
|
|
72
|
+
const inFlight = this.#creating.get(name);
|
|
73
|
+
if (inFlight !== undefined) {
|
|
74
|
+
const differs = specDiffer(spec, inFlight.spec, userOf === undefined ? {} : { userOf });
|
|
75
|
+
if (differs.length > 0)
|
|
76
|
+
return refuse("exists", otherSpecWords(name, "is being made", differs));
|
|
77
|
+
// The wait is this caller's to cut off by its own signal: aborted then, and the first create, and the computer
|
|
78
|
+
// it makes, go on untouched.
|
|
79
|
+
const signal = context.signal;
|
|
80
|
+
if (signal === undefined)
|
|
81
|
+
return inFlight.result;
|
|
82
|
+
const cut = () => refuse("aborted", `create was aborted while another create of this request made ${name}, which goes on`);
|
|
83
|
+
if (signal.aborted)
|
|
84
|
+
return cut();
|
|
85
|
+
return new Promise((resolve, reject) => {
|
|
86
|
+
const onAbort = () => resolve(cut());
|
|
87
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
88
|
+
inFlight.result.then((result) => (signal.removeEventListener("abort", onAbort), resolve(result)), (error) => (signal.removeEventListener("abort", onAbort), reject(error)));
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (this.#ended.has(name))
|
|
92
|
+
return refuse("exists", endedWords(name));
|
|
93
|
+
const creating = { spec, result: make(name) };
|
|
94
|
+
this.#creating.set(name, creating);
|
|
95
|
+
try {
|
|
96
|
+
return await creating.result;
|
|
97
|
+
}
|
|
98
|
+
finally {
|
|
99
|
+
if (this.#creating.get(name) === creating)
|
|
100
|
+
this.#creating.delete(name);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/** A request's computer given up on or deleted: its name remembered, the oldest let go past ENDED_MAX. */
|
|
104
|
+
end(name) {
|
|
105
|
+
this.#ended.delete(name);
|
|
106
|
+
this.#ended.add(name);
|
|
107
|
+
for (const oldest of this.#ended) {
|
|
108
|
+
if (this.#ended.size <= ENDED_MAX)
|
|
109
|
+
break;
|
|
110
|
+
this.#ended.delete(oldest);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/** A computer made under the name: its request is no longer ended. */
|
|
114
|
+
made(name) {
|
|
115
|
+
this.#ended.delete(name);
|
|
116
|
+
}
|
|
117
|
+
/** Whether this provider ended the computer of the request with this name. */
|
|
118
|
+
ended(name) {
|
|
119
|
+
return this.#ended.has(name);
|
|
120
|
+
}
|
|
121
|
+
}
|
package/dist/daytona.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { KindCapabilities } from "./kinds.js";
|
|
2
2
|
import { type MountKind } from "./mount.js";
|
|
3
3
|
import { type ProviderNote } from "./mount-archil.js";
|
|
4
|
-
import { type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type CreatedComputer, type NetworkPolicy, type NetworkSpec, type Refusal, type ReleaseHow } from "./provider.js";
|
|
4
|
+
import { type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type CreateContext, type CreatedComputer, type NetworkPolicy, type NetworkSpec, type Refusal, type ReleaseHow } from "./provider.js";
|
|
5
5
|
import { type Result } from "./result.js";
|
|
6
6
|
import { type ScreenWatch, type ScreenWatchHandlers, type WatchOptions } from "./screen-watch.js";
|
|
7
7
|
/** The longest each kind of call may take, and the pauses between polls and retries. */
|
|
@@ -145,9 +145,7 @@ export declare class DaytonaProvider implements ComputerProvider {
|
|
|
145
145
|
*/
|
|
146
146
|
capabilities(): ComputerCapabilities;
|
|
147
147
|
check(spec: ComputerSpec): Refusal[];
|
|
148
|
-
create(spec: ComputerSpec,
|
|
149
|
-
signal?: AbortSignal;
|
|
150
|
-
}): Promise<Result<CreatedComputer>>;
|
|
148
|
+
create(spec: ComputerSpec, context: CreateContext): Promise<Result<CreatedComputer>>;
|
|
151
149
|
/** The live view: screen.watch on a connection of the watch's own (daemonWatch); a sandbox has no screen. */
|
|
152
150
|
watch(ref: ComputerRef, handlers: ScreenWatchHandlers, options?: WatchOptions): Promise<Result<ScreenWatch>>;
|
|
153
151
|
connect(ref: ComputerRef): Promise<Result<ComputerConnection>>;
|
package/dist/daytona.js
CHANGED
|
@@ -7,7 +7,7 @@ import { readFileSync } from "node:fs";
|
|
|
7
7
|
import { resolve } from "node:path";
|
|
8
8
|
import { PassThrough, Writable } from "node:stream";
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
|
-
import { childCommands, daemonDrift, installerOf, shellCommand } from "./
|
|
10
|
+
import { childCommands, daemonDrift, installerOf, shellCommand } from "./hosted/scripts.js";
|
|
11
11
|
import { OWN_NETWORK_ONLY, readOwnNetwork, TOOL_USER } from "./isolation.js";
|
|
12
12
|
import { DaemonClient } from "./client.js";
|
|
13
13
|
import { DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_REGION, DAYTONA_GPU_SNAPSHOT, daytonaGpu, daytonaGpuSnapshot } from "./descriptors/daytona.js";
|
|
@@ -653,7 +653,8 @@ export class DaytonaProvider {
|
|
|
653
653
|
}
|
|
654
654
|
return refusals;
|
|
655
655
|
}
|
|
656
|
-
async create(spec,
|
|
656
|
+
async create(spec, context) {
|
|
657
|
+
const signal = context?.signal;
|
|
657
658
|
const refusals = this.check(spec);
|
|
658
659
|
if (refusals.length > 0)
|
|
659
660
|
return fail("refused", refusals.map(({ field, message }) => `${field}: ${message}`).join("; "));
|
package/dist/descriptor.d.ts
CHANGED
|
@@ -9,6 +9,11 @@ export interface DescriptorKey {
|
|
|
9
9
|
/** The create() option it fills (apiKey). */
|
|
10
10
|
readonly option: string;
|
|
11
11
|
readonly required: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* A person picks its value from the vendor's own list rather than typing it (Orgo's workspace, by name): Settings
|
|
14
|
+
* offers what the built provider's keyChoices(option) reads with the other keys. Absent: typed.
|
|
15
|
+
*/
|
|
16
|
+
readonly picked?: boolean;
|
|
12
17
|
}
|
|
13
18
|
/** A setting that is no key but fills a create() option, with the value used when the server names none. */
|
|
14
19
|
export interface DescriptorSetting {
|
package/dist/descriptor.js
CHANGED
|
@@ -67,6 +67,8 @@ export function descriptorProblems(value) {
|
|
|
67
67
|
named(d.settings, "settings");
|
|
68
68
|
if (Array.isArray(d.keys) && d.keys.some((key) => typeof key?.required !== "boolean"))
|
|
69
69
|
problems.push("each key says whether it is required");
|
|
70
|
+
if (Array.isArray(d.keys) && d.keys.some((key) => key?.picked !== undefined && typeof key.picked !== "boolean"))
|
|
71
|
+
problems.push("a key's picked is true or false");
|
|
70
72
|
if (d.ledger !== undefined && (typeof d.ledger?.option !== "string" || d.ledger.option === ""))
|
|
71
73
|
problems.push("ledger names the option it fills");
|
|
72
74
|
if (d.imageEnv !== undefined && (typeof d.imageEnv !== "string" || !/^[A-Z][A-Z0-9_]*$/.test(d.imageEnv)))
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** Agent37's plain Linux template: a sandbox when its setting names no image. */
|
|
2
|
+
export declare const AGENT37_BASE_TEMPLATE = "agent37-base";
|
|
3
|
+
/**
|
|
4
|
+
* Our box image (box/Dockerfile and Xvfb) as a template of the key's own workspace, which box/build-agent37.mjs builds
|
|
5
|
+
* and publishes under this one name: a desktop when its setting names no image.
|
|
6
|
+
*/
|
|
7
|
+
export declare const AGENT37_BOX_TEMPLATE = "agentrun-box";
|
|
8
|
+
export declare const AGENT37: {
|
|
9
|
+
readonly id: "agent37";
|
|
10
|
+
readonly label: "Agent37";
|
|
11
|
+
readonly keys: readonly [{
|
|
12
|
+
readonly name: "AGENT37_API_KEY";
|
|
13
|
+
readonly option: "apiKey";
|
|
14
|
+
readonly required: true;
|
|
15
|
+
}, {
|
|
16
|
+
readonly name: "AGENT37_SSH_KEY";
|
|
17
|
+
readonly option: "sshKey";
|
|
18
|
+
readonly required: true;
|
|
19
|
+
}];
|
|
20
|
+
readonly metered: true;
|
|
21
|
+
readonly mounts: readonly ["archil"];
|
|
22
|
+
readonly network: readonly ["none"];
|
|
23
|
+
readonly capabilities: readonly [import("../kinds.js").KindCapabilities, {
|
|
24
|
+
readonly options: {
|
|
25
|
+
readonly kind: "desktop";
|
|
26
|
+
};
|
|
27
|
+
readonly kind: import("../protocol.js").ComputerKind;
|
|
28
|
+
readonly groups: import("../protocol.js").Group[];
|
|
29
|
+
readonly gpu?: import("../provider.js").GpuCapability;
|
|
30
|
+
readonly persistence?: {
|
|
31
|
+
keepsState: true;
|
|
32
|
+
resume: boolean;
|
|
33
|
+
};
|
|
34
|
+
readonly image?: string;
|
|
35
|
+
}];
|
|
36
|
+
readonly defaultImage: {
|
|
37
|
+
readonly sandbox: "agent37-base";
|
|
38
|
+
readonly desktop: "agentrun-box";
|
|
39
|
+
};
|
|
40
|
+
readonly load: () => Promise<typeof import("../agent37.js")>;
|
|
41
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Agent37's descriptor: a Linux sandbox or a Linux desktop on an Agent37 instance (a VM by default), the run's folder on
|
|
2
|
+
// an Archil disk. The desktop starts from our box image built as a workspace template (box/build-agent37.mjs).
|
|
3
|
+
import { defineProvider } from "../descriptor.js";
|
|
4
|
+
import { LINUX_DESKTOP, SANDBOX } from "./shared.js";
|
|
5
|
+
/** Agent37's plain Linux template: a sandbox when its setting names no image. */
|
|
6
|
+
export const AGENT37_BASE_TEMPLATE = "agent37-base";
|
|
7
|
+
/**
|
|
8
|
+
* Our box image (box/Dockerfile and Xvfb) as a template of the key's own workspace, which box/build-agent37.mjs builds
|
|
9
|
+
* and publishes under this one name: a desktop when its setting names no image.
|
|
10
|
+
*/
|
|
11
|
+
export const AGENT37_BOX_TEMPLATE = "agentrun-box";
|
|
12
|
+
export const AGENT37 = defineProvider({
|
|
13
|
+
id: "agent37",
|
|
14
|
+
label: "Agent37",
|
|
15
|
+
keys: [
|
|
16
|
+
{ name: "AGENT37_API_KEY", option: "apiKey", required: true },
|
|
17
|
+
// The private half of the SSH key registered on the workspace: every command reaches the machine over SSH.
|
|
18
|
+
{ name: "AGENT37_SSH_KEY", option: "sshKey", required: true },
|
|
19
|
+
],
|
|
20
|
+
metered: true,
|
|
21
|
+
mounts: ["archil"],
|
|
22
|
+
// None: its programs run in a network of their own (isolation.ts OWN_NETWORK_ONLY).
|
|
23
|
+
network: ["none"],
|
|
24
|
+
// Each configuration built by its own create() options: kind linux is the provider's default.
|
|
25
|
+
capabilities: [SANDBOX, { ...LINUX_DESKTOP, options: { kind: "desktop" } }],
|
|
26
|
+
defaultImage: { sandbox: AGENT37_BASE_TEMPLATE, desktop: AGENT37_BOX_TEMPLATE },
|
|
27
|
+
load: () => import("../agent37.js"),
|
|
28
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AGENT37 } from "./agent37.js";
|
|
1
2
|
import { BROWSERBASE } from "./browserbase.js";
|
|
2
3
|
import { DAYTONA } from "./daytona.js";
|
|
3
4
|
import { DOCKER } from "./docker.js";
|
|
@@ -109,6 +110,39 @@ export declare const DESCRIPTORS: readonly [{
|
|
|
109
110
|
readonly desktop: "desktop";
|
|
110
111
|
};
|
|
111
112
|
readonly load: () => Promise<typeof import("../e2b.js")>;
|
|
113
|
+
}, {
|
|
114
|
+
readonly id: "agent37";
|
|
115
|
+
readonly label: "Agent37";
|
|
116
|
+
readonly keys: readonly [{
|
|
117
|
+
readonly name: "AGENT37_API_KEY";
|
|
118
|
+
readonly option: "apiKey";
|
|
119
|
+
readonly required: true;
|
|
120
|
+
}, {
|
|
121
|
+
readonly name: "AGENT37_SSH_KEY";
|
|
122
|
+
readonly option: "sshKey";
|
|
123
|
+
readonly required: true;
|
|
124
|
+
}];
|
|
125
|
+
readonly metered: true;
|
|
126
|
+
readonly mounts: readonly ["archil"];
|
|
127
|
+
readonly network: readonly ["none"];
|
|
128
|
+
readonly capabilities: readonly [import("../kinds.js").KindCapabilities, {
|
|
129
|
+
readonly options: {
|
|
130
|
+
readonly kind: "desktop";
|
|
131
|
+
};
|
|
132
|
+
readonly kind: import("../protocol.js").ComputerKind;
|
|
133
|
+
readonly groups: import("../protocol.js").Group[];
|
|
134
|
+
readonly gpu?: import("../provider.js").GpuCapability;
|
|
135
|
+
readonly persistence?: {
|
|
136
|
+
keepsState: true;
|
|
137
|
+
resume: boolean;
|
|
138
|
+
};
|
|
139
|
+
readonly image?: string;
|
|
140
|
+
}];
|
|
141
|
+
readonly defaultImage: {
|
|
142
|
+
readonly sandbox: "agent37-base";
|
|
143
|
+
readonly desktop: "agentrun-box";
|
|
144
|
+
};
|
|
145
|
+
readonly load: () => Promise<typeof import("../agent37.js")>;
|
|
112
146
|
}, {
|
|
113
147
|
readonly id: "orgo";
|
|
114
148
|
readonly label: "Orgo";
|
|
@@ -119,7 +153,8 @@ export declare const DESCRIPTORS: readonly [{
|
|
|
119
153
|
}, {
|
|
120
154
|
readonly name: "ORGO_WORKSPACE_ID";
|
|
121
155
|
readonly option: "workspaceId";
|
|
122
|
-
readonly required:
|
|
156
|
+
readonly required: false;
|
|
157
|
+
readonly picked: true;
|
|
123
158
|
}];
|
|
124
159
|
readonly metered: true;
|
|
125
160
|
readonly mounts: readonly [];
|
|
@@ -247,7 +282,8 @@ export declare const DESCRIPTORS: readonly [{
|
|
|
247
282
|
readonly hostEnv: readonly ["PI_BROWSER_CHROME", "CHROME_PATH", "PATH"];
|
|
248
283
|
readonly load: () => Promise<typeof import("../local-chrome.js")>;
|
|
249
284
|
}];
|
|
250
|
-
export { BROWSERBASE, DAYTONA, DOCKER, E2B, KERNEL, LOCAL, MODAL, ORGO, PHONE_HARNESS };
|
|
285
|
+
export { AGENT37, BROWSERBASE, DAYTONA, DOCKER, E2B, KERNEL, LOCAL, MODAL, ORGO, PHONE_HARNESS };
|
|
286
|
+
export { AGENT37_BASE_TEMPLATE, AGENT37_BOX_TEMPLATE } from "./agent37.js";
|
|
251
287
|
export { DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, type DaytonaGpuSnapshot, daytonaGpu, daytonaGpuSnapshot } from "./daytona.js";
|
|
252
288
|
export { E2B_BASE_TEMPLATE, E2B_DESKTOP_TEMPLATE } from "./e2b.js";
|
|
253
289
|
export { MODAL_DEFAULT_IMAGE } from "./modal.js";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Every built-in provider's descriptor, in the order Settings shows them. Importing this loads descriptors (data) alone:
|
|
2
2
|
// each provider module loads only when its descriptor's load() is called.
|
|
3
|
+
import { AGENT37 } from "./agent37.js";
|
|
3
4
|
import { BROWSERBASE } from "./browserbase.js";
|
|
4
5
|
import { DAYTONA } from "./daytona.js";
|
|
5
6
|
import { DOCKER } from "./docker.js";
|
|
@@ -9,8 +10,9 @@ import { LOCAL } from "./local-chrome.js";
|
|
|
9
10
|
import { MODAL } from "./modal.js";
|
|
10
11
|
import { ORGO } from "./orgo.js";
|
|
11
12
|
import { PHONE_HARNESS } from "./phone-harness.js";
|
|
12
|
-
export const DESCRIPTORS = [DOCKER, DAYTONA, MODAL, E2B, ORGO, PHONE_HARNESS, BROWSERBASE, KERNEL, LOCAL];
|
|
13
|
-
export { BROWSERBASE, DAYTONA, DOCKER, E2B, KERNEL, LOCAL, MODAL, ORGO, PHONE_HARNESS };
|
|
13
|
+
export const DESCRIPTORS = [DOCKER, DAYTONA, MODAL, E2B, AGENT37, ORGO, PHONE_HARNESS, BROWSERBASE, KERNEL, LOCAL];
|
|
14
|
+
export { AGENT37, BROWSERBASE, DAYTONA, DOCKER, E2B, KERNEL, LOCAL, MODAL, ORGO, PHONE_HARNESS };
|
|
15
|
+
export { AGENT37_BASE_TEMPLATE, AGENT37_BOX_TEMPLATE } from "./agent37.js";
|
|
14
16
|
export { DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, daytonaGpu, daytonaGpuSnapshot } from "./daytona.js";
|
|
15
17
|
export { E2B_BASE_TEMPLATE, E2B_DESKTOP_TEMPLATE } from "./e2b.js";
|
|
16
18
|
export { MODAL_DEFAULT_IMAGE } from "./modal.js";
|
|
@@ -56,7 +56,8 @@ export declare const ORGO: {
|
|
|
56
56
|
}, {
|
|
57
57
|
readonly name: "ORGO_WORKSPACE_ID";
|
|
58
58
|
readonly option: "workspaceId";
|
|
59
|
-
readonly required:
|
|
59
|
+
readonly required: false;
|
|
60
|
+
readonly picked: true;
|
|
60
61
|
}];
|
|
61
62
|
readonly metered: true;
|
|
62
63
|
readonly mounts: readonly [];
|
package/dist/descriptors/orgo.js
CHANGED
|
@@ -30,10 +30,11 @@ export const ORGO_PARKED = [
|
|
|
30
30
|
export const ORGO = defineProvider({
|
|
31
31
|
id: "orgo",
|
|
32
32
|
label: "Orgo",
|
|
33
|
-
// The workspace this server's computers live in: every Orgo provider
|
|
33
|
+
// The workspace this server's computers live in: every Orgo provider lists only it. Unsaved, it is the key's account's
|
|
34
|
+
// one workspace; with several, a person picks one by name in Settings (orgo-workspaces.ts).
|
|
34
35
|
keys: [
|
|
35
36
|
{ name: "ORGO_API_KEY", option: "apiKey", required: true },
|
|
36
|
-
{ name: "ORGO_WORKSPACE_ID", option: "workspaceId", required: true },
|
|
37
|
+
{ name: "ORGO_WORKSPACE_ID", option: "workspaceId", required: false, picked: true },
|
|
37
38
|
],
|
|
38
39
|
metered: true,
|
|
39
40
|
// None yet: an Archil mount needs an Orgo template that bakes the helper.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Group } from "../protocol.js";
|
|
2
|
-
/** The groups a phone harness phone offers. */
|
|
2
|
+
/** The groups a phone harness phone offers: phoned's, the driver it runs (daemon-android/), in its hello's order. */
|
|
3
3
|
export declare const PHONE_GROUPS: readonly Group[];
|
|
4
4
|
/** The phone harness's Android: a phone computer when its setting names no image. */
|
|
5
5
|
export declare const PHONE_IMAGE = "android";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The phone harness's descriptor: a cloud Android over adb, its sessions in a ledger the server keeps.
|
|
2
2
|
import { defineProvider } from "../descriptor.js";
|
|
3
|
-
/** The groups a phone harness phone offers. */
|
|
4
|
-
export const PHONE_GROUPS = ["screen", "input.
|
|
3
|
+
/** The groups a phone harness phone offers: phoned's, the driver it runs (daemon-android/), in its hello's order. */
|
|
4
|
+
export const PHONE_GROUPS = ["exec", "screen", "input.keys", "input.touch", "apps", "ui"];
|
|
5
5
|
/** The phone harness's Android: a phone computer when its setting names no image. */
|
|
6
6
|
export const PHONE_IMAGE = "android";
|
|
7
7
|
export const PHONE_HARNESS = defineProvider({
|
package/dist/docker.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { type DockerHost } from "./docker/inspect.js";
|
|
|
3
3
|
import { type EnsureImageOptions, type ImageSource } from "./docker/image.js";
|
|
4
4
|
import type { KindCapabilities } from "./kinds.js";
|
|
5
5
|
import { type MountKind } from "./mount.js";
|
|
6
|
-
import { type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type NetworkPolicy, type NetworkSpec, type Refusal, type ReleaseHow } from "./provider.js";
|
|
6
|
+
import { type AttachedComputer, type CallContext, type CreateContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type NetworkPolicy, type NetworkSpec, type Refusal, type ReleaseHow } from "./provider.js";
|
|
7
7
|
import { type Result } from "./result.js";
|
|
8
8
|
import { type ScreenWatch, type ScreenWatchHandlers, type WatchOptions } from "./screen-watch.js";
|
|
9
9
|
/**
|
|
@@ -114,9 +114,12 @@ export declare class DockerProvider implements ComputerProvider {
|
|
|
114
114
|
/** The spec's refusals, and the host's once create, attach or host() has read it: its problems, a bind or an
|
|
115
115
|
* allowlist on a host that remaps user ids, and an allowlist on a Docker host this provider does not run on. */
|
|
116
116
|
check(spec: ComputerSpec): Refusal[];
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Makes a computer, once per request (provider.md, Idempotent create): context.requestId names the container
|
|
119
|
+
* (computerNameFor). A request Docker holds a container for already answers that one (#taken); one whose computer
|
|
120
|
+
* was deleted here is refused exists; a create of a request in flight here waits for the first (CreateRequests).
|
|
121
|
+
*/
|
|
122
|
+
create(spec: ComputerSpec, context: CreateContext): Promise<Result<ComputerRef>>;
|
|
120
123
|
/** The Docker host's architecture and enforcement (hostOf), read by docker info once per provider. */
|
|
121
124
|
host({ signal }?: CallContext): Promise<Result<DockerHost>>;
|
|
122
125
|
/** The live view: screen.watch on a connection of the watch's own (daemonWatch); a linux computer has no screen. */
|