@dremio/js-sdk 0.39.0 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/cloud/ai/AIResource.d.ts +6 -2
  2. package/dist/cloud/ai/AIResource.js +2 -2
  3. package/dist/cloud/ai/AIResource.js.map +1 -1
  4. package/dist/cloud/ai/index.d.ts +1 -1
  5. package/dist/cloud/ai/index.js +1 -1
  6. package/dist/cloud/ai/index.js.map +1 -1
  7. package/dist/cloud/ai/modelProviderCodec.d.ts +36 -26
  8. package/dist/cloud/ai/modelProviderCodec.js +2 -2
  9. package/dist/cloud/ai/modelProviderCodec.js.map +1 -1
  10. package/dist/enterprise/ai/AIResource.d.ts +6 -4
  11. package/dist/enterprise/ai/AIResource.js +4 -4
  12. package/dist/enterprise/ai/AIResource.js.map +1 -1
  13. package/dist/enterprise/ai/chat/ChatSession.d.ts +22 -7
  14. package/dist/enterprise/ai/chat/ChatSession.js +57 -22
  15. package/dist/enterprise/ai/chat/ChatSession.js.map +1 -1
  16. package/dist/enterprise/ai/chat/ChatSessionClient.d.ts +1 -4
  17. package/dist/enterprise/ai/chat/ChatSessionClient.js +9 -12
  18. package/dist/enterprise/ai/chat/ChatSessionClient.js.map +1 -1
  19. package/dist/enterprise/ai/chat/eventWrappers/AgentChatExchange.d.ts +1 -1
  20. package/dist/enterprise/ai/chat/eventWrappers/AgentChatExchange.js.map +1 -1
  21. package/dist/enterprise/ai/chat/{AgentChatPartialResponse.d.ts → eventWrappers/AgentChatPartialResponse.d.ts} +9 -3
  22. package/dist/enterprise/ai/chat/{AgentChatPartialResponse.js → eventWrappers/AgentChatPartialResponse.js} +1 -1
  23. package/dist/enterprise/ai/chat/eventWrappers/AgentChatPartialResponse.js.map +1 -0
  24. package/dist/enterprise/ai/chat/{AgentChatResponse.d.ts → eventWrappers/AgentChatResponse.d.ts} +5 -5
  25. package/dist/enterprise/ai/chat/{AgentChatResponse.js → eventWrappers/AgentChatResponse.js} +10 -10
  26. package/dist/enterprise/ai/chat/eventWrappers/AgentChatResponse.js.map +1 -0
  27. package/dist/enterprise/ai/chat/eventWrappers/AgentToolCall.d.ts +3 -3
  28. package/dist/enterprise/ai/chat/eventWrappers/AgentToolCall.js +3 -3
  29. package/dist/enterprise/ai/chat/eventWrappers/AgentToolCall.js.map +1 -1
  30. package/dist/enterprise/ai/chat/eventWrappers/AgentToolCallGroup.d.ts +3 -3
  31. package/dist/enterprise/ai/chat/eventWrappers/AgentToolCallGroup.js.map +1 -1
  32. package/dist/enterprise/ai/chat/index.d.ts +6 -6
  33. package/dist/enterprise/ai/chat/index.js +6 -6
  34. package/dist/enterprise/ai/chat/index.js.map +1 -1
  35. package/dist/enterprise/ai/chat/methods/sendChatMessage.d.ts +2 -2
  36. package/dist/enterprise/ai/chat/methods/sendChatMessage.js +3 -3
  37. package/dist/enterprise/ai/chat/methods/sendChatMessage.js.map +1 -1
  38. package/dist/enterprise/ai/chat/responseContent/AgentErrorResponseContent.js.map +1 -0
  39. package/dist/enterprise/ai/chat/responseContent/AgentModelResponseContent.js.map +1 -0
  40. package/dist/enterprise/ai/chat/responseContent/AgentToolRequestResponseContent.js.map +1 -0
  41. package/dist/enterprise/ai/chat/responseContent/AgentToolResultResponseContent.js.map +1 -0
  42. package/dist/enterprise/ai/index.d.ts +1 -1
  43. package/dist/enterprise/ai/index.js +1 -1
  44. package/dist/enterprise/ai/index.js.map +1 -1
  45. package/dist/enterprise/ai/{ModelProvider.d.ts → modelProvider/ModelProvider.d.ts} +39 -29
  46. package/dist/enterprise/ai/{ModelProvider.js → modelProvider/ModelProvider.js} +1 -1
  47. package/dist/enterprise/ai/modelProvider/ModelProvider.js.map +1 -0
  48. package/dist/enterprise/ai/{modelProviderCodec.d.ts → modelProvider/modelProviderCodec.d.ts} +100 -70
  49. package/dist/enterprise/ai/modelProvider/modelProviderCodec.js.map +1 -0
  50. package/dist/enterprise/ai/{modelProviderConfigSchemas.d.ts → modelProvider/modelProviderConfigSchemas.d.ts} +60 -45
  51. package/dist/enterprise/ai/{modelProviderConfigSchemas.js → modelProvider/modelProviderConfigSchemas.js} +27 -25
  52. package/dist/enterprise/ai/modelProvider/modelProviderConfigSchemas.js.map +1 -0
  53. package/package.json +22 -6
  54. package/dist/enterprise/ai/ModelProvider.js.map +0 -1
  55. package/dist/enterprise/ai/chat/AgentChatPartialResponse.js.map +0 -1
  56. package/dist/enterprise/ai/chat/AgentChatResponse.js.map +0 -1
  57. package/dist/enterprise/ai/chat/AgentErrorResponseContent.js.map +0 -1
  58. package/dist/enterprise/ai/chat/AgentModelResponseContent.js.map +0 -1
  59. package/dist/enterprise/ai/chat/AgentToolRequestResponseContent.js.map +0 -1
  60. package/dist/enterprise/ai/chat/AgentToolResultResponseContent.js.map +0 -1
  61. package/dist/enterprise/ai/modelProviderCodec.js.map +0 -1
  62. package/dist/enterprise/ai/modelProviderConfigSchemas.js.map +0 -1
  63. /package/dist/enterprise/ai/chat/{AgentErrorResponseContent.d.ts → responseContent/AgentErrorResponseContent.d.ts} +0 -0
  64. /package/dist/enterprise/ai/chat/{AgentErrorResponseContent.js → responseContent/AgentErrorResponseContent.js} +0 -0
  65. /package/dist/enterprise/ai/chat/{AgentModelResponseContent.d.ts → responseContent/AgentModelResponseContent.d.ts} +0 -0
  66. /package/dist/enterprise/ai/chat/{AgentModelResponseContent.js → responseContent/AgentModelResponseContent.js} +0 -0
  67. /package/dist/enterprise/ai/chat/{AgentToolRequestResponseContent.d.ts → responseContent/AgentToolRequestResponseContent.d.ts} +0 -0
  68. /package/dist/enterprise/ai/chat/{AgentToolRequestResponseContent.js → responseContent/AgentToolRequestResponseContent.js} +0 -0
  69. /package/dist/enterprise/ai/chat/{AgentToolResultResponseContent.d.ts → responseContent/AgentToolResultResponseContent.d.ts} +0 -0
  70. /package/dist/enterprise/ai/chat/{AgentToolResultResponseContent.js → responseContent/AgentToolResultResponseContent.js} +0 -0
  71. /package/dist/enterprise/ai/{modelProviderCodec.js → modelProvider/modelProviderCodec.js} +0 -0
