@dremio/js-sdk 0.36.0 → 0.36.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,11 +21,28 @@ import { ModelProvider } from "./ModelProvider.js";
21
21
  import * as z from "zod/mini";
22
22
  import { modelProviderCreateCodec, modelProviderRetrieveCodec } from "./modelProviderCodec.js";
23
23
  import { safeParseResultToResult } from "../../common/safeParseResultToResult.js";
24
+ import { listModelsPropertiesSchema } from "./modelProviderConfigSchemas.js";
24
25
  import { Err, Ok } from "ts-results-es";
25
26
  import { Problem } from "../../common/Problem.js";
26
27
  import { AgentChatExchange } from "./chat/eventWrappers/AgentChatExchange.js";
27
28
  import { AgentEndTurn } from "../interfaces.js";
28
29
  import { ChatSessionClient } from "./chat/ChatSessionClient.js";
30
+ export function listAvailableModels(config) {
31
+ return function listAvailableModels(properties, { signal } = {}) {
32
+ return config
33
+ .v4Request("model-provider:listModels", {
34
+ body: JSON.stringify(z.parse(listModelsPropertiesSchema, properties)),
35
+ headers: {
36
+ Accept: "application/json",
37
+ "Content-Type": "application/json",
38
+ },
39
+ method: "POST",
40
+ signal,
41
+ })
42
+ .map((res) => res.json())
43
+ .map((result) => new Set(result.models));
44
+ };
45
+ }
29
46
  export class AIResource {
30
47
  #config;
31
48
  constructor(config) {
@@ -68,17 +85,7 @@ export class AIResource {
68
85
  };
69
86
  }
70
87
  listAvailableModels(properties) {
71
- return this.#config
72
- .v4Request("model-provider:listModels", {
73
- body: JSON.stringify({ access: properties }),
74
- headers: {
75
- Accept: "application/json",
76
- "Content-Type": "application/json",
77
- },
78
- method: "POST",
79
- })
80
- .map((res) => res.json())
81
- .map((result) => new Set(result.models));
88
+ return listAvailableModels(this.#config)(properties);
82
89
  }
83
90
  retrieveModelProvider(id, { signal } = {}) {
84
91
  return this.#config
@@ -1 +1 @@
1
- {"version":3,"file":"AIResource.js","sourceRoot":"","sources":["../../../src/enterprise/ai/AIResource.ts"],"names":[],"mappings":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,CAAC,KAAK,CAAC;QACtB,CAAC,CAAC,CACL,CAAC,IAAI,CACJ,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EACtE,GAAG,CAAC,CAAC,iBAAiB,EAAE,EAAE;YACxB,IAAI,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC;gBAC7B,WAAW,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACtD,CAAC;QACH,CAAC,CAAC,EACF,UAAU,CAAC,CAAC,CAAY,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC1D,KAAK,EAAE,CACR,CAAC;IACN,CAAC;CACF;AAWD,SAAS,gBAAgB,CAAC,CAAY;IACpC,IAAI,CAAC,CAAC,IAAI,YAAY,OAAO,EAAE,CAAC;QAC9B,OAAO,CAAC,CAAC,IAA4C,CAAC;IACxD,CAAC;IACD,OAAO,CAAC,CAAC;AACX,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 { catchError, endWith, map, of, scan, share, startWith, tap } from \"rxjs\";\nimport { ChatSession } from \"./chat/ChatSession.ts\";\nimport type { UserChatMessage } from \"./chat/UserChatMessage.ts\";\nimport { AgentChatResponse } from \"./chat/AgentChatResponse.ts\";\nimport type { Logger, SonarV4Config, V4Config } from \"../../common/Config.ts\";\nimport { fromTextEventStream } from \"../../common/fromTextEventStream.ts\";\nimport { ModelProvider } from \"./ModelProvider.ts\";\n\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 type { listModelsPropertiesSchema } from \"./modelProviderConfigSchemas.ts\";\nimport { Err, Ok } from \"ts-results-es\";\nimport type { HttpError } from \"../../common/HttpError.ts\";\nimport { Problem } from \"../../common/Problem.ts\";\nimport { AgentChatExchange } from \"./chat/eventWrappers/AgentChatExchange.ts\";\nimport { AgentEndTurn } from \"../interfaces.ts\";\nimport { ChatSessionClient } from \"./chat/ChatSessionClient.ts\";\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 this.#config\n .v4Request(\"model-provider:listModels\", {\n body: JSON.stringify({ access: properties }),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n method: \"POST\",\n })\n .map((res) => res.json() as Promise<{ models: string[] }>)\n .map((result) => new Set(result.models));\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$(chatSession: ChatSession, userChatMessage: UserChatMessage) {\n const initialAgentChatExchange = new AgentChatExchange(userChatMessage, []);\n\n return this.sendChatMessage(chatSession)(userChatMessage).pipe(\n map((eventResult) => eventResult.unwrap()),\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) {\n return (chatMessage: UserChatMessage) =>\n fromTextEventStream(({ signal }) =>\n this.#config\n .sonarV4Request(\"agent\", {\n body: JSON.stringify({\n message: chatMessage.toString(),\n sessionId: chatSession.sessionId,\n } satisfies {\n message: string;\n modelProviderId?: string;\n sessionId?: string;\n }),\n headers: {\n Accept: \"text/event-stream\",\n \"Content-Type\": \"application/json\",\n },\n method: \"POST\",\n signal,\n })\n .promise.then((result) => {\n if (result.isErr()) {\n throw result.error;\n }\n return result.value;\n }),\n ).pipe(\n map((event) => Ok(AgentChatResponse.fromJSON(JSON.parse(event.data)))),\n tap((agentChatResponse) => {\n if (agentChatResponse.isOk()) {\n chatSession.assign(agentChatResponse.value.session);\n }\n }),\n catchError((e: HttpError) => of(Err(refineChatErrors(e)))),\n share(),\n );\n }\n}\n\ntype SendChatMessageProblemCodes =\n | \"https://api.dremio.dev/problems/ai-agent/chat/agent-disabled\"\n | \"https://api.dremio.dev/problems/ai-agent/chat/input-too-large\"\n | \"https://api.dremio.dev/problems/ai-agent/chat/model-provider-not-found\"\n | \"https://api.dremio.dev/problems/ai-agent/chat/no-default-model-provider\"\n | \"https://api.dremio.dev/problems/ai-agent/chat/no-model-provider-privilege\"\n | \"https://api.dremio.dev/problems/ai-agent/chat/preview-disabled\"\n | \"https://api.dremio.dev/problems/ai-agent/chat/rate-limit-exceeded\";\n\nfunction refineChatErrors(e: HttpError) {\n if (e.body instanceof Problem) {\n return e.body as Problem<SendChatMessageProblemCodes>;\n }\n return e;\n}\n"]}
1
+ {"version":3,"file":"AIResource.js","sourceRoot":"","sources":["../../../src/enterprise/ai/AIResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CA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AK,EAAE,EAAE,CAAC,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EACtE,GAAG,CAAC,CAAC,iBAAiB,EAAE,EAAE;YACxB,IAAI,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC;gBAC7B,WAAW,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACtD,CAAC;QACH,CAAC,CAAC,EACF,UAAU,CAAC,CAAC,CAAY,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC1D,KAAK,EAAE,CACR,CAAC;IACN,CAAC;CACF;AAWD,SAAS,gBAAgB,CAAC,CAAY;IACpC,IAAI,CAAC,CAAC,IAAI,YAAY,OAAO,EAAE,CAAC;QAC9B,OAAO,CAAC,CAAC,IAA4C,CAAC;IACxD,CAAC;IACD,OAAO,CAAC,CAAC;AACX,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 { catchError, endWith, map, of, scan, share, startWith, tap } from \"rxjs\";\nimport { ChatSession } from \"./chat/ChatSession.ts\";\nimport type { UserChatMessage } from \"./chat/UserChatMessage.ts\";\nimport { AgentChatResponse } from \"./chat/AgentChatResponse.ts\";\nimport type { Logger, SonarV4Config, V4Config } from \"../../common/Config.ts\";\nimport { fromTextEventStream } from \"../../common/fromTextEventStream.ts\";\nimport { ModelProvider } from \"./ModelProvider.ts\";\n\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 { Err, Ok } from \"ts-results-es\";\nimport type { HttpError } from \"../../common/HttpError.ts\";\nimport { Problem } from \"../../common/Problem.ts\";\nimport { AgentChatExchange } from \"./chat/eventWrappers/AgentChatExchange.ts\";\nimport { AgentEndTurn } from \"../interfaces.ts\";\nimport { ChatSessionClient } from \"./chat/ChatSessionClient.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$(chatSession: ChatSession, userChatMessage: UserChatMessage) {\n const initialAgentChatExchange = new AgentChatExchange(userChatMessage, []);\n\n return this.sendChatMessage(chatSession)(userChatMessage).pipe(\n map((eventResult) => eventResult.unwrap()),\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) {\n return (chatMessage: UserChatMessage) =>\n fromTextEventStream(({ signal }) =>\n this.#config\n .sonarV4Request(\"agent\", {\n body: JSON.stringify({\n message: chatMessage.toString(),\n sessionId: chatSession.sessionId,\n } satisfies {\n message: string;\n modelProviderId?: string;\n sessionId?: string;\n }),\n headers: {\n Accept: \"text/event-stream\",\n \"Content-Type\": \"application/json\",\n },\n method: \"POST\",\n signal,\n })\n .promise.then((result) => {\n if (result.isErr()) {\n throw result.error;\n }\n return result.value;\n }),\n ).pipe(\n map((event) => Ok(AgentChatResponse.fromJSON(JSON.parse(event.data)))),\n tap((agentChatResponse) => {\n if (agentChatResponse.isOk()) {\n chatSession.assign(agentChatResponse.value.session);\n }\n }),\n catchError((e: HttpError) => of(Err(refineChatErrors(e)))),\n share(),\n );\n }\n}\n\ntype SendChatMessageProblemCodes =\n | \"https://api.dremio.dev/problems/ai-agent/chat/agent-disabled\"\n | \"https://api.dremio.dev/problems/ai-agent/chat/input-too-large\"\n | \"https://api.dremio.dev/problems/ai-agent/chat/model-provider-not-found\"\n | \"https://api.dremio.dev/problems/ai-agent/chat/no-default-model-provider\"\n | \"https://api.dremio.dev/problems/ai-agent/chat/no-model-provider-privilege\"\n | \"https://api.dremio.dev/problems/ai-agent/chat/preview-disabled\"\n | \"https://api.dremio.dev/problems/ai-agent/chat/rate-limit-exceeded\";\n\nfunction refineChatErrors(e: HttpError) {\n if (e.body instanceof Problem) {\n return e.body as Problem<SendChatMessageProblemCodes>;\n }\n return e;\n}\n"]}
@@ -32,38 +32,7 @@ export declare class ModelProvider implements Omit<ModelProviderProperties, "tag
32
32
  roleArn: z.ZodMiniString<string>;
33
33
  }, z.core.$strict>;
34
34
  }, z.core.$strict>]>;
