@codelia/shared-types 0.1.86 → 0.1.90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -21,24 +21,96 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  ATTACHMENT_ID_PATTERN: () => ATTACHMENT_ID_PATTERN,
24
+ AgentEventSchema: () => AgentEventSchema,
25
+ ApprovalModeSchema: () => ApprovalModeSchema,
26
+ AttachedImageMetadataSchema: () => AttachedImageMetadataSchema,
27
+ AttachmentRefPartSchema: () => AttachmentRefPartSchema,
28
+ AttachmentRefSchema: () => AttachmentRefSchema,
29
+ CompactionCompleteEventSchema: () => CompactionCompleteEventSchema,
30
+ CompactionStartEventSchema: () => CompactionStartEventSchema,
31
+ ContentPartSchema: () => ContentPartSchema,
32
+ ContextUsageBreakdownEntrySchema: () => ContextUsageBreakdownEntrySchema,
33
+ ContextUsageCategorySchema: () => ContextUsageCategorySchema,
34
+ ContextUsageSchema: () => ContextUsageSchema,
35
+ DocumentPartSchema: () => DocumentPartSchema,
36
+ FinalResponseEventSchema: () => FinalResponseEventSchema,
37
+ GeneratedImageMetadataSchema: () => GeneratedImageMetadataSchema,
38
+ GoalOfferSchema: () => GoalOfferSchema,
39
+ GoalRecordSchema: () => GoalRecordSchema,
40
+ GoalSnapshotSchema: () => GoalSnapshotSchema,
41
+ GoalStatusSchema: () => GoalStatusSchema,
42
+ GoalStopReasonSchema: () => GoalStopReasonSchema,
43
+ HiddenUserMessageEventSchema: () => HiddenUserMessageEventSchema,
24
44
  IMAGE_REFERENCE_MAX_COUNT: () => IMAGE_REFERENCE_MAX_COUNT,
45
+ ImageArtifactMetadataSchema: () => ImageArtifactMetadataSchema,
46
+ ImageArtifactRefSchema: () => ImageArtifactRefSchema,
47
+ ImageDetailSchema: () => ImageDetailSchema,
48
+ ImageGenerationUsageSchema: () => ImageGenerationUsageSchema,
49
+ ImageMediaTypeSchema: () => ImageMediaTypeSchema,
50
+ ImageModelViewSchema: () => ImageModelViewSchema,
51
+ ImagePartSchema: () => ImagePartSchema,
52
+ ImageRefPartSchema: () => ImageRefPartSchema,
53
+ ImageUrlSchema: () => ImageUrlSchema,
54
+ LlmCallTimingSchema: () => LlmCallTimingSchema,
55
+ LlmRetryEventSchema: () => LlmRetryEventSchema,
56
+ LlmStatusBufferingEventSchema: () => LlmStatusBufferingEventSchema,
57
+ LlmStatusEventSchema: () => LlmStatusEventSchema,
58
+ LlmStatusVerificationEventSchema: () => LlmStatusVerificationEventSchema,
25
59
  MODEL_REASONING_LEVELS: () => MODEL_REASONING_LEVELS,
60
+ ModelFastModeSchema: () => ModelFastModeSchema,
61
+ ModelReasoningLevelSchema: () => ModelReasoningLevelSchema,
62
+ ModelSpeedTierSchema: () => ModelSpeedTierSchema,
63
+ OtherPartSchema: () => OtherPartSchema,
64
+ PermissionPreviewEventSchema: () => PermissionPreviewEventSchema,
65
+ PermissionReadyEventSchema: () => PermissionReadyEventSchema,
66
+ ProviderNameSchema: () => ProviderNameSchema,
67
+ ReasoningDeltaEventSchema: () => ReasoningDeltaEventSchema,
68
+ ReasoningEventSchema: () => ReasoningEventSchema,
69
+ RunErrorInfoSchema: () => RunErrorInfoSchema,
70
+ SandboxModeSchema: () => SandboxModeSchema,
71
+ SessionStateSummarySchema: () => SessionStateSummarySchema,
26
72
  SkillCatalogSchema: () => SkillCatalogSchema,
27
73
  SkillLoadErrorSchema: () => SkillLoadErrorSchema,
28
74
  SkillMetadataSchema: () => SkillMetadataSchema,
29
75
  SkillScopeSchema: () => SkillScopeSchema,
30
76
  SkillSearchReasonSchema: () => SkillSearchReasonSchema,
31
77
  SkillSearchResultSchema: () => SkillSearchResultSchema,
