@dremio/js-sdk 0.61.0 → 0.62.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.
package/README.md CHANGED
@@ -409,6 +409,7 @@ The state of a conversation is represented as a stream of `ChatEvent` objects. T
409
409
  - `toolResponse` - The result of a tool execution
410
410
  - `error` - An error message
411
411
  - `conversationUpdate` - Updates to conversation metadata (title, summary)
412
+ - `selectedSkills` - Metadata for saved Skills selected for the run
412
413
  - `endOfStream` - Marks the end of a run's event stream
413
414
 
414
415
  #### Building a Conversation Snapshot
@@ -428,6 +429,7 @@ function reduceChatEvents(
428
429
 
429
430
  - **Groups events by exchange** - Each user-agent interaction (identified by `runId`) becomes a separate exchange
430
431
  - **Pairs tool calls** - Tool requests and responses are matched by `callId` and combined into a single object
432
+ - **Preserves run metadata** - Run-level metadata such as selected saved Skills is attached to the exchange
431
433
  - **Derives tool state** - Automatically determines if a tool call is `pending`, `success`, `error`, or `canceled`
432
434
  - `pending` - Tool request received but no response yet
433
435
  - `success` - Tool response received without error
@@ -457,8 +459,18 @@ Each exchange in the snapshot represents a single user-agent interaction:
457
459
  type ConversationExchange = {
458
460
  id: string; // The run ID
459
461
  messages: Map<string, ConversationExchangeMessage>;
460
- toolCalls: Map<string, AgentToolCall>;
462
+ runMetadata?: ConversationExchangeRunMetadata;
461
463
  submittedUserMessage?: UserChatMessage;
464
+ toolCalls: Map<string, AgentToolCall>;
465
+ };
466
+
467
+ type ConversationExchangeRunMetadata = {
468
+ selectedSkills?: SelectedSkillInfo[];
469
+ };
470
+
471
+ type SelectedSkillInfo = {
472
+ id: string;
473
+ name: string;
462
474
  };
463
475
 
464
476
  type ConversationExchangeMessage =
@@ -489,6 +501,10 @@ type ChatEvent = {
489
501
  | { chunkType: "endOfStream" }
490
502
  | { chunkType: "error"; message: string }
491
503
  | { chunkType: "model"; name: string; result: Record<string, unknown> }
504
+ | {
505
+ chunkType: "selectedSkills";
506
+ selectedSkills: { id: string; name: string }[];
507
+ }
492
508
  | { chunkType: "sandboxProgress"; stepName: string; text: string }
493
509
  | {
494
510
  chunkType: "sandboxStdout";
@@ -519,6 +535,17 @@ type ChatEventWithChunkType<T extends ChatEvent["content"]["chunkType"]> =
519
535
  Extract<ChatEvent, { content: { chunkType: T } }>;
520
536
  ```
521
537
 
538
+ Selected saved Skills are exposed as run metadata:
539
+
540
+ ```typescript
541
+ const selectedSkills = exchange.runMetadata?.selectedSkills ?? [];
542
+ ```
543
+
544
+ When additional events are reduced into an existing snapshot, `selectedSkills` is updated
545
+ from the newest `selectedSkills` event by `createdAt`. Equal timestamps use the event's
546
+ message position when available; otherwise they fall back to the order events are passed
547
+ to `reduceChatEvents` (later wins).
548
+
522
549
  #### UI Rendering and React Reconciliation
523
550
 
524
551
  The conversation snapshot produced by the reducer (and automatically managed by the `AgentConversationMachine`) is designed specifically for modern declarative UIs like React, Vue, Svelte, or Ink.
@@ -185,6 +185,21 @@ export declare class AIResource {
185
185
  result: Record<string, unknown>;
186
186
  };
187
187
  role: "agent";
188
+ } | {
189
+ conversationId: string;
190
+ modelName: string;
191
+ modelProviderId: string;
192
+ runId: string;
193
+ createdAt: import("temporal-polyfill").Temporal.Instant;
194
+ id: string;
195
+ content: {
196
+ chunkType: "selectedSkills";
197
+ selectedSkills: {
198
+ id: string;
199
+ name: string;
200
+ }[];
201
+ };
202
+ role: "agent";
188
203
  } | {
189
204
  conversationId: string;
190
205
  modelName: string;
@@ -347,6 +362,21 @@ export declare class AIResource {
347
362
  result: Record<string, unknown>;
348
363
  };
349
364
  role: "agent";
365
+ } | {
366
+ conversationId: string;
367
+ modelName: string;
368
+ modelProviderId: string;
369
+ runId: string;
370
+ createdAt: import("temporal-polyfill").Temporal.Instant;
371
+ id: string;
372
+ content: {
373
+ chunkType: "selectedSkills";
374
+ selectedSkills: {
375
+ id: string;
376
+ name: string;
377
+ }[];
378
+ };
379
+ role: "agent";
350
380
  } | {
351
381
  conversationId: string;
352
382
  modelName: string;
@@ -516,6 +546,21 @@ export declare class AIResource {
516
546
  result: Record<string, unknown>;
517
547
  };
518
548
  role: "agent";
549
+ } | {
550
+ conversationId: string;
551
+ modelName: string;
552
+ modelProviderId: string;
553
+ runId: string;
554
+ createdAt: import("temporal-polyfill").Temporal.Instant;
555
+ id: string;
556
+ content: {
557
+ chunkType: "selectedSkills";
558
+ selectedSkills: {
559
+ id: string;
560
+ name: string;
561
+ }[];
562
+ };
563
+ role: "agent";
519
564
  } | {
520
565
  conversationId: string;
521
566
  modelName: string;
@@ -702,6 +747,21 @@ export declare class AIResource {
702
747
  result: Record<string, unknown>;
703
748
  };
704
749
  role: "agent";
750
+ } | {
751
+ conversationId: string;
752
+ modelName: string;
753
+ modelProviderId: string;
754
+ runId: string;
755
+ createdAt: import("temporal-polyfill").Temporal.Instant;
756
+ id: string;
757
+ content: {
758
+ chunkType: "selectedSkills";
759
+ selectedSkills: {
760
+ id: string;
761
+ name: string;
762
+ }[];
763
+ };
764
+ role: "agent";
705
765
  } | {
706
766
  conversationId: string;
707
767
  modelName: string;
@@ -868,6 +928,21 @@ export declare class AIResource {
868
928
  result: Record<string, unknown>;
869
929
  };
870
930
  role: "agent";
931
+ } | {
932
+ conversationId: string;
933
+ modelName: string;
934
+ modelProviderId: string;
935
+ runId: string;
936
+ createdAt: import("temporal-polyfill").Temporal.Instant;
937
+ id: string;
938
+ content: {
939
+ chunkType: "selectedSkills";
940
+ selectedSkills: {
941
+ id: string;
942
+ name: string;
943
+ }[];
944
+ };
945
+ role: "agent";
871
946
  } | {
872
947
  conversationId: string;
873
948
  modelName: string;
@@ -1049,6 +1124,21 @@ export declare class AIResource {
1049
1124
  result: Record<string, unknown>;
1050
1125
  };
1051
1126
  role: "agent";
1127
+ } | {
1128
+ conversationId: string;
1129
+ modelName: string;
1130
+ modelProviderId: string;
1131
+ runId: string;
1132
+ createdAt: import("temporal-polyfill").Temporal.Instant;
1133
+ id: string;
1134
+ content: {
1135
+ chunkType: "selectedSkills";
1136
+ selectedSkills: {
1137
+ id: string;
1138
+ name: string;
1139
+ }[];
1140
+ };
1141
+ role: "agent";
1052
1142
  } | {
1053
1143
  conversationId: string;
1054
1144
  modelName: string;
@@ -127,6 +127,21 @@ export declare class AIResource {
127
127
  result: Record<string, unknown>;
128
128
  };
129
129
  role: "agent";
130
+ } | {
131
+ conversationId: string;
132
+ modelName: string;
133
+ modelProviderId: string;
134
+ runId: string;
135
+ createdAt: import("temporal-polyfill").Temporal.Instant;
136
+ id: string;
137
+ content: {
138
+ chunkType: "selectedSkills";
139
+ selectedSkills: {
140
+ id: string;
141
+ name: string;
142
+ }[];
143
+ };
144
+ role: "agent";
130
145
  } | {
131
146
  conversationId: string;
132
147
  modelName: string;
@@ -289,6 +304,21 @@ export declare class AIResource {
289
304
  result: Record<string, unknown>;
290
305
  };
291
306
  role: "agent";
307
+ } | {
308
+ conversationId: string;
309
+ modelName: string;
310
+ modelProviderId: string;
311
+ runId: string;
312
+ createdAt: import("temporal-polyfill").Temporal.Instant;
313
+ id: string;
314
+ content: {
315
+ chunkType: "selectedSkills";
316
+ selectedSkills: {
317
+ id: string;
318
+ name: string;
319
+ }[];
320
+ };
321
+ role: "agent";
292
322
  } | {
293
323
  conversationId: string;
294
324
  modelName: string;
@@ -458,6 +488,21 @@ export declare class AIResource {
458
488
  result: Record<string, unknown>;
459
489
  };
460
490
  role: "agent";
491
+ } | {
492
+ conversationId: string;
493
+ modelName: string;
494
+ modelProviderId: string;
495
+ runId: string;
496
+ createdAt: import("temporal-polyfill").Temporal.Instant;
497
+ id: string;
498
+ content: {
499
+ chunkType: "selectedSkills";
500
+ selectedSkills: {
501
+ id: string;
502
+ name: string;
503
+ }[];
504
+ };
505
+ role: "agent";
461
506
  } | {
462
507
  conversationId: string;
463
508
  modelName: string;
@@ -644,6 +689,21 @@ export declare class AIResource {
644
689
  result: Record<string, unknown>;
645
690
  };
646
691
  role: "agent";
692
+ } | {
693
+ conversationId: string;
694
+ modelName: string;
695
+ modelProviderId: string;
696
+ runId: string;
697
+ createdAt: import("temporal-polyfill").Temporal.Instant;
698
+ id: string;
699
+ content: {
700
+ chunkType: "selectedSkills";
701
+ selectedSkills: {
702
+ id: string;
703
+ name: string;
704
+ }[];
705
+ };
706
+ role: "agent";
647
707
  } | {
648
708
  conversationId: string;
649
709
  modelName: string;
@@ -810,6 +870,21 @@ export declare class AIResource {
810
870
  result: Record<string, unknown>;
811
871
  };
812
872
  role: "agent";
873
+ } | {
874
+ conversationId: string;
875
+ modelName: string;
876
+ modelProviderId: string;
877
+ runId: string;
878
+ createdAt: import("temporal-polyfill").Temporal.Instant;
879
+ id: string;
880
+ content: {
881
+ chunkType: "selectedSkills";
882
+ selectedSkills: {
883
+ id: string;
884
+ name: string;
885
+ }[];
886
+ };
887
+ role: "agent";
813
888
  } | {
814
889
  conversationId: string;
815
890
  modelName: string;
@@ -991,6 +1066,21 @@ export declare class AIResource {
991
1066
  result: Record<string, unknown>;
992
1067
  };
993
1068
  role: "agent";
1069
+ } | {
1070
+ conversationId: string;
1071
+ modelName: string;
1072
+ modelProviderId: string;
1073
+ runId: string;
1074
+ createdAt: import("temporal-polyfill").Temporal.Instant;
1075
+ id: string;
1076
+ content: {
1077
+ chunkType: "selectedSkills";
1078
+ selectedSkills: {
1079
+ id: string;
1080
+ name: string;
1081
+ }[];
1082
+ };
1083
+ role: "agent";
994
1084
  } | {
995
1085
  conversationId: string;
996
1086
  modelName: string;
@@ -1,5 +1,10 @@
1
1
  import { Temporal } from "temporal-polyfill";
2
2
  import * as z from "zod/mini";
3
+ declare const selectedSkillInfoSchema: z.ZodMiniObject<{
4
+ id: z.ZodMiniString<string>;
5
+ name: z.ZodMiniString<string>;
6
+ }, z.core.$strip>;
7
+ export type SelectedSkillInfo = z.infer<typeof selectedSkillInfoSchema>;
3
8
  /**
4
9
  * Captures all of the possible chunks of data that the Agent can reply
5
10
  * with. We're lenient to extra/unexpected fields being present (`z.object`
@@ -109,6 +114,18 @@ export declare const chatEventCodec: z.ZodMiniCodec<z.ZodMiniDiscriminatedUnion<
109
114
  modelName: z.ZodMiniString<string>;
110
115
  modelProviderId: z.ZodMiniString<string>;
111
116
  runId: z.ZodMiniString<string>;
117
+ }, z.core.$strip>, z.ZodMiniObject<{
118
+ chunkType: z.ZodMiniLiteral<"selectedSkills">;
119
+ selectedSkills: z.ZodMiniArray<z.ZodMiniObject<{
120
+ id: z.ZodMiniString<string>;
121
+ name: z.ZodMiniString<string>;
122
+ }, z.core.$strip>>;
123
+ conversationId: z.ZodMiniString<string>;
124
+ createdAt: z.ZodMiniString<string>;
125
+ messageId: z.ZodMiniString<string>;
126
+ modelName: z.ZodMiniString<string>;
127
+ modelProviderId: z.ZodMiniString<string>;
128
+ runId: z.ZodMiniString<string>;
112
129
  }, z.core.$strip>, z.ZodMiniObject<{
113
130
  chunkType: z.ZodMiniLiteral<"sandboxProgress">;
114
131
  stepName: z.ZodMiniString<string>;
@@ -247,6 +264,21 @@ export declare const chatEventCodec: z.ZodMiniCodec<z.ZodMiniDiscriminatedUnion<
247
264
  result: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>;
248
265
  }, z.core.$strip>;
249
266
  role: z.ZodMiniLiteral<"agent">;
267
+ }, z.core.$strict>, z.ZodMiniObject<{
268
+ conversationId: z.ZodMiniString<string>;
269
+ modelName: z.ZodMiniString<string>;
270
+ modelProviderId: z.ZodMiniString<string>;
271
+ runId: z.ZodMiniString<string>;
272
+ createdAt: z.ZodMiniCustom<Temporal.Instant, Temporal.Instant>;
273
+ id: z.ZodMiniString<string>;
274
+ content: z.ZodMiniObject<{
275
+ chunkType: z.ZodMiniLiteral<"selectedSkills">;
276
+ selectedSkills: z.ZodMiniArray<z.ZodMiniObject<{
277
+ id: z.ZodMiniString<string>;
278
+ name: z.ZodMiniString<string>;
279
+ }, z.core.$strip>>;
280
+ }, z.core.$strip>;
281
+ role: z.ZodMiniLiteral<"agent">;
250
282
  }, z.core.$strict>, z.ZodMiniObject<{
251
283
  conversationId: z.ZodMiniString<string>;
252
284
  modelName: z.ZodMiniString<string>;
@@ -326,3 +358,4 @@ export type ChatEventWithChunkType<T extends z.input<typeof chatEventCodec>["chu
326
358
  chunkType: T;
327
359
  };
328
360
  }>;
361
+ export {};
@@ -118,6 +118,14 @@ const jobUpdateChunkSchema = z.object({
118
118
  toolExecutionId: z.string(),
119
119
  toolName: z.string(),
120
120
  });
121
+ const selectedSkillInfoSchema = z.object({
122
+ id: z.string(),
123
+ name: z.string(),
124
+ });
125
+ const selectedSkillsChunkSchema = z.object({
126
+ chunkType: z.literal("selectedSkills"),
127
+ selectedSkills: z.array(selectedSkillInfoSchema),
128
+ });
121
129
  const userMessageChunkSchema = z.object({
122
130
  chunkType: z.literal("userMessage"),
123
131
  text: z.string(),
@@ -144,6 +152,7 @@ const chatEventInputSchema = z.discriminatedUnion("chunkType", [
144
152
  z.extend(conversationUpdateChunkSchema, chatEventSharedSchema),
145
153
  z.extend(jobUpdateChunkSchema, chatEventSharedSchema),
146
154
  z.extend(modelChunkSchema, chatEventSharedSchema),
155
+ z.extend(selectedSkillsChunkSchema, chatEventSharedSchema),
147
156
  z.extend(sandboxProgressChunkSchema, chatEventSharedSchema),
148
157
  sandboxStdoutChatEventSchema,
149
158
  z.extend(toolRequestChunkSchema, chatEventSharedSchema),
@@ -175,6 +184,10 @@ const chatEventOutputSchema = z.union([
175
184
  role: z.literal("agent"),
176
185
  }),
177
186
  z.extend(chatEventOutputSharedSchema, { content: modelChunkSchema, role: z.literal("agent") }),
187
+ z.extend(chatEventOutputSharedSchema, {
188
+ content: selectedSkillsChunkSchema,
189
+ role: z.literal("agent"),
190
+ }),
178
191
  z.extend(chatEventOutputSharedSchema, {
179
192
  content: sandboxProgressChunkSchema,
180
193
  role: z.literal("agent"),
@@ -268,6 +281,15 @@ export const chatEventCodec = z.codec(chatEventInputSchema, chatEventOutputSchem
268
281
  },
269
282
  role: "agent",
270
283
  };
284
+ case "selectedSkills":
285
+ return {
286
+ ...sharedProperties,
287
+ content: {
288
+ chunkType: "selectedSkills",
289
+ selectedSkills: v.selectedSkills,
290
+ },
291
+ role: "agent",
292
+ };
271
293
  case "sandboxProgress":
272
294
  return {
273
295
  ...sharedProperties,
@@ -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,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,EAAE;IAC1B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC7C,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE;IAC3B,K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,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\n// endOfStream omits messageId: the backend sends it absent or as \"\", neither maps to a meaningful id\nconst endOfStreamInputSchema = z.object({\n chunkType: z.literal(\"endOfStream\"),\n conversationId: z.string(),\n createdAt: z.string().check(z.iso.datetime()),\n modelName: z.string(),\n modelProviderId: z.string(),\n runId: z.string(),\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});\n\nconst sandboxStdoutChunkSchema = z.object({\n callId: z.string().check(z.trim(), z.minLength(1)),\n chunkType: z.literal(\"sandboxStdout\"),\n isFinal: z.boolean(),\n text: z.string(),\n});\nconst sandboxStdoutContentSchema = sandboxStdoutChunkSchema;\nconst sandboxStdoutChatEventSchema = z.extend(sandboxStdoutChunkSchema, chatEventSharedSchema);\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 endOfStreamInputSchema,\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 sandboxStdoutChatEventSchema,\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\n// endOfStream has no meaningful messageId on input, so no id on output\nconst endOfStreamOutputSchema = z.omit(chatEventOutputSharedSchema, { id: true });\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(endOfStreamOutputSchema, {\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: sandboxStdoutContentSchema,\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 if (v.chunkType === \"endOfStream\") {\n return {\n content: { chunkType: \"endOfStream\" },\n conversationId: v.conversationId,\n createdAt: Temporal.Instant.from(v.createdAt),\n modelName: v.modelName,\n modelProviderId: v.modelProviderId,\n role: \"agent\",\n runId: v.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 };\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 \"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 \"sandboxStdout\":\n return {\n ...sharedProperties,\n content: {\n callId: v.callId,\n chunkType: \"sandboxStdout\",\n isFinal: v.isFinal,\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 if (v.content.chunkType === \"endOfStream\") {\n return {\n chunkType: \"endOfStream\",\n conversationId: v.conversationId,\n createdAt: v.createdAt.toString(),\n modelName: v.modelName,\n modelProviderId: v.modelProviderId,\n runId: v.runId,\n } as const satisfies z.infer<typeof chatEventInputSchema>;\n }\n // Safe: endOfStream (the only variant without id) is handled by the early return above\n const id = (v as Extract<z.output<typeof chatEventOutputSchema>, { id: string }>).id;\n return {\n conversationId: v.conversationId,\n createdAt: v.createdAt.toString(),\n messageId: 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,EA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,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\n// endOfStream omits messageId: the backend sends it absent or as \"\", neither maps to a meaningful id\nconst endOfStreamInputSchema = z.object({\n chunkType: z.literal(\"endOfStream\"),\n conversationId: z.string(),\n createdAt: z.string().check(z.iso.datetime()),\n modelName: z.string(),\n modelProviderId: z.string(),\n runId: z.string(),\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});\n\nconst sandboxStdoutChunkSchema = z.object({\n callId: z.string().check(z.trim(), z.minLength(1)),\n chunkType: z.literal(\"sandboxStdout\"),\n isFinal: z.boolean(),\n text: z.string(),\n});\nconst sandboxStdoutContentSchema = sandboxStdoutChunkSchema;\nconst sandboxStdoutChatEventSchema = z.extend(sandboxStdoutChunkSchema, chatEventSharedSchema);\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 selectedSkillInfoSchema = z.object({\n id: z.string(),\n name: z.string(),\n});\n\nexport type SelectedSkillInfo = z.infer<typeof selectedSkillInfoSchema>;\n\nconst selectedSkillsChunkSchema = z.object({\n chunkType: z.literal(\"selectedSkills\"),\n selectedSkills: z.array(selectedSkillInfoSchema),\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 endOfStreamInputSchema,\n z.extend(interruptChunkSchema, chatEventSharedSchema),\n z.extend(conversationUpdateChunkSchema, chatEventSharedSchema),\n z.extend(jobUpdateChunkSchema, chatEventSharedSchema),\n z.extend(modelChunkSchema, chatEventSharedSchema),\n z.extend(selectedSkillsChunkSchema, chatEventSharedSchema),\n z.extend(sandboxProgressChunkSchema, chatEventSharedSchema),\n sandboxStdoutChatEventSchema,\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\n// endOfStream has no meaningful messageId on input, so no id on output\nconst endOfStreamOutputSchema = z.omit(chatEventOutputSharedSchema, { id: true });\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(endOfStreamOutputSchema, {\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: selectedSkillsChunkSchema,\n role: z.literal(\"agent\"),\n }),\n z.extend(chatEventOutputSharedSchema, {\n content: sandboxProgressChunkSchema,\n role: z.literal(\"agent\"),\n }),\n z.extend(chatEventOutputSharedSchema, {\n content: sandboxStdoutContentSchema,\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 if (v.chunkType === \"endOfStream\") {\n return {\n content: { chunkType: \"endOfStream\" },\n conversationId: v.conversationId,\n createdAt: Temporal.Instant.from(v.createdAt),\n modelName: v.modelName,\n modelProviderId: v.modelProviderId,\n role: \"agent\",\n runId: v.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 };\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 \"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 \"selectedSkills\":\n return {\n ...sharedProperties,\n content: {\n chunkType: \"selectedSkills\",\n selectedSkills: v.selectedSkills,\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 \"sandboxStdout\":\n return {\n ...sharedProperties,\n content: {\n callId: v.callId,\n chunkType: \"sandboxStdout\",\n isFinal: v.isFinal,\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 if (v.content.chunkType === \"endOfStream\") {\n return {\n chunkType: \"endOfStream\",\n conversationId: v.conversationId,\n createdAt: v.createdAt.toString(),\n modelName: v.modelName,\n modelProviderId: v.modelProviderId,\n runId: v.runId,\n } as const satisfies z.infer<typeof chatEventInputSchema>;\n }\n // Safe: endOfStream (the only variant without id) is handled by the early return above\n const id = (v as Extract<z.output<typeof chatEventOutputSchema>, { id: string }>).id;\n return {\n conversationId: v.conversationId,\n createdAt: v.createdAt.toString(),\n messageId: 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"]}
@@ -108,6 +108,21 @@ export declare class AgentConversation implements AgentConversationProperties {
108
108
  result: Record<string, unknown>;
109
109
  };
110
110
  role: "agent";
111
+ } | {
112
+ conversationId: string;
113
+ modelName: string;
114
+ modelProviderId: string;
115
+ runId: string;
116
+ createdAt: import("temporal-polyfill").Temporal.Instant;
117
+ id: string;
118
+ content: {
119
+ chunkType: "selectedSkills";
120
+ selectedSkills: {
121
+ id: string;
122
+ name: string;
123
+ }[];
124
+ };
125
+ role: "agent";
111
126
  } | {
112
127
  conversationId: string;
113
128
  modelName: string;
@@ -256,6 +271,21 @@ export declare class AgentConversation implements AgentConversationProperties {
256
271
  result: Record<string, unknown>;
257
272
  };
258
273
  role: "agent";
274
+ } | {
275
+ conversationId: string;
276
+ modelName: string;
277
+ modelProviderId: string;
278
+ runId: string;
279
+ createdAt: import("temporal-polyfill").Temporal.Instant;
280
+ id: string;
281
+ content: {
282
+ chunkType: "selectedSkills";
283
+ selectedSkills: {
284
+ id: string;
285
+ name: string;
286
+ }[];
287
+ };
288
+ role: "agent";
259
289
  } | {
260
290
  conversationId: string;
261
291
  modelName: string;