@axiom-lattice/client-sdk 2.1.56 → 2.1.57

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/index.d.ts CHANGED
@@ -935,6 +935,8 @@ declare abstract class AbstractClient {
935
935
  update: (id: string, data: UpdateMcpServerConfigRequest) => Promise<McpServerConfigEntry>;
936
936
  delete: (id: string) => Promise<void>;
937
937
  test: (id: string) => Promise<TestMcpServerResponse>;
938
+ connect: (id: string) => Promise<McpServerConfigEntry>;
939
+ disconnect: (id: string) => Promise<McpServerConfigEntry>;
938
940
  };
939
941
  /**
940
942
  * Tasks namespace for managing tasks
@@ -1217,6 +1219,80 @@ declare abstract class AbstractClient {
1217
1219
  */
1218
1220
  delete: (id: string) => Promise<void>;
1219
1221
  };
1222
+ /**
1223
+ * Collections namespace for managing vector collections
1224
+ */
1225
+ collections: {
1226
+ /**
1227
+ * Lists all available collections
1228
+ * @returns A promise that resolves to the list of collections
1229
+ */
1230
+ list: () => Promise<any[]>;
1231
+ /**
1232
+ * Retrieves a single collection by name
1233
+ * @param name - Collection name
1234
+ * @returns A promise that resolves to the collection information
1235
+ */
1236
+ get: (name: string) => Promise<any>;
1237
+ /**
1238
+ * Creates a new collection
1239
+ * @param options - Options for creating a collection
1240
+ * @returns A promise that resolves to the created collection
1241
+ */
1242
+ create: (options: {
1243
+ name: string;
1244
+ label: string;
1245
+ embeddingKey: string;
1246
+ schema?: {
1247
+ fields: Array<{
1248
+ key: string;
1249
+ type: string;
1250
+ enumValues?: string[];
1251
+ required?: boolean;
1252
+ }>;
1253
+ };
1254
+ }) => Promise<any>;
1255
+ /**
1256
+ * Updates an existing collection by name
1257
+ * @param name - Collection name
1258
+ * @param options - Options for updating a collection
1259
+ * @returns A promise that resolves to the updated collection
1260
+ */
1261
+ update: (name: string, options: {
1262
+ label?: string;
1263
+ embeddingKey?: string;
1264
+ schema?: any;
1265
+ }) => Promise<any>;
1266
+ /**
1267
+ * Deletes a collection by name
1268
+ * @param name - Collection name
1269
+ * @returns A promise that resolves when the collection is deleted
1270
+ */
1271
+ delete: (name: string) => Promise<void>;
1272
+ /**
1273
+ * Entries sub-namespace for a specific collection.
1274
+ * Returns entry CRUD + search methods scoped to the given collection.
1275
+ * @param collectionName - The collection name
1276
+ * @returns Entry operation methods
1277
+ */
1278
+ entries: (collectionName: string) => {
1279
+ list: () => Promise<any[]>;
1280
+ create: (data: {
1281
+ content: string;
1282
+ metadata?: Record<string, unknown>;
1283
+ }) => Promise<any>;
1284
+ get: (id: string) => Promise<any>;
1285
+ update: (id: string, data: {
1286
+ content?: string;
1287
+ metadata?: Record<string, unknown>;
1288
+ }) => Promise<any>;
1289
+ delete: (id: string) => Promise<void>;
1290
+ search: (query: string, opts?: {
1291
+ filter?: Record<string, unknown>;
1292
+ top_k?: number;
1293
+ }) => Promise<any[]>;
1294
+ };
1295
+ };
1220
1296
  /**
1221
1297
  * Threads namespace for managing threads for the current assistant
1222
1298
  */
package/dist/index.js CHANGED
@@ -2154,6 +2154,124 @@ var AbstractClient = class {
2154
2154
  );
2155
2155
  }
2156
2156
  };