78
+ SteerAppliedEventSchema: () => SteerAppliedEventSchema,
79
+ StepCompleteEventSchema: () => StepCompleteEventSchema,
80
+ StepStartEventSchema: () => StepStartEventSchema,
81
+ SubagentLineageSchema: () => SubagentLineageSchema,
82
+ TaskProgressCurrentToolSchema: () => TaskProgressCurrentToolSchema,
83
+ TaskProgressLastToolSchema: () => TaskProgressLastToolSchema,
84
+ TaskProgressSchema: () => TaskProgressSchema,
85
+ TaskTerminationReasonSchema: () => TaskTerminationReasonSchema,
86
+ TaskUsageSchema: () => TaskUsageSchema,
87
+ TextDeltaEventSchema: () => TextDeltaEventSchema,
88
+ TextEventSchema: () => TextEventSchema,
89
+ TextPartSchema: () => TextPartSchema,
90
+ ToolCallEventSchema: () => ToolCallEventSchema,
91
+ ToolResultEventSchema: () => ToolResultEventSchema,
92
+ WIRE_ENCODE_KEY: () => WIRE_ENCODE_KEY,
93
+ WIRE_KEYED_KEY: () => WIRE_KEYED_KEY,
94
+ WIRE_PRESENCE_KEY: () => WIRE_PRESENCE_KEY,
95
+ WIRE_TAG_KEY: () => WIRE_TAG_KEY,
96
+ clearable: () => clearable,
32
97
  isImageModelView: () => isImageModelView,
33
98
  isModelFastMode: () => isModelFastMode,
34
99
  isModelReasoningLevel: () => isModelReasoningLevel,
100
+ keyed: () => keyed,
101
+ nullish: () => nullish,
35
102
  parseApprovalMode: () => parseApprovalMode,
36
103
  parseSandboxMode: () => parseSandboxMode,
37
- sandboxModes: () => sandboxModes
104
+ sandboxModes: () => sandboxModes,
105
+ tagged: () => tagged,
106
+ wireCount: () => wireCount,
107
+ wireInt: () => wireInt
38
108
  });
39
109
  module.exports = __toCommonJS(index_exports);
40
110
 
41
111
  // src/approval.ts
