@clearideas/agent-runtime-contracts 0.1.0 → 0.3.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/index.d.ts +191 -45
- package/dist/index.js +198 -10
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -43,6 +43,8 @@ export interface ToolCall {
|
|
|
43
43
|
name: string;
|
|
44
44
|
input: JsonObject;
|
|
45
45
|
stepId?: string;
|
|
46
|
+
providerExecuted?: boolean;
|
|
47
|
+
metadata?: JsonObject;
|
|
46
48
|
}
|
|
47
49
|
export interface ToolResult {
|
|
48
50
|
callId: string;
|
|
@@ -52,7 +54,7 @@ export interface ToolResult {
|
|
|
52
54
|
artifacts?: ArtifactRef[];
|
|
53
55
|
metadata?: JsonObject;
|
|
54
56
|
}
|
|
55
|
-
export type ContentPart = {
|
|
57
|
+
export type ContentPart = ({
|
|
56
58
|
type: "text";
|
|
57
59
|
text: string;
|
|
58
60
|
} | {
|
|
@@ -66,17 +68,37 @@ export type ContentPart = {
|
|
|
66
68
|
type: "image";
|
|
67
69
|
artifact?: ArtifactRef;
|
|
68
70
|
url?: string;
|
|
71
|
+
/** Base64-encoded bytes. Prefer artifact references for durable histories. */
|
|
72
|
+
data?: string;
|
|
69
73
|
mediaType?: string;
|
|
70
74
|
} | {
|
|
71
75
|
type: "file";
|
|
72
|
-
artifact
|
|
76
|
+
artifact?: ArtifactRef;
|
|
77
|
+
url?: string;
|
|
78
|
+
/** Base64-encoded bytes. Prefer artifact references for durable histories. */
|
|
79
|
+
data?: string;
|
|
80
|
+
name?: string;
|
|
81
|
+
mediaType?: string;
|
|
73
82
|
} | {
|
|
74
83
|
type: "tool-call";
|
|
75
84
|
call: ToolCall;
|
|
76
85
|
} | {
|
|
77
86
|
type: "tool-result";
|
|
78
87
|
result: ToolResult;
|
|
88
|
+
}) & {
|
|
89
|
+
/** Opaque application metadata. It is persisted but never interpreted by a model adapter. */
|
|
90
|
+
metadata?: JsonObject;
|
|
91
|
+
/** Provider-specific replay information forwarded by compatible model adapters. */
|
|
92
|
+
providerOptions?: JsonObject;
|
|
79
93
|
};
|
|
94
|
+
export interface PromptMessage {
|
|
95
|
+
role: "system" | "user" | "assistant" | "tool";
|
|
96
|
+
content: ContentPart[];
|
|
97
|
+
/** Opaque application metadata. */
|
|
98
|
+
metadata?: JsonObject;
|
|
99
|
+
/** Provider-specific replay information forwarded by compatible model adapters. */
|
|
100
|
+
providerOptions?: JsonObject;
|
|
101
|
+
}
|
|
80
102
|
export interface TranscriptItem {
|
|
81
103
|
id: string;
|
|
82
104
|
type: "message" | "reasoning" | "tool-call" | "tool-result" | "artifact" | "error";
|
|
@@ -86,6 +108,7 @@ export interface TranscriptItem {
|
|
|
86
108
|
model?: string;
|
|
87
109
|
usage?: ModelUsage;
|
|
88
110
|
metadata?: JsonObject;
|
|
111
|
+
providerOptions?: JsonObject;
|
|
89
112
|
}
|
|
90
113
|
export type ModelReference = {
|
|
91
114
|
provider: string;
|
|
@@ -134,10 +157,8 @@ export interface AgentStepBase {
|
|
|
134
157
|
metadata?: JsonObject;
|
|
135
158
|
extensions?: JsonObject;
|
|
136
159
|
}
|
|
137
|
-
|
|
160
|
+
interface PromptStepDefinition extends AgentStepBase {
|
|
138
161
|
type: "prompt";
|
|
139
|
-
prompt: string;
|
|
140
|
-
systemPrompt?: string;
|
|
141
162
|
model?: ModelReference;
|
|
142
163
|
outputSchema?: JsonObject;
|
|
143
164
|
tools?: string[];
|
|
@@ -149,6 +170,17 @@ export interface PromptStep extends AgentStepBase {
|
|
|
149
170
|
requireOutput?: boolean;
|
|
150
171
|
};
|
|
151
172
|
}
|
|
173
|
+
export type PromptStep = PromptStepDefinition & ({
|
|
174
|
+
/** Backward-compatible single-user-message shorthand. */
|
|
175
|
+
prompt: string;
|
|
176
|
+
systemPrompt?: string;
|
|
177
|
+
messages?: never;
|
|
178
|
+
} | {
|
|
179
|
+
/** Complete ordered model history. */
|
|
180
|
+
messages: PromptMessage[];
|
|
181
|
+
prompt?: never;
|
|
182
|
+
systemPrompt?: never;
|
|
183
|
+
});
|
|
152
184
|
export interface LoopDefinition {
|
|
153
185
|
source?: string;
|
|
154
186
|
delimiter?: string;
|
|
@@ -194,6 +226,7 @@ export interface CodeStep extends AgentStepBase {
|
|
|
194
226
|
environment?: Record<string, string>;
|
|
195
227
|
}
|
|
196
228
|
export type AgentStep = PromptStep | LoopStep | WebhookStep | ApprovalStep | SubRunStep | CodeStep;
|
|
229
|
+
export declare const promptMessageSchema: z.ZodType<PromptMessage>;
|
|
197
230
|
export declare const agentStepSchema: z.ZodType<AgentStep>;
|
|
198
231
|
export interface AgentManifest {
|
|
199
232
|
schemaVersion: typeof AGENT_MANIFEST_SCHEMA_VERSION;
|
|
@@ -206,6 +239,8 @@ export interface AgentManifest {
|
|
|
206
239
|
steps: AgentStep[];
|
|
207
240
|
limits?: {
|
|
208
241
|
maxSteps?: number;
|
|
242
|
+
maxMessagesPerPrompt?: number;
|
|
243
|
+
maxInputBytes?: number;
|
|
209
244
|
maxOutputBytes?: number;
|
|
210
245
|
maxToolCallsPerIteration?: number;
|
|
211
246
|
providerTimeoutMs?: number;
|
|
@@ -308,31 +343,38 @@ export declare const runErrorSchema: z.ZodObject<{
|
|
|
308
343
|
export declare const transcriptItemSchema: z.ZodObject<{
|
|
309
344
|
id: z.ZodString;
|
|
310
345
|
type: z.ZodEnum<{
|
|
311
|
-
|
|
346
|
+
artifact: "artifact";
|
|
312
347
|
error: "error";
|
|
348
|
+
message: "message";
|
|
313
349
|
reasoning: "reasoning";
|
|
314
350
|
"tool-call": "tool-call";
|
|
315
351
|
"tool-result": "tool-result";
|
|
316
|
-
artifact: "artifact";
|
|
317
352
|
}>;
|
|
318
353
|
role: z.ZodOptional<z.ZodEnum<{
|
|
319
|
-
system: "system";
|
|
320
|
-
user: "user";
|
|
321
354
|
assistant: "assistant";
|
|
355
|
+
system: "system";
|
|
322
356
|
tool: "tool";
|
|
357
|
+
user: "user";
|
|
323
358
|
}>>;
|
|
324
359
|
content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
360
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
361
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
325
362
|
type: z.ZodLiteral<"text">;
|
|
326
363
|
text: z.ZodString;
|
|
327
364
|
}, z.core.$strict>, z.ZodObject<{
|
|
365
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
366
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
328
367
|
type: z.ZodLiteral<"reasoning">;
|
|
329
368
|
text: z.ZodOptional<z.ZodString>;
|
|
330
369
|
encrypted: z.ZodOptional<z.ZodString>;
|
|
331
370
|
}, z.core.$strict>, z.ZodObject<{
|
|
371
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
372
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
332
373
|
type: z.ZodLiteral<"json">;
|
|
333
374
|
value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
334
375
|
}, z.core.$strict>, z.ZodObject<{
|
|
335
|
-
|
|
376
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
377
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
336
378
|
artifact: z.ZodOptional<z.ZodObject<{
|
|
337
379
|
id: z.ZodString;
|
|
338
380
|
name: z.ZodString;
|
|
@@ -343,10 +385,13 @@ export declare const transcriptItemSchema: z.ZodObject<{
|
|
|
343
385
|
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
344
386
|
}, z.core.$strict>>;
|
|
345
387
|
url: z.ZodOptional<z.ZodString>;
|
|
388
|
+
data: z.ZodOptional<z.ZodString>;
|
|
389
|
+
type: z.ZodLiteral<"image">;
|
|
346
390
|
mediaType: z.ZodOptional<z.ZodString>;
|
|
347
391
|
}, z.core.$strict>, z.ZodObject<{
|
|
348
|
-
|
|
349
|
-
|
|
392
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
393
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
394
|
+
artifact: z.ZodOptional<z.ZodObject<{
|
|
350
395
|
id: z.ZodString;
|
|
351
396
|
name: z.ZodString;
|
|
352
397
|
mediaType: z.ZodString;
|
|
@@ -354,16 +399,27 @@ export declare const transcriptItemSchema: z.ZodObject<{
|
|
|
354
399
|
size: z.ZodOptional<z.ZodNumber>;
|
|
355
400
|
sha256: z.ZodOptional<z.ZodString>;
|
|
356
401
|
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
357
|
-
}, z.core.$strict
|
|
402
|
+
}, z.core.$strict>>;
|
|
403
|
+
url: z.ZodOptional<z.ZodString>;
|
|
404
|
+
data: z.ZodOptional<z.ZodString>;
|
|
405
|
+
type: z.ZodLiteral<"file">;
|
|
406
|
+
name: z.ZodOptional<z.ZodString>;
|
|
407
|
+
mediaType: z.ZodOptional<z.ZodString>;
|
|
358
408
|
}, z.core.$strict>, z.ZodObject<{
|
|
409
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
410
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
359
411
|
type: z.ZodLiteral<"tool-call">;
|
|
360
412
|
call: z.ZodObject<{
|
|
361
413
|
id: z.ZodString;
|
|
362
414
|
name: z.ZodString;
|
|
363
415
|
input: z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>;
|
|
364
416
|
stepId: z.ZodOptional<z.ZodString>;
|
|
417
|
+
providerExecuted: z.ZodOptional<z.ZodBoolean>;
|
|
418
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
365
419
|
}, z.core.$strict>;
|
|
366
420
|
}, z.core.$strict>, z.ZodObject<{
|
|
421
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
422
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
367
423
|
type: z.ZodLiteral<"tool-result">;
|
|
368
424
|
result: z.ZodObject<{
|
|
369
425
|
callId: z.ZodString;
|
|
@@ -401,6 +457,7 @@ export declare const transcriptItemSchema: z.ZodObject<{
|
|
|
401
457
|
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
402
458
|
}, z.core.$strict>>;
|
|
403
459
|
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
460
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
404
461
|
}, z.core.$strict>;
|
|
405
462
|
export declare const stepResultSchema: z.ZodObject<{
|
|
406
463
|
stepId: z.ZodString;
|
|
@@ -411,31 +468,38 @@ export declare const stepResultSchema: z.ZodObject<{
|
|
|
411
468
|
transcript: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
412
469
|
id: z.ZodString;
|
|
413
470
|
type: z.ZodEnum<{
|
|
414
|
-
|
|
471
|
+
artifact: "artifact";
|
|
415
472
|
error: "error";
|
|
473
|
+
message: "message";
|
|
416
474
|
reasoning: "reasoning";
|
|
417
475
|
"tool-call": "tool-call";
|
|
418
476
|
"tool-result": "tool-result";
|
|
419
|
-
artifact: "artifact";
|
|
420
477
|
}>;
|
|
421
478
|
role: z.ZodOptional<z.ZodEnum<{
|
|
422
|
-
system: "system";
|
|
423
|
-
user: "user";
|
|
424
479
|
assistant: "assistant";
|
|
480
|
+
system: "system";
|
|
425
481
|
tool: "tool";
|
|
482
|
+
user: "user";
|
|
426
483
|
}>>;
|
|
427
484
|
content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
485
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
486
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
428
487
|
type: z.ZodLiteral<"text">;
|
|
429
488
|
text: z.ZodString;
|
|
430
489
|
}, z.core.$strict>, z.ZodObject<{
|
|
490
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
491
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
431
492
|
type: z.ZodLiteral<"reasoning">;
|
|
432
493
|
text: z.ZodOptional<z.ZodString>;
|
|
433
494
|
encrypted: z.ZodOptional<z.ZodString>;
|
|
434
495
|
}, z.core.$strict>, z.ZodObject<{
|
|
496
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
497
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
435
498
|
type: z.ZodLiteral<"json">;
|
|
436
499
|
value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
437
500
|
}, z.core.$strict>, z.ZodObject<{
|
|
438
|
-
|
|
501
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
502
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
439
503
|
artifact: z.ZodOptional<z.ZodObject<{
|
|
440
504
|
id: z.ZodString;
|
|
441
505
|
name: z.ZodString;
|
|
@@ -446,10 +510,13 @@ export declare const stepResultSchema: z.ZodObject<{
|
|
|
446
510
|
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
447
511
|
}, z.core.$strict>>;
|
|
448
512
|
url: z.ZodOptional<z.ZodString>;
|
|
513
|
+
data: z.ZodOptional<z.ZodString>;
|
|
514
|
+
type: z.ZodLiteral<"image">;
|
|
449
515
|
mediaType: z.ZodOptional<z.ZodString>;
|
|
450
516
|
}, z.core.$strict>, z.ZodObject<{
|
|
451
|
-
|
|
452
|
-
|
|
517
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
518
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
519
|
+
artifact: z.ZodOptional<z.ZodObject<{
|
|
453
520
|
id: z.ZodString;
|
|
454
521
|
name: z.ZodString;
|
|
455
522
|
mediaType: z.ZodString;
|
|
@@ -457,16 +524,27 @@ export declare const stepResultSchema: z.ZodObject<{
|
|
|
457
524
|
size: z.ZodOptional<z.ZodNumber>;
|
|
458
525
|
sha256: z.ZodOptional<z.ZodString>;
|
|
459
526
|
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
460
|
-
}, z.core.$strict
|
|
527
|
+
}, z.core.$strict>>;
|
|
528
|
+
url: z.ZodOptional<z.ZodString>;
|
|
529
|
+
data: z.ZodOptional<z.ZodString>;
|
|
530
|
+
type: z.ZodLiteral<"file">;
|
|
531
|
+
name: z.ZodOptional<z.ZodString>;
|
|
532
|
+
mediaType: z.ZodOptional<z.ZodString>;
|
|
461
533
|
}, z.core.$strict>, z.ZodObject<{
|
|
534
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
535
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
462
536
|
type: z.ZodLiteral<"tool-call">;
|
|
463
537
|
call: z.ZodObject<{
|
|
464
538
|
id: z.ZodString;
|
|
465
539
|
name: z.ZodString;
|
|
466
540
|
input: z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>;
|
|
467
541
|
stepId: z.ZodOptional<z.ZodString>;
|
|
542
|
+
providerExecuted: z.ZodOptional<z.ZodBoolean>;
|
|
543
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
468
544
|
}, z.core.$strict>;
|
|
469
545
|
}, z.core.$strict>, z.ZodObject<{
|
|
546
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
547
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
470
548
|
type: z.ZodLiteral<"tool-result">;
|
|
471
549
|
result: z.ZodObject<{
|
|
472
550
|
callId: z.ZodString;
|
|
@@ -504,6 +582,7 @@ export declare const stepResultSchema: z.ZodObject<{
|
|
|
504
582
|
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
505
583
|
}, z.core.$strict>>;
|
|
506
584
|
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
585
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
507
586
|
}, z.core.$strict>>>;
|
|
508
587
|
artifacts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
509
588
|
id: z.ZodString;
|
|
@@ -552,31 +631,38 @@ export declare const runCheckpointSchema: z.ZodObject<{
|
|
|
552
631
|
transcript: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
553
632
|
id: z.ZodString;
|
|
554
633
|
type: z.ZodEnum<{
|
|
555
|
-
|
|
634
|
+
artifact: "artifact";
|
|
556
635
|
error: "error";
|
|
636
|
+
message: "message";
|
|
557
637
|
reasoning: "reasoning";
|
|
558
638
|
"tool-call": "tool-call";
|
|
559
639
|
"tool-result": "tool-result";
|
|
560
|
-
artifact: "artifact";
|
|
561
640
|
}>;
|
|
562
641
|
role: z.ZodOptional<z.ZodEnum<{
|
|
563
|
-
system: "system";
|
|
564
|
-
user: "user";
|
|
565
642
|
assistant: "assistant";
|
|
643
|
+
system: "system";
|
|
566
644
|
tool: "tool";
|
|
645
|
+
user: "user";
|
|
567
646
|
}>>;
|
|
568
647
|
content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
648
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
649
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
569
650
|
type: z.ZodLiteral<"text">;
|
|
570
651
|
text: z.ZodString;
|
|
571
652
|
}, z.core.$strict>, z.ZodObject<{
|
|
653
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
654
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
572
655
|
type: z.ZodLiteral<"reasoning">;
|
|
573
656
|
text: z.ZodOptional<z.ZodString>;
|
|
574
657
|
encrypted: z.ZodOptional<z.ZodString>;
|
|
575
658
|
}, z.core.$strict>, z.ZodObject<{
|
|
659
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
660
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
576
661
|
type: z.ZodLiteral<"json">;
|
|
577
662
|
value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
578
663
|
}, z.core.$strict>, z.ZodObject<{
|
|
579
|
-
|
|
664
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
665
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
580
666
|
artifact: z.ZodOptional<z.ZodObject<{
|
|
581
667
|
id: z.ZodString;
|
|
582
668
|
name: z.ZodString;
|
|
@@ -587,10 +673,13 @@ export declare const runCheckpointSchema: z.ZodObject<{
|
|
|
587
673
|
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
588
674
|
}, z.core.$strict>>;
|
|
589
675
|
url: z.ZodOptional<z.ZodString>;
|
|
676
|
+
data: z.ZodOptional<z.ZodString>;
|
|
677
|
+
type: z.ZodLiteral<"image">;
|
|
590
678
|
mediaType: z.ZodOptional<z.ZodString>;
|
|
591
679
|
}, z.core.$strict>, z.ZodObject<{
|
|
592
|
-
|
|
593
|
-
|
|
680
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
681
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
682
|
+
artifact: z.ZodOptional<z.ZodObject<{
|
|
594
683
|
id: z.ZodString;
|
|
595
684
|
name: z.ZodString;
|
|
596
685
|
mediaType: z.ZodString;
|
|
@@ -598,16 +687,27 @@ export declare const runCheckpointSchema: z.ZodObject<{
|
|
|
598
687
|
size: z.ZodOptional<z.ZodNumber>;
|
|
599
688
|
sha256: z.ZodOptional<z.ZodString>;
|
|
600
689
|
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
601
|
-
}, z.core.$strict
|
|
690
|
+
}, z.core.$strict>>;
|
|
691
|
+
url: z.ZodOptional<z.ZodString>;
|
|
692
|
+
data: z.ZodOptional<z.ZodString>;
|
|
693
|
+
type: z.ZodLiteral<"file">;
|
|
694
|
+
name: z.ZodOptional<z.ZodString>;
|
|
695
|
+
mediaType: z.ZodOptional<z.ZodString>;
|
|
602
696
|
}, z.core.$strict>, z.ZodObject<{
|
|
697
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
698
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
603
699
|
type: z.ZodLiteral<"tool-call">;
|
|
604
700
|
call: z.ZodObject<{
|
|
605
701
|
id: z.ZodString;
|
|
606
702
|
name: z.ZodString;
|
|
607
703
|
input: z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>;
|
|
608
704
|
stepId: z.ZodOptional<z.ZodString>;
|
|
705
|
+
providerExecuted: z.ZodOptional<z.ZodBoolean>;
|
|
706
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
609
707
|
}, z.core.$strict>;
|
|
610
708
|
}, z.core.$strict>, z.ZodObject<{
|
|
709
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
710
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
611
711
|
type: z.ZodLiteral<"tool-result">;
|
|
612
712
|
result: z.ZodObject<{
|
|
613
713
|
callId: z.ZodString;
|
|
@@ -645,6 +745,7 @@ export declare const runCheckpointSchema: z.ZodObject<{
|
|
|
645
745
|
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
646
746
|
}, z.core.$strict>>;
|
|
647
747
|
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
748
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
648
749
|
}, z.core.$strict>>>;
|
|
649
750
|
artifacts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
650
751
|
id: z.ZodString;
|
|
@@ -671,31 +772,38 @@ export declare const runCheckpointSchema: z.ZodObject<{
|
|
|
671
772
|
transcript: z.ZodArray<z.ZodObject<{
|
|
672
773
|
id: z.ZodString;
|
|
673
774
|
type: z.ZodEnum<{
|
|
674
|
-
|
|
775
|
+
artifact: "artifact";
|
|
675
776
|
error: "error";
|
|
777
|
+
message: "message";
|
|
676
778
|
reasoning: "reasoning";
|
|
677
779
|
"tool-call": "tool-call";
|
|
678
780
|
"tool-result": "tool-result";
|
|
679
|
-
artifact: "artifact";
|
|
680
781
|
}>;
|
|
681
782
|
role: z.ZodOptional<z.ZodEnum<{
|
|
682
|
-
system: "system";
|
|
683
|
-
user: "user";
|
|
684
783
|
assistant: "assistant";
|
|
784
|
+
system: "system";
|
|
685
785
|
tool: "tool";
|
|
786
|
+
user: "user";
|
|
686
787
|
}>>;
|
|
687
788
|
content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
789
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
790
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
688
791
|
type: z.ZodLiteral<"text">;
|
|
689
792
|
text: z.ZodString;
|
|
690
793
|
}, z.core.$strict>, z.ZodObject<{
|
|
794
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
795
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
691
796
|
type: z.ZodLiteral<"reasoning">;
|
|
692
797
|
text: z.ZodOptional<z.ZodString>;
|
|
693
798
|
encrypted: z.ZodOptional<z.ZodString>;
|
|
694
799
|
}, z.core.$strict>, z.ZodObject<{
|
|
800
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
801
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
695
802
|
type: z.ZodLiteral<"json">;
|
|
696
803
|
value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
697
804
|
}, z.core.$strict>, z.ZodObject<{
|
|
698
|
-
|
|
805
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
806
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
699
807
|
artifact: z.ZodOptional<z.ZodObject<{
|
|
700
808
|
id: z.ZodString;
|
|
701
809
|
name: z.ZodString;
|
|
@@ -706,10 +814,13 @@ export declare const runCheckpointSchema: z.ZodObject<{
|
|
|
706
814
|
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
707
815
|
}, z.core.$strict>>;
|
|
708
816
|
url: z.ZodOptional<z.ZodString>;
|
|
817
|
+
data: z.ZodOptional<z.ZodString>;
|
|
818
|
+
type: z.ZodLiteral<"image">;
|
|
709
819
|
mediaType: z.ZodOptional<z.ZodString>;
|
|
710
820
|
}, z.core.$strict>, z.ZodObject<{
|
|
711
|
-
|
|
712
|
-
|
|
821
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
822
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
823
|
+
artifact: z.ZodOptional<z.ZodObject<{
|
|
713
824
|
id: z.ZodString;
|
|
714
825
|
name: z.ZodString;
|
|
715
826
|
mediaType: z.ZodString;
|
|
@@ -717,16 +828,27 @@ export declare const runCheckpointSchema: z.ZodObject<{
|
|
|
717
828
|
size: z.ZodOptional<z.ZodNumber>;
|
|
718
829
|
sha256: z.ZodOptional<z.ZodString>;
|
|
719
830
|
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
720
|
-
}, z.core.$strict
|
|
831
|
+
}, z.core.$strict>>;
|
|
832
|
+
url: z.ZodOptional<z.ZodString>;
|
|
833
|
+
data: z.ZodOptional<z.ZodString>;
|
|
834
|
+
type: z.ZodLiteral<"file">;
|
|
835
|
+
name: z.ZodOptional<z.ZodString>;
|
|
836
|
+
mediaType: z.ZodOptional<z.ZodString>;
|
|
721
837
|
}, z.core.$strict>, z.ZodObject<{
|
|
838
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
839
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
722
840
|
type: z.ZodLiteral<"tool-call">;
|
|
723
841
|
call: z.ZodObject<{
|
|
724
842
|
id: z.ZodString;
|
|
725
843
|
name: z.ZodString;
|
|
726
844
|
input: z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>;
|
|
727
845
|
stepId: z.ZodOptional<z.ZodString>;
|
|
846
|
+
providerExecuted: z.ZodOptional<z.ZodBoolean>;
|
|
847
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
728
848
|
}, z.core.$strict>;
|
|
729
849
|
}, z.core.$strict>, z.ZodObject<{
|
|
850
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
851
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
730
852
|
type: z.ZodLiteral<"tool-result">;
|
|
731
853
|
result: z.ZodObject<{
|
|
732
854
|
callId: z.ZodString;
|
|
@@ -764,6 +886,7 @@ export declare const runCheckpointSchema: z.ZodObject<{
|
|
|
764
886
|
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
765
887
|
}, z.core.$strict>>;
|
|
766
888
|
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
889
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
767
890
|
}, z.core.$strict>>;
|
|
768
891
|
artifacts: z.ZodArray<z.ZodObject<{
|
|
769
892
|
id: z.ZodString;
|
|
@@ -777,31 +900,38 @@ export declare const runCheckpointSchema: z.ZodObject<{
|
|
|
777
900
|
activeStepTranscript: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
778
901
|
id: z.ZodString;
|
|
779
902
|
type: z.ZodEnum<{
|
|
780
|
-
|
|
903
|
+
artifact: "artifact";
|
|
781
904
|
error: "error";
|
|
905
|
+
message: "message";
|
|
782
906
|
reasoning: "reasoning";
|
|
783
907
|
"tool-call": "tool-call";
|
|
784
908
|
"tool-result": "tool-result";
|
|
785
|
-
artifact: "artifact";
|
|
786
909
|
}>;
|
|
787
910
|
role: z.ZodOptional<z.ZodEnum<{
|
|
788
|
-
system: "system";
|
|
789
|
-
user: "user";
|
|
790
911
|
assistant: "assistant";
|
|
912
|
+
system: "system";
|
|
791
913
|
tool: "tool";
|
|
914
|
+
user: "user";
|
|
792
915
|
}>>;
|
|
793
916
|
content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
917
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
918
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
794
919
|
type: z.ZodLiteral<"text">;
|
|
795
920
|
text: z.ZodString;
|
|
796
921
|
}, z.core.$strict>, z.ZodObject<{
|
|
922
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
923
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
797
924
|
type: z.ZodLiteral<"reasoning">;
|
|
798
925
|
text: z.ZodOptional<z.ZodString>;
|
|
799
926
|
encrypted: z.ZodOptional<z.ZodString>;
|
|
800
927
|
}, z.core.$strict>, z.ZodObject<{
|
|
928
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
929
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
801
930
|
type: z.ZodLiteral<"json">;
|
|
802
931
|
value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
803
932
|
}, z.core.$strict>, z.ZodObject<{
|
|
804
|
-
|
|
933
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
934
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
805
935
|
artifact: z.ZodOptional<z.ZodObject<{
|
|
806
936
|
id: z.ZodString;
|
|
807
937
|
name: z.ZodString;
|
|
@@ -812,10 +942,13 @@ export declare const runCheckpointSchema: z.ZodObject<{
|
|
|
812
942
|
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
813
943
|
}, z.core.$strict>>;
|
|
814
944
|
url: z.ZodOptional<z.ZodString>;
|
|
945
|
+
data: z.ZodOptional<z.ZodString>;
|
|
946
|
+
type: z.ZodLiteral<"image">;
|
|
815
947
|
mediaType: z.ZodOptional<z.ZodString>;
|
|
816
948
|
}, z.core.$strict>, z.ZodObject<{
|
|
817
|
-
|
|
818
|
-
|
|
949
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
950
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
951
|
+
artifact: z.ZodOptional<z.ZodObject<{
|
|
819
952
|
id: z.ZodString;
|
|
820
953
|
name: z.ZodString;
|
|
821
954
|
mediaType: z.ZodString;
|
|
@@ -823,16 +956,27 @@ export declare const runCheckpointSchema: z.ZodObject<{
|
|
|
823
956
|
size: z.ZodOptional<z.ZodNumber>;
|
|
824
957
|
sha256: z.ZodOptional<z.ZodString>;
|
|
825
958
|
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
826
|
-
}, z.core.$strict
|
|
959
|
+
}, z.core.$strict>>;
|
|
960
|
+
url: z.ZodOptional<z.ZodString>;
|
|
961
|
+
data: z.ZodOptional<z.ZodString>;
|
|
962
|
+
type: z.ZodLiteral<"file">;
|
|
963
|
+
name: z.ZodOptional<z.ZodString>;
|
|
964
|
+
mediaType: z.ZodOptional<z.ZodString>;
|
|
827
965
|
}, z.core.$strict>, z.ZodObject<{
|
|
966
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
967
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
828
968
|
type: z.ZodLiteral<"tool-call">;
|
|
829
969
|
call: z.ZodObject<{
|
|
830
970
|
id: z.ZodString;
|
|
831
971
|
name: z.ZodString;
|
|
832
972
|
input: z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>;
|
|
833
973
|
stepId: z.ZodOptional<z.ZodString>;
|
|
974
|
+
providerExecuted: z.ZodOptional<z.ZodBoolean>;
|
|
975
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
834
976
|
}, z.core.$strict>;
|
|
835
977
|
}, z.core.$strict>, z.ZodObject<{
|
|
978
|
+
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
979
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
836
980
|
type: z.ZodLiteral<"tool-result">;
|
|
837
981
|
result: z.ZodObject<{
|
|
838
982
|
callId: z.ZodString;
|
|
@@ -870,6 +1014,7 @@ export declare const runCheckpointSchema: z.ZodObject<{
|
|
|
870
1014
|
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
871
1015
|
}, z.core.$strict>>;
|
|
872
1016
|
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
1017
|
+
providerOptions: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
873
1018
|
}, z.core.$strict>>>;
|
|
874
1019
|
activeStepArtifacts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
875
1020
|
id: z.ZodString;
|
|
@@ -915,3 +1060,4 @@ export declare const parseAgentManifest: (input: unknown) => AgentManifest;
|
|
|
915
1060
|
export declare const safeParseAgentManifest: (input: unknown) => z.ZodSafeParseResult<AgentManifest>;
|
|
916
1061
|
export declare const parseAgentRunManifest: (input: unknown) => AgentRunManifest;
|
|
917
1062
|
export declare const safeParseAgentRunManifest: (input: unknown) => z.ZodSafeParseResult<AgentRunManifest>;
|
|
1063
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -113,6 +113,71 @@ const modelReferenceSchema = z.union([
|
|
|
113
113
|
explicitModelReferenceSchema,
|
|
114
114
|
profileModelReferenceSchema,
|
|
115
115
|
]);
|
|
116
|
+
export const promptMessageSchema = z.lazy(() => z
|
|
117
|
+
.strictObject({
|
|
118
|
+
role: z.enum(["system", "user", "assistant", "tool"]),
|
|
119
|
+
content: z.array(contentPartSchema).min(1),
|
|
120
|
+
metadata: jsonObjectSchema.optional(),
|
|
121
|
+
providerOptions: jsonObjectSchema.optional(),
|
|
122
|
+
})
|
|
123
|
+
.superRefine((message, context) => {
|
|
124
|
+
if (message.role === "system") {
|
|
125
|
+
message.content.forEach((part, index) => {
|
|
126
|
+
if (part.type !== "text") {
|
|
127
|
+
context.addIssue({
|
|
128
|
+
code: "custom",
|
|
129
|
+
path: ["content", index],
|
|
130
|
+
message: "System messages may contain only text parts.",
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
if (message.role === "tool") {
|
|
136
|
+
message.content.forEach((part, index) => {
|
|
137
|
+
if (part.type !== "tool-result") {
|
|
138
|
+
context.addIssue({
|
|
139
|
+
code: "custom",
|
|
140
|
+
path: ["content", index],
|
|
141
|
+
message: "Tool messages may contain only tool-result parts.",
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
if (message.role === "user") {
|
|
147
|
+
message.content.forEach((part, index) => {
|
|
148
|
+
if (part.type === "reasoning" ||
|
|
149
|
+
part.type === "tool-call" ||
|
|
150
|
+
part.type === "tool-result") {
|
|
151
|
+
context.addIssue({
|
|
152
|
+
code: "custom",
|
|
153
|
+
path: ["content", index],
|
|
154
|
+
message: `User messages cannot contain ${part.type} parts.`,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
message.content.forEach((part, index) => {
|
|
160
|
+
if (part.type !== "image" && part.type !== "file")
|
|
161
|
+
return;
|
|
162
|
+
const sourceCount = [part.artifact, part.url, part.data].filter((value) => value !== undefined).length;
|
|
163
|
+
if (sourceCount !== 1) {
|
|
164
|
+
context.addIssue({
|
|
165
|
+
code: "custom",
|
|
166
|
+
path: ["content", index],
|
|
167
|
+
message: "History media parts require exactly one of artifact, url, or data.",
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
if (part.type === "file" &&
|
|
171
|
+
part.artifact == null &&
|
|
172
|
+
part.mediaType == null) {
|
|
173
|
+
context.addIssue({
|
|
174
|
+
code: "custom",
|
|
175
|
+
path: ["content", index, "mediaType"],
|
|
176
|
+
message: "History file parts without an artifact reference require mediaType.",
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}));
|
|
116
181
|
const agentConnectionBindingSchema = z.strictObject({
|
|
117
182
|
ref: z.string().min(1),
|
|
118
183
|
alias: z
|
|
@@ -123,12 +188,16 @@ const agentConnectionBindingSchema = z.strictObject({
|
|
|
123
188
|
mode: z.enum(["read", "read_write"]).optional(),
|
|
124
189
|
required: z.boolean().optional(),
|
|
125
190
|
});
|
|
191
|
+
// The prompt refinement below enforces the PromptStep input union. Zod retains
|
|
192
|
+
// optional field inference after superRefine, so expose the refined output type.
|
|
126
193
|
export const agentStepSchema = z.lazy(() => z.discriminatedUnion("type", [
|
|
127
|
-
z
|
|
194
|
+
z
|
|
195
|
+
.strictObject({
|
|
128
196
|
...stepBaseShape,
|
|
129
197
|
type: z.literal("prompt"),
|
|
130
|
-
prompt: z.string(),
|
|
198
|
+
prompt: z.string().optional(),
|
|
131
199
|
systemPrompt: z.string().optional(),
|
|
200
|
+
messages: z.array(promptMessageSchema).min(1).optional(),
|
|
132
201
|
model: modelReferenceSchema.optional(),
|
|
133
202
|
outputSchema: jsonObjectSchema.optional(),
|
|
134
203
|
tools: z.array(z.string()).optional(),
|
|
@@ -139,6 +208,88 @@ export const agentStepSchema = z.lazy(() => z.discriminatedUnion("type", [
|
|
|
139
208
|
requireOutput: z.boolean().optional(),
|
|
140
209
|
})
|
|
141
210
|
.optional(),
|
|
211
|
+
})
|
|
212
|
+
.superRefine((step, context) => {
|
|
213
|
+
const usesLegacyPrompt = step.prompt !== undefined;
|
|
214
|
+
const usesMessages = step.messages !== undefined;
|
|
215
|
+
if (usesLegacyPrompt === usesMessages) {
|
|
216
|
+
context.addIssue({
|
|
217
|
+
code: "custom",
|
|
218
|
+
message: "Prompt steps require exactly one of prompt or messages.",
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
if (usesMessages && step.systemPrompt !== undefined) {
|
|
222
|
+
context.addIssue({
|
|
223
|
+
code: "custom",
|
|
224
|
+
path: ["systemPrompt"],
|
|
225
|
+
message: "systemPrompt cannot be combined with a complete messages history.",
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
const calls = new Map();
|
|
229
|
+
const results = new Set();
|
|
230
|
+
let sawNonSystemMessage = false;
|
|
231
|
+
for (const [messageIndex, message] of (step.messages ?? []).entries()) {
|
|
232
|
+
if (message.role === "system" && sawNonSystemMessage) {
|
|
233
|
+
context.addIssue({
|
|
234
|
+
code: "custom",
|
|
235
|
+
path: ["messages", messageIndex, "role"],
|
|
236
|
+
message: "System messages must precede user, assistant, and tool history.",
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
else if (message.role !== "system") {
|
|
240
|
+
sawNonSystemMessage = true;
|
|
241
|
+
}
|
|
242
|
+
for (const [partIndex, part] of message.content.entries()) {
|
|
243
|
+
if (part.type === "tool-call") {
|
|
244
|
+
if (calls.has(part.call.id)) {
|
|
245
|
+
context.addIssue({
|
|
246
|
+
code: "custom",
|
|
247
|
+
path: ["messages", messageIndex, "content", partIndex],
|
|
248
|
+
message: `Duplicate historical tool-call id: ${part.call.id}`,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
calls.set(part.call.id, part.call.name);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (part.type === "tool-result") {
|
|
256
|
+
const expectedName = calls.get(part.result.callId);
|
|
257
|
+
if (expectedName == null) {
|
|
258
|
+
context.addIssue({
|
|
259
|
+
code: "custom",
|
|
260
|
+
path: ["messages", messageIndex, "content", partIndex],
|
|
261
|
+
message: `Historical tool result ${part.result.callId} has no preceding tool call.`,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
else if (expectedName !== part.result.name) {
|
|
265
|
+
context.addIssue({
|
|
266
|
+
code: "custom",
|
|
267
|
+
path: ["messages", messageIndex, "content", partIndex],
|
|
268
|
+
message: `Historical tool result ${part.result.callId} names ${part.result.name}; expected ${expectedName}.`,
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
else if (results.has(part.result.callId)) {
|
|
272
|
+
context.addIssue({
|
|
273
|
+
code: "custom",
|
|
274
|
+
path: ["messages", messageIndex, "content", partIndex],
|
|
275
|
+
message: `Duplicate historical tool result: ${part.result.callId}`,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
results.add(part.result.callId);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
for (const callId of calls.keys()) {
|
|
285
|
+
if (!results.has(callId)) {
|
|
286
|
+
context.addIssue({
|
|
287
|
+
code: "custom",
|
|
288
|
+
path: ["messages"],
|
|
289
|
+
message: `Historical tool call ${callId} has no tool result.`,
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}
|
|
142
293
|
}),
|
|
143
294
|
z.strictObject({
|
|
144
295
|
...stepBaseShape,
|
|
@@ -225,6 +376,8 @@ export const agentManifestSchema = z
|
|
|
225
376
|
limits: z
|
|
226
377
|
.object({
|
|
227
378
|
maxSteps: z.number().int().positive().optional(),
|
|
379
|
+
maxMessagesPerPrompt: z.number().int().positive().optional(),
|
|
380
|
+
maxInputBytes: z.number().int().positive().optional(),
|
|
228
381
|
maxOutputBytes: z.number().int().positive().optional(),
|
|
229
382
|
maxToolCallsPerIteration: z.number().int().positive().optional(),
|
|
230
383
|
providerTimeoutMs: z.number().int().positive().optional(),
|
|
@@ -307,6 +460,8 @@ const toolCallSchema = z.strictObject({
|
|
|
307
460
|
name: z.string().min(1),
|
|
308
461
|
input: jsonObjectSchema,
|
|
309
462
|
stepId: z.string().optional(),
|
|
463
|
+
providerExecuted: z.boolean().optional(),
|
|
464
|
+
metadata: jsonObjectSchema.optional(),
|
|
310
465
|
});
|
|
311
466
|
const toolResultSchema = z.strictObject({
|
|
312
467
|
callId: z.string().min(1),
|
|
@@ -316,23 +471,55 @@ const toolResultSchema = z.strictObject({
|
|
|
316
471
|
artifacts: z.array(artifactRefSchema).optional(),
|
|
317
472
|
metadata: jsonObjectSchema.optional(),
|
|
318
473
|
});
|
|
474
|
+
const contentPartMetadataShape = {
|
|
475
|
+
metadata: jsonObjectSchema.optional(),
|
|
476
|
+
providerOptions: jsonObjectSchema.optional(),
|
|
477
|
+
};
|
|
478
|
+
const mediaSourceSchema = {
|
|
479
|
+
artifact: artifactRefSchema.optional(),
|
|
480
|
+
url: z.string().min(1).optional(),
|
|
481
|
+
data: z.string().min(1).optional(),
|
|
482
|
+
};
|
|
319
483
|
const contentPartSchema = z.discriminatedUnion("type", [
|
|
320
|
-
z.strictObject({
|
|
484
|
+
z.strictObject({
|
|
485
|
+
type: z.literal("text"),
|
|
486
|
+
text: z.string(),
|
|
487
|
+
...contentPartMetadataShape,
|
|
488
|
+
}),
|
|
321
489
|
z.strictObject({
|
|
322
490
|
type: z.literal("reasoning"),
|
|
323
491
|
text: z.string().optional(),
|
|
324
492
|
encrypted: z.string().optional(),
|
|
493
|
+
...contentPartMetadataShape,
|
|
494
|
+
}),
|
|
495
|
+
z.strictObject({
|
|
496
|
+
type: z.literal("json"),
|
|
497
|
+
value: jsonValueSchema,
|
|
498
|
+
...contentPartMetadataShape,
|
|
325
499
|
}),
|
|
326
|
-
z.strictObject({ type: z.literal("json"), value: jsonValueSchema }),
|
|
327
500
|
z.strictObject({
|
|
328
501
|
type: z.literal("image"),
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
502
|
+
...mediaSourceSchema,
|
|
503
|
+
mediaType: z.string().min(1).optional(),
|
|
504
|
+
...contentPartMetadataShape,
|
|
505
|
+
}),
|
|
506
|
+
z.strictObject({
|
|
507
|
+
type: z.literal("file"),
|
|
508
|
+
...mediaSourceSchema,
|
|
509
|
+
name: z.string().min(1).optional(),
|
|
510
|
+
mediaType: z.string().min(1).optional(),
|
|
511
|
+
...contentPartMetadataShape,
|
|
512
|
+
}),
|
|
513
|
+
z.strictObject({
|
|
514
|
+
type: z.literal("tool-call"),
|
|
515
|
+
call: toolCallSchema,
|
|
516
|
+
...contentPartMetadataShape,
|
|
517
|
+
}),
|
|
518
|
+
z.strictObject({
|
|
519
|
+
type: z.literal("tool-result"),
|
|
520
|
+
result: toolResultSchema,
|
|
521
|
+
...contentPartMetadataShape,
|
|
332
522
|
}),
|
|
333
|
-
z.strictObject({ type: z.literal("file"), artifact: artifactRefSchema }),
|
|
334
|
-
z.strictObject({ type: z.literal("tool-call"), call: toolCallSchema }),
|
|
335
|
-
z.strictObject({ type: z.literal("tool-result"), result: toolResultSchema }),
|
|
336
523
|
]);
|
|
337
524
|
export const transcriptItemSchema = z.strictObject({
|
|
338
525
|
id: z.string().min(1),
|
|
@@ -350,6 +537,7 @@ export const transcriptItemSchema = z.strictObject({
|
|
|
350
537
|
model: z.string().optional(),
|
|
351
538
|
usage: modelUsageSchema.optional(),
|
|
352
539
|
metadata: jsonObjectSchema.optional(),
|
|
540
|
+
providerOptions: jsonObjectSchema.optional(),
|
|
353
541
|
});
|
|
354
542
|
const executionCursorSchema = z.strictObject({
|
|
355
543
|
stepIndex: z.number().int().nonnegative(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clearideas/agent-runtime-contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Versioned, persistence-independent contracts for Clear Ideas Agent Runtime.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Clear Ideas Incorporated",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"zod": "^4.4.3"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"typescript": "^
|
|
42
|
+
"typescript": "^7.0.2",
|
|
43
43
|
"vitest": "^4.0.18"
|
|
44
44
|
},
|
|
45
45
|
"engines": {
|