@soat/sdk 0.3.4 → 0.4.4

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/esm/index.js CHANGED
@@ -5,20 +5,2679 @@ var __name = (target, value) => __defProp(target, "name", {
5
5
  configurable: true
6
6
  });
7
7
 
8
- // src/index.ts
9
- import createClient from "openapi-fetch";
10
- var createSoatClient = /* @__PURE__ */__name(args => {
11
- const {
12
- baseUrl,
13
- token
14
- } = args;
15
- return createClient({
16
- baseUrl,
17
- ...(token && {
8
+ // src/generated/core/bodySerializer.gen.ts
9
+ var serializeFormDataPair = /* @__PURE__ */__name((data, key, value) => {
10
+ if (typeof value === "string" || value instanceof Blob) {
11
+ data.append(key, value);
12
+ } else if (value instanceof Date) {
13
+ data.append(key, value.toISOString());
14
+ } else {
15
+ data.append(key, JSON.stringify(value));
16
+ }
17
+ }, "serializeFormDataPair");
18
+ var formDataBodySerializer = {
19
+ bodySerializer: /* @__PURE__ */__name(body => {
20
+ const data = new FormData();
21
+ Object.entries(body).forEach(([key, value]) => {
22
+ if (value === void 0 || value === null) {
23
+ return;
24
+ }
25
+ if (Array.isArray(value)) {
26
+ value.forEach(v => serializeFormDataPair(data, key, v));
27
+ } else {
28
+ serializeFormDataPair(data, key, value);
29
+ }
30
+ });
31
+ return data;
32
+ }, "bodySerializer")
33
+ };
34
+ var jsonBodySerializer = {
35
+ bodySerializer: /* @__PURE__ */__name(body => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value), "bodySerializer")
36
+ };
37
+
38
+ // src/generated/core/params.gen.ts
39
+ var extraPrefixesMap = {
40
+ $body_: "body",
41
+ $headers_: "headers",
42
+ $path_: "path",
43
+ $query_: "query"
44
+ };
45
+ var extraPrefixes = Object.entries(extraPrefixesMap);
46
+
47
+ // src/generated/core/serverSentEvents.gen.ts
48
+ function createSseClient({
49
+ onRequest,
50
+ onSseError,
51
+ onSseEvent,
52
+ responseTransformer,
53
+ responseValidator,
54
+ sseDefaultRetryDelay,
55
+ sseMaxRetryAttempts,
56
+ sseMaxRetryDelay,
57
+ sseSleepFn,
58
+ url,
59
+ ...options
60
+ }) {
61
+ let lastEventId;
62
+ const sleep = sseSleepFn ?? (ms => new Promise(resolve => setTimeout(resolve, ms)));
63
+ const createStream = /* @__PURE__ */__name(async function* () {
64
+ let retryDelay = sseDefaultRetryDelay ?? 3e3;
65
+ let attempt = 0;
66
+ const signal = options.signal ?? new AbortController().signal;
67
+ while (true) {
68
+ if (signal.aborted) break;
69
+ attempt++;
70
+ const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
71
+ if (lastEventId !== void 0) {
72
+ headers.set("Last-Event-ID", lastEventId);
73
+ }
74
+ try {
75
+ const requestInit = {
76
+ redirect: "follow",
77
+ ...options,
78
+ body: options.serializedBody,
79
+ headers,
80
+ signal
81
+ };
82
+ let request = new Request(url, requestInit);
83
+ if (onRequest) {
84
+ request = await onRequest(url, requestInit);
85
+ }
86
+ const _fetch = options.fetch ?? globalThis.fetch;
87
+ const response = await _fetch(request);
88
+ if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
89
+ if (!response.body) throw new Error("No body in SSE response");
90
+ const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
91
+ let buffer = "";
92
+ const abortHandler = /* @__PURE__ */__name(() => {
93
+ try {
94
+ reader.cancel();
95
+ } catch {}
96
+ }, "abortHandler");
97
+ signal.addEventListener("abort", abortHandler);
98
+ try {
99
+ while (true) {
100
+ const {
101
+ done,
102
+ value
103
+ } = await reader.read();
104
+ if (done) break;
105
+ buffer += value;
106
+ buffer = buffer.replace(/\r\n?/g, "\n");
107
+ const chunks = buffer.split("\n\n");
108
+ buffer = chunks.pop() ?? "";
109
+ for (const chunk of chunks) {
110
+ const lines = chunk.split("\n");
111
+ const dataLines = [];
112
+ let eventName;
113
+ for (const line of lines) {
114
+ if (line.startsWith("data:")) {
115
+ dataLines.push(line.replace(/^data:\s*/, ""));
116
+ } else if (line.startsWith("event:")) {
117
+ eventName = line.replace(/^event:\s*/, "");
118
+ } else if (line.startsWith("id:")) {
119
+ lastEventId = line.replace(/^id:\s*/, "");
120
+ } else if (line.startsWith("retry:")) {
121
+ const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
122
+ if (!Number.isNaN(parsed)) {
123
+ retryDelay = parsed;
124
+ }
125
+ }
126
+ }
127
+ let data;
128
+ let parsedJson = false;
129
+ if (dataLines.length) {
130
+ const rawData = dataLines.join("\n");
131
+ try {
132
+ data = JSON.parse(rawData);
133
+ parsedJson = true;
134
+ } catch {
135
+ data = rawData;
136
+ }
137
+ }
138
+ if (parsedJson) {
139
+ if (responseValidator) {
140
+ await responseValidator(data);
141
+ }
142
+ if (responseTransformer) {
143
+ data = await responseTransformer(data);
144
+ }
145
+ }
146
+ onSseEvent?.({
147
+ data,
148
+ event: eventName,
149
+ id: lastEventId,
150
+ retry: retryDelay
151
+ });
152
+ if (dataLines.length) {
153
+ yield data;
154
+ }
155
+ }
156
+ }
157
+ } finally {
158
+ signal.removeEventListener("abort", abortHandler);
159
+ reader.releaseLock();
160
+ }
161
+ break;
162
+ } catch (error) {
163
+ onSseError?.(error);
164
+ if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
165
+ break;
166
+ }
167
+ const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
168
+ await sleep(backoff);
169
+ }
170
+ }
171
+ }, "createStream");
172
+ const stream = createStream();
173
+ return {
174
+ stream
175
+ };
176
+ }
177
+ __name(createSseClient, "createSseClient");
178
+
179
+ // src/generated/core/pathSerializer.gen.ts
180
+ var separatorArrayExplode = /* @__PURE__ */__name(style => {
181
+ switch (style) {
182
+ case "label":
183
+ return ".";
184
+ case "matrix":
185
+ return ";";
186
+ case "simple":
187
+ return ",";
188
+ default:
189
+ return "&";
190
+ }
191
+ }, "separatorArrayExplode");
192
+ var separatorArrayNoExplode = /* @__PURE__ */__name(style => {
193
+ switch (style) {
194
+ case "form":
195
+ return ",";
196
+ case "pipeDelimited":
197
+ return "|";
198
+ case "spaceDelimited":
199
+ return "%20";
200
+ default:
201
+ return ",";
202
+ }
203
+ }, "separatorArrayNoExplode");
204
+ var separatorObjectExplode = /* @__PURE__ */__name(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
+ }, "separatorObjectExplode");
216
+ var serializeArrayParam = /* @__PURE__ */__name(({
217
+ allowReserved,
218
+ explode,
219
+ name,
220
+ style,
221
+ value
222
+ }) => {
223
+ if (!explode) {
224
+ const joinedValues2 = (allowReserved ? value : value.map(v => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
225
+ switch (style) {
226
+ case "label":
227
+ return `.${joinedValues2}`;
228
+ case "matrix":
229
+ return `;${name}=${joinedValues2}`;
230
+ case "simple":
231
+ return joinedValues2;
232
+ default:
233
+ return `${name}=${joinedValues2}`;
234
+ }
235
+ }
236
+ const separator = separatorArrayExplode(style);
237
+ const joinedValues = value.map(v => {
238
+ if (style === "label" || style === "simple") {
239
+ return allowReserved ? v : encodeURIComponent(v);
240
+ }
241
+ return serializePrimitiveParam({
242
+ allowReserved,
243
+ name,
244
+ value: v
245
+ });
246
+ }).join(separator);
247
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
248
+ }, "serializeArrayParam");
249
+ var serializePrimitiveParam = /* @__PURE__ */__name(({
250
+ allowReserved,
251
+ name,
252
+ value
253
+ }) => {
254
+ if (value === void 0 || value === null) {
255
+ return "";
256
+ }
257
+ if (typeof value === "object") {
258
+ throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");
259
+ }
260
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
261
+ }, "serializePrimitiveParam");
262
+ var serializeObjectParam = /* @__PURE__ */__name(({
263
+ allowReserved,
264
+ explode,
265
+ name,
266
+ style,
267
+ value,
268
+ valueOnly
269
+ }) => {
270
+ if (value instanceof Date) {
271
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
272
+ }
273
+ if (style !== "deepObject" && !explode) {
274
+ let values = [];
275
+ Object.entries(value).forEach(([key, v]) => {
276
+ values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
277
+ });
278
+ const joinedValues2 = values.join(",");
279
+ switch (style) {
280
+ case "form":
281
+ return `${name}=${joinedValues2}`;
282
+ case "label":
283
+ return `.${joinedValues2}`;
284
+ case "matrix":
285
+ return `;${name}=${joinedValues2}`;
286
+ default:
287
+ return joinedValues2;
288
+ }
289
+ }
290
+ const separator = separatorObjectExplode(style);
291
+ const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam({
292
+ allowReserved,
293
+ name: style === "deepObject" ? `${name}[${key}]` : key,
294
+ value: v
295
+ })).join(separator);
296
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
297
+ }, "serializeObjectParam");
298
+
299
+ // src/generated/core/utils.gen.ts
300
+ var PATH_PARAM_RE = /\{[^{}]+\}/g;
301
+ var defaultPathSerializer = /* @__PURE__ */__name(({
302
+ path,
303
+ url: _url
304
+ }) => {
305
+ let url = _url;
306
+ const matches = _url.match(PATH_PARAM_RE);
307
+ if (matches) {
308
+ for (const match of matches) {
309
+ let explode = false;
310
+ let name = match.substring(1, match.length - 1);
311
+ let style = "simple";
312
+ if (name.endsWith("*")) {
313
+ explode = true;
314
+ name = name.substring(0, name.length - 1);
315
+ }
316
+ if (name.startsWith(".")) {
317
+ name = name.substring(1);
318
+ style = "label";
319
+ } else if (name.startsWith(";")) {
320
+ name = name.substring(1);
321
+ style = "matrix";
322
+ }
323
+ const value = path[name];
324
+ if (value === void 0 || value === null) {
325
+ continue;
326
+ }
327
+ if (Array.isArray(value)) {
328
+ url = url.replace(match, serializeArrayParam({
329
+ explode,
330
+ name,
331
+ style,
332
+ value
333
+ }));
334
+ continue;
335
+ }
336
+ if (typeof value === "object") {
337
+ url = url.replace(match, serializeObjectParam({
338
+ explode,
339
+ name,
340
+ style,
341
+ value,
342
+ valueOnly: true
343
+ }));
344
+ continue;
345
+ }
346
+ if (style === "matrix") {
347
+ url = url.replace(match, `;${serializePrimitiveParam({
348
+ name,
349
+ value
350
+ })}`);
351
+ continue;
352
+ }
353
+ const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
354
+ url = url.replace(match, replaceValue);
355
+ }
356
+ }
357
+ return url;
358
+ }, "defaultPathSerializer");
359
+ var getUrl = /* @__PURE__ */__name(({
360
+ baseUrl,
361
+ path,
362
+ query,
363
+ querySerializer,
364
+ url: _url
365
+ }) => {
366
+ const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
367
+ let url = (baseUrl ?? "") + pathUrl;
368
+ if (path) {
369
+ url = defaultPathSerializer({
370
+ path,
371
+ url
372
+ });
373
+ }
374
+ let search = query ? querySerializer(query) : "";
375
+ if (search.startsWith("?")) {
376
+ search = search.substring(1);
377
+ }
378
+ if (search) {
379
+ url += `?${search}`;
380
+ }
381
+ return url;
382
+ }, "getUrl");
383
+ function getValidRequestBody(options) {
384
+ const hasBody = options.body !== void 0;
385
+ const isSerializedBody = hasBody && options.bodySerializer;
386
+ if (isSerializedBody) {
387
+ if ("serializedBody" in options) {
388
+ const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
389
+ return hasSerializedBody ? options.serializedBody : null;
390
+ }
391
+ return options.body !== "" ? options.body : null;
392
+ }
393
+ if (hasBody) {
394
+ return options.body;
395
+ }
396
+ return void 0;
397
+ }
398
+ __name(getValidRequestBody, "getValidRequestBody");
399
+
400
+ // src/generated/core/auth.gen.ts
401
+ var getAuthToken = /* @__PURE__ */__name(async (auth, callback) => {
402
+ const token = typeof callback === "function" ? await callback(auth) : callback;
403
+ if (!token) {
404
+ return;
405
+ }
406
+ if (auth.scheme === "bearer") {
407
+ return `Bearer ${token}`;
408
+ }
409
+ if (auth.scheme === "basic") {
410
+ return `Basic ${btoa(token)}`;
411
+ }
412
+ return token;
413
+ }, "getAuthToken");
414
+
415
+ // src/generated/client/utils.gen.ts
416
+ var createQuerySerializer = /* @__PURE__ */__name(({
417
+ parameters = {},
418
+ ...args
419
+ } = {}) => {
420
+ const querySerializer = /* @__PURE__ */__name(queryParams => {
421
+ const search = [];
422
+ if (queryParams && typeof queryParams === "object") {
423
+ for (const name in queryParams) {
424
+ const value = queryParams[name];
425
+ if (value === void 0 || value === null) {
426
+ continue;
427
+ }
428
+ const options = parameters[name] || args;
429
+ if (Array.isArray(value)) {
430
+ const serializedArray = serializeArrayParam({
431
+ allowReserved: options.allowReserved,
432
+ explode: true,
433
+ name,
434
+ style: "form",
435
+ value,
436
+ ...options.array
437
+ });
438
+ if (serializedArray) search.push(serializedArray);
439
+ } else if (typeof value === "object") {
440
+ const serializedObject = serializeObjectParam({
441
+ allowReserved: options.allowReserved,
442
+ explode: true,
443
+ name,
444
+ style: "deepObject",
445
+ value,
446
+ ...options.object
447
+ });
448
+ if (serializedObject) search.push(serializedObject);
449
+ } else {
450
+ const serializedPrimitive = serializePrimitiveParam({
451
+ allowReserved: options.allowReserved,
452
+ name,
453
+ value
454
+ });
455
+ if (serializedPrimitive) search.push(serializedPrimitive);
456
+ }
457
+ }
458
+ }
459
+ return search.join("&");
460
+ }, "querySerializer");
461
+ return querySerializer;
462
+ }, "createQuerySerializer");
463
+ var getParseAs = /* @__PURE__ */__name(contentType => {
464
+ if (!contentType) {
465
+ return "stream";
466
+ }
467
+ const cleanContent = contentType.split(";")[0]?.trim();
468
+ if (!cleanContent) {
469
+ return;
470
+ }
471
+ if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
472
+ return "json";
473
+ }
474
+ if (cleanContent === "multipart/form-data") {
475
+ return "formData";
476
+ }
477
+ if (["application/", "audio/", "image/", "video/"].some(type => cleanContent.startsWith(type))) {
478
+ return "blob";
479
+ }
480
+ if (cleanContent.startsWith("text/")) {
481
+ return "text";
482
+ }
483
+ return;
484
+ }, "getParseAs");
485
+ var checkForExistence = /* @__PURE__ */__name((options, name) => {
486
+ if (!name) {
487
+ return false;
488
+ }
489
+ if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
490
+ return true;
491
+ }
492
+ return false;
493
+ }, "checkForExistence");
494
+ var setAuthParams = /* @__PURE__ */__name(async ({
495
+ security,
496
+ ...options
497
+ }) => {
498
+ for (const auth of security) {
499
+ if (checkForExistence(options, auth.name)) {
500
+ continue;
501
+ }
502
+ const token = await getAuthToken(auth, options.auth);
503
+ if (!token) {
504
+ continue;
505
+ }
506
+ const name = auth.name ?? "Authorization";
507
+ switch (auth.in) {
508
+ case "query":
509
+ if (!options.query) {
510
+ options.query = {};
511
+ }
512
+ options.query[name] = token;
513
+ break;
514
+ case "cookie":
515
+ options.headers.append("Cookie", `${name}=${token}`);
516
+ break;
517
+ case "header":
518
+ default:
519
+ options.headers.set(name, token);
520
+ break;
521
+ }
522
+ }
523
+ }, "setAuthParams");
524
+ var buildUrl = /* @__PURE__ */__name(options => getUrl({
525
+ baseUrl: options.baseUrl,
526
+ path: options.path,
527
+ query: options.query,
528
+ querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
529
+ url: options.url
530
+ }), "buildUrl");
531
+ var mergeConfigs = /* @__PURE__ */__name((a, b) => {
532
+ const config = {
533
+ ...a,
534
+ ...b
535
+ };
536
+ if (config.baseUrl?.endsWith("/")) {
537
+ config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
538
+ }
539
+ config.headers = mergeHeaders(a.headers, b.headers);
540
+ return config;
541
+ }, "mergeConfigs");
542
+ var headersEntries = /* @__PURE__ */__name(headers => {
543
+ const entries = [];
544
+ headers.forEach((value, key) => {
545
+ entries.push([key, value]);
546
+ });
547
+ return entries;
548
+ }, "headersEntries");
549
+ var mergeHeaders = /* @__PURE__ */__name((...headers) => {
550
+ const mergedHeaders = new Headers();
551
+ for (const header of headers) {
552
+ if (!header) {
553
+ continue;
554
+ }
555
+ const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
556
+ for (const [key, value] of iterator) {
557
+ if (value === null) {
558
+ mergedHeaders.delete(key);
559
+ } else if (Array.isArray(value)) {
560
+ for (const v of value) {
561
+ mergedHeaders.append(key, v);
562
+ }
563
+ } else if (value !== void 0) {
564
+ mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
565
+ }
566
+ }
567
+ }
568
+ return mergedHeaders;
569
+ }, "mergeHeaders");
570
+ var Interceptors = class Interceptors2 {
571
+ static {
572
+ __name(this, "Interceptors");
573
+ }
574
+ fns = [];
575
+ clear() {
576
+ this.fns = [];
577
+ }
578
+ eject(id) {
579
+ const index = this.getInterceptorIndex(id);
580
+ if (this.fns[index]) {
581
+ this.fns[index] = null;
582
+ }
583
+ }
584
+ exists(id) {
585
+ const index = this.getInterceptorIndex(id);
586
+ return Boolean(this.fns[index]);
587
+ }
588
+ getInterceptorIndex(id) {
589
+ if (typeof id === "number") {
590
+ return this.fns[id] ? id : -1;
591
+ }
592
+ return this.fns.indexOf(id);
593
+ }
594
+ update(id, fn) {
595
+ const index = this.getInterceptorIndex(id);
596
+ if (this.fns[index]) {
597
+ this.fns[index] = fn;
598
+ return id;
599
+ }
600
+ return false;
601
+ }
602
+ use(fn) {
603
+ this.fns.push(fn);
604
+ return this.fns.length - 1;
605
+ }
606
+ };
607
+ var createInterceptors = /* @__PURE__ */__name(() => ({
608
+ error: new Interceptors(),
609
+ request: new Interceptors(),
610
+ response: new Interceptors()
611
+ }), "createInterceptors");
612
+ var defaultQuerySerializer = createQuerySerializer({
613
+ allowReserved: false,
614
+ array: {
615
+ explode: true,
616
+ style: "form"
617
+ },
618
+ object: {
619
+ explode: true,
620
+ style: "deepObject"
621
+ }
622
+ });
623
+ var defaultHeaders = {
624
+ "Content-Type": "application/json"
625
+ };
626
+ var createConfig = /* @__PURE__ */__name((override = {}) => ({
627
+ ...jsonBodySerializer,
628
+ headers: defaultHeaders,
629
+ parseAs: "auto",
630
+ querySerializer: defaultQuerySerializer,
631
+ ...override
632
+ }), "createConfig");
633
+
634
+ // src/generated/client/client.gen.ts
635
+ var createClient = /* @__PURE__ */__name((config = {}) => {
636
+ let _config = mergeConfigs(createConfig(), config);
637
+ const getConfig = /* @__PURE__ */__name(() => ({
638
+ ..._config
639
+ }), "getConfig");
640
+ const setConfig = /* @__PURE__ */__name(config2 => {
641
+ _config = mergeConfigs(_config, config2);
642
+ return getConfig();
643
+ }, "setConfig");
644
+ const interceptors = createInterceptors();
645
+ const beforeRequest = /* @__PURE__ */__name(async options => {
646
+ const opts = {
647
+ ..._config,
648
+ ...options,
649
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
650
+ headers: mergeHeaders(_config.headers, options.headers),
651
+ serializedBody: void 0
652
+ };
653
+ if (opts.security) {
654
+ await setAuthParams({
655
+ ...opts,
656
+ security: opts.security
657
+ });
658
+ }
659
+ if (opts.requestValidator) {
660
+ await opts.requestValidator(opts);
661
+ }
662
+ if (opts.body !== void 0 && opts.bodySerializer) {
663
+ opts.serializedBody = opts.bodySerializer(opts.body);
664
+ }
665
+ if (opts.body === void 0 || opts.serializedBody === "") {
666
+ opts.headers.delete("Content-Type");
667
+ }
668
+ const resolvedOpts = opts;
669
+ const url = buildUrl(resolvedOpts);
670
+ return {
671
+ opts: resolvedOpts,
672
+ url
673
+ };
674
+ }, "beforeRequest");
675
+ const request = /* @__PURE__ */__name(async options => {
676
+ const {
677
+ opts,
678
+ url
679
+ } = await beforeRequest(options);
680
+ const requestInit = {
681
+ redirect: "follow",
682
+ ...opts,
683
+ body: getValidRequestBody(opts)
684
+ };
685
+ let request2 = new Request(url, requestInit);
686
+ for (const fn of interceptors.request.fns) {
687
+ if (fn) {
688
+ request2 = await fn(request2, opts);
689
+ }
690
+ }
691
+ const _fetch = opts.fetch;
692
+ let response;
693
+ try {
694
+ response = await _fetch(request2);
695
+ } catch (error2) {
696
+ let finalError2 = error2;
697
+ for (const fn of interceptors.error.fns) {
698
+ if (fn) {
699
+ finalError2 = await fn(error2, void 0, request2, opts);
700
+ }
701
+ }
702
+ finalError2 = finalError2 || {};
703
+ if (opts.throwOnError) {
704
+ throw finalError2;
705
+ }
706
+ return opts.responseStyle === "data" ? void 0 : {
707
+ error: finalError2,
708
+ request: request2,
709
+ response: void 0
710
+ };
711
+ }
712
+ for (const fn of interceptors.response.fns) {
713
+ if (fn) {
714
+ response = await fn(response, request2, opts);
715
+ }
716
+ }
717
+ const result = {
718
+ request: request2,
719
+ response
720
+ };
721
+ if (response.ok) {
722
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
723
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
724
+ let emptyData;
725
+ switch (parseAs) {
726
+ case "arrayBuffer":
727
+ case "blob":
728
+ case "text":
729
+ emptyData = await response[parseAs]();
730
+ break;
731
+ case "formData":
732
+ emptyData = new FormData();
733
+ break;
734
+ case "stream":
735
+ emptyData = response.body;
736
+ break;
737
+ case "json":
738
+ default:
739
+ emptyData = {};
740
+ break;
741
+ }
742
+ return opts.responseStyle === "data" ? emptyData : {
743
+ data: emptyData,
744
+ ...result
745
+ };
746
+ }
747
+ let data;
748
+ switch (parseAs) {
749
+ case "arrayBuffer":
750
+ case "blob":
751
+ case "formData":
752
+ case "text":
753
+ data = await response[parseAs]();
754
+ break;
755
+ case "json":
756
+ {
757
+ const text = await response.text();
758
+ data = text ? JSON.parse(text) : {};
759
+ break;
760
+ }
761
+ case "stream":
762
+ return opts.responseStyle === "data" ? response.body : {
763
+ data: response.body,
764
+ ...result
765
+ };
766
+ }
767
+ if (parseAs === "json") {
768
+ if (opts.responseValidator) {
769
+ await opts.responseValidator(data);
770
+ }
771
+ if (opts.responseTransformer) {
772
+ data = await opts.responseTransformer(data);
773
+ }
774
+ }
775
+ return opts.responseStyle === "data" ? data : {
776
+ data,
777
+ ...result
778
+ };
779
+ }
780
+ const textError = await response.text();
781
+ let jsonError;
782
+ try {
783
+ jsonError = JSON.parse(textError);
784
+ } catch {}
785
+ const error = jsonError ?? textError;
786
+ let finalError = error;
787
+ for (const fn of interceptors.error.fns) {
788
+ if (fn) {
789
+ finalError = await fn(error, response, request2, opts);
790
+ }
791
+ }
792
+ finalError = finalError || {};
793
+ if (opts.throwOnError) {
794
+ throw finalError;
795
+ }
796
+ return opts.responseStyle === "data" ? void 0 : {
797
+ error: finalError,
798
+ ...result
799
+ };
800
+ }, "request");
801
+ const makeMethodFn = /* @__PURE__ */__name(method => options => request({
802
+ ...options,
803
+ method
804
+ }), "makeMethodFn");
805
+ const makeSseFn = /* @__PURE__ */__name(method => async options => {
806
+ const {
807
+ opts,
808
+ url
809
+ } = await beforeRequest(options);
810
+ return createSseClient({
811
+ ...opts,
812
+ body: opts.body,
813
+ headers: opts.headers,
814
+ method,
815
+ onRequest: /* @__PURE__ */__name(async (url2, init) => {
816
+ let request2 = new Request(url2, init);
817
+ for (const fn of interceptors.request.fns) {
818
+ if (fn) {
819
+ request2 = await fn(request2, opts);
820
+ }
821
+ }
822
+ return request2;
823
+ }, "onRequest"),
824
+ serializedBody: getValidRequestBody(opts),
825
+ url
826
+ });
827
+ }, "makeSseFn");
828
+ const _buildUrl = /* @__PURE__ */__name(options => buildUrl({
829
+ ..._config,
830
+ ...options
831
+ }), "_buildUrl");
832
+ return {
833
+ buildUrl: _buildUrl,
834
+ connect: makeMethodFn("CONNECT"),
835
+ delete: makeMethodFn("DELETE"),
836
+ get: makeMethodFn("GET"),
837
+ getConfig,
838
+ head: makeMethodFn("HEAD"),
839
+ interceptors,
840
+ options: makeMethodFn("OPTIONS"),
841
+ patch: makeMethodFn("PATCH"),
842
+ post: makeMethodFn("POST"),
843
+ put: makeMethodFn("PUT"),
844
+ request,
845
+ setConfig,
846
+ sse: {
847
+ connect: makeSseFn("CONNECT"),
848
+ delete: makeSseFn("DELETE"),
849
+ get: makeSseFn("GET"),
850
+ head: makeSseFn("HEAD"),
851
+ options: makeSseFn("OPTIONS"),
852
+ patch: makeSseFn("PATCH"),
853
+ post: makeSseFn("POST"),
854
+ put: makeSseFn("PUT"),
855
+ trace: makeSseFn("TRACE")
856
+ },
857
+ trace: makeMethodFn("TRACE")
858
+ };
859
+ }, "createClient");
860
+
861
+ // src/generated/client.gen.ts
862
+ var client = createClient(createConfig({
863
+ baseUrl: "/api/v1"
864
+ }));
865
+
866
+ // src/generated/sdk.gen.ts
867
+ var Actors = class {
868
+ static {
869
+ __name(this, "Actors");
870
+ }
871
+ /**
872
+ * List actors
873
+ *
874
+ * Returns all actors the caller has access to. If projectId is provided, returns only actors in that project. project keys are scoped to a single project automatically. JWT users without projectId receive actors across all their accessible projects.
875
+ */
876
+ static listActors(options) {
877
+ return (options?.client ?? client).get({
878
+ url: "/actors",
879
+ ...options
880
+ });
881
+ }
882
+ /**
883
+ * Create an actor
884
+ *
885
+ * Creates a new actor. project keys automatically infer the project from the key's scope; JWT callers must supply projectId.
886
+ */
887
+ static createActor(options) {
888
+ return (options.client ?? client).post({
889
+ url: "/actors",
890
+ ...options,
891
+ headers: {
892
+ "Content-Type": "application/json",
893
+ ...options.headers
894
+ }
895
+ });
896
+ }
897
+ /**
898
+ * Delete an actor
899
+ *
900
+ * Deletes an actor by its ID
901
+ */
902
+ static deleteActor(options) {
903
+ return (options.client ?? client).delete({
904
+ url: "/actors/{id}",
905
+ ...options
906
+ });
907
+ }
908
+ /**
909
+ * Get an actor by ID
910
+ *
911
+ * Returns an actor by its ID
912
+ */
913
+ static getActor(options) {
914
+ return (options.client ?? client).get({
915
+ url: "/actors/{id}",
916
+ ...options
917
+ });
918
+ }
919
+ /**
920
+ * Update an actor
921
+ *
922
+ * Updates an actor's properties
923
+ */
924
+ static updateActor(options) {
925
+ return (options.client ?? client).patch({
926
+ url: "/actors/{id}",
927
+ ...options,
18
928
  headers: {
19
- Authorization: `Bearer ${token}`
929
+ "Content-Type": "application/json",
930
+ ...options.headers
20
931
  }
21
- })
932
+ });
933
+ }
934
+ /**
935
+ * Get actor tags
936
+ *
937
+ * Returns all tags attached to the actor
938
+ */
939
+ static getActorTags(options) {
940
+ return (options.client ?? client).get({
941
+ url: "/actors/{id}/tags",
942
+ ...options
943
+ });
944
+ }
945
+ /**
946
+ * Merge actor tags
947
+ *
948
+ * Merges provided tags with existing tags (existing tags are preserved unless overridden)
949
+ */
950
+ static mergeActorTags(options) {
951
+ return (options.client ?? client).patch({
952
+ url: "/actors/{id}/tags",
953
+ ...options,
954
+ headers: {
955
+ "Content-Type": "application/json",
956
+ ...options.headers
957
+ }
958
+ });
959
+ }
960
+ /**
961
+ * Replace actor tags
962
+ *
963
+ * Replaces all tags on the actor with the provided tags (not merged)
964
+ */
965
+ static replaceActorTags(options) {
966
+ return (options.client ?? client).put({
967
+ url: "/actors/{id}/tags",
968
+ ...options,
969
+ headers: {
970
+ "Content-Type": "application/json",
971
+ ...options.headers
972
+ }
973
+ });
974
+ }
975
+ };
976
+ var AgentTools = class {
977
+ static {
978
+ __name(this, "AgentTools");
979
+ }
980
+ /**
981
+ * List agent tools
982
+ *
983
+ * Returns all agent tools in the project.
984
+ */
985
+ static listAgentTools(options) {
986
+ return (options?.client ?? client).get({
987
+ security: [{
988
+ scheme: "bearer",
989
+ type: "http"
990
+ }],
991
+ url: "/agents/tools",
992
+ ...options
993
+ });
994
+ }
995
+ /**
996
+ * Create an agent tool
997
+ *
998
+ * Creates a new agent tool in the project.
999
+ */
1000
+ static createAgentTool(options) {
1001
+ return (options.client ?? client).post({
1002
+ security: [{
1003
+ scheme: "bearer",
1004
+ type: "http"
1005
+ }],
1006
+ url: "/agents/tools",
1007
+ ...options,
1008
+ headers: {
1009
+ "Content-Type": "application/json",
1010
+ ...options.headers
1011
+ }
1012
+ });
1013
+ }
1014
+ /**
1015
+ * Delete an agent tool
1016
+ *
1017
+ * Deletes an agent tool by ID.
1018
+ */
1019
+ static deleteAgentTool(options) {
1020
+ return (options.client ?? client).delete({
1021
+ security: [{
1022
+ scheme: "bearer",
1023
+ type: "http"
1024
+ }],
1025
+ url: "/agents/tools/{tool_id}",
1026
+ ...options
1027
+ });
1028
+ }
1029
+ /**
1030
+ * Get an agent tool
1031
+ *
1032
+ * Returns a single agent tool by ID.
1033
+ */
1034
+ static getAgentTool(options) {
1035
+ return (options.client ?? client).get({
1036
+ security: [{
1037
+ scheme: "bearer",
1038
+ type: "http"
1039
+ }],
1040
+ url: "/agents/tools/{tool_id}",
1041
+ ...options
1042
+ });
1043
+ }
1044
+ /**
1045
+ * Update an agent tool
1046
+ *
1047
+ * Updates an existing agent tool.
1048
+ */
1049
+ static updateAgentTool(options) {
1050
+ return (options.client ?? client).put({
1051
+ security: [{
1052
+ scheme: "bearer",
1053
+ type: "http"
1054
+ }],
1055
+ url: "/agents/tools/{tool_id}",
1056
+ ...options,
1057
+ headers: {
1058
+ "Content-Type": "application/json",
1059
+ ...options.headers
1060
+ }
1061
+ });
1062
+ }
1063
+ };
1064
+ var AgentTraces = class {
1065
+ static {
1066
+ __name(this, "AgentTraces");
1067
+ }
1068
+ /**
1069
+ * List agent traces
1070
+ *
1071
+ * Returns all traces for the project.
1072
+ */
1073
+ static listAgentTraces(options) {
1074
+ return (options?.client ?? client).get({
1075
+ security: [{
1076
+ scheme: "bearer",
1077
+ type: "http"
1078
+ }],
1079
+ url: "/agents/traces",
1080
+ ...options
1081
+ });
1082
+ }
1083
+ /**
1084
+ * Get a trace
1085
+ *
1086
+ * Returns a single trace by ID.
1087
+ */
1088
+ static getAgentTrace(options) {
1089
+ return (options.client ?? client).get({
1090
+ security: [{
1091
+ scheme: "bearer",
1092
+ type: "http"
1093
+ }],
1094
+ url: "/agents/traces/{trace_id}",
1095
+ ...options
1096
+ });
1097
+ }
1098
+ };
1099
+ var Agents = class {
1100
+ static {
1101
+ __name(this, "Agents");
1102
+ }
1103
+ /**
1104
+ * List agents
1105
+ *
1106
+ * Returns all agents in the project.
1107
+ */
1108
+ static listAgents(options) {
1109
+ return (options?.client ?? client).get({
1110
+ security: [{
1111
+ scheme: "bearer",
1112
+ type: "http"
1113
+ }],
1114
+ url: "/agents",
1115
+ ...options
1116
+ });
1117
+ }
1118
+ /**
1119
+ * Create an agent
1120
+ *
1121
+ * Creates a new agent bound to an AI provider.
1122
+ */
1123
+ static createAgent(options) {
1124
+ return (options.client ?? client).post({
1125
+ security: [{
1126
+ scheme: "bearer",
1127
+ type: "http"
1128
+ }],
1129
+ url: "/agents",
1130
+ ...options,
1131
+ headers: {
1132
+ "Content-Type": "application/json",
1133
+ ...options.headers
1134
+ }
1135
+ });
1136
+ }
1137
+ /**
1138
+ * Delete an agent
1139
+ *
1140
+ * Deletes an agent by ID.
1141
+ */
1142
+ static deleteAgent(options) {
1143
+ return (options.client ?? client).delete({
1144
+ security: [{
1145
+ scheme: "bearer",
1146
+ type: "http"
1147
+ }],
1148
+ url: "/agents/{agent_id}",
1149
+ ...options
1150
+ });
1151
+ }
1152
+ /**
1153
+ * Get an agent
1154
+ *
1155
+ * Returns a single agent by ID.
1156
+ */
1157
+ static getAgent(options) {
1158
+ return (options.client ?? client).get({
1159
+ security: [{
1160
+ scheme: "bearer",
1161
+ type: "http"
1162
+ }],
1163
+ url: "/agents/{agent_id}",
1164
+ ...options
1165
+ });
1166
+ }
1167
+ /**
1168
+ * Update an agent
1169
+ *
1170
+ * Updates an existing agent.
1171
+ */
1172
+ static updateAgent(options) {
1173
+ return (options.client ?? client).put({
1174
+ security: [{
1175
+ scheme: "bearer",
1176
+ type: "http"
1177
+ }],
1178
+ url: "/agents/{agent_id}",
1179
+ ...options,
1180
+ headers: {
1181
+ "Content-Type": "application/json",
1182
+ ...options.headers
1183
+ }
1184
+ });
1185
+ }
1186
+ /**
1187
+ * Run an agent generation
1188
+ *
1189
+ * Sends messages to the agent, resolves its tools, and runs the AI model loop. Supports streaming via `stream: true`. Client tools pause the generation and return `requires_action`.
1190
+ *
1191
+ */
1192
+ static createAgentGeneration(options) {
1193
+ return (options.client ?? client).post({
1194
+ security: [{
1195
+ scheme: "bearer",
1196
+ type: "http"
1197
+ }],
1198
+ url: "/agents/{agent_id}/generate",
1199
+ ...options,
1200
+ headers: {
1201
+ "Content-Type": "application/json",
1202
+ ...options.headers
1203
+ }
1204
+ });
1205
+ }
1206
+ /**
1207
+ * Submit tool outputs for a paused generation
1208
+ *
1209
+ * Resumes a generation that was paused due to client tool calls. Provide tool outputs for each pending tool call.
1210
+ *
1211
+ */
1212
+ static submitAgentToolOutputs(options) {
1213
+ return (options.client ?? client).post({
1214
+ security: [{
1215
+ scheme: "bearer",
1216
+ type: "http"
1217
+ }],
1218
+ url: "/agents/{agent_id}/generate/{generation_id}/tool-outputs",
1219
+ ...options,
1220
+ headers: {
1221
+ "Content-Type": "application/json",
1222
+ ...options.headers
1223
+ }
1224
+ });
1225
+ }
1226
+ /**
1227
+ * Create an actor for an agent
1228
+ *
1229
+ * Creates a new actor associated with the specified agent
1230
+ */
1231
+ static createAgentActor(options) {
1232
+ return (options.client ?? client).post({
1233
+ url: "/agents/{agent_id}/actors",
1234
+ ...options,
1235
+ headers: {
1236
+ "Content-Type": "application/json",
1237
+ ...options.headers
1238
+ }
1239
+ });
1240
+ }
1241
+ };
1242
+ var AiProviders = class {
1243
+ static {
1244
+ __name(this, "AiProviders");
1245
+ }
1246
+ /**
1247
+ * List AI providers
1248
+ *
1249
+ * Returns a list of AI provider configurations for a project
1250
+ */
1251
+ static listAiProviders(options) {
1252
+ return (options?.client ?? client).get({
1253
+ url: "/ai-providers",
1254
+ ...options
1255
+ });
1256
+ }
1257
+ /**
1258
+ * Create an AI provider
1259
+ *
1260
+ * Creates a new LLM provider configuration
1261
+ */
1262
+ static createAiProvider(options) {
1263
+ return (options.client ?? client).post({
1264
+ url: "/ai-providers",
1265
+ ...options,
1266
+ headers: {
1267
+ "Content-Type": "application/json",
1268
+ ...options.headers
1269
+ }
1270
+ });
1271
+ }
1272
+ /**
1273
+ * Delete an AI provider
1274
+ *
1275
+ * Deletes an AI provider configuration
1276
+ */
1277
+ static deleteAiProvider(options) {
1278
+ return (options.client ?? client).delete({
1279
+ url: "/ai-providers/{ai_provider_id}",
1280
+ ...options
1281
+ });
1282
+ }
1283
+ /**
1284
+ * Get an AI provider
1285
+ *
1286
+ * Returns a specific AI provider configuration
1287
+ */
1288
+ static getAiProvider(options) {
1289
+ return (options.client ?? client).get({
1290
+ url: "/ai-providers/{ai_provider_id}",
1291
+ ...options
1292
+ });
1293
+ }
1294
+ /**
1295
+ * Update an AI provider
1296
+ *
1297
+ * Updates an AI provider configuration
1298
+ */
1299
+ static updateAiProvider(options) {
1300
+ return (options.client ?? client).patch({
1301
+ url: "/ai-providers/{ai_provider_id}",
1302
+ ...options,
1303
+ headers: {
1304
+ "Content-Type": "application/json",
1305
+ ...options.headers
1306
+ }
1307
+ });
1308
+ }
1309
+ };
1310
+ var ApiKeys = class {
1311
+ static {
1312
+ __name(this, "ApiKeys");
1313
+ }
1314
+ /**
1315
+ * Create an API key
1316
+ *
1317
+ * Creates a new API key for the authenticated user. - If `project_id` is provided, the key is scoped to that project. - If `policy_ids` is provided, the key's effective permissions are the intersection of the user's policies and the key's policies. - If neither is provided, the key inherits the user's full permissions.
1318
+ *
1319
+ */
1320
+ static createApiKey(options) {
1321
+ return (options.client ?? client).post({
1322
+ security: [{
1323
+ scheme: "bearer",
1324
+ type: "http"
1325
+ }],
1326
+ url: "/api-keys",
1327
+ ...options,
1328
+ headers: {
1329
+ "Content-Type": "application/json",
1330
+ ...options.headers
1331
+ }
1332
+ });
1333
+ }
1334
+ /**
1335
+ * Delete an API key
1336
+ *
1337
+ * Deletes an API key. Only the owner or an admin can delete it.
1338
+ */
1339
+ static deleteApiKey(options) {
1340
+ return (options.client ?? client).delete({
1341
+ security: [{
1342
+ scheme: "bearer",
1343
+ type: "http"
1344
+ }],
1345
+ url: "/api-keys/{id}",
1346
+ ...options
1347
+ });
1348
+ }
1349
+ /**
1350
+ * Get an API key
1351
+ *
1352
+ * Returns details of an API key. Only the owner or an admin can access it.
1353
+ */
1354
+ static getApiKey(options) {
1355
+ return (options.client ?? client).get({
1356
+ security: [{
1357
+ scheme: "bearer",
1358
+ type: "http"
1359
+ }],
1360
+ url: "/api-keys/{id}",
1361
+ ...options
1362
+ });
1363
+ }
1364
+ /**
1365
+ * Update an API key
1366
+ *
1367
+ * Updates an API key's name, project scope, or policies. Only the owner or an admin can update it.
1368
+ */
1369
+ static updateApiKey(options) {
1370
+ return (options.client ?? client).put({
1371
+ security: [{
1372
+ scheme: "bearer",
1373
+ type: "http"
1374
+ }],
1375
+ url: "/api-keys/{id}",
1376
+ ...options,
1377
+ headers: {
1378
+ "Content-Type": "application/json",
1379
+ ...options.headers
1380
+ }
1381
+ });
1382
+ }
1383
+ };
1384
+ var Chats = class {
1385
+ static {
1386
+ __name(this, "Chats");
1387
+ }
1388
+ /**
1389
+ * List chats
1390
+ *
1391
+ * Returns all chats in the project.
1392
+ */
1393
+ static listChats(options) {
1394
+ return (options?.client ?? client).get({
1395
+ security: [{
1396
+ scheme: "bearer",
1397
+ type: "http"
1398
+ }],
1399
+ url: "/chats",
1400
+ ...options
1401
+ });
1402
+ }
1403
+ /**
1404
+ * Create a chat
1405
+ *
1406
+ * Creates a new chat resource bound to an AI provider.
1407
+ */
1408
+ static createChat(options) {
1409
+ return (options.client ?? client).post({
1410
+ security: [{
1411
+ scheme: "bearer",
1412
+ type: "http"
1413
+ }],
1414
+ url: "/chats",
1415
+ ...options,
1416
+ headers: {
1417
+ "Content-Type": "application/json",
1418
+ ...options.headers
1419
+ }
1420
+ });
1421
+ }
1422
+ /**
1423
+ * Delete a chat
1424
+ *
1425
+ * Deletes a chat by ID.
1426
+ */
1427
+ static deleteChat(options) {
1428
+ return (options.client ?? client).delete({
1429
+ security: [{
1430
+ scheme: "bearer",
1431
+ type: "http"
1432
+ }],
1433
+ url: "/chats/{chat_id}",
1434
+ ...options
1435
+ });
1436
+ }
1437
+ /**
1438
+ * Get a chat
1439
+ *
1440
+ * Returns a single chat by ID.
1441
+ */
1442
+ static getChat(options) {
1443
+ return (options.client ?? client).get({
1444
+ security: [{
1445
+ scheme: "bearer",
1446
+ type: "http"
1447
+ }],
1448
+ url: "/chats/{chat_id}",
1449
+ ...options
1450
+ });
1451
+ }
1452
+ /**
1453
+ * Create a chat completion for a stored chat
1454
+ *
1455
+ * Runs a completion using the AI provider and settings stored in the chat. Pass `stream: true` for SSE streaming. A system message in `messages` overrides the chat's stored system message for this call only. Messages may use `documentId` instead of `content`.
1456
+ *
1457
+ */
1458
+ static createChatCompletionForChat(options) {
1459
+ return (options.client ?? client).post({
1460
+ security: [{
1461
+ scheme: "bearer",
1462
+ type: "http"
1463
+ }],
1464
+ url: "/chats/{chat_id}/completions",
1465
+ ...options,
1466
+ headers: {
1467
+ "Content-Type": "application/json",
1468
+ ...options.headers
1469
+ }
1470
+ });
1471
+ }
1472
+ /**
1473
+ * Create a chat completion (stateless)
1474
+ *
1475
+ * OpenAI Chat Completions-compatible endpoint. Resolves the AI provider from `aiProviderId`, decrypts its secret, and calls the appropriate Vercel AI SDK provider. Falls back to Ollama when `aiProviderId` is omitted.
1476
+ *
1477
+ */
1478
+ static createChatCompletion(options) {
1479
+ return (options.client ?? client).post({
1480
+ security: [{
1481
+ scheme: "bearer",
1482
+ type: "http"
1483
+ }],
1484
+ url: "/chats/completions",
1485
+ ...options,
1486
+ headers: {
1487
+ "Content-Type": "application/json",
1488
+ ...options.headers
1489
+ }
1490
+ });
1491
+ }
1492
+ /**
1493
+ * Create an actor for a chat
1494
+ *
1495
+ * Creates a new actor associated with the specified chat
1496
+ */
1497
+ static createChatActor(options) {
1498
+ return (options.client ?? client).post({
1499
+ url: "/chats/{chat_id}/actors",
1500
+ ...options,
1501
+ headers: {
1502
+ "Content-Type": "application/json",
1503
+ ...options.headers
1504
+ }
1505
+ });
1506
+ }
1507
+ };
1508
+ var Conversations = class {
1509
+ static {
1510
+ __name(this, "Conversations");
1511
+ }
1512
+ /**
1513
+ * List conversations
1514
+ *
1515
+ * Returns all conversations the caller has access to. If projectId is provided, returns only conversations in that project. project keys are scoped to a single project automatically.
1516
+ */
1517
+ static listConversations(options) {
1518
+ return (options?.client ?? client).get({
1519
+ url: "/conversations",
1520
+ ...options
1521
+ });
1522
+ }
1523
+ /**
1524
+ * Create a conversation
1525
+ *
1526
+ * Creates a new conversation. project keys automatically infer the project from the key's scope; JWT callers must supply projectId.
1527
+ */
1528
+ static createConversation(options) {
1529
+ return (options.client ?? client).post({
1530
+ url: "/conversations",
1531
+ ...options,
1532
+ headers: {
1533
+ "Content-Type": "application/json",
1534
+ ...options.headers
1535
+ }
1536
+ });
1537
+ }
1538
+ /**
1539
+ * Delete a conversation
1540
+ *
1541
+ * Deletes a conversation by its ID
1542
+ */
1543
+ static deleteConversation(options) {
1544
+ return (options.client ?? client).delete({
1545
+ url: "/conversations/{id}",
1546
+ ...options
1547
+ });
1548
+ }
1549
+ /**
1550
+ * Get a conversation by ID
1551
+ *
1552
+ * Returns a conversation by its ID
1553
+ */
1554
+ static getConversation(options) {
1555
+ return (options.client ?? client).get({
1556
+ url: "/conversations/{id}",
1557
+ ...options
1558
+ });
1559
+ }
1560
+ /**
1561
+ * Update a conversation
1562
+ *
1563
+ * Updates the status of a conversation
1564
+ */
1565
+ static updateConversation(options) {
1566
+ return (options.client ?? client).patch({
1567
+ url: "/conversations/{id}",
1568
+ ...options,
1569
+ headers: {
1570
+ "Content-Type": "application/json",
1571
+ ...options.headers
1572
+ }
1573
+ });
1574
+ }
1575
+ /**
1576
+ * List conversation messages
1577
+ *
1578
+ * Returns all messages (documents) attached to a conversation, ordered by position
1579
+ */
1580
+ static listConversationMessages(options) {
1581
+ return (options.client ?? client).get({
1582
+ url: "/conversations/{id}/messages",
1583
+ ...options
1584
+ });
1585
+ }
1586
+ /**
1587
+ * Add a message to a conversation
1588
+ *
1589
+ * Creates a document from the message text and attaches it to the conversation at the given position. If position is omitted, it is appended at the end.
1590
+ */
1591
+ static addConversationMessage(options) {
1592
+ return (options.client ?? client).post({
1593
+ url: "/conversations/{id}/messages",
1594
+ ...options,
1595
+ headers: {
1596
+ "Content-Type": "application/json",
1597
+ ...options.headers
1598
+ }
1599
+ });
1600
+ }
1601
+ /**
1602
+ * Generate the next message in a conversation
1603
+ *
1604
+ * Generates the next message using the specified actor's linked agent or chat.
1605
+ * On `completed`, the reply is persisted as a new ConversationMessage authored
1606
+ * by that actor. On `requires_action`, nothing is persisted; the caller must
1607
+ * submit tool outputs via the Agents module and re-invoke generate.
1608
+ *
1609
+ */
1610
+ static generateConversationMessage(options) {
1611
+ return (options.client ?? client).post({
1612
+ url: "/conversations/{id}/generate",
1613
+ ...options,
1614
+ headers: {
1615
+ "Content-Type": "application/json",
1616
+ ...options.headers
1617
+ }
1618
+ });
1619
+ }
1620
+ /**
1621
+ * List actors in a conversation
1622
+ *
1623
+ * Returns all distinct actors who have sent at least one message in the conversation
1624
+ */
1625
+ static listConversationActors(options) {
1626
+ return (options.client ?? client).get({
1627
+ url: "/conversations/{id}/actors",
1628
+ ...options
1629
+ });
1630
+ }
1631
+ /**
1632
+ * Remove a message from a conversation
1633
+ *
1634
+ * Removes a document from a conversation
1635
+ */
1636
+ static removeConversationMessage(options) {
1637
+ return (options.client ?? client).delete({
1638
+ url: "/conversations/{id}/messages/{document_id}",
1639
+ ...options
1640
+ });
1641
+ }
1642
+ /**
1643
+ * Get conversation tags
1644
+ *
1645
+ * Returns all tags attached to the conversation
1646
+ */
1647
+ static getConversationTags(options) {
1648
+ return (options.client ?? client).get({
1649
+ url: "/conversations/{id}/tags",
1650
+ ...options
1651
+ });
1652
+ }
1653
+ /**
1654
+ * Merge conversation tags
1655
+ *
1656
+ * Merges provided tags with existing tags
1657
+ */
1658
+ static mergeConversationTags(options) {
1659
+ return (options.client ?? client).patch({
1660
+ url: "/conversations/{id}/tags",
1661
+ ...options,
1662
+ headers: {
1663
+ "Content-Type": "application/json",
1664
+ ...options.headers
1665
+ }
1666
+ });
1667
+ }
1668
+ /**
1669
+ * Replace conversation tags
1670
+ *
1671
+ * Replaces all tags on the conversation with the provided tags
1672
+ */
1673
+ static replaceConversationTags(options) {
1674
+ return (options.client ?? client).put({
1675
+ url: "/conversations/{id}/tags",
1676
+ ...options,
1677
+ headers: {
1678
+ "Content-Type": "application/json",
1679
+ ...options.headers
1680
+ }
1681
+ });
1682
+ }
1683
+ };
1684
+ var Documents = class {
1685
+ static {
1686
+ __name(this, "Documents");
1687
+ }
1688
+ /**
1689
+ * List documents
1690
+ *
1691
+ * Returns all documents the caller has access to. If projectId is provided, returns only documents in that project. project keys are scoped to a single project automatically. JWT users without projectId receive documents across all their accessible projects.
1692
+ */
1693
+ static listDocuments(options) {
1694
+ return (options?.client ?? client).get({
1695
+ url: "/documents",
1696
+ ...options
1697
+ });
1698
+ }
1699
+ /**
1700
+ * Create a document
1701
+ *
1702
+ * Creates a new text document and generates an embedding vector for semantic search. project keys automatically infer the project from the key's scope; JWT callers must supply projectId.
1703
+ */
1704
+ static createDocument(options) {
1705
+ return (options.client ?? client).post({
1706
+ url: "/documents",
1707
+ ...options,
1708
+ headers: {
1709
+ "Content-Type": "application/json",
1710
+ ...options.headers
1711
+ }
1712
+ });
1713
+ }
1714
+ /**
1715
+ * Delete a document
1716
+ *
1717
+ * Deletes a document and its underlying file
1718
+ */
1719
+ static deleteDocument(options) {
1720
+ return (options.client ?? client).delete({
1721
+ url: "/documents/{id}",
1722
+ ...options
1723
+ });
1724
+ }
1725
+ /**
1726
+ * Get a document by ID
1727
+ *
1728
+ * Returns a document with its text content
1729
+ */
1730
+ static getDocument(options) {
1731
+ return (options.client ?? client).get({
1732
+ url: "/documents/{id}",
1733
+ ...options
1734
+ });
1735
+ }
1736
+ /**
1737
+ * Update a document
1738
+ *
1739
+ * Updates document content, title, path, metadata, or tags. Supplying `path` moves the document to a new logical path within the project.
1740
+ */
1741
+ static updateDocument(options) {
1742
+ return (options.client ?? client).patch({
1743
+ url: "/documents/{id}",
1744
+ ...options,
1745
+ headers: {
1746
+ "Content-Type": "application/json",
1747
+ ...options.headers
1748
+ }
1749
+ });
1750
+ }
1751
+ /**
1752
+ * Get document tags
1753
+ *
1754
+ * Returns all tags attached to the document
1755
+ */
1756
+ static getDocumentTags(options) {
1757
+ return (options.client ?? client).get({
1758
+ url: "/documents/{id}/tags",
1759
+ ...options
1760
+ });
1761
+ }
1762
+ /**
1763
+ * Merge document tags
1764
+ *
1765
+ * Merges provided tags with existing tags (existing tags are preserved unless overridden)
1766
+ */
1767
+ static mergeDocumentTags(options) {
1768
+ return (options.client ?? client).patch({
1769
+ url: "/documents/{id}/tags",
1770
+ ...options,
1771
+ headers: {
1772
+ "Content-Type": "application/json",
1773
+ ...options.headers
1774
+ }
1775
+ });
1776
+ }
1777
+ /**
1778
+ * Replace document tags
1779
+ *
1780
+ * Replaces all tags on the document with the provided tags (not merged)
1781
+ */
1782
+ static replaceDocumentTags(options) {
1783
+ return (options.client ?? client).put({
1784
+ url: "/documents/{id}/tags",
1785
+ ...options,
1786
+ headers: {
1787
+ "Content-Type": "application/json",
1788
+ ...options.headers
1789
+ }
1790
+ });
1791
+ }
1792
+ /**
1793
+ * Semantic search over documents
1794
+ *
1795
+ * Searches documents using semantic search, file paths, or document IDs. At least one of search, paths, or document_ids must be provided. Returns results ordered by similarity score.
1796
+ */
1797
+ static searchDocuments(options) {
1798
+ return (options.client ?? client).post({
1799
+ url: "/documents/search",
1800
+ ...options,
1801
+ headers: {
1802
+ "Content-Type": "application/json",
1803
+ ...options.headers
1804
+ }
1805
+ });
1806
+ }
1807
+ };
1808
+ var Files = class {
1809
+ static {
1810
+ __name(this, "Files");
1811
+ }
1812
+ /**
1813
+ * List all files
1814
+ *
1815
+ * Returns a list of all stored files
1816
+ */
1817
+ static listFiles(options) {
1818
+ return (options?.client ?? client).get({
1819
+ url: "/files",
1820
+ ...options
1821
+ });
1822
+ }
1823
+ /**
1824
+ * Create a file
1825
+ *
1826
+ * Creates a new file record in the system
1827
+ */
1828
+ static createFile(options) {
1829
+ return (options.client ?? client).post({
1830
+ url: "/files",
1831
+ ...options,
1832
+ headers: {
1833
+ "Content-Type": "application/json",
1834
+ ...options.headers
1835
+ }
1836
+ });
1837
+ }
1838
+ /**
1839
+ * Upload a file
1840
+ *
1841
+ * Uploads a file to the server and stores it in the configured storage directory
1842
+ */
1843
+ static uploadFile(options) {
1844
+ return (options.client ?? client).post({
1845
+ ...formDataBodySerializer,
1846
+ url: "/files/upload",
1847
+ ...options,
1848
+ headers: {
1849
+ "Content-Type": null,
1850
+ ...options.headers
1851
+ }
1852
+ });
1853
+ }
1854
+ /**
1855
+ * Upload a file using base64 encoding
1856
+ *
1857
+ * Uploads a file to the server using base64-encoded content
1858
+ */
1859
+ static uploadFileBase64(options) {
1860
+ return (options.client ?? client).post({
1861
+ url: "/files/upload/base64",
1862
+ ...options,
1863
+ headers: {
1864
+ "Content-Type": "application/json",
1865
+ ...options.headers
1866
+ }
1867
+ });
1868
+ }
1869
+ /**
1870
+ * Delete a file
1871
+ *
1872
+ * Removes a file from the system by ID
1873
+ */
1874
+ static deleteFile(options) {
1875
+ return (options.client ?? client).delete({
1876
+ url: "/files/{id}",
1877
+ ...options
1878
+ });
1879
+ }
1880
+ /**
1881
+ * Get a file by ID
1882
+ *
1883
+ * Returns the data and metadata of a specific file
1884
+ */
1885
+ static getFile(options) {
1886
+ return (options.client ?? client).get({
1887
+ url: "/files/{id}",
1888
+ ...options
1889
+ });
1890
+ }
1891
+ /**
1892
+ * Download a file
1893
+ *
1894
+ * Streams the file content to the client
1895
+ */
1896
+ static downloadFile(options) {
1897
+ return (options.client ?? client).get({
1898
+ url: "/files/{id}/download",
1899
+ ...options
1900
+ });
1901
+ }
1902
+ /**
1903
+ * Update file metadata
1904
+ *
1905
+ * Updates the metadata field of a file
1906
+ */
1907
+ static updateFileMetadata(options) {
1908
+ return (options.client ?? client).patch({
1909
+ url: "/files/{id}/metadata",
1910
+ ...options,
1911
+ headers: {
1912
+ "Content-Type": "application/json",
1913
+ ...options.headers
1914
+ }
1915
+ });
1916
+ }
1917
+ /**
1918
+ * Download file as base64
1919
+ *
1920
+ * Returns the file content encoded as base64
1921
+ */
1922
+ static downloadFileBase64(options) {
1923
+ return (options.client ?? client).get({
1924
+ url: "/files/{id}/download/base64",
1925
+ ...options
1926
+ });
1927
+ }
1928
+ /**
1929
+ * Get file tags
1930
+ *
1931
+ * Returns all tags attached to the file
1932
+ */
1933
+ static getFileTags(options) {
1934
+ return (options.client ?? client).get({
1935
+ url: "/files/{id}/tags",
1936
+ ...options
1937
+ });
1938
+ }
1939
+ /**
1940
+ * Merge file tags
1941
+ *
1942
+ * Merges provided tags with existing tags
1943
+ */
1944
+ static mergeFileTags(options) {
1945
+ return (options.client ?? client).patch({
1946
+ url: "/files/{id}/tags",
1947
+ ...options,
1948
+ headers: {
1949
+ "Content-Type": "application/json",
1950
+ ...options.headers
1951
+ }
1952
+ });
1953
+ }
1954
+ /**
1955
+ * Replace file tags
1956
+ *
1957
+ * Replaces all tags on the file with the provided tags
1958
+ */
1959
+ static replaceFileTags(options) {
1960
+ return (options.client ?? client).put({
1961
+ url: "/files/{id}/tags",
1962
+ ...options,
1963
+ headers: {
1964
+ "Content-Type": "application/json",
1965
+ ...options.headers
1966
+ }
1967
+ });
1968
+ }
1969
+ };
1970
+ var Policies = class {
1971
+ static {
1972
+ __name(this, "Policies");
1973
+ }
1974
+ /**
1975
+ * List all policies
1976
+ *
1977
+ * Returns a list of all global policies. Requires admin role.
1978
+ */
1979
+ static listPolicies(options) {
1980
+ return (options?.client ?? client).get({
1981
+ security: [{
1982
+ scheme: "bearer",
1983
+ type: "http"
1984
+ }],
1985
+ url: "/policies",
1986
+ ...options
1987
+ });
1988
+ }
1989
+ /**
1990
+ * Create a policy
1991
+ *
1992
+ * Creates a new global policy. Requires admin role.
1993
+ */
1994
+ static createPolicy(options) {
1995
+ return (options.client ?? client).post({
1996
+ security: [{
1997
+ scheme: "bearer",
1998
+ type: "http"
1999
+ }],
2000
+ url: "/policies",
2001
+ ...options,
2002
+ headers: {
2003
+ "Content-Type": "application/json",
2004
+ ...options.headers
2005
+ }
2006
+ });
2007
+ }
2008
+ /**
2009
+ * Delete a policy
2010
+ *
2011
+ * Deletes a global policy. Requires admin role.
2012
+ */
2013
+ static deletePolicy(options) {
2014
+ return (options.client ?? client).delete({
2015
+ security: [{
2016
+ scheme: "bearer",
2017
+ type: "http"
2018
+ }],
2019
+ url: "/policies/{policy_id}",
2020
+ ...options
2021
+ });
2022
+ }
2023
+ /**
2024
+ * Get a policy
2025
+ *
2026
+ * Returns details of a specific policy. Requires admin role.
2027
+ */
2028
+ static getPolicy(options) {
2029
+ return (options.client ?? client).get({
2030
+ security: [{
2031
+ scheme: "bearer",
2032
+ type: "http"
2033
+ }],
2034
+ url: "/policies/{policy_id}",
2035
+ ...options
2036
+ });
2037
+ }
2038
+ /**
2039
+ * Update a policy
2040
+ *
2041
+ * Updates an existing global policy. Requires admin role.
2042
+ */
2043
+ static updatePolicy(options) {
2044
+ return (options.client ?? client).put({
2045
+ security: [{
2046
+ scheme: "bearer",
2047
+ type: "http"
2048
+ }],
2049
+ url: "/policies/{policy_id}",
2050
+ ...options,
2051
+ headers: {
2052
+ "Content-Type": "application/json",
2053
+ ...options.headers
2054
+ }
2055
+ });
2056
+ }
2057
+ };
2058
+ var Projects = class {
2059
+ static {
2060
+ __name(this, "Projects");
2061
+ }
2062
+ /**
2063
+ * Create a project
2064
+ *
2065
+ * Creates a new project. Requires admin role.
2066
+ */
2067
+ static createProject(options) {
2068
+ return (options.client ?? client).post({
2069
+ url: "/projects",
2070
+ ...options,
2071
+ headers: {
2072
+ "Content-Type": "application/json",
2073
+ ...options.headers
2074
+ }
2075
+ });
2076
+ }
2077
+ /**
2078
+ * Delete a project
2079
+ *
2080
+ * Deletes a project. Requires admin role.
2081
+ */
2082
+ static deleteProject(options) {
2083
+ return (options.client ?? client).delete({
2084
+ security: [{
2085
+ scheme: "bearer",
2086
+ type: "http"
2087
+ }],
2088
+ url: "/projects/{project_id}",
2089
+ ...options
2090
+ });
2091
+ }
2092
+ /**
2093
+ * Get a project
2094
+ *
2095
+ * Returns details of a specific project.
2096
+ */
2097
+ static getProject(options) {
2098
+ return (options.client ?? client).get({
2099
+ security: [{
2100
+ scheme: "bearer",
2101
+ type: "http"
2102
+ }],
2103
+ url: "/projects/{project_id}",
2104
+ ...options
2105
+ });
2106
+ }
2107
+ };
2108
+ var Secrets = class {
2109
+ static {
2110
+ __name(this, "Secrets");
2111
+ }
2112
+ /**
2113
+ * List secrets
2114
+ *
2115
+ * Returns a list of secrets for a project
2116
+ */
2117
+ static listSecrets(options) {
2118
+ return (options?.client ?? client).get({
2119
+ url: "/secrets",
2120
+ ...options
2121
+ });
2122
+ }
2123
+ /**
2124
+ * Create a secret
2125
+ *
2126
+ * Creates a new encrypted secret in a project
2127
+ */
2128
+ static createSecret(options) {
2129
+ return (options.client ?? client).post({
2130
+ url: "/secrets",
2131
+ ...options,
2132
+ headers: {
2133
+ "Content-Type": "application/json",
2134
+ ...options.headers
2135
+ }
2136
+ });
2137
+ }
2138
+ /**
2139
+ * Delete a secret
2140
+ *
2141
+ * Deletes a secret
2142
+ */
2143
+ static deleteSecret(options) {
2144
+ return (options.client ?? client).delete({
2145
+ url: "/secrets/{secret_id}",
2146
+ ...options
2147
+ });
2148
+ }
2149
+ /**
2150
+ * Get a secret
2151
+ *
2152
+ * Returns a specific secret
2153
+ */
2154
+ static getSecret(options) {
2155
+ return (options.client ?? client).get({
2156
+ url: "/secrets/{secret_id}",
2157
+ ...options
2158
+ });
2159
+ }
2160
+ /**
2161
+ * Update a secret
2162
+ *
2163
+ * Updates a secret's name and/or value
2164
+ */
2165
+ static updateSecret(options) {
2166
+ return (options.client ?? client).patch({
2167
+ url: "/secrets/{secret_id}",
2168
+ ...options,
2169
+ headers: {
2170
+ "Content-Type": "application/json",
2171
+ ...options.headers
2172
+ }
2173
+ });
2174
+ }
2175
+ };
2176
+ var Sessions = class {
2177
+ static {
2178
+ __name(this, "Sessions");
2179
+ }
2180
+ /**
2181
+ * List sessions
2182
+ *
2183
+ * Returns sessions for the specified agent, optionally filtered by actorId and status.
2184
+ */
2185
+ static listAgentSessions(options) {
2186
+ return (options.client ?? client).get({
2187
+ security: [{
2188
+ scheme: "bearer",
2189
+ type: "http"
2190
+ }],
2191
+ url: "/agents/{agent_id}/sessions",
2192
+ ...options
2193
+ });
2194
+ }
2195
+ /**
2196
+ * Create a session
2197
+ *
2198
+ * Creates a new session for the specified agent. Internally creates a conversation and two actors (agent + user) so the caller only needs this single call to start interacting with the agent.
2199
+ *
2200
+ */
2201
+ static createAgentSession(options) {
2202
+ return (options.client ?? client).post({
2203
+ security: [{
2204
+ scheme: "bearer",
2205
+ type: "http"
2206
+ }],
2207
+ url: "/agents/{agent_id}/sessions",
2208
+ ...options,
2209
+ headers: {
2210
+ "Content-Type": "application/json",
2211
+ ...options.headers
2212
+ }
2213
+ });
2214
+ }
2215
+ /**
2216
+ * Delete a session
2217
+ *
2218
+ * Deletes the session and its underlying conversation and actors.
2219
+ */
2220
+ static deleteAgentSession(options) {
2221
+ return (options.client ?? client).delete({
2222
+ security: [{
2223
+ scheme: "bearer",
2224
+ type: "http"
2225
+ }],
2226
+ url: "/agents/{agent_id}/sessions/{session_id}",
2227
+ ...options
2228
+ });
2229
+ }
2230
+ /**
2231
+ * Get a session
2232
+ *
2233
+ * Returns details of a single session.
2234
+ */
2235
+ static getAgentSession(options) {
2236
+ return (options.client ?? client).get({
2237
+ security: [{
2238
+ scheme: "bearer",
2239
+ type: "http"
2240
+ }],
2241
+ url: "/agents/{agent_id}/sessions/{session_id}",
2242
+ ...options
2243
+ });
2244
+ }
2245
+ /**
2246
+ * Update a session
2247
+ *
2248
+ * Updates the session name and/or status.
2249
+ */
2250
+ static updateSession(options) {
2251
+ return (options.client ?? client).patch({
2252
+ security: [{
2253
+ scheme: "bearer",
2254
+ type: "http"
2255
+ }],
2256
+ url: "/agents/{agent_id}/sessions/{session_id}",
2257
+ ...options,
2258
+ headers: {
2259
+ "Content-Type": "application/json",
2260
+ ...options.headers
2261
+ }
2262
+ });
2263
+ }
2264
+ /**
2265
+ * List session messages
2266
+ *
2267
+ * Returns messages in the session with simplified roles (user/assistant) instead of raw actor IDs.
2268
+ *
2269
+ */
2270
+ static listAgentSessionMessages(options) {
2271
+ return (options.client ?? client).get({
2272
+ security: [{
2273
+ scheme: "bearer",
2274
+ type: "http"
2275
+ }],
2276
+ url: "/agents/{agent_id}/sessions/{session_id}/messages",
2277
+ ...options
2278
+ });
2279
+ }
2280
+ /**
2281
+ * Add a user message
2282
+ *
2283
+ * Saves a user message to the session. When autoGenerate is enabled on the session and no generation is currently in progress, generation is triggered automatically and the response mirrors GenerateSessionResponse. Otherwise returns the saved user message.
2284
+ *
2285
+ */
2286
+ static addSessionMessage(options) {
2287
+ return (options.client ?? client).post({
2288
+ security: [{
2289
+ scheme: "bearer",
2290
+ type: "http"
2291
+ }],
2292
+ url: "/agents/{agent_id}/sessions/{session_id}/messages",
2293
+ ...options,
2294
+ headers: {
2295
+ "Content-Type": "application/json",
2296
+ ...options.headers
2297
+ }
2298
+ });
2299
+ }
2300
+ /**
2301
+ * Trigger agent generation
2302
+ *
2303
+ * Triggers the agent to generate a response based on the current conversation. Returns the assistant reply or a requires_action status if the agent needs client tool outputs. Pass ?async=true for a 202 accepted response when you do not need to wait for the result.
2304
+ *
2305
+ */
2306
+ static generateSessionResponse(options) {
2307
+ return (options.client ?? client).post({
2308
+ security: [{
2309
+ scheme: "bearer",
2310
+ type: "http"
2311
+ }],
2312
+ url: "/agents/{agent_id}/sessions/{session_id}/generate",
2313
+ ...options,
2314
+ headers: {
2315
+ "Content-Type": "application/json",
2316
+ ...options.headers
2317
+ }
2318
+ });
2319
+ }
2320
+ /**
2321
+ * Submit tool outputs
2322
+ *
2323
+ * Submits client tool outputs for a generation that returned requires_action. The agent continues its loop and returns the final or next requires_action result.
2324
+ *
2325
+ */
2326
+ static submitSessionToolOutputs(options) {
2327
+ return (options.client ?? client).post({
2328
+ security: [{
2329
+ scheme: "bearer",
2330
+ type: "http"
2331
+ }],
2332
+ url: "/agents/{agent_id}/sessions/{session_id}/tool-outputs",
2333
+ ...options,
2334
+ headers: {
2335
+ "Content-Type": "application/json",
2336
+ ...options.headers
2337
+ }
2338
+ });
2339
+ }
2340
+ /**
2341
+ * Get session tags
2342
+ *
2343
+ * Returns the session's tags object.
2344
+ */
2345
+ static getSessionTags(options) {
2346
+ return (options.client ?? client).get({
2347
+ security: [{
2348
+ scheme: "bearer",
2349
+ type: "http"
2350
+ }],
2351
+ url: "/agents/{agent_id}/sessions/{session_id}/tags",
2352
+ ...options
2353
+ });
2354
+ }
2355
+ /**
2356
+ * Merge session tags
2357
+ *
2358
+ * Merges the provided tags into the session's existing tags.
2359
+ */
2360
+ static mergeSessionTags(options) {
2361
+ return (options.client ?? client).patch({
2362
+ security: [{
2363
+ scheme: "bearer",
2364
+ type: "http"
2365
+ }],
2366
+ url: "/agents/{agent_id}/sessions/{session_id}/tags",
2367
+ ...options,
2368
+ headers: {
2369
+ "Content-Type": "application/json",
2370
+ ...options.headers
2371
+ }
2372
+ });
2373
+ }
2374
+ /**
2375
+ * Replace session tags
2376
+ *
2377
+ * Replaces all tags on the session.
2378
+ */
2379
+ static replaceSessionTags(options) {
2380
+ return (options.client ?? client).put({
2381
+ security: [{
2382
+ scheme: "bearer",
2383
+ type: "http"
2384
+ }],
2385
+ url: "/agents/{agent_id}/sessions/{session_id}/tags",
2386
+ ...options,
2387
+ headers: {
2388
+ "Content-Type": "application/json",
2389
+ ...options.headers
2390
+ }
2391
+ });
2392
+ }
2393
+ };
2394
+ var Users = class {
2395
+ static {
2396
+ __name(this, "Users");
2397
+ }
2398
+ /**
2399
+ * List all users
2400
+ *
2401
+ * Returns a list of all users
2402
+ */
2403
+ static listUsers(options) {
2404
+ return (options?.client ?? client).get({
2405
+ url: "/users",
2406
+ ...options
2407
+ });
2408
+ }
2409
+ /**
2410
+ * Create a user
2411
+ *
2412
+ * Creates a new user in the system
2413
+ */
2414
+ static createUser(options) {
2415
+ return (options.client ?? client).post({
2416
+ url: "/users",
2417
+ ...options,
2418
+ headers: {
2419
+ "Content-Type": "application/json",
2420
+ ...options.headers
2421
+ }
2422
+ });
2423
+ }
2424
+ /**
2425
+ * Delete a user by ID
2426
+ *
2427
+ * Deletes a specific user
2428
+ */
2429
+ static deleteUser(options) {
2430
+ return (options.client ?? client).delete({
2431
+ url: "/users/{id}",
2432
+ ...options
2433
+ });
2434
+ }
2435
+ /**
2436
+ * Get a user by ID
2437
+ *
2438
+ * Returns the data of a specific user
2439
+ */
2440
+ static getUser(options) {
2441
+ return (options.client ?? client).get({
2442
+ url: "/users/{id}",
2443
+ ...options
2444
+ });
2445
+ }
2446
+ /**
2447
+ * Create the first admin user
2448
+ *
2449
+ * Creates the first admin user. Returns 409 if any user already exists.
2450
+ */
2451
+ static bootstrapUser(options) {
2452
+ return (options.client ?? client).post({
2453
+ url: "/users/bootstrap",
2454
+ ...options,
2455
+ headers: {
2456
+ "Content-Type": "application/json",
2457
+ ...options.headers
2458
+ }
2459
+ });
2460
+ }
2461
+ /**
2462
+ * Login user
2463
+ *
2464
+ * Authenticates a user and returns a JWT token
2465
+ */
2466
+ static loginUser(options) {
2467
+ return (options.client ?? client).post({
2468
+ url: "/users/login",
2469
+ ...options,
2470
+ headers: {
2471
+ "Content-Type": "application/json",
2472
+ ...options.headers
2473
+ }
2474
+ });
2475
+ }
2476
+ /**
2477
+ * Get policies attached to a user
2478
+ *
2479
+ * Returns the list of policies attached to a user. Requires admin role.
2480
+ */
2481
+ static getUserPolicies(options) {
2482
+ return (options.client ?? client).get({
2483
+ security: [{
2484
+ scheme: "bearer",
2485
+ type: "http"
2486
+ }],
2487
+ url: "/users/{user_id}/policies",
2488
+ ...options
2489
+ });
2490
+ }
2491
+ /**
2492
+ * Attach policies to a user
2493
+ *
2494
+ * Replaces the user's policy list with the provided policy IDs. Requires admin role.
2495
+ */
2496
+ static attachUserPolicies(options) {
2497
+ return (options.client ?? client).put({
2498
+ security: [{
2499
+ scheme: "bearer",
2500
+ type: "http"
2501
+ }],
2502
+ url: "/users/{user_id}/policies",
2503
+ ...options,
2504
+ headers: {
2505
+ "Content-Type": "application/json",
2506
+ ...options.headers
2507
+ }
2508
+ });
2509
+ }
2510
+ };
2511
+ var Webhooks = class {
2512
+ static {
2513
+ __name(this, "Webhooks");
2514
+ }
2515
+ /**
2516
+ * List webhooks for a project
2517
+ *
2518
+ * Lists all webhooks configured for the specified project
2519
+ */
2520
+ static listWebhooks(options) {
2521
+ return (options.client ?? client).get({
2522
+ url: "/projects/{project_id}/webhooks",
2523
+ ...options
2524
+ });
2525
+ }
2526
+ /**
2527
+ * Create a webhook
2528
+ *
2529
+ * Creates a new webhook for the specified project
2530
+ */
2531
+ static createWebhook(options) {
2532
+ return (options.client ?? client).post({
2533
+ url: "/projects/{project_id}/webhooks",
2534
+ ...options,
2535
+ headers: {
2536
+ "Content-Type": "application/json",
2537
+ ...options.headers
2538
+ }
2539
+ });
2540
+ }
2541
+ /**
2542
+ * Delete a webhook
2543
+ *
2544
+ * Deletes a webhook and stops all event deliveries
2545
+ */
2546
+ static deleteWebhook(options) {
2547
+ return (options.client ?? client).delete({
2548
+ url: "/projects/{project_id}/webhooks/{webhook_id}",
2549
+ ...options
2550
+ });
2551
+ }
2552
+ /**
2553
+ * Get a webhook
2554
+ *
2555
+ * Retrieves the details of a specific webhook
2556
+ */
2557
+ static getWebhook(options) {
2558
+ return (options.client ?? client).get({
2559
+ url: "/projects/{project_id}/webhooks/{webhook_id}",
2560
+ ...options
2561
+ });
2562
+ }
2563
+ /**
2564
+ * Update a webhook
2565
+ *
2566
+ * Updates an existing webhook's configuration
2567
+ */
2568
+ static updateWebhook(options) {
2569
+ return (options.client ?? client).put({
2570
+ url: "/projects/{project_id}/webhooks/{webhook_id}",
2571
+ ...options,
2572
+ headers: {
2573
+ "Content-Type": "application/json",
2574
+ ...options.headers
2575
+ }
2576
+ });
2577
+ }
2578
+ /**
2579
+ * List deliveries for a webhook
2580
+ *
2581
+ * Lists all event deliveries for a specific webhook
2582
+ */
2583
+ static listWebhookDeliveries(options) {
2584
+ return (options.client ?? client).get({
2585
+ url: "/projects/{project_id}/webhooks/{webhook_id}/deliveries",
2586
+ ...options
2587
+ });
2588
+ }
2589
+ /**
2590
+ * Get a delivery
2591
+ *
2592
+ * Retrieves the details of a specific webhook delivery
2593
+ */
2594
+ static getWebhookDelivery(options) {
2595
+ return (options.client ?? client).get({
2596
+ url: "/projects/{project_id}/webhooks/{webhook_id}/deliveries/{delivery_id}",
2597
+ ...options
2598
+ });
2599
+ }
2600
+ /**
2601
+ * Rotate webhook secret
2602
+ *
2603
+ * Rotates the secret key for the specified webhook
2604
+ */
2605
+ static rotateWebhookSecret(options) {
2606
+ return (options.client ?? client).post({
2607
+ url: "/projects/{project_id}/webhooks/{webhook_id}/rotate-secret",
2608
+ ...options
2609
+ });
2610
+ }
2611
+ };
2612
+
2613
+ // src/soatClient.ts
2614
+ var bindResource = /* @__PURE__ */__name((SdkClass, client2) => {
2615
+ return new Proxy(SdkClass, {
2616
+ get: /* @__PURE__ */__name((target, prop) => {
2617
+ const value = target[prop];
2618
+ if (typeof value === "function") {
2619
+ return options => {
2620
+ return value({
2621
+ ...options,
2622
+ client: client2
2623
+ });
2624
+ };
2625
+ }
2626
+ return value;
2627
+ }, "get")
22
2628
  });
23
- }, "createSoatClient");
24
- export { createSoatClient };
2629
+ }, "bindResource");
2630
+ var SoatClient = class {
2631
+ static {
2632
+ __name(this, "SoatClient");
2633
+ }
2634
+ actors;
2635
+ agentTools;
2636
+ agentTraces;
2637
+ agents;
2638
+ aiProviders;
2639
+ apiKeys;
2640
+ chats;
2641
+ conversations;
2642
+ documents;
2643
+ files;
2644
+ policies;
2645
+ projects;
2646
+ secrets;
2647
+ sessions;
2648
+ users;
2649
+ webhooks;
2650
+ constructor({
2651
+ baseUrl,
2652
+ token,
2653
+ headers
2654
+ } = {}) {
2655
+ const authHeaders = token ? {
2656
+ Authorization: `Bearer ${token}`
2657
+ } : {};
2658
+ const httpClient = createClient(createConfig({
2659
+ baseUrl: baseUrl ?? "/api/v1",
2660
+ headers: {
2661
+ ...authHeaders,
2662
+ ...headers
2663
+ }
2664
+ }));
2665
+ this.actors = bindResource(Actors, httpClient);
2666
+ this.agentTools = bindResource(AgentTools, httpClient);
2667
+ this.agentTraces = bindResource(AgentTraces, httpClient);
2668
+ this.agents = bindResource(Agents, httpClient);
2669
+ this.aiProviders = bindResource(AiProviders, httpClient);
2670
+ this.apiKeys = bindResource(ApiKeys, httpClient);
2671
+ this.chats = bindResource(Chats, httpClient);
2672
+ this.conversations = bindResource(Conversations, httpClient);
2673
+ this.documents = bindResource(Documents, httpClient);
2674
+ this.files = bindResource(Files, httpClient);
2675
+ this.policies = bindResource(Policies, httpClient);
2676
+ this.projects = bindResource(Projects, httpClient);
2677
+ this.secrets = bindResource(Secrets, httpClient);
2678
+ this.sessions = bindResource(Sessions, httpClient);
2679
+ this.users = bindResource(Users, httpClient);
2680
+ this.webhooks = bindResource(Webhooks, httpClient);
2681
+ }
2682
+ };
2683
+ export { Actors, AgentTools, AgentTraces, Agents, AiProviders, ApiKeys, Chats, Conversations, Documents, Files, Policies, Projects, Secrets, Sessions, SoatClient, Users, Webhooks, createClient, createConfig };