@axiom-lattice/client-sdk 8.2.0 → 8.3.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 +14 -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 +260 -441
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +253 -434
- 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 +3 -0
- 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) {
|
|
@@ -4853,16 +4746,13 @@ function invalidResponse2(message) {
|
|
|
4853
4746
|
return new PlatformClientError(message, 500, "INVALID_RESPONSE", false);
|
|
4854
4747
|
}
|
|
4855
4748
|
function requiredString5(row, field) {
|
|
4856
|
-
if (typeof row[field] !== "string")
|
|
4857
|
-
throw invalidResponse2(`Invalid ${field}`);
|
|
4749
|
+
if (typeof row[field] !== "string") throw invalidResponse2(`Invalid ${field}`);
|
|
4858
4750
|
return row[field];
|
|
4859
4751
|
}
|
|
4860
4752
|
function optionalNullableString(row, field) {
|
|
4861
4753
|
const value = row[field];
|
|
4862
|
-
if (value === null || value === void 0)
|
|
4863
|
-
|
|
4864
|
-
if (typeof value !== "string")
|
|
4865
|
-
throw invalidResponse2(`Invalid ${field}`);
|
|
4754
|
+
if (value === null || value === void 0) return null;
|
|
4755
|
+
if (typeof value !== "string") throw invalidResponse2(`Invalid ${field}`);
|
|
4866
4756
|
return value;
|
|
4867
4757
|
}
|
|
4868
4758
|
function hydrateSettingsSnapshot(value) {
|
|
@@ -4895,23 +4785,22 @@ var BRANDING_TEXT_KEYS = [
|
|
|
4895
4785
|
"loginSubtitle"
|
|
4896
4786
|
];
|
|
4897
4787
|
function hydrateBranding(value) {
|
|
4898
|
-
if (!isRecord5(value))
|
|
4899
|
-
throw invalidResponse2("Invalid branding");
|
|
4788
|
+
if (!isRecord5(value)) throw invalidResponse2("Invalid branding");
|
|
4900
4789
|
const branding = {};
|
|
4901
4790
|
for (const key of BRANDING_TEXT_KEYS) {
|
|
4902
4791
|
const field = value[key];
|
|
4903
|
-
if (field === void 0)
|
|
4904
|
-
continue;
|
|
4792
|
+
if (field === void 0) continue;
|
|
4905
4793
|
if (typeof field !== "string") {
|
|
4906
4794
|
throw invalidResponse2(`Invalid branding.${key}`);
|
|
4907
4795
|
}
|
|
4908
4796
|
branding[key] = field;
|
|
4909
4797
|
}
|
|
4798
|
+
const customCss = optionalString(value, "customCss");
|
|
4799
|
+
if (customCss !== void 0) branding.customCss = customCss;
|
|
4910
4800
|
return branding;
|
|
4911
4801
|
}
|
|
4912
4802
|
function hydrateBrandingDomain(value) {
|
|
4913
|
-
if (!isRecord5(value))
|
|
4914
|
-
throw invalidResponse2("Invalid branding domain");
|
|
4803
|
+
if (!isRecord5(value)) throw invalidResponse2("Invalid branding domain");
|
|
4915
4804
|
const domain = { host: requiredString5(value, "host") };
|
|
4916
4805
|
if (value.status !== void 0) {
|
|
4917
4806
|
if (value.status !== "active" && value.status !== "pending") {
|
|
@@ -4933,8 +4822,7 @@ function hydrateBrandingDomain(value) {
|
|
|
4933
4822
|
return domain;
|
|
4934
4823
|
}
|
|
4935
4824
|
function hydrateBrandingSettings(value) {
|
|
4936
|
-
if (!isRecord5(value))
|
|
4937
|
-
throw invalidResponse2("Invalid branding settings");
|
|
4825
|
+
if (!isRecord5(value)) throw invalidResponse2("Invalid branding settings");
|
|
4938
4826
|
const settings = {};
|
|
4939
4827
|
if (value.default !== void 0) {
|
|
4940
4828
|
settings.default = hydrateBranding(value.default);
|
|
@@ -4983,8 +4871,7 @@ function hydrateTenantRole(value) {
|
|
|
4983
4871
|
throw invalidResponse2("Invalid tenant role");
|
|
4984
4872
|
}
|
|
4985
4873
|
function hydrateStatus(value) {
|
|
4986
|
-
if (value === null || value === void 0)
|
|
4987
|
-
return null;
|
|
4874
|
+
if (value === null || value === void 0) return null;
|
|
4988
4875
|
if (value === "active" || value === "pending" || value === "suspended") {
|
|
4989
4876
|
return value;
|
|
4990
4877
|
}
|
|
@@ -4992,15 +4879,12 @@ function hydrateStatus(value) {
|
|
|
4992
4879
|
}
|
|
4993
4880
|
function optionalString(row, field) {
|
|
4994
4881
|
const value = row[field];
|
|
4995
|
-
if (value === null || value === void 0)
|
|
4996
|
-
|
|
4997
|
-
if (typeof value !== "string")
|
|
4998
|
-
throw invalidResponse2(`Invalid ${field}`);
|
|
4882
|
+
if (value === null || value === void 0) return void 0;
|
|
4883
|
+
if (typeof value !== "string") throw invalidResponse2(`Invalid ${field}`);
|
|
4999
4884
|
return value;
|
|
5000
4885
|
}
|
|
5001
4886
|
function hydrateInvitation(value) {
|
|
5002
|
-
if (!isRecord5(value))
|
|
5003
|
-
throw invalidResponse2("Invalid invitation");
|
|
4887
|
+
if (!isRecord5(value)) throw invalidResponse2("Invalid invitation");
|
|
5004
4888
|
const invitedBy = optionalString(value, "invitedBy");
|
|
5005
4889
|
const expiresAt = optionalString(value, "expiresAt");
|
|
5006
4890
|
const consumedAt = optionalString(value, "consumedAt");
|
|
@@ -5014,8 +4898,7 @@ function hydrateInvitation(value) {
|
|
|
5014
4898
|
};
|
|
5015
4899
|
}
|
|
5016
4900
|
function hydrateMember3(value) {
|
|
5017
|
-
if (!isRecord5(value))
|
|
5018
|
-
throw invalidResponse2("Invalid platform member");
|
|
4901
|
+
if (!isRecord5(value)) throw invalidResponse2("Invalid platform member");
|
|
5019
4902
|
return {
|
|
5020
4903
|
id: requiredString5(value, "id"),
|
|
5021
4904
|
email: optionalNullableString(value, "email"),
|
|
@@ -5027,8 +4910,7 @@ function hydrateMember3(value) {
|
|
|
5027
4910
|
};
|
|
5028
4911
|
}
|
|
5029
4912
|
function hydrateTenantMember(value) {
|
|
5030
|
-
if (!isRecord5(value))
|
|
5031
|
-
throw invalidResponse2("Invalid tenant member");
|
|
4913
|
+
if (!isRecord5(value)) throw invalidResponse2("Invalid tenant member");
|
|
5032
4914
|
return {
|
|
5033
4915
|
userId: requiredString5(value, "userId"),
|
|
5034
4916
|
tenantId: requiredString5(value, "tenantId"),
|
|
@@ -5046,8 +4928,7 @@ function hydrateOidcIdentityClaimStatus(value) {
|
|
|
5046
4928
|
throw invalidResponse2("Invalid SSO claim status");
|
|
5047
4929
|
}
|
|
5048
4930
|
function hydrateOidcIdentityClaim(value) {
|
|
5049
|
-
if (!isRecord5(value))
|
|
5050
|
-
throw invalidResponse2("Invalid SSO claim");
|
|
4931
|
+
if (!isRecord5(value)) throw invalidResponse2("Invalid SSO claim");
|
|
5051
4932
|
const name = optionalString(value, "name");
|
|
5052
4933
|
const picture = optionalString(value, "picture");
|
|
5053
4934
|
const reviewedBy = optionalString(value, "reviewedBy");
|
|
@@ -5062,8 +4943,7 @@ function hydrateOidcIdentityClaim(value) {
|
|
|
5062
4943
|
const existing = value.existingUser;
|
|
5063
4944
|
let existingUser;
|
|
5064
4945
|
if (existing !== void 0 && existing !== null) {
|
|
5065
|
-
if (!isRecord5(existing))
|
|
5066
|
-
throw invalidResponse2("Invalid existing user");
|
|
4946
|
+
if (!isRecord5(existing)) throw invalidResponse2("Invalid existing user");
|
|
5067
4947
|
const platformRole = existing.role !== void 0 ? hydratePlatformRole(existing.role) : existing.platformRole !== void 0 ? hydratePlatformRole(existing.platformRole) : void 0;
|
|
5068
4948
|
existingUser = {
|
|
5069
4949
|
id: requiredString5(existing, "id"),
|
|
@@ -5105,15 +4985,12 @@ function hydrateTenantStatus(value) {
|
|
|
5105
4985
|
}
|
|
5106
4986
|
function optionalRecord(row, field) {
|
|
5107
4987
|
const value = row[field];
|
|
5108
|
-
if (value === void 0 || value === null)
|
|
5109
|
-
|
|
5110
|
-
if (!isRecord5(value))
|
|
5111
|
-
throw invalidResponse2(`Invalid ${field}`);
|
|
4988
|
+
if (value === void 0 || value === null) return void 0;
|
|
4989
|
+
if (!isRecord5(value)) throw invalidResponse2(`Invalid ${field}`);
|
|
5112
4990
|
return value;
|
|
5113
4991
|
}
|
|
5114
4992
|
function hydrateInviteLink(value) {
|
|
5115
|
-
if (!isRecord5(value))
|
|
5116
|
-
throw invalidResponse2("Invalid invite link");
|
|
4993
|
+
if (!isRecord5(value)) throw invalidResponse2("Invalid invite link");
|
|
5117
4994
|
const scope = value.scope;
|
|
5118
4995
|
if (scope !== "platform" && scope !== "tenant") {
|
|
5119
4996
|
throw invalidResponse2("Invalid invite scope");
|
|
@@ -5139,8 +5016,7 @@ function hydrateInviteLink(value) {
|
|
|
5139
5016
|
};
|
|
5140
5017
|
}
|
|
5141
5018
|
function hydrateTenant(value) {
|
|
5142
|
-
if (!isRecord5(value))
|
|
5143
|
-
throw invalidResponse2("Invalid tenant");
|
|
5019
|
+
if (!isRecord5(value)) throw invalidResponse2("Invalid tenant");
|
|
5144
5020
|
const metadata = optionalRecord(value, "metadata");
|
|
5145
5021
|
return {
|
|
5146
5022
|
id: requiredString5(value, "id"),
|
|
@@ -5153,8 +5029,7 @@ function hydrateTenant(value) {
|
|
|
5153
5029
|
};
|
|
5154
5030
|
}
|
|
5155
5031
|
function hydrateUser(value) {
|
|
5156
|
-
if (!isRecord5(value))
|
|
5157
|
-
throw invalidResponse2("Invalid user");
|
|
5032
|
+
if (!isRecord5(value)) throw invalidResponse2("Invalid user");
|
|
5158
5033
|
const status = value.status;
|
|
5159
5034
|
if (status !== "active" && status !== "pending" && status !== "suspended") {
|
|
5160
5035
|
throw invalidResponse2("Invalid user status");
|
|
@@ -5231,8 +5106,7 @@ function hydrateAuditSource(value) {
|
|
|
5231
5106
|
throw invalidResponse2("Invalid platform audit source");
|
|
5232
5107
|
}
|
|
5233
5108
|
function hydrateAuditAction(value) {
|
|
5234
|
-
if (value === "write" || value === "playbook")
|
|
5235
|
-
return value;
|
|
5109
|
+
if (value === "write" || value === "playbook") return value;
|
|
5236
5110
|
throw invalidResponse2("Invalid platform audit action");
|
|
5237
5111
|
}
|
|
5238
5112
|
function hydrateAuditStatus(value) {
|
|
@@ -5281,8 +5155,7 @@ function hydratePlatformAudit(value) {
|
|
|
5281
5155
|
};
|
|
5282
5156
|
}
|
|
5283
5157
|
function requireRecordValue(value, message) {
|
|
5284
|
-
if (!isRecord5(value))
|
|
5285
|
-
throw invalidResponse2(message);
|
|
5158
|
+
if (!isRecord5(value)) throw invalidResponse2(message);
|
|
5286
5159
|
return value;
|
|
5287
5160
|
}
|
|
5288
5161
|
function hydrateModelCatalog(value) {
|
|
@@ -5432,10 +5305,8 @@ var PlatformClient = class {
|
|
|
5432
5305
|
}
|
|
5433
5306
|
async me() {
|
|
5434
5307
|
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;
|
|
5308
|
+
if (!isRecord5(data)) throw invalidResponse2("Invalid platform identity");
|
|
5309
|
+
if (data.role === null || data.role === void 0) return null;
|
|
5439
5310
|
return hydratePlatformRole(data.role);
|
|
5440
5311
|
}
|
|
5441
5312
|
/**
|
|
@@ -5496,8 +5367,7 @@ var PlatformClient = class {
|
|
|
5496
5367
|
async listAudit(query = {}) {
|
|
5497
5368
|
const search = new URLSearchParams();
|
|
5498
5369
|
for (const [key, value] of Object.entries(query)) {
|
|
5499
|
-
if (value !== void 0)
|
|
5500
|
-
search.set(key, String(value));
|
|
5370
|
+
if (value !== void 0) search.set(key, String(value));
|
|
5501
5371
|
}
|
|
5502
5372
|
const suffix = search.toString();
|
|
5503
5373
|
const data = await this.request(
|
|
@@ -5550,8 +5420,7 @@ var PlatformClient = class {
|
|
|
5550
5420
|
}
|
|
5551
5421
|
async listTenants() {
|
|
5552
5422
|
const data = await this.request("/api/tenants");
|
|
5553
|
-
if (!Array.isArray(data))
|
|
5554
|
-
throw invalidResponse2("Invalid tenant list");
|
|
5423
|
+
if (!Array.isArray(data)) throw invalidResponse2("Invalid tenant list");
|
|
5555
5424
|
return data.map(hydrateTenant);
|
|
5556
5425
|
}
|
|
5557
5426
|
async createTenant(input) {
|
|
@@ -5576,8 +5445,7 @@ var PlatformClient = class {
|
|
|
5576
5445
|
}
|
|
5577
5446
|
async listUsers() {
|
|
5578
5447
|
const data = await this.request("/api/users");
|
|
5579
|
-
if (!Array.isArray(data))
|
|
5580
|
-
throw invalidResponse2("Invalid user list");
|
|
5448
|
+
if (!Array.isArray(data)) throw invalidResponse2("Invalid user list");
|
|
5581
5449
|
return data.map(hydrateUser);
|
|
5582
5450
|
}
|
|
5583
5451
|
async createUser(input) {
|
|
@@ -5601,8 +5469,7 @@ var PlatformClient = class {
|
|
|
5601
5469
|
}
|
|
5602
5470
|
async listMembers() {
|
|
5603
5471
|
const data = await this.request("/api/platform/members");
|
|
5604
|
-
if (!Array.isArray(data))
|
|
5605
|
-
throw invalidResponse2("Invalid member list");
|
|
5472
|
+
if (!Array.isArray(data)) throw invalidResponse2("Invalid member list");
|
|
5606
5473
|
return data.map(hydrateMember3);
|
|
5607
5474
|
}
|
|
5608
5475
|
async grantMember(input) {
|
|
@@ -5610,8 +5477,7 @@ var PlatformClient = class {
|
|
|
5610
5477
|
method: "POST",
|
|
5611
5478
|
body: JSON.stringify(input)
|
|
5612
5479
|
});
|
|
5613
|
-
if (!isRecord5(data))
|
|
5614
|
-
throw invalidResponse2("Invalid platform grant");
|
|
5480
|
+
if (!isRecord5(data)) throw invalidResponse2("Invalid platform grant");
|
|
5615
5481
|
const member = data.member !== void 0 ? hydrateMember3(data.member) : void 0;
|
|
5616
5482
|
const invitation = data.invitation !== void 0 ? hydrateInvitation(data.invitation) : void 0;
|
|
5617
5483
|
if (!member && !invitation) {
|
|
@@ -5624,8 +5490,7 @@ var PlatformClient = class {
|
|
|
5624
5490
|
}
|
|
5625
5491
|
async listInvitations() {
|
|
5626
5492
|
const data = await this.request("/api/platform/invitations");
|
|
5627
|
-
if (!Array.isArray(data))
|
|
5628
|
-
throw invalidResponse2("Invalid invitation list");
|
|
5493
|
+
if (!Array.isArray(data)) throw invalidResponse2("Invalid invitation list");
|
|
5629
5494
|
return data.map(hydrateInvitation);
|
|
5630
5495
|
}
|
|
5631
5496
|
async revokeInvitation(email) {
|
|
@@ -5652,8 +5517,7 @@ var PlatformClient = class {
|
|
|
5652
5517
|
const data = await this.request(
|
|
5653
5518
|
`/api/platform/tenant-members?${query}`
|
|
5654
5519
|
);
|
|
5655
|
-
if (!Array.isArray(data))
|
|
5656
|
-
throw invalidResponse2("Invalid tenant member list");
|
|
5520
|
+
if (!Array.isArray(data)) throw invalidResponse2("Invalid tenant member list");
|
|
5657
5521
|
return data.map(hydrateTenantMember);
|
|
5658
5522
|
}
|
|
5659
5523
|
async addTenantMember(input) {
|
|
@@ -5665,8 +5529,7 @@ var PlatformClient = class {
|
|
|
5665
5529
|
}
|
|
5666
5530
|
async listInviteLinks() {
|
|
5667
5531
|
const data = await this.request("/api/platform/invite-links");
|
|
5668
|
-
if (!Array.isArray(data))
|
|
5669
|
-
throw invalidResponse2("Invalid invite link list");
|
|
5532
|
+
if (!Array.isArray(data)) throw invalidResponse2("Invalid invite link list");
|
|
5670
5533
|
return data.map(hydrateInviteLink);
|
|
5671
5534
|
}
|
|
5672
5535
|
async createInviteLink(input) {
|
|
@@ -5725,8 +5588,7 @@ var PlatformClient = class {
|
|
|
5725
5588
|
async listOidcClaims(status = "pending") {
|
|
5726
5589
|
const query = new URLSearchParams({ status }).toString();
|
|
5727
5590
|
const data = await this.request(`/api/platform/oidc-claims?${query}`);
|
|
5728
|
-
if (!Array.isArray(data))
|
|
5729
|
-
throw invalidResponse2("Invalid SSO claim list");
|
|
5591
|
+
if (!Array.isArray(data)) throw invalidResponse2("Invalid SSO claim list");
|
|
5730
5592
|
return data.map(hydrateOidcIdentityClaim);
|
|
5731
5593
|
}
|
|
5732
5594
|
async updateOidcClaimEmail(id, email) {
|
|
@@ -5771,7 +5633,7 @@ var PlatformClient = class {
|
|
|
5771
5633
|
};
|
|
5772
5634
|
|
|
5773
5635
|
// src/client.ts
|
|
5774
|
-
var _Client = class extends AbstractClient {
|
|
5636
|
+
var _Client = class _Client extends AbstractClient {
|
|
5775
5637
|
/**
|
|
5776
5638
|
* Creates a new Client instance
|
|
5777
5639
|
* @param config - Configuration options for the client
|
|
@@ -6074,8 +5936,7 @@ var _Client = class extends AbstractClient {
|
|
|
6074
5936
|
...this.getAllHeaders()
|
|
6075
5937
|
};
|
|
6076
5938
|
const res = await fetch(`${this.config.baseURL}${path}`, { headers, signal });
|
|
6077
|
-
if (!res.ok || !res.body)
|
|
6078
|
-
throw new Error("Stream connection failed");
|
|
5939
|
+
if (!res.ok || !res.body) throw new Error("Stream connection failed");
|
|
6079
5940
|
try {
|
|
6080
5941
|
for await (const frame of parseSseBody(res.body, { strictJsonObject: true })) {
|
|
6081
5942
|
yield { event: frame.event, data: frame.data };
|
|
@@ -6104,8 +5965,7 @@ var _Client = class extends AbstractClient {
|
|
|
6104
5965
|
return this.getAllHeaders();
|
|
6105
5966
|
}
|
|
6106
5967
|
bodyAffinityHeaders(body) {
|
|
6107
|
-
if (!body || typeof body !== "object" || body instanceof FormData)
|
|
6108
|
-
return {};
|
|
5968
|
+
if (!body || typeof body !== "object" || body instanceof FormData) return {};
|
|
6109
5969
|
const threadId = body.thread_id;
|
|
6110
5970
|
return typeof threadId === "string" ? threadAffinityHeaders2(threadId) : {};
|
|
6111
5971
|
}
|
|
@@ -6139,8 +5999,7 @@ var _Client = class extends AbstractClient {
|
|
|
6139
5999
|
if (!response.body) {
|
|
6140
6000
|
throw new Error("Response body is null");
|
|
6141
6001
|
}
|
|
6142
|
-
for await (const frame of parseSseBody(response.body, { strictJsonObject: true }))
|
|
6143
|
-
onEvent(frame.data);
|
|
6002
|
+
for await (const frame of parseSseBody(response.body, { strictJsonObject: true })) onEvent(frame.data);
|
|
6144
6003
|
if (onComplete) {
|
|
6145
6004
|
if (options.enableReturnStateWhenSteamCompleted) {
|
|
6146
6005
|
try {
|
|
@@ -6167,11 +6026,11 @@ var _Client = class extends AbstractClient {
|
|
|
6167
6026
|
};
|
|
6168
6027
|
}
|
|
6169
6028
|
};
|
|
6029
|
+
_Client.globalWorkspaceHeaders = {};
|
|
6170
6030
|
var Client = _Client;
|
|
6171
|
-
Client.globalWorkspaceHeaders = {};
|
|
6172
6031
|
|
|
6173
6032
|
// src/runtime-client.ts
|
|
6174
|
-
var RuntimeAxiomClient = class extends Client {
|
|
6033
|
+
var RuntimeAxiomClient = class _RuntimeAxiomClient extends Client {
|
|
6175
6034
|
constructor(config) {
|
|
6176
6035
|
super({
|
|
6177
6036
|
...config,
|
|
@@ -6198,8 +6057,7 @@ var RuntimeAxiomClient = class extends Client {
|
|
|
6198
6057
|
* priming — the first request triggers the token provider.
|
|
6199
6058
|
*/
|
|
6200
6059
|
async primeToken() {
|
|
6201
|
-
if (this.identity.mode !== "verified")
|
|
6202
|
-
return "";
|
|
6060
|
+
if (this.identity.mode !== "verified") return "";
|
|
6203
6061
|
if (!this.tokenPromise) {
|
|
6204
6062
|
this.tokenPromise = this.identity.tokenProvider().then((token) => {
|
|
6205
6063
|
this.token = token;
|
|
@@ -6248,8 +6106,7 @@ var RuntimeAxiomClient = class extends Client {
|
|
|
6248
6106
|
error.status = response.status;
|
|
6249
6107
|
throw error;
|
|
6250
6108
|
}
|
|
6251
|
-
if (response.status === 204)
|
|
6252
|
-
return void 0;
|
|
6109
|
+
if (response.status === 204) return void 0;
|
|
6253
6110
|
return await response.json();
|
|
6254
6111
|
}
|
|
6255
6112
|
getBaseUrl() {
|
|
@@ -6261,7 +6118,7 @@ var RuntimeAxiomClient = class extends Client {
|
|
|
6261
6118
|
* working (each clone carries its own resolved credential cache).
|
|
6262
6119
|
*/
|
|
6263
6120
|
createInstance(config) {
|
|
6264
|
-
return new
|
|
6121
|
+
return new _RuntimeAxiomClient({
|
|
6265
6122
|
gatewayUrl: this.gatewayUrl,
|
|
6266
6123
|
webAppId: this.webAppId,
|
|
6267
6124
|
identity: this.identity,
|
|
@@ -6280,7 +6137,7 @@ var RuntimeAxiomClient = class extends Client {
|
|
|
6280
6137
|
// src/wechat-client.ts
|
|
6281
6138
|
import { threadAffinityHeaders as threadAffinityHeaders3 } from "@axiom-lattice/protocols";
|
|
6282
6139
|
var import_encoding = __toESM(require_encoding());
|
|
6283
|
-
var WeChatClient = class extends AbstractClient {
|
|
6140
|
+
var WeChatClient = class _WeChatClient extends AbstractClient {
|
|
6284
6141
|
/**
|
|
6285
6142
|
* Creates a new WeChatClient instance
|
|
6286
6143
|
* @param config - Configuration options for the client
|
|
@@ -6305,16 +6162,12 @@ var WeChatClient = class extends AbstractClient {
|
|
|
6305
6162
|
*/
|
|
6306
6163
|
setWorkspaceContext(workspaceId, projectId) {
|
|
6307
6164
|
if (workspaceId !== void 0) {
|
|
6308
|
-
if (workspaceId)
|
|
6309
|
-
|
|
6310
|
-
else
|
|
6311
|
-
delete this.workspaceHeaders["x-workspace-id"];
|
|
6165
|
+
if (workspaceId) this.workspaceHeaders["x-workspace-id"] = workspaceId;
|
|
6166
|
+
else delete this.workspaceHeaders["x-workspace-id"];
|
|
6312
6167
|
}
|
|
6313
6168
|
if (projectId !== void 0) {
|
|
6314
|
-
if (projectId)
|
|
6315
|
-
|
|
6316
|
-
else
|
|
6317
|
-
delete this.workspaceHeaders["x-project-id"];
|
|
6169
|
+
if (projectId) this.workspaceHeaders["x-project-id"] = projectId;
|
|
6170
|
+
else delete this.workspaceHeaders["x-project-id"];
|
|
6318
6171
|
}
|
|
6319
6172
|
}
|
|
6320
6173
|
/**
|
|
@@ -6330,7 +6183,7 @@ var WeChatClient = class extends AbstractClient {
|
|
|
6330
6183
|
* @returns A new WeChatClient instance
|
|
6331
6184
|
*/
|
|
6332
6185
|
createInstance(config) {
|
|
6333
|
-
return new
|
|
6186
|
+
return new _WeChatClient(config);
|
|
6334
6187
|
}
|
|
6335
6188
|
/**
|
|
6336
6189
|
* Implementation of the abstract makeRequest method for WeChat clients
|
|
@@ -6390,8 +6243,7 @@ var WeChatClient = class extends AbstractClient {
|
|
|
6390
6243
|
let pending = "";
|
|
6391
6244
|
const handleLine = (line) => {
|
|
6392
6245
|
const trimmed = line.trim();
|
|
6393
|
-
if (!trimmed.startsWith("data:"))
|
|
6394
|
-
return;
|
|
6246
|
+
if (!trimmed.startsWith("data:")) return;
|
|
6395
6247
|
const payload = trimmed.slice("data:".length);
|
|
6396
6248
|
const json = payload.startsWith(" ") ? payload.slice(1) : payload;
|
|
6397
6249
|
try {
|
|
@@ -6403,8 +6255,7 @@ var WeChatClient = class extends AbstractClient {
|
|
|
6403
6255
|
}
|
|
6404
6256
|
};
|
|
6405
6257
|
const push = (res) => {
|
|
6406
|
-
if (!res.data)
|
|
6407
|
-
return;
|
|
6258
|
+
if (!res.data) return;
|
|
6408
6259
|
pending += decoder.decode(res.data, { stream: true });
|
|
6409
6260
|
const lines = pending.split("\n");
|
|
6410
6261
|
pending = lines.pop();
|
|
@@ -6430,8 +6281,7 @@ var WeChatClient = class extends AbstractClient {
|
|
|
6430
6281
|
errorMessageFromBody(data) {
|
|
6431
6282
|
if (typeof data === "string") {
|
|
6432
6283
|
const text = data.trim();
|
|
6433
|
-
if (!text)
|
|
6434
|
-
return void 0;
|
|
6284
|
+
if (!text) return void 0;
|
|
6435
6285
|
try {
|
|
6436
6286
|
return this.recordMessage(JSON.parse(text));
|
|
6437
6287
|
} catch {
|
|
@@ -6459,8 +6309,7 @@ var WeChatClient = class extends AbstractClient {
|
|
|
6459
6309
|
*/
|
|
6460
6310
|
streamStatusError(res) {
|
|
6461
6311
|
const statusCode = res.statusCode;
|
|
6462
|
-
if (statusCode >= 200 && statusCode < 300)
|
|
6463
|
-
return void 0;
|
|
6312
|
+
if (statusCode >= 200 && statusCode < 300) return void 0;
|
|
6464
6313
|
const message = this.errorMessageFromBody(res.data);
|
|
6465
6314
|
if (statusCode === 401) {
|
|
6466
6315
|
return new AuthenticationError(message || "Authentication failed");
|
|
@@ -6510,26 +6359,22 @@ var WeChatClient = class extends AbstractClient {
|
|
|
6510
6359
|
responseType: "text",
|
|
6511
6360
|
enableChunked: true,
|
|
6512
6361
|
success: (res) => {
|
|
6513
|
-
if (aborted || terminal)
|
|
6514
|
-
return;
|
|
6362
|
+
if (aborted || terminal) return;
|
|
6515
6363
|
const error = this.streamStatusError(res);
|
|
6516
6364
|
if (error) {
|
|
6517
6365
|
terminal = true;
|
|
6518
|
-
if (onError)
|
|
6519
|
-
onError(error);
|
|
6366
|
+
if (onError) onError(error);
|
|
6520
6367
|
}
|
|
6521
6368
|
},
|
|
6522
6369
|
fail: (err) => {
|
|
6523
|
-
if (aborted)
|
|
6524
|
-
return;
|
|
6370
|
+
if (aborted) return;
|
|
6525
6371
|
terminal = true;
|
|
6526
6372
|
if (onError) {
|
|
6527
6373
|
onError(new Error(`Resume stream request failed: ${err.errMsg}`));
|
|
6528
6374
|
}
|
|
6529
6375
|
},
|
|
6530
6376
|
complete: () => {
|
|
6531
|
-
if (terminal)
|
|
6532
|
-
return;
|
|
6377
|
+
if (terminal) return;
|
|
6533
6378
|
processor.flush();
|
|
6534
6379
|
if (onComplete) {
|
|
6535
6380
|
onComplete();
|
|
@@ -6537,8 +6382,7 @@ var WeChatClient = class extends AbstractClient {
|
|
|
6537
6382
|
}
|
|
6538
6383
|
});
|
|
6539
6384
|
requestTask.onChunkReceived((res) => {
|
|
6540
|
-
if (terminal)
|
|
6541
|
-
return;
|
|
6385
|
+
if (terminal) return;
|
|
6542
6386
|
processor.push(res);
|
|
6543
6387
|
});
|
|
6544
6388
|
return () => {
|
|
@@ -6625,26 +6469,22 @@ var WeChatClient = class extends AbstractClient {
|
|
|
6625
6469
|
responseType: "text",
|
|
6626
6470
|
enableChunked: true,
|
|
6627
6471
|
success: (res) => {
|
|
6628
|
-
if (aborted || terminal)
|
|
6629
|
-
return;
|
|
6472
|
+
if (aborted || terminal) return;
|
|
6630
6473
|
const error = this.streamStatusError(res);
|
|
6631
6474
|
if (error) {
|
|
6632
6475
|
terminal = true;
|
|
6633
|
-
if (onError)
|
|
6634
|
-
onError(error);
|
|
6476
|
+
if (onError) onError(error);
|
|
6635
6477
|
}
|
|
6636
6478
|
},
|
|
6637
6479
|
fail: (err) => {
|
|
6638
|
-
if (aborted)
|
|
6639
|
-
return;
|
|
6480
|
+
if (aborted) return;
|
|
6640
6481
|
terminal = true;
|
|
6641
6482
|
if (onError) {
|
|
6642
6483
|
onError(new Error(`Stream request failed: ${err.errMsg}`));
|
|
6643
6484
|
}
|
|
6644
6485
|
},
|
|
6645
6486
|
complete: async () => {
|
|
6646
|
-
if (terminal)
|
|
6647
|
-
return;
|
|
6487
|
+
if (terminal) return;
|
|
6648
6488
|
processor.flush();
|
|
6649
6489
|
if (onComplete) {
|
|
6650
6490
|
if (options.enableReturnStateWhenSteamCompleted) {
|
|
@@ -6661,8 +6501,7 @@ var WeChatClient = class extends AbstractClient {
|
|
|
6661
6501
|
}
|
|
6662
6502
|
});
|
|
6663
6503
|
requestTask.onChunkReceived((res) => {
|
|
6664
|
-
if (terminal)
|
|
6665
|
-
return;
|
|
6504
|
+
if (terminal) return;
|
|
6666
6505
|
processor.push(res);
|
|
6667
6506
|
});
|
|
6668
6507
|
return () => {
|
|
@@ -6932,8 +6771,7 @@ var WorkspaceClient = class {
|
|
|
6932
6771
|
*/
|
|
6933
6772
|
async downloadFolder(workspaceId, projectId, folderPath, assistantId) {
|
|
6934
6773
|
const params = new URLSearchParams({ path: folderPath, tenantId: this.tenantId });
|
|
6935
|
-
if (assistantId)
|
|
6936
|
-
params.set("assistantId", assistantId);
|
|
6774
|
+
if (assistantId) params.set("assistantId", assistantId);
|
|
6937
6775
|
const response = await fetch(
|
|
6938
6776
|
`${this.baseURL}/api/workspaces/${workspaceId}/projects/${projectId}/downloadfolder?${params}`,
|
|
6939
6777
|
{ headers: this.headers }
|
|
@@ -6984,24 +6822,18 @@ var isObj = (v) => typeof v === "object" && v !== null;
|
|
|
6984
6822
|
var TEXT_BLOCK_TYPES = /* @__PURE__ */ new Set(["text"]);
|
|
6985
6823
|
var ARTIFACT_SENTINEL_TYPES = /* @__PURE__ */ new Set(["mcp_structured_content", "mcp_meta"]);
|
|
6986
6824
|
function asBlocks(value) {
|
|
6987
|
-
if (Array.isArray(value))
|
|
6988
|
-
|
|
6989
|
-
if (value === void 0 || value === null)
|
|
6990
|
-
return [];
|
|
6825
|
+
if (Array.isArray(value)) return value;
|
|
6826
|
+
if (value === void 0 || value === null) return [];
|
|
6991
6827
|
return [value];
|
|
6992
6828
|
}
|
|
6993
6829
|
function looksLikeResource(block) {
|
|
6994
6830
|
return typeof block.uri === "string" && ("mimeType" in block || "blob" in block || "text" in block);
|
|
6995
6831
|
}
|
|
6996
6832
|
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;
|
|
6833
|
+
if (typeof block === "string") return block;
|
|
6834
|
+
if (!isObj(block) || typeof block.text !== "string") return null;
|
|
6835
|
+
if (block.type === "text") return block.text;
|
|
6836
|
+
if (allowUntyped && block.type === void 0 && !looksLikeResource(block)) return block.text;
|
|
7005
6837
|
return null;
|
|
7006
6838
|
}
|
|
7007
6839
|
function joinText(blocks, allowUntyped) {
|
|
@@ -7025,15 +6857,13 @@ function structuredFromArtifact(artifact) {
|
|
|
7025
6857
|
}
|
|
7026
6858
|
function metaFromContent(content) {
|
|
7027
6859
|
for (const block of asBlocks(content)) {
|
|
7028
|
-
if (isObj(block) && isObj(block.meta))
|
|
7029
|
-
return block.meta;
|
|
6860
|
+
if (isObj(block) && isObj(block.meta)) return block.meta;
|
|
7030
6861
|
}
|
|
7031
6862
|
return void 0;
|
|
7032
6863
|
}
|
|
7033
6864
|
function metaFromArtifact(artifact) {
|
|
7034
6865
|
for (const item of asBlocks(artifact)) {
|
|
7035
|
-
if (isObj(item) && item.type === "mcp_meta" && isObj(item.data))
|
|
7036
|
-
return item.data;
|
|
6866
|
+
if (isObj(item) && item.type === "mcp_meta" && isObj(item.data)) return item.data;
|
|
7037
6867
|
}
|
|
7038
6868
|
return void 0;
|
|
7039
6869
|
}
|
|
@@ -7061,22 +6891,17 @@ function normalizeToolResult(message) {
|
|
|
7061
6891
|
structuredContent = structuredFromArtifact(message.artifact);
|
|
7062
6892
|
}
|
|
7063
6893
|
let meta = metaFromContent(message.content);
|
|
7064
|
-
if (meta === void 0)
|
|
7065
|
-
meta = metaFromArtifact(message.artifact);
|
|
6894
|
+
if (meta === void 0) meta = metaFromArtifact(message.artifact);
|
|
7066
6895
|
const artifactBlocks = asBlocks(message.artifact).map(toUiBlock).filter(
|
|
7067
6896
|
(b) => b !== null && !ARTIFACT_SENTINEL_TYPES.has(b.type)
|
|
7068
6897
|
);
|
|
7069
6898
|
const allBlocks = [...contentBlocks, ...artifactBlocks];
|
|
7070
6899
|
let text = joinText(asBlocks(message.content), true);
|
|
7071
|
-
if (text.length === 0)
|
|
7072
|
-
text = joinText(asBlocks(message.artifact), false);
|
|
6900
|
+
if (text.length === 0) text = joinText(asBlocks(message.artifact), false);
|
|
7073
6901
|
const ui = {};
|
|
7074
|
-
if (structuredContent !== void 0)
|
|
7075
|
-
|
|
7076
|
-
if (
|
|
7077
|
-
ui.meta = meta;
|
|
7078
|
-
if (allBlocks.length > 0)
|
|
7079
|
-
ui.contentBlocks = allBlocks;
|
|
6902
|
+
if (structuredContent !== void 0) ui.structuredContent = structuredContent;
|
|
6903
|
+
if (meta !== void 0) ui.meta = meta;
|
|
6904
|
+
if (allBlocks.length > 0) ui.contentBlocks = allBlocks;
|
|
7080
6905
|
return Object.keys(ui).length > 0 ? { text, ui } : { text };
|
|
7081
6906
|
}
|
|
7082
6907
|
|
|
@@ -7140,16 +6965,14 @@ function createSimpleMessageMerger() {
|
|
|
7140
6965
|
}
|
|
7141
6966
|
function replaceMessage(id, updates) {
|
|
7142
6967
|
const index = messageMap.get(id);
|
|
7143
|
-
if (index === void 0)
|
|
7144
|
-
return null;
|
|
6968
|
+
if (index === void 0) return null;
|
|
7145
6969
|
const updated = { ...messages[index], ...updates };
|
|
7146
6970
|
messages[index] = updated;
|
|
7147
6971
|
return updated;
|
|
7148
6972
|
}
|
|
7149
6973
|
function buildToolCalls(messageId) {
|
|
7150
6974
|
const builders = toolBuilders.get(messageId);
|
|
7151
|
-
if (!builders || builders.size === 0)
|
|
7152
|
-
return null;
|
|
6975
|
+
if (!builders || builders.size === 0) return null;
|
|
7153
6976
|
const toolCalls = [];
|
|
7154
6977
|
for (const [, builder] of Array.from(builders.entries())) {
|
|
7155
6978
|
if (builder.name && builder.id) {
|
|
@@ -7172,8 +6995,7 @@ function createSimpleMessageMerger() {
|
|
|
7172
6995
|
});
|
|
7173
6996
|
}
|
|
7174
6997
|
function push(chunk) {
|
|
7175
|
-
if (chunk.type === "error")
|
|
7176
|
-
return;
|
|
6998
|
+
if (chunk.type === "error") return;
|
|
7177
6999
|
const role = normalizeRole(chunk.type);
|
|
7178
7000
|
let message = ensureMessage(chunk.data.id, role);
|
|
7179
7001
|
if (chunk.data.content && message.role !== "tool") {
|
|
@@ -7211,14 +7033,12 @@ function createSimpleMessageMerger() {
|
|
|
7211
7033
|
builder = { args: "" };
|
|
7212
7034
|
builders.set(chunk_item.index, builder);
|
|
7213
7035
|
}
|
|
7214
|
-
if (chunk_item.name)
|
|
7215
|
-
builder.name = chunk_item.name;
|
|
7036
|
+
if (chunk_item.name) builder.name = chunk_item.name;
|
|
7216
7037
|
if (chunk_item.id) {
|
|
7217
7038
|
builder.id = chunk_item.id;
|
|
7218
7039
|
toolId_MessageIdMap.set(chunk_item.id, message.id);
|
|
7219
7040
|
}
|
|
7220
|
-
if (chunk_item.args)
|
|
7221
|
-
builder.args += chunk_item.args;
|
|
7041
|
+
if (chunk_item.args) builder.args += chunk_item.args;
|
|
7222
7042
|
}
|
|
7223
7043
|
const toolCalls = buildToolCalls(message.id);
|
|
7224
7044
|
if (toolCalls) {
|
|
@@ -7228,8 +7048,7 @@ function createSimpleMessageMerger() {
|
|
|
7228
7048
|
if (message.role === "tool" && chunk.data.tool_call_id) {
|
|
7229
7049
|
const original_tool_message_id = chunk.data.id;
|
|
7230
7050
|
const messageId = toolId_MessageIdMap.get(chunk.data.tool_call_id);
|
|
7231
|
-
if (!messageId)
|
|
7232
|
-
return;
|
|
7051
|
+
if (!messageId) return;
|
|
7233
7052
|
const messageIndex = messageMap.get(messageId);
|
|
7234
7053
|
if (messageIndex !== void 0) {
|
|
7235
7054
|
const { text, ui } = normalizeToolResult({
|