@@ -1,13 +1,13 @@
1
1
  import { ChatSession } from "../../enterprise/ai/chat/ChatSession.ts";
2
2
  import type { UserChatMessage } from "../../enterprise/ai/chat/UserChatMessage.ts";
3
3
  import type { Logger, SonarV4Config, V4Config } from "../../common/Config.ts";
4
- import { ModelProvider } from "../../enterprise/ai/ModelProvider.ts";
4
+ import { ModelProvider } from "../../enterprise/ai/modelProvider/ModelProvider.ts";
5
5
  import * as z from "zod/mini";
6
6
  import { modelProviderCreateCodec } from "./modelProviderCodec.js";
7
7
  import { DremioModelProvider } from "./DremioModelProvider.ts";
8
8
  import { listAvailableModels } from "../../enterprise/ai/AIResource.ts";
9
9
  import type { SignalParam } from "../../common/Params.ts";
10
- import type { AgentChatResponse, AgentResponseContent } from "../../enterprise/ai/chat/AgentChatResponse.ts";
10
+ import type { AgentChatResponse, AgentResponseContent } from "../../enterprise/ai/chat/eventWrappers/AgentChatResponse.ts";
11
11
  import { type Observable } from "rxjs";
12
12
  import { AgentChatExchange } from "../../enterprise/ai/chat/eventWrappers/AgentChatExchange.ts";
13
13
  import { ChatSessionClient } from "../../enterprise/ai/chat/ChatSessionClient.ts";
@@ -50,6 +50,7 @@ export declare class AIResource {
50
50
  } | {
51
51
  openAi: {
52
52
  organizationId: string;
53
+ region: "GLOBAL" | "US" | "EU";
53
54
  };
54
55
  };
55
56
  defaultModelName: string;
@@ -105,6 +106,7 @@ export declare class AIResource {
105
106
  } | {
106
107
  openAi: {
107
108
  organizationId: string;
109
+ region: "GLOBAL" | "US" | "EU";
108
110
  };
109
111
  };
110
112
  defaultModelName: string;
@@ -160,6 +162,7 @@ export declare class AIResource {
160
162
  } | {
161
163
  openAi: {
162
164
  organizationId: string;
165
+ region: "GLOBAL" | "US" | "EU";
163
166
  };
164
167
  };
165
168
  defaultModelName: string;
@@ -217,6 +220,7 @@ export declare class AIResource {
217
220
  } | {
218
221
  openAi: {
219
222
  organizationId: string;
223
+ region: "GLOBAL" | "US" | "EU";
220
224
  };
221
225
  };
222
226
  defaultModelName: string;
@@ -14,10 +14,10 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { ChatSession } from "../../enterprise/ai/chat/ChatSession.js";
17
- import { ModelProvider } from "../../enterprise/ai/ModelProvider.js";
17
+ import { ModelProvider } from "../../enterprise/ai/modelProvider/ModelProvider.js";
18
18
  import * as z from "zod/mini";
19
19
  import { dremioProvidedSchema, modelProviderCreateCodec, modelProviderRetrieveCodec, safeDecodeModelProvider, } from "./modelProviderCodec.js";
20
- import { modelProviderRetrieveCodec as baseModelProviderRetrieveCodec } from "../../enterprise/ai/modelProviderCodec.js";
20
+ import { modelProviderRetrieveCodec as baseModelProviderRetrieveCodec } from "../../enterprise/ai/modelProvider/modelProviderCodec.js";
21
21
  import { DremioModelProvider } from "./DremioModelProvider.js";
22
22
  import { safeParseResultToResult } from "../../common/safeParseResultToResult.js";
23
23
  import { listAvailableModels } from "../../enterprise/ai/AIResource.js";