35
- region: z.ZodMiniEnum<{
36
- "ap-east-2": "ap-east-2";
37
- "ap-northeast-1": "ap-northeast-1";
38
- "ap-northeast-2": "ap-northeast-2";
39
- "ap-northeast-3": "ap-northeast-3";
40
- "ap-south-1": "ap-south-1";
41
- "ap-south-2": "ap-south-2";
42
- "ap-southeast-1": "ap-southeast-1";
43
- "ap-southeast-2": "ap-southeast-2";
44
- "ap-southeast-3": "ap-southeast-3";
45
- "ap-southeast-4": "ap-southeast-4";
46
- "ap-southeast-5": "ap-southeast-5";
47
- "ap-southeast-7": "ap-southeast-7";
48
- "ca-central-1": "ca-central-1";
49
- "eu-central-1": "eu-central-1";
50
- "eu-central-2": "eu-central-2";
51
- "eu-north-1": "eu-north-1";
52
- "eu-south-1": "eu-south-1";
53
- "eu-south-2": "eu-south-2";
54
- "eu-west-1": "eu-west-1";
55
- "eu-west-2": "eu-west-2";
56
- "eu-west-3": "eu-west-3";
57
- "il-central-1": "il-central-1";
58
- "me-central-1": "me-central-1";
59
- "sa-east-1": "sa-east-1";
60
- "us-east-1": "us-east-1";
61
- "us-east-2": "us-east-2";
62
- "us-gov-east-1": "us-gov-east-1";
63
- "us-gov-west-1": "us-gov-west-1";
64
- "us-west-1": "us-west-1";
65
- "us-west-2": "us-west-2";
66
- }>;
35
+ region: z.ZodMiniString<string>;
67
36
  }, z.core.$strict>;
