create-expert 0.0.39 → 0.0.40

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.
@@ -1,33 +1,36 @@
1
- import { $ as boolean, B as messageSchema, Ft as PerstackError, G as number$1, H as userMessageSchema, I as usageSchema, L as toolResultSchema, Q as array, R as toolCallSchema, U as activityOrGroupSchema, V as toolMessageSchema, W as boolean$1, X as _undefined, ct as object, dt as record, gt as unknown, ht as union, it as literal, pt as string, q as _enum, st as number, tt as discriminatedUnion, ut as preprocess, z as instructionMessageSchema } from "./src-C0pz_C3h.js";
1
+ import { B as instructionMessageSchema, G as boolean$1, H as toolMessageSchema, K as number$1, L as usageSchema, Lt as PerstackError, Q as _undefined, R as toolResultSchema, U as userMessageSchema, V as messageSchema, W as activityOrGroupSchema, Y as _enum, Z as _null, _t as union, at as lazy, et as array, ft as preprocess, ht as string, lt as number, ot as literal, pt as record, rt as discriminatedUnion, tt as boolean, ut as object, vt as unknown, z as toolCallSchema } from "./src-Ct-kpNVU.js";
2
2
 
3
- //#region ../../node_modules/.pnpm/@perstack+api-client@0.0.55_@perstack+core@packages+core_zod@4.3.6/node_modules/@perstack/api-client/dist/index.mjs
3
+ //#region ../../node_modules/.pnpm/@perstack+api-client@0.0.56_@perstack+core@packages+core_zod@4.3.6/node_modules/@perstack/api-client/dist/index.mjs
4
4
  function createValidationError(error) {
5
5
  return {
6
- errorType: "validation",
7
- code: 400,
6
+ type: "validation",
8
7
  message: `Validation failed: ${error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`).join("; ")}`,
9
8
  reason: error.issues
10
9
  };
11
10
  }
11
+ function validationErrorResult(error) {
12
+ return {
13
+ ok: false,
14
+ status: 0,
15
+ headers: new Headers(),
16
+ error: createValidationError(error)
17
+ };
18
+ }
12
19
  function createAbortError() {
13
20
  return {
14
- errorType: "abort",
15
- code: 0,
16
- message: "Request aborted",
17
- aborted: true
21
+ type: "abort",
22
+ message: "Request aborted"
18
23
  };
19
24
  }
20
25
  function createTimeoutError() {
21
26
  return {
22
- errorType: "timeout",
23
- code: 0,
27
+ type: "timeout",
24
28
  message: "Request timed out"
25
29
  };
26
30
  }
27
31
  function createNetworkError(error) {
28
32
  return {
29
- errorType: "network",
30
- code: 0,
33
+ type: "network",
31
34
  message: error instanceof Error ? error.message : "Network error",
32
35
  reason: error,
33
36
  cause: error instanceof Error ? error : void 0
@@ -42,38 +45,37 @@ async function handleHttpError(response) {
42
45
  }
43
46
  return {
44
47
  ok: false,
45
- error: createHttpError(response.status, response.statusText, errorBody)
48
+ status: response.status,
49
+ headers: response.headers,
50
+ error: createHttpError(response.statusText, errorBody)
46
51
  };
47
52
  }
48
- function createHttpError(status, statusText, body) {
53
+ function createHttpError(statusText, body) {
49
54
  if (typeof body === "object" && body !== null) {
50
55
  const hasReason = "reason" in body;
51
56
  if ("error" in body && typeof body.error === "string") return {
52
- errorType: "http",
53
- code: status,
57
+ type: "http",
54
58
  message: body.error,
55
59
  reason: hasReason ? body.reason : void 0
56
60
  };
57
61
  if (hasReason) return {
58
- errorType: "http",
59
- code: status,
62
+ type: "http",
60
63
  message: statusText,
61
64
  reason: body.reason
62
65
  };
63
66
  }
64
67
  return {
65
- errorType: "http",
66
- code: status,
68
+ type: "http",
67
69
  message: statusText
68
70
  };
69
71
  }
70
72
  const DEFAULT_BASE_URL = "https://api.perstack.ai";
71
- const DEFAULT_TIMEOUT = 3e4;
73
+ const DEFAULT_TIMEOUT = 6e4;
72
74
  function createFetcher(config) {
73
75
  const baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;
74
76
  const timeout = config.timeout ?? DEFAULT_TIMEOUT;
75
- const useCredentials = "credentials" in config && config.credentials === "include";
76
- const apiKey = "apiKey" in config ? config.apiKey : void 0;
77
+ const useCredentials = config.credentials === "include";
78
+ const apiKey = config.apiKey;
77
79
  function buildUrl(path) {
78
80
  return `${baseUrl}${path}`;
79
81
  }
@@ -169,23 +171,32 @@ function createFetcher(config) {
169
171
  credentials: getCredentials()
170
172
  });
171
173
  if (!response.ok) return handleHttpError(response);
174
+ const json = await response.json();
172
175
  return {
173
176
  ok: true,
174
- data: await response.json()
177
+ status: response.status,
178
+ headers: response.headers,
179
+ data: json
175
180
  };
176
181
  } catch (error) {
177
182
  if (error instanceof Error && error.name === "AbortError") {
178
183
  if (isTimeout()) return {
179
184
  ok: false,
185
+ status: 0,
186
+ headers: new Headers(),
180
187
  error: createTimeoutError()
181
188
  };
182
189
  return {
183
190
  ok: false,
191
+ status: 0,
192
+ headers: new Headers(),
184
193
  error: createAbortError()
185
194
  };
186
195
  }
187
196
  return {
188
197
  ok: false,
198
+ status: 0,
199
+ headers: new Headers(),
189
200
  error: createNetworkError(error)
190
201
  };
191
202
  } finally {
@@ -202,23 +213,32 @@ function createFetcher(config) {
202
213
  credentials: getCredentials()
203
214
  });
204
215
  if (!response.ok) return handleHttpError(response);
216
+ const blob = await response.blob();
205
217
  return {
206
218
  ok: true,
207
- data: await response.blob()
219
+ status: response.status,
220
+ headers: response.headers,
221
+ data: blob
208
222
  };
209
223
  } catch (error) {
210
224
  if (error instanceof Error && error.name === "AbortError") {
211
225
  if (isTimeout()) return {
212
226
  ok: false,
227
+ status: 0,
228
+ headers: new Headers(),
213
229
  error: createTimeoutError()
214
230
  };
215
231
  return {
216
232
  ok: false,
233
+ status: 0,
234
+ headers: new Headers(),
217
235
  error: createAbortError()
218
236
  };
219
237
  }
220
238
  return {
221
239
  ok: false,
240
+ status: 0,
241
+ headers: new Headers(),
222
242
  error: createNetworkError(error)
223
243
  };
224
244
  } finally {
@@ -242,29 +262,40 @@ function createFetcher(config) {
242
262
  cleanup();
243
263
  return {
244
264
  ok: false,
265
+ status: response.status,
266
+ headers: response.headers,
245
267
  error: createNetworkError(/* @__PURE__ */ new Error("Response body is null"))
246
268
  };
247
269
  }
248
270
  cleanup();
249
271
  const idleTimeout = options?.streamIdleTimeout ?? timeout;
272
+ const wrappedStream = wrapStreamWithIdleTimeout(response.body, idleTimeout, options?.signal);
250
273
  return {
251
274
  ok: true,
252
- data: wrapStreamWithIdleTimeout(response.body, idleTimeout, options?.signal)
275
+ status: response.status,
276
+ headers: response.headers,
277
+ data: wrappedStream
253
278
  };
254
279
  } catch (error) {
255
280
  cleanup();
256
281
  if (error instanceof Error && error.name === "AbortError") {
257
282
  if (isTimeout()) return {
258
283
  ok: false,
284
+ status: 0,
285
+ headers: new Headers(),
259
286
  error: createTimeoutError()
260
287
  };
261
288
  return {
262
289
  ok: false,
290
+ status: 0,
291
+ headers: new Headers(),
263
292
  error: createAbortError()
264
293
  };
265
294
  }
266
295
  return {
267
296
  ok: false,
297
+ status: 0,
298
+ headers: new Headers(),
268
299
  error: createNetworkError(error)
269
300
  };
270
301
  }
@@ -281,21 +312,29 @@ function createFetcher(config) {
281
312
  if (!response.ok) return handleHttpError(response);
282
313
  return {
283
314
  ok: true,
315
+ status: response.status,
316
+ headers: response.headers,
284
317
  data: void 0
285
318
  };
286
319
  } catch (error) {
287
320
  if (error instanceof Error && error.name === "AbortError") {
288
321
  if (isTimeout()) return {
289
322
  ok: false,
323
+ status: 0,
324
+ headers: new Headers(),
290
325
  error: createTimeoutError()
291
326
  };
292
327
  return {
293
328
  ok: false,
329
+ status: 0,
330
+ headers: new Headers(),
294
331
  error: createAbortError()
295
332
  };
296
333
  }
297
334
  return {
298
335
  ok: false,
336
+ status: 0,
337
+ headers: new Headers(),
299
338
  error: createNetworkError(error)
300
339
  };
301
340
  } finally {
@@ -545,12 +584,12 @@ const applicationSchema = object({
545
584
  totalJobs: number().describe("Total number of jobs executed for this application").optional(),
546
585
  lastJobExecutionAt: string().datetime({ offset: true }).nullable().describe("Timestamp of the most recent job execution").optional()
547
586
  });
548
- const request$17 = { body: object({
587
+ const request$21 = { body: object({
549
588
  name: applicationNameSchema,
550
589
  applicationGroupId: cuidSchema.optional()
551
590
  }) };
552
591
  object({ data: object({ application: applicationSchema }) });
553
- const request$16 = { query: object({
592
+ const request$20 = { query: object({
554
593
  name: preprocess((val) => Array.isArray(val) ? val.join(",") : val, string().optional()),
555
594
  sort: _enum([
556
595
  "name",
@@ -565,7 +604,7 @@ object({
565
604
  data: object({ applications: array(applicationSchema) }),
566
605
  meta: paginationMeta
567
606
  });
568
- const request$15 = {
607
+ const request$19 = {
569
608
  params: object({ applicationId: cuidSchema }),
570
609
  body: object({
571
610
  name: applicationNameSchema.optional(),
@@ -588,15 +627,25 @@ object({
588
627
  createdAt: datetimeSchema,
589
628
  updatedAt: datetimeSchema
590
629
  });
591
- const request$14 = { body: object({
630
+ const request$18 = { body: object({
592
631
  applicationId: cuidSchema,
593
632
  name: secretNameSchema,
594
633
  value: secretValueSchema
595
634
  }) };
596
635
  object({ data: object({ secret: secretMetadataSchema }) });
597
- const request$13 = { query: object({ applicationId: cuidSchema.optional() }) };
636
+ const request$17 = {
637
+ params: object({ name: string().min(1) }),
638
+ query: object({ applicationId: cuidSchema })
639
+ };
640
+ _null();
641
+ const request$16 = {
642
+ params: object({ name: string().min(1) }),
643
+ query: object({ applicationId: cuidSchema })
644
+ };
645
+ object({ data: object({ secret: secretMetadataSchema }) });
646
+ const request$15 = { query: object({ applicationId: cuidSchema.optional() }) };
598
647
  object({ data: object({ secrets: array(secretMetadataSchema) }) });
599
- const request$12 = {
648
+ const request$14 = {
600
649
  params: object({ name: string().min(1) }),
601
650
  body: object({
602
651
  applicationId: cuidSchema,
@@ -621,12 +670,22 @@ const variableResponseSchema = object({
621
670
  createdAt: datetimeSchema,
622
671
  updatedAt: datetimeSchema
623
672
  });
624
- const request$11 = { body: object({
673
+ const request$13 = { body: object({
625
674
  applicationId: cuidSchema,
626
675
  name: variableNameSchema,
627
676
  value: variableValueSchema
628
677
  }) };
629
678
  object({ data: object({ variable: variableResponseSchema }) });
679
+ const request$12 = {
680
+ params: object({ name: string().min(1) }),
681
+ query: object({ applicationId: cuidSchema })
682
+ };
683
+ _null();
684
+ const request$11 = {
685
+ params: object({ name: string().min(1) }),
686
+ query: object({ applicationId: cuidSchema })
687
+ };
688
+ object({ data: object({ variable: variableResponseSchema }) });
630
689
  const request$10 = { query: object({ applicationId: cuidSchema }) };
631
690
  object({ data: object({ variables: array(variableResponseSchema) }) });
632
691
  const request$9 = {
@@ -745,7 +804,7 @@ const expertSchema = object({
745
804
  skills: record(skillNameSchema, skillSchema).optional().default({}),
746
805
  delegates: array(expertKeyFieldSchema).min(0).max(maxExpertDelegateItems).optional().default([]),
747
806
  tags: array(expertTagFieldSchema).min(0).max(maxExpertTagItems).optional().default([]),
748
- minRuntimeVersion: runtimeVersionSchema.optional()
807
+ minRuntimeVersion: runtimeVersionSchema.optional().default("v1.0")
749
808
  });
750
809
  object({
751
810
  scope: expertScopeSchema,
@@ -757,14 +816,7 @@ const expertWithMetadataSchema = expertSchema.extend({
757
816
  });
758
817
  const request$8 = { query: object({
759
818
  filter: string().describe("Filter by scope name (partial match)").optional(),
760
- category: _enum([
761
- "general",
762
- "coding",
763
- "research",
764
- "writing",
765
- "data",
766
- "automation"
767
- ]).describe("Filter by category").optional(),
819
+ category: expertCategoryFieldSchema.describe("Filter by category").optional(),
768
820
  includeDrafts: boolean$1().default(false).describe("Include unpublished scopes (owner only)").optional(),
769
821
  take: number$1().min(1).max(100).default(20),
770
822
  skip: number$1().min(0).default(0)
@@ -774,6 +826,12 @@ object({
774
826
  meta: paginationMeta
775
827
  });
776
828
  const anthropicSupportModels = [
829
+ {
830
+ modelId: "claude-opus-4-6",
831
+ default: false,
832
+ provider: "anthropic",
833
+ contextWindow: 2e5
834
+ },
777
835
  {
778
836
  modelId: "claude-opus-4-5",
779
837
  default: false,
@@ -847,6 +905,12 @@ const googleSupportModels = [
847
905
  default: false,
848
906
  provider: "google",
849
907
  contextWindow: 1e6
908
+ },
909
+ {
910
+ modelId: "gemini-3-flash-preview",
911
+ default: false,
912
+ provider: "google",
913
+ contextWindow: 1e6
850
914
  }
851
915
  ];
852
916
  const openAiSupportModels = [
@@ -897,6 +961,24 @@ const openAiSupportModels = [
897
961
  default: false,
898
962
  provider: "openai",
899
963
  contextWindow: 1e6
964
+ },
965
+ {
966
+ modelId: "gpt-5.1",
967
+ default: false,
968
+ provider: "openai",
969
+ contextWindow: 4e5
970
+ },
971
+ {
972
+ modelId: "gpt-5.2",
973
+ default: false,
974
+ provider: "openai",
975
+ contextWindow: 4e5
976
+ },
977
+ {
978
+ modelId: "gpt-5.2-pro",
979
+ default: false,
980
+ provider: "openai",
981
+ contextWindow: 4e5
900
982
  }
901
983
  ];
902
984
  const deepseekSupportModels = [{
@@ -952,6 +1034,7 @@ const jobBaseSchema = object({
952
1034
  updatedAt: datetimeSchema,
953
1035
  status: jobStatusSchema,
954
1036
  currentExecutionId: cuidSchema.optional(),
1037
+ machineId: cuidSchema.nullable(),
955
1038
  coordinatorExpertKey: expertKeyFieldSchema,
956
1039
  query: string().min(1).max(maxExpertJobQueryLength).optional(),
957
1040
  expert: expertWithMetadataSchema,
@@ -1013,7 +1096,7 @@ const request$5 = { query: object({
1013
1096
  expertScopeId: cuidSchema.optional(),
1014
1097
  expertDraftScopeId: cuidSchema.optional(),
1015
1098
  applicationId: cuidSchema.optional(),
1016
- statuses: preprocess((val) => typeof val === "string" ? val.split(",") : val, array(jobStatusSchema).optional()),
1099
+ statuses: preprocess((val) => typeof val === "string" ? val.split(",") : val, array(jobStatusSchema)).optional(),
1017
1100
  expertKeyFilter: string().max(100).optional()
1018
1101
  }) };
1019
1102
  object({
@@ -1048,7 +1131,8 @@ const apiCheckpointSchema = object({
1048
1131
  "stoppedByInteractiveTool",
1049
1132
  "stoppedByDelegate",
1050
1133
  "stoppedByExceededMaxSteps",
1051
- "stoppedByError"
1134
+ "stoppedByError",
1135
+ "stoppedByCancellation"
1052
1136
  ]),
1053
1137
  expert: expertSchema,
1054
1138
  delegateTo: array(delegationTargetSchema).optional(),
@@ -1100,16 +1184,7 @@ object({
1100
1184
  data: object({ checkpoints: array(apiCheckpointSchema) }),
1101
1185
  meta: paginationMeta
1102
1186
  });
1103
- const runStatusSchema = _enum([
1104
- "queued",
1105
- "processing",
1106
- "completed",
1107
- "stoppedByInteractiveTool",
1108
- "stoppedByDelegate",
1109
- "stoppedByExceededMaxSteps",
1110
- "stoppedByError"
1111
- ]);
1112
- const runSchema = object({
1187
+ const runTreeNodeSchema = object({
1113
1188
  type: literal("run"),
1114
1189
  id: cuidSchema,
1115
1190
  jobId: cuidSchema,
@@ -1118,11 +1193,14 @@ const runSchema = object({
1118
1193
  organizationId: cuidSchema,
1119
1194
  createdAt: datetimeSchema,
1120
1195
  updatedAt: datetimeSchema,
1121
- status: runStatusSchema,
1122
1196
  expertKey: expertKeyFieldSchema,
1123
1197
  expert: expertWithMetadataSchema,
1124
1198
  stepNumber: number().int().min(0),
1125
1199
  usage: usageSchema
1200
+ }).extend({
1201
+ lastCheckpointId: cuidSchema.nullable(),
1202
+ checkpointIds: array(cuidSchema),
1203
+ childRuns: lazy(() => array(runTreeNodeSchema))
1126
1204
  });
1127
1205
  const request$3 = {
1128
1206
  params: object({ jobId: cuidSchema }),
@@ -1130,11 +1208,12 @@ const request$3 = {
1130
1208
  sort: _enum(["createdAt", "updatedAt"]).optional(),
1131
1209
  order: _enum(["asc", "desc"]).optional(),
1132
1210
  take: number$1().min(1).max(100).default(20),
1133
- skip: number$1().min(0).default(0)
1211
+ skip: number$1().min(0).default(0),
1212
+ depth: number$1().int().min(0).max(10).default(0)
1134
1213
  })
1135
1214
  };
1136
1215
  object({
1137
- data: object({ runs: array(runSchema) }),
1216
+ data: object({ runs: array(runTreeNodeSchema) }),
1138
1217
  meta: paginationMeta
1139
1218
  });
1140
1219
  const baseUrlSchema = string().url().max(maxProviderBaseUrlLength).optional();
@@ -1239,10 +1318,7 @@ function createRunCheckpointsApi(fetcher, basePath) {
1239
1318
  async list(jobId, runId, params, options) {
1240
1319
  if (params) {
1241
1320
  const result = request$4.query.safeParse(params);
1242
- if (!result.success) return {
1243
- ok: false,
1244
- error: createValidationError(result.error)
1245
- };
1321
+ if (!result.success) return validationErrorResult(result.error);
1246
1322
  }
1247
1323
  const queryString = buildQueryString(params);
1248
1324
  return fetcher.get(`${basePath}/${jobId}/runs/${runId}/checkpoints${queryString}`, options);
@@ -1252,26 +1328,26 @@ function createRunCheckpointsApi(fetcher, basePath) {
1252
1328
  }
1253
1329
  };
1254
1330
  }
1331
+ function createListFn(fetcher, basePath) {
1332
+ return async function list(jobId, params, options) {
1333
+ if (params) {
1334
+ const result = request$3.query.safeParse(params);
1335
+ if (!result.success) return validationErrorResult(result.error);
1336
+ }
1337
+ const queryString = buildQueryString(params);
1338
+ return fetcher.get(`${basePath}/${jobId}/runs${queryString}`, options);
1339
+ };
1340
+ }
1255
1341
  function createRunsApi(fetcher, basePath) {
1256
1342
  return {
1257
- async list(jobId, params, options) {
1258
- if (params) {
1259
- const result = request$3.query.safeParse(params);
1260
- if (!result.success) return {
1261
- ok: false,
1262
- error: createValidationError(result.error)
1263
- };
1264
- }
1265
- const queryString = buildQueryString(params);
1266
- return fetcher.get(`${basePath}/${jobId}/runs${queryString}`, options);
1267
- },
1343
+ list: createListFn(fetcher, basePath),
1268
1344
  async get(jobId, runId, options) {
1269
1345
  return fetcher.get(`${basePath}/${jobId}/runs/${runId}`, options);
1270
1346
  },
1271
1347
  checkpoints: createRunCheckpointsApi(fetcher, basePath)
1272
1348
  };
1273
1349
  }
1274
- const BASE_PATH$5 = "/api/v1/jobs";
1350
+ const BASE_PATH$6 = "/api/v1/jobs";
1275
1351
  /**
1276
1352
  * Error thrown when stream ends abnormally.
1277
1353
  */
@@ -1303,168 +1379,152 @@ function createJobsApi(fetcher) {
1303
1379
  async list(params, options) {
1304
1380
  if (params) {
1305
1381
  const result = request$5.query.safeParse(params);
1306
- if (!result.success) return {
1307
- ok: false,
1308
- error: createValidationError(result.error)
1309
- };
1382
+ if (!result.success) return validationErrorResult(result.error);
1310
1383
  }
1311
1384
  const queryString = buildQueryString(params);
1312
- return fetcher.get(`${BASE_PATH$5}${queryString}`, options);
1385
+ return fetcher.get(`${BASE_PATH$6}${queryString}`, options);
1313
1386
  },
1314
1387
  async get(id, options) {
1315
- return fetcher.get(`${BASE_PATH$5}/${id}`, options);
1388
+ return fetcher.get(`${BASE_PATH$6}/${id}`, options);
1316
1389
  },
1317
1390
  async start(input, options) {
1318
1391
  const result = request$6.body.safeParse(input);
1319
- if (!result.success) return {
1320
- ok: false,
1321
- error: createValidationError(result.error)
1322
- };
1323
- return fetcher.post(BASE_PATH$5, input, options);
1392
+ if (!result.success) return validationErrorResult(result.error);
1393
+ return fetcher.post(BASE_PATH$6, input, options);
1324
1394
  },
1325
1395
  async continue(id, input, options) {
1326
1396
  const result = request$7.body.safeParse(input);
1327
- if (!result.success) return {
1328
- ok: false,
1329
- error: createValidationError(result.error)
1330
- };
1331
- return fetcher.post(`${BASE_PATH$5}/${id}/continue`, input, options);
1397
+ if (!result.success) return validationErrorResult(result.error);
1398
+ return fetcher.post(`${BASE_PATH$6}/${id}/continue`, input, options);
1332
1399
  },
1333
1400
  async cancel(id, options) {
1334
- return fetcher.post(`${BASE_PATH$5}/${id}/cancel`, {}, options);
1401
+ return fetcher.post(`${BASE_PATH$6}/${id}/cancel`, {}, options);
1335
1402
  },
1336
- async *stream(id, options) {
1337
- const result = await fetcher.getStream(`${BASE_PATH$5}/${id}/stream`, options);
1338
- if (!result.ok) throw new StreamConnectionError(result.error.message);
1339
- const reader = result.data.getReader();
1340
- try {
1341
- for await (const sseEvent of parseSSEEvents(reader)) if (sseEvent.event === "message") yield sseEvent.data;
1342
- else if (sseEvent.event === "error" && isErrorEventData(sseEvent.data)) throw new StreamError(sseEvent.data.type, sseEvent.data.jobId, sseEvent.data.message);
1343
- else if (sseEvent.event === "complete" && isCompleteEventData(sseEvent.data)) return;
1344
- } catch (error) {
1345
- if (error instanceof StreamError || error instanceof StreamConnectionError) throw error;
1346
- if (error instanceof DOMException && error.name === "AbortError") throw error;
1347
- throw new StreamConnectionError(error instanceof Error ? error.message : "Stream read error");
1403
+ async stream(id, options) {
1404
+ const result = await fetcher.getStream(`${BASE_PATH$6}/${id}/stream`, options);
1405
+ if (!result.ok) return result;
1406
+ async function* createEventGenerator(reader) {
1407
+ try {
1408
+ for await (const sseEvent of parseSSEEvents(reader)) if (sseEvent.event === "message") yield sseEvent.data;
1409
+ else if (sseEvent.event === "error" && isErrorEventData(sseEvent.data)) throw new StreamError(sseEvent.data.type, sseEvent.data.jobId, sseEvent.data.message);
1410
+ else if (sseEvent.event === "complete" && isCompleteEventData(sseEvent.data)) return;
1411
+ } catch (error) {
1412
+ if (error instanceof StreamError || error instanceof StreamConnectionError) throw error;
1413
+ if (error instanceof DOMException && error.name === "AbortError") throw error;
1414
+ throw new StreamConnectionError(error instanceof Error ? error.message : "Stream read error");
1415
+ }
1348
1416
  }
1417
+ const reader = result.data.getReader();
1418
+ return {
1419
+ ok: true,
1420
+ status: result.status,
1421
+ headers: result.headers,
1422
+ data: { events: createEventGenerator(reader) }
1423
+ };
1349
1424
  },
1350
- runs: createRunsApi(fetcher, BASE_PATH$5)
1425
+ runs: createRunsApi(fetcher, BASE_PATH$6)
1351
1426
  };
1352
1427
  }
1353
- const BASE_PATH$4 = "/api/v1/applications";
1428
+ const BASE_PATH$5 = "/api/v1/applications";
1354
1429
  function createApplicationsApi(fetcher) {
1355
1430
  return {
1356
1431
  async list(params, options) {
1357
1432
  if (params) {
1358
- const result = request$16.query.safeParse(params);
1359
- if (!result.success) return {
1360
- ok: false,
1361
- error: createValidationError(result.error)
1362
- };
1433
+ const result = request$20.query.safeParse(params);
1434
+ if (!result.success) return validationErrorResult(result.error);
1363
1435
  }
1364
1436
  const queryString = buildQueryString(params);
1365
- return fetcher.get(`${BASE_PATH$4}${queryString}`, options);
1437
+ return fetcher.get(`${BASE_PATH$5}${queryString}`, options);
1366
1438
  },
1367
1439
  async get(id, options) {
1368
- return fetcher.get(`${BASE_PATH$4}/${id}`, options);
1440
+ return fetcher.get(`${BASE_PATH$5}/${id}`, options);
1369
1441
  },
1370
1442
  async create(input, options) {
1371
- const result = request$17.body.safeParse(input);
1372
- if (!result.success) return {
1373
- ok: false,
1374
- error: createValidationError(result.error)
1375
- };
1376
- return fetcher.post(BASE_PATH$4, input, options);
1443
+ const result = request$21.body.safeParse(input);
1444
+ if (!result.success) return validationErrorResult(result.error);
1445
+ return fetcher.post(BASE_PATH$5, input, options);
1377
1446
  },
1378
1447
  async update(id, input, options) {
1379
- const result = request$15.body.safeParse(input);
1380
- if (!result.success) return {
1381
- ok: false,
1382
- error: createValidationError(result.error)
1383
- };
1384
- return fetcher.post(`${BASE_PATH$4}/${id}`, input, options);
1448
+ const result = request$19.body.safeParse(input);
1449
+ if (!result.success) return validationErrorResult(result.error);
1450
+ return fetcher.post(`${BASE_PATH$5}/${id}`, input, options);
1385
1451
  },
1386
1452
  async delete(id, options) {
1387
- return fetcher.delete(`${BASE_PATH$4}/${id}`, options);
1453
+ return fetcher.delete(`${BASE_PATH$5}/${id}`, options);
1388
1454
  }
1389
1455
  };
1390
1456
  }
1391
- const BASE_PATH$3 = "/api/v1/env/secrets";
1457
+ const BASE_PATH$4 = "/api/v1/env/secrets";
1392
1458
  function createSecretsApi(fetcher) {
1393
1459
  return {
1394
1460
  async list(params, options) {
1395
1461
  if (params) {
1396
- const result = request$13.query.safeParse(params);
1397
- if (!result.success) return {
1398
- ok: false,
1399
- error: createValidationError(result.error)
1400
- };
1462
+ const result = request$15.query.safeParse(params);
1463
+ if (!result.success) return validationErrorResult(result.error);
1401
1464
  }
1402
1465
  const queryString = buildQueryString(params);
1403
- return fetcher.get(`${BASE_PATH$3}${queryString}`, options);
1466
+ return fetcher.get(`${BASE_PATH$4}${queryString}`, options);
1404
1467
  },
1405
- async get(name, options) {
1468
+ async get(name, params, options) {
1469
+ const result = request$16.query.safeParse(params);
1470
+ if (!result.success) return validationErrorResult(result.error);
1406
1471
  const encodedName = encodeURIComponent(name);
1407
- return fetcher.get(`${BASE_PATH$3}/${encodedName}`, options);
1472
+ const queryString = buildQueryString(params);
1473
+ return fetcher.get(`${BASE_PATH$4}/${encodedName}${queryString}`, options);
1408
1474
  },
1409
1475
  async create(input, options) {
1410
- const result = request$14.body.safeParse(input);
1411
- if (!result.success) return {
1412
- ok: false,
1413
- error: createValidationError(result.error)
1414
- };
1415
- return fetcher.post(BASE_PATH$3, input, options);
1476
+ const result = request$18.body.safeParse(input);
1477
+ if (!result.success) return validationErrorResult(result.error);
1478
+ return fetcher.post(BASE_PATH$4, input, options);
1416
1479
  },
1417
1480
  async update(name, input, options) {
1418
- const result = request$12.body.safeParse(input);
1419
- if (!result.success) return {
1420
- ok: false,
1421
- error: createValidationError(result.error)
1422
- };
1481
+ const result = request$14.body.safeParse(input);
1482
+ if (!result.success) return validationErrorResult(result.error);
1423
1483
  const encodedName = encodeURIComponent(name);
1424
- return fetcher.put(`${BASE_PATH$3}/${encodedName}`, input, options);
1484
+ return fetcher.post(`${BASE_PATH$4}/${encodedName}`, input, options);
1425
1485
  },
1426
- async delete(name, options) {
1486
+ async delete(name, params, options) {
1487
+ const result = request$17.query.safeParse(params);
1488
+ if (!result.success) return validationErrorResult(result.error);
1427
1489
  const encodedName = encodeURIComponent(name);
1428
- return fetcher.deleteNoContent(`${BASE_PATH$3}/${encodedName}`, options);
1490
+ const queryString = buildQueryString(params);
1491
+ return fetcher.deleteNoContent(`${BASE_PATH$4}/${encodedName}${queryString}`, options);
1429
1492
  }
1430
1493
  };
1431
1494
  }
1432
- const BASE_PATH$2 = "/api/v1/env/variables";
1495
+ const BASE_PATH$3 = "/api/v1/env/variables";
1433
1496
  function createVariablesApi(fetcher) {
1434
1497
  return {
1435
1498
  async list(params, options) {
1436
1499
  const result = request$10.query.safeParse(params);
1437
- if (!result.success) return {
1438
- ok: false,
1439
- error: createValidationError(result.error)
1440
- };
1500
+ if (!result.success) return validationErrorResult(result.error);
1441
1501
  const queryString = buildQueryString(params);
1442
- return fetcher.get(`${BASE_PATH$2}${queryString}`, options);
1502
+ return fetcher.get(`${BASE_PATH$3}${queryString}`, options);
1443
1503
  },
1444
- async get(name, options) {
1504
+ async get(name, params, options) {
1505
+ const result = request$11.query.safeParse(params);
1506
+ if (!result.success) return validationErrorResult(result.error);
1445
1507
  const encodedName = encodeURIComponent(name);
1446
- return fetcher.get(`${BASE_PATH$2}/${encodedName}`, options);
1508
+ const queryString = buildQueryString(params);
1509
+ return fetcher.get(`${BASE_PATH$3}/${encodedName}${queryString}`, options);
1447
1510
  },
1448
1511
  async create(input, options) {
1449
- const result = request$11.body.safeParse(input);
1450
- if (!result.success) return {
1451
- ok: false,
1452
- error: createValidationError(result.error)
1453
- };
1454
- return fetcher.post(BASE_PATH$2, input, options);
1512
+ const result = request$13.body.safeParse(input);
1513
+ if (!result.success) return validationErrorResult(result.error);
1514
+ return fetcher.post(BASE_PATH$3, input, options);
1455
1515
  },
1456
1516
  async update(name, input, options) {
1457
1517
  const result = request$9.body.safeParse(input);
1458
- if (!result.success) return {
1459
- ok: false,
1460
- error: createValidationError(result.error)
1461
- };
1518
+ if (!result.success) return validationErrorResult(result.error);
1462
1519
  const encodedName = encodeURIComponent(name);
1463
- return fetcher.put(`${BASE_PATH$2}/${encodedName}`, input, options);
1520
+ return fetcher.post(`${BASE_PATH$3}/${encodedName}`, input, options);
1464
1521
  },
1465
- async delete(name, options) {
1522
+ async delete(name, params, options) {
1523
+ const result = request$12.query.safeParse(params);
1524
+ if (!result.success) return validationErrorResult(result.error);
1466
1525
  const encodedName = encodeURIComponent(name);
1467
- return fetcher.deleteNoContent(`${BASE_PATH$2}/${encodedName}`, options);
1526
+ const queryString = buildQueryString(params);
1527
+ return fetcher.deleteNoContent(`${BASE_PATH$3}/${encodedName}${queryString}`, options);
1468
1528
  }
1469
1529
  };
1470
1530
  }
@@ -1480,46 +1540,49 @@ function createVersionsApi(fetcher, basePath) {
1480
1540
  return fetcher.get(`${basePath}/${encodedScopeName}/versions`, options);
1481
1541
  } };
1482
1542
  }
1483
- const BASE_PATH$1 = "/api/v1/experts";
1543
+ const BASE_PATH$2 = "/api/v1/experts";
1484
1544
  function createExpertsApi(fetcher) {
1485
1545
  return {
1486
1546
  async list(params, options) {
1487
1547
  if (params) {
1488
1548
  const result = request$8.query.safeParse(params);
1489
- if (!result.success) return {
1490
- ok: false,
1491
- error: createValidationError(result.error)
1492
- };
1549
+ if (!result.success) return validationErrorResult(result.error);
1493
1550
  }
1494
1551
  const queryString = buildQueryString(params);
1495
- return fetcher.get(`${BASE_PATH$1}${queryString}`, options);
1552
+ return fetcher.get(`${BASE_PATH$2}${queryString}`, options);
1496
1553
  },
1497
1554
  async get(key, options) {
1498
1555
  const encodedKey = encodeURIComponent(key);
1499
- return fetcher.get(`${BASE_PATH$1}/${encodedKey}`, options);
1556
+ return fetcher.get(`${BASE_PATH$2}/${encodedKey}`, options);
1500
1557
  },
1501
1558
  async getFeatured(options) {
1502
- return fetcher.get(`${BASE_PATH$1}/featured`, options);
1559
+ return fetcher.get(`${BASE_PATH$2}/featured`, options);
1503
1560
  },
1504
1561
  async getMeta(key, options) {
1505
1562
  const encodedKey = encodeURIComponent(key);
1506
- return fetcher.get(`${BASE_PATH$1}/${encodedKey}/meta`, options);
1563
+ return fetcher.get(`${BASE_PATH$2}/${encodedKey}/meta`, options);
1507
1564
  },
1508
1565
  async publish(scopeName, options) {
1509
1566
  const encodedScopeName = encodeURIComponent(scopeName);
1510
- return fetcher.post(`${BASE_PATH$1}/${encodedScopeName}/publish`, {}, options);
1567
+ return fetcher.post(`${BASE_PATH$2}/${encodedScopeName}/publish`, {}, options);
1511
1568
  },
1512
1569
  async unpublish(scopeName, options) {
1513
1570
  const encodedScopeName = encodeURIComponent(scopeName);
1514
- return fetcher.post(`${BASE_PATH$1}/${encodedScopeName}/unpublish`, {}, options);
1571
+ return fetcher.post(`${BASE_PATH$2}/${encodedScopeName}/unpublish`, {}, options);
1515
1572
  },
1516
1573
  async yank(key, options) {
1517
1574
  const encodedKey = encodeURIComponent(key);
1518
- return fetcher.delete(`${BASE_PATH$1}/${encodedKey}`, options);
1575
+ return fetcher.delete(`${BASE_PATH$2}/${encodedKey}`, options);
1519
1576
  },
1520
- versions: createVersionsApi(fetcher, BASE_PATH$1)
1577
+ versions: createVersionsApi(fetcher, BASE_PATH$2)
1521
1578
  };
1522
1579
  }
1580
+ const BASE_PATH$1 = "/api/v1/organizations";
1581
+ function createOrganizationsApi(fetcher) {
1582
+ return { async getCurrent(options) {
1583
+ return fetcher.get(`${BASE_PATH$1}/current`, options);
1584
+ } };
1585
+ }
1523
1586
  const BASE_PATH = "/api/v1/applications";
1524
1587
  function createProviderSettingsApi(fetcher) {
1525
1588
  return {
@@ -1532,18 +1595,12 @@ function createProviderSettingsApi(fetcher) {
1532
1595
  },
1533
1596
  async create(applicationId, input, options) {
1534
1597
  const result = request$1.body.safeParse(input);
1535
- if (!result.success) return {
1536
- ok: false,
1537
- error: createValidationError(result.error)
1538
- };
1598
+ if (!result.success) return validationErrorResult(result.error);
1539
1599
  return fetcher.post(`${BASE_PATH}/${applicationId}/provider_settings`, input, options);
1540
1600
  },
1541
1601
  async update(applicationId, provider, input, options) {
1542
1602
  const result = request.body.safeParse(input);
1543
- if (!result.success) return {
1544
- ok: false,
1545
- error: createValidationError(result.error)
1546
- };
1603
+ if (!result.success) return validationErrorResult(result.error);
1547
1604
  const encodedProvider = encodeURIComponent(provider);
1548
1605
  return fetcher.post(`${BASE_PATH}/${applicationId}/provider_settings/${encodedProvider}`, input, options);
1549
1606
  },
@@ -1557,10 +1614,7 @@ function createProviderSettingsApi(fetcher) {
1557
1614
  },
1558
1615
  async createApiKey(applicationId, provider, input, options) {
1559
1616
  const result = request$2.body.safeParse(input);
1560
- if (!result.success) return {
1561
- ok: false,
1562
- error: createValidationError(result.error)
1563
- };
1617
+ if (!result.success) return validationErrorResult(result.error);
1564
1618
  const encodedProvider = encodeURIComponent(provider);
1565
1619
  return fetcher.post(`${BASE_PATH}/${applicationId}/provider_settings/${encodedProvider}/api_keys`, input, options);
1566
1620
  },
@@ -1578,6 +1632,7 @@ function createApiClient(config) {
1578
1632
  env: createEnvApi(fetcher),
1579
1633
  jobs: createJobsApi(fetcher),
1580
1634
  experts: createExpertsApi(fetcher),
1635
+ organizations: createOrganizationsApi(fetcher),
1581
1636
  providerSettings: createProviderSettingsApi(fetcher)
1582
1637
  };
1583
1638
  }
@@ -1648,4 +1703,4 @@ function toRuntimeExpert(key, expert) {
1648
1703
 
1649
1704
  //#endregion
1650
1705
  export { resolveExpertToRun };
1651
- //# sourceMappingURL=resolve-expert-CTnETi9d.js.map
1706
+ //# sourceMappingURL=resolve-expert-Circ5eKU.js.map