@mquan/portal 0.0.1

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.
Files changed (116) hide show
  1. package/README.md +168 -0
  2. package/dist/src/api.d.ts +5 -0
  3. package/dist/src/api.js +357 -0
  4. package/dist/src/api.js.map +1 -0
  5. package/dist/src/cli.d.ts +17 -0
  6. package/dist/src/cli.js +618 -0
  7. package/dist/src/cli.js.map +1 -0
  8. package/dist/src/daemon-lifecycle.d.ts +24 -0
  9. package/dist/src/daemon-lifecycle.js +107 -0
  10. package/dist/src/daemon-lifecycle.js.map +1 -0
  11. package/dist/src/daemon.d.ts +17 -0
  12. package/dist/src/daemon.js +90 -0
  13. package/dist/src/daemon.js.map +1 -0
  14. package/dist/src/doctor.d.ts +14 -0
  15. package/dist/src/doctor.js +51 -0
  16. package/dist/src/doctor.js.map +1 -0
  17. package/dist/src/entrypoint.d.ts +2 -0
  18. package/dist/src/entrypoint.js +14 -0
  19. package/dist/src/entrypoint.js.map +1 -0
  20. package/dist/src/index.d.ts +5 -0
  21. package/dist/src/index.js +5 -0
  22. package/dist/src/index.js.map +1 -0
  23. package/dist/src/launch.d.ts +41 -0
  24. package/dist/src/launch.js +186 -0
  25. package/dist/src/launch.js.map +1 -0
  26. package/dist/src/mcp.d.ts +9 -0
  27. package/dist/src/mcp.js +132 -0
  28. package/dist/src/mcp.js.map +1 -0
  29. package/dist/src/network/client.d.ts +67 -0
  30. package/dist/src/network/client.js +540 -0
  31. package/dist/src/network/client.js.map +1 -0
  32. package/dist/src/network/coordinator.d.ts +83 -0
  33. package/dist/src/network/coordinator.js +225 -0
  34. package/dist/src/network/coordinator.js.map +1 -0
  35. package/dist/src/network/protocol.d.ts +1352 -0
  36. package/dist/src/network/protocol.js +360 -0
  37. package/dist/src/network/protocol.js.map +1 -0
  38. package/dist/src/network/server.d.ts +28 -0
  39. package/dist/src/network/server.js +474 -0
  40. package/dist/src/network/server.js.map +1 -0
  41. package/dist/src/network/tasks.d.ts +65 -0
  42. package/dist/src/network/tasks.js +276 -0
  43. package/dist/src/network/tasks.js.map +1 -0
  44. package/dist/src/portal-index.d.ts +21 -0
  45. package/dist/src/portal-index.js +140 -0
  46. package/dist/src/portal-index.js.map +1 -0
  47. package/dist/src/provider/claude-managed.d.ts +34 -0
  48. package/dist/src/provider/claude-managed.js +125 -0
  49. package/dist/src/provider/claude-managed.js.map +1 -0
  50. package/dist/src/provider/claude.d.ts +24 -0
  51. package/dist/src/provider/claude.js +114 -0
  52. package/dist/src/provider/claude.js.map +1 -0
  53. package/dist/src/provider/codex/app-server-client.d.ts +43 -0
  54. package/dist/src/provider/codex/app-server-client.js +143 -0
  55. package/dist/src/provider/codex/app-server-client.js.map +1 -0
  56. package/dist/src/provider/codex/index.d.ts +3 -0
  57. package/dist/src/provider/codex/index.js +4 -0
  58. package/dist/src/provider/codex/index.js.map +1 -0
  59. package/dist/src/provider/codex/managed-runner.d.ts +12 -0
  60. package/dist/src/provider/codex/managed-runner.js +162 -0
  61. package/dist/src/provider/codex/managed-runner.js.map +1 -0
  62. package/dist/src/provider/codex/probe.d.ts +2 -0
  63. package/dist/src/provider/codex/probe.js +33 -0
  64. package/dist/src/provider/codex/probe.js.map +1 -0
  65. package/dist/src/provider/codex/protocol.d.ts +193 -0
  66. package/dist/src/provider/codex/protocol.js +10 -0
  67. package/dist/src/provider/codex/protocol.js.map +1 -0
  68. package/dist/src/provider/codex/provider.d.ts +35 -0
  69. package/dist/src/provider/codex/provider.js +289 -0
  70. package/dist/src/provider/codex/provider.js.map +1 -0
  71. package/dist/src/provider/codex/remote-app-server.d.ts +16 -0
  72. package/dist/src/provider/codex/remote-app-server.js +80 -0
  73. package/dist/src/provider/codex/remote-app-server.js.map +1 -0
  74. package/dist/src/provider/codex/websocket-client.d.ts +40 -0
  75. package/dist/src/provider/codex/websocket-client.js +174 -0
  76. package/dist/src/provider/codex/websocket-client.js.map +1 -0
  77. package/dist/src/provider/types.d.ts +35 -0
  78. package/dist/src/provider/types.js +2 -0
  79. package/dist/src/provider/types.js.map +1 -0
  80. package/dist/src/recall/embedding.d.ts +28 -0
  81. package/dist/src/recall/embedding.js +142 -0
  82. package/dist/src/recall/embedding.js.map +1 -0
  83. package/dist/src/recall/types.d.ts +35 -0
  84. package/dist/src/recall/types.js +2 -0
  85. package/dist/src/recall/types.js.map +1 -0
  86. package/dist/src/rpc/client.d.ts +6 -0
  87. package/dist/src/rpc/client.js +58 -0
  88. package/dist/src/rpc/client.js.map +1 -0
  89. package/dist/src/rpc/protocol.d.ts +21 -0
  90. package/dist/src/rpc/protocol.js +11 -0
  91. package/dist/src/rpc/protocol.js.map +1 -0
  92. package/dist/src/rpc/server.d.ts +12 -0
  93. package/dist/src/rpc/server.js +154 -0
  94. package/dist/src/rpc/server.js.map +1 -0
  95. package/dist/src/runtime/paths.d.ts +8 -0
  96. package/dist/src/runtime/paths.js +18 -0
  97. package/dist/src/runtime/paths.js.map +1 -0
  98. package/dist/src/service.d.ts +127 -0
  99. package/dist/src/service.js +637 -0
  100. package/dist/src/service.js.map +1 -0
  101. package/dist/src/session-profile.d.ts +39 -0
  102. package/dist/src/session-profile.js +186 -0
  103. package/dist/src/session-profile.js.map +1 -0
  104. package/dist/src/storage/database.d.ts +9 -0
  105. package/dist/src/storage/database.js +354 -0
  106. package/dist/src/storage/database.js.map +1 -0
  107. package/dist/src/storage/repository.d.ts +275 -0
  108. package/dist/src/storage/repository.js +1291 -0
  109. package/dist/src/storage/repository.js.map +1 -0
  110. package/dist/src/version.d.ts +1 -0
  111. package/dist/src/version.js +2 -0
  112. package/dist/src/version.js.map +1 -0
  113. package/docs/architecture-plan.md +191 -0
  114. package/docs/mvp-plan.md +111 -0
  115. package/docs/remote-demo.md +346 -0
  116. package/package.json +47 -0
