@dremio/js-sdk 0.56.0 → 0.57.1

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.
@@ -186,6 +186,19 @@ export declare class AIResource {
186
186
  result: Record<string, unknown>;
187
187
  };
188
188
  role: "agent";
189
+ } | {
190
+ conversationId: string;
191
+ modelName: string;
192
+ modelProviderId: string;
193
+ runId: string;
194
+ createdAt: import("temporal-polyfill").Temporal.Instant;
195
+ id: string;
196
+ content: {
197
+ chunkType: "sandboxProgress";
198
+ stepName: string;
199
+ text: string;
200
+ };
201
+ role: "agent";
189
202
  } | {
190
203
  conversationId: string;
191
204
  modelName: string;
@@ -199,7 +212,9 @@ export declare class AIResource {
199
212
  chunkType: "toolRequest";
200
213
  name: string;
201
214
  commentary?: string | undefined;
215
+ replacePlan?: Record<string, unknown> | undefined;
202
216
  summarizedTitle?: string | undefined;
217
+ updatePlan?: Record<string, unknown> | undefined;
203
218
  };
204
219
  role: "agent";
205
220
  } | {
@@ -320,6 +335,19 @@ export declare class AIResource {
320
335
  result: Record<string, unknown>;
321
336
  };
322
337
  role: "agent";
338
+ } | {
339
+ conversationId: string;
340
+ modelName: string;
341
+ modelProviderId: string;
342
+ runId: string;
343
+ createdAt: import("temporal-polyfill").Temporal.Instant;
344
+ id: string;
345
+ content: {
346
+ chunkType: "sandboxProgress";
347
+ stepName: string;
348
+ text: string;
349
+ };
350
+ role: "agent";
323
351
  } | {
324
352
  conversationId: string;
325
353
  modelName: string;
@@ -333,7 +361,9 @@ export declare class AIResource {
333
361
  chunkType: "toolRequest";
334
362
  name: string;
335
363
  commentary?: string | undefined;
364
+ replacePlan?: Record<string, unknown> | undefined;
336
365
  summarizedTitle?: string | undefined;
366
+ updatePlan?: Record<string, unknown> | undefined;
337
367
  };
338
368
  role: "agent";
339
369
  } | {
@@ -461,6 +491,19 @@ export declare class AIResource {
461
491
  result: Record<string, unknown>;
462
492
  };
463
493
  role: "agent";
494
+ } | {
495
+ conversationId: string;
496
+ modelName: string;
497
+ modelProviderId: string;
498
+ runId: string;
499
+ createdAt: import("temporal-polyfill").Temporal.Instant;
500
+ id: string;
501
+ content: {
502
+ chunkType: "sandboxProgress";
503
+ stepName: string;
504
+ text: string;
505
+ };
506
+ role: "agent";
464
507
  } | {
465
508
  conversationId: string;
466
509
  modelName: string;
@@ -474,7 +517,9 @@ export declare class AIResource {
474
517
  chunkType: "toolRequest";
475
518
  name: string;
476
519
  commentary?: string | undefined;
520
+ replacePlan?: Record<string, unknown> | undefined;
477
521
  summarizedTitle?: string | undefined;
522
+ updatePlan?: Record<string, unknown> | undefined;
478
523
  };
479
524
  role: "agent";
480
525
  } | {
@@ -619,6 +664,19 @@ export declare class AIResource {
619
664
  result: Record<string, unknown>;
620
665
  };
621
666
  role: "agent";
667
+ } | {
668
+ conversationId: string;
669
+ modelName: string;
670
+ modelProviderId: string;
671
+ runId: string;
672
+ createdAt: import("temporal-polyfill").Temporal.Instant;
673
+ id: string;
674
+ content: {
675
+ chunkType: "sandboxProgress";
676
+ stepName: string;
677
+ text: string;
678
+ };
679
+ role: "agent";
622
680
  } | {
623
681
  conversationId: string;
624
682
  modelName: string;
@@ -632,7 +690,9 @@ export declare class AIResource {
632
690
  chunkType: "toolRequest";
633
691
  name: string;
634
692
  commentary?: string | undefined;
693
+ replacePlan?: Record<string, unknown> | undefined;
635
694
  summarizedTitle?: string | undefined;
695
+ updatePlan?: Record<string, unknown> | undefined;
636
696
  };
637
697
  role: "agent";
638
698
  } | {
@@ -757,6 +817,19 @@ export declare class AIResource {
757
817
  result: Record<string, unknown>;
758
818
  };
759
819
  role: "agent";
820
+ } | {
821
+ conversationId: string;
822
+ modelName: string;
823
+ modelProviderId: string;
824
+ runId: string;
825
+ createdAt: import("temporal-polyfill").Temporal.Instant;
826
+ id: string;
827
+ content: {
828
+ chunkType: "sandboxProgress";
829
+ stepName: string;
830
+ text: string;
831
+ };
832
+ role: "agent";
760
833
  } | {
761
834
  conversationId: string;
762
835
  modelName: string;
@@ -770,7 +843,9 @@ export declare class AIResource {
770
843
  chunkType: "toolRequest";
771
844
  name: string;
772
845
  commentary?: string | undefined;
846
+ replacePlan?: Record<string, unknown> | undefined;
773
847
  summarizedTitle?: string | undefined;
848
+ updatePlan?: Record<string, unknown> | undefined;
774
849
  };
775
850
  role: "agent";
776
851
  } | {
@@ -910,6 +985,19 @@ export declare class AIResource {
910
985
  result: Record<string, unknown>;
911
986
  };
912
987
  role: "agent";
988
+ } | {
989
+ conversationId: string;
990
+ modelName: string;
991
+ modelProviderId: string;
992
+ runId: string;
993
+ createdAt: import("temporal-polyfill").Temporal.Instant;
994
+ id: string;
995
+ content: {
996
+ chunkType: "sandboxProgress";
997
+ stepName: string;
998
+ text: string;
999
+ };
1000
+ role: "agent";
913
1001
  } | {
914
1002
  conversationId: string;
915
1003
  modelName: string;
@@ -923,7 +1011,9 @@ export declare class AIResource {
923
1011
  chunkType: "toolRequest";
924
1012
  name: string;
925
1013
  commentary?: string | undefined;
1014
+ replacePlan?: Record<string, unknown> | undefined;
926
1015
  summarizedTitle?: string | undefined;
1016
+ updatePlan?: Record<string, unknown> | undefined;
927
1017
  };
928
1018
  role: "agent";
929
1019
  } | {
@@ -128,6 +128,19 @@ export declare class AIResource {
128
128
  result: Record<string, unknown>;
129
129
  };
130
130
  role: "agent";
131
+ } | {
132
+ conversationId: string;
133
+ modelName: string;
134
+ modelProviderId: string;
135
+ runId: string;
136
+ createdAt: import("temporal-polyfill").Temporal.Instant;
137
+ id: string;
138
+ content: {
139
+ chunkType: "sandboxProgress";
140
+ stepName: string;
141
+ text: string;
142
+ };
143
+ role: "agent";
131
144
  } | {
132
145
  conversationId: string;
133
146
  modelName: string;
@@ -141,7 +154,9 @@ export declare class AIResource {
141
154
  chunkType: "toolRequest";
142
155
  name: string;
143
156
  commentary?: string | undefined;
157
+ replacePlan?: Record<string, unknown> | undefined;
144
158
  summarizedTitle?: string | undefined;
159
+ updatePlan?: Record<string, unknown> | undefined;
145
160
  };
146
161
  role: "agent";
147
162
  } | {
@@ -262,6 +277,19 @@ export declare class AIResource {
262
277
  result: Record<string, unknown>;
263
278
  };
264
279
  role: "agent";
280
+ } | {
281
+ conversationId: string;
282
+ modelName: string;
283
+ modelProviderId: string;
284
+ runId: string;
285
+ createdAt: import("temporal-polyfill").Temporal.Instant;
286
+ id: string;
287
+ content: {
288
+ chunkType: "sandboxProgress";
289
+ stepName: string;
290
+ text: string;
291
+ };
292
+ role: "agent";
265
293
  } | {
266
294
  conversationId: string;
267
295
  modelName: string;
@@ -275,7 +303,9 @@ export declare class AIResource {
275
303
  chunkType: "toolRequest";
276
304
  name: string;
277
305
  commentary?: string | undefined;
306
+ replacePlan?: Record<string, unknown> | undefined;
278
307
  summarizedTitle?: string | undefined;
308
+ updatePlan?: Record<string, unknown> | undefined;
279
309
  };
280
310
  role: "agent";
281
311
  } | {
@@ -403,6 +433,19 @@ export declare class AIResource {
403
433
  result: Record<string, unknown>;
404
434
  };
405
435
  role: "agent";
436
+ } | {
437
+ conversationId: string;
438
+ modelName: string;
439
+ modelProviderId: string;
440
+ runId: string;
441
+ createdAt: import("temporal-polyfill").Temporal.Instant;
442
+ id: string;
443
+ content: {
444
+ chunkType: "sandboxProgress";
445
+ stepName: string;
446
+ text: string;
447
+ };
448
+ role: "agent";
406
449
  } | {
407
450
  conversationId: string;
408
451
  modelName: string;
@@ -416,7 +459,9 @@ export declare class AIResource {
416
459
  chunkType: "toolRequest";
417
460
  name: string;
418
461
  commentary?: string | undefined;
462
+ replacePlan?: Record<string, unknown> | undefined;
419
463
  summarizedTitle?: string | undefined;
464
+ updatePlan?: Record<string, unknown> | undefined;
420
465
  };
421
466
  role: "agent";
422
467
  } | {
@@ -561,6 +606,19 @@ export declare class AIResource {
561
606
  result: Record<string, unknown>;
562
607
  };
563
608
  role: "agent";
609
+ } | {
610
+ conversationId: string;
611
+ modelName: string;
612
+ modelProviderId: string;
613
+ runId: string;
614
+ createdAt: import("temporal-polyfill").Temporal.Instant;
615
+ id: string;
616
+ content: {
617
+ chunkType: "sandboxProgress";
618
+ stepName: string;
619
+ text: string;
620
+ };
621
+ role: "agent";
564
622
  } | {
565
623
  conversationId: string;
566
624
  modelName: string;
@@ -574,7 +632,9 @@ export declare class AIResource {
574
632
  chunkType: "toolRequest";
575
633
  name: string;
576
634
  commentary?: string | undefined;
635
+ replacePlan?: Record<string, unknown> | undefined;
577
636
  summarizedTitle?: string | undefined;
637
+ updatePlan?: Record<string, unknown> | undefined;
578
638
  };
579
639
  role: "agent";
580
640
  } | {
@@ -699,6 +759,19 @@ export declare class AIResource {
699
759
  result: Record<string, unknown>;
700
760
  };
701
761
  role: "agent";
762
+ } | {
763
+ conversationId: string;
764
+ modelName: string;
765
+ modelProviderId: string;
766
+ runId: string;
767
+ createdAt: import("temporal-polyfill").Temporal.Instant;
768
+ id: string;
769
+ content: {
770
+ chunkType: "sandboxProgress";
771
+ stepName: string;
772
+ text: string;
773
+ };
774
+ role: "agent";
702
775
  } | {
703
776
  conversationId: string;
704
777
  modelName: string;
@@ -712,7 +785,9 @@ export declare class AIResource {
712
785
  chunkType: "toolRequest";
713
786
  name: string;
714
787
  commentary?: string | undefined;
788
+ replacePlan?: Record<string, unknown> | undefined;
715
789
  summarizedTitle?: string | undefined;
790
+ updatePlan?: Record<string, unknown> | undefined;
716
791
  };
717
792
  role: "agent";
718
793
  } | {
@@ -852,6 +927,19 @@ export declare class AIResource {
852
927
  result: Record<string, unknown>;
853
928
  };
854
929
  role: "agent";
930
+ } | {
931
+ conversationId: string;
932
+ modelName: string;
933
+ modelProviderId: string;
934
+ runId: string;
935
+ createdAt: import("temporal-polyfill").Temporal.Instant;
936
+ id: string;
937
+ content: {
938
+ chunkType: "sandboxProgress";
939
+ stepName: string;
940
+ text: string;
941
+ };
942
+ role: "agent";
855
943
  } | {
856
944
  conversationId: string;
857
945
  modelName: string;
@@ -865,7 +953,9 @@ export declare class AIResource {
865
953
  chunkType: "toolRequest";
866
954
  name: string;
867
955
  commentary?: string | undefined;
956
+ replacePlan?: Record<string, unknown> | undefined;
868
957
  summarizedTitle?: string | undefined;
958
+ updatePlan?: Record<string, unknown> | undefined;
869
959
  };
870
960
  role: "agent";
871
961
  } | {
@@ -30,7 +30,9 @@ export declare const chatEventV1Schema: z.ZodMiniDiscriminatedUnion<[z.ZodMiniOb
30
30
  chunkType: z.ZodMiniLiteral<"toolRequest">;
31
31
  commentary: z.ZodMiniOptional<z.ZodMiniString<string>>;
32
32
  name: z.ZodMiniString<string>;
33
+ replacePlan: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>>;
33
34
  summarizedTitle: z.ZodMiniOptional<z.ZodMiniString<string>>;
35
+ updatePlan: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>>;
34
36
  createdAt: z.ZodMiniString<string>;
35
37
  modelName: z.ZodMiniString<string>;
36
38
  modelProviderId: z.ZodMiniString<string>;
@@ -108,13 +110,25 @@ export declare const chatEventCodec: z.ZodMiniCodec<z.ZodMiniDiscriminatedUnion<
108
110
  modelName: z.ZodMiniString<string>;
109
111
  modelProviderId: z.ZodMiniString<string>;
110
112
  runId: z.ZodMiniString<string>;
113
+ }, z.core.$strip>, z.ZodMiniObject<{
114
+ chunkType: z.ZodMiniLiteral<"sandboxProgress">;
115
+ stepName: z.ZodMiniString<string>;
116
+ text: z.ZodMiniString<string>;
117
+ conversationId: z.ZodMiniString<string>;
118
+ createdAt: z.ZodMiniString<string>;
119
+ messageId: z.ZodMiniString<string>;
120
+ modelName: z.ZodMiniString<string>;
121
+ modelProviderId: z.ZodMiniString<string>;
122
+ runId: z.ZodMiniString<string>;
111
123
  }, z.core.$strip>, z.ZodMiniObject<{
112
124
  arguments: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>;
113
125
  callId: z.ZodMiniString<string>;
114
126
  chunkType: z.ZodMiniLiteral<"toolRequest">;
115
127
  commentary: z.ZodMiniOptional<z.ZodMiniString<string>>;
116
128
  name: z.ZodMiniString<string>;
129
+ replacePlan: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>>;
117
130
  summarizedTitle: z.ZodMiniOptional<z.ZodMiniString<string>>;
131
+ updatePlan: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>>;
118
132
  conversationId: z.ZodMiniString<string>;
119
133
  createdAt: z.ZodMiniString<string>;
120
134
  messageId: z.ZodMiniString<string>;
@@ -224,6 +238,19 @@ export declare const chatEventCodec: z.ZodMiniCodec<z.ZodMiniDiscriminatedUnion<
224
238
  result: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>;
225
239
  }, z.core.$strip>;
226
240
  role: z.ZodMiniLiteral<"agent">;
241
+ }, z.core.$strict>, z.ZodMiniObject<{
242
+ conversationId: z.ZodMiniString<string>;
243
+ modelName: z.ZodMiniString<string>;
244
+ modelProviderId: z.ZodMiniString<string>;
245
+ runId: z.ZodMiniString<string>;
246
+ createdAt: z.ZodMiniCustom<Temporal.Instant, Temporal.Instant>;
247
+ id: z.ZodMiniString<string>;
248
+ content: z.ZodMiniObject<{
249
+ chunkType: z.ZodMiniLiteral<"sandboxProgress">;
250
+ stepName: z.ZodMiniString<string>;
251
+ text: z.ZodMiniString<string>;
252
+ }, z.core.$strip>;
253
+ role: z.ZodMiniLiteral<"agent">;
227
254
  }, z.core.$strict>, z.ZodMiniObject<{
228
255
  conversationId: z.ZodMiniString<string>;
229
256
  modelName: z.ZodMiniString<string>;
@@ -237,7 +264,9 @@ export declare const chatEventCodec: z.ZodMiniCodec<z.ZodMiniDiscriminatedUnion<
237
264
  chunkType: z.ZodMiniLiteral<"toolRequest">;
238
265
  commentary: z.ZodMiniOptional<z.ZodMiniString<string>>;
239
266
  name: z.ZodMiniString<string>;
267
+ replacePlan: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>>;
240
268
  summarizedTitle: z.ZodMiniOptional<z.ZodMiniString<string>>;
269
+ updatePlan: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>>;
241
270
  }, z.core.$strip>;
