@dremio/js-sdk 0.45.4 → 0.45.6
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/cloud/ai/AIResource.d.ts +72 -0
- package/dist/enterprise/ai/AIResource.d.ts +72 -0
- package/dist/enterprise/ai/chat/chatEventSchema.d.ts +27 -8
- package/dist/enterprise/ai/chat/chatEventSchema.js +33 -18
- package/dist/enterprise/ai/chat/chatEventSchema.js.map +1 -1
- package/dist/enterprise/ai/conversations/AgentConversation.d.ts +24 -0
- package/dist/enterprise/ai/conversations/createConversationMachine.d.ts +72 -0
- package/dist/enterprise/ai/conversations/methods/retrieveConversationHistory.d.ts +12 -0
- package/dist-iife/cloud.js +33 -18
- package/dist-iife/enterprise.js +33 -18
- package/package.json +1 -1
|
@@ -123,6 +123,7 @@ export declare class AIResource {
|
|
|
123
123
|
content: {
|
|
124
124
|
chunkType: "error";
|
|
125
125
|
message: string;
|
|
126
|
+
type: string;
|
|
126
127
|
};
|
|
127
128
|
role: "agent";
|
|
128
129
|
} | {
|
|
@@ -136,6 +137,17 @@ export declare class AIResource {
|
|
|
136
137
|
chunkType: "endOfStream";
|
|
137
138
|
};
|
|
138
139
|
role: "agent";
|
|
140
|
+
} | {
|
|
141
|
+
conversationId: string;
|
|
142
|
+
modelName: string;
|
|
143
|
+
modelProviderId: string;
|
|
144
|
+
runId: string;
|
|
145
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
146
|
+
id: string;
|
|
147
|
+
content: {
|
|
148
|
+
chunkType: "interrupt";
|
|
149
|
+
};
|
|
150
|
+
role: "agent";
|
|
139
151
|
} | {
|
|
140
152
|
conversationId: string;
|
|
141
153
|
modelName: string;
|
|
@@ -230,6 +242,7 @@ export declare class AIResource {
|
|
|
230
242
|
content: {
|
|
231
243
|
chunkType: "error";
|
|
232
244
|
message: string;
|
|
245
|
+
type: string;
|
|
233
246
|
};
|
|
234
247
|
role: "agent";
|
|
235
248
|
} | {
|
|
@@ -243,6 +256,17 @@ export declare class AIResource {
|
|
|
243
256
|
chunkType: "endOfStream";
|
|
244
257
|
};
|
|
245
258
|
role: "agent";
|
|
259
|
+
} | {
|
|
260
|
+
conversationId: string;
|
|
261
|
+
modelName: string;
|
|
262
|
+
modelProviderId: string;
|
|
263
|
+
runId: string;
|
|
264
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
265
|
+
id: string;
|
|
266
|
+
content: {
|
|
267
|
+
chunkType: "interrupt";
|
|
268
|
+
};
|
|
269
|
+
role: "agent";
|
|
246
270
|
} | {
|
|
247
271
|
conversationId: string;
|
|
248
272
|
modelName: string;
|
|
@@ -344,6 +368,7 @@ export declare class AIResource {
|
|
|
344
368
|
content: {
|
|
345
369
|
chunkType: "error";
|
|
346
370
|
message: string;
|
|
371
|
+
type: string;
|
|
347
372
|
};
|
|
348
373
|
role: "agent";
|
|
349
374
|
} | {
|
|
@@ -357,6 +382,17 @@ export declare class AIResource {
|
|
|
357
382
|
chunkType: "endOfStream";
|
|
358
383
|
};
|
|
359
384
|
role: "agent";
|
|
385
|
+
} | {
|
|
386
|
+
conversationId: string;
|
|
387
|
+
modelName: string;
|
|
388
|
+
modelProviderId: string;
|
|
389
|
+
runId: string;
|
|
390
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
391
|
+
id: string;
|
|
392
|
+
content: {
|
|
393
|
+
chunkType: "interrupt";
|
|
394
|
+
};
|
|
395
|
+
role: "agent";
|
|
360
396
|
} | {
|
|
361
397
|
conversationId: string;
|
|
362
398
|
modelName: string;
|
|
@@ -466,6 +502,7 @@ export declare class AIResource {
|
|
|
466
502
|
content: {
|
|
467
503
|
chunkType: "error";
|
|
468
504
|
message: string;
|
|
505
|
+
type: string;
|
|
469
506
|
};
|
|
470
507
|
role: "agent";
|
|
471
508
|
} | {
|
|
@@ -479,6 +516,17 @@ export declare class AIResource {
|
|
|
479
516
|
chunkType: "endOfStream";
|
|
480
517
|
};
|
|
481
518
|
role: "agent";
|
|
519
|
+
} | {
|
|
520
|
+
conversationId: string;
|
|
521
|
+
modelName: string;
|
|
522
|
+
modelProviderId: string;
|
|
523
|
+
runId: string;
|
|
524
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
525
|
+
id: string;
|
|
526
|
+
content: {
|
|
527
|
+
chunkType: "interrupt";
|
|
528
|
+
};
|
|
529
|
+
role: "agent";
|
|
482
530
|
} | {
|
|
483
531
|
conversationId: string;
|
|
484
532
|
modelName: string;
|
|
@@ -577,6 +625,7 @@ export declare class AIResource {
|
|
|
577
625
|
content: {
|
|
578
626
|
chunkType: "error";
|
|
579
627
|
message: string;
|
|
628
|
+
type: string;
|
|
580
629
|
};
|
|
581
630
|
role: "agent";
|
|
582
631
|
} | {
|
|
@@ -590,6 +639,17 @@ export declare class AIResource {
|
|
|
590
639
|
chunkType: "endOfStream";
|
|
591
640
|
};
|
|
592
641
|
role: "agent";
|
|
642
|
+
} | {
|
|
643
|
+
conversationId: string;
|
|
644
|
+
modelName: string;
|
|
645
|
+
modelProviderId: string;
|
|
646
|
+
runId: string;
|
|
647
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
648
|
+
id: string;
|
|
649
|
+
content: {
|
|
650
|
+
chunkType: "interrupt";
|
|
651
|
+
};
|
|
652
|
+
role: "agent";
|
|
593
653
|
} | {
|
|
594
654
|
conversationId: string;
|
|
595
655
|
modelName: string;
|
|
@@ -703,6 +763,7 @@ export declare class AIResource {
|
|
|
703
763
|
content: {
|
|
704
764
|
chunkType: "error";
|
|
705
765
|
message: string;
|
|
766
|
+
type: string;
|
|
706
767
|
};
|
|
707
768
|
role: "agent";
|
|
708
769
|
} | {
|
|
@@ -716,6 +777,17 @@ export declare class AIResource {
|
|
|
716
777
|
chunkType: "endOfStream";
|
|
717
778
|
};
|
|
718
779
|
role: "agent";
|
|
780
|
+
} | {
|
|
781
|
+
conversationId: string;
|
|
782
|
+
modelName: string;
|
|
783
|
+
modelProviderId: string;
|
|
784
|
+
runId: string;
|
|
785
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
786
|
+
id: string;
|
|
787
|
+
content: {
|
|
788
|
+
chunkType: "interrupt";
|
|
789
|
+
};
|
|
790
|
+
role: "agent";
|
|
719
791
|
} | {
|
|
720
792
|
conversationId: string;
|
|
721
793
|
modelName: string;
|
|
@@ -65,6 +65,7 @@ export declare class AIResource {
|
|
|
65
65
|
content: {
|
|
66
66
|
chunkType: "error";
|
|
67
67
|
message: string;
|
|
68
|
+
type: string;
|
|
68
69
|
};
|
|
69
70
|
role: "agent";
|
|
70
71
|
} | {
|
|
@@ -78,6 +79,17 @@ export declare class AIResource {
|
|
|
78
79
|
chunkType: "endOfStream";
|
|
79
80
|
};
|
|
80
81
|
role: "agent";
|
|
82
|
+
} | {
|
|
83
|
+
conversationId: string;
|
|
84
|
+
modelName: string;
|
|
85
|
+
modelProviderId: string;
|
|
86
|
+
runId: string;
|
|
87
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
88
|
+
id: string;
|
|
89
|
+
content: {
|
|
90
|
+
chunkType: "interrupt";
|
|
91
|
+
};
|
|
92
|
+
role: "agent";
|
|
81
93
|
} | {
|
|
82
94
|
conversationId: string;
|
|
83
95
|
modelName: string;
|
|
@@ -172,6 +184,7 @@ export declare class AIResource {
|
|
|
172
184
|
content: {
|
|
173
185
|
chunkType: "error";
|
|
174
186
|
message: string;
|
|
187
|
+
type: string;
|
|
175
188
|
};
|
|
176
189
|
role: "agent";
|
|
177
190
|
} | {
|
|
@@ -185,6 +198,17 @@ export declare class AIResource {
|
|
|
185
198
|
chunkType: "endOfStream";
|
|
186
199
|
};
|
|
187
200
|
role: "agent";
|
|
201
|
+
} | {
|
|
202
|
+
conversationId: string;
|
|
203
|
+
modelName: string;
|
|
204
|
+
modelProviderId: string;
|
|
205
|
+
runId: string;
|
|
206
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
207
|
+
id: string;
|
|
208
|
+
content: {
|
|
209
|
+
chunkType: "interrupt";
|
|
210
|
+
};
|
|
211
|
+
role: "agent";
|
|
188
212
|
} | {
|
|
189
213
|
conversationId: string;
|
|
190
214
|
modelName: string;
|
|
@@ -286,6 +310,7 @@ export declare class AIResource {
|
|
|
286
310
|
content: {
|
|
287
311
|
chunkType: "error";
|
|
288
312
|
message: string;
|
|
313
|
+
type: string;
|
|
289
314
|
};
|
|
290
315
|
role: "agent";
|
|
291
316
|
} | {
|
|
@@ -299,6 +324,17 @@ export declare class AIResource {
|
|
|
299
324
|
chunkType: "endOfStream";
|
|
300
325
|
};
|
|
301
326
|
role: "agent";
|
|
327
|
+
} | {
|
|
328
|
+
conversationId: string;
|
|
329
|
+
modelName: string;
|
|
330
|
+
modelProviderId: string;
|
|
331
|
+
runId: string;
|
|
332
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
333
|
+
id: string;
|
|
334
|
+
content: {
|
|
335
|
+
chunkType: "interrupt";
|
|
336
|
+
};
|
|
337
|
+
role: "agent";
|
|
302
338
|
} | {
|
|
303
339
|
conversationId: string;
|
|
304
340
|
modelName: string;
|
|
@@ -408,6 +444,7 @@ export declare class AIResource {
|
|
|
408
444
|
content: {
|
|
409
445
|
chunkType: "error";
|
|
410
446
|
message: string;
|
|
447
|
+
type: string;
|
|
411
448
|
};
|
|
412
449
|
role: "agent";
|
|
413
450
|
} | {
|
|
@@ -421,6 +458,17 @@ export declare class AIResource {
|
|
|
421
458
|
chunkType: "endOfStream";
|
|
422
459
|
};
|
|
423
460
|
role: "agent";
|
|
461
|
+
} | {
|
|
462
|
+
conversationId: string;
|
|
463
|
+
modelName: string;
|
|
464
|
+
modelProviderId: string;
|
|
465
|
+
runId: string;
|
|
466
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
467
|
+
id: string;
|
|
468
|
+
content: {
|
|
469
|
+
chunkType: "interrupt";
|
|
470
|
+
};
|
|
471
|
+
role: "agent";
|
|
424
472
|
} | {
|
|
425
473
|
conversationId: string;
|
|
426
474
|
modelName: string;
|
|
@@ -519,6 +567,7 @@ export declare class AIResource {
|
|
|
519
567
|
content: {
|
|
520
568
|
chunkType: "error";
|
|
521
569
|
message: string;
|
|
570
|
+
type: string;
|
|
522
571
|
};
|
|
523
572
|
role: "agent";
|
|
524
573
|
} | {
|
|
@@ -532,6 +581,17 @@ export declare class AIResource {
|
|
|
532
581
|
chunkType: "endOfStream";
|
|
533
582
|
};
|
|
534
583
|
role: "agent";
|
|
584
|
+
} | {
|
|
585
|
+
conversationId: string;
|
|
586
|
+
modelName: string;
|
|
587
|
+
modelProviderId: string;
|
|
588
|
+
runId: string;
|
|
589
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
590
|
+
id: string;
|
|
591
|
+
content: {
|
|
592
|
+
chunkType: "interrupt";
|
|
593
|
+
};
|
|
594
|
+
role: "agent";
|
|
535
595
|
} | {
|
|
536
596
|
conversationId: string;
|
|
537
597
|
modelName: string;
|
|
@@ -645,6 +705,7 @@ export declare class AIResource {
|
|
|
645
705
|
content: {
|
|
646
706
|
chunkType: "error";
|
|
647
707
|
message: string;
|
|
708
|
+
type: string;
|
|
648
709
|
};
|
|
649
710
|
role: "agent";
|
|
650
711
|
} | {
|
|
@@ -658,6 +719,17 @@ export declare class AIResource {
|
|
|
658
719
|
chunkType: "endOfStream";
|
|
659
720
|
};
|
|
660
721
|
role: "agent";
|
|
722
|
+
} | {
|
|
723
|
+
conversationId: string;
|
|
724
|
+
modelName: string;
|
|
725
|
+
modelProviderId: string;
|
|
726
|
+
runId: string;
|
|
727
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
728
|
+
id: string;
|
|
729
|
+
content: {
|
|
730
|
+
chunkType: "interrupt";
|
|
731
|
+
};
|
|
732
|
+
role: "agent";
|
|
661
733
|
} | {
|
|
662
734
|
conversationId: string;
|
|
663
735
|
modelName: string;
|
|
@@ -52,11 +52,14 @@ export declare const chatEventV1Schema: z.ZodMiniDiscriminatedUnion<[z.ZodMiniOb
|
|
|
52
52
|
export type ChatEventV1 = z.infer<typeof chatEventV1Schema>;
|
|
53
53
|
export declare const chatEventCodec: z.ZodMiniCodec<z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
54
54
|
chunkType: z.ZodMiniLiteral<"error">;
|
|
55
|
-
/**
|
|
56
|
-
* If the message is not present or very short, it won't be useful to show
|
|
57
|
-
* anyways, so the parser should throw to the generic response error handler.
|
|
58
|
-
*/
|
|
59
55
|
message: z.ZodMiniString<string>;
|
|
56
|
+
type: z.ZodMiniString<string>;
|
|
57
|
+
conversationId: z.ZodMiniString<string>;
|
|
58
|
+
createdAt: z.ZodMiniString<string>;
|
|
59
|
+
messageId: z.ZodMiniString<string>;
|
|
60
|
+
modelName: z.ZodMiniString<string>;
|
|
61
|
+
modelProviderId: z.ZodMiniString<string>;
|
|
62
|
+
runId: z.ZodMiniString<string>;
|
|
60
63
|
}, z.core.$strip>, z.ZodMiniObject<{
|
|
61
64
|
chunkType: z.ZodMiniLiteral<"endOfStream">;
|
|
62
65
|
conversationId: z.ZodMiniString<string>;
|
|
@@ -65,6 +68,14 @@ export declare const chatEventCodec: z.ZodMiniCodec<z.ZodMiniDiscriminatedUnion<
|
|
|
65
68
|
modelName: z.ZodMiniString<string>;
|
|
66
69
|
modelProviderId: z.ZodMiniString<string>;
|
|
67
70
|
runId: z.ZodMiniString<string>;
|
|
71
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
72
|
+
chunkType: z.ZodMiniLiteral<"interrupt">;
|
|
73
|
+
conversationId: z.ZodMiniString<string>;
|
|
74
|
+
createdAt: z.ZodMiniString<string>;
|
|
75
|
+
messageId: z.ZodMiniString<string>;
|
|
76
|
+
modelName: z.ZodMiniString<string>;
|
|
77
|
+
modelProviderId: z.ZodMiniString<string>;
|
|
78
|
+
runId: z.ZodMiniString<string>;
|
|
68
79
|
}, z.core.$strip>, z.ZodMiniObject<{
|
|
69
80
|
chunkType: z.ZodMiniLiteral<"conversationUpdate">;
|
|
70
81
|
summary: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
@@ -141,11 +152,8 @@ export declare const chatEventCodec: z.ZodMiniCodec<z.ZodMiniDiscriminatedUnion<
|
|
|
141
152
|
id: z.ZodMiniString<string>;
|
|
142
153
|
content: z.ZodMiniObject<{
|
|
143
154
|
chunkType: z.ZodMiniLiteral<"error">;
|
|
144
|
-
/**
|
|
145
|
-
* If the message is not present or very short, it won't be useful to show
|
|
146
|
-
* anyways, so the parser should throw to the generic response error handler.
|
|
147
|
-
*/
|
|
148
155
|
message: z.ZodMiniString<string>;
|
|
156
|
+
type: z.ZodMiniString<string>;
|
|
149
157
|
}, z.core.$strip>;
|
|
150
158
|
role: z.ZodMiniLiteral<"agent">;
|
|
151
159
|
}, z.core.$strict>, z.ZodMiniObject<{
|
|
@@ -159,6 +167,17 @@ export declare const chatEventCodec: z.ZodMiniCodec<z.ZodMiniDiscriminatedUnion<
|
|
|
159
167
|
chunkType: z.ZodMiniLiteral<"endOfStream">;
|
|
160
168
|
}, z.core.$strip>;
|
|
161
169
|
role: z.ZodMiniLiteral<"agent">;
|
|
170
|
+
}, z.core.$strict>, z.ZodMiniObject<{
|
|
171
|
+
conversationId: z.ZodMiniString<string>;
|
|
172
|
+
modelName: z.ZodMiniString<string>;
|
|
173
|
+
modelProviderId: z.ZodMiniString<string>;
|
|
174
|
+
runId: z.ZodMiniString<string>;
|
|
175
|
+
createdAt: z.ZodMiniCustom<Temporal.Instant, Temporal.Instant>;
|
|
176
|
+
id: z.ZodMiniString<string>;
|
|
177
|
+
content: z.ZodMiniObject<{
|
|
178
|
+
chunkType: z.ZodMiniLiteral<"interrupt">;
|
|
179
|
+
}, z.core.$strip>;
|
|
180
|
+
role: z.ZodMiniLiteral<"agent">;
|
|
162
181
|
}, z.core.$strict>, z.ZodMiniObject<{
|
|
163
182
|
conversationId: z.ZodMiniString<string>;
|
|
164
183
|
modelName: z.ZodMiniString<string>;
|
|
@@ -44,6 +44,11 @@ const errorChunkSchema = z.object({
|
|
|
44
44
|
*/
|
|
45
45
|
message: z.string().check(z.trim(), z.minLength(2)),
|
|
46
46
|
});
|
|
47
|
+
const errorChunkV2Schema = z.object({
|
|
48
|
+
chunkType: z.literal("error"),
|
|
49
|
+
message: z.string().check(z.trim(), z.minLength(2)),
|
|
50
|
+
type: z.string(),
|
|
51
|
+
});
|
|
47
52
|
const conversationUpdateChunkSchema = z.object({
|
|
48
53
|
chunkType: z.literal("conversationUpdate"),
|
|
49
54
|
summary: z.optional(z.string()),
|
|
@@ -52,6 +57,9 @@ const conversationUpdateChunkSchema = z.object({
|
|
|
52
57
|
const endOfStreamChunkSchema = z.object({
|
|
53
58
|
chunkType: z.literal("endOfStream"),
|
|
54
59
|
});
|
|
60
|
+
const interruptChunkSchema = z.object({
|
|
61
|
+
chunkType: z.literal("interrupt"),
|
|
62
|
+
});
|
|
55
63
|
const modelChunkSchema = z.object({
|
|
56
64
|
chunkType: z.literal("model"),
|
|
57
65
|
name: z.string().check(z.trim(), z.minLength(1)),
|
|
@@ -98,8 +106,9 @@ export const chatEventV1Schema = z.discriminatedUnion("chunkType", [
|
|
|
98
106
|
z.extend(toolResponseChunkSchema, chatEventV1SharedSchema),
|
|
99
107
|
]);
|
|
100
108
|
const chatEventInputSchema = z.discriminatedUnion("chunkType", [
|
|
101
|
-
|
|
109
|
+
z.extend(errorChunkV2Schema, chatEventSharedSchema),
|
|
102
110
|
z.extend(endOfStreamChunkSchema, chatEventSharedSchema),
|
|
111
|
+
z.extend(interruptChunkSchema, chatEventSharedSchema),
|
|
103
112
|
z.extend(conversationUpdateChunkSchema, chatEventSharedSchema),
|
|
104
113
|
z.extend(modelChunkSchema, chatEventSharedSchema),
|
|
105
114
|
z.extend(toolRequestChunkSchema, chatEventSharedSchema),
|
|
@@ -115,11 +124,15 @@ const chatEventOutputSchema = z.union([
|
|
|
115
124
|
content: conversationUpdateChunkSchema,
|
|
116
125
|
role: z.literal("agent"),
|
|
117
126
|
}),
|
|
118
|
-
z.extend(chatEventOutputSharedSchema, { content:
|
|
127
|
+
z.extend(chatEventOutputSharedSchema, { content: errorChunkV2Schema, role: z.literal("agent") }),
|
|
119
128
|
z.extend(chatEventOutputSharedSchema, {
|
|
120
129
|
content: endOfStreamChunkSchema,
|
|
121
130
|
role: z.literal("agent"),
|
|
122
131
|
}),
|
|
132
|
+
z.extend(chatEventOutputSharedSchema, {
|
|
133
|
+
content: interruptChunkSchema,
|
|
134
|
+
role: z.literal("agent"),
|
|
135
|
+
}),
|
|
123
136
|
z.extend(chatEventOutputSharedSchema, { content: modelChunkSchema, role: z.literal("agent") }),
|
|
124
137
|
z.extend(chatEventOutputSharedSchema, {
|
|
125
138
|
content: toolRequestChunkSchema,
|
|
@@ -136,21 +149,6 @@ const chatEventOutputSchema = z.union([
|
|
|
136
149
|
]);
|
|
137
150
|
export const chatEventCodec = z.codec(chatEventInputSchema, chatEventOutputSchema, {
|
|
138
151
|
decode(v) {
|
|
139
|
-
if (v.chunkType === "error") {
|
|
140
|
-
return {
|
|
141
|
-
content: {
|
|
142
|
-
chunkType: "error",
|
|
143
|
-
message: v.message,
|
|
144
|
-
},
|
|
145
|
-
conversationId: "",
|
|
146
|
-
createdAt: Temporal.Now.instant(),
|
|
147
|
-
id: "",
|
|
148
|
-
modelName: "",
|
|
149
|
-
modelProviderId: "",
|
|
150
|
-
role: "agent",
|
|
151
|
-
runId: "",
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
152
|
const sharedProperties = {
|
|
155
153
|
conversationId: v.conversationId,
|
|
156
154
|
createdAt: Temporal.Instant.from(v.createdAt),
|
|
@@ -170,6 +168,16 @@ export const chatEventCodec = z.codec(chatEventInputSchema, chatEventOutputSchem
|
|
|
170
168
|
},
|
|
171
169
|
role: "agent",
|
|
172
170
|
};
|
|
171
|
+
case "error":
|
|
172
|
+
return {
|
|
173
|
+
...sharedProperties,
|
|
174
|
+
content: {
|
|
175
|
+
chunkType: "error",
|
|
176
|
+
message: v.message,
|
|
177
|
+
type: v.type,
|
|
178
|
+
},
|
|
179
|
+
role: "agent",
|
|
180
|
+
};
|
|
173
181
|
case "endOfStream":
|
|
174
182
|
return {
|
|
175
183
|
...sharedProperties,
|
|
@@ -178,6 +186,14 @@ export const chatEventCodec = z.codec(chatEventInputSchema, chatEventOutputSchem
|
|
|
178
186
|
},
|
|
179
187
|
role: "agent",
|
|
180
188
|
};
|
|
189
|
+
case "interrupt":
|
|
190
|
+
return {
|
|
191
|
+
...sharedProperties,
|
|
192
|
+
content: {
|
|
193
|
+
chunkType: "interrupt",
|
|
194
|
+
},
|
|
195
|
+
role: "agent",
|
|
196
|
+
};
|
|
181
197
|
case "model":
|
|
182
198
|
return {
|
|
183
199
|
...sharedProperties,
|
|
@@ -223,7 +239,6 @@ export const chatEventCodec = z.codec(chatEventInputSchema, chatEventOutputSchem
|
|
|
223
239
|
},
|
|
224
240
|
encode(v) {
|
|
225
241
|
return {
|
|
226
|
-
//@ts-ignore
|
|
227
242
|
conversationId: v.conversationId,
|
|
228
243
|
createdAt: v.createdAt.toString(),
|
|
229
244
|
messageId: v.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatEventSchema.js","sourceRoot":"","sources":["../../../../src/enterprise/ai/chat/chatEventSchema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B;;;GAGG;AACH,MAAM,uBAAuB,GAAG;IAC9B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC7C,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACrD,eAAe,EAAE,CAAC,CAAC,MA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AAO;SAC2C,CAAC;IAC5D,CAAC;CACF,CAAC,CAAC","sourcesContent":["/*\n * Copyright (C) 2024-2025 Dremio Corporation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Temporal } from \"temporal-polyfill\";\nimport * as z from \"zod/mini\";\n\n/**\n * Shared chat event fields for all responses (except error response)\n * @deprecated\n */\nconst chatEventV1SharedSchema = {\n createdAt: z.string().check(z.iso.datetime()),\n modelName: z.string().check(z.trim(), z.minLength(1)),\n modelProviderId: z.string().check(z.trim(), z.minLength(1)),\n sessionId: z.string().check(z.trim(), z.minLength(1)),\n};\n\n/**\n * Shared chat event fields for all responses (except error response)\n */\nconst chatEventSharedSchema = {\n conversationId: z.string(),\n createdAt: z.string().check(z.iso.datetime()),\n messageId: z.string(),\n modelName: z.string(),\n modelProviderId: z.string(),\n runId: z.string(),\n};\n\nconst errorChunkSchema = z.object({\n chunkType: z.literal(\"error\"),\n /**\n * If the message is not present or very short, it won't be useful to show\n * anyways, so the parser should throw to the generic response error handler.\n */\n message: z.string().check(z.trim(), z.minLength(2)),\n});\n\nconst conversationUpdateChunkSchema = z.object({\n chunkType: z.literal(\"conversationUpdate\"),\n summary: z.optional(z.string()),\n title: z.optional(z.string()),\n});\n\nconst endOfStreamChunkSchema = z.object({\n chunkType: z.literal(\"endOfStream\"),\n});\n\nconst modelChunkSchema = z.object({\n chunkType: z.literal(\"model\"),\n name: z.string().check(z.trim(), z.minLength(1)),\n /**\n * It's useful to indicate (to the type system) that the result contents\n * at this stage can only be data (de)serializable from JSON. Because\n * model responses can vary depending on runtime flags and edition, we can\n * leave this field generic and refine it more precisely in later stages.\n */\n result: z.record(z.string(), z.unknown()),\n});\n\nconst toolRequestChunkSchema = z.object({\n arguments: z.record(z.string(), z.unknown()),\n callId: z.string().check(z.trim(), z.minLength(1)),\n chunkType: z.literal(\"toolRequest\"),\n commentary: z.optional(z.string()),\n name: z.string(),\n summarizedTitle: z.optional(z.string()),\n});\n\nconst toolResponseChunkSchema = z.object({\n callId: z.string(),\n chunkType: z.literal(\"toolResponse\"),\n commentary: z.optional(z.string()),\n name: z.string(),\n result: z.record(z.string(), z.unknown()),\n});\n\nconst userMessageChunkSchema = z.object({\n chunkType: z.literal(\"userMessage\"),\n text: z.string(),\n});\n\n/**\n * Captures all of the possible chunks of data that the Agent can reply\n * with. We're lenient to extra/unexpected fields being present (`z.object`\n * instead of `z.strictObject`), but for the fields that are expected,\n * we validate that they match the most general type category they belong in.\n * For example, it's good enough to validate that the `callId` is a string\n * for type safety -- we don't need to verify that it's also a `z.uuid()`.\n * @deprecated\n */\nexport const chatEventV1Schema = z.discriminatedUnion(\"chunkType\", [\n errorChunkSchema,\n z.extend(modelChunkSchema, chatEventV1SharedSchema),\n z.extend(toolRequestChunkSchema, chatEventV1SharedSchema),\n z.extend(toolResponseChunkSchema, chatEventV1SharedSchema),\n]);\n\n/**\n * @deprecated\n */\nexport type ChatEventV1 = z.infer<typeof chatEventV1Schema>;\n\nconst chatEventInputSchema = z.discriminatedUnion(\"chunkType\", [\n errorChunkSchema,\n z.extend(endOfStreamChunkSchema, chatEventSharedSchema),\n z.extend(conversationUpdateChunkSchema, chatEventSharedSchema),\n z.extend(modelChunkSchema, chatEventSharedSchema),\n z.extend(toolRequestChunkSchema, chatEventSharedSchema),\n z.extend(toolResponseChunkSchema, chatEventSharedSchema),\n z.extend(userMessageChunkSchema, chatEventSharedSchema),\n]);\n\nconst chatEventOutputSharedSchema = z.extend(\n z.omit(z.strictObject(chatEventSharedSchema), { createdAt: true, messageId: true }),\n {\n createdAt: z.instanceof(Temporal.Instant),\n id: z.string(),\n },\n);\n\nconst chatEventOutputSchema = z.union([\n z.extend(chatEventOutputSharedSchema, {\n content: conversationUpdateChunkSchema,\n role: z.literal(\"agent\"),\n }),\n z.extend(chatEventOutputSharedSchema, { content: errorChunkSchema, role: z.literal(\"agent\") }),\n z.extend(chatEventOutputSharedSchema, {\n content: endOfStreamChunkSchema,\n role: z.literal(\"agent\"),\n }),\n z.extend(chatEventOutputSharedSchema, { content: modelChunkSchema, role: z.literal(\"agent\") }),\n z.extend(chatEventOutputSharedSchema, {\n content: toolRequestChunkSchema,\n role: z.literal(\"agent\"),\n }),\n z.extend(chatEventOutputSharedSchema, {\n content: toolResponseChunkSchema,\n role: z.literal(\"agent\"),\n }),\n z.extend(chatEventOutputSharedSchema, {\n content: userMessageChunkSchema,\n role: z.literal(\"user\"),\n }),\n]);\n\nexport const chatEventCodec = z.codec(chatEventInputSchema, chatEventOutputSchema, {\n decode(v) {\n if (v.chunkType === \"error\") {\n return {\n content: {\n chunkType: \"error\",\n message: v.message,\n },\n conversationId: \"\",\n createdAt: Temporal.Now.instant(),\n id: \"\",\n modelName: \"\",\n modelProviderId: \"\",\n role: \"agent\",\n runId: \"\",\n } as const satisfies z.output<typeof chatEventOutputSchema>;\n }\n\n const sharedProperties = {\n conversationId: v.conversationId,\n createdAt: Temporal.Instant.from(v.createdAt),\n id: v.messageId,\n modelName: v.modelName,\n modelProviderId: v.modelProviderId,\n runId: v.runId,\n } as const satisfies Omit<z.output<typeof chatEventOutputSchema>, \"content\" | \"role\">;\n\n switch (v.chunkType) {\n case \"conversationUpdate\":\n return {\n ...sharedProperties,\n content: {\n chunkType: \"conversationUpdate\",\n summary: v.summary,\n title: v.title,\n },\n role: \"agent\",\n } as const satisfies z.output<typeof chatEventOutputSchema>;\n case \"endOfStream\":\n return {\n ...sharedProperties,\n content: {\n chunkType: \"endOfStream\",\n },\n role: \"agent\",\n } as const satisfies z.output<typeof chatEventOutputSchema>;\n case \"model\":\n return {\n ...sharedProperties,\n content: {\n chunkType: \"model\",\n name: v.name,\n result: v.result,\n },\n role: \"agent\",\n } as const satisfies z.output<typeof chatEventOutputSchema>;\n case \"toolRequest\":\n return {\n ...sharedProperties,\n content: {\n arguments: v.arguments,\n callId: v.callId,\n chunkType: \"toolRequest\",\n commentary: v.commentary,\n name: v.name,\n summarizedTitle: v.summarizedTitle,\n },\n role: \"agent\",\n } as const satisfies z.output<typeof chatEventOutputSchema>;\n case \"toolResponse\":\n return {\n ...sharedProperties,\n content: {\n callId: v.callId,\n chunkType: \"toolResponse\",\n commentary: v.commentary,\n name: v.name,\n result: v.result,\n },\n role: \"agent\",\n } as const satisfies z.output<typeof chatEventOutputSchema>;\n case \"userMessage\":\n return {\n ...sharedProperties,\n content: { chunkType: \"userMessage\", text: v.text },\n role: \"user\",\n } as const satisfies z.output<typeof chatEventOutputSchema>;\n }\n },\n encode(v) {\n return {\n //@ts-ignore\n conversationId: v.conversationId,\n createdAt: v.createdAt.toString(),\n messageId: v.id,\n modelName: v.modelName,\n modelProviderId: v.modelProviderId,\n runId: v.runId,\n ...v.content,\n } as const satisfies z.infer<typeof chatEventInputSchema>;\n },\n});\n\nexport type ChatEvent = z.output<typeof chatEventCodec>;\nexport type ChatEventWithChunkType<T extends z.input<typeof chatEventCodec>[\"chunkType\"]> = Extract<\n ChatEvent,\n { content: { chunkType: T } }\n>;\n"]}
|
|
1
|
+
{"version":3,"file":"chatEventSchema.js","sourceRoot":"","sources":["../../../../src/enterprise/ai/chat/chatEventSchema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B;;;GAGG;AACH,MAAM,uBAAuB,GAAG;IAC9B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC7C,SAAS,EAAE,CAAC,CAAC,MAAM,EAA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L,GAAG,gBAAgB;oBACnB,OAAO,EAAE;wBACP,MAAM,EAAE,CAAC,CAAC,MAAM;wBAChB,SAAS,EAAE,cAAc;wBACzB,UAAU,EAAE,CAAC,CAAC,UAAU;wBACxB,IAAI,EAAE,CAAC,CAAC,IAAI;wBACZ,MAAM,EAAE,CAAC,CAAC,MAAM;qBACjB;oBACD,IAAI,EAAE,OAAO;iBAC4C,CAAC;YAC9D,KAAK,aAAa;gBAChB,OAAO;oBACL,GAAG,gBAAgB;oBACnB,OAAO,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;oBACnD,IAAI,EAAE,MAAM;iBAC6C,CAAC;QAChE,CAAC;IACH,CAAC;IACD,MAAM,CAAC,CAAC;QACN,OAAO;YACL,cAAc,EAAE,CAAC,CAAC,cAAc;YAChC,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,QAAQ,EAAE;YACjC,SAAS,EAAE,CAAC,CAAC,EAAE;YACf,SAAS,EAAE,CAAC,CAAC,SAAS;YACtB,eAAe,EAAE,CAAC,CAAC,eAAe;YAClC,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,GAAG,CAAC,CAAC,OAAO;SAC2C,CAAC;IAC5D,CAAC;CACF,CAAC,CAAC","sourcesContent":["/*\n * Copyright (C) 2024-2025 Dremio Corporation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Temporal } from \"temporal-polyfill\";\nimport * as z from \"zod/mini\";\n\n/**\n * Shared chat event fields for all responses (except error response)\n * @deprecated\n */\nconst chatEventV1SharedSchema = {\n createdAt: z.string().check(z.iso.datetime()),\n modelName: z.string().check(z.trim(), z.minLength(1)),\n modelProviderId: z.string().check(z.trim(), z.minLength(1)),\n sessionId: z.string().check(z.trim(), z.minLength(1)),\n};\n\n/**\n * Shared chat event fields for all responses (except error response)\n */\nconst chatEventSharedSchema = {\n conversationId: z.string(),\n createdAt: z.string().check(z.iso.datetime()),\n messageId: z.string(),\n modelName: z.string(),\n modelProviderId: z.string(),\n runId: z.string(),\n};\n\nconst errorChunkSchema = z.object({\n chunkType: z.literal(\"error\"),\n /**\n * If the message is not present or very short, it won't be useful to show\n * anyways, so the parser should throw to the generic response error handler.\n */\n message: z.string().check(z.trim(), z.minLength(2)),\n});\n\nconst errorChunkV2Schema = z.object({\n chunkType: z.literal(\"error\"),\n message: z.string().check(z.trim(), z.minLength(2)),\n type: z.string(),\n});\n\nconst conversationUpdateChunkSchema = z.object({\n chunkType: z.literal(\"conversationUpdate\"),\n summary: z.optional(z.string()),\n title: z.optional(z.string()),\n});\n\nconst endOfStreamChunkSchema = z.object({\n chunkType: z.literal(\"endOfStream\"),\n});\n\nconst interruptChunkSchema = z.object({\n chunkType: z.literal(\"interrupt\"),\n});\n\nconst modelChunkSchema = z.object({\n chunkType: z.literal(\"model\"),\n name: z.string().check(z.trim(), z.minLength(1)),\n /**\n * It's useful to indicate (to the type system) that the result contents\n * at this stage can only be data (de)serializable from JSON. Because\n * model responses can vary depending on runtime flags and edition, we can\n * leave this field generic and refine it more precisely in later stages.\n */\n result: z.record(z.string(), z.unknown()),\n});\n\nconst toolRequestChunkSchema = z.object({\n arguments: z.record(z.string(), z.unknown()),\n callId: z.string().check(z.trim(), z.minLength(1)),\n chunkType: z.literal(\"toolRequest\"),\n commentary: z.optional(z.string()),\n name: z.string(),\n summarizedTitle: z.optional(z.string()),\n});\n\nconst toolResponseChunkSchema = z.object({\n callId: z.string(),\n chunkType: z.literal(\"toolResponse\"),\n commentary: z.optional(z.string()),\n name: z.string(),\n result: z.record(z.string(), z.unknown()),\n});\n\nconst userMessageChunkSchema = z.object({\n chunkType: z.literal(\"userMessage\"),\n text: z.string(),\n});\n\n/**\n * Captures all of the possible chunks of data that the Agent can reply\n * with. We're lenient to extra/unexpected fields being present (`z.object`\n * instead of `z.strictObject`), but for the fields that are expected,\n * we validate that they match the most general type category they belong in.\n * For example, it's good enough to validate that the `callId` is a string\n * for type safety -- we don't need to verify that it's also a `z.uuid()`.\n * @deprecated\n */\nexport const chatEventV1Schema = z.discriminatedUnion(\"chunkType\", [\n errorChunkSchema,\n z.extend(modelChunkSchema, chatEventV1SharedSchema),\n z.extend(toolRequestChunkSchema, chatEventV1SharedSchema),\n z.extend(toolResponseChunkSchema, chatEventV1SharedSchema),\n]);\n\n/**\n * @deprecated\n */\nexport type ChatEventV1 = z.infer<typeof chatEventV1Schema>;\n\nconst chatEventInputSchema = z.discriminatedUnion(\"chunkType\", [\n z.extend(errorChunkV2Schema, chatEventSharedSchema),\n z.extend(endOfStreamChunkSchema, chatEventSharedSchema),\n z.extend(interruptChunkSchema, chatEventSharedSchema),\n z.extend(conversationUpdateChunkSchema, chatEventSharedSchema),\n z.extend(modelChunkSchema, chatEventSharedSchema),\n z.extend(toolRequestChunkSchema, chatEventSharedSchema),\n z.extend(toolResponseChunkSchema, chatEventSharedSchema),\n z.extend(userMessageChunkSchema, chatEventSharedSchema),\n]);\n\nconst chatEventOutputSharedSchema = z.extend(\n z.omit(z.strictObject(chatEventSharedSchema), { createdAt: true, messageId: true }),\n {\n createdAt: z.instanceof(Temporal.Instant),\n id: z.string(),\n },\n);\n\nconst chatEventOutputSchema = z.union([\n z.extend(chatEventOutputSharedSchema, {\n content: conversationUpdateChunkSchema,\n role: z.literal(\"agent\"),\n }),\n z.extend(chatEventOutputSharedSchema, { content: errorChunkV2Schema, role: z.literal(\"agent\") }),\n z.extend(chatEventOutputSharedSchema, {\n content: endOfStreamChunkSchema,\n role: z.literal(\"agent\"),\n }),\n z.extend(chatEventOutputSharedSchema, {\n content: interruptChunkSchema,\n role: z.literal(\"agent\"),\n }),\n z.extend(chatEventOutputSharedSchema, { content: modelChunkSchema, role: z.literal(\"agent\") }),\n z.extend(chatEventOutputSharedSchema, {\n content: toolRequestChunkSchema,\n role: z.literal(\"agent\"),\n }),\n z.extend(chatEventOutputSharedSchema, {\n content: toolResponseChunkSchema,\n role: z.literal(\"agent\"),\n }),\n z.extend(chatEventOutputSharedSchema, {\n content: userMessageChunkSchema,\n role: z.literal(\"user\"),\n }),\n]);\n\nexport const chatEventCodec = z.codec(chatEventInputSchema, chatEventOutputSchema, {\n decode(v) {\n const sharedProperties = {\n conversationId: v.conversationId,\n createdAt: Temporal.Instant.from(v.createdAt),\n id: v.messageId,\n modelName: v.modelName,\n modelProviderId: v.modelProviderId,\n runId: v.runId,\n } as const satisfies Omit<z.output<typeof chatEventOutputSchema>, \"content\" | \"role\">;\n\n switch (v.chunkType) {\n case \"conversationUpdate\":\n return {\n ...sharedProperties,\n content: {\n chunkType: \"conversationUpdate\",\n summary: v.summary,\n title: v.title,\n },\n role: \"agent\",\n } as const satisfies z.output<typeof chatEventOutputSchema>;\n case \"error\":\n return {\n ...sharedProperties,\n content: {\n chunkType: \"error\",\n message: v.message,\n type: v.type,\n },\n role: \"agent\",\n } as const satisfies z.output<typeof chatEventOutputSchema>;\n case \"endOfStream\":\n return {\n ...sharedProperties,\n content: {\n chunkType: \"endOfStream\",\n },\n role: \"agent\",\n } as const satisfies z.output<typeof chatEventOutputSchema>;\n case \"interrupt\":\n return {\n ...sharedProperties,\n content: {\n chunkType: \"interrupt\",\n },\n role: \"agent\",\n } as const satisfies z.output<typeof chatEventOutputSchema>;\n case \"model\":\n return {\n ...sharedProperties,\n content: {\n chunkType: \"model\",\n name: v.name,\n result: v.result,\n },\n role: \"agent\",\n } as const satisfies z.output<typeof chatEventOutputSchema>;\n case \"toolRequest\":\n return {\n ...sharedProperties,\n content: {\n arguments: v.arguments,\n callId: v.callId,\n chunkType: \"toolRequest\",\n commentary: v.commentary,\n name: v.name,\n summarizedTitle: v.summarizedTitle,\n },\n role: \"agent\",\n } as const satisfies z.output<typeof chatEventOutputSchema>;\n case \"toolResponse\":\n return {\n ...sharedProperties,\n content: {\n callId: v.callId,\n chunkType: \"toolResponse\",\n commentary: v.commentary,\n name: v.name,\n result: v.result,\n },\n role: \"agent\",\n } as const satisfies z.output<typeof chatEventOutputSchema>;\n case \"userMessage\":\n return {\n ...sharedProperties,\n content: { chunkType: \"userMessage\", text: v.text },\n role: \"user\",\n } as const satisfies z.output<typeof chatEventOutputSchema>;\n }\n },\n encode(v) {\n return {\n conversationId: v.conversationId,\n createdAt: v.createdAt.toString(),\n messageId: v.id,\n modelName: v.modelName,\n modelProviderId: v.modelProviderId,\n runId: v.runId,\n ...v.content,\n } as const satisfies z.infer<typeof chatEventInputSchema>;\n },\n});\n\nexport type ChatEvent = z.output<typeof chatEventCodec>;\nexport type ChatEventWithChunkType<T extends z.input<typeof chatEventCodec>[\"chunkType\"]> = Extract<\n ChatEvent,\n { content: { chunkType: T } }\n>;\n"]}
|
|
@@ -56,6 +56,7 @@ export declare class AgentConversation implements AgentConversationProperties {
|
|
|
56
56
|
content: {
|
|
57
57
|
chunkType: "error";
|
|
58
58
|
message: string;
|
|
59
|
+
type: string;
|
|
59
60
|
};
|
|
60
61
|
role: "agent";
|
|
61
62
|
} | {
|
|
@@ -69,6 +70,17 @@ export declare class AgentConversation implements AgentConversationProperties {
|
|
|
69
70
|
chunkType: "endOfStream";
|
|
70
71
|
};
|
|
71
72
|
role: "agent";
|
|
73
|
+
} | {
|
|
74
|
+
conversationId: string;
|
|
75
|
+
modelName: string;
|
|
76
|
+
modelProviderId: string;
|
|
77
|
+
runId: string;
|
|
78
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
79
|
+
id: string;
|
|
80
|
+
content: {
|
|
81
|
+
chunkType: "interrupt";
|
|
82
|
+
};
|
|
83
|
+
role: "agent";
|
|
72
84
|
} | {
|
|
73
85
|
conversationId: string;
|
|
74
86
|
modelName: string;
|
|
@@ -149,6 +161,7 @@ export declare class AgentConversation implements AgentConversationProperties {
|
|
|
149
161
|
content: {
|
|
150
162
|
chunkType: "error";
|
|
151
163
|
message: string;
|
|
164
|
+
type: string;
|
|
152
165
|
};
|
|
153
166
|
role: "agent";
|
|
154
167
|
} | {
|
|
@@ -162,6 +175,17 @@ export declare class AgentConversation implements AgentConversationProperties {
|
|
|
162
175
|
chunkType: "endOfStream";
|
|
163
176
|
};
|
|
164
177
|
role: "agent";
|
|
178
|
+
} | {
|
|
179
|
+
conversationId: string;
|
|
180
|
+
modelName: string;
|
|
181
|
+
modelProviderId: string;
|
|
182
|
+
runId: string;
|
|
183
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
184
|
+
id: string;
|
|
185
|
+
content: {
|
|
186
|
+
chunkType: "interrupt";
|
|
187
|
+
};
|
|
188
|
+
role: "agent";
|
|
165
189
|
} | {
|
|
166
190
|
conversationId: string;
|
|
167
191
|
modelName: string;
|
|
@@ -83,6 +83,7 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
83
83
|
content: {
|
|
84
84
|
chunkType: "error";
|
|
85
85
|
message: string;
|
|
86
|
+
type: string;
|
|
86
87
|
};
|
|
87
88
|
role: "agent";
|
|
88
89
|
} | {
|
|
@@ -96,6 +97,17 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
96
97
|
chunkType: "endOfStream";
|
|
97
98
|
};
|
|
98
99
|
role: "agent";
|
|
100
|
+
} | {
|
|
101
|
+
conversationId: string;
|
|
102
|
+
modelName: string;
|
|
103
|
+
modelProviderId: string;
|
|
104
|
+
runId: string;
|
|
105
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
106
|
+
id: string;
|
|
107
|
+
content: {
|
|
108
|
+
chunkType: "interrupt";
|
|
109
|
+
};
|
|
110
|
+
role: "agent";
|
|
99
111
|
} | {
|
|
100
112
|
conversationId: string;
|
|
101
113
|
modelName: string;
|
|
@@ -190,6 +202,7 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
190
202
|
content: {
|
|
191
203
|
chunkType: "error";
|
|
192
204
|
message: string;
|
|
205
|
+
type: string;
|
|
193
206
|
};
|
|
194
207
|
role: "agent";
|
|
195
208
|
} | {
|
|
@@ -203,6 +216,17 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
203
216
|
chunkType: "endOfStream";
|
|
204
217
|
};
|
|
205
218
|
role: "agent";
|
|
219
|
+
} | {
|
|
220
|
+
conversationId: string;
|
|
221
|
+
modelName: string;
|
|
222
|
+
modelProviderId: string;
|
|
223
|
+
runId: string;
|
|
224
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
225
|
+
id: string;
|
|
226
|
+
content: {
|
|
227
|
+
chunkType: "interrupt";
|
|
228
|
+
};
|
|
229
|
+
role: "agent";
|
|
206
230
|
} | {
|
|
207
231
|
conversationId: string;
|
|
208
232
|
modelName: string;
|
|
@@ -304,6 +328,7 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
304
328
|
content: {
|
|
305
329
|
chunkType: "error";
|
|
306
330
|
message: string;
|
|
331
|
+
type: string;
|
|
307
332
|
};
|
|
308
333
|
role: "agent";
|
|
309
334
|
} | {
|
|
@@ -317,6 +342,17 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
317
342
|
chunkType: "endOfStream";
|
|
318
343
|
};
|
|
319
344
|
role: "agent";
|
|
345
|
+
} | {
|
|
346
|
+
conversationId: string;
|
|
347
|
+
modelName: string;
|
|
348
|
+
modelProviderId: string;
|
|
349
|
+
runId: string;
|
|
350
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
351
|
+
id: string;
|
|
352
|
+
content: {
|
|
353
|
+
chunkType: "interrupt";
|
|
354
|
+
};
|
|
355
|
+
role: "agent";
|
|
320
356
|
} | {
|
|
321
357
|
conversationId: string;
|
|
322
358
|
modelName: string;
|
|
@@ -426,6 +462,7 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
426
462
|
content: {
|
|
427
463
|
chunkType: "error";
|
|
428
464
|
message: string;
|
|
465
|
+
type: string;
|
|
429
466
|
};
|
|
430
467
|
role: "agent";
|
|
431
468
|
} | {
|
|
@@ -439,6 +476,17 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
439
476
|
chunkType: "endOfStream";
|
|
440
477
|
};
|
|
441
478
|
role: "agent";
|
|
479
|
+
} | {
|
|
480
|
+
conversationId: string;
|
|
481
|
+
modelName: string;
|
|
482
|
+
modelProviderId: string;
|
|
483
|
+
runId: string;
|
|
484
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
485
|
+
id: string;
|
|
486
|
+
content: {
|
|
487
|
+
chunkType: "interrupt";
|
|
488
|
+
};
|
|
489
|
+
role: "agent";
|
|
442
490
|
} | {
|
|
443
491
|
conversationId: string;
|
|
444
492
|
modelName: string;
|
|
@@ -537,6 +585,7 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
537
585
|
content: {
|
|
538
586
|
chunkType: "error";
|
|
539
587
|
message: string;
|
|
588
|
+
type: string;
|
|
540
589
|
};
|
|
541
590
|
role: "agent";
|
|
542
591
|
} | {
|
|
@@ -550,6 +599,17 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
550
599
|
chunkType: "endOfStream";
|
|
551
600
|
};
|
|
552
601
|
role: "agent";
|
|
602
|
+
} | {
|
|
603
|
+
conversationId: string;
|
|
604
|
+
modelName: string;
|
|
605
|
+
modelProviderId: string;
|
|
606
|
+
runId: string;
|
|
607
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
608
|
+
id: string;
|
|
609
|
+
content: {
|
|
610
|
+
chunkType: "interrupt";
|
|
611
|
+
};
|
|
612
|
+
role: "agent";
|
|
553
613
|
} | {
|
|
554
614
|
conversationId: string;
|
|
555
615
|
modelName: string;
|
|
@@ -663,6 +723,7 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
663
723
|
content: {
|
|
664
724
|
chunkType: "error";
|
|
665
725
|
message: string;
|
|
726
|
+
type: string;
|
|
666
727
|
};
|
|
667
728
|
role: "agent";
|
|
668
729
|
} | {
|
|
@@ -676,6 +737,17 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
676
737
|
chunkType: "endOfStream";
|
|
677
738
|
};
|
|
678
739
|
role: "agent";
|
|
740
|
+
} | {
|
|
741
|
+
conversationId: string;
|
|
742
|
+
modelName: string;
|
|
743
|
+
modelProviderId: string;
|
|
744
|
+
runId: string;
|
|
745
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
746
|
+
id: string;
|
|
747
|
+
content: {
|
|
748
|
+
chunkType: "interrupt";
|
|
749
|
+
};
|
|
750
|
+
role: "agent";
|
|
679
751
|
} | {
|
|
680
752
|
conversationId: string;
|
|
681
753
|
modelName: string;
|
|
@@ -24,6 +24,7 @@ export declare const retrieveConversationHistory: (config: SonarV4Config) => (id
|
|
|
24
24
|
content: {
|
|
25
25
|
chunkType: "error";
|
|
26
26
|
message: string;
|
|
27
|
+
type: string;
|
|
27
28
|
};
|
|
28
29
|
role: "agent";
|
|
29
30
|
} | {
|
|
@@ -37,6 +38,17 @@ export declare const retrieveConversationHistory: (config: SonarV4Config) => (id
|
|
|
37
38
|
chunkType: "endOfStream";
|
|
38
39
|
};
|
|
39
40
|
role: "agent";
|
|
41
|
+
} | {
|
|
42
|
+
conversationId: string;
|
|
43
|
+
modelName: string;
|
|
44
|
+
modelProviderId: string;
|
|
45
|
+
runId: string;
|
|
46
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
47
|
+
id: string;
|
|
48
|
+
content: {
|
|
49
|
+
chunkType: "interrupt";
|
|
50
|
+
};
|
|
51
|
+
role: "agent";
|
|
40
52
|
} | {
|
|
41
53
|
conversationId: string;
|
|
42
54
|
modelName: string;
|
package/dist-iife/cloud.js
CHANGED
|
@@ -23885,6 +23885,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
23885
23885
|
*/
|
|
23886
23886
|
message: string2().check(_trim(), _minLength(2))
|
|
23887
23887
|
});
|
|
23888
|
+
var errorChunkV2Schema = object({
|
|
23889
|
+
chunkType: literal("error"),
|
|
23890
|
+
message: string2().check(_trim(), _minLength(2)),
|
|
23891
|
+
type: string2()
|
|
23892
|
+
});
|
|
23888
23893
|
var conversationUpdateChunkSchema = object({
|
|
23889
23894
|
chunkType: literal("conversationUpdate"),
|
|
23890
23895
|
summary: optional(string2()),
|
|
@@ -23893,6 +23898,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
23893
23898
|
var endOfStreamChunkSchema = object({
|
|
23894
23899
|
chunkType: literal("endOfStream")
|
|
23895
23900
|
});
|
|
23901
|
+
var interruptChunkSchema = object({
|
|
23902
|
+
chunkType: literal("interrupt")
|
|
23903
|
+
});
|
|
23896
23904
|
var modelChunkSchema = object({
|
|
23897
23905
|
chunkType: literal("model"),
|
|
23898
23906
|
name: string2().check(_trim(), _minLength(1)),
|
|
@@ -23930,8 +23938,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
23930
23938
|
extend2(toolResponseChunkSchema, chatEventV1SharedSchema)
|
|
23931
23939
|
]);
|
|
23932
23940
|
var chatEventInputSchema = discriminatedUnion("chunkType", [
|
|
23933
|
-
|
|
23941
|
+
extend2(errorChunkV2Schema, chatEventSharedSchema),
|
|
23934
23942
|
extend2(endOfStreamChunkSchema, chatEventSharedSchema),
|
|
23943
|
+
extend2(interruptChunkSchema, chatEventSharedSchema),
|
|
23935
23944
|
extend2(conversationUpdateChunkSchema, chatEventSharedSchema),
|
|
23936
23945
|
extend2(modelChunkSchema, chatEventSharedSchema),
|
|
23937
23946
|
extend2(toolRequestChunkSchema, chatEventSharedSchema),
|
|
@@ -23947,11 +23956,15 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
23947
23956
|
content: conversationUpdateChunkSchema,
|
|
23948
23957
|
role: literal("agent")
|
|
23949
23958
|
}),
|
|
23950
|
-
extend2(chatEventOutputSharedSchema, { content:
|
|
23959
|
+
extend2(chatEventOutputSharedSchema, { content: errorChunkV2Schema, role: literal("agent") }),
|
|
23951
23960
|
extend2(chatEventOutputSharedSchema, {
|
|
23952
23961
|
content: endOfStreamChunkSchema,
|
|
23953
23962
|
role: literal("agent")
|
|
23954
23963
|
}),
|
|
23964
|
+
extend2(chatEventOutputSharedSchema, {
|
|
23965
|
+
content: interruptChunkSchema,
|
|
23966
|
+
role: literal("agent")
|
|
23967
|
+
}),
|
|
23955
23968
|
extend2(chatEventOutputSharedSchema, { content: modelChunkSchema, role: literal("agent") }),
|
|
23956
23969
|
extend2(chatEventOutputSharedSchema, {
|
|
23957
23970
|
content: toolRequestChunkSchema,
|
|
@@ -23968,21 +23981,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
23968
23981
|
]);
|
|
23969
23982
|
var chatEventCodec = codec(chatEventInputSchema, chatEventOutputSchema, {
|
|
23970
23983
|
decode(v2) {
|
|
23971
|
-
if (v2.chunkType === "error") {
|
|
23972
|
-
return {
|
|
23973
|
-
content: {
|
|
23974
|
-
chunkType: "error",
|
|
23975
|
-
message: v2.message
|
|
23976
|
-
},
|
|
23977
|
-
conversationId: "",
|
|
23978
|
-
createdAt: Xn.Now.instant(),
|
|
23979
|
-
id: "",
|
|
23980
|
-
modelName: "",
|
|
23981
|
-
modelProviderId: "",
|
|
23982
|
-
role: "agent",
|
|
23983
|
-
runId: ""
|
|
23984
|
-
};
|
|
23985
|
-
}
|
|
23986
23984
|
const sharedProperties = {
|
|
23987
23985
|
conversationId: v2.conversationId,
|
|
23988
23986
|
createdAt: Xn.Instant.from(v2.createdAt),
|
|
@@ -24002,6 +24000,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
24002
24000
|
},
|
|
24003
24001
|
role: "agent"
|
|
24004
24002
|
};
|
|
24003
|
+
case "error":
|
|
24004
|
+
return {
|
|
24005
|
+
...sharedProperties,
|
|
24006
|
+
content: {
|
|
24007
|
+
chunkType: "error",
|
|
24008
|
+
message: v2.message,
|
|
24009
|
+
type: v2.type
|
|
24010
|
+
},
|
|
24011
|
+
role: "agent"
|
|
24012
|
+
};
|
|
24005
24013
|
case "endOfStream":
|
|
24006
24014
|
return {
|
|
24007
24015
|
...sharedProperties,
|
|
@@ -24010,6 +24018,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
24010
24018
|
},
|
|
24011
24019
|
role: "agent"
|
|
24012
24020
|
};
|
|
24021
|
+
case "interrupt":
|
|
24022
|
+
return {
|
|
24023
|
+
...sharedProperties,
|
|
24024
|
+
content: {
|
|
24025
|
+
chunkType: "interrupt"
|
|
24026
|
+
},
|
|
24027
|
+
role: "agent"
|
|
24028
|
+
};
|
|
24013
24029
|
case "model":
|
|
24014
24030
|
return {
|
|
24015
24031
|
...sharedProperties,
|
|
@@ -24055,7 +24071,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
24055
24071
|
},
|
|
24056
24072
|
encode(v2) {
|
|
24057
24073
|
return {
|
|
24058
|
-
//@ts-ignore
|
|
24059
24074
|
conversationId: v2.conversationId,
|
|
24060
24075
|
createdAt: v2.createdAt.toString(),
|
|
24061
24076
|
messageId: v2.id,
|
package/dist-iife/enterprise.js
CHANGED
|
@@ -24940,6 +24940,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
24940
24940
|
*/
|
|
24941
24941
|
message: string2().check(_trim(), _minLength(2))
|
|
24942
24942
|
});
|
|
24943
|
+
var errorChunkV2Schema = object({
|
|
24944
|
+
chunkType: literal("error"),
|
|
24945
|
+
message: string2().check(_trim(), _minLength(2)),
|
|
24946
|
+
type: string2()
|
|
24947
|
+
});
|
|
24943
24948
|
var conversationUpdateChunkSchema = object({
|
|
24944
24949
|
chunkType: literal("conversationUpdate"),
|
|
24945
24950
|
summary: optional(string2()),
|
|
@@ -24948,6 +24953,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
24948
24953
|
var endOfStreamChunkSchema = object({
|
|
24949
24954
|
chunkType: literal("endOfStream")
|
|
24950
24955
|
});
|
|
24956
|
+
var interruptChunkSchema = object({
|
|
24957
|
+
chunkType: literal("interrupt")
|
|
24958
|
+
});
|
|
24951
24959
|
var modelChunkSchema = object({
|
|
24952
24960
|
chunkType: literal("model"),
|
|
24953
24961
|
name: string2().check(_trim(), _minLength(1)),
|
|
@@ -24985,8 +24993,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
24985
24993
|
extend2(toolResponseChunkSchema, chatEventV1SharedSchema)
|
|
24986
24994
|
]);
|
|
24987
24995
|
var chatEventInputSchema = discriminatedUnion("chunkType", [
|
|
24988
|
-
|
|
24996
|
+
extend2(errorChunkV2Schema, chatEventSharedSchema),
|
|
24989
24997
|
extend2(endOfStreamChunkSchema, chatEventSharedSchema),
|
|
24998
|
+
extend2(interruptChunkSchema, chatEventSharedSchema),
|
|
24990
24999
|
extend2(conversationUpdateChunkSchema, chatEventSharedSchema),
|
|
24991
25000
|
extend2(modelChunkSchema, chatEventSharedSchema),
|
|
24992
25001
|
extend2(toolRequestChunkSchema, chatEventSharedSchema),
|
|
@@ -25002,11 +25011,15 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
25002
25011
|
content: conversationUpdateChunkSchema,
|
|
25003
25012
|
role: literal("agent")
|
|
25004
25013
|
}),
|
|
25005
|
-
extend2(chatEventOutputSharedSchema, { content:
|
|
25014
|
+
extend2(chatEventOutputSharedSchema, { content: errorChunkV2Schema, role: literal("agent") }),
|
|
25006
25015
|
extend2(chatEventOutputSharedSchema, {
|
|
25007
25016
|
content: endOfStreamChunkSchema,
|
|
25008
25017
|
role: literal("agent")
|
|
25009
25018
|
}),
|
|
25019
|
+
extend2(chatEventOutputSharedSchema, {
|
|
25020
|
+
content: interruptChunkSchema,
|
|
25021
|
+
role: literal("agent")
|
|
25022
|
+
}),
|
|
25010
25023
|
extend2(chatEventOutputSharedSchema, { content: modelChunkSchema, role: literal("agent") }),
|
|
25011
25024
|
extend2(chatEventOutputSharedSchema, {
|
|
25012
25025
|
content: toolRequestChunkSchema,
|
|
@@ -25023,21 +25036,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
25023
25036
|
]);
|
|
25024
25037
|
var chatEventCodec = codec(chatEventInputSchema, chatEventOutputSchema, {
|
|
25025
25038
|
decode(v2) {
|
|
25026
|
-
if (v2.chunkType === "error") {
|
|
25027
|
-
return {
|
|
25028
|
-
content: {
|
|
25029
|
-
chunkType: "error",
|
|
25030
|
-
message: v2.message
|
|
25031
|
-
},
|
|
25032
|
-
conversationId: "",
|
|
25033
|
-
createdAt: Xn.Now.instant(),
|
|
25034
|
-
id: "",
|
|
25035
|
-
modelName: "",
|
|
25036
|
-
modelProviderId: "",
|
|
25037
|
-
role: "agent",
|
|
25038
|
-
runId: ""
|
|
25039
|
-
};
|
|
25040
|
-
}
|
|
25041
25039
|
const sharedProperties = {
|
|
25042
25040
|
conversationId: v2.conversationId,
|
|
25043
25041
|
createdAt: Xn.Instant.from(v2.createdAt),
|
|
@@ -25057,6 +25055,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
25057
25055
|
},
|
|
25058
25056
|
role: "agent"
|
|
25059
25057
|
};
|
|
25058
|
+
case "error":
|
|
25059
|
+
return {
|
|
25060
|
+
...sharedProperties,
|
|
25061
|
+
content: {
|
|
25062
|
+
chunkType: "error",
|
|
25063
|
+
message: v2.message,
|
|
25064
|
+
type: v2.type
|
|
25065
|
+
},
|
|
25066
|
+
role: "agent"
|
|
25067
|
+
};
|
|
25060
25068
|
case "endOfStream":
|
|
25061
25069
|
return {
|
|
25062
25070
|
...sharedProperties,
|
|
@@ -25065,6 +25073,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
25065
25073
|
},
|
|
25066
25074
|
role: "agent"
|
|
25067
25075
|
};
|
|
25076
|
+
case "interrupt":
|
|
25077
|
+
return {
|
|
25078
|
+
...sharedProperties,
|
|
25079
|
+
content: {
|
|
25080
|
+
chunkType: "interrupt"
|
|
25081
|
+
},
|
|
25082
|
+
role: "agent"
|
|
25083
|
+
};
|
|
25068
25084
|
case "model":
|
|
25069
25085
|
return {
|
|
25070
25086
|
...sharedProperties,
|
|
@@ -25110,7 +25126,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
25110
25126
|
},
|
|
25111
25127
|
encode(v2) {
|
|
25112
25128
|
return {
|
|
25113
|
-
//@ts-ignore
|
|
25114
25129
|
conversationId: v2.conversationId,
|
|
25115
25130
|
createdAt: v2.createdAt.toString(),
|
|
25116
25131
|
messageId: v2.id,
|