@@ -0,0 +1,1352 @@
1
+ import { z } from "zod";
2
+ export declare const PROTOCOL_VERSION: 1;
3
+ export declare const PROTOCOL_LIMITS: Readonly<{
4
+ encodedMessageBytes: number;
5
+ idCharacters: 128;
6
+ agentNameCharacters: 64;
7
+ descriptionCharacters: 280;
8
+ discoveryQueryCharacters: 256;
9
+ objectiveCharacters: number;
10
+ contextCharacters: number;
11
+ expectedResultCharacters: number;
12
+ eventBodyCharacters: number;
13
+ errorCharacters: number;
14
+ artifactReferenceCharacters: number;
15
+ artifactReferences: 16;
16
+ capabilities: 16;
17
+ presenceResults: 100;
18
+ minimumHeartbeatSeconds: 5;
19
+ maximumHeartbeatSeconds: 60;
20
+ minimumLeaseSeconds: 15;
21
+ maximumLeaseSeconds: 120;
22
+ maximumTaskTtlMilliseconds: number;
23
+ }>;
24
+ export type ProtocolErrorCode = "protocol_mismatch" | "malformed_message" | "message_too_large" | "handshake_required" | "invalid_state" | "not_connected" | "route_not_found" | "route_not_owned" | "envelope_expired" | "envelope_conflict" | "internal_error";
25
+ export declare class NetworkProtocolError extends Error {
26
+ readonly code: ProtocolErrorCode;
27
+ readonly details?: unknown;
28
+ constructor(code: ProtocolErrorCode, message: string, details?: unknown);
29
+ }
30
+ export declare const providerSchema: z.ZodEnum<{
31
+ claude: "claude";
32
+ codex: "codex";
33
+ }>;
34
+ export declare const capabilitySchema: z.ZodEnum<{
35
+ message: "message";
36
+ task: "task";
37
+ }>;
38
+ export declare const presenceStateSchema: z.ZodEnum<{
39
+ available: "available";
40
+ busy: "busy";
41
+ }>;
42
+ export declare const taskEventKindSchema: z.ZodEnum<{
43
+ accepted: "accepted";
44
+ answer: "answer";
45
+ completed: "completed";
46
+ declined: "declined";
47
+ failed: "failed";
48
+ offer: "offer";
49
+ progress: "progress";
50
+ question: "question";
51
+ running: "running";
52
+ }>;
53
+ export declare const taskStateSchema: z.ZodEnum<{
54
+ accepted: "accepted";
55
+ completed: "completed";
56
+ declined: "declined";
57
+ failed: "failed";
58
+ offered: "offered";
59
+ running: "running";
60
+ }>;
61
+ export declare const agentPresenceSchema: z.ZodObject<{
62
+ sessionId: z.ZodString;
63
+ agentName: z.ZodString;
64
+ provider: z.ZodEnum<{
65
+ claude: "claude";
66
+ codex: "codex";
67
+ }>;
68
+ description: z.ZodString;
69
+ capabilities: z.ZodArray<z.ZodEnum<{
70
+ message: "message";
71
+ task: "task";
72
+ }>>;
73
+ state: z.ZodEnum<{
74
+ available: "available";
75
+ busy: "busy";
76
+ }>;
77
+ routeId: z.ZodString;
78
+ expiresAt: z.ZodString;
79
+ }, z.core.$strict>;
80
+ export declare const clientHelloSchema: z.ZodObject<{
81
+ protocolVersion: z.ZodLiteral<1>;
82
+ type: z.ZodLiteral<"client.hello">;
83
+ clientId: z.ZodString;
84
+ installationId: z.ZodString;
85
+ sentAt: z.ZodString;
86
+ }, z.core.$strict>;
87
+ export declare const serverHelloSchema: z.ZodObject<{
88
+ protocolVersion: z.ZodLiteral<1>;
89
+ type: z.ZodLiteral<"server.hello">;
90
+ connectionId: z.ZodString;
91
+ heartbeatIntervalSeconds: z.ZodNumber;
92
+ sentAt: z.ZodString;
93
+ }, z.core.$strict>;
94
+ export declare const agentRegisterSchema: z.ZodObject<{
95
+ protocolVersion: z.ZodLiteral<1>;
96
+ sessionId: z.ZodString;
97
+ agentName: z.ZodString;
98
+ provider: z.ZodEnum<{
99
+ claude: "claude";
100
+ codex: "codex";
101
+ }>;
102
+ description: z.ZodString;
103
+ capabilities: z.ZodArray<z.ZodEnum<{
104
+ message: "message";
105
+ task: "task";
106
+ }>>;
107
+ state: z.ZodEnum<{
108
+ available: "available";
109
+ busy: "busy";
110
+ }>;
111
+ type: z.ZodLiteral<"agent.register">;
112
+ requestId: z.ZodString;
113
+ leaseSeconds: z.ZodNumber;
114
+ }, z.core.$strict>;
115
+ export declare const agentRegisteredSchema: z.ZodObject<{
116
+ protocolVersion: z.ZodLiteral<1>;
117
+ type: z.ZodLiteral<"agent.registered">;
118
+ requestId: z.ZodString;
119
+ agent: z.ZodObject<{
120
+ sessionId: z.ZodString;
121
+ agentName: z.ZodString;
122
+ provider: z.ZodEnum<{
123
+ claude: "claude";
124
+ codex: "codex";
125
+ }>;
126
+ description: z.ZodString;
127
+ capabilities: z.ZodArray<z.ZodEnum<{
128
+ message: "message";
129
+ task: "task";
130
+ }>>;
131
+ state: z.ZodEnum<{
132
+ available: "available";
133
+ busy: "busy";
134
+ }>;
135
+ routeId: z.ZodString;
136
+ expiresAt: z.ZodString;
137
+ }, z.core.$strict>;
138
+ }, z.core.$strict>;
139
+ export declare const agentRenewSchema: z.ZodObject<{
140
+ protocolVersion: z.ZodLiteral<1>;
141
+ type: z.ZodLiteral<"agent.renew">;
142
+ requestId: z.ZodString;
143
+ routeId: z.ZodString;
144
+ state: z.ZodOptional<z.ZodEnum<{
145
+ available: "available";
146
+ busy: "busy";
147
+ }>>;
148
+ leaseSeconds: z.ZodNumber;
149
+ }, z.core.$strict>;
150
+ export declare const agentRenewedSchema: z.ZodObject<{
151
+ protocolVersion: z.ZodLiteral<1>;
152
+ type: z.ZodLiteral<"agent.renewed">;
153
+ requestId: z.ZodString;
154
+ agent: z.ZodObject<{
155
+ sessionId: z.ZodString;
156
+ agentName: z.ZodString;
157
+ provider: z.ZodEnum<{
158
+ claude: "claude";
159
+ codex: "codex";
160
+ }>;
161
+ description: z.ZodString;
162
+ capabilities: z.ZodArray<z.ZodEnum<{
163
+ message: "message";
164
+ task: "task";
165
+ }>>;
166
+ state: z.ZodEnum<{
167
+ available: "available";
168
+ busy: "busy";
169
+ }>;
170
+ routeId: z.ZodString;
171
+ expiresAt: z.ZodString;
172
+ }, z.core.$strict>;
173
+ }, z.core.$strict>;
174
+ export declare const agentUnregisterSchema: z.ZodObject<{
175
+ protocolVersion: z.ZodLiteral<1>;
176
+ type: z.ZodLiteral<"agent.unregister">;
177
+ requestId: z.ZodString;
178
+ routeId: z.ZodString;
179
+ }, z.core.$strict>;
180
+ export declare const agentUnregisteredSchema: z.ZodObject<{
181
+ protocolVersion: z.ZodLiteral<1>;
182
+ type: z.ZodLiteral<"agent.unregistered">;
183
+ requestId: z.ZodString;
184
+ routeId: z.ZodString;
185
+ }, z.core.$strict>;
186
+ export declare const agentDiscoverSchema: z.ZodObject<{
187
+ protocolVersion: z.ZodLiteral<1>;
188
+ type: z.ZodLiteral<"agent.discover">;
189
+ requestId: z.ZodString;
190
+ query: z.ZodOptional<z.ZodString>;
191
+ capability: z.ZodOptional<z.ZodEnum<{
192
+ message: "message";
193
+ task: "task";
194
+ }>>;
195
+ limit: z.ZodDefault<z.ZodNumber>;
196
+ }, z.core.$strict>;
197
+ export declare const agentPresenceResultSchema: z.ZodObject<{
198
+ protocolVersion: z.ZodLiteral<1>;
199
+ type: z.ZodLiteral<"agent.presence">;
200
+ requestId: z.ZodString;
201
+ agents: z.ZodArray<z.ZodObject<{
202
+ sessionId: z.ZodString;
203
+ agentName: z.ZodString;
204
+ provider: z.ZodEnum<{
205
+ claude: "claude";
206
+ codex: "codex";
207
+ }>;
208
+ description: z.ZodString;
209
+ capabilities: z.ZodArray<z.ZodEnum<{
210
+ message: "message";
211
+ task: "task";
212
+ }>>;
213
+ state: z.ZodEnum<{
214
+ available: "available";
215
+ busy: "busy";
216
+ }>;
217
+ routeId: z.ZodString;
218
+ expiresAt: z.ZodString;
219
+ }, z.core.$strict>>;
220
+ }, z.core.$strict>;
221
+ export declare const taskOfferEventSchema: z.ZodObject<{
222
+ eventId: z.ZodString;
223
+ taskId: z.ZodString;
224
+ createdAt: z.ZodString;
225
+ kind: z.ZodLiteral<"offer">;
226
+ state: z.ZodLiteral<"offered">;
227
+ objective: z.ZodString;
228
+ context: z.ZodOptional<z.ZodString>;
229
+ expectedResult: z.ZodOptional<z.ZodString>;
230
+ }, z.core.$strict>;
231
+ export declare const taskAcceptedEventSchema: z.ZodObject<{
232
+ eventId: z.ZodString;
233
+ taskId: z.ZodString;
234
+ createdAt: z.ZodString;
235
+ kind: z.ZodLiteral<"accepted">;
236
+ state: z.ZodLiteral<"accepted">;
237
+ message: z.ZodOptional<z.ZodString>;
238
+ }, z.core.$strict>;
239
+ export declare const taskDeclinedEventSchema: z.ZodObject<{
240
+ eventId: z.ZodString;
241
+ taskId: z.ZodString;
242
+ createdAt: z.ZodString;
243
+ kind: z.ZodLiteral<"declined">;
244
+ state: z.ZodLiteral<"declined">;
245
+ reason: z.ZodOptional<z.ZodString>;
246
+ }, z.core.$strict>;
247
+ export declare const taskRunningEventSchema: z.ZodObject<{
248
+ eventId: z.ZodString;
249
+ taskId: z.ZodString;
250
+ createdAt: z.ZodString;
251
+ kind: z.ZodLiteral<"running">;
252
+ state: z.ZodLiteral<"running">;
253
+ message: z.ZodOptional<z.ZodString>;
254
+ }, z.core.$strict>;
255
+ export declare const taskProgressEventSchema: z.ZodObject<{
256
+ eventId: z.ZodString;
257
+ taskId: z.ZodString;
258
+ createdAt: z.ZodString;
259
+ kind: z.ZodLiteral<"progress">;
260
+ state: z.ZodLiteral<"running">;
261
+ message: z.ZodString;
262
+ }, z.core.$strict>;
263
+ export declare const taskQuestionEventSchema: z.ZodObject<{
264
+ eventId: z.ZodString;
265
+ taskId: z.ZodString;
266
+ createdAt: z.ZodString;
267
+ kind: z.ZodLiteral<"question">;
268
+ state: z.ZodLiteral<"running">;
269
+ question: z.ZodString;
270
+ }, z.core.$strict>;
271
+ export declare const taskAnswerEventSchema: z.ZodObject<{
272
+ eventId: z.ZodString;
273
+ taskId: z.ZodString;
274
+ createdAt: z.ZodString;
275
+ kind: z.ZodLiteral<"answer">;
276
+ state: z.ZodLiteral<"running">;
277
+ answer: z.ZodString;
278
+ }, z.core.$strict>;
279
+ export declare const taskCompletedEventSchema: z.ZodObject<{
280
+ eventId: z.ZodString;
281
+ taskId: z.ZodString;
282
+ createdAt: z.ZodString;
283
+ kind: z.ZodLiteral<"completed">;
284
+ state: z.ZodLiteral<"completed">;
285
+ result: z.ZodString;
286
+ artifactReferences: z.ZodOptional<z.ZodArray<z.ZodString>>;
287
+ }, z.core.$strict>;
288
+ export declare const taskFailedEventSchema: z.ZodObject<{
289
+ eventId: z.ZodString;
290
+ taskId: z.ZodString;
291
+ createdAt: z.ZodString;
292
+ kind: z.ZodLiteral<"failed">;
293
+ state: z.ZodLiteral<"failed">;
294
+ error: z.ZodString;
295
+ }, z.core.$strict>;
296
+ export declare const taskEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
297
+ eventId: z.ZodString;
298
+ taskId: z.ZodString;
299
+ createdAt: z.ZodString;
300
+ kind: z.ZodLiteral<"offer">;
301
+ state: z.ZodLiteral<"offered">;
302
+ objective: z.ZodString;
303
+ context: z.ZodOptional<z.ZodString>;
304
+ expectedResult: z.ZodOptional<z.ZodString>;
305
+ }, z.core.$strict>, z.ZodObject<{
306
+ eventId: z.ZodString;
307
+ taskId: z.ZodString;
308
+ createdAt: z.ZodString;
309
+ kind: z.ZodLiteral<"accepted">;
310
+ state: z.ZodLiteral<"accepted">;
311
+ message: z.ZodOptional<z.ZodString>;
312
+ }, z.core.$strict>, z.ZodObject<{
313
+ eventId: z.ZodString;
314
+ taskId: z.ZodString;
315
+ createdAt: z.ZodString;
316
+ kind: z.ZodLiteral<"declined">;
317
+ state: z.ZodLiteral<"declined">;
318
+ reason: z.ZodOptional<z.ZodString>;
319
+ }, z.core.$strict>, z.ZodObject<{
320
+ eventId: z.ZodString;
321
+ taskId: z.ZodString;
322
+ createdAt: z.ZodString;
323
+ kind: z.ZodLiteral<"running">;
324
+ state: z.ZodLiteral<"running">;
325
+ message: z.ZodOptional<z.ZodString>;
326
+ }, z.core.$strict>, z.ZodObject<{
327
+ eventId: z.ZodString;
328
+ taskId: z.ZodString;
329
+ createdAt: z.ZodString;
330
+ kind: z.ZodLiteral<"progress">;
331
+ state: z.ZodLiteral<"running">;
332
+ message: z.ZodString;
333
+ }, z.core.$strict>, z.ZodObject<{
334
+ eventId: z.ZodString;
335
+ taskId: z.ZodString;
336
+ createdAt: z.ZodString;
337
+ kind: z.ZodLiteral<"question">;
338
+ state: z.ZodLiteral<"running">;
339
+ question: z.ZodString;
340
+ }, z.core.$strict>, z.ZodObject<{
341
+ eventId: z.ZodString;
342
+ taskId: z.ZodString;
343
+ createdAt: z.ZodString;
344
+ kind: z.ZodLiteral<"answer">;
345
+ state: z.ZodLiteral<"running">;
346
+ answer: z.ZodString;
347
+ }, z.core.$strict>, z.ZodObject<{
348
+ eventId: z.ZodString;
349
+ taskId: z.ZodString;
350
+ createdAt: z.ZodString;
351
+ kind: z.ZodLiteral<"completed">;
352
+ state: z.ZodLiteral<"completed">;
353
+ result: z.ZodString;
354
+ artifactReferences: z.ZodOptional<z.ZodArray<z.ZodString>>;
355
+ }, z.core.$strict>, z.ZodObject<{
356
+ eventId: z.ZodString;
357
+ taskId: z.ZodString;
358
+ createdAt: z.ZodString;
359
+ kind: z.ZodLiteral<"failed">;
360
+ state: z.ZodLiteral<"failed">;
361
+ error: z.ZodString;
362
+ }, z.core.$strict>], "kind">;
363
+ export declare const envelopeSchema: z.ZodObject<{
364
+ envelopeId: z.ZodString;
365
+ senderRouteId: z.ZodString;
366
+ targetRouteId: z.ZodString;
367
+ sentAt: z.ZodString;
368
+ expiresAt: z.ZodString;
369
+ event: z.ZodDiscriminatedUnion<[z.ZodObject<{
370
+ eventId: z.ZodString;
371
+ taskId: z.ZodString;
372
+ createdAt: z.ZodString;
373
+ kind: z.ZodLiteral<"offer">;
374
+ state: z.ZodLiteral<"offered">;
375
+ objective: z.ZodString;
376
+ context: z.ZodOptional<z.ZodString>;
377
+ expectedResult: z.ZodOptional<z.ZodString>;
378
+ }, z.core.$strict>, z.ZodObject<{
379
+ eventId: z.ZodString;
380
+ taskId: z.ZodString;
381
+ createdAt: z.ZodString;
382
+ kind: z.ZodLiteral<"accepted">;
383
+ state: z.ZodLiteral<"accepted">;
384
+ message: z.ZodOptional<z.ZodString>;
385
+ }, z.core.$strict>, z.ZodObject<{
386
+ eventId: z.ZodString;
387
+ taskId: z.ZodString;
388
+ createdAt: z.ZodString;
389
+ kind: z.ZodLiteral<"declined">;
390
+ state: z.ZodLiteral<"declined">;
391
+ reason: z.ZodOptional<z.ZodString>;
392
+ }, z.core.$strict>, z.ZodObject<{
393
+ eventId: z.ZodString;
394
+ taskId: z.ZodString;
395
+ createdAt: z.ZodString;
396
+ kind: z.ZodLiteral<"running">;
397
+ state: z.ZodLiteral<"running">;
398
+ message: z.ZodOptional<z.ZodString>;
399
+ }, z.core.$strict>, z.ZodObject<{
400
+ eventId: z.ZodString;
401
+ taskId: z.ZodString;
402
+ createdAt: z.ZodString;
403
+ kind: z.ZodLiteral<"progress">;
404
+ state: z.ZodLiteral<"running">;
405
+ message: z.ZodString;
406
+ }, z.core.$strict>, z.ZodObject<{
407
+ eventId: z.ZodString;
408
+ taskId: z.ZodString;
409
+ createdAt: z.ZodString;
410
+ kind: z.ZodLiteral<"question">;
411
+ state: z.ZodLiteral<"running">;
412
+ question: z.ZodString;
413
+ }, z.core.$strict>, z.ZodObject<{
414
+ eventId: z.ZodString;
415
+ taskId: z.ZodString;
416
+ createdAt: z.ZodString;
417
+ kind: z.ZodLiteral<"answer">;
418
+ state: z.ZodLiteral<"running">;
419
+ answer: z.ZodString;
420
+ }, z.core.$strict>, z.ZodObject<{
421
+ eventId: z.ZodString;
422
+ taskId: z.ZodString;
423
+ createdAt: z.ZodString;
424
+ kind: z.ZodLiteral<"completed">;
425
+ state: z.ZodLiteral<"completed">;
426
+ result: z.ZodString;
427
+ artifactReferences: z.ZodOptional<z.ZodArray<z.ZodString>>;
428
+ }, z.core.$strict>, z.ZodObject<{
429
+ eventId: z.ZodString;
430
+ taskId: z.ZodString;
431
+ createdAt: z.ZodString;
432
+ kind: z.ZodLiteral<"failed">;
433
+ state: z.ZodLiteral<"failed">;
434
+ error: z.ZodString;
435
+ }, z.core.$strict>], "kind">;
436
+ }, z.core.$strict>;
437
+ export declare const envelopeSendSchema: z.ZodObject<{
438
+ protocolVersion: z.ZodLiteral<1>;
439
+ type: z.ZodLiteral<"envelope.send">;
440
+ requestId: z.ZodString;
441
+ envelope: z.ZodObject<{
442
+ envelopeId: z.ZodString;
443
+ senderRouteId: z.ZodString;
444
+ targetRouteId: z.ZodString;
445
+ sentAt: z.ZodString;
446
+ expiresAt: z.ZodString;
447
+ event: z.ZodDiscriminatedUnion<[z.ZodObject<{
448
+ eventId: z.ZodString;
449
+ taskId: z.ZodString;
450
+ createdAt: z.ZodString;
451
+ kind: z.ZodLiteral<"offer">;
452
+ state: z.ZodLiteral<"offered">;
453
+ objective: z.ZodString;
454
+ context: z.ZodOptional<z.ZodString>;
455
+ expectedResult: z.ZodOptional<z.ZodString>;
456
+ }, z.core.$strict>, z.ZodObject<{
457
+ eventId: z.ZodString;
458
+ taskId: z.ZodString;
459
+ createdAt: z.ZodString;
460
+ kind: z.ZodLiteral<"accepted">;
461
+ state: z.ZodLiteral<"accepted">;
462
+ message: z.ZodOptional<z.ZodString>;
463
+ }, z.core.$strict>, z.ZodObject<{
464
+ eventId: z.ZodString;
465
+ taskId: z.ZodString;
466
+ createdAt: z.ZodString;
467
+ kind: z.ZodLiteral<"declined">;
468
+ state: z.ZodLiteral<"declined">;
469
+ reason: z.ZodOptional<z.ZodString>;
470
+ }, z.core.$strict>, z.ZodObject<{
471
+ eventId: z.ZodString;
472
+ taskId: z.ZodString;
473
+ createdAt: z.ZodString;
474
+ kind: z.ZodLiteral<"running">;
475
+ state: z.ZodLiteral<"running">;
476
+ message: z.ZodOptional<z.ZodString>;
477
+ }, z.core.$strict>, z.ZodObject<{
478
+ eventId: z.ZodString;
479
+ taskId: z.ZodString;
480
+ createdAt: z.ZodString;
481
+ kind: z.ZodLiteral<"progress">;
482
+ state: z.ZodLiteral<"running">;
483
+ message: z.ZodString;
484
+ }, z.core.$strict>, z.ZodObject<{
485
+ eventId: z.ZodString;
486
+ taskId: z.ZodString;
487
+ createdAt: z.ZodString;
488
+ kind: z.ZodLiteral<"question">;
489
+ state: z.ZodLiteral<"running">;
490
+ question: z.ZodString;
491
+ }, z.core.$strict>, z.ZodObject<{
492
+ eventId: z.ZodString;
493
+ taskId: z.ZodString;
494
+ createdAt: z.ZodString;
495
+ kind: z.ZodLiteral<"answer">;
496
+ state: z.ZodLiteral<"running">;
497
+ answer: z.ZodString;
498
+ }, z.core.$strict>, z.ZodObject<{
499
+ eventId: z.ZodString;
500
+ taskId: z.ZodString;
501
+ createdAt: z.ZodString;
502
+ kind: z.ZodLiteral<"completed">;
503
+ state: z.ZodLiteral<"completed">;
504
+ result: z.ZodString;
505
+ artifactReferences: z.ZodOptional<z.ZodArray<z.ZodString>>;
506
+ }, z.core.$strict>, z.ZodObject<{
507
+ eventId: z.ZodString;
508
+ taskId: z.ZodString;
509
+ createdAt: z.ZodString;
510
+ kind: z.ZodLiteral<"failed">;
511
+ state: z.ZodLiteral<"failed">;
512
+ error: z.ZodString;
513
+ }, z.core.$strict>], "kind">;
514
+ }, z.core.$strict>;
515
+ }, z.core.$strict>;
516
+ export declare const envelopeDeliverySchema: z.ZodObject<{
517
+ protocolVersion: z.ZodLiteral<1>;
518
+ type: z.ZodLiteral<"envelope.delivery">;
519
+ envelope: z.ZodObject<{
520
+ envelopeId: z.ZodString;
521
+ senderRouteId: z.ZodString;
522
+ targetRouteId: z.ZodString;
523
+ sentAt: z.ZodString;
524
+ expiresAt: z.ZodString;
525
+ event: z.ZodDiscriminatedUnion<[z.ZodObject<{
526
+ eventId: z.ZodString;
527
+ taskId: z.ZodString;
528
+ createdAt: z.ZodString;
529
+ kind: z.ZodLiteral<"offer">;
530
+ state: z.ZodLiteral<"offered">;
531
+ objective: z.ZodString;
532
+ context: z.ZodOptional<z.ZodString>;
533
+ expectedResult: z.ZodOptional<z.ZodString>;
534
+ }, z.core.$strict>, z.ZodObject<{
535
+ eventId: z.ZodString;
536
+ taskId: z.ZodString;
537
+ createdAt: z.ZodString;
538
+ kind: z.ZodLiteral<"accepted">;
539
+ state: z.ZodLiteral<"accepted">;
540
+ message: z.ZodOptional<z.ZodString>;
541
+ }, z.core.$strict>, z.ZodObject<{
542
+ eventId: z.ZodString;
543
+ taskId: z.ZodString;
544
+ createdAt: z.ZodString;
545
+ kind: z.ZodLiteral<"declined">;
546
+ state: z.ZodLiteral<"declined">;
547
+ reason: z.ZodOptional<z.ZodString>;
548
+ }, z.core.$strict>, z.ZodObject<{
549
+ eventId: z.ZodString;
550
+ taskId: z.ZodString;
551
+ createdAt: z.ZodString;
552
+ kind: z.ZodLiteral<"running">;
553
+ state: z.ZodLiteral<"running">;
554
+ message: z.ZodOptional<z.ZodString>;
555
+ }, z.core.$strict>, z.ZodObject<{
556
+ eventId: z.ZodString;
557
+ taskId: z.ZodString;
558
+ createdAt: z.ZodString;
559
+ kind: z.ZodLiteral<"progress">;
560
+ state: z.ZodLiteral<"running">;
561
+ message: z.ZodString;
562
+ }, z.core.$strict>, z.ZodObject<{
563
+ eventId: z.ZodString;
564
+ taskId: z.ZodString;
565
+ createdAt: z.ZodString;
566
+ kind: z.ZodLiteral<"question">;
567
+ state: z.ZodLiteral<"running">;
568
+ question: z.ZodString;
569
+ }, z.core.$strict>, z.ZodObject<{
570
+ eventId: z.ZodString;
571
+ taskId: z.ZodString;
572
+ createdAt: z.ZodString;
573
+ kind: z.ZodLiteral<"answer">;
574
+ state: z.ZodLiteral<"running">;
575
+ answer: z.ZodString;
576
+ }, z.core.$strict>, z.ZodObject<{
577
+ eventId: z.ZodString;
578
+ taskId: z.ZodString;
579
+ createdAt: z.ZodString;
580
+ kind: z.ZodLiteral<"completed">;
581
+ state: z.ZodLiteral<"completed">;
582
+ result: z.ZodString;
583
+ artifactReferences: z.ZodOptional<z.ZodArray<z.ZodString>>;
584
+ }, z.core.$strict>, z.ZodObject<{
585
+ eventId: z.ZodString;
586
+ taskId: z.ZodString;
587
+ createdAt: z.ZodString;
588
+ kind: z.ZodLiteral<"failed">;
589
+ state: z.ZodLiteral<"failed">;
590
+ error: z.ZodString;
591
+ }, z.core.$strict>], "kind">;
592
+ }, z.core.$strict>;
593
+ }, z.core.$strict>;
594
+ export declare const envelopeAcknowledgeSchema: z.ZodObject<{
595
+ protocolVersion: z.ZodLiteral<1>;
596
+ type: z.ZodLiteral<"envelope.acknowledge">;
597
+ requestId: z.ZodString;
598
+ targetRouteId: z.ZodString;
599
+ envelopeId: z.ZodString;
600
+ eventId: z.ZodString;
601
+ status: z.ZodEnum<{
602
+ received: "received";
603
+ rejected: "rejected";
604
+ }>;
605
+ receivedAt: z.ZodString;
606
+ error: z.ZodOptional<z.ZodString>;
607
+ }, z.core.$strict>;
608
+ export declare const envelopeAcknowledgeAcceptedSchema: z.ZodObject<{
609
+ protocolVersion: z.ZodLiteral<1>;
610
+ type: z.ZodLiteral<"envelope.acknowledge.accepted">;
611
+ requestId: z.ZodString;
612
+ envelopeId: z.ZodString;
613
+ eventId: z.ZodString;
614
+ }, z.core.$strict>;
615
+ export declare const envelopeAcknowledgedSchema: z.ZodObject<{
616
+ protocolVersion: z.ZodLiteral<1>;
617
+ type: z.ZodLiteral<"envelope.acknowledged">;
618
+ envelopeId: z.ZodString;
619
+ eventId: z.ZodString;
620
+ status: z.ZodEnum<{
621
+ received: "received";
622
+ rejected: "rejected";
623
+ }>;
624
+ receivedAt: z.ZodString;
625
+ error: z.ZodOptional<z.ZodString>;
626
+ }, z.core.$strict>;
627
+ export declare const protocolErrorSchema: z.ZodObject<{
628
+ protocolVersion: z.ZodLiteral<1>;
629
+ type: z.ZodLiteral<"protocol.error">;
630
+ requestId: z.ZodOptional<z.ZodString>;
631
+ code: z.ZodEnum<{
632
+ envelope_conflict: "envelope_conflict";
633
+ envelope_expired: "envelope_expired";
634
+ handshake_required: "handshake_required";
635
+ internal_error: "internal_error";
636
+ invalid_state: "invalid_state";
637
+ malformed_message: "malformed_message";
638
+ message_too_large: "message_too_large";
639
+ not_connected: "not_connected";
640
+ protocol_mismatch: "protocol_mismatch";
641
+ route_not_found: "route_not_found";
642
+ route_not_owned: "route_not_owned";
643
+ }>;
644
+ message: z.ZodString;
645
+ supportedVersion: z.ZodOptional<z.ZodLiteral<1>>;
646
+ }, z.core.$strict>;
647
+ export declare const clientMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
648
+ protocolVersion: z.ZodLiteral<1>;
649
+ type: z.ZodLiteral<"client.hello">;
650
+ clientId: z.ZodString;
651
+ installationId: z.ZodString;
652
+ sentAt: z.ZodString;
653
+ }, z.core.$strict>, z.ZodObject<{
654
+ protocolVersion: z.ZodLiteral<1>;
655
+ sessionId: z.ZodString;
656
+ agentName: z.ZodString;
657
+ provider: z.ZodEnum<{
658
+ claude: "claude";
659
+ codex: "codex";
660
+ }>;
661
+ description: z.ZodString;
662
+ capabilities: z.ZodArray<z.ZodEnum<{
663
+ message: "message";
664
+ task: "task";
665
+ }>>;
666
+ state: z.ZodEnum<{
667
+ available: "available";
668
+ busy: "busy";
669
+ }>;
670
+ type: z.ZodLiteral<"agent.register">;
671
+ requestId: z.ZodString;
672
+ leaseSeconds: z.ZodNumber;
673
+ }, z.core.$strict>, z.ZodObject<{
674
+ protocolVersion: z.ZodLiteral<1>;
675
+ type: z.ZodLiteral<"agent.renew">;
676
+ requestId: z.ZodString;
677
+ routeId: z.ZodString;
678
+ state: z.ZodOptional<z.ZodEnum<{
679
+ available: "available";
680
+ busy: "busy";
681
+ }>>;
682
+ leaseSeconds: z.ZodNumber;
683
+ }, z.core.$strict>, z.ZodObject<{
684
+ protocolVersion: z.ZodLiteral<1>;
685
+ type: z.ZodLiteral<"agent.unregister">;
686
+ requestId: z.ZodString;
687
+ routeId: z.ZodString;
688
+ }, z.core.$strict>, z.ZodObject<{
689
+ protocolVersion: z.ZodLiteral<1>;
690
+ type: z.ZodLiteral<"agent.discover">;
691
+ requestId: z.ZodString;
692
+ query: z.ZodOptional<z.ZodString>;
693
+ capability: z.ZodOptional<z.ZodEnum<{
694
+ message: "message";
695
+ task: "task";
696
+ }>>;
697
+ limit: z.ZodDefault<z.ZodNumber>;
698
+ }, z.core.$strict>, z.ZodObject<{
699
+ protocolVersion: z.ZodLiteral<1>;
700
+ type: z.ZodLiteral<"envelope.send">;
701
+ requestId: z.ZodString;
702
+ envelope: z.ZodObject<{
703
+ envelopeId: z.ZodString;
704
+ senderRouteId: z.ZodString;
705
+ targetRouteId: z.ZodString;
706
+ sentAt: z.ZodString;
707
+ expiresAt: z.ZodString;
708
+ event: z.ZodDiscriminatedUnion<[z.ZodObject<{
709
+ eventId: z.ZodString;
710
+ taskId: z.ZodString;
711
+ createdAt: z.ZodString;
712
+ kind: z.ZodLiteral<"offer">;
713
+ state: z.ZodLiteral<"offered">;
714
+ objective: z.ZodString;
715
+ context: z.ZodOptional<z.ZodString>;
716
+ expectedResult: z.ZodOptional<z.ZodString>;
717
+ }, z.core.$strict>, z.ZodObject<{
718
+ eventId: z.ZodString;
719
+ taskId: z.ZodString;
720
+ createdAt: z.ZodString;
721
+ kind: z.ZodLiteral<"accepted">;
722
+ state: z.ZodLiteral<"accepted">;
723
+ message: z.ZodOptional<z.ZodString>;
724
+ }, z.core.$strict>, z.ZodObject<{
725
+ eventId: z.ZodString;
726
+ taskId: z.ZodString;
727
+ createdAt: z.ZodString;
728
+ kind: z.ZodLiteral<"declined">;
729
+ state: z.ZodLiteral<"declined">;
730
+ reason: z.ZodOptional<z.ZodString>;
731
+ }, z.core.$strict>, z.ZodObject<{
732
+ eventId: z.ZodString;
733
+ taskId: z.ZodString;
734
+ createdAt: z.ZodString;
735
+ kind: z.ZodLiteral<"running">;
736
+ state: z.ZodLiteral<"running">;
737
+ message: z.ZodOptional<z.ZodString>;
738
+ }, z.core.$strict>, z.ZodObject<{
739
+ eventId: z.ZodString;
740
+ taskId: z.ZodString;
741
+ createdAt: z.ZodString;
742
+ kind: z.ZodLiteral<"progress">;
743
+ state: z.ZodLiteral<"running">;
744
+ message: z.ZodString;
745
+ }, z.core.$strict>, z.ZodObject<{
746
+ eventId: z.ZodString;
747
+ taskId: z.ZodString;
748
+ createdAt: z.ZodString;
749
+ kind: z.ZodLiteral<"question">;
750
+ state: z.ZodLiteral<"running">;
751
+ question: z.ZodString;
752
+ }, z.core.$strict>, z.ZodObject<{
753
+ eventId: z.ZodString;
754
+ taskId: z.ZodString;
755
+ createdAt: z.ZodString;
756
+ kind: z.ZodLiteral<"answer">;
757
+ state: z.ZodLiteral<"running">;
758
+ answer: z.ZodString;
759
+ }, z.core.$strict>, z.ZodObject<{
760
+ eventId: z.ZodString;
761
+ taskId: z.ZodString;
762
+ createdAt: z.ZodString;
763
+ kind: z.ZodLiteral<"completed">;
764
+ state: z.ZodLiteral<"completed">;
765
+ result: z.ZodString;
766
+ artifactReferences: z.ZodOptional<z.ZodArray<z.ZodString>>;
767
+ }, z.core.$strict>, z.ZodObject<{
768
+ eventId: z.ZodString;
769
+ taskId: z.ZodString;
770
+ createdAt: z.ZodString;
771
+ kind: z.ZodLiteral<"failed">;
772
+ state: z.ZodLiteral<"failed">;
773
+ error: z.ZodString;
774
+ }, z.core.$strict>], "kind">;
775
+ }, z.core.$strict>;
776
+ }, z.core.$strict>, z.ZodObject<{
777
+ protocolVersion: z.ZodLiteral<1>;
778
+ type: z.ZodLiteral<"envelope.acknowledge">;
779
+ requestId: z.ZodString;
780
+ targetRouteId: z.ZodString;
781
+ envelopeId: z.ZodString;
782
+ eventId: z.ZodString;
783
+ status: z.ZodEnum<{
784
+ received: "received";
785
+ rejected: "rejected";
786
+ }>;
787
+ receivedAt: z.ZodString;
788
+ error: z.ZodOptional<z.ZodString>;
789
+ }, z.core.$strict>], "type">;
790
+ export declare const serverMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
791
+ protocolVersion: z.ZodLiteral<1>;
792
+ type: z.ZodLiteral<"server.hello">;
793
+ connectionId: z.ZodString;
794
+ heartbeatIntervalSeconds: z.ZodNumber;
795
+ sentAt: z.ZodString;
796
+ }, z.core.$strict>, z.ZodObject<{
797
+ protocolVersion: z.ZodLiteral<1>;
798
+ type: z.ZodLiteral<"agent.registered">;
799
+ requestId: z.ZodString;
800
+ agent: z.ZodObject<{
801
+ sessionId: z.ZodString;
802
+ agentName: z.ZodString;
803
+ provider: z.ZodEnum<{
804
+ claude: "claude";
805
+ codex: "codex";
806
+ }>;
807
+ description: z.ZodString;
808
+ capabilities: z.ZodArray<z.ZodEnum<{
809
+ message: "message";
810
+ task: "task";
811
+ }>>;
812
+ state: z.ZodEnum<{
813
+ available: "available";
814
+ busy: "busy";
815
+ }>;
816
+ routeId: z.ZodString;
817
+ expiresAt: z.ZodString;
818
+ }, z.core.$strict>;
819
+ }, z.core.$strict>, z.ZodObject<{
820
+ protocolVersion: z.ZodLiteral<1>;
821
+ type: z.ZodLiteral<"agent.renewed">;
822
+ requestId: z.ZodString;
823
+ agent: z.ZodObject<{
824
+ sessionId: z.ZodString;
825
+ agentName: z.ZodString;
826
+ provider: z.ZodEnum<{
827
+ claude: "claude";
828
+ codex: "codex";
829
+ }>;
830
+ description: z.ZodString;
831
+ capabilities: z.ZodArray<z.ZodEnum<{
832
+ message: "message";
833
+ task: "task";
834
+ }>>;
835
+ state: z.ZodEnum<{
836
+ available: "available";
837
+ busy: "busy";
838
+ }>;
839
+ routeId: z.ZodString;
840
+ expiresAt: z.ZodString;
841
+ }, z.core.$strict>;
842
+ }, z.core.$strict>, z.ZodObject<{
843
+ protocolVersion: z.ZodLiteral<1>;
844
+ type: z.ZodLiteral<"agent.unregistered">;
845
+ requestId: z.ZodString;
846
+ routeId: z.ZodString;
847
+ }, z.core.$strict>, z.ZodObject<{
848
+ protocolVersion: z.ZodLiteral<1>;
849
+ type: z.ZodLiteral<"agent.presence">;
850
+ requestId: z.ZodString;
851
+ agents: z.ZodArray<z.ZodObject<{
852
+ sessionId: z.ZodString;
853
+ agentName: z.ZodString;
854
+ provider: z.ZodEnum<{
855
+ claude: "claude";
856
+ codex: "codex";
857
+ }>;
858
+ description: z.ZodString;
859
+ capabilities: z.ZodArray<z.ZodEnum<{
860
+ message: "message";
861
+ task: "task";
862
+ }>>;
863
+ state: z.ZodEnum<{
864
+ available: "available";
865
+ busy: "busy";
866
+ }>;
867
+ routeId: z.ZodString;
868
+ expiresAt: z.ZodString;
869
+ }, z.core.$strict>>;
870
+ }, z.core.$strict>, z.ZodObject<{
871
+ protocolVersion: z.ZodLiteral<1>;
872
+ type: z.ZodLiteral<"envelope.delivery">;
873
+ envelope: z.ZodObject<{
874
+ envelopeId: z.ZodString;
875
+ senderRouteId: z.ZodString;
876
+ targetRouteId: z.ZodString;
877
+ sentAt: z.ZodString;
878
+ expiresAt: z.ZodString;
879
+ event: z.ZodDiscriminatedUnion<[z.ZodObject<{
880
+ eventId: z.ZodString;
881
+ taskId: z.ZodString;
882
+ createdAt: z.ZodString;
883
+ kind: z.ZodLiteral<"offer">;
884
+ state: z.ZodLiteral<"offered">;
885
+ objective: z.ZodString;
886
+ context: z.ZodOptional<z.ZodString>;
887
+ expectedResult: z.ZodOptional<z.ZodString>;
888
+ }, z.core.$strict>, z.ZodObject<{
889
+ eventId: z.ZodString;
890
+ taskId: z.ZodString;
891
+ createdAt: z.ZodString;
892
+ kind: z.ZodLiteral<"accepted">;
893
+ state: z.ZodLiteral<"accepted">;
894
+ message: z.ZodOptional<z.ZodString>;
895
+ }, z.core.$strict>, z.ZodObject<{
896
+ eventId: z.ZodString;
897
+ taskId: z.ZodString;
898
+ createdAt: z.ZodString;
899
+ kind: z.ZodLiteral<"declined">;
900
+ state: z.ZodLiteral<"declined">;
901
+ reason: z.ZodOptional<z.ZodString>;
902
+ }, z.core.$strict>, z.ZodObject<{
903
+ eventId: z.ZodString;
904
+ taskId: z.ZodString;
905
+ createdAt: z.ZodString;
906
+ kind: z.ZodLiteral<"running">;
907
+ state: z.ZodLiteral<"running">;
908
+ message: z.ZodOptional<z.ZodString>;
909
+ }, z.core.$strict>, z.ZodObject<{
910
+ eventId: z.ZodString;
911
+ taskId: z.ZodString;
912
+ createdAt: z.ZodString;
913
+ kind: z.ZodLiteral<"progress">;
914
+ state: z.ZodLiteral<"running">;
915
+ message: z.ZodString;
916
+ }, z.core.$strict>, z.ZodObject<{
917
+ eventId: z.ZodString;
918
+ taskId: z.ZodString;
919
+ createdAt: z.ZodString;
920
+ kind: z.ZodLiteral<"question">;
921
+ state: z.ZodLiteral<"running">;
922
+ question: z.ZodString;
923
+ }, z.core.$strict>, z.ZodObject<{
924
+ eventId: z.ZodString;
925
+ taskId: z.ZodString;
926
+ createdAt: z.ZodString;
927
+ kind: z.ZodLiteral<"answer">;
928
+ state: z.ZodLiteral<"running">;
929
+ answer: z.ZodString;
930
+ }, z.core.$strict>, z.ZodObject<{
931
+ eventId: z.ZodString;
932
+ taskId: z.ZodString;
933
+ createdAt: z.ZodString;
934
+ kind: z.ZodLiteral<"completed">;
935
+ state: z.ZodLiteral<"completed">;
936
+ result: z.ZodString;
937
+ artifactReferences: z.ZodOptional<z.ZodArray<z.ZodString>>;
938
+ }, z.core.$strict>, z.ZodObject<{
939
+ eventId: z.ZodString;
940
+ taskId: z.ZodString;
941
+ createdAt: z.ZodString;
942
+ kind: z.ZodLiteral<"failed">;
943
+ state: z.ZodLiteral<"failed">;
944
+ error: z.ZodString;
945
+ }, z.core.$strict>], "kind">;
946
+ }, z.core.$strict>;
947
+ }, z.core.$strict>, z.ZodObject<{
948
+ protocolVersion: z.ZodLiteral<1>;
949
+ type: z.ZodLiteral<"envelope.acknowledge.accepted">;
950
+ requestId: z.ZodString;
951
+ envelopeId: z.ZodString;
952
+ eventId: z.ZodString;
953
+ }, z.core.$strict>, z.ZodObject<{
954
+ protocolVersion: z.ZodLiteral<1>;
955
+ type: z.ZodLiteral<"envelope.acknowledged">;
956
+ envelopeId: z.ZodString;
957
+ eventId: z.ZodString;
958
+ status: z.ZodEnum<{
959
+ received: "received";
960
+ rejected: "rejected";
961
+ }>;
962
+ receivedAt: z.ZodString;
963
+ error: z.ZodOptional<z.ZodString>;
964
+ }, z.core.$strict>, z.ZodObject<{
965
+ protocolVersion: z.ZodLiteral<1>;
966
+ type: z.ZodLiteral<"protocol.error">;
967
+ requestId: z.ZodOptional<z.ZodString>;
968
+ code: z.ZodEnum<{
969
+ envelope_conflict: "envelope_conflict";
970
+ envelope_expired: "envelope_expired";
971
+ handshake_required: "handshake_required";
972
+ internal_error: "internal_error";
973
+ invalid_state: "invalid_state";
974
+ malformed_message: "malformed_message";
975
+ message_too_large: "message_too_large";
976
+ not_connected: "not_connected";
977
+ protocol_mismatch: "protocol_mismatch";
978
+ route_not_found: "route_not_found";
979
+ route_not_owned: "route_not_owned";
980
+ }>;
981
+ message: z.ZodString;
982
+ supportedVersion: z.ZodOptional<z.ZodLiteral<1>>;
983
+ }, z.core.$strict>], "type">;
984
+ export declare const networkMessageSchema: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
985
+ protocolVersion: z.ZodLiteral<1>;
986
+ type: z.ZodLiteral<"client.hello">;
987
+ clientId: z.ZodString;
988
+ installationId: z.ZodString;
989
+ sentAt: z.ZodString;
990
+ }, z.core.$strict>, z.ZodObject<{
991
+ protocolVersion: z.ZodLiteral<1>;
992
+ sessionId: z.ZodString;
993
+ agentName: z.ZodString;
994
+ provider: z.ZodEnum<{
995
+ claude: "claude";
996
+ codex: "codex";
997
+ }>;
998
+ description: z.ZodString;
999
+ capabilities: z.ZodArray<z.ZodEnum<{
1000
+ message: "message";
1001
+ task: "task";
1002
+ }>>;
1003
+ state: z.ZodEnum<{
1004
+ available: "available";
1005
+ busy: "busy";
1006
+ }>;
1007
+ type: z.ZodLiteral<"agent.register">;
1008
+ requestId: z.ZodString;
1009
+ leaseSeconds: z.ZodNumber;
1010
+ }, z.core.$strict>, z.ZodObject<{
1011
+ protocolVersion: z.ZodLiteral<1>;
1012
+ type: z.ZodLiteral<"agent.renew">;
1013
+ requestId: z.ZodString;
1014
+ routeId: z.ZodString;
1015
+ state: z.ZodOptional<z.ZodEnum<{
1016
+ available: "available";
1017
+ busy: "busy";
1018
+ }>>;
1019
+ leaseSeconds: z.ZodNumber;
1020
+ }, z.core.$strict>, z.ZodObject<{
1021
+ protocolVersion: z.ZodLiteral<1>;
1022
+ type: z.ZodLiteral<"agent.unregister">;
1023
+ requestId: z.ZodString;
1024
+ routeId: z.ZodString;
1025
+ }, z.core.$strict>, z.ZodObject<{
1026
+ protocolVersion: z.ZodLiteral<1>;
1027
+ type: z.ZodLiteral<"agent.discover">;
1028
+ requestId: z.ZodString;
1029
+ query: z.ZodOptional<z.ZodString>;
1030
+ capability: z.ZodOptional<z.ZodEnum<{
1031
+ message: "message";
1032
+ task: "task";
1033
+ }>>;
1034
+ limit: z.ZodDefault<z.ZodNumber>;
1035
+ }, z.core.$strict>, z.ZodObject<{
1036
+ protocolVersion: z.ZodLiteral<1>;
1037
+ type: z.ZodLiteral<"envelope.send">;
1038
+ requestId: z.ZodString;
1039
+ envelope: z.ZodObject<{
1040
+ envelopeId: z.ZodString;
1041
+ senderRouteId: z.ZodString;
1042
+ targetRouteId: z.ZodString;
1043
+ sentAt: z.ZodString;
1044
+ expiresAt: z.ZodString;
1045
+ event: z.ZodDiscriminatedUnion<[z.ZodObject<{
1046
+ eventId: z.ZodString;
1047
+ taskId: z.ZodString;
1048
+ createdAt: z.ZodString;
1049
+ kind: z.ZodLiteral<"offer">;
1050
+ state: z.ZodLiteral<"offered">;
1051
+ objective: z.ZodString;
1052
+ context: z.ZodOptional<z.ZodString>;
1053
+ expectedResult: z.ZodOptional<z.ZodString>;
1054
+ }, z.core.$strict>, z.ZodObject<{
1055
+ eventId: z.ZodString;
1056
+ taskId: z.ZodString;
1057
+ createdAt: z.ZodString;
1058
+ kind: z.ZodLiteral<"accepted">;
1059
+ state: z.ZodLiteral<"accepted">;
1060
+ message: z.ZodOptional<z.ZodString>;
1061
+ }, z.core.$strict>, z.ZodObject<{
1062
+ eventId: z.ZodString;
1063
+ taskId: z.ZodString;
1064
+ createdAt: z.ZodString;
1065
+ kind: z.ZodLiteral<"declined">;
1066
+ state: z.ZodLiteral<"declined">;
1067
+ reason: z.ZodOptional<z.ZodString>;
1068
+ }, z.core.$strict>, z.ZodObject<{
1069
+ eventId: z.ZodString;
1070
+ taskId: z.ZodString;
1071
+ createdAt: z.ZodString;
1072
+ kind: z.ZodLiteral<"running">;
1073
+ state: z.ZodLiteral<"running">;
1074
+ message: z.ZodOptional<z.ZodString>;
1075
+ }, z.core.$strict>, z.ZodObject<{
1076
+ eventId: z.ZodString;
1077
+ taskId: z.ZodString;
1078
+ createdAt: z.ZodString;
1079
+ kind: z.ZodLiteral<"progress">;
1080
+ state: z.ZodLiteral<"running">;
1081
+ message: z.ZodString;
1082
+ }, z.core.$strict>, z.ZodObject<{
1083
+ eventId: z.ZodString;
1084
+ taskId: z.ZodString;
1085
+ createdAt: z.ZodString;
1086
+ kind: z.ZodLiteral<"question">;
1087
+ state: z.ZodLiteral<"running">;
1088
+ question: z.ZodString;
1089
+ }, z.core.$strict>, z.ZodObject<{
1090
+ eventId: z.ZodString;
1091
+ taskId: z.ZodString;
1092
+ createdAt: z.ZodString;
1093
+ kind: z.ZodLiteral<"answer">;
1094
+ state: z.ZodLiteral<"running">;
1095
+ answer: z.ZodString;
1096
+ }, z.core.$strict>, z.ZodObject<{
1097
+ eventId: z.ZodString;
1098
+ taskId: z.ZodString;
1099
+ createdAt: z.ZodString;
1100
+ kind: z.ZodLiteral<"completed">;
1101
+ state: z.ZodLiteral<"completed">;
1102
+ result: z.ZodString;
1103
+ artifactReferences: z.ZodOptional<z.ZodArray<z.ZodString>>;
1104
+ }, z.core.$strict>, z.ZodObject<{
1105
+ eventId: z.ZodString;
1106
+ taskId: z.ZodString;
1107
+ createdAt: z.ZodString;
1108
+ kind: z.ZodLiteral<"failed">;
1109
+ state: z.ZodLiteral<"failed">;
1110
+ error: z.ZodString;
1111
+ }, z.core.$strict>], "kind">;
1112
+ }, z.core.$strict>;
1113
+ }, z.core.$strict>, z.ZodObject<{
1114
+ protocolVersion: z.ZodLiteral<1>;
1115
+ type: z.ZodLiteral<"envelope.acknowledge">;
1116
+ requestId: z.ZodString;
1117
+ targetRouteId: z.ZodString;
1118
+ envelopeId: z.ZodString;
1119
+ eventId: z.ZodString;
1120
+ status: z.ZodEnum<{
1121
+ received: "received";
1122
+ rejected: "rejected";
1123
+ }>;
1124
+ receivedAt: z.ZodString;
1125
+ error: z.ZodOptional<z.ZodString>;
1126
+ }, z.core.$strict>], "type">, z.ZodDiscriminatedUnion<[z.ZodObject<{
1127
+ protocolVersion: z.ZodLiteral<1>;
1128
+ type: z.ZodLiteral<"server.hello">;
1129
+ connectionId: z.ZodString;
1130
+ heartbeatIntervalSeconds: z.ZodNumber;
1131
+ sentAt: z.ZodString;
1132
+ }, z.core.$strict>, z.ZodObject<{
1133
+ protocolVersion: z.ZodLiteral<1>;
1134
+ type: z.ZodLiteral<"agent.registered">;
1135
+ requestId: z.ZodString;
1136
+ agent: z.ZodObject<{
1137
+ sessionId: z.ZodString;
1138
+ agentName: z.ZodString;
1139
+ provider: z.ZodEnum<{
1140
+ claude: "claude";
1141
+ codex: "codex";
1142
+ }>;
1143
+ description: z.ZodString;
1144
+ capabilities: z.ZodArray<z.ZodEnum<{
1145
+ message: "message";
1146
+ task: "task";
1147
+ }>>;
1148
+ state: z.ZodEnum<{
1149
+ available: "available";
1150
+ busy: "busy";
1151
+ }>;
1152
+ routeId: z.ZodString;
1153
+ expiresAt: z.ZodString;
1154
+ }, z.core.$strict>;
1155
+ }, z.core.$strict>, z.ZodObject<{
1156
+ protocolVersion: z.ZodLiteral<1>;
1157
+ type: z.ZodLiteral<"agent.renewed">;
1158
+ requestId: z.ZodString;
1159
+ agent: z.ZodObject<{
1160
+ sessionId: z.ZodString;
1161
+ agentName: z.ZodString;
1162
+ provider: z.ZodEnum<{
1163
+ claude: "claude";
1164
+ codex: "codex";
1165
+ }>;
1166
+ description: z.ZodString;
1167
+ capabilities: z.ZodArray<z.ZodEnum<{
1168
+ message: "message";
1169
+ task: "task";
1170
+ }>>;
1171
+ state: z.ZodEnum<{
1172
+ available: "available";
1173
+ busy: "busy";
1174
+ }>;
1175
+ routeId: z.ZodString;
1176
+ expiresAt: z.ZodString;
1177
+ }, z.core.$strict>;
1178
+ }, z.core.$strict>, z.ZodObject<{
1179
+ protocolVersion: z.ZodLiteral<1>;
1180
+ type: z.ZodLiteral<"agent.unregistered">;
1181
+ requestId: z.ZodString;
1182
+ routeId: z.ZodString;
1183
+ }, z.core.$strict>, z.ZodObject<{
1184
+ protocolVersion: z.ZodLiteral<1>;
1185
+ type: z.ZodLiteral<"agent.presence">;
1186
+ requestId: z.ZodString;
1187
+ agents: z.ZodArray<z.ZodObject<{
1188
+ sessionId: z.ZodString;
1189
+ agentName: z.ZodString;
1190
+ provider: z.ZodEnum<{
1191
+ claude: "claude";
1192
+ codex: "codex";
1193
+ }>;
1194
+ description: z.ZodString;
1195
+ capabilities: z.ZodArray<z.ZodEnum<{
1196
+ message: "message";
1197
+ task: "task";
1198
+ }>>;
1199
+ state: z.ZodEnum<{
1200
+ available: "available";
1201
+ busy: "busy";
1202
+ }>;
1203
+ routeId: z.ZodString;
1204
+ expiresAt: z.ZodString;
1205
+ }, z.core.$strict>>;
1206
+ }, z.core.$strict>, z.ZodObject<{
1207
+ protocolVersion: z.ZodLiteral<1>;
1208
+ type: z.ZodLiteral<"envelope.delivery">;
1209
+ envelope: z.ZodObject<{
1210
+ envelopeId: z.ZodString;
1211
+ senderRouteId: z.ZodString;
1212
+ targetRouteId: z.ZodString;
1213
+ sentAt: z.ZodString;
1214
+ expiresAt: z.ZodString;
1215
+ event: z.ZodDiscriminatedUnion<[z.ZodObject<{
1216
+ eventId: z.ZodString;
1217
+ taskId: z.ZodString;
1218
+ createdAt: z.ZodString;
1219
+ kind: z.ZodLiteral<"offer">;
1220
+ state: z.ZodLiteral<"offered">;
1221
+ objective: z.ZodString;
1222
+ context: z.ZodOptional<z.ZodString>;
1223
+ expectedResult: z.ZodOptional<z.ZodString>;
1224
+ }, z.core.$strict>, z.ZodObject<{
1225
+ eventId: z.ZodString;
1226
+ taskId: z.ZodString;
1227
+ createdAt: z.ZodString;
1228
+ kind: z.ZodLiteral<"accepted">;
1229
+ state: z.ZodLiteral<"accepted">;
1230
+ message: z.ZodOptional<z.ZodString>;
1231
+ }, z.core.$strict>, z.ZodObject<{
1232
+ eventId: z.ZodString;
1233
+ taskId: z.ZodString;
1234
+ createdAt: z.ZodString;
1235
+ kind: z.ZodLiteral<"declined">;
1236
+ state: z.ZodLiteral<"declined">;
1237
+ reason: z.ZodOptional<z.ZodString>;
1238
+ }, z.core.$strict>, z.ZodObject<{
1239
+ eventId: z.ZodString;
1240
+ taskId: z.ZodString;
1241
+ createdAt: z.ZodString;
1242
+ kind: z.ZodLiteral<"running">;
1243
+ state: z.ZodLiteral<"running">;
1244
+ message: z.ZodOptional<z.ZodString>;
1245
+ }, z.core.$strict>, z.ZodObject<{
1246
+ eventId: z.ZodString;
1247
+ taskId: z.ZodString;
1248
+ createdAt: z.ZodString;
1249
+ kind: z.ZodLiteral<"progress">;
1250
+ state: z.ZodLiteral<"running">;
1251
+ message: z.ZodString;
1252
+ }, z.core.$strict>, z.ZodObject<{
1253
+ eventId: z.ZodString;
1254
+ taskId: z.ZodString;
1255
+ createdAt: z.ZodString;
1256
+ kind: z.ZodLiteral<"question">;
1257
+ state: z.ZodLiteral<"running">;
1258
+ question: z.ZodString;
1259
+ }, z.core.$strict>, z.ZodObject<{
1260
+ eventId: z.ZodString;
1261
+ taskId: z.ZodString;
1262
+ createdAt: z.ZodString;
1263
+ kind: z.ZodLiteral<"answer">;
1264
+ state: z.ZodLiteral<"running">;
1265
+ answer: z.ZodString;
1266
+ }, z.core.$strict>, z.ZodObject<{
1267
+ eventId: z.ZodString;
1268
+ taskId: z.ZodString;
1269
+ createdAt: z.ZodString;
1270
+ kind: z.ZodLiteral<"completed">;
1271
+ state: z.ZodLiteral<"completed">;
1272
+ result: z.ZodString;
1273
+ artifactReferences: z.ZodOptional<z.ZodArray<z.ZodString>>;
1274
+ }, z.core.$strict>, z.ZodObject<{
1275
+ eventId: z.ZodString;
1276
+ taskId: z.ZodString;
1277
+ createdAt: z.ZodString;
1278
+ kind: z.ZodLiteral<"failed">;
1279
+ state: z.ZodLiteral<"failed">;
1280
+ error: z.ZodString;
1281
+ }, z.core.$strict>], "kind">;
1282
+ }, z.core.$strict>;
1283
+ }, z.core.$strict>, z.ZodObject<{
1284
+ protocolVersion: z.ZodLiteral<1>;
1285
+ type: z.ZodLiteral<"envelope.acknowledge.accepted">;
1286
+ requestId: z.ZodString;
1287
+ envelopeId: z.ZodString;
1288
+ eventId: z.ZodString;
1289
+ }, z.core.$strict>, z.ZodObject<{
1290
+ protocolVersion: z.ZodLiteral<1>;
1291
+ type: z.ZodLiteral<"envelope.acknowledged">;
1292
+ envelopeId: z.ZodString;
1293
+ eventId: z.ZodString;
1294
+ status: z.ZodEnum<{
1295
+ received: "received";
1296
+ rejected: "rejected";
1297
+ }>;
1298
+ receivedAt: z.ZodString;
1299
+ error: z.ZodOptional<z.ZodString>;
1300
+ }, z.core.$strict>, z.ZodObject<{
1301
+ protocolVersion: z.ZodLiteral<1>;
1302
+ type: z.ZodLiteral<"protocol.error">;
1303
+ requestId: z.ZodOptional<z.ZodString>;
1304
+ code: z.ZodEnum<{
1305
+ envelope_conflict: "envelope_conflict";
1306
+ envelope_expired: "envelope_expired";
1307
+ handshake_required: "handshake_required";
1308
+ internal_error: "internal_error";
1309
+ invalid_state: "invalid_state";
1310
+ malformed_message: "malformed_message";
1311
+ message_too_large: "message_too_large";
1312
+ not_connected: "not_connected";
1313
+ protocol_mismatch: "protocol_mismatch";
1314
+ route_not_found: "route_not_found";
1315
+ route_not_owned: "route_not_owned";
1316
+ }>;
1317
+ message: z.ZodString;
1318
+ supportedVersion: z.ZodOptional<z.ZodLiteral<1>>;
1319
+ }, z.core.$strict>], "type">]>;
1320
+ export type AgentPresence = z.infer<typeof agentPresenceSchema>;
1321
+ export type ClientHello = z.infer<typeof clientHelloSchema>;
1322
+ export type ServerHello = z.infer<typeof serverHelloSchema>;
1323
+ export type AgentRegister = z.infer<typeof agentRegisterSchema>;
1324
+ export type AgentRegistered = z.infer<typeof agentRegisteredSchema>;
1325
+ export type AgentRenew = z.infer<typeof agentRenewSchema>;
1326
+ export type AgentRenewed = z.infer<typeof agentRenewedSchema>;
1327
+ export type AgentUnregister = z.infer<typeof agentUnregisterSchema>;
1328
+ export type AgentUnregistered = z.infer<typeof agentUnregisteredSchema>;
1329
+ export type AgentDiscover = z.infer<typeof agentDiscoverSchema>;
1330
+ export type AgentPresenceResult = z.infer<typeof agentPresenceResultSchema>;
1331
+ export type TaskEventKind = z.infer<typeof taskEventKindSchema>;
1332
+ export type TaskState = z.infer<typeof taskStateSchema>;
1333
+ export type TaskEvent = z.infer<typeof taskEventSchema>;
1334
+ export type Envelope = z.infer<typeof envelopeSchema>;
1335
+ export type EnvelopeSend = z.infer<typeof envelopeSendSchema>;
1336
+ export type EnvelopeDelivery = z.infer<typeof envelopeDeliverySchema>;
1337
+ export type EnvelopeAcknowledge = z.infer<typeof envelopeAcknowledgeSchema>;
1338
+ export type EnvelopeAcknowledgeAccepted = z.infer<typeof envelopeAcknowledgeAcceptedSchema>;
1339
+ export type EnvelopeAcknowledged = z.infer<typeof envelopeAcknowledgedSchema>;
1340
+ export type ProtocolError = z.infer<typeof protocolErrorSchema>;
1341
+ export type ClientMessage = z.infer<typeof clientMessageSchema>;
1342
+ export type ServerMessage = z.infer<typeof serverMessageSchema>;
1343
+ export type NetworkMessage = z.infer<typeof networkMessageSchema>;
1344
+ /** M0 compatibility rule: peers communicate only when protocol versions are exactly equal. */
1345
+ export declare function isProtocolVersionCompatible(peerVersion: number): peerVersion is typeof PROTOCOL_VERSION;
1346
+ /** Parse a decoded object or a UTF-8 JSON WebSocket frame with uniform wire errors. */
1347
+ export declare function parseNetworkMessage(input: string | unknown): NetworkMessage;
1348
+ export interface NetworkTransport {
1349
+ send(message: ClientMessage): Promise<void>;
1350
+ onMessage(handler: (message: ServerMessage) => void | Promise<void>): () => void;
1351
+ close(): Promise<void>;
1352
+ }