@perstack/api-client 0.0.53 → 0.0.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { activityOrGroupSchema, checkpointSchema as perstackCheckpointSchema, instructionMessageSchema, messageSchema, stepSchema, toolCallSchema, toolMessageSchema, toolResultSchema, usageSchema, userMessageSchema } from "@perstack/core";
2
+ import { activityOrGroupSchema, instructionMessageSchema, messageSchema, toolCallSchema, toolMessageSchema, toolResultSchema, usageSchema, userMessageSchema } from "@perstack/core";
3
3
 
4
4
  //#region src/lib/api-key.ts
5
5
  function matchWildcard(value, pattern) {
@@ -73,16 +73,16 @@ function createNetworkError(error) {
73
73
  cause: error instanceof Error ? error : void 0
74
74
  };
75
75
  }
76
- async function handleHttpError(response$19) {
76
+ async function handleHttpError(response) {
77
77
  let errorBody;
78
78
  try {
79
- errorBody = await response$19.json();
79
+ errorBody = await response.json();
80
80
  } catch {
81
81
  errorBody = void 0;
82
82
  }
83
83
  return {
84
84
  ok: false,
85
- error: createHttpError(response$19.status, response$19.statusText, errorBody)
85
+ error: createHttpError(response.status, response.statusText, errorBody)
86
86
  };
87
87
  }
88
88
  function createHttpError(status, statusText, body) {
@@ -219,20 +219,20 @@ function createFetcher(config) {
219
219
  }
220
220
  });
221
221
  }