242
271
  role: z.ZodMiniLiteral<"agent">;
243
272
  }, z.core.$strict>, z.ZodMiniObject<{
@@ -71,13 +71,21 @@ const modelChunkSchema = z.object({
71
71
  */
72
72
  result: z.record(z.string(), z.unknown()),
73
73
  });
74
+ const sandboxProgressChunkSchema = z.object({
75
+ chunkType: z.literal("sandboxProgress"),
76
+ stepName: z.string(),
77
+ text: z.string(),
78
+ });
79
+ const toolPlanSchema = z.record(z.string(), z.unknown());
74
80
  const toolRequestChunkSchema = z.object({
75
81
  arguments: z.record(z.string(), z.unknown()),
76
82
  callId: z.string().check(z.trim(), z.minLength(1)),
77
83
  chunkType: z.literal("toolRequest"),
78
84
  commentary: z.optional(z.string()),
79
85
  name: z.string(),
86
+ replacePlan: z.optional(toolPlanSchema),
80
87
  summarizedTitle: z.optional(z.string()),
88
+ updatePlan: z.optional(toolPlanSchema),
81
89
  });
82
90
  const toolResponseChunkSchema = z.object({
83
91
  callId: z.string(),
@@ -119,6 +127,7 @@ const chatEventInputSchema = z.discriminatedUnion("chunkType", [
119
127
  z.extend(conversationUpdateChunkSchema, chatEventSharedSchema),
120
128
  z.extend(jobUpdateChunkSchema, chatEventSharedSchema),
121
129
  z.extend(modelChunkSchema, chatEventSharedSchema),
130
+ z.extend(sandboxProgressChunkSchema, chatEventSharedSchema),
122
131
  z.extend(toolRequestChunkSchema, chatEventSharedSchema),
123
132
  z.extend(toolResponseChunkSchema, chatEventSharedSchema),
124
133
  z.extend(userMessageChunkSchema, chatEventSharedSchema),
@@ -146,6 +155,10 @@ const chatEventOutputSchema = z.union([
146
155
  role: z.literal("agent"),
147
156
  }),
148
157
  z.extend(chatEventOutputSharedSchema, { content: modelChunkSchema, role: z.literal("agent") }),
158
+ z.extend(chatEventOutputSharedSchema, {
159
+ content: sandboxProgressChunkSchema,
160
+ role: z.literal("agent"),
161
+ }),
149
162
  z.extend(chatEventOutputSharedSchema, {
150
163
  content: toolRequestChunkSchema,
151
164
  role: z.literal("agent"),
@@ -228,6 +241,16 @@ export const chatEventCodec = z.codec(chatEventInputSchema, chatEventOutputSchem
228
241
  },
229
242
  role: "agent",
230
243
  };
244
+ case "sandboxProgress":
245
+ return {
246
+ ...sharedProperties,
247
+ content: {
248
+ chunkType: "sandboxProgress",
249
+ stepName: v.stepName,
250
+ text: v.text,
251
+ },
252
+ role: "agent",
253
+ };
231
254
  case "toolRequest":
232
255
  return {
233
256
  ...sharedProperties,
@@ -237,7 +260,9 @@ export const chatEventCodec = z.codec(chatEventInputSchema, chatEventOutputSchem
237
260
  chunkType: "toolRequest",
238
261
  commentary: v.commentary,
239
262
  name: v.name,
263
+ replacePlan: v.replacePlan,
240
264
  summarizedTitle: v.summarizedTitle,
265
+ updatePlan: v.updatePlan,
241
266
  },
242
267
  role: "agent",
243
268
  };
@@ -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,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CA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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 jobUpdateChunkSchema = z.object({\n chunkType: z.literal(\"jobUpdate\"),\n jobId: z.string(),\n jobState: z.string(),\n toolExecutionId: z.string(),\n toolName: z.string(),\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(jobUpdateChunkSchema, 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, {\n content: jobUpdateChunkSchema,\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 \"jobUpdate\":\n return {\n ...sharedProperties,\n content: {\n chunkType: \"jobUpdate\",\n jobId: v.jobId,\n jobState: v.jobState,\n toolExecutionId: v.toolExecutionId,\n toolName: v.toolName,\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"]}
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,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAC3D,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;CACtD,CAAC;AAEF;;GAEG;AACH,MAAM,qBAAqB,GAAG;IAC5B,cAAc,EAAE,CAAC,CAAC,MAAM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AC;YAC9D,KAAK,cAAc;gBACjB,OAAO;oBACL,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 sandboxProgressChunkSchema = z.object({\n chunkType: z.literal(\"sandboxProgress\"),\n stepName: z.string(),\n text: z.string(),\n});\nconst toolPlanSchema = z.record(z.string(), z.unknown());\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 replacePlan: z.optional(toolPlanSchema),\n summarizedTitle: z.optional(z.string()),\n updatePlan: z.optional(toolPlanSchema),\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 jobUpdateChunkSchema = z.object({\n chunkType: z.literal(\"jobUpdate\"),\n jobId: z.string(),\n jobState: z.string(),\n toolExecutionId: z.string(),\n toolName: z.string(),\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(jobUpdateChunkSchema, chatEventSharedSchema),\n z.extend(modelChunkSchema, chatEventSharedSchema),\n z.extend(sandboxProgressChunkSchema, 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, {\n content: jobUpdateChunkSchema,\n role: z.literal(\"agent\"),\n }),\n z.extend(chatEventOutputSharedSchema, { content: modelChunkSchema, role: z.literal(\"agent\") }),\n z.extend(chatEventOutputSharedSchema, {\n content: sandboxProgressChunkSchema,\n role: z.literal(\"agent\"),\n }),\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 \"jobUpdate\":\n return {\n ...sharedProperties,\n content: {\n chunkType: \"jobUpdate\",\n jobId: v.jobId,\n jobState: v.jobState,\n toolExecutionId: v.toolExecutionId,\n toolName: v.toolName,\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 \"sandboxProgress\":\n return {\n ...sharedProperties,\n content: {\n chunkType: \"sandboxProgress\",\n stepName: v.stepName,\n text: v.text,\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 replacePlan: v.replacePlan,\n summarizedTitle: v.summarizedTitle,\n updatePlan: v.updatePlan,\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"]}
@@ -37,7 +37,9 @@ export declare class AgentChatResponse<T extends AgentResponseContent> {
37
37
  modelProviderId: string;
38
38
  sessionId: string;
39
39
  commentary?: string | undefined;
40
+ replacePlan?: Record<string, unknown> | undefined;
40
41
  summarizedTitle?: string | undefined;
42
+ updatePlan?: Record<string, unknown> | undefined;
41
43
  } | {
42
44
  callId: string;
43
45
  chunkType: "toolResponse";
@@ -67,7 +69,9 @@ export declare class AgentChatResponse<T extends AgentResponseContent> {
67
69
  chunkType: z.ZodMiniLiteral<"toolRequest">;
68
70
  commentary: z.ZodMiniOptional<z.ZodMiniString<string>>;
69
71
  name: z.ZodMiniString<string>;
72
+ replacePlan: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>>;
70
73
  summarizedTitle: z.ZodMiniOptional<z.ZodMiniString<string>>;
74
+ updatePlan: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>>;
71
75
  createdAt: z.ZodMiniString<string>;
72
76
  modelName: z.ZodMiniString<string>;
73
77
  modelProviderId: z.ZodMiniString<string>;
@@ -109,6 +109,19 @@ export declare class AgentConversation implements AgentConversationProperties {
109
109
  result: Record<string, unknown>;
110
110
  };
111
111
  role: "agent";
112
+ } | {
113
+ conversationId: string;
114
+ modelName: string;
115
+ modelProviderId: string;
116
+ runId: string;
117
+ createdAt: import("temporal-polyfill").Temporal.Instant;
118
+ id: string;
119
+ content: {
120
+ chunkType: "sandboxProgress";
121
+ stepName: string;
122
+ text: string;
123
+ };
124
+ role: "agent";
112
125
  } | {
113
126
  conversationId: string;
114
127
  modelName: string;
@@ -122,7 +135,9 @@ export declare class AgentConversation implements AgentConversationProperties {
122
135
  chunkType: "toolRequest";
123
136
  name: string;
124
137
  commentary?: string | undefined;
138
+ replacePlan?: Record<string, unknown> | undefined;
125
139
  summarizedTitle?: string | undefined;
140
+ updatePlan?: Record<string, unknown> | undefined;
126
141
  };
127
142
  role: "agent";
128
143
  } | {
@@ -229,6 +244,19 @@ export declare class AgentConversation implements AgentConversationProperties {
229
244
  result: Record<string, unknown>;
230
245
  };
231
246
  role: "agent";
247
+ } | {
248
+ conversationId: string;
249
+ modelName: string;
250
+ modelProviderId: string;
251
+ runId: string;
252
+ createdAt: import("temporal-polyfill").Temporal.Instant;
253
+ id: string;
254
+ content: {
255
+ chunkType: "sandboxProgress";
256
+ stepName: string;
257
+ text: string;
258
+ };
259
+ role: "agent";
232
260
  } | {
233
261
  conversationId: string;
234
262
  modelName: string;
@@ -242,7 +270,9 @@ export declare class AgentConversation implements AgentConversationProperties {
242
270
  chunkType: "toolRequest";
243
271
  name: string;
244
272
  commentary?: string | undefined;
273
+ replacePlan?: Record<string, unknown> | undefined;
245
274
  summarizedTitle?: string | undefined;
275
+ updatePlan?: Record<string, unknown> | undefined;
246
276
  };
247
277
  role: "agent";
248
278
  } | {
@@ -144,6 +144,19 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
144
144
  result: Record<string, unknown>;
145
145
  };
146
146
  role: "agent";
147
+ } | {
148
+ conversationId: string;
149
+ modelName: string;
150
+ modelProviderId: string;
151
+ runId: string;
152
+ createdAt: import("temporal-polyfill").Temporal.Instant;
153
+ id: string;
154
+ content: {
155
+ chunkType: "sandboxProgress";
156
+ stepName: string;
157
+ text: string;
158
+ };
159
+ role: "agent";
147
160
  } | {
148
161
  conversationId: string;
149
162
  modelName: string;
@@ -157,7 +170,9 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
157
170
  chunkType: "toolRequest";
158
171
  name: string;
159
172
  commentary?: string | undefined;
173
+ replacePlan?: Record<string, unknown> | undefined;
160
174
  summarizedTitle?: string | undefined;
175
+ updatePlan?: Record<string, unknown> | undefined;
161
176
  };
162
177
  role: "agent";
163
178
  } | {
@@ -278,6 +293,19 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
278
293
  result: Record<string, unknown>;
279
294
  };
280
295
  role: "agent";
296
+ } | {
297
+ conversationId: string;
298
+ modelName: string;
299
+ modelProviderId: string;
300
+ runId: string;
301
+ createdAt: import("temporal-polyfill").Temporal.Instant;
302
+ id: string;
303
+ content: {
304
+ chunkType: "sandboxProgress";
305
+ stepName: string;
306
+ text: string;
307
+ };
308
+ role: "agent";
281
309
  } | {
282
310
  conversationId: string;
283
311
  modelName: string;
@@ -291,7 +319,9 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
291
319
  chunkType: "toolRequest";
292
320
  name: string;
293
321
  commentary?: string | undefined;
322
+ replacePlan?: Record<string, unknown> | undefined;
294
323
  summarizedTitle?: string | undefined;
324
+ updatePlan?: Record<string, unknown> | undefined;
295
325
  };
296
326
  role: "agent";
297
327
  } | {
@@ -419,6 +449,19 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
419
449
  result: Record<string, unknown>;
420
450
  };
421
451
  role: "agent";
452
+ } | {
453
+ conversationId: string;
454
+ modelName: string;
455
+ modelProviderId: string;
456
+ runId: string;
457
+ createdAt: import("temporal-polyfill").Temporal.Instant;
458
+ id: string;
459
+ content: {
460
+ chunkType: "sandboxProgress";
461
+ stepName: string;
462
+ text: string;
463
+ };
464
+ role: "agent";
422
465
  } | {
423
466
  conversationId: string;
424
467
  modelName: string;
@@ -432,7 +475,9 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
432
475
  chunkType: "toolRequest";
433
476
  name: string;
434
477
  commentary?: string | undefined;
478
+ replacePlan?: Record<string, unknown> | undefined;
435
479
  summarizedTitle?: string | undefined;
480
+ updatePlan?: Record<string, unknown> | undefined;
436
481
  };
437
482
  role: "agent";
438
483
  } | {
@@ -577,6 +622,19 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
577
622
  result: Record<string, unknown>;
578
623
  };
579
624
  role: "agent";
625
+ } | {
626
+ conversationId: string;
627
+ modelName: string;
628
+ modelProviderId: string;
629
+ runId: string;
630
+ createdAt: import("temporal-polyfill").Temporal.Instant;
631
+ id: string;
632
+ content: {
633
+ chunkType: "sandboxProgress";
634
+ stepName: string;
635
+ text: string;
636
+ };
637
+ role: "agent";
580
638
  } | {
581
639
  conversationId: string;
582
640
  modelName: string;
@@ -590,7 +648,9 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
590
648
  chunkType: "toolRequest";
591
649
  name: string;
592
650
  commentary?: string | undefined;
651
+ replacePlan?: Record<string, unknown> | undefined;
593
652
  summarizedTitle?: string | undefined;
653
+ updatePlan?: Record<string, unknown> | undefined;
594
654
  };
595
655
  role: "agent";
596
656
  } | {
@@ -715,6 +775,19 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
715
775
  result: Record<string, unknown>;
716
776
  };
717
777
  role: "agent";
778
+ } | {
779
+ conversationId: string;
780
+ modelName: string;
781
+ modelProviderId: string;
782
+ runId: string;
783
+ createdAt: import("temporal-polyfill").Temporal.Instant;
784
+ id: string;
785
+ content: {
786
+ chunkType: "sandboxProgress";
787
+ stepName: string;
788
+ text: string;
789
+ };
790
+ role: "agent";
718
791
  } | {
719
792
  conversationId: string;
720
793
  modelName: string;
@@ -728,7 +801,9 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
728
801
  chunkType: "toolRequest";
729
802
  name: string;
730
803
  commentary?: string | undefined;
804
+ replacePlan?: Record<string, unknown> | undefined;
731
805
  summarizedTitle?: string | undefined;
806
+ updatePlan?: Record<string, unknown> | undefined;
732
807
  };
