@axiom-lattice/client-sdk 2.1.4 → 2.1.6
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 +32 -1
- package/dist/ChunkMessageMerger.js.map +1 -1
- package/dist/abstract-client.d.ts +80 -1
- package/dist/abstract-client.d.ts.map +1 -1
- package/dist/abstract-client.js +206 -19
- package/dist/abstract-client.js.map +1 -1
- package/dist/index.d.ts +248 -2
- package/dist/index.js +257 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +257 -20
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +168 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1936,6 +1936,209 @@ var AbstractClient = class {
|
|
|
1936
1936
|
this.registeredTools.delete(name);
|
|
1937
1937
|
}
|
|
1938
1938
|
};
|
|
1939
|
+
/**
|
|
1940
|
+
* Assistants namespace for managing assistants
|
|
1941
|
+
*/
|
|
1942
|
+
this.assistants = {
|
|
1943
|
+
/**
|
|
1944
|
+
* Lists all available assistants
|
|
1945
|
+
* Returns both code-configured and stored assistants
|
|
1946
|
+
* @returns A promise that resolves to the list of assistants
|
|
1947
|
+
*/
|
|
1948
|
+
list: async () => {
|
|
1949
|
+
try {
|
|
1950
|
+
const response = await this.makeRequest(
|
|
1951
|
+
"/api/assistants"
|
|
1952
|
+
);
|
|
1953
|
+
return response.data.records;
|
|
1954
|
+
} catch (error) {
|
|
1955
|
+
throw error;
|
|
1956
|
+
}
|
|
1957
|
+
},
|
|
1958
|
+
/**
|
|
1959
|
+
* Retrieves a single assistant by ID
|
|
1960
|
+
* Checks both code-configured and stored assistants
|
|
1961
|
+
* @param id - Assistant identifier
|
|
1962
|
+
* @returns A promise that resolves to the assistant information
|
|
1963
|
+
*/
|
|
1964
|
+
get: async (id) => {
|
|
1965
|
+
try {
|
|
1966
|
+
const response = await this.makeRequest(
|
|
1967
|
+
`/api/assistants/${id}`
|
|
1968
|
+
);
|
|
1969
|
+
if (!response.data) {
|
|
1970
|
+
throw new ApiError("Assistant not found", 404);
|
|
1971
|
+
}
|
|
1972
|
+
return response.data;
|
|
1973
|
+
} catch (error) {
|
|
1974
|
+
throw error;
|
|
1975
|
+
}
|
|
1976
|
+
},
|
|
1977
|
+
/**
|
|
1978
|
+
* Creates a new assistant
|
|
1979
|
+
* Only creates stored assistants (code-configured assistants cannot be created via API)
|
|
1980
|
+
* @param options - Options for creating an assistant
|
|
1981
|
+
* @returns A promise that resolves to the created assistant
|
|
1982
|
+
*/
|
|
1983
|
+
create: async (options) => {
|
|
1984
|
+
try {
|
|
1985
|
+
const response = await this.makeRequest(
|
|
1986
|
+
"/api/assistants",
|
|
1987
|
+
{
|
|
1988
|
+
method: "POST",
|
|
1989
|
+
body: options
|
|
1990
|
+
}
|
|
1991
|
+
);
|
|
1992
|
+
if (!response.data) {
|
|
1993
|
+
throw new ApiError("Failed to create assistant", 500);
|
|
1994
|
+
}
|
|
1995
|
+
return response.data;
|
|
1996
|
+
} catch (error) {
|
|
1997
|
+
throw error;
|
|
1998
|
+
}
|
|
1999
|
+
},
|
|
2000
|
+
/**
|
|
2001
|
+
* Updates an existing assistant by ID
|
|
2002
|
+
* Only works on stored assistants (code-configured assistants cannot be updated)
|
|
2003
|
+
* @param id - Assistant identifier
|
|
2004
|
+
* @param options - Options for updating an assistant
|
|
2005
|
+
* @returns A promise that resolves to the updated assistant
|
|
2006
|
+
*/
|
|
2007
|
+
update: async (id, options) => {
|
|
2008
|
+
try {
|
|
2009
|
+
const response = await this.makeRequest(
|
|
2010
|
+
`/api/assistants/${id}`,
|
|
2011
|
+
{
|
|
2012
|
+
method: "PUT",
|
|
2013
|
+
body: options
|
|
2014
|
+
}
|
|
2015
|
+
);
|
|
2016
|
+
if (!response.data) {
|
|
2017
|
+
throw new ApiError("Failed to update assistant", 500);
|
|
2018
|
+
}
|
|
2019
|
+
return response.data;
|
|
2020
|
+
} catch (error) {
|
|
2021
|
+
throw error;
|
|
2022
|
+
}
|
|
2023
|
+
},
|
|
2024
|
+
/**
|
|
2025
|
+
* Deletes an assistant by ID
|
|
2026
|
+
* Only works on stored assistants (code-configured assistants cannot be deleted)
|
|
2027
|
+
* @param id - Assistant identifier
|
|
2028
|
+
* @returns A promise that resolves when the assistant is deleted
|
|
2029
|
+
*/
|
|
2030
|
+
delete: async (id) => {
|
|
2031
|
+
try {
|
|
2032
|
+
await this.makeRequest(
|
|
2033
|
+
`/api/assistants/${id}`,
|
|
2034
|
+
{
|
|
2035
|
+
method: "DELETE"
|
|
2036
|
+
}
|
|
2037
|
+
);
|
|
2038
|
+
} catch (error) {
|
|
2039
|
+
throw error;
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
};
|
|
2043
|
+
/**
|
|
2044
|
+
* Threads namespace for managing threads for the current assistant
|
|
2045
|
+
*/
|
|
2046
|
+
this.threads = {
|
|
2047
|
+
/**
|
|
2048
|
+
* Lists all threads for the current assistant
|
|
2049
|
+
* @returns A promise that resolves to the list of threads
|
|
2050
|
+
*/
|
|
2051
|
+
list: async () => {
|
|
2052
|
+
try {
|
|
2053
|
+
const response = await this.makeRequest(
|
|
2054
|
+
`/api/assistants/${this.assistantId}/threads`
|
|
2055
|
+
);
|
|
2056
|
+
return response.data.records;
|
|
2057
|
+
} catch (error) {
|
|
2058
|
+
throw error;
|
|
2059
|
+
}
|
|
2060
|
+
},
|
|
2061
|
+
/**
|
|
2062
|
+
* Retrieves a single thread by ID for the current assistant
|
|
2063
|
+
* @param threadId - Thread identifier
|
|
2064
|
+
* @returns A promise that resolves to the thread information
|
|
2065
|
+
*/
|
|
2066
|
+
get: async (threadId) => {
|
|
2067
|
+
try {
|
|
2068
|
+
const response = await this.makeRequest(
|
|
2069
|
+
`/api/assistants/${this.assistantId}/threads/${threadId}`
|
|
2070
|
+
);
|
|
2071
|
+
if (!response.data) {
|
|
2072
|
+
throw new ApiError("Thread not found", 404);
|
|
2073
|
+
}
|
|
2074
|
+
return response.data;
|
|
2075
|
+
} catch (error) {
|
|
2076
|
+
throw error;
|
|
2077
|
+
}
|
|
2078
|
+
},
|
|
2079
|
+
/**
|
|
2080
|
+
* Creates a new thread for the current assistant
|
|
2081
|
+
* @param options - Options for creating a thread
|
|
2082
|
+
* @returns A promise that resolves to the created thread
|
|
2083
|
+
*/
|
|
2084
|
+
create: async (options) => {
|
|
2085
|
+
try {
|
|
2086
|
+
const response = await this.makeRequest(
|
|
2087
|
+
`/api/assistants/${this.assistantId}/threads`,
|
|
2088
|
+
{
|
|
2089
|
+
method: "POST",
|
|
2090
|
+
body: options
|
|
2091
|
+
}
|
|
2092
|
+
);
|
|
2093
|
+
if (!response.data) {
|
|
2094
|
+
throw new ApiError("Failed to create thread", 500);
|
|
2095
|
+
}
|
|
2096
|
+
return response.data;
|
|
2097
|
+
} catch (error) {
|
|
2098
|
+
throw error;
|
|
2099
|
+
}
|
|
2100
|
+
},
|
|
2101
|
+
/**
|
|
2102
|
+
* Updates an existing thread by ID for the current assistant
|
|
2103
|
+
* @param threadId - Thread identifier
|
|
2104
|
+
* @param options - Options for updating a thread
|
|
2105
|
+
* @returns A promise that resolves to the updated thread
|
|
2106
|
+
*/
|
|
2107
|
+
update: async (threadId, options) => {
|
|
2108
|
+
try {
|
|
2109
|
+
const response = await this.makeRequest(
|
|
2110
|
+
`/api/assistants/${this.assistantId}/threads/${threadId}`,
|
|
2111
|
+
{
|
|
2112
|
+
method: "PUT",
|
|
2113
|
+
body: options
|
|
2114
|
+
}
|
|
2115
|
+
);
|
|
2116
|
+
if (!response.data) {
|
|
2117
|
+
throw new ApiError("Failed to update thread", 500);
|
|
2118
|
+
}
|
|
2119
|
+
return response.data;
|
|
2120
|
+
} catch (error) {
|
|
2121
|
+
throw error;
|
|
2122
|
+
}
|
|
2123
|
+
},
|
|
2124
|
+
/**
|
|
2125
|
+
* Deletes a thread by ID for the current assistant
|
|
2126
|
+
* @param threadId - Thread identifier
|
|
2127
|
+
* @returns A promise that resolves when the thread is deleted
|
|
2128
|
+
*/
|
|
2129
|
+
delete: async (threadId) => {
|
|
2130
|
+
try {
|
|
2131
|
+
await this.makeRequest(
|
|
2132
|
+
`/api/assistants/${this.assistantId}/threads/${threadId}`,
|
|
2133
|
+
{
|
|
2134
|
+
method: "DELETE"
|
|
2135
|
+
}
|
|
2136
|
+
);
|
|
2137
|
+
} catch (error) {
|
|
2138
|
+
throw error;
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
};
|
|
1939
2142
|
this.config = {
|
|
1940
2143
|
timeout: 3e5,
|
|
1941
2144
|
// Default timeout
|
|
@@ -1998,65 +2201,74 @@ var AbstractClient = class {
|
|
|
1998
2201
|
}
|
|
1999
2202
|
/**
|
|
2000
2203
|
* Creates a new thread
|
|
2204
|
+
* @deprecated Use threads.create() instead
|
|
2001
2205
|
* @param options - Options for creating a thread
|
|
2002
2206
|
* @returns A promise that resolves to the thread ID
|
|
2003
2207
|
*/
|
|
2004
2208
|
async createThread(options) {
|
|
2005
2209
|
try {
|
|
2006
|
-
const
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2210
|
+
const response = await this.makeRequest(
|
|
2211
|
+
`/api/assistants/${this.assistantId}/threads`,
|
|
2212
|
+
{
|
|
2213
|
+
method: "POST",
|
|
2214
|
+
body: options
|
|
2011
2215
|
}
|
|
2012
|
-
|
|
2013
|
-
|
|
2216
|
+
);
|
|
2217
|
+
if (!response.data) {
|
|
2218
|
+
throw new ApiError("Failed to create thread", 500);
|
|
2219
|
+
}
|
|
2220
|
+
return response.data.id;
|
|
2014
2221
|
} catch (error) {
|
|
2015
2222
|
throw error;
|
|
2016
2223
|
}
|
|
2017
2224
|
}
|
|
2018
2225
|
/**
|
|
2019
2226
|
* Retrieves thread information
|
|
2227
|
+
* @deprecated Use threads.get() instead
|
|
2020
2228
|
* @param threadId - Thread identifier
|
|
2021
2229
|
* @returns A promise that resolves to the thread information
|
|
2022
2230
|
*/
|
|
2023
2231
|
async getThread(threadId) {
|
|
2024
2232
|
try {
|
|
2025
|
-
const
|
|
2026
|
-
|
|
2233
|
+
const response = await this.makeRequest(
|
|
2234
|
+
`/api/assistants/${this.assistantId}/threads/${threadId}`
|
|
2235
|
+
);
|
|
2236
|
+
if (!response.data) {
|
|
2237
|
+
throw new ApiError("Thread not found", 404);
|
|
2238
|
+
}
|
|
2239
|
+
return response.data;
|
|
2027
2240
|
} catch (error) {
|
|
2028
2241
|
throw error;
|
|
2029
2242
|
}
|
|
2030
2243
|
}
|
|
2031
2244
|
/**
|
|
2032
2245
|
* Lists all threads
|
|
2246
|
+
* @deprecated Use threads.list() instead
|
|
2033
2247
|
* @param options - Options for listing threads
|
|
2034
2248
|
* @returns A promise that resolves to an array of threads
|
|
2035
2249
|
*/
|
|
2036
2250
|
async listThreads(options) {
|
|
2037
2251
|
try {
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
if (options?.offset !== void 0) {
|
|
2043
|
-
url += `&offset=${options.offset}`;
|
|
2044
|
-
}
|
|
2045
|
-
const data = await this.makeRequest(url);
|
|
2046
|
-
return data.threads;
|
|
2252
|
+
const response = await this.makeRequest(
|
|
2253
|
+
`/api/assistants/${this.assistantId}/threads`
|
|
2254
|
+
);
|
|
2255
|
+
return response.data.records;
|
|
2047
2256
|
} catch (error) {
|
|
2048
2257
|
throw error;
|
|
2049
2258
|
}
|
|
2050
2259
|
}
|
|
2051
2260
|
/**
|
|
2052
2261
|
* Deletes a thread
|
|
2262
|
+
* @deprecated Use threads.delete() instead
|
|
2053
2263
|
* @param threadId - Thread identifier
|
|
2054
2264
|
* @returns A promise that resolves when the thread is deleted
|
|
2055
2265
|
*/
|
|
2056
2266
|
async deleteThread(threadId) {
|
|
2057
2267
|
try {
|
|
2058
|
-
|
|
2059
|
-
|
|
2268
|
+
await this.makeRequest(
|
|
2269
|
+
`/api/assistants/${this.assistantId}/threads/${threadId}`,
|
|
2270
|
+
{ method: "DELETE" }
|
|
2271
|
+
);
|
|
2060
2272
|
} catch (error) {
|
|
2061
2273
|
throw error;
|
|
2062
2274
|
}
|
|
@@ -2821,6 +3033,31 @@ function createSimpleMessageMerger() {
|
|
|
2821
3033
|
}
|
|
2822
3034
|
function initialMessages(msgs) {
|
|
2823
3035
|
messages = msgs;
|
|
3036
|
+
messageMap.clear();
|
|
3037
|
+
messages.forEach((msg, index) => {
|
|
3038
|
+
if (msg.id) {
|
|
3039
|
+
messageMap.set(msg.id, index);
|
|
3040
|
+
}
|
|
3041
|
+
});
|
|
3042
|
+
toolBuilders.clear();
|
|
3043
|
+
messages.forEach((msg) => {
|
|
3044
|
+
if (msg.role === "ai" && msg.tool_calls && Array.isArray(msg.tool_calls)) {
|
|
3045
|
+
const builders = /* @__PURE__ */ new Map();
|
|
3046
|
+
msg.tool_calls.forEach((toolCall, index) => {
|
|
3047
|
+
if (toolCall.id && toolCall.name) {
|
|
3048
|
+
const argsStr = typeof toolCall.args === "object" ? JSON.stringify(toolCall.args) : String(toolCall.args || "");
|
|
3049
|
+
builders.set(index, {
|
|
3050
|
+
id: toolCall.id,
|
|
3051
|
+
name: toolCall.name,
|
|
3052
|
+
args: argsStr
|
|
3053
|
+
});
|
|
3054
|
+
}
|
|
3055
|
+
});
|
|
3056
|
+
if (builders.size > 0) {
|
|
3057
|
+
toolBuilders.set(msg.id, builders);
|
|
3058
|
+
}
|
|
3059
|
+
}
|
|
3060
|
+
});
|
|
2824
3061
|
}
|
|
2825
3062
|
function push(chunk) {
|
|
2826
3063
|
const role = normalizeRole(chunk.type);
|