68
37
  }, z.core.$strict>, z.ZodMiniObject<{
69
38
  anthropic: z.ZodMiniObject<{
@@ -108,38 +77,7 @@ export declare class ModelProvider implements Omit<ModelProviderProperties, "tag
108
77
  roleArn: z.ZodMiniString<string>;
109
78
  }, z.core.$strict>;
110
79
  }, z.core.$strict>]>>;
111
- region: z.ZodMiniOptional<z.ZodMiniEnum<{
112
- "ap-east-2": "ap-east-2";
113
- "ap-northeast-1": "ap-northeast-1";
114
- "ap-northeast-2": "ap-northeast-2";
115
- "ap-northeast-3": "ap-northeast-3";
116
- "ap-south-1": "ap-south-1";
117
- "ap-south-2": "ap-south-2";
118
- "ap-southeast-1": "ap-southeast-1";
119
- "ap-southeast-2": "ap-southeast-2";
120
- "ap-southeast-3": "ap-southeast-3";
121
- "ap-southeast-4": "ap-southeast-4";
122
- "ap-southeast-5": "ap-southeast-5";
123
- "ap-southeast-7": "ap-southeast-7";
124
- "ca-central-1": "ca-central-1";
125
- "eu-central-1": "eu-central-1";
126
- "eu-central-2": "eu-central-2";
127
- "eu-north-1": "eu-north-1";
128
- "eu-south-1": "eu-south-1";
129
- "eu-south-2": "eu-south-2";
130
- "eu-west-1": "eu-west-1";
131
- "eu-west-2": "eu-west-2";
132
- "eu-west-3": "eu-west-3";
133
- "il-central-1": "il-central-1";
134
- "me-central-1": "me-central-1";
135
- "sa-east-1": "sa-east-1";
136
- "us-east-1": "us-east-1";
137
- "us-east-2": "us-east-2";
138
- "us-gov-east-1": "us-gov-east-1";
139
- "us-gov-west-1": "us-gov-west-1";
140
- "us-west-1": "us-west-1";
141
- "us-west-2": "us-west-2";
142
- }>>;
80
+ region: z.ZodMiniOptional<z.ZodMiniString<string>>;
143
81
  }, z.core.$strict>;
