@gpt-platform/admin 0.1.1

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 ADDED
@@ -0,0 +1,2086 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if ((from && typeof from === "object") || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
17
+ });
18
+ }
19
+ return to;
20
+ };
21
+ var __toCommonJS = (mod) =>
22
+ __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
+
24
+ // src/index.ts
25
+ var index_exports = {};
26
+ __export(index_exports, {
27
+ AccountCreditSchema: () => AccountCreditSchema,
28
+ AccountDebitSchema: () => AccountDebitSchema,
29
+ AgentAdminCreateSchema: () => AgentAdminCreateSchema,
30
+ ApiKeyAllocateSchema: () => ApiKeyAllocateSchema,
31
+ AuthenticationError: () => AuthenticationError,
32
+ AuthorizationError: () => AuthorizationError,
33
+ DEFAULT_API_VERSION: () => DEFAULT_API_VERSION,
34
+ DocumentBulkDeleteSchema: () => DocumentBulkDeleteSchema,
35
+ DocumentBulkReprocessSchema: () => DocumentBulkReprocessSchema,
36
+ GptAdmin: () => GptAdmin,
37
+ GptCoreError: () => GptCoreError,
38
+ NetworkError: () => NetworkError,
39
+ NotFoundError: () => NotFoundError,
40
+ RateLimitError: () => RateLimitError,
41
+ ServerError: () => ServerError,
42
+ StorageStatsRequestSchema: () => StorageStatsRequestSchema,
43
+ TimeoutError: () => TimeoutError,
44
+ ValidationError: () => ValidationError,
45
+ WebhookBulkDisableSchema: () => WebhookBulkDisableSchema,
46
+ WebhookBulkEnableSchema: () => WebhookBulkEnableSchema,
47
+ WebhookConfigCreateSchema: () => WebhookConfigCreateSchema,
48
+ WebhookDeliveryBulkRetrySchema: () => WebhookDeliveryBulkRetrySchema,
49
+ default: () => index_default,
50
+ handleApiError: () => handleApiError,
51
+ });
52
+ module.exports = __toCommonJS(index_exports);
53
+
54
+ // src/_internal/core/bodySerializer.gen.ts
55
+ var jsonBodySerializer = {
56
+ bodySerializer: (body) =>
57
+ JSON.stringify(body, (_key, value) =>
58
+ typeof value === "bigint" ? value.toString() : value,
59
+ ),
60
+ };
61
+
62
+ // src/_internal/core/serverSentEvents.gen.ts
63
+ var createSseClient = ({
64
+ onRequest,
65
+ onSseError,
66
+ onSseEvent,
67
+ responseTransformer,
68
+ responseValidator,
69
+ sseDefaultRetryDelay,
70
+ sseMaxRetryAttempts,
71
+ sseMaxRetryDelay,
72
+ sseSleepFn,
73
+ url,
74
+ ...options
75
+ }) => {
76
+ let lastEventId;
77
+ const sleep =
78
+ sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
79
+ const createStream = async function* () {
80
+ let retryDelay = sseDefaultRetryDelay ?? 3e3;
81
+ let attempt = 0;
82
+ const signal = options.signal ?? new AbortController().signal;
83
+ while (true) {
84
+ if (signal.aborted) break;
85
+ attempt++;
86
+ const headers =
87
+ options.headers instanceof Headers
88
+ ? options.headers
89
+ : new Headers(options.headers);
90
+ if (lastEventId !== void 0) {
91
+ headers.set("Last-Event-ID", lastEventId);
92
+ }
93
+ try {
94
+ const requestInit = {
95
+ redirect: "follow",
96
+ ...options,
97
+ body: options.serializedBody,
98
+ headers,
99
+ signal,
100
+ };
101
+ let request = new Request(url, requestInit);
102
+ if (onRequest) {
103
+ request = await onRequest(url, requestInit);
104
+ }
105
+ const _fetch = options.fetch ?? globalThis.fetch;
106
+ const response = await _fetch(request);
107
+ if (!response.ok)
108
+ throw new Error(
109
+ `SSE failed: ${response.status} ${response.statusText}`,
110
+ );
111
+ if (!response.body) throw new Error("No body in SSE response");
112
+ const reader = response.body
113
+ .pipeThrough(new TextDecoderStream())
114
+ .getReader();
115
+ let buffer = "";
116
+ const abortHandler = () => {
117
+ try {
118
+ reader.cancel();
119
+ } catch {}
120
+ };
121
+ signal.addEventListener("abort", abortHandler);
122
+ try {
123
+ while (true) {
124
+ const { done, value } = await reader.read();
125
+ if (done) break;
126
+ buffer += value;
127
+ buffer = buffer.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
128
+ const chunks = buffer.split("\n\n");
129
+ buffer = chunks.pop() ?? "";
130
+ for (const chunk of chunks) {
131
+ const lines = chunk.split("\n");
132
+ const dataLines = [];
133
+ let eventName;
134
+ for (const line of lines) {
135
+ if (line.startsWith("data:")) {
136
+ dataLines.push(line.replace(/^data:\s*/, ""));
137
+ } else if (line.startsWith("event:")) {
138
+ eventName = line.replace(/^event:\s*/, "");
139
+ } else if (line.startsWith("id:")) {
140
+ lastEventId = line.replace(/^id:\s*/, "");
141
+ } else if (line.startsWith("retry:")) {
142
+ const parsed = Number.parseInt(
143
+ line.replace(/^retry:\s*/, ""),
144
+ 10,
145
+ );
146
+ if (!Number.isNaN(parsed)) {
147
+ retryDelay = parsed;
148
+ }
149
+ }
150
+ }
151
+ let data;
152
+ let parsedJson = false;
153
+ if (dataLines.length) {
154
+ const rawData = dataLines.join("\n");
155
+ try {
156
+ data = JSON.parse(rawData);
157
+ parsedJson = true;
158
+ } catch {
159
+ data = rawData;
160
+ }
161
+ }
162
+ if (parsedJson) {
163
+ if (responseValidator) {
164
+ await responseValidator(data);
165
+ }
166
+ if (responseTransformer) {
167
+ data = await responseTransformer(data);
168
+ }
169
+ }
170
+ onSseEvent?.({
171
+ data,
172
+ event: eventName,
173
+ id: lastEventId,
174
+ retry: retryDelay,
175
+ });
176
+ if (dataLines.length) {
177
+ yield data;
178
+ }
179
+ }
180
+ }
181
+ } finally {
182
+ signal.removeEventListener("abort", abortHandler);
183
+ reader.releaseLock();
184
+ }
185
+ break;
186
+ } catch (error) {
187
+ onSseError?.(error);
188
+ if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
189
+ break;
190
+ }
191
+ const backoff = Math.min(
192
+ retryDelay * 2 ** (attempt - 1),
193
+ sseMaxRetryDelay ?? 3e4,
194
+ );
195
+ await sleep(backoff);
196
+ }
197
+ }
198
+ };
199
+ const stream = createStream();
200
+ return { stream };
201
+ };
202
+
203
+ // src/_internal/core/pathSerializer.gen.ts
204
+ var separatorArrayExplode = (style) => {
205
+ switch (style) {
206
+ case "label":
207
+ return ".";
208
+ case "matrix":
209
+ return ";";
210
+ case "simple":
211
+ return ",";
212
+ default:
213
+ return "&";
214
+ }
215
+ };
216
+ var separatorArrayNoExplode = (style) => {
217
+ switch (style) {
218
+ case "form":
219
+ return ",";
220
+ case "pipeDelimited":
221
+ return "|";
222
+ case "spaceDelimited":
223
+ return "%20";
224
+ default:
225
+ return ",";
226
+ }
227
+ };
228
+ var separatorObjectExplode = (style) => {
229
+ switch (style) {
230
+ case "label":
231
+ return ".";
232
+ case "matrix":
233
+ return ";";
234
+ case "simple":
235
+ return ",";
236
+ default:
237
+ return "&";
238
+ }
239
+ };
240
+ var serializeArrayParam = ({ allowReserved, explode, name, style, value }) => {
241
+ if (!explode) {
242
+ const joinedValues2 = (
243
+ allowReserved ? value : value.map((v) => encodeURIComponent(v))
244
+ ).join(separatorArrayNoExplode(style));
245
+ switch (style) {
246
+ case "label":
247
+ return `.${joinedValues2}`;
248
+ case "matrix":
249
+ return `;${name}=${joinedValues2}`;
250
+ case "simple":
251
+ return joinedValues2;
252
+ default:
253
+ return `${name}=${joinedValues2}`;
254
+ }
255
+ }
256
+ const separator = separatorArrayExplode(style);
257
+ const joinedValues = value
258
+ .map((v) => {
259
+ if (style === "label" || style === "simple") {
260
+ return allowReserved ? v : encodeURIComponent(v);
261
+ }
262
+ return serializePrimitiveParam({
263
+ allowReserved,
264
+ name,
265
+ value: v,
266
+ });
267
+ })
268
+ .join(separator);
269
+ return style === "label" || style === "matrix"
270
+ ? separator + joinedValues
271
+ : joinedValues;
272
+ };
273
+ var serializePrimitiveParam = ({ allowReserved, name, value }) => {
274
+ if (value === void 0 || value === null) {
275
+ return "";
276
+ }
277
+ if (typeof value === "object") {
278
+ throw new Error(
279
+ "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.",
280
+ );
281
+ }
282
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
283
+ };
284
+ var serializeObjectParam = ({
285
+ allowReserved,
286
+ explode,
287
+ name,
288
+ style,
289
+ value,
290
+ valueOnly,
291
+ }) => {
292
+ if (value instanceof Date) {
293
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
294
+ }
295
+ if (style !== "deepObject" && !explode) {
296
+ let values = [];
297
+ Object.entries(value).forEach(([key, v]) => {
298
+ values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
299
+ });
300
+ const joinedValues2 = values.join(",");
301
+ switch (style) {
302
+ case "form":
303
+ return `${name}=${joinedValues2}`;
304
+ case "label":
305
+ return `.${joinedValues2}`;
306
+ case "matrix":
307
+ return `;${name}=${joinedValues2}`;
308
+ default:
309
+ return joinedValues2;
310
+ }
311
+ }
312
+ const separator = separatorObjectExplode(style);
313
+ const joinedValues = Object.entries(value)
314
+ .map(([key, v]) =>
315
+ serializePrimitiveParam({
316
+ allowReserved,
317
+ name: style === "deepObject" ? `${name}[${key}]` : key,
318
+ value: v,
319
+ }),
320
+ )
321
+ .join(separator);
322
+ return style === "label" || style === "matrix"
323
+ ? separator + joinedValues
324
+ : joinedValues;
325
+ };
326
+
327
+ // src/_internal/core/utils.gen.ts
328
+ var PATH_PARAM_RE = /\{[^{}]+\}/g;
329
+ var defaultPathSerializer = ({ path, url: _url }) => {
330
+ let url = _url;
331
+ const matches = _url.match(PATH_PARAM_RE);
332
+ if (matches) {
333
+ for (const match of matches) {
334
+ let explode = false;
335
+ let name = match.substring(1, match.length - 1);
336
+ let style = "simple";
337
+ if (name.endsWith("*")) {
338
+ explode = true;
339
+ name = name.substring(0, name.length - 1);
340
+ }
341
+ if (name.startsWith(".")) {
342
+ name = name.substring(1);
343
+ style = "label";
344
+ } else if (name.startsWith(";")) {
345
+ name = name.substring(1);
346
+ style = "matrix";
347
+ }
348
+ const value = path[name];
349
+ if (value === void 0 || value === null) {
350
+ continue;
351
+ }
352
+ if (Array.isArray(value)) {
353
+ url = url.replace(
354
+ match,
355
+ serializeArrayParam({ explode, name, style, value }),
356
+ );
357
+ continue;
358
+ }
359
+ if (typeof value === "object") {
360
+ url = url.replace(
361
+ match,
362
+ serializeObjectParam({
363
+ explode,
364
+ name,
365
+ style,
366
+ value,
367
+ valueOnly: true,
368
+ }),
369
+ );
370
+ continue;
371
+ }
372
+ if (style === "matrix") {
373
+ url = url.replace(
374
+ match,
375
+ `;${serializePrimitiveParam({
376
+ name,
377
+ value,
378
+ })}`,
379
+ );
380
+ continue;
381
+ }
382
+ const replaceValue = encodeURIComponent(
383
+ style === "label" ? `.${value}` : value,
384
+ );
385
+ url = url.replace(match, replaceValue);
386
+ }
387
+ }
388
+ return url;
389
+ };
390
+ var getUrl = ({ baseUrl, path, query, querySerializer, url: _url }) => {
391
+ const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
392
+ let url = (baseUrl ?? "") + pathUrl;
393
+ if (path) {
394
+ url = defaultPathSerializer({ path, url });
395
+ }
396
+ let search = query ? querySerializer(query) : "";
397
+ if (search.startsWith("?")) {
398
+ search = search.substring(1);
399
+ }
400
+ if (search) {
401
+ url += `?${search}`;
402
+ }
403
+ return url;
404
+ };
405
+ function getValidRequestBody(options) {
406
+ const hasBody = options.body !== void 0;
407
+ const isSerializedBody = hasBody && options.bodySerializer;
408
+ if (isSerializedBody) {
409
+ if ("serializedBody" in options) {
410
+ const hasSerializedBody =
411
+ options.serializedBody !== void 0 && options.serializedBody !== "";
412
+ return hasSerializedBody ? options.serializedBody : null;
413
+ }
414
+ return options.body !== "" ? options.body : null;
415
+ }
416
+ if (hasBody) {
417
+ return options.body;
418
+ }
419
+ return void 0;
420
+ }
421
+
422
+ // src/_internal/core/auth.gen.ts
423
+ var getAuthToken = async (auth, callback) => {
424
+ const token =
425
+ typeof callback === "function" ? await callback(auth) : callback;
426
+ if (!token) {
427
+ return;
428
+ }
429
+ if (auth.scheme === "bearer") {
430
+ return `Bearer ${token}`;
431
+ }
432
+ if (auth.scheme === "basic") {
433
+ return `Basic ${btoa(token)}`;
434
+ }
435
+ return token;
436
+ };
437
+
438
+ // src/_internal/client/utils.gen.ts
439
+ var createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
440
+ const querySerializer = (queryParams) => {
441
+ const search = [];
442
+ if (queryParams && typeof queryParams === "object") {
443
+ for (const name in queryParams) {
444
+ const value = queryParams[name];
445
+ if (value === void 0 || value === null) {
446
+ continue;
447
+ }
448
+ const options = parameters[name] || args;
449
+ if (Array.isArray(value)) {
450
+ const serializedArray = serializeArrayParam({
451
+ allowReserved: options.allowReserved,
452
+ explode: true,
453
+ name,
454
+ style: "form",
455
+ value,
456
+ ...options.array,
457
+ });
458
+ if (serializedArray) search.push(serializedArray);
459
+ } else if (typeof value === "object") {
460
+ const serializedObject = serializeObjectParam({
461
+ allowReserved: options.allowReserved,
462
+ explode: true,
463
+ name,
464
+ style: "deepObject",
465
+ value,
466
+ ...options.object,
467
+ });
468
+ if (serializedObject) search.push(serializedObject);
469
+ } else {
470
+ const serializedPrimitive = serializePrimitiveParam({
471
+ allowReserved: options.allowReserved,
472
+ name,
473
+ value,
474
+ });
475
+ if (serializedPrimitive) search.push(serializedPrimitive);
476
+ }
477
+ }
478
+ }
479
+ return search.join("&");
480
+ };
481
+ return querySerializer;
482
+ };
483
+ var getParseAs = (contentType) => {
484
+ if (!contentType) {
485
+ return "stream";
486
+ }
487
+ const cleanContent = contentType.split(";")[0]?.trim();
488
+ if (!cleanContent) {
489
+ return;
490
+ }
491
+ if (
492
+ cleanContent.startsWith("application/json") ||
493
+ cleanContent.endsWith("+json")
494
+ ) {
495
+ return "json";
496
+ }
497
+ if (cleanContent === "multipart/form-data") {
498
+ return "formData";
499
+ }
500
+ if (
501
+ ["application/", "audio/", "image/", "video/"].some((type) =>
502
+ cleanContent.startsWith(type),
503
+ )
504
+ ) {
505
+ return "blob";
506
+ }
507
+ if (cleanContent.startsWith("text/")) {
508
+ return "text";
509
+ }
510
+ return;
511
+ };
512
+ var checkForExistence = (options, name) => {
513
+ if (!name) {
514
+ return false;
515
+ }
516
+ if (
517
+ options.headers.has(name) ||
518
+ options.query?.[name] ||
519
+ options.headers.get("Cookie")?.includes(`${name}=`)
520
+ ) {
521
+ return true;
522
+ }
523
+ return false;
524
+ };
525
+ var setAuthParams = async ({ security, ...options }) => {
526
+ for (const auth of security) {
527
+ if (checkForExistence(options, auth.name)) {
528
+ continue;
529
+ }
530
+ const token = await getAuthToken(auth, options.auth);
531
+ if (!token) {
532
+ continue;
533
+ }
534
+ const name = auth.name ?? "Authorization";
535
+ switch (auth.in) {
536
+ case "query":
537
+ if (!options.query) {
538
+ options.query = {};
539
+ }
540
+ options.query[name] = token;
541
+ break;
542
+ case "cookie":
543
+ options.headers.append("Cookie", `${name}=${token}`);
544
+ break;
545
+ case "header":
546
+ default:
547
+ options.headers.set(name, token);
548
+ break;
549
+ }
550
+ }
551
+ };
552
+ var buildUrl = (options) =>
553
+ getUrl({
554
+ baseUrl: options.baseUrl,
555
+ path: options.path,
556
+ query: options.query,
557
+ querySerializer:
558
+ typeof options.querySerializer === "function"
559
+ ? options.querySerializer
560
+ : createQuerySerializer(options.querySerializer),
561
+ url: options.url,
562
+ });
563
+ var mergeConfigs = (a, b) => {
564
+ const config = { ...a, ...b };
565
+ if (config.baseUrl?.endsWith("/")) {
566
+ config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
567
+ }
568
+ config.headers = mergeHeaders(a.headers, b.headers);
569
+ return config;
570
+ };
571
+ var headersEntries = (headers) => {
572
+ const entries = [];
573
+ headers.forEach((value, key) => {
574
+ entries.push([key, value]);
575
+ });
576
+ return entries;
577
+ };
578
+ var mergeHeaders = (...headers) => {
579
+ const mergedHeaders = new Headers();
580
+ for (const header of headers) {
581
+ if (!header) {
582
+ continue;
583
+ }
584
+ const iterator =
585
+ header instanceof Headers
586
+ ? headersEntries(header)
587
+ : Object.entries(header);
588
+ for (const [key, value] of iterator) {
589
+ if (value === null) {
590
+ mergedHeaders.delete(key);
591
+ } else if (Array.isArray(value)) {
592
+ for (const v of value) {
593
+ mergedHeaders.append(key, v);
594
+ }
595
+ } else if (value !== void 0) {
596
+ mergedHeaders.set(
597
+ key,
598
+ typeof value === "object" ? JSON.stringify(value) : value,
599
+ );
600
+ }
601
+ }
602
+ }
603
+ return mergedHeaders;
604
+ };
605
+ var Interceptors = class {
606
+ constructor() {
607
+ this.fns = [];
608
+ }
609
+ clear() {
610
+ this.fns = [];
611
+ }
612
+ eject(id) {
613
+ const index = this.getInterceptorIndex(id);
614
+ if (this.fns[index]) {
615
+ this.fns[index] = null;
616
+ }
617
+ }
618
+ exists(id) {
619
+ const index = this.getInterceptorIndex(id);
620
+ return Boolean(this.fns[index]);
621
+ }
622
+ getInterceptorIndex(id) {
623
+ if (typeof id === "number") {
624
+ return this.fns[id] ? id : -1;
625
+ }
626
+ return this.fns.indexOf(id);
627
+ }
628
+ update(id, fn) {
629
+ const index = this.getInterceptorIndex(id);
630
+ if (this.fns[index]) {
631
+ this.fns[index] = fn;
632
+ return id;
633
+ }
634
+ return false;
635
+ }
636
+ use(fn) {
637
+ this.fns.push(fn);
638
+ return this.fns.length - 1;
639
+ }
640
+ };
641
+ var createInterceptors = () => ({
642
+ error: new Interceptors(),
643
+ request: new Interceptors(),
644
+ response: new Interceptors(),
645
+ });
646
+ var defaultQuerySerializer = createQuerySerializer({
647
+ allowReserved: false,
648
+ array: {
649
+ explode: true,
650
+ style: "form",
651
+ },
652
+ object: {
653
+ explode: true,
654
+ style: "deepObject",
655
+ },
656
+ });
657
+ var defaultHeaders = {
658
+ "Content-Type": "application/json",
659
+ };
660
+ var createConfig = (override = {}) => ({
661
+ ...jsonBodySerializer,
662
+ headers: defaultHeaders,
663
+ parseAs: "auto",
664
+ querySerializer: defaultQuerySerializer,
665
+ ...override,
666
+ });
667
+
668
+ // src/_internal/client/client.gen.ts
669
+ var createClient = (config = {}) => {
670
+ let _config = mergeConfigs(createConfig(), config);
671
+ const getConfig = () => ({ ..._config });
672
+ const setConfig = (config2) => {
673
+ _config = mergeConfigs(_config, config2);
674
+ return getConfig();
675
+ };
676
+ const interceptors = createInterceptors();
677
+ const beforeRequest = async (options) => {
678
+ const opts = {
679
+ ..._config,
680
+ ...options,
681
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
682
+ headers: mergeHeaders(_config.headers, options.headers),
683
+ serializedBody: void 0,
684
+ };
685
+ if (opts.security) {
686
+ await setAuthParams({
687
+ ...opts,
688
+ security: opts.security,
689
+ });
690
+ }
691
+ if (opts.requestValidator) {
692
+ await opts.requestValidator(opts);
693
+ }
694
+ if (opts.body !== void 0 && opts.bodySerializer) {
695
+ opts.serializedBody = opts.bodySerializer(opts.body);
696
+ }
697
+ if (opts.body === void 0 || opts.serializedBody === "") {
698
+ opts.headers.delete("Content-Type");
699
+ }
700
+ const url = buildUrl(opts);
701
+ return { opts, url };
702
+ };
703
+ const request = async (options) => {
704
+ const { opts, url } = await beforeRequest(options);
705
+ const requestInit = {
706
+ redirect: "follow",
707
+ ...opts,
708
+ body: getValidRequestBody(opts),
709
+ };
710
+ let request2 = new Request(url, requestInit);
711
+ for (const fn of interceptors.request.fns) {
712
+ if (fn) {
713
+ request2 = await fn(request2, opts);
714
+ }
715
+ }
716
+ const _fetch = opts.fetch;
717
+ let response;
718
+ try {
719
+ response = await _fetch(request2);
720
+ } catch (error2) {
721
+ let finalError2 = error2;
722
+ for (const fn of interceptors.error.fns) {
723
+ if (fn) {
724
+ finalError2 = await fn(error2, void 0, request2, opts);
725
+ }
726
+ }
727
+ finalError2 = finalError2 || {};
728
+ if (opts.throwOnError) {
729
+ throw finalError2;
730
+ }
731
+ return opts.responseStyle === "data"
732
+ ? void 0
733
+ : {
734
+ error: finalError2,
735
+ request: request2,
736
+ response: void 0,
737
+ };
738
+ }
739
+ for (const fn of interceptors.response.fns) {
740
+ if (fn) {
741
+ response = await fn(response, request2, opts);
742
+ }
743
+ }
744
+ const result = {
745
+ request: request2,
746
+ response,
747
+ };
748
+ if (response.ok) {
749
+ const parseAs =
750
+ (opts.parseAs === "auto"
751
+ ? getParseAs(response.headers.get("Content-Type"))
752
+ : opts.parseAs) ?? "json";
753
+ if (
754
+ response.status === 204 ||
755
+ response.headers.get("Content-Length") === "0"
756
+ ) {
757
+ let emptyData;
758
+ switch (parseAs) {
759
+ case "arrayBuffer":
760
+ case "blob":
761
+ case "text":
762
+ emptyData = await response[parseAs]();
763
+ break;
764
+ case "formData":
765
+ emptyData = new FormData();
766
+ break;
767
+ case "stream":
768
+ emptyData = response.body;
769
+ break;
770
+ case "json":
771
+ default:
772
+ emptyData = {};
773
+ break;
774
+ }
775
+ return opts.responseStyle === "data"
776
+ ? emptyData
777
+ : {
778
+ data: emptyData,
779
+ ...result,
780
+ };
781
+ }
782
+ let data;
783
+ switch (parseAs) {
784
+ case "arrayBuffer":
785
+ case "blob":
786
+ case "formData":
787
+ case "json":
788
+ case "text":
789
+ data = await response[parseAs]();
790
+ break;
791
+ case "stream":
792
+ return opts.responseStyle === "data"
793
+ ? response.body
794
+ : {
795
+ data: response.body,
796
+ ...result,
797
+ };
798
+ }
799
+ if (parseAs === "json") {
800
+ if (opts.responseValidator) {
801
+ await opts.responseValidator(data);
802
+ }
803
+ if (opts.responseTransformer) {
804
+ data = await opts.responseTransformer(data);
805
+ }
806
+ }
807
+ return opts.responseStyle === "data"
808
+ ? data
809
+ : {
810
+ data,
811
+ ...result,
812
+ };
813
+ }
814
+ const textError = await response.text();
815
+ let jsonError;
816
+ try {
817
+ jsonError = JSON.parse(textError);
818
+ } catch {}
819
+ const error = jsonError ?? textError;
820
+ let finalError = error;
821
+ for (const fn of interceptors.error.fns) {
822
+ if (fn) {
823
+ finalError = await fn(error, response, request2, opts);
824
+ }
825
+ }
826
+ finalError = finalError || {};
827
+ if (opts.throwOnError) {
828
+ throw finalError;
829
+ }
830
+ return opts.responseStyle === "data"
831
+ ? void 0
832
+ : {
833
+ error: finalError,
834
+ ...result,
835
+ };
836
+ };
837
+ const makeMethodFn = (method) => (options) => request({ ...options, method });
838
+ const makeSseFn = (method) => async (options) => {
839
+ const { opts, url } = await beforeRequest(options);
840
+ return createSseClient({
841
+ ...opts,
842
+ body: opts.body,
843
+ headers: opts.headers,
844
+ method,
845
+ onRequest: async (url2, init) => {
846
+ let request2 = new Request(url2, init);
847
+ for (const fn of interceptors.request.fns) {
848
+ if (fn) {
849
+ request2 = await fn(request2, opts);
850
+ }
851
+ }
852
+ return request2;
853
+ },
854
+ url,
855
+ });
856
+ };
857
+ return {
858
+ buildUrl,
859
+ connect: makeMethodFn("CONNECT"),
860
+ delete: makeMethodFn("DELETE"),
861
+ get: makeMethodFn("GET"),
862
+ getConfig,
863
+ head: makeMethodFn("HEAD"),
864
+ interceptors,
865
+ options: makeMethodFn("OPTIONS"),
866
+ patch: makeMethodFn("PATCH"),
867
+ post: makeMethodFn("POST"),
868
+ put: makeMethodFn("PUT"),
869
+ request,
870
+ setConfig,
871
+ sse: {
872
+ connect: makeSseFn("CONNECT"),
873
+ delete: makeSseFn("DELETE"),
874
+ get: makeSseFn("GET"),
875
+ head: makeSseFn("HEAD"),
876
+ options: makeSseFn("OPTIONS"),
877
+ patch: makeSseFn("PATCH"),
878
+ post: makeSseFn("POST"),
879
+ put: makeSseFn("PUT"),
880
+ trace: makeSseFn("TRACE"),
881
+ },
882
+ trace: makeMethodFn("TRACE"),
883
+ };
884
+ };
885
+
886
+ // src/_internal/client.gen.ts
887
+ var client = createClient(createConfig({ baseUrl: "http://localhost:33333" }));
888
+
889
+ // src/base-client.ts
890
+ var DEFAULT_API_VERSION = "2025-12-03";
891
+ function isSecureUrl(url) {
892
+ try {
893
+ const parsed = new URL(url);
894
+ if (parsed.protocol === "https:") return true;
895
+ if (parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1")
896
+ return true;
897
+ return false;
898
+ } catch {
899
+ return false;
900
+ }
901
+ }
902
+ var BaseClient = class {
903
+ constructor(config = {}) {
904
+ /** The underlying HTTP client instance, exposed for namespace factories */
905
+ this.clientInstance = client;
906
+ this.config = config;
907
+ this.apiVersion = config.apiVersion ?? DEFAULT_API_VERSION;
908
+ if (config.baseUrl && !isSecureUrl(config.baseUrl)) {
909
+ console.warn(
910
+ "[GPT Core SDK] Warning: Using non-HTTPS URL. Credentials may be transmitted insecurely. Use HTTPS in production environments.",
911
+ );
912
+ }
913
+ if (config.baseUrl) {
914
+ client.setConfig({ baseUrl: config.baseUrl });
915
+ }
916
+ client.interceptors.request.use((req) => {
917
+ const requestUrl = req.url || config.baseUrl || "";
918
+ if ((config.apiKey || config.token) && !isSecureUrl(requestUrl)) {
919
+ console.warn(
920
+ "[GPT Core SDK] Warning: Sending credentials over non-HTTPS connection.",
921
+ );
922
+ }
923
+ req.headers.set(
924
+ "Accept",
925
+ `application/vnd.api+json; version=${this.apiVersion}`,
926
+ );
927
+ req.headers.set("Content-Type", "application/vnd.api+json");
928
+ if (config.apiKey) {
929
+ req.headers.set("x-application-key", config.apiKey);
930
+ }
931
+ if (config.applicationId) {
932
+ req.headers.set("x-application-id", config.applicationId);
933
+ }
934
+ if (config.token) {
935
+ req.headers.set("Authorization", `Bearer ${config.token}`);
936
+ }
937
+ return req;
938
+ });
939
+ }
940
+ async requestWithRetry(fn) {
941
+ return fn();
942
+ }
943
+ unwrap(resource) {
944
+ if (!resource) return null;
945
+ const obj = resource;
946
+ if (obj.data && !obj.id && !obj.type) {
947
+ return obj.data;
948
+ }
949
+ return resource;
950
+ }
951
+ getHeaders() {
952
+ return {
953
+ "x-application-key": this.config.apiKey || "",
954
+ };
955
+ }
956
+ };
957
+
958
+ // src/errors/index.ts
959
+ var GptCoreError = class extends Error {
960
+ constructor(message, options) {
961
+ super(message);
962
+ this.name = this.constructor.name;
963
+ this.statusCode = options?.statusCode;
964
+ this.code = options?.code;
965
+ this.requestId = options?.requestId;
966
+ this.headers = options?.headers;
967
+ this.body = options?.body;
968
+ this.cause = options?.cause;
969
+ if (Error.captureStackTrace) {
970
+ Error.captureStackTrace(this, this.constructor);
971
+ }
972
+ }
973
+ };
974
+ var AuthenticationError = class extends GptCoreError {
975
+ constructor(message = "Authentication failed", options) {
976
+ super(message, { statusCode: 401, ...options });
977
+ }
978
+ };
979
+ var AuthorizationError = class extends GptCoreError {
980
+ constructor(message = "Permission denied", options) {
981
+ super(message, { statusCode: 403, ...options });
982
+ }
983
+ };
984
+ var NotFoundError = class extends GptCoreError {
985
+ constructor(message = "Resource not found", options) {
986
+ super(message, { statusCode: 404, ...options });
987
+ }
988
+ };
989
+ var ValidationError = class extends GptCoreError {
990
+ constructor(message = "Validation failed", errors, options) {
991
+ super(message, { statusCode: 422, ...options });
992
+ this.errors = errors;
993
+ }
994
+ };
995
+ var RateLimitError = class extends GptCoreError {
996
+ constructor(message = "Rate limit exceeded", retryAfter, options) {
997
+ super(message, { statusCode: 429, ...options });
998
+ this.retryAfter = retryAfter;
999
+ }
1000
+ };
1001
+ var NetworkError = class extends GptCoreError {
1002
+ constructor(message = "Network request failed", options) {
1003
+ super(message, options);
1004
+ }
1005
+ };
1006
+ var TimeoutError = class extends GptCoreError {
1007
+ constructor(message = "Request timeout", options) {
1008
+ super(message, options);
1009
+ }
1010
+ };
1011
+ var ServerError = class extends GptCoreError {
1012
+ constructor(message = "Internal server error", options) {
1013
+ super(message, { statusCode: 500, ...options });
1014
+ }
1015
+ };
1016
+ function handleApiError(error) {
1017
+ const err = error;
1018
+ const response = err?.response || err;
1019
+ const statusCode = response?.status || err?.status || err?.statusCode;
1020
+ const headers = response?.headers || err?.headers;
1021
+ const requestId = headers?.get?.("x-request-id") || headers?.["x-request-id"];
1022
+ const body =
1023
+ response?.body || response?.data || err?.body || err?.data || err;
1024
+ let message = "An error occurred";
1025
+ let errors;
1026
+ const bodyObj = body;
1027
+ if (bodyObj?.errors && Array.isArray(bodyObj.errors)) {
1028
+ const firstError = bodyObj.errors[0];
1029
+ message = firstError?.title || firstError?.detail || message;
1030
+ errors = bodyObj.errors.map((e) => ({
1031
+ field: e.source?.pointer?.split("/").pop(),
1032
+ message: e.detail || e.title || "Unknown error",
1033
+ }));
1034
+ } else if (bodyObj?.message) {
1035
+ message = bodyObj.message;
1036
+ } else if (typeof body === "string") {
1037
+ message = body;
1038
+ } else if (err?.message) {
1039
+ message = err.message;
1040
+ }
1041
+ const sensitiveHeaderPatterns = [
1042
+ "set-cookie",
1043
+ "authorization",
1044
+ "x-application-key",
1045
+ "cookie",
1046
+ "x-forwarded-for",
1047
+ "x-real-ip",
1048
+ ];
1049
+ const filterSensitiveHeaders = (hdrs) => {
1050
+ if (!hdrs) return void 0;
1051
+ const entries =
1052
+ hdrs instanceof Headers
1053
+ ? Array.from(hdrs.entries())
1054
+ : Object.entries(hdrs);
1055
+ const filtered = entries.filter(([key]) => {
1056
+ const lowerKey = key.toLowerCase();
1057
+ return !sensitiveHeaderPatterns.some((pattern) =>
1058
+ lowerKey.includes(pattern),
1059
+ );
1060
+ });
1061
+ return filtered.length > 0 ? Object.fromEntries(filtered) : void 0;
1062
+ };
1063
+ const errorOptions = {
1064
+ statusCode,
1065
+ requestId,
1066
+ headers: filterSensitiveHeaders(headers),
1067
+ body,
1068
+ cause: error instanceof Error ? error : void 0,
1069
+ };
1070
+ switch (statusCode) {
1071
+ case 401:
1072
+ throw new AuthenticationError(message, errorOptions);
1073
+ case 403:
1074
+ throw new AuthorizationError(message, errorOptions);
1075
+ case 404:
1076
+ throw new NotFoundError(message, errorOptions);
1077
+ case 400:
1078
+ case 422:
1079
+ throw new ValidationError(message, errors, errorOptions);
1080
+ case 429: {
1081
+ const retryAfter =
1082
+ headers?.get?.("retry-after") || headers?.["retry-after"];
1083
+ throw new RateLimitError(
1084
+ message,
1085
+ retryAfter ? parseInt(retryAfter, 10) : void 0,
1086
+ errorOptions,
1087
+ );
1088
+ }
1089
+ case 500:
1090
+ case 502:
1091
+ case 503:
1092
+ case 504:
1093
+ throw new ServerError(message, errorOptions);
1094
+ default:
1095
+ if (statusCode && statusCode >= 400) {
1096
+ throw new GptCoreError(message, errorOptions);
1097
+ }
1098
+ throw new NetworkError(message, errorOptions);
1099
+ }
1100
+ }
1101
+
1102
+ // src/streaming.ts
1103
+ var DEFAULT_STREAM_TIMEOUT = 3e5;
1104
+ var DEFAULT_MAX_CHUNKS = 1e4;
1105
+ var DEFAULT_MAX_BUFFER_SIZE = 10 * 1024 * 1024;
1106
+ async function* streamSSE(response, options = {}) {
1107
+ if (!response.body) {
1108
+ throw new GptCoreError("Response body is null", { code: "stream_error" });
1109
+ }
1110
+ const reader = response.body.getReader();
1111
+ const decoder = new TextDecoder();
1112
+ let buffer = "";
1113
+ const timeout = options.timeout ?? DEFAULT_STREAM_TIMEOUT;
1114
+ const maxChunks = options.maxChunks ?? DEFAULT_MAX_CHUNKS;
1115
+ const maxBufferSize = options.maxBufferSize ?? DEFAULT_MAX_BUFFER_SIZE;
1116
+ const startTime = Date.now();
1117
+ let chunkCount = 0;
1118
+ let bufferSize = 0;
1119
+ try {
1120
+ while (true) {
1121
+ const elapsed = Date.now() - startTime;
1122
+ if (elapsed > timeout) {
1123
+ reader.cancel();
1124
+ throw new TimeoutError(
1125
+ `Stream timeout exceeded after ${elapsed}ms (limit: ${timeout}ms)`,
1126
+ );
1127
+ }
1128
+ if (chunkCount >= maxChunks) {
1129
+ reader.cancel();
1130
+ throw new GptCoreError(`Maximum chunk limit exceeded (${maxChunks})`, {
1131
+ code: "stream_limit_exceeded",
1132
+ });
1133
+ }
1134
+ const { done, value } = await reader.read();
1135
+ if (done) break;
1136
+ if (options.signal?.aborted) {
1137
+ reader.cancel();
1138
+ throw new Error("Stream aborted");
1139
+ }
1140
+ bufferSize += value.length;
1141
+ if (bufferSize > maxBufferSize) {
1142
+ reader.cancel();
1143
+ throw new GptCoreError(
1144
+ `Stream buffer size exceeded (${bufferSize} bytes, limit: ${maxBufferSize})`,
1145
+ { code: "stream_limit_exceeded" },
1146
+ );
1147
+ }
1148
+ buffer += decoder.decode(value, { stream: true });
1149
+ const lines = buffer.split("\n");
1150
+ buffer = lines.pop() || "";
1151
+ for (const line of lines) {
1152
+ if (line.startsWith("data: ")) {
1153
+ const data = line.slice(6);
1154
+ if (data === "[DONE]" || data.trim() === "") continue;
1155
+ chunkCount++;
1156
+ try {
1157
+ yield JSON.parse(data);
1158
+ } catch {
1159
+ yield {
1160
+ type: "error",
1161
+ error: `Malformed SSE data: ${data.substring(0, 200)}`,
1162
+ };
1163
+ }
1164
+ }
1165
+ }
1166
+ }
1167
+ } catch (error) {
1168
+ if (options.onError) options.onError(error);
1169
+ throw error;
1170
+ } finally {
1171
+ reader.releaseLock();
1172
+ }
1173
+ }
1174
+ async function* streamMessage(response, options = {}) {
1175
+ for await (const chunk of streamSSE(response, options)) {
1176
+ yield chunk;
1177
+ if (chunk.type === "done" || chunk.type === "error") break;
1178
+ }
1179
+ }
1180
+
1181
+ // src/request-builder.ts
1182
+ function buildHeaders(getHeaders, options) {
1183
+ const headers = { ...getHeaders() };
1184
+ if (options?.headers) {
1185
+ Object.assign(headers, options.headers);
1186
+ }
1187
+ if (options?.idempotencyKey) {
1188
+ headers["Idempotency-Key"] = options.idempotencyKey;
1189
+ }
1190
+ return headers;
1191
+ }
1192
+ var RequestBuilder = class {
1193
+ constructor(clientInstance, getHeaders, unwrap, requestWithRetry) {
1194
+ this.clientInstance = clientInstance;
1195
+ this.getHeaders = getHeaders;
1196
+ this.unwrap = unwrap;
1197
+ this.requestWithRetry = requestWithRetry;
1198
+ }
1199
+ /** Get auth headers for manual requests (used by streaming extensions) */
1200
+ getRequestHeaders() {
1201
+ return this.getHeaders();
1202
+ }
1203
+ /**
1204
+ * Execute a generated SDK function with full middleware pipeline.
1205
+ * Handles headers, retry, unwrapping, and error conversion.
1206
+ */
1207
+ async execute(fn, params, options) {
1208
+ const headers = buildHeaders(this.getHeaders, options);
1209
+ try {
1210
+ const { data } = await this.requestWithRetry(() =>
1211
+ fn({
1212
+ client: this.clientInstance,
1213
+ headers,
1214
+ ...params,
1215
+ ...(options?.signal && { signal: options.signal }),
1216
+ }),
1217
+ );
1218
+ return this.unwrap(data?.data);
1219
+ } catch (error) {
1220
+ throw handleApiError(error);
1221
+ }
1222
+ }
1223
+ /**
1224
+ * Execute a delete operation that returns true on success.
1225
+ */
1226
+ async executeDelete(fn, params, options) {
1227
+ const headers = buildHeaders(this.getHeaders, options);
1228
+ try {
1229
+ await this.requestWithRetry(() =>
1230
+ fn({
1231
+ client: this.clientInstance,
1232
+ headers,
1233
+ ...params,
1234
+ ...(options?.signal && { signal: options.signal }),
1235
+ }),
1236
+ );
1237
+ return true;
1238
+ } catch (error) {
1239
+ throw handleApiError(error);
1240
+ }
1241
+ }
1242
+ /**
1243
+ * Execute a raw GET request to a custom (non-generated) endpoint.
1244
+ * Used for endpoints implemented as custom Phoenix controllers.
1245
+ */
1246
+ async rawGet(url, options) {
1247
+ const headers = buildHeaders(this.getHeaders, options);
1248
+ try {
1249
+ const { data } = await this.requestWithRetry(() =>
1250
+ this.clientInstance.get({
1251
+ url,
1252
+ headers,
1253
+ ...(options?.signal && { signal: options.signal }),
1254
+ }),
1255
+ );
1256
+ return this.unwrap(data?.data);
1257
+ } catch (error) {
1258
+ throw handleApiError(error);
1259
+ }
1260
+ }
1261
+ /**
1262
+ * Execute a raw POST request to a custom (non-generated) endpoint.
1263
+ * Used for endpoints implemented as custom Phoenix controllers.
1264
+ */
1265
+ async rawPost(url, body, options) {
1266
+ const headers = buildHeaders(this.getHeaders, options);
1267
+ try {
1268
+ const { data } = await this.requestWithRetry(() =>
1269
+ this.clientInstance.post({
1270
+ url,
1271
+ headers,
1272
+ ...(body !== void 0 && { body: JSON.stringify(body) }),
1273
+ ...(options?.signal && { signal: options.signal }),
1274
+ }),
1275
+ );
1276
+ return this.unwrap(data?.data);
1277
+ } catch (error) {
1278
+ throw handleApiError(error);
1279
+ }
1280
+ }
1281
+ /**
1282
+ * Create a paginated fetcher function for listAll operations.
1283
+ * Encapsulates the pattern of calling a generated SDK function with pagination params.
1284
+ *
1285
+ * @param fn - The generated SDK function (e.g., getAgents)
1286
+ * @param queryBuilder - Function that builds the query object with page params
1287
+ * @param options - Request options (headers, signal, etc.)
1288
+ * @returns A fetcher function for use with paginateToArray
1289
+ */
1290
+ createPaginatedFetcher(fn, queryBuilder, options) {
1291
+ return async (page, pageSize) => {
1292
+ const headers = buildHeaders(this.getHeaders, options);
1293
+ const { data } = await this.requestWithRetry(() =>
1294
+ fn({
1295
+ client: this.clientInstance,
1296
+ headers,
1297
+ ...(options?.signal && { signal: options.signal }),
1298
+ ...queryBuilder(page, pageSize),
1299
+ }),
1300
+ );
1301
+ const envelope = data;
1302
+ const items = this.unwrap(envelope.data) || [];
1303
+ return { data: items, links: envelope.links };
1304
+ };
1305
+ }
1306
+ /**
1307
+ * Make a streaming POST request through the client instance,
1308
+ * ensuring all interceptors (auth, events, API version, etc.) fire.
1309
+ *
1310
+ * Uses the client's `post()` method with `parseAs: 'stream'` so the
1311
+ * request/response interceptors execute, then wraps the stream body
1312
+ * into an SSE message iterator.
1313
+ */
1314
+ async streamRequest(url, body, options, streamOptions) {
1315
+ const headers = buildHeaders(this.getHeaders, options);
1316
+ headers["Accept"] = "text/event-stream";
1317
+ const result = await this.clientInstance.post({
1318
+ url,
1319
+ headers,
1320
+ body: JSON.stringify({ data: { type: "message", attributes: body } }),
1321
+ parseAs: "stream",
1322
+ ...(options?.signal && { signal: options.signal }),
1323
+ });
1324
+ const envelope = result;
1325
+ const streamBody = envelope.data ?? result;
1326
+ const response = envelope.response;
1327
+ if (response && !response.ok) {
1328
+ throw new ServerError(`Stream request failed: ${response.status}`, {
1329
+ statusCode: response.status,
1330
+ });
1331
+ }
1332
+ if (streamBody instanceof ReadableStream) {
1333
+ const syntheticResponse = new Response(streamBody, {
1334
+ headers: { "Content-Type": "text/event-stream" },
1335
+ });
1336
+ return streamMessage(syntheticResponse, {
1337
+ signal: options?.signal,
1338
+ ...streamOptions,
1339
+ });
1340
+ }
1341
+ if (streamBody instanceof Response) {
1342
+ if (!streamBody.ok) {
1343
+ throw new ServerError(`Stream request failed: ${streamBody.status}`, {
1344
+ statusCode: streamBody.status,
1345
+ });
1346
+ }
1347
+ return streamMessage(streamBody, {
1348
+ signal: options?.signal,
1349
+ ...streamOptions,
1350
+ });
1351
+ }
1352
+ throw new GptCoreError("Unexpected stream response format", {
1353
+ code: "stream_error",
1354
+ });
1355
+ }
1356
+ /**
1357
+ * Make a streaming GET request through the client instance.
1358
+ * Used for subscribing to SSE event streams (e.g., execution streaming).
1359
+ */
1360
+ async streamGetRequest(url, options, streamOptions) {
1361
+ const headers = buildHeaders(this.getHeaders, options);
1362
+ headers["Accept"] = "text/event-stream";
1363
+ const result = await this.clientInstance.get({
1364
+ url,
1365
+ headers,
1366
+ parseAs: "stream",
1367
+ ...(options?.signal && { signal: options.signal }),
1368
+ });
1369
+ const envelope = result;
1370
+ const streamBody = envelope.data ?? result;
1371
+ const response = envelope.response;
1372
+ if (response && !response.ok) {
1373
+ throw new ServerError(`Stream request failed: ${response.status}`, {
1374
+ statusCode: response.status,
1375
+ });
1376
+ }
1377
+ if (streamBody instanceof ReadableStream) {
1378
+ const syntheticResponse = new Response(streamBody, {
1379
+ headers: { "Content-Type": "text/event-stream" },
1380
+ });
1381
+ return streamMessage(syntheticResponse, {
1382
+ signal: options?.signal,
1383
+ ...streamOptions,
1384
+ });
1385
+ }
1386
+ if (streamBody instanceof Response) {
1387
+ if (!streamBody.ok) {
1388
+ throw new ServerError(`Stream request failed: ${streamBody.status}`, {
1389
+ statusCode: streamBody.status,
1390
+ });
1391
+ }
1392
+ return streamMessage(streamBody, {
1393
+ signal: options?.signal,
1394
+ ...streamOptions,
1395
+ });
1396
+ }
1397
+ throw new GptCoreError("Unexpected stream response format", {
1398
+ code: "stream_error",
1399
+ });
1400
+ }
1401
+ };
1402
+
1403
+ // src/_internal/sdk.gen.ts
1404
+ var patchAdminAccountsByIdCredit = (options) =>
1405
+ (options.client ?? client).patch({
1406
+ security: [{ scheme: "bearer", type: "http" }],
1407
+ url: "/admin/accounts/{id}/credit",
1408
+ ...options,
1409
+ headers: {
1410
+ "Content-Type": "application/vnd.api+json",
1411
+ ...options.headers,
1412
+ },
1413
+ });
1414
+ var getAdminWebhookDeliveriesById = (options) =>
1415
+ (options.client ?? client).get({
1416
+ security: [{ scheme: "bearer", type: "http" }],
1417
+ url: "/admin/webhook-deliveries/{id}",
1418
+ ...options,
1419
+ });
1420
+ var getAdminApiKeysById = (options) =>
1421
+ (options.client ?? client).get({
1422
+ security: [{ scheme: "bearer", type: "http" }],
1423
+ url: "/admin/api-keys/{id}",
1424
+ ...options,
1425
+ });
1426
+ var deleteAdminWebhookConfigsById = (options) =>
1427
+ (options.client ?? client).delete({
1428
+ security: [{ scheme: "bearer", type: "http" }],
1429
+ url: "/admin/webhook-configs/{id}",
1430
+ ...options,
1431
+ });
1432
+ var getAdminWebhookConfigsById = (options) =>
1433
+ (options.client ?? client).get({
1434
+ security: [{ scheme: "bearer", type: "http" }],
1435
+ url: "/admin/webhook-configs/{id}",
1436
+ ...options,
1437
+ });
1438
+ var patchAdminWebhookConfigsById = (options) =>
1439
+ (options.client ?? client).patch({
1440
+ security: [{ scheme: "bearer", type: "http" }],
1441
+ url: "/admin/webhook-configs/{id}",
1442
+ ...options,
1443
+ headers: {
1444
+ "Content-Type": "application/vnd.api+json",
1445
+ ...options.headers,
1446
+ },
1447
+ });
1448
+ var patchAdminAccountsByIdDebit = (options) =>
1449
+ (options.client ?? client).patch({
1450
+ security: [{ scheme: "bearer", type: "http" }],
1451
+ url: "/admin/accounts/{id}/debit",
1452
+ ...options,
1453
+ headers: {
1454
+ "Content-Type": "application/vnd.api+json",
1455
+ ...options.headers,
1456
+ },
1457
+ });
1458
+ var getAdminApiKeys = (options) =>
1459
+ (options.client ?? client).get({
1460
+ security: [{ scheme: "bearer", type: "http" }],
1461
+ url: "/admin/api-keys",
1462
+ ...options,
1463
+ });
1464
+ var getAdminExtractionDocumentsById = (options) =>
1465
+ (options.client ?? client).get({
1466
+ security: [{ scheme: "bearer", type: "http" }],
1467
+ url: "/admin/extraction/documents/{id}",
1468
+ ...options,
1469
+ });
1470
+ var getAdminAccounts = (options) =>
1471
+ (options.client ?? client).get({
1472
+ security: [{ scheme: "bearer", type: "http" }],
1473
+ url: "/admin/accounts",
1474
+ ...options,
1475
+ });
1476
+ var getAdminStorageStats = (options) =>
1477
+ (options.client ?? client).get({
1478
+ security: [{ scheme: "bearer", type: "http" }],
1479
+ url: "/admin/storage/stats",
1480
+ ...options,
1481
+ });
1482
+ var getAdminAccountsById = (options) =>
1483
+ (options.client ?? client).get({
1484
+ security: [{ scheme: "bearer", type: "http" }],
1485
+ url: "/admin/accounts/{id}",
1486
+ ...options,
1487
+ });
1488
+ var getAdminBucketsByIdStats = (options) =>
1489
+ (options.client ?? client).get({
1490
+ security: [{ scheme: "bearer", type: "http" }],
1491
+ url: "/admin/buckets/{id}/stats",
1492
+ ...options,
1493
+ });
1494
+ var getAdminDocumentsStats = (options) =>
1495
+ (options.client ?? client).get({
1496
+ security: [{ scheme: "bearer", type: "http" }],
1497
+ url: "/admin/documents/stats",
1498
+ ...options,
1499
+ });
1500
+ var getAdminWebhookDeliveries = (options) =>
1501
+ (options.client ?? client).get({
1502
+ security: [{ scheme: "bearer", type: "http" }],
1503
+ url: "/admin/webhook-deliveries",
1504
+ ...options,
1505
+ });
1506
+ var getAdminExtractionDocuments = (options) =>
1507
+ (options.client ?? client).get({
1508
+ security: [{ scheme: "bearer", type: "http" }],
1509
+ url: "/admin/extraction/documents",
1510
+ ...options,
1511
+ });
1512
+ var getAdminBucketsByIdObjects = (options) =>
1513
+ (options.client ?? client).get({
1514
+ security: [{ scheme: "bearer", type: "http" }],
1515
+ url: "/admin/buckets/{id}/objects",
1516
+ ...options,
1517
+ });
1518
+ var postAdminDocumentsBulkDelete = (options) =>
1519
+ (options.client ?? client).post({
1520
+ security: [{ scheme: "bearer", type: "http" }],
1521
+ url: "/admin/documents/bulk-delete",
1522
+ ...options,
1523
+ headers: {
1524
+ "Content-Type": "application/vnd.api+json",
1525
+ ...options.headers,
1526
+ },
1527
+ });
1528
+ var getAdminWebhookConfigs = (options) =>
1529
+ (options.client ?? client).get({
1530
+ security: [{ scheme: "bearer", type: "http" }],
1531
+ url: "/admin/webhook-configs",
1532
+ ...options,
1533
+ });
1534
+ var postAdminWebhookConfigs = (options) =>
1535
+ (options.client ?? client).post({
1536
+ security: [{ scheme: "bearer", type: "http" }],
1537
+ url: "/admin/webhook-configs",
1538
+ ...options,
1539
+ headers: {
1540
+ "Content-Type": "application/vnd.api+json",
1541
+ ...options.headers,
1542
+ },
1543
+ });
1544
+ var patchAdminApiKeysByIdAllocate = (options) =>
1545
+ (options.client ?? client).patch({
1546
+ security: [{ scheme: "bearer", type: "http" }],
1547
+ url: "/admin/api-keys/{id}/allocate",
1548
+ ...options,
1549
+ headers: {
1550
+ "Content-Type": "application/vnd.api+json",
1551
+ ...options.headers,
1552
+ },
1553
+ });
1554
+ var patchAdminApiKeysByIdRevoke = (options) =>
1555
+ (options.client ?? client).patch({
1556
+ security: [{ scheme: "bearer", type: "http" }],
1557
+ url: "/admin/api-keys/{id}/revoke",
1558
+ ...options,
1559
+ headers: {
1560
+ "Content-Type": "application/vnd.api+json",
1561
+ ...options.headers,
1562
+ },
1563
+ });
1564
+ var getAdminBuckets = (options) =>
1565
+ (options.client ?? client).get({
1566
+ security: [{ scheme: "bearer", type: "http" }],
1567
+ url: "/admin/buckets",
1568
+ ...options,
1569
+ });
1570
+ var patchAdminApiKeysByIdRotate = (options) =>
1571
+ (options.client ?? client).patch({
1572
+ security: [{ scheme: "bearer", type: "http" }],
1573
+ url: "/admin/api-keys/{id}/rotate",
1574
+ ...options,
1575
+ headers: {
1576
+ "Content-Type": "application/vnd.api+json",
1577
+ ...options.headers,
1578
+ },
1579
+ });
1580
+ var getAdminBucketsById = (options) =>
1581
+ (options.client ?? client).get({
1582
+ security: [{ scheme: "bearer", type: "http" }],
1583
+ url: "/admin/buckets/{id}",
1584
+ ...options,
1585
+ });
1586
+ var postAdminWebhookConfigsByIdTest = (options) =>
1587
+ (options.client ?? client).post({
1588
+ security: [{ scheme: "bearer", type: "http" }],
1589
+ url: "/admin/webhook-configs/{id}/test",
1590
+ ...options,
1591
+ headers: {
1592
+ "Content-Type": "application/vnd.api+json",
1593
+ ...options.headers,
1594
+ },
1595
+ });
1596
+ var postAdminWebhookDeliveriesByIdRetry = (options) =>
1597
+ (options.client ?? client).post({
1598
+ security: [{ scheme: "bearer", type: "http" }],
1599
+ url: "/admin/webhook-deliveries/{id}/retry",
1600
+ ...options,
1601
+ headers: {
1602
+ "Content-Type": "application/vnd.api+json",
1603
+ ...options.headers,
1604
+ },
1605
+ });
1606
+
1607
+ // src/schemas/requests.ts
1608
+ var import_zod = require("zod");
1609
+ var StorageStatsRequestSchema = import_zod.z.object({
1610
+ workspace_id: import_zod.z.string().optional(),
1611
+ });
1612
+ var WebhookConfigCreateSchema = import_zod.z.object({
1613
+ url: import_zod.z.string().url(),
1614
+ events: import_zod.z.array(import_zod.z.string()).min(1),
1615
+ secret: import_zod.z.string().optional(),
1616
+ enabled: import_zod.z.boolean().default(true),
1617
+ });
1618
+ var WebhookBulkEnableSchema = import_zod.z.object({
1619
+ config_ids: import_zod.z.array(import_zod.z.string()).min(1).max(100),
1620
+ });
1621
+ var WebhookBulkDisableSchema = import_zod.z.object({
1622
+ config_ids: import_zod.z.array(import_zod.z.string()).min(1).max(100),
1623
+ });
1624
+ var WebhookDeliveryBulkRetrySchema = import_zod.z.object({
1625
+ delivery_ids: import_zod.z.array(import_zod.z.string()).min(1).max(100),
1626
+ });
1627
+ var AgentAdminCreateSchema = import_zod.z.object({
1628
+ name: import_zod.z.string().min(1).max(255),
1629
+ prompt_template: import_zod.z.string().min(1),
1630
+ system_wide: import_zod.z.boolean().default(false),
1631
+ });
1632
+ var AccountCreditSchema = import_zod.z.object({
1633
+ amount: import_zod.z.number().positive(),
1634
+ description: import_zod.z.string().optional(),
1635
+ });
1636
+ var AccountDebitSchema = import_zod.z.object({
1637
+ amount: import_zod.z.number().positive(),
1638
+ description: import_zod.z.string().optional(),
1639
+ });
1640
+ var ApiKeyAllocateSchema = import_zod.z.object({
1641
+ rate_limit: import_zod.z.number().int().positive().optional(),
1642
+ expires_at: import_zod.z.string().datetime().optional(),
1643
+ });
1644
+ var DocumentBulkDeleteSchema = import_zod.z.object({
1645
+ document_ids: import_zod.z.array(import_zod.z.string()).min(1).max(100),
1646
+ });
1647
+ var DocumentBulkReprocessSchema = import_zod.z.object({
1648
+ document_ids: import_zod.z.array(import_zod.z.string()).min(1).max(100),
1649
+ });
1650
+
1651
+ // src/namespaces/accounts.ts
1652
+ function createAccountsNamespace(rb) {
1653
+ return {
1654
+ /** List all billing accounts */
1655
+ list: async (options) => {
1656
+ return rb.execute(getAdminAccounts, {}, options);
1657
+ },
1658
+ /** Get a billing account by ID */
1659
+ get: async (id, options) => {
1660
+ return rb.execute(getAdminAccountsById, { path: { id } }, options);
1661
+ },
1662
+ /** Credit an account */
1663
+ credit: async (id, amount, description, options) => {
1664
+ const validated = AccountCreditSchema.parse({ amount, description });
1665
+ return rb.execute(
1666
+ patchAdminAccountsByIdCredit,
1667
+ {
1668
+ path: { id },
1669
+ body: {
1670
+ data: {
1671
+ id,
1672
+ type: "account",
1673
+ attributes: validated,
1674
+ },
1675
+ },
1676
+ },
1677
+ options,
1678
+ );
1679
+ },
1680
+ /** Debit an account */
1681
+ debit: async (id, amount, description, options) => {
1682
+ const validated = AccountDebitSchema.parse({ amount, description });
1683
+ return rb.execute(
1684
+ patchAdminAccountsByIdDebit,
1685
+ {
1686
+ path: { id },
1687
+ body: {
1688
+ data: {
1689
+ id,
1690
+ type: "account",
1691
+ attributes: validated,
1692
+ },
1693
+ },
1694
+ },
1695
+ options,
1696
+ );
1697
+ },
1698
+ };
1699
+ }
1700
+
1701
+ // src/namespaces/apiKeys.ts
1702
+ function createApiKeysNamespace(rb) {
1703
+ return {
1704
+ /** List all API keys */
1705
+ list: async (options) => {
1706
+ return rb.execute(getAdminApiKeys, {}, options);
1707
+ },
1708
+ /** Get an API key by ID */
1709
+ get: async (id, options) => {
1710
+ return rb.execute(getAdminApiKeysById, { path: { id } }, options);
1711
+ },
1712
+ /** Allocate credits to an API key */
1713
+ allocate: async (id, amount, description, options) => {
1714
+ return rb.execute(
1715
+ patchAdminApiKeysByIdAllocate,
1716
+ {
1717
+ path: { id },
1718
+ body: {
1719
+ data: {
1720
+ id,
1721
+ type: "api_key",
1722
+ attributes: {
1723
+ amount,
1724
+ description,
1725
+ },
1726
+ },
1727
+ },
1728
+ },
1729
+ options,
1730
+ );
1731
+ },
1732
+ /** Revoke an API key */
1733
+ revoke: async (id, options) => {
1734
+ return rb.execute(patchAdminApiKeysByIdRevoke, { path: { id } }, options);
1735
+ },
1736
+ /** Rotate an API key */
1737
+ rotate: async (id, options) => {
1738
+ return rb.execute(patchAdminApiKeysByIdRotate, { path: { id } }, options);
1739
+ },
1740
+ };
1741
+ }
1742
+
1743
+ // src/namespaces/documents.ts
1744
+ function createDocumentsNamespace(rb) {
1745
+ return {
1746
+ /** List extraction documents */
1747
+ list: async (options) => {
1748
+ return rb.execute(getAdminExtractionDocuments, {}, options);
1749
+ },
1750
+ /** Get a document by ID */
1751
+ get: async (id, options) => {
1752
+ return rb.execute(
1753
+ getAdminExtractionDocumentsById,
1754
+ { path: { id } },
1755
+ options,
1756
+ );
1757
+ },
1758
+ /** Get document statistics */
1759
+ stats: async (options) => {
1760
+ return rb.execute(getAdminDocumentsStats, {}, options);
1761
+ },
1762
+ /** Bulk delete documents */
1763
+ bulkDelete: async (documentIds, options) => {
1764
+ const validated = DocumentBulkDeleteSchema.parse({
1765
+ document_ids: documentIds,
1766
+ });
1767
+ return rb.execute(
1768
+ postAdminDocumentsBulkDelete,
1769
+ {
1770
+ body: {
1771
+ data: {
1772
+ type: "operation_success",
1773
+ attributes: {
1774
+ ids: validated.document_ids,
1775
+ },
1776
+ },
1777
+ },
1778
+ },
1779
+ options,
1780
+ );
1781
+ },
1782
+ };
1783
+ }
1784
+
1785
+ // src/namespaces/_executions-streaming.ts
1786
+ function addExecutionStreaming(executions, getHeaders) {
1787
+ executions.stream = async (executionId, options) => {
1788
+ const headers = {
1789
+ ...getHeaders(),
1790
+ Accept: "text/event-stream",
1791
+ };
1792
+ const result = await client.get({
1793
+ url: `/isv/agent-executions/${executionId}/stream`,
1794
+ headers,
1795
+ parseAs: "stream",
1796
+ ...(options?.signal && { signal: options.signal }),
1797
+ });
1798
+ const envelope = result;
1799
+ const streamBody = envelope.data ?? result;
1800
+ const response = envelope.response;
1801
+ if (response && !response.ok) {
1802
+ throw new ServerError(`Stream request failed: ${response.status}`, {
1803
+ statusCode: response.status,
1804
+ });
1805
+ }
1806
+ if (streamBody instanceof ReadableStream) {
1807
+ const syntheticResponse = new Response(streamBody, {
1808
+ headers: { "Content-Type": "text/event-stream" },
1809
+ });
1810
+ return streamMessage(syntheticResponse, {
1811
+ signal: options?.signal,
1812
+ ...options,
1813
+ });
1814
+ }
1815
+ if (streamBody instanceof Response) {
1816
+ if (!streamBody.ok) {
1817
+ throw new ServerError(`Stream request failed: ${streamBody.status}`, {
1818
+ statusCode: streamBody.status,
1819
+ });
1820
+ }
1821
+ return streamMessage(streamBody, {
1822
+ signal: options?.signal,
1823
+ ...options,
1824
+ });
1825
+ }
1826
+ throw new GptCoreError("Unexpected stream response format", {
1827
+ code: "stream_error",
1828
+ });
1829
+ };
1830
+ }
1831
+
1832
+ // src/namespaces/executions.ts
1833
+ function createExecutionsNamespace(rb) {
1834
+ const executions = {
1835
+ /** Start a new agent execution */
1836
+ start: async (agentId, params, options) => {
1837
+ return rb.rawPost(`/isv/agents/${agentId}/execute`, params, options);
1838
+ },
1839
+ /** Get execution status and details */
1840
+ get: async (executionId, options) => {
1841
+ return rb.rawGet(`/isv/agent-executions/${executionId}`, options);
1842
+ },
1843
+ /** List executions for a workspace */
1844
+ list: async (filters, options) => {
1845
+ const query = filters?.status ? `?status=${filters.status}` : "";
1846
+ return rb.rawGet(`/isv/agent-executions${query}`, options);
1847
+ },
1848
+ /** Cancel a running execution */
1849
+ cancel: async (executionId, options) => {
1850
+ return rb.rawPost(
1851
+ `/isv/agent-executions/${executionId}/cancel`,
1852
+ void 0,
1853
+ options,
1854
+ );
1855
+ },
1856
+ /** Approve a pending tool call */
1857
+ approve: async (executionId, options) => {
1858
+ return rb.rawPost(
1859
+ `/isv/agent-executions/${executionId}/approve`,
1860
+ void 0,
1861
+ options,
1862
+ );
1863
+ },
1864
+ /** Deny a pending tool call */
1865
+ deny: async (executionId, reason, options) => {
1866
+ return rb.rawPost(
1867
+ `/isv/agent-executions/${executionId}/deny`,
1868
+ reason ? { reason } : void 0,
1869
+ options,
1870
+ );
1871
+ },
1872
+ /** Estimate cost for executing an agent */
1873
+ estimate: async (agentId, params, options) => {
1874
+ return rb.rawPost(`/isv/agents/${agentId}/estimate`, params, options);
1875
+ },
1876
+ /** Get child executions of a parent execution */
1877
+ getChildren: async (executionId, options) => {
1878
+ return rb.rawGet(
1879
+ `/isv/agent-executions/${executionId}/children`,
1880
+ options,
1881
+ );
1882
+ },
1883
+ /** Get the execution tree rooted at a given execution */
1884
+ getTree: async (executionId, options) => {
1885
+ return rb.rawGet(`/isv/agent-executions/${executionId}/tree`, options);
1886
+ },
1887
+ };
1888
+ addExecutionStreaming(executions, () => rb.getRequestHeaders());
1889
+ return executions;
1890
+ }
1891
+
1892
+ // src/namespaces/storage.ts
1893
+ function createStorageNamespace(rb) {
1894
+ return {
1895
+ /** Get storage statistics */
1896
+ stats: async (workspaceId, options) => {
1897
+ const validated = StorageStatsRequestSchema.parse({
1898
+ workspace_id: workspaceId,
1899
+ });
1900
+ return rb.execute(
1901
+ getAdminStorageStats,
1902
+ validated.workspace_id
1903
+ ? { query: { filter: { workspace_id: validated.workspace_id } } }
1904
+ : {},
1905
+ options,
1906
+ );
1907
+ },
1908
+ /** Bucket management */
1909
+ buckets: {
1910
+ /** List all buckets */
1911
+ list: async (options) => {
1912
+ return rb.execute(getAdminBuckets, {}, options);
1913
+ },
1914
+ /** Get a bucket by ID */
1915
+ get: async (id, options) => {
1916
+ return rb.execute(getAdminBucketsById, { path: { id } }, options);
1917
+ },
1918
+ /** Get bucket statistics */
1919
+ stats: async (id, options) => {
1920
+ return rb.execute(getAdminBucketsByIdStats, { path: { id } }, options);
1921
+ },
1922
+ /** List objects in a bucket */
1923
+ objects: async (id, options) => {
1924
+ return rb.execute(
1925
+ getAdminBucketsByIdObjects,
1926
+ { path: { id } },
1927
+ options,
1928
+ );
1929
+ },
1930
+ },
1931
+ };
1932
+ }
1933
+
1934
+ // src/namespaces/webhooks-ns.ts
1935
+ function createWebhooksNamespace(rb) {
1936
+ return {
1937
+ configs: {
1938
+ /** List all webhook configs */
1939
+ list: async (options) => {
1940
+ return rb.execute(getAdminWebhookConfigs, {}, options);
1941
+ },
1942
+ /** Create a webhook config */
1943
+ create: async (
1944
+ name,
1945
+ url,
1946
+ events,
1947
+ applicationId,
1948
+ secret,
1949
+ enabled = true,
1950
+ options,
1951
+ ) => {
1952
+ return rb.execute(
1953
+ postAdminWebhookConfigs,
1954
+ {
1955
+ body: {
1956
+ data: {
1957
+ type: "webhook_config",
1958
+ attributes: {
1959
+ name,
1960
+ url,
1961
+ events,
1962
+ application_id: applicationId,
1963
+ secret,
1964
+ enabled,
1965
+ },
1966
+ },
1967
+ },
1968
+ },
1969
+ options,
1970
+ );
1971
+ },
1972
+ /** Get a webhook config by ID */
1973
+ get: async (id, options) => {
1974
+ return rb.execute(
1975
+ getAdminWebhookConfigsById,
1976
+ { path: { id } },
1977
+ options,
1978
+ );
1979
+ },
1980
+ /** Update a webhook config */
1981
+ update: async (id, updates, options) => {
1982
+ return rb.execute(
1983
+ patchAdminWebhookConfigsById,
1984
+ {
1985
+ path: { id },
1986
+ body: {
1987
+ data: {
1988
+ id,
1989
+ type: "webhook_config",
1990
+ attributes: updates,
1991
+ },
1992
+ },
1993
+ },
1994
+ options,
1995
+ );
1996
+ },
1997
+ /** Delete a webhook config */
1998
+ delete: async (id, options) => {
1999
+ return rb.executeDelete(
2000
+ deleteAdminWebhookConfigsById,
2001
+ { path: { id } },
2002
+ options,
2003
+ );
2004
+ },
2005
+ /** Test a webhook config */
2006
+ test: async (id, options) => {
2007
+ return rb.execute(
2008
+ postAdminWebhookConfigsByIdTest,
2009
+ { path: { id } },
2010
+ options,
2011
+ );
2012
+ },
2013
+ },
2014
+ deliveries: {
2015
+ /** List webhook deliveries */
2016
+ list: async (options) => {
2017
+ return rb.execute(getAdminWebhookDeliveries, {}, options);
2018
+ },
2019
+ /** Get a webhook delivery by ID */
2020
+ get: async (id, options) => {
2021
+ return rb.execute(
2022
+ getAdminWebhookDeliveriesById,
2023
+ { path: { id } },
2024
+ options,
2025
+ );
2026
+ },
2027
+ /** Retry a webhook delivery */
2028
+ retry: async (id, options) => {
2029
+ return rb.execute(
2030
+ postAdminWebhookDeliveriesByIdRetry,
2031
+ { path: { id } },
2032
+ options,
2033
+ );
2034
+ },
2035
+ },
2036
+ };
2037
+ }
2038
+
2039
+ // src/gpt-admin.ts
2040
+ var GptAdmin = class extends BaseClient {
2041
+ constructor(config) {
2042
+ super(config);
2043
+ const rb = new RequestBuilder(
2044
+ this.clientInstance,
2045
+ () => this.getHeaders(),
2046
+ (d) => this.unwrap(d),
2047
+ (fn) => this.requestWithRetry(fn),
2048
+ );
2049
+ this.accounts = createAccountsNamespace(rb);
2050
+ this.apiKeys = createApiKeysNamespace(rb);
2051
+ this.documents = createDocumentsNamespace(rb);
2052
+ this.executions = createExecutionsNamespace(rb);
2053
+ this.storage = createStorageNamespace(rb);
2054
+ this.webhooks = createWebhooksNamespace(rb);
2055
+ }
2056
+ };
2057
+
2058
+ // src/index.ts
2059
+ var index_default = GptAdmin;
2060
+ // Annotate the CommonJS export names for ESM import in node:
2061
+ 0 &&
2062
+ (module.exports = {
2063
+ AccountCreditSchema,
2064
+ AccountDebitSchema,
2065
+ AgentAdminCreateSchema,
2066
+ ApiKeyAllocateSchema,
2067
+ AuthenticationError,
2068
+ AuthorizationError,
2069
+ DEFAULT_API_VERSION,
2070
+ DocumentBulkDeleteSchema,
2071
+ DocumentBulkReprocessSchema,
2072
+ GptAdmin,
2073
+ GptCoreError,
2074
+ NetworkError,
2075
+ NotFoundError,
2076
+ RateLimitError,
2077
+ ServerError,
2078
+ StorageStatsRequestSchema,
2079
+ TimeoutError,
2080
+ ValidationError,
2081
+ WebhookBulkDisableSchema,
2082
+ WebhookBulkEnableSchema,
2083
+ WebhookConfigCreateSchema,
2084
+ WebhookDeliveryBulkRetrySchema,
2085
+ handleApiError,
2086
+ });