@opengeni/agent-proto 0.3.0 → 0.5.0

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/dist/index.d.ts CHANGED
@@ -1,1481 +1,16 @@
1
- import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
2
-
3
- declare const protobufPackage = "opengeni.agent.v1";
4
- declare enum ErrorCode {
5
- ERROR_CODE_UNSPECIFIED = 0,
6
- /** ERROR_CODE_UNSUPPORTED - The requested op is not implemented / not permitted on this platform. */
7
- ERROR_CODE_UNSUPPORTED = 1,
8
- /** ERROR_CODE_OS - A filesystem/exec/git op failed at the OS layer (see `detail`). */
9
- ERROR_CODE_OS = 2,
10
- /** ERROR_CODE_NOT_FOUND - The path/ref/target referenced by the op does not exist. */
11
- ERROR_CODE_NOT_FOUND = 3,
12
- /** ERROR_CODE_CONSENT_REQUIRED - The op was rejected by consent/capability gating (e.g. screen-control off). */
13
- ERROR_CODE_CONSENT_REQUIRED = 4,
14
- /** ERROR_CODE_TIMEOUT - The op timed out inside the agent. */
15
- ERROR_CODE_TIMEOUT = 5,
16
- /** ERROR_CODE_DRAINING - The agent is shutting down / draining and cannot accept new work. */
17
- ERROR_CODE_DRAINING = 6,
18
- /** ERROR_CODE_PROTOCOL - A protocol-level violation (bad envelope, unknown op for this version). */
19
- ERROR_CODE_PROTOCOL = 7,
20
- /** ERROR_CODE_STREAM - A required stream channel could not be opened on the relay. */
21
- ERROR_CODE_STREAM = 8,
22
- /** ERROR_CODE_AGENT_OFFLINE - The control plane synthesized this because no agent responded (offline). */
23
- ERROR_CODE_AGENT_OFFLINE = 9,
24
- /** ERROR_CODE_FENCED - An epoch fence rejected a stale op; caller should re-resolve and retry. */
25
- ERROR_CODE_FENCED = 10,
26
- /**
27
- * ERROR_CODE_PAYLOAD_TOO_LARGE - The op's reply would exceed the transport's negotiated max payload and could
28
- * not be published (e.g. a full-res screenshot, or an unbounded file read/exec
29
- * output). The agent's wire-seam backstop synthesizes THIS instead of letting
30
- * the oversized publish fail silently and the caller time out opaquely.
31
- * Not retryable — the same op would produce the same oversized reply.
32
- */
33
- ERROR_CODE_PAYLOAD_TOO_LARGE = 11
34
- }
35
- declare function errorCodeFromJSON(object: any): ErrorCode;
36
- declare function errorCodeToJSON(object: ErrorCode): string;
37
- /** The operating system family the agent runs on. */
38
- declare enum Os {
39
- OS_UNSPECIFIED = 0,
40
- OS_LINUX = 1,
41
- OS_MACOS = 2,
42
- OS_WINDOWS = 3
43
- }
44
- declare function osFromJSON(object: any): Os;
45
- declare function osToJSON(object: Os): string;
46
- /** CPU architecture. */
47
- declare enum Arch {
48
- ARCH_UNSPECIFIED = 0,
49
- ARCH_X86_64 = 1,
50
- ARCH_AARCH64 = 2
51
- }
52
- declare function archFromJSON(object: any): Arch;
53
- declare function archToJSON(object: Arch): string;
54
- /** The kind of byte stream a relay channel carries. */
55
- declare enum StreamKind {
56
- STREAM_KIND_UNSPECIFIED = 0,
57
- /** STREAM_KIND_PTY - An interactive pseudo-terminal (ttyd-equivalent). */
58
- STREAM_KIND_PTY = 1,
59
- /** STREAM_KIND_DESKTOP - A desktop framebuffer (noVNC-equivalent) for view + computer-use. */
60
- STREAM_KIND_DESKTOP = 2
61
- }
62
- declare function streamKindFromJSON(object: any): StreamKind;
63
- declare function streamKindToJSON(object: StreamKind): string;
64
- declare enum DeviceAuthState {
65
- DEVICE_AUTH_STATE_UNSPECIFIED = 0,
66
- /** DEVICE_AUTH_STATE_PENDING - The user has not yet completed the flow; keep polling. */
67
- DEVICE_AUTH_STATE_PENDING = 1,
68
- /** DEVICE_AUTH_STATE_AUTHORIZED - The user authorized; `credentials` are present. */
69
- DEVICE_AUTH_STATE_AUTHORIZED = 2,
70
- /** DEVICE_AUTH_STATE_DENIED - The user explicitly denied the request. */
71
- DEVICE_AUTH_STATE_DENIED = 3,
72
- /** DEVICE_AUTH_STATE_EXPIRED - The device_code expired before authorization. */
73
- DEVICE_AUTH_STATE_EXPIRED = 4,
74
- /** DEVICE_AUTH_STATE_SLOW_DOWN - The agent is polling too fast and must slow down. */
75
- DEVICE_AUTH_STATE_SLOW_DOWN = 5
76
- }
77
- declare function deviceAuthStateFromJSON(object: any): DeviceAuthState;
78
- declare function deviceAuthStateToJSON(object: DeviceAuthState): string;
79
- declare enum FsEntryKind {
80
- FS_ENTRY_KIND_UNSPECIFIED = 0,
81
- FS_ENTRY_KIND_FILE = 1,
82
- FS_ENTRY_KIND_DIRECTORY = 2,
83
- FS_ENTRY_KIND_SYMLINK = 3
84
- }
85
- declare function fsEntryKindFromJSON(object: any): FsEntryKind;
86
- declare function fsEntryKindToJSON(object: FsEntryKind): string;
87
- declare enum GitOp {
88
- GIT_OP_UNSPECIFIED = 0,
89
- GIT_OP_STATUS = 1,
90
- GIT_OP_DIFF = 2,
91
- GIT_OP_LOG = 3,
92
- GIT_OP_ADD = 4,
93
- GIT_OP_COMMIT = 5,
94
- GIT_OP_BRANCH = 6,
95
- GIT_OP_CHECKOUT = 7,
96
- GIT_OP_PULL = 8,
97
- GIT_OP_PUSH = 9,
98
- /** GIT_OP_RAW - Any other subcommand, passed through verbatim via `args`. */
99
- GIT_OP_RAW = 15
100
- }
101
- declare function gitOpFromJSON(object: any): GitOp;
102
- declare function gitOpToJSON(object: GitOp): string;
103
- declare enum GoingOfflineReason {
104
- GOING_OFFLINE_REASON_UNSPECIFIED = 0,
105
- /** GOING_OFFLINE_REASON_USER_STOP - The user stopped the foreground process. */
106
- GOING_OFFLINE_REASON_USER_STOP = 1,
107
- /** GOING_OFFLINE_REASON_UPDATE - The agent is restarting itself for a self-update. */
108
- GOING_OFFLINE_REASON_UPDATE = 2,
109
- /** GOING_OFFLINE_REASON_HOST_SHUTDOWN - The host is shutting down / suspending. */
110
- GOING_OFFLINE_REASON_HOST_SHUTDOWN = 3
111
- }
112
- declare function goingOfflineReasonFromJSON(object: any): GoingOfflineReason;
113
- declare function goingOfflineReasonToJSON(object: GoingOfflineReason): string;
114
- /** The logical byte stream an op-frame Data chunk belongs to. */
115
- declare enum OpChannel {
116
- OP_CHANNEL_UNSPECIFIED = 0,
117
- OP_CHANNEL_STDOUT = 1,
118
- OP_CHANNEL_STDERR = 2,
119
- /** OP_CHANNEL_CONTENT - Non-exec content (fs_read bodies and similar). */
120
- OP_CHANNEL_CONTENT = 3
121
- }
122
- declare function opChannelFromJSON(object: any): OpChannel;
123
- declare function opChannelToJSON(object: OpChannel): string;
124
1
  /**
125
- * An op's lifecycle state on the runner: accepted → running → complete(retained)
126
- * gc; or lost. `lost` is always TYPED (see OpLostReason) — never a silent gap.
127
- */
128
- declare enum OpState {
129
- OP_STATE_UNSPECIFIED = 0,
130
- OP_STATE_ACCEPTED = 1,
131
- OP_STATE_RUNNING = 2,
132
- OP_STATE_COMPLETE = 3,
133
- OP_STATE_LOST = 4
134
- }
135
- declare function opStateFromJSON(object: any): OpState;
136
- declare function opStateToJSON(object: OpState): string;
137
- /** Why a lost op is lost (present iff OpStatus.state == OP_STATE_LOST). */
138
- declare enum OpLostReason {
139
- OP_LOST_REASON_UNSPECIFIED = 0,
140
- /**
141
- * OP_LOST_REASON_EVICTED - A completed op's retained result was evicted (bounded LRU registry) before a
142
- * final ack arrived — a loud, counted event, surfaced honestly on a late query.
143
- */
144
- OP_LOST_REASON_EVICTED = 1,
145
- /**
146
- * OP_LOST_REASON_AGENT_RESTARTED - The runner process restarted and the op's in-memory scope did not survive
147
- * (until the journal + scope re-adoption of a later milestone).
148
- */
149
- OP_LOST_REASON_AGENT_RESTARTED = 2
150
- }
151
- declare function opLostReasonFromJSON(object: any): OpLostReason;
152
- declare function opLostReasonToJSON(object: OpLostReason): string;
153
- declare enum StreamRole {
154
- STREAM_ROLE_UNSPECIFIED = 0,
155
- /** STREAM_ROLE_AGENT - The agent producing pty/desktop bytes. */
156
- STREAM_ROLE_AGENT = 1,
157
- /** STREAM_ROLE_CLIENT - The viewer/pty client consuming them (and sending input back). */
158
- STREAM_ROLE_CLIENT = 2
159
- }
160
- declare function streamRoleFromJSON(object: any): StreamRole;
161
- declare function streamRoleToJSON(object: StreamRole): string;
162
- declare enum StreamCloseReason {
163
- STREAM_CLOSE_REASON_UNSPECIFIED = 0,
164
- /** STREAM_CLOSE_REASON_NORMAL - Normal end (pty exited, viewer left). */
165
- STREAM_CLOSE_REASON_NORMAL = 1,
166
- /** STREAM_CLOSE_REASON_PROCESS_EXIT - The producing process ended. */
167
- STREAM_CLOSE_REASON_PROCESS_EXIT = 2,
168
- /** STREAM_CLOSE_REASON_FENCED - The epoch fence invalidated the channel (a swap-away). */
169
- STREAM_CLOSE_REASON_FENCED = 3,
170
- /** STREAM_CLOSE_REASON_TRANSPORT_ERROR - A relay/transport error (the client should reconnect+resume). */
171
- STREAM_CLOSE_REASON_TRANSPORT_ERROR = 4,
172
- /** STREAM_CLOSE_REASON_RATE_LIMITED - Rate-limit / backpressure shed the channel. */
173
- STREAM_CLOSE_REASON_RATE_LIMITED = 5
174
- }
175
- declare function streamCloseReasonFromJSON(object: any): StreamCloseReason;
176
- declare function streamCloseReasonToJSON(object: StreamCloseReason): string;
177
- declare enum PointerAction {
178
- POINTER_ACTION_UNSPECIFIED = 0,
179
- POINTER_ACTION_MOVE = 1,
180
- POINTER_ACTION_DOWN = 2,
181
- POINTER_ACTION_UP = 3,
182
- POINTER_ACTION_CLICK = 4,
183
- POINTER_ACTION_DOUBLE_CLICK = 5
184
- }
185
- declare function pointerActionFromJSON(object: any): PointerAction;
186
- declare function pointerActionToJSON(object: PointerAction): string;
187
- declare enum PointerButton {
188
- POINTER_BUTTON_UNSPECIFIED = 0,
189
- POINTER_BUTTON_LEFT = 1,
190
- POINTER_BUTTON_RIGHT = 2,
191
- POINTER_BUTTON_MIDDLE = 3
192
- }
193
- declare function pointerButtonFromJSON(object: any): PointerButton;
194
- declare function pointerButtonToJSON(object: PointerButton): string;
195
- declare enum KeyAction {
196
- KEY_ACTION_UNSPECIFIED = 0,
197
- KEY_ACTION_DOWN = 1,
198
- KEY_ACTION_UP = 2,
199
- KEY_ACTION_PRESS = 3
200
- }
201
- declare function keyActionFromJSON(object: any): KeyAction;
202
- declare function keyActionToJSON(object: KeyAction): string;
203
- /**
204
- * A typed error returned by the agent (or synthesized by the control plane for
205
- * a non-responding agent). `code` is a stable machine-readable discriminant;
206
- * `message` is human-facing; `retryable` lets the turn layer decide whether to
207
- * pause-and-retry (a reconnect blip) versus surface a hard failure.
208
- */
209
- interface AgentError {
210
- code: ErrorCode;
211
- message: string;
212
- retryable: boolean;
213
- /** Optional structured detail (e.g. an OS errno, a git exit code) for logs. */
214
- detail: {
215
- [key: string]: string;
216
- };
217
- }
218
- declare const AgentError: MessageFns<AgentError>;
219
- interface AgentError_DetailEntry {
220
- key: string;
221
- value: string;
222
- }
223
- declare const AgentError_DetailEntry: MessageFns<AgentError_DetailEntry>;
224
- /**
225
- * The agent's self-description, sent on connect (the "hello") and refreshed on
226
- * reconnect. The control plane folds this into the negotiated SessionCapabilities
227
- * document (every capability cell is available:false+reason, never absent).
228
- */
229
- interface Hello {
230
- agentId: string;
231
- workspaceId: string;
232
- /** Semantic version of the running agent binary (drives staged self-update). */
233
- agentVersion: string;
234
- os: Os;
235
- arch: Arch;
236
- /** Human-friendly machine name (hostname by default; user-overridable). */
237
- machineName: string;
238
- /** The agent-reported working root the control plane treats as the sandbox cwd. */
239
- workspaceRoot: string;
240
- /** Capabilities the agent can serve given its platform + consent grants. */
241
- capabilities: Capabilities | undefined;
242
- /** The update channel this agent follows (stable|beta), for fleet-pinning. */
243
- updateChannel: string;
244
- /**
245
- * A resume token minted by a prior connection, echoed so the control plane can
246
- * recognize a reconnect (vs a fresh enrollment) and fence by epoch. Empty on
247
- * first connect.
248
- */
249
- resumeToken: string;
250
- }
251
- declare const Hello: MessageFns<Hello>;
252
- /**
253
- * What the agent is able and consented to do. Each bool is a hard capability
254
- * gate; the control plane maps a false to a CapabilityUnavailableReason.
255
- */
256
- interface Capabilities {
257
- /** Channel-A structural surface (always true for a connected agent). */
258
- exec: boolean;
259
- filesystem: boolean;
260
- git: boolean;
261
- /** An interactive PTY can be opened over the relay. */
262
- pty: boolean;
263
- /** A desktop framebuffer is available (a display exists or Xvfb is enabled). */
264
- desktop: boolean;
265
- /** The user consented to whole-machine access during enrollment. */
266
- consentedWholeMachine: boolean;
267
- /** The user consented to screen capture + synthetic input (computer-use). */
268
- consentedScreenControl: boolean;
269
- /** Display detail (absent => headless / no display). */
270
- display: Display | undefined;
271
- /**
272
- * When a display physically EXISTS but the OS withholds the screen-CAPTURE grant
273
- * (macOS Screen Recording / TCC), `desktop` is reported false and this carries a
274
- * human, actionable reason (e.g. "grant Screen Recording in System Settings").
275
- * Empty when capture is permitted or the platform has no separate capture grant
276
- * (Linux/x11). Advertised at Hello so the control plane degrades the desktop cell
277
- * with a legible hint instead of offering a desktop it cannot capture — the
278
- * machine that "claims a display it can't capture" bug the 0.1.3 incident exposed.
279
- */
280
- desktopUnavailableReason: string;
281
- /**
282
- * The runner speaks the op-stream protocol (OpStart/OpFrame/OpAck; see the
283
- * op-stream section below). Advertised at Hello; the server uses the streaming
284
- * path only when this is true AND its own feature flag is on, else the legacy
285
- * monolithic ops run exactly as today. Additive — absent (false) on an older
286
- * runner means "legacy path", no version coupling.
287
- */
288
- opStream: boolean;
289
- }
290
- declare const Capabilities: MessageFns<Capabilities>;
291
- /** Detail about the agent's graphical display, when one is present. */
292
- interface Display {
293
- /** e.g. ":0", ":99" (Xvfb), or a platform handle. */
294
- id: string;
295
- width: number;
296
- height: number;
297
- /** True when backed by a virtual framebuffer (Xvfb) rather than a real screen. */
298
- virtual: boolean;
299
- }
300
- declare const Display: MessageFns<Display>;
301
- /**
302
- * The agent begins enrollment by asking the control plane to start a device
303
- * flow. The control plane returns a user-code + verification URL the user visits
304
- * to consent (whole-machine + optional screen-control) and authorize.
305
- */
306
- interface DeviceAuthStartRequest {
307
- /**
308
- * The agent's stable install identity (a per-install keypair fingerprint),
309
- * bound to the enrollment so the issued credentials are non-transferable.
310
- */
311
- installFingerprint: string;
312
- os: Os;
313
- arch: Arch;
314
- machineName: string;
315
- /** The update channel the user selected at install time. */
316
- updateChannel: string;
317
- }
318
- declare const DeviceAuthStartRequest: MessageFns<DeviceAuthStartRequest>;
319
- interface DeviceAuthStartResponse {
320
- /** Short code the user types at the verification URL. */
321
- userCode: string;
322
- /** The opaque device code the agent polls with. */
323
- deviceCode: string;
324
- /** Where the user goes to authorize (e.g. https://get.opengeni.ai/device). */
325
- verificationUri: string;
326
- /** A pre-filled convenience URL embedding the user_code. */
327
- verificationUriComplete: string;
328
- /** Seconds the device_code remains valid. */
329
- expiresInSeconds: number;
330
- /** Minimum seconds the agent must wait between polls. */
331
- pollIntervalSeconds: number;
332
- }
333
- declare const DeviceAuthStartResponse: MessageFns<DeviceAuthStartResponse>;
334
- /** The agent polls until the user authorizes (or it expires / is denied). */
335
- interface DeviceAuthPollRequest {
336
- deviceCode: string;
337
- }
338
- declare const DeviceAuthPollRequest: MessageFns<DeviceAuthPollRequest>;
339
- interface DeviceAuthPollResponse {
340
- state: DeviceAuthState;
341
- /** Present only when state == AUTHORIZED. */
342
- credentials: EnrollmentCredentials | undefined;
343
- }
344
- declare const DeviceAuthPollResponse: MessageFns<DeviceAuthPollResponse>;
345
- /**
346
- * The scoped credentials persisted (0600) on the machine after enrollment.
347
- * These are workspace-scoped — they can address only this workspace's agents.
348
- */
349
- interface EnrollmentCredentials {
350
- agentId: string;
351
- workspaceId: string;
352
- /**
353
- * The NATS CONNECT AUTH-TOKEN the agent presents (the signed `oge_` enrollment
354
- * bearer). The server runs with AUTH CALLOUT (dossier §10.1 / M-AUTH): on connect
355
- * the agent passes this as the auth-token; nats-server issues an authorization
356
- * request to the control-plane's callout responder, which validates the bearer
357
- * and returns a SIGNED user JWT scoping the connection to pub/sub ONLY
358
- * `agent.<ws>.>` (+ `_INBOX.>`). That per-subject scope IS the per-workspace
359
- * tenancy boundary — there is NO per-machine creds file to ship. (Field name kept
360
- * for proto stability; it now carries the bearer, not an operator creds-file body.)
361
- */
362
- natsCredentials: string;
363
- /**
364
- * The NATS server URL(s) to dial. For the control plane these are `wss://` URLs
365
- * (the relay-symmetric TLS ingress) so the agent rides the same TLS endpoint as
366
- * the stream relay — no separate public TCP load balancer (dossier M-AUTH).
367
- */
368
- natsUrls: string[];
369
- /** The relay edge base URL for opening stream channels. */
370
- relayUrl: string;
371
- /** The minisign public key the agent pins for self-update verification. */
372
- updatePubkey: string;
373
- /** Whether the user consented to whole-machine access. */
374
- consentedWholeMachine: boolean;
375
- /** Whether the user consented to screen capture + synthetic input. */
376
- consentedScreenControl: boolean;
377
- /**
378
- * The agent's PRODUCER token for the relay edge (dossier §10.5 / the relay-dial
379
- * protocol). Presented as `StreamOpen.token` when the agent registers a
380
- * pty/desktop channel (role=AGENT). It is a control-plane-minted, workspace+agent
381
- * -scoped `ogr_` HMAC token the relay verifies on its own merits — DISTINCT from
382
- * the viewer's `ogs_` stream token (which the control plane mints per viewer and
383
- * the relay also verifies). The relay pairs the producer and consumer by the
384
- * channel key once BOTH tokens pass. Additive proto3 field; empty for an
385
- * enrollment minted before the relay-token plane is configured (the agent then
386
- * presents an empty token the relay rejects, surfacing the gap loudly).
387
- */
388
- relayToken: string;
389
- }
390
- declare const EnrollmentCredentials: MessageFns<EnrollmentCredentials>;
391
- interface ExecRequest {
392
- /** argv[0] is the program; the agent does NOT shell-interpret unless `shell`. */
393
- command: string[];
394
- /** When true, `command` is joined and run through the platform shell. */
395
- shell: boolean;
396
- /** Working directory; defaults to the agent's workspace_root when empty. */
397
- cwd: string;
398
- /** Extra environment variables layered over the agent's environment. */
399
- env: {
400
- [key: string]: string;
401
- };
402
- /** Optional stdin fed to the process. */
403
- stdin: Uint8Array;
404
- /** Hard wall-clock timeout; 0 means the control-plane default. */
405
- timeoutMs: number;
406
- }
407
- declare const ExecRequest: MessageFns<ExecRequest>;
408
- interface ExecRequest_EnvEntry {
409
- key: string;
410
- value: string;
411
- }
412
- declare const ExecRequest_EnvEntry: MessageFns<ExecRequest_EnvEntry>;
413
- interface ExecResponse {
414
- exitCode: number;
415
- stdout: Uint8Array;
416
- stderr: Uint8Array;
417
- /** True when the process was killed by `timeout_ms`. */
418
- timedOut: boolean;
419
- /** Wall-clock duration the process ran. */
420
- durationMs: string;
421
- }
422
- declare const ExecResponse: MessageFns<ExecResponse>;
423
- interface FsReadRequest {
424
- path: string;
425
- /** Optional byte offset + length for ranged reads (0 length => to EOF). */
426
- offset: string;
427
- length: string;
428
- }
429
- declare const FsReadRequest: MessageFns<FsReadRequest>;
430
- interface FsReadResponse {
431
- content: Uint8Array;
432
- /** Total size of the file (so a ranged read knows there is more). */
433
- totalSize: string;
434
- }
435
- declare const FsReadResponse: MessageFns<FsReadResponse>;
436
- interface FsWriteRequest {
437
- path: string;
438
- content: Uint8Array;
439
- /** Create parent directories as needed. */
440
- createParents: boolean;
441
- /** Append rather than truncate-and-write. */
442
- append: boolean;
443
- /** POSIX mode for a newly created file (e.g. 0644); 0 => platform default. */
444
- mode: number;
445
- }
446
- declare const FsWriteRequest: MessageFns<FsWriteRequest>;
447
- interface FsWriteResponse {
448
- bytesWritten: string;
449
- }
450
- declare const FsWriteResponse: MessageFns<FsWriteResponse>;
451
- interface FsListRequest {
452
- path: string;
453
- /** Recurse into subdirectories. */
454
- recursive: boolean;
455
- }
456
- declare const FsListRequest: MessageFns<FsListRequest>;
457
- interface FsListResponse {
458
- entries: FsEntry[];
459
- }
460
- declare const FsListResponse: MessageFns<FsListResponse>;
461
- interface FsEntry {
462
- name: string;
463
- /** Path relative to the listed directory. */
464
- path: string;
465
- kind: FsEntryKind;
466
- size: string;
467
- /** Last-modified time, unix epoch ms. */
468
- modifiedMs: string;
469
- mode: number;
470
- }
471
- declare const FsEntry: MessageFns<FsEntry>;
472
- interface FsMkdirRequest {
473
- path: string;
474
- /** Create intermediate directories (mkdir -p). */
475
- parents: boolean;
476
- mode: number;
477
- }
478
- declare const FsMkdirRequest: MessageFns<FsMkdirRequest>;
479
- interface FsMkdirResponse {
480
- }
481
- declare const FsMkdirResponse: MessageFns<FsMkdirResponse>;
482
- interface FsMoveRequest {
483
- from: string;
484
- to: string;
485
- /** Overwrite the destination if it exists. */
486
- overwrite: boolean;
487
- }
488
- declare const FsMoveRequest: MessageFns<FsMoveRequest>;
489
- interface FsMoveResponse {
490
- }
491
- declare const FsMoveResponse: MessageFns<FsMoveResponse>;
492
- interface FsStatRequest {
493
- path: string;
494
- }
495
- declare const FsStatRequest: MessageFns<FsStatRequest>;
496
- interface FsStatResponse {
497
- /** Absent when the path does not exist (the op still succeeds; `exists=false`). */
498
- exists: boolean;
499
- entry: FsEntry | undefined;
500
- }
501
- declare const FsStatResponse: MessageFns<FsStatResponse>;
502
- interface FsRemoveRequest {
503
- path: string;
504
- /** Remove directories recursively. */
505
- recursive: boolean;
506
- }
507
- declare const FsRemoveRequest: MessageFns<FsRemoveRequest>;
508
- interface FsRemoveResponse {
509
- }
510
- declare const FsRemoveResponse: MessageFns<FsRemoveResponse>;
511
- /**
512
- * A single git operation. The agent runs git against the repo rooted at `cwd`
513
- * (or workspace_root) and returns structured results where it can, falling back
514
- * to raw stdout for pass-through subcommands.
515
- */
516
- interface GitRequest {
517
- op: GitOp;
518
- /** Repo working directory; defaults to workspace_root. */
519
- cwd: string;
520
- /** Free-form args for ops that pass through (e.g. log/diff flags). */
521
- args: string[];
522
- }
523
- declare const GitRequest: MessageFns<GitRequest>;
524
- interface GitResponse {
525
- exitCode: number;
526
- /** Raw stdout/stderr for pass-through fidelity. */
527
- stdout: Uint8Array;
528
- stderr: Uint8Array;
529
- /** Structured status, present for GIT_OP_STATUS. */
530
- status: GitStatus | undefined;
531
- }
532
- declare const GitResponse: MessageFns<GitResponse>;
533
- interface GitStatus {
534
- branch: string;
535
- /** The upstream tracking branch, if any. */
536
- upstream: string;
537
- ahead: number;
538
- behind: number;
539
- files: GitFileStatus[];
540
- clean: boolean;
541
- }
542
- declare const GitStatus: MessageFns<GitStatus>;
543
- interface GitFileStatus {
544
- path: string;
545
- /** Two-letter porcelain code (e.g. " M", "??", "A "). */
546
- code: string;
547
- staged: boolean;
548
- }
549
- declare const GitFileStatus: MessageFns<GitFileStatus>;
550
- /**
551
- * Open a PTY. The agent allocates a pseudo-terminal, spawns the shell/command,
552
- * and registers a relay stream channel of kind PTY. The returned `channel`
553
- * identifies the stream the viewer connects to.
554
- */
555
- interface PtyOpenRequest {
556
- /** Shell/command to run; empty => the user's default login shell. */
557
- command: string[];
558
- cwd: string;
559
- env: {
560
- [key: string]: string;
561
- };
562
- cols: number;
563
- rows: number;
564
- /** The TERM value to advertise (e.g. "xterm-256color"). */
565
- term: string;
566
- }
567
- declare const PtyOpenRequest: MessageFns<PtyOpenRequest>;
568
- interface PtyOpenRequest_EnvEntry {
569
- key: string;
570
- value: string;
571
- }
572
- declare const PtyOpenRequest_EnvEntry: MessageFns<PtyOpenRequest_EnvEntry>;
573
- interface PtyOpenResponse {
574
- /** A handle for subsequent resize/close control ops. */
575
- ptyId: string;
576
- /** The relay stream channel carrying the PTY bytes. */
577
- channel: StreamChannel | undefined;
578
- }
579
- declare const PtyOpenResponse: MessageFns<PtyOpenResponse>;
580
- /**
581
- * Write input bytes to a PTY. (Bulk interactive bytes normally ride the stream
582
- * plane as StreamFrames; this control op exists for programmatic injection.)
583
- */
584
- interface PtyWriteRequest {
585
- ptyId: string;
586
- data: Uint8Array;
587
- }
588
- declare const PtyWriteRequest: MessageFns<PtyWriteRequest>;
589
- interface PtyWriteResponse {
590
- bytesWritten: string;
591
- }
592
- declare const PtyWriteResponse: MessageFns<PtyWriteResponse>;
593
- interface PtyResizeRequest {
594
- ptyId: string;
595
- cols: number;
596
- rows: number;
597
- }
598
- declare const PtyResizeRequest: MessageFns<PtyResizeRequest>;
599
- interface PtyResizeResponse {
600
- }
601
- declare const PtyResizeResponse: MessageFns<PtyResizeResponse>;
602
- interface PtyCloseRequest {
603
- ptyId: string;
604
- }
605
- declare const PtyCloseRequest: MessageFns<PtyCloseRequest>;
606
- interface PtyCloseResponse {
607
- /** The exit code of the PTY's root process, if it had exited. */
608
- exitCode: number;
609
- }
610
- declare const PtyCloseResponse: MessageFns<PtyCloseResponse>;
611
- /**
612
- * Ensure a desktop framebuffer stream exists, registering a relay channel of
613
- * kind DESKTOP. Idempotent: repeated calls return the same live channel.
614
- */
615
- interface DesktopEnsureRequest {
616
- /** Request a specific geometry (0 => the display's native geometry). */
617
- width: number;
618
- height: number;
619
- }
620
- declare const DesktopEnsureRequest: MessageFns<DesktopEnsureRequest>;
621
- interface DesktopEnsureResponse {
622
- channel: StreamChannel | undefined;
623
- display: Display | undefined;
624
- }
625
- declare const DesktopEnsureResponse: MessageFns<DesktopEnsureResponse>;
626
- /**
627
- * Inject one synthetic computer-use input event on the machine's desktop — the
628
- * CONTROL-PLANE twin of the relay DesktopInput (the agent drives its OWN screen
629
- * for computer-use; there is no human viewer channel). Reuses the relay
630
- * DesktopInput event shapes; there is no channel_id (this goes straight to the
631
- * display, not a relay channel). Injection is gated on consented_screen_control:
632
- * an ungated call fails with ERROR_CODE_CONSENT_REQUIRED and never touches the OS.
633
- */
634
- interface DesktopInputRequest {
635
- event: {
636
- $case: "pointer";
637
- pointer: PointerEvent;
638
- } | {
639
- $case: "key";
640
- key: KeyEvent;
641
- } | {
642
- $case: "scroll";
643
- scroll: ScrollEvent;
644
- } | undefined;
645
- }
646
- declare const DesktopInputRequest: MessageFns<DesktopInputRequest>;
647
- interface DesktopInputResponse {
648
- }
649
- declare const DesktopInputResponse: MessageFns<DesktopInputResponse>;
650
- /**
651
- * Capture a single screenshot of the machine's desktop as a PNG. A VIEW op: it
652
- * needs a display, NOT screen-control consent (the view/control decoupling), so
653
- * it is not consent-gated. Returns the encoded image plus its geometry so the
654
- * caller can size a canvas without decoding.
655
- */
656
- interface DesktopScreenshotRequest {
657
- }
658
- declare const DesktopScreenshotRequest: MessageFns<DesktopScreenshotRequest>;
659
- interface DesktopScreenshotResponse {
660
- png: Uint8Array;
661
- /**
662
- * The geometry of the ENCODED image (what a viewer/model actually sees). When
663
- * the raw capture is too large to fit the control-plane transport's max payload,
664
- * the agent DOWNSCALES the PNG so the reply publishes (a full-res Retina/busy
665
- * screen can exceed NATS's 1 MiB default); width/height then describe the
666
- * downscaled image, and `native_width`/`native_height` below carry the original.
667
- */
668
- width: number;
669
- height: number;
670
- /**
671
- * The ORIGINAL (pre-downscale) capture geometry. Equal to width/height when no
672
- * downscale was needed. The computer-use coordinate mapping scales a model click
673
- * (expressed in the ENCODED pixel space it saw) back up to this native pixel
674
- * space before injecting, so clicks land correctly even on a downscaled frame.
675
- * 0 (unset by an older agent) MUST be read as "same as width/height" (no scale).
676
- */
677
- nativeWidth: number;
678
- nativeHeight: number;
679
- }
680
- declare const DesktopScreenshotResponse: MessageFns<DesktopScreenshotResponse>;
681
- /**
682
- * The agent's periodic liveness ping. Carries a metrics sample so the control
683
- * plane can upsert the machine's last-sample without a separate RPC. The
684
- * `seq` increments per heartbeat so the control plane can detect a gap.
685
- */
686
- interface Heartbeat {
687
- seq: string;
688
- /** Agent monotonic uptime in ms. */
689
- uptimeMs: string;
690
- /**
691
- * The number of sessions currently sharing this machine (lease refcount as the
692
- * agent sees it; the authoritative count lives in Postgres).
693
- */
694
- activeSessions: number;
695
- metrics: MetricsSample | undefined;
696
- /**
697
- * True when the agent is draining for a pending self-update (prefer other
698
- * sandboxes for new work).
699
- */
700
- draining: boolean;
701
- /**
702
- * The runner's measured host capacity — the upward report the server paces
703
- * against (LIMITS-DOCTRINE: the runner holds no concurrency policy; the
704
- * swarm/scheduler reads this and decides how much to throw at the machine).
705
- */
706
- capacity: HostCapacitySample | undefined;
707
- /**
708
- * Point-in-time op-admission counts (queues only ever fill once a derived
709
- * pathology breaker saturates — nonzero queued figures are telemetry-worthy).
710
- */
711
- admission: AdmissionTelemetry | undefined;
712
- }
713
- declare const Heartbeat: MessageFns<Heartbeat>;
714
- /**
715
- * A point-in-time host-capacity sample: the impure sampler's reading of
716
- * MemAvailable, spool-filesystem free space, fd/pid headroom, and CPUs. Every
717
- * runner-side budget/breaker is a fraction of these (rule R), so this is also
718
- * how the server understands what the machine can take.
719
- */
720
- interface HostCapacitySample {
721
- memAvailableBytes: string;
722
- diskFreeBytes: string;
723
- fdHeadroom: string;
724
- pidHeadroom: string;
725
- nproc: string;
726
- }
727
- declare const HostCapacitySample: MessageFns<HostCapacitySample>;
728
- /** Point-in-time op-admission counts, per class. */
729
- interface AdmissionTelemetry {
730
- lightRunning: string;
731
- lightQueued: string;
732
- heavyRunning: string;
733
- heavyQueued: string;
734
- /**
735
- * Jobs with a live mailbox (running + completed-retained awaiting final
736
- * ack) — the op-engine's routing-table size.
737
- */
738
- liveOps: string;
739
- /**
740
- * Op frames dropped by the fire-and-forget publish path (bulk lane down or
741
- * its channel full). Protocol-healed by replay; recorded so an undersized
742
- * lane is visible before it matters (monotonic).
743
- */
744
- opFramesDroppedTotal: string;
745
- /**
746
- * Completed ops evicted before their final ack (dropped results) — the
747
- * registry's loud counter (monotonic).
748
- */
749
- evictedUnackedTotal: string;
750
- }
751
- declare const AdmissionTelemetry: MessageFns<AdmissionTelemetry>;
752
- interface HeartbeatAck {
753
- /** The control plane may instruct the agent to adjust its heartbeat cadence. */
754
- nextIntervalMs: number;
755
- /** The control plane may signal a pending fleet action (e.g. update available). */
756
- updateAvailable: boolean;
757
- }
758
- declare const HeartbeatAck: MessageFns<HeartbeatAck>;
759
- /** On-demand metrics request (the dashboard force-poll path). */
760
- interface MetricsRequest {
761
- }
762
- declare const MetricsRequest: MessageFns<MetricsRequest>;
763
- /** A point-in-time machine metrics sample. */
764
- interface MetricsSample {
765
- /** Unix epoch ms when sampled. */
766
- sampledAtMs: string;
767
- /** CPU utilization 0..100 (whole machine). */
768
- cpuPercent: number;
769
- /** Load averages. */
770
- load1: number;
771
- load5: number;
772
- load15: number;
773
- memUsedBytes: string;
774
- memTotalBytes: string;
775
- diskUsedBytes: string;
776
- diskTotalBytes: string;
777
- /** A contention signal (run-queue length / pressure), if available. */
778
- runQueue: number;
779
- /** Per-GPU samples, when GPUs are present. */
780
- gpus: GpuSample[];
781
- }
782
- declare const MetricsSample: MessageFns<MetricsSample>;
783
- interface GpuSample {
784
- name: string;
785
- /** Utilization 0..100. */
786
- utilPercent: number;
787
- memUsedBytes: string;
788
- memTotalBytes: string;
789
- }
790
- declare const GpuSample: MessageFns<GpuSample>;
791
- /**
792
- * A cheap liveness probe — the control plane requests it to test that a
793
- * responder exists on the subject (the NATS "is there an agent" check).
794
- */
795
- interface PingRequest {
796
- /** Echoed back so the caller can correlate / measure RTT. */
797
- nonce: string;
798
- }
799
- declare const PingRequest: MessageFns<PingRequest>;
800
- interface PingResponse {
801
- nonce: string;
802
- /** The agent's monotonic clock, for skew estimation. */
803
- agentMonotonicMs: string;
804
- }
805
- declare const PingResponse: MessageFns<PingResponse>;
806
- /**
807
- * Sent by the agent on a clean stop (SIGINT/SIGTERM) so the lease flips to
808
- * offline IMMEDIATELY rather than waiting on heartbeat dead-detection.
809
- */
810
- interface GoingOffline {
811
- reason: GoingOfflineReason;
812
- /** Optional human note (e.g. "user pressed Ctrl-C"). */
813
- message: string;
814
- }
815
- declare const GoingOffline: MessageFns<GoingOffline>;
816
- /**
817
- * On reconnect, the agent presents its resume token; the control plane fences by
818
- * epoch and either accepts the resume (same machine, new connection generation)
819
- * or, if the token is unknown/stale, requires a fresh hello.
820
- */
821
- interface ResumeRequest {
822
- agentId: string;
823
- resumeToken: string;
824
- /** The lease epoch the agent last observed, for the integer fence. */
825
- lastKnownEpoch: number;
826
- }
827
- declare const ResumeRequest: MessageFns<ResumeRequest>;
828
- interface ResumeResponse {
829
- accepted: boolean;
830
- /**
831
- * The new lease epoch the control plane assigned to this connection. Any op
832
- * fenced by an older epoch must re-resolve and retry.
833
- */
834
- epoch: number;
835
- /** A fresh resume token for the NEXT reconnect (tokens rotate per generation). */
836
- resumeToken: string;
837
- }
838
- declare const ResumeResponse: MessageFns<ResumeResponse>;
839
- /** The agent asks whether a newer build is available for its channel + target. */
840
- interface UpdateCheckRequest {
841
- currentVersion: string;
842
- channel: string;
843
- os: Os;
844
- arch: Arch;
845
- }
846
- declare const UpdateCheckRequest: MessageFns<UpdateCheckRequest>;
847
- interface UpdateCheckResponse {
848
- updateAvailable: boolean;
849
- manifest: UpdateManifest | undefined;
850
- }
851
- declare const UpdateCheckResponse: MessageFns<UpdateCheckResponse>;
852
- /**
853
- * A signed channel manifest. It is itself minisign-signed out-of-band; this
854
- * message is the decoded body the updater reasons over.
855
- */
856
- interface UpdateManifest {
857
- channel: string;
858
- version: string;
859
- /** The minimum version still permitted (downgrade-attack protection). */
860
- minSupported: string;
861
- /** Staged-rollout gate: an agent applies when blake3(agentId+salt)%100 < percent. */
862
- rolloutPercent: number;
863
- cohortSalt: string;
864
- artifacts: UpdateArtifact[];
865
- notesUrl: string;
866
- signedAtMs: string;
867
- /** When true, override drain and update mid-session (security CVE path). */
868
- force: boolean;
869
- }
870
- declare const UpdateManifest: MessageFns<UpdateManifest>;
871
- interface UpdateArtifact {
872
- /** Target triple, e.g. "x86_64-unknown-linux-musl". */
873
- target: string;
874
- url: string;
875
- size: string;
876
- sha256: string;
877
- /** URL of the detached minisign signature for the artifact. */
878
- minisigUrl: string;
879
- }
880
- declare const UpdateArtifact: MessageFns<UpdateArtifact>;
881
- /**
882
- * Before applying, the updater asks the control plane whether it may proceed
883
- * (the control plane reads the Postgres lease refcount). The agent drains until
884
- * the refcount reaches zero or a grace window elapses.
885
- */
886
- interface UpdateMayProceedRequest {
887
- agentId: string;
888
- targetVersion: string;
889
- }
890
- declare const UpdateMayProceedRequest: MessageFns<UpdateMayProceedRequest>;
891
- interface UpdateMayProceedResponse {
892
- mayProceed: boolean;
893
- /** When false, the number of live sessions blocking the update. */
894
- activeSessions: number;
895
- }
896
- declare const UpdateMayProceedResponse: MessageFns<UpdateMayProceedResponse>;
897
- /**
898
- * The terminal outcome of an op — carried in the Exit frame body AND echoed in
899
- * OpStatus once complete. Digests/totals are keyed by channel name
900
- * ("stdout"/"stderr"/"content") for a byte-exact assembly proof.
901
- */
902
- interface OpExit {
903
- exitCode: number;
904
- /** Hit the runner-enforced deadline (process-tree killed). */
905
- timedOut: boolean;
906
- /** Cancelled via OpCancel. */
907
- cancelled: boolean;
908
- durationMs: string;
909
- /** channel name → blake3 hex digest of the full channel stream. */
910
- digests: {
911
- [key: string]: string;
912
- };
913
- /** channel name → total bytes emitted on the channel. */
914
- totals: {
915
- [key: string]: string;
916
- };
917
- /**
918
- * Set iff the RUNNER failed the op with a typed reason ("OP_OVERFLOW" /
919
- * "OP_SPOOL_IO" / "OP_PIPE_IO"); empty for every child-decided outcome
920
- * (exit/timeout/cancel). Never an exit-code sentinel — ambiguous renderings
921
- * are outlawed (FAILURE-VISIBILITY.md).
922
- */
923
- failureCode: string;
924
- /**
925
- * Structured detail for failure_code (exact counters: retained bytes, the
926
- * IO error text, captured byte totals) — the out-of-band plane's food.
927
- */
928
- failureDetail: {
929
- [key: string]: string;
930
- };
931
- }
932
- declare const OpExit: MessageFns<OpExit>;
933
- interface OpExit_DigestsEntry {
934
- key: string;
935
- value: string;
936
- }
937
- declare const OpExit_DigestsEntry: MessageFns<OpExit_DigestsEntry>;
938
- interface OpExit_TotalsEntry {
939
- key: string;
940
- value: string;
941
- }
942
- declare const OpExit_TotalsEntry: MessageFns<OpExit_TotalsEntry>;
943
- interface OpExit_FailureDetailEntry {
944
- key: string;
945
- value: string;
946
- }
947
- declare const OpExit_FailureDetailEntry: MessageFns<OpExit_FailureDetailEntry>;
948
- /**
949
- * The op-begin for a STREAMING fs_write (M7): the target is set up here; the bytes
950
- * arrive as chunked, idempotent WriteChunk request/replies (no reverse streaming).
951
- */
952
- interface FsWriteBegin {
953
- path: string;
954
- /** Create parent directories as needed. */
955
- createParents: boolean;
956
- /** POSIX mode for a newly created file (0 => platform default). */
957
- mode: number;
958
- /**
959
- * Editor safety (M6): the expected blake3 hex digest of the file's CURRENT
960
- * content for a read-modify-write; empty for a plain write. On a re-dispatch a
961
- * mismatch REFUSES rather than double-applying a diff.
962
- */
963
- expectedBaseDigest: string;
964
- }
965
- declare const FsWriteBegin: MessageFns<FsWriteBegin>;
966
- /**
967
- * Start an op (server→runner). IDEMPOTENT by op_id (= ControlRequest.request_id):
968
- * a known op_id returns its current status and NEVER re-runs — this closes the
969
- * at-least-once re-run hazard (a re-dispatched turn re-issues OpStart{same id} and
970
- * attaches).
971
- */
972
- interface OpStart {
973
- op: {
974
- $case: "exec";
975
- exec: ExecRequest;
976
- } | {
977
- $case: "fsRead";
978
- fsRead: FsReadRequest;
979
- } | {
980
- $case: "fsWrite";
981
- fsWrite: FsWriteBegin;
982
- } | undefined;
983
- /** Initial send credit in bytes (0 => the runner default, ~4 MiB). */
984
- windowBytes: string;
985
- /**
986
- * Absolute runner-enforced deadline, unix-epoch ms (0 = none). Runner-side
987
- * enforcement is authoritative (process-tree kill + Exit{timed_out}); the
988
- * server wall-clock is advisory.
989
- */
990
- deadlineMs: string;
991
- /** The originating session id, for per-origin fair admission. */
992
- originId: string;
993
- }
994
- declare const OpStart: MessageFns<OpStart>;
995
- interface OpStarted {
996
- accepted: boolean;
997
- status: OpStatus | undefined;
998
- }
999
- declare const OpStarted: MessageFns<OpStarted>;
1000
- /**
1001
- * Cancel an op (server→runner). Idempotent; triggers the #344 process-tree kill and
1002
- * a terminal frame. Reply is OpStatus.
1003
- */
1004
- interface OpCancel {
1005
- opId: string;
1006
- }
1007
- declare const OpCancel: MessageFns<OpCancel>;
1008
- /** Query an op's status (server→runner). Reply is OpStatus. */
1009
- interface OpQuery {
1010
- opId: string;
1011
- }
1012
- declare const OpQuery: MessageFns<OpQuery>;
1013
- /**
1014
- * Re-attach to an op after a reconnect or a missed frame (server→runner): the
1015
- * runner re-publishes frames ≥ from_seq from its ring/spool, then resumes live
1016
- * flow. Reply is OpStatus.
1017
- */
1018
- interface OpAttach {
1019
- opId: string;
1020
- /** Resume from this exclusive sequence (the consumer's cumulative-ack floor). */
1021
- fromSeq: string;
1022
- /**
1023
- * Attach generation (B2): monotonic (the consumer's Temporal attempt number).
1024
- * The runner serves replay/credit only for the HIGHEST generation seen; a
1025
- * lower-generation (zombie) consumer's acks are ignored.
1026
- */
1027
- attachGeneration: string;
1028
- /**
1029
- * The fresh send-credit window for the resumed attachment, in bytes
1030
- * (0 => reuse the window granted at OpStart). OpAck's absolute credit_bytes
1031
- * resizes it thereafter.
1032
- */
1033
- windowBytes: string;
1034
- }
1035
- declare const OpAttach: MessageFns<OpAttach>;
1036
- /**
1037
- * The current status of an op (server←runner reply to OpCancel/OpQuery/OpAttach,
1038
- * and embedded in OpStarted).
1039
- */
1040
- interface OpStatus {
1041
- opId: string;
1042
- state: OpState;
1043
- /**
1044
- * The next sequence number the runner will assign (the high watermark, for gap
1045
- * detection).
1046
- */
1047
- nextSeq: string;
1048
- /** Present iff state == OP_STATE_COMPLETE. */
1049
- exit: OpExit | undefined;
1050
- /** Present iff state == OP_STATE_LOST. */
1051
- lostReason: OpLostReason;
1052
- }
1053
- declare const OpStatus: MessageFns<OpStatus>;
1054
- /**
1055
- * One chunk of a streaming upload (server→runner): plain idempotent request/reply
1056
- * per chunk (≤512 KiB). A duplicate (op_id, seq) is acked WITHOUT re-applying.
1057
- */
1058
- interface WriteChunk {
1059
- opId: string;
1060
- /** The op-scoped monotonic chunk sequence. */
1061
- seq: string;
1062
- bytes: Uint8Array;
1063
- /** The final chunk: commit = digest-verify then atomic rename (M7). */
1064
- last: boolean;
1065
- /**
1066
- * Byte offset this chunk writes at (M7: writes land in an op-scoped temp file,
1067
- * committed on the last chunk — an aborted transfer leaves no visible file).
1068
- */
1069
- offset: string;
1070
- }
1071
- declare const WriteChunk: MessageFns<WriteChunk>;
1072
- interface WriteChunkAck {
1073
- seq: string;
1074
- }
1075
- declare const WriteChunkAck: MessageFns<WriteChunkAck>;
1076
- /**
1077
- * A runner→server op frame, published fire-and-forget on the op subject
1078
- * (`agent.<ws>.<id>.op.<op_id>`). `seq` is a SINGLE monotonic sequence per op
1079
- * across ALL body kinds (Progress frames consume sequence numbers too, so gap
1080
- * detection is uniform).
1081
- */
1082
- interface OpFrame {
1083
- opId: string;
1084
- seq: string;
1085
- body: {
1086
- $case: "data";
1087
- data: OpData;
1088
- } | {
1089
- $case: "progress";
1090
- progress: OpProgress;
1091
- } | {
1092
- $case: "exit";
1093
- exit: OpExit;
1094
- } | undefined;
1095
- }
1096
- declare const OpFrame: MessageFns<OpFrame>;
1097
- /** A chunk of op output on a channel (≤128 KiB per frame). */
1098
- interface OpData {
1099
- channel: OpChannel;
1100
- bytes: Uint8Array;
1101
- }
1102
- declare const OpData: MessageFns<OpData>;
1103
- /**
1104
- * A liveness tick: the op is alive but produced no Data. Emitted every 5s while an
1105
- * op is live and quiet; consumes a sequence number like any frame.
1106
- */
1107
- interface OpProgress {
1108
- }
1109
- declare const OpProgress: MessageFns<OpProgress>;
1110
- /**
1111
- * A server→runner cumulative ack + credit replenishment, published fire-and-forget
1112
- * on the ack subject (`agent.<ws>.<id>.ack`). Best-effort, healed by repetition.
1113
- */
1114
- interface OpAck {
1115
- opId: string;
1116
- /** Cumulative: every frame with seq ≤ acked_seq is acknowledged. */
1117
- ackedSeq: string;
1118
- /** The replenished ABSOLUTE send-credit window in bytes. */
1119
- creditBytes: string;
1120
- /** The server has fully consumed the terminal frame → the runner may GC the op. */
1121
- final: boolean;
1122
- /**
1123
- * The consumer's attach generation (matches OpAttach.attach_generation; the
1124
- * consumer's Temporal attempt number). The runner honors this ack — its floor
1125
- * advance AND its credit grant — ONLY for the HIGHEST generation it has seen for
1126
- * the op; a lower-generation (zombie) ack is ignored. This must ride the wire
1127
- * (not be inferred from monotonic acked_seq alone) because credit_bytes is an
1128
- * ABSOLUTE window REPLACEMENT: a stale consumer's ack could otherwise shrink the
1129
- * live consumer's window (stall) or grant unintended credit (B2).
1130
- */
1131
- attachGeneration: string;
1132
- }
1133
- declare const OpAck: MessageFns<OpAck>;
1134
- /**
1135
- * Wraps an op-specific request. `request_id` correlates a response to a request
1136
- * even over fan-out; `epoch` carries the lease/active epoch the control plane
1137
- * resolved this op against, so the agent can reject a stale op (ERROR_CODE_FENCED).
1138
- */
1139
- interface ControlRequest {
1140
- requestId: string;
1141
- epoch: number;
1142
- op: {
1143
- $case: "ping";
1144
- ping: PingRequest;
1145
- } | {
1146
- $case: "hello";
1147
- hello: Hello;
1148
- } | {
1149
- $case: "resume";
1150
- resume: ResumeRequest;
1151
- } | {
1152
- $case: "exec";
1153
- exec: ExecRequest;
1154
- } | {
1155
- $case: "fsRead";
1156
- fsRead: FsReadRequest;
1157
- } | {
1158
- $case: "fsWrite";
1159
- fsWrite: FsWriteRequest;
1160
- } | {
1161
- $case: "fsList";
1162
- fsList: FsListRequest;
1163
- } | {
1164
- $case: "fsMkdir";
1165
- fsMkdir: FsMkdirRequest;
1166
- } | {
1167
- $case: "fsMove";
1168
- fsMove: FsMoveRequest;
1169
- } | {
1170
- $case: "fsStat";
1171
- fsStat: FsStatRequest;
1172
- } | {
1173
- $case: "fsRemove";
1174
- fsRemove: FsRemoveRequest;
1175
- } | {
1176
- $case: "git";
1177
- git: GitRequest;
1178
- } | {
1179
- $case: "ptyOpen";
1180
- ptyOpen: PtyOpenRequest;
1181
- } | {
1182
- $case: "ptyWrite";
1183
- ptyWrite: PtyWriteRequest;
1184
- } | {
1185
- $case: "ptyResize";
1186
- ptyResize: PtyResizeRequest;
1187
- } | {
1188
- $case: "ptyClose";
1189
- ptyClose: PtyCloseRequest;
1190
- } | {
1191
- $case: "desktopEnsure";
1192
- desktopEnsure: DesktopEnsureRequest;
1193
- } | {
1194
- $case: "metrics";
1195
- metrics: MetricsRequest;
1196
- } | {
1197
- $case: "updateMayProceed";
1198
- updateMayProceed: UpdateMayProceedRequest;
1199
- } | {
1200
- $case: "desktopInput";
1201
- desktopInput: DesktopInputRequest;
1202
- } | {
1203
- $case: "desktopScreenshot";
1204
- desktopScreenshot: DesktopScreenshotRequest;
1205
- }
1206
- /**
1207
- * Op-stream (v1.1), additive. All ride the same rpc subject; each has an
1208
- * idempotent, typed reply in ControlResponse.result below.
1209
- */
1210
- | {
1211
- $case: "opStart";
1212
- opStart: OpStart;
1213
- } | {
1214
- $case: "opCancel";
1215
- opCancel: OpCancel;
1216
- } | {
1217
- $case: "opQuery";
1218
- opQuery: OpQuery;
1219
- } | {
1220
- $case: "opAttach";
1221
- opAttach: OpAttach;
1222
- } | {
1223
- $case: "writeChunk";
1224
- writeChunk: WriteChunk;
1225
- } | undefined;
1226
- }
1227
- declare const ControlRequest: MessageFns<ControlRequest>;
1228
- /** Wraps an op-specific response, or an error. `request_id` echoes the request. */
1229
- interface ControlResponse {
1230
- requestId: string;
1231
- /** Present when the op failed; when set, `result` is empty. */
1232
- error: AgentError | undefined;
1233
- result: {
1234
- $case: "ping";
1235
- ping: PingResponse;
1236
- } | {
1237
- $case: "hello";
1238
- hello: HelloAck;
1239
- } | {
1240
- $case: "resume";
1241
- resume: ResumeResponse;
1242
- } | {
1243
- $case: "exec";
1244
- exec: ExecResponse;
1245
- } | {
1246
- $case: "fsRead";
1247
- fsRead: FsReadResponse;
1248
- } | {
1249
- $case: "fsWrite";
1250
- fsWrite: FsWriteResponse;
1251
- } | {
1252
- $case: "fsList";
1253
- fsList: FsListResponse;
1254
- } | {
1255
- $case: "fsMkdir";
1256
- fsMkdir: FsMkdirResponse;
1257
- } | {
1258
- $case: "fsMove";
1259
- fsMove: FsMoveResponse;
1260
- } | {
1261
- $case: "fsStat";
1262
- fsStat: FsStatResponse;
1263
- } | {
1264
- $case: "fsRemove";
1265
- fsRemove: FsRemoveResponse;
1266
- } | {
1267
- $case: "git";
1268
- git: GitResponse;
1269
- } | {
1270
- $case: "ptyOpen";
1271
- ptyOpen: PtyOpenResponse;
1272
- } | {
1273
- $case: "ptyWrite";
1274
- ptyWrite: PtyWriteResponse;
1275
- } | {
1276
- $case: "ptyResize";
1277
- ptyResize: PtyResizeResponse;
1278
- } | {
1279
- $case: "ptyClose";
1280
- ptyClose: PtyCloseResponse;
1281
- } | {
1282
- $case: "desktopEnsure";
1283
- desktopEnsure: DesktopEnsureResponse;
1284
- } | {
1285
- $case: "metrics";
1286
- metrics: MetricsSample;
1287
- } | {
1288
- $case: "updateMayProceed";
1289
- updateMayProceed: UpdateMayProceedResponse;
1290
- } | {
1291
- $case: "desktopInput";
1292
- desktopInput: DesktopInputResponse;
1293
- } | {
1294
- $case: "desktopScreenshot";
1295
- desktopScreenshot: DesktopScreenshotResponse;
1296
- }
1297
- /**
1298
- * Op-stream (v1.1) replies, additive. OpStart → OpStarted; OpCancel / OpQuery /
1299
- * OpAttach all reply OpStatus (op_status); WriteChunk → WriteChunkAck.
1300
- */
1301
- | {
1302
- $case: "opStart";
1303
- opStart: OpStarted;
1304
- } | {
1305
- $case: "opStatus";
1306
- opStatus: OpStatus;
1307
- } | {
1308
- $case: "writeChunk";
1309
- writeChunk: WriteChunkAck;
1310
- } | undefined;
1311
- }
1312
- declare const ControlResponse: MessageFns<ControlResponse>;
1313
- /**
1314
- * The control plane's acknowledgement of a Hello, carrying the epoch it assigned
1315
- * and a resume token for the next reconnect.
1316
- */
1317
- interface HelloAck {
1318
- epoch: number;
1319
- resumeToken: string;
1320
- /** The heartbeat interval the agent should use. */
1321
- heartbeatIntervalMs: number;
1322
- }
1323
- declare const HelloAck: MessageFns<HelloAck>;
1324
- /**
1325
- * Wraps a message the AGENT originates (not a reply to a ControlRequest):
1326
- * heartbeats, the clean going-offline signal. These are published on the agent's
1327
- * outbound subject; the control plane folds them into lease/metrics state.
1328
- */
1329
- interface AgentEvent {
1330
- agentId: string;
1331
- event: {
1332
- $case: "heartbeat";
1333
- heartbeat: Heartbeat;
1334
- } | {
1335
- $case: "goingOffline";
1336
- goingOffline: GoingOffline;
1337
- } | undefined;
1338
- }
1339
- declare const AgentEvent: MessageFns<AgentEvent>;
1340
- /** The control plane's ack of an AgentEvent (e.g. a HeartbeatAck). */
1341
- interface AgentEventAck {
1342
- ack: {
1343
- $case: "heartbeat";
1344
- heartbeat: HeartbeatAck;
1345
- } | undefined;
1346
- }
1347
- declare const AgentEventAck: MessageFns<AgentEventAck>;
1348
- /**
1349
- * Identifies a relay stream channel. The viewer/pty client connects to the
1350
- * relay with this channel's coordinates plus a scoped `ogs_` token; the agent
1351
- * dials out and registers the same channel. `{workspace_id, agent_id, port}`
1352
- * is the routing key.
1353
- */
1354
- interface StreamChannel {
1355
- channelId: string;
1356
- workspaceId: string;
1357
- agentId: string;
1358
- kind: StreamKind;
1359
- /** The logical port the channel maps to (so resolveExposedPort can address it). */
1360
- port: number;
1361
- }
1362
- declare const StreamChannel: MessageFns<StreamChannel>;
1363
- /**
1364
- * Open a stream channel on the relay. Sent by both ends (agent registers; client
1365
- * attaches) as the first frame of a relay connection.
1366
- */
1367
- interface StreamOpen {
1368
- channel: StreamChannel | undefined;
1369
- /**
1370
- * The scoped stream token (`ogs_` envelope) authorizing this channel; the
1371
- * relay validates authenticity + the lease/active-epoch fence.
1372
- */
1373
- token: string;
1374
- /** Whether the sender is the producing agent or the consuming viewer. */
1375
- role: StreamRole;
1376
- /**
1377
- * For resume: the last frame sequence the sender successfully processed, so
1378
- * the peer can replay from there after a reconnect blip.
1379
- */
1380
- resumeFromSeq: string;
1381
- }
1382
- declare const StreamOpen: MessageFns<StreamOpen>;
1383
- /** The relay's acknowledgement of a StreamOpen. */
1384
- interface StreamOpenAck {
1385
- accepted: boolean;
1386
- error: AgentError | undefined;
1387
- /** The sequence the peer will resume sending from. */
1388
- resumeFromSeq: string;
1389
- }
1390
- declare const StreamOpenAck: MessageFns<StreamOpenAck>;
1391
- /**
1392
- * A data frame carrying raw stream bytes in either direction. `seq` is a
1393
- * monotonic per-channel-per-direction counter enabling resume-from-seq. For a
1394
- * DESKTOP channel `data` is an encoded framebuffer chunk; for PTY it is raw tty
1395
- * bytes. Input (client→agent) for desktop computer-use rides DesktopInput
1396
- * instead so synthetic events are typed, not opaque bytes.
1397
- */
1398
- interface StreamFrame {
1399
- channelId: string;
1400
- seq: string;
1401
- data: Uint8Array;
1402
- /** Unix epoch ms the frame was produced (for latency/lag metrics). */
1403
- producedAtMs: string;
1404
- }
1405
- declare const StreamFrame: MessageFns<StreamFrame>;
1406
- /**
1407
- * Close a stream channel. Either end may send it; the relay tears down the
1408
- * channel and notifies the peer.
1409
- */
1410
- interface StreamClose {
1411
- channelId: string;
1412
- reason: StreamCloseReason;
1413
- message: string;
1414
- }
1415
- declare const StreamClose: MessageFns<StreamClose>;
1416
- /**
1417
- * Typed computer-use input from a client to a desktop channel (client→agent).
1418
- * Synthetic input is gated on consented_screen_control; an ungated input op
1419
- * fails with ERROR_CODE_CONSENT_REQUIRED.
1420
- */
1421
- interface DesktopInput {
1422
- channelId: string;
1423
- event: {
1424
- $case: "pointer";
1425
- pointer: PointerEvent;
1426
- } | {
1427
- $case: "key";
1428
- key: KeyEvent;
1429
- } | {
1430
- $case: "scroll";
1431
- scroll: ScrollEvent;
1432
- } | undefined;
1433
- }
1434
- declare const DesktopInput: MessageFns<DesktopInput>;
1435
- interface PointerEvent {
1436
- x: number;
1437
- y: number;
1438
- action: PointerAction;
1439
- button: PointerButton;
1440
- }
1441
- declare const PointerEvent: MessageFns<PointerEvent>;
1442
- interface KeyEvent {
1443
- /** A platform-independent key name (e.g. "Enter", "a", "ctrl+c") OR text to type. */
1444
- key: string;
1445
- isText: boolean;
1446
- action: KeyAction;
1447
- }
1448
- declare const KeyEvent: MessageFns<KeyEvent>;
1449
- interface ScrollEvent {
1450
- x: number;
1451
- y: number;
1452
- deltaX: number;
1453
- deltaY: number;
1454
- }
1455
- declare const ScrollEvent: MessageFns<ScrollEvent>;
1456
- type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
1457
- type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {
1458
- $case: string;
1459
- } ? {
1460
- [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]>;
1461
- } & {
1462
- $case: T["$case"];
1463
- } : T extends {} ? {
1464
- [K in keyof T]?: DeepPartial<T[K]>;
1465
- } : Partial<T>;
1466
- type KeysOfUnion<T> = T extends T ? keyof T : never;
1467
- type Exact<P, I extends P> = P extends Builtin ? P : P & {
1468
- [K in keyof P]: Exact<P[K], I[K]>;
1469
- } & {
1470
- [K in Exclude<keyof I, KeysOfUnion<P>>]: never;
1471
- };
1472
- interface MessageFns<T> {
1473
- encode(message: T, writer?: BinaryWriter): BinaryWriter;
1474
- decode(input: BinaryReader | Uint8Array, length?: number): T;
1475
- fromJSON(object: any): T;
1476
- toJSON(message: T): unknown;
1477
- create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
1478
- fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
1479
- }
1480
-
1481
- export { AdmissionTelemetry, AgentError, AgentError_DetailEntry, AgentEvent, AgentEventAck, Arch, Capabilities, ControlRequest, ControlResponse, type DeepPartial, DesktopEnsureRequest, DesktopEnsureResponse, DesktopInput, DesktopInputRequest, DesktopInputResponse, DesktopScreenshotRequest, DesktopScreenshotResponse, DeviceAuthPollRequest, DeviceAuthPollResponse, DeviceAuthStartRequest, DeviceAuthStartResponse, DeviceAuthState, Display, EnrollmentCredentials, ErrorCode, type Exact, ExecRequest, ExecRequest_EnvEntry, ExecResponse, FsEntry, FsEntryKind, FsListRequest, FsListResponse, FsMkdirRequest, FsMkdirResponse, FsMoveRequest, FsMoveResponse, FsReadRequest, FsReadResponse, FsRemoveRequest, FsRemoveResponse, FsStatRequest, FsStatResponse, FsWriteBegin, FsWriteRequest, FsWriteResponse, GitFileStatus, GitOp, GitRequest, GitResponse, GitStatus, GoingOffline, GoingOfflineReason, GpuSample, Heartbeat, HeartbeatAck, Hello, HelloAck, HostCapacitySample, KeyAction, KeyEvent, type MessageFns, MetricsRequest, MetricsSample, OpAck, OpAttach, OpCancel, OpChannel, OpData, OpExit, OpExit_DigestsEntry, OpExit_FailureDetailEntry, OpExit_TotalsEntry, OpFrame, OpLostReason, OpProgress, OpQuery, OpStart, OpStarted, OpState, OpStatus, Os, PingRequest, PingResponse, PointerAction, PointerButton, PointerEvent, PtyCloseRequest, PtyCloseResponse, PtyOpenRequest, PtyOpenRequest_EnvEntry, PtyOpenResponse, PtyResizeRequest, PtyResizeResponse, PtyWriteRequest, PtyWriteResponse, ResumeRequest, ResumeResponse, ScrollEvent, StreamChannel, StreamClose, StreamCloseReason, StreamFrame, StreamKind, StreamOpen, StreamOpenAck, StreamRole, UpdateArtifact, UpdateCheckRequest, UpdateCheckResponse, UpdateManifest, UpdateMayProceedRequest, UpdateMayProceedResponse, WriteChunk, WriteChunkAck, archFromJSON, archToJSON, deviceAuthStateFromJSON, deviceAuthStateToJSON, errorCodeFromJSON, errorCodeToJSON, fsEntryKindFromJSON, fsEntryKindToJSON, gitOpFromJSON, gitOpToJSON, goingOfflineReasonFromJSON, goingOfflineReasonToJSON, keyActionFromJSON, keyActionToJSON, opChannelFromJSON, opChannelToJSON, opLostReasonFromJSON, opLostReasonToJSON, opStateFromJSON, opStateToJSON, osFromJSON, osToJSON, pointerActionFromJSON, pointerActionToJSON, pointerButtonFromJSON, pointerButtonToJSON, protobufPackage, streamCloseReasonFromJSON, streamCloseReasonToJSON, streamKindFromJSON, streamKindToJSON, streamRoleFromJSON, streamRoleToJSON };
2
+ * `@opengeni/agent-proto` generated TypeScript wire-protocol types for the
3
+ * OpenGeni self-hosted agent.
4
+ *
5
+ * This is the **control-plane side** of the single-source-of-truth wire protocol
6
+ * defined once in `agent/proto/opengeni_agent.proto`. The types here are
7
+ * code-generated (ts-proto) from that schema; the SAME schema generates the Rust
8
+ * (`prost`) types the agent uses. Because both stacks are generated from the one
9
+ * IDL, the control plane and the agent can never drift — proven by the
10
+ * cross-stack round-trip test (`test/roundtrip.test.ts`).
11
+ *
12
+ * Do not edit `src/gen/*` by hand; regenerate via `bun run --filter
13
+ * @opengeni/agent-proto codegen` (or `agent/scripts/codegen.sh` to regenerate
14
+ * both Rust and TS at once).
15
+ */
16
+ export * from "./gen/opengeni_agent.js";