144
82
  }, z.core.$strict>, z.ZodMiniObject<{
145
83
  anthropic: z.ZodMiniObject<{
@@ -42,7 +42,7 @@ export class AgentToolCallGroup {
42
42
  ...this.toolCalls.slice(0, requestIndex),
43
43
  toolCall.withResult(toolResult),
44
44
  ...this.toolCalls.slice(requestIndex + 1),
45
- ]);
45
+ ], this.id);
46
46
  }
47
47
  toJSON() {
48
48
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"AgentToolCallGroup.js","sourceRoot":"","sources":["../../../../../src/enterprise/ai/chat/eventWrappers/AgentToolCallGroup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKnD;;;;GAIG;AACH,MAAM,OAAO,kBAAkB;IACpB,EAAE,GAAG,MAAM,EAAE,CAAC;IACd,SAAS,CAAkB;IAEpC,YAAY,SAA0C,EAAE,EAA6B;QACnF,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,EAAE,EAAE,CAAC;YACP,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACf,CAAC;IACH,CAAC;IAED,UAAU,CAAC,WAA+D;QACxE,OAAO,IAAI,kBAAkB,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,aAAa,CAAC,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9F,CAAC;IAED,SAAS,CAAC,UAA6D;QACrE,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAC/C,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,UAAU,CAAC,OAAO,CAAC,MAAM,CACxD,CAAC;QAEF,IAAI,YAAY,KAAK,CAAC,CAAC,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,YAAY,CAAE,CAAC;QAElD,OAAO,IAAI,kBAAkB,CAAC;YAC5B,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC;YACxC,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC;YAC/B,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC;SAC1C,CAAC,CAAC;IACL,CAAC;IAED,MAAM;QACJ,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;SAC/D,CAAC;IACJ,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 { nanoid } from \"nanoid/non-secure\";\nimport { AgentToolCall } from \"./AgentToolCall.ts\";\nimport type { AgentChatResponse } from \"../AgentChatResponse.ts\";\nimport type { AgentToolRequestResponseContent } from \"../AgentToolRequestResponseContent.ts\";\nimport type { AgentToolResultResponseContent } from \"../AgentToolResultResponseContent.ts\";\n\n/**\n * Contains a collection of `AgentToolCall` associated with an `AgentChatExchange`.\n * As tool calls stream in, this class is updated immutably but maintains\n * a stable `.id` property.\n */\nexport class AgentToolCallGroup {\n readonly id = nanoid();\n readonly toolCalls: AgentToolCall[];\n\n constructor(toolCalls: AgentToolCallGroup[\"toolCalls\"], id?: AgentToolCallGroup[\"id\"]) {\n this.toolCalls = toolCalls;\n if (id) {\n this.id = id;\n }\n }\n\n addRequest(toolRequest: AgentChatResponse<AgentToolRequestResponseContent>) {\n return new AgentToolCallGroup([...this.toolCalls, new AgentToolCall(toolRequest)], this.id);\n }\n\n addResult(toolResult: AgentChatResponse<AgentToolResultResponseContent>) {\n const requestIndex = this.toolCalls.findLastIndex(\n (toolCall) => toolCall.id === toolResult.content.callId,\n );\n\n if (requestIndex === -1) {\n return this;\n }\n\n const toolCall = this.toolCalls.at(requestIndex)!;\n\n return new AgentToolCallGroup([\n ...this.toolCalls.slice(0, requestIndex),\n toolCall.withResult(toolResult),\n ...this.toolCalls.slice(requestIndex + 1),\n ]);\n }\n\n toJSON() {\n return {\n id: this.id,\n toolCalls: this.toolCalls.map((toolCall) => toolCall.toJSON()),\n };\n }\n}\n"]}
1
+ {"version":3,"file":"AgentToolCallGroup.js","sourceRoot":"","sources":["../../../../../src/enterprise/ai/chat/eventWrappers/AgentToolCallGroup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKnD;;;;GAIG;AACH,MAAM,OAAO,kBAAkB;IACpB,EAAE,GAAG,MAAM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025 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 { nanoid } from \"nanoid/non-secure\";\nimport { AgentToolCall } from \"./AgentToolCall.ts\";\nimport type { AgentChatResponse } from \"../AgentChatResponse.ts\";\nimport type { AgentToolRequestResponseContent } from \"../AgentToolRequestResponseContent.ts\";\nimport type { AgentToolResultResponseContent } from \"../AgentToolResultResponseContent.ts\";\n\n/**\n * Contains a collection of `AgentToolCall` associated with an `AgentChatExchange`.\n * As tool calls stream in, this class is updated immutably but maintains\n * a stable `.id` property.\n */\nexport class AgentToolCallGroup {\n readonly id = nanoid();\n readonly toolCalls: AgentToolCall[];\n\n constructor(toolCalls: AgentToolCallGroup[\"toolCalls\"], id?: AgentToolCallGroup[\"id\"]) {\n this.toolCalls = toolCalls;\n if (id) {\n this.id = id;\n }\n }\n\n addRequest(toolRequest: AgentChatResponse<AgentToolRequestResponseContent>) {\n return new AgentToolCallGroup([...this.toolCalls, new AgentToolCall(toolRequest)], this.id);\n }\n\n addResult(toolResult: AgentChatResponse<AgentToolResultResponseContent>) {\n const requestIndex = this.toolCalls.findLastIndex(\n (toolCall) => toolCall.id === toolResult.content.callId,\n );\n\n if (requestIndex === -1) {\n return this;\n }\n\n const toolCall = this.toolCalls.at(requestIndex)!;\n\n return new AgentToolCallGroup(\n [\n ...this.toolCalls.slice(0, requestIndex),\n toolCall.withResult(toolResult),\n ...this.toolCalls.slice(requestIndex + 1),\n ],\n this.id,\n );\n }\n\n toJSON() {\n return {\n id: this.id,\n toolCalls: this.toolCalls.map((toolCall) => toolCall.toJSON()),\n };\n }\n}\n"]}
@@ -22,38 +22,7 @@ export declare const modelProviderRetrieveCodec: z.ZodMiniCodec<z.ZodMiniObject<
22
22
  roleArn: z.ZodMiniString<string>;
