@fungi.computer/computer-contract 0.0.0-stage → 0.0.2

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.
@@ -0,0 +1,742 @@
1
+ import * as z from "zod";
2
+ /**
3
+ * The stable Workspace id of one attached execution backend: `container`,
4
+ * `vm-` followed by a lowercase letter-or-digit name that may contain hyphens,
5
+ * or `local-` followed by 16 lowercase base32 characters. A command request
6
+ * names one to run there; omitted, the Computer routes by its default order.
7
+ */
8
+ export declare const attachedBackendIdSchema: z.ZodLazy<z.ZodString>;
9
+ /**
10
+ * Most bytes of file content one Computer read or write carries, counted as
11
+ * UTF-8.
12
+ */
13
+ export declare const maximumFileBytes: number;
14
+ /** Most entries one list, glob or grep reply returns in a single page. */
15
+ export declare const maximumListEntries = 256;
16
+ /** Longest glob or search pattern a request may send. */
17
+ export declare const maximumPatternCharacters = 512;
18
+ /** Longest command string a request may send. */
19
+ export declare const maximumCommandCharacters: number;
20
+ /**
21
+ * Most bytes of stdout or stderr kept from one command. A longer stream is cut
22
+ * and marked.
23
+ */
24
+ export declare const maximumStreamBytes: number;
25
+ /** Room inside the stream cap for the visible truncation marker. */
26
+ export declare const truncationMarkerReserveBytes = 256;
27
+ /** The bound for ordinary Computer commands; hosts own any admitted job budget. */
28
+ export declare const maximumExecutionTimeMs = 120000;
29
+ /** Host-owned policy, never supplied in a Computer request body. */
30
+ export type ComputerExecutionBudget = Readonly<{
31
+ /** Longest time, in milliseconds, a command may be asked to run. */
32
+ maximumTimeMs: number;
33
+ }>;
34
+ /**
35
+ * The budget for ordinary Computer commands. Hosts that admit a job principal
36
+ * choose their own.
37
+ */
38
+ export declare const genericComputerExecutionBudget: ComputerExecutionBudget;
39
+ /**
40
+ * Accepts any JSON value. Capability descriptions and other transport data are
41
+ * checked against it.
42
+ */
43
+ export declare const computerValueSchema: z.ZodJSONSchema;
44
+ /** A JSON value accepted by `computerValueSchema`. */
45
+ export type ComputerValue = z.output<typeof computerValueSchema>;
46
+ /**
47
+ * Accepts the name of one Computer operation: a letter, then letters, digits or
48
+ * underscores.
49
+ */
50
+ export declare const capabilityNameSchema: z.ZodLazy<z.ZodString>;
51
+ /** One valid TCP port number, used only with this Computer's container. */
52
+ export declare const computerPortSchema: z.ZodLazy<z.ZodNumber>;
53
+ /** Most preview ports one Computer admits at once. */
54
+ export declare const maximumExposedPorts = 64;
55
+ /** computerd's Workspace RPC port, pinned by the Cloudflare container backend. */
56
+ export declare const computerDaemonPort = 8080;
57
+ /** The Computer-owned terminal server inside the container image. */
58
+ export declare const computerTerminalPort = 7681;
59
+ /**
60
+ * Ports served by the Computer's own in-container daemons. An admitted
61
+ * preview must never reach a control plane.
62
+ */
63
+ export declare const computerReservedPorts: ReadonlySet<number>;
64
+ /**
65
+ * Whether a Computer daemon owns this port, so it can never be admitted for
66
+ * preview.
67
+ */
68
+ export declare function isComputerReservedPort(port: number): boolean;
69
+ /** Names one container port to expose or remove. */
70
+ export declare const computerPortInputSchema: z.ZodObject<{
71
+ port: z.ZodLazy<z.ZodNumber>;
72
+ }, z.core.$strict>;
73
+ /** Reply to a request to expose a port. */
74
+ export declare const computerPortOutputSchema: z.ZodLazy<z.ZodObject<{
75
+ port: z.ZodLazy<z.ZodNumber>;
76
+ exposed: z.ZodBoolean;
77
+ }, z.core.$strict>>;
78
+ /** Reply to a request to stop exposing a port. */
79
+ export declare const computerPortRemovalOutputSchema: z.ZodLazy<z.ZodObject<{
80
+ port: z.ZodLazy<z.ZodNumber>;
81
+ removed: z.ZodBoolean;
82
+ }, z.core.$strict>>;
83
+ /** The ports this Computer currently admits for preview. */
84
+ export declare const computerPortsOutputSchema: z.ZodLazy<z.ZodObject<{
85
+ ports: z.ZodArray<z.ZodLazy<z.ZodNumber>>;
86
+ }, z.core.$strict>>;
87
+ /** The port belongs to a Computer daemon and cannot be admitted for preview. */
88
+ export declare class ComputerPortReservedError extends Error {
89
+ constructor(port: number);
90
+ }
91
+ /** A requested port cannot be reserved; no other process identity is disclosed. */
92
+ export declare class ComputerPortConflictError extends Error {
93
+ constructor();
94
+ }
95
+ /** This Computer already admits the maximum number of preview ports. */
96
+ export declare class ComputerPortLimitError extends Error {
97
+ constructor();
98
+ }
99
+ /** Native operation descriptions shared by discovery and its OpenAPI document. */
100
+ export declare const computerCapabilitiesSchema: z.ZodLazy<z.ZodArray<z.ZodObject<{
101
+ id: z.ZodLazy<z.ZodString>;
102
+ name: z.ZodLazy<z.ZodString>;
103
+ kind: z.ZodString;
104
+ description: z.ZodString;
105
+ parameters: z.ZodLazy<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
106
+ output: z.ZodLazy<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
107
+ }, z.core.$strict>>>;
108
+ /**
109
+ * Accepts an absolute path inside the Computer: it starts with a slash and
110
+ * holds no null byte.
111
+ */
112
+ export declare const pathSchema: z.ZodString;
113
+ /**
114
+ * Builds a schema for text of at least the given length whose UTF-8 size stays
115
+ * within `maximumFileBytes`.
116
+ */
117
+ export declare const boundedTextSchema: (minimumLength?: number) => z.ZodString;
118
+ /** Complete bounded UTF-8 text reads. Binary reads use the same path input. */
119
+ export declare const readInputSchema: z.ZodObject<{
120
+ path: z.ZodString;
121
+ }, z.core.$strict>;
122
+ /** A request to read one whole file as text. */
123
+ export type ComputerFileReadInput = z.output<typeof readInputSchema>;
124
+ /** The whole contents of one file, as text. */
125
+ export declare const readOutputSchema: z.ZodLazy<z.ZodObject<{
126
+ path: z.ZodString;
127
+ content: z.ZodString;
128
+ }, z.core.$strict>>;
129
+ /** The reply to reading one whole file as text. */
130
+ export type ComputerFileReadOutput = z.output<typeof readOutputSchema>;
131
+ /** Optional byte window; text reads remain complete and independently bounded. */
132
+ export declare const readBytesInputSchema: z.ZodObject<{
133
+ path: z.ZodString;
134
+ byteOffset: z.ZodOptional<z.ZodNumber>;
135
+ byteLength: z.ZodOptional<z.ZodNumber>;
136
+ }, z.core.$strict>;
137
+ /** A request to read a window of bytes from one file. */
138
+ export type ComputerFileByteReadInput = z.output<typeof readBytesInputSchema>;
139
+ /** Finite byte-read reply used by admitted App frame bindings. */
140
+ export declare const computerByteReadReplySchema: z.ZodLazy<z.ZodObject<{
141
+ path: z.ZodString;
142
+ byteOffset: z.ZodNumber;
143
+ content: z.ZodString;
144
+ encoding: z.ZodLiteral<"base64">;
145
+ truncated: z.ZodBoolean;
146
+ }, z.core.$strict>>;
147
+ /** Host-admitted App method preview; parsing does not grant port access. */
148
+ export declare const appMethodPreviewResultSchema: z.ZodLazy<z.ZodObject<{
149
+ previewUrl: z.ZodURL;
150
+ expiresAt: z.ZodNumber;
151
+ }, z.core.$strict>>;
152
+ /**
153
+ * Accepts how many entries a list returns: 1 up to `maximumListEntries`, 100
154
+ * when omitted.
155
+ */
156
+ export declare const listLimitSchema: z.ZodDefault<z.ZodNumber>;
157
+ /** Accepts how many entries a list skips. Zero when omitted. */
158
+ export declare const listOffsetSchema: z.ZodDefault<z.ZodNumber>;
159
+ /** A request for one page of a directory's entries. */
160
+ export declare const listInputSchema: z.ZodObject<{
161
+ path: z.ZodDefault<z.ZodString>;
162
+ limit: z.ZodDefault<z.ZodNumber>;
163
+ offset: z.ZodDefault<z.ZodNumber>;
164
+ }, z.core.$strict>;
165
+ /** One page of a directory's entries. */
166
+ export declare const listOutputSchema: z.ZodLazy<z.ZodObject<{
167
+ path: z.ZodString;
168
+ entries: z.ZodArray<z.ZodLazy<z.ZodObject<{
169
+ name: z.ZodString;
170
+ size: z.ZodNumber;
171
+ modifiedAt: z.ZodNumber;
172
+ type: z.ZodEnum<{
173
+ /** A regular file. */
174
+ readonly file: "file";
175
+ /** A directory. */
176
+ readonly directory: "directory";
177
+ /** A symbolic link. */
178
+ readonly symlink: "symlink";
179
+ }>;
180
+ }, z.core.$strict>>>;
181
+ nextOffset: z.ZodNullable<z.ZodNumber>;
182
+ }, z.core.$strict>>;
183
+ /** A request for one page of a directory's entries. */
184
+ export type ComputerFileListInput = z.output<typeof listInputSchema>;
185
+ /** The reply to a directory listing. */
186
+ export type ComputerFileListOutput = z.output<typeof listOutputSchema>;
187
+ /** Accepts text to store in a file, within `maximumFileBytes`. */
188
+ export declare const fileContentSchema: z.ZodLazy<z.ZodString>;
189
+ /** A request to write one file, creating or replacing its contents. */
190
+ export declare const writeInputSchema: z.ZodObject<{
191
+ path: z.ZodString;
192
+ content: z.ZodLazy<z.ZodString>;
193
+ }, z.core.$strict>;
194
+ /** The reply to a committed file write. */
195
+ export declare const writeOutputSchema: z.ZodLazy<z.ZodObject<{
196
+ path: z.ZodString;
197
+ bytes: z.ZodNumber;
198
+ }, z.core.$strict>>;
199
+ /** A request to write one file. */
200
+ export type ComputerFileWriteInput = z.output<typeof writeInputSchema>;
201
+ /** The reply to a committed file write. */
202
+ export type ComputerFileWriteOutput = z.output<typeof writeOutputSchema>;
203
+ /** Names the file for a binary write. The bytes travel as the request body. */
204
+ export declare const writeBytesInputSchema: z.ZodObject<{
205
+ path: z.ZodString;
206
+ }, z.core.$strict>;
207
+ /**
208
+ * A request to replace a file's contents only if they still equal what the
209
+ * caller last saw.
210
+ */
211
+ export declare const replaceInputSchema: z.ZodObject<{
212
+ path: z.ZodString;
213
+ expectedContent: z.ZodLazy<z.ZodString>;
214
+ content: z.ZodLazy<z.ZodString>;
215
+ }, z.core.$strict>;
216
+ /** The reply to a committed replacement. It has the shape of a write reply. */
217
+ export declare const replaceOutputSchema: z.ZodLazy<z.ZodObject<{
218
+ path: z.ZodString;
219
+ bytes: z.ZodNumber;
220
+ }, z.core.$strict>>;
221
+ /** A request to find paths under a directory that match a glob. */
222
+ export declare const globInputSchema: z.ZodLazy<z.ZodObject<{
223
+ path: z.ZodString;
224
+ pattern: z.ZodString;
225
+ limit: z.ZodDefault<z.ZodNumber>;
226
+ }, z.core.$strict>>;
227
+ /** The paths a glob found. */
228
+ export declare const globOutputSchema: z.ZodLazy<z.ZodObject<{
229
+ path: z.ZodString;
230
+ matches: z.ZodArray<z.ZodString>;
231
+ truncated: z.ZodBoolean;
232
+ }, z.core.$strict>>;
233
+ /** A request to search file contents under a directory. */
234
+ export declare const grepInputSchema: z.ZodLazy<z.ZodObject<{
235
+ path: z.ZodString;
236
+ pattern: z.ZodString;
237
+ regex: z.ZodDefault<z.ZodBoolean>;
238
+ ignoreCase: z.ZodDefault<z.ZodBoolean>;
239
+ include: z.ZodOptional<z.ZodString>;
240
+ limit: z.ZodDefault<z.ZodNumber>;
241
+ }, z.core.$strict>>;
242
+ /** The lines a search found. */
243
+ export declare const grepOutputSchema: z.ZodLazy<z.ZodObject<{
244
+ path: z.ZodString;
245
+ matches: z.ZodArray<z.ZodObject<{
246
+ path: z.ZodString;
247
+ line: z.ZodNumber;
248
+ text: z.ZodString;
249
+ }, z.core.$strict>>;
250
+ truncated: z.ZodBoolean;
251
+ }, z.core.$strict>>;
252
+ /** A request to find paths that match a glob. */
253
+ export type ComputerFileGlobInput = z.output<typeof globInputSchema>;
254
+ /** A request to search file contents. */
255
+ export type ComputerFileGrepInput = z.output<typeof grepInputSchema>;
256
+ /** A request to replace one piece of text in a file. */
257
+ export declare const editInputSchema: z.ZodLazy<z.ZodObject<{
258
+ path: z.ZodString;
259
+ oldText: z.ZodString;
260
+ newText: z.ZodString;
261
+ }, z.core.$strict>>;
262
+ /** The reply to a committed edit. */
263
+ export declare const editOutputSchema: z.ZodLazy<z.ZodObject<{
264
+ path: z.ZodString;
265
+ bytes: z.ZodNumber;
266
+ diff: z.ZodString;
267
+ firstChangedLine: z.ZodNullable<z.ZodNumber>;
268
+ }, z.core.$strict>>;
269
+ export { patchInputSchema, patchOutputSchema, } from "@fungi.computer/knapsack/files-patch";
270
+ /** A request to create a directory. */
271
+ export declare const mkdirInputSchema: z.ZodLazy<z.ZodObject<{
272
+ path: z.ZodString;
273
+ recursive: z.ZodDefault<z.ZodBoolean>;
274
+ }, z.core.$strict>>;
275
+ /** The reply to a directory creation. */
276
+ export declare const mkdirOutputSchema: z.ZodObject<{
277
+ path: z.ZodString;
278
+ }, z.core.$strict>;
279
+ /**
280
+ * Host-owned idempotency key for one `exec` or `bash` tool invocation. The
281
+ * host mints it once per invocation and keeps it across its own retries of that
282
+ * invocation; the model never sees or supplies it.
283
+ */
284
+ export declare const computerRequestIdSchema: z.ZodUUID;
285
+ /** A request id that passed `computerRequestIdSchema`. */
286
+ export type ComputerRequestId = z.output<typeof computerRequestIdSchema>;
287
+ /** Mint the request ID for one host tool invocation. */
288
+ export declare function mintComputerRequestId(): ComputerRequestId;
289
+ /**
290
+ * The model's command input: command, directory, backend and timeout. It
291
+ * carries no request id.
292
+ */
293
+ export declare const execInputSchema: z.ZodObject<{
294
+ command: z.ZodString;
295
+ cwd: z.ZodOptional<z.ZodString>;
296
+ backend: z.ZodOptional<z.ZodLazy<z.ZodString>>;
297
+ timeoutMs: z.ZodDefault<z.ZodNumber>;
298
+ }, z.core.$strict>;
299
+ /** Resource hosts select a budget only after admitting their job principal. */
300
+ export declare function computerExecutionRequestSchema(budget: ComputerExecutionBudget): z.ZodObject<{
301
+ command: z.ZodString;
302
+ cwd: z.ZodOptional<z.ZodString>;
303
+ backend: z.ZodOptional<z.ZodLazy<z.ZodString>>;
304
+ timeoutMs: z.ZodDefault<z.ZodNumber>;
305
+ requestId: z.ZodUUID;
306
+ }, z.core.$strict>;
307
+ /** Host-to-Computer command request: the model input plus the host's ID. */
308
+ export declare const execRequestSchema: z.ZodObject<{
309
+ command: z.ZodString;
310
+ cwd: z.ZodOptional<z.ZodString>;
311
+ backend: z.ZodOptional<z.ZodLazy<z.ZodString>>;
312
+ timeoutMs: z.ZodDefault<z.ZodNumber>;
313
+ requestId: z.ZodUUID;
314
+ }, z.core.$strict>;
315
+ /** One command stream cut at `maximumStreamBytes`; absent streams were whole. */
316
+ export declare const execTruncationSchema: z.ZodObject<{
317
+ stream: z.ZodEnum<{
318
+ /** The command's standard output. */
319
+ readonly stdout: "stdout";
320
+ /** The command's standard error. */
321
+ readonly stderr: "stderr";
322
+ }>;
323
+ keptBytes: z.ZodNumber;
324
+ totalBytes: z.ZodNumber;
325
+ }, z.core.$strict>;
326
+ /** The visible line appended to a cut stream; sizes exclude the line itself. */
327
+ export declare function execTruncationMarker(entry: ComputerExecTruncation): string;
328
+ /** Matches the marker line `execTruncationMarker` appends at the end of a stream. */
329
+ export declare const execTruncationMarkerPattern: RegExp;
330
+ /** Longest prefix of `bytes` within `limit` that ends on a UTF-8 character boundary. */
331
+ export declare function utf8Prefix(bytes: Uint8Array, limit: number): Uint8Array<ArrayBuffer>;
332
+ /** A record that one command stream was cut. */
333
+ export type ComputerExecTruncation = z.output<typeof execTruncationSchema>;
334
+ /** What a finished command left behind. */
335
+ export declare const execOutputSchema: z.ZodObject<{
336
+ status: z.ZodEnum<{
337
+ /** The command exited with code 0. */
338
+ readonly completed: "completed";
339
+ /** The command exited with a nonzero code that is not a cancellation. */
340
+ readonly failed: "failed";
341
+ /** The command was cancelled. */
342
+ readonly cancelled: "cancelled";
343
+ }>;
344
+ exitCode: z.ZodNumber;
345
+ stdout: z.ZodString;
346
+ stderr: z.ZodString;
347
+ truncated: z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodArray<z.ZodObject<{
348
+ stream: z.ZodEnum<{
349
+ /** The command's standard output. */
350
+ readonly stdout: "stdout";
351
+ /** The command's standard error. */
352
+ readonly stderr: "stderr";
353
+ }>;
354
+ keptBytes: z.ZodNumber;
355
+ totalBytes: z.ZodNumber;
356
+ }, z.core.$strict>>]>;
357
+ }, z.core.$strict>;
358
+ /** Accepts the durable id of one started process. */
359
+ export declare const computerProcessIdSchema: z.ZodLazy<z.ZodString & z.ZodType<import("@fungi.computer/cairn").CairnId<"computer-process", "process", 1>, string, z.core.$ZodTypeInternals<import("@fungi.computer/cairn").CairnId<"computer-process", "process", 1>, string>>>;
360
+ /** A process id that passed `computerProcessIdSchema`. */
361
+ export type ComputerProcessId = z.output<typeof computerProcessIdSchema>;
362
+ /** At most this many processes may be running in one host scope at once. */
363
+ export declare const maximumRunningProcesses = 16;
364
+ /** At most this many process records, running or exited, are kept per host scope. */
365
+ export declare const maximumProcessRecords = 64;
366
+ /** Mint the durable identity of one started process. */
367
+ export declare function mintComputerProcessId(): ComputerProcessId;
368
+ /** The host's request to start one long-running process. */
369
+ export declare const processStartInputSchema: z.ZodObject<{
370
+ requestId: z.ZodString;
371
+ requestScope: z.ZodString;
372
+ port: z.ZodOptional<z.ZodLazy<z.ZodNumber>>;
373
+ command: z.ZodString;
374
+ cwd: z.ZodOptional<z.ZodString>;
375
+ }, z.core.$strict>;
376
+ /** Model input excludes the host's replay identity and authority scope. */
377
+ export declare const processStartToolInputSchema: z.ZodObject<{
378
+ port: z.ZodOptional<z.ZodLazy<z.ZodNumber>>;
379
+ command: z.ZodString;
380
+ cwd: z.ZodOptional<z.ZodString>;
381
+ }, z.core.$strict>;
382
+ /** A trusted App host binds replay identity to its admitted installation and caller. */
383
+ export declare function installationProcessScope(installation: string, method: string, actor: Readonly<{
384
+ kind: "member" | "agent" | "team-key";
385
+ id: string;
386
+ }>): string;
387
+ /** Names one started process. */
388
+ export declare const processIdInputSchema: z.ZodObject<{
389
+ id: z.ZodLazy<z.ZodString & z.ZodType<import("@fungi.computer/cairn").CairnId<"computer-process", "process", 1>, string, z.core.$ZodTypeInternals<import("@fungi.computer/cairn").CairnId<"computer-process", "process", 1>, string>>>;
390
+ }, z.core.$strict>;
391
+ /**
392
+ * `running`: computerd still reports the execution live. `exited`: it ended;
393
+ * `exitCode` is null when the runtime that ran it was replaced or its record
394
+ * expired before the exit code was observed. `uncertain`: the Computer could
395
+ * not reach its container to check, so neither is claimed.
396
+ */
397
+ export declare const computerProcessStateSchema: z.ZodEnum<{
398
+ /** computerd still reports the execution live. */
399
+ readonly running: "running";
400
+ /** The execution ended. */
401
+ readonly exited: "exited";
402
+ /** The Computer could not reach its container to check. */
403
+ readonly uncertain: "uncertain";
404
+ }>;
405
+ /**
406
+ * `synced`: the drain that recorded this exit read all the way to EOF,
407
+ * which is also the read that runs computerd's post-command pull.
408
+ * `pending`: that drain gave up waiting at its own deadline (a
409
+ * backgrounded child, for example `node server.js &`, can hold the
410
+ * transport open long after its parent exits) -- a background
411
+ * continuation keeps watching and upgrades this row to `synced` once it
412
+ * reaches that real EOF, so `pending` rows stay updatable. `unknown`:
413
+ * this exit was recorded with no pull evidence at all (a replaced
414
+ * runtime, an expired record, or any other exit path that never drained
415
+ * for one). Never claim `synced` without the specific evidence for this
416
+ * exit; default to `unknown`, not `synced`.
417
+ */
418
+ export declare const computerProcessSyncSchema: z.ZodEnum<{
419
+ /** The drain that recorded the exit read to the end of the stream. */
420
+ readonly synced: "synced";
421
+ /** The drain gave up at its deadline. A background watcher upgrades it to synced. */
422
+ readonly pending: "pending";
423
+ /** The exit was recorded with no pull evidence. */
424
+ readonly unknown: "unknown";
425
+ }>;
426
+ /** A value of `computerProcessSyncSchema`. */
427
+ export type ComputerProcessSync = z.output<typeof computerProcessSyncSchema>;
428
+ /** One started process, as the Computer reports it. */
429
+ export declare const computerProcessSchema: z.ZodObject<{
430
+ id: z.ZodLazy<z.ZodString & z.ZodType<import("@fungi.computer/cairn").CairnId<"computer-process", "process", 1>, string, z.core.$ZodTypeInternals<import("@fungi.computer/cairn").CairnId<"computer-process", "process", 1>, string>>>;
431
+ port: z.ZodNullable<z.ZodLazy<z.ZodNumber>>;
432
+ command: z.ZodString;
433
+ cwd: z.ZodNullable<z.ZodString>;
434
+ state: z.ZodEnum<{
435
+ /** computerd still reports the execution live. */
436
+ readonly running: "running";
437
+ /** The execution ended. */
438
+ readonly exited: "exited";
439
+ /** The Computer could not reach its container to check. */
440
+ readonly uncertain: "uncertain";
441
+ }>;
442
+ exitCode: z.ZodNullable<z.ZodNumber>;
443
+ sync: z.ZodEnum<{
444
+ /** The drain that recorded the exit read to the end of the stream. */
445
+ readonly synced: "synced";
446
+ /** The drain gave up at its deadline. A background watcher upgrades it to synced. */
447
+ readonly pending: "pending";
448
+ /** The exit was recorded with no pull evidence. */
449
+ readonly unknown: "unknown";
450
+ }>;
451
+ startedAt: z.ZodNumber;
452
+ endedAt: z.ZodNullable<z.ZodNumber>;
453
+ }, z.core.$strict>;
454
+ /** One started process, as the Computer reports it. */
455
+ export type ComputerProcess = z.output<typeof computerProcessSchema>;
456
+ /** The processes started on this Computer. */
457
+ export declare const processListOutputSchema: z.ZodObject<{
458
+ processes: z.ZodArray<z.ZodObject<{
459
+ id: z.ZodLazy<z.ZodString & z.ZodType<import("@fungi.computer/cairn").CairnId<"computer-process", "process", 1>, string, z.core.$ZodTypeInternals<import("@fungi.computer/cairn").CairnId<"computer-process", "process", 1>, string>>>;
460
+ port: z.ZodNullable<z.ZodLazy<z.ZodNumber>>;
461
+ command: z.ZodString;
462
+ cwd: z.ZodNullable<z.ZodString>;
463
+ state: z.ZodEnum<{
464
+ /** computerd still reports the execution live. */
465
+ readonly running: "running";
466
+ /** The execution ended. */
467
+ readonly exited: "exited";
468
+ /** The Computer could not reach its container to check. */
469
+ readonly uncertain: "uncertain";
470
+ }>;
471
+ exitCode: z.ZodNullable<z.ZodNumber>;
472
+ sync: z.ZodEnum<{
473
+ /** The drain that recorded the exit read to the end of the stream. */
474
+ readonly synced: "synced";
475
+ /** The drain gave up at its deadline. A background watcher upgrades it to synced. */
476
+ readonly pending: "pending";
477
+ /** The exit was recorded with no pull evidence. */
478
+ readonly unknown: "unknown";
479
+ }>;
480
+ startedAt: z.ZodNumber;
481
+ endedAt: z.ZodNullable<z.ZodNumber>;
482
+ }, z.core.$strict>>;
483
+ }, z.core.$strict>;
484
+ /** The reply to a request to stop a process. */
485
+ export declare const processKillOutputSchema: z.ZodLazy<z.ZodObject<{
486
+ process: z.ZodObject<{
487
+ id: z.ZodLazy<z.ZodString & z.ZodType<import("@fungi.computer/cairn").CairnId<"computer-process", "process", 1>, string, z.core.$ZodTypeInternals<import("@fungi.computer/cairn").CairnId<"computer-process", "process", 1>, string>>>;
488
+ port: z.ZodNullable<z.ZodLazy<z.ZodNumber>>;
489
+ command: z.ZodString;
490
+ cwd: z.ZodNullable<z.ZodString>;
491
+ state: z.ZodEnum<{
492
+ /** computerd still reports the execution live. */
493
+ readonly running: "running";
494
+ /** The execution ended. */
495
+ readonly exited: "exited";
496
+ /** The Computer could not reach its container to check. */
497
+ readonly uncertain: "uncertain";
498
+ }>;
499
+ exitCode: z.ZodNullable<z.ZodNumber>;
500
+ sync: z.ZodEnum<{
501
+ /** The drain that recorded the exit read to the end of the stream. */
502
+ readonly synced: "synced";
503
+ /** The drain gave up at its deadline. A background watcher upgrades it to synced. */
504
+ readonly pending: "pending";
505
+ /** The exit was recorded with no pull evidence. */
506
+ readonly unknown: "unknown";
507
+ }>;
508
+ startedAt: z.ZodNumber;
509
+ endedAt: z.ZodNullable<z.ZodNumber>;
510
+ }, z.core.$strict>;
511
+ signalled: z.ZodBoolean;
512
+ }, z.core.$strict>>;
513
+ /** No process with this id was started on this Computer. */
514
+ export declare class ComputerProcessNotFoundError extends Error {
515
+ constructor(id: string);
516
+ }
517
+ /** Every process slot is occupied by a running process. */
518
+ export declare class ComputerProcessLimitError extends Error {
519
+ constructor();
520
+ }
521
+ /** The model's command input. */
522
+ export type ComputerExecInput = z.output<typeof execInputSchema>;
523
+ /** The host's command request: the model's input plus the host's request id. */
524
+ export type ComputerExecRequest = z.output<typeof execRequestSchema>;
525
+ /** What a finished command left behind. */
526
+ export type ComputerExecOutput = z.output<typeof execOutputSchema>;
527
+ /** Host-memory-only native inputs. Never part of a tool, replay row or log. */
528
+ export type ComputerExecutionCarriage = Readonly<{
529
+ /** Command-local environment supplied only to this actual native invocation. */
530
+ env?: Readonly<Record<string, string>>;
531
+ /** String or byte input supplied to the same native invocation's stdin. */
532
+ stdin?: string | Uint8Array;
533
+ }>;
534
+ /** Non-secret identity of the actual native invocation, not its credential. */
535
+ export type ComputerExecutionInvocation = Readonly<{
536
+ /** Stable public native identity, reused on replay without another dispatch. */
537
+ id: string;
538
+ /** The existing admission owner for this command or managed process. */
539
+ kind: "exec" | "process";
540
+ }>;
541
+ /** Authority closure is distinct from asserting a native exit code. */
542
+ export type ComputerExecutionCloseReason = "refused_start" | "native_exit" | "unknown" | "reconstructed";
543
+ /**
544
+ * The resource host owns cargo meaning and issuance. Computer owns NEW/replay,
545
+ * dispatch and actual native liveness. Only non-secret context is durable;
546
+ * hooks and carriage stay in host memory.
547
+ */
548
+ export type ComputerExecutionHostHooks = Readonly<{
549
+ /** Open host authority after NEW admission, immediately before native dispatch. */
550
+ open(invocation: ComputerExecutionInvocation, context: ComputerValue): Promise<ComputerExecutionCarriage>;
551
+ /** Renew from a caller observation only after actual native liveness is proven. */
552
+ renew(invocation: ComputerExecutionInvocation, context: ComputerValue): Promise<void>;
553
+ /** Release host authority after Computer durably records its closure reason. */
554
+ close(invocation: ComputerExecutionInvocation, context: ComputerValue, reason: ComputerExecutionCloseReason): Promise<void>;
555
+ }>;
556
+ /** Protected host seam only. Public command/process parsers do not accept cargo. */
557
+ export type ComputerExecutionHostPort = Readonly<{
558
+ /** The trusted host's in-memory hooks, absent when no such host is attached. */
559
+ executionHooks(): ComputerExecutionHostHooks | undefined;
560
+ /** Observe the selected native invocation without consuming its output reader. */
561
+ executionIsLive(invocationId: string): Promise<boolean>;
562
+ /** Admit a command with optional non-secret context supplied by the trusted host. */
563
+ executeOperationAfterAcceptance(input: ComputerExecRequest, accept: () => void, kind: "exec" | "bash" | "hosted", budget?: ComputerExecutionBudget, signal?: AbortSignal, executionContext?: ComputerValue): Promise<ComputerOperationResult>;
564
+ /** Admit or replay a managed process without accepting public credential cargo. */
565
+ startProcessAfterAcceptance(input: ComputerValue, accept: () => void, executionContext?: ComputerValue): Promise<ComputerProcess>;
566
+ /** Dispatch an ordinary capability while preserving the trusted host's context. */
567
+ callAfterAcceptance(capabilityId: ComputerValue, input: ComputerValue, accept: () => void, executionContext?: ComputerValue): Promise<ComputerValue>;
568
+ }>;
569
+ /**
570
+ * Where one command invocation stands: accepted, running, succeeded, failed,
571
+ * unknown (the outcome cannot be established, because the Computer restarted
572
+ * mid-command or the id has no record yet is still inside the admission
573
+ * window) or expired (no record, and older than the admission window).
574
+ */
575
+ export declare const computerOperationStatusSchema: z.ZodEnum<{
576
+ /** The request id is recorded and the command has not started. */
577
+ readonly accepted: "accepted";
578
+ /** The command is running. */
579
+ readonly running: "running";
580
+ /** The command completed. */
581
+ readonly succeeded: "succeeded";
582
+ /** The command ended without completing. */
583
+ readonly failed: "failed";
584
+ /**
585
+ * The outcome cannot be established: the Computer restarted mid-command, or
586
+ * the id has no record yet is still inside the admission window.
587
+ */
588
+ readonly unknown: "unknown";
589
+ /** The id has no record and is older than the admission window. */
590
+ readonly expired: "expired";
591
+ }>;
592
+ /** Durable operation status returned to the host that owns the request ID. */
593
+ export declare const computerOperationResultSchema: z.ZodObject<{
594
+ requestId: z.ZodUUID;
595
+ status: z.ZodEnum<{
596
+ /** The request id is recorded and the command has not started. */
597
+ readonly accepted: "accepted";
598
+ /** The command is running. */
599
+ readonly running: "running";
600
+ /** The command completed. */
601
+ readonly succeeded: "succeeded";
602
+ /** The command ended without completing. */
603
+ readonly failed: "failed";
604
+ /**
605
+ * The outcome cannot be established: the Computer restarted mid-command, or
606
+ * the id has no record yet is still inside the admission window.
607
+ */
608
+ readonly unknown: "unknown";
609
+ /** The id has no record and is older than the admission window. */
610
+ readonly expired: "expired";
611
+ }>;
612
+ output: z.ZodNullable<z.ZodObject<{
613
+ status: z.ZodEnum<{
614
+ /** The command exited with code 0. */
615
+ readonly completed: "completed";
616
+ /** The command exited with a nonzero code that is not a cancellation. */
617
+ readonly failed: "failed";
618
+ /** The command was cancelled. */
619
+ readonly cancelled: "cancelled";
620
+ }>;
621
+ exitCode: z.ZodNumber;
622
+ stdout: z.ZodString;
623
+ stderr: z.ZodString;
624
+ truncated: z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodArray<z.ZodObject<{
625
+ stream: z.ZodEnum<{
626
+ /** The command's standard output. */
627
+ readonly stdout: "stdout";
628
+ /** The command's standard error. */
629
+ readonly stderr: "stderr";
630
+ }>;
631
+ keptBytes: z.ZodNumber;
632
+ totalBytes: z.ZodNumber;
633
+ }, z.core.$strict>>]>;
634
+ }, z.core.$strict>>;
635
+ }, z.core.$strict>;
636
+ /**
637
+ * The durable status of one command invocation, for the host that owns its
638
+ * request id.
639
+ */
640
+ export type ComputerOperationResult = z.output<typeof computerOperationResultSchema>;
641
+ /** Model-facing command result: the durable status without the host's ID. */
642
+ export declare const computerToolResultSchema: z.ZodObject<{
643
+ output: z.ZodNullable<z.ZodObject<{
644
+ status: z.ZodEnum<{
645
+ /** The command exited with code 0. */
646
+ readonly completed: "completed";
647
+ /** The command exited with a nonzero code that is not a cancellation. */
648
+ readonly failed: "failed";
649
+ /** The command was cancelled. */
650
+ readonly cancelled: "cancelled";
651
+ }>;
652
+ exitCode: z.ZodNumber;
653
+ stdout: z.ZodString;
654
+ stderr: z.ZodString;
655
+ truncated: z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodArray<z.ZodObject<{
656
+ stream: z.ZodEnum<{
657
+ /** The command's standard output. */
658
+ readonly stdout: "stdout";
659
+ /** The command's standard error. */
660
+ readonly stderr: "stderr";
661
+ }>;
662
+ keptBytes: z.ZodNumber;
663
+ totalBytes: z.ZodNumber;
664
+ }, z.core.$strict>>]>;
665
+ }, z.core.$strict>>;
666
+ status: z.ZodEnum<{
667
+ /** The request id is recorded and the command has not started. */
668
+ readonly accepted: "accepted";
669
+ /** The command is running. */
670
+ readonly running: "running";
671
+ /** The command completed. */
672
+ readonly succeeded: "succeeded";
673
+ /** The command ended without completing. */
674
+ readonly failed: "failed";
675
+ /**
676
+ * The outcome cannot be established: the Computer restarted mid-command, or
677
+ * the id has no record yet is still inside the admission window.
678
+ */
679
+ readonly unknown: "unknown";
680
+ /** The id has no record and is older than the admission window. */
681
+ readonly expired: "expired";
682
+ }>;
683
+ }, z.core.$strict>;
684
+ /** The status of one command invocation without the host's request id. */
685
+ export type ComputerToolResult = z.output<typeof computerToolResultSchema>;
686
+ /** Project one host operation result onto the model-facing tool result. */
687
+ export declare function computerToolResult(result: ComputerOperationResult): ComputerToolResult;
688
+ /** Public operation vocabulary; transport adapters map these to routes. */
689
+ export declare const computerOperationSchema: z.ZodEnum<{
690
+ /** Read one whole file as text. */
691
+ readonly "files.read": "files.read";
692
+ /** Read a window of bytes from one file. */
693
+ readonly "files.readBytes": "files.readBytes";
694
+ /** Write one file as text. */
695
+ readonly "files.write": "files.write";
696
+ /** Write one file from binary bytes. */
697
+ readonly "files.writeBytes": "files.writeBytes";
698
+ /** List one page of a directory. */
699
+ readonly "files.list": "files.list";
700
+ /** Find paths that match a glob. */
701
+ readonly "files.glob": "files.glob";
702
+ /** Search file contents. */
703
+ readonly "files.grep": "files.grep";
704
+ /** Replace one piece of text in a file. */
705
+ readonly "files.edit": "files.edit";
706
+ /** Apply a patch to files. */
707
+ readonly "files.patch": "files.patch";
708
+ /** Create a directory. */
709
+ readonly mkdir: "mkdir";
710
+ /** Run a command in the Computer's container. */
711
+ readonly bash: "bash";
712
+ /** Run a command in the Computer's lightweight Worker shell. */
713
+ readonly exec: "exec";
714
+ }>;
715
+ /** One public operation name. */
716
+ export type ComputerOperation = z.output<typeof computerOperationSchema>;
717
+ /** A request to replace a file's contents if they still match. */
718
+ export type ComputerFileReplacement = z.output<typeof replaceInputSchema>;
719
+ /** The reply to a committed replacement. */
720
+ export type ComputerFileReplacementResult = z.output<typeof replaceOutputSchema>;
721
+ /** The expected file contents no longer match at atomic replacement. */
722
+ export declare class ComputerFileConflict extends Error {
723
+ constructor();
724
+ }
725
+ /** A byte window starts beyond the current file extent. */
726
+ export declare class ComputerFileRangeError extends Error {
727
+ /** The file's current size in bytes. */
728
+ readonly size: number;
729
+ constructor(
730
+ /** The file's current size in bytes. */
731
+ size: number);
732
+ }
733
+ /** The requested file bytes exceed the admitted read bound. */
734
+ export declare class ComputerFileTooLargeError extends Error {
735
+ constructor();
736
+ }
737
+ /**
738
+ * The operations every Computer advertises; static, so hosts can describe them
739
+ * without a call. Built on first read: deriving JSON Schema for every operation
740
+ * is real work that a Worker should not pay at startup.
741
+ */
742
+ export declare function computerCapabilities(): z.output<typeof computerCapabilitiesSchema>;