@parcha/agentrun-kernel 0.1.0-beta.31 → 0.1.0-beta.32
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/CHANGELOG.md +64 -0
- package/README.md +5 -0
- package/dist/errors.d.ts +7 -0
- package/dist/errors.js +10 -0
- package/dist/host/box.d.ts +0 -58
- package/dist/host/box.js +7 -0
- package/dist/host/index.d.ts +4 -10
- package/dist/host/index.js +2 -5
- package/dist/host/mcp-route.d.ts +3 -0
- package/dist/host/mcp-route.js +6 -2
- package/dist/host/proxy.d.ts +96 -5
- package/dist/host/proxy.js +518 -43
- package/dist/host/serial.js +2 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +3 -2
- package/dist/kernel/cap/admit.d.ts +35 -0
- package/dist/kernel/cap/admit.js +186 -0
- package/dist/kernel/cap/errors.d.ts +20 -0
- package/dist/kernel/cap/errors.js +25 -0
- package/dist/kernel/cap/index.d.ts +14 -0
- package/dist/kernel/cap/index.js +15 -0
- package/dist/kernel/cap/ledger.d.ts +37 -0
- package/dist/kernel/cap/ledger.js +83 -0
- package/dist/kernel/cap/marks.d.ts +50 -0
- package/dist/kernel/cap/marks.js +28 -0
- package/dist/kernel/cap/park.d.ts +80 -0
- package/dist/kernel/cap/park.js +57 -0
- package/dist/kernel/cap/port.d.ts +21 -0
- package/dist/kernel/cap/port.js +95 -0
- package/dist/kernel/cap/price.d.ts +54 -0
- package/dist/kernel/cap/price.js +117 -0
- package/dist/kernel/cap/recover.d.ts +18 -0
- package/dist/kernel/cap/recover.js +71 -0
- package/dist/kernel/cap/rule.d.ts +55 -0
- package/dist/kernel/cap/rule.js +93 -0
- package/dist/kernel/cap/run-cap.d.ts +80 -0
- package/dist/kernel/cap/run-cap.js +132 -0
- package/dist/kernel/cap/steps.d.ts +36 -0
- package/dist/kernel/cap/steps.js +64 -0
- package/dist/kernel/cap/stopped.d.ts +17 -0
- package/dist/kernel/cap/stopped.js +34 -0
- package/dist/kernel/cap/types.d.ts +151 -0
- package/dist/kernel/cap/types.js +1 -0
- package/dist/kernel/cap/words.d.ts +39 -0
- package/dist/kernel/cap/words.js +75 -0
- package/dist/kernel/cap/wrap-up.d.ts +17 -0
- package/dist/kernel/cap/wrap-up.js +37 -0
- package/dist/kernel/drive.d.ts +0 -1
- package/dist/kernel/drive.js +9 -2
- package/dist/kernel/index.d.ts +1 -0
- package/dist/kernel/index.js +1 -0
- package/dist/kernel/registry/background.d.ts +12 -0
- package/dist/kernel/registry/background.js +342 -0
- package/dist/kernel/registry/bash.d.ts +3 -0
- package/dist/kernel/registry/bash.js +23 -0
- package/dist/kernel/registry/browser.d.ts +11 -0
- package/dist/kernel/registry/browser.js +14 -0
- package/dist/kernel/registry/defs.d.ts +42 -0
- package/dist/kernel/registry/defs.js +153 -0
- package/dist/kernel/registry/desktop.d.ts +11 -0
- package/dist/kernel/registry/desktop.js +90 -0
- package/dist/kernel/registry/gate.d.ts +20 -0
- package/dist/kernel/registry/gate.js +32 -0
- package/dist/kernel/registry/handoff.d.ts +11 -0
- package/dist/kernel/registry/handoff.js +51 -0
- package/dist/kernel/registry/hands.d.ts +280 -0
- package/dist/kernel/registry/hands.js +28 -0
- package/dist/kernel/registry/index.d.ts +17 -0
- package/dist/kernel/registry/index.js +14 -0
- package/dist/kernel/registry/limits.d.ts +27 -0
- package/dist/kernel/registry/limits.js +29 -0
- package/dist/kernel/registry/phone.d.ts +15 -0
- package/dist/kernel/registry/phone.js +135 -0
- package/dist/kernel/registry/registry.d.ts +22 -0
- package/dist/kernel/registry/registry.js +75 -0
- package/dist/kernel/types.d.ts +0 -7
- package/dist/process/builtins.js +1 -1
- package/dist/process/index.d.ts +1 -0
- package/dist/process/index.js +1 -0
- package/dist/process/journal.js +1 -1
- package/dist/process/recovery.js +1 -1
- package/dist/process/resume.d.ts +20 -0
- package/dist/process/resume.js +16 -0
- package/dist/process/tail.js +1 -1
- package/dist/process/tools.d.ts +8 -1
- package/dist/process/tools.js +20 -3
- package/dist/process/zod.js +1 -1
- package/dist/run-booking.d.ts +9 -0
- package/dist/run-booking.js +50 -0
- package/dist/runner.d.ts +91 -17
- package/dist/runner.js +132 -41
- package/dist/testing.d.ts +79 -12
- package/dist/testing.js +106 -13
- package/dist/types.d.ts +204 -10
- package/package.json +8 -4
- package/vendor/durable-harness/UPSTREAM.json +0 -9
- package/dist/host/box-slot.d.ts +0 -26
- package/dist/host/box-slot.js +0 -112
- package/dist/host/egress-proxy.d.ts +0 -45
- package/dist/host/egress-proxy.js +0 -416
- package/dist/host/egress-table.d.ts +0 -24
- package/dist/host/egress-table.js +0 -165
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import type { ToolImage } from "../../types.js";
|
|
2
|
+
/** How one exec ended: its exit code, or the signal that ended it (exitCode null), and whether its timeout did. */
|
|
3
|
+
export type ExecResult = {
|
|
4
|
+
readonly exitCode: number | null;
|
|
5
|
+
readonly signal: string | null;
|
|
6
|
+
readonly timedOut: boolean;
|
|
7
|
+
};
|
|
8
|
+
/** The exit code a shell would report: the code, or 128 + n for signal n (any signal the system names); undefined when
|
|
9
|
+
* it is not known. */
|
|
10
|
+
export declare function exitCodeOf(result: ExecResult): number | undefined;
|
|
11
|
+
/** A process the computer runs, as the background tools read it: its argv (which marks a background one), whether it
|
|
12
|
+
* runs, how it ended, when it started, and whether it has a terminal. */
|
|
13
|
+
export type ProcessInfo = {
|
|
14
|
+
readonly handle: string;
|
|
15
|
+
readonly argv: readonly string[];
|
|
16
|
+
readonly running: boolean;
|
|
17
|
+
readonly exitCode: number | null;
|
|
18
|
+
readonly signal: string | null;
|
|
19
|
+
/** Epoch milliseconds. */
|
|
20
|
+
readonly startedAt: number;
|
|
21
|
+
readonly pty: boolean;
|
|
22
|
+
};
|
|
23
|
+
/** The computer's processes, as the five background tools use them, and nothing more. A refusal throws an error with a
|
|
24
|
+
* `code` ("not_found", "invalid", "denied", ...) and the computer's words. Paths are the run's folder's. */
|
|
25
|
+
export type Processes = {
|
|
26
|
+
/** Starts `argv` in `cwd`; its stdout and stderr go to `log` (the first 16 MiB, made never through a link); the
|
|
27
|
+
* process runs until it and its group (on a terminal, its session) have ended, and what leaves the group is kept. */
|
|
28
|
+
start(spec: {
|
|
29
|
+
readonly argv: readonly string[];
|
|
30
|
+
readonly cwd: string;
|
|
31
|
+
readonly log: string;
|
|
32
|
+
readonly waitGroup: true;
|
|
33
|
+
readonly orphans: "keep";
|
|
34
|
+
readonly stdin?: true;
|
|
35
|
+
readonly pty?: {
|
|
36
|
+
readonly cols: number;
|
|
37
|
+
readonly rows: number;
|
|
38
|
+
};
|
|
39
|
+
}): Promise<{
|
|
40
|
+
handle: string;
|
|
41
|
+
pid: number;
|
|
42
|
+
}>;
|
|
43
|
+
/** At most `maxBytes` of its log from `offset`, the log's size, and whether output past the cap was dropped. A read
|
|
44
|
+
* past the end is refused ("invalid"). */
|
|
45
|
+
read(handle: string, range: {
|
|
46
|
+
readonly offset: number;
|
|
47
|
+
readonly maxBytes: number;
|
|
48
|
+
}): Promise<{
|
|
49
|
+
data: Uint8Array;
|
|
50
|
+
size: number;
|
|
51
|
+
capped: boolean;
|
|
52
|
+
}>;
|
|
53
|
+
write(handle: string, input: {
|
|
54
|
+
readonly data?: Uint8Array;
|
|
55
|
+
readonly close?: true;
|
|
56
|
+
}): Promise<void>;
|
|
57
|
+
/** The signal to its group; on a terminal, INT to its foreground job. `note`: what the computer adds to say. */
|
|
58
|
+
signal(handle: string, name: "TERM" | "INT" | "KILL"): Promise<{
|
|
59
|
+
note?: string;
|
|
60
|
+
}>;
|
|
61
|
+
list(): Promise<readonly ProcessInfo[]>;
|
|
62
|
+
};
|
|
63
|
+
/** A computer's kind past files and a shell: each adds its own tools to the run's (defs.ts capabilityToolDefs). */
|
|
64
|
+
export type CapabilityKind = "desktop" | "phone" | "browser";
|
|
65
|
+
/** A kind's tool refused in a run whose computer is not of that kind (or lacks the port): the words name the setting. */
|
|
66
|
+
export declare const needsKindWords: (tool: string, kind: CapabilityKind) => string;
|
|
67
|
+
/** A screenshot as a tool's answer: the words, and the PNG in the answer's images. */
|
|
68
|
+
export declare const shotAnswer: (text: string, shot: Shot) => ToolAnswer;
|
|
69
|
+
/** A point in a screenshot's pixels, origin top left, as computerd's input.actions takes it. */
|
|
70
|
+
export type ScreenPoint = readonly [x: number, y: number];
|
|
71
|
+
/** A screenshot: its PNG's bytes, and its size in pixels (the coordinates input takes). */
|
|
72
|
+
export type Shot = {
|
|
73
|
+
readonly png: Uint8Array;
|
|
74
|
+
readonly width: number;
|
|
75
|
+
readonly height: number;
|
|
76
|
+
};
|
|
77
|
+
/** A desktop's screen (computerd's screen.shot): the whole screen, or a region of it in the whole screen's pixels. */
|
|
78
|
+
export type Screen = {
|
|
79
|
+
shot(options?: {
|
|
80
|
+
readonly region?: {
|
|
81
|
+
readonly x: number;
|
|
82
|
+
readonly y: number;
|
|
83
|
+
readonly w: number;
|
|
84
|
+
readonly h: number;
|
|
85
|
+
};
|
|
86
|
+
}): Promise<Shot>;
|
|
87
|
+
};
|
|
88
|
+
/** One action of a desktop's input, as computerd's input.actions takes it: the pointer's and the keyboard's, and
|
|
89
|
+
* nothing more. A key is a name of computerd's key table or one printable ASCII character. */
|
|
90
|
+
export type InputAction = {
|
|
91
|
+
readonly type: "move";
|
|
92
|
+
readonly at: ScreenPoint;
|
|
93
|
+
} | {
|
|
94
|
+
readonly type: "click";
|
|
95
|
+
readonly at?: ScreenPoint;
|
|
96
|
+
readonly button?: "left" | "right" | "middle";
|
|
97
|
+
readonly count?: 1 | 2 | 3;
|
|
98
|
+
} | {
|
|
99
|
+
readonly type: "drag";
|
|
100
|
+
readonly path: readonly ScreenPoint[];
|
|
101
|
+
readonly button?: "left" | "right" | "middle";
|
|
102
|
+
} | {
|
|
103
|
+
readonly type: "scroll";
|
|
104
|
+
readonly at?: ScreenPoint;
|
|
105
|
+
readonly dx?: number;
|
|
106
|
+
readonly dy?: number;
|
|
107
|
+
readonly unit: "clicks" | "px";
|
|
108
|
+
} | {
|
|
109
|
+
readonly type: "type";
|
|
110
|
+
readonly text: string;
|
|
111
|
+
} | {
|
|
112
|
+
readonly type: "key";
|
|
113
|
+
readonly keys: readonly string[];
|
|
114
|
+
};
|
|
115
|
+
/** A desktop's input (computerd's input.actions): the batch runs in order; a refusal throws its code and words. */
|
|
116
|
+
export type Input = {
|
|
117
|
+
actions(list: readonly InputAction[]): Promise<void>;
|
|
118
|
+
};
|
|
119
|
+
/** A point on a phone's screen, in its screenshot's pixels. */
|
|
120
|
+
export type PhonePoint = {
|
|
121
|
+
readonly x: number;
|
|
122
|
+
readonly y: number;
|
|
123
|
+
};
|
|
124
|
+
/** A node of a phone screen's structure, flattened: its platform class, its id, text and label where it has them, its
|
|
125
|
+
* bounds in screenshot pixels, and whether a model can tap it or type into it. */
|
|
126
|
+
export type PhoneNode = {
|
|
127
|
+
readonly role: string;
|
|
128
|
+
readonly id?: string;
|
|
129
|
+
readonly text?: string;
|
|
130
|
+
readonly label?: string;
|
|
131
|
+
readonly bounds: {
|
|
132
|
+
readonly x: number;
|
|
133
|
+
readonly y: number;
|
|
134
|
+
readonly w: number;
|
|
135
|
+
readonly h: number;
|
|
136
|
+
};
|
|
137
|
+
readonly clickable: boolean;
|
|
138
|
+
readonly editable: boolean;
|
|
139
|
+
readonly focused?: boolean;
|
|
140
|
+
/** A node with no text or label of its own, named by its first inner text (else label): an Android list row, a
|
|
141
|
+
* clickable layout whose title sits on a child that is not clickable. */
|
|
142
|
+
readonly inner?: string;
|
|
143
|
+
};
|
|
144
|
+
/** A key a phone presses: its back and home buttons, and enter. */
|
|
145
|
+
export type PhoneKey = "back" | "home" | "enter";
|
|
146
|
+
/** A phone: its screen and the screen's structure, a tap, a swipe, typing into the field in focus, its keys, and its apps. */
|
|
147
|
+
export type Phone = {
|
|
148
|
+
shot(): Promise<Shot>;
|
|
149
|
+
/** The screen's structure, flattened (`total` the nodes the phone gave, `truncated` when it gave only part); absent on a
|
|
150
|
+
* phone that does not offer it. */
|
|
151
|
+
tree?(): Promise<{
|
|
152
|
+
readonly nodes: readonly PhoneNode[];
|
|
153
|
+
readonly total: number;
|
|
154
|
+
readonly truncated: boolean;
|
|
155
|
+
}>;
|
|
156
|
+
tap(at: PhonePoint): Promise<void>;
|
|
157
|
+
swipe(spec: {
|
|
158
|
+
readonly from: PhonePoint;
|
|
159
|
+
readonly to: PhonePoint;
|
|
160
|
+
readonly durationMs: number;
|
|
161
|
+
}): Promise<void>;
|
|
162
|
+
type(text: string): Promise<void>;
|
|
163
|
+
/** Absent on a phone that does not offer its keys. */
|
|
164
|
+
key?(name: PhoneKey): Promise<void>;
|
|
165
|
+
readonly apps: {
|
|
166
|
+
list(): Promise<{
|
|
167
|
+
readonly apps: readonly {
|
|
168
|
+
readonly id: string;
|
|
169
|
+
readonly name?: string;
|
|
170
|
+
}[];
|
|
171
|
+
readonly foreground: string | null;
|
|
172
|
+
}>;
|
|
173
|
+
open(id: string): Promise<void>;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
/** A connection to a browser's DevTools protocol (pi-browser's CdpLink, in shape). */
|
|
177
|
+
export type CdpSession = {
|
|
178
|
+
send(method: string, params?: object, sessionId?: string): Promise<unknown>;
|
|
179
|
+
on(listener: (event: {
|
|
180
|
+
method?: string;
|
|
181
|
+
params?: unknown;
|
|
182
|
+
sessionId?: string;
|
|
183
|
+
}) => void): () => void;
|
|
184
|
+
close(): void;
|
|
185
|
+
};
|
|
186
|
+
/** A browser computer: a connection to its CDP. The browser's tools and take-over are the host's (pi-browser's). */
|
|
187
|
+
export type Browser = {
|
|
188
|
+
connect(): Promise<CdpSession>;
|
|
189
|
+
};
|
|
190
|
+
/** The agent's hand-over of a desktop or a phone to the person, through the run's hold: ask opens it (what the person is
|
|
191
|
+
* to do, how both will know it is done, when it expires, ISO time) and resolves with its first answer, or expired. An
|
|
192
|
+
* abort of `signal` (a stop, a lost claim) rejects it. */
|
|
193
|
+
export type Handoff = {
|
|
194
|
+
ask(request: {
|
|
195
|
+
readonly instruction: string;
|
|
196
|
+
readonly completion_condition: string;
|
|
197
|
+
readonly expires_at: string;
|
|
198
|
+
}, signal?: AbortSignal): Promise<{
|
|
199
|
+
readonly outcome: "done" | "cancelled" | "expired";
|
|
200
|
+
}>;
|
|
201
|
+
};
|
|
202
|
+
/** What a host tool does with the run's files and shell. */
|
|
203
|
+
export type Hands = {
|
|
204
|
+
/** The longest one exec may run, in seconds: 600 locally and on a computer, 295 on Archil's exec. */
|
|
205
|
+
readonly maxExecS: number;
|
|
206
|
+
stat(path: string): Promise<{
|
|
207
|
+
kind: "file" | "dir" | "link";
|
|
208
|
+
size: number;
|
|
209
|
+
mtimeMs: number;
|
|
210
|
+
} | undefined>;
|
|
211
|
+
read(path: string, range?: {
|
|
212
|
+
offset?: number;
|
|
213
|
+
length?: number;
|
|
214
|
+
}): Promise<Uint8Array>;
|
|
215
|
+
/** Durable when it returns. */
|
|
216
|
+
write(path: string, bytes: Uint8Array): Promise<void>;
|
|
217
|
+
append(path: string, bytes: Uint8Array): Promise<void>;
|
|
218
|
+
list(path: string): Promise<readonly {
|
|
219
|
+
name: string;
|
|
220
|
+
kind: "file" | "dir" | "link";
|
|
221
|
+
size: number;
|
|
222
|
+
}[]>;
|
|
223
|
+
grep(pattern: string, path: string, options?: {
|
|
224
|
+
glob?: string;
|
|
225
|
+
ignoreCase?: boolean;
|
|
226
|
+
maxMatches?: number;
|
|
227
|
+
}): Promise<string>;
|
|
228
|
+
/** `command` run by the run's shell (`bash -c`, a fixed minimal env) in the run's folder, stdin /dev/null, for at most
|
|
229
|
+
* `timeoutS`: its exit code, or the signal that ended it, and whether the timeout did. An abort throws. */
|
|
230
|
+
exec(command: string, options: {
|
|
231
|
+
timeoutS: number;
|
|
232
|
+
onOutput?: (chunk: {
|
|
233
|
+
stream: "stdout" | "stderr";
|
|
234
|
+
data: string;
|
|
235
|
+
}) => void;
|
|
236
|
+
}, signal?: AbortSignal): Promise<ExecResult>;
|
|
237
|
+
/** The attached computer's processes; absent with no computer, where the background tools are refused. */
|
|
238
|
+
readonly processes?: Processes;
|
|
239
|
+
/** A desktop's screen and input; absent where the computer has none, and their tools are refused in words. */
|
|
240
|
+
readonly screen?: Screen;
|
|
241
|
+
readonly input?: Input;
|
|
242
|
+
/** A phone's screen, touch, typing and apps; absent where the computer is no phone. */
|
|
243
|
+
readonly phone?: Phone;
|
|
244
|
+
/** A browser's CDP; absent where the computer is no browser. */
|
|
245
|
+
readonly browser?: Browser;
|
|
246
|
+
/** A desktop's or a phone's hand-over to the person (the run's hold); absent where there is none. */
|
|
247
|
+
readonly handoff?: Handoff;
|
|
248
|
+
};
|
|
249
|
+
/** A tool's answer: the text the model reads (and its images), with details for the run's timeline. A failure is an
|
|
250
|
+
* answer too: `error` holds its words, apart from the output, so what the call printed before it failed is kept. The
|
|
251
|
+
* host shows `[text, error, ...diagnostics' messages].join("\n\n")`. Only an abort throws. */
|
|
252
|
+
export type ToolAnswer = {
|
|
253
|
+
readonly text: string;
|
|
254
|
+
readonly error?: string;
|
|
255
|
+
readonly images?: readonly ToolImage[];
|
|
256
|
+
readonly details?: unknown;
|
|
257
|
+
readonly isError?: boolean;
|
|
258
|
+
readonly diagnostics?: readonly {
|
|
259
|
+
readonly severity: "info" | "warn" | "error";
|
|
260
|
+
readonly code?: string;
|
|
261
|
+
readonly message: string;
|
|
262
|
+
}[];
|
|
263
|
+
};
|
|
264
|
+
/** One call's world: the run's hands, the call's signal, where output streamed while it runs goes, and (passed through,
|
|
265
|
+
* unread by the kernel) the call's model, whose image limits a host's read may use. */
|
|
266
|
+
export type ToolCall = {
|
|
267
|
+
readonly hands: Hands;
|
|
268
|
+
readonly signal?: AbortSignal;
|
|
269
|
+
output?(chunk: string): void;
|
|
270
|
+
readonly model?: unknown;
|
|
271
|
+
};
|
|
272
|
+
/** An executor's failure as an answer: an abort (the call's signal aborted) throws; any other error is its words. */
|
|
273
|
+
export declare function answerOf(call: ToolCall, run: () => Promise<ToolAnswer>): Promise<ToolAnswer>;
|
|
274
|
+
/** A host tool's run. */
|
|
275
|
+
export type Executor = (args: unknown, call: ToolCall) => Promise<ToolAnswer>;
|
|
276
|
+
/** What the host gives the registry, by tool name: read, write and edit, and bash's own run, which the registry bounds;
|
|
277
|
+
* and, for a browser, its tools' runs (pi-browser's, over hands.browser), by tool name. */
|
|
278
|
+
export type HostExecutors = Readonly<Partial<Record<"read" | "write" | "edit" | "bash", Executor>>> & {
|
|
279
|
+
readonly browser?: Readonly<Record<string, Executor>>;
|
|
280
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// The run's hands, as the registry's tools reach them: Workspace(run) on the host's side (a folder on this machine, the
|
|
2
|
+
// run's Archil disk, or an attached computer), given to each call. The kernel never knows which.
|
|
3
|
+
import { constants } from "node:os";
|
|
4
|
+
/** The exit code a shell would report: the code, or 128 + n for signal n (any signal the system names); undefined when
|
|
5
|
+
* it is not known. */
|
|
6
|
+
export function exitCodeOf(result) {
|
|
7
|
+
if (result.exitCode !== null)
|
|
8
|
+
return result.exitCode;
|
|
9
|
+
if (result.signal === null)
|
|
10
|
+
return undefined;
|
|
11
|
+
const n = constants.signals[`SIG${result.signal.replace(/^SIG/, "")}`];
|
|
12
|
+
return n === undefined ? undefined : 128 + n;
|
|
13
|
+
}
|
|
14
|
+
/** A kind's tool refused in a run whose computer is not of that kind (or lacks the port): the words name the setting. */
|
|
15
|
+
export const needsKindWords = (tool, kind) => `${tool} needs a ${kind} computer: set this agent's computer to ${kind} (Settings → Computers).`;
|
|
16
|
+
/** A screenshot as a tool's answer: the words, and the PNG in the answer's images. */
|
|
17
|
+
export const shotAnswer = (text, shot) => ({ text, images: [{ mimeType: "image/png", data: Buffer.from(shot.png.buffer, shot.png.byteOffset, shot.png.byteLength).toString("base64") }] });
|
|
18
|
+
/** An executor's failure as an answer: an abort (the call's signal aborted) throws; any other error is its words. */
|
|
19
|
+
export async function answerOf(call, run) {
|
|
20
|
+
try {
|
|
21
|
+
return await run();
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
if (call.signal?.aborted)
|
|
25
|
+
throw call.signal.reason ?? error;
|
|
26
|
+
return { text: "", error: error instanceof Error ? error.message : String(error) };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { BACKGROUND_EXECUTORS, endBackground, NEEDS_A_COMPUTER, NO_SHELL } from "./background.js";
|
|
2
|
+
export { boundedBash } from "./bash.js";
|
|
3
|
+
export { browserToolDefs } from "./browser.js";
|
|
4
|
+
export type { BrowserContract } from "./browser.js";
|
|
5
|
+
export { bashTimeoutWords, CAPABILITY_KINDS, capabilityToolDefs, hostToolDefs } from "./defs.js";
|
|
6
|
+
export type { ShellPlace, ToolDef } from "./defs.js";
|
|
7
|
+
export { DESKTOP_ACTIONS, DESKTOP_EXECUTORS, DESKTOP_KEYS, DESKTOP_MAX_ACTIONS, DESKTOP_TOOL_DEFS } from "./desktop.js";
|
|
8
|
+
export { defaultPermissionOf, SHELL_FAMILY, SHELL_WATCHERS, shellPermission, shellToolOf } from "./gate.js";
|
|
9
|
+
export type { Permission } from "./gate.js";
|
|
10
|
+
export { answerOf, exitCodeOf, needsKindWords } from "./hands.js";
|
|
11
|
+
export type { Browser, CapabilityKind, CdpSession, ExecResult, Executor, Hands, HostExecutors, Input, InputAction, Phone, PhoneKey, PhoneNode, PhonePoint, ProcessInfo, Processes, Screen, ScreenPoint, Shot, ToolAnswer, ToolCall, } from "./hands.js";
|
|
12
|
+
export { PHONE_EXECUTORS, PHONE_KEYS, PHONE_SWIPE_MAX_MS, PHONE_SWIPE_MS, PHONE_TOOL_DEFS, PHONE_TREE_MAX_CHARS, PHONE_TREE_MAX_NODES } from "./phone.js";
|
|
13
|
+
export { HANDOFF_DEFAULT_S, HANDOFF_MAX_S, HANDOFF_MIN_S, HANDOFF_TOOL } from "./handoff.js";
|
|
14
|
+
export type { Handoff } from "./hands.js";
|
|
15
|
+
export { BACKGROUND_DIR, BACKGROUND_INPUT_BYTES, BACKGROUND_LIST_MAX, BACKGROUND_LOG_BYTES, BACKGROUND_MAX, BACKGROUND_PAGE_BYTES, BACKGROUND_SIGNALS, BACKGROUND_TOOLS, BASH_DEFAULT_TIMEOUT_S, BASH_MAX_TIMEOUT_S, READ_IMAGE_MAX_BYTES, SHELL_TOOLS, } from "./limits.js";
|
|
16
|
+
export { createRegistry } from "./registry.js";
|
|
17
|
+
export type { Registry } from "./registry.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// The kernel's one tool registry: the host tools' definitions, words and limits, the gate's shell family, the run's
|
|
2
|
+
// hands, and the executors the kernel owns; a computer kind's own tools (desktop, phone, browser) and the narrow ports
|
|
3
|
+
// they run on. Unused on main until the cutover wires serve onto it.
|
|
4
|
+
export { BACKGROUND_EXECUTORS, endBackground, NEEDS_A_COMPUTER, NO_SHELL } from "./background.js";
|
|
5
|
+
export { boundedBash } from "./bash.js";
|
|
6
|
+
export { browserToolDefs } from "./browser.js";
|
|
7
|
+
export { bashTimeoutWords, CAPABILITY_KINDS, capabilityToolDefs, hostToolDefs } from "./defs.js";
|
|
8
|
+
export { DESKTOP_ACTIONS, DESKTOP_EXECUTORS, DESKTOP_KEYS, DESKTOP_MAX_ACTIONS, DESKTOP_TOOL_DEFS } from "./desktop.js";
|
|
9
|
+
export { defaultPermissionOf, SHELL_FAMILY, SHELL_WATCHERS, shellPermission, shellToolOf } from "./gate.js";
|
|
10
|
+
export { answerOf, exitCodeOf, needsKindWords } from "./hands.js";
|
|
11
|
+
export { PHONE_EXECUTORS, PHONE_KEYS, PHONE_SWIPE_MAX_MS, PHONE_SWIPE_MS, PHONE_TOOL_DEFS, PHONE_TREE_MAX_CHARS, PHONE_TREE_MAX_NODES } from "./phone.js";
|
|
12
|
+
export { HANDOFF_DEFAULT_S, HANDOFF_MAX_S, HANDOFF_MIN_S, HANDOFF_TOOL } from "./handoff.js";
|
|
13
|
+
export { BACKGROUND_DIR, BACKGROUND_INPUT_BYTES, BACKGROUND_LIST_MAX, BACKGROUND_LOG_BYTES, BACKGROUND_MAX, BACKGROUND_PAGE_BYTES, BACKGROUND_SIGNALS, BACKGROUND_TOOLS, BASH_DEFAULT_TIMEOUT_S, BASH_MAX_TIMEOUT_S, READ_IMAGE_MAX_BYTES, SHELL_TOOLS, } from "./limits.js";
|
|
14
|
+
export { createRegistry } from "./registry.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** bash's timeout, in seconds: the default when a call names none, and the most a call gets where the hands allow it
|
|
2
|
+
* (Claude Code's own 120 s and 600 s). A command that needs longer is a background process (bash_background). The
|
|
3
|
+
* ceiling a run gets is its hands' `maxExecS`: 600 s locally and on a computer, less where the hands' exec is bounded. */
|
|
4
|
+
export declare const BASH_DEFAULT_TIMEOUT_S = 120;
|
|
5
|
+
export declare const BASH_MAX_TIMEOUT_S = 600;
|
|
6
|
+
/** The largest image read hands the model, in bytes: 3.75 MiB, whose base64 is the 5 MiB the strictest platform a
|
|
7
|
+
* harness sends images to takes (the claude-agent adapter's CLAUDE_AGENT_MAX_IMAGE_BYTES, Amazon Bedrock's). */
|
|
8
|
+
export declare const READ_IMAGE_MAX_BYTES = 3932160;
|
|
9
|
+
/** The most background processes that run at once in one run's computer. */
|
|
10
|
+
export declare const BACKGROUND_MAX = 8;
|
|
11
|
+
/** The most bytes of output one background process's log keeps: later output is dropped, and the process runs on. */
|
|
12
|
+
export declare const BACKGROUND_LOG_BYTES: number;
|
|
13
|
+
/** The most bytes of output one `bash_output` call answers, and its default. */
|
|
14
|
+
export declare const BACKGROUND_PAGE_BYTES: number;
|
|
15
|
+
/** The most bytes one `bash_input` call writes. */
|
|
16
|
+
export declare const BACKGROUND_INPUT_BYTES: number;
|
|
17
|
+
/** The most processes `bash_list` names: every running one, then the newest that ended. */
|
|
18
|
+
export declare const BACKGROUND_LIST_MAX = 40;
|
|
19
|
+
/** Where a background process's log and state live, under the run's work/. */
|
|
20
|
+
export declare const BACKGROUND_DIR = "background";
|
|
21
|
+
/** The signals `bash_signal` sends. */
|
|
22
|
+
export declare const BACKGROUND_SIGNALS: readonly ["TERM", "INT", "KILL"];
|
|
23
|
+
/** The background tools, by name. */
|
|
24
|
+
export declare const BACKGROUND_TOOLS: readonly ["bash_background", "bash_output", "bash_input", "bash_signal", "bash_list"];
|
|
25
|
+
/** The tools that run a command on the run's computer: bash, and the background tools. The tool gate holds each to
|
|
26
|
+
* bash's setting (SHELL_FAMILY). */
|
|
27
|
+
export declare const SHELL_TOOLS: readonly string[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// The host tools' limits, moved from serve (coding-tools.ts, background.ts) unchanged: the kernel's registry holds every
|
|
2
|
+
// model-visible host tool's words and limits, and serve reads them from here once the cutover wires it.
|
|
3
|
+
/** bash's timeout, in seconds: the default when a call names none, and the most a call gets where the hands allow it
|
|
4
|
+
* (Claude Code's own 120 s and 600 s). A command that needs longer is a background process (bash_background). The
|
|
5
|
+
* ceiling a run gets is its hands' `maxExecS`: 600 s locally and on a computer, less where the hands' exec is bounded. */
|
|
6
|
+
export const BASH_DEFAULT_TIMEOUT_S = 120;
|
|
7
|
+
export const BASH_MAX_TIMEOUT_S = 600;
|
|
8
|
+
/** The largest image read hands the model, in bytes: 3.75 MiB, whose base64 is the 5 MiB the strictest platform a
|
|
9
|
+
* harness sends images to takes (the claude-agent adapter's CLAUDE_AGENT_MAX_IMAGE_BYTES, Amazon Bedrock's). */
|
|
10
|
+
export const READ_IMAGE_MAX_BYTES = 3_932_160;
|
|
11
|
+
/** The most background processes that run at once in one run's computer. */
|
|
12
|
+
export const BACKGROUND_MAX = 8;
|
|
13
|
+
/** The most bytes of output one background process's log keeps: later output is dropped, and the process runs on. */
|
|
14
|
+
export const BACKGROUND_LOG_BYTES = 16 * 1024 * 1024;
|
|
15
|
+
/** The most bytes of output one `bash_output` call answers, and its default. */
|
|
16
|
+
export const BACKGROUND_PAGE_BYTES = 48 * 1024;
|
|
17
|
+
/** The most bytes one `bash_input` call writes. */
|
|
18
|
+
export const BACKGROUND_INPUT_BYTES = 64 * 1024;
|
|
19
|
+
/** The most processes `bash_list` names: every running one, then the newest that ended. */
|
|
20
|
+
export const BACKGROUND_LIST_MAX = 40;
|
|
21
|
+
/** Where a background process's log and state live, under the run's work/. */
|
|
22
|
+
export const BACKGROUND_DIR = "background";
|
|
23
|
+
/** The signals `bash_signal` sends. */
|
|
24
|
+
export const BACKGROUND_SIGNALS = ["TERM", "INT", "KILL"];
|
|
25
|
+
/** The background tools, by name. */
|
|
26
|
+
export const BACKGROUND_TOOLS = ["bash_background", "bash_output", "bash_input", "bash_signal", "bash_list"];
|
|
27
|
+
/** The tools that run a command on the run's computer: bash, and the background tools. The tool gate holds each to
|
|
28
|
+
* bash's setting (SHELL_FAMILY). */
|
|
29
|
+
export const SHELL_TOOLS = ["bash", ...BACKGROUND_TOOLS];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ToolDef } from "./defs.js";
|
|
2
|
+
import { type Executor, type PhoneKey } from "./hands.js";
|
|
3
|
+
/** How long a swipe takes when a call names no duration, and the longest one may. */
|
|
4
|
+
export declare const PHONE_SWIPE_MS = 300;
|
|
5
|
+
export declare const PHONE_SWIPE_MAX_MS = 10000;
|
|
6
|
+
/** The most nodes phone_tree lists, and the most characters its answer takes: past either, one line counts the rest. A
|
|
7
|
+
* screen's structure can hold thousands of nodes; the answer stays a screenful, never a flood in the model's context or
|
|
8
|
+
* the run's journal. */
|
|
9
|
+
export declare const PHONE_TREE_MAX_NODES = 150;
|
|
10
|
+
export declare const PHONE_TREE_MAX_CHARS = 12000;
|
|
11
|
+
/** The keys phone_key presses. */
|
|
12
|
+
export declare const PHONE_KEYS: readonly PhoneKey[];
|
|
13
|
+
export declare const PHONE_TOOL_DEFS: readonly ToolDef[];
|
|
14
|
+
/** The phone's tools' runs, on the hands' phone. */
|
|
15
|
+
export declare const PHONE_EXECUTORS: Readonly<Record<string, Executor>>;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { answerOf, needsKindWords, shotAnswer } from "./hands.js";
|
|
2
|
+
import { HANDOFF_TOOL, handoffDef, handoffExecutor } from "./handoff.js";
|
|
3
|
+
/** How long a swipe takes when a call names no duration, and the longest one may. */
|
|
4
|
+
export const PHONE_SWIPE_MS = 300;
|
|
5
|
+
export const PHONE_SWIPE_MAX_MS = 10_000;
|
|
6
|
+
/** The most nodes phone_tree lists, and the most characters its answer takes: past either, one line counts the rest. A
|
|
7
|
+
* screen's structure can hold thousands of nodes; the answer stays a screenful, never a flood in the model's context or
|
|
8
|
+
* the run's journal. */
|
|
9
|
+
export const PHONE_TREE_MAX_NODES = 150;
|
|
10
|
+
export const PHONE_TREE_MAX_CHARS = 12_000;
|
|
11
|
+
/** The most characters of a node's text or label phone_tree shows. */
|
|
12
|
+
const PHONE_TREE_TEXT_CHARS = 80;
|
|
13
|
+
/** The keys phone_key presses. */
|
|
14
|
+
export const PHONE_KEYS = Object.freeze(["back", "home", "enter"]);
|
|
15
|
+
const def = (name, description, parameters, replaySafe) => ({
|
|
16
|
+
name, source: "host", gateName: `host:phone/${name}`, settingsKey: "phone", description, parameters, replaySafe,
|
|
17
|
+
});
|
|
18
|
+
const object = (properties, required) => ({ type: "object", additionalProperties: false, properties, required });
|
|
19
|
+
const COORDINATE = { type: "integer", minimum: 0 };
|
|
20
|
+
const POINT = { ...object({ x: COORDINATE, y: COORDINATE }, ["x", "y"]), description: "A point in screenshot pixels, origin top left." };
|
|
21
|
+
export const PHONE_TOOL_DEFS = Object.freeze([
|
|
22
|
+
def("phone_screen", "Take a screenshot of the phone's screen, as an image. Its pixels are the coordinates phone_tap and phone_swipe take, origin top left.", object({}, []), true),
|
|
23
|
+
def("phone_tree", `List what on the phone's screen can be tapped or typed into, from the screen's structure: each node's class, its text or label, its id, and its center and bounds in a phone_screen screenshot's pixels (tap the center). At most ${PHONE_TREE_MAX_NODES} nodes; a last line counts any more.`, object({}, []), true),
|
|
24
|
+
def("phone_tap", "Tap the phone's screen once at x, y, in the pixels of a phone_screen screenshot.", object({ x: COORDINATE, y: COORDINATE }, ["x", "y"]), false),
|
|
25
|
+
def("phone_swipe", `Swipe on the phone's screen from one point to another, in screenshot pixels, over duration_ms (${PHONE_SWIPE_MS} ms when absent). A swipe up scrolls a list down.`, object({ from: POINT, to: POINT, duration_ms: { type: "integer", minimum: 1, maximum: PHONE_SWIPE_MAX_MS } }, ["from", "to"]), false),
|
|
26
|
+
def("phone_type", "Type text into the field that has focus on the phone, as given. Tap the field first.", object({ text: { type: "string", minLength: 1 } }, ["text"]), false),
|
|
27
|
+
def("phone_key", "Press one of the phone's keys: back (the system back: leaves a page, closes a dialog or the keyboard), home (the home screen) or enter (submits the field in focus).", object({ key: { type: "string", enum: [...PHONE_KEYS] } }, ["key"]), false),
|
|
28
|
+
def("phone_apps", "List the phone's installed apps, each by its id (and its name where the phone gives one), and which app is in front.", object({}, []), true),
|
|
29
|
+
def("phone_open", "Open an app on the phone by its id (phone_apps lists them), bringing it to the front.", object({ id: { type: "string", minLength: 1 } }, ["id"]), false),
|
|
30
|
+
// The agent's hand-over of the phone to the person (handoff.ts), under the phone's settings key.
|
|
31
|
+
handoffDef("phone"),
|
|
32
|
+
]);
|
|
33
|
+
const POINT_WORDS = "x and y are whole numbers from 0, in the screenshot's pixels";
|
|
34
|
+
const pointOf = (value, what = POINT_WORDS) => {
|
|
35
|
+
const point = value;
|
|
36
|
+
if (typeof point !== "object" || point === null || !Number.isSafeInteger(point.x) || !Number.isSafeInteger(point.y) || point.x < 0 || point.y < 0)
|
|
37
|
+
throw new Error(what);
|
|
38
|
+
return { x: point.x, y: point.y };
|
|
39
|
+
};
|
|
40
|
+
const said = (point) => `(${point.x}, ${point.y})`;
|
|
41
|
+
const phoneOf = (hands, tool) => {
|
|
42
|
+
if (!hands.phone)
|
|
43
|
+
throw new Error(needsKindWords(tool, "phone"));
|
|
44
|
+
return hands.phone;
|
|
45
|
+
};
|
|
46
|
+
const run = (tool, body) => (args, call) => answerOf(call, async () => body(phoneOf(call.hands, tool), (typeof args === "object" && args !== null ? args : {})));
|
|
47
|
+
/** A node's class as a model reads it: the platform's, its package or iOS prefix dropped ("Button", "EditText"). */
|
|
48
|
+
const classOf = (role) => role.replace(/^XCUIElementType/, "").split(".").pop() || role;
|
|
49
|
+
const clip = (text) => (text.length > PHONE_TREE_TEXT_CHARS ? `${text.slice(0, PHONE_TREE_TEXT_CHARS - 1)}…` : text);
|
|
50
|
+
/** One node, on one line: its class, its text or label (else its first inner text, marked so), its id, whether it is a
|
|
51
|
+
* field (and in focus), its center to tap and its bounds. */
|
|
52
|
+
function nodeLine(node) {
|
|
53
|
+
const own = node.text || node.label;
|
|
54
|
+
const name = own ? JSON.stringify(clip(own)) : node.inner ? `${JSON.stringify(clip(node.inner))} (inner text)` : "";
|
|
55
|
+
const { x, y, w, h } = node.bounds;
|
|
56
|
+
const state = node.editable ? `a field${node.focused ? ", focused" : ""}; ` : node.focused ? "focused; " : "";
|
|
57
|
+
const center = `(${Math.round(x + w / 2)}, ${Math.round(y + h / 2)})`;
|
|
58
|
+
return `- ${clip(classOf(node.role))}${name ? ` ${name}` : ""}${node.id ? ` [${clip(node.id)}]` : ""}: ${state}center ${center}, bounds ${x},${y} ${w}x${h}`;
|
|
59
|
+
}
|
|
60
|
+
/** phone_tree's answer: a head line, then a line a node, at most PHONE_TREE_MAX_NODES of them and PHONE_TREE_MAX_CHARS
|
|
61
|
+
* characters in all; one last line counts the nodes not shown. */
|
|
62
|
+
function treeAnswer(tree) {
|
|
63
|
+
const nodes = tree.nodes.filter((node) => node.clickable || node.editable);
|
|
64
|
+
const head = `${nodes.length} node${nodes.length === 1 ? "" : "s"} you can tap or type into, of ${tree.total} on the screen. Coordinates are a phone_screen screenshot's pixels.${tree.truncated ? " The phone gave only part of the screen's structure: take a phone_screen screenshot for the rest." : ""}`;
|
|
65
|
+
const lines = [head];
|
|
66
|
+
// Room kept for the last line, whatever it counts.
|
|
67
|
+
let room = PHONE_TREE_MAX_CHARS - head.length - `\n${nodes.length} more nodes not shown.`.length;
|
|
68
|
+
let shown = 0;
|
|
69
|
+
for (const node of nodes) {
|
|
70
|
+
if (shown >= PHONE_TREE_MAX_NODES)
|
|
71
|
+
break;
|
|
72
|
+
const line = nodeLine(node);
|
|
73
|
+
if (line.length + 1 > room)
|
|
74
|
+
break;
|
|
75
|
+
lines.push(line);
|
|
76
|
+
room -= line.length + 1;
|
|
77
|
+
shown += 1;
|
|
78
|
+
}
|
|
79
|
+
if (shown < nodes.length)
|
|
80
|
+
lines.push(`${nodes.length - shown} more node${nodes.length - shown === 1 ? "" : "s"} not shown.`);
|
|
81
|
+
return lines.join("\n");
|
|
82
|
+
}
|
|
83
|
+
/** The phone's tools' runs, on the hands' phone. */
|
|
84
|
+
export const PHONE_EXECUTORS = Object.freeze({
|
|
85
|
+
phone_screen: run("phone_screen", async (phone) => {
|
|
86
|
+
const shot = await phone.shot();
|
|
87
|
+
return shotAnswer(`A screenshot of the phone's screen, ${shot.width}x${shot.height} pixels.`, shot);
|
|
88
|
+
}),
|
|
89
|
+
phone_tree: run("phone_tree", async (phone) => {
|
|
90
|
+
if (!phone.tree)
|
|
91
|
+
throw new Error("this phone does not offer its UI tree");
|
|
92
|
+
return { text: treeAnswer(await phone.tree()) };
|
|
93
|
+
}),
|
|
94
|
+
phone_key: run("phone_key", async (phone, args) => {
|
|
95
|
+
if (!phone.key)
|
|
96
|
+
throw new Error("this phone does not offer its keys");
|
|
97
|
+
const key = args.key;
|
|
98
|
+
if (typeof key !== "string" || !PHONE_KEYS.includes(key))
|
|
99
|
+
throw new Error(`key is ${PHONE_KEYS.slice(0, -1).join(", ")} or ${PHONE_KEYS.at(-1)}`);
|
|
100
|
+
await phone.key(key);
|
|
101
|
+
return { text: `Pressed ${key}.` };
|
|
102
|
+
}),
|
|
103
|
+
phone_tap: run("phone_tap", async (phone, args) => {
|
|
104
|
+
const at = pointOf(args);
|
|
105
|
+
await phone.tap(at);
|
|
106
|
+
return { text: `Tapped at ${said(at)}.` };
|
|
107
|
+
}),
|
|
108
|
+
phone_swipe: run("phone_swipe", async (phone, args) => {
|
|
109
|
+
const from = pointOf(args.from, `from: ${POINT_WORDS}`);
|
|
110
|
+
const to = pointOf(args.to, `to: ${POINT_WORDS}`);
|
|
111
|
+
const durationMs = args.duration_ms ?? PHONE_SWIPE_MS;
|
|
112
|
+
if (!Number.isSafeInteger(durationMs) || durationMs < 1 || durationMs > PHONE_SWIPE_MAX_MS)
|
|
113
|
+
throw new Error(`duration_ms is a whole number of milliseconds from 1 to ${PHONE_SWIPE_MAX_MS}`);
|
|
114
|
+
await phone.swipe({ from, to, durationMs: durationMs });
|
|
115
|
+
return { text: `Swiped from ${said(from)} to ${said(to)} over ${durationMs} ms.` };
|
|
116
|
+
}),
|
|
117
|
+
phone_type: run("phone_type", async (phone, args) => {
|
|
118
|
+
if (typeof args.text !== "string" || args.text === "")
|
|
119
|
+
throw new Error("text is the text to type");
|
|
120
|
+
await phone.type(args.text);
|
|
121
|
+
return { text: `Typed ${[...args.text].length} characters.` };
|
|
122
|
+
}),
|
|
123
|
+
phone_apps: run("phone_apps", async (phone) => {
|
|
124
|
+
const { apps, foreground } = await phone.apps.list();
|
|
125
|
+
const head = `${apps.length} app${apps.length === 1 ? "" : "s"}; ${foreground === null ? "none is in front" : `${foreground} is in front`}.`;
|
|
126
|
+
return { text: [head, ...apps.map((app) => (app.name ? `${app.id} (${app.name})` : app.id))].join("\n") };
|
|
127
|
+
}),
|
|
128
|
+
phone_open: run("phone_open", async (phone, args) => {
|
|
129
|
+
if (typeof args.id !== "string" || args.id === "")
|
|
130
|
+
throw new Error("id is an app's id, as phone_apps lists it");
|
|
131
|
+
await phone.apps.open(args.id);
|
|
132
|
+
return { text: `Opened ${args.id}.` };
|
|
133
|
+
}),
|
|
134
|
+
[HANDOFF_TOOL]: handoffExecutor("phone"),
|
|
135
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { BrowserContract } from "./browser.js";
|
|
2
|
+
import { type ShellPlace, type ToolDef } from "./defs.js";
|
|
3
|
+
import { type CapabilityKind, type HostExecutors, type ToolAnswer, type ToolCall } from "./hands.js";
|
|
4
|
+
export type Registry = {
|
|
5
|
+
/** The tools the model sees, in order. */
|
|
6
|
+
list(): readonly ToolDef[];
|
|
7
|
+
get(name: string): ToolDef | undefined;
|
|
8
|
+
invoke(name: string, args: unknown, call: ToolCall): Promise<ToolAnswer>;
|
|
9
|
+
};
|
|
10
|
+
/** The registry of a run's host tools, by where its shell is, and its computer's kinds (`kinds`: none, or the desktop,
|
|
11
|
+
* the phone or the browser it is), with the host's executors. `browserTools`: pi-browser's BROWSER_TOOLS, as the host
|
|
12
|
+
* lists them for this run; needed with the browser kind, and naming them in a refusal without it. `without`: a kind's
|
|
13
|
+
* tools this run's computer does not offer (its capabilities lack them: an iPhone's tree and keys, say), not listed to
|
|
14
|
+
* the model; one called anyway runs, and its port's absence answers in words. */
|
|
15
|
+
export declare function createRegistry(options: {
|
|
16
|
+
maxExecS: number;
|
|
17
|
+
shell: ShellPlace;
|
|
18
|
+
kinds?: readonly CapabilityKind[];
|
|
19
|
+
executors: HostExecutors;
|
|
20
|
+
browserTools?: readonly BrowserContract[];
|
|
21
|
+
without?: readonly string[];
|
|
22
|
+
}): Registry;
|