@dremio/js-sdk 0.42.0 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +209 -0
- package/dist/cloud/ai/AIResource.d.ts +716 -17
- package/dist/cloud/ai/AIResource.js +40 -18
- package/dist/cloud/ai/AIResource.js.map +1 -1
- package/dist/cloud/ai/DremioModelProvider.d.ts +1 -1
- package/dist/cloud/ai/DremioModelProvider.js +6 -13
- package/dist/cloud/ai/DremioModelProvider.js.map +1 -1
- package/dist/cloud/ai/modelProviderCodec.d.ts +12 -0
- package/dist/cloud/replaceOriginResource.js +4 -0
- package/dist/cloud/replaceOriginResource.js.map +1 -1
- package/dist/common/ConflictResolver.d.ts +9 -1
- package/dist/common/ConflictResolver.js +10 -1
- package/dist/common/ConflictResolver.js.map +1 -1
- package/dist/common/refineRfc9557Schema.d.ts +1 -0
- package/dist/common/refineRfc9557Schema.js +26 -0
- package/dist/common/refineRfc9557Schema.js.map +1 -0
- package/dist/common/sharedExports.d.ts +1 -0
- package/dist/common/sharedExports.js +1 -0
- package/dist/common/sharedExports.js.map +1 -1
- package/dist/enterprise/Dremio.d.ts +1 -1
- package/dist/enterprise/Dremio.js +3 -2
- package/dist/enterprise/Dremio.js.map +1 -1
- package/dist/enterprise/ai/AIResource.d.ts +699 -18
- package/dist/enterprise/ai/AIResource.js +41 -19
- package/dist/enterprise/ai/AIResource.js.map +1 -1
- package/dist/enterprise/ai/chat/ChatSession.d.ts +4 -25
- package/dist/enterprise/ai/chat/ChatSession.js +6 -55
- package/dist/enterprise/ai/chat/ChatSession.js.map +1 -1
- package/dist/enterprise/ai/chat/UserChatMessage.d.ts +38 -22
- package/dist/enterprise/ai/chat/UserChatMessage.js +33 -41
- package/dist/enterprise/ai/chat/UserChatMessage.js.map +1 -1
- package/dist/enterprise/ai/chat/chatEventSchema.d.ts +169 -11
- package/dist/enterprise/ai/chat/chatEventSchema.js +183 -35
- package/dist/enterprise/ai/chat/chatEventSchema.js.map +1 -1
- package/dist/enterprise/ai/chat/eventWrappers/AgentChatPartialResponse.d.ts +0 -6
- package/dist/enterprise/ai/chat/eventWrappers/AgentChatResponse.d.ts +6 -6
- package/dist/enterprise/ai/chat/eventWrappers/AgentChatResponse.js +2 -2
- package/dist/enterprise/ai/chat/eventWrappers/AgentChatResponse.js.map +1 -1
- package/dist/enterprise/ai/chat/index.d.ts +0 -3
- package/dist/enterprise/ai/chat/index.js +0 -1
- package/dist/enterprise/ai/chat/index.js.map +1 -1
- package/dist/enterprise/ai/chat/methods/sendChatMessage.js +4 -1
- package/dist/enterprise/ai/chat/methods/sendChatMessage.js.map +1 -1
- package/dist/enterprise/ai/chat/responseContent/AgentModelResponseContent.d.ts +1 -2
- package/dist/enterprise/ai/chat/responseContent/AgentModelResponseContent.js.map +1 -1
- package/dist/enterprise/ai/chat/responseContent/AgentToolRequestResponseContent.d.ts +1 -2
- package/dist/enterprise/ai/chat/responseContent/AgentToolRequestResponseContent.js +0 -1
- package/dist/enterprise/ai/chat/responseContent/AgentToolRequestResponseContent.js.map +1 -1
- package/dist/enterprise/ai/chat/responseContent/AgentToolResultResponseContent.d.ts +1 -2
- package/dist/enterprise/ai/chat/responseContent/AgentToolResultResponseContent.js +0 -1
- package/dist/enterprise/ai/chat/responseContent/AgentToolResultResponseContent.js.map +1 -1
- package/dist/enterprise/ai/conversations/AgentConversation.d.ts +215 -0
- package/dist/enterprise/ai/conversations/AgentConversation.js +180 -0
- package/dist/enterprise/ai/conversations/AgentConversation.js.map +1 -0
- package/dist/enterprise/ai/conversations/conversationPropertiesCodec.d.ts +22 -0
- package/dist/enterprise/ai/conversations/conversationPropertiesCodec.js +62 -0
- package/dist/enterprise/ai/conversations/conversationPropertiesCodec.js.map +1 -0
- package/dist/enterprise/ai/conversations/createConversationMachine.d.ts +682 -0
- package/dist/enterprise/ai/conversations/createConversationMachine.js +354 -0
- package/dist/enterprise/ai/conversations/createConversationMachine.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/createConversation.d.ts +28 -0
- package/dist/enterprise/ai/conversations/methods/createConversation.js +68 -0
- package/dist/enterprise/ai/conversations/methods/createConversation.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/createExchangeRun.d.ts +16 -0
- package/dist/enterprise/ai/conversations/methods/createExchangeRun.js +36 -0
- package/dist/enterprise/ai/conversations/methods/createExchangeRun.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/deleteConversation.d.ts +2 -0
- package/dist/enterprise/ai/conversations/methods/deleteConversation.js +24 -0
- package/dist/enterprise/ai/conversations/methods/deleteConversation.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/listConversations.d.ts +8 -0
- package/dist/enterprise/ai/conversations/methods/listConversations.js +30 -0
- package/dist/enterprise/ai/conversations/methods/listConversations.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/retrieveConversation.d.ts +12 -0
- package/dist/enterprise/ai/conversations/methods/retrieveConversation.js +29 -0
- package/dist/enterprise/ai/conversations/methods/retrieveConversation.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/retrieveConversationHistory.d.ts +86 -0
- package/dist/enterprise/ai/conversations/methods/retrieveConversationHistory.js +32 -0
- package/dist/enterprise/ai/conversations/methods/retrieveConversationHistory.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/stopExchangeRun.d.ts +2 -0
- package/dist/enterprise/ai/conversations/methods/stopExchangeRun.js +24 -0
- package/dist/enterprise/ai/conversations/methods/stopExchangeRun.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/streamRunEvents.d.ts +6 -0
- package/dist/enterprise/ai/conversations/methods/streamRunEvents.js +33 -0
- package/dist/enterprise/ai/conversations/methods/streamRunEvents.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/updateConversation.d.ts +15 -0
- package/dist/enterprise/ai/conversations/methods/updateConversation.js +35 -0
- package/dist/enterprise/ai/conversations/methods/updateConversation.js.map +1 -0
- package/dist/enterprise/ai/conversations/reduceChatEvents.d.ts +17 -0
- package/dist/enterprise/ai/conversations/reduceChatEvents.js +74 -0
- package/dist/enterprise/ai/conversations/reduceChatEvents.js.map +1 -0
- package/dist/enterprise/ai/index.d.ts +5 -1
- package/dist/enterprise/ai/index.js +4 -1
- package/dist/enterprise/ai/index.js.map +1 -1
- package/dist/enterprise/ai/modelProvider/ModelProvider.d.ts +15 -1
- package/dist/enterprise/ai/modelProvider/ModelProvider.js +12 -1
- package/dist/enterprise/ai/modelProvider/ModelProvider.js.map +1 -1
- package/dist/enterprise/ai/modelProvider/modelProviderCodec.d.ts +40 -0
- package/dist/enterprise/ai/modelProvider/modelProviderCodec.js +10 -1
- package/dist/enterprise/ai/modelProvider/modelProviderCodec.js.map +1 -1
- package/dist/enterprise/ai/modelProvider/modelProviderConfigSchemas.d.ts +21 -0
- package/dist/enterprise/ai/modelProvider/modelProviderConfigSchemas.js +17 -0
- package/dist/enterprise/ai/modelProvider/modelProviderConfigSchemas.js.map +1 -1
- package/dist/oss/catalog/CatalogReferences/DatasetCatalogReference.d.ts +1 -0
- package/dist/oss/catalog/CatalogReferences/DatasetCatalogReference.js +1 -0
- package/dist/oss/catalog/CatalogReferences/DatasetCatalogReference.js.map +1 -1
- package/dist-iife/cloud.js +21620 -6202
- package/dist-iife/community.js +14 -0
- package/dist-iife/enterprise.js +19404 -4038
- package/package.json +5 -2
- package/dist/enterprise/ai/chat/ChatSessionClient.d.ts +0 -18
- package/dist/enterprise/ai/chat/ChatSessionClient.js +0 -55
- package/dist/enterprise/ai/chat/ChatSessionClient.js.map +0 -1
- package/dist/enterprise/ai/chat/UserChatMessageContent.d.ts +0 -19
- package/dist/enterprise/ai/chat/UserChatMessageContent.js +0 -44
- package/dist/enterprise/ai/chat/UserChatMessageContent.js.map +0 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2024-2025 Dremio Corporation
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import * as z from "zod/mini";
|
|
17
|
+
import { AgentConversation } from "../AgentConversation.js";
|
|
18
|
+
import { conversationPropertiesCodec, } from "../conversationPropertiesCodec.js";
|
|
19
|
+
export const listConversations = (config) => function listConversations(params, { signal } = {}) {
|
|
20
|
+
return config
|
|
21
|
+
.sonarV4Request(`agent/conversations?${new URLSearchParams({ maxResults: String(params.maxResults) }).toString()}`, { signal })
|
|
22
|
+
.map((res) => res.json())
|
|
23
|
+
.map((response) => {
|
|
24
|
+
return {
|
|
25
|
+
...response,
|
|
26
|
+
data: response.data.map((entity) => new AgentConversation(config, z.decode(conversationPropertiesCodec, entity))),
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=listConversations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listConversations.js","sourceRoot":"","sources":["../../../../../src/enterprise/ai/conversations/methods/listConversations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAG9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EACL,2BAA2B,GAE5B,MAAM,mCAAmC,CAAC;AAE3C,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAqB,EAAE,EAAE,CACzD,SAAS,iBAAiB,CAAC,MAA8B,EAAE,EAAE,MAAM,KAAkB,EAAE;IACrF,OAAO,MAAM;SACV,cAAc,CACb,uBAAuB,IAAI,eAAe,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,EAClG,EAAE,MAAM,EAAE,CACX;SACA,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAA6C,CAAC;SACnE,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;QAChB,OAAO;YACL,GAAG,QAAQ;YACX,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CACrB,CAAC,MAAM,EAAE,EAAE,CACT,IAAI,iBAAiB,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,2BAA2B,EAAE,MAAM,CAAC,CAAC,CAC/E;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC,CAAC","sourcesContent":["/*\n * Copyright (C) 2024-2025 Dremio Corporation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as z from \"zod/mini\";\nimport type { SonarV4Config } from \"../../../../common/Config.ts\";\nimport type { SignalParam } from \"../../../../common/Params.ts\";\nimport { AgentConversation } from \"../AgentConversation.ts\";\nimport {\n conversationPropertiesCodec,\n type ConversationEntity,\n} from \"../conversationPropertiesCodec.ts\";\n\nexport const listConversations = (config: SonarV4Config) =>\n function listConversations(params: { maxResults: number }, { signal }: SignalParam = {}) {\n return config\n .sonarV4Request(\n `agent/conversations?${new URLSearchParams({ maxResults: String(params.maxResults) }).toString()}`,\n { signal },\n )\n .map((res) => res.json() as Promise<{ data: ConversationEntity[] }>)\n .map((response) => {\n return {\n ...response,\n data: response.data.map(\n (entity) =>\n new AgentConversation(config, z.decode(conversationPropertiesCodec, entity)),\n ),\n };\n });\n };\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SonarV4Config } from "../../../../common/Config.ts";
|
|
2
|
+
import type { SignalParam } from "../../../../common/Params.ts";
|
|
3
|
+
export declare const retrieveConversation: (config: SonarV4Config) => (id: string, { signal }?: SignalParam) => import("ts-results-es").AsyncResult<{
|
|
4
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
5
|
+
currentRunId: string | null;
|
|
6
|
+
id: string;
|
|
7
|
+
modelName: string | null;
|
|
8
|
+
modelProviderId: string | null;
|
|
9
|
+
modifiedAt: import("temporal-polyfill").Temporal.Instant;
|
|
10
|
+
tag: string;
|
|
11
|
+
title: string;
|
|
12
|
+
}, import("../../../index.ts").HttpError>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2024-2025 Dremio Corporation
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import z from "zod";
|
|
17
|
+
import { conversationPropertiesCodec } from "../conversationPropertiesCodec.js";
|
|
18
|
+
export const retrieveConversation = (config) => function retrieveConversation(id, { signal } = {}) {
|
|
19
|
+
return config
|
|
20
|
+
.sonarV4Request(`agent/conversations/${id}`, {
|
|
21
|
+
headers: {
|
|
22
|
+
Accept: "application/json",
|
|
23
|
+
},
|
|
24
|
+
signal,
|
|
25
|
+
})
|
|
26
|
+
.map((res) => res.json())
|
|
27
|
+
.map((entity) => z.decode(conversationPropertiesCodec, entity));
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=retrieveConversation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieveConversation.js","sourceRoot":"","sources":["../../../../../src/enterprise/ai/conversations/methods/retrieveConversation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,CAAC,MAAM,KAAK,CAAC;AAGpB,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAEhF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,MAAqB,EAAE,EAAE,CAC5D,SAAS,oBAAoB,CAAC,EAAU,EAAE,EAAE,MAAM,KAAkB,EAAE;IACpE,OAAO,MAAM;SACV,cAAc,CAAC,uBAAuB,EAAE,EAAE,EAAE;QAC3C,OAAO,EAAE;YACP,MAAM,EAAE,kBAAkB;SAC3B;QACD,MAAM;KACP,CAAC;SACD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAA0D,CAAC;SAChF,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,2BAA2B,EAAE,MAAM,CAAC,CAAC,CAAC;AACpE,CAAC,CAAC","sourcesContent":["/*\n * Copyright (C) 2024-2025 Dremio Corporation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport z from \"zod\";\nimport type { SonarV4Config } from \"../../../../common/Config.ts\";\nimport type { SignalParam } from \"../../../../common/Params.ts\";\nimport { conversationPropertiesCodec } from \"../conversationPropertiesCodec.ts\";\n\nexport const retrieveConversation = (config: SonarV4Config) =>\n function retrieveConversation(id: string, { signal }: SignalParam = {}) {\n return config\n .sonarV4Request(`agent/conversations/${id}`, {\n headers: {\n Accept: \"application/json\",\n },\n signal,\n })\n .map((res) => res.json() as Promise<z.input<typeof conversationPropertiesCodec>>)\n .map((entity) => z.decode(conversationPropertiesCodec, entity));\n };\n"]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { SonarV4Config } from "../../../../common/Config.ts";
|
|
2
|
+
import type { SignalParam } from "../../../../common/Params.ts";
|
|
3
|
+
export declare const retrieveConversationHistory: (config: SonarV4Config) => (id: string, { signal }?: SignalParam) => import("ts-results-es").AsyncResult<{
|
|
4
|
+
data: ({
|
|
5
|
+
conversationId: string;
|
|
6
|
+
modelName: string;
|
|
7
|
+
modelProviderId: string;
|
|
8
|
+
runId: string;
|
|
9
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
10
|
+
id: string;
|
|
11
|
+
content: {
|
|
12
|
+
chunkType: "conversationUpdate";
|
|
13
|
+
summary?: string | undefined;
|
|
14
|
+
title?: string | undefined;
|
|
15
|
+
};
|
|
16
|
+
role: "agent";
|
|
17
|
+
} | {
|
|
18
|
+
conversationId: string;
|
|
19
|
+
modelName: string;
|
|
20
|
+
modelProviderId: string;
|
|
21
|
+
runId: string;
|
|
22
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
23
|
+
id: string;
|
|
24
|
+
content: {
|
|
25
|
+
chunkType: "error";
|
|
26
|
+
message: string;
|
|
27
|
+
};
|
|
28
|
+
role: "agent";
|
|
29
|
+
} | {
|
|
30
|
+
conversationId: string;
|
|
31
|
+
modelName: string;
|
|
32
|
+
modelProviderId: string;
|
|
33
|
+
runId: string;
|
|
34
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
35
|
+
id: string;
|
|
36
|
+
content: {
|
|
37
|
+
chunkType: "model";
|
|
38
|
+
name: string;
|
|
39
|
+
result: Record<string, unknown>;
|
|
40
|
+
};
|
|
41
|
+
role: "agent";
|
|
42
|
+
} | {
|
|
43
|
+
conversationId: string;
|
|
44
|
+
modelName: string;
|
|
45
|
+
modelProviderId: string;
|
|
46
|
+
runId: string;
|
|
47
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
48
|
+
id: string;
|
|
49
|
+
content: {
|
|
50
|
+
arguments: Record<string, unknown>;
|
|
51
|
+
callId: string;
|
|
52
|
+
chunkType: "toolRequest";
|
|
53
|
+
name: string;
|
|
54
|
+
commentary?: string | undefined;
|
|
55
|
+
summarizedTitle?: string | undefined;
|
|
56
|
+
};
|
|
57
|
+
role: "agent";
|
|
58
|
+
} | {
|
|
59
|
+
conversationId: string;
|
|
60
|
+
modelName: string;
|
|
61
|
+
modelProviderId: string;
|
|
62
|
+
runId: string;
|
|
63
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
64
|
+
id: string;
|
|
65
|
+
content: {
|
|
66
|
+
callId: string;
|
|
67
|
+
chunkType: "toolResponse";
|
|
68
|
+
name: string;
|
|
69
|
+
result: Record<string, unknown>;
|
|
70
|
+
commentary?: string | undefined;
|
|
71
|
+
};
|
|
72
|
+
role: "agent";
|
|
73
|
+
} | {
|
|
74
|
+
conversationId: string;
|
|
75
|
+
modelName: string;
|
|
76
|
+
modelProviderId: string;
|
|
77
|
+
runId: string;
|
|
78
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
79
|
+
id: string;
|
|
80
|
+
content: {
|
|
81
|
+
chunkType: "userMessage";
|
|
82
|
+
text: string;
|
|
83
|
+
};
|
|
84
|
+
role: "user";
|
|
85
|
+
})[];
|
|
86
|
+
}, import("../../../index.ts").HttpError>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2024-2025 Dremio Corporation
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { chatEventCodec } from "../../chat/chatEventSchema.js";
|
|
17
|
+
import * as z from "zod/mini";
|
|
18
|
+
export const retrieveConversationHistory = (config) => function retrieveConversationHistory(id, { signal } = {}) {
|
|
19
|
+
return config
|
|
20
|
+
.sonarV4Request(`agent/conversations/${id}/messages`, {
|
|
21
|
+
headers: {
|
|
22
|
+
Accept: "application/json",
|
|
23
|
+
},
|
|
24
|
+
signal,
|
|
25
|
+
})
|
|
26
|
+
.map((res) => res.json())
|
|
27
|
+
.map((response) => ({
|
|
28
|
+
...response,
|
|
29
|
+
data: response.data.map((chatEvent) => z.decode(chatEventCodec, chatEvent)),
|
|
30
|
+
}));
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=retrieveConversationHistory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieveConversationHistory.js","sourceRoot":"","sources":["../../../../../src/enterprise/ai/conversations/methods/retrieveConversationHistory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,MAAqB,EAAE,EAAE,CACnE,SAAS,2BAA2B,CAAC,EAAU,EAAE,EAAE,MAAM,KAAkB,EAAE;IAC3E,OAAO,MAAM;SACV,cAAc,CAAC,uBAAuB,EAAE,WAAW,EAAE;QACpD,OAAO,EAAE;YACP,MAAM,EAAE,kBAAkB;SAC3B;QACD,MAAM;KACP,CAAC;SACD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAyD,CAAC;SAC/E,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAClB,GAAG,QAAQ;QACX,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;KAC5E,CAAC,CAAC,CAAC;AACR,CAAC,CAAC","sourcesContent":["/*\n * Copyright (C) 2024-2025 Dremio Corporation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { SonarV4Config } from \"../../../../common/Config.ts\";\nimport type { SignalParam } from \"../../../../common/Params.ts\";\nimport { chatEventCodec } from \"../../chat/chatEventSchema.js\";\nimport * as z from \"zod/mini\";\n\nexport const retrieveConversationHistory = (config: SonarV4Config) =>\n function retrieveConversationHistory(id: string, { signal }: SignalParam = {}) {\n return config\n .sonarV4Request(`agent/conversations/${id}/messages`, {\n headers: {\n Accept: \"application/json\",\n },\n signal,\n })\n .map((res) => res.json() as Promise<{ data: z.input<typeof chatEventCodec>[] }>)\n .map((response) => ({\n ...response,\n data: response.data.map((chatEvent) => z.decode(chatEventCodec, chatEvent)),\n }));\n };\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2024-2025 Dremio Corporation
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export const stopExchangeRun = (config) => function stopExchangeRun(conversationId, id) {
|
|
17
|
+
return config
|
|
18
|
+
.sonarV4Request(`agent/conversations/${conversationId}/runs/${id}:cancel`, {
|
|
19
|
+
keepalive: true,
|
|
20
|
+
method: "POST",
|
|
21
|
+
})
|
|
22
|
+
.map(() => undefined);
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=stopExchangeRun.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stopExchangeRun.js","sourceRoot":"","sources":["../../../../../src/enterprise/ai/conversations/methods/stopExchangeRun.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAqB,EAAE,EAAE,CACvD,SAAS,eAAe,CAAC,cAAsB,EAAE,EAAU;IACzD,OAAO,MAAM;SACV,cAAc,CAAC,uBAAuB,cAAc,SAAS,EAAE,SAAS,EAAE;QACzE,SAAS,EAAE,IAAI;QACf,MAAM,EAAE,MAAM;KACf,CAAC;SACD,GAAG,CAAC,GAAG,EAAE,CAAC,SAAiB,CAAC,CAAC;AAClC,CAAC,CAAC","sourcesContent":["/*\n * Copyright (C) 2024-2025 Dremio Corporation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { SonarV4Config } from \"../../../../common/Config.ts\";\n\nexport const stopExchangeRun = (config: SonarV4Config) =>\n function stopExchangeRun(conversationId: string, id: string) {\n return config\n .sonarV4Request(`agent/conversations/${conversationId}/runs/${id}:cancel`, {\n keepalive: true,\n method: \"POST\",\n })\n .map(() => undefined as void);\n };\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SonarV4Config } from "../../../../common/Config.ts";
|
|
2
|
+
import type { SignalParam } from "../../../../common/Params.ts";
|
|
3
|
+
export declare const streamRunEvents: (config: SonarV4Config) => (params: {
|
|
4
|
+
conversationId: string;
|
|
5
|
+
runId: string;
|
|
6
|
+
}, { signal }?: SignalParam) => Promise<Response>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2024-2025 Dremio Corporation
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export const streamRunEvents = (config) => function streamRunEvents(params, { signal } = {}) {
|
|
17
|
+
return config
|
|
18
|
+
.sonarV4Request(`agent/conversations/${params.conversationId}/runs/${params.runId}`, {
|
|
19
|
+
headers: {
|
|
20
|
+
Accept: "text/event-stream",
|
|
21
|
+
"Accept-Encoding": "identity",
|
|
22
|
+
Connection: "keep-alive",
|
|
23
|
+
},
|
|
24
|
+
signal,
|
|
25
|
+
})
|
|
26
|
+
.promise.then((result) => {
|
|
27
|
+
if (result.isErr()) {
|
|
28
|
+
throw result.error;
|
|
29
|
+
}
|
|
30
|
+
return result.value;
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=streamRunEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamRunEvents.js","sourceRoot":"","sources":["../../../../../src/enterprise/ai/conversations/methods/streamRunEvents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAqB,EAAE,EAAE,CACvD,SAAS,eAAe,CACtB,MAAiD,EACjD,EAAE,MAAM,KAAkB,EAAE;IAE5B,OAAO,MAAM;SACV,cAAc,CAAC,uBAAuB,MAAM,CAAC,cAAc,SAAS,MAAM,CAAC,KAAK,EAAE,EAAE;QACnF,OAAO,EAAE;YACP,MAAM,EAAE,mBAAmB;YAC3B,iBAAiB,EAAE,UAAU;YAC7B,UAAU,EAAE,YAAY;SACzB;QACD,MAAM;KACP,CAAC;SACD,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QACvB,IAAI,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;YACnB,MAAM,MAAM,CAAC,KAAK,CAAC;QACrB,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC;IACtB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC","sourcesContent":["/*\n * Copyright (C) 2024-2025 Dremio Corporation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { SonarV4Config } from \"../../../../common/Config.ts\";\nimport type { SignalParam } from \"../../../../common/Params.ts\";\n\nexport const streamRunEvents = (config: SonarV4Config) =>\n function streamRunEvents(\n params: { conversationId: string; runId: string },\n { signal }: SignalParam = {},\n ) {\n return config\n .sonarV4Request(`agent/conversations/${params.conversationId}/runs/${params.runId}`, {\n headers: {\n Accept: \"text/event-stream\",\n \"Accept-Encoding\": \"identity\",\n Connection: \"keep-alive\",\n },\n signal,\n })\n .promise.then((result) => {\n if (result.isErr()) {\n throw result.error;\n }\n return result.value;\n });\n };\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as z from "zod/mini";
|
|
2
|
+
import type { SonarV4Config } from "../../../../common/Config.ts";
|
|
3
|
+
export declare const updateConversation: (config: SonarV4Config) => (id: string, tag: string, properties: z.infer<typeof conversationUpdateSchema>) => import("ts-results-es").AsyncResult<{
|
|
4
|
+
createdAt: import("temporal-polyfill").Temporal.Instant;
|
|
5
|
+
currentRunId: string | null;
|
|
6
|
+
id: string;
|
|
7
|
+
modelName: string | null;
|
|
8
|
+
modelProviderId: string | null;
|
|
9
|
+
modifiedAt: import("temporal-polyfill").Temporal.Instant;
|
|
10
|
+
tag: string;
|
|
11
|
+
title: string;
|
|
12
|
+
}, import("../../../index.ts").HttpError>;
|
|
13
|
+
export declare const conversationUpdateSchema: z.ZodMiniObject<{
|
|
14
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
15
|
+
}, z.core.$strict>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2024-2025 Dremio Corporation
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import * as z from "zod/mini";
|
|
17
|
+
import { conversationPropertiesCodec, } from "../conversationPropertiesCodec.js";
|
|
18
|
+
export const updateConversation = (config) => function updateConversation(id, tag, properties) {
|
|
19
|
+
return config
|
|
20
|
+
.sonarV4Request(`agent/conversations/${id}`, {
|
|
21
|
+
body: JSON.stringify({
|
|
22
|
+
...z.parse(conversationUpdateSchema, properties),
|
|
23
|
+
tag,
|
|
24
|
+
}),
|
|
25
|
+
headers: { Accept: "application/json", "Content-Type": "application/json" },
|
|
26
|
+
keepalive: true,
|
|
27
|
+
method: "PATCH",
|
|
28
|
+
})
|
|
29
|
+
.map((res) => res.json())
|
|
30
|
+
.map((entity) => z.decode(conversationPropertiesCodec, entity));
|
|
31
|
+
};
|
|
32
|
+
export const conversationUpdateSchema = z.strictObject({
|
|
33
|
+
title: z.optional(z.string().check(z.trim(), z.minLength(1))),
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=updateConversation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateConversation.js","sourceRoot":"","sources":["../../../../../src/enterprise/ai/conversations/methods/updateConversation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,OAAO,EACL,2BAA2B,GAE5B,MAAM,mCAAmC,CAAC;AAE3C,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAqB,EAAE,EAAE,CAC1D,SAAS,kBAAkB,CACzB,EAAU,EACV,GAAW,EACX,UAAoD;IAEpD,OAAO,MAAM;SACV,cAAc,CAAC,uBAAuB,EAAE,EAAE,EAAE;QAC3C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,GAAG,CAAC,CAAC,KAAK,CAAC,wBAAwB,EAAE,UAAU,CAAC;YAChD,GAAG;SACJ,CAAC;QACF,OAAO,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC3E,SAAS,EAAE,IAAI;QACf,MAAM,EAAE,OAAO;KAChB,CAAC;SACD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAiC,CAAC;SACvD,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,2BAA2B,EAAE,MAAM,CAAC,CAAC,CAAC;AACpE,CAAC,CAAC;AAEJ,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,YAAY,CAAC;IACrD,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;CAC9D,CAAC,CAAC","sourcesContent":["/*\n * Copyright (C) 2024-2025 Dremio Corporation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as z from \"zod/mini\";\nimport type { SonarV4Config } from \"../../../../common/Config.ts\";\nimport {\n conversationPropertiesCodec,\n type ConversationEntity,\n} from \"../conversationPropertiesCodec.ts\";\n\nexport const updateConversation = (config: SonarV4Config) =>\n function updateConversation(\n id: string,\n tag: string,\n properties: z.infer<typeof conversationUpdateSchema>,\n ) {\n return config\n .sonarV4Request(`agent/conversations/${id}`, {\n body: JSON.stringify({\n ...z.parse(conversationUpdateSchema, properties),\n tag,\n }),\n headers: { Accept: \"application/json\", \"Content-Type\": \"application/json\" },\n keepalive: true,\n method: \"PATCH\",\n })\n .map((res) => res.json() as Promise<ConversationEntity>)\n .map((entity) => z.decode(conversationPropertiesCodec, entity));\n };\n\nexport const conversationUpdateSchema = z.strictObject({\n title: z.optional(z.string().check(z.trim(), z.minLength(1))),\n});\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ChatEvent, ChatEventWithChunkType } from "../chat/chatEventSchema.ts";
|
|
2
|
+
import type { UserChatMessage } from "../chat/UserChatMessage.ts";
|
|
3
|
+
export type AgentToolCall = {
|
|
4
|
+
id: string;
|
|
5
|
+
state: "error" | "pending" | "success";
|
|
6
|
+
request: ChatEventWithChunkType<"toolRequest"> | undefined;
|
|
7
|
+
result: ChatEventWithChunkType<"toolResponse"> | undefined;
|
|
8
|
+
};
|
|
9
|
+
export type ConversationExchangeMessage = ChatEventWithChunkType<"error"> | ChatEventWithChunkType<"model"> | ChatEventWithChunkType<"userMessage">;
|
|
10
|
+
export type ConversationExchange = {
|
|
11
|
+
id: string;
|
|
12
|
+
messages: Map<string, ConversationExchangeMessage>;
|
|
13
|
+
submittedUserMessage?: UserChatMessage;
|
|
14
|
+
toolCalls: Map<string, AgentToolCall>;
|
|
15
|
+
};
|
|
16
|
+
export type ChatEventReducerState = ConversationExchange[];
|
|
17
|
+
export declare function reduceChatEvents(state: ChatEventReducerState | undefined, chatEvents: ChatEvent[]): ChatEventReducerState;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2024-2025 Dremio Corporation
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { create } from "mutative";
|
|
17
|
+
function applyChatEventToConversation(draft, chatEvent) {
|
|
18
|
+
let conversationExchange = draft.findLast((exchange) => exchange.id === chatEvent.runId);
|
|
19
|
+
if (!conversationExchange) {
|
|
20
|
+
conversationExchange = {
|
|
21
|
+
id: chatEvent.runId,
|
|
22
|
+
messages: new Map(),
|
|
23
|
+
toolCalls: new Map(),
|
|
24
|
+
};
|
|
25
|
+
draft.push(conversationExchange);
|
|
26
|
+
conversationExchange = draft[draft.length - 1];
|
|
27
|
+
}
|
|
28
|
+
applyChatEventToConversationExchange(conversationExchange, chatEvent);
|
|
29
|
+
}
|
|
30
|
+
function applyChatEventToConversationExchange(conversationExchange, chatEvent) {
|
|
31
|
+
switch (chatEvent.content.chunkType) {
|
|
32
|
+
case "error":
|
|
33
|
+
case "model":
|
|
34
|
+
case "userMessage": {
|
|
35
|
+
conversationExchange.messages.set(chatEvent.id, chatEvent);
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
case "toolRequest":
|
|
39
|
+
case "toolResponse": {
|
|
40
|
+
const callId = chatEvent.content.callId;
|
|
41
|
+
if (!conversationExchange.toolCalls.has(callId)) {
|
|
42
|
+
conversationExchange.toolCalls.set(callId, {
|
|
43
|
+
id: callId,
|
|
44
|
+
request: undefined,
|
|
45
|
+
result: undefined,
|
|
46
|
+
state: "pending",
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const toolCall = conversationExchange.toolCalls.get(callId);
|
|
50
|
+
switch (chatEvent.content.chunkType) {
|
|
51
|
+
case "toolRequest":
|
|
52
|
+
toolCall.request = chatEvent;
|
|
53
|
+
break;
|
|
54
|
+
case "toolResponse":
|
|
55
|
+
toolCall.result = chatEvent;
|
|
56
|
+
if ("errorMessage" in toolCall.result.content.result) {
|
|
57
|
+
toolCall.state = "error";
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
toolCall.state = "success";
|
|
61
|
+
}
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export function reduceChatEvents(state = [], chatEvents) {
|
|
68
|
+
return create(state, (draft) => {
|
|
69
|
+
for (const chatEvent of chatEvents) {
|
|
70
|
+
applyChatEventToConversation(draft, Object.freeze(chatEvent));
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=reduceChatEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reduceChatEvents.js","sourceRoot":"","sources":["../../../../src/enterprise/ai/conversations/reduceChatEvents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,MAAM,EAAc,MAAM,UAAU,CAAC;AAyB9C,SAAS,4BAA4B,CACnC,KAAmC,EACnC,SAAoB;IAEpB,IAAI,oBAAoB,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC;IAEzF,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC1B,oBAAoB,GAAG;YACrB,EAAE,EAAE,SAAS,CAA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,MAAM,GAAG,SAAqE,CAAC;oBACxF,IAAI,cAAc,IAAI,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;wBACrD,QAAQ,CAAC,KAAK,GAAG,OAAO,CAAC;oBAC3B,CAAC;yBAAM,CAAC;wBACN,QAAQ,CAAC,KAAK,GAAG,SAAS,CAAC;oBAC7B,CAAC;oBACD,MAAM;YACV,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,QAA+B,EAAE,EAAE,UAAuB;IACzF,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;QAC7B,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,4BAA4B,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;QAChE,CAAC;IACH,CAAC,CAAC,CAAC;AACL,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 { create, type Draft } from \"mutative\";\nimport type { ChatEvent, ChatEventWithChunkType } from \"../chat/chatEventSchema.ts\";\nimport type { UserChatMessage } from \"../chat/UserChatMessage.ts\";\n\nexport type AgentToolCall = {\n id: string;\n state: \"error\" | \"pending\" | \"success\";\n request: ChatEventWithChunkType<\"toolRequest\"> | undefined;\n result: ChatEventWithChunkType<\"toolResponse\"> | undefined;\n};\n\nexport type ConversationExchangeMessage =\n | ChatEventWithChunkType<\"error\">\n | ChatEventWithChunkType<\"model\">\n | ChatEventWithChunkType<\"userMessage\">;\n\nexport type ConversationExchange = {\n id: string;\n messages: Map<string, ConversationExchangeMessage>;\n submittedUserMessage?: UserChatMessage;\n toolCalls: Map<string, AgentToolCall>;\n};\n\nexport type ChatEventReducerState = ConversationExchange[];\n\nfunction applyChatEventToConversation(\n draft: Draft<ChatEventReducerState>,\n chatEvent: ChatEvent,\n): void {\n let conversationExchange = draft.findLast((exchange) => exchange.id === chatEvent.runId);\n\n if (!conversationExchange) {\n conversationExchange = {\n id: chatEvent.runId,\n messages: new Map(),\n toolCalls: new Map(),\n };\n draft.push(conversationExchange);\n conversationExchange = draft[draft.length - 1];\n }\n\n applyChatEventToConversationExchange(conversationExchange!, chatEvent);\n}\n\nfunction applyChatEventToConversationExchange(\n conversationExchange: Draft<ConversationExchange>,\n chatEvent: ChatEvent,\n): void {\n switch (chatEvent.content.chunkType) {\n case \"error\":\n case \"model\":\n case \"userMessage\": {\n conversationExchange.messages.set(\n chatEvent.id,\n chatEvent as Draft<ConversationExchangeMessage>,\n );\n break;\n }\n case \"toolRequest\":\n case \"toolResponse\": {\n const callId = chatEvent.content.callId;\n\n if (!conversationExchange.toolCalls.has(callId)) {\n conversationExchange.toolCalls.set(callId, {\n id: callId,\n request: undefined,\n result: undefined,\n state: \"pending\",\n });\n }\n\n const toolCall = conversationExchange.toolCalls.get(callId)!;\n\n switch (chatEvent.content.chunkType) {\n case \"toolRequest\":\n toolCall.request = chatEvent as unknown as Draft<ChatEventWithChunkType<\"toolRequest\">>;\n break;\n case \"toolResponse\":\n toolCall.result = chatEvent as unknown as Draft<ChatEventWithChunkType<\"toolResponse\">>;\n if (\"errorMessage\" in toolCall.result.content.result) {\n toolCall.state = \"error\";\n } else {\n toolCall.state = \"success\";\n }\n break;\n }\n }\n }\n}\n\nexport function reduceChatEvents(state: ChatEventReducerState = [], chatEvents: ChatEvent[]) {\n return create(state, (draft) => {\n for (const chatEvent of chatEvents) {\n applyChatEventToConversation(draft, Object.freeze(chatEvent));\n }\n });\n}\n"]}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { AgentConversation } from "./conversations/AgentConversation.ts";
|
|
1
2
|
import { ModelProvider } from "./modelProvider/ModelProvider.ts";
|
|
3
|
+
import { type ChatEvent, type ChatEventWithChunkType } from "./chat/chatEventSchema.ts";
|
|
4
|
+
import type { ConversationExchange, ConversationExchangeMessage, AgentToolCall } from "./conversations/reduceChatEvents.ts";
|
|
5
|
+
import { type AgentConversationMachine } from "./conversations/createConversationMachine.ts";
|
|
2
6
|
export * from "./chat/index.ts";
|
|
3
|
-
export { ModelProvider };
|
|
7
|
+
export { AgentConversation, ModelProvider, type ChatEvent, type ChatEventWithChunkType, type ConversationExchange, type ConversationExchangeMessage, type AgentToolCall, type AgentConversationMachine, };
|
|
@@ -13,7 +13,10 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import { AgentConversation } from "./conversations/AgentConversation.js";
|
|
16
17
|
import { ModelProvider } from "./modelProvider/ModelProvider.js";
|
|
18
|
+
import {} from "./chat/chatEventSchema.js";
|
|
19
|
+
import {} from "./conversations/createConversationMachine.js";
|
|
17
20
|
export * from "./chat/index.js";
|
|
18
|
-
export { ModelProvider };
|
|
21
|
+
export { AgentConversation, ModelProvider, };
|
|
19
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/enterprise/ai/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,cAAc,iBAAiB,CAAC;AAChC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/enterprise/ai/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAA+C,MAAM,2BAA2B,CAAC;AAMxF,OAAO,EAAiC,MAAM,8CAA8C,CAAC;AAC7F,cAAc,iBAAiB,CAAC;AAChC,OAAO,EACL,iBAAiB,EACjB,aAAa,GAOd,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 { AgentConversation } from \"./conversations/AgentConversation.ts\";\nimport { ModelProvider } from \"./modelProvider/ModelProvider.ts\";\nimport { type ChatEvent, type ChatEventWithChunkType } from \"./chat/chatEventSchema.ts\";\nimport type {\n ConversationExchange,\n ConversationExchangeMessage,\n AgentToolCall,\n} from \"./conversations/reduceChatEvents.ts\";\nimport { type AgentConversationMachine } from \"./conversations/createConversationMachine.ts\";\nexport * from \"./chat/index.ts\";\nexport {\n AgentConversation,\n ModelProvider,\n type ChatEvent,\n type ChatEventWithChunkType,\n type ConversationExchange,\n type ConversationExchangeMessage,\n type AgentToolCall,\n type AgentConversationMachine,\n};\n"]}
|
|
@@ -16,7 +16,7 @@ export declare class ModelProvider implements Omit<ModelProviderProperties, "tag
|
|
|
16
16
|
readonly sqlModelNames: ModelProviderProperties["sqlModelNames"];
|
|
17
17
|
constructor(config: V4Config, properties: z.output<typeof modelProviderRetrieveCodec>);
|
|
18
18
|
delete(): import("ts-results-es").AsyncResult<void, import("../../index.ts").HttpError>;
|
|
19
|
-
setDefault(): import("ts-results-es").AsyncResult<
|
|
19
|
+
setDefault(): import("ts-results-es").AsyncResult<void, import("../../index.ts").HttpError>;
|
|
20
20
|
update(fields: Partial<z.output<typeof modelProviderUpdateCodec>>): import("ts-results-es").AsyncResult<ModelProvider, VersionConflictError | import("../../index.ts").HttpError>;
|
|
21
21
|
static createSchema: z.ZodMiniObject<{
|
|
22
22
|
name: z.ZodMiniString<string>;
|
|
@@ -63,6 +63,13 @@ export declare class ModelProvider implements Omit<ModelProviderProperties, "tag
|
|
|
63
63
|
EU: "EU";
|
|
64
64
|
}>>;
|
|
65
65
|
}, z.core.$strip>;
|
|
66
|
+
}, z.core.$strict>, z.ZodMiniObject<{
|
|
67
|
+
openAiCompatibleApi: z.ZodMiniObject<{
|
|
68
|
+
accessKey: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
69
|
+
completionsApiUrl: z.ZodMiniString<string>;
|
|
70
|
+
modelParameters: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
71
|
+
organizationId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
72
|
+
}, z.core.$strip>;
|
|
66
73
|
}, z.core.$strict>]>;
|
|
67
74
|
defaultModelName: z.ZodMiniString<string>;
|
|
68
75
|
isDefault: z.ZodMiniBoolean<boolean>;
|
|
@@ -119,6 +126,13 @@ export declare class ModelProvider implements Omit<ModelProviderProperties, "tag
|
|
|
119
126
|
EU: "EU";
|
|
120
127
|
}>>>;
|
|
121
128
|
}, z.core.$strip>;
|
|
129
|
+
}, z.core.$strict>, z.ZodMiniObject<{
|
|
130
|
+
openAiCompatibleApi: z.ZodMiniObject<{
|
|
131
|
+
accessKey: z.ZodMiniOptional<z.ZodMiniOptional<z.ZodMiniString<string>>>;
|
|
132
|
+
completionsApiUrl: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
133
|
+
modelParameters: z.ZodMiniOptional<z.ZodMiniOptional<z.ZodMiniString<string>>>;
|
|
134
|
+
organizationId: z.ZodMiniOptional<z.ZodMiniOptional<z.ZodMiniString<string>>>;
|
|
135
|
+
}, z.core.$strip>;
|
|
122
136
|
}, z.core.$strict>]>;
|
|
123
137
|
defaultModelName: z.ZodMiniString<string>;
|
|
124
138
|
isDefault: z.ZodMiniBoolean<boolean>;
|
|
@@ -52,7 +52,18 @@ export class ModelProvider {
|
|
|
52
52
|
.map(() => undefined);
|
|
53
53
|
}
|
|
54
54
|
setDefault() {
|
|
55
|
-
return this
|
|
55
|
+
return this.#config
|
|
56
|
+
.v4Request(`model-provider:setDefault`, {
|
|
57
|
+
body: JSON.stringify({
|
|
58
|
+
id: this.id,
|
|
59
|
+
}),
|
|
60
|
+
headers: {
|
|
61
|
+
"Content-Type": "application/json",
|
|
62
|
+
},
|
|
63
|
+
keepalive: true,
|
|
64
|
+
method: "POST",
|
|
65
|
+
})
|
|
66
|
+
.map(() => undefined);
|
|
56
67
|
}
|
|
57
68
|
update(fields) {
|
|
58
69
|
const body = z.encode(modelProviderUpdateCodec, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelProvider.js","sourceRoot":"","sources":["../../../../src/enterprise/ai/modelProvider/ModelProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,MAAM,OAAO,aAAa;IACf,MAAM,CAAoC;IAC1C,SAAS,CAAuC;IAChD,SAAS,CAAuC;IAChD,gBAAgB,CAA8C;IAC9D,EAAE,CAAgC;IAClC,SAAS,CAAuC;IAChD,UAAU,CAAwC;IAClD,UAAU,CAAwC;IAClD,IAAI,CAAkC;IACtC,aAAa,CAA2C;IAExD,OAAO,CAAW;IAClB,IAAI,CAAS;IAEtB,YAAY,MAAgB,EAAE,UAAuD;QACnF,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,S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GAAG,EAAE,CAAC;gBACvB,OAAO,IAAI,oBAAoB,EAAE,CAAC;YACpC,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC,CAAC,CAAC;IACP,CAAC;IAED,MAAM,CAAC,YAAY,GAAG,wBAAwB,CAAC,GAAG,CAAC,GAAG,CAAC;IACvD,MAAM,CAAC,YAAY,GAAG,wBAAwB,CAAC,GAAG,CAAC,GAAG,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 type { V4Config } from \"../../../common/Config.ts\";\nimport * as z from \"zod/mini\";\nimport {\n modelProviderCreateCodec,\n modelProviderRetrieveCodec,\n modelProviderUpdateCodec,\n} from \"./modelProviderCodec.ts\";\nimport { VersionConflictError } from \"../../../common/problems.ts\";\n\nexport class ModelProvider implements Omit<ModelProviderProperties, \"tag\"> {\n readonly config: ModelProviderProperties[\"config\"];\n readonly createdAt: ModelProviderProperties[\"createdAt\"];\n readonly createdBy: ModelProviderProperties[\"createdBy\"];\n readonly defaultModelName: ModelProviderProperties[\"defaultModelName\"];\n readonly id: ModelProviderProperties[\"id\"];\n readonly isDefault: ModelProviderProperties[\"isDefault\"];\n readonly modifiedAt: ModelProviderProperties[\"modifiedAt\"];\n readonly modifiedBy: ModelProviderProperties[\"modifiedBy\"];\n readonly name: ModelProviderProperties[\"name\"];\n readonly sqlModelNames: ModelProviderProperties[\"sqlModelNames\"];\n\n readonly #config: V4Config;\n readonly #tag: string;\n\n constructor(config: V4Config, properties: z.output<typeof modelProviderRetrieveCodec>) {\n this.config = properties.config;\n this.createdAt = properties.createdAt;\n this.createdBy = properties.createdBy;\n this.defaultModelName = properties.defaultModelName;\n this.id = properties.id;\n this.isDefault = properties.isDefault;\n this.modifiedAt = properties.modifiedAt;\n this.modifiedBy = properties.modifiedBy;\n this.name = properties.name;\n this.sqlModelNames = properties.sqlModelNames;\n\n this.#config = config;\n this.#tag = properties.tag;\n }\n\n delete() {\n return this.#config\n .v4Request(`model-provider/config/${this.id}`, {\n keepalive: true,\n method: \"DELETE\",\n })\n .map(() => undefined as void);\n }\n\n setDefault() {\n return this.#config\n .v4Request(`model-provider:setDefault`, {\n body: JSON.stringify({\n id: this.id,\n }),\n headers: {\n \"Content-Type\": \"application/json\",\n },\n keepalive: true,\n method: \"POST\",\n })\n .map(() => undefined as void);\n }\n\n update(fields: Partial<z.output<typeof modelProviderUpdateCodec>>) {\n const body = z.encode(modelProviderUpdateCodec, {\n config: fields.config ?? this.config,\n defaultModelName: fields.defaultModelName ?? this.defaultModelName,\n isDefault: fields.isDefault ?? this.isDefault,\n name: fields.name ?? this.name,\n sqlModelNames: fields.sqlModelNames ?? this.sqlModelNames,\n });\n\n return this.#config\n .v4Request(`model-provider/config/${this.id}`, {\n body: JSON.stringify({ ...body, tag: this.#tag }),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n keepalive: true,\n method: \"PUT\",\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 .mapErr((val) => {\n if (val.status === 409) {\n return new VersionConflictError();\n }\n return val;\n });\n }\n\n static createSchema = modelProviderCreateCodec.def.out;\n static updateSchema = modelProviderUpdateCodec.def.out;\n}\n\ntype ModelProviderProperties = z.output<typeof modelProviderRetrieveCodec>;\n"]}
|