@@ -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,sCAAsC,CAAC;AACrE,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,2CAA2C,CAAC;AACzH,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,M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AwB,EAAE,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC;SACnE,CAAC,CAAC;IACL,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.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/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 type {\n AgentChatResponse,\n AgentResponseContent,\n} from \"../../enterprise/ai/chat/AgentChatResponse.ts\";\nimport {\n catchError,\n concatMap,\n endWith,\n map,\n of,\n scan,\n share,\n startWith,\n type Observable,\n} from \"rxjs\";\nimport { AgentEndTurn } from \"../../enterprise/ai/chat/eventWrappers/AgentEndTurn.ts\";\nimport { AgentChatExchange } from \"../../enterprise/ai/chat/eventWrappers/AgentChatExchange.ts\";\nimport { ChatSessionClient } from \"../../enterprise/ai/chat/ChatSessionClient.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 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 sendChatMessage(chatSession: ChatSession, userChatMessage: UserChatMessage) {\n return createSendChatMessage(this.#config)(chatSession, userChatMessage);\n }\n\n /**\n * Creates an Observable that emits each time the `AgentChatExchange` is updated\n * with events from the Agent.\n */\n createAgentChatExchange$<T extends AgentResponseContent>(\n chatSession: ChatSession,\n userChatMessage: UserChatMessage,\n options: {\n mapChatEvents?: (\n v: AgentChatResponse<AgentResponseContent>,\n ) => Observable<AgentChatResponse<T>>;\n } = {},\n ) {\n const initialAgentChatExchange = new AgentChatExchange(userChatMessage, []);\n\n return this.sendChatMessage(chatSession, userChatMessage).pipe(\n map((eventResult) => eventResult.unwrap()),\n concatMap((agentChatEvent) => options.mapChatEvents?.(agentChatEvent) || of(agentChatEvent)),\n endWith(new AgentEndTurn({ type: \"reply_finished\" })),\n catchError((error: unknown) => of(new AgentEndTurn({ error, type: \"error\" }))),\n scan(\n (agentChatExchange, agentChatEvent) => agentChatExchange._addChatEvent(agentChatEvent),\n initialAgentChatExchange,\n ),\n startWith(initialAgentChatExchange),\n share(),\n );\n }\n\n createChatSessionClient(chatSession: ChatSession) {\n return new ChatSessionClient({\n chatSession,\n createAgentChatExchange$: this.createAgentChatExchange$.bind(this),\n });\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,E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AiB,EAAE,cAAc,EAAE,EAAE,CAAC,iBAAiB,CAAC,aAAa,CAAC,cAAc,CAAC,EACtF,wBAAwB,CACzB,EACD,SAAS,CAAC,wBAAwB,CAAC,EACnC,KAAK,EAAE,CACR,CAAC;IACJ,CAAC;IAED,uBAAuB,CAAC,WAAwB;QAC9C,OAAO,IAAI,iBAAiB,CAAC;YAC3B,WAAW;YACX,wBAAwB,EAAE,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC;SACnE,CAAC,CAAC;IACL,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 type {\n AgentChatResponse,\n AgentResponseContent,\n} from \"../../enterprise/ai/chat/eventWrappers/AgentChatResponse.ts\";\nimport {\n catchError,\n concatMap,\n endWith,\n map,\n of,\n scan,\n share,\n startWith,\n type Observable,\n} from \"rxjs\";\nimport { AgentEndTurn } from \"../../enterprise/ai/chat/eventWrappers/AgentEndTurn.ts\";\nimport { AgentChatExchange } from \"../../enterprise/ai/chat/eventWrappers/AgentChatExchange.ts\";\nimport { ChatSessionClient } from \"../../enterprise/ai/chat/ChatSessionClient.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 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 sendChatMessage(chatSession: ChatSession, userChatMessage: UserChatMessage) {\n return createSendChatMessage(this.#config)(chatSession, userChatMessage);\n }\n\n /**\n * Creates an Observable that emits each time the `AgentChatExchange` is updated\n * with events from the Agent.\n */\n createAgentChatExchange$<T extends AgentResponseContent>(\n chatSession: ChatSession,\n userChatMessage: UserChatMessage,\n options: {\n mapChatEvents?: (\n v: AgentChatResponse<AgentResponseContent>,\n ) => Observable<AgentChatResponse<T>>;\n } = {},\n ) {\n const initialAgentChatExchange = new AgentChatExchange(userChatMessage, []);\n\n return this.sendChatMessage(chatSession, userChatMessage).pipe(\n map((eventResult) => eventResult.unwrap()),\n concatMap((agentChatEvent) => options.mapChatEvents?.(agentChatEvent) || of(agentChatEvent)),\n endWith(new AgentEndTurn({ type: \"reply_finished\" })),\n catchError((error: unknown) => of(new AgentEndTurn({ error, type: \"error\" }))),\n scan(\n (agentChatExchange, agentChatEvent) => agentChatExchange._addChatEvent(agentChatEvent),\n initialAgentChatExchange,\n ),\n startWith(initialAgentChatExchange),\n share(),\n );\n }\n\n createChatSessionClient(chatSession: ChatSession) {\n return new ChatSessionClient({\n chatSession,\n createAgentChatExchange$: this.createAgentChatExchange$.bind(this),\n });\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  import { DremioModelProvider } from "./DremioModelProvider.ts";
2
- import { ModelProvider } from "../../enterprise/ai/ModelProvider.ts";
2
+ import { ModelProvider } from "../../enterprise/ai/modelProvider/ModelProvider.ts";
3
3
  export { ModelProvider, DremioModelProvider };
4
4
  export * from "../../enterprise/ai/chat/index.ts";
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { DremioModelProvider } from "./DremioModelProvider.js";
17
- import { ModelProvider } from "../../enterprise/ai/ModelProvider.js";
17
+ import { ModelProvider } from "../../enterprise/ai/modelProvider/ModelProvider.js";
18
18
  export { ModelProvider, DremioModelProvider };
19
19
  export * from "../../enterprise/ai/chat/index.js";
20
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cloud/ai/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,CAAC;AAC9C,cAAc,mCAAmC,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 { DremioModelProvider } from \"./DremioModelProvider.ts\";\nimport { ModelProvider } from \"../../enterprise/ai/ModelProvider.ts\";\nexport { ModelProvider, DremioModelProvider };\nexport * from \"../../enterprise/ai/chat/index.ts\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cloud/ai/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,oDAAoD,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,CAAC;AAC9C,cAAc,mCAAmC,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 { DremioModelProvider } from \"./DremioModelProvider.ts\";\nimport { ModelProvider } from \"../../enterprise/ai/modelProvider/ModelProvider.ts\";\nexport { ModelProvider, DremioModelProvider };\nexport * from \"../../enterprise/ai/chat/index.ts\";\n"]}
@@ -1,5 +1,5 @@
1
1
  import * as z from "zod/mini";
2
- import { modelProviderCreateCodec, modelProviderUpdateCodec } from "../../enterprise/ai/modelProviderCodec.ts";
2
+ import { modelProviderCreateCodec, modelProviderUpdateCodec } from "../../enterprise/ai/modelProvider/modelProviderCodec.ts";
3
3
  import { Result } from "ts-results-es";
4
4
  import { DremioModelProvider } from "./DremioModelProvider.ts";
5
5
  import type { V4Config } from "../../common/Config.ts";
@@ -8,7 +8,7 @@ export { modelProviderCreateCodec, modelProviderUpdateCodec };
8
8
  export declare const dremioProvidedSchema: z.ZodMiniObject<{
9
9
  config: z.ZodMiniObject<{
10
10
  dremioProvided: z.ZodMiniObject<Record<never, z.core.SomeType>, z.core.$strip>;
11
- }, z.core.$strict>;
11
+ }, z.core.$strip>;
12
12
  defaultModelName: z.ZodMiniString<string>;
13
13
  id: z.ZodMiniString<string>;
14
14
  isDefault: z.ZodMiniBoolean<boolean>;
@@ -32,37 +32,42 @@ export declare const modelProviderRetrieveCodec: z.ZodMiniCodec<z.ZodMiniUnion<r
32
32
  auth: z.ZodMiniUnion<readonly [z.ZodMiniObject<{
33
33
  accessKey: z.ZodMiniObject<{
34
34
  accessKeyId: z.ZodMiniString<string>;
35
- }, z.core.$strict>;
36
- }, z.core.$strict>, z.ZodMiniObject<{
35
+ }, z.core.$strip>;
36
+ }, z.core.$strip>, z.ZodMiniObject<{
37
37
  role: z.ZodMiniObject<{
38
38
  roleArn: z.ZodMiniString<string>;
39
- }, z.core.$strict>;
40
- }, z.core.$strict>]>;
39
+ }, z.core.$strip>;
40
+ }, z.core.$strip>]>;
41
41
  region: z.ZodMiniString<string>;