23
23
  }, z.core.$strict>;
24
24
  }, z.core.$strict>]>;
25
- region: z.ZodMiniEnum<{
26
- "ap-east-2": "ap-east-2";
27
- "ap-northeast-1": "ap-northeast-1";
28
- "ap-northeast-2": "ap-northeast-2";
29
- "ap-northeast-3": "ap-northeast-3";
30
- "ap-south-1": "ap-south-1";
31
- "ap-south-2": "ap-south-2";
32
- "ap-southeast-1": "ap-southeast-1";
33
- "ap-southeast-2": "ap-southeast-2";
34
- "ap-southeast-3": "ap-southeast-3";
35
- "ap-southeast-4": "ap-southeast-4";
36
- "ap-southeast-5": "ap-southeast-5";
37
- "ap-southeast-7": "ap-southeast-7";
38
- "ca-central-1": "ca-central-1";
39
- "eu-central-1": "eu-central-1";
40
- "eu-central-2": "eu-central-2";
41
- "eu-north-1": "eu-north-1";
42
- "eu-south-1": "eu-south-1";
43
- "eu-south-2": "eu-south-2";
44
- "eu-west-1": "eu-west-1";
45
- "eu-west-2": "eu-west-2";
46
- "eu-west-3": "eu-west-3";
47
- "il-central-1": "il-central-1";
48
- "me-central-1": "me-central-1";
49
- "sa-east-1": "sa-east-1";
50
- "us-east-1": "us-east-1";
51
- "us-east-2": "us-east-2";
52
- "us-gov-east-1": "us-gov-east-1";
53
- "us-gov-west-1": "us-gov-west-1";
54
- "us-west-1": "us-west-1";
55
- "us-west-2": "us-west-2";
56
- }>;
25
+ region: z.ZodMiniString<string>;
57
26
  }, z.core.$strict>;
