@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/index.js CHANGED
@@ -32,7 +32,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
32
32
 
33
33
  // src/wechat_lib/encoding-indexes.js
34
34
  var require_encoding_indexes = __commonJS({
35
- "src/wechat_lib/encoding-indexes.js"(exports, module2) {
35
+ "src/wechat_lib/encoding-indexes.js"(exports2, module2) {
36
36
  "use strict";
37
37
  (function(global) {
38
38
  "use strict";
@@ -74,13 +74,13 @@ var require_encoding_indexes = __commonJS({
74
74
  "windows-1258": [8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 138, 8249, 338, 141, 142, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 154, 8250, 339, 157, 158, 376, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 258, 196, 197, 198, 199, 200, 201, 202, 203, 768, 205, 206, 207, 272, 209, 777, 211, 212, 416, 214, 215, 216, 217, 218, 219, 220, 431, 771, 223, 224, 225, 226, 259, 228, 229, 230, 231, 232, 233, 234, 235, 769, 237, 238, 239, 273, 241, 803, 243, 244, 417, 246, 247, 248, 249, 250, 251, 252, 432, 8363, 255],
75
75
  "x-mac-cyrillic": [1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 8224, 176, 1168, 163, 167, 8226, 182, 1030, 174, 169, 8482, 1026, 1106, 8800, 1027, 1107, 8734, 177, 8804, 8805, 1110, 181, 1169, 1032, 1028, 1108, 1031, 1111, 1033, 1113, 1034, 1114, 1112, 1029, 172, 8730, 402, 8776, 8710, 171, 187, 8230, 160, 1035, 1115, 1036, 1116, 1109, 8211, 8212, 8220, 8221, 8216, 8217, 247, 8222, 1038, 1118, 1039, 1119, 8470, 1025, 1105, 1103, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 8364]
76
76
  };
77
- })(exports || {});
77
+ })(exports2 || {});
78
78
  }
79
79
  });
80
80
 
81
81
  // src/wechat_lib/encoding.js