42
- }, z.core.$strict>;
42
+ }, z.core.$strip>;
43
43
  }, z.core.$strict>, z.ZodMiniObject<{
44
- anthropic: z.ZodMiniObject<{}, z.core.$strict>;
44
+ anthropic: z.ZodMiniObject<{}, z.core.$strip>;
45
45
  }, z.core.$strict>, z.ZodMiniObject<{
46
46
  azureOpenAi: z.ZodMiniObject<{
47
47
  auth: z.ZodMiniObject<{
48
48
  clientSecretAuth: z.ZodMiniObject<{
49
49
  azureClientId: z.ZodMiniString<string>;
50
50
  azureTenantId: z.ZodMiniString<string>;
51
- }, z.core.$strict>;
52
- }, z.core.$strict>;
51
+ }, z.core.$strip>;
52
+ }, z.core.$strip>;
53
53
  resourceName: z.ZodMiniString<string>;
54
- }, z.core.$strict>;
54
+ }, z.core.$strip>;
55
55
  }, z.core.$strict>, z.ZodMiniObject<{
56
- googleGemini: z.ZodMiniObject<{}, z.core.$strict>;
56
+ googleGemini: z.ZodMiniObject<{}, z.core.$strip>;
57
57
  }, z.core.$strict>, z.ZodMiniObject<{
58
58
  openAi: z.ZodMiniObject<{
59
59
  organizationId: z.ZodMiniString<string>;
60
- }, z.core.$strict>;
60
+ region: z.ZodMiniEnum<{
61
+ GLOBAL: "GLOBAL";
62
+ US: "US";
63
+ EU: "EU";
64
+ }>;
65
+ }, z.core.$strip>;
61
66
  }, z.core.$strict>]>;
62
67
  }, z.core.$strip>, z.ZodMiniObject<{
63
68
  config: z.ZodMiniObject<{
64
69
  dremioProvided: z.ZodMiniObject<Record<never, z.core.SomeType>, z.core.$strip>;
65
- }, z.core.$strict>;
70
+ }, z.core.$strip>;
66
71
  defaultModelName: z.ZodMiniString<string>;
67
72
  id: z.ZodMiniString<string>;
68
73
  isDefault: z.ZodMiniBoolean<boolean>;
@@ -80,32 +85,37 @@ export declare const modelProviderRetrieveCodec: z.ZodMiniCodec<z.ZodMiniUnion<r
80
85
  auth: z.ZodMiniUnion<readonly [z.ZodMiniObject<{
81
86
  accessKey: z.ZodMiniObject<{
82
87
  accessKeyId: z.ZodMiniString<string>;
83
- }, z.core.$strict>;
84
- }, z.core.$strict>, z.ZodMiniObject<{
88
+ }, z.core.$strip>;
89
+ }, z.core.$strip>, z.ZodMiniObject<{
85
90
  role: z.ZodMiniObject<{
86
91
  roleArn: z.ZodMiniString<string>;
87
- }, z.core.$strict>;
88
- }, z.core.$strict>]>;
92
+ }, z.core.$strip>;
93
+ }, z.core.$strip>]>;
89
94
  region: z.ZodMiniString<string>;
90
- }, z.core.$strict>;
95
+ }, z.core.$strip>;
91
96
  }, z.core.$strict>, z.ZodMiniObject<{
92
- anthropic: z.ZodMiniObject<{}, z.core.$strict>;
97
+ anthropic: z.ZodMiniObject<{}, z.core.$strip>;
93
98
  }, z.core.$strict>, z.ZodMiniObject<{
94
99
  azureOpenAi: z.ZodMiniObject<{
95
100
  auth: z.ZodMiniObject<{
96
101
  clientSecretAuth: z.ZodMiniObject<{
97
102
  azureClientId: z.ZodMiniString<string>;
98
103
  azureTenantId: z.ZodMiniString<string>;
99
- }, z.core.$strict>;
100
- }, z.core.$strict>;
104
+ }, z.core.$strip>;
105
+ }, z.core.$strip>;
101
106
  resourceName: z.ZodMiniString<string>;
102
- }, z.core.$strict>;
107
+ }, z.core.$strip>;
103
108
  }, z.core.$strict>, z.ZodMiniObject<{
104
- googleGemini: z.ZodMiniObject<{}, z.core.$strict>;
109
+ googleGemini: z.ZodMiniObject<{}, z.core.$strip>;
105
110
  }, z.core.$strict>, z.ZodMiniObject<{
106
111
  openAi: z.ZodMiniObject<{
107
112
  organizationId: z.ZodMiniString<string>;
108
- }, z.core.$strict>;
113
+ region: z.ZodMiniEnum<{
114
+ GLOBAL: "GLOBAL";
115
+ US: "US";
116
+ EU: "EU";
117
+ }>;
118
+ }, z.core.$strip>;
109
119
  }, z.core.$strict>]>;
110
120
  defaultModelName: z.ZodMiniString<string>;
111
121
  isDefault: z.ZodMiniBoolean<boolean>;
@@ -115,7 +125,7 @@ export declare const modelProviderRetrieveCodec: z.ZodMiniCodec<z.ZodMiniUnion<r
115
125
  }, z.core.$strip>, z.ZodMiniObject<{
116
126
  config: z.ZodMiniObject<{
117
127
  dremioProvided: z.ZodMiniObject<Record<never, z.core.SomeType>, z.core.$strip>;
118
- }, z.core.$strict>;
128
+ }, z.core.$strip>;
119
129
  defaultModelName: z.ZodMiniString<string>;
120
130
  id: z.ZodMiniString<string>;
121
131
  isDefault: z.ZodMiniBoolean<boolean>;
@@ -14,13 +14,13 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import * as z from "zod/mini";
17
- import { modelProviderCreateCodec, modelProviderRetrieveCodec as baseModelProviderRetrieveCodec, modelProviderUpdateCodec, } from "../../enterprise/ai/modelProviderCodec.js";
17
+ import { modelProviderCreateCodec, modelProviderRetrieveCodec as baseModelProviderRetrieveCodec, modelProviderUpdateCodec, } from "../../enterprise/ai/modelProvider/modelProviderCodec.js";
18
18
  import { Err, Ok, Result } from "ts-results-es";
19
19
  import { DremioModelProvider } from "./DremioModelProvider.js";
20
20
  import { ModelProvider } from "../interfaces.js";
21
21
  export { modelProviderCreateCodec, modelProviderUpdateCodec };