58
27
  }, z.core.$strict>, z.ZodMiniObject<{
59
28
  anthropic: z.ZodMiniObject<{}, z.core.$strict>;
@@ -91,38 +60,7 @@ export declare const modelProviderRetrieveCodec: z.ZodMiniCodec<z.ZodMiniObject<
91
60
  roleArn: z.ZodMiniString<string>;
92
61
  }, z.core.$strict>;
93
62
  }, z.core.$strict>]>;
94
- region: z.ZodMiniEnum<{
95
- "ap-east-2": "ap-east-2";
96
- "ap-northeast-1": "ap-northeast-1";
97
- "ap-northeast-2": "ap-northeast-2";
98
- "ap-northeast-3": "ap-northeast-3";
99
- "ap-south-1": "ap-south-1";
100
- "ap-south-2": "ap-south-2";
101
- "ap-southeast-1": "ap-southeast-1";
102
- "ap-southeast-2": "ap-southeast-2";
103
- "ap-southeast-3": "ap-southeast-3";
104
- "ap-southeast-4": "ap-southeast-4";
105
- "ap-southeast-5": "ap-southeast-5";
106
- "ap-southeast-7": "ap-southeast-7";
107
- "ca-central-1": "ca-central-1";
108
- "eu-central-1": "eu-central-1";
109
- "eu-central-2": "eu-central-2";
110
- "eu-north-1": "eu-north-1";
111
- "eu-south-1": "eu-south-1";
112
- "eu-south-2": "eu-south-2";
113
- "eu-west-1": "eu-west-1";
114
- "eu-west-2": "eu-west-2";
115
- "eu-west-3": "eu-west-3";
116
- "il-central-1": "il-central-1";
117
- "me-central-1": "me-central-1";
118
- "sa-east-1": "sa-east-1";
119
- "us-east-1": "us-east-1";
120
- "us-east-2": "us-east-2";
121
- "us-gov-east-1": "us-gov-east-1";
122
- "us-gov-west-1": "us-gov-west-1";
123
- "us-west-1": "us-west-1";
124
- "us-west-2": "us-west-2";
125
- }>;
63
+ region: z.ZodMiniString<string>;
126
64
  }, z.core.$strict>;
127
65
  }, z.core.$strict>, z.ZodMiniObject<{
128
66
  anthropic: z.ZodMiniObject<{}, z.core.$strict>;
@@ -166,38 +104,7 @@ export declare const modelProviderCreateCodec: z.ZodMiniCodec<z.ZodMiniObject<{
166
104
  roleArn: z.ZodMiniString<string>;
167
105
  }, z.core.$strict>;
168
106
  }, z.core.$strict>]>;
