@dremio/js-sdk 0.45.6 → 0.46.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/dist/cloud/ai/AIResource.d.ts +42 -5
  2. package/dist/cloud/ai/AIResource.js +2 -1
  3. package/dist/cloud/ai/AIResource.js.map +1 -1
  4. package/dist/enterprise/ai/AIResource.d.ts +43 -6
  5. package/dist/enterprise/ai/AIResource.js +2 -2
  6. package/dist/enterprise/ai/AIResource.js.map +1 -1
  7. package/dist/enterprise/ai/conversations/conversationPropertiesCodec.d.ts +1 -1
  8. package/dist/enterprise/ai/conversations/conversationPropertiesCodec.js +2 -2
  9. package/dist/enterprise/ai/conversations/conversationPropertiesCodec.js.map +1 -1
  10. package/dist/enterprise/ai/conversations/createConversationMachine.d.ts +20 -3
  11. package/dist/enterprise/ai/conversations/methods/createConversation.d.ts +10 -2
  12. package/dist/enterprise/ai/conversations/methods/createConversation.js +1 -2
  13. package/dist/enterprise/ai/conversations/methods/createConversation.js.map +1 -1
  14. package/dist/enterprise/ai/conversations/methods/listConversations.d.ts +15 -1
  15. package/dist/enterprise/ai/conversations/methods/listConversations.js +9 -6
  16. package/dist/enterprise/ai/conversations/methods/listConversations.js.map +1 -1
  17. package/dist/enterprise/ai/conversations/methods/retrieveConversation.js +1 -1
  18. package/dist/enterprise/ai/conversations/methods/retrieveConversation.js.map +1 -1
  19. package/dist/enterprise/ai/conversations/methods/retrieveConversationHistory.d.ts +4 -0
  20. package/dist/enterprise/ai/conversations/methods/retrieveConversationHistory.js +4 -0
  21. package/dist/enterprise/ai/conversations/methods/retrieveConversationHistory.js.map +1 -1
  22. package/dist-iife/cloud.js +1262 -11614
  23. package/dist-iife/enterprise.js +4408 -14725
  24. package/package.json +1 -1
@@ -10,6 +10,7 @@ import type { SignalParam } from "../../common/Params.ts";
10
10
  import { type createConversationCodec } from "../../enterprise/ai/conversations/methods/createConversation.ts";
11
11
  import type { ChatEvent } from "../../enterprise/ai/chat/chatEventSchema.ts";
12
12
  import type { HttpError } from "../../common/HttpError.ts";