2157
+ /**
2158
+ * Collections namespace for managing vector collections
2159
+ */
2160
+ this.collections = {
2161
+ /**
2162
+ * Lists all available collections
2163
+ * @returns A promise that resolves to the list of collections
2164
+ */
2165
+ list: async () => {
2166
+ const response = await this.makeRequest("/api/collections");
2167
+ return response.data.records;
2168
+ },
2169
+ /**
2170
+ * Retrieves a single collection by name
2171
+ * @param name - Collection name
2172
+ * @returns A promise that resolves to the collection information
2173
+ */
2174
+ get: async (name) => {
2175
+ const response = await this.makeRequest(`/api/collections/${name}`);
2176
+ if (!response.data) {
2177
+ throw new ApiError("Collection not found", 404);
2178
+ }
2179
+ return response.data;
2180
+ },
2181
+ /**
2182
+ * Creates a new collection
2183
+ * @param options - Options for creating a collection
2184
+ * @returns A promise that resolves to the created collection
2185
+ */
2186
+ create: async (options) => {
2187
+ const response = await this.makeRequest("/api/collections", {
2188
+ method: "POST",
2189
+ body: options
2190
+ });
2191
+ if (!response.data) {
2192
+ throw new ApiError("Failed to create collection", 500);
2193
+ }
2194
+ return response.data;
2195
+ },
2196
+ /**
2197
+ * Updates an existing collection by name
2198
+ * @param name - Collection name
2199
+ * @param options - Options for updating a collection
2200
+ * @returns A promise that resolves to the updated collection
2201
+ */
2202
+ update: async (name, options) => {
2203
+ const response = await this.makeRequest(`/api/collections/${name}`, {
2204
+ method: "PUT",
2205
+ body: options
2206
+ });
2207
+ if (!response.data) {
2208
+ throw new ApiError("Failed to update collection", 500);
2209
+ }
2210
+ return response.data;
2211
+ },
2212
+ /**
2213
+ * Deletes a collection by name
2214
+ * @param name - Collection name
2215
+ * @returns A promise that resolves when the collection is deleted
2216
+ */
2217
+ delete: async (name) => {
2218
+ await this.makeRequest(
2219
+ `/api/collections/${name}`,
2220
+ {
2221
+ method: "DELETE"
2222
+ }
2223
+ );
2224
+ },
2225
+ /**
2226
+ * Entries sub-namespace for a specific collection.
2227
+ * Returns entry CRUD + search methods scoped to the given collection.
2228
+ * @param collectionName - The collection name
2229
+ * @returns Entry operation methods
2230
+ */
2231
+ entries: (collectionName) => ({
2232
+ list: async () => {
2233
+ const response = await this.makeRequest(`/api/collections/${collectionName}/entries`);
2234
+ return response.data.records;
2235
+ },
2236
+ create: async (data) => {
2237
+ const response = await this.makeRequest(`/api/collections/${collectionName}/entries`, {
2238
+ method: "POST",
2239
+ body: data
2240
+ });
2241
+ if (!response.data)
2242
+ throw new ApiError("Failed to create entry", 500);
2243
+ return response.data;
2244
+ },
2245
+ get: async (id) => {
2246
+ const response = await this.makeRequest(`/api/collections/${collectionName}/entries/${id}`);
2247
+ if (!response.data)
2248
+ throw new ApiError("Entry not found", 404);
2249
+ return response.data;
2250
+ },
2251
+ update: async (id, data) => {
2252
+ const response = await this.makeRequest(`/api/collections/${collectionName}/entries/${id}`, {
2253
+ method: "PUT",
2254
+ body: data
2255
+ });
2256
+ if (!response.data)
2257
+ throw new ApiError("Failed to update entry", 500);
2258
+ return response.data;
2259
+ },
2260
+ delete: async (id) => {
2261
+ await this.makeRequest(
2262
+ `/api/collections/${collectionName}/entries/${id}`,
2263
+ { method: "DELETE" }
2264
+ );
2265
+ },
2266
+ search: async (query, opts) => {
2267
+ const response = await this.makeRequest(`/api/collections/${collectionName}/search`, {
2268
+ method: "POST",
2269
+ body: { query, ...opts }
2270
+ });
2271
+ return response.data.records;
2272
+ }
2273
+ })
2274
+ };
2157
2275
  /**
2158
2276
  * Threads namespace for managing threads for the current assistant
2159
2277
  */
@@ -2431,6 +2549,18 @@ var AbstractClient = class {
2431
2549
  },
2432
2550
  test: async (id) => {
2433
2551
  return await this.makeRequest(`/api/mcp-servers/${id}/test`, { method: "POST" });
2552
+ },
2553
+ connect: async (id) => {
2554
+ const response = await this.makeRequest(`/api/mcp-servers/${id}/connect`, { method: "POST" });
2555
+ if (!response.data)
2556
+ throw new ApiError("Failed to connect MCP server", 500);
2557
+ return response.data;
2558
+ },
2559
+ disconnect: async (id) => {
2560
+ const response = await this.makeRequest(`/api/mcp-servers/${id}/disconnect`, { method: "POST" });
2561
+ if (!response.data)
2562
+ throw new ApiError("Failed to disconnect MCP server", 500);
2563
+ return response.data;
2434
2564
  }
2435
2565
  };
2436
2566
  this.tasks = {
@@ -3738,14 +3868,20 @@ function createSimpleMessageMerger() {
3738
3868
  }
3739
3869
  return newMessage;
3740
3870
  }