112
+ var import_zod = require("zod");
113
+ var ApprovalModeSchema = import_zod.z.enum(["minimal", "trusted", "full-access"]).meta({ id: "ApprovalMode" });
42
114
  var parseApprovalMode = (value) => {
43
115
  if (value === "minimal" || value === "trusted" || value === "full-access") {
44
116
  return value;
@@ -50,20 +122,383 @@ var sandboxModes = [
50
122
  "workspace-write",
51
123
  "full-access"
52
124
  ];
125
+ var SandboxModeSchema = import_zod.z.enum(sandboxModes).meta({ id: "SandboxMode" });
53
126
  var parseSandboxMode = (value) => sandboxModes.find((mode) => mode === value);
54
127
 
128
+ // src/attachment.ts
129
+ var import_zod3 = require("zod");
130
+
131
+ // src/wire.ts
132
+ var import_zod2 = require("zod");
133
+ var WIRE_PRESENCE_KEY = "x-codelia-presence";
134
+ var WIRE_TAG_KEY = "x-codelia-tag";
135
+ var WIRE_KEYED_KEY = "x-codelia-keyed";
136
+ var WIRE_ENCODE_KEY = "x-codelia-encode";
137
+ var wireInt = () => import_zod2.z.int();
138
+ var wireCount = () => import_zod2.z.number().meta({ [WIRE_ENCODE_KEY]: "integer" });
139
+ var clearable = (schema) => schema.nullable().optional().meta({ [WIRE_PRESENCE_KEY]: "tri-state" });
140
+ var nullish = (schema) => schema.nullable().optional().meta({ [WIRE_PRESENCE_KEY]: "collapse" });
141
+ var tagged = (tag, branches, meta) => import_zod2.z.discriminatedUnion(tag, branches).meta({ ...meta, [WIRE_TAG_KEY]: tag });
142
+ var keyed = (branches, meta) => import_zod2.z.union(branches).meta({ ...meta, [WIRE_KEYED_KEY]: true });
143
+
55
144
  // src/attachment.ts
56
145
  var ATTACHMENT_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;
146
+ var AttachmentRefSchema = import_zod3.z.object({
147
+ attachment_id: import_zod3.z.string(),
148
+ sha256: import_zod3.z.string(),
149
+ byte_size: wireInt(),
150
+ media_type: import_zod3.z.string(),
151
+ display_name: import_zod3.z.string(),
152
+ width: wireInt().optional(),
153
+ height: wireInt().optional(),
154
+ origin: import_zod3.z.enum(["file", "clipboard_image"]).optional()
155
+ }).meta({
156
+ id: "AttachmentRef",
157
+ description: "Immutable runtime-owned attachment metadata. No source path is retained."
158
+ });
159
+
160
+ // src/content.ts
161
+ var import_zod5 = require("zod");
57
162
 
58
163
  // src/image-artifact.ts
164
+ var import_zod4 = require("zod");
59
165
  var IMAGE_REFERENCE_MAX_COUNT = 16;
166
+ var ImageMediaTypeSchema = import_zod4.z.enum(["image/png", "image/jpeg", "image/webp", "image/gif"]).meta({ id: "ImageMediaType" });
167
+ var ImageModelViewSchema = import_zod4.z.object({
168
+ // Single-value enums: later views may add values that older receivers
169
+ // must keep as unknown rather than reject.
170
+ version: import_zod4.z.enum(["jpeg-q90-444-v1"]),
171
+ media_type: import_zod4.z.enum(["image/jpeg"]),
172
+ sha256: import_zod4.z.string(),
173
+ byte_size: wireInt()
174
+ }).meta({
175
+ id: "ImageModelView",
176
+ description: "Fixed model input representation; absent means the immutable original."
177
+ });
60
178
  function isImageModelView(value) {
61
179
  if (!value || typeof value !== "object") return false;
62
180
  const view = value;
63
181
  return view.version === "jpeg-q90-444-v1" && view.media_type === "image/jpeg" && typeof view.sha256 === "string" && /^[0-9a-f]{64}$/.test(view.sha256) && typeof view.byte_size === "number" && Number.isSafeInteger(view.byte_size) && view.byte_size > 0 && view.byte_size <= 32 * 1024 * 1024;
64
182
  }
183
+ var ImageArtifactRefSchema = import_zod4.z.object({
184
+ artifact_id: import_zod4.z.string(),
185
+ sha256: import_zod4.z.string(),
186
+ media_type: ImageMediaTypeSchema,
187
+ byte_size: wireInt(),
188
+ width: wireInt(),
189
+ height: wireInt(),
190
+ model_view: ImageModelViewSchema.optional()
191
+ }).meta({
192
+ id: "ImageArtifactRef",
193
+ description: "Durable image identity. Bytes are resolved only at the request/preview boundary."
194
+ });
195
+ var ImageGenerationUsageSchema = import_zod4.z.object({
196
+ input_tokens: wireInt().optional(),
197
+ output_tokens: wireInt().optional(),
198
+ cost_usd: import_zod4.z.number().optional()
199
+ }).meta({ id: "ImageGenerationUsage" });
200
+ var GeneratedImageMetadataSchema = ImageArtifactRefSchema.extend({
201
+ kind: import_zod4.z.literal("generated").optional(),
202
+ media_type: import_zod4.z.enum(["image/png", "image/jpeg"]),
203
+ /** ISO 8601 timestamp. */
204
+ created_at: import_zod4.z.string(),
205
+ provider: import_zod4.z.string(),
206
+ requested_model: import_zod4.z.string(),
207
+ effective_model: import_zod4.z.string().optional(),
208
+ endpoint: import_zod4.z.string(),
209
+ parent_artifact_ids: import_zod4.z.array(import_zod4.z.string()),
210
+ usage: ImageGenerationUsageSchema.optional()
211
+ }).meta({ id: "GeneratedImageMetadata" });
212
+ var AttachedImageMetadataSchema = ImageArtifactRefSchema.extend({
213
+ kind: import_zod4.z.literal("attachment"),
214
+ /** ISO 8601 timestamp. */
215
+ created_at: import_zod4.z.string()
216
+ }).meta({ id: "AttachedImageMetadata" });
217
+ var ImageArtifactMetadataSchema = tagged(
218
+ "kind",
219
+ [GeneratedImageMetadataSchema, AttachedImageMetadataSchema],
220
+ { id: "ImageArtifactMetadata" }
221
+ );
222
+
223
+ // src/content.ts
224
+ var ImageDetailSchema = import_zod5.z.enum(["auto", "low", "high"]).meta({ id: "ImageDetail" });
225
+ var ImageRefPartSchema = import_zod5.z.object({
226
+ type: import_zod5.z.literal("image_ref"),
227
+ image_ref: ImageArtifactRefSchema,
228
+ detail: ImageDetailSchema.optional()
229
+ }).meta({ id: "ImageRefPart" });
230
+ var AttachmentRefPartSchema = import_zod5.z.object({
231
+ type: import_zod5.z.literal("attachment_ref"),
232
+ attachment_ref: AttachmentRefSchema,
233
+ image_ref: ImageArtifactRefSchema.optional()
234
+ }).meta({ id: "AttachmentRefPart" });
235
+ var TextPartSchema = import_zod5.z.object({
236
+ type: import_zod5.z.literal("text"),
237
+ text: import_zod5.z.string()
238
+ }).meta({ id: "TextPart" });
239
+ var ImageUrlSchema = import_zod5.z.object({
240
+ url: import_zod5.z.string(),
241
+ detail: ImageDetailSchema.optional(),
242
+ media_type: ImageMediaTypeSchema.optional()
243
+ }).meta({ id: "ImageUrl" });
244
+ var ImagePartSchema = import_zod5.z.object({
245
+ type: import_zod5.z.literal("image_url"),
246
+ image_url: ImageUrlSchema
247
+ }).meta({ id: "ImagePart" });
248
+ var DocumentPartSchema = import_zod5.z.object({
249
+ type: import_zod5.z.literal("document"),
250
+ source: import_zod5.z.object({
251
+ data: import_zod5.z.string(),
252
+ // Open: persisted content may carry document types added later.
253
+ media_type: import_zod5.z.enum(["application/pdf"])
254
+ })
255
+ }).meta({ id: "DocumentPart" });
256
+ var OtherPartSchema = import_zod5.z.object({
257
+ type: import_zod5.z.literal("other"),
258
+ provider: import_zod5.z.string(),
259
+ kind: import_zod5.z.string(),
260
+ /** Provider-native payload; opaque to the protocol. */
261
+ payload: import_zod5.z.unknown()
262
+ }).meta({ id: "OtherPart" });
263
+ var ContentPartSchema = tagged(
264
+ "type",
265
+ [
266
+ TextPartSchema,
267
+ ImagePartSchema,
268
+ ImageRefPartSchema,
269
+ AttachmentRefPartSchema,
270
+ DocumentPartSchema,
271
+ OtherPartSchema
272
+ ],
273
+ { id: "ContentPart" }
274
+ );
275
+
276
+ // src/context-usage.ts
277
+ var import_zod6 = require("zod");
278
+ var ContextUsageCategorySchema = import_zod6.z.enum(["system", "tools", "messages", "tool_results", "images"]).meta({ id: "ContextUsageCategory" });
279
+ var ContextUsageBreakdownEntrySchema = import_zod6.z.object({
280
+ category: ContextUsageCategorySchema,
281
+ /** Estimated tokens of the current history in this category. */
282
+ tokens: wireInt(),
283
+ /** Number of items (images only). */
284
+ count: wireInt().optional()
285
+ }).meta({ id: "ContextUsageBreakdownEntry" });
286
+ var ContextUsageSchema = import_zod6.z.object({
287
+ /** Null only when no agent has been built yet. */
288
+ provider: import_zod6.z.string().nullable(),
289
+ model: import_zod6.z.string().nullable(),
290
+ /** Model input limit (`maxInputTokens ?? contextWindow`); null when unknown. */
291
+ limit_tokens: wireInt().nullable(),
292
+ /** Last provider-reported `total_tokens` (same basis as `left_percent`). */
293
+ used_tokens: wireInt().nullable(),
294
+ /** Last provider-reported `input_tokens`. */
295
+ input_tokens: wireInt().nullable(),
296
+ left_percent: import_zod6.z.number().nullable(),
297
+ /** `provider`: used/input come from the last model call; `none`: no call yet. */
298
+ basis: import_zod6.z.enum(["provider", "none"]),
299
+ /**
300
+ * Size estimate of the current history and tool definitions by category
301
+ * (serialized bytes / 3; images via the model's image-token estimate). Not
302
+ * normalized to `used_tokens`, which stays provider-reported only.
303
+ */
304
+ breakdown: import_zod6.z.array(ContextUsageBreakdownEntrySchema)
305
+ }).meta({ id: "ContextUsage" });
306
+
307
+ // src/events.ts
308
+ var import_zod8 = require("zod");
309
+
310
+ // src/provider.ts
311
+ var import_zod7 = require("zod");
312
+ var ProviderNameSchema = import_zod7.z.string().meta({ id: "ProviderName" });
313
+
314
+ // src/events.ts
315
+ var TextEventSchema = import_zod8.z.object({
316
+ type: import_zod8.z.literal("text"),
317
+ content: import_zod8.z.string(),
318
+ timestamp: wireInt()
319
+ }).meta({ id: "TextEvent" });
320
+ var ReasoningEventSchema = import_zod8.z.object({
321
+ type: import_zod8.z.literal("reasoning"),
322
+ content: import_zod8.z.string(),
323
+ timestamp: wireInt()
324
+ }).meta({ id: "ReasoningEvent" });
325
+ var TextDeltaEventSchema = import_zod8.z.object({
326
+ type: import_zod8.z.literal("text.delta"),
327
+ delta: import_zod8.z.string(),
328
+ stream_id: import_zod8.z.string(),
329
+ index: wireInt()
330
+ }).meta({
331
+ id: "TextDeltaEvent",
332
+ description: "Provisional text of one model call attempt. Complete `text` events replace all provisional text of the same `stream_id`. Never persisted or replayed."
333
+ });
334
+ var ReasoningDeltaEventSchema = import_zod8.z.object({
335
+ type: import_zod8.z.literal("reasoning.delta"),
336
+ delta: import_zod8.z.string(),
337
+ stream_id: import_zod8.z.string(),
338
+ index: wireInt()
339
+ }).meta({
340
+ id: "ReasoningDeltaEvent",
341
+ description: "Reasoning counterpart of `TextDeltaEvent`; the complete `reasoning` event stays authoritative."
342
+ });
343
+ var LlmRetryEventSchema = import_zod8.z.object({
344
+ type: import_zod8.z.literal("llm.retry"),
345
+ provider: ProviderNameSchema,
346
+ failure_kind: import_zod8.z.enum([
347
+ "rate_limit",
348
+ "overloaded",
349
+ "timeout",
350
+ "network",
351
+ "provider"
352
+ ]),
353
+ next_attempt: wireInt(),
354
+ max_attempts: wireInt(),
355
+ delay_ms: import_zod8.z.number(),
356
+ delay_source: import_zod8.z.enum([
357
+ "retry-after",
358
+ "reset-header",
359
+ "provider-body",
360
+ "backoff"
361
+ ]),
362
+ status: wireInt().optional()
363
+ }).meta({ id: "LlmRetryEvent" });
364
+ var LlmStatusVerificationEventSchema = import_zod8.z.object({
365
+ type: import_zod8.z.literal("llm.status"),
366
+ // Open: receivers ignore statuses from providers they do not know.
367
+ provider: import_zod8.z.enum(["openai"]),
368
+ kind: import_zod8.z.literal("verification"),
369
+ // Open: receivers ignore verification kinds they do not know.
370
+ verification: import_zod8.z.enum(["trusted_access_for_cyber"])
371
+ }).meta({ id: "LlmStatusVerificationEvent" });
372
+ var LlmStatusBufferingEventSchema = import_zod8.z.object({
373
+ type: import_zod8.z.literal("llm.status"),
374
+ // Open: receivers ignore statuses from providers they do not know.
375
+ provider: import_zod8.z.enum(["openai"]),
376
+ kind: import_zod8.z.literal("buffering"),
377
+ active: import_zod8.z.boolean(),
378
+ faster_model: import_zod8.z.string().optional()
379
+ }).meta({ id: "LlmStatusBufferingEvent" });
380
+ var LlmStatusEventSchema = tagged(
381
+ "kind",
382
+ [LlmStatusVerificationEventSchema, LlmStatusBufferingEventSchema],
383
+ {
384
+ id: "LlmStatusEvent",
385
+ description: "Informational provider status; never assistant history or model selection."
386
+ }
387
+ );
388
+ var StepStartEventSchema = import_zod8.z.object({
389
+ type: import_zod8.z.literal("step_start"),
390
+ step_id: import_zod8.z.string(),
391
+ title: import_zod8.z.string(),
392
+ step_number: wireInt()
393
+ }).meta({ id: "StepStartEvent" });
394
+ var ToolCallEventSchema = import_zod8.z.object({
395
+ type: import_zod8.z.literal("tool_call"),
396
+ tool: import_zod8.z.string(),
397
+ /** Tool-specific arguments; opaque to the protocol. */
398
+ args: import_zod8.z.record(import_zod8.z.string(), import_zod8.z.unknown()),
399
+ raw_args: import_zod8.z.string().optional(),
400
+ tool_call_id: import_zod8.z.string(),
401
+ display_name: import_zod8.z.string().optional()
402
+ }).meta({ id: "ToolCallEvent" });
403
+ var ToolResultEventSchema = import_zod8.z.object({
404
+ type: import_zod8.z.literal("tool_result"),
405
+ tool: import_zod8.z.string(),
406
+ /** Display text; clients parse it per tool. */
407
+ result: import_zod8.z.string(),
408
+ tool_call_id: import_zod8.z.string(),
409
+ is_error: import_zod8.z.boolean().optional(),
410
+ screenshot_base64: nullish(import_zod8.z.string())
411
+ }).meta({ id: "ToolResultEvent" });
412
+ var PermissionPreviewEventSchema = import_zod8.z.object({
413
+ type: import_zod8.z.literal("permission.preview"),
414
+ tool: import_zod8.z.string(),
415
+ tool_call_id: import_zod8.z.string().optional(),
416
+ file_path: import_zod8.z.string().optional(),
417
+ language: import_zod8.z.string().optional(),
418
+ diff: import_zod8.z.string().optional(),
419
+ summary: import_zod8.z.string().optional(),
420
+ truncated: import_zod8.z.boolean().optional()
421
+ }).meta({ id: "PermissionPreviewEvent" });
422
+ var PermissionReadyEventSchema = import_zod8.z.object({
423
+ type: import_zod8.z.literal("permission.ready"),
424
+ tool: import_zod8.z.string(),
425
+ tool_call_id: import_zod8.z.string().optional()
426
+ }).meta({ id: "PermissionReadyEvent" });
427
+ var StepCompleteEventSchema = import_zod8.z.object({
428
+ type: import_zod8.z.literal("step_complete"),
429
+ step_id: import_zod8.z.string(),
430
+ status: import_zod8.z.enum(["completed", "error"]),
431
+ duration_ms: import_zod8.z.number()
432
+ }).meta({ id: "StepCompleteEvent" });
433
+ var CompactionStartEventSchema = import_zod8.z.object({
434
+ type: import_zod8.z.literal("compaction_start"),
435
+ timestamp: wireInt()
436
+ }).meta({ id: "CompactionStartEvent" });
437
+ var CompactionCompleteEventSchema = import_zod8.z.object({
438
+ type: import_zod8.z.literal("compaction_complete"),
439
+ timestamp: wireInt(),
440
+ compacted: import_zod8.z.boolean()
441
+ }).meta({ id: "CompactionCompleteEvent" });
442
+ var HiddenUserMessageEventSchema = import_zod8.z.object({
443
+ type: import_zod8.z.literal("hidden_user_message"),
444
+ content: import_zod8.z.string()
445
+ }).meta({ id: "HiddenUserMessageEvent" });
446
+ var SteerAppliedEventSchema = import_zod8.z.object({
447
+ type: import_zod8.z.literal("steer_applied"),
448
+ steer_id: import_zod8.z.string(),
449
+ client_steer_id: import_zod8.z.string().optional(),
450
+ content: import_zod8.z.union([import_zod8.z.string(), import_zod8.z.array(ContentPartSchema)]),
451
+ timestamp: wireInt()
452
+ }).meta({ id: "SteerAppliedEvent" });
453
+ var FinalResponseEventSchema = import_zod8.z.object({
454
+ type: import_zod8.z.literal("final"),
455
+ content: import_zod8.z.string(),
456
+ termination_reason: import_zod8.z.enum(["normal", "max_steps", "permission_denied"]).optional()
457
+ }).meta({ id: "FinalResponseEvent" });
458
+ var AgentEventSchema = tagged(
459
+ "type",
460
+ [
461
+ TextEventSchema,
462
+ ReasoningEventSchema,
463
+ TextDeltaEventSchema,
464
+ ReasoningDeltaEventSchema,
465
+ LlmRetryEventSchema,
466
+ LlmStatusEventSchema,
467
+ StepStartEventSchema,
468
+ ToolCallEventSchema,
469
+ ToolResultEventSchema,
470
+ PermissionPreviewEventSchema,
471
+ PermissionReadyEventSchema,
472
+ StepCompleteEventSchema,
473
+ CompactionStartEventSchema,
474
+ CompactionCompleteEventSchema,
475
+ HiddenUserMessageEventSchema,
476
+ SteerAppliedEventSchema,
477
+ FinalResponseEventSchema
478
+ ],
479
+ {
480
+ id: "AgentEvent",
481
+ description: "Persisted and replayed: add variants and optional fields only."
482
+ }
483
+ );
484
+
485
+ // src/llm-timing.ts
486
+ var import_zod9 = require("zod");
487
+ var LlmCallTimingSchema = import_zod9.z.object({
488
+ time_to_first_token_ms: import_zod9.z.number(),
489
+ generation_duration_ms: import_zod9.z.number(),
490
+ /** Optional observed start of hidden reasoning, distinct from first delta. */
491
+ generation_start_ms: import_zod9.z.number().optional(),
492
+ generation_start_source: import_zod9.z.enum(["reasoning_item", "thought_step"]).optional()
493
+ }).meta({
494
+ id: "LlmCallTiming",
495
+ description: "Observed successful stream timing, measured with a monotonic clock."
496
+ });
65
497
 
66
498
  // src/model.ts
499
+ var import_zod10 = require("zod");
500
+ var ModelSpeedTierSchema = import_zod10.z.enum(["ultrafast"]).meta({ id: "ModelSpeedTier" });
501
+ var ModelFastModeSchema = import_zod10.z.union([import_zod10.z.boolean(), ModelSpeedTierSchema]).meta({ id: "ModelFastMode" });
67
502
  var isModelFastMode = (value) => typeof value === "boolean" || value === "ultrafast";
68
503
  var MODEL_REASONING_LEVELS = [
69
504
  "low",
@@ -72,55 +507,261 @@ var MODEL_REASONING_LEVELS = [
72
507
  "xhigh",
73
508
  "max"
74
509
  ];
510
+ var ModelReasoningLevelSchema = import_zod10.z.enum(MODEL_REASONING_LEVELS).meta({ id: "ModelReasoningLevel" });
75
511
  var isModelReasoningLevel = (value) => MODEL_REASONING_LEVELS.some((level) => level === value);
76
512
 
513
+ // src/run-error.ts
514
+ var import_zod11 = require("zod");
515
+ var RunErrorInfoSchema = import_zod11.z.object({
516
+ name: import_zod11.z.string(),
517
+ message: import_zod11.z.string(),
518
+ provider: ProviderNameSchema.optional(),
519
+ kind: import_zod11.z.string().optional(),
520
+ /** HTTP status, when the failure came from a provider response. */
521
+ status: wireInt().optional(),
522
+ code: import_zod11.z.string().optional(),
523
+ attempts: wireInt().optional(),
524
+ max_attempts: wireInt().optional(),
525
+ detail: import_zod11.z.string().optional(),
526
+ hint: import_zod11.z.string().optional()
527
+ }).meta({
528
+ id: "RunErrorInfo",
529
+ description: "Safe failure-only context for status notifications and retained errors."
530
+ });
531
+
532
+ // src/session.ts
533
+ var import_zod12 = require("zod");
534
+ var SessionStateSummarySchema = import_zod12.z.object({
535
+ session_id: import_zod12.z.string(),
536
+ /** ISO 8601 timestamp. */
537
+ updated_at: import_zod12.z.string(),
538
+ run_id: import_zod12.z.string().optional(),
539
+ message_count: wireInt().optional(),
540
+ last_user_message: import_zod12.z.string().optional(),
541
+ workspace_root: import_zod12.z.string().optional(),
542
+ pinned: import_zod12.z.boolean().optional(),
543
+ /** ISO 8601 timestamp; absent when the session is not archived. */
544
+ archived_at: import_zod12.z.string().optional()
545
+ }).meta({ id: "SessionStateSummary" });
546
+
77
547
  // src/skills/schema.ts
78
- var import_zod = require("zod");
79
- var SkillScopeSchema = import_zod.z.enum(["repo", "user"]);
80
- var SkillMetadataSchema = import_zod.z.object({
81
- id: import_zod.z.string().min(1),
82
- name: import_zod.z.string().min(1),
83
- description: import_zod.z.string().min(1),
84
- path: import_zod.z.string().min(1),
85
- dir: import_zod.z.string().min(1),
548
+ var import_zod13 = require("zod");
549
+ var SkillScopeSchema = import_zod13.z.enum(["repo", "user"]);
550
+ var SkillMetadataSchema = import_zod13.z.object({
551
+ id: import_zod13.z.string().min(1),
552
+ name: import_zod13.z.string().min(1),
553
+ description: import_zod13.z.string().min(1),
554
+ path: import_zod13.z.string().min(1),
555
+ dir: import_zod13.z.string().min(1),
86
556
  scope: SkillScopeSchema,
87
- mtime_ms: import_zod.z.number().int().nonnegative()
557
+ mtime_ms: import_zod13.z.number().int().nonnegative()
88
558
  }).strict();
89
- var SkillLoadErrorSchema = import_zod.z.object({
90
- path: import_zod.z.string().min(1),
91
- message: import_zod.z.string().min(1)
559
+ var SkillLoadErrorSchema = import_zod13.z.object({
560
+ path: import_zod13.z.string().min(1),
561
+ message: import_zod13.z.string().min(1)
92
562
  }).strict();
93
- var SkillCatalogSchema = import_zod.z.object({
94
- skills: import_zod.z.array(SkillMetadataSchema),
95
- errors: import_zod.z.array(SkillLoadErrorSchema),
96
- truncated: import_zod.z.boolean()
563
+ var SkillCatalogSchema = import_zod13.z.object({
564
+ skills: import_zod13.z.array(SkillMetadataSchema),
565
+ errors: import_zod13.z.array(SkillLoadErrorSchema),
566
+ truncated: import_zod13.z.boolean()
97
567
  }).strict();
98
- var SkillSearchReasonSchema = import_zod.z.enum([
568
+ var SkillSearchReasonSchema = import_zod13.z.enum([
99
569
  "exact_name",
100
570
  "exact_path",
101
571
  "prefix",
102
572
  "token_overlap"
103
573
  ]);
104
- var SkillSearchResultSchema = import_zod.z.object({
574
+ var SkillSearchResultSchema = import_zod13.z.object({
105
575
  skill: SkillMetadataSchema,
106
- score: import_zod.z.number(),
576
+ score: import_zod13.z.number(),
107
577
  reason: SkillSearchReasonSchema
108
578
  }).strict();
579
+
580
+ // src/task.ts
581
+ var import_zod14 = require("zod");
582
+ var TaskTerminationReasonSchema = import_zod14.z.enum([
583
+ "normal",
584
+ "max_steps",
585
+ "timeout",
586
+ "cancelled",
587
+ "startup_error",
588
+ "execution_error"
589
+ ]).meta({ id: "TaskTerminationReason" });
590
+ var SubagentLineageSchema = import_zod14.z.object({
591
+ /** Immutable agent display name; absent on older records. */
592
+ name: import_zod14.z.string().optional(),
593
+ tree_id: import_zod14.z.string(),
594
+ node_id: import_zod14.z.string(),
595
+ parent_node_id: import_zod14.z.string(),
596
+ owner_session_id: import_zod14.z.string(),
597
+ depth: import_zod14.z.literal(1),
598
+ spawn_index: wireInt(),
599
+ // Open: only "fresh" today; spawn params already name resume and fork.
600
+ context_mode: import_zod14.z.enum(["fresh"]),
601
+ effective_policy_id: import_zod14.z.string(),
602
+ workspace_lease_id: import_zod14.z.string()
603
+ }).meta({ id: "SubagentLineage" });
604
+ var TaskUsageSchema = import_zod14.z.object({
605
+ total_tokens: wireInt(),
606
+ /** Absent and `null` both mean the cost is unknown. */
607
+ total_cost_usd: nullish(import_zod14.z.number())
608
+ }).meta({ id: "TaskUsage" });
609
+ var TaskProgressCurrentToolSchema = import_zod14.z.object({
610
+ name: import_zod14.z.string(),
611
+ tool_call_id: import_zod14.z.string(),
612
+ started_at: import_zod14.z.string()
613
+ }).meta({ id: "TaskProgressCurrentTool" });
614
+ var TaskProgressLastToolSchema = import_zod14.z.object({
615
+ name: import_zod14.z.string(),
616
+ status: import_zod14.z.enum(["ok", "error"]),
617
+ finished_at: import_zod14.z.string()
618
+ }).meta({ id: "TaskProgressLastTool" });
619
+ var TaskProgressSchema = import_zod14.z.object({
620
+ /** Model calls started so far (1-based once the first call starts). */
621
+ step: wireInt(),
622
+ max_steps: wireInt().optional(),
623
+ phase: import_zod14.z.enum(["model", "tool", "compacting", "finishing"]),
624
+ current_tool: TaskProgressCurrentToolSchema.optional(),
625
+ last_tool: TaskProgressLastToolSchema.optional(),
626
+ /** Tool calls requested so far. */
627
+ tool_calls: wireInt(),
628
+ updated_at: import_zod14.z.string()
629
+ }).meta({ id: "TaskProgress" });
630
+
631
+ // src/goal.ts
632
+ var import_zod15 = require("zod");
633
+ var GoalStatusSchema = import_zod15.z.enum([
634
+ "active",
635
+ "paused",
636
+ "blocked",
637
+ "usage_limited",
638
+ "budget_limited",
639
+ "complete"
640
+ ]).meta({ id: "GoalStatus" });
641
+ var GoalStopReasonSchema = import_zod15.z.enum([
642
+ "user",
643
+ "turn_limit",
644
+ "run_error",
645
+ "checkpoint_failed",
646
+ "interrupted",
647
+ "blocker"
648
+ ]).meta({ id: "GoalStopReason" });
649
+ var GoalRecordSchema = import_zod15.z.object({
650
+ session_id: import_zod15.z.string(),
651
+ goal_id: import_zod15.z.string(),
652
+ revision: wireInt(),
653
+ objective: import_zod15.z.string(),
654
+ status: GoalStatusSchema,
655
+ stop_reason: GoalStopReasonSchema.optional(),
656
+ stop_detail: import_zod15.z.string().optional(),
657
+ /** Always sent; `null` means no budget. */
658
+ token_budget: wireInt().nullable(),
659
+ tokens_used: wireInt(),
660
+ usage_known: import_zod15.z.boolean(),
661
+ activation_id: import_zod15.z.string(),
662
+ automatic_runs: wireInt(),
663
+ created_at: import_zod15.z.string(),
664
+ updated_at: import_zod15.z.string()
665
+ }).meta({ id: "GoalRecord" });
666
+ var GoalSnapshotSchema = import_zod15.z.object({
667
+ session_id: import_zod15.z.string().nullable(),
668
+ goal: GoalRecordSchema.nullable(),
669
+ can_continue: import_zod15.z.boolean(),
670
+ accepted_run_id: import_zod15.z.string().optional(),
671
+ active_run_id: import_zod15.z.string().optional()
672
+ }).meta({ id: "GoalSnapshot" });
673
+ var GoalOfferSchema = import_zod15.z.object({
674
+ session_id: import_zod15.z.string(),
675
+ goal_id: import_zod15.z.string(),
676
+ revision: wireInt(),
677
+ continuation_id: import_zod15.z.string(),
678
+ after_run_id: import_zod15.z.string().optional()
679
+ }).meta({ id: "GoalOffer" });
109
680
  // Annotate the CommonJS export names for ESM import in node:
110
681
  0 && (module.exports = {
111
682
  ATTACHMENT_ID_PATTERN,
683
+ AgentEventSchema,
684
+ ApprovalModeSchema,
685
+ AttachedImageMetadataSchema,
686
+ AttachmentRefPartSchema,
687
+ AttachmentRefSchema,
688
+ CompactionCompleteEventSchema,
689
+ CompactionStartEventSchema,
690
+ ContentPartSchema,
691
+ ContextUsageBreakdownEntrySchema,
692
+ ContextUsageCategorySchema,
693
+ ContextUsageSchema,
694
+ DocumentPartSchema,
695
+ FinalResponseEventSchema,
696
+ GeneratedImageMetadataSchema,
697
+ GoalOfferSchema,
698
+ GoalRecordSchema,
699
+ GoalSnapshotSchema,
700
+ GoalStatusSchema,
701
+ GoalStopReasonSchema,
702
+ HiddenUserMessageEventSchema,
112
703
  IMAGE_REFERENCE_MAX_COUNT,
704
+ ImageArtifactMetadataSchema,
705
+ ImageArtifactRefSchema,
706
+ ImageDetailSchema,
707
+ ImageGenerationUsageSchema,
708
+ ImageMediaTypeSchema,
709
+ ImageModelViewSchema,
710
+ ImagePartSchema,
711
+ ImageRefPartSchema,
712
+ ImageUrlSchema,
713
+ LlmCallTimingSchema,
714
+ LlmRetryEventSchema,
715
+ LlmStatusBufferingEventSchema,
716
+ LlmStatusEventSchema,
717
+ LlmStatusVerificationEventSchema,
113
718
  MODEL_REASONING_LEVELS,
719
+ ModelFastModeSchema,
720
+ ModelReasoningLevelSchema,
721
+ ModelSpeedTierSchema,
722
+ OtherPartSchema,
723
+ PermissionPreviewEventSchema,
724
+ PermissionReadyEventSchema,
725
+ ProviderNameSchema,
726
+ ReasoningDeltaEventSchema,
727
+ ReasoningEventSchema,
728
+ RunErrorInfoSchema,
729
+ SandboxModeSchema,
730
+ SessionStateSummarySchema,
114
731
  SkillCatalogSchema,
115
732
  SkillLoadErrorSchema,
116
733
  SkillMetadataSchema,
117
734
  SkillScopeSchema,
118
735
  SkillSearchReasonSchema,
119
736
  SkillSearchResultSchema,
737
+ SteerAppliedEventSchema,
738
+ StepCompleteEventSchema,
739
+ StepStartEventSchema,
740
+ SubagentLineageSchema,
741
+ TaskProgressCurrentToolSchema,
742
+ TaskProgressLastToolSchema,
743
+ TaskProgressSchema,
744
+ TaskTerminationReasonSchema,
745
+ TaskUsageSchema,
746
+ TextDeltaEventSchema,
747
+ TextEventSchema,
748
+ TextPartSchema,
749
+ ToolCallEventSchema,
750
+ ToolResultEventSchema,
751
+ WIRE_ENCODE_KEY,
752
+ WIRE_KEYED_KEY,
753
+ WIRE_PRESENCE_KEY,
754
+ WIRE_TAG_KEY,
755
+ clearable,
120
756
  isImageModelView,
121
757
  isModelFastMode,
122
758
  isModelReasoningLevel,
759
+ keyed,
760
+ nullish,
123
761
  parseApprovalMode,
124
762
  parseSandboxMode,
125
- sandboxModes
763
+ sandboxModes,
764
+ tagged,
765
+ wireCount,
766
+ wireInt
126
767
  });