@axiom-lattice/client-sdk 8.2.0 → 8.4.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/dist/__tests__/abstract-client.namespaces.test.js +38 -0
- package/dist/__tests__/abstract-client.namespaces.test.js.map +1 -1
- package/dist/__tests__/platform.test.js +64 -0
- package/dist/__tests__/platform.test.js.map +1 -1
- package/dist/abstract-client.d.ts +19 -0
- package/dist/abstract-client.d.ts.map +1 -1
- package/dist/abstract-client.js +31 -0
- package/dist/abstract-client.js.map +1 -1
- package/dist/index.d.mts +3939 -0
- package/dist/index.d.ts +23 -4
- package/dist/index.js +276 -458
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +265 -444
- package/dist/index.mjs.map +1 -1
- package/dist/oidc-providers.d.ts +2 -2
- package/dist/oidc-providers.d.ts.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +12 -11
- package/dist/platform.js.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -89,10 +89,8 @@ var require_encoding = __commonJS({
|
|
|
89
89
|
}
|
|
90
90
|
var floor = Math.floor;
|
|
91
91
|
function ToDictionary(o) {
|
|
92
|
-
if (o === void 0)
|
|
93
|
-
|
|
94
|
-
if (o === Object(o))
|
|
95
|
-
return o;
|
|
92
|
+
if (o === void 0) return {};
|
|
93
|
+
if (o === Object(o)) return o;
|
|
96
94
|
throw TypeError("Could not convert argument to dictionary");
|
|
97
95
|
}
|
|
98
96
|
function stringToCodePoints(string) {
|
|
@@ -717,8 +715,7 @@ var require_encoding = __commonJS({
|
|
|
717
715
|
var encoders = {};
|
|
718
716
|
var decoders = {};
|
|
719
717
|
function indexCodePointFor(pointer, index2) {
|
|
720
|
-
if (!index2)
|
|
721
|
-
return null;
|
|
718
|
+
if (!index2) return null;
|
|
722
719
|
return index2[pointer] || null;
|
|
723
720
|
}
|
|
724
721
|
function indexPointerFor(code_point, index2) {
|
|
@@ -734,8 +731,7 @@ var require_encoding = __commonJS({
|
|
|
734
731
|
function indexGB18030RangesCodePointFor(pointer) {
|
|
735
732
|
if (pointer > 39419 && pointer < 189e3 || pointer > 1237575)
|
|
736
733
|
return null;
|
|
737
|
-
if (pointer === 7457)
|
|
738
|
-
return 59335;
|
|
734
|
+
if (pointer === 7457) return 59335;
|
|
739
735
|
var offset = 0;
|
|
740
736
|
var code_point_offset = 0;
|
|
741
737
|
var idx = index("gb18030-ranges");
|
|
@@ -752,8 +748,7 @@ var require_encoding = __commonJS({
|
|
|
752
748
|
return code_point_offset + pointer - offset;
|
|
753
749
|
}
|
|
754
750
|
function indexGB18030RangesPointerFor(code_point) {
|
|
755
|
-
if (code_point === 59335)
|
|
756
|
-
return 7457;
|
|
751
|
+
if (code_point === 59335) return 7457;
|
|
757
752
|
var offset = 0;
|
|
758
753
|
var pointer_offset = 0;
|
|
759
754
|
var idx = index("gb18030-ranges");
|
|
@@ -1887,8 +1882,7 @@ async function* parseSseBody(body, options = {}) {
|
|
|
1887
1882
|
} catch {
|
|
1888
1883
|
throw new SseParseError("Invalid SSE JSON");
|
|
1889
1884
|
}
|
|
1890
|
-
if (options.strictJsonObject && (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)))
|
|
1891
|
-
throw new SseParseError("SSE data must be an object");
|
|
1885
|
+
if (options.strictJsonObject && (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))) throw new SseParseError("SSE data must be an object");
|
|
1892
1886
|
const result = { event, data: parsed, ...id === void 0 ? {} : { id }, ...retry === void 0 ? {} : { retry } };
|
|
1893
1887
|
event = "";
|
|
1894
1888
|
id = void 0;
|
|
@@ -1898,25 +1892,18 @@ async function* parseSseBody(body, options = {}) {
|
|
|
1898
1892
|
};
|
|
1899
1893
|
const processLine = (raw) => {
|
|
1900
1894
|
const line = raw.endsWith("\r") ? raw.slice(0, -1) : raw;
|
|
1901
|
-
if (line === "")
|
|
1902
|
-
|
|
1903
|
-
if (line.startsWith(":"))
|
|
1904
|
-
return void 0;
|
|
1895
|
+
if (line === "") return dispatch();
|
|
1896
|
+
if (line.startsWith(":")) return void 0;
|
|
1905
1897
|
const separator = line.indexOf(":");
|
|
1906
1898
|
const field = separator < 0 ? line : line.slice(0, separator);
|
|
1907
1899
|
let value = separator < 0 ? "" : line.slice(separator + 1);
|
|
1908
|
-
if (value.startsWith(" "))
|
|
1909
|
-
|
|
1910
|
-
if (field === "
|
|
1911
|
-
|
|
1912
|
-
else if (field === "data")
|
|
1913
|
-
data.push(value);
|
|
1914
|
-
else if (field === "id")
|
|
1915
|
-
id = value;
|
|
1900
|
+
if (value.startsWith(" ")) value = value.slice(1);
|
|
1901
|
+
if (field === "event") event = value;
|
|
1902
|
+
else if (field === "data") data.push(value);
|
|
1903
|
+
else if (field === "id") id = value;
|
|
1916
1904
|
else if (field === "retry") {
|
|
1917
1905
|
const parsed = Number(value);
|
|
1918
|
-
if (!Number.isInteger(parsed) || parsed < 0 || !Number.isFinite(parsed))
|
|
1919
|
-
throw new SseParseError("Invalid SSE retry");
|
|
1906
|
+
if (!Number.isInteger(parsed) || parsed < 0 || !Number.isFinite(parsed)) throw new SseParseError("Invalid SSE retry");
|
|
1920
1907
|
retry = parsed;
|
|
1921
1908
|
}
|
|
1922
1909
|
return void 0;
|
|
@@ -1931,23 +1918,19 @@ async function* parseSseBody(body, options = {}) {
|
|
|
1931
1918
|
buffer += decoder.decode(chunk.value, { stream: true });
|
|
1932
1919
|
let index = findLineBreak(buffer);
|
|
1933
1920
|
while (index >= 0) {
|
|
1934
|
-
if (buffer[index] === "\r" && index === buffer.length - 1)
|
|
1935
|
-
break;
|
|
1921
|
+
if (buffer[index] === "\r" && index === buffer.length - 1) break;
|
|
1936
1922
|
const frame2 = processLine(buffer.slice(0, index));
|
|
1937
1923
|
buffer = buffer.slice(index + lineBreakLength(buffer, index));
|
|
1938
|
-
if (frame2)
|
|
1939
|
-
yield frame2;
|
|
1924
|
+
if (frame2) yield frame2;
|
|
1940
1925
|
index = findLineBreak(buffer);
|
|
1941
1926
|
}
|
|
1942
1927
|
}
|
|
1943
1928
|
if (buffer) {
|
|
1944
1929
|
const frame2 = processLine(buffer);
|
|
1945
|
-
if (frame2)
|
|
1946
|
-
yield frame2;
|
|
1930
|
+
if (frame2) yield frame2;
|
|
1947
1931
|
}
|
|
1948
1932
|
const frame = processLine("");
|
|
1949
|
-
if (frame)
|
|
1950
|
-
yield frame;
|
|
1933
|
+
if (frame) yield frame;
|
|
1951
1934
|
} finally {
|
|
1952
1935
|
await reader.cancel().catch(() => void 0);
|
|
1953
1936
|
reader.releaseLock();
|
|
@@ -1956,10 +1939,8 @@ async function* parseSseBody(body, options = {}) {
|
|
|
1956
1939
|
function findLineBreak(value) {
|
|
1957
1940
|
const lf = value.indexOf("\n");
|
|
1958
1941
|
const cr = value.indexOf("\r");
|
|
1959
|
-
if (lf < 0)
|
|
1960
|
-
|
|
1961
|
-
if (cr < 0)
|
|
1962
|
-
return lf;
|
|
1942
|
+
if (lf < 0) return cr;
|
|
1943
|
+
if (cr < 0) return lf;
|
|
1963
1944
|
return Math.min(lf, cr);
|
|
1964
1945
|
}
|
|
1965
1946
|
function lineBreakLength(value, index) {
|
|
@@ -2268,20 +2249,13 @@ var AbstractClient = class {
|
|
|
2268
2249
|
*/
|
|
2269
2250
|
auditLogs: async (params) => {
|
|
2270
2251
|
const searchParams = new URLSearchParams();
|
|
2271
|
-
if (params?.credentialId)
|
|
2272
|
-
|
|
2273
|
-
if (params?.
|
|
2274
|
-
|
|
2275
|
-
if (params?.
|
|
2276
|
-
|
|
2277
|
-
if (params?.
|
|
2278
|
-
searchParams.set("from", params.from);
|
|
2279
|
-
if (params?.to)
|
|
2280
|
-
searchParams.set("to", params.to);
|
|
2281
|
-
if (params?.limit !== void 0)
|
|
2282
|
-
searchParams.set("limit", String(params.limit));
|
|
2283
|
-
if (params?.offset !== void 0)
|
|
2284
|
-
searchParams.set("offset", String(params.offset));
|
|
2252
|
+
if (params?.credentialId) searchParams.set("credentialId", params.credentialId);
|
|
2253
|
+
if (params?.domain) searchParams.set("domain", params.domain);
|
|
2254
|
+
if (params?.status) searchParams.set("status", params.status);
|
|
2255
|
+
if (params?.from) searchParams.set("from", params.from);
|
|
2256
|
+
if (params?.to) searchParams.set("to", params.to);
|
|
2257
|
+
if (params?.limit !== void 0) searchParams.set("limit", String(params.limit));
|
|
2258
|
+
if (params?.offset !== void 0) searchParams.set("offset", String(params.offset));
|
|
2285
2259
|
const qs = searchParams.toString();
|
|
2286
2260
|
const response = await this.makeRequest(`/api/open/audit${qs ? `?${qs}` : ""}`);
|
|
2287
2261
|
return response.data.records;
|
|
@@ -2329,12 +2303,9 @@ var AbstractClient = class {
|
|
|
2329
2303
|
*/
|
|
2330
2304
|
list: async (params) => {
|
|
2331
2305
|
const searchParams = new URLSearchParams();
|
|
2332
|
-
if (params?.tenantId)
|
|
2333
|
-
|
|
2334
|
-
if (params?.
|
|
2335
|
-
searchParams.set("limit", String(params.limit));
|
|
2336
|
-
if (params?.offset !== void 0)
|
|
2337
|
-
searchParams.set("offset", String(params.offset));
|
|
2306
|
+
if (params?.tenantId) searchParams.set("tenantId", params.tenantId);
|
|
2307
|
+
if (params?.limit !== void 0) searchParams.set("limit", String(params.limit));
|
|
2308
|
+
if (params?.offset !== void 0) searchParams.set("offset", String(params.offset));
|
|
2338
2309
|
const qs = searchParams.toString();
|
|
2339
2310
|
const response = await this.makeRequest(`/api/a2a/keys${qs ? `?${qs}` : ""}`);
|
|
2340
2311
|
return response.data;
|
|
@@ -2752,14 +2723,26 @@ var AbstractClient = class {
|
|
|
2752
2723
|
method: "POST",
|
|
2753
2724
|
body: data
|
|
2754
2725
|
});
|
|
2755
|
-
if (!response.data)
|
|
2756
|
-
throw new ApiError("Failed to create entry", 500);
|
|
2726
|
+
if (!response.data) throw new ApiError("Failed to create entry", 500);
|
|
2757
2727
|
return response.data;
|
|
2758
2728
|
},
|
|
2729
|
+
/**
|
|
2730
|
+
* Creates 1-50 entries in one all-or-nothing vector-store write.
|
|
2731
|
+
*
|
|
2732
|
+
* @param data - Batch payload with one or more entries.
|
|
2733
|
+
* @returns The created entries with generated ids.
|
|
2734
|
+
*/
|
|
2735
|
+
createMany: async (data) => {
|
|
2736
|
+
const response = await this.makeRequest(`/api/collections/${collectionName}/entries/batch`, {
|
|
2737
|
+
method: "POST",
|
|
2738
|
+
body: data
|
|
2739
|
+
});
|
|
2740
|
+
if (!response.data?.records) throw new ApiError("Failed to create entries", 500);
|
|
2741
|
+
return response.data.records;
|
|
2742
|
+
},
|
|
2759
2743
|
get: async (id) => {
|
|
2760
2744
|
const response = await this.makeRequest(`/api/collections/${collectionName}/entries/${id}`);
|
|
2761
|
-
if (!response.data)
|
|
2762
|
-
throw new ApiError("Entry not found", 404);
|
|
2745
|
+
if (!response.data) throw new ApiError("Entry not found", 404);
|
|
2763
2746
|
return response.data;
|
|
2764
2747
|
},
|
|
2765
2748
|
update: async (id, data) => {
|
|
@@ -2767,8 +2750,7 @@ var AbstractClient = class {
|
|
|
2767
2750
|
method: "PUT",
|
|
2768
2751
|
body: data
|
|
2769
2752
|
});
|
|
2770
|
-
if (!response.data)
|
|
2771
|
-
throw new ApiError("Failed to update entry", 500);
|
|
2753
|
+
if (!response.data) throw new ApiError("Failed to update entry", 500);
|
|
2772
2754
|
return response.data;
|
|
2773
2755
|
},
|
|
2774
2756
|
delete: async (id) => {
|
|
@@ -2777,6 +2759,22 @@ var AbstractClient = class {
|
|
|
2777
2759
|
{ method: "DELETE" }
|
|
2778
2760
|
);
|
|
2779
2761
|
},
|
|
2762
|
+
/**
|
|
2763
|
+
* Deletes 1-50 entries in one all-or-nothing vector-store call.
|
|
2764
|
+
*
|
|
2765
|
+
* @param entryIds - Entry IDs to delete.
|
|
2766
|
+
* @returns The number of requested entry IDs processed by the delete call.
|
|
2767
|
+
*/
|
|
2768
|
+
deleteMany: async (entryIds) => {
|
|
2769
|
+
const response = await this.makeRequest(`/api/collections/${collectionName}/entries/batch`, {
|
|
2770
|
+
method: "DELETE",
|
|
2771
|
+
body: { entryIds }
|
|
2772
|
+
});
|
|
2773
|
+
if (typeof response.data?.processed !== "number") {
|
|
2774
|
+
throw new ApiError("Failed to delete entries", 500);
|
|
2775
|
+
}
|
|
2776
|
+
return response.data.processed;
|
|
2777
|
+
},
|
|
2780
2778
|
search: async (query, opts) => {
|
|
2781
2779
|
const response = await this.makeRequest(`/api/collections/${collectionName}/search`, {
|
|
2782
2780
|
method: "POST",
|
|
@@ -3080,14 +3078,10 @@ var AbstractClient = class {
|
|
|
3080
3078
|
*/
|
|
3081
3079
|
create: async (threadId, input, options, assistantId) => {
|
|
3082
3080
|
const body = {};
|
|
3083
|
-
if (input !== void 0)
|
|
3084
|
-
|
|
3085
|
-
if (options?.
|
|
3086
|
-
|
|
3087
|
-
if (options?.config !== void 0)
|
|
3088
|
-
body.config = options.config;
|
|
3089
|
-
if (options?.mode !== void 0)
|
|
3090
|
-
body.mode = options.mode;
|
|
3081
|
+
if (input !== void 0) body.input = input;
|
|
3082
|
+
if (options?.command !== void 0) body.command = options.command;
|
|
3083
|
+
if (options?.config !== void 0) body.config = options.config;
|
|
3084
|
+
if (options?.mode !== void 0) body.mode = options.mode;
|
|
3091
3085
|
if (options?.multitaskStrategy !== void 0) {
|
|
3092
3086
|
body.multitask_strategy = options.multitaskStrategy;
|
|
3093
3087
|
}
|
|
@@ -3158,10 +3152,8 @@ var AbstractClient = class {
|
|
|
3158
3152
|
*/
|
|
3159
3153
|
cancel: async (threadId, runId, options, assistantId) => {
|
|
3160
3154
|
const params = new URLSearchParams();
|
|
3161
|
-
if (options?.action !== void 0)
|
|
3162
|
-
|
|
3163
|
-
if (options?.wait !== void 0)
|
|
3164
|
-
params.set("wait", String(options.wait));
|
|
3155
|
+
if (options?.action !== void 0) params.set("action", options.action);
|
|
3156
|
+
if (options?.wait !== void 0) params.set("wait", String(options.wait));
|
|
3165
3157
|
const query = params.toString();
|
|
3166
3158
|
const response = await this.makeRequest(
|
|
3167
3159
|
`/api/assistants/${assistantId ?? this.assistantId}/threads/${threadId}/runs/${runId}/cancel${query ? `?${query}` : ""}`,
|
|
@@ -3269,20 +3261,17 @@ var AbstractClient = class {
|
|
|
3269
3261
|
},
|
|
3270
3262
|
get: async (id) => {
|
|
3271
3263
|
const response = await this.makeRequest(`/api/tools/${id}`);
|
|
3272
|
-
if (!response.data)
|
|
3273
|
-
throw new ApiError("Tool not found", 404);
|
|
3264
|
+
if (!response.data) throw new ApiError("Tool not found", 404);
|
|
3274
3265
|
return response.data;
|
|
3275
3266
|
},
|
|
3276
3267
|
create: async (data) => {
|
|
3277
3268
|
const response = await this.makeRequest("/api/tools", { method: "POST", body: data });
|
|
3278
|
-
if (!response.data)
|
|
3279
|
-
throw new ApiError("Failed to create tool", 500);
|
|
3269
|
+
if (!response.data) throw new ApiError("Failed to create tool", 500);
|
|
3280
3270
|
return response.data;
|
|
3281
3271
|
},
|
|
3282
3272
|
update: async (id, data) => {
|
|
3283
3273
|
const response = await this.makeRequest(`/api/tools/${id}`, { method: "PUT", body: data });
|
|
3284
|
-
if (!response.data)
|
|
3285
|
-
throw new ApiError("Failed to update tool", 500);
|
|
3274
|
+
if (!response.data) throw new ApiError("Failed to update tool", 500);
|
|
3286
3275
|
return response.data;
|
|
3287
3276
|
},
|
|
3288
3277
|
delete: async (id) => {
|
|
@@ -3296,20 +3285,17 @@ var AbstractClient = class {
|
|
|
3296
3285
|
},
|
|
3297
3286
|
get: async (id) => {
|
|
3298
3287
|
const response = await this.makeRequest(`/api/database-configs/${id}`);
|
|
3299
|
-
if (!response.data)
|
|
3300
|
-
throw new ApiError("Database config not found", 404);
|
|
3288
|
+
if (!response.data) throw new ApiError("Database config not found", 404);
|
|
3301
3289
|
return response.data;
|
|
3302
3290
|
},
|
|
3303
3291
|
create: async (data) => {
|
|
3304
3292
|
const response = await this.makeRequest("/api/database-configs", { method: "POST", body: data });
|
|
3305
|
-
if (!response.data)
|
|
3306
|
-
throw new ApiError("Failed to create database config", 500);
|
|
3293
|
+
if (!response.data) throw new ApiError("Failed to create database config", 500);
|
|
3307
3294
|
return response.data;
|
|
3308
3295
|
},
|
|
3309
3296
|
update: async (id, data) => {
|
|
3310
3297
|
const response = await this.makeRequest(`/api/database-configs/${id}`, { method: "PUT", body: data });
|
|
3311
|
-
if (!response.data)
|
|
3312
|
-
throw new ApiError("Failed to update database config", 500);
|
|
3298
|
+
if (!response.data) throw new ApiError("Failed to update database config", 500);
|
|
3313
3299
|
return response.data;
|
|
3314
3300
|
},
|
|
3315
3301
|
delete: async (id) => {
|
|
@@ -3326,20 +3312,17 @@ var AbstractClient = class {
|
|
|
3326
3312
|
},
|
|
3327
3313
|
get: async (id) => {
|
|
3328
3314
|
const response = await this.makeRequest(`/api/model-providers/${encodeURIComponent(id)}`);
|
|
3329
|
-
if (!response.data)
|
|
3330
|
-
throw new ApiError("Model provider not found", 404);
|
|
3315
|
+
if (!response.data) throw new ApiError("Model provider not found", 404);
|
|
3331
3316
|
return response.data;
|
|
3332
3317
|
},
|
|
3333
3318
|
create: async (data) => {
|
|
3334
3319
|
const response = await this.makeRequest("/api/model-providers", { method: "POST", body: data });
|
|
3335
|
-
if (!response.data)
|
|
3336
|
-
throw new ApiError("Failed to create model provider", 500);
|
|
3320
|
+
if (!response.data) throw new ApiError("Failed to create model provider", 500);
|
|
3337
3321
|
return response.data;
|
|
3338
3322
|
},
|
|
3339
3323
|
update: async (id, data) => {
|
|
3340
3324
|
const response = await this.makeRequest(`/api/model-providers/${encodeURIComponent(id)}`, { method: "PUT", body: data });
|
|
3341
|
-
if (!response.data)
|
|
3342
|
-
throw new ApiError("Failed to update model provider", 500);
|
|
3325
|
+
if (!response.data) throw new ApiError("Failed to update model provider", 500);
|
|
3343
3326
|
return response.data;
|
|
3344
3327
|
},
|
|
3345
3328
|
delete: async (id) => {
|
|
@@ -3349,8 +3332,7 @@ var AbstractClient = class {
|
|
|
3349
3332
|
// provider form to validate before saving.
|
|
3350
3333
|
probe: async (data) => {
|
|
3351
3334
|
const response = await this.makeRequest("/api/model-providers/probe", { method: "POST", body: data });
|
|
3352
|
-
if (!response.data)
|
|
3353
|
-
throw new ApiError("Failed to probe model provider", 500);
|
|
3335
|
+
if (!response.data) throw new ApiError("Failed to probe model provider", 500);
|
|
3354
3336
|
return response.data;
|
|
3355
3337
|
},
|
|
3356
3338
|
// Replace this provider's model set with exactly these models, picked
|
|
@@ -3358,22 +3340,19 @@ var AbstractClient = class {
|
|
|
3358
3340
|
// model arrives as `enabled: false` rather than being dropped.
|
|
3359
3341
|
setModels: async (id, models) => {
|
|
3360
3342
|
const response = await this.makeRequest(`/api/model-providers/${encodeURIComponent(id)}/models`, { method: "PUT", body: { models } });
|
|
3361
|
-
if (!response.data)
|
|
3362
|
-
throw new ApiError("Failed to update models", 500);
|
|
3343
|
+
if (!response.data) throw new ApiError("Failed to update models", 500);
|
|
3363
3344
|
return response.data;
|
|
3364
3345
|
},
|
|
3365
3346
|
discover: async (id) => {
|
|
3366
3347
|
const response = await this.makeRequest(`/api/model-providers/${encodeURIComponent(id)}/discover`, { method: "POST", body: {} });
|
|
3367
|
-
if (!response.data)
|
|
3368
|
-
throw new ApiError("Failed to discover models", 500);
|
|
3348
|
+
if (!response.data) throw new ApiError("Failed to discover models", 500);
|
|
3369
3349
|
return response.data;
|
|
3370
3350
|
},
|
|
3371
3351
|
// The model id travels in the body because upstream ids routinely
|
|
3372
3352
|
// contain "/" (e.g. Qwen/Qwen2.5-7B-Instruct).
|
|
3373
3353
|
setModelEnabled: async (id, modelId, enabled) => {
|
|
3374
3354
|
const response = await this.makeRequest(`/api/model-providers/${encodeURIComponent(id)}/models/enabled`, { method: "POST", body: { modelId, enabled } });
|
|
3375
|
-
if (!response.data)
|
|
3376
|
-
throw new ApiError("Failed to update model", 500);
|
|
3355
|
+
if (!response.data) throw new ApiError("Failed to update model", 500);
|
|
3377
3356
|
return response.data;
|
|
3378
3357
|
}
|
|
3379
3358
|
};
|
|
@@ -3390,20 +3369,17 @@ var AbstractClient = class {
|
|
|
3390
3369
|
},
|
|
3391
3370
|
get: async (id) => {
|
|
3392
3371
|
const response = await this.makeRequest(`/api/metrics-configs/${id}`);
|
|
3393
|
-
if (!response.data)
|
|
3394
|
-
throw new ApiError("Metrics config not found", 404);
|
|
3372
|
+
if (!response.data) throw new ApiError("Metrics config not found", 404);
|
|
3395
3373
|
return response.data;
|
|
3396
3374
|
},
|
|
3397
3375
|
create: async (data) => {
|
|
3398
3376
|
const response = await this.makeRequest("/api/metrics-configs", { method: "POST", body: data });
|
|
3399
|
-
if (!response.data)
|
|
3400
|
-
throw new ApiError("Failed to create metrics config", 500);
|
|
3377
|
+
if (!response.data) throw new ApiError("Failed to create metrics config", 500);
|
|
3401
3378
|
return response.data;
|
|
3402
3379
|
},
|
|
3403
3380
|
update: async (id, data) => {
|
|
3404
3381
|
const response = await this.makeRequest(`/api/metrics-configs/${id}`, { method: "PUT", body: data });
|
|
3405
|
-
if (!response.data)
|
|
3406
|
-
throw new ApiError("Failed to update metrics config", 500);
|
|
3382
|
+
if (!response.data) throw new ApiError("Failed to update metrics config", 500);
|
|
3407
3383
|
return response.data;
|
|
3408
3384
|
},
|
|
3409
3385
|
delete: async (id) => {
|
|
@@ -3424,20 +3400,17 @@ var AbstractClient = class {
|
|
|
3424
3400
|
},
|
|
3425
3401
|
get: async (id) => {
|
|
3426
3402
|
const response = await this.makeRequest(`/api/mcp-servers/${id}`);
|
|
3427
|
-
if (!response.data)
|
|
3428
|
-
throw new ApiError("MCP server config not found", 404);
|
|
3403
|
+
if (!response.data) throw new ApiError("MCP server config not found", 404);
|
|
3429
3404
|
return response.data;
|
|
3430
3405
|
},
|
|
3431
3406
|
create: async (data) => {
|
|
3432
3407
|
const response = await this.makeRequest("/api/mcp-servers", { method: "POST", body: data });
|
|
3433
|
-
if (!response.data)
|
|
3434
|
-
throw new ApiError("Failed to create MCP server config", 500);
|
|
3408
|
+
if (!response.data) throw new ApiError("Failed to create MCP server config", 500);
|
|
3435
3409
|
return response.data;
|
|
3436
3410
|
},
|
|
3437
3411
|
update: async (id, data) => {
|
|
3438
3412
|
const response = await this.makeRequest(`/api/mcp-servers/${id}`, { method: "PUT", body: data });
|
|
3439
|
-
if (!response.data)
|
|
3440
|
-
throw new ApiError("Failed to update MCP server config", 500);
|
|
3413
|
+
if (!response.data) throw new ApiError("Failed to update MCP server config", 500);
|
|
3441
3414
|
return response.data;
|
|
3442
3415
|
},
|
|
3443
3416
|
delete: async (id) => {
|
|
@@ -3448,14 +3421,12 @@ var AbstractClient = class {
|
|
|
3448
3421
|
},
|
|
3449
3422
|
connect: async (id) => {
|
|
3450
3423
|
const response = await this.makeRequest(`/api/mcp-servers/${id}/connect`, { method: "POST" });
|
|
3451
|
-
if (!response.data)
|
|
3452
|
-
throw new ApiError("Failed to connect MCP server", 500);
|
|
3424
|
+
if (!response.data) throw new ApiError("Failed to connect MCP server", 500);
|
|
3453
3425
|
return response.data;
|
|
3454
3426
|
},
|
|
3455
3427
|
disconnect: async (id) => {
|
|
3456
3428
|
const response = await this.makeRequest(`/api/mcp-servers/${id}/disconnect`, { method: "POST" });
|
|
3457
|
-
if (!response.data)
|
|
3458
|
-
throw new ApiError("Failed to disconnect MCP server", 500);
|
|
3429
|
+
if (!response.data) throw new ApiError("Failed to disconnect MCP server", 500);
|
|
3459
3430
|
return response.data;
|
|
3460
3431
|
}
|
|
3461
3432
|
};
|
|
@@ -3466,20 +3437,17 @@ var AbstractClient = class {
|
|
|
3466
3437
|
},
|
|
3467
3438
|
get: async (keyOrId) => {
|
|
3468
3439
|
const response = await this.makeRequest(`/api/personal-mcp-servers/${keyOrId}`);
|
|
3469
|
-
if (!response.data)
|
|
3470
|
-
throw new ApiError("Personal MCP server config not found", 404);
|
|
3440
|
+
if (!response.data) throw new ApiError("Personal MCP server config not found", 404);
|
|
3471
3441
|
return response.data;
|
|
3472
3442
|
},
|
|
3473
3443
|
create: async (data) => {
|
|
3474
3444
|
const response = await this.makeRequest("/api/personal-mcp-servers", { method: "POST", body: data });
|
|
3475
|
-
if (!response.data)
|
|
3476
|
-
throw new ApiError("Failed to create personal MCP server config", 500);
|
|
3445
|
+
if (!response.data) throw new ApiError("Failed to create personal MCP server config", 500);
|
|
3477
3446
|
return response.data;
|
|
3478
3447
|
},
|
|
3479
3448
|
update: async (keyOrId, data) => {
|
|
3480
3449
|
const response = await this.makeRequest(`/api/personal-mcp-servers/${keyOrId}`, { method: "PUT", body: data });
|
|
3481
|
-
if (!response.data)
|
|
3482
|
-
throw new ApiError("Failed to update personal MCP server config", 500);
|
|
3450
|
+
if (!response.data) throw new ApiError("Failed to update personal MCP server config", 500);
|
|
3483
3451
|
return response.data;
|
|
3484
3452
|
},
|
|
3485
3453
|
delete: async (keyOrId) => {
|
|
@@ -3490,14 +3458,12 @@ var AbstractClient = class {
|
|
|
3490
3458
|
},
|
|
3491
3459
|
connect: async (keyOrId) => {
|
|
3492
3460
|
const response = await this.makeRequest(`/api/personal-mcp-servers/${keyOrId}/connect`, { method: "POST" });
|
|
3493
|
-
if (!response.data)
|
|
3494
|
-
throw new ApiError("Failed to connect personal MCP server", 500);
|
|
3461
|
+
if (!response.data) throw new ApiError("Failed to connect personal MCP server", 500);
|
|
3495
3462
|
return response.data;
|
|
3496
3463
|
},
|
|
3497
3464
|
disconnect: async (keyOrId) => {
|
|
3498
3465
|
const response = await this.makeRequest(`/api/personal-mcp-servers/${keyOrId}/disconnect`, { method: "POST" });
|
|
3499
|
-
if (!response.data)
|
|
3500
|
-
throw new ApiError("Failed to disconnect personal MCP server", 500);
|
|
3466
|
+
if (!response.data) throw new ApiError("Failed to disconnect personal MCP server", 500);
|
|
3501
3467
|
return response.data;
|
|
3502
3468
|
}
|
|
3503
3469
|
};
|
|
@@ -3524,20 +3490,17 @@ var AbstractClient = class {
|
|
|
3524
3490
|
},
|
|
3525
3491
|
get: async (id) => {
|
|
3526
3492
|
const response = await this.makeRequest(`/api/tasks/${id}`);
|
|
3527
|
-
if (!response.data)
|
|
3528
|
-
throw new ApiError("Task not found", 404);
|
|
3493
|
+
if (!response.data) throw new ApiError("Task not found", 404);
|
|
3529
3494
|
return response.data;
|
|
3530
3495
|
},
|
|
3531
3496
|
create: async (data) => {
|
|
3532
3497
|
const response = await this.makeRequest("/api/tasks", { method: "POST", body: data });
|
|
3533
|
-
if (!response.data)
|
|
3534
|
-
throw new ApiError("Failed to create task", 500);
|
|
3498
|
+
if (!response.data) throw new ApiError("Failed to create task", 500);
|
|
3535
3499
|
return response.data;
|
|
3536
3500
|
},
|
|
3537
3501
|
update: async (id, data) => {
|
|
3538
3502
|
const response = await this.makeRequest(`/api/tasks/${id}`, { method: "PUT", body: data });
|
|
3539
|
-
if (!response.data)
|
|
3540
|
-
throw new ApiError("Failed to update task", 500);
|
|
3503
|
+
if (!response.data) throw new ApiError("Failed to update task", 500);
|
|
3541
3504
|
return response.data;
|
|
3542
3505
|
},
|
|
3543
3506
|
delete: async (id) => {
|
|
@@ -3545,25 +3508,20 @@ var AbstractClient = class {
|
|
|
3545
3508
|
},
|
|
3546
3509
|
complete: async (id, data) => {
|
|
3547
3510
|
const response = await this.makeRequest(`/api/tasks/${id}/complete`, { method: "PATCH", body: data });
|
|
3548
|
-
if (!response.data)
|
|
3549
|
-
throw new ApiError("Failed to complete task", 500);
|
|
3511
|
+
if (!response.data) throw new ApiError("Failed to complete task", 500);
|
|
3550
3512
|
return response;
|
|
3551
3513
|
},
|
|
3552
3514
|
command: async (id, input) => {
|
|
3553
3515
|
const response = await this.makeRequest(`/api/tasks/${id}/commands`, { method: "POST", body: input });
|
|
3554
|
-
if (!response.data)
|
|
3555
|
-
throw new ApiError("Failed to run task command", 500);
|
|
3516
|
+
if (!response.data) throw new ApiError("Failed to run task command", 500);
|
|
3556
3517
|
return response;
|
|
3557
3518
|
},
|
|
3558
3519
|
workItems: {
|
|
3559
3520
|
list: async (taskId, params) => {
|
|
3560
3521
|
const searchParams = new URLSearchParams();
|
|
3561
|
-
if (params?.action)
|
|
3562
|
-
|
|
3563
|
-
if (params?.
|
|
3564
|
-
searchParams.set("limit", String(params.limit));
|
|
3565
|
-
if (params?.offset)
|
|
3566
|
-
searchParams.set("offset", String(params.offset));
|
|
3522
|
+
if (params?.action) searchParams.set("action", params.action);
|
|
3523
|
+
if (params?.limit) searchParams.set("limit", String(params.limit));
|
|
3524
|
+
if (params?.offset) searchParams.set("offset", String(params.offset));
|
|
3567
3525
|
const qs = searchParams.toString();
|
|
3568
3526
|
const response = await this.makeRequest(
|
|
3569
3527
|
`/api/tasks/${taskId}/work-items${qs ? `?${qs}` : ""}`
|
|
@@ -3580,20 +3538,17 @@ var AbstractClient = class {
|
|
|
3580
3538
|
},
|
|
3581
3539
|
get: async (id) => {
|
|
3582
3540
|
const response = await this.makeRequest(`/api/menu-items/${id}`);
|
|
3583
|
-
if (!response.data)
|
|
3584
|
-
throw new Error("Menu item not found");
|
|
3541
|
+
if (!response.data) throw new Error("Menu item not found");
|
|
3585
3542
|
return response.data;
|
|
3586
3543
|
},
|
|
3587
3544
|
create: async (data) => {
|
|
3588
3545
|
const response = await this.makeRequest("/api/menu-items", { method: "POST", body: data });
|
|
3589
|
-
if (!response.data)
|
|
3590
|
-
throw new Error("Failed to create menu item");
|
|
3546
|
+
if (!response.data) throw new Error("Failed to create menu item");
|
|
3591
3547
|
return response.data;
|
|
3592
3548
|
},
|
|
3593
3549
|
update: async (id, data) => {
|
|
3594
3550
|
const response = await this.makeRequest(`/api/menu-items/${id}`, { method: "PUT", body: data });
|
|
3595
|
-
if (!response.data)
|
|
3596
|
-
throw new Error("Failed to update menu item");
|
|
3551
|
+
if (!response.data) throw new Error("Failed to update menu item");
|
|
3597
3552
|
return response.data;
|
|
3598
3553
|
},
|
|
3599
3554
|
delete: async (id) => {
|
|
@@ -3723,8 +3678,7 @@ var AbstractClient = class {
|
|
|
3723
3678
|
{ status: response.status, responseBody: errorData }
|
|
3724
3679
|
);
|
|
3725
3680
|
}
|
|
3726
|
-
if (!response.body)
|
|
3727
|
-
throw new Error("Response body is null");
|
|
3681
|
+
if (!response.body) throw new Error("Response body is null");
|
|
3728
3682
|
for await (const frame of parseSseBody(response.body, { strictJsonObject: true })) {
|
|
3729
3683
|
if (frame.event === "error") {
|
|
3730
3684
|
const data = frame.data;
|
|
@@ -3749,10 +3703,8 @@ var AbstractClient = class {
|
|
|
3749
3703
|
}
|
|
3750
3704
|
}
|
|
3751
3705
|
} catch (error) {
|
|
3752
|
-
if (controller.signal.aborted)
|
|
3753
|
-
|
|
3754
|
-
if (error instanceof DOMException && error.name === "AbortError")
|
|
3755
|
-
return;
|
|
3706
|
+
if (controller.signal.aborted) return;
|
|
3707
|
+
if (error instanceof DOMException && error.name === "AbortError") return;
|
|
3756
3708
|
if (error instanceof SseParseError) {
|
|
3757
3709
|
onError?.(Object.assign(new Error(error.message), { code: "INVALID_EVENT" }));
|
|
3758
3710
|
return;
|
|
@@ -3855,10 +3807,8 @@ var AbstractClient = class {
|
|
|
3855
3807
|
*/
|
|
3856
3808
|
async getThreadHistory(threadId, options = {}) {
|
|
3857
3809
|
const params = new URLSearchParams();
|
|
3858
|
-
if (options.limit !== void 0)
|
|
3859
|
-
|
|
3860
|
-
if (options.before !== void 0)
|
|
3861
|
-
params.append("before", options.before);
|
|
3810
|
+
if (options.limit !== void 0) params.append("limit", String(options.limit));
|
|
3811
|
+
if (options.before !== void 0) params.append("before", options.before);
|
|
3862
3812
|
const query = params.toString();
|
|
3863
3813
|
const response = await this.makeRequest(
|
|
3864
3814
|
`/api/assistants/${this.assistantId}/threads/${threadId}/history${query ? `?${query}` : ""}`
|
|
@@ -4033,8 +3983,7 @@ var ResourcesClient = class {
|
|
|
4033
3983
|
headers: { "Content-Type": "application/json", ...this.getHeaders() },
|
|
4034
3984
|
body: JSON.stringify(request)
|
|
4035
3985
|
});
|
|
4036
|
-
if (!res.ok)
|
|
4037
|
-
throw new Error(`Share failed: ${res.status}`);
|
|
3986
|
+
if (!res.ok) throw new Error(`Share failed: ${res.status}`);
|
|
4038
3987
|
return await res.json();
|
|
4039
3988
|
}
|
|
4040
3989
|
async unshare(token) {
|
|
@@ -4042,8 +3991,7 @@ var ResourcesClient = class {
|
|
|
4042
3991
|
method: "DELETE",
|
|
4043
3992
|
headers: this.getHeaders()
|
|
4044
3993
|
});
|
|
4045
|
-
if (!res.ok)
|
|
4046
|
-
throw new Error(`Unshare failed: ${res.status}`);
|
|
3994
|
+
if (!res.ok) throw new Error(`Unshare failed: ${res.status}`);
|
|
4047
3995
|
}
|
|
4048
3996
|
async updateShare(token, patch) {
|
|
4049
3997
|
const res = await fetch(`${this.baseURL}/api/resources/share/${token}`, {
|
|
@@ -4051,15 +3999,13 @@ var ResourcesClient = class {
|
|
|
4051
3999
|
headers: { "Content-Type": "application/json", ...this.getHeaders() },
|
|
4052
4000
|
body: JSON.stringify(patch)
|
|
4053
4001
|
});
|
|
4054
|
-
if (!res.ok)
|
|
4055
|
-
throw new Error(`Update failed: ${res.status}`);
|
|
4002
|
+
if (!res.ok) throw new Error(`Update failed: ${res.status}`);
|
|
4056
4003
|
}
|
|
4057
4004
|
async listShares() {
|
|
4058
4005
|
const res = await fetch(`${this.baseURL}/api/resources/shares`, {
|
|
4059
4006
|
headers: this.getHeaders()
|
|
4060
4007
|
});
|
|
4061
|
-
if (!res.ok)
|
|
4062
|
-
throw new Error(`List failed: ${res.status}`);
|
|
4008
|
+
if (!res.ok) throw new Error(`List failed: ${res.status}`);
|
|
4063
4009
|
return await res.json();
|
|
4064
4010
|
}
|
|
4065
4011
|
};
|
|
@@ -4097,8 +4043,7 @@ async function archiveToBlob(archive) {
|
|
|
4097
4043
|
};
|
|
4098
4044
|
}
|
|
4099
4045
|
function attachmentFilename(contentDisposition) {
|
|
4100
|
-
if (!contentDisposition)
|
|
4101
|
-
return "tenant-export.tar.gz";
|
|
4046
|
+
if (!contentDisposition) return "tenant-export.tar.gz";
|
|
4102
4047
|
const encoded = contentDisposition.match(/filename\*=UTF-8''([^;]+)/i)?.[1];
|
|
4103
4048
|
if (encoded) {
|
|
4104
4049
|
try {
|
|
@@ -4133,8 +4078,7 @@ var ExportImportClient = class {
|
|
|
4133
4078
|
};
|
|
4134
4079
|
if (options.body instanceof FormData) {
|
|
4135
4080
|
for (const name of Object.keys(headers)) {
|
|
4136
|
-
if (name.toLowerCase() === "content-type")
|
|
4137
|
-
delete headers[name];
|
|
4081
|
+
if (name.toLowerCase() === "content-type") delete headers[name];
|
|
4138
4082
|
}
|
|
4139
4083
|
}
|
|
4140
4084
|
const response = await fetch(`${this.baseURL}${url}`, {
|
|
@@ -4268,18 +4212,15 @@ var ProjectRoomClientError = class extends Error {
|
|
|
4268
4212
|
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4269
4213
|
var date = (value, field) => {
|
|
4270
4214
|
const result = value instanceof Date ? new Date(value.getTime()) : new Date(typeof value === "string" || typeof value === "number" ? value : Number.NaN);
|
|
4271
|
-
if (!Number.isFinite(result.getTime()))
|
|
4272
|
-
throw new ProjectRoomClientError(`Invalid ${field}`, 500, "INVALID_RESPONSE", false);
|
|
4215
|
+
if (!Number.isFinite(result.getTime())) throw new ProjectRoomClientError(`Invalid ${field}`, 500, "INVALID_RESPONSE", false);
|
|
4273
4216
|
return result;
|
|
4274
4217
|
};
|
|
4275
4218
|
var requiredString = (record3, field) => {
|
|
4276
|
-
if (typeof record3[field] !== "string")
|
|
4277
|
-
throw new ProjectRoomClientError(`Invalid ${field}`, 500, "INVALID_RESPONSE", false);
|
|
4219
|
+
if (typeof record3[field] !== "string") throw new ProjectRoomClientError(`Invalid ${field}`, 500, "INVALID_RESPONSE", false);
|
|
4278
4220
|
return record3[field];
|
|
4279
4221
|
};
|
|
4280
4222
|
var oneOf = (value, values, field) => {
|
|
4281
|
-
if (typeof value !== "string" || !values.includes(value))
|
|
4282
|
-
throw new ProjectRoomClientError(`Invalid ${field}`, 500, "INVALID_RESPONSE", false);
|
|
4223
|
+
if (typeof value !== "string" || !values.includes(value)) throw new ProjectRoomClientError(`Invalid ${field}`, 500, "INVALID_RESPONSE", false);
|
|
4283
4224
|
return value;
|
|
4284
4225
|
};
|
|
4285
4226
|
var messageSources = ["user", "agent", "task", "routine", "system"];
|
|
@@ -4288,8 +4229,7 @@ var memberStatuses = ["active", "removed"];
|
|
|
4288
4229
|
var botRoles = ["coordinator", "specialist"];
|
|
4289
4230
|
var botStatuses = ["active", "paused", "removed"];
|
|
4290
4231
|
var exactKeys = (row, required, optional = []) => {
|
|
4291
|
-
if (required.some((key) => !Object.prototype.hasOwnProperty.call(row, key)) || Object.keys(row).some((key) => !required.includes(key) && !optional.includes(key)))
|
|
4292
|
-
throw new ProjectRoomClientError("Invalid Project Room response", 500, "INVALID_RESPONSE", false);
|
|
4232
|
+
if (required.some((key) => !Object.prototype.hasOwnProperty.call(row, key)) || Object.keys(row).some((key) => !required.includes(key) && !optional.includes(key))) throw new ProjectRoomClientError("Invalid Project Room response", 500, "INVALID_RESPONSE", false);
|
|
4293
4233
|
};
|
|
4294
4234
|
var hydrateAuthor = (value) => {
|
|
4295
4235
|
const row = record(value);
|
|
@@ -4298,29 +4238,24 @@ var hydrateAuthor = (value) => {
|
|
|
4298
4238
|
exactKeys(row, ["type", "userId"]);
|
|
4299
4239
|
return { type, userId: requiredString(row, "userId") };
|
|
4300
4240
|
}
|
|
4301
|
-
if (type === "bot")
|
|
4302
|
-
|
|
4303
|
-
if (Object.keys(row).some((key) => key !== "type"))
|
|
4304
|
-
throw new ProjectRoomClientError("Invalid author", 500, "INVALID_RESPONSE", false);
|
|
4241
|
+
if (type === "bot") return { type, membershipId: requiredString(row, "membershipId") };
|
|
4242
|
+
if (Object.keys(row).some((key) => key !== "type")) throw new ProjectRoomClientError("Invalid author", 500, "INVALID_RESPONSE", false);
|
|
4305
4243
|
return { type };
|
|
4306
4244
|
};
|
|
4307
4245
|
var hydrateMentions = (value) => {
|
|
4308
|
-
if (!Array.isArray(value))
|
|
4309
|
-
throw new ProjectRoomClientError("Invalid mentions", 500, "INVALID_RESPONSE", false);
|
|
4246
|
+
if (!Array.isArray(value)) throw new ProjectRoomClientError("Invalid mentions", 500, "INVALID_RESPONSE", false);
|
|
4310
4247
|
return value.map((entry) => {
|
|
4311
4248
|
const row = record(entry);
|
|
4312
4249
|
const type = oneOf(row.type, ["bot", "team"], "mention.type");
|
|
4313
4250
|
if (type === "team") {
|
|
4314
|
-
if (Object.keys(row).length !== 1)
|
|
4315
|
-
throw new ProjectRoomClientError("Invalid mention", 500, "INVALID_RESPONSE", false);
|
|
4251
|
+
if (Object.keys(row).length !== 1) throw new ProjectRoomClientError("Invalid mention", 500, "INVALID_RESPONSE", false);
|
|
4316
4252
|
return { type };
|
|
4317
4253
|
}
|
|
4318
4254
|
return { type, membershipId: requiredString(row, "membershipId") };
|
|
4319
4255
|
});
|
|
4320
4256
|
};
|
|
4321
4257
|
var record = (value) => {
|
|
4322
|
-
if (!isRecord(value))
|
|
4323
|
-
throw new ProjectRoomClientError("Invalid Project Room response", 500, "INVALID_RESPONSE", false);
|
|
4258
|
+
if (!isRecord(value)) throw new ProjectRoomClientError("Invalid Project Room response", 500, "INVALID_RESPONSE", false);
|
|
4324
4259
|
return value;
|
|
4325
4260
|
};
|
|
4326
4261
|
var hydrateRoom = (value) => {
|
|
@@ -4332,8 +4267,7 @@ var hydrateMessage = (value) => {
|
|
|
4332
4267
|
const row = record(value);
|
|
4333
4268
|
exactKeys(row, ["id", "roomId", "author", "content", "mentions", "source", "createdAt"], ["replyToMessageId", "sourceId"]);
|
|
4334
4269
|
const content = record(row.content);
|
|
4335
|
-
if (oneOf(content.type, ["text"], "content.type") !== "text")
|
|
4336
|
-
throw new ProjectRoomClientError("Invalid content", 500, "INVALID_RESPONSE", false);
|
|
4270
|
+
if (oneOf(content.type, ["text"], "content.type") !== "text") throw new ProjectRoomClientError("Invalid content", 500, "INVALID_RESPONSE", false);
|
|
4337
4271
|
return { id: requiredString(row, "id"), roomId: requiredString(row, "roomId"), author: hydrateAuthor(row.author), content: { type: "text", text: requiredString(content, "text") }, mentions: hydrateMentions(row.mentions), ...row.replyToMessageId === void 0 ? {} : { replyToMessageId: requiredString(row, "replyToMessageId") }, ...row.sourceId === void 0 ? {} : { sourceId: requiredString(row, "sourceId") }, source: oneOf(row.source, messageSources, "source"), createdAt: date(row.createdAt, "createdAt") };
|
|
4338
4272
|
};
|
|
4339
4273
|
var hydrateMember = (value) => {
|
|
@@ -4348,8 +4282,7 @@ var hydrateBot = (value) => {
|
|
|
4348
4282
|
};
|
|
4349
4283
|
var hydrateDispatch = (value) => {
|
|
4350
4284
|
const row = record(value);
|
|
4351
|
-
if (typeof row.success !== "boolean" || row.membershipId !== void 0 && typeof row.membershipId !== "string" || row.errorCode !== void 0 && typeof row.errorCode !== "string")
|
|
4352
|
-
throw new ProjectRoomClientError("Invalid dispatch response", 500, "INVALID_RESPONSE", false);
|
|
4285
|
+
if (typeof row.success !== "boolean" || row.membershipId !== void 0 && typeof row.membershipId !== "string" || row.errorCode !== void 0 && typeof row.errorCode !== "string") throw new ProjectRoomClientError("Invalid dispatch response", 500, "INVALID_RESPONSE", false);
|
|
4353
4286
|
return { success: row.success, ...row.membershipId === void 0 ? {} : { membershipId: row.membershipId }, ...row.errorCode === void 0 ? {} : { errorCode: row.errorCode } };
|
|
4354
4287
|
};
|
|
4355
4288
|
function hydratePublicMember(value) {
|
|
@@ -4375,23 +4308,19 @@ var ProjectRoomsClient = class {
|
|
|
4375
4308
|
query.set("beforeCreatedAt", iso(options.cursor.createdAt));
|
|
4376
4309
|
query.set("beforeId", options.cursor.id);
|
|
4377
4310
|
}
|
|
4378
|
-
if (options.limit !== void 0)
|
|
4379
|
-
query.set("limit", String(options.limit));
|
|
4311
|
+
if (options.limit !== void 0) query.set("limit", String(options.limit));
|
|
4380
4312
|
const result = await this.request(`/api/projects/${encode(projectId)}/room/messages${query.toString() ? `?${query}` : ""}`);
|
|
4381
|
-
if (!Array.isArray(result))
|
|
4382
|
-
throw new ProjectRoomClientError("Invalid messages response", 500, "INVALID_RESPONSE", false);
|
|
4313
|
+
if (!Array.isArray(result)) throw new ProjectRoomClientError("Invalid messages response", 500, "INVALID_RESPONSE", false);
|
|
4383
4314
|
return result.map(hydrateMessage);
|
|
4384
4315
|
},
|
|
4385
4316
|
send: async (projectId, input) => {
|
|
4386
4317
|
const result = await this.request(`/api/projects/${encode(projectId)}/room/messages`, { method: "POST", body: { text: input.text, mentions: input.mentions, ...input.replyToMessageId === void 0 ? {} : { replyToMessageId: input.replyToMessageId } }, headers: { "Idempotency-Key": input.idempotencyKey.trim() } });
|
|
4387
|
-
if (!Array.isArray(result.dispatch) || typeof result.replayed !== "boolean")
|
|
4388
|
-
throw new ProjectRoomClientError("Invalid send response", 500, "INVALID_RESPONSE", false);
|
|
4318
|
+
if (!Array.isArray(result.dispatch) || typeof result.replayed !== "boolean") throw new ProjectRoomClientError("Invalid send response", 500, "INVALID_RESPONSE", false);
|
|
4389
4319
|
return { message: hydrateMessage(result.message), dispatch: result.dispatch.map(hydrateDispatch), replayed: result.replayed };
|
|
4390
4320
|
},
|
|
4391
4321
|
retry: async (projectId, messageId) => {
|
|
4392
4322
|
const result = await this.request(`/api/projects/${encode(projectId)}/room/messages/${encode(messageId)}/retry`, { method: "POST", body: {} });
|
|
4393
|
-
if (!Array.isArray(result))
|
|
4394
|
-
throw new ProjectRoomClientError("Invalid retry response", 500, "INVALID_RESPONSE", false);
|
|
4323
|
+
if (!Array.isArray(result)) throw new ProjectRoomClientError("Invalid retry response", 500, "INVALID_RESPONSE", false);
|
|
4395
4324
|
return result.map(hydrateDispatch);
|
|
4396
4325
|
},
|
|
4397
4326
|
markRead: async (projectId) => {
|
|
@@ -4432,8 +4361,7 @@ var ProjectRoomsClient = class {
|
|
|
4432
4361
|
}
|
|
4433
4362
|
async records(path, hydrate) {
|
|
4434
4363
|
const result = await this.request(path);
|
|
4435
|
-
if (!Array.isArray(result))
|
|
4436
|
-
throw new ProjectRoomClientError("Invalid records response", 500, "INVALID_RESPONSE", false);
|
|
4364
|
+
if (!Array.isArray(result)) throw new ProjectRoomClientError("Invalid records response", 500, "INVALID_RESPONSE", false);
|
|
4437
4365
|
return result.map(hydrate);
|
|
4438
4366
|
}
|
|
4439
4367
|
async request(path, options = {}) {
|
|
@@ -4445,8 +4373,7 @@ var ProjectRoomsClient = class {
|
|
|
4445
4373
|
const error = payload?.error;
|
|
4446
4374
|
throw new ProjectRoomClientError(typeof error?.message === "string" ? error.message : "Project Room request failed", response.status, typeof error?.code === "string" ? error.code : response.ok ? "INVALID_RESPONSE" : "HTTP_ERROR", error?.retryable === true, error?.details);
|
|
4447
4375
|
}
|
|
4448
|
-
if (!Object.prototype.hasOwnProperty.call(payload, "data"))
|
|
4449
|
-
throw new ProjectRoomClientError("Missing response data", 500, "INVALID_RESPONSE", false);
|
|
4376
|
+
if (!Object.prototype.hasOwnProperty.call(payload, "data")) throw new ProjectRoomClientError("Missing response data", 500, "INVALID_RESPONSE", false);
|
|
4450
4377
|
return payload.data;
|
|
4451
4378
|
}
|
|
4452
4379
|
};
|
|
@@ -4454,19 +4381,16 @@ var ProjectRoomsClient = class {
|
|
|
4454
4381
|
// src/workspace-rooms.ts
|
|
4455
4382
|
var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4456
4383
|
var record2 = (value) => {
|
|
4457
|
-
if (!isRecord2(value))
|
|
4458
|
-
throw new ProjectRoomClientError("Invalid workspace rooms response", 500, "INVALID_RESPONSE", false);
|
|
4384
|
+
if (!isRecord2(value)) throw new ProjectRoomClientError("Invalid workspace rooms response", 500, "INVALID_RESPONSE", false);
|
|
4459
4385
|
return value;
|
|
4460
4386
|
};
|
|
4461
4387
|
var requiredString2 = (row, field) => {
|
|
4462
|
-
if (typeof row[field] !== "string")
|
|
4463
|
-
throw new ProjectRoomClientError(`Invalid ${field}`, 500, "INVALID_RESPONSE", false);
|
|
4388
|
+
if (typeof row[field] !== "string") throw new ProjectRoomClientError(`Invalid ${field}`, 500, "INVALID_RESPONSE", false);
|
|
4464
4389
|
return row[field];
|
|
4465
4390
|
};
|
|
4466
4391
|
var date2 = (value, field) => {
|
|
4467
4392
|
const result = value instanceof Date ? new Date(value.getTime()) : new Date(typeof value === "string" ? value : Number.NaN);
|
|
4468
|
-
if (!Number.isFinite(result.getTime()))
|
|
4469
|
-
throw new ProjectRoomClientError(`Invalid ${field}`, 500, "INVALID_RESPONSE", false);
|
|
4393
|
+
if (!Number.isFinite(result.getTime())) throw new ProjectRoomClientError(`Invalid ${field}`, 500, "INVALID_RESPONSE", false);
|
|
4470
4394
|
return result;
|
|
4471
4395
|
};
|
|
4472
4396
|
var hydrateProject = (value) => {
|
|
@@ -4486,10 +4410,8 @@ var hydrateProject = (value) => {
|
|
|
4486
4410
|
var hydrateEntry = (value) => {
|
|
4487
4411
|
const row = record2(value);
|
|
4488
4412
|
const names = row.participantNames;
|
|
4489
|
-
if (!Array.isArray(names) || names.some((n) => typeof n !== "string"))
|
|
4490
|
-
|
|
4491
|
-
if (typeof row.participantCount !== "number" || typeof row.unreadCount !== "number")
|
|
4492
|
-
throw new ProjectRoomClientError("Invalid room entry counts", 500, "INVALID_RESPONSE", false);
|
|
4413
|
+
if (!Array.isArray(names) || names.some((n) => typeof n !== "string")) throw new ProjectRoomClientError("Invalid participantNames", 500, "INVALID_RESPONSE", false);
|
|
4414
|
+
if (typeof row.participantCount !== "number" || typeof row.unreadCount !== "number") throw new ProjectRoomClientError("Invalid room entry counts", 500, "INVALID_RESPONSE", false);
|
|
4493
4415
|
return {
|
|
4494
4416
|
project: hydrateProject(row.project),
|
|
4495
4417
|
room: hydrateRoom(row.room),
|
|
@@ -4514,8 +4436,7 @@ var WorkspaceRoomsClient = class {
|
|
|
4514
4436
|
const error = payload?.error;
|
|
4515
4437
|
throw new ProjectRoomClientError(typeof error?.message === "string" ? error.message : "Workspace rooms request failed", response.status, typeof error?.code === "string" ? error.code : response.ok ? "INVALID_RESPONSE" : "HTTP_ERROR", error?.retryable === true, error?.details);
|
|
4516
4438
|
}
|
|
4517
|
-
if (!payload.data || !Array.isArray(payload.data.rooms))
|
|
4518
|
-
throw new ProjectRoomClientError("Invalid workspace rooms response", 500, "INVALID_RESPONSE", false);
|
|
4439
|
+
if (!payload.data || !Array.isArray(payload.data.rooms)) throw new ProjectRoomClientError("Invalid workspace rooms response", 500, "INVALID_RESPONSE", false);
|
|
4519
4440
|
return payload.data.rooms.map(hydrateEntry);
|
|
4520
4441
|
}
|
|
4521
4442
|
};
|
|
@@ -4523,10 +4444,8 @@ var WorkspaceRoomsClient = class {
|
|
|
4523
4444
|
// src/workspace-members.ts
|
|
4524
4445
|
var isRecord3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4525
4446
|
var hydrateMember2 = (value) => {
|
|
4526
|
-
if (!isRecord3(value))
|
|
4527
|
-
|
|
4528
|
-
if (typeof value.userId !== "string" || typeof value.name !== "string")
|
|
4529
|
-
throw new ProjectRoomClientError("Invalid workspace member", 500, "INVALID_RESPONSE", false);
|
|
4447
|
+
if (!isRecord3(value)) throw new ProjectRoomClientError("Invalid workspace member", 500, "INVALID_RESPONSE", false);
|
|
4448
|
+
if (typeof value.userId !== "string" || typeof value.name !== "string") throw new ProjectRoomClientError("Invalid workspace member", 500, "INVALID_RESPONSE", false);
|
|
4530
4449
|
return {
|
|
4531
4450
|
userId: value.userId,
|
|
4532
4451
|
name: value.name,
|
|
@@ -4550,8 +4469,7 @@ var WorkspaceMembersClient = class {
|
|
|
4550
4469
|
throw new ProjectRoomClientError(typeof error?.message === "string" ? error.message : "Workspace members request failed", response.status, typeof error?.code === "string" ? error.code : response.ok ? "INVALID_RESPONSE" : "HTTP_ERROR", error?.retryable === true, error?.details);
|
|
4551
4470
|
}
|
|
4552
4471
|
const members = payload.data?.members;
|
|
4553
|
-
if (!Array.isArray(members))
|
|
4554
|
-
throw new ProjectRoomClientError("Invalid workspace members response", 500, "INVALID_RESPONSE", false);
|
|
4472
|
+
if (!Array.isArray(members)) throw new ProjectRoomClientError("Invalid workspace members response", 500, "INVALID_RESPONSE", false);
|
|
4555
4473
|
return members.map(hydrateMember2);
|
|
4556
4474
|
}
|
|
4557
4475
|
};
|
|
@@ -4559,76 +4477,61 @@ var WorkspaceMembersClient = class {
|
|
|
4559
4477
|
// src/room-events.ts
|
|
4560
4478
|
var invalidFrame = (message) => new ProjectRoomClientError(message, 200, "INVALID_EVENT", false);
|
|
4561
4479
|
var requiredString3 = (row, field) => {
|
|
4562
|
-
if (typeof row[field] !== "string")
|
|
4563
|
-
throw invalidFrame(`Invalid ${field}`);
|
|
4480
|
+
if (typeof row[field] !== "string") throw invalidFrame(`Invalid ${field}`);
|
|
4564
4481
|
return row[field];
|
|
4565
4482
|
};
|
|
4566
4483
|
var oneOf2 = (value, values, field) => {
|
|
4567
|
-
if (typeof value !== "string" || !values.includes(value))
|
|
4568
|
-
throw invalidFrame(`Invalid ${field}`);
|
|
4484
|
+
if (typeof value !== "string" || !values.includes(value)) throw invalidFrame(`Invalid ${field}`);
|
|
4569
4485
|
return value;
|
|
4570
4486
|
};
|
|
4571
4487
|
var hydrateScope = (value) => {
|
|
4572
|
-
if (!isRecord(value))
|
|
4573
|
-
throw invalidFrame("Invalid scope");
|
|
4488
|
+
if (!isRecord(value)) throw invalidFrame("Invalid scope");
|
|
4574
4489
|
return { tenantId: requiredString3(value, "tenantId"), roomId: requiredString3(value, "roomId"), projectId: requiredString3(value, "projectId") };
|
|
4575
4490
|
};
|
|
4576
4491
|
var hydrateControl = (event, payload) => {
|
|
4577
4492
|
if (event === "ready") {
|
|
4578
|
-
if (typeof payload.epoch !== "string" || payload.headEventId !== null && typeof payload.headEventId !== "string" || Object.keys(payload).some((key) => key !== "epoch" && key !== "headEventId"))
|
|
4579
|
-
throw invalidFrame("Invalid SSE control");
|
|
4493
|
+
if (typeof payload.epoch !== "string" || payload.headEventId !== null && typeof payload.headEventId !== "string" || Object.keys(payload).some((key) => key !== "epoch" && key !== "headEventId")) throw invalidFrame("Invalid SSE control");
|
|
4580
4494
|
return { type: "ready", data: { epoch: payload.epoch, headEventId: payload.headEventId } };
|
|
4581
4495
|
}
|
|
4582
|
-
if (Object.keys(payload).some((key) => key !== "reason"))
|
|
4583
|
-
|
|
4584
|
-
if (event === "resync")
|
|
4585
|
-
return { type: "resync", data: { reason: oneOf2(payload.reason, ["SERVER_RESTART", "CURSOR_EXPIRED", "SLOW_CONSUMER"], "reason") } };
|
|
4496
|
+
if (Object.keys(payload).some((key) => key !== "reason")) throw invalidFrame("Invalid SSE control");
|
|
4497
|
+
if (event === "resync") return { type: "resync", data: { reason: oneOf2(payload.reason, ["SERVER_RESTART", "CURSOR_EXPIRED", "SLOW_CONSUMER"], "reason") } };
|
|
4586
4498
|
return { type: "access.revoked", data: { reason: oneOf2(payload.reason, ["PROJECT_ACCESS_REVOKED", "TOKEN_EXPIRED", "CONNECTION_SUPERSEDED"], "reason") } };
|
|
4587
4499
|
};
|
|
4588
4500
|
var ROOM_SCOPED_TYPES = ["message.created", "roster.changed", "membership.changed", "task.changed"];
|
|
4589
4501
|
function hydrateWorkspaceFrame(raw) {
|
|
4590
4502
|
const payload = isRecord(raw.data) ? raw.data : void 0;
|
|
4591
4503
|
if (raw.event === "ready" || raw.event === "resync" || raw.event === "access.revoked") {
|
|
4592
|
-
if (!payload || Object.prototype.hasOwnProperty.call(payload, "type"))
|
|
4593
|
-
throw invalidFrame("Invalid SSE control");
|
|
4504
|
+
if (!payload || Object.prototype.hasOwnProperty.call(payload, "type")) throw invalidFrame("Invalid SSE control");
|
|
4594
4505
|
return hydrateControl(raw.event, payload);
|
|
4595
4506
|
}
|
|
4596
|
-
if (typeof payload?.type !== "string" || payload.type !== raw.event || typeof payload.id !== "string" || raw.id !== payload.id)
|
|
4597
|
-
throw invalidFrame("Invalid SSE business event");
|
|
4507
|
+
if (typeof payload?.type !== "string" || payload.type !== raw.event || typeof payload.id !== "string" || raw.id !== payload.id) throw invalidFrame("Invalid SSE business event");
|
|
4598
4508
|
const occurredAt = date(payload.occurredAt, "occurredAt");
|
|
4599
4509
|
const scope = payload.scope === void 0 ? void 0 : hydrateScope(payload.scope);
|
|
4600
4510
|
const roomScoped = ROOM_SCOPED_TYPES.includes(payload.type);
|
|
4601
|
-
if (roomScoped && scope === void 0)
|
|
4602
|
-
throw invalidFrame("Invalid SSE business event scope");
|
|
4511
|
+
if (roomScoped && scope === void 0) throw invalidFrame("Invalid SSE business event scope");
|
|
4603
4512
|
const data = payload.data;
|
|
4604
4513
|
if (payload.type === "message.created") {
|
|
4605
|
-
if (!isRecord(data))
|
|
4606
|
-
throw invalidFrame("Invalid SSE business event data");
|
|
4514
|
+
if (!isRecord(data)) throw invalidFrame("Invalid SSE business event data");
|
|
4607
4515
|
return { type: payload.type, id: payload.id, occurredAt, scope, data: { message: hydrateMessage(data.message) } };
|
|
4608
4516
|
}
|
|
4609
4517
|
if (payload.type === "roster.changed") {
|
|
4610
|
-
if (!isRecord(data))
|
|
4611
|
-
throw invalidFrame("Invalid SSE business event data");
|
|
4518
|
+
if (!isRecord(data)) throw invalidFrame("Invalid SSE business event data");
|
|
4612
4519
|
return { type: payload.type, id: payload.id, occurredAt, scope, data: { change: requiredString3(data, "change"), membership: hydratePublicBot(data.membership) } };
|
|
4613
4520
|
}
|
|
4614
4521
|
if (payload.type === "membership.changed") {
|
|
4615
|
-
if (!isRecord(data))
|
|
4616
|
-
throw invalidFrame("Invalid SSE business event data");
|
|
4522
|
+
if (!isRecord(data)) throw invalidFrame("Invalid SSE business event data");
|
|
4617
4523
|
return { type: payload.type, id: payload.id, occurredAt, scope, data: { change: requiredString3(data, "change"), membership: hydratePublicMember(data.membership) } };
|
|
4618
4524
|
}
|
|
4619
4525
|
if (payload.type === "task.changed") {
|
|
4620
|
-
if (!isRecord(data))
|
|
4621
|
-
throw invalidFrame("Invalid SSE business event data");
|
|
4526
|
+
if (!isRecord(data)) throw invalidFrame("Invalid SSE business event data");
|
|
4622
4527
|
return { type: payload.type, id: payload.id, occurredAt, scope, data: { taskId: requiredString3(data, "taskId"), status: requiredString3(data, "status"), ownerMembershipId: requiredString3(data, "ownerMembershipId"), updatedAt: date(data.updatedAt, "updatedAt") } };
|
|
4623
4528
|
}
|
|
4624
4529
|
if (payload.type === "read.changed") {
|
|
4625
|
-
if (!isRecord(data))
|
|
4626
|
-
throw invalidFrame("Invalid SSE business event data");
|
|
4530
|
+
if (!isRecord(data)) throw invalidFrame("Invalid SSE business event data");
|
|
4627
4531
|
return { type: payload.type, id: payload.id, occurredAt, data: { projectId: requiredString3(data, "projectId"), roomId: requiredString3(data, "roomId"), lastReadAt: date(data.lastReadAt, "lastReadAt") } };
|
|
4628
4532
|
}
|
|
4629
4533
|
if (payload.type === "membership.affected") {
|
|
4630
|
-
if (!isRecord(data))
|
|
4631
|
-
throw invalidFrame("Invalid SSE business event data");
|
|
4534
|
+
if (!isRecord(data)) throw invalidFrame("Invalid SSE business event data");
|
|
4632
4535
|
return { type: payload.type, id: payload.id, occurredAt, data: { change: oneOf2(data.change, ["added", "removed", "role_changed"], "change"), projectId: requiredString3(data, "projectId"), roomId: requiredString3(data, "roomId") } };
|
|
4633
4536
|
}
|
|
4634
4537
|
return { type: payload.type, id: payload.id, occurredAt, data: payload.data, ...scope === void 0 ? {} : { scope } };
|
|
@@ -4652,35 +4555,29 @@ var RoomEventsClient = class {
|
|
|
4652
4555
|
const error = payload?.error;
|
|
4653
4556
|
throw new ProjectRoomClientError(typeof error?.message === "string" ? error.message : "Workspace room events stream failed", response.status, typeof error?.code === "string" ? error.code : "HTTP_ERROR", error?.retryable === true, error?.details);
|
|
4654
4557
|
}
|
|
4655
|
-
if (response.headers?.get && response.headers.get("content-type")?.split(";")[0].trim() !== "text/event-stream")
|
|
4656
|
-
|
|
4657
|
-
if (!response.body)
|
|
4658
|
-
throw new ProjectRoomClientError("Workspace room events stream has no body", 500, "INVALID_RESPONSE", false);
|
|
4558
|
+
if (response.headers?.get && response.headers.get("content-type")?.split(";")[0].trim() !== "text/event-stream") throw new ProjectRoomClientError("Workspace room events stream has invalid content type", response.status, "INVALID_RESPONSE", false);
|
|
4559
|
+
if (!response.body) throw new ProjectRoomClientError("Workspace room events stream has no body", 500, "INVALID_RESPONSE", false);
|
|
4659
4560
|
resolveOpen({ status: 200 });
|
|
4660
4561
|
return response;
|
|
4661
4562
|
}).catch((error) => {
|
|
4662
4563
|
rejectOpen(error);
|
|
4663
4564
|
throw error;
|
|
4664
4565
|
});
|
|
4665
|
-
const stream = async function* () {
|
|
4566
|
+
const stream = (async function* () {
|
|
4666
4567
|
const response = await responsePromise;
|
|
4667
4568
|
const body = response.body;
|
|
4668
|
-
if (!body)
|
|
4669
|
-
throw new ProjectRoomClientError("Workspace room events stream has no body", 500, "INVALID_RESPONSE", false);
|
|
4569
|
+
if (!body) throw new ProjectRoomClientError("Workspace room events stream has no body", 500, "INVALID_RESPONSE", false);
|
|
4670
4570
|
for await (const raw of parseSseBody(body, { strictJsonObject: true })) {
|
|
4671
4571
|
try {
|
|
4672
4572
|
yield { event: hydrateWorkspaceFrame(raw), ...raw.id === void 0 ? {} : { id: raw.id }, ...raw.retry === void 0 ? {} : { retry: raw.retry } };
|
|
4673
4573
|
} catch (error) {
|
|
4674
|
-
if (error instanceof ProjectRoomClientError && error.code === "INVALID_EVENT")
|
|
4675
|
-
|
|
4676
|
-
if (error instanceof
|
|
4677
|
-
throw new ProjectRoomClientError(error.message, 400, "INVALID_EVENT", false);
|
|
4678
|
-
if (error instanceof ProjectRoomClientError)
|
|
4679
|
-
throw new ProjectRoomClientError(error.message, 400, "INVALID_EVENT", false, error.details);
|
|
4574
|
+
if (error instanceof ProjectRoomClientError && error.code === "INVALID_EVENT") throw new ProjectRoomClientError(error.message, 400, "INVALID_EVENT", false, error.details);
|
|
4575
|
+
if (error instanceof SseParseError) throw new ProjectRoomClientError(error.message, 400, "INVALID_EVENT", false);
|
|
4576
|
+
if (error instanceof ProjectRoomClientError) throw new ProjectRoomClientError(error.message, 400, "INVALID_EVENT", false, error.details);
|
|
4680
4577
|
throw new ProjectRoomClientError("Invalid SSE event", 400, "INVALID_EVENT", false);
|
|
4681
4578
|
}
|
|
4682
4579
|
}
|
|
4683
|
-
}();
|
|
4580
|
+
})();
|
|
4684
4581
|
return { opened, [Symbol.asyncIterator]: () => stream };
|
|
4685
4582
|
}
|
|
4686
4583
|
};
|
|
@@ -4701,13 +4598,11 @@ function invalidResponse(message) {
|
|
|
4701
4598
|
return new OidcProviderClientError(message, 500, "INVALID_RESPONSE", false);
|
|
4702
4599
|
}
|
|
4703
4600
|
function requiredString4(row, field) {
|
|
4704
|
-
if (typeof row[field] !== "string")
|
|
4705
|
-
throw invalidResponse(`Invalid ${field}`);
|
|
4601
|
+
if (typeof row[field] !== "string") throw invalidResponse(`Invalid ${field}`);
|
|
4706
4602
|
return row[field];
|
|
4707
4603
|
}
|
|
4708
4604
|
function hydrateSummary(value) {
|
|
4709
|
-
if (!isRecord4(value))
|
|
4710
|
-
throw invalidResponse("Invalid OIDC provider summary");
|
|
4605
|
+
if (!isRecord4(value)) throw invalidResponse("Invalid OIDC provider summary");
|
|
4711
4606
|
const source = value.source;
|
|
4712
4607
|
if (source !== "env" && source !== "store") {
|
|
4713
4608
|
throw invalidResponse("Invalid OIDC provider source");
|
|
@@ -4734,8 +4629,7 @@ function hydrateSummary(value) {
|
|
|
4734
4629
|
};
|
|
4735
4630
|
}
|
|
4736
4631
|
function hydrateTestResult(value) {
|
|
4737
|
-
if (!isRecord4(value))
|
|
4738
|
-
throw invalidResponse("Invalid OIDC test result");
|
|
4632
|
+
if (!isRecord4(value)) throw invalidResponse("Invalid OIDC test result");
|
|
4739
4633
|
const scopesSupported = Array.isArray(value.scopesSupported) ? value.scopesSupported.filter(
|
|
4740
4634
|
(scope) => typeof scope === "string"
|
|
4741
4635
|
) : void 0;
|
|
@@ -4777,8 +4671,7 @@ var OidcProvidersClient = class {
|
|
|
4777
4671
|
}
|
|
4778
4672
|
async list() {
|
|
4779
4673
|
const data = await this.request("/api/oidc-providers");
|
|
4780
|
-
if (!Array.isArray(data))
|
|
4781
|
-
throw invalidResponse("Invalid provider list");
|
|
4674
|
+
if (!Array.isArray(data)) throw invalidResponse("Invalid provider list");
|
|
4782
4675
|
return data.map(hydrateSummary);
|
|
4783
4676
|
}
|
|
4784
4677
|
async create(input) {
|
|
@@ -4836,6 +4729,10 @@ var OidcProvidersClient = class {
|
|
|
4836
4729
|
};
|
|
4837
4730
|
|
|
4838
4731
|
// src/platform.ts
|
|
4732
|
+
import {
|
|
4733
|
+
PLATFORM_BRANDING_FIELDS,
|
|
4734
|
+
PLATFORM_BRANDING_FIELD_KEYS
|
|
4735
|
+
} from "@axiom-lattice/protocols";
|
|
4839
4736
|
var PlatformClientError = class extends Error {
|
|
4840
4737
|
constructor(message, status, code, retryable = false, details) {
|
|
4841
4738
|
super(message);
|
|
@@ -4853,16 +4750,13 @@ function invalidResponse2(message) {
|
|
|
4853
4750
|
return new PlatformClientError(message, 500, "INVALID_RESPONSE", false);
|
|
4854
4751
|
}
|
|
4855
4752
|
function requiredString5(row, field) {
|
|
4856
|
-
if (typeof row[field] !== "string")
|
|
4857
|
-
throw invalidResponse2(`Invalid ${field}`);
|
|
4753
|
+
if (typeof row[field] !== "string") throw invalidResponse2(`Invalid ${field}`);
|
|
4858
4754
|
return row[field];
|
|
4859
4755
|
}
|
|
4860
4756
|
function optionalNullableString(row, field) {
|
|
4861
4757
|
const value = row[field];
|
|
4862
|
-
if (value === null || value === void 0)
|
|
4863
|
-
|
|
4864
|
-
if (typeof value !== "string")
|
|
4865
|
-
throw invalidResponse2(`Invalid ${field}`);
|
|
4758
|
+
if (value === null || value === void 0) return null;
|
|
4759
|
+
if (typeof value !== "string") throw invalidResponse2(`Invalid ${field}`);
|
|
4866
4760
|
return value;
|
|
4867
4761
|
}
|
|
4868
4762
|
function hydrateSettingsSnapshot(value) {
|
|
@@ -4885,33 +4779,30 @@ function hydrateEnvironment(value) {
|
|
|
4885
4779
|
}
|
|
4886
4780
|
return value;
|
|
4887
4781
|
}
|
|
4888
|
-
var BRANDING_TEXT_KEYS = [
|
|
4889
|
-
"brandName",
|
|
4890
|
-
"logoUrl",
|
|
4891
|
-
"faviconUrl",
|
|
4892
|
-
"primaryColor",
|
|
4893
|
-
"backgroundColor",
|
|
4894
|
-
"loginTitle",
|
|
4895
|
-
"loginSubtitle"
|
|
4896
|
-
];
|
|
4897
4782
|
function hydrateBranding(value) {
|
|
4898
|
-
if (!isRecord5(value))
|
|
4899
|
-
throw invalidResponse2("Invalid branding");
|
|
4783
|
+
if (!isRecord5(value)) throw invalidResponse2("Invalid branding");
|
|
4900
4784
|
const branding = {};
|
|
4901
|
-
|
|
4785
|
+
const target = branding;
|
|
4786
|
+
for (const key of PLATFORM_BRANDING_FIELD_KEYS) {
|
|
4902
4787
|
const field = value[key];
|
|
4903
|
-
if (field === void 0)
|
|
4788
|
+
if (field === void 0) continue;
|
|
4789
|
+
const kind = PLATFORM_BRANDING_FIELDS[key].kind;
|
|
4790
|
+
if (kind === "integer" || kind === "percent") {
|
|
4791
|
+
if (typeof field !== "number" || !Number.isInteger(field)) {
|
|
4792
|
+
throw invalidResponse2(`Invalid branding.${key}`);
|
|
4793
|
+
}
|
|
4794
|
+
target[key] = field;
|
|
4904
4795
|
continue;
|
|
4796
|
+
}
|
|
4905
4797
|
if (typeof field !== "string") {
|
|
4906
4798
|
throw invalidResponse2(`Invalid branding.${key}`);
|
|
4907
4799
|
}
|
|
4908
|
-
|
|
4800
|
+
target[key] = field;
|
|
4909
4801
|
}
|
|
4910
4802
|
return branding;
|
|
4911
4803
|
}
|
|
4912
4804
|
function hydrateBrandingDomain(value) {
|
|
4913
|
-
if (!isRecord5(value))
|
|
4914
|
-
throw invalidResponse2("Invalid branding domain");
|
|
4805
|
+
if (!isRecord5(value)) throw invalidResponse2("Invalid branding domain");
|
|
4915
4806
|
const domain = { host: requiredString5(value, "host") };
|
|
4916
4807
|
if (value.status !== void 0) {
|
|
4917
4808
|
if (value.status !== "active" && value.status !== "pending") {
|
|
@@ -4933,8 +4824,7 @@ function hydrateBrandingDomain(value) {
|
|
|
4933
4824
|
return domain;
|
|
4934
4825
|
}
|
|
4935
4826
|
function hydrateBrandingSettings(value) {
|
|
4936
|
-
if (!isRecord5(value))
|
|
4937
|
-
throw invalidResponse2("Invalid branding settings");
|
|
4827
|
+
if (!isRecord5(value)) throw invalidResponse2("Invalid branding settings");
|
|
4938
4828
|
const settings = {};
|
|
4939
4829
|
if (value.default !== void 0) {
|
|
4940
4830
|
settings.default = hydrateBranding(value.default);
|
|
@@ -4983,8 +4873,7 @@ function hydrateTenantRole(value) {
|
|
|
4983
4873
|
throw invalidResponse2("Invalid tenant role");
|
|
4984
4874
|
}
|
|
4985
4875
|
function hydrateStatus(value) {
|
|
4986
|
-
if (value === null || value === void 0)
|
|
4987
|
-
return null;
|
|
4876
|
+
if (value === null || value === void 0) return null;
|
|
4988
4877
|
if (value === "active" || value === "pending" || value === "suspended") {
|
|
4989
4878
|
return value;
|
|
4990
4879
|
}
|
|
@@ -4992,15 +4881,12 @@ function hydrateStatus(value) {
|
|
|
4992
4881
|
}
|
|
4993
4882
|
function optionalString(row, field) {
|
|
4994
4883
|
const value = row[field];
|
|
4995
|
-
if (value === null || value === void 0)
|
|
4996
|
-
|
|
4997
|
-
if (typeof value !== "string")
|
|
4998
|
-
throw invalidResponse2(`Invalid ${field}`);
|
|
4884
|
+
if (value === null || value === void 0) return void 0;
|
|
4885
|
+
if (typeof value !== "string") throw invalidResponse2(`Invalid ${field}`);
|
|
4999
4886
|
return value;
|
|
5000
4887
|
}
|
|
5001
4888
|
function hydrateInvitation(value) {
|
|
5002
|
-
if (!isRecord5(value))
|
|
5003
|
-
throw invalidResponse2("Invalid invitation");
|
|
4889
|
+
if (!isRecord5(value)) throw invalidResponse2("Invalid invitation");
|
|
5004
4890
|
const invitedBy = optionalString(value, "invitedBy");
|
|
5005
4891
|
const expiresAt = optionalString(value, "expiresAt");
|
|
5006
4892
|
const consumedAt = optionalString(value, "consumedAt");
|
|
@@ -5014,8 +4900,7 @@ function hydrateInvitation(value) {
|
|
|
5014
4900
|
};
|
|
5015
4901
|
}
|
|
5016
4902
|
function hydrateMember3(value) {
|
|
5017
|
-
if (!isRecord5(value))
|
|
5018
|
-
throw invalidResponse2("Invalid platform member");
|
|
4903
|
+
if (!isRecord5(value)) throw invalidResponse2("Invalid platform member");
|
|
5019
4904
|
return {
|
|
5020
4905
|
id: requiredString5(value, "id"),
|
|
5021
4906
|
email: optionalNullableString(value, "email"),
|
|
@@ -5027,8 +4912,7 @@ function hydrateMember3(value) {
|
|
|
5027
4912
|
};
|
|
5028
4913
|
}
|
|
5029
4914
|
function hydrateTenantMember(value) {
|
|
5030
|
-
if (!isRecord5(value))
|
|
5031
|
-
throw invalidResponse2("Invalid tenant member");
|
|
4915
|
+
if (!isRecord5(value)) throw invalidResponse2("Invalid tenant member");
|
|
5032
4916
|
return {
|
|
5033
4917
|
userId: requiredString5(value, "userId"),
|
|
5034
4918
|
tenantId: requiredString5(value, "tenantId"),
|
|
@@ -5046,8 +4930,7 @@ function hydrateOidcIdentityClaimStatus(value) {
|
|
|
5046
4930
|
throw invalidResponse2("Invalid SSO claim status");
|
|
5047
4931
|
}
|
|
5048
4932
|
function hydrateOidcIdentityClaim(value) {
|
|
5049
|
-
if (!isRecord5(value))
|
|
5050
|
-
throw invalidResponse2("Invalid SSO claim");
|
|
4933
|
+
if (!isRecord5(value)) throw invalidResponse2("Invalid SSO claim");
|
|
5051
4934
|
const name = optionalString(value, "name");
|
|
5052
4935
|
const picture = optionalString(value, "picture");
|
|
5053
4936
|
const reviewedBy = optionalString(value, "reviewedBy");
|
|
@@ -5062,8 +4945,7 @@ function hydrateOidcIdentityClaim(value) {
|
|
|
5062
4945
|
const existing = value.existingUser;
|
|
5063
4946
|
let existingUser;
|
|
5064
4947
|
if (existing !== void 0 && existing !== null) {
|
|
5065
|
-
if (!isRecord5(existing))
|
|
5066
|
-
throw invalidResponse2("Invalid existing user");
|
|
4948
|
+
if (!isRecord5(existing)) throw invalidResponse2("Invalid existing user");
|
|
5067
4949
|
const platformRole = existing.role !== void 0 ? hydratePlatformRole(existing.role) : existing.platformRole !== void 0 ? hydratePlatformRole(existing.platformRole) : void 0;
|
|
5068
4950
|
existingUser = {
|
|
5069
4951
|
id: requiredString5(existing, "id"),
|
|
@@ -5105,15 +4987,12 @@ function hydrateTenantStatus(value) {
|
|
|
5105
4987
|
}
|
|
5106
4988
|
function optionalRecord(row, field) {
|
|
5107
4989
|
const value = row[field];
|
|
5108
|
-
if (value === void 0 || value === null)
|
|
5109
|
-
|
|
5110
|
-
if (!isRecord5(value))
|
|
5111
|
-
throw invalidResponse2(`Invalid ${field}`);
|
|
4990
|
+
if (value === void 0 || value === null) return void 0;
|
|
4991
|
+
if (!isRecord5(value)) throw invalidResponse2(`Invalid ${field}`);
|
|
5112
4992
|
return value;
|
|
5113
4993
|
}
|
|
5114
4994
|
function hydrateInviteLink(value) {
|
|
5115
|
-
if (!isRecord5(value))
|
|
5116
|
-
throw invalidResponse2("Invalid invite link");
|
|
4995
|
+
if (!isRecord5(value)) throw invalidResponse2("Invalid invite link");
|
|
5117
4996
|
const scope = value.scope;
|
|
5118
4997
|
if (scope !== "platform" && scope !== "tenant") {
|
|
5119
4998
|
throw invalidResponse2("Invalid invite scope");
|
|
@@ -5139,8 +5018,7 @@ function hydrateInviteLink(value) {
|
|
|
5139
5018
|
};
|
|
5140
5019
|
}
|
|
5141
5020
|
function hydrateTenant(value) {
|
|
5142
|
-
if (!isRecord5(value))
|
|
5143
|
-
throw invalidResponse2("Invalid tenant");
|
|
5021
|
+
if (!isRecord5(value)) throw invalidResponse2("Invalid tenant");
|
|
5144
5022
|
const metadata = optionalRecord(value, "metadata");
|
|
5145
5023
|
return {
|
|
5146
5024
|
id: requiredString5(value, "id"),
|
|
@@ -5153,8 +5031,7 @@ function hydrateTenant(value) {
|
|
|
5153
5031
|
};
|
|
5154
5032
|
}
|
|
5155
5033
|
function hydrateUser(value) {
|
|
5156
|
-
if (!isRecord5(value))
|
|
5157
|
-
throw invalidResponse2("Invalid user");
|
|
5034
|
+
if (!isRecord5(value)) throw invalidResponse2("Invalid user");
|
|
5158
5035
|
const status = value.status;
|
|
5159
5036
|
if (status !== "active" && status !== "pending" && status !== "suspended") {
|
|
5160
5037
|
throw invalidResponse2("Invalid user status");
|
|
@@ -5231,8 +5108,7 @@ function hydrateAuditSource(value) {
|
|
|
5231
5108
|
throw invalidResponse2("Invalid platform audit source");
|
|
5232
5109
|
}
|
|
5233
5110
|
function hydrateAuditAction(value) {
|
|
5234
|
-
if (value === "write" || value === "playbook")
|
|
5235
|
-
return value;
|
|
5111
|
+
if (value === "write" || value === "playbook") return value;
|
|
5236
5112
|
throw invalidResponse2("Invalid platform audit action");
|
|
5237
5113
|
}
|
|
5238
5114
|
function hydrateAuditStatus(value) {
|
|
@@ -5281,8 +5157,7 @@ function hydratePlatformAudit(value) {
|
|
|
5281
5157
|
};
|
|
5282
5158
|
}
|
|
5283
5159
|
function requireRecordValue(value, message) {
|
|
5284
|
-
if (!isRecord5(value))
|
|
5285
|
-
throw invalidResponse2(message);
|
|
5160
|
+
if (!isRecord5(value)) throw invalidResponse2(message);
|
|
5286
5161
|
return value;
|
|
5287
5162
|
}
|
|
5288
5163
|
function hydrateModelCatalog(value) {
|
|
@@ -5432,10 +5307,8 @@ var PlatformClient = class {
|
|
|
5432
5307
|
}
|
|
5433
5308
|
async me() {
|
|
5434
5309
|
const data = await this.request("/api/platform/me");
|
|
5435
|
-
if (!isRecord5(data))
|
|
5436
|
-
|
|
5437
|
-
if (data.role === null || data.role === void 0)
|
|
5438
|
-
return null;
|
|
5310
|
+
if (!isRecord5(data)) throw invalidResponse2("Invalid platform identity");
|
|
5311
|
+
if (data.role === null || data.role === void 0) return null;
|
|
5439
5312
|
return hydratePlatformRole(data.role);
|
|
5440
5313
|
}
|
|
5441
5314
|
/**
|
|
@@ -5496,8 +5369,7 @@ var PlatformClient = class {
|
|
|
5496
5369
|
async listAudit(query = {}) {
|
|
5497
5370
|
const search = new URLSearchParams();
|
|
5498
5371
|
for (const [key, value] of Object.entries(query)) {
|
|
5499
|
-
if (value !== void 0)
|
|
5500
|
-
search.set(key, String(value));
|
|
5372
|
+
if (value !== void 0) search.set(key, String(value));
|
|
5501
5373
|
}
|
|
5502
5374
|
const suffix = search.toString();
|
|
5503
5375
|
const data = await this.request(
|
|
@@ -5550,8 +5422,7 @@ var PlatformClient = class {
|
|
|
5550
5422
|
}
|
|
5551
5423
|
async listTenants() {
|
|
5552
5424
|
const data = await this.request("/api/tenants");
|
|
5553
|
-
if (!Array.isArray(data))
|
|
5554
|
-
throw invalidResponse2("Invalid tenant list");
|
|
5425
|
+
if (!Array.isArray(data)) throw invalidResponse2("Invalid tenant list");
|
|
5555
5426
|
return data.map(hydrateTenant);
|
|
5556
5427
|
}
|
|
5557
5428
|
async createTenant(input) {
|
|
@@ -5576,8 +5447,7 @@ var PlatformClient = class {
|
|
|
5576
5447
|
}
|
|
5577
5448
|
async listUsers() {
|
|
5578
5449
|
const data = await this.request("/api/users");
|
|
5579
|
-
if (!Array.isArray(data))
|
|
5580
|
-
throw invalidResponse2("Invalid user list");
|
|
5450
|
+
if (!Array.isArray(data)) throw invalidResponse2("Invalid user list");
|
|
5581
5451
|
return data.map(hydrateUser);
|
|
5582
5452
|
}
|
|
5583
5453
|
async createUser(input) {
|
|
@@ -5601,8 +5471,7 @@ var PlatformClient = class {
|
|
|
5601
5471
|
}
|
|
5602
5472
|
async listMembers() {
|
|
5603
5473
|
const data = await this.request("/api/platform/members");
|
|
5604
|
-
if (!Array.isArray(data))
|
|
5605
|
-
throw invalidResponse2("Invalid member list");
|
|
5474
|
+
if (!Array.isArray(data)) throw invalidResponse2("Invalid member list");
|
|
5606
5475
|
return data.map(hydrateMember3);
|
|
5607
5476
|
}
|
|
5608
5477
|
async grantMember(input) {
|
|
@@ -5610,8 +5479,7 @@ var PlatformClient = class {
|
|
|
5610
5479
|
method: "POST",
|
|
5611
5480
|
body: JSON.stringify(input)
|
|
5612
5481
|
});
|
|
5613
|
-
if (!isRecord5(data))
|
|
5614
|
-
throw invalidResponse2("Invalid platform grant");
|
|
5482
|
+
if (!isRecord5(data)) throw invalidResponse2("Invalid platform grant");
|
|
5615
5483
|
const member = data.member !== void 0 ? hydrateMember3(data.member) : void 0;
|
|
5616
5484
|
const invitation = data.invitation !== void 0 ? hydrateInvitation(data.invitation) : void 0;
|
|
5617
5485
|
if (!member && !invitation) {
|
|
@@ -5624,8 +5492,7 @@ var PlatformClient = class {
|
|
|
5624
5492
|
}
|
|
5625
5493
|
async listInvitations() {
|
|
5626
5494
|
const data = await this.request("/api/platform/invitations");
|
|
5627
|
-
if (!Array.isArray(data))
|
|
5628
|
-
throw invalidResponse2("Invalid invitation list");
|
|
5495
|
+
if (!Array.isArray(data)) throw invalidResponse2("Invalid invitation list");
|
|
5629
5496
|
return data.map(hydrateInvitation);
|
|
5630
5497
|
}
|
|
5631
5498
|
async revokeInvitation(email) {
|
|
@@ -5652,8 +5519,7 @@ var PlatformClient = class {
|
|
|
5652
5519
|
const data = await this.request(
|
|
5653
5520
|
`/api/platform/tenant-members?${query}`
|
|
5654
5521
|
);
|
|
5655
|
-
if (!Array.isArray(data))
|
|
5656
|
-
throw invalidResponse2("Invalid tenant member list");
|
|
5522
|
+
if (!Array.isArray(data)) throw invalidResponse2("Invalid tenant member list");
|
|
5657
5523
|
return data.map(hydrateTenantMember);
|
|
5658
5524
|
}
|
|
5659
5525
|
async addTenantMember(input) {
|
|
@@ -5665,8 +5531,7 @@ var PlatformClient = class {
|
|
|
5665
5531
|
}
|
|
5666
5532
|
async listInviteLinks() {
|
|
5667
5533
|
const data = await this.request("/api/platform/invite-links");
|
|
5668
|
-
if (!Array.isArray(data))
|
|
5669
|
-
throw invalidResponse2("Invalid invite link list");
|
|
5534
|
+
if (!Array.isArray(data)) throw invalidResponse2("Invalid invite link list");
|
|
5670
5535
|
return data.map(hydrateInviteLink);
|
|
5671
5536
|
}
|
|
5672
5537
|
async createInviteLink(input) {
|
|
@@ -5725,8 +5590,7 @@ var PlatformClient = class {
|
|
|
5725
5590
|
async listOidcClaims(status = "pending") {
|
|
5726
5591
|
const query = new URLSearchParams({ status }).toString();
|
|
5727
5592
|
const data = await this.request(`/api/platform/oidc-claims?${query}`);
|
|
5728
|
-
if (!Array.isArray(data))
|
|
5729
|
-
throw invalidResponse2("Invalid SSO claim list");
|
|
5593
|
+
if (!Array.isArray(data)) throw invalidResponse2("Invalid SSO claim list");
|
|
5730
5594
|
return data.map(hydrateOidcIdentityClaim);
|
|
5731
5595
|
}
|
|
5732
5596
|
async updateOidcClaimEmail(id, email) {
|
|
@@ -5771,7 +5635,7 @@ var PlatformClient = class {
|
|
|
5771
5635
|
};
|
|
5772
5636
|
|
|
5773
5637
|
// src/client.ts
|
|
5774
|
-
var _Client = class extends AbstractClient {
|
|
5638
|
+
var _Client = class _Client extends AbstractClient {
|
|
5775
5639
|
/**
|
|
5776
5640
|
* Creates a new Client instance
|
|
5777
5641
|
* @param config - Configuration options for the client
|
|
@@ -6074,8 +5938,7 @@ var _Client = class extends AbstractClient {
|
|
|
6074
5938
|
...this.getAllHeaders()
|
|
6075
5939
|
};
|
|
6076
5940
|
const res = await fetch(`${this.config.baseURL}${path}`, { headers, signal });
|
|
6077
|
-
if (!res.ok || !res.body)
|
|
6078
|
-
throw new Error("Stream connection failed");
|
|
5941
|
+
if (!res.ok || !res.body) throw new Error("Stream connection failed");
|
|
6079
5942
|
try {
|
|
6080
5943
|
for await (const frame of parseSseBody(res.body, { strictJsonObject: true })) {
|
|
6081
5944
|
yield { event: frame.event, data: frame.data };
|
|
@@ -6104,8 +5967,7 @@ var _Client = class extends AbstractClient {
|
|
|
6104
5967
|
return this.getAllHeaders();
|
|
6105
5968
|
}
|
|
6106
5969
|
bodyAffinityHeaders(body) {
|
|
6107
|
-
if (!body || typeof body !== "object" || body instanceof FormData)
|
|
6108
|
-
return {};
|
|
5970
|
+
if (!body || typeof body !== "object" || body instanceof FormData) return {};
|
|
6109
5971
|
const threadId = body.thread_id;
|
|
6110
5972
|
return typeof threadId === "string" ? threadAffinityHeaders2(threadId) : {};
|
|
6111
5973
|
}
|
|
@@ -6139,8 +6001,7 @@ var _Client = class extends AbstractClient {
|
|
|
6139
6001
|
if (!response.body) {
|
|
6140
6002
|
throw new Error("Response body is null");
|
|
6141
6003
|
}
|
|
6142
|
-
for await (const frame of parseSseBody(response.body, { strictJsonObject: true }))
|
|
6143
|
-
onEvent(frame.data);
|
|
6004
|
+
for await (const frame of parseSseBody(response.body, { strictJsonObject: true })) onEvent(frame.data);
|
|
6144
6005
|
if (onComplete) {
|
|
6145
6006
|
if (options.enableReturnStateWhenSteamCompleted) {
|
|
6146
6007
|
try {
|
|
@@ -6167,11 +6028,11 @@ var _Client = class extends AbstractClient {
|
|
|
6167
6028
|
};
|
|
6168
6029
|
}
|
|
6169
6030
|
};
|
|
6031
|
+
_Client.globalWorkspaceHeaders = {};
|
|
6170
6032
|
var Client = _Client;
|
|
6171
|
-
Client.globalWorkspaceHeaders = {};
|
|
6172
6033
|
|
|
6173
6034
|
// src/runtime-client.ts
|
|
6174
|
-
var RuntimeAxiomClient = class extends Client {
|
|
6035
|
+
var RuntimeAxiomClient = class _RuntimeAxiomClient extends Client {
|
|
6175
6036
|
constructor(config) {
|
|
6176
6037
|
super({
|
|
6177
6038
|
...config,
|
|
@@ -6198,8 +6059,7 @@ var RuntimeAxiomClient = class extends Client {
|
|
|
6198
6059
|
* priming — the first request triggers the token provider.
|
|
6199
6060
|
*/
|
|
6200
6061
|
async primeToken() {
|
|
6201
|
-
if (this.identity.mode !== "verified")
|
|
6202
|
-
return "";
|
|
6062
|
+
if (this.identity.mode !== "verified") return "";
|
|
6203
6063
|
if (!this.tokenPromise) {
|
|
6204
6064
|
this.tokenPromise = this.identity.tokenProvider().then((token) => {
|
|
6205
6065
|
this.token = token;
|
|
@@ -6248,8 +6108,7 @@ var RuntimeAxiomClient = class extends Client {
|
|
|
6248
6108
|
error.status = response.status;
|
|
6249
6109
|
throw error;
|
|
6250
6110
|
}
|
|
6251
|
-
if (response.status === 204)
|
|
6252
|
-
return void 0;
|
|
6111
|
+
if (response.status === 204) return void 0;
|
|
6253
6112
|
return await response.json();
|
|
6254
6113
|
}
|
|
6255
6114
|
getBaseUrl() {
|
|
@@ -6261,7 +6120,7 @@ var RuntimeAxiomClient = class extends Client {
|
|
|
6261
6120
|
* working (each clone carries its own resolved credential cache).
|
|
6262
6121
|
*/
|
|
6263
6122
|
createInstance(config) {
|
|
6264
|
-
return new
|
|
6123
|
+
return new _RuntimeAxiomClient({
|
|
6265
6124
|
gatewayUrl: this.gatewayUrl,
|
|
6266
6125
|
webAppId: this.webAppId,
|
|
6267
6126
|
identity: this.identity,
|
|
@@ -6280,7 +6139,7 @@ var RuntimeAxiomClient = class extends Client {
|
|
|
6280
6139
|
// src/wechat-client.ts
|
|
6281
6140
|
import { threadAffinityHeaders as threadAffinityHeaders3 } from "@axiom-lattice/protocols";
|
|
6282
6141
|
var import_encoding = __toESM(require_encoding());
|
|
6283
|
-
var WeChatClient = class extends AbstractClient {
|
|
6142
|
+
var WeChatClient = class _WeChatClient extends AbstractClient {
|
|
6284
6143
|
/**
|
|
6285
6144
|
* Creates a new WeChatClient instance
|
|
6286
6145
|
* @param config - Configuration options for the client
|
|
@@ -6305,16 +6164,12 @@ var WeChatClient = class extends AbstractClient {
|
|
|
6305
6164
|
*/
|
|
6306
6165
|
setWorkspaceContext(workspaceId, projectId) {
|
|
6307
6166
|
if (workspaceId !== void 0) {
|
|
6308
|
-
if (workspaceId)
|
|
6309
|
-
|
|
6310
|
-
else
|
|
6311
|
-
delete this.workspaceHeaders["x-workspace-id"];
|
|
6167
|
+
if (workspaceId) this.workspaceHeaders["x-workspace-id"] = workspaceId;
|
|
6168
|
+
else delete this.workspaceHeaders["x-workspace-id"];
|
|
6312
6169
|
}
|
|
6313
6170
|
if (projectId !== void 0) {
|
|
6314
|
-
if (projectId)
|
|
6315
|
-
|
|
6316
|
-
else
|
|
6317
|
-
delete this.workspaceHeaders["x-project-id"];
|
|
6171
|
+
if (projectId) this.workspaceHeaders["x-project-id"] = projectId;
|
|
6172
|
+
else delete this.workspaceHeaders["x-project-id"];
|
|
6318
6173
|
}
|
|
6319
6174
|
}
|
|
6320
6175
|
/**
|
|
@@ -6330,7 +6185,7 @@ var WeChatClient = class extends AbstractClient {
|
|
|
6330
6185
|
* @returns A new WeChatClient instance
|
|
6331
6186
|
*/
|
|
6332
6187
|
createInstance(config) {
|
|
6333
|
-
return new
|
|
6188
|
+
return new _WeChatClient(config);
|
|
6334
6189
|
}
|
|
6335
6190
|
/**
|
|
6336
6191
|
* Implementation of the abstract makeRequest method for WeChat clients
|
|
@@ -6390,8 +6245,7 @@ var WeChatClient = class extends AbstractClient {
|
|
|
6390
6245
|
let pending = "";
|
|
6391
6246
|
const handleLine = (line) => {
|
|
6392
6247
|
const trimmed = line.trim();
|
|
6393
|
-
if (!trimmed.startsWith("data:"))
|
|
6394
|
-
return;
|
|
6248
|
+
if (!trimmed.startsWith("data:")) return;
|
|
6395
6249
|
const payload = trimmed.slice("data:".length);
|
|
6396
6250
|
const json = payload.startsWith(" ") ? payload.slice(1) : payload;
|
|
6397
6251
|
try {
|
|
@@ -6403,8 +6257,7 @@ var WeChatClient = class extends AbstractClient {
|
|
|
6403
6257
|
}
|
|
6404
6258
|
};
|
|
6405
6259
|
const push = (res) => {
|
|
6406
|
-
if (!res.data)
|
|
6407
|
-
return;
|
|
6260
|
+
if (!res.data) return;
|
|
6408
6261
|
pending += decoder.decode(res.data, { stream: true });
|
|
6409
6262
|
const lines = pending.split("\n");
|
|
6410
6263
|
pending = lines.pop();
|
|
@@ -6430,8 +6283,7 @@ var WeChatClient = class extends AbstractClient {
|
|
|
6430
6283
|
errorMessageFromBody(data) {
|
|
6431
6284
|
if (typeof data === "string") {
|
|
6432
6285
|
const text = data.trim();
|
|
6433
|
-
if (!text)
|
|
6434
|
-
return void 0;
|
|
6286
|
+
if (!text) return void 0;
|
|
6435
6287
|
try {
|
|
6436
6288
|
return this.recordMessage(JSON.parse(text));
|
|
6437
6289
|
} catch {
|
|
@@ -6459,8 +6311,7 @@ var WeChatClient = class extends AbstractClient {
|
|
|
6459
6311
|
*/
|
|
6460
6312
|
streamStatusError(res) {
|
|
6461
6313
|
const statusCode = res.statusCode;
|
|
6462
|
-
if (statusCode >= 200 && statusCode < 300)
|
|
6463
|
-
return void 0;
|
|
6314
|
+
if (statusCode >= 200 && statusCode < 300) return void 0;
|
|
6464
6315
|
const message = this.errorMessageFromBody(res.data);
|
|
6465
6316
|
if (statusCode === 401) {
|
|
6466
6317
|
return new AuthenticationError(message || "Authentication failed");
|
|
@@ -6510,26 +6361,22 @@ var WeChatClient = class extends AbstractClient {
|
|
|
6510
6361
|
responseType: "text",
|
|
6511
6362
|
enableChunked: true,
|
|
6512
6363
|
success: (res) => {
|
|
6513
|
-
if (aborted || terminal)
|
|
6514
|
-
return;
|
|
6364
|
+
if (aborted || terminal) return;
|
|
6515
6365
|
const error = this.streamStatusError(res);
|
|
6516
6366
|
if (error) {
|
|
6517
6367
|
terminal = true;
|
|
6518
|
-
if (onError)
|
|
6519
|
-
onError(error);
|
|
6368
|
+
if (onError) onError(error);
|
|
6520
6369
|
}
|
|
6521
6370
|
},
|
|
6522
6371
|
fail: (err) => {
|
|
6523
|
-
if (aborted)
|
|
6524
|
-
return;
|
|
6372
|
+
if (aborted) return;
|
|
6525
6373
|
terminal = true;
|
|
6526
6374
|
if (onError) {
|
|
6527
6375
|
onError(new Error(`Resume stream request failed: ${err.errMsg}`));
|
|
6528
6376
|
}
|
|
6529
6377
|
},
|
|
6530
6378
|
complete: () => {
|
|
6531
|
-
if (terminal)
|
|
6532
|
-
return;
|
|
6379
|
+
if (terminal) return;
|
|
6533
6380
|
processor.flush();
|
|
6534
6381
|
if (onComplete) {
|
|
6535
6382
|
onComplete();
|
|
@@ -6537,8 +6384,7 @@ var WeChatClient = class extends AbstractClient {
|
|
|
6537
6384
|
}
|
|
6538
6385
|
});
|
|
6539
6386
|
requestTask.onChunkReceived((res) => {
|
|
6540
|
-
if (terminal)
|
|
6541
|
-
return;
|
|
6387
|
+
if (terminal) return;
|
|
6542
6388
|
processor.push(res);
|
|
6543
6389
|
});
|
|
6544
6390
|
return () => {
|
|
@@ -6625,26 +6471,22 @@ var WeChatClient = class extends AbstractClient {
|
|
|
6625
6471
|
responseType: "text",
|
|
6626
6472
|
enableChunked: true,
|
|
6627
6473
|
success: (res) => {
|
|
6628
|
-
if (aborted || terminal)
|
|
6629
|
-
return;
|
|
6474
|
+
if (aborted || terminal) return;
|
|
6630
6475
|
const error = this.streamStatusError(res);
|
|
6631
6476
|
if (error) {
|
|
6632
6477
|
terminal = true;
|
|
6633
|
-
if (onError)
|
|
6634
|
-
onError(error);
|
|
6478
|
+
if (onError) onError(error);
|
|
6635
6479
|
}
|
|
6636
6480
|
},
|
|
6637
6481
|
fail: (err) => {
|
|
6638
|
-
if (aborted)
|
|
6639
|
-
return;
|
|
6482
|
+
if (aborted) return;
|
|
6640
6483
|
terminal = true;
|
|
6641
6484
|
if (onError) {
|
|
6642
6485
|
onError(new Error(`Stream request failed: ${err.errMsg}`));
|
|
6643
6486
|
}
|
|
6644
6487
|
},
|
|
6645
6488
|
complete: async () => {
|
|
6646
|
-
if (terminal)
|
|
6647
|
-
return;
|
|
6489
|
+
if (terminal) return;
|
|
6648
6490
|
processor.flush();
|
|
6649
6491
|
if (onComplete) {
|
|
6650
6492
|
if (options.enableReturnStateWhenSteamCompleted) {
|
|
@@ -6661,8 +6503,7 @@ var WeChatClient = class extends AbstractClient {
|
|
|
6661
6503
|
}
|
|
6662
6504
|
});
|
|
6663
6505
|
requestTask.onChunkReceived((res) => {
|
|
6664
|
-
if (terminal)
|
|
6665
|
-
return;
|
|
6506
|
+
if (terminal) return;
|
|
6666
6507
|
processor.push(res);
|
|
6667
6508
|
});
|
|
6668
6509
|
return () => {
|
|
@@ -6932,8 +6773,7 @@ var WorkspaceClient = class {
|
|
|
6932
6773
|
*/
|
|
6933
6774
|
async downloadFolder(workspaceId, projectId, folderPath, assistantId) {
|
|
6934
6775
|
const params = new URLSearchParams({ path: folderPath, tenantId: this.tenantId });
|
|
6935
|
-
if (assistantId)
|
|
6936
|
-
params.set("assistantId", assistantId);
|
|
6776
|
+
if (assistantId) params.set("assistantId", assistantId);
|
|
6937
6777
|
const response = await fetch(
|
|
6938
6778
|
`${this.baseURL}/api/workspaces/${workspaceId}/projects/${projectId}/downloadfolder?${params}`,
|
|
6939
6779
|
{ headers: this.headers }
|
|
@@ -6984,24 +6824,18 @@ var isObj = (v) => typeof v === "object" && v !== null;
|
|
|
6984
6824
|
var TEXT_BLOCK_TYPES = /* @__PURE__ */ new Set(["text"]);
|
|
6985
6825
|
var ARTIFACT_SENTINEL_TYPES = /* @__PURE__ */ new Set(["mcp_structured_content", "mcp_meta"]);
|
|
6986
6826
|
function asBlocks(value) {
|
|
6987
|
-
if (Array.isArray(value))
|
|
6988
|
-
|
|
6989
|
-
if (value === void 0 || value === null)
|
|
6990
|
-
return [];
|
|
6827
|
+
if (Array.isArray(value)) return value;
|
|
6828
|
+
if (value === void 0 || value === null) return [];
|
|
6991
6829
|
return [value];
|
|
6992
6830
|
}
|
|
6993
6831
|
function looksLikeResource(block) {
|
|
6994
6832
|
return typeof block.uri === "string" && ("mimeType" in block || "blob" in block || "text" in block);
|
|
6995
6833
|
}
|
|
6996
6834
|
function textOf(block, allowUntyped) {
|
|
6997
|
-
if (typeof block === "string")
|
|
6998
|
-
|
|
6999
|
-
if (
|
|
7000
|
-
|
|
7001
|
-
if (block.type === "text")
|
|
7002
|
-
return block.text;
|
|
7003
|
-
if (allowUntyped && block.type === void 0 && !looksLikeResource(block))
|
|
7004
|
-
return block.text;
|
|
6835
|
+
if (typeof block === "string") return block;
|
|
6836
|
+
if (!isObj(block) || typeof block.text !== "string") return null;
|
|
6837
|
+
if (block.type === "text") return block.text;
|
|
6838
|
+
if (allowUntyped && block.type === void 0 && !looksLikeResource(block)) return block.text;
|
|
7005
6839
|
return null;
|
|
7006
6840
|
}
|
|
7007
6841
|
function joinText(blocks, allowUntyped) {
|
|
@@ -7025,15 +6859,13 @@ function structuredFromArtifact(artifact) {
|
|
|
7025
6859
|
}
|
|
7026
6860
|
function metaFromContent(content) {
|
|
7027
6861
|
for (const block of asBlocks(content)) {
|
|
7028
|
-
if (isObj(block) && isObj(block.meta))
|
|
7029
|
-
return block.meta;
|
|
6862
|
+
if (isObj(block) && isObj(block.meta)) return block.meta;
|
|
7030
6863
|
}
|
|
7031
6864
|
return void 0;
|
|
7032
6865
|
}
|
|
7033
6866
|
function metaFromArtifact(artifact) {
|
|
7034
6867
|
for (const item of asBlocks(artifact)) {
|
|
7035
|
-
if (isObj(item) && item.type === "mcp_meta" && isObj(item.data))
|
|
7036
|
-
return item.data;
|
|
6868
|
+
if (isObj(item) && item.type === "mcp_meta" && isObj(item.data)) return item.data;
|
|
7037
6869
|
}
|
|
7038
6870
|
return void 0;
|
|
7039
6871
|
}
|
|
@@ -7061,22 +6893,17 @@ function normalizeToolResult(message) {
|
|
|
7061
6893
|
structuredContent = structuredFromArtifact(message.artifact);
|
|
7062
6894
|
}
|
|
7063
6895
|
let meta = metaFromContent(message.content);
|
|
7064
|
-
if (meta === void 0)
|
|
7065
|
-
meta = metaFromArtifact(message.artifact);
|
|
6896
|
+
if (meta === void 0) meta = metaFromArtifact(message.artifact);
|
|
7066
6897
|
const artifactBlocks = asBlocks(message.artifact).map(toUiBlock).filter(
|
|
7067
6898
|
(b) => b !== null && !ARTIFACT_SENTINEL_TYPES.has(b.type)
|
|
7068
6899
|
);
|
|
7069
6900
|
const allBlocks = [...contentBlocks, ...artifactBlocks];
|
|
7070
6901
|
let text = joinText(asBlocks(message.content), true);
|
|
7071
|
-
if (text.length === 0)
|
|
7072
|
-
text = joinText(asBlocks(message.artifact), false);
|
|
6902
|
+
if (text.length === 0) text = joinText(asBlocks(message.artifact), false);
|
|
7073
6903
|
const ui = {};
|
|
7074
|
-
if (structuredContent !== void 0)
|
|
7075
|
-
|
|
7076
|
-
if (
|
|
7077
|
-
ui.meta = meta;
|
|
7078
|
-
if (allBlocks.length > 0)
|
|
7079
|
-
ui.contentBlocks = allBlocks;
|
|
6904
|
+
if (structuredContent !== void 0) ui.structuredContent = structuredContent;
|
|
6905
|
+
if (meta !== void 0) ui.meta = meta;
|
|
6906
|
+
if (allBlocks.length > 0) ui.contentBlocks = allBlocks;
|
|
7080
6907
|
return Object.keys(ui).length > 0 ? { text, ui } : { text };
|
|
7081
6908
|
}
|
|
7082
6909
|
|
|
@@ -7140,16 +6967,14 @@ function createSimpleMessageMerger() {
|
|
|
7140
6967
|
}
|
|
7141
6968
|
function replaceMessage(id, updates) {
|
|
7142
6969
|
const index = messageMap.get(id);
|
|
7143
|
-
if (index === void 0)
|
|
7144
|
-
return null;
|
|
6970
|
+
if (index === void 0) return null;
|
|
7145
6971
|
const updated = { ...messages[index], ...updates };
|
|
7146
6972
|
messages[index] = updated;
|
|
7147
6973
|
return updated;
|
|
7148
6974
|
}
|
|
7149
6975
|
function buildToolCalls(messageId) {
|
|
7150
6976
|
const builders = toolBuilders.get(messageId);
|
|
7151
|
-
if (!builders || builders.size === 0)
|
|
7152
|
-
return null;
|
|
6977
|
+
if (!builders || builders.size === 0) return null;
|
|
7153
6978
|
const toolCalls = [];
|
|
7154
6979
|
for (const [, builder] of Array.from(builders.entries())) {
|
|
7155
6980
|
if (builder.name && builder.id) {
|
|
@@ -7172,8 +6997,7 @@ function createSimpleMessageMerger() {
|
|
|
7172
6997
|
});
|
|
7173
6998
|
}
|
|
7174
6999
|
function push(chunk) {
|
|
7175
|
-
if (chunk.type === "error")
|
|
7176
|
-
return;
|
|
7000
|
+
if (chunk.type === "error") return;
|
|
7177
7001
|
const role = normalizeRole(chunk.type);
|
|
7178
7002
|
let message = ensureMessage(chunk.data.id, role);
|
|
7179
7003
|
if (chunk.data.content && message.role !== "tool") {
|
|
@@ -7211,14 +7035,12 @@ function createSimpleMessageMerger() {
|
|
|
7211
7035
|
builder = { args: "" };
|
|
7212
7036
|
builders.set(chunk_item.index, builder);
|
|
7213
7037
|
}
|
|
7214
|
-
if (chunk_item.name)
|
|
7215
|
-
builder.name = chunk_item.name;
|
|
7038
|
+
if (chunk_item.name) builder.name = chunk_item.name;
|
|
7216
7039
|
if (chunk_item.id) {
|
|
7217
7040
|
builder.id = chunk_item.id;
|
|
7218
7041
|
toolId_MessageIdMap.set(chunk_item.id, message.id);
|
|
7219
7042
|
}
|
|
7220
|
-
if (chunk_item.args)
|
|
7221
|
-
builder.args += chunk_item.args;
|
|
7043
|
+
if (chunk_item.args) builder.args += chunk_item.args;
|
|
7222
7044
|
}
|
|
7223
7045
|
const toolCalls = buildToolCalls(message.id);
|
|
7224
7046
|
if (toolCalls) {
|
|
@@ -7228,8 +7050,7 @@ function createSimpleMessageMerger() {
|
|
|
7228
7050
|
if (message.role === "tool" && chunk.data.tool_call_id) {
|
|
7229
7051
|
const original_tool_message_id = chunk.data.id;
|
|
7230
7052
|
const messageId = toolId_MessageIdMap.get(chunk.data.tool_call_id);
|
|
7231
|
-
if (!messageId)
|
|
7232
|
-
return;
|
|
7053
|
+
if (!messageId) return;
|
|
7233
7054
|
const messageIndex = messageMap.get(messageId);
|
|
7234
7055
|
if (messageIndex !== void 0) {
|
|
7235
7056
|
const { text, ui } = normalizeToolResult({
|