222
- async function request$19(method, path, body, options) {
222
+ async function request(method, path, body, options) {
223
223
  const { signal, cleanup, isTimeout } = createTimeoutSignal(options?.signal);
224
224
  try {
225
- const response$19 = await fetch(buildUrl(path), {
225
+ const response = await fetch(buildUrl(path), {
226
226
  method,
227
227
  headers: buildHeaders(body ? { hasBody: true } : void 0),
228
228
  body: body ? JSON.stringify(body) : void 0,
229
229
  signal,
230
230
  credentials: getCredentials()
231
231
  });
232
- if (!response$19.ok) return handleHttpError(response$19);
232
+ if (!response.ok) return handleHttpError(response);
233
233
  return {
234
234
  ok: true,
235
- data: await response$19.json()
235
+ data: await response.json()
236
236
  };
237
237
  } catch (error) {
238
238
  if (error instanceof Error && error.name === "AbortError") {
@@ -256,16 +256,16 @@ function createFetcher(config) {
256
256
  async function requestBlob(path, options) {
257
257
  const { signal, cleanup, isTimeout } = createTimeoutSignal(options?.signal);
258
258
  try {
259
- const response$19 = await fetch(buildUrl(path), {
259
+ const response = await fetch(buildUrl(path), {
260
260
  method: "GET",
261
261
  headers: buildHeaders(),
262
262
  signal,
263
263
  credentials: getCredentials()
264
264
  });
265
- if (!response$19.ok) return handleHttpError(response$19);
265
+ if (!response.ok) return handleHttpError(response);
266
266
  return {
267
267
  ok: true,
268
- data: await response$19.blob()
268
+ data: await response.blob()
269
269
  };
270
270
  } catch (error) {
271
271
  if (error instanceof Error && error.name === "AbortError") {
@@ -289,17 +289,17 @@ function createFetcher(config) {
289
289
  async function requestStream(path, options) {
290
290
  const { signal, cleanup, isTimeout } = createTimeoutSignal(options?.signal);
291
291
  try {
292
- const response$19 = await fetch(buildUrl(path), {
292
+ const response = await fetch(buildUrl(path), {
293
293
  method: "GET",
294
294
  headers: buildHeaders(),
295
295
  signal,
296
296
  credentials: getCredentials()
297
297
  });
298
- if (!response$19.ok) {
298
+ if (!response.ok) {
299
299
  cleanup();
300
- return handleHttpError(response$19);
300
+ return handleHttpError(response);
301
301
  }
302
- if (!response$19.body) {
302
+ if (!response.body) {
303
303
  cleanup();
304
304
  return {
305
305
  ok: false,
@@ -310,7 +310,7 @@ function createFetcher(config) {
310
310
  const idleTimeout = options?.streamIdleTimeout ?? timeout;
311
311
  return {
312
312
  ok: true,
313
- data: wrapStreamWithIdleTimeout(response$19.body, idleTimeout, options?.signal)
313
+ data: wrapStreamWithIdleTimeout(response.body, idleTimeout, options?.signal)
314
314
  };
315
315
  } catch (error) {
316
316
  cleanup();
@@ -333,13 +333,13 @@ function createFetcher(config) {
333
333
  async function requestNoContent(method, path, options) {
334
334
  const { signal, cleanup, isTimeout } = createTimeoutSignal(options?.signal);
335
335
  try {
336
- const response$19 = await fetch(buildUrl(path), {
336
+ const response = await fetch(buildUrl(path), {
337
337
  method,
338
338
  headers: buildHeaders(),
339
339
  signal,
340
340
  credentials: getCredentials()
341
341
  });
342
- if (!response$19.ok) return handleHttpError(response$19);
342
+ if (!response.ok) return handleHttpError(response);
343
343
  return {
344
344
  ok: true,
345
345
  data: void 0
@@ -364,10 +364,10 @@ function createFetcher(config) {
364
364
  }
365
365
  }
366
366
  return {
367
- get: (path, options) => request$19("GET", path, void 0, options),
368
- post: (path, body, options) => request$19("POST", path, body, options),
369
- put: (path, body, options) => request$19("PUT", path, body, options),
370
- delete: (path, options) => request$19("DELETE", path, void 0, options),
367
+ get: (path, options) => request("GET", path, void 0, options),
368
+ post: (path, body, options) => request("POST", path, body, options),
369
+ put: (path, body, options) => request("PUT", path, body, options),
370
+ delete: (path, options) => request("DELETE", path, void 0, options),
371
371
  deleteNoContent: (path, options) => requestNoContent("DELETE", path, options),
372
372
  getBlob: (path, options) => requestBlob(path, options),
373
373
  getStream: (path, options) => requestStream(path, options)
@@ -604,6 +604,16 @@ const errorNotFound = z.object({
604
604
  error: z.literal("Not Found"),
605
605
  reason: z.string()
606
606
  }).describe("Resource not found.");
607
+ const errorConflict = z.object({
608
+ code: z.literal(409),
609
+ error: z.literal("Conflict"),
610
+ reason: z.string()
611
+ }).describe("Request conflicts with current state of the resource.");
612
+ const errorServiceUnavailable = z.object({
613
+ code: z.literal(503),
614
+ error: z.literal("Service Unavailable"),
615
+ reason: z.string()
616
+ }).describe("Service temporarily unavailable. Retry with exponential backoff.");
607
617
  const errorValidationFailed = z.object({
608
618
  code: z.literal(422),
609
619
  error: z.literal("Validation Failed"),
@@ -645,16 +655,16 @@ const applicationSchema = z.object({
645
655
 
646
656
  //#endregion
647
657
  //#region ../models/src/api/applications/create.ts
648
- const request$18 = { body: z.object({
658
+ const request$17 = { body: z.object({
649
659
  name: applicationNameSchema,
650
660
  applicationGroupId: cuidSchema.optional()
651
661
  }) };
652
- const response$18 = z.object({ data: z.object({ application: applicationSchema }) });
662
+ const response$17 = z.object({ data: z.object({ application: applicationSchema }) });
653
663
 
654
664
  //#endregion
655
665
  //#region ../models/src/api/applications/getAll.ts
656
- const request$17 = { query: z.object({
657
- name: z.union([z.string(), z.array(z.string())]).optional().transform((v) => Array.isArray(v) ? v.join(",") : v),
666
+ const request$16 = { query: z.object({
667
+ name: z.preprocess((val) => Array.isArray(val) ? val.join(",") : val, z.string().optional()),
658
668
  sort: z.enum([
659
669
  "name",
660
670
  "createdAt",
@@ -664,21 +674,21 @@ const request$17 = { query: z.object({
664
674
  take: z.coerce.number().min(1).max(100).default(20),
665
675
  skip: z.coerce.number().min(0).default(0)
666
676
  }) };
667
- const response$17 = z.object({
677
+ const response$16 = z.object({
668
678
  data: z.object({ applications: z.array(applicationSchema) }),
669
679
  meta: paginationMeta
670
680
  });
671
681
 
672
682
  //#endregion
673
683
  //#region ../models/src/api/applications/update.ts
674
- const request$16 = {
684
+ const request$15 = {
675
685
  params: z.object({ applicationId: cuidSchema }),
676
686
  body: z.object({
677
687
  name: applicationNameSchema.optional(),
678
688
  status: applicationStatusSchema.exclude(["deleted"]).optional()
679
689
  }).refine((data) => data.name !== void 0 || data.status !== void 0, { message: "At least one field must be provided" })
680
690
  };
681
- const response$16 = z.object({ data: z.object({ application: applicationSchema }) });
691
+ const response$15 = z.object({ data: z.object({ application: applicationSchema }) });
682
692
 
683
693
  //#endregion
684
694
  //#region ../models/src/domain/secret.ts
@@ -700,28 +710,28 @@ const secretSchema = z.object({
700
710
 
701
711
  //#endregion
702
712
  //#region ../models/src/api/env/secrets/create.ts
703
- const request$15 = { body: z.object({
713
+ const request$14 = { body: z.object({
704
714
  applicationId: cuidSchema,
705
715
  name: secretNameSchema,
706
716
  value: secretValueSchema
707
717
  }) };
708
- const response$15 = z.object({ data: z.object({ secret: secretMetadataSchema }) });
718
+ const response$14 = z.object({ data: z.object({ secret: secretMetadataSchema }) });
709
719
 
710
720
  //#endregion
711
721
  //#region ../models/src/api/env/secrets/getAll.ts
712
- const request$14 = { query: z.object({ applicationId: cuidSchema.optional() }) };
713
- const response$14 = z.object({ data: z.object({ secrets: z.array(secretMetadataSchema) }) });
722
+ const request$13 = { query: z.object({ applicationId: cuidSchema.optional() }) };
723
+ const response$13 = z.object({ data: z.object({ secrets: z.array(secretMetadataSchema) }) });
714
724
 
715
725
  //#endregion
716
726
  //#region ../models/src/api/env/secrets/update.ts
717
- const request$13 = {
727
+ const request$12 = {
718
728
  params: z.object({ name: z.string().min(1) }),
719
729
  body: z.object({
720
730
  applicationId: cuidSchema,
721
731
  value: secretValueSchema
722
732
  })
723
733
  };
724
- const response$13 = z.object({ data: z.object({ secret: secretMetadataSchema }) });
734
+ const response$12 = z.object({ data: z.object({ secret: secretMetadataSchema }) });
725
735
 
726
736
  //#endregion
727
737
  //#region ../models/src/domain/variable.ts
@@ -745,28 +755,28 @@ const variableResponseSchema = z.object({
745
755
 
746
756
  //#endregion
747
757
  //#region ../models/src/api/env/variables/create.ts
748
- const request$12 = { body: z.object({
758
+ const request$11 = { body: z.object({
749
759
  applicationId: cuidSchema,
750
760
  name: variableNameSchema,
751
761
  value: variableValueSchema
752
762
  }) };
753
- const response$12 = z.object({ data: z.object({ variable: variableResponseSchema }) });
763
+ const response$11 = z.object({ data: z.object({ variable: variableResponseSchema }) });
754
764
 
755
765
  //#endregion
756
766
  //#region ../models/src/api/env/variables/getAll.ts
757
- const request$11 = { query: z.object({ applicationId: cuidSchema }) };
758
- const response$11 = z.object({ data: z.object({ variables: z.array(variableResponseSchema) }) });
767
+ const request$10 = { query: z.object({ applicationId: cuidSchema }) };
768
+ const response$10 = z.object({ data: z.object({ variables: z.array(variableResponseSchema) }) });
759
769
 
760
770
  //#endregion
761
771
  //#region ../models/src/api/env/variables/update.ts
762
- const request$10 = {
772
+ const request$9 = {
763
773
  params: z.object({ name: z.string().min(1) }),
764
774
  body: z.object({
765
775
  applicationId: cuidSchema,
766
776
  value: variableValueSchema
767
777
  })
768
778
  };
769
- const response$10 = z.object({ data: z.object({ variable: variableResponseSchema }) });
779
+ const response$9 = z.object({ data: z.object({ variable: variableResponseSchema }) });
770
780
 
771
781
  //#endregion
772
782
  //#region ../models/src/domain/expertScope.ts
@@ -776,7 +786,7 @@ const expertScopeSchema = z.object({
776
786
  organizationId: cuidSchema,
777
787
  expertDraftScopeId: cuidSchema,
778
788
  published: z.boolean(),
779
- publishedAt: datetimeSchema.optional(),
789
+ publishedAt: datetimeSchema.nullable(),
780
790
  category: expertCategoryFieldSchema,
781
791
  totalRuns: z.number().int().min(0),
782
792
  totalJobs: z.number().int().min(0),
@@ -839,18 +849,18 @@ const skillNameSchema = z.string().min(1).max(maxSkillNameLength).regex(packageW
839
849
  const mcpStdioSkillCommandSchema = z.enum(["npx", "uvx"]);
840
850
  const mcpStdioSkillSchema = z.object({
841
851
  type: z.literal("mcpStdioSkill"),
842
- name: z.string(),
852
+ name: z.string().min(1),
843
853
  description: z.string().min(1).max(maxSkillDescriptionLength),
844
854
  rule: z.string().min(1).max(maxSkillRuleLength).optional(),
845
855
  pick: z.array(z.string().min(1).max(maxSkillToolNameLength)).max(maxSkillPickOmitItems).optional().default([]),
846
856
  omit: z.array(z.string().min(1).max(maxSkillToolNameLength)).max(maxSkillPickOmitItems).optional().default([]),
847
857
  command: mcpStdioSkillCommandSchema,
848
858
  packageName: z.string().min(1).max(maxSkillNameLength).regex(packageWithVersionRegex),
849
- requiredEnv: z.array(z.string().min(1).max(maxEnvNameLength).regex(envNameRegex)).min(0).max(maxSkillRequiredEnvItems).optional()
859
+ requiredEnv: z.array(z.string().min(1).max(maxEnvNameLength).regex(envNameRegex)).max(maxSkillRequiredEnvItems).optional().default([])
850
860
  });
851
861
  const mcpSseSkillSchema = z.object({
852
862
  type: z.literal("mcpSseSkill"),
853
- name: z.string(),
863
+ name: z.string().min(1),
854
864
  description: z.string().min(1).max(maxSkillDescriptionLength),
855
865
  rule: z.string().min(1).max(maxSkillRuleLength).optional(),
856
866
  pick: z.array(z.string().min(1).max(maxSkillToolNameLength)).max(maxSkillPickOmitItems).optional().default([]),
@@ -859,7 +869,7 @@ const mcpSseSkillSchema = z.object({
859
869
  });
860
870
  const interactiveSkillSchema = z.object({
861
871
  type: z.literal("interactiveSkill"),
862
- name: z.string(),
872
+ name: z.string().min(1),
863
873
  description: z.string().min(1).max(maxSkillDescriptionLength),
864
874
  rule: z.string().min(1).max(maxSkillRuleLength).optional(),
865
875
  tools: z.record(z.string().min(1).max(maxSkillToolNameLength).regex(urlSafeRegex), z.object({
@@ -883,7 +893,8 @@ const expertSchema = z.object({
883
893
  instruction: z.string().min(1).max(maxExpertInstructionLength),
884
894
  skills: z.record(skillNameSchema, skillSchema).optional().default({}),
885
895
  delegates: z.array(expertKeyFieldSchema).min(0).max(maxExpertDelegateItems).optional().default([]),
886
- tags: z.array(expertTagFieldSchema).min(0).max(maxExpertTagItems).optional().default([])
896
+ tags: z.array(expertTagFieldSchema).min(0).max(maxExpertTagItems).optional().default([]),
897
+ minRuntimeVersion: runtimeVersionSchema.optional()
887
898
  });
888
899
  const expertMetadataSchema = z.object({
889
900
  scope: expertScopeSchema,
@@ -896,7 +907,7 @@ const expertWithMetadataSchema = expertSchema.extend({
896
907
 
897
908
  //#endregion
898
909
  //#region ../models/src/api/experts/getAll.ts
899
- const request$9 = { query: z.object({
910
+ const request$8 = { query: z.object({
900
911
  filter: z.string().describe("Filter by scope name (partial match)").optional(),
901
912
  category: z.enum([
902
913
  "general",
@@ -910,114 +921,11 @@ const request$9 = { query: z.object({
910
921
  take: z.coerce.number().min(1).max(100).default(20),
911
922
  skip: z.coerce.number().min(0).default(0)
912
923
  }) };
913
- const response$9 = z.object({
924
+ const response$8 = z.object({
914
925
  data: z.object({ experts: z.array(expertScopeSchema.extend({ currentVersion: expertVersionSchema.nullable() })) }),
915
926
  meta: paginationMeta
916
927
  });
917
928
 
918
- //#endregion
919
- //#region ../models/src/domain/checkpoint.ts
920
- const delegationTargetSchema = z.object({
921
- expert: expertSchema,
922
- toolCallId: z.string().min(1).max(maxCheckpointToolCallIdLength),
923
- toolName: z.string().min(1).max(maxSkillToolNameLength),
924
- query: z.string()
925
- });
926
- /**
927
- * API Checkpoint schema - extended checkpoint format for API responses.
928
- * Includes additional fields computed from runtime checkpoint and step data:
929
- * - activities: computed via getActivities() from @perstack/core
930
- * - inputMessages, newMessages, toolCalls, toolResults: step-related data
931
- * - expert: full Expert type (with instruction, skills, etc.)
932
- * - startedAt/finishedAt: ISO string format (runtime uses Unix timestamps)
933
- */
934
- const apiCheckpointSchema = z.object({
935
- type: z.literal("checkpoint"),
936
- id: cuidSchema,
937
- jobId: cuidSchema,
938
- runId: cuidSchema,
939
- activities: z.array(activityOrGroupSchema),
940
- stepNumber: z.number().int().min(1),
941
- status: z.enum([
942
- "init",
943
- "proceeding",
944
- "completed",
945
- "stoppedByInteractiveTool",
946
- "stoppedByDelegate",
947
- "stoppedByExceededMaxSteps",
948
- "stoppedByError"
949
- ]),
950
- expert: expertSchema,
951
- delegateTo: z.array(delegationTargetSchema).optional(),
952
- delegatedBy: z.object({
953
- expert: expertSchema,
954
- toolCallId: z.string().min(1).max(maxCheckpointToolCallIdLength),
955
- toolName: z.string().min(1).max(maxSkillToolNameLength),
956
- checkpointId: cuidSchema,
957
- runId: cuidSchema
958
- }).optional(),
959
- inputMessages: z.array(z.union([
960
- instructionMessageSchema,
961
- userMessageSchema,
962
- toolMessageSchema
963
- ])).optional(),
964
- messages: z.array(messageSchema),
965
- newMessages: z.array(messageSchema),
966
- toolCalls: z.array(toolCallSchema).optional(),
967
- toolResults: z.array(toolResultSchema).optional(),
968
- pendingToolCalls: z.array(toolCallSchema).optional(),
969
- partialToolResults: z.array(toolResultSchema).optional(),
970
- usage: usageSchema,
971
- contextWindow: z.number().int().min(0).optional(),
972
- contextWindowUsage: z.number().int().min(0).optional(),
973
- error: z.object({
974
- name: z.string(),
975
- message: z.string(),
976
- statusCode: z.number().optional(),
977
- isRetryable: z.boolean()
978
- }).optional(),
979
- retryCount: z.number().optional(),
980
- startedAt: datetimeSchema,
981
- finishedAt: datetimeSchema.optional()
982
- });
983
-
984
- //#endregion
985
- //#region ../models/src/api/jobs/checkpoints/create.ts
986
- /**
987
- * Request checkpoint schema - `id` and `runId` are omitted because:
988
- * - `id` is server-generated (CUID)
989
- * - `runId` is optional in request, server will use job's run ID
990
- */
991
- const requestCheckpointSchema = perstackCheckpointSchema.omit({
992
- id: true,
993
- runId: true
994
- }).extend({ runId: z.string().optional() });
995
- const request$8 = {
996
- params: z.object({ jobId: cuidSchema }),
997
- body: z.object({
998
- checkpoint: requestCheckpointSchema,
999
- step: stepSchema
1000
- })
1001
- };
1002
- const response$8 = z.object({ data: z.object({ checkpoint: apiCheckpointSchema }) });
1003
-
1004
- //#endregion
1005
- //#region ../models/src/api/jobs/checkpoints/getAll.ts
1006
- const request$7 = {
1007
- params: z.object({ jobId: cuidSchema }),
1008
- query: z.object({
1009
- filter: z.string().min(1).max(256).optional(),
1010
- sort: z.enum(["createdAt", "updatedAt"]).optional(),
1011
- order: z.enum(["asc", "desc"]).optional(),
1012
- take: z.coerce.number().min(1).max(100).default(20),
1013
- skip: z.coerce.number().min(0).default(0)
1014
- })
1015
- };
1016
- const response$7 = z.object({
1017
- data: z.object({ checkpoints: z.array(apiCheckpointSchema) }),
1018
- meta: paginationMeta
1019
- });
1020
-
1021
929
  //#endregion
1022
930
  //#region ../support-models/src/index.ts
1023
931
  const anthropicSupportModels = [
@@ -1176,7 +1084,7 @@ const reasoningBudgetSchema = z.union([z.enum([
1176
1084
  "low",
1177
1085
  "medium",
1178
1086
  "high"
1179
- ]), z.number().min(0)]);
1087
+ ]), z.number().int().min(0)]);
1180
1088
  const jobStatusSchema = z.enum([
1181
1089
  "queued",
1182
1090
  "processing",
@@ -1192,8 +1100,8 @@ const jobStatusSchema = z.enum([
1192
1100
  const modelNames = getSupportModelNames();
1193
1101
  const firstModel = modelNames[0];
1194
1102
  if (firstModel === void 0) throw new Error("No support models available");
1195
- const modelEnum = z.enum([firstModel, ...modelNames.slice(1)]);
1196
- const jobSchema = z.object({
1103
+ const jobModelSchema = z.enum([firstModel, ...modelNames.slice(1)]);
1104
+ const jobBaseSchema = z.object({
1197
1105
  type: z.literal("job"),
1198
1106
  id: cuidSchema,
1199
1107
  organizationId: cuidSchema,
@@ -1201,37 +1109,46 @@ const jobSchema = z.object({
1201
1109
  createdAt: datetimeSchema,
1202
1110
  updatedAt: datetimeSchema,
1203
1111
  status: jobStatusSchema,
1112
+ currentExecutionId: cuidSchema.optional(),
1204
1113
  coordinatorExpertKey: expertKeyFieldSchema,
1205
1114
  query: z.string().min(1).max(maxExpertJobQueryLength).optional(),
1206
1115
  expert: expertWithMetadataSchema,
1207
- expertDraftRefId: cuidSchema.optional(),
1208
1116
  provider: providerSchema,
1209
- model: modelEnum,
1117
+ model: jobModelSchema,
1210
1118
  reasoningBudget: reasoningBudgetSchema,
1119
+ runtimeVersion: runtimeVersionSchema,
1211
1120
  maxSteps: z.number().int().min(1),
1212
1121
  maxRetries: z.number().int().min(0),
1213
1122
  currentStep: z.number().int().min(0),
1214
1123
  totalSteps: z.number().int().min(0),
1215
- totalDuration: z.number().min(0),
1124
+ totalDuration: z.number().int().min(0),
1216
1125
  usage: usageSchema,
1217
1126
  lastActivity: activityOrGroupSchema.nullable().optional()
1218
1127
  });
1128
+ const publishedJobSchema = jobBaseSchema.extend({
1129
+ expertVersionId: cuidSchema,
1130
+ expertDraftRefId: z.undefined()
1131
+ });
1132
+ const draftJobSchema = jobBaseSchema.extend({
1133
+ expertVersionId: z.undefined(),
1134
+ expertDraftRefId: cuidSchema
1135
+ });
1136
+ const jobSchema = z.union([publishedJobSchema, draftJobSchema]);
1219
1137
 
1220
1138
  //#endregion
1221
1139
  //#region ../models/src/api/jobs/continue.ts
1222
- const request$6 = {
1140
+ const request$7 = {
1223
1141
  params: z.object({ jobId: cuidSchema }),
1224
1142
  body: z.object({
1225
1143
  query: z.string().min(1).max(maxExpertJobQueryLength),
1226
- interactiveToolCallResult: z.boolean().optional(),
1227
1144
  provider: providerSchema.optional(),
1228
- model: jobSchema.shape.model.optional(),
1145
+ model: jobModelSchema.optional(),
1229
1146
  reasoningBudget: reasoningBudgetSchema.optional(),
1230
1147
  maxSteps: z.coerce.number().optional(),
1231
1148
  maxRetries: z.coerce.number().optional()
1232
1149
  })
1233
1150
  };
1234
- const response$6 = z.object({ data: z.object({ job: jobSchema }) });
1151
+ const response$7 = z.object({ data: z.object({ job: jobSchema }) });
1235
1152
 
1236
1153
  //#endregion
1237
1154
  //#region ../models/src/api/jobs/create.ts
@@ -1239,12 +1156,12 @@ const baseBodySchema = z.object({
1239
1156
  applicationId: cuidSchema.describe("Application ID to create the job in"),
1240
1157
  query: z.string().min(1).max(maxExpertJobQueryLength),
1241
1158
  provider: providerSchema,
1242
- model: jobSchema.shape.model.optional(),
1159
+ model: jobModelSchema.optional(),
1243
1160
  reasoningBudget: reasoningBudgetSchema.optional(),
1244
1161
  maxSteps: z.coerce.number().optional(),
1245
1162
  maxRetries: z.coerce.number().optional()
1246
1163
  });
1247
- const request$5 = { body: baseBodySchema.extend({
1164
+ const request$6 = { body: baseBodySchema.extend({
1248
1165
  expertKey: expertKeyFieldSchema.optional(),
1249
1166
  draftRefId: cuidSchema.describe("Draft ref ID to run the job with").optional()
1250
1167
  }).refine((data) => {
@@ -1252,11 +1169,11 @@ const request$5 = { body: baseBodySchema.extend({
1252
1169
  const hasDraftRefId = data.draftRefId !== void 0;
1253
1170
  return hasExpertKey && !hasDraftRefId || !hasExpertKey && hasDraftRefId;
1254
1171
  }, { message: "Either expertKey or draftRefId must be provided, but not both" }) };
1255
- const response$5 = z.object({ data: z.object({ job: jobSchema }) });
1172
+ const response$6 = z.object({ data: z.object({ job: jobSchema }) });
1256
1173
 
1257
1174
  //#endregion
1258
1175
  //#region ../models/src/api/jobs/getAll.ts
1259
- const request$4 = { query: z.object({
1176
+ const request$5 = { query: z.object({
1260
1177
  sort: z.enum(["createdAt", "updatedAt"]).optional(),
1261
1178
  order: z.enum(["asc", "desc"]).optional(),
1262
1179
  take: z.coerce.number().min(1).max(100).default(20),
@@ -1267,18 +1184,139 @@ const request$4 = { query: z.object({
1267
1184
  statuses: z.preprocess((val) => typeof val === "string" ? val.split(",") : val, z.array(jobStatusSchema).optional()),
1268
1185
  expertKeyFilter: z.string().max(100).optional()
1269
1186
  }) };
1270
- const response$4 = z.object({
1187
+ const response$5 = z.object({
1271
1188
  data: z.object({ jobs: z.array(jobSchema) }),
1272
1189
  meta: paginationMeta
1273
1190
  });
1274
1191
 
1275
1192
  //#endregion
1276
- //#region ../models/src/api/jobs/update.ts
1193
+ //#region ../models/src/domain/checkpoint.ts
1194
+ const delegationTargetSchema = z.object({
1195
+ expert: expertSchema,
1196
+ toolCallId: z.string().min(1).max(maxCheckpointToolCallIdLength),
1197
+ toolName: z.string().min(1).max(maxSkillToolNameLength),
1198
+ query: z.string().min(1)
1199
+ });
1200
+ /**
1201
+ * API Checkpoint schema - extended checkpoint format for API responses.
1202
+ * Includes additional fields computed from runtime checkpoint and step data:
1203
+ * - activities: computed via getActivities() from @perstack/core
1204
+ * - inputMessages, newMessages, toolCalls, toolResults: step-related data
1205
+ * - expert: full Expert type (with instruction, skills, etc.)
1206
+ * - startedAt/finishedAt: ISO string format (runtime uses Unix timestamps)
1207
+ */
1208
+ const apiCheckpointSchema = z.object({
1209
+ type: z.literal("checkpoint"),
1210
+ id: cuidSchema,
1211
+ jobId: cuidSchema,
1212
+ runId: cuidSchema,
1213
+ activities: z.array(activityOrGroupSchema),
1214
+ stepNumber: z.number().int().min(1),
1215
+ status: z.enum([
1216
+ "init",
1217
+ "proceeding",
1218
+ "completed",
1219
+ "stoppedByInteractiveTool",
1220
+ "stoppedByDelegate",
1221
+ "stoppedByExceededMaxSteps",
1222
+ "stoppedByError"
1223
+ ]),
1224
+ expert: expertSchema,
1225
+ delegateTo: z.array(delegationTargetSchema).optional(),
1226
+ delegatedBy: z.object({
1227
+ expert: expertSchema,
1228
+ toolCallId: z.string().min(1).max(maxCheckpointToolCallIdLength),
1229
+ toolName: z.string().min(1).max(maxSkillToolNameLength),
1230
+ checkpointId: cuidSchema,
1231
+ runId: cuidSchema
1232
+ }).optional(),
1233
+ inputMessages: z.array(z.union([
1234
+ instructionMessageSchema,
1235
+ userMessageSchema,
1236
+ toolMessageSchema
1237
+ ])).optional(),
1238
+ messages: z.array(messageSchema),
1239
+ newMessages: z.array(messageSchema),
1240
+ toolCalls: z.array(toolCallSchema).optional(),
1241
+ toolResults: z.array(toolResultSchema).optional(),
1242
+ pendingToolCalls: z.array(toolCallSchema).optional(),
1243
+ partialToolResults: z.array(toolResultSchema).optional(),
1244
+ usage: usageSchema,
1245
+ contextWindow: z.number().int().min(0).optional(),
1246
+ contextWindowUsage: z.number().int().min(0).optional(),
1247
+ error: z.object({
1248
+ name: z.string().min(1),
1249
+ message: z.string().min(1),
1250
+ statusCode: z.number().int().min(100).max(599).optional(),
1251
+ isRetryable: z.boolean()
1252
+ }).optional(),
1253
+ retryCount: z.number().int().min(0).optional(),
1254
+ startedAt: datetimeSchema,
1255
+ finishedAt: datetimeSchema.optional()
1256
+ });
1257
+
1258
+ //#endregion
1259
+ //#region ../models/src/api/jobs/runs/checkpoints/getAll.ts
1260
+ const request$4 = {
1261
+ params: z.object({
1262
+ jobId: cuidSchema,
1263
+ runId: cuidSchema
1264
+ }),
1265
+ query: z.object({
1266
+ filter: z.string().min(1).max(256).optional(),
1267
+ sort: z.enum(["createdAt", "updatedAt"]).optional(),
1268
+ order: z.enum(["asc", "desc"]).optional(),
1269
+ take: z.coerce.number().min(1).max(100).default(20),
1270
+ skip: z.coerce.number().min(0).default(0)
1271
+ })
1272
+ };
1273
+ const response$4 = z.object({
1274
+ data: z.object({ checkpoints: z.array(apiCheckpointSchema) }),
1275
+ meta: paginationMeta
1276
+ });
1277
+
1278
+ //#endregion
1279
+ //#region ../models/src/domain/run.ts
1280
+ const runStatusSchema = z.enum([
1281
+ "queued",
1282
+ "processing",
1283
+ "completed",
1284
+ "stoppedByInteractiveTool",
1285
+ "stoppedByDelegate",
1286
+ "stoppedByExceededMaxSteps",
1287
+ "stoppedByError"
1288
+ ]);
1289
+ const runSchema = z.object({
1290
+ type: z.literal("run"),
1291
+ id: cuidSchema,
1292
+ jobId: cuidSchema,
1293
+ executionId: cuidSchema.optional(),
1294
+ parentRunId: cuidSchema.optional(),
1295
+ organizationId: cuidSchema,
1296
+ createdAt: datetimeSchema,
1297
+ updatedAt: datetimeSchema,
1298
+ status: runStatusSchema,
1299
+ expertKey: expertKeyFieldSchema,
1300
+ expert: expertWithMetadataSchema,
1301
+ stepNumber: z.number().int().min(0),
1302
+ usage: usageSchema
1303
+ });
1304
+
1305
+ //#endregion
1306
+ //#region ../models/src/api/jobs/runs/getAll.ts
1277
1307
  const request$3 = {
1278
1308
  params: z.object({ jobId: cuidSchema }),
1279
- body: z.object({ status: jobStatusSchema })
1309
+ query: z.object({
1310
+ sort: z.enum(["createdAt", "updatedAt"]).optional(),
1311
+ order: z.enum(["asc", "desc"]).optional(),
1312
+ take: z.coerce.number().min(1).max(100).default(20),
1313
+ skip: z.coerce.number().min(0).default(0)
1314
+ })
1280
1315
  };
1281
- const response$3 = z.object({ data: z.object({ job: jobSchema }) });
1316
+ const response$3 = z.object({
1317
+ data: z.object({ runs: z.array(runSchema) }),
1318
+ meta: paginationMeta
1319
+ });
1282
1320
 
1283
1321
  //#endregion
1284
1322
  //#region ../models/src/domain/providerSetting.ts
@@ -1295,9 +1333,9 @@ const googleProviderSettingsSchema = z.object({
1295
1333
  const openaiProviderSettingsSchema = z.object({
1296
1334
  baseUrl: baseUrlSchema,
1297
1335
  headers: headersSchema,
1298
- organization: z.string().optional(),
1299
- project: z.string().optional(),
1300
- name: z.string().optional()
1336
+ organization: z.string().min(1).optional(),
1337
+ project: z.string().min(1).optional(),
1338
+ name: z.string().min(1).optional()
1301
1339
  });
1302
1340
  const deepseekProviderSettingsSchema = z.object({
1303
1341
  baseUrl: baseUrlSchema,
@@ -1306,16 +1344,16 @@ const deepseekProviderSettingsSchema = z.object({
1306
1344
  const azureOpenaiProviderSettingsSchema = z.object({
1307
1345
  baseUrl: baseUrlSchema,
1308
1346
  headers: headersSchema,
1309
- resourceName: z.string().optional(),
1310
- apiVersion: z.string().optional(),
1347
+ resourceName: z.string().min(1).optional(),
1348
+ apiVersion: z.string().min(1).optional(),
1311
1349
  useDeploymentBasedUrls: z.boolean().optional()
1312
1350
  });
1313
- const amazonBedrockProviderSettingsSchema = z.object({ region: z.string().optional() });
1351
+ const amazonBedrockProviderSettingsSchema = z.object({ region: z.string().min(1).optional() });
1314
1352
  const googleVertexProviderSettingsSchema = z.object({
1315
1353
  baseUrl: baseUrlSchema,
1316
1354
  headers: headersSchema,
1317
- project: z.string().optional(),
1318
- location: z.string().optional()
1355
+ project: z.string().min(1).optional(),
1356
+ location: z.string().min(1).optional()
1319
1357
  });
1320
1358
  const providerSettingsSchema = z.union([
1321
1359
  anthropicProviderSettingsSchema,
@@ -1390,13 +1428,82 @@ const request = {
1390
1428
  const response = z.object({ data: z.object({ providerSetting: providerSettingResponseSchema }) });
1391
1429
 
1392
1430
  //#endregion
1393
- //#region src/endpoints/applications.ts
1394
- const BASE_PATH$5 = "/api/v1/applications";
1395
- function createApplicationsApi(fetcher) {
1431
+ //#region src/endpoints/jobs-runs-checkpoints.ts
1432
+ function createRunCheckpointsApi(fetcher, basePath) {
1433
+ return {
1434
+ async list(jobId, runId, params, options) {
1435
+ if (params) {
1436
+ const result = request$4.query.safeParse(params);
1437
+ if (!result.success) return {
1438
+ ok: false,
1439
+ error: createValidationError(result.error)
1440
+ };
1441
+ }
1442
+ const queryString = buildQueryString(params);
1443
+ return fetcher.get(`${basePath}/${jobId}/runs/${runId}/checkpoints${queryString}`, options);
1444
+ },
1445
+ async get(jobId, runId, checkpointId, options) {
1446
+ return fetcher.get(`${basePath}/${jobId}/runs/${runId}/checkpoints/${checkpointId}`, options);
1447
+ }
1448
+ };
1449
+ }
1450
+
1451
+ //#endregion
1452
+ //#region src/endpoints/jobs-runs.ts
1453
+ function createRunsApi(fetcher, basePath) {
1454
+ return {
1455
+ async list(jobId, params, options) {
1456
+ if (params) {
1457
+ const result = request$3.query.safeParse(params);
1458
+ if (!result.success) return {
1459
+ ok: false,
1460
+ error: createValidationError(result.error)
1461
+ };
1462
+ }
1463
+ const queryString = buildQueryString(params);
1464
+ return fetcher.get(`${basePath}/${jobId}/runs${queryString}`, options);
1465
+ },
1466
+ async get(jobId, runId, options) {
1467
+ return fetcher.get(`${basePath}/${jobId}/runs/${runId}`, options);
1468
+ },
1469
+ checkpoints: createRunCheckpointsApi(fetcher, basePath)
1470
+ };
1471
+ }
1472
+
1473
+ //#endregion
1474
+ //#region src/endpoints/jobs.ts
1475
+ const BASE_PATH$5 = "/api/v1/jobs";
1476
+ /**
1477
+ * Error thrown when stream ends abnormally.
1478
+ */
1479
+ var StreamError = class extends Error {
1480
+ constructor(type, jobId, message) {
1481
+ super(message ?? `Stream error: ${type}`);
1482
+ this.type = type;
1483
+ this.jobId = jobId;
1484
+ this.name = "StreamError";
1485
+ }
1486
+ };
1487
+ /**
1488
+ * Error thrown when stream connection or reading fails.
1489
+ */
1490
+ var StreamConnectionError = class extends Error {
1491
+ constructor(message) {
1492
+ super(message);
1493
+ this.name = "StreamConnectionError";
1494
+ }
1495
+ };
1496
+ function isErrorEventData(data) {
1497
+ return typeof data === "object" && data !== null && "type" in data && typeof data.type === "string" && "jobId" in data && typeof data.jobId === "string";
1498
+ }
1499
+ function isCompleteEventData(data) {
1500
+ return typeof data === "object" && data !== null && "status" in data && typeof data.status === "string" && "jobId" in data && typeof data.jobId === "string";
1501
+ }
1502
+ function createJobsApi(fetcher) {
1396
1503
  return {
1397
1504
  async list(params, options) {
1398
1505
  if (params) {
1399
- const result = request$17.query.safeParse(params);
1506
+ const result = request$5.query.safeParse(params);
1400
1507
  if (!result.success) return {
1401
1508
  ok: false,
1402
1509
  error: createValidationError(result.error)
@@ -1408,110 +1515,166 @@ function createApplicationsApi(fetcher) {
1408
1515
  async get(id, options) {
1409
1516
  return fetcher.get(`${BASE_PATH$5}/${id}`, options);
1410
1517
  },
1411
- async create(input, options) {
1412
- const result = request$18.body.safeParse(input);
1518
+ async start(input, options) {
1519
+ const result = request$6.body.safeParse(input);
1413
1520
  if (!result.success) return {
1414
1521
  ok: false,
1415
1522
  error: createValidationError(result.error)
1416
1523
  };
1417
1524
  return fetcher.post(BASE_PATH$5, input, options);
1418
1525
  },
1526
+ async continue(id, input, options) {
1527
+ const result = request$7.body.safeParse(input);
1528
+ if (!result.success) return {
1529
+ ok: false,
1530
+ error: createValidationError(result.error)
1531
+ };
1532
+ return fetcher.post(`${BASE_PATH$5}/${id}/continue`, input, options);
1533
+ },
1534
+ async cancel(id, options) {
1535
+ return fetcher.post(`${BASE_PATH$5}/${id}/cancel`, {}, options);
1536
+ },
1537
+ async *stream(id, options) {
1538
+ const result = await fetcher.getStream(`${BASE_PATH$5}/${id}/stream`, options);
1539
+ if (!result.ok) throw new StreamConnectionError(result.error.message);
1540
+ const reader = result.data.getReader();
1541
+ try {
1542
+ for await (const sseEvent of parseSSEEvents(reader)) if (sseEvent.event === "message") yield sseEvent.data;
1543
+ else if (sseEvent.event === "error" && isErrorEventData(sseEvent.data)) throw new StreamError(sseEvent.data.type, sseEvent.data.jobId, sseEvent.data.message);
1544
+ else if (sseEvent.event === "complete" && isCompleteEventData(sseEvent.data)) return;
1545
+ } catch (error) {
1546
+ if (error instanceof StreamError || error instanceof StreamConnectionError) throw error;
1547
+ if (error instanceof DOMException && error.name === "AbortError") throw error;
1548
+ throw new StreamConnectionError(error instanceof Error ? error.message : "Stream read error");
1549
+ }
1550
+ },
1551
+ runs: createRunsApi(fetcher, BASE_PATH$5)
1552
+ };
1553
+ }
1554
+
1555
+ //#endregion
1556
+ //#region src/endpoints/applications.ts
1557
+ const BASE_PATH$4 = "/api/v1/applications";
1558
+ function createApplicationsApi(fetcher) {
1559
+ return {
1560
+ async list(params, options) {
1561
+ if (params) {
1562
+ const result = request$16.query.safeParse(params);
1563
+ if (!result.success) return {
1564
+ ok: false,
1565
+ error: createValidationError(result.error)
1566
+ };
1567
+ }
1568
+ const queryString = buildQueryString(params);
1569
+ return fetcher.get(`${BASE_PATH$4}${queryString}`, options);
1570
+ },
1571
+ async get(id, options) {
1572
+ return fetcher.get(`${BASE_PATH$4}/${id}`, options);
1573
+ },
1574
+ async create(input, options) {
1575
+ const result = request$17.body.safeParse(input);
1576
+ if (!result.success) return {
1577
+ ok: false,
1578
+ error: createValidationError(result.error)
1579
+ };
1580
+ return fetcher.post(BASE_PATH$4, input, options);
1581
+ },
1419
1582
  async update(id, input, options) {
1420
- const result = request$16.body.safeParse(input);
1583
+ const result = request$15.body.safeParse(input);
1421
1584
  if (!result.success) return {
1422
1585
  ok: false,
1423
1586
  error: createValidationError(result.error)
1424
1587
  };
1425
- return fetcher.post(`${BASE_PATH$5}/${id}`, input, options);
1588
+ return fetcher.post(`${BASE_PATH$4}/${id}`, input, options);
1426
1589
  },
1427
1590
  async delete(id, options) {
1428
- return fetcher.delete(`${BASE_PATH$5}/${id}`, options);
1591
+ return fetcher.delete(`${BASE_PATH$4}/${id}`, options);
1429
1592
  }
1430
1593
  };
1431
1594
  }
1432
1595
 
1433
1596
  //#endregion
1434
1597
  //#region src/endpoints/env-secrets.ts
1435
- const BASE_PATH$4 = "/api/v1/env/secrets";
1598
+ const BASE_PATH$3 = "/api/v1/env/secrets";
1436
1599
  function createSecretsApi(fetcher) {
1437
1600
  return {
1438
1601
  async list(params, options) {
1439
1602
  if (params) {
1440
- const result = request$14.query.safeParse(params);
1603
+ const result = request$13.query.safeParse(params);
1441
1604
  if (!result.success) return {
1442
1605
  ok: false,
1443
1606
  error: createValidationError(result.error)
1444
1607
  };
1445
1608
  }
1446
1609
  const queryString = buildQueryString(params);
1447
- return fetcher.get(`${BASE_PATH$4}${queryString}`, options);
1610
+ return fetcher.get(`${BASE_PATH$3}${queryString}`, options);
1448
1611
  },
1449
1612
  async get(name, options) {
1450
1613
  const encodedName = encodeURIComponent(name);
1451
- return fetcher.get(`${BASE_PATH$4}/${encodedName}`, options);
1614
+ return fetcher.get(`${BASE_PATH$3}/${encodedName}`, options);
1452
1615
  },
1453
1616
  async create(input, options) {
1454
- const result = request$15.body.safeParse(input);
1617
+ const result = request$14.body.safeParse(input);
1455
1618
  if (!result.success) return {
1456
1619
  ok: false,
1457
1620
  error: createValidationError(result.error)
1458
1621
  };
1459
- return fetcher.post(BASE_PATH$4, input, options);
1622
+ return fetcher.post(BASE_PATH$3, input, options);
1460
1623
  },
1461
1624
  async update(name, input, options) {
1462
- const result = request$13.body.safeParse(input);
1625
+ const result = request$12.body.safeParse(input);
1463
1626
  if (!result.success) return {
1464
1627
  ok: false,
1465
1628
  error: createValidationError(result.error)
1466
1629
  };
1467
1630
  const encodedName = encodeURIComponent(name);
1468
- return fetcher.put(`${BASE_PATH$4}/${encodedName}`, input, options);
1631
+ return fetcher.put(`${BASE_PATH$3}/${encodedName}`, input, options);
1469
1632
  },
1470
1633
  async delete(name, options) {
1471
1634
  const encodedName = encodeURIComponent(name);
1472
- return fetcher.deleteNoContent(`${BASE_PATH$4}/${encodedName}`, options);
1635
+ return fetcher.deleteNoContent(`${BASE_PATH$3}/${encodedName}`, options);
1473
1636
  }
1474
1637
  };
1475
1638
  }
1476
1639
 
1477
1640
  //#endregion
1478
1641
  //#region src/endpoints/env-variables.ts
1479
- const BASE_PATH$3 = "/api/v1/env/variables";
1642
+ const BASE_PATH$2 = "/api/v1/env/variables";
1480
1643
  function createVariablesApi(fetcher) {
1481
1644
  return {
1482
1645
  async list(params, options) {
1483
- const result = request$11.query.safeParse(params);
1646
+ const result = request$10.query.safeParse(params);
1484
1647
  if (!result.success) return {
1485
1648
  ok: false,
1486
1649
  error: createValidationError(result.error)
1487
1650
  };
1488
1651
  const queryString = buildQueryString(params);
1489
- return fetcher.get(`${BASE_PATH$3}${queryString}`, options);
1652
+ return fetcher.get(`${BASE_PATH$2}${queryString}`, options);
1490
1653
  },
1491
1654
  async get(name, options) {
1492
1655
  const encodedName = encodeURIComponent(name);
1493
- return fetcher.get(`${BASE_PATH$3}/${encodedName}`, options);
1656
+ return fetcher.get(`${BASE_PATH$2}/${encodedName}`, options);
1494
1657
  },
1495
1658
  async create(input, options) {
1496
- const result = request$12.body.safeParse(input);
1659
+ const result = request$11.body.safeParse(input);
1497
1660
  if (!result.success) return {
1498
1661
  ok: false,
1499
1662
  error: createValidationError(result.error)
1500
1663
  };
1501
- return fetcher.post(BASE_PATH$3, input, options);
1664
+ return fetcher.post(BASE_PATH$2, input, options);
1502
1665
  },
1503
1666
  async update(name, input, options) {
1504
- const result = request$10.body.safeParse(input);
1667
+ const result = request$9.body.safeParse(input);
1505
1668
  if (!result.success) return {
1506
1669
  ok: false,
1507
1670
  error: createValidationError(result.error)
1508
1671
  };
1509
1672
  const encodedName = encodeURIComponent(name);
1510
- return fetcher.put(`${BASE_PATH$3}/${encodedName}`, input, options);
1673
+ return fetcher.put(`${BASE_PATH$2}/${encodedName}`, input, options);
1511
1674
  },
1512
1675
  async delete(name, options) {
1513
1676
  const encodedName = encodeURIComponent(name);
1514
- return fetcher.deleteNoContent(`${BASE_PATH$3}/${encodedName}`, options);
1677
+ return fetcher.deleteNoContent(`${BASE_PATH$2}/${encodedName}`, options);
1515
1678
  }
1516
1679
  };
1517
1680
  }
@@ -1536,198 +1699,44 @@ function createVersionsApi(fetcher, basePath) {
1536
1699
 
1537
1700
  //#endregion
1538
1701
  //#region src/endpoints/experts.ts
1539
- const BASE_PATH$2 = "/api/v1/experts";
1702
+ const BASE_PATH$1 = "/api/v1/experts";
1540
1703
  function createExpertsApi(fetcher) {
1541
1704
  return {
1542
1705
  async list(params, options) {
1543
1706
  if (params) {
1544
- const result = request$9.query.safeParse(params);
1707
+ const result = request$8.query.safeParse(params);
1545
1708
  if (!result.success) return {
1546
1709
  ok: false,
1547
1710
  error: createValidationError(result.error)
1548
1711
  };
1549
1712
  }
1550
1713
  const queryString = buildQueryString(params);
1551
- return fetcher.get(`${BASE_PATH$2}${queryString}`, options);
1714
+ return fetcher.get(`${BASE_PATH$1}${queryString}`, options);
1552
1715
  },
1553
1716
  async get(key, options) {
1554
1717
  const encodedKey = encodeURIComponent(key);
1555
- return fetcher.get(`${BASE_PATH$2}/${encodedKey}`, options);
1718
+ return fetcher.get(`${BASE_PATH$1}/${encodedKey}`, options);
1556
1719
  },
1557
1720
  async getFeatured(options) {
1558
- return fetcher.get(`${BASE_PATH$2}/featured`, options);
1721
+ return fetcher.get(`${BASE_PATH$1}/featured`, options);
1559
1722
  },
1560
1723
  async getMeta(key, options) {
1561
1724
  const encodedKey = encodeURIComponent(key);
1562
- return fetcher.get(`${BASE_PATH$2}/${encodedKey}/meta`, options);
1725
+ return fetcher.get(`${BASE_PATH$1}/${encodedKey}/meta`, options);
1563
1726
  },
1564
1727
  async publish(scopeName, options) {
1565
1728
  const encodedScopeName = encodeURIComponent(scopeName);
1566
- return fetcher.post(`${BASE_PATH$2}/${encodedScopeName}/publish`, {}, options);
1729
+ return fetcher.post(`${BASE_PATH$1}/${encodedScopeName}/publish`, {}, options);
1567
1730
  },
1568
1731
  async unpublish(scopeName, options) {
1569
1732
  const encodedScopeName = encodeURIComponent(scopeName);
1570
- return fetcher.post(`${BASE_PATH$2}/${encodedScopeName}/unpublish`, {}, options);
1733
+ return fetcher.post(`${BASE_PATH$1}/${encodedScopeName}/unpublish`, {}, options);
1571
1734
  },
1572
1735
  async yank(key, options) {
1573
1736
  const encodedKey = encodeURIComponent(key);
1574
- return fetcher.delete(`${BASE_PATH$2}/${encodedKey}`, options);
1575
- },
1576
- versions: createVersionsApi(fetcher, BASE_PATH$2)
1577
- };
1578
- }
1579
-
1580
- //#endregion
1581
- //#region src/endpoints/jobs-checkpoints.ts
1582
- function isErrorEventData(data) {
1583
- return typeof data === "object" && data !== null && "type" in data && typeof data.type === "string" && "jobId" in data && typeof data.jobId === "string";
1584
- }
1585
- function isCompleteEventData(data) {
1586
- return typeof data === "object" && data !== null && "status" in data && typeof data.status === "string" && "jobId" in data && typeof data.jobId === "string";
1587
- }
1588
- function createCheckpointsApi(fetcher, basePath) {
1589
- return {
1590
- async list(jobId, params, options) {
1591
- if (params) {
1592
- const result = request$7.query.safeParse(params);
1593
- if (!result.success) return {
1594
- ok: false,
1595
- error: createValidationError(result.error)
1596
- };
1597
- }
1598
- const queryString = buildQueryString(params);
1599
- return fetcher.get(`${basePath}/${jobId}/checkpoints${queryString}`, options);
1600
- },
1601
- async get(jobId, checkpointId, options) {
1602
- return fetcher.get(`${basePath}/${jobId}/checkpoints/${checkpointId}`, options);
1603
- },
1604
- async create(jobId, input, options) {
1605
- const result = request$8.body.safeParse(input);
1606
- if (!result.success) return {
1607
- ok: false,
1608
- error: createValidationError(result.error)
1609
- };
1610
- return fetcher.post(`${basePath}/${jobId}/checkpoints`, input, options);
1611
- },
1612
- async *stream(jobId, options) {
1613
- const result = await fetcher.getStream(`${basePath}/${jobId}/checkpoints/stream`, options);
1614
- if (!result.ok) {
1615
- yield {
1616
- ok: false,
1617
- error: result.error
1618
- };
1619
- return;
1620
- }
1621
- const reader = result.data.getReader();
1622
- try {
1623
- for await (const checkpoint of parseSSE(reader)) yield {
1624
- ok: true,
1625
- data: checkpoint
1626
- };
1627
- } catch (error) {
1628
- if (error instanceof DOMException && error.name === "AbortError") yield {
1629
- ok: false,
1630
- error: createAbortError()
1631
- };
1632
- else yield {
1633
- ok: false,
1634
- error: createNetworkError(error)
1635
- };
1636
- }
1637
- },
1638
- async *streamEvents(jobId, options) {
1639
- const result = await fetcher.getStream(`${basePath}/${jobId}/checkpoints/stream`, options);
1640
- if (!result.ok) {
1641
- yield {
1642
- ok: false,
1643
- error: result.error
1644
- };
1645
- return;
1646
- }
1647
- const reader = result.data.getReader();
1648
- try {
1649
- for await (const sseEvent of parseSSEEvents(reader)) if (sseEvent.event === "message") yield {
1650
- ok: true,
1651
- data: {
1652
- event: "message",
1653
- data: sseEvent.data
1654
- }
1655
- };
1656
- else if (sseEvent.event === "error" && isErrorEventData(sseEvent.data)) yield {
1657
- ok: true,
1658
- data: {
1659
- event: "error",
1660
- data: sseEvent.data
1661
- }
1662
- };
1663
- else if (sseEvent.event === "complete" && isCompleteEventData(sseEvent.data)) yield {
1664
- ok: true,
1665
- data: {
1666
- event: "complete",
1667
- data: sseEvent.data
1668
- }
1669
- };
1670
- } catch (error) {
1671
- if (error instanceof DOMException && error.name === "AbortError") yield {
1672
- ok: false,
1673
- error: createAbortError()
1674
- };
1675
- else yield {
1676
- ok: false,
1677
- error: createNetworkError(error)
1678
- };
1679
- }
1680
- }
1681
- };
1682
- }
1683
-
1684
- //#endregion
1685
- //#region src/endpoints/jobs.ts
1686
- const BASE_PATH$1 = "/api/v1/jobs";
1687
- function createJobsApi(fetcher) {
1688
- return {
1689
- async list(params, options) {
1690
- if (params) {
1691
- const result = request$4.query.safeParse(params);
1692
- if (!result.success) return {
1693
- ok: false,
1694
- error: createValidationError(result.error)
1695
- };
1696
- }
1697
- const queryString = buildQueryString(params);
1698
- return fetcher.get(`${BASE_PATH$1}${queryString}`, options);
1699
- },
1700
- async get(id, options) {
1701
- return fetcher.get(`${BASE_PATH$1}/${id}`, options);
1702
- },
1703
- async start(input, options) {
1704
- const result = request$5.body.safeParse(input);
1705
- if (!result.success) return {
1706
- ok: false,
1707
- error: createValidationError(result.error)
1708
- };
1709
- return fetcher.post(BASE_PATH$1, input, options);
1710
- },
1711
- async update(id, input, options) {
1712
- const result = request$3.body.safeParse(input);
1713
- if (!result.success) return {
1714
- ok: false,
1715
- error: createValidationError(result.error)
1716
- };
1717
- return fetcher.post(`${BASE_PATH$1}/${id}`, input, options);
1718
- },
1719
- async continue(id, input, options) {
1720
- const result = request$6.body.safeParse(input);
1721
- if (!result.success) return {
1722
- ok: false,
1723
- error: createValidationError(result.error)
1724
- };
1725
- return fetcher.post(`${BASE_PATH$1}/${id}/continue`, input, options);
1726
- },
1727
- async cancel(id, options) {
1728
- return fetcher.post(`${BASE_PATH$1}/${id}/cancel`, {}, options);
1737
+ return fetcher.delete(`${BASE_PATH$1}/${encodedKey}`, options);
1729
1738
  },
1730
- checkpoints: createCheckpointsApi(fetcher, BASE_PATH$1)
1739
+ versions: createVersionsApi(fetcher, BASE_PATH$1)
1731
1740
  };
1732
1741
  }
1733
1742
 
@@ -1799,5 +1808,5 @@ function createApiClient(config) {
1799
1808
  }
1800
1809
 
1801
1810
  //#endregion
1802
- export { buildAuthHeaders, buildQueryString, createAbortError, createApiClient, createFetcher, createHttpError, createNetworkError, createTimeoutError, createValidationError, handleHttpError, isAbortError, isClientError, isHttpError, isNetworkError, isTimeoutError, isValidationError, matchExperts, matchOperations, matchWildcard, parseApiKeyPermissions, parseSSE, parseSSEEvents, stringifyApiKeyPermissions };
1811
+ export { StreamConnectionError, StreamError, buildAuthHeaders, buildQueryString, createAbortError, createApiClient, createFetcher, createHttpError, createNetworkError, createTimeoutError, createValidationError, handleHttpError, isAbortError, isClientError, isHttpError, isNetworkError, isTimeoutError, isValidationError, matchExperts, matchOperations, matchWildcard, parseApiKeyPermissions, parseSSE, parseSSEEvents, stringifyApiKeyPermissions };
1803
1812
  //# sourceMappingURL=index.mjs.map