82
82
  var require_encoding = __commonJS({
83
- "src/wechat_lib/encoding.js"(exports, module2) {
83
+ "src/wechat_lib/encoding.js"(exports2, module2) {
84
84
  "use strict";
85
85
  (function(global) {
86
86
  "use strict";
@@ -95,10 +95,8 @@ var require_encoding = __commonJS({
95
95
  }
96
96
  var floor = Math.floor;
97
97
  function ToDictionary(o) {
98
- if (o === void 0)
99
- return {};
100
- if (o === Object(o))
101
- return o;
98
+ if (o === void 0) return {};
99
+ if (o === Object(o)) return o;
102
100
  throw TypeError("Could not convert argument to dictionary");
103
101
  }
104
102
  function stringToCodePoints(string) {
@@ -723,8 +721,7 @@ var require_encoding = __commonJS({
723
721
  var encoders = {};
724
722
  var decoders = {};
725
723
  function indexCodePointFor(pointer, index2) {
726
- if (!index2)
727
- return null;
724
+ if (!index2) return null;
728
725
  return index2[pointer] || null;
729
726
  }
730
727
  function indexPointerFor(code_point, index2) {
@@ -740,8 +737,7 @@ var require_encoding = __commonJS({
740
737
  function indexGB18030RangesCodePointFor(pointer) {
741
738
  if (pointer > 39419 && pointer < 189e3 || pointer > 1237575)
742
739
  return null;
743
- if (pointer === 7457)
744
- return 59335;
740
+ if (pointer === 7457) return 59335;
745
741
  var offset = 0;
746
742
  var code_point_offset = 0;
747
743
  var idx = index("gb18030-ranges");
@@ -758,8 +754,7 @@ var require_encoding = __commonJS({
758
754
  return code_point_offset + pointer - offset;
759
755
  }
760
756
  function indexGB18030RangesPointerFor(code_point) {
761
- if (code_point === 59335)
762
- return 7457;
757
+ if (code_point === 59335) return 7457;
763
758
  var offset = 0;
764
759
  var pointer_offset = 0;
765
760
  var idx = index("gb18030-ranges");
@@ -1821,13 +1816,13 @@ var require_encoding = __commonJS({
1821
1816
  EncodingIndexes: global["encoding-indexes"]
1822
1817
  };
1823
1818
  }
1824
- })(exports || {});
1819
+ })(exports2 || {});
1825
1820
  }
1826
1821
  });
1827
1822
 
1828
1823
  // src/index.ts
1829
- var src_exports = {};
1830
- __export(src_exports, {
1824
+ var index_exports = {};
1825
+ __export(index_exports, {
1831
1826
  AbstractClient: () => AbstractClient,
1832
1827
  ApiError: () => ApiError,
1833
1828
  AuthenticationError: () => AuthenticationError,
@@ -1853,7 +1848,7 @@ __export(src_exports, {
1853
1848
  createSimpleMessageMerger: () => createSimpleMessageMerger,
1854
1849
  normalizeToolResult: () => normalizeToolResult
1855
1850
  });
1856
- module.exports = __toCommonJS(src_exports);
1851
+ module.exports = __toCommonJS(index_exports);
1857
1852
 
1858
1853
  // src/types.ts
1859
1854
  var ApiError = class extends Error {
@@ -1923,8 +1918,7 @@ async function* parseSseBody(body, options = {}) {
1923
1918
  } catch {
1924
1919
  throw new SseParseError("Invalid SSE JSON");
1925
1920
  }
1926
- if (options.strictJsonObject && (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)))
1927
- throw new SseParseError("SSE data must be an object");
1921
+ if (options.strictJsonObject && (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))) throw new SseParseError("SSE data must be an object");
1928
1922
  const result = { event, data: parsed, ...id === void 0 ? {} : { id }, ...retry === void 0 ? {} : { retry } };
1929
1923
  event = "";
1930
1924
  id = void 0;
@@ -1934,25 +1928,18 @@ async function* parseSseBody(body, options = {}) {
1934
1928
  };
1935
1929
  const processLine = (raw) => {
1936
1930
  const line = raw.endsWith("\r") ? raw.slice(0, -1) : raw;
1937
- if (line === "")
1938
- return dispatch();
1939
- if (line.startsWith(":"))
1940
- return void 0;
1931
+ if (line === "") return dispatch();
1932
+ if (line.startsWith(":")) return void 0;
1941
1933
  const separator = line.indexOf(":");
1942
1934
  const field = separator < 0 ? line : line.slice(0, separator);
1943
1935
  let value = separator < 0 ? "" : line.slice(separator + 1);
1944
- if (value.startsWith(" "))
1945
- value = value.slice(1);
1946
- if (field === "event")
1947
- event = value;
1948
- else if (field === "data")
1949
- data.push(value);
1950
- else if (field === "id")
1951
- id = value;
1936
+ if (value.startsWith(" ")) value = value.slice(1);
1937
+ if (field === "event") event = value;
1938
+ else if (field === "data") data.push(value);
1939
+ else if (field === "id") id = value;
1952
1940
  else if (field === "retry") {
1953
1941
  const parsed = Number(value);
1954
- if (!Number.isInteger(parsed) || parsed < 0 || !Number.isFinite(parsed))
1955
- throw new SseParseError("Invalid SSE retry");
1942
+ if (!Number.isInteger(parsed) || parsed < 0 || !Number.isFinite(parsed)) throw new SseParseError("Invalid SSE retry");
1956
1943
  retry = parsed;
1957
1944
  }
1958
1945
  return void 0;
@@ -1967,23 +1954,19 @@ async function* parseSseBody(body, options = {}) {
1967
1954
  buffer += decoder.decode(chunk.value, { stream: true });
1968
1955
  let index = findLineBreak(buffer);
1969
1956
  while (index >= 0) {
1970
- if (buffer[index] === "\r" && index === buffer.length - 1)
1971
- break;
1957
+ if (buffer[index] === "\r" && index === buffer.length - 1) break;
1972
1958
  const frame2 = processLine(buffer.slice(0, index));
1973
1959
  buffer = buffer.slice(index + lineBreakLength(buffer, index));
1974
- if (frame2)
1975
- yield frame2;
1960
+ if (frame2) yield frame2;
1976
1961
  index = findLineBreak(buffer);
1977
1962
  }
1978
1963
  }
1979
1964
  if (buffer) {
1980
1965
  const frame2 = processLine(buffer);
1981
- if (frame2)
1982
- yield frame2;
1966
+ if (frame2) yield frame2;
1983
1967
  }
1984
1968
  const frame = processLine("");
1985
- if (frame)
1986
- yield frame;
1969
+ if (frame) yield frame;
1987
1970
  } finally {
1988
1971
  await reader.cancel().catch(() => void 0);
1989
1972
  reader.releaseLock();
@@ -1992,10 +1975,8 @@ async function* parseSseBody(body, options = {}) {
1992
1975
  function findLineBreak(value) {
1993
1976
  const lf = value.indexOf("\n");
1994
1977
  const cr = value.indexOf("\r");
1995
- if (lf < 0)
1996
- return cr;
1997
- if (cr < 0)
1998
- return lf;
1978
+ if (lf < 0) return cr;
1979
+ if (cr < 0) return lf;
1999
1980
  return Math.min(lf, cr);
2000
1981
  }
2001
1982
  function lineBreakLength(value, index) {
@@ -2304,20 +2285,13 @@ var AbstractClient = class {
2304
2285
  */
2305
2286
  auditLogs: async (params) => {
2306
2287
  const searchParams = new URLSearchParams();
2307
- if (params?.credentialId)
2308
- searchParams.set("credentialId", params.credentialId);
2309
- if (params?.domain)
2310
- searchParams.set("domain", params.domain);
2311
- if (params?.status)
2312
- searchParams.set("status", params.status);
2313
- if (params?.from)
2314
- searchParams.set("from", params.from);
2315
- if (params?.to)
2316
- searchParams.set("to", params.to);
2317
- if (params?.limit !== void 0)
2318
- searchParams.set("limit", String(params.limit));
2319
- if (params?.offset !== void 0)
2320
- searchParams.set("offset", String(params.offset));
2288
+ if (params?.credentialId) searchParams.set("credentialId", params.credentialId);
2289
+ if (params?.domain) searchParams.set("domain", params.domain);
2290
+ if (params?.status) searchParams.set("status", params.status);
2291
+ if (params?.from) searchParams.set("from", params.from);
2292
+ if (params?.to) searchParams.set("to", params.to);
2293
+ if (params?.limit !== void 0) searchParams.set("limit", String(params.limit));
2294
+ if (params?.offset !== void 0) searchParams.set("offset", String(params.offset));
2321
2295
  const qs = searchParams.toString();
2322
2296
  const response = await this.makeRequest(`/api/open/audit${qs ? `?${qs}` : ""}`);
2323
2297
  return response.data.records;
@@ -2365,12 +2339,9 @@ var AbstractClient = class {
2365
2339
  */
2366
2340
  list: async (params) => {
2367
2341
  const searchParams = new URLSearchParams();
2368
- if (params?.tenantId)
2369
- searchParams.set("tenantId", params.tenantId);
2370
- if (params?.limit !== void 0)
2371
- searchParams.set("limit", String(params.limit));
2372
- if (params?.offset !== void 0)
2373
- searchParams.set("offset", String(params.offset));
2342
+ if (params?.tenantId) searchParams.set("tenantId", params.tenantId);
2343
+ if (params?.limit !== void 0) searchParams.set("limit", String(params.limit));
2344
+ if (params?.offset !== void 0) searchParams.set("offset", String(params.offset));
2374
2345
  const qs = searchParams.toString();
2375
2346
  const response = await this.makeRequest(`/api/a2a/keys${qs ? `?${qs}` : ""}`);
2376
2347
  return response.data;
@@ -2788,14 +2759,26 @@ var AbstractClient = class {
2788
2759
  method: "POST",
2789
2760
  body: data
2790
2761
  });
2791
- if (!response.data)
2792
- throw new ApiError("Failed to create entry", 500);
2762
+ if (!response.data) throw new ApiError("Failed to create entry", 500);
2793
2763
  return response.data;
2794
2764
  },
2765
+ /**
2766
+ * Creates 1-50 entries in one all-or-nothing vector-store write.
2767
+ *
2768
+ * @param data - Batch payload with one or more entries.
2769
+ * @returns The created entries with generated ids.
2770
+ */
2771
+ createMany: async (data) => {
2772
+ const response = await this.makeRequest(`/api/collections/${collectionName}/entries/batch`, {
2773
+ method: "POST",
2774
+ body: data
2775
+ });
2776
+ if (!response.data?.records) throw new ApiError("Failed to create entries", 500);
2777
+ return response.data.records;
2778
+ },
2795
2779
  get: async (id) => {
2796
2780
  const response = await this.makeRequest(`/api/collections/${collectionName}/entries/${id}`);
2797
- if (!response.data)
2798
- throw new ApiError("Entry not found", 404);
2781
+ if (!response.data) throw new ApiError("Entry not found", 404);
2799
2782
  return response.data;
2800
2783
  },
2801
2784
  update: async (id, data) => {
@@ -2803,8 +2786,7 @@ var AbstractClient = class {
2803
2786
  method: "PUT",
2804
2787
  body: data
2805
2788
  });
2806
- if (!response.data)
2807
- throw new ApiError("Failed to update entry", 500);
2789
+ if (!response.data) throw new ApiError("Failed to update entry", 500);
2808
2790
  return response.data;
2809
2791
  },
2810
2792
  delete: async (id) => {
@@ -2813,6 +2795,22 @@ var AbstractClient = class {
2813
2795
  { method: "DELETE" }
2814
2796
  );
2815
2797
  },
2798
+ /**
2799
+ * Deletes 1-50 entries in one all-or-nothing vector-store call.
2800
+ *
2801
+ * @param entryIds - Entry IDs to delete.
2802
+ * @returns The number of requested entry IDs processed by the delete call.
2803
+ */
2804
+ deleteMany: async (entryIds) => {
2805
+ const response = await this.makeRequest(`/api/collections/${collectionName}/entries/batch`, {
2806
+ method: "DELETE",
2807
+ body: { entryIds }
2808
+ });
2809
+ if (typeof response.data?.processed !== "number") {
2810
+ throw new ApiError("Failed to delete entries", 500);
2811
+ }
2812
+ return response.data.processed;
2813
+ },
2816
2814
  search: async (query, opts) => {
2817
2815
  const response = await this.makeRequest(`/api/collections/${collectionName}/search`, {
2818
2816
  method: "POST",
@@ -3116,14 +3114,10 @@ var AbstractClient = class {
3116
3114
  */
3117
3115
  create: async (threadId, input, options, assistantId) => {
3118
3116
  const body = {};
3119
- if (input !== void 0)
3120
- body.input = input;
3121
- if (options?.command !== void 0)
3122
- body.command = options.command;
3123
- if (options?.config !== void 0)
3124
- body.config = options.config;
3125
- if (options?.mode !== void 0)
3126
- body.mode = options.mode;
3117
+ if (input !== void 0) body.input = input;
3118
+ if (options?.command !== void 0) body.command = options.command;
3119
+ if (options?.config !== void 0) body.config = options.config;
3120
+ if (options?.mode !== void 0) body.mode = options.mode;
3127
3121
  if (options?.multitaskStrategy !== void 0) {
3128
3122
  body.multitask_strategy = options.multitaskStrategy;
3129
3123
  }
@@ -3194,10 +3188,8 @@ var AbstractClient = class {
3194
3188
  */
3195
3189
  cancel: async (threadId, runId, options, assistantId) => {
3196
3190
  const params = new URLSearchParams();
3197
- if (options?.action !== void 0)
3198
- params.set("action", options.action);
3199
- if (options?.wait !== void 0)
3200
- params.set("wait", String(options.wait));
3191
+ if (options?.action !== void 0) params.set("action", options.action);
3192
+ if (options?.wait !== void 0) params.set("wait", String(options.wait));
3201
3193
  const query = params.toString();
3202
3194
  const response = await this.makeRequest(
3203
3195
  `/api/assistants/${assistantId ?? this.assistantId}/threads/${threadId}/runs/${runId}/cancel${query ? `?${query}` : ""}`,
@@ -3305,20 +3297,17 @@ var AbstractClient = class {
3305
3297
  },
3306
3298
  get: async (id) => {
3307
3299
  const response = await this.makeRequest(`/api/tools/${id}`);
3308
- if (!response.data)
3309
- throw new ApiError("Tool not found", 404);
3300
+ if (!response.data) throw new ApiError("Tool not found", 404);
3310
3301
  return response.data;
3311
3302
  },
3312
3303
  create: async (data) => {
3313
3304
  const response = await this.makeRequest("/api/tools", { method: "POST", body: data });
3314
- if (!response.data)
3315
- throw new ApiError("Failed to create tool", 500);
3305
+ if (!response.data) throw new ApiError("Failed to create tool", 500);
3316
3306
  return response.data;
3317
3307
  },
3318
3308
  update: async (id, data) => {
3319
3309
  const response = await this.makeRequest(`/api/tools/${id}`, { method: "PUT", body: data });
3320
- if (!response.data)
3321
- throw new ApiError("Failed to update tool", 500);
3310
+ if (!response.data) throw new ApiError("Failed to update tool", 500);
3322
3311
  return response.data;
3323
3312
  },
3324
3313
  delete: async (id) => {
@@ -3332,20 +3321,17 @@ var AbstractClient = class {
3332
3321
  },
3333
3322
  get: async (id) => {
3334
3323
  const response = await this.makeRequest(`/api/database-configs/${id}`);
3335
- if (!response.data)
3336
- throw new ApiError("Database config not found", 404);
3324
+ if (!response.data) throw new ApiError("Database config not found", 404);
3337
3325
  return response.data;
3338
3326
  },
3339
3327
  create: async (data) => {
3340
3328
  const response = await this.makeRequest("/api/database-configs", { method: "POST", body: data });
3341
- if (!response.data)
3342
- throw new ApiError("Failed to create database config", 500);
3329
+ if (!response.data) throw new ApiError("Failed to create database config", 500);
3343
3330
  return response.data;
3344
3331
  },
3345
3332
  update: async (id, data) => {
3346
3333
  const response = await this.makeRequest(`/api/database-configs/${id}`, { method: "PUT", body: data });
3347
- if (!response.data)
3348
- throw new ApiError("Failed to update database config", 500);
3334
+ if (!response.data) throw new ApiError("Failed to update database config", 500);
3349
3335
  return response.data;
3350
3336
  },
3351
3337
  delete: async (id) => {
@@ -3362,20 +3348,17 @@ var AbstractClient = class {
3362
3348
  },
3363
3349
  get: async (id) => {
3364
3350
  const response = await this.makeRequest(`/api/model-providers/${encodeURIComponent(id)}`);
3365
- if (!response.data)
3366
- throw new ApiError("Model provider not found", 404);
3351
+ if (!response.data) throw new ApiError("Model provider not found", 404);
3367
3352
  return response.data;
3368
3353
  },
3369
3354
  create: async (data) => {
3370
3355
  const response = await this.makeRequest("/api/model-providers", { method: "POST", body: data });
3371
- if (!response.data)
3372
- throw new ApiError("Failed to create model provider", 500);
3356
+ if (!response.data) throw new ApiError("Failed to create model provider", 500);
3373
3357
  return response.data;
3374
3358
  },
3375
3359
  update: async (id, data) => {
3376
3360
  const response = await this.makeRequest(`/api/model-providers/${encodeURIComponent(id)}`, { method: "PUT", body: data });
3377
- if (!response.data)
3378
- throw new ApiError("Failed to update model provider", 500);
3361
+ if (!response.data) throw new ApiError("Failed to update model provider", 500);
3379
3362
  return response.data;
3380
3363
  },
3381
3364
  delete: async (id) => {
@@ -3385,8 +3368,7 @@ var AbstractClient = class {
3385
3368
  // provider form to validate before saving.
3386
3369
  probe: async (data) => {
3387
3370
  const response = await this.makeRequest("/api/model-providers/probe", { method: "POST", body: data });
3388
- if (!response.data)
3389
- throw new ApiError("Failed to probe model provider", 500);
3371
+ if (!response.data) throw new ApiError("Failed to probe model provider", 500);
3390
3372
  return response.data;
3391
3373
  },
3392
3374
  // Replace this provider's model set with exactly these models, picked
@@ -3394,22 +3376,19 @@ var AbstractClient = class {
3394
3376
  // model arrives as `enabled: false` rather than being dropped.
3395
3377
  setModels: async (id, models) => {
3396
3378
  const response = await this.makeRequest(`/api/model-providers/${encodeURIComponent(id)}/models`, { method: "PUT", body: { models } });
3397
- if (!response.data)
3398
- throw new ApiError("Failed to update models", 500);
3379
+ if (!response.data) throw new ApiError("Failed to update models", 500);
3399
3380
  return response.data;
3400
3381
  },
3401
3382
  discover: async (id) => {
3402
3383
  const response = await this.makeRequest(`/api/model-providers/${encodeURIComponent(id)}/discover`, { method: "POST", body: {} });
3403
- if (!response.data)
3404
- throw new ApiError("Failed to discover models", 500);
3384
+ if (!response.data) throw new ApiError("Failed to discover models", 500);
3405
3385
  return response.data;
3406
3386
  },
3407
3387
  // The model id travels in the body because upstream ids routinely
3408
3388
  // contain "/" (e.g. Qwen/Qwen2.5-7B-Instruct).
3409
3389
  setModelEnabled: async (id, modelId, enabled) => {
3410
3390
  const response = await this.makeRequest(`/api/model-providers/${encodeURIComponent(id)}/models/enabled`, { method: "POST", body: { modelId, enabled } });
3411
- if (!response.data)
3412
- throw new ApiError("Failed to update model", 500);
3391
+ if (!response.data) throw new ApiError("Failed to update model", 500);
3413
3392
  return response.data;
3414
3393
  }
3415
3394
  };
@@ -3426,20 +3405,17 @@ var AbstractClient = class {
3426
3405
  },
3427
3406
  get: async (id) => {
3428
3407
  const response = await this.makeRequest(`/api/metrics-configs/${id}`);
3429
- if (!response.data)
3430
- throw new ApiError("Metrics config not found", 404);
3408
+ if (!response.data) throw new ApiError("Metrics config not found", 404);
3431
3409
  return response.data;
3432
3410
  },
3433
3411
  create: async (data) => {
3434
3412
  const response = await this.makeRequest("/api/metrics-configs", { method: "POST", body: data });
3435
- if (!response.data)
3436
- throw new ApiError("Failed to create metrics config", 500);
3413
+ if (!response.data) throw new ApiError("Failed to create metrics config", 500);
3437
3414
  return response.data;
3438
3415
  },
3439
3416
  update: async (id, data) => {
3440
3417
  const response = await this.makeRequest(`/api/metrics-configs/${id}`, { method: "PUT", body: data });
3441
- if (!response.data)
3442
- throw new ApiError("Failed to update metrics config", 500);
3418
+ if (!response.data) throw new ApiError("Failed to update metrics config", 500);
3443
3419
  return response.data;
3444
3420
  },
3445
3421
  delete: async (id) => {
@@ -3460,20 +3436,17 @@ var AbstractClient = class {
3460
3436
  },
3461
3437
  get: async (id) => {
3462
3438
  const response = await this.makeRequest(`/api/mcp-servers/${id}`);
3463
- if (!response.data)
3464
- throw new ApiError("MCP server config not found", 404);
3439
+ if (!response.data) throw new ApiError("MCP server config not found", 404);
3465
3440
  return response.data;
3466
3441
  },
3467
3442
  create: async (data) => {
3468
3443
  const response = await this.makeRequest("/api/mcp-servers", { method: "POST", body: data });
3469
- if (!response.data)
3470
- throw new ApiError("Failed to create MCP server config", 500);
3444
+ if (!response.data) throw new ApiError("Failed to create MCP server config", 500);
3471
3445
  return response.data;
3472
3446
  },
3473
3447
  update: async (id, data) => {
3474
3448
  const response = await this.makeRequest(`/api/mcp-servers/${id}`, { method: "PUT", body: data });
3475
- if (!response.data)
3476
- throw new ApiError("Failed to update MCP server config", 500);
3449
+ if (!response.data) throw new ApiError("Failed to update MCP server config", 500);
3477
3450
  return response.data;
3478
3451
  },
3479
3452
  delete: async (id) => {
@@ -3484,14 +3457,12 @@ var AbstractClient = class {
3484
3457
  },
3485
3458
  connect: async (id) => {
3486
3459
  const response = await this.makeRequest(`/api/mcp-servers/${id}/connect`, { method: "POST" });
3487
- if (!response.data)
3488
- throw new ApiError("Failed to connect MCP server", 500);
3460
+ if (!response.data) throw new ApiError("Failed to connect MCP server", 500);
3489
3461
  return response.data;
3490
3462
  },
3491
3463
  disconnect: async (id) => {
3492
3464
  const response = await this.makeRequest(`/api/mcp-servers/${id}/disconnect`, { method: "POST" });
3493
- if (!response.data)
3494
- throw new ApiError("Failed to disconnect MCP server", 500);
3465
+ if (!response.data) throw new ApiError("Failed to disconnect MCP server", 500);
3495
3466
  return response.data;
3496
3467
  }
3497
3468
  };
@@ -3502,20 +3473,17 @@ var AbstractClient = class {
3502
3473
  },
3503
3474
  get: async (keyOrId) => {
3504
3475
  const response = await this.makeRequest(`/api/personal-mcp-servers/${keyOrId}`);
3505
- if (!response.data)
3506
- throw new ApiError("Personal MCP server config not found", 404);
3476
+ if (!response.data) throw new ApiError("Personal MCP server config not found", 404);
3507
3477
  return response.data;
3508
3478
  },
3509
3479
  create: async (data) => {
3510
3480
  const response = await this.makeRequest("/api/personal-mcp-servers", { method: "POST", body: data });
3511
- if (!response.data)
3512
- throw new ApiError("Failed to create personal MCP server config", 500);
3481
+ if (!response.data) throw new ApiError("Failed to create personal MCP server config", 500);
3513
3482
  return response.data;
3514
3483
  },
3515
3484
  update: async (keyOrId, data) => {
3516
3485
  const response = await this.makeRequest(`/api/personal-mcp-servers/${keyOrId}`, { method: "PUT", body: data });
3517
- if (!response.data)
3518
- throw new ApiError("Failed to update personal MCP server config", 500);
3486
+ if (!response.data) throw new ApiError("Failed to update personal MCP server config", 500);
3519
3487
  return response.data;
3520
3488
  },
3521
3489
  delete: async (keyOrId) => {
@@ -3526,14 +3494,12 @@ var AbstractClient = class {
3526
3494
  },
3527
3495
  connect: async (keyOrId) => {
3528
3496
  const response = await this.makeRequest(`/api/personal-mcp-servers/${keyOrId}/connect`, { method: "POST" });
3529
- if (!response.data)
3530
- throw new ApiError("Failed to connect personal MCP server", 500);
3497
+ if (!response.data) throw new ApiError("Failed to connect personal MCP server", 500);
3531
3498
  return response.data;
3532
3499
  },
3533
3500
  disconnect: async (keyOrId) => {
3534
3501
  const response = await this.makeRequest(`/api/personal-mcp-servers/${keyOrId}/disconnect`, { method: "POST" });
3535
- if (!response.data)
3536
- throw new ApiError("Failed to disconnect personal MCP server", 500);
3502
+ if (!response.data) throw new ApiError("Failed to disconnect personal MCP server", 500);
3537
3503
  return response.data;
3538
3504
  }
3539
3505
  };
@@ -3560,20 +3526,17 @@ var AbstractClient = class {
3560
3526
  },
3561
3527
  get: async (id) => {
3562
3528
  const response = await this.makeRequest(`/api/tasks/${id}`);
3563
- if (!response.data)
3564
- throw new ApiError("Task not found", 404);
3529
+ if (!response.data) throw new ApiError("Task not found", 404);
3565
3530
  return response.data;
3566
3531
  },
3567
3532
  create: async (data) => {
3568
3533
  const response = await this.makeRequest("/api/tasks", { method: "POST", body: data });
3569
- if (!response.data)
3570
- throw new ApiError("Failed to create task", 500);
3534
+ if (!response.data) throw new ApiError("Failed to create task", 500);
3571
3535
  return response.data;
3572
3536
  },
3573
3537
  update: async (id, data) => {
3574
3538
  const response = await this.makeRequest(`/api/tasks/${id}`, { method: "PUT", body: data });
3575
- if (!response.data)
3576
- throw new ApiError("Failed to update task", 500);
3539
+ if (!response.data) throw new ApiError("Failed to update task", 500);
3577
3540
  return response.data;
3578
3541
  },
3579
3542
  delete: async (id) => {
@@ -3581,25 +3544,20 @@ var AbstractClient = class {
3581
3544
  },
3582
3545
  complete: async (id, data) => {
3583
3546
  const response = await this.makeRequest(`/api/tasks/${id}/complete`, { method: "PATCH", body: data });
3584
- if (!response.data)
3585
- throw new ApiError("Failed to complete task", 500);
3547
+ if (!response.data) throw new ApiError("Failed to complete task", 500);
3586
3548
  return response;
3587
3549
  },
3588
3550
  command: async (id, input) => {
3589
3551
  const response = await this.makeRequest(`/api/tasks/${id}/commands`, { method: "POST", body: input });
3590
- if (!response.data)
3591
- throw new ApiError("Failed to run task command", 500);
3552
+ if (!response.data) throw new ApiError("Failed to run task command", 500);
3592
3553
  return response;
3593
3554
  },
3594
3555
  workItems: {
3595
3556
  list: async (taskId, params) => {
3596
3557
  const searchParams = new URLSearchParams();
3597
- if (params?.action)
3598
- searchParams.set("action", params.action);
3599
- if (params?.limit)
3600
- searchParams.set("limit", String(params.limit));
3601
- if (params?.offset)
3602
- searchParams.set("offset", String(params.offset));
3558
+ if (params?.action) searchParams.set("action", params.action);
3559
+ if (params?.limit) searchParams.set("limit", String(params.limit));
3560
+ if (params?.offset) searchParams.set("offset", String(params.offset));
3603
3561
  const qs = searchParams.toString();
3604
3562
  const response = await this.makeRequest(
3605
3563
  `/api/tasks/${taskId}/work-items${qs ? `?${qs}` : ""}`
@@ -3616,20 +3574,17 @@ var AbstractClient = class {
3616
3574
  },
3617
3575
  get: async (id) => {
3618
3576
  const response = await this.makeRequest(`/api/menu-items/${id}`);
3619
- if (!response.data)
3620
- throw new Error("Menu item not found");
3577
+ if (!response.data) throw new Error("Menu item not found");
3621
3578
  return response.data;
3622
3579
  },
3623
3580
  create: async (data) => {
3624
3581
  const response = await this.makeRequest("/api/menu-items", { method: "POST", body: data });
3625
- if (!response.data)
3626
- throw new Error("Failed to create menu item");
3582
+ if (!response.data) throw new Error("Failed to create menu item");
3627
3583
  return response.data;
3628
3584
  },
3629
3585
  update: async (id, data) => {
3630
3586
  const response = await this.makeRequest(`/api/menu-items/${id}`, { method: "PUT", body: data });
3631
- if (!response.data)
3632
- throw new Error("Failed to update menu item");
3587
+ if (!response.data) throw new Error("Failed to update menu item");
3633
3588
  return response.data;
3634
3589
  },
3635
3590
  delete: async (id) => {
@@ -3759,8 +3714,7 @@ var AbstractClient = class {
3759
3714
  { status: response.status, responseBody: errorData }
3760
3715
  );
3761
3716
  }
3762
- if (!response.body)
3763
- throw new Error("Response body is null");
3717
+ if (!response.body) throw new Error("Response body is null");
3764
3718
  for await (const frame of parseSseBody(response.body, { strictJsonObject: true })) {
3765
3719
  if (frame.event === "error") {
3766
3720
  const data = frame.data;
@@ -3785,10 +3739,8 @@ var AbstractClient = class {
3785
3739
  }
3786
3740
  }
3787
3741
  } catch (error) {
3788
- if (controller.signal.aborted)
3789
- return;
3790
- if (error instanceof DOMException && error.name === "AbortError")
3791
- return;
3742
+ if (controller.signal.aborted) return;
3743
+ if (error instanceof DOMException && error.name === "AbortError") return;
3792
3744
  if (error instanceof SseParseError) {
3793
3745
  onError?.(Object.assign(new Error(error.message), { code: "INVALID_EVENT" }));
3794
3746
  return;
@@ -3891,10 +3843,8 @@ var AbstractClient = class {
3891
3843
  */
3892
3844
  async getThreadHistory(threadId, options = {}) {
3893
3845
  const params = new URLSearchParams();
3894
- if (options.limit !== void 0)
3895
- params.append("limit", String(options.limit));
3896
- if (options.before !== void 0)
3897
- params.append("before", options.before);
3846
+ if (options.limit !== void 0) params.append("limit", String(options.limit));
3847
+ if (options.before !== void 0) params.append("before", options.before);
3898
3848
  const query = params.toString();
3899
3849
  const response = await this.makeRequest(
3900
3850
  `/api/assistants/${this.assistantId}/threads/${threadId}/history${query ? `?${query}` : ""}`
@@ -4069,8 +4019,7 @@ var ResourcesClient = class {
4069
4019
  headers: { "Content-Type": "application/json", ...this.getHeaders() },
4070
4020
  body: JSON.stringify(request)
4071
4021
  });
4072
- if (!res.ok)
4073
- throw new Error(`Share failed: ${res.status}`);
4022
+ if (!res.ok) throw new Error(`Share failed: ${res.status}`);
4074
4023
  return await res.json();
4075
4024
  }
4076
4025
  async unshare(token) {
@@ -4078,8 +4027,7 @@ var ResourcesClient = class {
4078
4027
  method: "DELETE",
4079
4028
  headers: this.getHeaders()
4080
4029
  });
4081
- if (!res.ok)
4082
- throw new Error(`Unshare failed: ${res.status}`);
4030
+ if (!res.ok) throw new Error(`Unshare failed: ${res.status}`);
4083
4031
  }
4084
4032
  async updateShare(token, patch) {
4085
4033
  const res = await fetch(`${this.baseURL}/api/resources/share/${token}`, {
@@ -4087,15 +4035,13 @@ var ResourcesClient = class {
4087
4035
  headers: { "Content-Type": "application/json", ...this.getHeaders() },
4088
4036
  body: JSON.stringify(patch)
4089
4037
  });
4090
- if (!res.ok)
4091
- throw new Error(`Update failed: ${res.status}`);
4038
+ if (!res.ok) throw new Error(`Update failed: ${res.status}`);
4092
4039
  }
4093
4040
  async listShares() {
4094
4041
  const res = await fetch(`${this.baseURL}/api/resources/shares`, {
4095
4042
  headers: this.getHeaders()
4096
4043
  });
4097
- if (!res.ok)
4098
- throw new Error(`List failed: ${res.status}`);
4044
+ if (!res.ok) throw new Error(`List failed: ${res.status}`);
4099
4045
  return await res.json();
4100
4046
  }
4101
4047
  };
@@ -4133,8 +4079,7 @@ async function archiveToBlob(archive) {
4133
4079
  };
4134
4080
  }
4135
4081
  function attachmentFilename(contentDisposition) {
4136
- if (!contentDisposition)
4137
- return "tenant-export.tar.gz";
4082
+ if (!contentDisposition) return "tenant-export.tar.gz";
4138
4083
  const encoded = contentDisposition.match(/filename\*=UTF-8''([^;]+)/i)?.[1];
4139
4084
  if (encoded) {
4140
4085
  try {
@@ -4169,8 +4114,7 @@ var ExportImportClient = class {
4169
4114
  };
4170
4115
  if (options.body instanceof FormData) {
4171
4116
  for (const name of Object.keys(headers)) {
4172
- if (name.toLowerCase() === "content-type")
4173
- delete headers[name];
4117
+ if (name.toLowerCase() === "content-type") delete headers[name];
4174
4118
  }
4175
4119
  }
4176
4120
  const response = await fetch(`${this.baseURL}${url}`, {
@@ -4304,18 +4248,15 @@ var ProjectRoomClientError = class extends Error {
4304
4248
  var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
4305
4249
  var date = (value, field) => {
4306
4250
  const result = value instanceof Date ? new Date(value.getTime()) : new Date(typeof value === "string" || typeof value === "number" ? value : Number.NaN);
4307
- if (!Number.isFinite(result.getTime()))
4308
- throw new ProjectRoomClientError(`Invalid ${field}`, 500, "INVALID_RESPONSE", false);
4251
+ if (!Number.isFinite(result.getTime())) throw new ProjectRoomClientError(`Invalid ${field}`, 500, "INVALID_RESPONSE", false);
4309
4252
  return result;
4310
4253
  };
4311
4254
  var requiredString = (record3, field) => {
4312
- if (typeof record3[field] !== "string")
4313
- throw new ProjectRoomClientError(`Invalid ${field}`, 500, "INVALID_RESPONSE", false);
4255
+ if (typeof record3[field] !== "string") throw new ProjectRoomClientError(`Invalid ${field}`, 500, "INVALID_RESPONSE", false);
4314
4256
  return record3[field];
4315
4257
  };
4316
4258
  var oneOf = (value, values, field) => {
4317
- if (typeof value !== "string" || !values.includes(value))
4318
- throw new ProjectRoomClientError(`Invalid ${field}`, 500, "INVALID_RESPONSE", false);
4259
+ if (typeof value !== "string" || !values.includes(value)) throw new ProjectRoomClientError(`Invalid ${field}`, 500, "INVALID_RESPONSE", false);
4319
4260
  return value;
4320
4261
  };
4321
4262
  var messageSources = ["user", "agent", "task", "routine", "system"];
@@ -4324,8 +4265,7 @@ var memberStatuses = ["active", "removed"];
4324
4265
  var botRoles = ["coordinator", "specialist"];
4325
4266
  var botStatuses = ["active", "paused", "removed"];
4326
4267
  var exactKeys = (row, required, optional = []) => {
4327
- if (required.some((key) => !Object.prototype.hasOwnProperty.call(row, key)) || Object.keys(row).some((key) => !required.includes(key) && !optional.includes(key)))
4328
- throw new ProjectRoomClientError("Invalid Project Room response", 500, "INVALID_RESPONSE", false);
4268
+ 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);
4329
4269
  };
4330
4270
  var hydrateAuthor = (value) => {
4331
4271
  const row = record(value);
@@ -4334,29 +4274,24 @@ var hydrateAuthor = (value) => {
4334
4274
  exactKeys(row, ["type", "userId"]);
4335
4275
  return { type, userId: requiredString(row, "userId") };
4336
4276
  }
4337
- if (type === "bot")
4338
- return { type, membershipId: requiredString(row, "membershipId") };
4339
- if (Object.keys(row).some((key) => key !== "type"))
4340
- throw new ProjectRoomClientError("Invalid author", 500, "INVALID_RESPONSE", false);
4277
+ if (type === "bot") return { type, membershipId: requiredString(row, "membershipId") };
4278
+ if (Object.keys(row).some((key) => key !== "type")) throw new ProjectRoomClientError("Invalid author", 500, "INVALID_RESPONSE", false);
4341
4279
  return { type };
4342
4280
  };
4343
4281
  var hydrateMentions = (value) => {
4344
- if (!Array.isArray(value))
4345
- throw new ProjectRoomClientError("Invalid mentions", 500, "INVALID_RESPONSE", false);
4282
+ if (!Array.isArray(value)) throw new ProjectRoomClientError("Invalid mentions", 500, "INVALID_RESPONSE", false);
4346
4283
  return value.map((entry) => {
4347
4284
  const row = record(entry);
4348
4285
  const type = oneOf(row.type, ["bot", "team"], "mention.type");
4349
4286
  if (type === "team") {
4350
- if (Object.keys(row).length !== 1)
4351
- throw new ProjectRoomClientError("Invalid mention", 500, "INVALID_RESPONSE", false);
4287
+ if (Object.keys(row).length !== 1) throw new ProjectRoomClientError("Invalid mention", 500, "INVALID_RESPONSE", false);
4352
4288
  return { type };
4353
4289
  }
4354
4290
  return { type, membershipId: requiredString(row, "membershipId") };
4355
4291
  });
4356
4292
  };
4357
4293
  var record = (value) => {
4358
- if (!isRecord(value))
4359
- throw new ProjectRoomClientError("Invalid Project Room response", 500, "INVALID_RESPONSE", false);
4294
+ if (!isRecord(value)) throw new ProjectRoomClientError("Invalid Project Room response", 500, "INVALID_RESPONSE", false);
4360
4295
  return value;
4361
4296
  };
4362
4297
  var hydrateRoom = (value) => {
@@ -4368,8 +4303,7 @@ var hydrateMessage = (value) => {
4368
4303
  const row = record(value);
4369
4304
  exactKeys(row, ["id", "roomId", "author", "content", "mentions", "source", "createdAt"], ["replyToMessageId", "sourceId"]);
4370
4305
  const content = record(row.content);
4371
- if (oneOf(content.type, ["text"], "content.type") !== "text")
4372
- throw new ProjectRoomClientError("Invalid content", 500, "INVALID_RESPONSE", false);
4306
+ if (oneOf(content.type, ["text"], "content.type") !== "text") throw new ProjectRoomClientError("Invalid content", 500, "INVALID_RESPONSE", false);
4373
4307
  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") };
4374
4308
  };
4375
4309
  var hydrateMember = (value) => {
@@ -4384,8 +4318,7 @@ var hydrateBot = (value) => {
4384
4318
  };
4385
4319
  var hydrateDispatch = (value) => {
4386
4320
  const row = record(value);
4387
- if (typeof row.success !== "boolean" || row.membershipId !== void 0 && typeof row.membershipId !== "string" || row.errorCode !== void 0 && typeof row.errorCode !== "string")
4388
- throw new ProjectRoomClientError("Invalid dispatch response", 500, "INVALID_RESPONSE", false);
4321
+ 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);
4389
4322
  return { success: row.success, ...row.membershipId === void 0 ? {} : { membershipId: row.membershipId }, ...row.errorCode === void 0 ? {} : { errorCode: row.errorCode } };
4390
4323
  };
4391
4324
  function hydratePublicMember(value) {
@@ -4411,23 +4344,19 @@ var ProjectRoomsClient = class {
4411
4344
  query.set("beforeCreatedAt", iso(options.cursor.createdAt));
4412
4345
  query.set("beforeId", options.cursor.id);
4413
4346
  }
4414
- if (options.limit !== void 0)
4415
- query.set("limit", String(options.limit));
4347
+ if (options.limit !== void 0) query.set("limit", String(options.limit));
4416
4348
  const result = await this.request(`/api/projects/${encode(projectId)}/room/messages${query.toString() ? `?${query}` : ""}`);
4417
- if (!Array.isArray(result))
4418
- throw new ProjectRoomClientError("Invalid messages response", 500, "INVALID_RESPONSE", false);
4349
+ if (!Array.isArray(result)) throw new ProjectRoomClientError("Invalid messages response", 500, "INVALID_RESPONSE", false);
4419
4350
  return result.map(hydrateMessage);
4420
4351
  },
4421
4352
  send: async (projectId, input) => {
4422
4353
  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() } });
4423
- if (!Array.isArray(result.dispatch) || typeof result.replayed !== "boolean")
4424
- throw new ProjectRoomClientError("Invalid send response", 500, "INVALID_RESPONSE", false);
4354
+ if (!Array.isArray(result.dispatch) || typeof result.replayed !== "boolean") throw new ProjectRoomClientError("Invalid send response", 500, "INVALID_RESPONSE", false);
4425
4355
  return { message: hydrateMessage(result.message), dispatch: result.dispatch.map(hydrateDispatch), replayed: result.replayed };
4426
4356
  },
4427
4357
  retry: async (projectId, messageId) => {
4428
4358
  const result = await this.request(`/api/projects/${encode(projectId)}/room/messages/${encode(messageId)}/retry`, { method: "POST", body: {} });
4429
- if (!Array.isArray(result))
4430
- throw new ProjectRoomClientError("Invalid retry response", 500, "INVALID_RESPONSE", false);
4359
+ if (!Array.isArray(result)) throw new ProjectRoomClientError("Invalid retry response", 500, "INVALID_RESPONSE", false);
4431
4360
  return result.map(hydrateDispatch);
4432
4361
  },
4433
4362
  markRead: async (projectId) => {
@@ -4468,8 +4397,7 @@ var ProjectRoomsClient = class {
4468
4397
  }
4469
4398
  async records(path, hydrate) {
4470
4399
  const result = await this.request(path);
4471
- if (!Array.isArray(result))
4472
- throw new ProjectRoomClientError("Invalid records response", 500, "INVALID_RESPONSE", false);
4400
+ if (!Array.isArray(result)) throw new ProjectRoomClientError("Invalid records response", 500, "INVALID_RESPONSE", false);
4473
4401
  return result.map(hydrate);
4474
4402
  }
4475
4403
  async request(path, options = {}) {
@@ -4481,8 +4409,7 @@ var ProjectRoomsClient = class {
4481
4409
  const error = payload?.error;
4482
4410
  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);
4483
4411
  }
4484
- if (!Object.prototype.hasOwnProperty.call(payload, "data"))
4485
- throw new ProjectRoomClientError("Missing response data", 500, "INVALID_RESPONSE", false);
4412
+ if (!Object.prototype.hasOwnProperty.call(payload, "data")) throw new ProjectRoomClientError("Missing response data", 500, "INVALID_RESPONSE", false);
4486
4413
  return payload.data;
4487
4414
  }
4488
4415
  };
@@ -4490,19 +4417,16 @@ var ProjectRoomsClient = class {
4490
4417
  // src/workspace-rooms.ts
4491
4418
  var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
4492
4419
  var record2 = (value) => {
4493
- if (!isRecord2(value))
4494
- throw new ProjectRoomClientError("Invalid workspace rooms response", 500, "INVALID_RESPONSE", false);
4420
+ if (!isRecord2(value)) throw new ProjectRoomClientError("Invalid workspace rooms response", 500, "INVALID_RESPONSE", false);
4495
4421
  return value;
4496
4422
  };
4497
4423
  var requiredString2 = (row, field) => {
4498
- if (typeof row[field] !== "string")
4499
- throw new ProjectRoomClientError(`Invalid ${field}`, 500, "INVALID_RESPONSE", false);
4424
+ if (typeof row[field] !== "string") throw new ProjectRoomClientError(`Invalid ${field}`, 500, "INVALID_RESPONSE", false);
4500
4425
  return row[field];
4501
4426
  };
4502
4427
  var date2 = (value, field) => {
4503
4428
  const result = value instanceof Date ? new Date(value.getTime()) : new Date(typeof value === "string" ? value : Number.NaN);
4504
- if (!Number.isFinite(result.getTime()))
4505
- throw new ProjectRoomClientError(`Invalid ${field}`, 500, "INVALID_RESPONSE", false);
4429
+ if (!Number.isFinite(result.getTime())) throw new ProjectRoomClientError(`Invalid ${field}`, 500, "INVALID_RESPONSE", false);
4506
4430
  return result;
4507
4431
  };
4508
4432
  var hydrateProject = (value) => {
@@ -4522,10 +4446,8 @@ var hydrateProject = (value) => {
4522
4446
  var hydrateEntry = (value) => {
4523
4447
  const row = record2(value);
4524
4448
  const names = row.participantNames;
4525
- if (!Array.isArray(names) || names.some((n) => typeof n !== "string"))
4526
- throw new ProjectRoomClientError("Invalid participantNames", 500, "INVALID_RESPONSE", false);
4527
- if (typeof row.participantCount !== "number" || typeof row.unreadCount !== "number")
4528
- throw new ProjectRoomClientError("Invalid room entry counts", 500, "INVALID_RESPONSE", false);
4449
+ if (!Array.isArray(names) || names.some((n) => typeof n !== "string")) throw new ProjectRoomClientError("Invalid participantNames", 500, "INVALID_RESPONSE", false);
4450
+ if (typeof row.participantCount !== "number" || typeof row.unreadCount !== "number") throw new ProjectRoomClientError("Invalid room entry counts", 500, "INVALID_RESPONSE", false);
4529
4451
  return {
4530
4452
  project: hydrateProject(row.project),
4531
4453
  room: hydrateRoom(row.room),
@@ -4550,8 +4472,7 @@ var WorkspaceRoomsClient = class {
4550
4472
  const error = payload?.error;
4551
4473
  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);
4552
4474
  }
4553
- if (!payload.data || !Array.isArray(payload.data.rooms))
4554
- throw new ProjectRoomClientError("Invalid workspace rooms response", 500, "INVALID_RESPONSE", false);
4475
+ if (!payload.data || !Array.isArray(payload.data.rooms)) throw new ProjectRoomClientError("Invalid workspace rooms response", 500, "INVALID_RESPONSE", false);
4555
4476
  return payload.data.rooms.map(hydrateEntry);
4556
4477
  }
4557
4478
  };
@@ -4559,10 +4480,8 @@ var WorkspaceRoomsClient = class {
4559
4480
  // src/workspace-members.ts
4560
4481
  var isRecord3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
4561
4482
  var hydrateMember2 = (value) => {
4562
- if (!isRecord3(value))
4563
- throw new ProjectRoomClientError("Invalid workspace member", 500, "INVALID_RESPONSE", false);
4564
- if (typeof value.userId !== "string" || typeof value.name !== "string")
4565
- throw new ProjectRoomClientError("Invalid workspace member", 500, "INVALID_RESPONSE", false);
4483
+ if (!isRecord3(value)) throw new ProjectRoomClientError("Invalid workspace member", 500, "INVALID_RESPONSE", false);
4484
+ if (typeof value.userId !== "string" || typeof value.name !== "string") throw new ProjectRoomClientError("Invalid workspace member", 500, "INVALID_RESPONSE", false);
4566
4485
  return {
4567
4486
  userId: value.userId,
4568
4487
  name: value.name,
@@ -4586,8 +4505,7 @@ var WorkspaceMembersClient = class {
4586
4505
  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);
4587
4506
  }
4588
4507
  const members = payload.data?.members;
4589
- if (!Array.isArray(members))
4590
- throw new ProjectRoomClientError("Invalid workspace members response", 500, "INVALID_RESPONSE", false);
4508
+ if (!Array.isArray(members)) throw new ProjectRoomClientError("Invalid workspace members response", 500, "INVALID_RESPONSE", false);
4591
4509
  return members.map(hydrateMember2);
4592
4510
  }
4593
4511
  };
@@ -4595,76 +4513,61 @@ var WorkspaceMembersClient = class {
4595
4513
  // src/room-events.ts
4596
4514
  var invalidFrame = (message) => new ProjectRoomClientError(message, 200, "INVALID_EVENT", false);
4597
4515
  var requiredString3 = (row, field) => {
4598
- if (typeof row[field] !== "string")
4599
- throw invalidFrame(`Invalid ${field}`);
4516
+ if (typeof row[field] !== "string") throw invalidFrame(`Invalid ${field}`);
4600
4517
  return row[field];
4601
4518
  };
4602
4519
  var oneOf2 = (value, values, field) => {
4603
- if (typeof value !== "string" || !values.includes(value))
4604
- throw invalidFrame(`Invalid ${field}`);
4520
+ if (typeof value !== "string" || !values.includes(value)) throw invalidFrame(`Invalid ${field}`);
4605
4521
  return value;
4606
4522
  };
4607
4523
  var hydrateScope = (value) => {
4608
- if (!isRecord(value))
4609
- throw invalidFrame("Invalid scope");
4524
+ if (!isRecord(value)) throw invalidFrame("Invalid scope");
4610
4525
  return { tenantId: requiredString3(value, "tenantId"), roomId: requiredString3(value, "roomId"), projectId: requiredString3(value, "projectId") };
4611
4526
  };
4612
4527
  var hydrateControl = (event, payload) => {
4613
4528
  if (event === "ready") {
4614
- if (typeof payload.epoch !== "string" || payload.headEventId !== null && typeof payload.headEventId !== "string" || Object.keys(payload).some((key) => key !== "epoch" && key !== "headEventId"))
4615
- throw invalidFrame("Invalid SSE control");
4529
+ 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");
4616
4530
  return { type: "ready", data: { epoch: payload.epoch, headEventId: payload.headEventId } };
4617
4531
  }
4618
- if (Object.keys(payload).some((key) => key !== "reason"))
4619
- throw invalidFrame("Invalid SSE control");
4620
- if (event === "resync")
4621
- return { type: "resync", data: { reason: oneOf2(payload.reason, ["SERVER_RESTART", "CURSOR_EXPIRED", "SLOW_CONSUMER"], "reason") } };
4532
+ if (Object.keys(payload).some((key) => key !== "reason")) throw invalidFrame("Invalid SSE control");
4533
+ if (event === "resync") return { type: "resync", data: { reason: oneOf2(payload.reason, ["SERVER_RESTART", "CURSOR_EXPIRED", "SLOW_CONSUMER"], "reason") } };
4622
4534
  return { type: "access.revoked", data: { reason: oneOf2(payload.reason, ["PROJECT_ACCESS_REVOKED", "TOKEN_EXPIRED", "CONNECTION_SUPERSEDED"], "reason") } };
4623
4535
  };
4624
4536
  var ROOM_SCOPED_TYPES = ["message.created", "roster.changed", "membership.changed", "task.changed"];
4625
4537
  function hydrateWorkspaceFrame(raw) {
4626
4538
  const payload = isRecord(raw.data) ? raw.data : void 0;
4627
4539
  if (raw.event === "ready" || raw.event === "resync" || raw.event === "access.revoked") {
4628
- if (!payload || Object.prototype.hasOwnProperty.call(payload, "type"))
4629
- throw invalidFrame("Invalid SSE control");
4540
+ if (!payload || Object.prototype.hasOwnProperty.call(payload, "type")) throw invalidFrame("Invalid SSE control");
4630
4541
  return hydrateControl(raw.event, payload);
4631
4542
  }
4632
- if (typeof payload?.type !== "string" || payload.type !== raw.event || typeof payload.id !== "string" || raw.id !== payload.id)
4633
- throw invalidFrame("Invalid SSE business event");
4543
+ if (typeof payload?.type !== "string" || payload.type !== raw.event || typeof payload.id !== "string" || raw.id !== payload.id) throw invalidFrame("Invalid SSE business event");
4634
4544
  const occurredAt = date(payload.occurredAt, "occurredAt");
4635
4545
  const scope = payload.scope === void 0 ? void 0 : hydrateScope(payload.scope);
4636
4546
  const roomScoped = ROOM_SCOPED_TYPES.includes(payload.type);
4637
- if (roomScoped && scope === void 0)
4638
- throw invalidFrame("Invalid SSE business event scope");
4547
+ if (roomScoped && scope === void 0) throw invalidFrame("Invalid SSE business event scope");
4639
4548
  const data = payload.data;
4640
4549
  if (payload.type === "message.created") {
4641
- if (!isRecord(data))
4642
- throw invalidFrame("Invalid SSE business event data");
4550
+ if (!isRecord(data)) throw invalidFrame("Invalid SSE business event data");
4643
4551
  return { type: payload.type, id: payload.id, occurredAt, scope, data: { message: hydrateMessage(data.message) } };
4644
4552
  }
4645
4553
  if (payload.type === "roster.changed") {
4646
- if (!isRecord(data))
4647
- throw invalidFrame("Invalid SSE business event data");
4554
+ if (!isRecord(data)) throw invalidFrame("Invalid SSE business event data");
4648
4555
  return { type: payload.type, id: payload.id, occurredAt, scope, data: { change: requiredString3(data, "change"), membership: hydratePublicBot(data.membership) } };
4649
4556
  }
4650
4557
  if (payload.type === "membership.changed") {
4651
- if (!isRecord(data))
4652
- throw invalidFrame("Invalid SSE business event data");
4558
+ if (!isRecord(data)) throw invalidFrame("Invalid SSE business event data");
4653
4559
  return { type: payload.type, id: payload.id, occurredAt, scope, data: { change: requiredString3(data, "change"), membership: hydratePublicMember(data.membership) } };
4654
4560
  }
4655
4561
  if (payload.type === "task.changed") {
4656
- if (!isRecord(data))
4657
- throw invalidFrame("Invalid SSE business event data");
4562
+ if (!isRecord(data)) throw invalidFrame("Invalid SSE business event data");
4658
4563
  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") } };
4659
4564
  }
4660
4565
  if (payload.type === "read.changed") {
4661
- if (!isRecord(data))
4662
- throw invalidFrame("Invalid SSE business event data");
4566
+ if (!isRecord(data)) throw invalidFrame("Invalid SSE business event data");
4663
4567
  return { type: payload.type, id: payload.id, occurredAt, data: { projectId: requiredString3(data, "projectId"), roomId: requiredString3(data, "roomId"), lastReadAt: date(data.lastReadAt, "lastReadAt") } };
4664
4568
  }
4665
4569
  if (payload.type === "membership.affected") {
4666
- if (!isRecord(data))
4667
- throw invalidFrame("Invalid SSE business event data");
4570
+ if (!isRecord(data)) throw invalidFrame("Invalid SSE business event data");
4668
4571
  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") } };
4669
4572
  }
4670
4573
  return { type: payload.type, id: payload.id, occurredAt, data: payload.data, ...scope === void 0 ? {} : { scope } };
@@ -4688,35 +4591,29 @@ var RoomEventsClient = class {
4688
4591
  const error = payload?.error;
4689
4592
  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);
4690
4593
  }
4691
- if (response.headers?.get && response.headers.get("content-type")?.split(";")[0].trim() !== "text/event-stream")
4692
- throw new ProjectRoomClientError("Workspace room events stream has invalid content type", response.status, "INVALID_RESPONSE", false);
4693
- if (!response.body)
4694
- throw new ProjectRoomClientError("Workspace room events stream has no body", 500, "INVALID_RESPONSE", false);
4594
+ 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);
4595
+ if (!response.body) throw new ProjectRoomClientError("Workspace room events stream has no body", 500, "INVALID_RESPONSE", false);
4695
4596
  resolveOpen({ status: 200 });
4696
4597
  return response;
4697
4598
  }).catch((error) => {
4698
4599
  rejectOpen(error);
4699
4600
  throw error;
4700
4601
  });
4701
- const stream = async function* () {
4602
+ const stream = (async function* () {
4702
4603
  const response = await responsePromise;
4703
4604
  const body = response.body;
4704
- if (!body)
4705
- throw new ProjectRoomClientError("Workspace room events stream has no body", 500, "INVALID_RESPONSE", false);
4605
+ if (!body) throw new ProjectRoomClientError("Workspace room events stream has no body", 500, "INVALID_RESPONSE", false);
4706
4606
  for await (const raw of parseSseBody(body, { strictJsonObject: true })) {
4707
4607
  try {
4708
4608
  yield { event: hydrateWorkspaceFrame(raw), ...raw.id === void 0 ? {} : { id: raw.id }, ...raw.retry === void 0 ? {} : { retry: raw.retry } };
4709
4609
  } catch (error) {
4710
- if (error instanceof ProjectRoomClientError && error.code === "INVALID_EVENT")
4711
- throw new ProjectRoomClientError(error.message, 400, "INVALID_EVENT", false, error.details);
4712
- if (error instanceof SseParseError)
4713
- throw new ProjectRoomClientError(error.message, 400, "INVALID_EVENT", false);
4714
- if (error instanceof ProjectRoomClientError)
4715
- throw new ProjectRoomClientError(error.message, 400, "INVALID_EVENT", false, error.details);
4610
+ if (error instanceof ProjectRoomClientError && error.code === "INVALID_EVENT") throw new ProjectRoomClientError(error.message, 400, "INVALID_EVENT", false, error.details);
4611
+ if (error instanceof SseParseError) throw new ProjectRoomClientError(error.message, 400, "INVALID_EVENT", false);
4612
+ if (error instanceof ProjectRoomClientError) throw new ProjectRoomClientError(error.message, 400, "INVALID_EVENT", false, error.details);
4716
4613
  throw new ProjectRoomClientError("Invalid SSE event", 400, "INVALID_EVENT", false);
4717
4614
  }
4718
4615
  }
4719
- }();
4616
+ })();
4720
4617
  return { opened, [Symbol.asyncIterator]: () => stream };
4721
4618
  }
4722
4619
  };
@@ -4737,13 +4634,11 @@ function invalidResponse(message) {
4737
4634
  return new OidcProviderClientError(message, 500, "INVALID_RESPONSE", false);
4738
4635
  }
4739
4636
  function requiredString4(row, field) {
4740
- if (typeof row[field] !== "string")
4741
- throw invalidResponse(`Invalid ${field}`);
4637
+ if (typeof row[field] !== "string") throw invalidResponse(`Invalid ${field}`);
4742
4638
  return row[field];
4743
4639
  }
4744
4640
  function hydrateSummary(value) {
4745
- if (!isRecord4(value))
4746
- throw invalidResponse("Invalid OIDC provider summary");
4641
+ if (!isRecord4(value)) throw invalidResponse("Invalid OIDC provider summary");
4747
4642
  const source = value.source;
4748
4643
  if (source !== "env" && source !== "store") {
4749
4644
  throw invalidResponse("Invalid OIDC provider source");
@@ -4770,8 +4665,7 @@ function hydrateSummary(value) {
4770
4665
  };
4771
4666
  }
4772
4667
  function hydrateTestResult(value) {
4773
- if (!isRecord4(value))
4774
- throw invalidResponse("Invalid OIDC test result");
4668
+ if (!isRecord4(value)) throw invalidResponse("Invalid OIDC test result");
4775
4669
  const scopesSupported = Array.isArray(value.scopesSupported) ? value.scopesSupported.filter(
4776
4670
  (scope) => typeof scope === "string"
4777
4671
  ) : void 0;
@@ -4813,8 +4707,7 @@ var OidcProvidersClient = class {
4813
4707
  }
4814
4708
  async list() {
4815
4709
  const data = await this.request("/api/oidc-providers");
4816
- if (!Array.isArray(data))
4817
- throw invalidResponse("Invalid provider list");
4710
+ if (!Array.isArray(data)) throw invalidResponse("Invalid provider list");
4818
4711
  return data.map(hydrateSummary);
4819
4712
  }
4820
4713
  async create(input) {
@@ -4889,16 +4782,13 @@ function invalidResponse2(message) {
4889
4782
  return new PlatformClientError(message, 500, "INVALID_RESPONSE", false);
4890
4783
  }
4891
4784
  function requiredString5(row, field) {
4892
- if (typeof row[field] !== "string")
4893
- throw invalidResponse2(`Invalid ${field}`);
4785
+ if (typeof row[field] !== "string") throw invalidResponse2(`Invalid ${field}`);
4894
4786
  return row[field];
4895
4787
  }
4896
4788
  function optionalNullableString(row, field) {
4897
4789
  const value = row[field];
4898
- if (value === null || value === void 0)
4899
- return null;
4900
- if (typeof value !== "string")
4901
- throw invalidResponse2(`Invalid ${field}`);
4790
+ if (value === null || value === void 0) return null;
4791
+ if (typeof value !== "string") throw invalidResponse2(`Invalid ${field}`);
4902
4792
  return value;
4903
4793
  }
4904
4794
  function hydrateSettingsSnapshot(value) {
@@ -4931,23 +4821,22 @@ var BRANDING_TEXT_KEYS = [
4931
4821
  "loginSubtitle"
4932
4822
  ];
4933
4823
  function hydrateBranding(value) {
4934
- if (!isRecord5(value))
4935
- throw invalidResponse2("Invalid branding");
4824
+ if (!isRecord5(value)) throw invalidResponse2("Invalid branding");
4936
4825
  const branding = {};
4937
4826
  for (const key of BRANDING_TEXT_KEYS) {
4938
4827
  const field = value[key];
4939
- if (field === void 0)
4940
- continue;
4828
+ if (field === void 0) continue;
4941
4829
  if (typeof field !== "string") {
4942
4830
  throw invalidResponse2(`Invalid branding.${key}`);
4943
4831
  }
4944
4832
  branding[key] = field;
4945
4833
  }
4834
+ const customCss = optionalString(value, "customCss");
4835
+ if (customCss !== void 0) branding.customCss = customCss;
4946
4836
  return branding;
4947
4837
  }
4948
4838
  function hydrateBrandingDomain(value) {
4949
- if (!isRecord5(value))
4950
- throw invalidResponse2("Invalid branding domain");
4839
+ if (!isRecord5(value)) throw invalidResponse2("Invalid branding domain");
4951
4840
  const domain = { host: requiredString5(value, "host") };
4952
4841
  if (value.status !== void 0) {
4953
4842
  if (value.status !== "active" && value.status !== "pending") {
@@ -4969,8 +4858,7 @@ function hydrateBrandingDomain(value) {
4969
4858
  return domain;
4970
4859
  }
4971
4860
  function hydrateBrandingSettings(value) {
4972
- if (!isRecord5(value))
4973
- throw invalidResponse2("Invalid branding settings");
4861
+ if (!isRecord5(value)) throw invalidResponse2("Invalid branding settings");
4974
4862
  const settings = {};
4975
4863
  if (value.default !== void 0) {
4976
4864
  settings.default = hydrateBranding(value.default);
@@ -5019,8 +4907,7 @@ function hydrateTenantRole(value) {
5019
4907
  throw invalidResponse2("Invalid tenant role");
5020
4908
  }
5021
4909
  function hydrateStatus(value) {
5022
- if (value === null || value === void 0)
5023
- return null;
4910
+ if (value === null || value === void 0) return null;
5024
4911
  if (value === "active" || value === "pending" || value === "suspended") {
5025
4912
  return value;
5026
4913
  }
@@ -5028,15 +4915,12 @@ function hydrateStatus(value) {
5028
4915
  }
5029
4916
  function optionalString(row, field) {
5030
4917
  const value = row[field];
5031
- if (value === null || value === void 0)
5032
- return void 0;
5033
- if (typeof value !== "string")
5034
- throw invalidResponse2(`Invalid ${field}`);
4918
+ if (value === null || value === void 0) return void 0;
4919
+ if (typeof value !== "string") throw invalidResponse2(`Invalid ${field}`);
5035
4920
  return value;
5036
4921
  }
5037
4922
  function hydrateInvitation(value) {
5038
- if (!isRecord5(value))
5039
- throw invalidResponse2("Invalid invitation");
4923
+ if (!isRecord5(value)) throw invalidResponse2("Invalid invitation");
5040
4924
  const invitedBy = optionalString(value, "invitedBy");
5041
4925
  const expiresAt = optionalString(value, "expiresAt");
5042
4926
  const consumedAt = optionalString(value, "consumedAt");
@@ -5050,8 +4934,7 @@ function hydrateInvitation(value) {
5050
4934
  };
5051
4935
  }
5052
4936
  function hydrateMember3(value) {
5053
- if (!isRecord5(value))
5054
- throw invalidResponse2("Invalid platform member");
4937
+ if (!isRecord5(value)) throw invalidResponse2("Invalid platform member");
5055
4938
  return {
5056
4939
  id: requiredString5(value, "id"),
5057
4940
  email: optionalNullableString(value, "email"),
@@ -5063,8 +4946,7 @@ function hydrateMember3(value) {
5063
4946
  };
5064
4947
  }
5065
4948
  function hydrateTenantMember(value) {
5066
- if (!isRecord5(value))
5067
- throw invalidResponse2("Invalid tenant member");
4949
+ if (!isRecord5(value)) throw invalidResponse2("Invalid tenant member");
5068
4950
  return {
5069
4951
  userId: requiredString5(value, "userId"),
5070
4952
  tenantId: requiredString5(value, "tenantId"),
@@ -5082,8 +4964,7 @@ function hydrateOidcIdentityClaimStatus(value) {
5082
4964
  throw invalidResponse2("Invalid SSO claim status");
5083
4965
  }
5084
4966
  function hydrateOidcIdentityClaim(value) {
5085
- if (!isRecord5(value))
5086
- throw invalidResponse2("Invalid SSO claim");
4967
+ if (!isRecord5(value)) throw invalidResponse2("Invalid SSO claim");
5087
4968
  const name = optionalString(value, "name");
5088
4969
  const picture = optionalString(value, "picture");
5089
4970
  const reviewedBy = optionalString(value, "reviewedBy");
@@ -5098,8 +4979,7 @@ function hydrateOidcIdentityClaim(value) {
5098
4979
  const existing = value.existingUser;
5099
4980
  let existingUser;
5100
4981
  if (existing !== void 0 && existing !== null) {
5101
- if (!isRecord5(existing))
5102
- throw invalidResponse2("Invalid existing user");
4982
+ if (!isRecord5(existing)) throw invalidResponse2("Invalid existing user");
5103
4983
  const platformRole = existing.role !== void 0 ? hydratePlatformRole(existing.role) : existing.platformRole !== void 0 ? hydratePlatformRole(existing.platformRole) : void 0;
5104
4984
  existingUser = {
5105
4985
  id: requiredString5(existing, "id"),
@@ -5141,15 +5021,12 @@ function hydrateTenantStatus(value) {
5141
5021
  }
5142
5022
  function optionalRecord(row, field) {
5143
5023
  const value = row[field];
5144
- if (value === void 0 || value === null)
5145
- return void 0;
5146
- if (!isRecord5(value))
5147
- throw invalidResponse2(`Invalid ${field}`);
5024
+ if (value === void 0 || value === null) return void 0;
5025
+ if (!isRecord5(value)) throw invalidResponse2(`Invalid ${field}`);
5148
5026
  return value;
5149
5027
  }
5150
5028
  function hydrateInviteLink(value) {
5151
- if (!isRecord5(value))
5152
- throw invalidResponse2("Invalid invite link");
5029
+ if (!isRecord5(value)) throw invalidResponse2("Invalid invite link");
5153
5030
  const scope = value.scope;
5154
5031
  if (scope !== "platform" && scope !== "tenant") {
5155
5032
  throw invalidResponse2("Invalid invite scope");
@@ -5175,8 +5052,7 @@ function hydrateInviteLink(value) {
5175
5052
  };
5176
5053
  }
5177
5054
  function hydrateTenant(value) {
5178
- if (!isRecord5(value))
5179
- throw invalidResponse2("Invalid tenant");
5055
+ if (!isRecord5(value)) throw invalidResponse2("Invalid tenant");
5180
5056
  const metadata = optionalRecord(value, "metadata");
5181
5057
  return {
5182
5058
  id: requiredString5(value, "id"),
@@ -5189,8 +5065,7 @@ function hydrateTenant(value) {
5189
5065
  };
5190
5066
  }
5191
5067
  function hydrateUser(value) {
5192
- if (!isRecord5(value))
5193
- throw invalidResponse2("Invalid user");
5068
+ if (!isRecord5(value)) throw invalidResponse2("Invalid user");
5194
5069
  const status = value.status;
5195
5070
  if (status !== "active" && status !== "pending" && status !== "suspended") {
5196
5071
  throw invalidResponse2("Invalid user status");
@@ -5267,8 +5142,7 @@ function hydrateAuditSource(value) {
5267
5142
  throw invalidResponse2("Invalid platform audit source");
5268
5143
  }
5269
5144
  function hydrateAuditAction(value) {
5270
- if (value === "write" || value === "playbook")
5271
- return value;
5145
+ if (value === "write" || value === "playbook") return value;
5272
5146
  throw invalidResponse2("Invalid platform audit action");
5273
5147
  }
5274
5148
  function hydrateAuditStatus(value) {
@@ -5317,8 +5191,7 @@ function hydratePlatformAudit(value) {
5317
5191
  };
5318
5192
  }
5319
5193
  function requireRecordValue(value, message) {
5320
- if (!isRecord5(value))
5321
- throw invalidResponse2(message);
5194
+ if (!isRecord5(value)) throw invalidResponse2(message);
5322
5195
  return value;
5323
5196
  }
5324
5197
  function hydrateModelCatalog(value) {
@@ -5468,10 +5341,8 @@ var PlatformClient = class {
5468
5341
  }
5469
5342
  async me() {
5470
5343
  const data = await this.request("/api/platform/me");
5471
- if (!isRecord5(data))
5472
- throw invalidResponse2("Invalid platform identity");
5473
- if (data.role === null || data.role === void 0)
5474
- return null;
5344
+ if (!isRecord5(data)) throw invalidResponse2("Invalid platform identity");
5345
+ if (data.role === null || data.role === void 0) return null;
5475
5346
  return hydratePlatformRole(data.role);
5476
5347
  }
5477
5348
  /**
@@ -5532,8 +5403,7 @@ var PlatformClient = class {
5532
5403
  async listAudit(query = {}) {
5533
5404
  const search = new URLSearchParams();
5534
5405
  for (const [key, value] of Object.entries(query)) {
5535
- if (value !== void 0)
5536
- search.set(key, String(value));
5406
+ if (value !== void 0) search.set(key, String(value));
5537
5407
  }
5538
5408
  const suffix = search.toString();
5539
5409
  const data = await this.request(
@@ -5586,8 +5456,7 @@ var PlatformClient = class {
5586
5456
  }
5587
5457
  async listTenants() {
5588
5458
  const data = await this.request("/api/tenants");
5589
- if (!Array.isArray(data))
5590
- throw invalidResponse2("Invalid tenant list");
5459
+ if (!Array.isArray(data)) throw invalidResponse2("Invalid tenant list");
5591
5460
  return data.map(hydrateTenant);
5592
5461
  }
5593
5462
  async createTenant(input) {
@@ -5612,8 +5481,7 @@ var PlatformClient = class {
5612
5481
  }
5613
5482
  async listUsers() {
5614
5483
  const data = await this.request("/api/users");
5615
- if (!Array.isArray(data))
5616
- throw invalidResponse2("Invalid user list");
5484
+ if (!Array.isArray(data)) throw invalidResponse2("Invalid user list");
5617
5485
  return data.map(hydrateUser);
5618
5486
  }
5619
5487
  async createUser(input) {
@@ -5637,8 +5505,7 @@ var PlatformClient = class {
5637
5505
  }
5638
5506
  async listMembers() {
5639
5507
  const data = await this.request("/api/platform/members");
5640
- if (!Array.isArray(data))
5641
- throw invalidResponse2("Invalid member list");
5508
+ if (!Array.isArray(data)) throw invalidResponse2("Invalid member list");
5642
5509
  return data.map(hydrateMember3);
5643
5510
  }
5644
5511
  async grantMember(input) {
@@ -5646,8 +5513,7 @@ var PlatformClient = class {
5646
5513
  method: "POST",
5647
5514
  body: JSON.stringify(input)
5648
5515
  });
5649
- if (!isRecord5(data))
5650
- throw invalidResponse2("Invalid platform grant");
5516
+ if (!isRecord5(data)) throw invalidResponse2("Invalid platform grant");
5651
5517
  const member = data.member !== void 0 ? hydrateMember3(data.member) : void 0;
5652
5518
  const invitation = data.invitation !== void 0 ? hydrateInvitation(data.invitation) : void 0;
5653
5519
  if (!member && !invitation) {
@@ -5660,8 +5526,7 @@ var PlatformClient = class {
5660
5526
  }
5661
5527
  async listInvitations() {
5662
5528
  const data = await this.request("/api/platform/invitations");
5663
- if (!Array.isArray(data))
5664
- throw invalidResponse2("Invalid invitation list");
5529
+ if (!Array.isArray(data)) throw invalidResponse2("Invalid invitation list");
5665
5530
  return data.map(hydrateInvitation);
5666
5531
  }
5667
5532
  async revokeInvitation(email) {
@@ -5688,8 +5553,7 @@ var PlatformClient = class {
5688
5553
  const data = await this.request(
5689
5554
  `/api/platform/tenant-members?${query}`
5690
5555
  );
5691
- if (!Array.isArray(data))
5692
- throw invalidResponse2("Invalid tenant member list");
5556
+ if (!Array.isArray(data)) throw invalidResponse2("Invalid tenant member list");
5693
5557
  return data.map(hydrateTenantMember);
5694
5558
  }
5695
5559
  async addTenantMember(input) {
@@ -5701,8 +5565,7 @@ var PlatformClient = class {
5701
5565
  }
5702
5566
  async listInviteLinks() {
5703
5567
  const data = await this.request("/api/platform/invite-links");
5704
- if (!Array.isArray(data))
5705
- throw invalidResponse2("Invalid invite link list");
5568
+ if (!Array.isArray(data)) throw invalidResponse2("Invalid invite link list");
5706
5569
  return data.map(hydrateInviteLink);
5707
5570
  }
5708
5571
  async createInviteLink(input) {
@@ -5761,8 +5624,7 @@ var PlatformClient = class {
5761
5624
  async listOidcClaims(status = "pending") {
5762
5625
  const query = new URLSearchParams({ status }).toString();
5763
5626
  const data = await this.request(`/api/platform/oidc-claims?${query}`);
5764
- if (!Array.isArray(data))
5765
- throw invalidResponse2("Invalid SSO claim list");
5627
+ if (!Array.isArray(data)) throw invalidResponse2("Invalid SSO claim list");
5766
5628
  return data.map(hydrateOidcIdentityClaim);
5767
5629
  }
5768
5630
  async updateOidcClaimEmail(id, email) {
@@ -5807,7 +5669,7 @@ var PlatformClient = class {
5807
5669
  };
5808
5670
 
5809
5671
  // src/client.ts
5810
- var _Client = class extends AbstractClient {
5672
+ var _Client = class _Client extends AbstractClient {
5811
5673
  /**
5812
5674
  * Creates a new Client instance
5813
5675
  * @param config - Configuration options for the client
@@ -6110,8 +5972,7 @@ var _Client = class extends AbstractClient {
6110
5972
  ...this.getAllHeaders()
6111
5973
  };
6112
5974
  const res = await fetch(`${this.config.baseURL}${path}`, { headers, signal });
6113
- if (!res.ok || !res.body)
6114
- throw new Error("Stream connection failed");
5975
+ if (!res.ok || !res.body) throw new Error("Stream connection failed");
6115
5976
  try {
6116
5977
  for await (const frame of parseSseBody(res.body, { strictJsonObject: true })) {
6117
5978
  yield { event: frame.event, data: frame.data };
@@ -6140,8 +6001,7 @@ var _Client = class extends AbstractClient {
6140
6001
  return this.getAllHeaders();
6141
6002
  }
6142
6003
  bodyAffinityHeaders(body) {
6143
- if (!body || typeof body !== "object" || body instanceof FormData)
6144
- return {};
6004
+ if (!body || typeof body !== "object" || body instanceof FormData) return {};
6145
6005
  const threadId = body.thread_id;
6146
6006
  return typeof threadId === "string" ? (0, import_protocols2.threadAffinityHeaders)(threadId) : {};
6147
6007
  }
@@ -6175,8 +6035,7 @@ var _Client = class extends AbstractClient {
6175
6035
  if (!response.body) {
6176
6036
  throw new Error("Response body is null");
6177
6037
  }
6178
- for await (const frame of parseSseBody(response.body, { strictJsonObject: true }))
6179
- onEvent(frame.data);
6038
+ for await (const frame of parseSseBody(response.body, { strictJsonObject: true })) onEvent(frame.data);
6180
6039
  if (onComplete) {
6181
6040
  if (options.enableReturnStateWhenSteamCompleted) {
6182
6041
  try {
@@ -6203,11 +6062,11 @@ var _Client = class extends AbstractClient {
6203
6062
  };
6204
6063
  }
6205
6064
  };
6065
+ _Client.globalWorkspaceHeaders = {};
6206
6066
  var Client = _Client;
6207
- Client.globalWorkspaceHeaders = {};
6208
6067
 
6209
6068
  // src/runtime-client.ts
6210
- var RuntimeAxiomClient = class extends Client {
6069
+ var RuntimeAxiomClient = class _RuntimeAxiomClient extends Client {
6211
6070
  constructor(config) {
6212
6071
  super({
6213
6072
  ...config,
@@ -6234,8 +6093,7 @@ var RuntimeAxiomClient = class extends Client {
6234
6093
  * priming — the first request triggers the token provider.
6235
6094
  */
6236
6095
  async primeToken() {
6237
- if (this.identity.mode !== "verified")
6238
- return "";
6096
+ if (this.identity.mode !== "verified") return "";
6239
6097
  if (!this.tokenPromise) {
6240
6098
  this.tokenPromise = this.identity.tokenProvider().then((token) => {
6241
6099
  this.token = token;
@@ -6284,8 +6142,7 @@ var RuntimeAxiomClient = class extends Client {
6284
6142
  error.status = response.status;
6285
6143
  throw error;
6286
6144
  }
6287
- if (response.status === 204)
6288
- return void 0;
6145
+ if (response.status === 204) return void 0;
6289
6146
  return await response.json();
6290
6147
  }
6291
6148
  getBaseUrl() {
@@ -6297,7 +6154,7 @@ var RuntimeAxiomClient = class extends Client {
6297
6154
  * working (each clone carries its own resolved credential cache).
6298
6155
  */
6299
6156
  createInstance(config) {
6300
- return new RuntimeAxiomClient({
6157
+ return new _RuntimeAxiomClient({
6301
6158
  gatewayUrl: this.gatewayUrl,
6302
6159
  webAppId: this.webAppId,
6303
6160
  identity: this.identity,
@@ -6316,7 +6173,7 @@ var RuntimeAxiomClient = class extends Client {
6316
6173
  // src/wechat-client.ts
6317
6174
  var import_protocols3 = require("@axiom-lattice/protocols");
6318
6175
  var import_encoding = __toESM(require_encoding());
6319
- var WeChatClient = class extends AbstractClient {
6176
+ var WeChatClient = class _WeChatClient extends AbstractClient {
6320
6177
  /**
6321
6178
  * Creates a new WeChatClient instance
6322
6179
  * @param config - Configuration options for the client
@@ -6341,16 +6198,12 @@ var WeChatClient = class extends AbstractClient {
6341
6198
  */
6342
6199
  setWorkspaceContext(workspaceId, projectId) {
6343
6200
  if (workspaceId !== void 0) {
6344
- if (workspaceId)
6345
- this.workspaceHeaders["x-workspace-id"] = workspaceId;
6346
- else
6347
- delete this.workspaceHeaders["x-workspace-id"];
6201
+ if (workspaceId) this.workspaceHeaders["x-workspace-id"] = workspaceId;
6202
+ else delete this.workspaceHeaders["x-workspace-id"];
6348
6203
  }
6349
6204
  if (projectId !== void 0) {
6350
- if (projectId)
6351
- this.workspaceHeaders["x-project-id"] = projectId;
6352
- else
6353
- delete this.workspaceHeaders["x-project-id"];
6205
+ if (projectId) this.workspaceHeaders["x-project-id"] = projectId;
6206
+ else delete this.workspaceHeaders["x-project-id"];
6354
6207
  }
6355
6208
  }
6356
6209
  /**
@@ -6366,7 +6219,7 @@ var WeChatClient = class extends AbstractClient {
6366
6219
  * @returns A new WeChatClient instance
6367
6220
  */
6368
6221
  createInstance(config) {
6369
- return new WeChatClient(config);
6222
+ return new _WeChatClient(config);
6370
6223
  }
6371
6224
  /**
6372
6225
  * Implementation of the abstract makeRequest method for WeChat clients
@@ -6426,8 +6279,7 @@ var WeChatClient = class extends AbstractClient {
6426
6279
  let pending = "";
6427
6280
  const handleLine = (line) => {
6428
6281
  const trimmed = line.trim();
6429
- if (!trimmed.startsWith("data:"))
6430
- return;
6282
+ if (!trimmed.startsWith("data:")) return;
6431
6283
  const payload = trimmed.slice("data:".length);
6432
6284
  const json = payload.startsWith(" ") ? payload.slice(1) : payload;
6433
6285
  try {
@@ -6439,8 +6291,7 @@ var WeChatClient = class extends AbstractClient {
6439
6291
  }
6440
6292
  };
6441
6293
  const push = (res) => {
6442
- if (!res.data)
6443
- return;
6294
+ if (!res.data) return;
6444
6295
  pending += decoder.decode(res.data, { stream: true });
6445
6296
  const lines = pending.split("\n");
6446
6297
  pending = lines.pop();
@@ -6466,8 +6317,7 @@ var WeChatClient = class extends AbstractClient {
6466
6317
  errorMessageFromBody(data) {
6467
6318
  if (typeof data === "string") {
6468
6319
  const text = data.trim();
6469
- if (!text)
6470
- return void 0;
6320
+ if (!text) return void 0;
6471
6321
  try {
6472
6322
  return this.recordMessage(JSON.parse(text));
6473
6323
  } catch {
@@ -6495,8 +6345,7 @@ var WeChatClient = class extends AbstractClient {
6495
6345
  */
6496
6346
  streamStatusError(res) {
6497
6347
  const statusCode = res.statusCode;
6498
- if (statusCode >= 200 && statusCode < 300)
6499
- return void 0;
6348
+ if (statusCode >= 200 && statusCode < 300) return void 0;
6500
6349
  const message = this.errorMessageFromBody(res.data);
6501
6350
  if (statusCode === 401) {
6502
6351
  return new AuthenticationError(message || "Authentication failed");
@@ -6546,26 +6395,22 @@ var WeChatClient = class extends AbstractClient {
6546
6395
  responseType: "text",
6547
6396
  enableChunked: true,
6548
6397
  success: (res) => {
6549
- if (aborted || terminal)
6550
- return;
6398
+ if (aborted || terminal) return;
6551
6399
  const error = this.streamStatusError(res);
6552
6400
  if (error) {
6553
6401
  terminal = true;
6554
- if (onError)
6555
- onError(error);
6402
+ if (onError) onError(error);
6556
6403
  }
6557
6404
  },
6558
6405
  fail: (err) => {
6559
- if (aborted)
6560
- return;
6406
+ if (aborted) return;
6561
6407
  terminal = true;
6562
6408
  if (onError) {
6563
6409
  onError(new Error(`Resume stream request failed: ${err.errMsg}`));
6564
6410
  }
6565
6411
  },
6566
6412
  complete: () => {
6567
- if (terminal)
6568
- return;
6413
+ if (terminal) return;
6569
6414
  processor.flush();
6570
6415
  if (onComplete) {
6571
6416
  onComplete();
@@ -6573,8 +6418,7 @@ var WeChatClient = class extends AbstractClient {
6573
6418
  }
6574
6419
  });
6575
6420
  requestTask.onChunkReceived((res) => {
6576
- if (terminal)
6577
- return;
6421
+ if (terminal) return;
6578
6422
  processor.push(res);
6579
6423
  });
6580
6424
  return () => {
@@ -6661,26 +6505,22 @@ var WeChatClient = class extends AbstractClient {
6661
6505
  responseType: "text",
6662
6506
  enableChunked: true,
6663
6507
  success: (res) => {
6664
- if (aborted || terminal)
6665
- return;
6508
+ if (aborted || terminal) return;
6666
6509
  const error = this.streamStatusError(res);
6667
6510
  if (error) {
6668
6511
  terminal = true;
6669
- if (onError)
6670
- onError(error);
6512
+ if (onError) onError(error);
6671
6513
  }
6672
6514
  },
6673
6515
  fail: (err) => {
6674
- if (aborted)
6675
- return;
6516
+ if (aborted) return;
6676
6517
  terminal = true;
6677
6518
  if (onError) {
6678
6519
  onError(new Error(`Stream request failed: ${err.errMsg}`));
6679
6520
  }
6680
6521
  },
6681
6522
  complete: async () => {
6682
- if (terminal)
6683
- return;
6523
+ if (terminal) return;
6684
6524
  processor.flush();
6685
6525
  if (onComplete) {
6686
6526
  if (options.enableReturnStateWhenSteamCompleted) {
@@ -6697,8 +6537,7 @@ var WeChatClient = class extends AbstractClient {
6697
6537
  }
6698
6538
  });
6699
6539
  requestTask.onChunkReceived((res) => {
6700
- if (terminal)
6701
- return;
6540
+ if (terminal) return;
6702
6541
  processor.push(res);
6703
6542
  });
6704
6543
  return () => {
@@ -6968,8 +6807,7 @@ var WorkspaceClient = class {
6968
6807
  */
6969
6808
  async downloadFolder(workspaceId, projectId, folderPath, assistantId) {
6970
6809
  const params = new URLSearchParams({ path: folderPath, tenantId: this.tenantId });
6971
- if (assistantId)
6972
- params.set("assistantId", assistantId);
6810
+ if (assistantId) params.set("assistantId", assistantId);
6973
6811
  const response = await fetch(
6974
6812
  `${this.baseURL}/api/workspaces/${workspaceId}/projects/${projectId}/downloadfolder?${params}`,
6975
6813
  { headers: this.headers }
@@ -7020,24 +6858,18 @@ var isObj = (v) => typeof v === "object" && v !== null;
7020
6858
  var TEXT_BLOCK_TYPES = /* @__PURE__ */ new Set(["text"]);
7021
6859
  var ARTIFACT_SENTINEL_TYPES = /* @__PURE__ */ new Set(["mcp_structured_content", "mcp_meta"]);
7022
6860
  function asBlocks(value) {
7023
- if (Array.isArray(value))
7024
- return value;
7025
- if (value === void 0 || value === null)
7026
- return [];
6861
+ if (Array.isArray(value)) return value;
6862
+ if (value === void 0 || value === null) return [];
7027
6863
  return [value];
7028
6864
  }
7029
6865
  function looksLikeResource(block) {
7030
6866
  return typeof block.uri === "string" && ("mimeType" in block || "blob" in block || "text" in block);
7031
6867
  }
7032
6868
  function textOf(block, allowUntyped) {
7033
- if (typeof block === "string")
7034
- return block;
7035
- if (!isObj(block) || typeof block.text !== "string")
7036
- return null;
7037
- if (block.type === "text")
7038
- return block.text;
7039
- if (allowUntyped && block.type === void 0 && !looksLikeResource(block))
7040
- return block.text;
6869
+ if (typeof block === "string") return block;
6870
+ if (!isObj(block) || typeof block.text !== "string") return null;
6871
+ if (block.type === "text") return block.text;
6872
+ if (allowUntyped && block.type === void 0 && !looksLikeResource(block)) return block.text;
7041
6873
  return null;
7042
6874
  }
7043
6875
  function joinText(blocks, allowUntyped) {
@@ -7061,15 +6893,13 @@ function structuredFromArtifact(artifact) {
7061
6893
  }
7062
6894
  function metaFromContent(content) {
7063
6895
  for (const block of asBlocks(content)) {
7064
- if (isObj(block) && isObj(block.meta))
7065
- return block.meta;
6896
+ if (isObj(block) && isObj(block.meta)) return block.meta;
7066
6897
  }
7067
6898
  return void 0;
7068
6899
  }
7069
6900
  function metaFromArtifact(artifact) {
7070
6901
  for (const item of asBlocks(artifact)) {
7071
- if (isObj(item) && item.type === "mcp_meta" && isObj(item.data))
7072
- return item.data;
6902
+ if (isObj(item) && item.type === "mcp_meta" && isObj(item.data)) return item.data;
7073
6903
  }
7074
6904
  return void 0;
7075
6905
  }
@@ -7097,22 +6927,17 @@ function normalizeToolResult(message) {
7097
6927
  structuredContent = structuredFromArtifact(message.artifact);
7098
6928
  }
7099
6929
  let meta = metaFromContent(message.content);
7100
- if (meta === void 0)
7101
- meta = metaFromArtifact(message.artifact);
6930
+ if (meta === void 0) meta = metaFromArtifact(message.artifact);
7102
6931
  const artifactBlocks = asBlocks(message.artifact).map(toUiBlock).filter(
7103
6932
  (b) => b !== null && !ARTIFACT_SENTINEL_TYPES.has(b.type)
7104
6933
  );
7105
6934
  const allBlocks = [...contentBlocks, ...artifactBlocks];
7106
6935
  let text = joinText(asBlocks(message.content), true);
7107
- if (text.length === 0)
7108
- text = joinText(asBlocks(message.artifact), false);
6936
+ if (text.length === 0) text = joinText(asBlocks(message.artifact), false);
7109
6937
  const ui = {};
7110
- if (structuredContent !== void 0)
7111
- ui.structuredContent = structuredContent;
7112
- if (meta !== void 0)
7113
- ui.meta = meta;
7114
- if (allBlocks.length > 0)
7115
- ui.contentBlocks = allBlocks;
6938
+ if (structuredContent !== void 0) ui.structuredContent = structuredContent;
6939
+ if (meta !== void 0) ui.meta = meta;
6940
+ if (allBlocks.length > 0) ui.contentBlocks = allBlocks;
7116
6941
  return Object.keys(ui).length > 0 ? { text, ui } : { text };
7117
6942
  }
7118
6943
 
@@ -7176,16 +7001,14 @@ function createSimpleMessageMerger() {
7176
7001
  }
7177
7002
  function replaceMessage(id, updates) {
7178
7003
  const index = messageMap.get(id);
7179
- if (index === void 0)
7180
- return null;
7004
+ if (index === void 0) return null;
7181
7005
  const updated = { ...messages[index], ...updates };
7182
7006
  messages[index] = updated;
7183
7007
  return updated;
7184
7008
  }
7185
7009
  function buildToolCalls(messageId) {
7186
7010
  const builders = toolBuilders.get(messageId);
7187
- if (!builders || builders.size === 0)
7188
- return null;
7011
+ if (!builders || builders.size === 0) return null;
7189
7012
  const toolCalls = [];
7190
7013
  for (const [, builder] of Array.from(builders.entries())) {
7191
7014
  if (builder.name && builder.id) {
@@ -7208,8 +7031,7 @@ function createSimpleMessageMerger() {
7208
7031
  });
7209
7032
  }
7210
7033
  function push(chunk) {
7211
- if (chunk.type === "error")
7212
- return;
7034
+ if (chunk.type === "error") return;
7213
7035
  const role = normalizeRole(chunk.type);
7214
7036
  let message = ensureMessage(chunk.data.id, role);
7215
7037
  if (chunk.data.content && message.role !== "tool") {
@@ -7247,14 +7069,12 @@ function createSimpleMessageMerger() {
7247
7069
  builder = { args: "" };
7248
7070
  builders.set(chunk_item.index, builder);
7249
7071
  }
7250
- if (chunk_item.name)
7251
- builder.name = chunk_item.name;
7072
+ if (chunk_item.name) builder.name = chunk_item.name;
7252
7073
  if (chunk_item.id) {
7253
7074
  builder.id = chunk_item.id;
7254
7075
  toolId_MessageIdMap.set(chunk_item.id, message.id);
7255
7076
  }
7256
- if (chunk_item.args)
7257
- builder.args += chunk_item.args;
7077
+ if (chunk_item.args) builder.args += chunk_item.args;
7258
7078
  }
7259
7079
  const toolCalls = buildToolCalls(message.id);
7260
7080
  if (toolCalls) {
@@ -7264,8 +7084,7 @@ function createSimpleMessageMerger() {
7264
7084
  if (message.role === "tool" && chunk.data.tool_call_id) {
7265
7085
  const original_tool_message_id = chunk.data.id;
7266
7086
  const messageId = toolId_MessageIdMap.get(chunk.data.tool_call_id);
7267
- if (!messageId)
7268
- return;
7087
+ if (!messageId) return;
7269
7088
  const messageIndex = messageMap.get(messageId);
7270
7089
  if (messageIndex !== void 0) {
7271
7090
  const { text, ui } = normalizeToolResult({