3741
- function updateToolCalls(message) {
3742
- if (message.role !== "ai")
3743
- return;
3744
- const builders = toolBuilders.get(message.id);
3871
+ function replaceMessage(id, updates) {
3872
+ const index = messageMap.get(id);
3873
+ if (index === void 0)
3874
+ return null;
3875
+ const updated = { ...messages[index], ...updates };
3876
+ messages[index] = updated;
3877
+ return updated;
3878
+ }
3879
+ function buildToolCalls(messageId) {
3880
+ const builders = toolBuilders.get(messageId);
3745
3881
  if (!builders || builders.size === 0)
3746
- return;
3882
+ return null;
3747
3883
  const toolCalls = [];
3748
- for (const [index, builder] of Array.from(builders.entries())) {
3884
+ for (const [, builder] of Array.from(builders.entries())) {
3749
3885
  if (builder.name && builder.id) {
3750
3886
  const args = builder.args.trim();
3751
3887
  const parsedArgs = safeJsonParse(args);
@@ -3757,9 +3893,7 @@ function createSimpleMessageMerger() {
3757
3893
  });
3758
3894
  }
3759
3895
  }
3760
- if (toolCalls.length > 0) {
3761
- message.tool_calls = toolCalls;
3762
- }
3896
+ return toolCalls.length > 0 ? toolCalls : null;
3763
3897
  }
3764
3898
  function initialMessages(msgs) {
3765
3899
  reset();
@@ -3769,15 +3903,21 @@ function createSimpleMessageMerger() {
3769
3903
  }
3770
3904
  function push(chunk) {
3771
3905
  const role = normalizeRole(chunk.type);
3772
- const message = ensureMessage(chunk.data.id, role);
3906
+ let message = ensureMessage(chunk.data.id, role);
3907
+ const isInArray = message.role !== "tool";
3773
3908
  if (chunk.data.content) {
3774
- message.content = (message.content || "") + chunk.data.content;
3909
+ const newContent = (message.content || "") + chunk.data.content;
3910
+ if (isInArray) {
3911
+ message = replaceMessage(chunk.data.id, { content: newContent }) || message;
3912
+ } else {
3913
+ message.content = newContent;
3914
+ }
3775
3915
  }
3776
3916
  if (message.role === "ai" && chunk.data.tool_calls && chunk.data.tool_calls.length > 0) {
3777
3917
  for (const toolCall of chunk.data.tool_calls) {
3778
3918
  toolId_MessageIdMap.set(toolCall.id, message.id);
3779
3919
  }
3780
- message.tool_calls = chunk.data.tool_calls;
3920
+ message = replaceMessage(chunk.data.id, { tool_calls: [...chunk.data.tool_calls] }) || message;
3781
3921
  }
3782
3922
  if (chunk.data.tool_call_chunks && message.role === "ai") {
3783
3923
  let builders = toolBuilders.get(message.id);
@@ -3798,7 +3938,10 @@ function createSimpleMessageMerger() {
3798
3938
  if (chunk_item.args)
3799
3939
  builder.args += chunk_item.args;
3800
3940
  }
3801
- updateToolCalls(message);
3941
+ const toolCalls = buildToolCalls(message.id);
3942
+ if (toolCalls) {
3943
+ message = replaceMessage(chunk.data.id, { tool_calls: toolCalls }) || message;
3944
+ }
3802
3945
  }
3803
3946
  if (message.role === "tool" && chunk.data.tool_call_id) {
3804
3947
  const original_tool_message_id = chunk.data.id;
@@ -3807,49 +3950,19 @@ function createSimpleMessageMerger() {
3807
3950
  return;
3808
3951
  const messageIndex = messageMap.get(messageId);
3809
3952
  if (messageIndex !== void 0) {
3810
- const message2 = messages[messageIndex];
3811
- message2.tool_calls = message2.tool_calls?.map((tc) => {
3953
+ const aiMessage = messages[messageIndex];
3954
+ const updatedToolCalls = aiMessage.tool_calls?.map((tc) => {
3812
3955
  if (tc.id === chunk.data.tool_call_id) {
3813
3956
  return { ...tc, response: chunk.data.content, status: "success", original_tool_message_id };
3814
3957
  }
3815
3958
  return tc;
3816
3959
  });
3817
- messages[messageIndex] = message2;
3960
+ messages[messageIndex] = { ...aiMessage, tool_calls: updatedToolCalls };
3818
3961
  }
3819
3962
  }
3820
3963
  }
3821
3964
  function getMessages() {
3822
3965
  return [...messages];
3823
- const toolResponsesMap = {};
3824
- messages.forEach((message) => {
3825
- if (message.role === "tool" && message.tool_call_id) {
3826
- toolResponsesMap[message.tool_call_id] = message;
3827
- }
3828
- });
3829
- return messages.filter((message) => {
3830
- return message.role !== "tool";
3831
- }).map((message) => {
3832
- if (message.role === "ai" && message.tool_calls) {
3833
- const mergedMessage = { ...message };
3834
- if (mergedMessage.tool_calls) {
3835
- mergedMessage.tool_calls = mergedMessage.tool_calls.map(
3836
- (toolCall) => {
3837
- const toolResponse = toolResponsesMap[toolCall.id];
3838
- if (toolResponse) {
3839
- return {
3840
- ...toolCall,
3841
- response: toolResponse.content,
3842
- status: "success"
3843
- };
3844
- }
3845
- return toolCall;
3846
- }
3847
- );
3848
- }
3849
- return mergedMessage;
3850
- }
3851
- return message;
3852
- });
3853
3966
  }
3854
3967
  function getMessagesWithoutToolCalls() {
3855
3968
  return messages.filter(