@dremio/js-sdk 0.45.0 → 0.45.2

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.
@@ -96,7 +96,7 @@ export declare class AIResource {
96
96
  modelProviderId: string | null;
97
97
  modifiedAt: import("temporal-polyfill").Temporal.Instant;
98
98
  tag: string;
99
- title: string;
99
+ title: string | null;
100
100
  }, {
101
101
  conversationId: string;
102
102
  }, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<{
@@ -204,7 +204,7 @@ export declare class AIResource {
204
204
  modelProviderId: string | null;
205
205
  modifiedAt: import("temporal-polyfill").Temporal.Instant;
206
206
  tag: string;
207
- title: string;
207
+ title: string | null;
208
208
  };
209
209
  history: {
210
210
  data: ({
@@ -312,7 +312,7 @@ export declare class AIResource {
312
312
  modelProviderId: string | null;
313
313
  modifiedAt: import("temporal-polyfill").Temporal.Instant;
314
314
  tag: string;
315
- title: string;
315
+ title: string | null;
316
316
  };
317
317
  currentRunId: string;
318
318
  }, {
@@ -435,7 +435,7 @@ export declare class AIResource {
435
435
  modelProviderId: string | null;
436
436
  modifiedAt: import("temporal-polyfill").Temporal.Instant;
437
437
  tag: string;
438
- title: string;
438
+ title: string | null;
439
439
  }, {
440
440
  conversationId: string;
441
441
  }, import("xstate").EventObject>;
@@ -551,7 +551,7 @@ export declare class AIResource {
551
551
  modelProviderId: string | null;
552
552
  modifiedAt: import("temporal-polyfill").Temporal.Instant;
553
553
  tag: string;
554
- title: string;
554
+ title: string | null;
555
555
  };
556
556
  history: {
557
557
  data: ({
@@ -663,7 +663,7 @@ export declare class AIResource {
663
663
  modelProviderId: string | null;
664
664
  modifiedAt: import("temporal-polyfill").Temporal.Instant;
665
665
  tag: string;
666
- title: string;
666
+ title: string | null;
667
667
  };
668
668
  currentRunId: string;
669
669
  }, {
@@ -823,7 +823,7 @@ export declare class AIResource {
823
823
  modelProviderId: string | null;
824
824
  modifiedAt: import("temporal-polyfill").Temporal.Instant;
825
825
  tag: string;
826
- title: string;
826
+ title: string | null;
827
827
  }, HttpError>;
828
828
  retrieveConversationHistory(id: string): {
829
829
  data(): AsyncGenerator<ChatEvent, void, HttpError>;
@@ -38,7 +38,7 @@ export declare class AIResource {
38
38
  modelProviderId: string | null;
39
39
  modifiedAt: import("temporal-polyfill").Temporal.Instant;
40
40
  tag: string;
41
- title: string;
41
+ title: string | null;
42
42
  }, {
43
43
  conversationId: string;
44
44
  }, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<{
@@ -146,7 +146,7 @@ export declare class AIResource {
146
146
  modelProviderId: string | null;
147
147
  modifiedAt: import("temporal-polyfill").Temporal.Instant;
148
148
  tag: string;
149
- title: string;
149
+ title: string | null;
150
150
  };
151
151
  history: {
152
152
  data: ({
@@ -254,7 +254,7 @@ export declare class AIResource {
254
254
  modelProviderId: string | null;
255
255
  modifiedAt: import("temporal-polyfill").Temporal.Instant;
256
256
  tag: string;
257
- title: string;
257
+ title: string | null;
258
258
  };
259
259
  currentRunId: string;
260
260
  }, {
@@ -377,7 +377,7 @@ export declare class AIResource {
377
377
  modelProviderId: string | null;
378
378
  modifiedAt: import("temporal-polyfill").Temporal.Instant;
379
379
  tag: string;
380
- title: string;
380
+ title: string | null;
381
381
  }, {
382
382
  conversationId: string;
383
383
  }, import("xstate").EventObject>;
@@ -493,7 +493,7 @@ export declare class AIResource {
493
493
  modelProviderId: string | null;
494
494
  modifiedAt: import("temporal-polyfill").Temporal.Instant;
495
495
  tag: string;
496
- title: string;
496
+ title: string | null;
497
497
  };
498
498
  history: {
499
499
  data: ({
@@ -605,7 +605,7 @@ export declare class AIResource {
605
605
  modelProviderId: string | null;
606
606
  modifiedAt: import("temporal-polyfill").Temporal.Instant;
607
607
  tag: string;
608
- title: string;
608
+ title: string | null;
609
609
  };
610
610
  currentRunId: string;
611
611
  }, {
@@ -20,7 +20,7 @@ export declare class AgentConversation implements AgentConversationProperties {
20
20
  get modelProviderId(): string | null;
21
21
  get modifiedAt(): import("temporal-polyfill").Temporal.Instant;
22
22
  get tag(): string;
23
- get title(): string;
23
+ get title(): string | null;
24
24
  clone(): AgentConversation;
25
25
  /**
26
26
  * Permanently deletes this conversation.
@@ -1 +1 @@
1
- {"version":3,"file":"AgentConversation.js","sourceRoot":"","sources":["../../../../src/enterprise/ai/conversations/AgentConversation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAC/F,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AAEvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAKzD;;GAEG;AACH,MAAM,OAAO,iBAAiB;IACnB,OAAO,CAAgB;IACvB,SAAS,CAA2C;IACpD,EAAE,CAAoC;IAC/C,aAAa,CAA8C;IAC3D,UAAU,CAA2C;IACrD,gBAAgB,C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AAU,KAAK,SAAS,EAAE,CAAC;YACxC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;QAC3C,CAAC;QAED,IAAI,UAAU,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC;QAC7B,CAAC;QAED,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YACnC,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC;QACjC,CAAC;IACH,CAAC;IAED,MAAM,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC3C,MAAM,CAAC,YAAY,GAAG,wBAAwB,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 * as z from \"zod/mini\";\nimport { conversationPropertiesCodec } from \"./conversationPropertiesCodec.ts\";\nimport type { SonarV4Config } from \"../../../common/Config.ts\";\nimport { createExchangeRun } from \"./methods/createExchangeRun.ts\";\nimport { deleteConversation } from \"./methods/deleteConversation.ts\";\nimport { conversationUpdateSchema, updateConversation } from \"./methods/updateConversation.ts\";\nimport { map } from \"rxjs\";\nimport { stopExchangeRun } from \"./methods/stopExchangeRun.ts\";\nimport { chatEventCodec } from \"../chat/chatEventSchema.ts\";\nimport { fromTextEventStream } from \"../../../common/fromTextEventStream.ts\";\nimport { streamRunEvents } from \"./methods/streamRunEvents.ts\";\nimport { retrieveConversationHistory } from \"./methods/retrieveConversationHistory.ts\";\nimport type { SignalParam } from \"../../../common/Params.ts\";\nimport { reduceChatEvents } from \"./reduceChatEvents.ts\";\nimport type { ConflictResolver } from \"../../../common/ConflictResolver.ts\";\nimport { AsyncResult } from \"ts-results-es\";\nimport { retrieveConversation } from \"./methods/retrieveConversation.ts\";\nimport { isProblem } from \"../../../common/HttpError.ts\";\nimport type { createConversationCodec } from \"./methods/createConversation.ts\";\n\nexport type AgentConversationProperties = z.output<typeof conversationPropertiesCodec>;\n\n/**\n * Represents a saved conversation with the Dremio AI Agent.\n */\nexport class AgentConversation implements AgentConversationProperties {\n readonly #config: SonarV4Config;\n readonly createdAt: AgentConversationProperties[\"createdAt\"];\n readonly id: AgentConversationProperties[\"id\"];\n #currentRunId: AgentConversationProperties[\"currentRunId\"];\n #modelName: AgentConversationProperties[\"modelName\"];\n #modelProviderId: AgentConversationProperties[\"modelProviderId\"];\n #modifiedAt: AgentConversationProperties[\"modifiedAt\"];\n #tag: string;\n #title: string;\n\n constructor(config: SonarV4Config, properties: AgentConversationProperties) {\n this.#config = config;\n this.createdAt = properties.createdAt;\n this.id = properties.id;\n this.#currentRunId = properties.currentRunId;\n this.#modelName = properties.modelName;\n this.#modelProviderId = properties.modelProviderId;\n this.#modifiedAt = properties.modifiedAt;\n this.#tag = properties.tag;\n this.#title = properties.title;\n }\n\n get currentRunId() {\n return this.#currentRunId;\n }\n\n get modelName() {\n return this.#modelName;\n }\n\n get modelProviderId() {\n return this.#modelProviderId;\n }\n\n get modifiedAt() {\n return this.#modifiedAt;\n }\n\n get tag() {\n return this.#tag;\n }\n\n get title() {\n return this.#title;\n }\n\n clone() {\n return new AgentConversation(this.#config, this);\n }\n\n /**\n * Permanently deletes this conversation.\n */\n delete() {\n return deleteConversation(this.#config)(this.id);\n }\n\n /**\n * Patches properties for this `AgentConversation`, mutating instance properties after\n * a successful commit.\n */\n update(\n properties: z.infer<typeof AgentConversation.updateSchema>,\n options: {\n onConflict?: ConflictResolver<\n AgentConversationProperties,\n z.infer<typeof AgentConversation.updateSchema>\n >;\n } = {},\n ) {\n const { onConflict = () => null } = options;\n return new AsyncResult(\n (async () => {\n const attempt = await updateConversation(this.#config)(this.id, this.#tag, properties).map(\n (properties) => {\n this.#updateProperties(properties);\n },\n );\n\n if (\n attempt.isErr() &&\n isProblem(attempt.error.body) &&\n attempt.error.body.title === \"https://api.dremio.dev/problems/concurrent-modification\"\n ) {\n const remoteResult = await retrieveConversation(this.#config)(this.id);\n if (remoteResult.isOk()) {\n const remote = new AgentConversation(this.#config, remoteResult.value);\n const resolved = await onConflict(this.toJSON(), remote.toJSON(), properties);\n if (resolved !== null) {\n return updateConversation(this.#config)(this.id, remote.tag, resolved).map(\n (properties) => {\n this.#updateProperties(properties);\n },\n );\n }\n }\n }\n\n return attempt;\n })(),\n );\n }\n\n history({ signal }: SignalParam = {}) {\n return retrieveConversationHistory(this.#config)(this.id, { signal }).map(\n (response) => response.data,\n );\n }\n\n runEvents$(runId: string) {\n return fromTextEventStream(({ signal }) =>\n streamRunEvents(this.#config)({ conversationId: this.id, runId }, { signal }),\n ).pipe(\n map((event) =>\n z.decode(chatEventCodec, JSON.parse(event.data) as z.input<typeof chatEventCodec>),\n ),\n );\n }\n\n /**\n * Sends a message to the Agent, initiating a new run process.\n * @returns An `AsyncResult` containing the `runId` for the newly created run.\n */\n startRun(properties: z.input<typeof createConversationCodec>) {\n const asyncResult = createExchangeRun(this.#config)(this.id, properties);\n\n asyncResult\n .then((result) => {\n if (result.isOk()) {\n this.#updateProperties(result.value.conversationProperties);\n }\n })\n .catch(() => {});\n\n return asyncResult.map((properties) => properties.currentRunId);\n }\n\n /**\n * Only a single run can be active for a conversation, so for now\n * this method is kept private.\n */\n stopRun(id: string) {\n const asyncResult = stopExchangeRun(this.#config)(this.id, id);\n\n asyncResult\n .then((result) => {\n if (result.isOk() && this.#currentRunId === id) {\n this.#currentRunId = null;\n }\n })\n .catch(() => {});\n\n return asyncResult;\n }\n\n toJSON(): AgentConversationProperties {\n return {\n createdAt: this.createdAt,\n currentRunId: this.currentRunId,\n id: this.id,\n modelName: this.modelName,\n modelProviderId: this.modelProviderId,\n modifiedAt: this.modifiedAt,\n tag: this.tag,\n title: this.title,\n };\n }\n\n #updateProperties(properties: Partial<Omit<AgentConversationProperties, \"createdAt\" | \"id\">>) {\n if (properties.currentRunId !== undefined) {\n this.#currentRunId = properties.currentRunId;\n }\n\n if (properties.modelName !== undefined) {\n this.#modelName = properties.modelName;\n }\n\n if (properties.modelProviderId !== undefined) {\n this.#modelProviderId = properties.modelProviderId;\n }\n\n if (properties.modifiedAt !== undefined) {\n this.#modifiedAt = properties.modifiedAt;\n }\n\n if (properties.tag !== undefined) {\n this.#tag = properties.tag;\n }\n\n if (properties.title !== undefined) {\n this.#title = properties.title;\n }\n }\n\n static reduceChatEvents = reduceChatEvents;\n static updateSchema = conversationUpdateSchema;\n}\n"]}
1
+ {"version":3,"file":"AgentConversation.js","sourceRoot":"","sources":["../../../../src/enterprise/ai/conversations/AgentConversation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAC/F,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AAEvF,OAAO,EAAE,gBAAgB,EAAE,MAA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IAAI,CAAC,aAAa,GAAG,UAAU,CAAC,YAAY,CAAC;QAC/C,CAAC;QAED,IAAI,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YACvC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,SAAS,CAAC;QACzC,CAAC;QAED,IAAI,UAAU,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;YAC7C,IAAI,CAAC,gBAAgB,GAAG,UAAU,CAAC,eAAe,CAAC;QACrD,CAAC;QAED,IAAI,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YACxC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;QAC3C,CAAC;QAED,IAAI,UAAU,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC;QAC7B,CAAC;QAED,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YACnC,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC;QACjC,CAAC;IACH,CAAC;IAED,MAAM,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC3C,MAAM,CAAC,YAAY,GAAG,wBAAwB,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 * as z from \"zod/mini\";\nimport { conversationPropertiesCodec } from \"./conversationPropertiesCodec.ts\";\nimport type { SonarV4Config } from \"../../../common/Config.ts\";\nimport { createExchangeRun } from \"./methods/createExchangeRun.ts\";\nimport { deleteConversation } from \"./methods/deleteConversation.ts\";\nimport { conversationUpdateSchema, updateConversation } from \"./methods/updateConversation.ts\";\nimport { map } from \"rxjs\";\nimport { stopExchangeRun } from \"./methods/stopExchangeRun.ts\";\nimport { chatEventCodec } from \"../chat/chatEventSchema.ts\";\nimport { fromTextEventStream } from \"../../../common/fromTextEventStream.ts\";\nimport { streamRunEvents } from \"./methods/streamRunEvents.ts\";\nimport { retrieveConversationHistory } from \"./methods/retrieveConversationHistory.ts\";\nimport type { SignalParam } from \"../../../common/Params.ts\";\nimport { reduceChatEvents } from \"./reduceChatEvents.ts\";\nimport type { ConflictResolver } from \"../../../common/ConflictResolver.ts\";\nimport { AsyncResult } from \"ts-results-es\";\nimport { retrieveConversation } from \"./methods/retrieveConversation.ts\";\nimport { isProblem } from \"../../../common/HttpError.ts\";\nimport type { createConversationCodec } from \"./methods/createConversation.ts\";\n\nexport type AgentConversationProperties = z.output<typeof conversationPropertiesCodec>;\n\n/**\n * Represents a saved conversation with the Dremio AI Agent.\n */\nexport class AgentConversation implements AgentConversationProperties {\n readonly #config: SonarV4Config;\n readonly createdAt: AgentConversationProperties[\"createdAt\"];\n readonly id: AgentConversationProperties[\"id\"];\n #currentRunId: AgentConversationProperties[\"currentRunId\"];\n #modelName: AgentConversationProperties[\"modelName\"];\n #modelProviderId: AgentConversationProperties[\"modelProviderId\"];\n #modifiedAt: AgentConversationProperties[\"modifiedAt\"];\n #tag: string;\n #title: string | null;\n\n constructor(config: SonarV4Config, properties: AgentConversationProperties) {\n this.#config = config;\n this.createdAt = properties.createdAt;\n this.id = properties.id;\n this.#currentRunId = properties.currentRunId;\n this.#modelName = properties.modelName;\n this.#modelProviderId = properties.modelProviderId;\n this.#modifiedAt = properties.modifiedAt;\n this.#tag = properties.tag;\n this.#title = properties.title;\n }\n\n get currentRunId() {\n return this.#currentRunId;\n }\n\n get modelName() {\n return this.#modelName;\n }\n\n get modelProviderId() {\n return this.#modelProviderId;\n }\n\n get modifiedAt() {\n return this.#modifiedAt;\n }\n\n get tag() {\n return this.#tag;\n }\n\n get title() {\n return this.#title;\n }\n\n clone() {\n return new AgentConversation(this.#config, this);\n }\n\n /**\n * Permanently deletes this conversation.\n */\n delete() {\n return deleteConversation(this.#config)(this.id);\n }\n\n /**\n * Patches properties for this `AgentConversation`, mutating instance properties after\n * a successful commit.\n */\n update(\n properties: z.infer<typeof AgentConversation.updateSchema>,\n options: {\n onConflict?: ConflictResolver<\n AgentConversationProperties,\n z.infer<typeof AgentConversation.updateSchema>\n >;\n } = {},\n ) {\n const { onConflict = () => null } = options;\n return new AsyncResult(\n (async () => {\n const attempt = await updateConversation(this.#config)(this.id, this.#tag, properties).map(\n (properties) => {\n this.#updateProperties(properties);\n },\n );\n\n if (\n attempt.isErr() &&\n isProblem(attempt.error.body) &&\n attempt.error.body.title === \"https://api.dremio.dev/problems/concurrent-modification\"\n ) {\n const remoteResult = await retrieveConversation(this.#config)(this.id);\n if (remoteResult.isOk()) {\n const remote = new AgentConversation(this.#config, remoteResult.value);\n const resolved = await onConflict(this.toJSON(), remote.toJSON(), properties);\n if (resolved !== null) {\n return updateConversation(this.#config)(this.id, remote.tag, resolved).map(\n (properties) => {\n this.#updateProperties(properties);\n },\n );\n }\n }\n }\n\n return attempt;\n })(),\n );\n }\n\n history({ signal }: SignalParam = {}) {\n return retrieveConversationHistory(this.#config)(this.id, { signal }).map(\n (response) => response.data,\n );\n }\n\n runEvents$(runId: string) {\n return fromTextEventStream(({ signal }) =>\n streamRunEvents(this.#config)({ conversationId: this.id, runId }, { signal }),\n ).pipe(\n map((event) =>\n z.decode(chatEventCodec, JSON.parse(event.data) as z.input<typeof chatEventCodec>),\n ),\n );\n }\n\n /**\n * Sends a message to the Agent, initiating a new run process.\n * @returns An `AsyncResult` containing the `runId` for the newly created run.\n */\n startRun(properties: z.input<typeof createConversationCodec>) {\n const asyncResult = createExchangeRun(this.#config)(this.id, properties);\n\n asyncResult\n .then((result) => {\n if (result.isOk()) {\n this.#updateProperties(result.value.conversationProperties);\n }\n })\n .catch(() => {});\n\n return asyncResult.map((properties) => properties.currentRunId);\n }\n\n /**\n * Only a single run can be active for a conversation, so for now\n * this method is kept private.\n */\n stopRun(id: string) {\n const asyncResult = stopExchangeRun(this.#config)(this.id, id);\n\n asyncResult\n .then((result) => {\n if (result.isOk() && this.#currentRunId === id) {\n this.#currentRunId = null;\n }\n })\n .catch(() => {});\n\n return asyncResult;\n }\n\n toJSON(): AgentConversationProperties {\n return {\n createdAt: this.createdAt,\n currentRunId: this.currentRunId,\n id: this.id,\n modelName: this.modelName,\n modelProviderId: this.modelProviderId,\n modifiedAt: this.modifiedAt,\n tag: this.tag,\n title: this.title,\n };\n }\n\n #updateProperties(properties: Partial<Omit<AgentConversationProperties, \"createdAt\" | \"id\">>) {\n if (properties.currentRunId !== undefined) {\n this.#currentRunId = properties.currentRunId;\n }\n\n if (properties.modelName !== undefined) {\n this.#modelName = properties.modelName;\n }\n\n if (properties.modelProviderId !== undefined) {\n this.#modelProviderId = properties.modelProviderId;\n }\n\n if (properties.modifiedAt !== undefined) {\n this.#modifiedAt = properties.modifiedAt;\n }\n\n if (properties.tag !== undefined) {\n this.#tag = properties.tag;\n }\n\n if (properties.title !== undefined) {\n this.#title = properties.title;\n }\n }\n\n static reduceChatEvents = reduceChatEvents;\n static updateSchema = conversationUpdateSchema;\n}\n"]}
@@ -8,7 +8,7 @@ export declare const conversationPropertiesCodec: z.ZodMiniCodec<z.ZodMiniObject
8
8
  modelProviderId: z.ZodMiniOptional<z.ZodMiniString<string>>;
9
9
  modifiedAt: z.iso.ZodMiniISODateTime;
10
10
  tag: z.ZodMiniString<string>;
11
- title: z.ZodMiniString<string>;
11
+ title: z.ZodMiniNullable<z.ZodMiniString<string>>;
12
12
  }, z.core.$strip>, z.ZodMiniObject<{
13
13
  createdAt: z.ZodMiniCustom<Temporal.Instant, Temporal.Instant>;
14
14
  currentRunId: z.ZodMiniNullable<z.ZodMiniString<string>>;
@@ -17,6 +17,6 @@ export declare const conversationPropertiesCodec: z.ZodMiniCodec<z.ZodMiniObject
17
17
  modelProviderId: z.ZodMiniNullable<z.ZodMiniString<string>>;
18
18
  modifiedAt: z.ZodMiniCustom<Temporal.Instant, Temporal.Instant>;
19
19
  tag: z.ZodMiniString<string>;
20
- title: z.ZodMiniString<string>;
20
+ title: z.ZodMiniNullable<z.ZodMiniString<string>>;
21
21
  }, z.core.$strip>>;
22
22
  export type ConversationEntity = z.input<typeof conversationPropertiesCodec>;
@@ -23,7 +23,7 @@ export const conversationPropertiesCodec = z.codec(z.object({
23
23
  modelProviderId: z.optional(z.string()),
24
24
  modifiedAt: z.iso.datetime(),
25
25
  tag: z.string(),
26
- title: z.string(),
26
+ title: z.nullable(z.string()),
27
27
  }), z.object({
28
28
  createdAt: z.instanceof(Temporal.Instant),
29
29
  currentRunId: z.nullable(z.string()),
@@ -32,7 +32,7 @@ export const conversationPropertiesCodec = z.codec(z.object({
32
32
  modelProviderId: z.nullable(z.string()),
33
33
  modifiedAt: z.instanceof(Temporal.Instant),
34
34
  tag: z.string(),
35
- title: z.string(),
35
+ title: z.nullable(z.string()),
36
36
  }), {
37
37
  decode(v) {
38
38
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"conversationPropertiesCodec.js","sourceRoot":"","sources":["../../../../src/enterprise/ai/conversations/conversationPropertiesCodec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAChD,CAAC,CAAC,MAAM,CAAC;IACP,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE;IAC3B,YAAY,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACpC,SAAS,EAAE,CAAC,C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,CAAC,KAAK;SACf,CAAC;IACJ,CAAC;IACD,MAAM,CAAC,CAAC;QACN,OAAO;YACL,cAAc,EAAE,CAAC,CAAC,EAAE;YACpB,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,QAAQ,EAAE;YACjC,YAAY,EAAE,CAAC,CAAC,YAAY,IAAI,SAAS;YACzC,SAAS,EAAE,CAAC,CAAC,SAAS,IAAI,SAAS;YACnC,eAAe,EAAE,CAAC,CAAC,eAAe,IAAI,SAAS;YAC/C,UAAU,EAAE,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE;YACnC,GAAG,EAAE,CAAC,CAAC,GAAG;YACV,KAAK,EAAE,CAAC,CAAC,KAAK;SACf,CAAC;IACJ,CAAC;CACF,CACF,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\nexport const conversationPropertiesCodec = z.codec(\n z.object({\n conversationId: z.string(),\n createdAt: z.iso.datetime(),\n currentRunId: z.optional(z.string()),\n modelName: z.optional(z.string()),\n modelProviderId: z.optional(z.string()),\n modifiedAt: z.iso.datetime(),\n tag: z.string(),\n title: z.string(),\n }),\n z.object({\n createdAt: z.instanceof(Temporal.Instant),\n currentRunId: z.nullable(z.string()),\n id: z.string(),\n modelName: z.nullable(z.string()),\n modelProviderId: z.nullable(z.string()),\n modifiedAt: z.instanceof(Temporal.Instant),\n tag: z.string(),\n title: z.string(),\n }),\n {\n decode(v) {\n return {\n createdAt: Temporal.Instant.from(v.createdAt),\n currentRunId: v.currentRunId || null,\n id: v.conversationId,\n modelName: v.modelName || null,\n modelProviderId: v.modelProviderId || null,\n modifiedAt: Temporal.Instant.from(v.modifiedAt),\n tag: v.tag,\n title: v.title,\n };\n },\n encode(v) {\n return {\n conversationId: v.id,\n createdAt: v.createdAt.toString(),\n currentRunId: v.currentRunId || undefined,\n modelName: v.modelName || undefined,\n modelProviderId: v.modelProviderId || undefined,\n modifiedAt: v.modifiedAt.toString(),\n tag: v.tag,\n title: v.title,\n };\n },\n },\n);\n\nexport type ConversationEntity = z.input<typeof conversationPropertiesCodec>;\n"]}
1
+ {"version":3,"file":"conversationPropertiesCodec.js","sourceRoot":"","sources":["../../../../src/enterprise/ai/conversations/conversationPropertiesCodec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAChD,CAAC,CAAC,MAAM,CAAC;IACP,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE;IAC3B,YAAY,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACpC,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACjC,eAAe,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACvC,UAAU,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE;IAC5B,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;CAC9B,CAAC,EACF,CAAC,CAAC,MAAM,CAAC;IACP,SAAS,EAAE,CAAC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,IAAI,SAAS;YAC/C,UAAU,EAAE,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE;YACnC,GAAG,EAAE,CAAC,CAAC,GAAG;YACV,KAAK,EAAE,CAAC,CAAC,KAAK;SACf,CAAC;IACJ,CAAC;CACF,CACF,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\nexport const conversationPropertiesCodec = z.codec(\n z.object({\n conversationId: z.string(),\n createdAt: z.iso.datetime(),\n currentRunId: z.optional(z.string()),\n modelName: z.optional(z.string()),\n modelProviderId: z.optional(z.string()),\n modifiedAt: z.iso.datetime(),\n tag: z.string(),\n title: z.nullable(z.string()),\n }),\n z.object({\n createdAt: z.instanceof(Temporal.Instant),\n currentRunId: z.nullable(z.string()),\n id: z.string(),\n modelName: z.nullable(z.string()),\n modelProviderId: z.nullable(z.string()),\n modifiedAt: z.instanceof(Temporal.Instant),\n tag: z.string(),\n title: z.nullable(z.string()),\n }),\n {\n decode(v) {\n return {\n createdAt: Temporal.Instant.from(v.createdAt),\n currentRunId: v.currentRunId || null,\n id: v.conversationId,\n modelName: v.modelName || null,\n modelProviderId: v.modelProviderId || null,\n modifiedAt: Temporal.Instant.from(v.modifiedAt),\n tag: v.tag,\n title: v.title,\n };\n },\n encode(v) {\n return {\n conversationId: v.id,\n createdAt: v.createdAt.toString(),\n currentRunId: v.currentRunId || undefined,\n modelName: v.modelName || undefined,\n modelProviderId: v.modelProviderId || undefined,\n modifiedAt: v.modifiedAt.toString(),\n tag: v.tag,\n title: v.title,\n };\n },\n },\n);\n\nexport type ConversationEntity = z.input<typeof conversationPropertiesCodec>;\n"]}
@@ -56,7 +56,7 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
56
56
  modelProviderId: string | null;
57
57
  modifiedAt: import("temporal-polyfill").Temporal.Instant;
58
58
  tag: string;
59
- title: string;
59
+ title: string | null;
60
60
  }, {
61
61
  conversationId: string;
62
62
  }, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<{
@@ -164,7 +164,7 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
164
164
  modelProviderId: string | null;
165
165
  modifiedAt: import("temporal-polyfill").Temporal.Instant;
166
166
  tag: string;
167
- title: string;
167
+ title: string | null;
168
168
  };
169
169
  history: {
170
170
  data: ({
@@ -272,7 +272,7 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
272
272
  modelProviderId: string | null;
273
273
  modifiedAt: import("temporal-polyfill").Temporal.Instant;
274
274
  tag: string;
275
- title: string;
275
+ title: string | null;
276
276
  };
277
277
  currentRunId: string;
278
278
  }, {
@@ -395,7 +395,7 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
395
395
  modelProviderId: string | null;
396
396
  modifiedAt: import("temporal-polyfill").Temporal.Instant;
397
397
  tag: string;
398
- title: string;
398
+ title: string | null;
399
399
  }, {
400
400
  conversationId: string;
401
401
  }, import("xstate").EventObject>;
@@ -511,7 +511,7 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
511
511
  modelProviderId: string | null;
512
512
  modifiedAt: import("temporal-polyfill").Temporal.Instant;
513
513
  tag: string;
514
- title: string;
514
+ title: string | null;
515
515
  };
516
516
  history: {
517
517
  data: ({
@@ -623,7 +623,7 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
623
623
  modelProviderId: string | null;
624
624
  modifiedAt: import("temporal-polyfill").Temporal.Instant;
625
625
  tag: string;
626
- title: string;
626
+ title: string | null;
627
627
  };
628
628
  currentRunId: string;
629
629
  }, {
@@ -46,23 +46,19 @@ export const createConversationMachine = (config) => setup({
46
46
  return result.value;
47
47
  })),
48
48
  retrieveState: fromPromise(async ({ input, signal }) => {
49
- const [conversation, history] = await Promise.all([
50
- retrieveConversation(config)(input.conversationId, { signal }).then((result) => {
51
- if (result.isErr()) {
52
- throw result.error;
53
- }
54
- return result.value;
55
- }),
56
- retrieveConversationHistory(config)(input.conversationId, { signal }).then((result) => {
57
- if (result.isErr()) {
58
- throw result.error;
59
- }
60
- return result.value;
61
- }),
49
+ const [conversationResult, historyResult] = await Promise.all([
50
+ retrieveConversation(config)(input.conversationId, { signal }),
51
+ retrieveConversationHistory(config)(input.conversationId, { signal }),
62
52
  ]);
53
+ if (conversationResult.isErr()) {
54
+ throw conversationResult.error;
55
+ }
56
+ if (historyResult.isErr()) {
57
+ throw historyResult.error;
58
+ }
63
59
  return {
64
- conversation,
65
- history,
60
+ conversation: conversationResult.value,
61
+ history: historyResult.value,
66
62
  };
67
63
  }),
68
64
  startRun: fromPromise(({ input }) => createExchangeRun(config)(input.conversationId, { message: input.message }).then((result) => {
@@ -1 +1 @@
1
- {"version":3,"file":"createConversationMachine.js","sourceRoot":"","sources":["../../../../src/enterprise/ai/conversations/createConversationMachine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC9F,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,EAAE,iBAAiB,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BAAyB,EAAE;YACzB,WAAW,EAAE,0BAA0B;YACvC,EAAE,EAAE;gBACF,eAAe,EAAE;oBACf,OAAO,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;oBACzC,MAAM,EAAE,oBAAoB;iBAC7B;gBACD,aAAa,EAAE;oBACb,OAAO,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;oBACzC,MAAM,EAAE,oBAAoB;iBAC7B;gBACD,mBAAmB,EAAE;oBACnB,OAAO,EAAE,MAAM,CAAC;wBACd,SAAS,EAAE,SAAS;wBACpB,cAAc,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO;qBAC7C,CAAC;oBACF,MAAM,EAAE,oBAAoB;iBAC7B;aACF;SACF;QACD,aAAa,EAAE;YACb,MAAM,EAAE;gBACN,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc;gBAChD,MAAM,EAAE,oBAAoB;aAC7B;YACD,WAAW,EACT,gFAAgF;YAClF,EAAE,EAAE;gBACF,mBAAmB,EAAE;oBACnB,OAAO,EAAE,MAAM,CAAC;wBACd,cAAc,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO;qBAC7C,CAAC;oBACF,MAAM,EAAE,uBAAuB;iBAChC;aACF;SACF;KACF;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 { setup, fromObservable, fromPromise, assign, enqueueActions, emit } from \"xstate\";\nimport type { UserChatMessage } from \"../chat/UserChatMessage.ts\";\nimport { AgentConversation } from \"./AgentConversation.ts\";\nimport type { ConversationExchange } from \"./reduceChatEvents.ts\";\nimport type { SonarV4Config } from \"../../../common/Config.ts\";\nimport { createConversation, createConversationCodec } from \"./methods/createConversation.ts\";\nimport * as z from \"zod/mini\";\nimport { retrieveConversation } from \"./methods/retrieveConversation.ts\";\nimport { retrieveConversationHistory } from \"./methods/retrieveConversationHistory.ts\";\nimport { createExchangeRun } from \"./methods/createExchangeRun.ts\";\nimport { stopExchangeRun } from \"./methods/stopExchangeRun.ts\";\nimport { streamRunEvents } from \"./methods/streamRunEvents.ts\";\nimport { fromTextEventStream } from \"../../../common/fromTextEventStream.ts\";\nimport { map } from \"rxjs\";\nimport { chatEventCodec, type ChatEvent } from \"../chat/chatEventSchema.ts\";\nimport type { HttpError } from \"../../../common/HttpError.ts\";\n\nexport type ConversationMachineInput = {\n conversationId: string | null;\n};\n\nexport type ConversationMachineContext = {\n conversationId: string | null;\n conversationSnapshot?: ConversationExchange[];\n currentRunId?: string | null;\n lastError?: unknown;\n messageAttempt?: UserChatMessage;\n};\nexport type ConversationMachineEvents =\n | { type: \"STOP_RUN\" }\n | { type: \"SUBMIT_USER_MESSAGE\"; message: UserChatMessage }\n | { type: \"RETRY_MESSAGE\" }\n | { type: \"REFRESH_HISTORY\" };\n\nexport type ConversationMachineEmitted =\n | {\n type: \"apiError\";\n error: HttpError;\n }\n | {\n type: \"chatEventReceived\";\n chatEvent: ChatEvent;\n }\n | {\n type: \"conversationCreated\";\n id: string;\n };\n\nexport const createConversationMachine = (config: SonarV4Config) =>\n setup({\n actors: {\n createConversation: fromPromise(\n ({ input }: { input: z.input<typeof createConversationCodec> }) =>\n createConversation(config)(input).then((result) => {\n if (result.isErr()) {\n throw result.error;\n }\n return result.value;\n }),\n ),\n retrieveConversation: fromPromise(\n ({ input, signal }: { input: { conversationId: string }; signal: AbortSignal }) =>\n retrieveConversation(config)(input.conversationId, { signal }).then((result) => {\n if (result.isErr()) {\n throw result.error;\n }\n return result.value;\n }),\n ),\n retrieveHistory: fromPromise(\n ({ input, signal }: { input: { conversationId: string }; signal: AbortSignal }) =>\n retrieveConversationHistory(config)(input.conversationId, { signal }).then((result) => {\n if (result.isErr()) {\n throw result.error;\n }\n return result.value;\n }),\n ),\n retrieveState: fromPromise(\n async ({ input, signal }: { input: { conversationId: string }; signal: AbortSignal }) => {\n const [conversation, history] = await Promise.all([\n retrieveConversation(config)(input.conversationId, { signal }).then((result) => {\n if (result.isErr()) {\n throw result.error;\n }\n return result.value;\n }),\n retrieveConversationHistory(config)(input.conversationId, { signal }).then((result) => {\n if (result.isErr()) {\n throw result.error;\n }\n return result.value;\n }),\n ]);\n return {\n conversation,\n history,\n };\n },\n ),\n startRun: fromPromise(\n ({ input }: { input: { conversationId: string; message: UserChatMessage } }) =>\n createExchangeRun(config)(input.conversationId, { message: input.message }).then(\n (result) => {\n if (result.isErr()) {\n throw result.error;\n }\n return result.value;\n },\n ),\n ),\n stopRun: fromPromise(({ input }: { input: { conversationId: string; runId: string } }) =>\n stopExchangeRun(config)(input.conversationId, input.runId).then((result) => {\n if (result.isErr()) {\n throw result.error;\n }\n return result.value;\n }),\n ),\n streamRun: fromObservable(({ input }: { input: { conversationId: string; runId: string } }) =>\n fromTextEventStream(({ signal }) =>\n streamRunEvents(config)(\n { conversationId: input.conversationId, runId: input.runId },\n { signal },\n ),\n ).pipe(\n map((event) =>\n z.decode(chatEventCodec, JSON.parse(event.data) as z.input<typeof chatEventCodec>),\n ),\n ),\n ),\n },\n types: {\n context: {} as ConversationMachineContext,\n emitted: {} as ConversationMachineEmitted,\n events: {} as ConversationMachineEvents,\n input: {} as ConversationMachineInput,\n },\n }).createMachine({\n context: ({ input }) => ({\n conversationId: input.conversationId,\n conversationSnapshot: undefined,\n currentRunId: undefined,\n messageAttempt: undefined,\n }),\n id: \"agentConversation\",\n initial: \"uninitialized\",\n states: {\n creating_conversation: {\n description: \"Creating a new conversation object\",\n invoke: {\n input: ({ context }) => ({\n message: context.messageAttempt!,\n }),\n onDone: [\n {\n actions: [\n assign({\n conversationId: ({ event }) => event.output.id,\n // Add the message attempt into the snapshot manually\n conversationSnapshot: ({ context, event }) => [\n ...(context.conversationSnapshot ?? []),\n {\n id: event.output.currentRunId!,\n messages: new Map(),\n submittedUserMessage: context.messageAttempt,\n toolCalls: new Map(),\n } satisfies ConversationExchange,\n ],\n currentRunId: ({ event }) => event.output.currentRunId,\n messageAttempt: undefined,\n }),\n emit(({ event }) => ({\n id: event.output.id,\n type: \"conversationCreated\",\n })),\n ],\n // Don't transition to streaming in a situation where we didn't receive a currentRunId\n guard: ({ event }) => !!event.output.currentRunId,\n target: \"streaming\",\n },\n /**\n * Fall back to the retrieving_history state if we didn't receive a currentRunId\n */\n {\n actions: assign({\n conversationId: ({ event }) => event.output.id,\n currentRunId: ({ event }) => event.output.currentRunId,\n messageAttempt: undefined,\n }),\n target: \"retrieving_history\",\n },\n ],\n onError: {\n actions: emit(({ event }) => ({\n error: event.error as HttpError,\n type: \"apiError\",\n })),\n target: \"uninitialized\",\n },\n src: \"createConversation\",\n },\n },\n idle: {\n description: \"Waiting for user input to start the next reply stream\",\n on: {\n REFRESH_HISTORY: {\n target: \"retrieving_history\",\n },\n SUBMIT_USER_MESSAGE: {\n actions: assign({\n messageAttempt: ({ event }) => event.message,\n }),\n target: \"submitting_message\",\n },\n },\n },\n retrieve_history_failed: {\n on: {\n REFRESH_HISTORY: {\n actions: assign({ lastError: undefined }),\n target: \"retrieving_history\",\n },\n },\n },\n retrieving_history: {\n description: \"Retrieving latest copy of conversation history\",\n invoke: {\n input: ({ context }) => ({ conversationId: context.conversationId! }),\n onDone: [\n {\n actions: assign({\n conversationSnapshot: ({ context, event }) =>\n AgentConversation.reduceChatEvents(\n context.conversationSnapshot,\n event.output.history.data,\n ),\n currentRunId: ({ event }) => event.output.conversation.currentRunId,\n }),\n guard: ({ event }) => !!event.output.conversation.currentRunId,\n target: \"streaming\",\n },\n {\n actions: assign({\n conversationSnapshot: ({ context, event }) =>\n AgentConversation.reduceChatEvents(\n context.conversationSnapshot,\n event.output.history.data,\n ),\n currentRunId: ({ event }) => event.output.conversation.currentRunId,\n }),\n target: \"idle\",\n },\n ],\n onError: [\n {\n guard: ({ event }) => {\n const e = event.error as Error & { code?: string };\n return (\n e?.name === \"AbortError\" ||\n e?.message?.includes(\"aborted\") ||\n e?.code === \"ABORT_ERR\"\n );\n },\n target: \"uninitialized\",\n },\n {\n actions: [\n assign({\n lastError: ({ event }) => event.error,\n }),\n emit(({ event }) => ({\n error: event.error as HttpError,\n type: \"apiError\",\n })),\n ],\n target: \"retrieve_history_failed\",\n },\n ],\n src: \"retrieveState\",\n },\n },\n streaming: {\n description: \"Manages monitoring and canceling the current run\",\n initial: \"monitoring_replies\",\n invoke: {\n input: ({ context }) => {\n if (!context.currentRunId) {\n throw new Error(\"Attempted to stream without a runId\");\n }\n return {\n conversationId: context.conversationId!,\n runId: context.currentRunId,\n };\n },\n onDone: {\n actions: assign({ currentRunId: null }),\n target: \"idle\",\n },\n onError: {\n actions: assign({ currentRunId: null }),\n target: \"idle\",\n },\n onSnapshot: {\n actions: enqueueActions(({ context, enqueue, event }) => {\n const chatEvent = event.snapshot.context;\n if (!chatEvent) {\n return;\n }\n\n const nextSnapshot = AgentConversation.reduceChatEvents(\n context.conversationSnapshot,\n [chatEvent],\n );\n\n enqueue.assign({\n conversationSnapshot: nextSnapshot,\n });\n enqueue.emit({\n chatEvent,\n type: \"chatEventReceived\",\n });\n }),\n },\n src: \"streamRun\",\n },\n states: {\n monitoring_replies: {\n description: \"Attached to the run event stream\",\n on: {\n STOP_RUN: {\n target: \"stopping\",\n },\n },\n },\n stopping: {\n description: \"Background cancelation of the run stream\",\n invoke: {\n input: ({ context }) => ({\n conversationId: context.conversationId!,\n runId: context.currentRunId!,\n }),\n onDone: {\n actions: assign({ currentRunId: undefined }),\n target: \"#agentConversation.idle\",\n },\n onError: {\n target: \"#agentConversation.retrieving_history\",\n },\n src: \"stopRun\",\n },\n },\n },\n },\n submitting_message: {\n description: \"Submitting message to start a new reply stream\",\n invoke: {\n input: ({ context, event }) => {\n switch (event.type) {\n case \"RETRY_MESSAGE\":\n if (!context.messageAttempt) {\n throw new Error(\"Tried to resubmit nonexistent message\");\n }\n return {\n conversationId: context.conversationId!,\n message: context.messageAttempt,\n };\n case \"SUBMIT_USER_MESSAGE\":\n return {\n conversationId: context.conversationId!,\n message: event.message,\n };\n }\n throw new Error(`Unexpected event type received in submitting_message: ${event.type}`);\n },\n onDone: {\n actions: assign({\n // Add the message attempt into the snapshot manually\n conversationSnapshot: ({ context, event }) => [\n ...(context.conversationSnapshot ?? []),\n {\n id: event.output.currentRunId,\n messages: new Map(),\n submittedUserMessage: context.messageAttempt || undefined,\n toolCalls: new Map(),\n } satisfies ConversationExchange,\n ],\n currentRunId: ({ event }) => event.output.currentRunId,\n messageAttempt: undefined,\n }),\n target: \"streaming\",\n },\n onError: {\n actions: [\n assign({\n currentRunId: () => null,\n lastError: ({ event }) => event.error,\n }),\n emit(({ event }) => ({\n error: event.error as HttpError,\n type: \"apiError\",\n })),\n ],\n target: \"submitting_message_failed\",\n },\n src: \"startRun\",\n },\n },\n submitting_message_failed: {\n description: \"Failed to submit message\",\n on: {\n REFRESH_HISTORY: {\n actions: assign({ lastError: undefined }),\n target: \"retrieving_history\",\n },\n RETRY_MESSAGE: {\n actions: assign({ lastError: undefined }),\n target: \"submitting_message\",\n },\n SUBMIT_USER_MESSAGE: {\n actions: assign({\n lastError: undefined,\n messageAttempt: ({ event }) => event.message,\n }),\n target: \"submitting_message\",\n },\n },\n },\n uninitialized: {\n always: {\n guard: ({ context }) => !!context.conversationId,\n target: \"retrieving_history\",\n },\n description:\n \"Entry state that the machine remains in when no conversation has been provided\",\n on: {\n SUBMIT_USER_MESSAGE: {\n actions: assign({\n messageAttempt: ({ event }) => event.message,\n }),\n target: \"creating_conversation\",\n },\n },\n },\n },\n });\n\nexport type AgentConversationMachine = ReturnType<typeof createConversationMachine>;\n"]}
1
+ {"version":3,"file":"createConversationMachine.js","sourceRoot":"","sources":["../../../../src/enterprise/ai/conversations/createConversationMachine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC9F,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAkB,MAAM,4BAA4B,CAAC;AAkC5E,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,MAAqB,EAAE,EAAE,CACjE,KAAK,CAAC;IACJ,MAAM,EAAE;QACN,kBAAkB,EAAE,WAAW,CAC7B,CAAC,EAAE,KAAK,EAAsD,EAAE,EAAE,CAChE,kBAAkB,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YAChD,IAAI,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;gBACnB,MAAM,MAAM,CA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MAAM,CAAC;wBACd,cAAc,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO;qBAC7C,CAAC;oBACF,MAAM,EAAE,uBAAuB;iBAChC;aACF;SACF;KACF;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 { setup, fromObservable, fromPromise, assign, enqueueActions, emit } from \"xstate\";\nimport type { UserChatMessage } from \"../chat/UserChatMessage.ts\";\nimport { AgentConversation } from \"./AgentConversation.ts\";\nimport type { ConversationExchange } from \"./reduceChatEvents.ts\";\nimport type { SonarV4Config } from \"../../../common/Config.ts\";\nimport { createConversation, createConversationCodec } from \"./methods/createConversation.ts\";\nimport * as z from \"zod/mini\";\nimport { retrieveConversation } from \"./methods/retrieveConversation.ts\";\nimport { retrieveConversationHistory } from \"./methods/retrieveConversationHistory.ts\";\nimport { createExchangeRun } from \"./methods/createExchangeRun.ts\";\nimport { stopExchangeRun } from \"./methods/stopExchangeRun.ts\";\nimport { streamRunEvents } from \"./methods/streamRunEvents.ts\";\nimport { fromTextEventStream } from \"../../../common/fromTextEventStream.ts\";\nimport { map } from \"rxjs\";\nimport { chatEventCodec, type ChatEvent } from \"../chat/chatEventSchema.ts\";\nimport type { HttpError } from \"../../../common/HttpError.ts\";\n\nexport type ConversationMachineInput = {\n conversationId: string | null;\n};\n\nexport type ConversationMachineContext = {\n conversationId: string | null;\n conversationSnapshot?: ConversationExchange[];\n currentRunId?: string | null;\n lastError?: unknown;\n messageAttempt?: UserChatMessage;\n};\nexport type ConversationMachineEvents =\n | { type: \"STOP_RUN\" }\n | { type: \"SUBMIT_USER_MESSAGE\"; message: UserChatMessage }\n | { type: \"RETRY_MESSAGE\" }\n | { type: \"REFRESH_HISTORY\" };\n\nexport type ConversationMachineEmitted =\n | {\n type: \"apiError\";\n error: HttpError;\n }\n | {\n type: \"chatEventReceived\";\n chatEvent: ChatEvent;\n }\n | {\n type: \"conversationCreated\";\n id: string;\n };\n\nexport const createConversationMachine = (config: SonarV4Config) =>\n setup({\n actors: {\n createConversation: fromPromise(\n ({ input }: { input: z.input<typeof createConversationCodec> }) =>\n createConversation(config)(input).then((result) => {\n if (result.isErr()) {\n throw result.error;\n }\n return result.value;\n }),\n ),\n retrieveConversation: fromPromise(\n ({ input, signal }: { input: { conversationId: string }; signal: AbortSignal }) =>\n retrieveConversation(config)(input.conversationId, { signal }).then((result) => {\n if (result.isErr()) {\n throw result.error;\n }\n return result.value;\n }),\n ),\n retrieveHistory: fromPromise(\n ({ input, signal }: { input: { conversationId: string }; signal: AbortSignal }) =>\n retrieveConversationHistory(config)(input.conversationId, { signal }).then((result) => {\n if (result.isErr()) {\n throw result.error;\n }\n return result.value;\n }),\n ),\n retrieveState: fromPromise(\n async ({ input, signal }: { input: { conversationId: string }; signal: AbortSignal }) => {\n const [conversationResult, historyResult] = await Promise.all([\n retrieveConversation(config)(input.conversationId, { signal }),\n retrieveConversationHistory(config)(input.conversationId, { signal }),\n ]);\n\n if (conversationResult.isErr()) {\n throw conversationResult.error;\n }\n\n if (historyResult.isErr()) {\n throw historyResult.error;\n }\n\n return {\n conversation: conversationResult.value,\n history: historyResult.value,\n };\n },\n ),\n startRun: fromPromise(\n ({ input }: { input: { conversationId: string; message: UserChatMessage } }) =>\n createExchangeRun(config)(input.conversationId, { message: input.message }).then(\n (result) => {\n if (result.isErr()) {\n throw result.error;\n }\n return result.value;\n },\n ),\n ),\n stopRun: fromPromise(({ input }: { input: { conversationId: string; runId: string } }) =>\n stopExchangeRun(config)(input.conversationId, input.runId).then((result) => {\n if (result.isErr()) {\n throw result.error;\n }\n return result.value;\n }),\n ),\n streamRun: fromObservable(({ input }: { input: { conversationId: string; runId: string } }) =>\n fromTextEventStream(({ signal }) =>\n streamRunEvents(config)(\n { conversationId: input.conversationId, runId: input.runId },\n { signal },\n ),\n ).pipe(\n map((event) =>\n z.decode(chatEventCodec, JSON.parse(event.data) as z.input<typeof chatEventCodec>),\n ),\n ),\n ),\n },\n types: {\n context: {} as ConversationMachineContext,\n emitted: {} as ConversationMachineEmitted,\n events: {} as ConversationMachineEvents,\n input: {} as ConversationMachineInput,\n },\n }).createMachine({\n context: ({ input }) => ({\n conversationId: input.conversationId,\n conversationSnapshot: undefined,\n currentRunId: undefined,\n messageAttempt: undefined,\n }),\n id: \"agentConversation\",\n initial: \"uninitialized\",\n states: {\n creating_conversation: {\n description: \"Creating a new conversation object\",\n invoke: {\n input: ({ context }) => ({\n message: context.messageAttempt!,\n }),\n onDone: [\n {\n actions: [\n assign({\n conversationId: ({ event }) => event.output.id,\n // Add the message attempt into the snapshot manually\n conversationSnapshot: ({ context, event }) => [\n ...(context.conversationSnapshot ?? []),\n {\n id: event.output.currentRunId!,\n messages: new Map(),\n submittedUserMessage: context.messageAttempt,\n toolCalls: new Map(),\n } satisfies ConversationExchange,\n ],\n currentRunId: ({ event }) => event.output.currentRunId,\n messageAttempt: undefined,\n }),\n emit(({ event }) => ({\n id: event.output.id,\n type: \"conversationCreated\",\n })),\n ],\n // Don't transition to streaming in a situation where we didn't receive a currentRunId\n guard: ({ event }) => !!event.output.currentRunId,\n target: \"streaming\",\n },\n /**\n * Fall back to the retrieving_history state if we didn't receive a currentRunId\n */\n {\n actions: assign({\n conversationId: ({ event }) => event.output.id,\n currentRunId: ({ event }) => event.output.currentRunId,\n messageAttempt: undefined,\n }),\n target: \"retrieving_history\",\n },\n ],\n onError: {\n actions: emit(({ event }) => ({\n error: event.error as HttpError,\n type: \"apiError\",\n })),\n target: \"uninitialized\",\n },\n src: \"createConversation\",\n },\n },\n idle: {\n description: \"Waiting for user input to start the next reply stream\",\n on: {\n REFRESH_HISTORY: {\n target: \"retrieving_history\",\n },\n SUBMIT_USER_MESSAGE: {\n actions: assign({\n messageAttempt: ({ event }) => event.message,\n }),\n target: \"submitting_message\",\n },\n },\n },\n retrieve_history_failed: {\n on: {\n REFRESH_HISTORY: {\n actions: assign({ lastError: undefined }),\n target: \"retrieving_history\",\n },\n },\n },\n retrieving_history: {\n description: \"Retrieving latest copy of conversation history\",\n invoke: {\n input: ({ context }) => ({ conversationId: context.conversationId! }),\n onDone: [\n {\n actions: assign({\n conversationSnapshot: ({ context, event }) =>\n AgentConversation.reduceChatEvents(\n context.conversationSnapshot,\n event.output.history.data,\n ),\n currentRunId: ({ event }) => event.output.conversation.currentRunId,\n }),\n guard: ({ event }) => !!event.output.conversation.currentRunId,\n target: \"streaming\",\n },\n {\n actions: assign({\n conversationSnapshot: ({ context, event }) =>\n AgentConversation.reduceChatEvents(\n context.conversationSnapshot,\n event.output.history.data,\n ),\n currentRunId: ({ event }) => event.output.conversation.currentRunId,\n }),\n target: \"idle\",\n },\n ],\n onError: [\n {\n guard: ({ event }) => {\n const e = event.error as Error & { code?: string };\n return (\n e?.name === \"AbortError\" ||\n e?.message?.includes(\"aborted\") ||\n e?.code === \"ABORT_ERR\"\n );\n },\n target: \"uninitialized\",\n },\n {\n actions: [\n assign({\n lastError: ({ event }) => event.error,\n }),\n emit(({ event }) => ({\n error: event.error as HttpError,\n type: \"apiError\",\n })),\n ],\n target: \"retrieve_history_failed\",\n },\n ],\n src: \"retrieveState\",\n },\n },\n streaming: {\n description: \"Manages monitoring and canceling the current run\",\n initial: \"monitoring_replies\",\n invoke: {\n input: ({ context }) => {\n if (!context.currentRunId) {\n throw new Error(\"Attempted to stream without a runId\");\n }\n return {\n conversationId: context.conversationId!,\n runId: context.currentRunId,\n };\n },\n onDone: {\n actions: assign({ currentRunId: null }),\n target: \"idle\",\n },\n onError: {\n actions: assign({ currentRunId: null }),\n target: \"idle\",\n },\n onSnapshot: {\n actions: enqueueActions(({ context, enqueue, event }) => {\n const chatEvent = event.snapshot.context;\n if (!chatEvent) {\n return;\n }\n\n const nextSnapshot = AgentConversation.reduceChatEvents(\n context.conversationSnapshot,\n [chatEvent],\n );\n\n enqueue.assign({\n conversationSnapshot: nextSnapshot,\n });\n enqueue.emit({\n chatEvent,\n type: \"chatEventReceived\",\n });\n }),\n },\n src: \"streamRun\",\n },\n states: {\n monitoring_replies: {\n description: \"Attached to the run event stream\",\n on: {\n STOP_RUN: {\n target: \"stopping\",\n },\n },\n },\n stopping: {\n description: \"Background cancelation of the run stream\",\n invoke: {\n input: ({ context }) => ({\n conversationId: context.conversationId!,\n runId: context.currentRunId!,\n }),\n onDone: {\n actions: assign({ currentRunId: undefined }),\n target: \"#agentConversation.idle\",\n },\n onError: {\n target: \"#agentConversation.retrieving_history\",\n },\n src: \"stopRun\",\n },\n },\n },\n },\n submitting_message: {\n description: \"Submitting message to start a new reply stream\",\n invoke: {\n input: ({ context, event }) => {\n switch (event.type) {\n case \"RETRY_MESSAGE\":\n if (!context.messageAttempt) {\n throw new Error(\"Tried to resubmit nonexistent message\");\n }\n return {\n conversationId: context.conversationId!,\n message: context.messageAttempt,\n };\n case \"SUBMIT_USER_MESSAGE\":\n return {\n conversationId: context.conversationId!,\n message: event.message,\n };\n }\n throw new Error(`Unexpected event type received in submitting_message: ${event.type}`);\n },\n onDone: {\n actions: assign({\n // Add the message attempt into the snapshot manually\n conversationSnapshot: ({ context, event }) => [\n ...(context.conversationSnapshot ?? []),\n {\n id: event.output.currentRunId,\n messages: new Map(),\n submittedUserMessage: context.messageAttempt || undefined,\n toolCalls: new Map(),\n } satisfies ConversationExchange,\n ],\n currentRunId: ({ event }) => event.output.currentRunId,\n messageAttempt: undefined,\n }),\n target: \"streaming\",\n },\n onError: {\n actions: [\n assign({\n currentRunId: () => null,\n lastError: ({ event }) => event.error,\n }),\n emit(({ event }) => ({\n error: event.error as HttpError,\n type: \"apiError\",\n })),\n ],\n target: \"submitting_message_failed\",\n },\n src: \"startRun\",\n },\n },\n submitting_message_failed: {\n description: \"Failed to submit message\",\n on: {\n REFRESH_HISTORY: {\n actions: assign({ lastError: undefined }),\n target: \"retrieving_history\",\n },\n RETRY_MESSAGE: {\n actions: assign({ lastError: undefined }),\n target: \"submitting_message\",\n },\n SUBMIT_USER_MESSAGE: {\n actions: assign({\n lastError: undefined,\n messageAttempt: ({ event }) => event.message,\n }),\n target: \"submitting_message\",\n },\n },\n },\n uninitialized: {\n always: {\n guard: ({ context }) => !!context.conversationId,\n target: \"retrieving_history\",\n },\n description:\n \"Entry state that the machine remains in when no conversation has been provided\",\n on: {\n SUBMIT_USER_MESSAGE: {\n actions: assign({\n messageAttempt: ({ event }) => event.message,\n }),\n target: \"creating_conversation\",\n },\n },\n },\n },\n });\n\nexport type AgentConversationMachine = ReturnType<typeof createConversationMachine>;\n"]}
@@ -10,7 +10,7 @@ export declare const createExchangeRun: (config: SonarV4Config) => (conversation
10
10
  modelProviderId: string | null;
11
11
  modifiedAt: import("temporal-polyfill").Temporal.Instant;
12
12
  tag: string;
13
- title: string;
13
+ title: string | null;
14
14
  };
15
15
  currentRunId: string;
16
16
  }, import("../../../index.ts").HttpError>;
@@ -8,5 +8,5 @@ export declare const retrieveConversation: (config: SonarV4Config) => (id: strin
8
8
  modelProviderId: string | null;
9
9
  modifiedAt: import("temporal-polyfill").Temporal.Instant;
10
10
  tag: string;
11
- title: string;
11
+ title: string | null;
12
12
  }, import("../../../index.ts").HttpError>;
@@ -8,7 +8,7 @@ export declare const updateConversation: (config: SonarV4Config) => (id: string,
8
8
  modelProviderId: string | null;
9
9
  modifiedAt: import("temporal-polyfill").Temporal.Instant;
10
10
  tag: string;
11
- title: string;
11
+ title: string | null;
12
12
  }, import("../../../index.ts").HttpError>;
13
13
  export declare const conversationUpdateSchema: z.ZodMiniObject<{
14
14
  title: z.ZodMiniOptional<z.ZodMiniString<string>>;
@@ -24616,7 +24616,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
24616
24616
  modelProviderId: optional(string2()),
24617
24617
  modifiedAt: iso_exports.datetime(),
24618
24618
  tag: string2(),
24619
- title: string2()
24619
+ title: nullable(string2())
24620
24620
  }), object({
24621
24621
  createdAt: _instanceof(Xn.Instant),
24622
24622
  currentRunId: nullable(string2()),
@@ -24625,7 +24625,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
24625
24625
  modelProviderId: nullable(string2()),
24626
24626
  modifiedAt: _instanceof(Xn.Instant),
24627
24627
  tag: string2(),
24628
- title: string2()
24628
+ title: nullable(string2())
24629
24629
  }), {
24630
24630
  decode(v2) {
24631
24631
  return {
@@ -30939,23 +30939,19 @@ ${err.message}`);
30939
30939
  return result.value;
30940
30940
  })),
30941
30941
  retrieveState: fromPromise2(async ({ input, signal }) => {
30942
- const [conversation, history] = await Promise.all([
30943
- retrieveConversation(config3)(input.conversationId, { signal }).then((result) => {
30944
- if (result.isErr()) {
30945
- throw result.error;
30946
- }
30947
- return result.value;
30948
- }),
30949
- retrieveConversationHistory(config3)(input.conversationId, { signal }).then((result) => {
30950
- if (result.isErr()) {
30951
- throw result.error;
30952
- }
30953
- return result.value;
30954
- })
30942
+ const [conversationResult, historyResult] = await Promise.all([
30943
+ retrieveConversation(config3)(input.conversationId, { signal }),
30944
+ retrieveConversationHistory(config3)(input.conversationId, { signal })
30955
30945
  ]);
30946
+ if (conversationResult.isErr()) {
30947
+ throw conversationResult.error;
30948
+ }
30949
+ if (historyResult.isErr()) {
30950
+ throw historyResult.error;
30951
+ }
30956
30952
  return {
30957
- conversation,
30958
- history
30953
+ conversation: conversationResult.value,
30954
+ history: historyResult.value
30959
30955
  };
30960
30956
  }),
30961
30957
  startRun: fromPromise2(({ input }) => createExchangeRun(config3)(input.conversationId, { message: input.message }).then((result) => {
@@ -25279,7 +25279,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
25279
25279
  modelProviderId: optional(string2()),
25280
25280
  modifiedAt: iso_exports.datetime(),
25281
25281
  tag: string2(),
25282
- title: string2()
25282
+ title: nullable(string2())
25283
25283
  }), object({
25284
25284
  createdAt: _instanceof(Xn.Instant),
25285
25285
  currentRunId: nullable(string2()),
@@ -25288,7 +25288,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
25288
25288
  modelProviderId: nullable(string2()),
25289
25289
  modifiedAt: _instanceof(Xn.Instant),
25290
25290
  tag: string2(),
25291
- title: string2()
25291
+ title: nullable(string2())
25292
25292
  }), {
25293
25293
  decode(v2) {
25294
25294
  return {
@@ -31645,23 +31645,19 @@ ${err.message}`);
31645
31645
  return result.value;
31646
31646
  })),
31647
31647
  retrieveState: fromPromise2(async ({ input, signal }) => {
31648
- const [conversation, history] = await Promise.all([
31649
- retrieveConversation(config3)(input.conversationId, { signal }).then((result) => {
31650
- if (result.isErr()) {
31651
- throw result.error;
31652
- }
31653
- return result.value;
31654
- }),
31655
- retrieveConversationHistory(config3)(input.conversationId, { signal }).then((result) => {
31656
- if (result.isErr()) {
31657
- throw result.error;
31658
- }
31659
- return result.value;
31660
- })
31648
+ const [conversationResult, historyResult] = await Promise.all([
31649
+ retrieveConversation(config3)(input.conversationId, { signal }),
31650
+ retrieveConversationHistory(config3)(input.conversationId, { signal })
31661
31651
  ]);
31652
+ if (conversationResult.isErr()) {
31653
+ throw conversationResult.error;
31654
+ }
31655
+ if (historyResult.isErr()) {
31656
+ throw historyResult.error;
31657
+ }
31662
31658
  return {
31663
- conversation,
31664
- history
31659
+ conversation: conversationResult.value,
31660
+ history: historyResult.value
31665
31661
  };
31666
31662
  }),
31667
31663
  startRun: fromPromise2(({ input }) => createExchangeRun(config3)(input.conversationId, { message: input.message }).then((result) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dremio/js-sdk",
3
- "version": "0.45.0",
3
+ "version": "0.45.2",
4
4
  "description": "JavaScript library for the Dremio API",
5
5
  "keywords": [
6
6
  "dremio",