@roll-agent/relay-protocol 0.0.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.
@@ -0,0 +1,1050 @@
1
+ import { type JsonValue } from "@roll-agent/protocol";
2
+ import { z } from "zod/v4";
3
+ export declare const SUPPORTED_RELAY_PROTOCOL_VERSIONS: readonly ["1.0"];
4
+ export type RelayProtocolVersion = (typeof SUPPORTED_RELAY_PROTOCOL_VERSIONS)[number];
5
+ export declare const RELAY_PROTOCOL_VERSION: "1.0";
6
+ /** @deprecated Use `RELAY_PROTOCOL_VERSION`. */
7
+ export declare const COMPANION_RELAY_PROTOCOL_VERSION: "1.0";
8
+ export declare const RELAY_MESSAGE_TYPES: {
9
+ readonly deviceConnect: "device.connect";
10
+ readonly runtimeRequest: "runtime.request";
11
+ readonly runtimeResponse: "runtime.response";
12
+ readonly runtimeEvent: "runtime.event";
13
+ readonly runtimeAck: "runtime.ack";
14
+ readonly runtimeGap: "runtime.gap";
15
+ readonly runtimeEncrypted: "runtime.encrypted";
16
+ };
17
+ export declare const RELAY_MESSAGE_TYPE_VALUES: readonly ["device.connect", "runtime.request", "runtime.response", "runtime.event", "runtime.ack", "runtime.gap", "runtime.encrypted"];
18
+ /**
19
+ * Relay Wire 1.0 is intentionally independent from the latest Runtime registry.
20
+ * New Runtime methods never become remotely callable without a Relay version change.
21
+ */
22
+ export declare const RELAY_REQUEST_METHODS: {
23
+ readonly initialize: "initialize";
24
+ readonly threadList: "thread.list";
25
+ readonly threadCreate: "thread.create";
26
+ readonly threadOpen: "thread.open";
27
+ readonly threadSnapshot: "thread.snapshot";
28
+ readonly threadRename: "thread.rename";
29
+ readonly threadDelete: "thread.delete";
30
+ readonly threadDetach: "thread.detach";
31
+ readonly threadCapabilities: "thread.capabilities";
32
+ readonly turnStart: "turn.start";
33
+ readonly turnCancel: "turn.cancel";
34
+ readonly approvalRespond: "approval.respond";
35
+ readonly operationGet: "operation.get";
36
+ readonly approvalCandidate: "approval.candidate";
37
+ };
38
+ export type RelayRequestMethod = (typeof RELAY_REQUEST_METHODS)[keyof typeof RELAY_REQUEST_METHODS];
39
+ export declare const RELAY_REQUEST_METHOD_VALUES: readonly ["initialize", "thread.list", "thread.create", "thread.open", "thread.snapshot", "thread.rename", "thread.delete", "thread.detach", "thread.capabilities", "turn.start", "turn.cancel", "approval.respond", "operation.get", "approval.candidate"];
40
+ export declare const RELAY_REQUEST_METHOD_DISPOSITIONS: {
41
+ readonly initialize: "local-only";
42
+ readonly "thread.list": "query";
43
+ readonly "thread.create": "mutation";
44
+ readonly "thread.open": "query";
45
+ readonly "thread.snapshot": "query";
46
+ readonly "thread.rename": "mutation";
47
+ readonly "thread.delete": "mutation";
48
+ readonly "thread.detach": "mutation";
49
+ readonly "thread.capabilities": "query";
50
+ readonly "turn.start": "mutation";
51
+ readonly "turn.cancel": "mutation";
52
+ readonly "approval.respond": "mutation";
53
+ readonly "operation.get": "query";
54
+ readonly "approval.candidate": "mutation";
55
+ };
56
+ export type RelayRequestMethodDisposition = (typeof RELAY_REQUEST_METHOD_DISPOSITIONS)[RelayRequestMethod];
57
+ export declare const RELAY_MUTATION_REQUEST_METHODS: readonly ["thread.create", "thread.rename", "thread.delete", "thread.detach", "turn.start", "turn.cancel", "approval.respond", "approval.candidate"];
58
+ export declare const RELAY_LOCAL_ONLY_REQUEST_METHODS: readonly ["initialize"];
59
+ export declare const RELAY_ERROR_CODES: {
60
+ readonly protocolVersionUnsupported: "RELAY_PROTOCOL_VERSION_UNSUPPORTED";
61
+ readonly invalidFrame: "RELAY_INVALID_FRAME";
62
+ readonly invalidParams: "INVALID_PARAMS";
63
+ readonly requestIdConflict: "RELAY_REQUEST_ID_CONFLICT";
64
+ readonly workspaceNotFound: "WORKSPACE_NOT_FOUND";
65
+ readonly encryptionRequired: "RELAY_ENCRYPTION_REQUIRED";
66
+ readonly encryptedPayloadInvalid: "ENCRYPTED_PAYLOAD_INVALID";
67
+ readonly localApprovalDenied: "LocalApprovalDeniedError";
68
+ readonly localConfirmationRequired: "LocalConfirmationRequiredError";
69
+ readonly companionError: "COMPANION_ERROR";
70
+ };
71
+ export type RelayErrorCode = (typeof RELAY_ERROR_CODES)[keyof typeof RELAY_ERROR_CODES];
72
+ export declare const RELAY_ERROR_RETRYABILITY: {
73
+ readonly RELAY_PROTOCOL_VERSION_UNSUPPORTED: false;
74
+ readonly RELAY_INVALID_FRAME: false;
75
+ readonly INVALID_PARAMS: false;
76
+ readonly RELAY_REQUEST_ID_CONFLICT: false;
77
+ readonly WORKSPACE_NOT_FOUND: false;
78
+ readonly RELAY_ENCRYPTION_REQUIRED: false;
79
+ readonly ENCRYPTED_PAYLOAD_INVALID: false;
80
+ readonly LocalApprovalDeniedError: false;
81
+ readonly LocalConfirmationRequiredError: false;
82
+ readonly COMPANION_ERROR: false;
83
+ };
84
+ export declare function getRelayErrorRetryability(code: RelayErrorCode): boolean;
85
+ export declare const relayProtocolVersionSchema: z.ZodEnum<{
86
+ "1.0": "1.0";
87
+ }>;
88
+ export declare const deviceIdSchema: z.core.$ZodBranded<z.ZodString, "DeviceId">;
89
+ export declare const workspaceIdSchema: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
90
+ export declare const relayRequestIdSchema: z.core.$ZodBranded<z.ZodString, "RelayRequestId">;
91
+ export declare const relayEnvelopeIdSchema: z.ZodString;
92
+ export declare const relayApprovalCandidateParamsSchema: z.ZodReadonly<z.ZodObject<{
93
+ threadId: z.core.$ZodBranded<z.ZodString, "ThreadId">;
94
+ turnId: z.core.$ZodBranded<z.ZodString, "TurnId">;
95
+ approvalId: z.core.$ZodBranded<z.ZodString, "ApprovalId">;
96
+ decision: z.ZodEnum<{
97
+ approve: "approve";
98
+ reject: "reject";
99
+ }>;
100
+ reason: z.ZodOptional<z.ZodString>;
101
+ }, z.core.$strict>>;
102
+ export declare const relayApprovalCandidateResultSchema: z.ZodReadonly<z.ZodObject<{
103
+ accepted: z.ZodLiteral<true>;
104
+ }, z.core.$strict>>;
105
+ export declare const relayRequestMethodSchemas: {
106
+ readonly initialize: {
107
+ readonly params: z.ZodReadonly<z.ZodObject<{
108
+ protocolVersions: z.ZodArray<z.ZodString>;
109
+ client: z.ZodReadonly<z.ZodObject<{
110
+ name: z.ZodString;
111
+ version: z.ZodString;
112
+ }, z.core.$strict>>;
113
+ }, z.core.$strict>>;
114
+ readonly result: z.ZodReadonly<z.ZodObject<{
115
+ protocolVersion: z.ZodEnum<{
116
+ 1.1: "1.1";
117
+ "1.0": "1.0";
118
+ }>;
119
+ runtimeInstanceId: z.core.$ZodBranded<z.ZodString, "RuntimeInstanceId">;
120
+ server: z.ZodReadonly<z.ZodObject<{
121
+ runtimeVersion: z.ZodString;
122
+ name: z.ZodString;
123
+ version: z.ZodString;
124
+ }, z.core.$strict>>;
125
+ features: z.ZodArray<z.ZodEnum<{
126
+ "thread-management": "thread-management";
127
+ snapshots: "snapshots";
128
+ turns: "turns";
129
+ approvals: "approvals";
130
+ "tool-streaming": "tool-streaming";
131
+ "reasoning-summary": "reasoning-summary";
132
+ "operation-projection": "operation-projection";
133
+ "process-local-sequence": "process-local-sequence";
134
+ }>>;
135
+ limits: z.ZodReadonly<z.ZodObject<{
136
+ maxFrameBytes: z.ZodNumber;
137
+ maxPageSize: z.ZodNumber;
138
+ eventReplay: z.ZodLiteral<false>;
139
+ idempotencyCacheEntries: z.ZodNumber;
140
+ }, z.core.$strict>>;
141
+ }, z.core.$strict>>;
142
+ };
143
+ readonly "thread.list": {
144
+ readonly params: z.ZodReadonly<z.ZodObject<{
145
+ cursor: z.ZodOptional<z.ZodString>;
146
+ limit: z.ZodDefault<z.ZodNumber>;
147
+ }, z.core.$strict>>;
148
+ readonly result: z.ZodReadonly<z.ZodObject<{
149
+ items: z.ZodArray<z.ZodReadonly<z.ZodObject<{
150
+ id: z.core.$ZodBranded<z.ZodString, "ThreadId">;
151
+ title: z.ZodOptional<z.ZodString>;
152
+ model: z.ZodOptional<z.ZodString>;
153
+ createdAt: z.ZodString;
154
+ updatedAt: z.ZodString;
155
+ messageCount: z.ZodNumber;
156
+ }, z.core.$strict>>>;
157
+ nextCursor: z.ZodNullable<z.ZodString>;
158
+ }, z.core.$strict>>;
159
+ };
160
+ readonly "thread.create": {
161
+ readonly params: z.ZodReadonly<z.ZodObject<{
162
+ title: z.ZodOptional<z.ZodString>;
163
+ requestId: z.core.$ZodBranded<z.ZodString, "RequestId">;
164
+ }, z.core.$strict>>;
165
+ readonly result: z.ZodReadonly<z.ZodObject<{
166
+ thread: z.ZodReadonly<z.ZodObject<{
167
+ id: z.core.$ZodBranded<z.ZodString, "ThreadId">;
168
+ title: z.ZodOptional<z.ZodString>;
169
+ model: z.ZodOptional<z.ZodString>;
170
+ createdAt: z.ZodString;
171
+ updatedAt: z.ZodString;
172
+ messageCount: z.ZodNumber;
173
+ }, z.core.$strict>>;
174
+ }, z.core.$strict>>;
175
+ };
176
+ readonly "thread.open": {
177
+ readonly params: z.ZodReadonly<z.ZodObject<{
178
+ threadId: z.core.$ZodBranded<z.ZodString, "ThreadId">;
179
+ }, z.core.$strict>>;
180
+ readonly result: z.ZodReadonly<z.ZodObject<{
181
+ thread: z.ZodReadonly<z.ZodObject<{
182
+ id: z.core.$ZodBranded<z.ZodString, "ThreadId">;
183
+ title: z.ZodOptional<z.ZodString>;
184
+ model: z.ZodOptional<z.ZodString>;
185
+ createdAt: z.ZodString;
186
+ updatedAt: z.ZodString;
187
+ messageCount: z.ZodNumber;
188
+ }, z.core.$strict>>;
189
+ messages: z.ZodReadonly<z.ZodObject<{
190
+ items: z.ZodArray<z.ZodReadonly<z.ZodObject<{
191
+ sequence: z.ZodNumber;
192
+ role: z.ZodEnum<{
193
+ user: "user";
194
+ assistant: "assistant";
195
+ }>;
196
+ createdAt: z.ZodString;
197
+ parts: z.ZodArray<z.ZodReadonly<z.ZodObject<{
198
+ type: z.ZodLiteral<"text">;
199
+ text: z.ZodString;
200
+ }, z.core.$strict>>>;
201
+ }, z.core.$strict>>>;
202
+ nextBeforeSequence: z.ZodNullable<z.ZodNumber>;
203
+ }, z.core.$strict>>;
204
+ operations: z.ZodReadonly<z.ZodObject<{
205
+ items: z.ZodArray<z.ZodReadonly<z.ZodObject<{
206
+ id: z.core.$ZodBranded<z.ZodString, "OperationId">;
207
+ sequence: z.ZodNumber;
208
+ toolCallId: z.ZodString;
209
+ agentName: z.ZodString;
210
+ toolName: z.ZodString;
211
+ createdAt: z.ZodString;
212
+ outcome: z.ZodReadonly<z.ZodObject<{
213
+ kind: z.ZodEnum<{
214
+ success: "success";
215
+ user_rejected: "user_rejected";
216
+ policy_denied: "policy_denied";
217
+ invalid_input: "invalid_input";
218
+ cancelled: "cancelled";
219
+ tool_failed: "tool_failed";
220
+ }>;
221
+ reason: z.ZodOptional<z.ZodString>;
222
+ }, z.core.$strict>>;
223
+ display: z.ZodJSONSchema;
224
+ }, z.core.$strict>>>;
225
+ nextBeforeSequence: z.ZodNullable<z.ZodNumber>;
226
+ }, z.core.$strict>>;
227
+ activeTurn: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
228
+ id: z.core.$ZodBranded<z.ZodString, "TurnId">;
229
+ status: z.ZodEnum<{
230
+ running: "running";
231
+ cancelling: "cancelling";
232
+ }>;
233
+ startedAt: z.ZodString;
234
+ }, z.core.$strict>>>;
235
+ pendingApprovals: z.ZodArray<z.ZodReadonly<z.ZodObject<{
236
+ id: z.core.$ZodBranded<z.ZodString, "ApprovalId">;
237
+ turnId: z.core.$ZodBranded<z.ZodString, "TurnId">;
238
+ agentName: z.ZodString;
239
+ toolName: z.ZodString;
240
+ preview: z.ZodJSONSchema;
241
+ reason: z.ZodOptional<z.ZodString>;
242
+ }, z.core.$strict>>>;
243
+ transcriptCompleteness: z.ZodEnum<{
244
+ complete: "complete";
245
+ legacy_snapshot: "legacy_snapshot";
246
+ }>;
247
+ }, z.core.$strict>>;
248
+ };
249
+ readonly "thread.snapshot": {
250
+ readonly params: z.ZodReadonly<z.ZodObject<{
251
+ messageBeforeSequence: z.ZodOptional<z.ZodNumber>;
252
+ operationBeforeSequence: z.ZodOptional<z.ZodNumber>;
253
+ limit: z.ZodDefault<z.ZodNumber>;
254
+ threadId: z.core.$ZodBranded<z.ZodString, "ThreadId">;
255
+ }, z.core.$strict>>;
256
+ readonly result: z.ZodReadonly<z.ZodObject<{
257
+ thread: z.ZodReadonly<z.ZodObject<{
258
+ id: z.core.$ZodBranded<z.ZodString, "ThreadId">;
259
+ title: z.ZodOptional<z.ZodString>;
260
+ model: z.ZodOptional<z.ZodString>;
261
+ createdAt: z.ZodString;
262
+ updatedAt: z.ZodString;
263
+ messageCount: z.ZodNumber;
264
+ }, z.core.$strict>>;
265
+ messages: z.ZodReadonly<z.ZodObject<{
266
+ items: z.ZodArray<z.ZodReadonly<z.ZodObject<{
267
+ sequence: z.ZodNumber;
268
+ role: z.ZodEnum<{
269
+ user: "user";
270
+ assistant: "assistant";
271
+ }>;
272
+ createdAt: z.ZodString;
273
+ parts: z.ZodArray<z.ZodReadonly<z.ZodObject<{
274
+ type: z.ZodLiteral<"text">;
275
+ text: z.ZodString;
276
+ }, z.core.$strict>>>;
277
+ }, z.core.$strict>>>;
278
+ nextBeforeSequence: z.ZodNullable<z.ZodNumber>;
279
+ }, z.core.$strict>>;
280
+ operations: z.ZodReadonly<z.ZodObject<{
281
+ items: z.ZodArray<z.ZodReadonly<z.ZodObject<{
282
+ id: z.core.$ZodBranded<z.ZodString, "OperationId">;
283
+ sequence: z.ZodNumber;
284
+ toolCallId: z.ZodString;
285
+ agentName: z.ZodString;
286
+ toolName: z.ZodString;
287
+ createdAt: z.ZodString;
288
+ outcome: z.ZodReadonly<z.ZodObject<{
289
+ kind: z.ZodEnum<{
290
+ success: "success";
291
+ user_rejected: "user_rejected";
292
+ policy_denied: "policy_denied";
293
+ invalid_input: "invalid_input";
294
+ cancelled: "cancelled";
295
+ tool_failed: "tool_failed";
296
+ }>;
297
+ reason: z.ZodOptional<z.ZodString>;
298
+ }, z.core.$strict>>;
299
+ display: z.ZodJSONSchema;
300
+ }, z.core.$strict>>>;
301
+ nextBeforeSequence: z.ZodNullable<z.ZodNumber>;
302
+ }, z.core.$strict>>;
303
+ activeTurn: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
304
+ id: z.core.$ZodBranded<z.ZodString, "TurnId">;
305
+ status: z.ZodEnum<{
306
+ running: "running";
307
+ cancelling: "cancelling";
308
+ }>;
309
+ startedAt: z.ZodString;
310
+ }, z.core.$strict>>>;
311
+ pendingApprovals: z.ZodArray<z.ZodReadonly<z.ZodObject<{
312
+ id: z.core.$ZodBranded<z.ZodString, "ApprovalId">;
313
+ turnId: z.core.$ZodBranded<z.ZodString, "TurnId">;
314
+ agentName: z.ZodString;
315
+ toolName: z.ZodString;
316
+ preview: z.ZodJSONSchema;
317
+ reason: z.ZodOptional<z.ZodString>;
318
+ }, z.core.$strict>>>;
319
+ transcriptCompleteness: z.ZodEnum<{
320
+ complete: "complete";
321
+ legacy_snapshot: "legacy_snapshot";
322
+ }>;
323
+ }, z.core.$strict>>;
324
+ };
325
+ readonly "thread.rename": {
326
+ readonly params: z.ZodReadonly<z.ZodObject<{
327
+ title: z.ZodString;
328
+ threadId: z.core.$ZodBranded<z.ZodString, "ThreadId">;
329
+ requestId: z.core.$ZodBranded<z.ZodString, "RequestId">;
330
+ }, z.core.$strict>>;
331
+ readonly result: z.ZodReadonly<z.ZodObject<{
332
+ thread: z.ZodReadonly<z.ZodObject<{
333
+ id: z.core.$ZodBranded<z.ZodString, "ThreadId">;
334
+ title: z.ZodOptional<z.ZodString>;
335
+ model: z.ZodOptional<z.ZodString>;
336
+ createdAt: z.ZodString;
337
+ updatedAt: z.ZodString;
338
+ messageCount: z.ZodNumber;
339
+ }, z.core.$strict>>;
340
+ }, z.core.$strict>>;
341
+ };
342
+ readonly "thread.delete": {
343
+ readonly params: z.ZodReadonly<z.ZodObject<{
344
+ threadId: z.core.$ZodBranded<z.ZodString, "ThreadId">;
345
+ requestId: z.core.$ZodBranded<z.ZodString, "RequestId">;
346
+ }, z.core.$strict>>;
347
+ readonly result: z.ZodReadonly<z.ZodObject<{
348
+ deleted: z.ZodLiteral<true>;
349
+ }, z.core.$strict>>;
350
+ };
351
+ readonly "thread.detach": {
352
+ readonly params: z.ZodReadonly<z.ZodObject<{
353
+ threadId: z.core.$ZodBranded<z.ZodString, "ThreadId">;
354
+ requestId: z.core.$ZodBranded<z.ZodString, "RequestId">;
355
+ }, z.core.$strict>>;
356
+ readonly result: z.ZodReadonly<z.ZodObject<{
357
+ detached: z.ZodBoolean;
358
+ }, z.core.$strict>>;
359
+ };
360
+ readonly "thread.capabilities": {
361
+ readonly params: z.ZodReadonly<z.ZodObject<{
362
+ threadId: z.core.$ZodBranded<z.ZodString, "ThreadId">;
363
+ }, z.core.$strict>>;
364
+ readonly result: z.ZodReadonly<z.ZodObject<{
365
+ manifest: z.ZodJSONSchema;
366
+ }, z.core.$strict>>;
367
+ };
368
+ readonly "turn.start": {
369
+ readonly params: z.ZodReadonly<z.ZodObject<{
370
+ turnId: z.core.$ZodBranded<z.ZodString, "TurnId">;
371
+ input: z.ZodReadonly<z.ZodObject<{
372
+ text: z.ZodString;
373
+ }, z.core.$strict>>;
374
+ threadId: z.core.$ZodBranded<z.ZodString, "ThreadId">;
375
+ requestId: z.core.$ZodBranded<z.ZodString, "RequestId">;
376
+ }, z.core.$strict>>;
377
+ readonly result: z.ZodReadonly<z.ZodObject<{
378
+ accepted: z.ZodLiteral<true>;
379
+ turnId: z.core.$ZodBranded<z.ZodString, "TurnId">;
380
+ }, z.core.$strict>>;
381
+ };
382
+ readonly "turn.cancel": {
383
+ readonly params: z.ZodReadonly<z.ZodObject<{
384
+ turnId: z.core.$ZodBranded<z.ZodString, "TurnId">;
385
+ threadId: z.core.$ZodBranded<z.ZodString, "ThreadId">;
386
+ requestId: z.core.$ZodBranded<z.ZodString, "RequestId">;
387
+ }, z.core.$strict>>;
388
+ readonly result: z.ZodReadonly<z.ZodObject<{
389
+ cancelling: z.ZodBoolean;
390
+ }, z.core.$strict>>;
391
+ };
392
+ readonly "approval.respond": {
393
+ readonly params: z.ZodReadonly<z.ZodObject<{
394
+ turnId: z.core.$ZodBranded<z.ZodString, "TurnId">;
395
+ approvalId: z.core.$ZodBranded<z.ZodString, "ApprovalId">;
396
+ decision: z.ZodEnum<{
397
+ approve: "approve";
398
+ reject: "reject";
399
+ }>;
400
+ reason: z.ZodOptional<z.ZodString>;
401
+ threadId: z.core.$ZodBranded<z.ZodString, "ThreadId">;
402
+ requestId: z.core.$ZodBranded<z.ZodString, "RequestId">;
403
+ }, z.core.$strict>>;
404
+ readonly result: z.ZodReadonly<z.ZodObject<{
405
+ resolved: z.ZodLiteral<true>;
406
+ }, z.core.$strict>>;
407
+ };
408
+ readonly "operation.get": {
409
+ readonly params: z.ZodReadonly<z.ZodObject<{
410
+ operationId: z.core.$ZodBranded<z.ZodString, "OperationId">;
411
+ threadId: z.core.$ZodBranded<z.ZodString, "ThreadId">;
412
+ }, z.core.$strict>>;
413
+ readonly result: z.ZodReadonly<z.ZodObject<{
414
+ operation: z.ZodNullable<z.ZodReadonly<z.ZodObject<{
415
+ id: z.core.$ZodBranded<z.ZodString, "OperationId">;
416
+ sequence: z.ZodNumber;
417
+ toolCallId: z.ZodString;
418
+ agentName: z.ZodString;
419
+ toolName: z.ZodString;
420
+ createdAt: z.ZodString;
421
+ outcome: z.ZodReadonly<z.ZodObject<{
422
+ kind: z.ZodEnum<{
423
+ success: "success";
424
+ user_rejected: "user_rejected";
425
+ policy_denied: "policy_denied";
426
+ invalid_input: "invalid_input";
427
+ cancelled: "cancelled";
428
+ tool_failed: "tool_failed";
429
+ }>;
430
+ reason: z.ZodOptional<z.ZodString>;
431
+ }, z.core.$strict>>;
432
+ display: z.ZodJSONSchema;
433
+ }, z.core.$strict>>>;
434
+ }, z.core.$strict>>;
435
+ };
436
+ readonly "approval.candidate": {
437
+ readonly params: z.ZodReadonly<z.ZodObject<{
438
+ threadId: z.core.$ZodBranded<z.ZodString, "ThreadId">;
439
+ turnId: z.core.$ZodBranded<z.ZodString, "TurnId">;
440
+ approvalId: z.core.$ZodBranded<z.ZodString, "ApprovalId">;
441
+ decision: z.ZodEnum<{
442
+ approve: "approve";
443
+ reject: "reject";
444
+ }>;
445
+ reason: z.ZodOptional<z.ZodString>;
446
+ }, z.core.$strict>>;
447
+ readonly result: z.ZodReadonly<z.ZodObject<{
448
+ accepted: z.ZodLiteral<true>;
449
+ }, z.core.$strict>>;
450
+ };
451
+ };
452
+ export type RelayRequestParams<TMethod extends RelayRequestMethod> = z.infer<(typeof relayRequestMethodSchemas)[TMethod]["params"]>;
453
+ export type RelayRequestResult<TMethod extends RelayRequestMethod> = z.infer<(typeof relayRequestMethodSchemas)[TMethod]["result"]>;
454
+ export declare function isRelayRequestMethod(value: string): value is RelayRequestMethod;
455
+ export declare function getRelayRequestMethodDisposition(value: string): RelayRequestMethodDisposition | undefined;
456
+ export declare function isRelayMutationRequestMethod(method: RelayRequestMethod): method is (typeof RELAY_MUTATION_REQUEST_METHODS)[number];
457
+ export declare function parseRelayRequestParams<TMethod extends RelayRequestMethod>(method: TMethod, value: unknown): RelayRequestParams<TMethod>;
458
+ export declare function parseRelayRequestResult<TMethod extends RelayRequestMethod>(method: TMethod, value: unknown): RelayRequestResult<TMethod>;
459
+ export declare const relayDeviceConnectSchema: z.ZodReadonly<z.ZodObject<{
460
+ type: z.ZodLiteral<"device.connect">;
461
+ protocolVersion: z.ZodLiteral<"1.0">;
462
+ deviceId: z.core.$ZodBranded<z.ZodString, "DeviceId">;
463
+ pairingToken: z.ZodString;
464
+ }, z.core.$strict>>;
465
+ export declare const relayRuntimeRequestSchema: z.ZodReadonly<z.ZodObject<{
466
+ type: z.ZodLiteral<"runtime.request">;
467
+ requestId: z.core.$ZodBranded<z.ZodString, "RelayRequestId">;
468
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
469
+ method: z.ZodEnum<{
470
+ initialize: "initialize";
471
+ "thread.list": "thread.list";
472
+ "thread.create": "thread.create";
473
+ "thread.open": "thread.open";
474
+ "thread.snapshot": "thread.snapshot";
475
+ "thread.rename": "thread.rename";
476
+ "thread.delete": "thread.delete";
477
+ "thread.detach": "thread.detach";
478
+ "thread.capabilities": "thread.capabilities";
479
+ "turn.start": "turn.start";
480
+ "turn.cancel": "turn.cancel";
481
+ "approval.respond": "approval.respond";
482
+ "operation.get": "operation.get";
483
+ "approval.candidate": "approval.candidate";
484
+ }>;
485
+ params: z.ZodJSONSchema;
486
+ }, z.core.$strict>>;
487
+ export declare const relayErrorSchema: z.ZodReadonly<z.ZodObject<{
488
+ code: z.ZodString;
489
+ message: z.ZodString;
490
+ retryable: z.ZodBoolean;
491
+ }, z.core.$strict>>;
492
+ /**
493
+ * This preserves the pre-freeze v1.0 shape: result/error are independently optional.
494
+ * A strict exactly-one response belongs in a later Relay Wire version.
495
+ */
496
+ export declare const relayRuntimeResponseSchema: z.ZodReadonly<z.ZodObject<{
497
+ type: z.ZodLiteral<"runtime.response">;
498
+ requestId: z.core.$ZodBranded<z.ZodString, "RelayRequestId">;
499
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
500
+ result: z.ZodOptional<z.ZodJSONSchema>;
501
+ error: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
502
+ code: z.ZodString;
503
+ message: z.ZodString;
504
+ retryable: z.ZodBoolean;
505
+ }, z.core.$strict>>>;
506
+ }, z.core.$strict>>;
507
+ export declare const relayRuntimeEventSchema: z.ZodReadonly<z.ZodObject<{
508
+ type: z.ZodLiteral<"runtime.event">;
509
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
510
+ relaySequence: z.ZodNumber;
511
+ event: z.ZodReadonly<z.ZodObject<{
512
+ protocolVersion: z.ZodEnum<{
513
+ 1.1: "1.1";
514
+ "1.0": "1.0";
515
+ }>;
516
+ runtimeInstanceId: z.core.$ZodBranded<z.ZodString, "RuntimeInstanceId">;
517
+ sequence: z.ZodNumber;
518
+ timestamp: z.ZodString;
519
+ threadId: z.core.$ZodBranded<z.ZodString, "ThreadId">;
520
+ turnId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "TurnId">>;
521
+ event: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
522
+ type: z.ZodLiteral<"turn.started">;
523
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
524
+ type: z.ZodLiteral<"message.started">;
525
+ streamId: z.core.$ZodBranded<z.ZodString, "StreamId">;
526
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
527
+ type: z.ZodLiteral<"message.delta">;
528
+ streamId: z.core.$ZodBranded<z.ZodString, "StreamId">;
529
+ delta: z.ZodString;
530
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
531
+ type: z.ZodLiteral<"message.completed">;
532
+ streamId: z.core.$ZodBranded<z.ZodString, "StreamId">;
533
+ text: z.ZodString;
534
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
535
+ type: z.ZodLiteral<"reasoning.summary.delta">;
536
+ reasoningId: z.ZodString;
537
+ delta: z.ZodString;
538
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
539
+ type: z.ZodLiteral<"tool.started">;
540
+ toolCallId: z.ZodString;
541
+ agentName: z.ZodString;
542
+ toolName: z.ZodString;
543
+ input: z.ZodJSONSchema;
544
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
545
+ type: z.ZodLiteral<"tool.output">;
546
+ toolCallId: z.ZodString;
547
+ agentName: z.ZodString;
548
+ toolName: z.ZodString;
549
+ stream: z.ZodEnum<{
550
+ stdout: "stdout";
551
+ stderr: "stderr";
552
+ }>;
553
+ delta: z.ZodString;
554
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
555
+ type: z.ZodLiteral<"tool.completed">;
556
+ toolCallId: z.ZodString;
557
+ agentName: z.ZodString;
558
+ toolName: z.ZodString;
559
+ operationId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "OperationId">>;
560
+ outcome: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
561
+ kind: z.ZodEnum<{
562
+ success: "success";
563
+ user_rejected: "user_rejected";
564
+ policy_denied: "policy_denied";
565
+ invalid_input: "invalid_input";
566
+ cancelled: "cancelled";
567
+ tool_failed: "tool_failed";
568
+ }>;
569
+ reason: z.ZodOptional<z.ZodString>;
570
+ }, z.core.$strict>>>;
571
+ display: z.ZodJSONSchema;
572
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
573
+ type: z.ZodLiteral<"approval.required">;
574
+ approval: z.ZodReadonly<z.ZodObject<{
575
+ id: z.core.$ZodBranded<z.ZodString, "ApprovalId">;
576
+ turnId: z.core.$ZodBranded<z.ZodString, "TurnId">;
577
+ agentName: z.ZodString;
578
+ toolName: z.ZodString;
579
+ preview: z.ZodJSONSchema;
580
+ reason: z.ZodOptional<z.ZodString>;
581
+ }, z.core.$strict>>;
582
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
583
+ type: z.ZodLiteral<"approval.resolved">;
584
+ approvalId: z.core.$ZodBranded<z.ZodString, "ApprovalId">;
585
+ resolution: z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
586
+ status: z.ZodLiteral<"resolved">;
587
+ decision: z.ZodLiteral<"approve">;
588
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
589
+ status: z.ZodLiteral<"resolved">;
590
+ decision: z.ZodLiteral<"reject">;
591
+ reason: z.ZodOptional<z.ZodString>;
592
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
593
+ status: z.ZodLiteral<"cancelled">;
594
+ reason: z.ZodString;
595
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
596
+ status: z.ZodLiteral<"expired">;
597
+ reason: z.ZodOptional<z.ZodString>;
598
+ }, z.core.$strict>>]>;
599
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
600
+ type: z.ZodLiteral<"turn.completed">;
601
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
602
+ type: z.ZodLiteral<"turn.cancelled">;
603
+ reason: z.ZodString;
604
+ message: z.ZodString;
605
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
606
+ type: z.ZodLiteral<"turn.failed">;
607
+ stage: z.ZodEnum<{
608
+ bootstrap: "bootstrap";
609
+ plan: "plan";
610
+ execute: "execute";
611
+ }>;
612
+ message: z.ZodString;
613
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
614
+ type: z.ZodLiteral<"capabilities.changed">;
615
+ }, z.core.$strict>>]>;
616
+ }, z.core.$strict>>;
617
+ }, z.core.$strict>>;
618
+ export declare const relayAckSchema: z.ZodReadonly<z.ZodObject<{
619
+ type: z.ZodLiteral<"runtime.ack">;
620
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
621
+ throughRelaySequence: z.ZodNumber;
622
+ }, z.core.$strict>>;
623
+ export declare const relayGapSchema: z.ZodReadonly<z.ZodObject<{
624
+ type: z.ZodLiteral<"runtime.gap">;
625
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
626
+ fromRelaySequence: z.ZodNumber;
627
+ throughRelaySequence: z.ZodNumber;
628
+ recovery: z.ZodLiteral<"thread.snapshot">;
629
+ }, z.core.$strict>>;
630
+ /**
631
+ * This preserves the pre-freeze v1.0 metadata shape. Payload-kind-specific required
632
+ * fields must be introduced under a later Relay Wire version.
633
+ */
634
+ export declare const relayEncryptedMessageSchema: z.ZodReadonly<z.ZodObject<{
635
+ type: z.ZodLiteral<"runtime.encrypted">;
636
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
637
+ envelopeId: z.ZodString;
638
+ payloadKind: z.ZodEnum<{
639
+ event: "event";
640
+ request: "request";
641
+ response: "response";
642
+ }>;
643
+ requestId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "RelayRequestId">>;
644
+ relaySequence: z.ZodOptional<z.ZodNumber>;
645
+ algorithm: z.ZodString;
646
+ nonce: z.ZodString;
647
+ ciphertext: z.ZodString;
648
+ }, z.core.$strict>>;
649
+ export declare const relayMessageSchemas: {
650
+ readonly "device.connect": z.ZodReadonly<z.ZodObject<{
651
+ type: z.ZodLiteral<"device.connect">;
652
+ protocolVersion: z.ZodLiteral<"1.0">;
653
+ deviceId: z.core.$ZodBranded<z.ZodString, "DeviceId">;
654
+ pairingToken: z.ZodString;
655
+ }, z.core.$strict>>;
656
+ readonly "runtime.request": z.ZodReadonly<z.ZodObject<{
657
+ type: z.ZodLiteral<"runtime.request">;
658
+ requestId: z.core.$ZodBranded<z.ZodString, "RelayRequestId">;
659
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
660
+ method: z.ZodEnum<{
661
+ initialize: "initialize";
662
+ "thread.list": "thread.list";
663
+ "thread.create": "thread.create";
664
+ "thread.open": "thread.open";
665
+ "thread.snapshot": "thread.snapshot";
666
+ "thread.rename": "thread.rename";
667
+ "thread.delete": "thread.delete";
668
+ "thread.detach": "thread.detach";
669
+ "thread.capabilities": "thread.capabilities";
670
+ "turn.start": "turn.start";
671
+ "turn.cancel": "turn.cancel";
672
+ "approval.respond": "approval.respond";
673
+ "operation.get": "operation.get";
674
+ "approval.candidate": "approval.candidate";
675
+ }>;
676
+ params: z.ZodJSONSchema;
677
+ }, z.core.$strict>>;
678
+ readonly "runtime.response": z.ZodReadonly<z.ZodObject<{
679
+ type: z.ZodLiteral<"runtime.response">;
680
+ requestId: z.core.$ZodBranded<z.ZodString, "RelayRequestId">;
681
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
682
+ result: z.ZodOptional<z.ZodJSONSchema>;
683
+ error: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
684
+ code: z.ZodString;
685
+ message: z.ZodString;
686
+ retryable: z.ZodBoolean;
687
+ }, z.core.$strict>>>;
688
+ }, z.core.$strict>>;
689
+ readonly "runtime.event": z.ZodReadonly<z.ZodObject<{
690
+ type: z.ZodLiteral<"runtime.event">;
691
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
692
+ relaySequence: z.ZodNumber;
693
+ event: z.ZodReadonly<z.ZodObject<{
694
+ protocolVersion: z.ZodEnum<{
695
+ 1.1: "1.1";
696
+ "1.0": "1.0";
697
+ }>;
698
+ runtimeInstanceId: z.core.$ZodBranded<z.ZodString, "RuntimeInstanceId">;
699
+ sequence: z.ZodNumber;
700
+ timestamp: z.ZodString;
701
+ threadId: z.core.$ZodBranded<z.ZodString, "ThreadId">;
702
+ turnId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "TurnId">>;
703
+ event: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
704
+ type: z.ZodLiteral<"turn.started">;
705
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
706
+ type: z.ZodLiteral<"message.started">;
707
+ streamId: z.core.$ZodBranded<z.ZodString, "StreamId">;
708
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
709
+ type: z.ZodLiteral<"message.delta">;
710
+ streamId: z.core.$ZodBranded<z.ZodString, "StreamId">;
711
+ delta: z.ZodString;
712
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
713
+ type: z.ZodLiteral<"message.completed">;
714
+ streamId: z.core.$ZodBranded<z.ZodString, "StreamId">;
715
+ text: z.ZodString;
716
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
717
+ type: z.ZodLiteral<"reasoning.summary.delta">;
718
+ reasoningId: z.ZodString;
719
+ delta: z.ZodString;
720
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
721
+ type: z.ZodLiteral<"tool.started">;
722
+ toolCallId: z.ZodString;
723
+ agentName: z.ZodString;
724
+ toolName: z.ZodString;
725
+ input: z.ZodJSONSchema;
726
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
727
+ type: z.ZodLiteral<"tool.output">;
728
+ toolCallId: z.ZodString;
729
+ agentName: z.ZodString;
730
+ toolName: z.ZodString;
731
+ stream: z.ZodEnum<{
732
+ stdout: "stdout";
733
+ stderr: "stderr";
734
+ }>;
735
+ delta: z.ZodString;
736
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
737
+ type: z.ZodLiteral<"tool.completed">;
738
+ toolCallId: z.ZodString;
739
+ agentName: z.ZodString;
740
+ toolName: z.ZodString;
741
+ operationId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "OperationId">>;
742
+ outcome: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
743
+ kind: z.ZodEnum<{
744
+ success: "success";
745
+ user_rejected: "user_rejected";
746
+ policy_denied: "policy_denied";
747
+ invalid_input: "invalid_input";
748
+ cancelled: "cancelled";
749
+ tool_failed: "tool_failed";
750
+ }>;
751
+ reason: z.ZodOptional<z.ZodString>;
752
+ }, z.core.$strict>>>;
753
+ display: z.ZodJSONSchema;
754
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
755
+ type: z.ZodLiteral<"approval.required">;
756
+ approval: z.ZodReadonly<z.ZodObject<{
757
+ id: z.core.$ZodBranded<z.ZodString, "ApprovalId">;
758
+ turnId: z.core.$ZodBranded<z.ZodString, "TurnId">;
759
+ agentName: z.ZodString;
760
+ toolName: z.ZodString;
761
+ preview: z.ZodJSONSchema;
762
+ reason: z.ZodOptional<z.ZodString>;
763
+ }, z.core.$strict>>;
764
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
765
+ type: z.ZodLiteral<"approval.resolved">;
766
+ approvalId: z.core.$ZodBranded<z.ZodString, "ApprovalId">;
767
+ resolution: z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
768
+ status: z.ZodLiteral<"resolved">;
769
+ decision: z.ZodLiteral<"approve">;
770
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
771
+ status: z.ZodLiteral<"resolved">;
772
+ decision: z.ZodLiteral<"reject">;
773
+ reason: z.ZodOptional<z.ZodString>;
774
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
775
+ status: z.ZodLiteral<"cancelled">;
776
+ reason: z.ZodString;
777
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
778
+ status: z.ZodLiteral<"expired">;
779
+ reason: z.ZodOptional<z.ZodString>;
780
+ }, z.core.$strict>>]>;
781
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
782
+ type: z.ZodLiteral<"turn.completed">;
783
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
784
+ type: z.ZodLiteral<"turn.cancelled">;
785
+ reason: z.ZodString;
786
+ message: z.ZodString;
787
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
788
+ type: z.ZodLiteral<"turn.failed">;
789
+ stage: z.ZodEnum<{
790
+ bootstrap: "bootstrap";
791
+ plan: "plan";
792
+ execute: "execute";
793
+ }>;
794
+ message: z.ZodString;
795
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
796
+ type: z.ZodLiteral<"capabilities.changed">;
797
+ }, z.core.$strict>>]>;
798
+ }, z.core.$strict>>;
799
+ }, z.core.$strict>>;
800
+ readonly "runtime.ack": z.ZodReadonly<z.ZodObject<{
801
+ type: z.ZodLiteral<"runtime.ack">;
802
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
803
+ throughRelaySequence: z.ZodNumber;
804
+ }, z.core.$strict>>;
805
+ readonly "runtime.gap": z.ZodReadonly<z.ZodObject<{
806
+ type: z.ZodLiteral<"runtime.gap">;
807
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
808
+ fromRelaySequence: z.ZodNumber;
809
+ throughRelaySequence: z.ZodNumber;
810
+ recovery: z.ZodLiteral<"thread.snapshot">;
811
+ }, z.core.$strict>>;
812
+ readonly "runtime.encrypted": z.ZodReadonly<z.ZodObject<{
813
+ type: z.ZodLiteral<"runtime.encrypted">;
814
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
815
+ envelopeId: z.ZodString;
816
+ payloadKind: z.ZodEnum<{
817
+ event: "event";
818
+ request: "request";
819
+ response: "response";
820
+ }>;
821
+ requestId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "RelayRequestId">>;
822
+ relaySequence: z.ZodOptional<z.ZodNumber>;
823
+ algorithm: z.ZodString;
824
+ nonce: z.ZodString;
825
+ ciphertext: z.ZodString;
826
+ }, z.core.$strict>>;
827
+ };
828
+ export declare const relayMessageSchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
829
+ type: z.ZodLiteral<"device.connect">;
830
+ protocolVersion: z.ZodLiteral<"1.0">;
831
+ deviceId: z.core.$ZodBranded<z.ZodString, "DeviceId">;
832
+ pairingToken: z.ZodString;
833
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
834
+ type: z.ZodLiteral<"runtime.request">;
835
+ requestId: z.core.$ZodBranded<z.ZodString, "RelayRequestId">;
836
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
837
+ method: z.ZodEnum<{
838
+ initialize: "initialize";
839
+ "thread.list": "thread.list";
840
+ "thread.create": "thread.create";
841
+ "thread.open": "thread.open";
842
+ "thread.snapshot": "thread.snapshot";
843
+ "thread.rename": "thread.rename";
844
+ "thread.delete": "thread.delete";
845
+ "thread.detach": "thread.detach";
846
+ "thread.capabilities": "thread.capabilities";
847
+ "turn.start": "turn.start";
848
+ "turn.cancel": "turn.cancel";
849
+ "approval.respond": "approval.respond";
850
+ "operation.get": "operation.get";
851
+ "approval.candidate": "approval.candidate";
852
+ }>;
853
+ params: z.ZodJSONSchema;
854
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
855
+ type: z.ZodLiteral<"runtime.response">;
856
+ requestId: z.core.$ZodBranded<z.ZodString, "RelayRequestId">;
857
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
858
+ result: z.ZodOptional<z.ZodJSONSchema>;
859
+ error: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
860
+ code: z.ZodString;
861
+ message: z.ZodString;
862
+ retryable: z.ZodBoolean;
863
+ }, z.core.$strict>>>;
864
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
865
+ type: z.ZodLiteral<"runtime.event">;
866
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
867
+ relaySequence: z.ZodNumber;
868
+ event: z.ZodReadonly<z.ZodObject<{
869
+ protocolVersion: z.ZodEnum<{
870
+ 1.1: "1.1";
871
+ "1.0": "1.0";
872
+ }>;
873
+ runtimeInstanceId: z.core.$ZodBranded<z.ZodString, "RuntimeInstanceId">;
874
+ sequence: z.ZodNumber;
875
+ timestamp: z.ZodString;
876
+ threadId: z.core.$ZodBranded<z.ZodString, "ThreadId">;
877
+ turnId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "TurnId">>;
878
+ event: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
879
+ type: z.ZodLiteral<"turn.started">;
880
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
881
+ type: z.ZodLiteral<"message.started">;
882
+ streamId: z.core.$ZodBranded<z.ZodString, "StreamId">;
883
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
884
+ type: z.ZodLiteral<"message.delta">;
885
+ streamId: z.core.$ZodBranded<z.ZodString, "StreamId">;
886
+ delta: z.ZodString;
887
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
888
+ type: z.ZodLiteral<"message.completed">;
889
+ streamId: z.core.$ZodBranded<z.ZodString, "StreamId">;
890
+ text: z.ZodString;
891
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
892
+ type: z.ZodLiteral<"reasoning.summary.delta">;
893
+ reasoningId: z.ZodString;
894
+ delta: z.ZodString;
895
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
896
+ type: z.ZodLiteral<"tool.started">;
897
+ toolCallId: z.ZodString;
898
+ agentName: z.ZodString;
899
+ toolName: z.ZodString;
900
+ input: z.ZodJSONSchema;
901
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
902
+ type: z.ZodLiteral<"tool.output">;
903
+ toolCallId: z.ZodString;
904
+ agentName: z.ZodString;
905
+ toolName: z.ZodString;
906
+ stream: z.ZodEnum<{
907
+ stdout: "stdout";
908
+ stderr: "stderr";
909
+ }>;
910
+ delta: z.ZodString;
911
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
912
+ type: z.ZodLiteral<"tool.completed">;
913
+ toolCallId: z.ZodString;
914
+ agentName: z.ZodString;
915
+ toolName: z.ZodString;
916
+ operationId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "OperationId">>;
917
+ outcome: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
918
+ kind: z.ZodEnum<{
919
+ success: "success";
920
+ user_rejected: "user_rejected";
921
+ policy_denied: "policy_denied";
922
+ invalid_input: "invalid_input";
923
+ cancelled: "cancelled";
924
+ tool_failed: "tool_failed";
925
+ }>;
926
+ reason: z.ZodOptional<z.ZodString>;
927
+ }, z.core.$strict>>>;
928
+ display: z.ZodJSONSchema;
929
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
930
+ type: z.ZodLiteral<"approval.required">;
931
+ approval: z.ZodReadonly<z.ZodObject<{
932
+ id: z.core.$ZodBranded<z.ZodString, "ApprovalId">;
933
+ turnId: z.core.$ZodBranded<z.ZodString, "TurnId">;
934
+ agentName: z.ZodString;
935
+ toolName: z.ZodString;
936
+ preview: z.ZodJSONSchema;
937
+ reason: z.ZodOptional<z.ZodString>;
938
+ }, z.core.$strict>>;
939
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
940
+ type: z.ZodLiteral<"approval.resolved">;
941
+ approvalId: z.core.$ZodBranded<z.ZodString, "ApprovalId">;
942
+ resolution: z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
943
+ status: z.ZodLiteral<"resolved">;
944
+ decision: z.ZodLiteral<"approve">;
945
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
946
+ status: z.ZodLiteral<"resolved">;
947
+ decision: z.ZodLiteral<"reject">;
948
+ reason: z.ZodOptional<z.ZodString>;
949
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
950
+ status: z.ZodLiteral<"cancelled">;
951
+ reason: z.ZodString;
952
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
953
+ status: z.ZodLiteral<"expired">;
954
+ reason: z.ZodOptional<z.ZodString>;
955
+ }, z.core.$strict>>]>;
956
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
957
+ type: z.ZodLiteral<"turn.completed">;
958
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
959
+ type: z.ZodLiteral<"turn.cancelled">;
960
+ reason: z.ZodString;
961
+ message: z.ZodString;
962
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
963
+ type: z.ZodLiteral<"turn.failed">;
964
+ stage: z.ZodEnum<{
965
+ bootstrap: "bootstrap";
966
+ plan: "plan";
967
+ execute: "execute";
968
+ }>;
969
+ message: z.ZodString;
970
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
971
+ type: z.ZodLiteral<"capabilities.changed">;
972
+ }, z.core.$strict>>]>;
973
+ }, z.core.$strict>>;
974
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
975
+ type: z.ZodLiteral<"runtime.ack">;
976
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
977
+ throughRelaySequence: z.ZodNumber;
978
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
979
+ type: z.ZodLiteral<"runtime.gap">;
980
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
981
+ fromRelaySequence: z.ZodNumber;
982
+ throughRelaySequence: z.ZodNumber;
983
+ recovery: z.ZodLiteral<"thread.snapshot">;
984
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
985
+ type: z.ZodLiteral<"runtime.encrypted">;
986
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId">;
987
+ envelopeId: z.ZodString;
988
+ payloadKind: z.ZodEnum<{
989
+ event: "event";
990
+ request: "request";
991
+ response: "response";
992
+ }>;
993
+ requestId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "RelayRequestId">>;
994
+ relaySequence: z.ZodOptional<z.ZodNumber>;
995
+ algorithm: z.ZodString;
996
+ nonce: z.ZodString;
997
+ ciphertext: z.ZodString;
998
+ }, z.core.$strict>>]>;
999
+ export interface RelayProtocolRegistry {
1000
+ readonly messageTypes: readonly (typeof RELAY_MESSAGE_TYPE_VALUES)[number][];
1001
+ readonly requestMethods: readonly RelayRequestMethod[];
1002
+ readonly mutationMethods: readonly RelayRequestMethod[];
1003
+ readonly localOnlyMethods: readonly RelayRequestMethod[];
1004
+ }
1005
+ export declare const RELAY_PROTOCOL_REGISTRY: {
1006
+ readonly "1.0": {
1007
+ readonly messageTypes: readonly ["device.connect", "runtime.request", "runtime.response", "runtime.event", "runtime.ack", "runtime.gap", "runtime.encrypted"];
1008
+ readonly requestMethods: readonly ["initialize", "thread.list", "thread.create", "thread.open", "thread.snapshot", "thread.rename", "thread.delete", "thread.detach", "thread.capabilities", "turn.start", "turn.cancel", "approval.respond", "operation.get", "approval.candidate"];
1009
+ readonly mutationMethods: readonly ["thread.create", "thread.rename", "thread.delete", "thread.detach", "turn.start", "turn.cancel", "approval.respond", "approval.candidate"];
1010
+ readonly localOnlyMethods: readonly ["initialize"];
1011
+ };
1012
+ };
1013
+ export declare function getRelayProtocolRegistry(version: RelayProtocolVersion): RelayProtocolRegistry;
1014
+ export declare function negotiateRelayProtocolVersion(peerVersions: readonly string[]): RelayProtocolVersion | undefined;
1015
+ export declare function canonicalizeRelayJson(value: JsonValue): string;
1016
+ export declare const RELAY_REQUEST_REPLAY_DISPOSITIONS: {
1017
+ readonly new: "new";
1018
+ readonly replay: "replay";
1019
+ readonly conflict: "conflict";
1020
+ };
1021
+ export type RelayRequestReplayDisposition = (typeof RELAY_REQUEST_REPLAY_DISPOSITIONS)[keyof typeof RELAY_REQUEST_REPLAY_DISPOSITIONS];
1022
+ export type RelayRequestReplayClassification = {
1023
+ readonly disposition: typeof RELAY_REQUEST_REPLAY_DISPOSITIONS.new | typeof RELAY_REQUEST_REPLAY_DISPOSITIONS.replay;
1024
+ } | {
1025
+ readonly disposition: typeof RELAY_REQUEST_REPLAY_DISPOSITIONS.conflict;
1026
+ readonly errorCode: typeof RELAY_ERROR_CODES.requestIdConflict;
1027
+ };
1028
+ export declare function classifyRelayRequestReplay(existing: RelayRuntimeRequest, candidate: RelayRuntimeRequest): RelayRequestReplayClassification;
1029
+ export interface RelayAckState {
1030
+ readonly acknowledgedThrough: number;
1031
+ /** Highest sequence the caller has proved was delivered without a preceding send hole. */
1032
+ readonly advertisedThrough: number;
1033
+ readonly incomingThrough: number;
1034
+ }
1035
+ export type RelayAckDisposition = "advance" | "duplicate" | "invalid";
1036
+ export declare function classifyRelayAck(state: RelayAckState): RelayAckDisposition;
1037
+ export type DeviceId = z.infer<typeof deviceIdSchema>;
1038
+ export type WorkspaceId = z.infer<typeof workspaceIdSchema>;
1039
+ export type RelayRequestId = z.infer<typeof relayRequestIdSchema>;
1040
+ export type RelayEnvelopeId = z.infer<typeof relayEnvelopeIdSchema>;
1041
+ export type RelayApprovalCandidateInput = z.input<typeof relayApprovalCandidateParamsSchema>;
1042
+ export type RelayApprovalCandidateParams = z.infer<typeof relayApprovalCandidateParamsSchema>;
1043
+ export type RelayApprovalCandidateResult = z.infer<typeof relayApprovalCandidateResultSchema>;
1044
+ export type RelayError = z.infer<typeof relayErrorSchema>;
1045
+ export type RelayMessage = z.infer<typeof relayMessageSchema>;
1046
+ export type RelayRuntimeRequest = z.infer<typeof relayRuntimeRequestSchema>;
1047
+ export type RelayRuntimeResponse = z.infer<typeof relayRuntimeResponseSchema>;
1048
+ export type RelayRuntimeEvent = z.infer<typeof relayRuntimeEventSchema>;
1049
+ export type RelayGap = z.infer<typeof relayGapSchema>;
1050
+ export type RelayEncryptedMessage = z.infer<typeof relayEncryptedMessageSchema>;