@meistrari/chat-nuxt 4.9.0 → 4.10.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@meistrari/chat-nuxt",
3
3
  "configKey": "chatNuxt",
4
- "version": "4.9.0-rc.0",
4
+ "version": "4.10.0-rc.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
@@ -0,0 +1,55 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Chat API v3 (`/v3/chat`): the conversational surface over agent-api v5 events-v1.
4
+ * The chat-api owns the conversation; agent-api owns the session and its history.
5
+ */
6
+ export declare const CHAT_V3_CONTRACT_VERSION = "events-v1";
7
+ /** Where the agent of the request stands in the v5 catalog. */
8
+ export declare const chatV3AgentStatusSchema: z.ZodEnum<{
9
+ ready: "ready";
10
+ not_requested: "not_requested";
11
+ not_in_catalog: "not_in_catalog";
12
+ not_published: "not_published";
13
+ }>;
14
+ export type ChatV3AgentStatus = z.infer<typeof chatV3AgentStatusSchema>;
15
+ export declare const chatV3AgentSchema: z.ZodObject<{
16
+ agentId: z.ZodString;
17
+ repository: z.ZodString;
18
+ harness: z.ZodNullable<z.ZodEnum<{
19
+ claude: "claude";
20
+ lightweight: "lightweight";
21
+ codex: "codex";
22
+ }>>;
23
+ model: z.ZodNullable<z.ZodString>;
24
+ publishedSnapshotId: z.ZodNullable<z.ZodString>;
25
+ publishedCommitSha: z.ZodNullable<z.ZodString>;
26
+ }, z.core.$strip>;
27
+ export type ChatV3Agent = z.infer<typeof chatV3AgentSchema>;
28
+ export declare const chatV3ConfigurationSchema: z.ZodObject<{
29
+ apiVersion: z.ZodLiteral<3>;
30
+ contractVersion: z.ZodLiteral<"events-v1">;
31
+ agentStatus: z.ZodEnum<{
32
+ ready: "ready";
33
+ not_requested: "not_requested";
34
+ not_in_catalog: "not_in_catalog";
35
+ not_published: "not_published";
36
+ }>;
37
+ agent: z.ZodNullable<z.ZodObject<{
38
+ agentId: z.ZodString;
39
+ repository: z.ZodString;
40
+ harness: z.ZodNullable<z.ZodEnum<{
41
+ claude: "claude";
42
+ lightweight: "lightweight";
43
+ codex: "codex";
44
+ }>>;
45
+ model: z.ZodNullable<z.ZodString>;
46
+ publishedSnapshotId: z.ZodNullable<z.ZodString>;
47
+ publishedCommitSha: z.ZodNullable<z.ZodString>;
48
+ }, z.core.$strip>>;
49
+ limits: z.ZodObject<{
50
+ messageTextChars: z.ZodNumber;
51
+ inlinePayloadBytes: z.ZodNumber;
52
+ eventsPerRequest: z.ZodNumber;
53
+ }, z.core.$strip>;
54
+ }, z.core.$strip>;
55
+ export type ChatV3Configuration = z.infer<typeof chatV3ConfigurationSchema>;
@@ -0,0 +1,37 @@
1
+ import { z } from 'zod';
2
+ import { v5HarnessSchema } from '../integrations/agent-events';
3
+ /**
4
+ * Chat API v3 (`/v3/chat`): the conversational surface over agent-api v5 events-v1.
5
+ * The chat-api owns the conversation; agent-api owns the session and its history.
6
+ */
7
+ export const CHAT_V3_CONTRACT_VERSION = 'events-v1';
8
+ /** Where the agent of the request stands in the v5 catalog. */
9
+ export const chatV3AgentStatusSchema = z.enum([
10
+ /** No `telaAgentId` on the request: nothing to resolve yet. */
11
+ 'not_requested',
12
+ /** Tela knows the agent, but the v5 catalog does not: Tela has to create it there. */
13
+ 'not_in_catalog',
14
+ /** In the catalog without a publication: `POST /v5/agents/snapshots` first. */
15
+ 'not_published',
16
+ /** Published: a session can start. */
17
+ 'ready',
18
+ ]);
19
+ export const chatV3AgentSchema = z.object({
20
+ agentId: z.string().uuid(),
21
+ repository: z.string(),
22
+ harness: v5HarnessSchema.nullable(),
23
+ model: z.string().nullable(),
24
+ publishedSnapshotId: z.string().uuid().nullable(),
25
+ publishedCommitSha: z.string().nullable(),
26
+ });
27
+ export const chatV3ConfigurationSchema = z.object({
28
+ apiVersion: z.literal(3),
29
+ contractVersion: z.literal(CHAT_V3_CONTRACT_VERSION),
30
+ agentStatus: chatV3AgentStatusSchema,
31
+ agent: chatV3AgentSchema.nullable(),
32
+ limits: z.object({
33
+ messageTextChars: z.number().int().positive(),
34
+ inlinePayloadBytes: z.number().int().positive(),
35
+ eventsPerRequest: z.number().int().positive(),
36
+ }),
37
+ });
@@ -0,0 +1,901 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Agent events: client-side mirror of the agent-api v5 events-v1 contract (`packages/models` in
4
+ * meistrari/agent-api). Responses are parsed as loose objects so a field the API adds
5
+ * later never breaks the chat; requests keep the API's own limits so a bad payload is
6
+ * refused here, before it travels.
7
+ */
8
+ export declare const v5Limits: {
9
+ readonly messageTextChars: 200000;
10
+ readonly inputTextChars: 800000;
11
+ readonly userEventBytes: 1048576;
12
+ readonly inlinePayloadBytes: 16384;
13
+ readonly eventsPerRequest: 32;
14
+ readonly idempotencyKeyChars: 200;
15
+ readonly turnIdChars: 200;
16
+ readonly attributionChars: 200;
17
+ readonly eventPage: {
18
+ readonly default: 100;
19
+ readonly max: 500;
20
+ };
21
+ readonly artifactPage: {
22
+ readonly default: 100;
23
+ readonly max: 100;
24
+ };
25
+ readonly sessionList: 100;
26
+ readonly turnList: 500;
27
+ readonly agentList: 100;
28
+ readonly draftTextChars: 65536;
29
+ readonly streamHeartbeatMs: 15000;
30
+ };
31
+ /** Every code a v5 route answers in `{ error }`, with its HTTP status. */
32
+ export declare const v5ErrorStatus: {
33
+ readonly invalid_request: 400;
34
+ readonly invalid_vault_reference: 400;
35
+ readonly input_payload_required: 400;
36
+ readonly invalid_tool_result_answers: 400;
37
+ readonly cursor_not_found: 400;
38
+ readonly invalid_event_limit: 400;
39
+ readonly invalid_artifact_limit: 400;
40
+ readonly invalid_user_event_batch: 400;
41
+ readonly provider_harness_mismatch: 400;
42
+ readonly insufficient_role: 403;
43
+ readonly agent_publication_forbidden: 403;
44
+ readonly session_not_found: 404;
45
+ readonly agent_not_found: 404;
46
+ readonly snapshot_not_found: 404;
47
+ readonly event_not_found: 404;
48
+ readonly message_not_found: 404;
49
+ readonly turn_not_found: 404;
50
+ readonly artifact_not_found: 404;
51
+ readonly repository_not_found: 404;
52
+ readonly commit_not_found: 404;
53
+ readonly content_unavailable: 404;
54
+ readonly idempotency_conflict: 409;
55
+ readonly agent_not_published: 409;
56
+ readonly snapshot_not_ready: 409;
57
+ readonly snapshot_protected: 409;
58
+ readonly snapshot_build_in_progress: 409;
59
+ readonly session_closed: 409;
60
+ readonly turn_not_running: 409;
61
+ readonly user_event_already_dispatched: 409;
62
+ readonly invalid_tool_result: 409;
63
+ readonly repository_ambiguous: 409;
64
+ readonly user_event_too_large: 413;
65
+ readonly request_too_large: 413;
66
+ readonly payload_not_offloaded: 413;
67
+ readonly agent_config_invalid: 422;
68
+ readonly model_not_on_provider: 422;
69
+ readonly internal_error: 500;
70
+ readonly session_vault_unavailable: 503;
71
+ readonly detached_delivery_unavailable: 503;
72
+ readonly content_storage_unavailable: 503;
73
+ readonly artifact_storage_unavailable: 503;
74
+ readonly snapshot_publishing_unavailable: 503;
75
+ };
76
+ export type V5ErrorCode = keyof typeof v5ErrorStatus;
77
+ export declare const v5ErrorBodySchema: z.ZodObject<{
78
+ error: z.ZodString;
79
+ }, z.core.$strip>;
80
+ export declare const v5EventIdSchema: z.ZodString;
81
+ export declare const v5TurnIdSchema: z.ZodString;
82
+ export declare const v5HarnessSchema: z.ZodEnum<{
83
+ claude: "claude";
84
+ lightweight: "lightweight";
85
+ codex: "codex";
86
+ }>;
87
+ export declare const v5SessionStatusSchema: z.ZodEnum<{
88
+ running: "running";
89
+ failed: "failed";
90
+ ready: "ready";
91
+ initializing: "initializing";
92
+ paused: "paused";
93
+ detached: "detached";
94
+ closing: "closing";
95
+ closed: "closed";
96
+ }>;
97
+ export declare const v5UserEventStatusSchema: z.ZodEnum<{
98
+ running: "running";
99
+ completed: "completed";
100
+ failed: "failed";
101
+ cancelled: "cancelled";
102
+ queued: "queued";
103
+ dispatched: "dispatched";
104
+ received: "received";
105
+ uncertain: "uncertain";
106
+ }>;
107
+ export declare const v5UserEventTypeSchema: z.ZodEnum<{
108
+ input: "input";
109
+ "tool-result": "tool-result";
110
+ "message-queue": "message-queue";
111
+ "message-steer": "message-steer";
112
+ cancel: "cancel";
113
+ }>;
114
+ export declare const VAULT_REFERENCE_PREFIX = "vault://";
115
+ export declare function isVaultReference(payload: string): boolean;
116
+ export declare const v5VaultReferenceSchema: z.ZodString;
117
+ /** A user event as the client sends it: a message, a steer, an input, a cancel or an answer. */
118
+ export declare const v5UserEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
119
+ type: z.ZodLiteral<"message-queue">;
120
+ payload: z.ZodString;
121
+ }, z.core.$strict>, z.ZodObject<{
122
+ type: z.ZodLiteral<"message-steer">;
123
+ turnId: z.ZodString;
124
+ payload: z.ZodString;
125
+ }, z.core.$strict>, z.ZodObject<{
126
+ type: z.ZodLiteral<"input">;
127
+ name: z.ZodOptional<z.ZodString>;
128
+ payload: z.ZodOptional<z.ZodString>;
129
+ }, z.core.$strict>, z.ZodObject<{
130
+ type: z.ZodLiteral<"cancel">;
131
+ turnId: z.ZodString;
132
+ }, z.core.$strict>, z.ZodObject<{
133
+ type: z.ZodLiteral<"tool-result">;
134
+ toolCallId: z.ZodString;
135
+ payload: z.ZodString;
136
+ }, z.core.$strict>], "type">;
137
+ export type V5UserEvent = z.infer<typeof v5UserEventSchema>;
138
+ export declare const v5EventsRequestSchema: z.ZodObject<{
139
+ events: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
140
+ type: z.ZodLiteral<"message-queue">;
141
+ payload: z.ZodString;
142
+ }, z.core.$strict>, z.ZodObject<{
143
+ type: z.ZodLiteral<"message-steer">;
144
+ turnId: z.ZodString;
145
+ payload: z.ZodString;
146
+ }, z.core.$strict>, z.ZodObject<{
147
+ type: z.ZodLiteral<"input">;
148
+ name: z.ZodOptional<z.ZodString>;
149
+ payload: z.ZodOptional<z.ZodString>;
150
+ }, z.core.$strict>, z.ZodObject<{
151
+ type: z.ZodLiteral<"cancel">;
152
+ turnId: z.ZodString;
153
+ }, z.core.$strict>, z.ZodObject<{
154
+ type: z.ZodLiteral<"tool-result">;
155
+ toolCallId: z.ZodString;
156
+ payload: z.ZodString;
157
+ }, z.core.$strict>], "type">>;
158
+ }, z.core.$strict>;
159
+ export type V5EventsRequest = z.infer<typeof v5EventsRequestSchema>;
160
+ export declare const v5EventReceiptSchema: z.ZodObject<{
161
+ eventId: z.ZodString;
162
+ type: z.ZodEnum<{
163
+ input: "input";
164
+ "tool-result": "tool-result";
165
+ "message-queue": "message-queue";
166
+ "message-steer": "message-steer";
167
+ cancel: "cancel";
168
+ }>;
169
+ messageId: z.ZodOptional<z.ZodString>;
170
+ sessionId: z.ZodString;
171
+ turnId: z.ZodNullable<z.ZodString>;
172
+ status: z.ZodEnum<{
173
+ running: "running";
174
+ completed: "completed";
175
+ failed: "failed";
176
+ cancelled: "cancelled";
177
+ queued: "queued";
178
+ dispatched: "dispatched";
179
+ received: "received";
180
+ uncertain: "uncertain";
181
+ }>;
182
+ }, z.core.$loose>;
183
+ export type V5EventReceipt = z.infer<typeof v5EventReceiptSchema>;
184
+ export declare const v5EventsReceiptSchema: z.ZodObject<{
185
+ events: z.ZodArray<z.ZodObject<{
186
+ eventId: z.ZodString;
187
+ type: z.ZodEnum<{
188
+ input: "input";
189
+ "tool-result": "tool-result";
190
+ "message-queue": "message-queue";
191
+ "message-steer": "message-steer";
192
+ cancel: "cancel";
193
+ }>;
194
+ messageId: z.ZodOptional<z.ZodString>;
195
+ sessionId: z.ZodString;
196
+ turnId: z.ZodNullable<z.ZodString>;
197
+ status: z.ZodEnum<{
198
+ running: "running";
199
+ completed: "completed";
200
+ failed: "failed";
201
+ cancelled: "cancelled";
202
+ queued: "queued";
203
+ dispatched: "dispatched";
204
+ received: "received";
205
+ uncertain: "uncertain";
206
+ }>;
207
+ }, z.core.$loose>>;
208
+ }, z.core.$loose>;
209
+ /**
210
+ * Hints of the stored event types the chat reads. Unknown types still parse (the type is an open
211
+ * string); `parseV5EventHint` gives the typed hint for the ones listed here.
212
+ */
213
+ export declare const v5EventHintSchemas: {
214
+ readonly 'session.initializing': z.ZodObject<{
215
+ executionMode: z.ZodOptional<z.ZodEnum<{
216
+ chat: "chat";
217
+ sync: "sync";
218
+ async: "async";
219
+ }>>;
220
+ resumed: z.ZodOptional<z.ZodLiteral<true>>;
221
+ }, z.core.$loose>;
222
+ readonly 'session.ready': z.ZodObject<{
223
+ resumed: z.ZodOptional<z.ZodLiteral<true>>;
224
+ }, z.core.$loose>;
225
+ readonly 'session.suspending': z.ZodObject<{}, z.core.$loose>;
226
+ readonly 'session.paused': z.ZodObject<{}, z.core.$loose>;
227
+ readonly 'session.closing': z.ZodObject<{}, z.core.$loose>;
228
+ readonly 'session.closed': z.ZodObject<{}, z.core.$loose>;
229
+ readonly 'session.failed': z.ZodObject<{
230
+ error: z.ZodString;
231
+ }, z.core.$loose>;
232
+ readonly 'user_event.admitted': z.ZodObject<{
233
+ eventId: z.ZodString;
234
+ inputType: z.ZodEnum<{
235
+ input: "input";
236
+ "tool-result": "tool-result";
237
+ "message-queue": "message-queue";
238
+ "message-steer": "message-steer";
239
+ cancel: "cancel";
240
+ }>;
241
+ status: z.ZodLiteral<"queued">;
242
+ }, z.core.$loose>;
243
+ readonly 'user_event.received': z.ZodObject<{
244
+ eventId: z.ZodOptional<z.ZodString>;
245
+ status: z.ZodLiteral<"received">;
246
+ }, z.core.$loose>;
247
+ readonly 'user_event.completed': z.ZodObject<{
248
+ eventId: z.ZodOptional<z.ZodString>;
249
+ status: z.ZodLiteral<"completed">;
250
+ }, z.core.$loose>;
251
+ readonly 'user_event.failed': z.ZodObject<{
252
+ eventId: z.ZodOptional<z.ZodString>;
253
+ status: z.ZodLiteral<"failed">;
254
+ error: z.ZodOptional<z.ZodString>;
255
+ errorCode: z.ZodOptional<z.ZodString>;
256
+ }, z.core.$loose>;
257
+ readonly 'user_event.cancelled': z.ZodObject<{
258
+ eventId: z.ZodOptional<z.ZodString>;
259
+ status: z.ZodLiteral<"cancelled">;
260
+ }, z.core.$loose>;
261
+ readonly 'user_event.uncertain': z.ZodObject<{
262
+ eventId: z.ZodOptional<z.ZodString>;
263
+ status: z.ZodLiteral<"uncertain">;
264
+ error: z.ZodOptional<z.ZodString>;
265
+ }, z.core.$loose>;
266
+ readonly message: z.ZodObject<{
267
+ mode: z.ZodEnum<{
268
+ queue: "queue";
269
+ steer: "steer";
270
+ answer: "answer";
271
+ }>;
272
+ status: z.ZodLiteral<"running">;
273
+ inputSnapshot: z.ZodNumber;
274
+ model: z.ZodString;
275
+ reasoningEffort: z.ZodNullable<z.ZodString>;
276
+ }, z.core.$loose>;
277
+ readonly 'message.pending': z.ZodObject<{
278
+ status: z.ZodEnum<{
279
+ running: "running";
280
+ completed: "completed";
281
+ failed: "failed";
282
+ cancelled: "cancelled";
283
+ queued: "queued";
284
+ dispatched: "dispatched";
285
+ received: "received";
286
+ uncertain: "uncertain";
287
+ }>;
288
+ }, z.core.$loose>;
289
+ readonly input: z.ZodObject<{
290
+ eventId: z.ZodString;
291
+ name: z.ZodNullable<z.ZodString>;
292
+ }, z.core.$loose>;
293
+ readonly 'assistant.text': z.ZodObject<{
294
+ stepId: z.ZodString;
295
+ partIndex: z.ZodNumber;
296
+ partCount: z.ZodNumber;
297
+ }, z.core.$loose>;
298
+ readonly step: z.ZodObject<{
299
+ title: z.ZodString;
300
+ status: z.ZodString;
301
+ step: z.ZodObject<{
302
+ kind: z.ZodOptional<z.ZodEnum<{
303
+ message: "message";
304
+ reasoning: "reasoning";
305
+ tool: "tool";
306
+ }>>;
307
+ toolName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
308
+ status: z.ZodOptional<z.ZodString>;
309
+ preview: z.ZodOptional<z.ZodString>;
310
+ startedAt: z.ZodOptional<z.ZodString>;
311
+ endedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
312
+ }, z.core.$loose>;
313
+ }, z.core.$loose>;
314
+ readonly usage: z.ZodObject<{
315
+ provider: z.ZodOptional<z.ZodString>;
316
+ usageScope: z.ZodString;
317
+ }, z.core.$loose>;
318
+ readonly 'user_input.requested': z.ZodObject<{
319
+ requestId: z.ZodString;
320
+ questionCount: z.ZodNumber;
321
+ contentOmitted: z.ZodOptional<z.ZodLiteral<true>>;
322
+ }, z.core.$loose>;
323
+ readonly 'user_input.resolved': z.ZodObject<{
324
+ requestId: z.ZodString;
325
+ userEventId: z.ZodString;
326
+ }, z.core.$loose>;
327
+ readonly 'turn.completed': z.ZodObject<{
328
+ status: z.ZodLiteral<"completed">;
329
+ }, z.core.$loose>;
330
+ readonly 'turn.failed': z.ZodObject<{
331
+ status: z.ZodLiteral<"failed">;
332
+ error: z.ZodOptional<z.ZodString>;
333
+ reason: z.ZodOptional<z.ZodString>;
334
+ errorCode: z.ZodOptional<z.ZodString>;
335
+ }, z.core.$loose>;
336
+ readonly 'turn.cancelled': z.ZodObject<{
337
+ status: z.ZodLiteral<"cancelled">;
338
+ reason: z.ZodOptional<z.ZodString>;
339
+ }, z.core.$loose>;
340
+ readonly 'turn.uncertain': z.ZodObject<{
341
+ status: z.ZodLiteral<"uncertain">;
342
+ error: z.ZodOptional<z.ZodString>;
343
+ }, z.core.$loose>;
344
+ readonly 'artifact.published': z.ZodObject<{
345
+ artifactId: z.ZodString;
346
+ filename: z.ZodString;
347
+ byteSize: z.ZodNumber;
348
+ sha256: z.ZodString;
349
+ kind: z.ZodEnum<{
350
+ file: "file";
351
+ result: "result";
352
+ }>;
353
+ validationError: z.ZodOptional<z.ZodString>;
354
+ }, z.core.$loose>;
355
+ };
356
+ export type V5KnownEventType = keyof typeof v5EventHintSchemas;
357
+ export type V5EventHint<T extends V5KnownEventType> = z.infer<typeof v5EventHintSchemas[T]>;
358
+ export declare function isKnownV5EventType(type: string): type is V5KnownEventType;
359
+ /** The typed hint of a known event, or `null` when the type is unknown or the hint does not match. */
360
+ export declare function parseV5EventHint<T extends V5KnownEventType>(type: T, hint: unknown): V5EventHint<T> | null;
361
+ /** The question an agent asked (`user_input.requested`), as its event text decodes. */
362
+ export declare const v5UserInputRequestSchema: z.ZodObject<{
363
+ prompt: z.ZodOptional<z.ZodString>;
364
+ questions: z.ZodArray<z.ZodObject<{
365
+ id: z.ZodString;
366
+ label: z.ZodString;
367
+ description: z.ZodOptional<z.ZodString>;
368
+ required: z.ZodOptional<z.ZodBoolean>;
369
+ type: z.ZodEnum<{
370
+ text: "text";
371
+ single_select: "single_select";
372
+ }>;
373
+ placeholder: z.ZodOptional<z.ZodString>;
374
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{
375
+ value: z.ZodString;
376
+ label: z.ZodString;
377
+ description: z.ZodOptional<z.ZodString>;
378
+ }, z.core.$loose>>>;
379
+ }, z.core.$loose>>;
380
+ }, z.core.$loose>;
381
+ export type V5UserInputRequest = z.infer<typeof v5UserInputRequestSchema>;
382
+ export declare const v5SessionEventSchema: z.ZodObject<{
383
+ eventId: z.ZodString;
384
+ sessionId: z.ZodString;
385
+ type: z.ZodString;
386
+ turnId: z.ZodNullable<z.ZodString>;
387
+ messageId: z.ZodNullable<z.ZodString>;
388
+ toolCallId: z.ZodNullable<z.ZodString>;
389
+ occurredAt: z.ZodString;
390
+ hint: z.ZodRecord<z.ZodString, z.ZodUnknown>;
391
+ text: z.ZodNullable<z.ZodString>;
392
+ partIndex: z.ZodNullable<z.ZodNumber>;
393
+ partCount: z.ZodNullable<z.ZodNumber>;
394
+ payloadVaultStatus: z.ZodEnum<{
395
+ pending: "pending";
396
+ none: "none";
397
+ published: "published";
398
+ }>;
399
+ receipt: z.ZodOptional<z.ZodObject<{
400
+ eventId: z.ZodString;
401
+ type: z.ZodEnum<{
402
+ input: "input";
403
+ "tool-result": "tool-result";
404
+ "message-queue": "message-queue";
405
+ "message-steer": "message-steer";
406
+ cancel: "cancel";
407
+ }>;
408
+ messageId: z.ZodOptional<z.ZodString>;
409
+ sessionId: z.ZodString;
410
+ turnId: z.ZodNullable<z.ZodString>;
411
+ status: z.ZodEnum<{
412
+ running: "running";
413
+ completed: "completed";
414
+ failed: "failed";
415
+ cancelled: "cancelled";
416
+ queued: "queued";
417
+ dispatched: "dispatched";
418
+ received: "received";
419
+ uncertain: "uncertain";
420
+ }>;
421
+ }, z.core.$loose>>;
422
+ }, z.core.$loose>;
423
+ export type V5SessionEvent = z.infer<typeof v5SessionEventSchema>;
424
+ /** Transient cumulative text of one step, relayed live without an id; never advances the cursor. */
425
+ export declare const v5EventDraftSchema: z.ZodObject<{
426
+ kind: z.ZodDefault<z.ZodEnum<{
427
+ message: "message";
428
+ reasoning: "reasoning";
429
+ }>>;
430
+ messageId: z.ZodString;
431
+ turnId: z.ZodString;
432
+ afterEventId: z.ZodString;
433
+ sourceId: z.ZodString;
434
+ stepId: z.ZodString;
435
+ generation: z.ZodNumber;
436
+ revision: z.ZodNumber;
437
+ text: z.ZodString;
438
+ }, z.core.$loose>;
439
+ export type V5EventDraft = z.infer<typeof v5EventDraftSchema>;
440
+ export declare const v5EventPageSchema: z.ZodObject<{
441
+ events: z.ZodArray<z.ZodObject<{
442
+ eventId: z.ZodString;
443
+ sessionId: z.ZodString;
444
+ type: z.ZodString;
445
+ turnId: z.ZodNullable<z.ZodString>;
446
+ messageId: z.ZodNullable<z.ZodString>;
447
+ toolCallId: z.ZodNullable<z.ZodString>;
448
+ occurredAt: z.ZodString;
449
+ hint: z.ZodRecord<z.ZodString, z.ZodUnknown>;
450
+ text: z.ZodNullable<z.ZodString>;
451
+ partIndex: z.ZodNullable<z.ZodNumber>;
452
+ partCount: z.ZodNullable<z.ZodNumber>;
453
+ payloadVaultStatus: z.ZodEnum<{
454
+ pending: "pending";
455
+ none: "none";
456
+ published: "published";
457
+ }>;
458
+ receipt: z.ZodOptional<z.ZodObject<{
459
+ eventId: z.ZodString;
460
+ type: z.ZodEnum<{
461
+ input: "input";
462
+ "tool-result": "tool-result";
463
+ "message-queue": "message-queue";
464
+ "message-steer": "message-steer";
465
+ cancel: "cancel";
466
+ }>;
467
+ messageId: z.ZodOptional<z.ZodString>;
468
+ sessionId: z.ZodString;
469
+ turnId: z.ZodNullable<z.ZodString>;
470
+ status: z.ZodEnum<{
471
+ running: "running";
472
+ completed: "completed";
473
+ failed: "failed";
474
+ cancelled: "cancelled";
475
+ queued: "queued";
476
+ dispatched: "dispatched";
477
+ received: "received";
478
+ uncertain: "uncertain";
479
+ }>;
480
+ }, z.core.$loose>>;
481
+ }, z.core.$loose>>;
482
+ nextCursor: z.ZodNullable<z.ZodString>;
483
+ hasMore: z.ZodBoolean;
484
+ }, z.core.$loose>;
485
+ export type V5EventPage = z.infer<typeof v5EventPageSchema>;
486
+ export declare const v5EventQuerySchema: z.ZodObject<{
487
+ after: z.ZodOptional<z.ZodString>;
488
+ before: z.ZodOptional<z.ZodString>;
489
+ messageId: z.ZodOptional<z.ZodString>;
490
+ turnId: z.ZodOptional<z.ZodString>;
491
+ limit: z.ZodOptional<z.ZodNumber>;
492
+ }, z.core.$strict>;
493
+ export type V5EventQuery = z.infer<typeof v5EventQuerySchema>;
494
+ /** One frame of the live event stream: a stored event (with its id), a draft, or a heartbeat. */
495
+ export declare const v5EventStreamFrameSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
496
+ kind: z.ZodLiteral<"event">;
497
+ event: z.ZodObject<{
498
+ eventId: z.ZodString;
499
+ sessionId: z.ZodString;
500
+ type: z.ZodString;
501
+ turnId: z.ZodNullable<z.ZodString>;
502
+ messageId: z.ZodNullable<z.ZodString>;
503
+ toolCallId: z.ZodNullable<z.ZodString>;
504
+ occurredAt: z.ZodString;
505
+ hint: z.ZodRecord<z.ZodString, z.ZodUnknown>;
506
+ text: z.ZodNullable<z.ZodString>;
507
+ partIndex: z.ZodNullable<z.ZodNumber>;
508
+ partCount: z.ZodNullable<z.ZodNumber>;
509
+ payloadVaultStatus: z.ZodEnum<{
510
+ pending: "pending";
511
+ none: "none";
512
+ published: "published";
513
+ }>;
514
+ receipt: z.ZodOptional<z.ZodObject<{
515
+ eventId: z.ZodString;
516
+ type: z.ZodEnum<{
517
+ input: "input";
518
+ "tool-result": "tool-result";
519
+ "message-queue": "message-queue";
520
+ "message-steer": "message-steer";
521
+ cancel: "cancel";
522
+ }>;
523
+ messageId: z.ZodOptional<z.ZodString>;
524
+ sessionId: z.ZodString;
525
+ turnId: z.ZodNullable<z.ZodString>;
526
+ status: z.ZodEnum<{
527
+ running: "running";
528
+ completed: "completed";
529
+ failed: "failed";
530
+ cancelled: "cancelled";
531
+ queued: "queued";
532
+ dispatched: "dispatched";
533
+ received: "received";
534
+ uncertain: "uncertain";
535
+ }>;
536
+ }, z.core.$loose>>;
537
+ }, z.core.$loose>;
538
+ }, z.core.$strip>, z.ZodObject<{
539
+ kind: z.ZodLiteral<"draft">;
540
+ draft: z.ZodObject<{
541
+ kind: z.ZodDefault<z.ZodEnum<{
542
+ message: "message";
543
+ reasoning: "reasoning";
544
+ }>>;
545
+ messageId: z.ZodString;
546
+ turnId: z.ZodString;
547
+ afterEventId: z.ZodString;
548
+ sourceId: z.ZodString;
549
+ stepId: z.ZodString;
550
+ generation: z.ZodNumber;
551
+ revision: z.ZodNumber;
552
+ text: z.ZodString;
553
+ }, z.core.$loose>;
554
+ }, z.core.$strip>, z.ZodObject<{
555
+ kind: z.ZodLiteral<"heartbeat">;
556
+ }, z.core.$strip>], "kind">;
557
+ export type V5EventStreamFrame = z.infer<typeof v5EventStreamFrameSchema>;
558
+ export declare const v5SessionSchema: z.ZodObject<{
559
+ sessionId: z.ZodString;
560
+ agentId: z.ZodString;
561
+ snapshotId: z.ZodString;
562
+ harness: z.ZodEnum<{
563
+ claude: "claude";
564
+ lightweight: "lightweight";
565
+ codex: "codex";
566
+ }>;
567
+ status: z.ZodEnum<{
568
+ running: "running";
569
+ failed: "failed";
570
+ ready: "ready";
571
+ initializing: "initializing";
572
+ paused: "paused";
573
+ detached: "detached";
574
+ closing: "closing";
575
+ closed: "closed";
576
+ }>;
577
+ executionMode: z.ZodEnum<{
578
+ chat: "chat";
579
+ sync: "sync";
580
+ async: "async";
581
+ }>;
582
+ runtime: z.ZodObject<{
583
+ state: z.ZodString;
584
+ }, z.core.$loose>;
585
+ configuration: z.ZodObject<{
586
+ harness: z.ZodEnum<{
587
+ claude: "claude";
588
+ lightweight: "lightweight";
589
+ codex: "codex";
590
+ }>;
591
+ model: z.ZodOptional<z.ZodString>;
592
+ provider: z.ZodOptional<z.ZodString>;
593
+ effort: z.ZodOptional<z.ZodString>;
594
+ commitSha: z.ZodString;
595
+ repository: z.ZodString;
596
+ }, z.core.$loose>;
597
+ effectiveModelSettings: z.ZodNullable<z.ZodObject<{
598
+ model: z.ZodString;
599
+ reasoningEffort: z.ZodNullable<z.ZodString>;
600
+ }, z.core.$loose>>;
601
+ createdAt: z.ZodString;
602
+ }, z.core.$loose>;
603
+ export type V5Session = z.infer<typeof v5SessionSchema>;
604
+ export declare const v5SessionListSchema: z.ZodObject<{
605
+ sessions: z.ZodArray<z.ZodObject<{
606
+ sessionId: z.ZodString;
607
+ agentId: z.ZodString;
608
+ snapshotId: z.ZodString;
609
+ harness: z.ZodEnum<{
610
+ claude: "claude";
611
+ lightweight: "lightweight";
612
+ codex: "codex";
613
+ }>;
614
+ status: z.ZodEnum<{
615
+ running: "running";
616
+ failed: "failed";
617
+ ready: "ready";
618
+ initializing: "initializing";
619
+ paused: "paused";
620
+ detached: "detached";
621
+ closing: "closing";
622
+ closed: "closed";
623
+ }>;
624
+ executionMode: z.ZodEnum<{
625
+ chat: "chat";
626
+ sync: "sync";
627
+ async: "async";
628
+ }>;
629
+ runtime: z.ZodObject<{
630
+ state: z.ZodString;
631
+ }, z.core.$loose>;
632
+ configuration: z.ZodObject<{
633
+ harness: z.ZodEnum<{
634
+ claude: "claude";
635
+ lightweight: "lightweight";
636
+ codex: "codex";
637
+ }>;
638
+ model: z.ZodOptional<z.ZodString>;
639
+ provider: z.ZodOptional<z.ZodString>;
640
+ effort: z.ZodOptional<z.ZodString>;
641
+ commitSha: z.ZodString;
642
+ repository: z.ZodString;
643
+ }, z.core.$loose>;
644
+ effectiveModelSettings: z.ZodNullable<z.ZodObject<{
645
+ model: z.ZodString;
646
+ reasoningEffort: z.ZodNullable<z.ZodString>;
647
+ }, z.core.$loose>>;
648
+ createdAt: z.ZodString;
649
+ }, z.core.$loose>>;
650
+ }, z.core.$loose>;
651
+ /** Creation admits the session and its first queued messages and inputs in one idempotent request. */
652
+ export declare const v5SessionCreateSchema: z.ZodObject<{
653
+ agentId: z.ZodString;
654
+ snapshotId: z.ZodOptional<z.ZodString>;
655
+ commitHash: z.ZodOptional<z.ZodString>;
656
+ executionMode: z.ZodOptional<z.ZodEnum<{
657
+ chat: "chat";
658
+ sync: "sync";
659
+ async: "async";
660
+ }>>;
661
+ events: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
662
+ type: z.ZodLiteral<"message-queue">;
663
+ payload: z.ZodString;
664
+ }, z.core.$strict>, z.ZodObject<{
665
+ type: z.ZodLiteral<"message-steer">;
666
+ turnId: z.ZodString;
667
+ payload: z.ZodString;
668
+ }, z.core.$strict>, z.ZodObject<{
669
+ type: z.ZodLiteral<"input">;
670
+ name: z.ZodOptional<z.ZodString>;
671
+ payload: z.ZodOptional<z.ZodString>;
672
+ }, z.core.$strict>, z.ZodObject<{
673
+ type: z.ZodLiteral<"cancel">;
674
+ turnId: z.ZodString;
675
+ }, z.core.$strict>, z.ZodObject<{
676
+ type: z.ZodLiteral<"tool-result">;
677
+ toolCallId: z.ZodString;
678
+ payload: z.ZodString;
679
+ }, z.core.$strict>], "type">>>;
680
+ telaAgentId: z.ZodOptional<z.ZodString>;
681
+ projectId: z.ZodOptional<z.ZodString>;
682
+ tags: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
683
+ }, z.core.$strict>;
684
+ export type V5SessionCreate = z.infer<typeof v5SessionCreateSchema>;
685
+ export declare const v5SessionCreationReceiptSchema: z.ZodObject<{
686
+ sessionId: z.ZodString;
687
+ snapshotId: z.ZodString;
688
+ status: z.ZodEnum<{
689
+ running: "running";
690
+ failed: "failed";
691
+ ready: "ready";
692
+ initializing: "initializing";
693
+ paused: "paused";
694
+ detached: "detached";
695
+ closing: "closing";
696
+ closed: "closed";
697
+ }>;
698
+ events: z.ZodArray<z.ZodObject<{
699
+ eventId: z.ZodString;
700
+ type: z.ZodEnum<{
701
+ input: "input";
702
+ "tool-result": "tool-result";
703
+ "message-queue": "message-queue";
704
+ "message-steer": "message-steer";
705
+ cancel: "cancel";
706
+ }>;
707
+ messageId: z.ZodOptional<z.ZodString>;
708
+ sessionId: z.ZodString;
709
+ turnId: z.ZodNullable<z.ZodString>;
710
+ status: z.ZodEnum<{
711
+ running: "running";
712
+ completed: "completed";
713
+ failed: "failed";
714
+ cancelled: "cancelled";
715
+ queued: "queued";
716
+ dispatched: "dispatched";
717
+ received: "received";
718
+ uncertain: "uncertain";
719
+ }>;
720
+ }, z.core.$loose>>;
721
+ }, z.core.$loose>;
722
+ export type V5SessionCreationReceipt = z.infer<typeof v5SessionCreationReceiptSchema>;
723
+ export declare const v5SessionClosureReceiptSchema: z.ZodObject<{
724
+ status: z.ZodLiteral<"closing">;
725
+ }, z.core.$loose>;
726
+ export declare const v5AgentSnapshotSchema: z.ZodObject<{
727
+ snapshotId: z.ZodString;
728
+ commitSha: z.ZodString;
729
+ purpose: z.ZodEnum<{
730
+ publication: "publication";
731
+ iteration: "iteration";
732
+ }>;
733
+ status: z.ZodEnum<{
734
+ failed: "failed";
735
+ ready: "ready";
736
+ building: "building";
737
+ superseded: "superseded";
738
+ unbuilt: "unbuilt";
739
+ }>;
740
+ readyAt: z.ZodNullable<z.ZodString>;
741
+ createdAt: z.ZodString;
742
+ }, z.core.$loose>;
743
+ export type V5AgentSnapshot = z.infer<typeof v5AgentSnapshotSchema>;
744
+ /** A catalog agent; `repository` is `organization/repository`, the same coordinates Tela knows. */
745
+ export declare const v5AgentSchema: z.ZodObject<{
746
+ agentId: z.ZodString;
747
+ repository: z.ZodString;
748
+ defaultBranch: z.ZodString;
749
+ publishedSnapshotId: z.ZodNullable<z.ZodString>;
750
+ publishedCommitSha: z.ZodNullable<z.ZodString>;
751
+ harness: z.ZodNullable<z.ZodEnum<{
752
+ claude: "claude";
753
+ lightweight: "lightweight";
754
+ codex: "codex";
755
+ }>>;
756
+ model: z.ZodNullable<z.ZodString>;
757
+ createdAt: z.ZodString;
758
+ updatedAt: z.ZodString;
759
+ }, z.core.$loose>;
760
+ export type V5Agent = z.infer<typeof v5AgentSchema>;
761
+ export declare const v5AgentDetailSchema: z.ZodObject<{
762
+ agentId: z.ZodString;
763
+ repository: z.ZodString;
764
+ defaultBranch: z.ZodString;
765
+ publishedSnapshotId: z.ZodNullable<z.ZodString>;
766
+ publishedCommitSha: z.ZodNullable<z.ZodString>;
767
+ harness: z.ZodNullable<z.ZodEnum<{
768
+ claude: "claude";
769
+ lightweight: "lightweight";
770
+ codex: "codex";
771
+ }>>;
772
+ model: z.ZodNullable<z.ZodString>;
773
+ createdAt: z.ZodString;
774
+ updatedAt: z.ZodString;
775
+ snapshots: z.ZodArray<z.ZodObject<{
776
+ snapshotId: z.ZodString;
777
+ commitSha: z.ZodString;
778
+ purpose: z.ZodEnum<{
779
+ publication: "publication";
780
+ iteration: "iteration";
781
+ }>;
782
+ status: z.ZodEnum<{
783
+ failed: "failed";
784
+ ready: "ready";
785
+ building: "building";
786
+ superseded: "superseded";
787
+ unbuilt: "unbuilt";
788
+ }>;
789
+ readyAt: z.ZodNullable<z.ZodString>;
790
+ createdAt: z.ZodString;
791
+ }, z.core.$loose>>;
792
+ }, z.core.$loose>;
793
+ export type V5AgentDetail = z.infer<typeof v5AgentDetailSchema>;
794
+ export declare const v5AgentListSchema: z.ZodObject<{
795
+ agents: z.ZodArray<z.ZodObject<{
796
+ agentId: z.ZodString;
797
+ repository: z.ZodString;
798
+ defaultBranch: z.ZodString;
799
+ publishedSnapshotId: z.ZodNullable<z.ZodString>;
800
+ publishedCommitSha: z.ZodNullable<z.ZodString>;
801
+ harness: z.ZodNullable<z.ZodEnum<{
802
+ claude: "claude";
803
+ lightweight: "lightweight";
804
+ codex: "codex";
805
+ }>>;
806
+ model: z.ZodNullable<z.ZodString>;
807
+ createdAt: z.ZodString;
808
+ updatedAt: z.ZodString;
809
+ }, z.core.$loose>>;
810
+ }, z.core.$loose>;
811
+ export declare const v5SnapshotPublishSchema: z.ZodObject<{
812
+ organizationName: z.ZodString;
813
+ repository: z.ZodString;
814
+ commit: z.ZodOptional<z.ZodString>;
815
+ }, z.core.$strict>;
816
+ export declare const v5SnapshotPublicationSchema: z.ZodObject<{
817
+ agentId: z.ZodString;
818
+ snapshot: z.ZodObject<{
819
+ snapshotId: z.ZodString;
820
+ commitSha: z.ZodString;
821
+ purpose: z.ZodEnum<{
822
+ publication: "publication";
823
+ iteration: "iteration";
824
+ }>;
825
+ status: z.ZodEnum<{
826
+ failed: "failed";
827
+ ready: "ready";
828
+ building: "building";
829
+ superseded: "superseded";
830
+ unbuilt: "unbuilt";
831
+ }>;
832
+ readyAt: z.ZodNullable<z.ZodString>;
833
+ createdAt: z.ZodString;
834
+ error: z.ZodNullable<z.ZodString>;
835
+ }, z.core.$loose>;
836
+ }, z.core.$loose>;
837
+ export type V5SnapshotPublication = z.infer<typeof v5SnapshotPublicationSchema>;
838
+ export declare const v5TurnSchema: z.ZodObject<{
839
+ turnId: z.ZodString;
840
+ status: z.ZodEnum<{
841
+ running: "running";
842
+ completed: "completed";
843
+ failed: "failed";
844
+ cancelled: "cancelled";
845
+ uncertain: "uncertain";
846
+ }>;
847
+ usage: z.ZodRecord<z.ZodString, z.ZodUnknown>;
848
+ error: z.ZodNullable<z.ZodString>;
849
+ createdAt: z.ZodString;
850
+ completedAt: z.ZodNullable<z.ZodString>;
851
+ }, z.core.$loose>;
852
+ export type V5Turn = z.infer<typeof v5TurnSchema>;
853
+ export declare const v5TurnListSchema: z.ZodObject<{
854
+ turns: z.ZodArray<z.ZodObject<{
855
+ turnId: z.ZodString;
856
+ status: z.ZodEnum<{
857
+ running: "running";
858
+ completed: "completed";
859
+ failed: "failed";
860
+ cancelled: "cancelled";
861
+ uncertain: "uncertain";
862
+ }>;
863
+ usage: z.ZodRecord<z.ZodString, z.ZodUnknown>;
864
+ error: z.ZodNullable<z.ZodString>;
865
+ createdAt: z.ZodString;
866
+ completedAt: z.ZodNullable<z.ZodString>;
867
+ }, z.core.$loose>>;
868
+ }, z.core.$loose>;
869
+ export declare const v5ArtifactIdSchema: z.ZodString;
870
+ export declare const v5ArtifactSchema: z.ZodObject<{
871
+ artifactId: z.ZodString;
872
+ turnId: z.ZodString;
873
+ filename: z.ZodString;
874
+ byteSize: z.ZodNumber;
875
+ sha256: z.ZodString;
876
+ eventId: z.ZodString;
877
+ messageId: z.ZodString;
878
+ stepId: z.ZodNullable<z.ZodString>;
879
+ mediaType: z.ZodString;
880
+ }, z.core.$loose>;
881
+ export type V5Artifact = z.infer<typeof v5ArtifactSchema>;
882
+ export declare const v5ArtifactPageSchema: z.ZodObject<{
883
+ artifacts: z.ZodArray<z.ZodObject<{
884
+ artifactId: z.ZodString;
885
+ turnId: z.ZodString;
886
+ filename: z.ZodString;
887
+ byteSize: z.ZodNumber;
888
+ sha256: z.ZodString;
889
+ eventId: z.ZodString;
890
+ messageId: z.ZodString;
891
+ stepId: z.ZodNullable<z.ZodString>;
892
+ mediaType: z.ZodString;
893
+ }, z.core.$loose>>;
894
+ nextCursor: z.ZodNullable<z.ZodString>;
895
+ hasMore: z.ZodBoolean;
896
+ }, z.core.$loose>;
897
+ export declare const v5ArtifactQuerySchema: z.ZodObject<{
898
+ after: z.ZodOptional<z.ZodString>;
899
+ limit: z.ZodOptional<z.ZodNumber>;
900
+ }, z.core.$strict>;
901
+ export type V5ArtifactQuery = z.infer<typeof v5ArtifactQuerySchema>;
@@ -0,0 +1,353 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Agent events: client-side mirror of the agent-api v5 events-v1 contract (`packages/models` in
4
+ * meistrari/agent-api). Responses are parsed as loose objects so a field the API adds
5
+ * later never breaks the chat; requests keep the API's own limits so a bad payload is
6
+ * refused here, before it travels.
7
+ */
8
+ export const v5Limits = {
9
+ messageTextChars: 200_000,
10
+ inputTextChars: 800_000,
11
+ userEventBytes: 1_048_576,
12
+ inlinePayloadBytes: 16_384,
13
+ eventsPerRequest: 32,
14
+ idempotencyKeyChars: 200,
15
+ turnIdChars: 200,
16
+ attributionChars: 200,
17
+ eventPage: { default: 100, max: 500 },
18
+ artifactPage: { default: 100, max: 100 },
19
+ sessionList: 100,
20
+ turnList: 500,
21
+ agentList: 100,
22
+ draftTextChars: 65_536,
23
+ streamHeartbeatMs: 15_000,
24
+ };
25
+ /** Every code a v5 route answers in `{ error }`, with its HTTP status. */
26
+ export const v5ErrorStatus = {
27
+ invalid_request: 400,
28
+ invalid_vault_reference: 400,
29
+ input_payload_required: 400,
30
+ invalid_tool_result_answers: 400,
31
+ cursor_not_found: 400,
32
+ invalid_event_limit: 400,
33
+ invalid_artifact_limit: 400,
34
+ invalid_user_event_batch: 400,
35
+ provider_harness_mismatch: 400,
36
+ insufficient_role: 403,
37
+ agent_publication_forbidden: 403,
38
+ session_not_found: 404,
39
+ agent_not_found: 404,
40
+ snapshot_not_found: 404,
41
+ event_not_found: 404,
42
+ message_not_found: 404,
43
+ turn_not_found: 404,
44
+ artifact_not_found: 404,
45
+ repository_not_found: 404,
46
+ commit_not_found: 404,
47
+ content_unavailable: 404,
48
+ idempotency_conflict: 409,
49
+ agent_not_published: 409,
50
+ snapshot_not_ready: 409,
51
+ snapshot_protected: 409,
52
+ snapshot_build_in_progress: 409,
53
+ session_closed: 409,
54
+ turn_not_running: 409,
55
+ user_event_already_dispatched: 409,
56
+ invalid_tool_result: 409,
57
+ repository_ambiguous: 409,
58
+ user_event_too_large: 413,
59
+ request_too_large: 413,
60
+ payload_not_offloaded: 413,
61
+ agent_config_invalid: 422,
62
+ model_not_on_provider: 422,
63
+ internal_error: 500,
64
+ session_vault_unavailable: 503,
65
+ detached_delivery_unavailable: 503,
66
+ content_storage_unavailable: 503,
67
+ artifact_storage_unavailable: 503,
68
+ snapshot_publishing_unavailable: 503,
69
+ };
70
+ export const v5ErrorBodySchema = z.object({ error: z.string() });
71
+ export const v5EventIdSchema = z.string().uuid();
72
+ export const v5TurnIdSchema = z.string().min(1).max(v5Limits.turnIdChars);
73
+ export const v5HarnessSchema = z.enum(['claude', 'codex', 'lightweight']);
74
+ export const v5SessionStatusSchema = z.enum(['initializing', 'ready', 'running', 'paused', 'detached', 'closing', 'closed', 'failed']);
75
+ export const v5UserEventStatusSchema = z.enum(['queued', 'dispatched', 'received', 'running', 'completed', 'failed', 'cancelled', 'uncertain']);
76
+ export const v5UserEventTypeSchema = z.enum(['message-queue', 'message-steer', 'input', 'cancel', 'tool-result']);
77
+ export const VAULT_REFERENCE_PREFIX = 'vault://';
78
+ export function isVaultReference(payload) {
79
+ return payload.startsWith(VAULT_REFERENCE_PREFIX);
80
+ }
81
+ export const v5VaultReferenceSchema = z.string().max(2048).regex(/^vault:\/\/\S+$/u);
82
+ const inputNameSchema = z.string().min(1).max(128).regex(/^[a-z_][\w-]*$/iu);
83
+ const payloadSchema = z.string().min(1);
84
+ function isAnswers(payload) {
85
+ try {
86
+ const value = JSON.parse(payload);
87
+ return typeof value === 'object' && value !== null && !Array.isArray(value) && Object.keys(value).length > 0;
88
+ }
89
+ catch {
90
+ return false;
91
+ }
92
+ }
93
+ /** A user event as the client sends it: a message, a steer, an input, a cancel or an answer. */
94
+ export const v5UserEventSchema = z.discriminatedUnion('type', [
95
+ z.object({ type: z.literal('message-queue'), payload: payloadSchema }).strict(),
96
+ z.object({ type: z.literal('message-steer'), turnId: v5TurnIdSchema, payload: payloadSchema }).strict(),
97
+ z.object({ type: z.literal('input'), name: inputNameSchema.optional(), payload: payloadSchema.optional() }).strict(),
98
+ z.object({ type: z.literal('cancel'), turnId: v5TurnIdSchema }).strict(),
99
+ z.object({ type: z.literal('tool-result'), toolCallId: z.string().min(1).max(v5Limits.turnIdChars), payload: payloadSchema }).strict(),
100
+ ]).superRefine((input, ctx) => {
101
+ const payload = 'payload' in input ? input.payload : undefined;
102
+ if (input.type === 'input' && payload === undefined && input.name === undefined)
103
+ ctx.addIssue({ code: 'custom', path: ['payload'], message: 'An input without a name needs a payload.' });
104
+ if (payload === undefined)
105
+ return;
106
+ if (input.type === 'tool-result') {
107
+ if (!isAnswers(payload))
108
+ ctx.addIssue({ code: 'custom', path: ['payload'], message: 'The answers are a JSON object keyed by question id.' });
109
+ return;
110
+ }
111
+ if (isVaultReference(payload)) {
112
+ if (!v5VaultReferenceSchema.safeParse(payload).success)
113
+ ctx.addIssue({ code: 'custom', path: ['payload'], message: 'Not a Vault reference.' });
114
+ return;
115
+ }
116
+ if (input.type === 'input' && input.name === undefined) {
117
+ ctx.addIssue({ code: 'custom', path: ['payload'], message: 'An input without a name is a file: its payload is a Vault reference.' });
118
+ return;
119
+ }
120
+ const maximum = input.type === 'input' ? v5Limits.inputTextChars : v5Limits.messageTextChars;
121
+ if (payload.length > maximum)
122
+ ctx.addIssue({ code: 'custom', path: ['payload'], message: `Text exceeds ${maximum} characters.` });
123
+ });
124
+ export const v5EventsRequestSchema = z.object({
125
+ events: z.array(v5UserEventSchema).min(1).max(v5Limits.eventsPerRequest),
126
+ }).strict();
127
+ export const v5EventReceiptSchema = z.looseObject({
128
+ eventId: v5EventIdSchema,
129
+ type: v5UserEventTypeSchema,
130
+ messageId: v5EventIdSchema.optional(),
131
+ sessionId: z.string().uuid(),
132
+ turnId: v5TurnIdSchema.nullable(),
133
+ status: v5UserEventStatusSchema,
134
+ });
135
+ export const v5EventsReceiptSchema = z.looseObject({ events: z.array(v5EventReceiptSchema) });
136
+ /**
137
+ * Hints of the stored event types the chat reads. Unknown types still parse (the type is an open
138
+ * string); `parseV5EventHint` gives the typed hint for the ones listed here.
139
+ */
140
+ export const v5EventHintSchemas = {
141
+ 'session.initializing': z.looseObject({ executionMode: z.enum(['chat', 'sync', 'async']).optional(), resumed: z.literal(true).optional() }),
142
+ 'session.ready': z.looseObject({ resumed: z.literal(true).optional() }),
143
+ 'session.suspending': z.looseObject({}),
144
+ 'session.paused': z.looseObject({}),
145
+ 'session.closing': z.looseObject({}),
146
+ 'session.closed': z.looseObject({}),
147
+ 'session.failed': z.looseObject({ error: z.string() }),
148
+ 'user_event.admitted': z.looseObject({ eventId: z.string().uuid(), inputType: v5UserEventTypeSchema, status: z.literal('queued') }),
149
+ 'user_event.received': z.looseObject({ eventId: z.string().uuid().optional(), status: z.literal('received') }),
150
+ 'user_event.completed': z.looseObject({ eventId: z.string().uuid().optional(), status: z.literal('completed') }),
151
+ 'user_event.failed': z.looseObject({ eventId: z.string().uuid().optional(), status: z.literal('failed'), error: z.string().optional(), errorCode: z.string().optional() }),
152
+ 'user_event.cancelled': z.looseObject({ eventId: z.string().uuid().optional(), status: z.literal('cancelled') }),
153
+ 'user_event.uncertain': z.looseObject({ eventId: z.string().uuid().optional(), status: z.literal('uncertain'), error: z.string().optional() }),
154
+ 'message': z.looseObject({
155
+ mode: z.enum(['queue', 'steer', 'answer']),
156
+ status: z.literal('running'),
157
+ inputSnapshot: z.number().int().nonnegative(),
158
+ model: z.string(),
159
+ reasoningEffort: z.string().nullable(),
160
+ }),
161
+ 'message.pending': z.looseObject({ status: v5UserEventStatusSchema }),
162
+ 'input': z.looseObject({ eventId: z.string().uuid(), name: z.string().nullable() }),
163
+ 'assistant.text': z.looseObject({ stepId: z.string().min(1), partIndex: z.number().int().nonnegative(), partCount: z.number().int().positive() }),
164
+ 'step': z.looseObject({
165
+ title: z.string(),
166
+ status: z.string(),
167
+ step: z.looseObject({
168
+ kind: z.enum(['message', 'tool', 'reasoning']).optional(),
169
+ toolName: z.string().nullable().optional(),
170
+ status: z.string().optional(),
171
+ preview: z.string().optional(),
172
+ startedAt: z.string().optional(),
173
+ endedAt: z.string().nullable().optional(),
174
+ }),
175
+ }),
176
+ 'usage': z.looseObject({ provider: z.string().optional(), usageScope: z.string() }),
177
+ 'user_input.requested': z.looseObject({ requestId: z.string().min(1), questionCount: z.number().int().positive(), contentOmitted: z.literal(true).optional() }),
178
+ 'user_input.resolved': z.looseObject({ requestId: z.string().min(1), userEventId: z.string().uuid() }),
179
+ 'turn.completed': z.looseObject({ status: z.literal('completed') }),
180
+ 'turn.failed': z.looseObject({ status: z.literal('failed'), error: z.string().optional(), reason: z.string().optional(), errorCode: z.string().optional() }),
181
+ 'turn.cancelled': z.looseObject({ status: z.literal('cancelled'), reason: z.string().optional() }),
182
+ 'turn.uncertain': z.looseObject({ status: z.literal('uncertain'), error: z.string().optional() }),
183
+ 'artifact.published': z.looseObject({
184
+ artifactId: z.string().regex(/^[a-f0-9]{64}$/u),
185
+ filename: z.string().min(1),
186
+ byteSize: z.number().int().nonnegative(),
187
+ sha256: z.string().regex(/^[a-f0-9]{64}$/u),
188
+ kind: z.enum(['file', 'result']),
189
+ validationError: z.string().optional(),
190
+ }),
191
+ };
192
+ export function isKnownV5EventType(type) {
193
+ return Object.hasOwn(v5EventHintSchemas, type);
194
+ }
195
+ /** The typed hint of a known event, or `null` when the type is unknown or the hint does not match. */
196
+ export function parseV5EventHint(type, hint) {
197
+ const parsed = v5EventHintSchemas[type].safeParse(hint);
198
+ return parsed.success ? parsed.data : null;
199
+ }
200
+ /** The question an agent asked (`user_input.requested`), as its event text decodes. */
201
+ export const v5UserInputRequestSchema = z.looseObject({
202
+ prompt: z.string().optional(),
203
+ questions: z.array(z.looseObject({
204
+ id: z.string().min(1),
205
+ label: z.string(),
206
+ description: z.string().optional(),
207
+ required: z.boolean().optional(),
208
+ type: z.enum(['text', 'single_select']),
209
+ placeholder: z.string().optional(),
210
+ options: z.array(z.looseObject({ value: z.string(), label: z.string(), description: z.string().optional() })).optional(),
211
+ })),
212
+ });
213
+ export const v5SessionEventSchema = z.looseObject({
214
+ eventId: v5EventIdSchema,
215
+ sessionId: z.string().uuid(),
216
+ type: z.string().min(1),
217
+ turnId: v5TurnIdSchema.nullable(),
218
+ messageId: v5EventIdSchema.nullable(),
219
+ toolCallId: z.string().nullable(),
220
+ occurredAt: z.string(),
221
+ hint: z.record(z.string(), z.unknown()),
222
+ text: z.string().nullable(),
223
+ partIndex: z.number().int().nullable(),
224
+ partCount: z.number().int().nullable(),
225
+ payloadVaultStatus: z.enum(['none', 'pending', 'published']),
226
+ receipt: v5EventReceiptSchema.optional(),
227
+ });
228
+ /** Transient cumulative text of one step, relayed live without an id; never advances the cursor. */
229
+ export const v5EventDraftSchema = z.looseObject({
230
+ kind: z.enum(['message', 'reasoning']).default('message'),
231
+ messageId: v5EventIdSchema,
232
+ turnId: v5TurnIdSchema,
233
+ afterEventId: v5EventIdSchema,
234
+ sourceId: z.string().min(1),
235
+ stepId: z.string().min(1),
236
+ generation: z.number().int().nonnegative(),
237
+ revision: z.number().int().positive(),
238
+ text: z.string(),
239
+ });
240
+ export const v5EventPageSchema = z.looseObject({ events: z.array(v5SessionEventSchema), nextCursor: v5EventIdSchema.nullable(), hasMore: z.boolean() });
241
+ export const v5EventQuerySchema = z.object({
242
+ after: v5EventIdSchema.optional(),
243
+ before: v5EventIdSchema.optional(),
244
+ messageId: v5EventIdSchema.optional(),
245
+ turnId: v5TurnIdSchema.optional(),
246
+ limit: z.number().int().min(1).max(v5Limits.eventPage.max).optional(),
247
+ }).strict();
248
+ /** One frame of the live event stream: a stored event (with its id), a draft, or a heartbeat. */
249
+ export const v5EventStreamFrameSchema = z.discriminatedUnion('kind', [
250
+ z.object({ kind: z.literal('event'), event: v5SessionEventSchema }),
251
+ z.object({ kind: z.literal('draft'), draft: v5EventDraftSchema }),
252
+ z.object({ kind: z.literal('heartbeat') }),
253
+ ]);
254
+ export const v5SessionSchema = z.looseObject({
255
+ sessionId: z.string().uuid(),
256
+ agentId: z.string().uuid(),
257
+ snapshotId: z.string().uuid(),
258
+ harness: v5HarnessSchema,
259
+ status: v5SessionStatusSchema,
260
+ executionMode: z.enum(['chat', 'sync', 'async']),
261
+ runtime: z.looseObject({ state: z.string() }),
262
+ configuration: z.looseObject({
263
+ harness: v5HarnessSchema,
264
+ model: z.string().optional(),
265
+ provider: z.string().optional(),
266
+ effort: z.string().optional(),
267
+ commitSha: z.string(),
268
+ repository: z.string(),
269
+ }),
270
+ effectiveModelSettings: z.looseObject({ model: z.string(), reasoningEffort: z.string().nullable() }).nullable(),
271
+ createdAt: z.string(),
272
+ });
273
+ export const v5SessionListSchema = z.looseObject({ sessions: z.array(v5SessionSchema) });
274
+ /** Creation admits the session and its first queued messages and inputs in one idempotent request. */
275
+ export const v5SessionCreateSchema = z.object({
276
+ agentId: z.string().uuid(),
277
+ snapshotId: z.string().uuid().optional(),
278
+ commitHash: z.string().regex(/^[0-9a-f]{7,64}$/iu).optional(),
279
+ executionMode: z.enum(['chat', 'sync', 'async']).optional(),
280
+ events: z.array(v5UserEventSchema).max(v5Limits.eventsPerRequest).optional(),
281
+ telaAgentId: z.string().min(1).max(v5Limits.attributionChars).optional(),
282
+ projectId: z.string().min(1).max(v5Limits.attributionChars).optional(),
283
+ tags: z.record(z.string(), z.unknown()).optional(),
284
+ }).strict().superRefine((body, ctx) => {
285
+ for (const [index, event] of (body.events ?? []).entries()) {
286
+ if (event.type !== 'message-queue' && event.type !== 'input')
287
+ ctx.addIssue({ code: 'custom', path: ['events', index, 'type'], message: 'A new session starts with queued messages and inputs only.' });
288
+ }
289
+ });
290
+ export const v5SessionCreationReceiptSchema = z.looseObject({
291
+ sessionId: z.string().uuid(),
292
+ snapshotId: z.string().uuid(),
293
+ status: v5SessionStatusSchema,
294
+ events: z.array(v5EventReceiptSchema),
295
+ });
296
+ export const v5SessionClosureReceiptSchema = z.looseObject({ status: z.literal('closing') });
297
+ export const v5AgentSnapshotSchema = z.looseObject({
298
+ snapshotId: z.string().uuid(),
299
+ commitSha: z.string(),
300
+ purpose: z.enum(['publication', 'iteration']),
301
+ status: z.enum(['building', 'ready', 'failed', 'superseded', 'unbuilt']),
302
+ readyAt: z.string().nullable(),
303
+ createdAt: z.string(),
304
+ });
305
+ /** A catalog agent; `repository` is `organization/repository`, the same coordinates Tela knows. */
306
+ export const v5AgentSchema = z.looseObject({
307
+ agentId: z.string().uuid(),
308
+ repository: z.string(),
309
+ defaultBranch: z.string(),
310
+ publishedSnapshotId: z.string().uuid().nullable(),
311
+ publishedCommitSha: z.string().nullable(),
312
+ harness: v5HarnessSchema.nullable(),
313
+ model: z.string().nullable(),
314
+ createdAt: z.string(),
315
+ updatedAt: z.string(),
316
+ });
317
+ export const v5AgentDetailSchema = v5AgentSchema.extend({ snapshots: z.array(v5AgentSnapshotSchema) });
318
+ export const v5AgentListSchema = z.looseObject({ agents: z.array(v5AgentSchema) });
319
+ export const v5SnapshotPublishSchema = z.object({
320
+ organizationName: z.string().min(1).max(v5Limits.attributionChars),
321
+ repository: z.string().min(1).max(v5Limits.attributionChars),
322
+ commit: z.string().regex(/^[0-9a-f]{7,64}$/iu).optional(),
323
+ }).strict();
324
+ export const v5SnapshotPublicationSchema = z.looseObject({
325
+ agentId: z.string().uuid(),
326
+ snapshot: v5AgentSnapshotSchema.extend({ error: z.string().nullable() }),
327
+ });
328
+ export const v5TurnSchema = z.looseObject({
329
+ turnId: v5TurnIdSchema,
330
+ status: z.enum(['running', 'completed', 'failed', 'cancelled', 'uncertain']),
331
+ usage: z.record(z.string(), z.unknown()),
332
+ error: z.string().nullable(),
333
+ createdAt: z.string(),
334
+ completedAt: z.string().nullable(),
335
+ });
336
+ export const v5TurnListSchema = z.looseObject({ turns: z.array(v5TurnSchema) });
337
+ export const v5ArtifactIdSchema = z.string().regex(/^[a-f0-9]{64}$/u);
338
+ export const v5ArtifactSchema = z.looseObject({
339
+ artifactId: v5ArtifactIdSchema,
340
+ turnId: v5TurnIdSchema,
341
+ filename: z.string().min(1),
342
+ byteSize: z.number().int().nonnegative(),
343
+ sha256: v5ArtifactIdSchema,
344
+ eventId: v5EventIdSchema,
345
+ messageId: v5EventIdSchema,
346
+ stepId: z.string().nullable(),
347
+ mediaType: z.string(),
348
+ });
349
+ export const v5ArtifactPageSchema = z.looseObject({ artifacts: z.array(v5ArtifactSchema), nextCursor: v5EventIdSchema.nullable(), hasMore: z.boolean() });
350
+ export const v5ArtifactQuerySchema = z.object({
351
+ after: v5EventIdSchema.optional(),
352
+ limit: z.number().int().min(1).max(v5Limits.artifactPage.max).optional(),
353
+ }).strict();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/chat-nuxt",
3
- "version": "4.9.0",
3
+ "version": "4.10.0-rc.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {