@zyraxon-ai/client 19.0.3 → 19.0.5

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.
Files changed (56) hide show
  1. package/dist/contract.d.ts +35 -0
  2. package/dist/contract.d.ts.map +1 -0
  3. package/dist/contract.js +45 -0
  4. package/dist/contract.js.map +1 -0
  5. package/dist/effect.d.ts +24 -0
  6. package/dist/effect.d.ts.map +1 -0
  7. package/dist/effect.js +25 -0
  8. package/dist/effect.js.map +1 -0
  9. package/dist/generated/client-error.d.ts +7 -0
  10. package/dist/generated/client-error.d.ts.map +1 -0
  11. package/dist/generated/client-error.js +9 -0
  12. package/dist/generated/client-error.js.map +1 -0
  13. package/dist/generated/client.d.ts +791 -0
  14. package/dist/generated/client.d.ts.map +1 -0
  15. package/dist/generated/client.js +679 -0
  16. package/dist/generated/client.js.map +1 -0
  17. package/dist/generated/index.d.ts +4 -0
  18. package/dist/generated/index.d.ts.map +1 -0
  19. package/dist/generated/index.js +4 -0
  20. package/dist/generated/index.js.map +1 -0
  21. package/dist/generated/types.d.ts +4228 -0
  22. package/dist/generated/types.d.ts.map +1 -0
  23. package/dist/generated/types.js +14 -0
  24. package/dist/generated/types.js.map +1 -0
  25. package/dist/generated-effect/client-error.d.ts +8 -0
  26. package/dist/generated-effect/client-error.d.ts.map +1 -0
  27. package/dist/generated-effect/client-error.js +6 -0
  28. package/dist/generated-effect/client-error.js.map +1 -0
  29. package/dist/generated-effect/client.d.ts +401 -0
  30. package/dist/generated-effect/client.d.ts.map +1 -0
  31. package/dist/generated-effect/client.js +253 -0
  32. package/dist/generated-effect/client.js.map +1 -0
  33. package/dist/generated-effect/index.d.ts +3 -0
  34. package/dist/generated-effect/index.d.ts.map +1 -0
  35. package/dist/generated-effect/index.js +3 -0
  36. package/dist/generated-effect/index.js.map +1 -0
  37. package/dist/index.d.ts +3 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +2 -0
  40. package/dist/index.js.map +1 -0
  41. package/package.json +25 -14
  42. package/script/build.ts +0 -30
  43. package/src/contract.ts +0 -53
  44. package/src/effect.ts +0 -25
  45. package/src/generated/.httpapi-codegen.json +0 -6
  46. package/src/generated/client-error.ts +0 -11
  47. package/src/generated/client.ts +0 -1029
  48. package/src/generated/index.ts +0 -3
  49. package/src/generated/types.ts +0 -2807
  50. package/src/generated-effect/.httpapi-codegen.json +0 -5
  51. package/src/generated-effect/client-error.ts +0 -5
  52. package/src/generated-effect/client.ts +0 -706
  53. package/src/generated-effect/index.ts +0 -2
  54. package/src/index.ts +0 -2
  55. package/sst-env.d.ts +0 -10
  56. package/tsconfig.json +0 -9
@@ -1,1029 +0,0 @@
1
- import type {
2
- HealthGetOutput,
3
- LocationGetInput,
4
- LocationGetOutput,
5
- AgentsListInput,
6
- AgentsListOutput,
7
- SessionsListInput,
8
- SessionsListOutput,
9
- SessionsCreateInput,
10
- SessionsCreateOutput,
11
- SessionsActiveOutput,
12
- SessionsGetInput,
13
- SessionsGetOutput,
14
- SessionsSwitchAgentInput,
15
- SessionsSwitchAgentOutput,
16
- SessionsSwitchModelInput,
17
- SessionsSwitchModelOutput,
18
- SessionsPromptInput,
19
- SessionsPromptOutput,
20
- SessionsCompactInput,
21
- SessionsCompactOutput,
22
- SessionsWaitInput,
23
- SessionsWaitOutput,
24
- SessionsStageInput,
25
- SessionsStageOutput,
26
- SessionsClearInput,
27
- SessionsClearOutput,
28
- SessionsCommitInput,
29
- SessionsCommitOutput,
30
- SessionsContextInput,
31
- SessionsContextOutput,
32
- SessionsHistoryInput,
33
- SessionsHistoryOutput,
34
- SessionsEventsInput,
35
- SessionsEventsOutput,
36
- SessionsInterruptInput,
37
- SessionsInterruptOutput,
38
- SessionsMessageInput,
39
- SessionsMessageOutput,
40
- MessagesListInput,
41
- MessagesListOutput,
42
- ModelsListInput,
43
- ModelsListOutput,
44
- ProvidersListInput,
45
- ProvidersListOutput,
46
- ProvidersGetInput,
47
- ProvidersGetOutput,
48
- IntegrationsListInput,
49
- IntegrationsListOutput,
50
- IntegrationsGetInput,
51
- IntegrationsGetOutput,
52
- IntegrationsConnectKeyInput,
53
- IntegrationsConnectKeyOutput,
54
- IntegrationsConnectOauthInput,
55
- IntegrationsConnectOauthOutput,
56
- IntegrationsAttemptStatusInput,
57
- IntegrationsAttemptStatusOutput,
58
- IntegrationsAttemptCompleteInput,
59
- IntegrationsAttemptCompleteOutput,
60
- IntegrationsAttemptCancelInput,
61
- IntegrationsAttemptCancelOutput,
62
- CredentialsUpdateInput,
63
- CredentialsUpdateOutput,
64
- CredentialsRemoveInput,
65
- CredentialsRemoveOutput,
66
- PermissionsListRequestsInput,
67
- PermissionsListRequestsOutput,
68
- PermissionsListSavedInput,
69
- PermissionsListSavedOutput,
70
- PermissionsRemoveSavedInput,
71
- PermissionsRemoveSavedOutput,
72
- PermissionsCreateInput,
73
- PermissionsCreateOutput,
74
- PermissionsListInput,
75
- PermissionsListOutput,
76
- PermissionsGetInput,
77
- PermissionsGetOutput,
78
- PermissionsReplyInput,
79
- PermissionsReplyOutput,
80
- FilesListInput,
81
- FilesListOutput,
82
- FilesFindInput,
83
- FilesFindOutput,
84
- CommandsListInput,
85
- CommandsListOutput,
86
- SkillsListInput,
87
- SkillsListOutput,
88
- EventsSubscribeOutput,
89
- PtysListInput,
90
- PtysListOutput,
91
- PtysCreateInput,
92
- PtysCreateOutput,
93
- PtysGetInput,
94
- PtysGetOutput,
95
- PtysUpdateInput,
96
- PtysUpdateOutput,
97
- PtysRemoveInput,
98
- PtysRemoveOutput,
99
- QuestionsListRequestsInput,
100
- QuestionsListRequestsOutput,
101
- QuestionsListInput,
102
- QuestionsListOutput,
103
- QuestionsReplyInput,
104
- QuestionsReplyOutput,
105
- QuestionsRejectInput,
106
- QuestionsRejectOutput,
107
- ReferencesListInput,
108
- ReferencesListOutput,
109
- ProjectCopiesCreateInput,
110
- ProjectCopiesCreateOutput,
111
- ProjectCopiesRemoveInput,
112
- ProjectCopiesRemoveOutput,
113
- ProjectCopiesRefreshInput,
114
- ProjectCopiesRefreshOutput,
115
- } from "./types"
116
- import { ClientError } from "./client-error"
117
-
118
- export interface ClientOptions {
119
- readonly baseUrl: string
120
- readonly fetch?: typeof globalThis.fetch
121
- readonly headers?: HeadersInit
122
- }
123
-
124
- export interface RequestOptions {
125
- readonly signal?: AbortSignal
126
- readonly headers?: HeadersInit
127
- }
128
-
129
- interface RequestDescriptor {
130
- readonly method: string
131
- readonly path: string
132
- readonly query?: Record<string, unknown>
133
- readonly headers?: Record<string, unknown>
134
- readonly body?: unknown
135
- readonly successStatus: number
136
- readonly declaredStatuses: ReadonlyArray<number>
137
- readonly empty: boolean
138
- }
139
-
140
- export function make(options: ClientOptions) {
141
- const fetch = options.fetch ?? globalThis.fetch
142
-
143
- const prepare = (descriptor: RequestDescriptor, requestOptions?: RequestOptions) => {
144
- const url = new URL(descriptor.path, options.baseUrl)
145
- for (const [key, value] of Object.entries(descriptor.query ?? {})) appendQuery(url.searchParams, key, value)
146
- const headers = new Headers(options.headers)
147
- for (const [key, value] of Object.entries(descriptor.headers ?? {})) {
148
- if (value !== undefined && value !== null) headers.set(key, String(value))
149
- }
150
- for (const [key, value] of new Headers(requestOptions?.headers)) headers.set(key, value)
151
- if (descriptor.body !== undefined && !headers.has("content-type")) headers.set("content-type", "application/json")
152
- return {
153
- url,
154
- init: {
155
- method: descriptor.method,
156
- signal: requestOptions?.signal,
157
- headers,
158
- body: descriptor.body === undefined ? undefined : JSON.stringify(descriptor.body),
159
- } satisfies RequestInit,
160
- }
161
- }
162
-
163
- const execute = async (descriptor: RequestDescriptor, requestOptions?: RequestOptions) => {
164
- try {
165
- const prepared = prepare(descriptor, requestOptions)
166
- return await fetch(prepared.url, prepared.init)
167
- } catch (cause) {
168
- throw new ClientError("Transport", { cause })
169
- }
170
- }
171
-
172
- const responseError = async (response: Response, descriptor: RequestDescriptor): Promise<never> => {
173
- if (descriptor.declaredStatuses.includes(response.status)) throw await json(response)
174
- try {
175
- await response.body?.cancel()
176
- } catch {}
177
- throw new ClientError("UnexpectedStatus", { cause: { status: response.status } })
178
- }
179
-
180
- const request = async <A>(descriptor: RequestDescriptor, requestOptions?: RequestOptions): Promise<A> => {
181
- const response = await execute(descriptor, requestOptions)
182
- if (response.status !== descriptor.successStatus) return responseError(response, descriptor)
183
- if (descriptor.empty) {
184
- try {
185
- await response.body?.cancel()
186
- } catch {}
187
- return undefined as A
188
- }
189
- return (await json(response)) as A
190
- }
191
-
192
- const sse = <A>(descriptor: RequestDescriptor, requestOptions?: RequestOptions): AsyncIterable<A> => ({
193
- async *[Symbol.asyncIterator]() {
194
- const response = await execute(descriptor, requestOptions)
195
- if (response.status !== descriptor.successStatus) await responseError(response, descriptor)
196
- if (!isContentType(response, "text/event-stream")) {
197
- try {
198
- await response.body?.cancel()
199
- } catch {}
200
- throw new ClientError("UnsupportedContentType")
201
- }
202
- if (response.body === null) throw new ClientError("MalformedResponse")
203
- const reader = response.body.getReader()
204
- const decoder = new TextDecoder()
205
- let buffer = ""
206
- try {
207
- while (true) {
208
- let next
209
- try {
210
- next = await reader.read()
211
- } catch (cause) {
212
- throw new ClientError("Transport", { cause })
213
- }
214
- buffer += decoder.decode(next.value, { stream: !next.done })
215
- if (buffer.length > 1_048_576) throw new ClientError("MalformedResponse")
216
- const trailingCarriageReturn = !next.done && buffer.endsWith("\r")
217
- if (trailingCarriageReturn) buffer = buffer.slice(0, -1)
218
- buffer = buffer.replaceAll("\r\n", "\n").replaceAll("\r", "\n")
219
- if (trailingCarriageReturn) buffer += "\r"
220
- if (next.done && buffer !== "") buffer += "\n\n"
221
- let boundary = buffer.indexOf("\n\n")
222
- while (boundary >= 0) {
223
- const block = buffer.slice(0, boundary)
224
- buffer = buffer.slice(boundary + 2)
225
- const data = block
226
- .split("\n")
227
- .flatMap((line) => (line.startsWith("data:") ? [line.slice(5).trimStart()] : []))
228
- .join("\n")
229
- if (data !== "") {
230
- try {
231
- yield JSON.parse(data) as A
232
- } catch (cause) {
233
- throw new ClientError("MalformedResponse", { cause })
234
- }
235
- }
236
- boundary = buffer.indexOf("\n\n")
237
- }
238
- if (next.done) return
239
- }
240
- } finally {
241
- try {
242
- await reader.cancel()
243
- } catch {}
244
- reader.releaseLock()
245
- }
246
- },
247
- })
248
-
249
- return {
250
- health: {
251
- get: (requestOptions?: RequestOptions) =>
252
- request<HealthGetOutput>(
253
- { method: "GET", path: `/api/health`, successStatus: 200, declaredStatuses: [401, 400], empty: false },
254
- requestOptions,
255
- ),
256
- },
257
- location: {
258
- get: (input?: LocationGetInput, requestOptions?: RequestOptions) =>
259
- request<LocationGetOutput>(
260
- {
261
- method: "GET",
262
- path: `/api/location`,
263
- query: { location: input?.["location"] },
264
- successStatus: 200,
265
- declaredStatuses: [401, 400],
266
- empty: false,
267
- },
268
- requestOptions,
269
- ),
270
- },
271
- agents: {
272
- list: (input?: AgentsListInput, requestOptions?: RequestOptions) =>
273
- request<AgentsListOutput>(
274
- {
275
- method: "GET",
276
- path: `/api/agent`,
277
- query: { location: input?.["location"] },
278
- successStatus: 200,
279
- declaredStatuses: [401, 400],
280
- empty: false,
281
- },
282
- requestOptions,
283
- ),
284
- },
285
- sessions: {
286
- list: (input?: SessionsListInput, requestOptions?: RequestOptions) =>
287
- request<SessionsListOutput>(
288
- {
289
- method: "GET",
290
- path: `/api/session`,
291
- query: {
292
- workspace: input?.["workspace"],
293
- limit: input?.["limit"],
294
- order: input?.["order"],
295
- search: input?.["search"],
296
- directory: input?.["directory"],
297
- project: input?.["project"],
298
- subpath: input?.["subpath"],
299
- cursor: input?.["cursor"],
300
- },
301
- successStatus: 200,
302
- declaredStatuses: [400, 401],
303
- empty: false,
304
- },
305
- requestOptions,
306
- ),
307
- create: (input?: SessionsCreateInput, requestOptions?: RequestOptions) =>
308
- request<{ readonly data: SessionsCreateOutput }>(
309
- {
310
- method: "POST",
311
- path: `/api/session`,
312
- body: {
313
- id: input?.["id"],
314
- agent: input?.["agent"],
315
- model: input?.["model"],
316
- location: input?.["location"],
317
- },
318
- successStatus: 200,
319
- declaredStatuses: [401, 400],
320
- empty: false,
321
- },
322
- requestOptions,
323
- ).then((value) => value.data),
324
- active: (requestOptions?: RequestOptions) =>
325
- request<{ readonly data: SessionsActiveOutput }>(
326
- {
327
- method: "GET",
328
- path: `/api/session/active`,
329
- successStatus: 200,
330
- declaredStatuses: [401, 400],
331
- empty: false,
332
- },
333
- requestOptions,
334
- ).then((value) => value.data),
335
- get: (input: SessionsGetInput, requestOptions?: RequestOptions) =>
336
- request<{ readonly data: SessionsGetOutput }>(
337
- {
338
- method: "GET",
339
- path: `/api/session/${encodeURIComponent(input.sessionID)}`,
340
- successStatus: 200,
341
- declaredStatuses: [404, 400, 401],
342
- empty: false,
343
- },
344
- requestOptions,
345
- ).then((value) => value.data),
346
- switchAgent: (input: SessionsSwitchAgentInput, requestOptions?: RequestOptions) =>
347
- request<SessionsSwitchAgentOutput>(
348
- {
349
- method: "POST",
350
- path: `/api/session/${encodeURIComponent(input.sessionID)}/agent`,
351
- body: { agent: input["agent"] },
352
- successStatus: 204,
353
- declaredStatuses: [404, 400, 401],
354
- empty: true,
355
- },
356
- requestOptions,
357
- ),
358
- switchModel: (input: SessionsSwitchModelInput, requestOptions?: RequestOptions) =>
359
- request<SessionsSwitchModelOutput>(
360
- {
361
- method: "POST",
362
- path: `/api/session/${encodeURIComponent(input.sessionID)}/model`,
363
- body: { model: input["model"] },
364
- successStatus: 204,
365
- declaredStatuses: [404, 400, 401],
366
- empty: true,
367
- },
368
- requestOptions,
369
- ),
370
- prompt: (input: SessionsPromptInput, requestOptions?: RequestOptions) =>
371
- request<{ readonly data: SessionsPromptOutput }>(
372
- {
373
- method: "POST",
374
- path: `/api/session/${encodeURIComponent(input.sessionID)}/prompt`,
375
- body: { id: input["id"], prompt: input["prompt"], delivery: input["delivery"], resume: input["resume"] },
376
- successStatus: 200,
377
- declaredStatuses: [409, 404, 400, 401],
378
- empty: false,
379
- },
380
- requestOptions,
381
- ).then((value) => value.data),
382
- compact: (input: SessionsCompactInput, requestOptions?: RequestOptions) =>
383
- request<SessionsCompactOutput>(
384
- {
385
- method: "POST",
386
- path: `/api/session/${encodeURIComponent(input.sessionID)}/compact`,
387
- successStatus: 204,
388
- declaredStatuses: [404, 503, 400, 401],
389
- empty: true,
390
- },
391
- requestOptions,
392
- ),
393
- wait: (input: SessionsWaitInput, requestOptions?: RequestOptions) =>
394
- request<SessionsWaitOutput>(
395
- {
396
- method: "POST",
397
- path: `/api/session/${encodeURIComponent(input.sessionID)}/wait`,
398
- successStatus: 204,
399
- declaredStatuses: [404, 503, 400, 401],
400
- empty: true,
401
- },
402
- requestOptions,
403
- ),
404
- stage: (input: SessionsStageInput, requestOptions?: RequestOptions) =>
405
- request<{ readonly data: SessionsStageOutput }>(
406
- {
407
- method: "POST",
408
- path: `/api/session/${encodeURIComponent(input.sessionID)}/revert/stage`,
409
- body: { messageID: input["messageID"], files: input["files"] },
410
- successStatus: 200,
411
- declaredStatuses: [404, 500, 400, 401],
412
- empty: false,
413
- },
414
- requestOptions,
415
- ).then((value) => value.data),
416
- clear: (input: SessionsClearInput, requestOptions?: RequestOptions) =>
417
- request<SessionsClearOutput>(
418
- {
419
- method: "POST",
420
- path: `/api/session/${encodeURIComponent(input.sessionID)}/revert/clear`,
421
- successStatus: 204,
422
- declaredStatuses: [404, 500, 400, 401],
423
- empty: true,
424
- },
425
- requestOptions,
426
- ),
427
- commit: (input: SessionsCommitInput, requestOptions?: RequestOptions) =>
428
- request<SessionsCommitOutput>(
429
- {
430
- method: "POST",
431
- path: `/api/session/${encodeURIComponent(input.sessionID)}/revert/commit`,
432
- successStatus: 204,
433
- declaredStatuses: [404, 400, 401],
434
- empty: true,
435
- },
436
- requestOptions,
437
- ),
438
- context: (input: SessionsContextInput, requestOptions?: RequestOptions) =>
439
- request<{ readonly data: SessionsContextOutput }>(
440
- {
441
- method: "GET",
442
- path: `/api/session/${encodeURIComponent(input.sessionID)}/context`,
443
- successStatus: 200,
444
- declaredStatuses: [404, 500, 400, 401],
445
- empty: false,
446
- },
447
- requestOptions,
448
- ).then((value) => value.data),
449
- history: (input: SessionsHistoryInput, requestOptions?: RequestOptions) =>
450
- request<SessionsHistoryOutput>(
451
- {
452
- method: "GET",
453
- path: `/api/session/${encodeURIComponent(input.sessionID)}/history`,
454
- query: { limit: input["limit"], after: input["after"] },
455
- successStatus: 200,
456
- declaredStatuses: [404, 400, 401],
457
- empty: false,
458
- },
459
- requestOptions,
460
- ),
461
- events: (input: SessionsEventsInput, requestOptions?: RequestOptions): AsyncIterable<SessionsEventsOutput> =>
462
- sse<SessionsEventsOutput>(
463
- {
464
- method: "GET",
465
- path: `/api/session/${encodeURIComponent(input.sessionID)}/event`,
466
- query: { after: input["after"] },
467
- successStatus: 200,
468
- declaredStatuses: [404, 400, 401],
469
- empty: false,
470
- },
471
- requestOptions,
472
- ),
473
- interrupt: (input: SessionsInterruptInput, requestOptions?: RequestOptions) =>
474
- request<SessionsInterruptOutput>(
475
- {
476
- method: "POST",
477
- path: `/api/session/${encodeURIComponent(input.sessionID)}/interrupt`,
478
- successStatus: 204,
479
- declaredStatuses: [404, 400, 401],
480
- empty: true,
481
- },
482
- requestOptions,
483
- ),
484
- message: (input: SessionsMessageInput, requestOptions?: RequestOptions) =>
485
- request<{ readonly data: SessionsMessageOutput }>(
486
- {
487
- method: "GET",
488
- path: `/api/session/${encodeURIComponent(input.sessionID)}/message/${encodeURIComponent(input.messageID)}`,
489
- successStatus: 200,
490
- declaredStatuses: [404, 400, 401],
491
- empty: false,
492
- },
493
- requestOptions,
494
- ).then((value) => value.data),
495
- },
496
- messages: {
497
- list: (input: MessagesListInput, requestOptions?: RequestOptions) =>
498
- request<MessagesListOutput>(
499
- {
500
- method: "GET",
501
- path: `/api/session/${encodeURIComponent(input.sessionID)}/message`,
502
- query: { limit: input["limit"], order: input["order"], cursor: input["cursor"] },
503
- successStatus: 200,
504
- declaredStatuses: [400, 404, 500, 401],
505
- empty: false,
506
- },
507
- requestOptions,
508
- ),
509
- },
510
- models: {
511
- list: (input?: ModelsListInput, requestOptions?: RequestOptions) =>
512
- request<ModelsListOutput>(
513
- {
514
- method: "GET",
515
- path: `/api/model`,
516
- query: { location: input?.["location"] },
517
- successStatus: 200,
518
- declaredStatuses: [503, 401, 400],
519
- empty: false,
520
- },
521
- requestOptions,
522
- ),
523
- },
524
- providers: {
525
- list: (input?: ProvidersListInput, requestOptions?: RequestOptions) =>
526
- request<ProvidersListOutput>(
527
- {
528
- method: "GET",
529
- path: `/api/provider`,
530
- query: { location: input?.["location"] },
531
- successStatus: 200,
532
- declaredStatuses: [503, 401, 400],
533
- empty: false,
534
- },
535
- requestOptions,
536
- ),
537
- get: (input: ProvidersGetInput, requestOptions?: RequestOptions) =>
538
- request<ProvidersGetOutput>(
539
- {
540
- method: "GET",
541
- path: `/api/provider/${encodeURIComponent(input.providerID)}`,
542
- query: { location: input["location"] },
543
- successStatus: 200,
544
- declaredStatuses: [404, 503, 401, 400],
545
- empty: false,
546
- },
547
- requestOptions,
548
- ),
549
- },
550
- integrations: {
551
- list: (input?: IntegrationsListInput, requestOptions?: RequestOptions) =>
552
- request<IntegrationsListOutput>(
553
- {
554
- method: "GET",
555
- path: `/api/integration`,
556
- query: { location: input?.["location"] },
557
- successStatus: 200,
558
- declaredStatuses: [401, 400],
559
- empty: false,
560
- },
561
- requestOptions,
562
- ),
563
- get: (input: IntegrationsGetInput, requestOptions?: RequestOptions) =>
564
- request<IntegrationsGetOutput>(
565
- {
566
- method: "GET",
567
- path: `/api/integration/${encodeURIComponent(input.integrationID)}`,
568
- query: { location: input["location"] },
569
- successStatus: 200,
570
- declaredStatuses: [401, 400],
571
- empty: false,
572
- },
573
- requestOptions,
574
- ),
575
- connectKey: (input: IntegrationsConnectKeyInput, requestOptions?: RequestOptions) =>
576
- request<IntegrationsConnectKeyOutput>(
577
- {
578
- method: "POST",
579
- path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/key`,
580
- query: { location: input["location"] },
581
- body: { key: input["key"], label: input["label"] },
582
- successStatus: 204,
583
- declaredStatuses: [400, 401],
584
- empty: true,
585
- },
586
- requestOptions,
587
- ),
588
- connectOauth: (input: IntegrationsConnectOauthInput, requestOptions?: RequestOptions) =>
589
- request<IntegrationsConnectOauthOutput>(
590
- {
591
- method: "POST",
592
- path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/oauth`,
593
- query: { location: input["location"] },
594
- body: { methodID: input["methodID"], inputs: input["inputs"], label: input["label"] },
595
- successStatus: 200,
596
- declaredStatuses: [400, 401],
597
- empty: false,
598
- },
599
- requestOptions,
600
- ),
601
- attemptStatus: (input: IntegrationsAttemptStatusInput, requestOptions?: RequestOptions) =>
602
- request<IntegrationsAttemptStatusOutput>(
603
- {
604
- method: "GET",
605
- path: `/api/integration/attempt/${encodeURIComponent(input.attemptID)}`,
606
- query: { location: input["location"] },
607
- successStatus: 200,
608
- declaredStatuses: [401, 400],
609
- empty: false,
610
- },
611
- requestOptions,
612
- ),
613
- attemptComplete: (input: IntegrationsAttemptCompleteInput, requestOptions?: RequestOptions) =>
614
- request<IntegrationsAttemptCompleteOutput>(
615
- {
616
- method: "POST",
617
- path: `/api/integration/attempt/${encodeURIComponent(input.attemptID)}/complete`,
618
- query: { location: input["location"] },
619
- body: { code: input["code"] },
620
- successStatus: 204,
621
- declaredStatuses: [400, 401],
622
- empty: true,
623
- },
624
- requestOptions,
625
- ),
626
- attemptCancel: (input: IntegrationsAttemptCancelInput, requestOptions?: RequestOptions) =>
627
- request<IntegrationsAttemptCancelOutput>(
628
- {
629
- method: "DELETE",
630
- path: `/api/integration/attempt/${encodeURIComponent(input.attemptID)}`,
631
- query: { location: input["location"] },
632
- successStatus: 204,
633
- declaredStatuses: [401, 400],
634
- empty: true,
635
- },
636
- requestOptions,
637
- ),
638
- },
639
- credentials: {
640
- update: (input: CredentialsUpdateInput, requestOptions?: RequestOptions) =>
641
- request<CredentialsUpdateOutput>(
642
- {
643
- method: "PATCH",
644
- path: `/api/credential/${encodeURIComponent(input.credentialID)}`,
645
- query: { location: input["location"] },
646
- body: { label: input["label"] },
647
- successStatus: 204,
648
- declaredStatuses: [401, 400],
649
- empty: true,
650
- },
651
- requestOptions,
652
- ),
653
- remove: (input: CredentialsRemoveInput, requestOptions?: RequestOptions) =>
654
- request<CredentialsRemoveOutput>(
655
- {
656
- method: "DELETE",
657
- path: `/api/credential/${encodeURIComponent(input.credentialID)}`,
658
- query: { location: input["location"] },
659
- successStatus: 204,
660
- declaredStatuses: [401, 400],
661
- empty: true,
662
- },
663
- requestOptions,
664
- ),
665
- },
666
- permissions: {
667
- listRequests: (input?: PermissionsListRequestsInput, requestOptions?: RequestOptions) =>
668
- request<PermissionsListRequestsOutput>(
669
- {
670
- method: "GET",
671
- path: `/api/permission/request`,
672
- query: { location: input?.["location"] },
673
- successStatus: 200,
674
- declaredStatuses: [401, 400],
675
- empty: false,
676
- },
677
- requestOptions,
678
- ),
679
- listSaved: (input?: PermissionsListSavedInput, requestOptions?: RequestOptions) =>
680
- request<{ readonly data: PermissionsListSavedOutput }>(
681
- {
682
- method: "GET",
683
- path: `/api/permission/saved`,
684
- query: { projectID: input?.["projectID"] },
685
- successStatus: 200,
686
- declaredStatuses: [401, 400],
687
- empty: false,
688
- },
689
- requestOptions,
690
- ).then((value) => value.data),
691
- removeSaved: (input: PermissionsRemoveSavedInput, requestOptions?: RequestOptions) =>
692
- request<PermissionsRemoveSavedOutput>(
693
- {
694
- method: "DELETE",
695
- path: `/api/permission/saved/${encodeURIComponent(input.id)}`,
696
- successStatus: 204,
697
- declaredStatuses: [401, 400],
698
- empty: true,
699
- },
700
- requestOptions,
701
- ),
702
- create: (input: PermissionsCreateInput, requestOptions?: RequestOptions) =>
703
- request<{ readonly data: PermissionsCreateOutput }>(
704
- {
705
- method: "POST",
706
- path: `/api/session/${encodeURIComponent(input.sessionID)}/permission`,
707
- body: {
708
- id: input["id"],
709
- action: input["action"],
710
- resources: input["resources"],
711
- save: input["save"],
712
- metadata: input["metadata"],
713
- source: input["source"],
714
- agent: input["agent"],
715
- },
716
- successStatus: 200,
717
- declaredStatuses: [404, 400, 401],
718
- empty: false,
719
- },
720
- requestOptions,
721
- ).then((value) => value.data),
722
- list: (input: PermissionsListInput, requestOptions?: RequestOptions) =>
723
- request<{ readonly data: PermissionsListOutput }>(
724
- {
725
- method: "GET",
726
- path: `/api/session/${encodeURIComponent(input.sessionID)}/permission`,
727
- successStatus: 200,
728
- declaredStatuses: [404, 400, 401],
729
- empty: false,
730
- },
731
- requestOptions,
732
- ).then((value) => value.data),
733
- get: (input: PermissionsGetInput, requestOptions?: RequestOptions) =>
734
- request<{ readonly data: PermissionsGetOutput }>(
735
- {
736
- method: "GET",
737
- path: `/api/session/${encodeURIComponent(input.sessionID)}/permission/${encodeURIComponent(input.requestID)}`,
738
- successStatus: 200,
739
- declaredStatuses: [404, 400, 401],
740
- empty: false,
741
- },
742
- requestOptions,
743
- ).then((value) => value.data),
744
- reply: (input: PermissionsReplyInput, requestOptions?: RequestOptions) =>
745
- request<PermissionsReplyOutput>(
746
- {
747
- method: "POST",
748
- path: `/api/session/${encodeURIComponent(input.sessionID)}/permission/${encodeURIComponent(input.requestID)}/reply`,
749
- body: { reply: input["reply"], message: input["message"] },
750
- successStatus: 204,
751
- declaredStatuses: [404, 400, 401],
752
- empty: true,
753
- },
754
- requestOptions,
755
- ),
756
- },
757
- files: {
758
- list: (input?: FilesListInput, requestOptions?: RequestOptions) =>
759
- request<FilesListOutput>(
760
- {
761
- method: "GET",
762
- path: `/api/fs/list`,
763
- query: { location: input?.["location"], path: input?.["path"] },
764
- successStatus: 200,
765
- declaredStatuses: [401, 400],
766
- empty: false,
767
- },
768
- requestOptions,
769
- ),
770
- find: (input: FilesFindInput, requestOptions?: RequestOptions) =>
771
- request<FilesFindOutput>(
772
- {
773
- method: "GET",
774
- path: `/api/fs/find`,
775
- query: { location: input["location"], query: input["query"], type: input["type"], limit: input["limit"] },
776
- successStatus: 200,
777
- declaredStatuses: [401, 400],
778
- empty: false,
779
- },
780
- requestOptions,
781
- ),
782
- },
783
- commands: {
784
- list: (input?: CommandsListInput, requestOptions?: RequestOptions) =>
785
- request<CommandsListOutput>(
786
- {
787
- method: "GET",
788
- path: `/api/command`,
789
- query: { location: input?.["location"] },
790
- successStatus: 200,
791
- declaredStatuses: [401, 400],
792
- empty: false,
793
- },
794
- requestOptions,
795
- ),
796
- },
797
- skills: {
798
- list: (input?: SkillsListInput, requestOptions?: RequestOptions) =>
799
- request<SkillsListOutput>(
800
- {
801
- method: "GET",
802
- path: `/api/skill`,
803
- query: { location: input?.["location"] },
804
- successStatus: 200,
805
- declaredStatuses: [401, 400],
806
- empty: false,
807
- },
808
- requestOptions,
809
- ),
810
- },
811
- events: {
812
- subscribe: (requestOptions?: RequestOptions): AsyncIterable<EventsSubscribeOutput> =>
813
- sse<EventsSubscribeOutput>(
814
- { method: "GET", path: `/api/event`, successStatus: 200, declaredStatuses: [401, 400], empty: false },
815
- requestOptions,
816
- ),
817
- },
818
- ptys: {
819
- list: (input?: PtysListInput, requestOptions?: RequestOptions) =>
820
- request<PtysListOutput>(
821
- {
822
- method: "GET",
823
- path: `/api/pty`,
824
- query: { location: input?.["location"] },
825
- successStatus: 200,
826
- declaredStatuses: [401, 400],
827
- empty: false,
828
- },
829
- requestOptions,
830
- ),
831
- create: (input?: PtysCreateInput, requestOptions?: RequestOptions) =>
832
- request<PtysCreateOutput>(
833
- {
834
- method: "POST",
835
- path: `/api/pty`,
836
- query: { location: input?.["location"] },
837
- body: {
838
- command: input?.["command"],
839
- args: input?.["args"],
840
- cwd: input?.["cwd"],
841
- title: input?.["title"],
842
- env: input?.["env"],
843
- },
844
- successStatus: 200,
845
- declaredStatuses: [401, 400],
846
- empty: false,
847
- },
848
- requestOptions,
849
- ),
850
- get: (input: PtysGetInput, requestOptions?: RequestOptions) =>
851
- request<PtysGetOutput>(
852
- {
853
- method: "GET",
854
- path: `/api/pty/${encodeURIComponent(input.ptyID)}`,
855
- query: { location: input["location"] },
856
- successStatus: 200,
857
- declaredStatuses: [404, 401, 400],
858
- empty: false,
859
- },
860
- requestOptions,
861
- ),
862
- update: (input: PtysUpdateInput, requestOptions?: RequestOptions) =>
863
- request<PtysUpdateOutput>(
864
- {
865
- method: "PUT",
866
- path: `/api/pty/${encodeURIComponent(input.ptyID)}`,
867
- query: { location: input["location"] },
868
- body: { title: input["title"], size: input["size"] },
869
- successStatus: 200,
870
- declaredStatuses: [404, 401, 400],
871
- empty: false,
872
- },
873
- requestOptions,
874
- ),
875
- remove: (input: PtysRemoveInput, requestOptions?: RequestOptions) =>
876
- request<PtysRemoveOutput>(
877
- {
878
- method: "DELETE",
879
- path: `/api/pty/${encodeURIComponent(input.ptyID)}`,
880
- query: { location: input["location"] },
881
- successStatus: 204,
882
- declaredStatuses: [404, 401, 400],
883
- empty: true,
884
- },
885
- requestOptions,
886
- ),
887
- },
888
- questions: {
889
- listRequests: (input?: QuestionsListRequestsInput, requestOptions?: RequestOptions) =>
890
- request<QuestionsListRequestsOutput>(
891
- {
892
- method: "GET",
893
- path: `/api/question/request`,
894
- query: { location: input?.["location"] },
895
- successStatus: 200,
896
- declaredStatuses: [401, 400],
897
- empty: false,
898
- },
899
- requestOptions,
900
- ),
901
- list: (input: QuestionsListInput, requestOptions?: RequestOptions) =>
902
- request<{ readonly data: QuestionsListOutput }>(
903
- {
904
- method: "GET",
905
- path: `/api/session/${encodeURIComponent(input.sessionID)}/question`,
906
- successStatus: 200,
907
- declaredStatuses: [404, 400, 401],
908
- empty: false,
909
- },
910
- requestOptions,
911
- ).then((value) => value.data),
912
- reply: (input: QuestionsReplyInput, requestOptions?: RequestOptions) =>
913
- request<QuestionsReplyOutput>(
914
- {
915
- method: "POST",
916
- path: `/api/session/${encodeURIComponent(input.sessionID)}/question/${encodeURIComponent(input.requestID)}/reply`,
917
- body: { answers: input["answers"] },
918
- successStatus: 204,
919
- declaredStatuses: [404, 400, 401],
920
- empty: true,
921
- },
922
- requestOptions,
923
- ),
924
- reject: (input: QuestionsRejectInput, requestOptions?: RequestOptions) =>
925
- request<QuestionsRejectOutput>(
926
- {
927
- method: "POST",
928
- path: `/api/session/${encodeURIComponent(input.sessionID)}/question/${encodeURIComponent(input.requestID)}/reject`,
929
- successStatus: 204,
930
- declaredStatuses: [404, 400, 401],
931
- empty: true,
932
- },
933
- requestOptions,
934
- ),
935
- },
936
- references: {
937
- list: (input?: ReferencesListInput, requestOptions?: RequestOptions) =>
938
- request<ReferencesListOutput>(
939
- {
940
- method: "GET",
941
- path: `/api/reference`,
942
- query: { location: input?.["location"] },
943
- successStatus: 200,
944
- declaredStatuses: [401, 400],
945
- empty: false,
946
- },
947
- requestOptions,
948
- ),
949
- },
950
- projectCopies: {
951
- create: (input: ProjectCopiesCreateInput, requestOptions?: RequestOptions) =>
952
- request<ProjectCopiesCreateOutput>(
953
- {
954
- method: "POST",
955
- path: `/experimental/project/${encodeURIComponent(input.projectID)}/copy`,
956
- query: { location: input["location"] },
957
- body: { strategy: input["strategy"], directory: input["directory"], name: input["name"] },
958
- successStatus: 200,
959
- declaredStatuses: [400, 401],
960
- empty: false,
961
- },
962
- requestOptions,
963
- ),
964
- remove: (input: ProjectCopiesRemoveInput, requestOptions?: RequestOptions) =>
965
- request<ProjectCopiesRemoveOutput>(
966
- {
967
- method: "DELETE",
968
- path: `/experimental/project/${encodeURIComponent(input.projectID)}/copy`,
969
- query: { location: input["location"] },
970
- body: { directory: input["directory"], force: input["force"] },
971
- successStatus: 204,
972
- declaredStatuses: [400, 401],
973
- empty: true,
974
- },
975
- requestOptions,
976
- ),
977
- refresh: (input: ProjectCopiesRefreshInput, requestOptions?: RequestOptions) =>
978
- request<ProjectCopiesRefreshOutput>(
979
- {
980
- method: "POST",
981
- path: `/experimental/project/${encodeURIComponent(input.projectID)}/copy/refresh`,
982
- query: { location: input["location"] },
983
- successStatus: 204,
984
- declaredStatuses: [400, 401],
985
- empty: true,
986
- },
987
- requestOptions,
988
- ),
989
- },
990
- }
991
- }
992
-
993
- function appendQuery(params: URLSearchParams, key: string, value: unknown): void {
994
- if (value === undefined || value === null) return
995
- if (Array.isArray(value)) {
996
- for (const item of value) appendQuery(params, key, item)
997
- return
998
- }
999
- if (typeof value === "object") {
1000
- for (const [child, item] of Object.entries(value)) appendQuery(params, `${key}[${child}]`, item)
1001
- return
1002
- }
1003
- params.append(key, String(value))
1004
- }
1005
-
1006
- async function json(response: Response): Promise<unknown> {
1007
- if (!isContentType(response, "application/json") && !response.headers.get("content-type")?.includes("+json")) {
1008
- try {
1009
- await response.body?.cancel()
1010
- } catch {}
1011
- throw new ClientError("UnsupportedContentType")
1012
- }
1013
- let text: string
1014
- try {
1015
- text = await response.text()
1016
- } catch (cause) {
1017
- throw new ClientError("Transport", { cause })
1018
- }
1019
- if (text === "") throw new ClientError("MalformedResponse")
1020
- try {
1021
- return JSON.parse(text)
1022
- } catch (cause) {
1023
- throw new ClientError("MalformedResponse", { cause })
1024
- }
1025
- }
1026
-
1027
- function isContentType(response: Response, expected: string) {
1028
- return response.headers.get("content-type")?.split(";", 1)[0]?.trim().toLowerCase() === expected
1029
- }