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