13
+ import { AgentConversation } from "../../enterprise/ai/conversations/AgentConversation.ts";
13
14
  export declare class AIResource {
14
15
  #private;
15
16
  constructor(config: Logger & V4Config & SonarV4Config);
@@ -84,7 +85,16 @@ export declare class AIResource {
84
85
  } | {
85
86
  type: "REFRESH_HISTORY";
86
87
  }, {
87
- [x: string]: import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<import("../../enterprise/interfaces.ts").AgentConversation, {
88
+ [x: string]: import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<{
89
+ createdAt: import("temporal-polyfill").Temporal.Instant;
90
+ currentRunId: string | null;
91
+ id: string;
92
+ modelName: string | null;
93
+ modelProviderId: string | null;
94
+ modifiedAt: import("temporal-polyfill").Temporal.Instant;
95
+ tag: string;
96
+ title: string | null;
97
+ }, {
88
98
  message: UserChatMessage;
89
99
  modelName?: string | undefined;
90
100
  modelProviderId?: string | undefined;
@@ -455,7 +465,16 @@ export declare class AIResource {
455
465
  }, import("xstate").EventObject>> | undefined;
456
466
  }, {
457
467
  src: "createConversation";
458
- logic: import("xstate").PromiseActorLogic<import("../../enterprise/interfaces.ts").AgentConversation, {
468
+ logic: import("xstate").PromiseActorLogic<{
469
+ createdAt: import("temporal-polyfill").Temporal.Instant;
470
+ currentRunId: string | null;
471
+ id: string;
472
+ modelName: string | null;
473
+ modelProviderId: string | null;
474
+ modifiedAt: import("temporal-polyfill").Temporal.Instant;
475
+ tag: string;
476
+ title: string | null;
477
+ }, {
459
478
  message: UserChatMessage;
460
479
  modelName?: string | undefined;
461
480
  modelProviderId?: string | undefined;
@@ -878,13 +897,31 @@ export declare class AIResource {
878
897
  readonly uninitialized: {};
879
898
  };
880
899
  }>;
881
- createConversation(body: z.input<typeof createConversationCodec>): import("ts-results-es").AsyncResult<import("../../enterprise/interfaces.ts").AgentConversation, HttpError>;
900
+ createConversation(body: z.input<typeof createConversationCodec>): import("ts-results-es").AsyncResult<AgentConversation, HttpError>;
882
901
  listConversations(): {
883
- data({ signal }?: SignalParam): AsyncGenerator<import("../../enterprise/interfaces.ts").AgentConversation, void, unknown>;
902
+ data({ signal }?: SignalParam): AsyncGenerator<import("ts-results-es").Err<z.core.$ZodError<{
903
+ createdAt: import("temporal-polyfill").Temporal.Instant;
904
+ currentRunId: string | null;
905
+ id: string;
906
+ modelName: string | null;
907
+ modelProviderId: string | null;
908
+ modifiedAt: import("temporal-polyfill").Temporal.Instant;
909
+ tag: string;
910
+ title: string | null;
911
+ }>> | import("ts-results-es").Ok<AgentConversation>, void, unknown>;
884
912
  getPage: (params: {
885
913
  maxResults: number;
886
914
  }, { signal }?: SignalParam) => import("ts-results-es").AsyncResult<{
887
- data: import("../../enterprise/interfaces.ts").AgentConversation[];
915
+ data: (import("ts-results-es").Err<z.core.$ZodError<{
916
+ createdAt: import("temporal-polyfill").Temporal.Instant;
917
+ currentRunId: string | null;
918
+ id: string;
919
+ modelName: string | null;
920
+ modelProviderId: string | null;
921
+ modifiedAt: import("temporal-polyfill").Temporal.Instant;
922
+ tag: string;
923
+ title: string | null;
924
+ }>> | import("ts-results-es").Ok<AgentConversation>)[];
888
925
  }, HttpError>;
889
926
  };
890
927
  retrieveConversation(id: string, { signal }?: SignalParam): import("ts-results-es").AsyncResult<{
@@ -27,6 +27,7 @@ import { createConversation, } from "../../enterprise/ai/conversations/methods/c
27
27
  import { retrieveConversation } from "../../enterprise/ai/conversations/methods/retrieveConversation.js";
28
28
  import { retrieveConversationHistory } from "../../enterprise/ai/conversations/methods/retrieveConversationHistory.js";
29
29
  import { createConversationMachine } from "../../enterprise/ai/conversations/createConversationMachine.js";
30
+ import { AgentConversation } from "../../enterprise/ai/conversations/AgentConversation.js";
30
31
  export class AIResource {
31
32
  #config;
32
33
  constructor(config) {
@@ -51,7 +52,7 @@ export class AIResource {
51
52
  return createConversationMachine(this.#config);
52
53
  }
53
54
  createConversation(body) {
54
- return createConversation(this.#config)(body);
55
+ return createConversation(this.#config)(body).map((properties) => new AgentConversation(this.#config, properties));
55
56
  }
56
57
  listConversations() {
57
58
  const getPage = listConversations(this.#config);
@@ -1 +1 @@
1
- {"version":3,"file":"AIResource.js","sourceRoot":"","sources":["../../../src/cloud/ai/AIResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAGtE,OAAO,EAAE,aAAa,EAAE,MAAM,oDAAoD,CAAC;AACnF,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,0BAA0B,EAC1B,uBAAuB,GAExB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,0BAA0B,IAAI,8BAA8B,EAAE,MAAM,yDAAyD,CAAC;AACvI,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qDAAqD,CAAC;AAC5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,gEAAgE,CAAC;AACnG,OAAO,EACL,kBAAkB,GAEnB,MAAM,iEAAiE,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mEAAmE,CAAC;AACzG,OAAO,EAAE,2BAA2B,EAAE,MAAM,0EAA0E,CAAC;AAGvH,OAAO,EAAE,yBAAyB,EAAE,MAAM,gEAAgE,CAAC;AAE3G,MAAM,OAAO,UAAU;IACrB,OAAO,CAAoC;IAE3C,YAAY,MAAyC;QACnD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,mBAAmB,CAAC,UAAqD;QACvE,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,wBAAwB,EAAE,UAAU,C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poration\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 { ChatSession } from \"../../enterprise/ai/chat/ChatSession.ts\";\nimport type { UserChatMessage } from \"../../enterprise/ai/chat/UserChatMessage.ts\";\nimport type { Logger, SonarV4Config, V4Config } from \"../../common/Config.ts\";\nimport { ModelProvider } from \"../../enterprise/ai/modelProvider/ModelProvider.ts\";\nimport * as z from \"zod/mini\";\nimport {\n dremioProvidedSchema,\n modelProviderCreateCodec,\n modelProviderRetrieveCodec,\n safeDecodeModelProvider,\n type SafeDecodeResultWithoutDremioLLM,\n} from \"./modelProviderCodec.js\";\nimport { modelProviderRetrieveCodec as baseModelProviderRetrieveCodec } from \"../../enterprise/ai/modelProvider/modelProviderCodec.ts\";\nimport { DremioModelProvider } from \"./DremioModelProvider.ts\";\nimport { safeParseResultToResult } from \"../../common/safeParseResultToResult.ts\";\nimport { listAvailableModels } from \"../../enterprise/ai/AIResource.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport { createSendChatMessage } from \"../../enterprise/ai/chat/methods/sendChatMessage.ts\";\nimport { listConversations } from \"../../enterprise/ai/conversations/methods/listConversations.ts\";\nimport {\n createConversation,\n type createConversationCodec,\n} from \"../../enterprise/ai/conversations/methods/createConversation.ts\";\nimport { retrieveConversation } from \"../../enterprise/ai/conversations/methods/retrieveConversation.ts\";\nimport { retrieveConversationHistory } from \"../../enterprise/ai/conversations/methods/retrieveConversationHistory.ts\";\nimport type { ChatEvent } from \"../../enterprise/ai/chat/chatEventSchema.ts\";\nimport type { HttpError } from \"../../common/HttpError.ts\";\nimport { createConversationMachine } from \"../../enterprise/ai/conversations/createConversationMachine.ts\";\n\nexport class AIResource {\n #config: Logger & V4Config & SonarV4Config;\n\n constructor(config: Logger & V4Config & SonarV4Config) {\n this.#config = config;\n }\n\n createModelProvider(properties: z.output<typeof modelProviderCreateCodec>) {\n const body = z.encode(modelProviderCreateCodec, properties);\n return this.#config\n .v4Request(`model-provider/config`, {\n body: JSON.stringify(body),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n keepalive: true,\n method: \"POST\",\n })\n .map((res) => res.json() as Promise<z.input<typeof modelProviderRetrieveCodec>>)\n .andThen(\n (entity) =>\n safeDecodeModelProvider(this.#config, entity) as SafeDecodeResultWithoutDremioLLM,\n );\n }\n\n get conversationMachine() {\n return createConversationMachine(this.#config);\n }\n\n createConversation(body: z.input<typeof createConversationCodec>) {\n return createConversation(this.#config)(body);\n }\n\n listConversations() {\n const getPage = listConversations(this.#config);\n return {\n async *data({ signal }: SignalParam = {}) {\n yield* (\n await getPage({ maxResults: 100 }, { signal }).map((response) => response.data).promise\n ).unwrap();\n },\n getPage,\n };\n }\n\n retrieveConversation(id: string, { signal }: SignalParam = {}) {\n return retrieveConversation(this.#config)(id, { signal });\n }\n\n retrieveConversationHistory(id: string) {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n const getPage = (params: {}, { signal }: SignalParam = {}) =>\n retrieveConversationHistory(this.#config)(id, { signal });\n return {\n async *data(): AsyncGenerator<ChatEvent, void, HttpError> {\n const history = await getPage({}).then((result) => {\n if (result.isErr()) {\n throw result.error;\n }\n return result.value;\n });\n yield* history.data;\n },\n };\n }\n\n listModelProviders() {\n const getPage = ({ signal }: SignalParam = {}) => {\n return this.#config\n .v4Request(\"model-provider/config\", {\n headers: {\n Accept: \"application/json\",\n },\n signal,\n })\n .map(\n (res) => res.json() as Promise<{ configs: z.input<typeof modelProviderRetrieveCodec>[] }>,\n )\n .map((response) => ({\n data: response.configs.map((entity) =>\n safeParseResultToResult(z.safeDecode(modelProviderRetrieveCodec, entity)).map(\n (properties) => {\n if (\"dremioProvided\" in properties.config) {\n return new DremioModelProvider(\n this.#config,\n properties as z.infer<typeof dremioProvidedSchema>,\n );\n }\n return new ModelProvider(\n this.#config,\n properties as z.output<typeof baseModelProviderRetrieveCodec>,\n );\n },\n ),\n ),\n }));\n };\n return {\n async *data({ signal }: SignalParam = {}) {\n yield* (await getPage({ signal }).promise).map((response) => response.data).unwrap();\n },\n getPage,\n };\n }\n\n listAvailableModels(...args: Parameters<ReturnType<typeof listAvailableModels>>) {\n return listAvailableModels(this.#config)(...args);\n }\n\n retrieveModelProvider(id: string) {\n return this.#config\n .v4Request(`model-provider/config/${id}`, {\n headers: {\n Accept: \"application/json\",\n },\n })\n .map((res) => res.json() as Promise<z.input<typeof modelProviderRetrieveCodec>>)\n .andThen((entity) => safeDecodeModelProvider(this.#config, entity));\n }\n\n /**\n * Sends a chat message to the Dremio AI Agent and returns an Observable containing\n * Agent replies.\n *\n * @deprecated\n */\n sendChatMessage(chatSession: ChatSession, userChatMessage: UserChatMessage) {\n return createSendChatMessage(this.#config)(chatSession, userChatMessage);\n }\n}\n"]}
1
+ {"version":3,"file":"AIResource.js","sourceRoot":"","sources":["../../../src/cloud/ai/AIResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAGtE,OAAO,EAAE,aAAa,EAAE,MAAM,oDAAoD,CAAC;AACnF,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,0BAA0B,EAC1B,uBAAuB,GAExB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,0BAA0B,IAAI,8BAA8B,EAAE,MAAM,yDAAyD,CAAC;AACvI,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,EAAE,mBA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vF,CAAC;YACD,OAAO;SACR,CAAC;IACJ,CAAC;IAED,mBAAmB,CAAC,GAAG,IAAwD;QAC7E,OAAO,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACpD,CAAC;IAED,qBAAqB,CAAC,EAAU;QAC9B,OAAO,IAAI,CAAC,OAAO;aAChB,SAAS,CAAC,yBAAyB,EAAE,EAAE,EAAE;YACxC,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;aAC3B;SACF,CAAC;aACD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAyD,CAAC;aAC/E,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,uBAAuB,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IACxE,CAAC;IAED;;;;;OAKG;IACH,eAAe,CAAC,WAAwB,EAAE,eAAgC;QACxE,OAAO,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IAC3E,CAAC;CACF","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 { ChatSession } from \"../../enterprise/ai/chat/ChatSession.ts\";\nimport type { UserChatMessage } from \"../../enterprise/ai/chat/UserChatMessage.ts\";\nimport type { Logger, SonarV4Config, V4Config } from \"../../common/Config.ts\";\nimport { ModelProvider } from \"../../enterprise/ai/modelProvider/ModelProvider.ts\";\nimport * as z from \"zod/mini\";\nimport {\n dremioProvidedSchema,\n modelProviderCreateCodec,\n modelProviderRetrieveCodec,\n safeDecodeModelProvider,\n type SafeDecodeResultWithoutDremioLLM,\n} from \"./modelProviderCodec.js\";\nimport { modelProviderRetrieveCodec as baseModelProviderRetrieveCodec } from \"../../enterprise/ai/modelProvider/modelProviderCodec.ts\";\nimport { DremioModelProvider } from \"./DremioModelProvider.ts\";\nimport { safeParseResultToResult } from \"../../common/safeParseResultToResult.ts\";\nimport { listAvailableModels } from \"../../enterprise/ai/AIResource.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport { createSendChatMessage } from \"../../enterprise/ai/chat/methods/sendChatMessage.ts\";\nimport { listConversations } from \"../../enterprise/ai/conversations/methods/listConversations.ts\";\nimport {\n createConversation,\n type createConversationCodec,\n} from \"../../enterprise/ai/conversations/methods/createConversation.ts\";\nimport { retrieveConversation } from \"../../enterprise/ai/conversations/methods/retrieveConversation.ts\";\nimport { retrieveConversationHistory } from \"../../enterprise/ai/conversations/methods/retrieveConversationHistory.ts\";\nimport type { ChatEvent } from \"../../enterprise/ai/chat/chatEventSchema.ts\";\nimport type { HttpError } from \"../../common/HttpError.ts\";\nimport { createConversationMachine } from \"../../enterprise/ai/conversations/createConversationMachine.ts\";\nimport { AgentConversation } from \"../../enterprise/ai/conversations/AgentConversation.ts\";\n\nexport class AIResource {\n #config: Logger & V4Config & SonarV4Config;\n\n constructor(config: Logger & V4Config & SonarV4Config) {\n this.#config = config;\n }\n\n createModelProvider(properties: z.output<typeof modelProviderCreateCodec>) {\n const body = z.encode(modelProviderCreateCodec, properties);\n return this.#config\n .v4Request(`model-provider/config`, {\n body: JSON.stringify(body),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n keepalive: true,\n method: \"POST\",\n })\n .map((res) => res.json() as Promise<z.input<typeof modelProviderRetrieveCodec>>)\n .andThen(\n (entity) =>\n safeDecodeModelProvider(this.#config, entity) as SafeDecodeResultWithoutDremioLLM,\n );\n }\n\n get conversationMachine() {\n return createConversationMachine(this.#config);\n }\n\n createConversation(body: z.input<typeof createConversationCodec>) {\n return createConversation(this.#config)(body).map(\n (properties) => new AgentConversation(this.#config, properties),\n );\n }\n\n listConversations() {\n const getPage = listConversations(this.#config);\n return {\n async *data({ signal }: SignalParam = {}) {\n yield* (\n await getPage({ maxResults: 100 }, { signal }).map((response) => response.data).promise\n ).unwrap();\n },\n getPage,\n };\n }\n\n retrieveConversation(id: string, { signal }: SignalParam = {}) {\n return retrieveConversation(this.#config)(id, { signal });\n }\n\n retrieveConversationHistory(id: string) {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n const getPage = (params: {}, { signal }: SignalParam = {}) =>\n retrieveConversationHistory(this.#config)(id, { signal });\n return {\n async *data(): AsyncGenerator<ChatEvent, void, HttpError> {\n const history = await getPage({}).then((result) => {\n if (result.isErr()) {\n throw result.error;\n }\n return result.value;\n });\n yield* history.data;\n },\n };\n }\n\n listModelProviders() {\n const getPage = ({ signal }: SignalParam = {}) => {\n return this.#config\n .v4Request(\"model-provider/config\", {\n headers: {\n Accept: \"application/json\",\n },\n signal,\n })\n .map(\n (res) => res.json() as Promise<{ configs: z.input<typeof modelProviderRetrieveCodec>[] }>,\n )\n .map((response) => ({\n data: response.configs.map((entity) =>\n safeParseResultToResult(z.safeDecode(modelProviderRetrieveCodec, entity)).map(\n (properties) => {\n if (\"dremioProvided\" in properties.config) {\n return new DremioModelProvider(\n this.#config,\n properties as z.infer<typeof dremioProvidedSchema>,\n );\n }\n return new ModelProvider(\n this.#config,\n properties as z.output<typeof baseModelProviderRetrieveCodec>,\n );\n },\n ),\n ),\n }));\n };\n return {\n async *data({ signal }: SignalParam = {}) {\n yield* (await getPage({ signal }).promise).map((response) => response.data).unwrap();\n },\n getPage,\n };\n }\n\n listAvailableModels(...args: Parameters<ReturnType<typeof listAvailableModels>>) {\n return listAvailableModels(this.#config)(...args);\n }\n\n retrieveModelProvider(id: string) {\n return this.#config\n .v4Request(`model-provider/config/${id}`, {\n headers: {\n Accept: \"application/json\",\n },\n })\n .map((res) => res.json() as Promise<z.input<typeof modelProviderRetrieveCodec>>)\n .andThen((entity) => safeDecodeModelProvider(this.#config, entity));\n }\n\n /**\n * Sends a chat message to the Dremio AI Agent and returns an Observable containing\n * Agent replies.\n *\n * @deprecated\n */\n sendChatMessage(chatSession: ChatSession, userChatMessage: UserChatMessage) {\n return createSendChatMessage(this.#config)(chatSession, userChatMessage);\n }\n}\n"]}
@@ -7,8 +7,9 @@ import { modelProviderCreateCodec } from "./modelProvider/modelProviderCodec.ts"
7
7
  import type { SignalParam } from "../../common/Params.ts";
8
8
  import { listModelsPropertiesSchema } from "./modelProvider/modelProviderConfigSchemas.ts";
9
9
  import { createConversationCodec } from "./conversations/methods/createConversation.ts";
10
- import { AgentConversation, type ChatEvent } from "../interfaces.ts";
11
10
  import type { HttpError } from "../../common/HttpError.ts";
11
+ import { AgentConversation } from "./conversations/AgentConversation.ts";
12
+ import type { ChatEvent } from "./chat/chatEventSchema.ts";
12
13
  export declare function listAvailableModels(config: V4Config): (properties: z.infer<typeof listModelsPropertiesSchema>, { signal }?: SignalParam) => import("ts-results-es").AsyncResult<Set<{
13
14
  name: string;
14
15
  isRecommended: boolean;
@@ -26,7 +27,16 @@ export declare class AIResource {
26
27
  } | {
27
28
  type: "REFRESH_HISTORY";
28
29
  }, {
29
- [x: string]: import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<AgentConversation, {
30
+ [x: string]: import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<{
31
+ createdAt: import("temporal-polyfill").Temporal.Instant;
32
+ currentRunId: string | null;
33
+ id: string;
34
+ modelName: string | null;
35
+ modelProviderId: string | null;
36
+ modifiedAt: import("temporal-polyfill").Temporal.Instant;
37
+ tag: string;
38
+ title: string | null;
39
+ }, {
30
40
  message: UserChatMessage;
31
41
  modelName?: string | undefined;
32
42
  modelProviderId?: string | undefined;
@@ -397,7 +407,16 @@ export declare class AIResource {
397
407
  }, import("xstate").EventObject>> | undefined;
398
408
  }, {
399
409
  src: "createConversation";
400
- logic: import("xstate").PromiseActorLogic<AgentConversation, {
410
+ logic: import("xstate").PromiseActorLogic<{
411
+ createdAt: import("temporal-polyfill").Temporal.Instant;
412
+ currentRunId: string | null;
413
+ id: string;
414
+ modelName: string | null;
415
+ modelProviderId: string | null;
416
+ modifiedAt: import("temporal-polyfill").Temporal.Instant;
417
+ tag: string;
418
+ title: string | null;
419
+ }, {
401
420
  message: UserChatMessage;
402
421
  modelName?: string | undefined;
403
422
  modelProviderId?: string | undefined;
@@ -823,11 +842,29 @@ export declare class AIResource {
823
842
  createConversation(body: z.input<typeof createConversationCodec>): import("ts-results-es").AsyncResult<AgentConversation, HttpError>;
824
843
  createModelProvider(properties: z.output<typeof modelProviderCreateCodec>): import("ts-results-es").AsyncResult<ModelProvider, HttpError>;
825
844
  listConversations(): {
826
- data({ signal }?: SignalParam): AsyncGenerator<AgentConversation, void, unknown>;
845
+ data({ signal }?: SignalParam): AsyncGenerator<import("ts-results-es").Err<z.core.$ZodError<{
846
+ createdAt: import("temporal-polyfill").Temporal.Instant;
847
+ currentRunId: string | null;
848
+ id: string;
849
+ modelName: string | null;
850
+ modelProviderId: string | null;
851
+ modifiedAt: import("temporal-polyfill").Temporal.Instant;
852
+ tag: string;
853
+ title: string | null;
854
+ }>> | import("ts-results-es").Ok<AgentConversation>, void, unknown>;
827
855
  getPage: (params: {
828
856
  maxResults: number;
829
857
  }, { signal }?: SignalParam) => import("ts-results-es").AsyncResult<{
830
- data: AgentConversation[];
858
+ data: (import("ts-results-es").Err<z.core.$ZodError<{
859
+ createdAt: import("temporal-polyfill").Temporal.Instant;
860
+ currentRunId: string | null;
861
+ id: string;
862
+ modelName: string | null;
863
+ modelProviderId: string | null;
864
+ modifiedAt: import("temporal-polyfill").Temporal.Instant;
865
+ tag: string;
866
+ title: string | null;
867
+ }>> | import("ts-results-es").Ok<AgentConversation>)[];
831
868
  }, HttpError>;
832
869
  };
833
870
  listModelProviders(): {
@@ -951,5 +988,5 @@ export declare class AIResource {
951
988
  *
952
989
  * @deprecated
953
990
  */
954
- sendChatMessage(chatSession: ChatSession, userChatMessage: UserChatMessage): import("rxjs").Observable<import("ts-results-es").Ok<import("../interfaces.ts").AgentChatResponse<import("../interfaces.ts").AgentResponseContent>> | import("ts-results-es").Err<HttpError | import("../index.ts").Problem<"https://api.dremio.dev/problems/ai-agent/chat/agent-disabled" | "https://api.dremio.dev/problems/ai-agent/chat/input-too-large" | "https://api.dremio.dev/problems/ai-agent/chat/model-provider-not-found" | "https://api.dremio.dev/problems/ai-agent/chat/no-default-model-provider" | "https://api.dremio.dev/problems/ai-agent/chat/no-model-provider-privilege" | "https://api.dremio.dev/problems/ai-agent/chat/preview-disabled" | "https://api.dremio.dev/problems/ai-agent/chat/rate-limit-exceeded", undefined>>>;
991
+ sendChatMessage(chatSession: ChatSession, userChatMessage: UserChatMessage): import("rxjs").Observable<import("ts-results-es").Ok<import("./index.ts").AgentChatResponse<import("./index.ts").AgentResponseContent>> | import("ts-results-es").Err<HttpError | import("../index.ts").Problem<"https://api.dremio.dev/problems/ai-agent/chat/agent-disabled" | "https://api.dremio.dev/problems/ai-agent/chat/input-too-large" | "https://api.dremio.dev/problems/ai-agent/chat/model-provider-not-found" | "https://api.dremio.dev/problems/ai-agent/chat/no-default-model-provider" | "https://api.dremio.dev/problems/ai-agent/chat/no-model-provider-privilege" | "https://api.dremio.dev/problems/ai-agent/chat/preview-disabled" | "https://api.dremio.dev/problems/ai-agent/chat/rate-limit-exceeded", undefined>>>;
955
992
  }
@@ -23,9 +23,9 @@ import { createSendChatMessage } from "./chat/methods/sendChatMessage.js";
23
23
  import { listConversations } from "./conversations/methods/listConversations.js";
24
24
  import { createConversation, createConversationCodec, } from "./conversations/methods/createConversation.js";
25
25
  import { retrieveConversation } from "./conversations/methods/retrieveConversation.js";
26
- import { AgentConversation } from "../interfaces.js";
27
26
  import { retrieveConversationHistory } from "./conversations/methods/retrieveConversationHistory.js";
28
27
  import { createConversationMachine } from "./conversations/createConversationMachine.js";
28
+ import { AgentConversation } from "./conversations/AgentConversation.js";
29
29
  export function listAvailableModels(config) {
30
30
  return function listAvailableModels(properties, { signal } = {}) {
31
31
  return config
@@ -51,7 +51,7 @@ export class AIResource {
51
51
  return createConversationMachine(this.#config);
52
52
  }
53
53
  createConversation(body) {
54
- return createConversation(this.#config)(body);
54
+ return createConversation(this.#config)(body).map((properties) => new AgentConversation(this.#config, properties));
55
55
  }
56
56
  createModelProvider(properties) {
57
57
  const body = z.encode(modelProviderCreateCodec, properties);
@@ -1 +1 @@
1
- {"version":3,"file":"AIResource.js","sourceRoot":"","sources":["../../../src/enterprise/ai/AIResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EACL,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAC3F,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AACjF,OAAO,EACL,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iDAAiD,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAkB,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,2BAA2B,EAAE,MAAM,wDAAwD,CAAC;AAErG,OAAO,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAC;AAEzF,MAAM,UAAU,mBAAmB,CAAC,MAAgB;IAClD,OAAO,SAAS,mB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;oBACrB,CAAC;oBACD,OAAO,MAAM,CAAC,KAAK,CAAC;gBACtB,CAAC,CAAC,CAAC;gBACH,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;YACtB,CAAC;SACF,CAAC;IACJ,CAAC;IAED,qBAAqB,CAAC,EAAU,EAAE,EAAE,MAAM,KAAkB,EAAE;QAC5D,OAAO,IAAI,CAAC,OAAO;aAChB,SAAS,CAAC,yBAAyB,EAAE,EAAE,EAAE;YACxC,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;aAC3B;YACD,MAAM;SACP,CAAC;aACD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAyD,CAAC;aAC/E,GAAG,CACF,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAC,CAC1F,CAAC;IACN,CAAC;IAED;;;;;OAKG;IACH,eAAe,CAAC,WAAwB,EAAE,eAAgC;QACxE,OAAO,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IAC3E,CAAC;CACF","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 { ChatSession } from \"./chat/ChatSession.ts\";\nimport type { UserChatMessage } from \"./chat/UserChatMessage.ts\";\nimport type { Logger, SonarV4Config, V4Config } from \"../../common/Config.ts\";\nimport { ModelProvider } from \"./modelProvider/ModelProvider.ts\";\nimport * as z from \"zod/mini\";\nimport {\n modelProviderCreateCodec,\n modelProviderRetrieveCodec,\n} from \"./modelProvider/modelProviderCodec.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport { safeParseResultToResult } from \"../../common/safeParseResultToResult.ts\";\nimport { listModelsPropertiesSchema } from \"./modelProvider/modelProviderConfigSchemas.ts\";\nimport { createSendChatMessage } from \"./chat/methods/sendChatMessage.ts\";\nimport { listConversations } from \"./conversations/methods/listConversations.ts\";\nimport {\n createConversation,\n createConversationCodec,\n} from \"./conversations/methods/createConversation.ts\";\nimport { retrieveConversation } from \"./conversations/methods/retrieveConversation.ts\";\nimport { AgentConversation, type ChatEvent } from \"../interfaces.ts\";\nimport { retrieveConversationHistory } from \"./conversations/methods/retrieveConversationHistory.ts\";\nimport type { HttpError } from \"../../common/HttpError.ts\";\nimport { createConversationMachine } from \"./conversations/createConversationMachine.ts\";\n\nexport function listAvailableModels(config: V4Config) {\n return function listAvailableModels(\n properties: z.infer<typeof listModelsPropertiesSchema>,\n { signal }: SignalParam = {},\n ) {\n return config\n .v4Request(\"model-provider:listModels\", {\n body: JSON.stringify(z.parse(listModelsPropertiesSchema, properties)),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n method: \"POST\",\n signal,\n })\n .map((res) => res.json() as Promise<{ models: { name: string; isRecommended: boolean }[] }>)\n .map((result) => new Set(result.models));\n };\n}\n\nexport class AIResource {\n #config: Logger & V4Config & SonarV4Config;\n\n constructor(config: Logger & V4Config & SonarV4Config) {\n this.#config = config;\n }\n\n get conversationMachine() {\n return createConversationMachine(this.#config);\n }\n\n createConversation(body: z.input<typeof createConversationCodec>) {\n return createConversation(this.#config)(body);\n }\n\n createModelProvider(properties: z.output<typeof modelProviderCreateCodec>) {\n const body = z.encode(modelProviderCreateCodec, properties);\n return this.#config\n .v4Request(`model-provider/config`, {\n body: JSON.stringify(body),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n keepalive: true,\n method: \"POST\",\n })\n .map((res) => res.json() as Promise<z.input<typeof modelProviderRetrieveCodec>>)\n .map(\n (entity) => new ModelProvider(this.#config, z.decode(modelProviderRetrieveCodec, entity)),\n );\n }\n\n listConversations() {\n const getPage = listConversations(this.#config);\n return {\n async *data({ signal }: SignalParam = {}) {\n yield* (\n await getPage({ maxResults: 100 }, { signal }).map((response) => response.data).promise\n ).unwrap();\n },\n getPage,\n };\n }\n\n listModelProviders() {\n const getPage = ({ signal }: SignalParam = {}) => {\n return this.#config\n .v4Request(\"model-provider/config\", {\n headers: {\n Accept: \"application/json\",\n },\n signal,\n })\n .map(\n (res) => res.json() as Promise<{ configs: z.input<typeof modelProviderRetrieveCodec>[] }>,\n )\n .map((response) => ({\n data: response.configs.map((entity) =>\n safeParseResultToResult(z.safeDecode(modelProviderRetrieveCodec, entity)).map(\n (properties) => new ModelProvider(this.#config, properties),\n ),\n ),\n }));\n };\n return {\n async *data({ signal }: SignalParam = {}) {\n yield* (await getPage({ signal }).promise).map((response) => response.data).unwrap();\n },\n getPage,\n };\n }\n\n listAvailableModels(properties: z.infer<typeof listModelsPropertiesSchema>) {\n return listAvailableModels(this.#config)(properties);\n }\n\n retrieveConversation(id: string, { signal }: SignalParam = {}) {\n return retrieveConversation(this.#config)(id, { signal }).map(\n (properties) => new AgentConversation(this.#config, properties),\n );\n }\n\n retrieveConversationHistory(id: string) {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n const getPage = (params: {}, { signal }: SignalParam = {}) =>\n retrieveConversationHistory(this.#config)(id, { signal });\n return {\n async *data(): AsyncGenerator<ChatEvent, void, HttpError> {\n const history = await getPage({}).then((result) => {\n if (result.isErr()) {\n throw result.error;\n }\n return result.value;\n });\n yield* history.data;\n },\n };\n }\n\n retrieveModelProvider(id: string, { signal }: SignalParam = {}) {\n return this.#config\n .v4Request(`model-provider/config/${id}`, {\n headers: {\n Accept: \"application/json\",\n },\n signal,\n })\n .map((res) => res.json() as Promise<z.input<typeof modelProviderRetrieveCodec>>)\n .map(\n (entity) => new ModelProvider(this.#config, z.decode(modelProviderRetrieveCodec, entity)),\n );\n }\n\n /**\n * Sends a chat message to the Dremio AI Agent and returns an Observable containing\n * Agent replies.\n *\n * @deprecated\n */\n sendChatMessage(chatSession: ChatSession, userChatMessage: UserChatMessage) {\n return createSendChatMessage(this.#config)(chatSession, userChatMessage);\n }\n}\n"]}
1
+ {"version":3,"file":"AIResource.js","sourceRoot":"","sources":["../../../src/enterprise/ai/AIResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EACL,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAC3F,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AACjF,OAAO,EACL,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iDAAiD,CAAC;AACvF,OAAO,EAAE,2BAA2B,EAAE,MAAM,wDAAwD,CAAC;AAErG,OAAO,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAGzE,MAAM,UAAU,mBAAmB,CAAC,MAAgB;IAClD,OAAO,SAAS,mBAAmB,CACjC,UAAsD,EACtD,EAAE,MAAM,KAAkB,EAAE;QAE5B,OAAO,MAAM;aACV,SAAS,CAAC,2BAA2B,EAAE;YACtC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,CAAC;oBACrB,CAAC;oBACD,OAAO,MAAM,CAAC,KAAK,CAAC;gBACtB,CAAC,CAAC,CAAC;gBACH,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;YACtB,CAAC;SACF,CAAC;IACJ,CAAC;IAED,qBAAqB,CAAC,EAAU,EAAE,EAAE,MAAM,KAAkB,EAAE;QAC5D,OAAO,IAAI,CAAC,OAAO;aAChB,SAAS,CAAC,yBAAyB,EAAE,EAAE,EAAE;YACxC,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;aAC3B;YACD,MAAM;SACP,CAAC;aACD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAyD,CAAC;aAC/E,GAAG,CACF,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAC,CAC1F,CAAC;IACN,CAAC;IAED;;;;;OAKG;IACH,eAAe,CAAC,WAAwB,EAAE,eAAgC;QACxE,OAAO,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IAC3E,CAAC;CACF","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 { ChatSession } from \"./chat/ChatSession.ts\";\nimport type { UserChatMessage } from \"./chat/UserChatMessage.ts\";\nimport type { Logger, SonarV4Config, V4Config } from \"../../common/Config.ts\";\nimport { ModelProvider } from \"./modelProvider/ModelProvider.ts\";\nimport * as z from \"zod/mini\";\nimport {\n modelProviderCreateCodec,\n modelProviderRetrieveCodec,\n} from \"./modelProvider/modelProviderCodec.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport { safeParseResultToResult } from \"../../common/safeParseResultToResult.ts\";\nimport { listModelsPropertiesSchema } from \"./modelProvider/modelProviderConfigSchemas.ts\";\nimport { createSendChatMessage } from \"./chat/methods/sendChatMessage.ts\";\nimport { listConversations } from \"./conversations/methods/listConversations.ts\";\nimport {\n createConversation,\n createConversationCodec,\n} from \"./conversations/methods/createConversation.ts\";\nimport { retrieveConversation } from \"./conversations/methods/retrieveConversation.ts\";\nimport { retrieveConversationHistory } from \"./conversations/methods/retrieveConversationHistory.ts\";\nimport type { HttpError } from \"../../common/HttpError.ts\";\nimport { createConversationMachine } from \"./conversations/createConversationMachine.ts\";\nimport { AgentConversation } from \"./conversations/AgentConversation.ts\";\nimport type { ChatEvent } from \"./chat/chatEventSchema.ts\";\n\nexport function listAvailableModels(config: V4Config) {\n return function listAvailableModels(\n properties: z.infer<typeof listModelsPropertiesSchema>,\n { signal }: SignalParam = {},\n ) {\n return config\n .v4Request(\"model-provider:listModels\", {\n body: JSON.stringify(z.parse(listModelsPropertiesSchema, properties)),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n method: \"POST\",\n signal,\n })\n .map((res) => res.json() as Promise<{ models: { name: string; isRecommended: boolean }[] }>)\n .map((result) => new Set(result.models));\n };\n}\n\nexport class AIResource {\n #config: Logger & V4Config & SonarV4Config;\n\n constructor(config: Logger & V4Config & SonarV4Config) {\n this.#config = config;\n }\n\n get conversationMachine() {\n return createConversationMachine(this.#config);\n }\n\n createConversation(body: z.input<typeof createConversationCodec>) {\n return createConversation(this.#config)(body).map(\n (properties) => new AgentConversation(this.#config, properties),\n );\n }\n\n createModelProvider(properties: z.output<typeof modelProviderCreateCodec>) {\n const body = z.encode(modelProviderCreateCodec, properties);\n return this.#config\n .v4Request(`model-provider/config`, {\n body: JSON.stringify(body),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n keepalive: true,\n method: \"POST\",\n })\n .map((res) => res.json() as Promise<z.input<typeof modelProviderRetrieveCodec>>)\n .map(\n (entity) => new ModelProvider(this.#config, z.decode(modelProviderRetrieveCodec, entity)),\n );\n }\n\n listConversations() {\n const getPage = listConversations(this.#config);\n return {\n async *data({ signal }: SignalParam = {}) {\n yield* (\n await getPage({ maxResults: 100 }, { signal }).map((response) => response.data).promise\n ).unwrap();\n },\n getPage,\n };\n }\n\n listModelProviders() {\n const getPage = ({ signal }: SignalParam = {}) => {\n return this.#config\n .v4Request(\"model-provider/config\", {\n headers: {\n Accept: \"application/json\",\n },\n signal,\n })\n .map(\n (res) => res.json() as Promise<{ configs: z.input<typeof modelProviderRetrieveCodec>[] }>,\n )\n .map((response) => ({\n data: response.configs.map((entity) =>\n safeParseResultToResult(z.safeDecode(modelProviderRetrieveCodec, entity)).map(\n (properties) => new ModelProvider(this.#config, properties),\n ),\n ),\n }));\n };\n return {\n async *data({ signal }: SignalParam = {}) {\n yield* (await getPage({ signal }).promise).map((response) => response.data).unwrap();\n },\n getPage,\n };\n }\n\n listAvailableModels(properties: z.infer<typeof listModelsPropertiesSchema>) {\n return listAvailableModels(this.#config)(properties);\n }\n\n retrieveConversation(id: string, { signal }: SignalParam = {}) {\n return retrieveConversation(this.#config)(id, { signal }).map(\n (properties) => new AgentConversation(this.#config, properties),\n );\n }\n\n retrieveConversationHistory(id: string) {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n const getPage = (params: {}, { signal }: SignalParam = {}) =>\n retrieveConversationHistory(this.#config)(id, { signal });\n return {\n async *data(): AsyncGenerator<ChatEvent, void, HttpError> {\n const history = await getPage({}).then((result) => {\n if (result.isErr()) {\n throw result.error;\n }\n return result.value;\n });\n yield* history.data;\n },\n };\n }\n\n retrieveModelProvider(id: string, { signal }: SignalParam = {}) {\n return this.#config\n .v4Request(`model-provider/config/${id}`, {\n headers: {\n Accept: \"application/json\",\n },\n signal,\n })\n .map((res) => res.json() as Promise<z.input<typeof modelProviderRetrieveCodec>>)\n .map(\n (entity) => new ModelProvider(this.#config, z.decode(modelProviderRetrieveCodec, entity)),\n );\n }\n\n /**\n * Sends a chat message to the Dremio AI Agent and returns an Observable containing\n * Agent replies.\n *\n * @deprecated\n */\n sendChatMessage(chatSession: ChatSession, userChatMessage: UserChatMessage) {\n return createSendChatMessage(this.#config)(chatSession, userChatMessage);\n }\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.ZodMiniNullable<z.ZodMiniString<string>>;
11
+ title: z.ZodMiniOptional<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>>;
@@ -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.nullable(z.string()),
26
+ title: z.optional(z.nullable(z.string())),
27
27
  }), z.object({
28
28
  createdAt: z.instanceof(Temporal.Instant),
29
29
  currentRunId: z.nullable(z.string()),
@@ -43,7 +43,7 @@ export const conversationPropertiesCodec = z.codec(z.object({
43
43
  modelProviderId: v.modelProviderId || null,
44
44
  modifiedAt: Temporal.Instant.from(v.modifiedAt),
45
45
  tag: v.tag,
46
- title: v.title,
46
+ title: v.title || null,
47
47
  };
48
48
  },
49
49
  encode(v) {
@@ -1 +1 @@
1
- {"version":3,"file":"conversationPropertiesCodec.js","sourceRoot":"","sources":["../../../../src/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KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;CAC9B,CAAC,EACF;IACE,MAAM,CAAC,CAAC;QACN,OAAO;YACL,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;YAC7C,YAAY,EAAE,CAAC,CAAC,YAAY,IAAI,IAAI;YACpC,EAAE,EAAE,CAAC,CAAC,cAAc;YACpB,SAAS,EAAE,CAAC,CAAC,SAAS,IAAI,IAAI;YAC9B,eAAe,EAAE,CAAC,CAAC,eAAe,IAAI,IAAI;YAC1C,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC;YAC/C,GAAG,EAAE,CAAC,CAAC,GAAG;YACV,KAAK,EAAE,CAAC,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.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"]}
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,CA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;YACpC,EAAE,EAAE,CAAC,CAAC,cAAc;YACpB,SAAS,EAAE,CAAC,CAAC,SAAS,IAAI,IAAI;YAC9B,eAAe,EAAE,CAAC,CAAC,eAAe,IAAI,IAAI;YAC1C,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC;YAC/C,GAAG,EAAE,CAAC,CAAC,GAAG;YACV,KAAK,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI;SACvB,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.optional(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 || null,\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,5 +1,4 @@
1
1
  import type { UserChatMessage } from "../chat/UserChatMessage.ts";
2
- import { AgentConversation } from "./AgentConversation.ts";
3
2
  import type { ConversationExchange } from "./reduceChatEvents.ts";
4
3
  import type { SonarV4Config } from "../../../common/Config.ts";
5
4
  import { type ChatEvent } from "../chat/chatEventSchema.ts";
@@ -44,7 +43,16 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
44
43
  } | {
45
44
  type: "REFRESH_HISTORY";
46
45
  }, {
47
- [x: string]: import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<AgentConversation, {
46
+ [x: string]: import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<{
47
+ createdAt: import("temporal-polyfill").Temporal.Instant;
48
+ currentRunId: string | null;
49
+ id: string;
50
+ modelName: string | null;
51
+ modelProviderId: string | null;
52
+ modifiedAt: import("temporal-polyfill").Temporal.Instant;
53
+ tag: string;
54
+ title: string | null;
55
+ }, {
48
56
  message: UserChatMessage;
49
57
  modelName?: string | undefined;
50
58
  modelProviderId?: string | undefined;
@@ -415,7 +423,16 @@ export declare const createConversationMachine: (config: SonarV4Config) => impor
415
423
  }, import("xstate").EventObject>> | undefined;
416
424
  }, {
417
425
  src: "createConversation";
418
- logic: import("xstate").PromiseActorLogic<AgentConversation, {
426
+ logic: import("xstate").PromiseActorLogic<{
427
+ createdAt: import("temporal-polyfill").Temporal.Instant;
428
+ currentRunId: string | null;
429
+ id: string;
430
+ modelName: string | null;
431
+ modelProviderId: string | null;
432
+ modifiedAt: import("temporal-polyfill").Temporal.Instant;
433
+ tag: string;
434
+ title: string | null;
435
+ }, {
419
436
  message: UserChatMessage;
420
437
  modelName?: string | undefined;
421
438
  modelProviderId?: string | undefined;
@@ -1,8 +1,16 @@
1
1
  import * as z from "zod/mini";
2
2
  import type { SonarV4Config } from "../../../../common/Config.ts";
3
- import { AgentConversation } from "../AgentConversation.ts";
4
3
  import { UserChatMessage } from "../../chat/UserChatMessage.ts";
5
- export declare const createConversation: (config: SonarV4Config) => (body: z.input<typeof createConversationCodec>) => import("ts-results-es").AsyncResult<AgentConversation, import("../../../index.ts").HttpError>;
4
+ export declare const createConversation: (config: SonarV4Config) => (body: z.input<typeof createConversationCodec>) => import("ts-results-es").AsyncResult<{
5
+ createdAt: import("temporal-polyfill").Temporal.Instant;
6
+ currentRunId: string | null;
7
+ id: string;
8
+ modelName: string | null;
9
+ modelProviderId: string | null;
10
+ modifiedAt: import("temporal-polyfill").Temporal.Instant;
11
+ tag: string;
12
+ title: string | null;
13
+ }, import("../../../index.ts").HttpError>;
6
14
  export declare const createConversationCodec: z.ZodMiniCodec<z.ZodMiniObject<{
7
15
  message: z.ZodMiniCustom<UserChatMessage, UserChatMessage>;
8
16
  modelName: z.ZodMiniOptional<z.ZodMiniString<string>>;
@@ -15,7 +15,6 @@
15
15
  */
16
16
  import * as z from "zod/mini";
17
17
  import { conversationPropertiesCodec } from "../conversationPropertiesCodec.js";
18
- import { AgentConversation } from "../AgentConversation.js";
19
18
  import { createConversationPromptSchema, UserChatMessage } from "../../chat/UserChatMessage.js";
20
19
  export const createConversation = (config) => function createConversation(body) {
21
20
  return config
@@ -29,7 +28,7 @@ export const createConversation = (config) => function createConversation(body)
29
28
  method: "POST",
30
29
  })
31
30
  .map((res) => res.json())
32
- .map((entity) => new AgentConversation(config, z.decode(conversationPropertiesCodec, entity)));
31
+ .map((entity) => z.decode(conversationPropertiesCodec, entity));
33
32
  };
34
33
  const createConversationInSchema = z.strictObject({
35
34
  message: z.instanceof(UserChatMessage),
@@ -1 +1 @@
1
- {"version":3,"file":"createConversation.js","sourceRoot":"","sources":["../../../../../src/enterprise/ai/conversations/methods/createConversation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,8BAA8B,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhG,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAqB,EAAE,EAAE,CAC1D,SAAS,kBAAkB,CAAC,IAA6C;IACvE,OAAO,MAAM;SACV,cAAc,CAAC,qBAAqB,EAAE;QACrC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAC;QAC7D,OAAO,EAAE;YACP,MAAM,EAAE,kBAAkB;YAC1B,cAAc,EAAE,kBAAkB;SACnC;QACD,SAAS,EAAE,IAAI;QACf,MAAM,EAAE,MAAM;KACf,CAAC;SACD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAA0D,CAAC;SAChF,GAAG,CACF,CAAC,MAAM,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B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,QAAQ;aAC7B,CAAC;YACF,SAAS,EAAE,CAAC,CAAC,SAAS;YACtB,eAAe,EAAE,CAAC,CAAC,eAAe;SACnC,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 * as z from \"zod/mini\";\nimport type { SonarV4Config } from \"../../../../common/Config.ts\";\nimport { conversationPropertiesCodec } from \"../conversationPropertiesCodec.ts\";\nimport { AgentConversation } from \"../AgentConversation.ts\";\nimport { createConversationPromptSchema, UserChatMessage } from \"../../chat/UserChatMessage.ts\";\n\nexport const createConversation = (config: SonarV4Config) =>\n function createConversation(body: z.input<typeof createConversationCodec>) {\n return config\n .sonarV4Request(`agent/conversations`, {\n body: JSON.stringify(z.decode(createConversationCodec, body)),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n keepalive: true,\n method: \"POST\",\n })\n .map((res) => res.json() as Promise<z.input<typeof conversationPropertiesCodec>>)\n .map(\n (entity) => new AgentConversation(config, z.decode(conversationPropertiesCodec, entity)),\n );\n };\n\nconst createConversationInSchema = z.strictObject({\n message: z.instanceof(UserChatMessage),\n modelName: z.optional(z.string()),\n modelProviderId: z.optional(z.string()),\n});\n\nexport const createConversationCodec = z.codec(\n createConversationInSchema,\n z.extend(\n z.omit(createConversationInSchema, {\n message: true,\n }),\n {\n prompt: createConversationPromptSchema,\n },\n ),\n {\n decode(v) {\n return {\n modelName: v.modelName,\n modelProviderId: v.modelProviderId,\n prompt: {\n approvals: v.message.prompt?.approvals,\n context: v.message.prompt?.context,\n skillIds: v.message.prompt?.skillIds,\n text: v.message.content,\n },\n };\n },\n encode(v) {\n return {\n message: UserChatMessage.new(v.prompt.text, {\n approvals: v.prompt?.approvals,\n context: v.prompt?.context,\n skillIds: v.prompt?.skillIds,\n }),\n modelName: v.modelName,\n modelProviderId: v.modelProviderId,\n };\n },\n },\n);\n"]}
1
+ {"version":3,"file":"createConversation.js","sourceRoot":"","sources":["../../../../../src/enterprise/ai/conversations/methods/createConversation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,EAAE,8BAA8B,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhG,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAqB,EAAE,EAAE,CAC1D,SAAS,kBAAkB,CAAC,IAA6C;IACvE,OAAO,MAAM;SACV,cAAc,CAAC,qBAAqB,EAAE;QACrC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAC;QAC7D,OAAO,EAAE;YACP,MAAM,EAAE,kBAAkB;YAC1B,cAAc,EAAE,kBAAkB;SACnC;QACD,SAAS,EAAE,IAAI;QACf,MAAM,EAAE,MAAM;KACf,CAAC;SACD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAA0D,CAAC;SAChF,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,2BAA2B,EAAE,MAAM,CAAC,CAAC,CAAC;AACpE,CAAC,CAAC;AAEJ,MAAM,0BAA0B,GAAG,CAAC,CAAC,YAAY,CAAC;IAChD,OAAO,EAAE,CAAC,CAAC,UAAU,CAAC,eAAe,CAAC;I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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 type { SonarV4Config } from \"../../../../common/Config.ts\";\nimport { conversationPropertiesCodec } from \"../conversationPropertiesCodec.ts\";\nimport { createConversationPromptSchema, UserChatMessage } from \"../../chat/UserChatMessage.ts\";\n\nexport const createConversation = (config: SonarV4Config) =>\n function createConversation(body: z.input<typeof createConversationCodec>) {\n return config\n .sonarV4Request(`agent/conversations`, {\n body: JSON.stringify(z.decode(createConversationCodec, body)),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n keepalive: true,\n method: \"POST\",\n })\n .map((res) => res.json() as Promise<z.input<typeof conversationPropertiesCodec>>)\n .map((entity) => z.decode(conversationPropertiesCodec, entity));\n };\n\nconst createConversationInSchema = z.strictObject({\n message: z.instanceof(UserChatMessage),\n modelName: z.optional(z.string()),\n modelProviderId: z.optional(z.string()),\n});\n\nexport const createConversationCodec = z.codec(\n createConversationInSchema,\n z.extend(\n z.omit(createConversationInSchema, {\n message: true,\n }),\n {\n prompt: createConversationPromptSchema,\n },\n ),\n {\n decode(v) {\n return {\n modelName: v.modelName,\n modelProviderId: v.modelProviderId,\n prompt: {\n approvals: v.message.prompt?.approvals,\n context: v.message.prompt?.context,\n skillIds: v.message.prompt?.skillIds,\n text: v.message.content,\n },\n };\n },\n encode(v) {\n return {\n message: UserChatMessage.new(v.prompt.text, {\n approvals: v.prompt?.approvals,\n context: v.prompt?.context,\n skillIds: v.prompt?.skillIds,\n }),\n modelName: v.modelName,\n modelProviderId: v.modelProviderId,\n };\n },\n },\n);\n"]}
@@ -1,8 +1,22 @@
1
+ import * as z from "zod/mini";
1
2
  import type { SonarV4Config } from "../../../../common/Config.ts";
2
3
  import type { SignalParam } from "../../../../common/Params.ts";
3
4
  import { AgentConversation } from "../AgentConversation.ts";
4
5
  export declare const listConversations: (config: SonarV4Config) => (params: {
5
6
  maxResults: number;
6
7
  }, { signal }?: SignalParam) => import("ts-results-es").AsyncResult<{
7
- data: AgentConversation[];
8
+ /**
9
+ * Safe parse individual list items so that the consumer has the option to still display and of the
10
+ * conversations that parsed successfully, while ignoring others that failed to parse.
11
+ */
12
+ data: (import("ts-results-es").Err<z.core.$ZodError<{
13
+ createdAt: import("temporal-polyfill").Temporal.Instant;
14
+ currentRunId: string | null;
15
+ id: string;
16
+ modelName: string | null;
17
+ modelProviderId: string | null;
18
+ modifiedAt: import("temporal-polyfill").Temporal.Instant;
19
+ tag: string;
20
+ title: string | null;
21
+ }>> | import("ts-results-es").Ok<AgentConversation>)[];
8
22
  }, import("../../../index.ts").HttpError>;
@@ -16,15 +16,18 @@
16
16
  import * as z from "zod/mini";
17
17
  import { AgentConversation } from "../AgentConversation.js";
18
18
  import { conversationPropertiesCodec, } from "../conversationPropertiesCodec.js";
19
+ import { safeParseResultToResult } from "../../../../common/safeParseResultToResult.js";
19
20
  export const listConversations = (config) => function listConversations(params, { signal } = {}) {
20
21
  return config
21
22
  .sonarV4Request(`agent/conversations?${new URLSearchParams({ maxResults: String(params.maxResults) }).toString()}`, { signal })
22
23
  .map((res) => res.json())
23
- .map((response) => {
24
- return {
25
- ...response,
26
- data: response.data.map((entity) => new AgentConversation(config, z.decode(conversationPropertiesCodec, entity))),
27
- };
28
- });
24
+ .map((response) => ({
25
+ ...response,
26
+ /**
27
+ * Safe parse individual list items so that the consumer has the option to still display and of the
28
+ * conversations that parsed successfully, while ignoring others that failed to parse.
29
+ */
30
+ data: response.data.map((entity) => safeParseResultToResult(z.safeDecode(conversationPropertiesCodec, entity)).map((properties) => new AgentConversation(config, properties))),
31
+ }));
29
32
  };
30
33
  //# sourceMappingURL=listConversations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"listConversations.js","sourceRoot":"","sources":["../../../../../src/enterprise/ai/conversations/methods/listConversations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAG9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EACL,2BAA2B,GAE5B,MAAM,mCAAmC,CAAC;AAE3C,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAqB,EAAE,EAAE,CACzD,SAAS,iBAAiB,CAAC,MAA8B,EAAE,EAAE,MAAM,KAAkB,EAAE;IACrF,OAAO,MAAM;SACV,cAAc,CACb,uBAAuB,IAAI,eAAe,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,EAClG,EAAE,MAAM,EAAE,CACX;SACA,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAA6C,CAAC;SACnE,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;QAChB,OAAO;YACL,GAAG,QAAQ;YACX,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CACrB,CAAC,MAAM,EAAE,EAAE,CACT,IAAI,iBAAiB,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,2BAA2B,EAAE,MAAM,CAAC,CAAC,CAC/E;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,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 * as z from \"zod/mini\";\nimport type { SonarV4Config } from \"../../../../common/Config.ts\";\nimport type { SignalParam } from \"../../../../common/Params.ts\";\nimport { AgentConversation } from \"../AgentConversation.ts\";\nimport {\n conversationPropertiesCodec,\n type ConversationEntity,\n} from \"../conversationPropertiesCodec.ts\";\n\nexport const listConversations = (config: SonarV4Config) =>\n function listConversations(params: { maxResults: number }, { signal }: SignalParam = {}) {\n return config\n .sonarV4Request(\n `agent/conversations?${new URLSearchParams({ maxResults: String(params.maxResults) }).toString()}`,\n { signal },\n )\n .map((res) => res.json() as Promise<{ data: ConversationEntity[] }>)\n .map((response) => {\n return {\n ...response,\n data: response.data.map(\n (entity) =>\n new AgentConversation(config, z.decode(conversationPropertiesCodec, entity)),\n ),\n };\n });\n };\n"]}
1
+ {"version":3,"file":"listConversations.js","sourceRoot":"","sources":["../../../../../src/enterprise/ai/conversations/methods/listConversations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAG9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EACL,2BAA2B,GAE5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAC;AAExF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAqB,EAAE,EAAE,CACzD,SAAS,iBAAiB,CAAC,MAA8B,EAAE,EAAE,MAAM,KAAkB,EAAE;IACrF,OAAO,MAAM;SACV,cAAc,CACb,uBAAuB,IAAI,eAAe,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,EAClG,EAAE,MAAM,EAAE,CACX;SACA,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAA6C,CAAC;SACnE,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAClB,GAAG,QAAQ;QACX;;;WAGG;QACH,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CACjC,uBAAuB,CAAC,CAAC,CAAC,UAAU,CAAC,2BAA2B,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAC5E,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,iBAAiB,CAAC,MAAM,EAAE,UAAU,CAAC,CAC1D,CACF;KACF,CAAC,CAAC,CAAC;AACR,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 * as z from \"zod/mini\";\nimport type { SonarV4Config } from \"../../../../common/Config.ts\";\nimport type { SignalParam } from \"../../../../common/Params.ts\";\nimport { AgentConversation } from \"../AgentConversation.ts\";\nimport {\n conversationPropertiesCodec,\n type ConversationEntity,\n} from \"../conversationPropertiesCodec.ts\";\nimport { safeParseResultToResult } from \"../../../../common/safeParseResultToResult.ts\";\n\nexport const listConversations = (config: SonarV4Config) =>\n function listConversations(params: { maxResults: number }, { signal }: SignalParam = {}) {\n return config\n .sonarV4Request(\n `agent/conversations?${new URLSearchParams({ maxResults: String(params.maxResults) }).toString()}`,\n { signal },\n )\n .map((res) => res.json() as Promise<{ data: ConversationEntity[] }>)\n .map((response) => ({\n ...response,\n /**\n * Safe parse individual list items so that the consumer has the option to still display and of the\n * conversations that parsed successfully, while ignoring others that failed to parse.\n */\n data: response.data.map((entity) =>\n safeParseResultToResult(z.safeDecode(conversationPropertiesCodec, entity)).map(\n (properties) => new AgentConversation(config, properties),\n ),\n ),\n }));\n };\n"]}
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import z from "zod";
16
+ import * as z from "zod/mini";
17
17
  import { conversationPropertiesCodec } from "../conversationPropertiesCodec.js";
18
18
  export const retrieveConversation = (config) => function retrieveConversation(id, { signal } = {}) {
19
19
  return config
@@ -1 +1 @@
1
- {"version":3,"file":"retrieveConversation.js","sourceRoot":"","sources":["../../../../../src/enterprise/ai/conversations/methods/retrieveConversation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,CAAC,MAAM,KAAK,CAAC;AAGpB,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAEhF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,MAAqB,EAAE,EAAE,CAC5D,SAAS,oBAAoB,CAAC,EAAU,EAAE,EAAE,MAAM,KAAkB,EAAE;IACpE,OAAO,MAAM;SACV,cAAc,CAAC,uBAAuB,EAAE,EAAE,EAAE;QAC3C,OAAO,EAAE;YACP,MAAM,EAAE,kBAAkB;SAC3B;QACD,MAAM;KACP,CAAC;SACD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAA0D,CAAC;SAChF,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,2BAA2B,EAAE,MAAM,CAAC,CAAC,CAAC;AACpE,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 z from \"zod\";\nimport type { SonarV4Config } from \"../../../../common/Config.ts\";\nimport type { SignalParam } from \"../../../../common/Params.ts\";\nimport { conversationPropertiesCodec } from \"../conversationPropertiesCodec.ts\";\n\nexport const retrieveConversation = (config: SonarV4Config) =>\n function retrieveConversation(id: string, { signal }: SignalParam = {}) {\n return config\n .sonarV4Request(`agent/conversations/${id}`, {\n headers: {\n Accept: \"application/json\",\n },\n signal,\n })\n .map((res) => res.json() as Promise<z.input<typeof conversationPropertiesCodec>>)\n .map((entity) => z.decode(conversationPropertiesCodec, entity));\n };\n"]}
1
+ {"version":3,"file":"retrieveConversation.js","sourceRoot":"","sources":["../../../../../src/enterprise/ai/conversations/methods/retrieveConversation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAG9B,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAEhF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,MAAqB,EAAE,EAAE,CAC5D,SAAS,oBAAoB,CAAC,EAAU,EAAE,EAAE,MAAM,KAAkB,EAAE;IACpE,OAAO,MAAM;SACV,cAAc,CAAC,uBAAuB,EAAE,EAAE,EAAE;QAC3C,OAAO,EAAE;YACP,MAAM,EAAE,kBAAkB;SAC3B;QACD,MAAM;KACP,CAAC;SACD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAA0D,CAAC;SAChF,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,2BAA2B,EAAE,MAAM,CAAC,CAAC,CAAC;AACpE,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 * as z from \"zod/mini\";\nimport type { SonarV4Config } from \"../../../../common/Config.ts\";\nimport type { SignalParam } from \"../../../../common/Params.ts\";\nimport { conversationPropertiesCodec } from \"../conversationPropertiesCodec.ts\";\n\nexport const retrieveConversation = (config: SonarV4Config) =>\n function retrieveConversation(id: string, { signal }: SignalParam = {}) {\n return config\n .sonarV4Request(`agent/conversations/${id}`, {\n headers: {\n Accept: \"application/json\",\n },\n signal,\n })\n .map((res) => res.json() as Promise<z.input<typeof conversationPropertiesCodec>>)\n .map((entity) => z.decode(conversationPropertiesCodec, entity));\n };\n"]}
@@ -1,6 +1,10 @@
1
1
  import type { SonarV4Config } from "../../../../common/Config.ts";
2
2
  import type { SignalParam } from "../../../../common/Params.ts";
3
3
  export declare const retrieveConversationHistory: (config: SonarV4Config) => (id: string, { signal }?: SignalParam) => import("ts-results-es").AsyncResult<{
4
+ /**
5
+ * Intentionally throw when parsing chat events (rather than using safeDecode)
6
+ * because the chat history may fail to reconstruct without one of these items.
7
+ */
4
8
  data: ({
5
9
  conversationId: string;
6
10
  modelName: string;
@@ -26,6 +26,10 @@ export const retrieveConversationHistory = (config) => function retrieveConversa
26
26
  .map((res) => res.json())
27
27
  .map((response) => ({
28
28
  ...response,
29
+ /**
30
+ * Intentionally throw when parsing chat events (rather than using safeDecode)
31
+ * because the chat history may fail to reconstruct without one of these items.
32
+ */
29
33
  data: response.data.map((chatEvent) => z.decode(chatEventCodec, chatEvent)),
30
34
  }));
31
35
  };