169
- region: z.ZodMiniEnum<{
170
- "ap-east-2": "ap-east-2";
171
- "ap-northeast-1": "ap-northeast-1";
172
- "ap-northeast-2": "ap-northeast-2";
173
- "ap-northeast-3": "ap-northeast-3";
174
- "ap-south-1": "ap-south-1";
175
- "ap-south-2": "ap-south-2";
176
- "ap-southeast-1": "ap-southeast-1";
177
- "ap-southeast-2": "ap-southeast-2";
178
- "ap-southeast-3": "ap-southeast-3";
179
- "ap-southeast-4": "ap-southeast-4";
180
- "ap-southeast-5": "ap-southeast-5";
181
- "ap-southeast-7": "ap-southeast-7";
182
- "ca-central-1": "ca-central-1";
183
- "eu-central-1": "eu-central-1";
184
- "eu-central-2": "eu-central-2";
185
- "eu-north-1": "eu-north-1";
186
- "eu-south-1": "eu-south-1";
187
- "eu-south-2": "eu-south-2";
188
- "eu-west-1": "eu-west-1";
189
- "eu-west-2": "eu-west-2";
190
- "eu-west-3": "eu-west-3";
191
- "il-central-1": "il-central-1";
192
- "me-central-1": "me-central-1";
193
- "sa-east-1": "sa-east-1";
194
- "us-east-1": "us-east-1";
195
- "us-east-2": "us-east-2";
196
- "us-gov-east-1": "us-gov-east-1";
197
- "us-gov-west-1": "us-gov-west-1";
198
- "us-west-1": "us-west-1";
199
- "us-west-2": "us-west-2";
200
- }>;
107
+ region: z.ZodMiniString<string>;
201
108
  }, z.core.$strict>;
202
109
  }, z.core.$strict>, z.ZodMiniObject<{
203
110
  anthropic: z.ZodMiniObject<{
@@ -238,38 +145,7 @@ export declare const modelProviderCreateCodec: z.ZodMiniCodec<z.ZodMiniObject<{
238
145
  roleArn: z.ZodMiniString<string>;
239
146
  }, z.core.$strict>;
240
147
  }, z.core.$strict>]>;
241
- region: z.ZodMiniEnum<{
242
- "ap-east-2": "ap-east-2";
243
- "ap-northeast-1": "ap-northeast-1";
244
- "ap-northeast-2": "ap-northeast-2";
245
- "ap-northeast-3": "ap-northeast-3";
246
- "ap-south-1": "ap-south-1";
247
- "ap-south-2": "ap-south-2";
248
- "ap-southeast-1": "ap-southeast-1";
249
- "ap-southeast-2": "ap-southeast-2";
250
- "ap-southeast-3": "ap-southeast-3";
251
- "ap-southeast-4": "ap-southeast-4";
252
- "ap-southeast-5": "ap-southeast-5";
253
- "ap-southeast-7": "ap-southeast-7";
254
- "ca-central-1": "ca-central-1";
255
- "eu-central-1": "eu-central-1";
256
- "eu-central-2": "eu-central-2";
257
- "eu-north-1": "eu-north-1";
258
- "eu-south-1": "eu-south-1";
259
- "eu-south-2": "eu-south-2";
260
- "eu-west-1": "eu-west-1";
261
- "eu-west-2": "eu-west-2";
262
- "eu-west-3": "eu-west-3";
263
- "il-central-1": "il-central-1";
264
- "me-central-1": "me-central-1";
265
- "sa-east-1": "sa-east-1";
266
- "us-east-1": "us-east-1";
267
- "us-east-2": "us-east-2";
268
- "us-gov-east-1": "us-gov-east-1";
269
- "us-gov-west-1": "us-gov-west-1";
270
- "us-west-1": "us-west-1";
271
- "us-west-2": "us-west-2";
272
- }>;
148
+ region: z.ZodMiniString<string>;
273
149
  }, z.core.$strict>;
274
150
  }, z.core.$strict>, z.ZodMiniObject<{
275
151
  anthropic: z.ZodMiniObject<{
@@ -317,38 +193,7 @@ export declare const modelProviderUpdateCodec: z.ZodMiniCodec<z.ZodMiniObject<{
317
193
  roleArn: z.ZodMiniString<string>;
318
194
  }, z.core.$strict>;
319
195
  }, z.core.$strict>]>>;