733
808
  role: "agent";
734
809
  } | {
@@ -868,6 +943,19 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
868
943
  result: Record<string, unknown>;
869
944
  };
870
945
  role: "agent";
946
+ } | {
947
+ conversationId: string;
948
+ modelName: string;
949
+ modelProviderId: string;
950
+ runId: string;
951
+ createdAt: import("temporal-polyfill").Temporal.Instant;
952
+ id: string;
953
+ content: {
954
+ chunkType: "sandboxProgress";
955
+ stepName: string;
956
+ text: string;
957
+ };
958
+ role: "agent";
871
959
  } | {
872
960
  conversationId: string;
873
961
  modelName: string;
@@ -881,7 +969,9 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
881
969
  chunkType: "toolRequest";
882
970
  name: string;
883
971
  commentary?: string | undefined;
972
+ replacePlan?: Record<string, unknown> | undefined;
884
973
  summarizedTitle?: string | undefined;
974
+ updatePlan?: Record<string, unknown> | undefined;
885
975
  };
886
976
  role: "agent";
887
977
  } | {
@@ -81,6 +81,19 @@ export declare const retrieveConversationHistory: (config: SonarV4Config) => (id
81
81
  result: Record<string, unknown>;
82
82
  };
83
83
  role: "agent";
84
+ } | {
85
+ conversationId: string;
86
+ modelName: string;
87
+ modelProviderId: string;
88
+ runId: string;
89
+ createdAt: import("temporal-polyfill").Temporal.Instant;
90
+ id: string;
91
+ content: {
92
+ chunkType: "sandboxProgress";
93
+ stepName: string;
94
+ text: string;
95
+ };
96
+ role: "agent";
84
97
  } | {
85
98
  conversationId: string;
86
99
  modelName: string;
@@ -94,7 +107,9 @@ export declare const retrieveConversationHistory: (config: SonarV4Config) => (id
94
107
  chunkType: "toolRequest";
95
108
  name: string;
96
109
  commentary?: string | undefined;
110
+ replacePlan?: Record<string, unknown> | undefined;
97
111
  summarizedTitle?: string | undefined;
112
+ updatePlan?: Record<string, unknown> | undefined;
98
113
  };
99
114
  role: "agent";
100
115
  } | {
@@ -6,7 +6,7 @@ export type AgentToolCall = {
6
6
  request: ChatEventWithChunkType<"toolRequest"> | undefined;
7
7
  result: ChatEventWithChunkType<"toolResponse"> | undefined;
8
8
  };
9
- export type ConversationExchangeMessage = ChatEventWithChunkType<"error"> | ChatEventWithChunkType<"model"> | ChatEventWithChunkType<"userMessage">;
9
+ export type ConversationExchangeMessage = ChatEventWithChunkType<"error"> | ChatEventWithChunkType<"model"> | ChatEventWithChunkType<"sandboxProgress"> | ChatEventWithChunkType<"userMessage">;
10
10
  export type ConversationExchange = {
11
11
  id: string;
12
12
  messages: Map<string, ConversationExchangeMessage>;
@@ -39,6 +39,7 @@ function applyChatEventToConversationExchange(conversationExchange, chatEvent) {
39
39
  }
40
40
  case "error":
41
41
  case "model":
42
+ case "sandboxProgress":
42
43
  case "userMessage": {
43
44
  conversationExchange.messages.set(chatEvent.id, chatEvent);
44
45
  break;
@@ -1 +1 @@
1
- {"version":3,"file":"reduceChatEvents.js","sourceRoot":"","sources":["../../../../src/enterprise/ai/conversations/reduceChatEvents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,MAAM,EAAc,MAAM,UAAU,CAAC;AAyB9C,SAAS,4BAA4B,CACnC,KAAmC,EACnC,SAAoB;IAEpB,IAAI,oBAAoB,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC;IAEzF,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC1B,oBAAoB,GAAG;YACrB,EAAE,EAAE,SAAS,CAAC,KAAK;YACnB,QAAQ,EAAE,IAAI,GAAG,EAAE;YACnB,SAAS,EAAE,IAAI,GAAG,EAAE;SACrB,CAAC;QACF,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACjC,oBAAoB,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,oCAAoC,CAAC,oBAAqB,EAAE,SAAS,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,oCAAoC,CAC3C,oBAAiD,EACjD,SAAoB;IAEpB,QAAQ,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;QACpC,KAAK,aAAa,C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B,CAAC;yBAAM,CAAC;wBACN,QAAQ,CAAC,KAAK,GAAG,SAAS,CAAC;oBAC7B,CAAC;oBACD,MAAM;YACV,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,QAA+B,EAAE,EAAE,UAAuB;IACzF,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;QAC7B,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,4BAA4B,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;QAChE,CAAC;IACH,CAAC,CAAC,CAAC;AACL,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 { create, type Draft } from \"mutative\";\nimport type { ChatEvent, ChatEventWithChunkType } from \"../chat/chatEventSchema.ts\";\nimport type { UserChatMessage } from \"../chat/UserChatMessage.ts\";\n\nexport type AgentToolCall = {\n id: string;\n state: \"canceled\" | \"error\" | \"pending\" | \"success\";\n request: ChatEventWithChunkType<\"toolRequest\"> | undefined;\n result: ChatEventWithChunkType<\"toolResponse\"> | undefined;\n};\n\nexport type ConversationExchangeMessage =\n | ChatEventWithChunkType<\"error\">\n | ChatEventWithChunkType<\"model\">\n | ChatEventWithChunkType<\"userMessage\">;\n\nexport type ConversationExchange = {\n id: string;\n messages: Map<string, ConversationExchangeMessage>;\n submittedUserMessage?: UserChatMessage;\n toolCalls: Map<string, AgentToolCall>;\n};\n\nexport type ChatEventReducerState = ConversationExchange[];\n\nfunction applyChatEventToConversation(\n draft: Draft<ChatEventReducerState>,\n chatEvent: ChatEvent,\n): void {\n let conversationExchange = draft.findLast((exchange) => exchange.id === chatEvent.runId);\n\n if (!conversationExchange) {\n conversationExchange = {\n id: chatEvent.runId,\n messages: new Map(),\n toolCalls: new Map(),\n };\n draft.push(conversationExchange);\n conversationExchange = draft[draft.length - 1];\n }\n\n applyChatEventToConversationExchange(conversationExchange!, chatEvent);\n}\n\nfunction applyChatEventToConversationExchange(\n conversationExchange: Draft<ConversationExchange>,\n chatEvent: ChatEvent,\n): void {\n switch (chatEvent.content.chunkType) {\n case \"endOfStream\": {\n for (const [, toolCall] of conversationExchange.toolCalls) {\n if (!toolCall.result) {\n toolCall.state = \"canceled\";\n }\n }\n break;\n }\n case \"error\":\n case \"model\":\n case \"userMessage\": {\n conversationExchange.messages.set(\n chatEvent.id,\n chatEvent as Draft<ConversationExchangeMessage>,\n );\n break;\n }\n case \"toolRequest\":\n case \"toolResponse\": {\n const callId = chatEvent.content.callId;\n\n if (!conversationExchange.toolCalls.has(callId)) {\n conversationExchange.toolCalls.set(callId, {\n id: callId,\n request: undefined,\n result: undefined,\n state: \"pending\",\n });\n }\n\n const toolCall = conversationExchange.toolCalls.get(callId)!;\n\n switch (chatEvent.content.chunkType) {\n case \"toolRequest\":\n toolCall.request = chatEvent as unknown as Draft<ChatEventWithChunkType<\"toolRequest\">>;\n break;\n case \"toolResponse\":\n toolCall.result = chatEvent as unknown as Draft<ChatEventWithChunkType<\"toolResponse\">>;\n if (\"errorMessage\" in toolCall.result.content.result) {\n toolCall.state = \"error\";\n } else {\n toolCall.state = \"success\";\n }\n break;\n }\n }\n }\n}\n\nexport function reduceChatEvents(state: ChatEventReducerState = [], chatEvents: ChatEvent[]) {\n return create(state, (draft) => {\n for (const chatEvent of chatEvents) {\n applyChatEventToConversation(draft, Object.freeze(chatEvent));\n }\n });\n}\n"]}
1
+ {"version":3,"file":"reduceChatEvents.js","sourceRoot":"","sources":["../../../../src/enter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;IACH,CAAC,CAAC,CAAC;AACL,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 { create, type Draft } from \"mutative\";\nimport type { ChatEvent, ChatEventWithChunkType } from \"../chat/chatEventSchema.ts\";\nimport type { UserChatMessage } from \"../chat/UserChatMessage.ts\";\n\nexport type AgentToolCall = {\n id: string;\n state: \"canceled\" | \"error\" | \"pending\" | \"success\";\n request: ChatEventWithChunkType<\"toolRequest\"> | undefined;\n result: ChatEventWithChunkType<\"toolResponse\"> | undefined;\n};\n\nexport type ConversationExchangeMessage =\n | ChatEventWithChunkType<\"error\">\n | ChatEventWithChunkType<\"model\">\n | ChatEventWithChunkType<\"sandboxProgress\">\n | ChatEventWithChunkType<\"userMessage\">;\n\nexport type ConversationExchange = {\n id: string;\n messages: Map<string, ConversationExchangeMessage>;\n submittedUserMessage?: UserChatMessage;\n toolCalls: Map<string, AgentToolCall>;\n};\n\nexport type ChatEventReducerState = ConversationExchange[];\n\nfunction applyChatEventToConversation(\n draft: Draft<ChatEventReducerState>,\n chatEvent: ChatEvent,\n): void {\n let conversationExchange = draft.findLast((exchange) => exchange.id === chatEvent.runId);\n\n if (!conversationExchange) {\n conversationExchange = {\n id: chatEvent.runId,\n messages: new Map(),\n toolCalls: new Map(),\n };\n draft.push(conversationExchange);\n conversationExchange = draft[draft.length - 1];\n }\n\n applyChatEventToConversationExchange(conversationExchange!, chatEvent);\n}\n\nfunction applyChatEventToConversationExchange(\n conversationExchange: Draft<ConversationExchange>,\n chatEvent: ChatEvent,\n): void {\n switch (chatEvent.content.chunkType) {\n case \"endOfStream\": {\n for (const [, toolCall] of conversationExchange.toolCalls) {\n if (!toolCall.result) {\n toolCall.state = \"canceled\";\n }\n }\n break;\n }\n case \"error\":\n case \"model\":\n case \"sandboxProgress\":\n case \"userMessage\": {\n conversationExchange.messages.set(\n chatEvent.id,\n chatEvent as Draft<ConversationExchangeMessage>,\n );\n break;\n }\n case \"toolRequest\":\n case \"toolResponse\": {\n const callId = chatEvent.content.callId;\n\n if (!conversationExchange.toolCalls.has(callId)) {\n conversationExchange.toolCalls.set(callId, {\n id: callId,\n request: undefined,\n result: undefined,\n state: \"pending\",\n });\n }\n\n const toolCall = conversationExchange.toolCalls.get(callId)!;\n\n switch (chatEvent.content.chunkType) {\n case \"toolRequest\":\n toolCall.request = chatEvent as unknown as Draft<ChatEventWithChunkType<\"toolRequest\">>;\n break;\n case \"toolResponse\":\n toolCall.result = chatEvent as unknown as Draft<ChatEventWithChunkType<\"toolResponse\">>;\n if (\"errorMessage\" in toolCall.result.content.result) {\n toolCall.state = \"error\";\n } else {\n toolCall.state = \"success\";\n }\n break;\n }\n }\n }\n}\n\nexport function reduceChatEvents(state: ChatEventReducerState = [], chatEvents: ChatEvent[]) {\n return create(state, (draft) => {\n for (const chatEvent of chatEvents) {\n applyChatEventToConversation(draft, Object.freeze(chatEvent));\n }\n });\n}\n"]}
@@ -17142,13 +17142,21 @@ var DremioCloud = (() => {
17142
17142
  */
17143
17143
  result: record(string2(), unknown())
17144
17144
  });
17145
+ var sandboxProgressChunkSchema = object({
17146
+ chunkType: literal("sandboxProgress"),
17147
+ stepName: string2(),
17148
+ text: string2()
17149
+ });
17150
+ var toolPlanSchema = record(string2(), unknown());
17145
17151
  var toolRequestChunkSchema = object({
17146
17152
  arguments: record(string2(), unknown()),
17147
17153
  callId: string2().check(_trim(), _minLength(1)),
17148
17154
  chunkType: literal("toolRequest"),
17149
17155
  commentary: optional(string2()),
17150
17156
  name: string2(),
17151
- summarizedTitle: optional(string2())
17157
+ replacePlan: optional(toolPlanSchema),
17158
+ summarizedTitle: optional(string2()),
17159
+ updatePlan: optional(toolPlanSchema)
17152
17160
  });
17153
17161
  var toolResponseChunkSchema = object({
17154
17162
  callId: string2(),
@@ -17181,6 +17189,7 @@ var DremioCloud = (() => {
17181
17189
  extend2(conversationUpdateChunkSchema, chatEventSharedSchema),
17182
17190
  extend2(jobUpdateChunkSchema, chatEventSharedSchema),
17183
17191
  extend2(modelChunkSchema, chatEventSharedSchema),
17192
+ extend2(sandboxProgressChunkSchema, chatEventSharedSchema),
17184
17193
  extend2(toolRequestChunkSchema, chatEventSharedSchema),
17185
17194
  extend2(toolResponseChunkSchema, chatEventSharedSchema),
17186
17195
  extend2(userMessageChunkSchema, chatEventSharedSchema)
@@ -17208,6 +17217,10 @@ var DremioCloud = (() => {
17208
17217
  role: literal("agent")
17209
17218
  }),
17210
17219
  extend2(chatEventOutputSharedSchema, { content: modelChunkSchema, role: literal("agent") }),
17220
+ extend2(chatEventOutputSharedSchema, {
17221
+ content: sandboxProgressChunkSchema,
17222
+ role: literal("agent")
17223
+ }),
17211
17224
  extend2(chatEventOutputSharedSchema, {
17212
17225
  content: toolRequestChunkSchema,
17213
17226
  role: literal("agent")
@@ -17290,6 +17303,16 @@ var DremioCloud = (() => {
17290
17303
  },
17291
17304
  role: "agent"
17292
17305
  };
17306
+ case "sandboxProgress":
17307
+ return {
17308
+ ...sharedProperties,
17309
+ content: {
17310
+ chunkType: "sandboxProgress",
17311
+ stepName: v2.stepName,
17312
+ text: v2.text
17313
+ },
17314
+ role: "agent"
17315
+ };
17293
17316
  case "toolRequest":
17294
17317
  return {
17295
17318
  ...sharedProperties,
@@ -17299,7 +17322,9 @@ var DremioCloud = (() => {
17299
17322
  chunkType: "toolRequest",
17300
17323
  commentary: v2.commentary,
17301
17324
  name: v2.name,
17302
- summarizedTitle: v2.summarizedTitle
17325
+ replacePlan: v2.replacePlan,
17326
+ summarizedTitle: v2.summarizedTitle,
17327
+ updatePlan: v2.updatePlan
17303
17328
  },
17304
17329
  role: "agent"
17305
17330
  };
@@ -19347,6 +19372,7 @@ var DremioCloud = (() => {
19347
19372
  }
19348
19373
  case "error":
19349
19374
  case "model":
19375
+ case "sandboxProgress":
19350
19376
  case "userMessage": {
19351
19377
  conversationExchange.messages.set(chatEvent.id, chatEvent);
19352
19378
  break;
@@ -16067,13 +16067,21 @@ var DremioEnterprise = (() => {
16067
16067
  */
16068
16068
  result: record(string2(), unknown())
16069
16069
  });
16070
+ var sandboxProgressChunkSchema = object({
16071
+ chunkType: literal("sandboxProgress"),
16072
+ stepName: string2(),
16073
+ text: string2()
16074
+ });
16075
+ var toolPlanSchema = record(string2(), unknown());
16070
16076
  var toolRequestChunkSchema = object({
16071
16077
  arguments: record(string2(), unknown()),
16072
16078
  callId: string2().check(_trim(), _minLength(1)),
16073
16079
  chunkType: literal("toolRequest"),
16074
16080
  commentary: optional(string2()),
16075
16081
  name: string2(),
16076
- summarizedTitle: optional(string2())
16082
+ replacePlan: optional(toolPlanSchema),
16083
+ summarizedTitle: optional(string2()),
16084
+ updatePlan: optional(toolPlanSchema)
16077
16085
  });
16078
16086
  var toolResponseChunkSchema = object({
16079
16087
  callId: string2(),
@@ -16106,6 +16114,7 @@ var DremioEnterprise = (() => {
16106
16114
  extend2(conversationUpdateChunkSchema, chatEventSharedSchema),
16107
16115
  extend2(jobUpdateChunkSchema, chatEventSharedSchema),
16108
16116
  extend2(modelChunkSchema, chatEventSharedSchema),
16117
+ extend2(sandboxProgressChunkSchema, chatEventSharedSchema),
16109
16118
  extend2(toolRequestChunkSchema, chatEventSharedSchema),
16110
16119
  extend2(toolResponseChunkSchema, chatEventSharedSchema),
16111
16120
  extend2(userMessageChunkSchema, chatEventSharedSchema)
@@ -16133,6 +16142,10 @@ var DremioEnterprise = (() => {
16133
16142
  role: literal("agent")
16134
16143
  }),
16135
16144
  extend2(chatEventOutputSharedSchema, { content: modelChunkSchema, role: literal("agent") }),
16145
+ extend2(chatEventOutputSharedSchema, {
16146
+ content: sandboxProgressChunkSchema,
16147
+ role: literal("agent")
16148
+ }),
16136
16149
  extend2(chatEventOutputSharedSchema, {
16137
16150
  content: toolRequestChunkSchema,
16138
16151
  role: literal("agent")
@@ -16215,6 +16228,16 @@ var DremioEnterprise = (() => {
16215
16228
  },
16216
16229
  role: "agent"
16217
16230
  };
16231
+ case "sandboxProgress":
16232
+ return {
16233
+ ...sharedProperties,
16234
+ content: {
16235
+ chunkType: "sandboxProgress",
16236
+ stepName: v2.stepName,
16237
+ text: v2.text
16238
+ },
16239
+ role: "agent"
16240
+ };
16218
16241
  case "toolRequest":
16219
16242
  return {
16220
16243
  ...sharedProperties,
@@ -16224,7 +16247,9 @@ var DremioEnterprise = (() => {
16224
16247
  chunkType: "toolRequest",
16225
16248
  commentary: v2.commentary,
16226
16249
  name: v2.name,
16227
- summarizedTitle: v2.summarizedTitle
16250
+ replacePlan: v2.replacePlan,
16251
+ summarizedTitle: v2.summarizedTitle,
16252
+ updatePlan: v2.updatePlan
16228
16253
  },
16229
16254
  role: "agent"
16230
16255
  };
@@ -17923,6 +17948,7 @@ var DremioEnterprise = (() => {
17923
17948
  }
17924
17949
  case "error":
17925
17950
  case "model":
17951
+ case "sandboxProgress":
17926
17952
  case "userMessage": {
17927
17953
  conversationExchange.messages.set(chatEvent.id, chatEvent);
17928
17954
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dremio/js-sdk",
3
- "version": "0.56.0",
3
+ "version": "0.57.1",
4
4
  "description": "JavaScript library for the Dremio API",
5
5
  "keywords": [
6
6
  "dremio",