@dremio/js-sdk 0.58.0 → 0.60.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/cloud/ai/AIResource.d.ts +93 -13
- package/dist/enterprise/ai/AIResource.d.ts +93 -13
- package/dist/enterprise/ai/chat/UserChatMessage.d.ts +0 -2
- package/dist/enterprise/ai/chat/UserChatMessage.js +0 -1
- package/dist/enterprise/ai/chat/UserChatMessage.js.map +1 -1
- package/dist/enterprise/ai/chat/chatEventSchema.d.ts +26 -3
- package/dist/enterprise/ai/chat/chatEventSchema.js +61 -11
- package/dist/enterprise/ai/chat/chatEventSchema.js.map +1 -1
- package/dist/enterprise/ai/conversations/AgentConversation.d.ts +30 -4
- package/dist/enterprise/ai/conversations/createConversationMachine.d.ts +97 -13
- package/dist/enterprise/ai/conversations/createConversationMachine.js +80 -11
- package/dist/enterprise/ai/conversations/createConversationMachine.js.map +1 -1
- package/dist/enterprise/ai/conversations/methods/createConversation.d.ts +0 -1
- package/dist/enterprise/ai/conversations/methods/createConversation.js +0 -2
- package/dist/enterprise/ai/conversations/methods/createConversation.js.map +1 -1
- package/dist/enterprise/ai/conversations/methods/retrieveConversationHistory.d.ts +15 -2
- package/dist/enterprise/ai/conversations/reduceChatEvents.d.ts +1 -1
- package/dist/enterprise/ai/conversations/reduceChatEvents.js +4 -1
- package/dist/enterprise/ai/conversations/reduceChatEvents.js.map +1 -1
- package/dist/enterprise/catalog/CatalogObjects/EnterpriseDatasetCatalogObject.d.ts +7 -0
- package/dist/enterprise/catalog/CatalogObjects/EnterpriseDatasetCatalogObject.js +3 -0
- package/dist/enterprise/catalog/CatalogObjects/EnterpriseDatasetCatalogObject.js.map +1 -1
- package/dist-iife/cloud.js +150 -32
- package/dist-iife/enterprise.js +150 -32
- package/package.json +1 -1
|
@@ -57,6 +57,15 @@ const conversationUpdateChunkSchema = z.object({
|
|
|
57
57
|
const endOfStreamChunkSchema = z.object({
|
|
58
58
|
chunkType: z.literal("endOfStream"),
|
|
59
59
|
});
|
|
60
|
+
// endOfStream omits messageId: the backend sends it absent or as "", neither maps to a meaningful id
|
|
61
|
+
const endOfStreamInputSchema = z.object({
|
|
62
|
+
chunkType: z.literal("endOfStream"),
|
|
63
|
+
conversationId: z.string(),
|
|
64
|
+
createdAt: z.string().check(z.iso.datetime()),
|
|
65
|
+
modelName: z.string(),
|
|
66
|
+
modelProviderId: z.string(),
|
|
67
|
+
runId: z.string(),
|
|
68
|
+
});
|
|
60
69
|
const interruptChunkSchema = z.object({
|
|
61
70
|
chunkType: z.literal("interrupt"),
|
|
62
71
|
});
|
|
@@ -76,6 +85,14 @@ const sandboxProgressChunkSchema = z.object({
|
|
|
76
85
|
stepName: z.string(),
|
|
77
86
|
text: z.string(),
|
|
78
87
|
});
|
|
88
|
+
const sandboxStdoutChunkSchema = z.object({
|
|
89
|
+
callId: z.string().check(z.trim(), z.minLength(1)),
|
|
90
|
+
chunkType: z.literal("sandboxStdout"),
|
|
91
|
+
isFinal: z.boolean(),
|
|
92
|
+
text: z.string(),
|
|
93
|
+
});
|
|
94
|
+
const sandboxStdoutContentSchema = sandboxStdoutChunkSchema;
|
|
95
|
+
const sandboxStdoutChatEventSchema = z.extend(sandboxStdoutChunkSchema, chatEventSharedSchema);
|
|
79
96
|
const toolPlanSchema = z.record(z.string(), z.unknown());
|
|
80
97
|
const toolRequestChunkSchema = z.object({
|
|
81
98
|
arguments: z.record(z.string(), z.unknown()),
|
|
@@ -122,12 +139,13 @@ export const chatEventV1Schema = z.discriminatedUnion("chunkType", [
|
|
|
122
139
|
]);
|
|
123
140
|
const chatEventInputSchema = z.discriminatedUnion("chunkType", [
|
|
124
141
|
z.extend(errorChunkV2Schema, chatEventSharedSchema),
|
|
125
|
-
|
|
142
|
+
endOfStreamInputSchema,
|
|
126
143
|
z.extend(interruptChunkSchema, chatEventSharedSchema),
|
|
127
144
|
z.extend(conversationUpdateChunkSchema, chatEventSharedSchema),
|
|
128
145
|
z.extend(jobUpdateChunkSchema, chatEventSharedSchema),
|
|
129
146
|
z.extend(modelChunkSchema, chatEventSharedSchema),
|
|
130
147
|
z.extend(sandboxProgressChunkSchema, chatEventSharedSchema),
|
|
148
|
+
sandboxStdoutChatEventSchema,
|
|
131
149
|
z.extend(toolRequestChunkSchema, chatEventSharedSchema),
|
|
132
150
|
z.extend(toolResponseChunkSchema, chatEventSharedSchema),
|
|
133
151
|
z.extend(userMessageChunkSchema, chatEventSharedSchema),
|
|
@@ -136,13 +154,15 @@ const chatEventOutputSharedSchema = z.extend(z.omit(z.strictObject(chatEventShar
|
|
|
136
154
|
createdAt: z.instanceof(Temporal.Instant),
|
|
137
155
|
id: z.string(),
|
|
138
156
|
});
|
|
157
|
+
// endOfStream has no meaningful messageId on input, so no id on output
|
|
158
|
+
const endOfStreamOutputSchema = z.omit(chatEventOutputSharedSchema, { id: true });
|
|
139
159
|
const chatEventOutputSchema = z.union([
|
|
140
160
|
z.extend(chatEventOutputSharedSchema, {
|
|
141
161
|
content: conversationUpdateChunkSchema,
|
|
142
162
|
role: z.literal("agent"),
|
|
143
163
|
}),
|
|
144
164
|
z.extend(chatEventOutputSharedSchema, { content: errorChunkV2Schema, role: z.literal("agent") }),
|
|
145
|
-
z.extend(
|
|
165
|
+
z.extend(endOfStreamOutputSchema, {
|
|
146
166
|
content: endOfStreamChunkSchema,
|
|
147
167
|
role: z.literal("agent"),
|
|
148
168
|
}),
|
|
@@ -159,6 +179,10 @@ const chatEventOutputSchema = z.union([
|
|
|
159
179
|
content: sandboxProgressChunkSchema,
|
|
160
180
|
role: z.literal("agent"),
|
|
161
181
|
}),
|
|
182
|
+
z.extend(chatEventOutputSharedSchema, {
|
|
183
|
+
content: sandboxStdoutContentSchema,
|
|
184
|
+
role: z.literal("agent"),
|
|
185
|
+
}),
|
|
162
186
|
z.extend(chatEventOutputSharedSchema, {
|
|
163
187
|
content: toolRequestChunkSchema,
|
|
164
188
|
role: z.literal("agent"),
|
|
@@ -174,6 +198,17 @@ const chatEventOutputSchema = z.union([
|
|
|
174
198
|
]);
|
|
175
199
|
export const chatEventCodec = z.codec(chatEventInputSchema, chatEventOutputSchema, {
|
|
176
200
|
decode(v) {
|
|
201
|
+
if (v.chunkType === "endOfStream") {
|
|
202
|
+
return {
|
|
203
|
+
content: { chunkType: "endOfStream" },
|
|
204
|
+
conversationId: v.conversationId,
|
|
205
|
+
createdAt: Temporal.Instant.from(v.createdAt),
|
|
206
|
+
modelName: v.modelName,
|
|
207
|
+
modelProviderId: v.modelProviderId,
|
|
208
|
+
role: "agent",
|
|
209
|
+
runId: v.runId,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
177
212
|
const sharedProperties = {
|
|
178
213
|
conversationId: v.conversationId,
|
|
179
214
|
createdAt: Temporal.Instant.from(v.createdAt),
|
|
@@ -203,14 +238,6 @@ export const chatEventCodec = z.codec(chatEventInputSchema, chatEventOutputSchem
|
|
|
203
238
|
},
|
|
204
239
|
role: "agent",
|
|
205
240
|
};
|
|
206
|
-
case "endOfStream":
|
|
207
|
-
return {
|
|
208
|
-
...sharedProperties,
|
|
209
|
-
content: {
|
|
210
|
-
chunkType: "endOfStream",
|
|
211
|
-
},
|
|
212
|
-
role: "agent",
|
|
213
|
-
};
|
|
214
241
|
case "interrupt":
|
|
215
242
|
return {
|
|
216
243
|
...sharedProperties,
|
|
@@ -251,6 +278,17 @@ export const chatEventCodec = z.codec(chatEventInputSchema, chatEventOutputSchem
|
|
|
251
278
|
},
|
|
252
279
|
role: "agent",
|
|
253
280
|
};
|
|
281
|
+
case "sandboxStdout":
|
|
282
|
+
return {
|
|
283
|
+
...sharedProperties,
|
|
284
|
+
content: {
|
|
285
|
+
callId: v.callId,
|
|
286
|
+
chunkType: "sandboxStdout",
|
|
287
|
+
isFinal: v.isFinal,
|
|
288
|
+
text: v.text,
|
|
289
|
+
},
|
|
290
|
+
role: "agent",
|
|
291
|
+
};
|
|
254
292
|
case "toolRequest":
|
|
255
293
|
return {
|
|
256
294
|
...sharedProperties,
|
|
@@ -287,10 +325,22 @@ export const chatEventCodec = z.codec(chatEventInputSchema, chatEventOutputSchem
|
|
|
287
325
|
}
|
|
288
326
|
},
|
|
289
327
|
encode(v) {
|
|
328
|
+
if (v.content.chunkType === "endOfStream") {
|
|
329
|
+
return {
|
|
330
|
+
chunkType: "endOfStream",
|
|
331
|
+
conversationId: v.conversationId,
|
|
332
|
+
createdAt: v.createdAt.toString(),
|
|
333
|
+
modelName: v.modelName,
|
|
334
|
+
modelProviderId: v.modelProviderId,
|
|
335
|
+
runId: v.runId,
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
// Safe: endOfStream (the only variant without id) is handled by the early return above
|
|
339
|
+
const id = v.id;
|
|
290
340
|
return {
|
|
291
341
|
conversationId: v.conversationId,
|
|
292
342
|
createdAt: v.createdAt.toString(),
|
|
293
|
-
messageId:
|
|
343
|
+
messageId: id,
|
|
294
344
|
modelName: v.modelName,
|
|
295
345
|
modelProviderId: v.modelProviderId,
|
|
296
346
|
runId: v.runId,
|
|
@@ -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,C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AAS;wBACtB,MAAM,EAAE,CAAC,CAAC,MAAM;wBAChB,SAAS,EAAE,aAAa;wBACxB,UAAU,EAAE,CAAC,CAAC,UAAU;wBACxB,IAAI,EAAE,CAAC,CAAC,IAAI;wBACZ,WAAW,EAAE,CAAC,CAAC,WAAW;wBAC1B,eAAe,EAAE,CAAC,CAAC,eAAe;wBAClC,UAAU,EAAE,CAAC,CAAC,UAAU;qBACzB;oBACD,IAAI,EAAE,OAAO;iBAC4C,CAAC;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"]}
|
|
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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AC,CAAC,cAAc;gBAChC,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,QAAQ,EAAE;gBACjC,SAAS,EAAE,CAAC,CAAC,SAAS;gBACtB,eAAe,EAAE,CAAC,CAAC,eAAe;gBAClC,KAAK,EAAE,CAAC,CAAC,KAAK;aACyC,CAAC;QAC5D,CAAC;QACD,uFAAuF;QACvF,MAAM,EAAE,GAAI,CAAqE,CAAC,EAAE,CAAC;QACrF,OAAO;YACL,cAAc,EAAE,CAAC,CAAC,cAAc;YAChC,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,QAAQ,EAAE;YACjC,SAAS,EAAE,EAAE;YACb,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\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"]}
|
|
@@ -60,12 +60,11 @@ export declare class AgentConversation implements AgentConversationProperties {
|
|
|
60
60
|
};
|
|
61
61
|
role: "agent";
|
|
62
62
|
} | {
|
|
63
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
63
64
|
conversationId: string;
|
|
64
65
|
modelName: string;
|
|
65
66
|
modelProviderId: string;
|
|
66
67
|
runId: string;
|
|
67
|
-
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
68
|
-
id: string;
|
|
69
68
|
content: {
|
|
70
69
|
chunkType: "endOfStream";
|
|
71
70
|
};
|
|
@@ -122,6 +121,20 @@ export declare class AgentConversation implements AgentConversationProperties {
|
|
|
122
121
|
text: string;
|
|
123
122
|
};
|
|
124
123
|
role: "agent";
|
|
124
|
+
} | {
|
|
125
|
+
conversationId: string;
|
|
126
|
+
modelName: string;
|
|
127
|
+
modelProviderId: string;
|
|
128
|
+
runId: string;
|
|
129
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
130
|
+
id: string;
|
|
131
|
+
content: {
|
|
132
|
+
callId: string;
|
|
133
|
+
chunkType: "sandboxStdout";
|
|
134
|
+
isFinal: boolean;
|
|
135
|
+
text: string;
|
|
136
|
+
};
|
|
137
|
+
role: "agent";
|
|
125
138
|
} | {
|
|
126
139
|
conversationId: string;
|
|
127
140
|
modelName: string;
|
|
@@ -195,12 +208,11 @@ export declare class AgentConversation implements AgentConversationProperties {
|
|
|
195
208
|
};
|
|
196
209
|
role: "agent";
|
|
197
210
|
} | {
|
|
211
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
198
212
|
conversationId: string;
|
|
199
213
|
modelName: string;
|
|
200
214
|
modelProviderId: string;
|
|
201
215
|
runId: string;
|
|
202
|
-
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
203
|
-
id: string;
|
|
204
216
|
content: {
|
|
205
217
|
chunkType: "endOfStream";
|
|
206
218
|
};
|
|
@@ -257,6 +269,20 @@ export declare class AgentConversation implements AgentConversationProperties {
|
|
|
257
269
|
text: string;
|
|
258
270
|
};
|
|
259
271
|
role: "agent";
|
|
272
|
+
} | {
|
|
273
|
+
conversationId: string;
|
|
274
|
+
modelName: string;
|
|
275
|
+
modelProviderId: string;
|
|
276
|
+
runId: string;
|
|
277
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
278
|
+
id: string;
|
|
279
|
+
content: {
|
|
280
|
+
callId: string;
|
|
281
|
+
chunkType: "sandboxStdout";
|
|
282
|
+
isFinal: boolean;
|
|
283
|
+
text: string;
|
|
284
|
+
};
|
|
285
|
+
role: "agent";
|
|
260
286
|
} | {
|
|
261
287
|
conversationId: string;
|
|
262
288
|
modelName: string;
|
|
@@ -12,6 +12,9 @@ export type ConversationMachineContext = {
|
|
|
12
12
|
currentRunId?: string | null;
|
|
13
13
|
lastError?: unknown;
|
|
14
14
|
messageAttempt?: UserChatMessage;
|
|
15
|
+
receivedEndOfStream: boolean;
|
|
16
|
+
streamRetryCount: number;
|
|
17
|
+
userRequestedStop: boolean;
|
|
15
18
|
};
|
|
16
19
|
export type ConversationMachineEvents = {
|
|
17
20
|
type: "STOP_RUN";
|
|
@@ -33,6 +36,7 @@ export type ConversationMachineEmitted = {
|
|
|
33
36
|
type: "conversationCreated";
|
|
34
37
|
id: string;
|
|
35
38
|
};
|
|
39
|
+
export declare const MAX_STREAM_RETRIES = 5;
|
|
36
40
|
export declare const createConversationMachine: (config: SonarV4Config) => import("xstate").StateMachine<ConversationMachineContext, {
|
|
37
41
|
type: "STOP_RUN";
|
|
38
42
|
} | {
|
|
@@ -95,12 +99,11 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
95
99
|
};
|
|
96
100
|
role: "agent";
|
|
97
101
|
} | {
|
|
102
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
98
103
|
conversationId: string;
|
|
99
104
|
modelName: string;
|
|
100
105
|
modelProviderId: string;
|
|
101
106
|
runId: string;
|
|
102
|
-
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
103
|
-
id: string;
|
|
104
107
|
content: {
|
|
105
108
|
chunkType: "endOfStream";
|
|
106
109
|
};
|
|
@@ -157,6 +160,20 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
157
160
|
text: string;
|
|
158
161
|
};
|
|
159
162
|
role: "agent";
|
|
163
|
+
} | {
|
|
164
|
+
conversationId: string;
|
|
165
|
+
modelName: string;
|
|
166
|
+
modelProviderId: string;
|
|
167
|
+
runId: string;
|
|
168
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
169
|
+
id: string;
|
|
170
|
+
content: {
|
|
171
|
+
callId: string;
|
|
172
|
+
chunkType: "sandboxStdout";
|
|
173
|
+
isFinal: boolean;
|
|
174
|
+
text: string;
|
|
175
|
+
};
|
|
176
|
+
role: "agent";
|
|
160
177
|
} | {
|
|
161
178
|
conversationId: string;
|
|
162
179
|
modelName: string;
|
|
@@ -244,12 +261,11 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
244
261
|
};
|
|
245
262
|
role: "agent";
|
|
246
263
|
} | {
|
|
264
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
247
265
|
conversationId: string;
|
|
248
266
|
modelName: string;
|
|
249
267
|
modelProviderId: string;
|
|
250
268
|
runId: string;
|
|
251
|
-
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
252
|
-
id: string;
|
|
253
269
|
content: {
|
|
254
270
|
chunkType: "endOfStream";
|
|
255
271
|
};
|
|
@@ -306,6 +322,20 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
306
322
|
text: string;
|
|
307
323
|
};
|
|
308
324
|
role: "agent";
|
|
325
|
+
} | {
|
|
326
|
+
conversationId: string;
|
|
327
|
+
modelName: string;
|
|
328
|
+
modelProviderId: string;
|
|
329
|
+
runId: string;
|
|
330
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
331
|
+
id: string;
|
|
332
|
+
content: {
|
|
333
|
+
callId: string;
|
|
334
|
+
chunkType: "sandboxStdout";
|
|
335
|
+
isFinal: boolean;
|
|
336
|
+
text: string;
|
|
337
|
+
};
|
|
338
|
+
role: "agent";
|
|
309
339
|
} | {
|
|
310
340
|
conversationId: string;
|
|
311
341
|
modelName: string;
|
|
@@ -400,12 +430,11 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
400
430
|
};
|
|
401
431
|
role: "agent";
|
|
402
432
|
} | {
|
|
433
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
403
434
|
conversationId: string;
|
|
404
435
|
modelName: string;
|
|
405
436
|
modelProviderId: string;
|
|
406
437
|
runId: string;
|
|
407
|
-
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
408
|
-
id: string;
|
|
409
438
|
content: {
|
|
410
439
|
chunkType: "endOfStream";
|
|
411
440
|
};
|
|
@@ -462,6 +491,20 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
462
491
|
text: string;
|
|
463
492
|
};
|
|
464
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
|
+
callId: string;
|
|
503
|
+
chunkType: "sandboxStdout";
|
|
504
|
+
isFinal: boolean;
|
|
505
|
+
text: string;
|
|
506
|
+
};
|
|
507
|
+
role: "agent";
|
|
465
508
|
} | {
|
|
466
509
|
conversationId: string;
|
|
467
510
|
modelName: string;
|
|
@@ -573,12 +616,11 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
573
616
|
};
|
|
574
617
|
role: "agent";
|
|
575
618
|
} | {
|
|
619
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
576
620
|
conversationId: string;
|
|
577
621
|
modelName: string;
|
|
578
622
|
modelProviderId: string;
|
|
579
623
|
runId: string;
|
|
580
|
-
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
581
|
-
id: string;
|
|
582
624
|
content: {
|
|
583
625
|
chunkType: "endOfStream";
|
|
584
626
|
};
|
|
@@ -635,6 +677,20 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
635
677
|
text: string;
|
|
636
678
|
};
|
|
637
679
|
role: "agent";
|
|
680
|
+
} | {
|
|
681
|
+
conversationId: string;
|
|
682
|
+
modelName: string;
|
|
683
|
+
modelProviderId: string;
|
|
684
|
+
runId: string;
|
|
685
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
686
|
+
id: string;
|
|
687
|
+
content: {
|
|
688
|
+
callId: string;
|
|
689
|
+
chunkType: "sandboxStdout";
|
|
690
|
+
isFinal: boolean;
|
|
691
|
+
text: string;
|
|
692
|
+
};
|
|
693
|
+
role: "agent";
|
|
638
694
|
} | {
|
|
639
695
|
conversationId: string;
|
|
640
696
|
modelName: string;
|
|
@@ -726,12 +782,11 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
726
782
|
};
|
|
727
783
|
role: "agent";
|
|
728
784
|
} | {
|
|
785
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
729
786
|
conversationId: string;
|
|
730
787
|
modelName: string;
|
|
731
788
|
modelProviderId: string;
|
|
732
789
|
runId: string;
|
|
733
|
-
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
734
|
-
id: string;
|
|
735
790
|
content: {
|
|
736
791
|
chunkType: "endOfStream";
|
|
737
792
|
};
|
|
@@ -788,6 +843,20 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
788
843
|
text: string;
|
|
789
844
|
};
|
|
790
845
|
role: "agent";
|
|
846
|
+
} | {
|
|
847
|
+
conversationId: string;
|
|
848
|
+
modelName: string;
|
|
849
|
+
modelProviderId: string;
|
|
850
|
+
runId: string;
|
|
851
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
852
|
+
id: string;
|
|
853
|
+
content: {
|
|
854
|
+
callId: string;
|
|
855
|
+
chunkType: "sandboxStdout";
|
|
856
|
+
isFinal: boolean;
|
|
857
|
+
text: string;
|
|
858
|
+
};
|
|
859
|
+
role: "agent";
|
|
791
860
|
} | {
|
|
792
861
|
conversationId: string;
|
|
793
862
|
modelName: string;
|
|
@@ -894,12 +963,11 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
894
963
|
};
|
|
895
964
|
role: "agent";
|
|
896
965
|
} | {
|
|
966
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
897
967
|
conversationId: string;
|
|
898
968
|
modelName: string;
|
|
899
969
|
modelProviderId: string;
|
|
900
970
|
runId: string;
|
|
901
|
-
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
902
|
-
id: string;
|
|
903
971
|
content: {
|
|
904
972
|
chunkType: "endOfStream";
|
|
905
973
|
};
|
|
@@ -956,6 +1024,20 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
956
1024
|
text: string;
|
|
957
1025
|
};
|
|
958
1026
|
role: "agent";
|
|
1027
|
+
} | {
|
|
1028
|
+
conversationId: string;
|
|
1029
|
+
modelName: string;
|
|
1030
|
+
modelProviderId: string;
|
|
1031
|
+
runId: string;
|
|
1032
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
1033
|
+
id: string;
|
|
1034
|
+
content: {
|
|
1035
|
+
callId: string;
|
|
1036
|
+
chunkType: "sandboxStdout";
|
|
1037
|
+
isFinal: boolean;
|
|
1038
|
+
text: string;
|
|
1039
|
+
};
|
|
1040
|
+
role: "agent";
|
|
959
1041
|
} | {
|
|
960
1042
|
conversationId: string;
|
|
961
1043
|
modelName: string;
|
|
@@ -1006,7 +1088,7 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
1006
1088
|
runId: string;
|
|
1007
1089
|
}, import("xstate").EventObject>;
|
|
1008
1090
|
id: string | undefined;
|
|
1009
|
-
}, never, never,
|
|
1091
|
+
}, never, never, "STREAM_RETRY_DELAY", "uninitialized" | "creating_conversation" | "retrieving_history" | "idle" | "submitting_message" | "retrieve_history_failed" | "stream_interrupted" | "stream_recovery_failed" | "submitting_message_failed" | {
|
|
1010
1092
|
streaming: "monitoring_replies" | "stopping";
|
|
1011
1093
|
}, string, ConversationMachineInput, import("xstate").NonReducibleUnknown, {
|
|
1012
1094
|
type: "apiError";
|
|
@@ -1024,6 +1106,8 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
|
|
|
1024
1106
|
readonly idle: {};
|
|
1025
1107
|
readonly retrieve_history_failed: {};
|
|
1026
1108
|
readonly retrieving_history: {};
|
|
1109
|
+
readonly stream_interrupted: {};
|
|
1110
|
+
readonly stream_recovery_failed: {};
|
|
1027
1111
|
readonly streaming: {
|
|
1028
1112
|
states: {
|
|
1029
1113
|
readonly monitoring_replies: {};
|