320
- region: z.ZodMiniOptional<z.ZodMiniEnum<{
321
- "ap-east-2": "ap-east-2";
322
- "ap-northeast-1": "ap-northeast-1";
323
- "ap-northeast-2": "ap-northeast-2";
324
- "ap-northeast-3": "ap-northeast-3";
325
- "ap-south-1": "ap-south-1";
326
- "ap-south-2": "ap-south-2";
327
- "ap-southeast-1": "ap-southeast-1";
328
- "ap-southeast-2": "ap-southeast-2";
329
- "ap-southeast-3": "ap-southeast-3";
330
- "ap-southeast-4": "ap-southeast-4";
331
- "ap-southeast-5": "ap-southeast-5";
332
- "ap-southeast-7": "ap-southeast-7";
333
- "ca-central-1": "ca-central-1";
334
- "eu-central-1": "eu-central-1";
335
- "eu-central-2": "eu-central-2";
336
- "eu-north-1": "eu-north-1";
337
- "eu-south-1": "eu-south-1";
338
- "eu-south-2": "eu-south-2";
339
- "eu-west-1": "eu-west-1";
340
- "eu-west-2": "eu-west-2";
341
- "eu-west-3": "eu-west-3";
342
- "il-central-1": "il-central-1";
343
- "me-central-1": "me-central-1";
344
- "sa-east-1": "sa-east-1";
345
- "us-east-1": "us-east-1";
346
- "us-east-2": "us-east-2";
347
- "us-gov-east-1": "us-gov-east-1";
348
- "us-gov-west-1": "us-gov-west-1";
349
- "us-west-1": "us-west-1";
350
- "us-west-2": "us-west-2";
351
- }>>;
196
+ region: z.ZodMiniOptional<z.ZodMiniString<string>>;
352
197
  }, z.core.$strict>;
353
198
  }, z.core.$strict>, z.ZodMiniObject<{
354
199
  anthropic: z.ZodMiniObject<{
@@ -395,38 +240,7 @@ export declare const modelProviderUpdateCodec: z.ZodMiniCodec<z.ZodMiniObject<{
395
240
  roleArn: z.ZodMiniString<string>;
396
241
  }, z.core.$strict>;
397
242
  }, z.core.$strict>]>>;
398
- region: z.ZodMiniOptional<z.ZodMiniEnum<{
399
- "ap-east-2": "ap-east-2";
400
- "ap-northeast-1": "ap-northeast-1";
401
- "ap-northeast-2": "ap-northeast-2";
402
- "ap-northeast-3": "ap-northeast-3";
403
- "ap-south-1": "ap-south-1";
404
- "ap-south-2": "ap-south-2";
405
- "ap-southeast-1": "ap-southeast-1";
406
- "ap-southeast-2": "ap-southeast-2";
407
- "ap-southeast-3": "ap-southeast-3";
408
- "ap-southeast-4": "ap-southeast-4";
409
- "ap-southeast-5": "ap-southeast-5";
410
- "ap-southeast-7": "ap-southeast-7";
411
- "ca-central-1": "ca-central-1";
412
- "eu-central-1": "eu-central-1";
413
- "eu-central-2": "eu-central-2";
414
- "eu-north-1": "eu-north-1";
415
- "eu-south-1": "eu-south-1";
416
- "eu-south-2": "eu-south-2";
417
- "eu-west-1": "eu-west-1";
418
- "eu-west-2": "eu-west-2";
419
- "eu-west-3": "eu-west-3";
420
- "il-central-1": "il-central-1";
421
- "me-central-1": "me-central-1";
422
- "sa-east-1": "sa-east-1";
423
- "us-east-1": "us-east-1";
424
- "us-east-2": "us-east-2";
425
- "us-gov-east-1": "us-gov-east-1";
426
- "us-gov-west-1": "us-gov-west-1";
427
- "us-west-1": "us-west-1";
428
- "us-west-2": "us-west-2";
429
- }>>;
243
+ region: z.ZodMiniOptional<z.ZodMiniString<string>>;
430
244
  }, z.core.$strict>;
431
245
  }, z.core.$strict>, z.ZodMiniObject<{
432
246
  anthropic: z.ZodMiniObject<{