22
22
  export const dremioProvidedSchema = z.object({
23
- config: z.strictObject({
23
+ config: z.object({
24
24
  dremioProvided: z.object(),
25
25
  }),
26
26
  defaultModelName: z.string(),
@@ -1 +1 @@
1
- {"version":3,"file":"model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I,CAAC,CAAC,MAAM,EAAE,CAAC;YACjC,OAAO,CAAyC,CAAC;QACnD,CAAC;QAED,OAAO,CAAC,CAAC,MAAM,CACb,8BAA8B,EAC9B,CAAmD,CACpD,CAAC;IACJ,CAAC;IACD,MAAM,CAAC,CAAC;QACN,IAAI,gBAAgB,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;YACjC,OAAO,CAAyC,CAAC;QACnD,CAAC;QAED,OAAO,CAAC,CAAC,MAAM,CACb,8BAA8B,EAC9B,CAAoD,CACrD,CAAC;IACJ,CAAC;CACF,CACF,CAAC;AAEF,MAAM,UAAU,uBAAuB,CACrC,MAAgB,EAChB,MAAkD;IAKlD,MAAM,YAAY,GAAG,CAAC,CAAC,UAAU,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAC;IAEtE,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;QACzB,IAAI,gBAAgB,IAAI,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjD,OAAO,EAAE,CACP,IAAI,mBAAmB,CAAC,MAAM,EAAE,YAAY,CAAC,IAA4C,CAAC,CAC3F,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,CACP,IAAI,aAAa,CACf,MAAM,EACN,YAAY,CAAC,IAAuD,CACrE,CACF,CAAC;IACJ,CAAC;IAED,OAAO,GAAG,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;AACjC,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 {\n modelProviderCreateCodec,\n modelProviderRetrieveCodec as baseModelProviderRetrieveCodec,\n modelProviderUpdateCodec,\n} from \"../../enterprise/ai/modelProviderCodec.ts\";\nimport { Err, Ok, Result } from \"ts-results-es\";\nimport { DremioModelProvider } from \"./DremioModelProvider.ts\";\nimport type { V4Config } from \"../../common/Config.ts\";\nimport { ModelProvider } from \"../interfaces.ts\";\n\nexport { modelProviderCreateCodec, modelProviderUpdateCodec };\n\nexport const dremioProvidedSchema = z.object({\n config: z.strictObject({\n dremioProvided: z.object(),\n }),\n defaultModelName: z.string(),\n id: z.string(),\n isDefault: z.boolean(),\n name: z.string(),\n sqlModelNames: z.array(z.string()),\n tag: z.string(),\n});\n\nexport const modelProviderRetrieveCodec = z.codec(\n z.union([baseModelProviderRetrieveCodec.def.in, dremioProvidedSchema]),\n z.union([baseModelProviderRetrieveCodec.def.out, dremioProvidedSchema]),\n {\n decode(v) {\n if (\"dremioProvided\" in v.config) {\n return v as z.infer<typeof dremioProvidedSchema>;\n }\n\n return z.decode(\n baseModelProviderRetrieveCodec,\n v as z.input<typeof baseModelProviderRetrieveCodec>,\n );\n },\n encode(v) {\n if (\"dremioProvided\" in v.config) {\n return v as z.infer<typeof dremioProvidedSchema>;\n }\n\n return z.encode(\n baseModelProviderRetrieveCodec,\n v as z.output<typeof baseModelProviderRetrieveCodec>,\n );\n },\n },\n);\n\nexport function safeDecodeModelProvider(\n config: V4Config,\n entity: z.input<typeof modelProviderRetrieveCodec>,\n): Result<\n DremioModelProvider | ModelProvider,\n z.core.util.SafeParseResult<z.output<typeof modelProviderRetrieveCodec>>[\"error\"]\n> {\n const decodeResult = z.safeDecode(modelProviderRetrieveCodec, entity);\n\n if (decodeResult.success) {\n if (\"dremioProvided\" in decodeResult.data.config) {\n return Ok(\n new DremioModelProvider(config, decodeResult.data as z.infer<typeof dremioProvidedSchema>),\n );\n }\n return Ok(\n new ModelProvider(\n config,\n decodeResult.data as z.output<typeof baseModelProviderRetrieveCodec>,\n ),\n );\n }\n\n return Err(decodeResult.error);\n}\n\nexport type SafeDecodeResultWithoutDremioLLM = Result<\n ModelProvider,\n z.core.util.SafeParseResult<z.output<typeof modelProviderRetrieveCodec>>[\"error\"]\n>;\n"]}
1
+ {"version":3,"file":"modelProviderCodec.js","sourceRoot":"","sources":["../../../src/cloud/ai/modelProviderCodec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EACL,wBAAwB,EACxB,0BAA0B,IAAI,8BAA8B,EAC5D,wBAAwB,GACzB,MAAM,yDAAyD,CAAC;AACjE,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,CAAC;AAE9D,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;KAC3B,CAAC;IACF,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE;IAC5B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE;IACtB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;CAChB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC/C,CAAC,CAAC,KAAK,CAAC,CAAC,8BAA8B,CAAC,GAAG,CAAC,EAAE,EAAE,oBAAoB,CAAC,CAAC,EACtE,CAAC,CAAC,KAAK,CAAC,CAAC,8BAA8B,CAAC,GAAG,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,EACvE;IACE,MAAM,CAAC,CAAC;QACN,IAAI,gBAAgB,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;YACjC,OAAO,CAAyC,CAAC;QACnD,CAAC;QAED,OAAO,CAAC,CAAC,MAAM,CACb,8BAA8B,EAC9B,CAAmD,CACpD,CAAC;IACJ,CAAC;IACD,MAAM,CAAC,CAAC;QACN,IAAI,gBAAgB,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;YACjC,OAAO,CAAyC,CAAC;QACnD,CAAC;QAED,OAAO,CAAC,CAAC,MAAM,CACb,8BAA8B,EAC9B,CAAoD,CACrD,CAAC;IACJ,CAAC;CACF,CACF,CAAC;AAEF,MAAM,UAAU,uBAAuB,CACrC,MAAgB,EAChB,MAAkD;IAKlD,MAAM,YAAY,GAAG,CAAC,CAAC,UAAU,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAC;IAEtE,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;QACzB,IAAI,gBAAgB,IAAI,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjD,OAAO,EAAE,CACP,IAAI,mBAAmB,CAAC,MAAM,EAAE,YAAY,CAAC,IAA4C,CAAC,CAC3F,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,CACP,IAAI,aAAa,CACf,MAAM,EACN,YAAY,CAAC,IAAuD,CACrE,CACF,CAAC;IACJ,CAAC;IAED,OAAO,GAAG,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;AACjC,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 {\n modelProviderCreateCodec,\n modelProviderRetrieveCodec as baseModelProviderRetrieveCodec,\n modelProviderUpdateCodec,\n} from \"../../enterprise/ai/modelProvider/modelProviderCodec.ts\";\nimport { Err, Ok, Result } from \"ts-results-es\";\nimport { DremioModelProvider } from \"./DremioModelProvider.ts\";\nimport type { V4Config } from \"../../common/Config.ts\";\nimport { ModelProvider } from \"../interfaces.ts\";\n\nexport { modelProviderCreateCodec, modelProviderUpdateCodec };\n\nexport const dremioProvidedSchema = z.object({\n config: z.object({\n dremioProvided: z.object(),\n }),\n defaultModelName: z.string(),\n id: z.string(),\n isDefault: z.boolean(),\n name: z.string(),\n sqlModelNames: z.array(z.string()),\n tag: z.string(),\n});\n\nexport const modelProviderRetrieveCodec = z.codec(\n z.union([baseModelProviderRetrieveCodec.def.in, dremioProvidedSchema]),\n z.union([baseModelProviderRetrieveCodec.def.out, dremioProvidedSchema]),\n {\n decode(v) {\n if (\"dremioProvided\" in v.config) {\n return v as z.infer<typeof dremioProvidedSchema>;\n }\n\n return z.decode(\n baseModelProviderRetrieveCodec,\n v as z.input<typeof baseModelProviderRetrieveCodec>,\n );\n },\n encode(v) {\n if (\"dremioProvided\" in v.config) {\n return v as z.infer<typeof dremioProvidedSchema>;\n }\n\n return z.encode(\n baseModelProviderRetrieveCodec,\n v as z.output<typeof baseModelProviderRetrieveCodec>,\n );\n },\n },\n);\n\nexport function safeDecodeModelProvider(\n config: V4Config,\n entity: z.input<typeof modelProviderRetrieveCodec>,\n): Result<\n DremioModelProvider | ModelProvider,\n z.core.util.SafeParseResult<z.output<typeof modelProviderRetrieveCodec>>[\"error\"]\n> {\n const decodeResult = z.safeDecode(modelProviderRetrieveCodec, entity);\n\n if (decodeResult.success) {\n if (\"dremioProvided\" in decodeResult.data.config) {\n return Ok(\n new DremioModelProvider(config, decodeResult.data as z.infer<typeof dremioProvidedSchema>),\n );\n }\n return Ok(\n new ModelProvider(\n config,\n decodeResult.data as z.output<typeof baseModelProviderRetrieveCodec>,\n ),\n );\n }\n\n return Err(decodeResult.error);\n}\n\nexport type SafeDecodeResultWithoutDremioLLM = Result<\n ModelProvider,\n z.core.util.SafeParseResult<z.output<typeof modelProviderRetrieveCodec>>[\"error\"]\n>;\n"]}
@@ -1,13 +1,13 @@
1
1
  import { Observable } from "rxjs";
2
2
  import { ChatSession } from "./chat/ChatSession.ts";
3
3
  import type { UserChatMessage } from "./chat/UserChatMessage.ts";
4
- import { AgentChatResponse, type AgentResponseContent } from "./chat/AgentChatResponse.ts";
4
+ import { AgentChatResponse, type AgentResponseContent } from "./chat/eventWrappers/AgentChatResponse.ts";
5
5
  import type { Logger, SonarV4Config, V4Config } from "../../common/Config.ts";
6
- import { ModelProvider } from "./ModelProvider.ts";
6
+ import { ModelProvider } from "./modelProvider/ModelProvider.ts";
7
7
  import * as z from "zod/mini";
8
- import { modelProviderCreateCodec } from "./modelProviderCodec.js";
8
+ import { modelProviderCreateCodec } from "./modelProvider/modelProviderCodec.ts";
9
9
  import type { SignalParam } from "../../common/Params.ts";
10
- import { listModelsPropertiesSchema } from "./modelProviderConfigSchemas.js";
10
+ import { listModelsPropertiesSchema } from "./modelProvider/modelProviderConfigSchemas.ts";
11
11
  import { AgentChatExchange } from "./chat/eventWrappers/AgentChatExchange.ts";
12
12
  import { ChatSessionClient } from "./chat/ChatSessionClient.ts";
13
13
  export declare function listAvailableModels(config: V4Config): (properties: z.infer<typeof listModelsPropertiesSchema>, { signal }?: SignalParam) => import("ts-results-es").AsyncResult<Set<string>, import("../index.ts").HttpError>;
@@ -52,6 +52,7 @@ export declare class AIResource {
52
52
  } | {
53
53
  openAi: {
54
54
  organizationId: string;
55
+ region: "GLOBAL" | "US" | "EU";
55
56
  };
56
57
  };
57
58
  defaultModelName: string;
@@ -97,6 +98,7 @@ export declare class AIResource {
97
98
  } | {
98
99
  openAi: {
99
100
  organizationId: string;
101
+ region: "GLOBAL" | "US" | "EU";
100
102
  };
101
103
  };
102
104
  defaultModelName: string;
@@ -15,12 +15,12 @@
15
15
  */
16
16
  import { catchError, concatMap, endWith, map, Observable, of, scan, share, startWith } from "rxjs";
17
17
  import { ChatSession } from "./chat/ChatSession.js";
18
- import { AgentChatResponse } from "./chat/AgentChatResponse.js";
19
- import { ModelProvider } from "./ModelProvider.js";
18
+ import { AgentChatResponse, } from "./chat/eventWrappers/AgentChatResponse.js";
19
+ import { ModelProvider } from "./modelProvider/ModelProvider.js";
20
20
  import * as z from "zod/mini";
21
- import { modelProviderCreateCodec, modelProviderRetrieveCodec } from "./modelProviderCodec.js";
21
+ import { modelProviderCreateCodec, modelProviderRetrieveCodec, } from "./modelProvider/modelProviderCodec.js";
22
22
  import { safeParseResultToResult } from "../../common/safeParseResultToResult.js";
23
- import { listModelsPropertiesSchema } from "./modelProviderConfigSchemas.js";
23
+ import { listModelsPropertiesSchema } from "./modelProvider/modelProviderConfigSchemas.js";
24
24
  import { AgentChatExchange } from "./chat/eventWrappers/AgentChatExchange.js";
25
25
  import { AgentEndTurn } from "../interfaces.js";
26
26
  import { ChatSessionClient } from "./chat/ChatSessionClient.js";
@@ -1 +1 @@
1
- {"version":3,"file":"AIResource.js","sourceRoot":"","sources":["../../../src/enterprise/ai/AIResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAA6B,MAAM,6BAA6B,CAAC;AAE3F,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC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O,CAAC,IAAI,YAAY,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC,EACrD,UAAU,CAAC,CAAC,KAAc,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,YAAY,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAC9E,IAAI,CACF,CAAC,iBAAiB,EAAE,cAAc,EAAE,EAAE,CAAC,iBAAiB,CAAC,aAAa,CAAC,cAAc,CAAC,EACtF,wBAAwB,CACzB,EACD,SAAS,CAAC,wBAAwB,CAAC,EACnC,KAAK,EAAE,CACR,CAAC;IACJ,CAAC;IAED,uBAAuB,CAAC,WAAwB;QAC9C,OAAO,IAAI,iBAAiB,CAAC;YAC3B,WAAW;YACX,wBAAwB,EAAE,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC;SACnE,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;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 { catchError, concatMap, endWith, map, Observable, of, scan, share, startWith } from \"rxjs\";\nimport { ChatSession } from \"./chat/ChatSession.ts\";\nimport type { UserChatMessage } from \"./chat/UserChatMessage.ts\";\nimport { AgentChatResponse, type AgentResponseContent } from \"./chat/AgentChatResponse.ts\";\nimport type { Logger, SonarV4Config, V4Config } from \"../../common/Config.ts\";\nimport { ModelProvider } from \"./ModelProvider.ts\";\nimport * as z from \"zod/mini\";\nimport { modelProviderCreateCodec, modelProviderRetrieveCodec } from \"./modelProviderCodec.js\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport { safeParseResultToResult } from \"../../common/safeParseResultToResult.ts\";\nimport { listModelsPropertiesSchema } from \"./modelProviderConfigSchemas.js\";\nimport { AgentChatExchange } from \"./chat/eventWrappers/AgentChatExchange.ts\";\nimport { AgentEndTurn } from \"../interfaces.ts\";\nimport { ChatSessionClient } from \"./chat/ChatSessionClient.ts\";\nimport { createSendChatMessage } from \"./chat/methods/sendChatMessage.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: string[] }>)\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 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 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 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 * Creates an Observable that emits each time the `AgentChatExchange` is updated\n * with events from the Agent.\n */\n createAgentChatExchange$<T extends AgentResponseContent>(\n chatSession: ChatSession,\n userChatMessage: UserChatMessage,\n options: {\n mapChatEvents?: (\n v: AgentChatResponse<AgentResponseContent>,\n ) => Observable<AgentChatResponse<T>>;\n } = {},\n ) {\n const initialAgentChatExchange = new AgentChatExchange(userChatMessage, []);\n\n return this.sendChatMessage(chatSession, userChatMessage).pipe(\n map((eventResult) => eventResult.unwrap()),\n concatMap((agentChatEvent) => options.mapChatEvents?.(agentChatEvent) || of(agentChatEvent)),\n endWith(new AgentEndTurn({ type: \"reply_finished\" })),\n catchError((error: unknown) => of(new AgentEndTurn({ error, type: \"error\" }))),\n scan(\n (agentChatExchange, agentChatEvent) => agentChatExchange._addChatEvent(agentChatEvent),\n initialAgentChatExchange,\n ),\n startWith(initialAgentChatExchange),\n share(),\n );\n }\n\n createChatSessionClient(chatSession: ChatSession) {\n return new ChatSessionClient({\n chatSession,\n createAgentChatExchange$: this.createAgentChatExchange$.bind(this),\n });\n }\n\n /**\n * Sends a chat message to the Dremio AI Agent and returns an Observable containing\n * Agent replies.\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,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EACL,iBAAiB,GAElB,MAAM,2CAA2C,CAAC;AAEnD,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,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,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,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,0BAA0B,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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 { catchError, concatMap, endWith, map, Observable, of, scan, share, startWith } from \"rxjs\";\nimport { ChatSession } from \"./chat/ChatSession.ts\";\nimport type { UserChatMessage } from \"./chat/UserChatMessage.ts\";\nimport {\n AgentChatResponse,\n type AgentResponseContent,\n} from \"./chat/eventWrappers/AgentChatResponse.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 { AgentChatExchange } from \"./chat/eventWrappers/AgentChatExchange.ts\";\nimport { AgentEndTurn } from \"../interfaces.ts\";\nimport { ChatSessionClient } from \"./chat/ChatSessionClient.ts\";\nimport { createSendChatMessage } from \"./chat/methods/sendChatMessage.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: string[] }>)\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 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 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 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 * Creates an Observable that emits each time the `AgentChatExchange` is updated\n * with events from the Agent.\n */\n createAgentChatExchange$<T extends AgentResponseContent>(\n chatSession: ChatSession,\n userChatMessage: UserChatMessage,\n options: {\n mapChatEvents?: (\n v: AgentChatResponse<AgentResponseContent>,\n ) => Observable<AgentChatResponse<T>>;\n } = {},\n ) {\n const initialAgentChatExchange = new AgentChatExchange(userChatMessage, []);\n\n return this.sendChatMessage(chatSession, userChatMessage).pipe(\n map((eventResult) => eventResult.unwrap()),\n concatMap((agentChatEvent) => options.mapChatEvents?.(agentChatEvent) || of(agentChatEvent)),\n endWith(new AgentEndTurn({ type: \"reply_finished\" })),\n catchError((error: unknown) => of(new AgentEndTurn({ error, type: \"error\" }))),\n scan(\n (agentChatExchange, agentChatEvent) => agentChatExchange._addChatEvent(agentChatEvent),\n initialAgentChatExchange,\n ),\n startWith(initialAgentChatExchange),\n share(),\n );\n }\n\n createChatSessionClient(chatSession: ChatSession) {\n return new ChatSessionClient({\n chatSession,\n createAgentChatExchange$: this.createAgentChatExchange$.bind(this),\n });\n }\n\n /**\n * Sends a chat message to the Dremio AI Agent and returns an Observable containing\n * Agent replies.\n */\n sendChatMessage(chatSession: ChatSession, userChatMessage: UserChatMessage) {\n return createSendChatMessage(this.#config)(chatSession, userChatMessage);\n }\n}\n"]}
@@ -1,8 +1,12 @@
1
1
  import * as z from "zod/mini";
2
+ import { Temporal } from "temporal-polyfill";
2
3
  declare const chatSessionInputSchema: z.ZodMiniObject<{
4
+ createdAt: z.ZodMiniString<string>;
5
+ id: z.ZodMiniString<string>;
3
6
  modelName: z.ZodMiniString<string>;
4
7
  modelProviderId: z.ZodMiniString<string>;
5
- sessionId: z.ZodMiniString<string>;
8
+ title: z.ZodMiniOptional<z.ZodMiniString<string>>;
9
+ updatedAt: z.ZodMiniString<string>;
6
10
  }, z.core.$strip>;
7
11
  declare const newChatSessionSchema: z.ZodMiniObject<{
8
12
  modelName: z.ZodMiniOptional<z.ZodMiniString<string>>;
@@ -15,17 +19,25 @@ declare const newChatSessionSchema: z.ZodMiniObject<{
15
19
  * they're mutated on the instance of the class.
16
20
  */
17
21
  export declare class ChatSession {
18
- modelName?: string;
19
- modelProviderId?: string;
20
- sessionId?: string;
22
+ #private;
23
+ get createdAt(): Temporal.Instant;
24
+ get id(): string | undefined;
25
+ get modelName(): string | undefined;
26
+ get modelProviderId(): string | undefined;
27
+ get title(): string | undefined;
28
+ get updatedAt(): Temporal.Instant;
21
29
  private constructor();
30
+ [Symbol.observable](): import("rxjs").Observable<ChatSession>;
22
31
  toJSON(): {
32
+ createdAt: string;
33
+ id: string;
23
34
  modelName: string;
24
35
  modelProviderId: string;
25
- sessionId: string;
36
+ updatedAt: string;
37
+ title?: string | undefined;
26
38
  };
27
39
  assign(properties: Partial<z.infer<typeof chatSessionInputSchema>>): void;
28
- equals(other: ChatSession): boolean;
40
+ equals(other: unknown): boolean;
29
41
  static fromJSON(data: z.input<typeof ChatSession.codec>): ChatSession;
30
42
  /**
31
43
  * Creates a new ChatSession with fields that will be populated automatically
@@ -33,9 +45,12 @@ export declare class ChatSession {
33
45
  */
34
46
  static new(options?: z.infer<typeof newChatSessionSchema>): ChatSession;
35
47
  static codec: z.ZodMiniCodec<z.ZodMiniObject<{
48
+ createdAt: z.ZodMiniString<string>;
49
+ id: z.ZodMiniString<string>;
36
50
  modelName: z.ZodMiniString<string>;
37
51
  modelProviderId: z.ZodMiniString<string>;
38
- sessionId: z.ZodMiniString<string>;
52
+ title: z.ZodMiniOptional<z.ZodMiniString<string>>;
53
+ updatedAt: z.ZodMiniString<string>;
39
54
  }, z.core.$strip>, z.ZodMiniCustom<ChatSession, ChatSession>>;
40
55
  }
41
56
  export {};
@@ -14,10 +14,15 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import * as z from "zod/mini";
17
+ import { Temporal } from "temporal-polyfill";
18
+ import { BehaviorSubject } from "rxjs";
17
19
  const chatSessionInputSchema = z.object({
20
+ createdAt: z.string().check(z.iso.datetime()),
21
+ id: z.string(),
18
22
  modelName: z.string(),
19
23
  modelProviderId: z.string(),
20
- sessionId: z.string(),
24
+ title: z.optional(z.string()),
25
+ updatedAt: z.string().check(z.iso.datetime()),
21
26
  });
22
27
  const newChatSessionSchema = z.partial(z.pick(chatSessionInputSchema, {
23
28
  modelName: true,
@@ -30,37 +35,64 @@ const newChatSessionSchema = z.partial(z.pick(chatSessionInputSchema, {
30
35
  * they're mutated on the instance of the class.
31
36
  */
32
37
  export class ChatSession {
33
- modelName;
34
- modelProviderId;
35
- sessionId;
38
+ #createdAt = Temporal.Now.instant();
39
+ #id;
40
+ #modelName;
41
+ #modelProviderId;
42
+ #title;
43
+ #updatedAt = Temporal.Now.instant();
44
+ #bus = new BehaviorSubject(this);
45
+ get createdAt() {
46
+ return this.#createdAt;
47
+ }
48
+ get id() {
49
+ return this.#id;
50
+ }
51
+ get modelName() {
52
+ return this.#modelName;
53
+ }
54
+ get modelProviderId() {
55
+ return this.#modelProviderId;
56
+ }
57
+ get title() {
58
+ return this.#title;
59
+ }
60
+ get updatedAt() {
61
+ return this.#updatedAt;
62
+ }
36
63
  constructor(properties = {}) {
37
- if (properties.modelName) {
38
- this.modelName = properties.modelName;
39
- }
40
- if (properties.modelProviderId) {
41
- this.modelProviderId = properties.modelProviderId;
42
- }
43
- if (properties.sessionId) {
44
- this.sessionId = properties.sessionId;
45
- }
64
+ this.assign(properties);
65
+ }
66
+ [Symbol.observable]() {
67
+ return this.#bus.asObservable();
46
68
  }
47
69
  toJSON() {
48
70
  return z.encode(ChatSession.codec, this);
49
71
  }
50
72
  assign(properties) {
73
+ if (properties.createdAt) {
74
+ this.#createdAt = Temporal.Instant.from(properties.createdAt);
75
+ }
76
+ if (properties.id) {
77
+ this.#id = properties.id;
78
+ }
51
79
  if (properties.modelName) {
52
- this.modelName = properties.modelName;
80
+ this.#modelName = properties.modelName;
53
81
  }
54
82
  if (properties.modelProviderId) {
55
- this.modelProviderId = properties.modelProviderId;
83
+ this.#modelProviderId = properties.modelProviderId;
84
+ }
85
+ if (properties.title) {
86
+ this.#title = properties.title;
56
87
  }
57
- if (properties.sessionId) {
58
- this.sessionId = properties.sessionId;
88
+ if (properties.updatedAt) {
89
+ this.#updatedAt = Temporal.Instant.from(properties.updatedAt);
59
90
  }
91
+ this.#bus.next(this);
60
92
  }
61
93
  equals(other) {
62
- return (this === other ||
63
- (this.sessionId === other.sessionId && (!!this.sessionId || !!other.sessionId)));
94
+ return (other instanceof ChatSession &&
95
+ (this === other || (this.id === other.id && (!!this.id || !!other.id))));
64
96
  }
65
97
  static fromJSON(data) {
66
98
  return z.decode(ChatSession.codec, data);
@@ -77,13 +109,16 @@ export class ChatSession {
77
109
  return new ChatSession(v);
78
110
  },
79
111
  encode(v) {
80
- if (!v.sessionId) {
81
- throw new Error("Cannot encode an uninitialized ChatSession");
112
+ if (!v.id) {
113
+ throw new Error("An uninitialized ChatSession cannot be encoded.");
82
114
  }
83
115
  return {
116
+ createdAt: v.createdAt.toString(),
117
+ id: v.id,
84
118
  modelName: v.modelName,
85
119
  modelProviderId: v.modelProviderId,
86
- sessionId: v.sessionId,
120
+ title: v.title,
121
+ updatedAt: v.updatedAt.toString(),
87
122
  };
88
123
  },
89
124
  });