@axiom-lattice/client-sdk 2.1.56 → 2.1.58
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/dist/ChunkMessageMerger.d.ts.map +1 -1
- package/dist/ChunkMessageMerger.js +42 -103
- package/dist/ChunkMessageMerger.js.map +1 -1
- package/dist/abstract-client.d.ts +98 -1
- package/dist/abstract-client.d.ts.map +1 -1
- package/dist/abstract-client.js +139 -0
- package/dist/abstract-client.js.map +1 -1
- package/dist/index.d.ts +98 -1
- package/dist/index.js +174 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +174 -46
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -2130,6 +2130,124 @@ var AbstractClient = class {
|
|
|
2130
2130
|
);
|
|
2131
2131
|
}
|
|
2132
2132
|
};
|
|
2133
|
+
/**
|
|
2134
|
+
* Collections namespace for managing vector collections
|
|
2135
|
+
*/
|
|
2136
|
+
this.collections = {
|
|
2137
|
+
/**
|
|
2138
|
+
* Lists all available collections
|
|
2139
|
+
* @returns A promise that resolves to the list of collections
|
|
2140
|
+
*/
|
|
2141
|
+
list: async () => {
|
|
2142
|
+
const response = await this.makeRequest("/api/collections");
|
|
2143
|
+
return response.data.records;
|
|
2144
|
+
},
|
|
2145
|
+
/**
|
|
2146
|
+
* Retrieves a single collection by name
|
|
2147
|
+
* @param name - Collection name
|
|
2148
|
+
* @returns A promise that resolves to the collection information
|
|
2149
|
+
*/
|
|
2150
|
+
get: async (name) => {
|
|
2151
|
+
const response = await this.makeRequest(`/api/collections/${name}`);
|
|
2152
|
+
if (!response.data) {
|
|
2153
|
+
throw new ApiError("Collection not found", 404);
|
|
2154
|
+
}
|
|
2155
|
+
return response.data;
|
|
2156
|
+
},
|
|
2157
|
+
/**
|
|
2158
|
+
* Creates a new collection
|
|
2159
|
+
* @param options - Options for creating a collection
|
|
2160
|
+
* @returns A promise that resolves to the created collection
|
|
2161
|
+
*/
|
|
2162
|
+
create: async (options) => {
|
|
2163
|
+
const response = await this.makeRequest("/api/collections", {
|
|
2164
|
+
method: "POST",
|
|
2165
|
+
body: options
|
|
2166
|
+
});
|
|
2167
|
+
if (!response.data) {
|
|
2168
|
+
throw new ApiError("Failed to create collection", 500);
|
|
2169
|
+
}
|
|
2170
|
+
return response.data;
|
|
2171
|
+
},
|
|
2172
|
+
/**
|
|
2173
|
+
* Updates an existing collection by name
|
|
2174
|
+
* @param name - Collection name
|
|
2175
|
+
* @param options - Options for updating a collection
|
|
2176
|
+
* @returns A promise that resolves to the updated collection
|
|
2177
|
+
*/
|
|
2178
|
+
update: async (name, options) => {
|
|
2179
|
+
const response = await this.makeRequest(`/api/collections/${name}`, {
|
|
2180
|
+
method: "PUT",
|
|
2181
|
+
body: options
|
|
2182
|
+
});
|
|
2183
|
+
if (!response.data) {
|
|
2184
|
+
throw new ApiError("Failed to update collection", 500);
|
|
2185
|
+
}
|
|
2186
|
+
return response.data;
|
|
2187
|
+
},
|
|
2188
|
+
/**
|
|
2189
|
+
* Deletes a collection by name
|
|
2190
|
+
* @param name - Collection name
|
|
2191
|
+
* @returns A promise that resolves when the collection is deleted
|
|
2192
|
+
*/
|
|
2193
|
+
delete: async (name) => {
|
|
2194
|
+
await this.makeRequest(
|
|
2195
|
+
`/api/collections/${name}`,
|
|
2196
|
+
{
|
|
2197
|
+
method: "DELETE"
|
|
2198
|
+
}
|
|
2199
|
+
);
|
|
2200
|
+
},
|
|
2201
|
+
/**
|
|
2202
|
+
* Entries sub-namespace for a specific collection.
|
|
2203
|
+
* Returns entry CRUD + search methods scoped to the given collection.
|
|
2204
|
+
* @param collectionName - The collection name
|
|
2205
|
+
* @returns Entry operation methods
|
|
2206
|
+
*/
|
|
2207
|
+
entries: (collectionName) => ({
|
|
2208
|
+
list: async () => {
|
|
2209
|
+
const response = await this.makeRequest(`/api/collections/${collectionName}/entries`);
|
|
2210
|
+
return response.data.records;
|
|
2211
|
+
},
|
|
2212
|
+
create: async (data) => {
|
|
2213
|
+
const response = await this.makeRequest(`/api/collections/${collectionName}/entries`, {
|
|
2214
|
+
method: "POST",
|
|
2215
|
+
body: data
|
|
2216
|
+
});
|
|
2217
|
+
if (!response.data)
|
|
2218
|
+
throw new ApiError("Failed to create entry", 500);
|
|
2219
|
+
return response.data;
|
|
2220
|
+
},
|
|
2221
|
+
get: async (id) => {
|
|
2222
|
+
const response = await this.makeRequest(`/api/collections/${collectionName}/entries/${id}`);
|
|
2223
|
+
if (!response.data)
|
|
2224
|
+
throw new ApiError("Entry not found", 404);
|
|
2225
|
+
return response.data;
|
|
2226
|
+
},
|
|
2227
|
+
update: async (id, data) => {
|
|
2228
|
+
const response = await this.makeRequest(`/api/collections/${collectionName}/entries/${id}`, {
|
|
2229
|
+
method: "PUT",
|
|
2230
|
+
body: data
|
|
2231
|
+
});
|
|
2232
|
+
if (!response.data)
|
|
2233
|
+
throw new ApiError("Failed to update entry", 500);
|
|
2234
|
+
return response.data;
|
|
2235
|
+
},
|
|
2236
|
+
delete: async (id) => {
|
|
2237
|
+
await this.makeRequest(
|
|
2238
|
+
`/api/collections/${collectionName}/entries/${id}`,
|
|
2239
|
+
{ method: "DELETE" }
|
|
2240
|
+
);
|
|
2241
|
+
},
|
|
2242
|
+
search: async (query, opts) => {
|
|
2243
|
+
const response = await this.makeRequest(`/api/collections/${collectionName}/search`, {
|
|
2244
|
+
method: "POST",
|
|
2245
|
+
body: { query, ...opts }
|
|
2246
|
+
});
|
|
2247
|
+
return response.data.records;
|
|
2248
|
+
}
|
|
2249
|
+
})
|
|
2250
|
+
};
|
|
2133
2251
|
/**
|
|
2134
2252
|
* Threads namespace for managing threads for the current assistant
|
|
2135
2253
|
*/
|
|
@@ -2407,6 +2525,33 @@ var AbstractClient = class {
|
|
|
2407
2525
|
},
|
|
2408
2526
|
test: async (id) => {
|
|
2409
2527
|
return await this.makeRequest(`/api/mcp-servers/${id}/test`, { method: "POST" });
|
|
2528
|
+
},
|
|
2529
|
+
connect: async (id) => {
|
|
2530
|
+
const response = await this.makeRequest(`/api/mcp-servers/${id}/connect`, { method: "POST" });
|
|
2531
|
+
if (!response.data)
|
|
2532
|
+
throw new ApiError("Failed to connect MCP server", 500);
|
|
2533
|
+
return response.data;
|
|
2534
|
+
},
|
|
2535
|
+
disconnect: async (id) => {
|
|
2536
|
+
const response = await this.makeRequest(`/api/mcp-servers/${id}/disconnect`, { method: "POST" });
|
|
2537
|
+
if (!response.data)
|
|
2538
|
+
throw new ApiError("Failed to disconnect MCP server", 500);
|
|
2539
|
+
return response.data;
|
|
2540
|
+
}
|
|
2541
|
+
};
|
|
2542
|
+
this.connections = {
|
|
2543
|
+
list: async (type) => {
|
|
2544
|
+
const response = await this.makeRequest(`/api/connections?type=${encodeURIComponent(type)}`);
|
|
2545
|
+
return response.data.records;
|
|
2546
|
+
},
|
|
2547
|
+
create: async (data) => {
|
|
2548
|
+
return await this.makeRequest("/api/connections", { method: "POST", body: data });
|
|
2549
|
+
},
|
|
2550
|
+
update: async (type, key, data) => {
|
|
2551
|
+
return await this.makeRequest(`/api/connections/${encodeURIComponent(key)}?type=${encodeURIComponent(type)}`, { method: "PUT", body: data });
|
|
2552
|
+
},
|
|
2553
|
+
delete: async (type, key) => {
|
|
2554
|
+
await this.makeRequest(`/api/connections/${encodeURIComponent(key)}?type=${encodeURIComponent(type)}`, { method: "DELETE" });
|
|
2410
2555
|
}
|
|
2411
2556
|
};
|
|
2412
2557
|
this.tasks = {
|
|
@@ -3714,14 +3859,20 @@ function createSimpleMessageMerger() {
|
|
|
3714
3859
|
}
|
|
3715
3860
|
return newMessage;
|
|
3716
3861
|
}
|
|
3717
|
-
function
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3862
|
+
function replaceMessage(id, updates) {
|
|
3863
|
+
const index = messageMap.get(id);
|
|
3864
|
+
if (index === void 0)
|
|
3865
|
+
return null;
|
|
3866
|
+
const updated = { ...messages[index], ...updates };
|
|
3867
|
+
messages[index] = updated;
|
|
3868
|
+
return updated;
|
|
3869
|
+
}
|
|
3870
|
+
function buildToolCalls(messageId) {
|
|
3871
|
+
const builders = toolBuilders.get(messageId);
|
|
3721
3872
|
if (!builders || builders.size === 0)
|
|
3722
|
-
return;
|
|
3873
|
+
return null;
|
|
3723
3874
|
const toolCalls = [];
|
|
3724
|
-
for (const [
|
|
3875
|
+
for (const [, builder] of Array.from(builders.entries())) {
|
|
3725
3876
|
if (builder.name && builder.id) {
|
|
3726
3877
|
const args = builder.args.trim();
|
|
3727
3878
|
const parsedArgs = safeJsonParse(args);
|
|
@@ -3733,9 +3884,7 @@ function createSimpleMessageMerger() {
|
|
|
3733
3884
|
});
|
|
3734
3885
|
}
|
|
3735
3886
|
}
|
|
3736
|
-
|
|
3737
|
-
message.tool_calls = toolCalls;
|
|
3738
|
-
}
|
|
3887
|
+
return toolCalls.length > 0 ? toolCalls : null;
|
|
3739
3888
|
}
|
|
3740
3889
|
function initialMessages(msgs) {
|
|
3741
3890
|
reset();
|
|
@@ -3745,15 +3894,21 @@ function createSimpleMessageMerger() {
|
|
|
3745
3894
|
}
|
|
3746
3895
|
function push(chunk) {
|
|
3747
3896
|
const role = normalizeRole(chunk.type);
|
|
3748
|
-
|
|
3897
|
+
let message = ensureMessage(chunk.data.id, role);
|
|
3898
|
+
const isInArray = message.role !== "tool";
|
|
3749
3899
|
if (chunk.data.content) {
|
|
3750
|
-
|
|
3900
|
+
const newContent = (message.content || "") + chunk.data.content;
|
|
3901
|
+
if (isInArray) {
|
|
3902
|
+
message = replaceMessage(chunk.data.id, { content: newContent }) || message;
|
|
3903
|
+
} else {
|
|
3904
|
+
message.content = newContent;
|
|
3905
|
+
}
|
|
3751
3906
|
}
|
|
3752
3907
|
if (message.role === "ai" && chunk.data.tool_calls && chunk.data.tool_calls.length > 0) {
|
|
3753
3908
|
for (const toolCall of chunk.data.tool_calls) {
|
|
3754
3909
|
toolId_MessageIdMap.set(toolCall.id, message.id);
|
|
3755
3910
|
}
|
|
3756
|
-
message
|
|
3911
|
+
message = replaceMessage(chunk.data.id, { tool_calls: [...chunk.data.tool_calls] }) || message;
|
|
3757
3912
|
}
|
|
3758
3913
|
if (chunk.data.tool_call_chunks && message.role === "ai") {
|
|
3759
3914
|
let builders = toolBuilders.get(message.id);
|
|
@@ -3774,7 +3929,10 @@ function createSimpleMessageMerger() {
|
|
|
3774
3929
|
if (chunk_item.args)
|
|
3775
3930
|
builder.args += chunk_item.args;
|
|
3776
3931
|
}
|
|
3777
|
-
|
|
3932
|
+
const toolCalls = buildToolCalls(message.id);
|
|
3933
|
+
if (toolCalls) {
|
|
3934
|
+
message = replaceMessage(chunk.data.id, { tool_calls: toolCalls }) || message;
|
|
3935
|
+
}
|
|
3778
3936
|
}
|
|
3779
3937
|
if (message.role === "tool" && chunk.data.tool_call_id) {
|
|
3780
3938
|
const original_tool_message_id = chunk.data.id;
|
|
@@ -3783,49 +3941,19 @@ function createSimpleMessageMerger() {
|
|
|
3783
3941
|
return;
|
|
3784
3942
|
const messageIndex = messageMap.get(messageId);
|
|
3785
3943
|
if (messageIndex !== void 0) {
|
|
3786
|
-
const
|
|
3787
|
-
|
|
3944
|
+
const aiMessage = messages[messageIndex];
|
|
3945
|
+
const updatedToolCalls = aiMessage.tool_calls?.map((tc) => {
|
|
3788
3946
|
if (tc.id === chunk.data.tool_call_id) {
|
|
3789
3947
|
return { ...tc, response: chunk.data.content, status: "success", original_tool_message_id };
|
|
3790
3948
|
}
|
|
3791
3949
|
return tc;
|
|
3792
3950
|
});
|
|
3793
|
-
messages[messageIndex] =
|
|
3951
|
+
messages[messageIndex] = { ...aiMessage, tool_calls: updatedToolCalls };
|
|
3794
3952
|
}
|
|
3795
3953
|
}
|
|
3796
3954
|
}
|
|
3797
3955
|
function getMessages() {
|
|
3798
3956
|
return [...messages];
|
|
3799
|
-
const toolResponsesMap = {};
|
|
3800
|
-
messages.forEach((message) => {
|
|
3801
|
-
if (message.role === "tool" && message.tool_call_id) {
|
|
3802
|
-
toolResponsesMap[message.tool_call_id] = message;
|
|
3803
|
-
}
|
|
3804
|
-
});
|
|
3805
|
-
return messages.filter((message) => {
|
|
3806
|
-
return message.role !== "tool";
|
|
3807
|
-
}).map((message) => {
|
|
3808
|
-
if (message.role === "ai" && message.tool_calls) {
|
|
3809
|
-
const mergedMessage = { ...message };
|
|
3810
|
-
if (mergedMessage.tool_calls) {
|
|
3811
|
-
mergedMessage.tool_calls = mergedMessage.tool_calls.map(
|
|
3812
|
-
(toolCall) => {
|
|
3813
|
-
const toolResponse = toolResponsesMap[toolCall.id];
|
|
3814
|
-
if (toolResponse) {
|
|
3815
|
-
return {
|
|
3816
|
-
...toolCall,
|
|
3817
|
-
response: toolResponse.content,
|
|
3818
|
-
status: "success"
|
|
3819
|
-
};
|
|
3820
|
-
}
|
|
3821
|
-
return toolCall;
|
|
3822
|
-
}
|
|
3823
|
-
);
|
|
3824
|
-
}
|
|
3825
|
-
return mergedMessage;
|
|
3826
|
-
}
|
|
3827
|
-
return message;
|
|
3828
|
-
});
|
|
3829
3957
|
}
|
|
3830
3958
|
function getMessagesWithoutToolCalls() {
|
|
3831
3959
|
return messages.filter(
|