@perstack/api-client 0.0.54 → 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.d.mts +14752 -7537
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +356 -354
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { activityOrGroupSchema,
|
|
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
|
|
76
|
+
async function handleHttpError(response) {
|
|
77
77
|
let errorBody;
|
|
78
78
|
try {
|
|
79
|
-
errorBody = await response
|
|
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
|
|
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
|
|
222
|
+
async function request(method, path, body, options) {
|
|
223
223
|
const { signal, cleanup, isTimeout } = createTimeoutSignal(options?.signal);
|
|
224
224
|
try {
|
|
225
|
-
const response
|
|
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
|
|
232
|
+
if (!response.ok) return handleHttpError(response);
|
|
233
233
|
return {
|
|
234
234
|
ok: true,
|
|
235
|
-
data: await response
|
|
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
|
|
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
|
|
265
|
+
if (!response.ok) return handleHttpError(response);
|
|
266
266
|
return {
|
|
267
267
|
ok: true,
|
|
268
|
-
data: await response
|
|
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
|
|
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
|
|
298
|
+
if (!response.ok) {
|
|
299
299
|
cleanup();
|
|
300
|
-
return handleHttpError(response
|
|
300
|
+
return handleHttpError(response);
|
|
301
301
|
}
|
|
302
|
-
if (!response
|
|
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
|
|
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
|
|
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
|
|
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
|
|
368
|
-
post: (path, body, options) => request
|
|
369
|
-
put: (path, body, options) => request
|
|
370
|
-
delete: (path, options) => request
|
|
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)
|
|
@@ -609,6 +609,11 @@ const errorConflict = z.object({
|
|
|
609
609
|
error: z.literal("Conflict"),
|
|
610
610
|
reason: z.string()
|
|
611
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.");
|
|
612
617
|
const errorValidationFailed = z.object({
|
|
613
618
|
code: z.literal(422),
|
|
614
619
|
error: z.literal("Validation Failed"),
|
|
@@ -650,16 +655,16 @@ const applicationSchema = z.object({
|
|
|
650
655
|
|
|
651
656
|
//#endregion
|
|
652
657
|
//#region ../models/src/api/applications/create.ts
|
|
653
|
-
const request$
|
|
658
|
+
const request$17 = { body: z.object({
|
|
654
659
|
name: applicationNameSchema,
|
|
655
660
|
applicationGroupId: cuidSchema.optional()
|
|
656
661
|
}) };
|
|
657
|
-
const response$
|
|
662
|
+
const response$17 = z.object({ data: z.object({ application: applicationSchema }) });
|
|
658
663
|
|
|
659
664
|
//#endregion
|
|
660
665
|
//#region ../models/src/api/applications/getAll.ts
|
|
661
|
-
const request$
|
|
662
|
-
name: z.
|
|
666
|
+
const request$16 = { query: z.object({
|
|
667
|
+
name: z.preprocess((val) => Array.isArray(val) ? val.join(",") : val, z.string().optional()),
|
|
663
668
|
sort: z.enum([
|
|
664
669
|
"name",
|
|
665
670
|
"createdAt",
|
|
@@ -669,21 +674,21 @@ const request$17 = { query: z.object({
|
|
|
669
674
|
take: z.coerce.number().min(1).max(100).default(20),
|
|
670
675
|
skip: z.coerce.number().min(0).default(0)
|
|
671
676
|
}) };
|
|
672
|
-
const response$
|
|
677
|
+
const response$16 = z.object({
|
|
673
678
|
data: z.object({ applications: z.array(applicationSchema) }),
|
|
674
679
|
meta: paginationMeta
|
|
675
680
|
});
|
|
676
681
|
|
|
677
682
|
//#endregion
|
|
678
683
|
//#region ../models/src/api/applications/update.ts
|
|
679
|
-
const request$
|
|
684
|
+
const request$15 = {
|
|
680
685
|
params: z.object({ applicationId: cuidSchema }),
|
|
681
686
|
body: z.object({
|
|
682
687
|
name: applicationNameSchema.optional(),
|
|
683
688
|
status: applicationStatusSchema.exclude(["deleted"]).optional()
|
|
684
689
|
}).refine((data) => data.name !== void 0 || data.status !== void 0, { message: "At least one field must be provided" })
|
|
685
690
|
};
|
|
686
|
-
const response$
|
|
691
|
+
const response$15 = z.object({ data: z.object({ application: applicationSchema }) });
|
|
687
692
|
|
|
688
693
|
//#endregion
|
|
689
694
|
//#region ../models/src/domain/secret.ts
|
|
@@ -705,28 +710,28 @@ const secretSchema = z.object({
|
|
|
705
710
|
|
|
706
711
|
//#endregion
|
|
707
712
|
//#region ../models/src/api/env/secrets/create.ts
|
|
708
|
-
const request$
|
|
713
|
+
const request$14 = { body: z.object({
|
|
709
714
|
applicationId: cuidSchema,
|
|
710
715
|
name: secretNameSchema,
|
|
711
716
|
value: secretValueSchema
|
|
712
717
|
}) };
|
|
713
|
-
const response$
|
|
718
|
+
const response$14 = z.object({ data: z.object({ secret: secretMetadataSchema }) });
|
|
714
719
|
|
|
715
720
|
//#endregion
|
|
716
721
|
//#region ../models/src/api/env/secrets/getAll.ts
|
|
717
|
-
const request$
|
|
718
|
-
const response$
|
|
722
|
+
const request$13 = { query: z.object({ applicationId: cuidSchema.optional() }) };
|
|
723
|
+
const response$13 = z.object({ data: z.object({ secrets: z.array(secretMetadataSchema) }) });
|
|
719
724
|
|
|
720
725
|
//#endregion
|
|
721
726
|
//#region ../models/src/api/env/secrets/update.ts
|
|
722
|
-
const request$
|
|
727
|
+
const request$12 = {
|
|
723
728
|
params: z.object({ name: z.string().min(1) }),
|
|
724
729
|
body: z.object({
|
|
725
730
|
applicationId: cuidSchema,
|
|
726
731
|
value: secretValueSchema
|
|
727
732
|
})
|
|
728
733
|
};
|
|
729
|
-
const response$
|
|
734
|
+
const response$12 = z.object({ data: z.object({ secret: secretMetadataSchema }) });
|
|
730
735
|
|
|
731
736
|
//#endregion
|
|
732
737
|
//#region ../models/src/domain/variable.ts
|
|
@@ -750,28 +755,28 @@ const variableResponseSchema = z.object({
|
|
|
750
755
|
|
|
751
756
|
//#endregion
|
|
752
757
|
//#region ../models/src/api/env/variables/create.ts
|
|
753
|
-
const request$
|
|
758
|
+
const request$11 = { body: z.object({
|
|
754
759
|
applicationId: cuidSchema,
|
|
755
760
|
name: variableNameSchema,
|
|
756
761
|
value: variableValueSchema
|
|
757
762
|
}) };
|
|
758
|
-
const response$
|
|
763
|
+
const response$11 = z.object({ data: z.object({ variable: variableResponseSchema }) });
|
|
759
764
|
|
|
760
765
|
//#endregion
|
|
761
766
|
//#region ../models/src/api/env/variables/getAll.ts
|
|
762
|
-
const request$
|
|
763
|
-
const response$
|
|
767
|
+
const request$10 = { query: z.object({ applicationId: cuidSchema }) };
|
|
768
|
+
const response$10 = z.object({ data: z.object({ variables: z.array(variableResponseSchema) }) });
|
|
764
769
|
|
|
765
770
|
//#endregion
|
|
766
771
|
//#region ../models/src/api/env/variables/update.ts
|
|
767
|
-
const request$
|
|
772
|
+
const request$9 = {
|
|
768
773
|
params: z.object({ name: z.string().min(1) }),
|
|
769
774
|
body: z.object({
|
|
770
775
|
applicationId: cuidSchema,
|
|
771
776
|
value: variableValueSchema
|
|
772
777
|
})
|
|
773
778
|
};
|
|
774
|
-
const response$
|
|
779
|
+
const response$9 = z.object({ data: z.object({ variable: variableResponseSchema }) });
|
|
775
780
|
|
|
776
781
|
//#endregion
|
|
777
782
|
//#region ../models/src/domain/expertScope.ts
|
|
@@ -902,7 +907,7 @@ const expertWithMetadataSchema = expertSchema.extend({
|
|
|
902
907
|
|
|
903
908
|
//#endregion
|
|
904
909
|
//#region ../models/src/api/experts/getAll.ts
|
|
905
|
-
const request$
|
|
910
|
+
const request$8 = { query: z.object({
|
|
906
911
|
filter: z.string().describe("Filter by scope name (partial match)").optional(),
|
|
907
912
|
category: z.enum([
|
|
908
913
|
"general",
|
|
@@ -916,114 +921,11 @@ const request$9 = { query: z.object({
|
|
|
916
921
|
take: z.coerce.number().min(1).max(100).default(20),
|
|
917
922
|
skip: z.coerce.number().min(0).default(0)
|
|
918
923
|
}) };
|
|
919
|
-
const response$
|
|
924
|
+
const response$8 = z.object({
|
|
920
925
|
data: z.object({ experts: z.array(expertScopeSchema.extend({ currentVersion: expertVersionSchema.nullable() })) }),
|
|
921
926
|
meta: paginationMeta
|
|
922
927
|
});
|
|
923
928
|
|
|
924
|
-
//#endregion
|
|
925
|
-
//#region ../models/src/domain/checkpoint.ts
|
|
926
|
-
const delegationTargetSchema = z.object({
|
|
927
|
-
expert: expertSchema,
|
|
928
|
-
toolCallId: z.string().min(1).max(maxCheckpointToolCallIdLength),
|
|
929
|
-
toolName: z.string().min(1).max(maxSkillToolNameLength),
|
|
930
|
-
query: z.string().min(1)
|
|
931
|
-
});
|
|
932
|
-
/**
|
|
933
|
-
* API Checkpoint schema - extended checkpoint format for API responses.
|
|
934
|
-
* Includes additional fields computed from runtime checkpoint and step data:
|
|
935
|
-
* - activities: computed via getActivities() from @perstack/core
|
|
936
|
-
* - inputMessages, newMessages, toolCalls, toolResults: step-related data
|
|
937
|
-
* - expert: full Expert type (with instruction, skills, etc.)
|
|
938
|
-
* - startedAt/finishedAt: ISO string format (runtime uses Unix timestamps)
|
|
939
|
-
*/
|
|
940
|
-
const apiCheckpointSchema = z.object({
|
|
941
|
-
type: z.literal("checkpoint"),
|
|
942
|
-
id: cuidSchema,
|
|
943
|
-
jobId: cuidSchema,
|
|
944
|
-
runId: cuidSchema,
|
|
945
|
-
activities: z.array(activityOrGroupSchema),
|
|
946
|
-
stepNumber: z.number().int().min(1),
|
|
947
|
-
status: z.enum([
|
|
948
|
-
"init",
|
|
949
|
-
"proceeding",
|
|
950
|
-
"completed",
|
|
951
|
-
"stoppedByInteractiveTool",
|
|
952
|
-
"stoppedByDelegate",
|
|
953
|
-
"stoppedByExceededMaxSteps",
|
|
954
|
-
"stoppedByError"
|
|
955
|
-
]),
|
|
956
|
-
expert: expertSchema,
|
|
957
|
-
delegateTo: z.array(delegationTargetSchema).optional(),
|
|
958
|
-
delegatedBy: z.object({
|
|
959
|
-
expert: expertSchema,
|
|
960
|
-
toolCallId: z.string().min(1).max(maxCheckpointToolCallIdLength),
|
|
961
|
-
toolName: z.string().min(1).max(maxSkillToolNameLength),
|
|
962
|
-
checkpointId: cuidSchema,
|
|
963
|
-
runId: cuidSchema
|
|
964
|
-
}).optional(),
|
|
965
|
-
inputMessages: z.array(z.union([
|
|
966
|
-
instructionMessageSchema,
|
|
967
|
-
userMessageSchema,
|
|
968
|
-
toolMessageSchema
|
|
969
|
-
])).optional(),
|
|
970
|
-
messages: z.array(messageSchema),
|
|
971
|
-
newMessages: z.array(messageSchema),
|
|
972
|
-
toolCalls: z.array(toolCallSchema).optional(),
|
|
973
|
-
toolResults: z.array(toolResultSchema).optional(),
|
|
974
|
-
pendingToolCalls: z.array(toolCallSchema).optional(),
|
|
975
|
-
partialToolResults: z.array(toolResultSchema).optional(),
|
|
976
|
-
usage: usageSchema,
|
|
977
|
-
contextWindow: z.number().int().min(0).optional(),
|
|
978
|
-
contextWindowUsage: z.number().int().min(0).optional(),
|
|
979
|
-
error: z.object({
|
|
980
|
-
name: z.string().min(1),
|
|
981
|
-
message: z.string().min(1),
|
|
982
|
-
statusCode: z.number().int().min(100).max(599).optional(),
|
|
983
|
-
isRetryable: z.boolean()
|
|
984
|
-
}).optional(),
|
|
985
|
-
retryCount: z.number().int().min(0).optional(),
|
|
986
|
-
startedAt: datetimeSchema,
|
|
987
|
-
finishedAt: datetimeSchema.optional()
|
|
988
|
-
});
|
|
989
|
-
|
|
990
|
-
//#endregion
|
|
991
|
-
//#region ../models/src/api/jobs/checkpoints/create.ts
|
|
992
|
-
/**
|
|
993
|
-
* Request checkpoint schema - `id` and `runId` are omitted because:
|
|
994
|
-
* - `id` is server-generated (CUID)
|
|
995
|
-
* - `runId` is optional in request, server will use job's run ID
|
|
996
|
-
*/
|
|
997
|
-
const requestCheckpointSchema = perstackCheckpointSchema.omit({
|
|
998
|
-
id: true,
|
|
999
|
-
runId: true
|
|
1000
|
-
}).extend({ runId: z.string().optional() });
|
|
1001
|
-
const request$8 = {
|
|
1002
|
-
params: z.object({ jobId: cuidSchema }),
|
|
1003
|
-
body: z.object({
|
|
1004
|
-
checkpoint: requestCheckpointSchema,
|
|
1005
|
-
step: stepSchema
|
|
1006
|
-
})
|
|
1007
|
-
};
|
|
1008
|
-
const response$8 = z.object({ data: z.object({ checkpoint: apiCheckpointSchema }) });
|
|
1009
|
-
|
|
1010
|
-
//#endregion
|
|
1011
|
-
//#region ../models/src/api/jobs/checkpoints/getAll.ts
|
|
1012
|
-
const request$7 = {
|
|
1013
|
-
params: z.object({ jobId: cuidSchema }),
|
|
1014
|
-
query: z.object({
|
|
1015
|
-
filter: z.string().min(1).max(256).optional(),
|
|
1016
|
-
sort: z.enum(["createdAt", "updatedAt"]).optional(),
|
|
1017
|
-
order: z.enum(["asc", "desc"]).optional(),
|
|
1018
|
-
take: z.coerce.number().min(1).max(100).default(20),
|
|
1019
|
-
skip: z.coerce.number().min(0).default(0)
|
|
1020
|
-
})
|
|
1021
|
-
};
|
|
1022
|
-
const response$7 = z.object({
|
|
1023
|
-
data: z.object({ checkpoints: z.array(apiCheckpointSchema) }),
|
|
1024
|
-
meta: paginationMeta
|
|
1025
|
-
});
|
|
1026
|
-
|
|
1027
929
|
//#endregion
|
|
1028
930
|
//#region ../support-models/src/index.ts
|
|
1029
931
|
const anthropicSupportModels = [
|
|
@@ -1198,8 +1100,8 @@ const jobStatusSchema = z.enum([
|
|
|
1198
1100
|
const modelNames = getSupportModelNames();
|
|
1199
1101
|
const firstModel = modelNames[0];
|
|
1200
1102
|
if (firstModel === void 0) throw new Error("No support models available");
|
|
1201
|
-
const
|
|
1202
|
-
const
|
|
1103
|
+
const jobModelSchema = z.enum([firstModel, ...modelNames.slice(1)]);
|
|
1104
|
+
const jobBaseSchema = z.object({
|
|
1203
1105
|
type: z.literal("job"),
|
|
1204
1106
|
id: cuidSchema,
|
|
1205
1107
|
organizationId: cuidSchema,
|
|
@@ -1207,12 +1109,12 @@ const jobSchema = z.object({
|
|
|
1207
1109
|
createdAt: datetimeSchema,
|
|
1208
1110
|
updatedAt: datetimeSchema,
|
|
1209
1111
|
status: jobStatusSchema,
|
|
1112
|
+
currentExecutionId: cuidSchema.optional(),
|
|
1210
1113
|
coordinatorExpertKey: expertKeyFieldSchema,
|
|
1211
1114
|
query: z.string().min(1).max(maxExpertJobQueryLength).optional(),
|
|
1212
1115
|
expert: expertWithMetadataSchema,
|
|
1213
|
-
expertDraftRefId: cuidSchema.optional(),
|
|
1214
1116
|
provider: providerSchema,
|
|
1215
|
-
model:
|
|
1117
|
+
model: jobModelSchema,
|
|
1216
1118
|
reasoningBudget: reasoningBudgetSchema,
|
|
1217
1119
|
runtimeVersion: runtimeVersionSchema,
|
|
1218
1120
|
maxSteps: z.number().int().min(1),
|
|
@@ -1223,22 +1125,30 @@ const jobSchema = z.object({
|
|
|
1223
1125
|
usage: usageSchema,
|
|
1224
1126
|
lastActivity: activityOrGroupSchema.nullable().optional()
|
|
1225
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]);
|
|
1226
1137
|
|
|
1227
1138
|
//#endregion
|
|
1228
1139
|
//#region ../models/src/api/jobs/continue.ts
|
|
1229
|
-
const request$
|
|
1140
|
+
const request$7 = {
|
|
1230
1141
|
params: z.object({ jobId: cuidSchema }),
|
|
1231
1142
|
body: z.object({
|
|
1232
1143
|
query: z.string().min(1).max(maxExpertJobQueryLength),
|
|
1233
|
-
interactiveToolCallResult: z.boolean().optional(),
|
|
1234
1144
|
provider: providerSchema.optional(),
|
|
1235
|
-
model:
|
|
1145
|
+
model: jobModelSchema.optional(),
|
|
1236
1146
|
reasoningBudget: reasoningBudgetSchema.optional(),
|
|
1237
1147
|
maxSteps: z.coerce.number().optional(),
|
|
1238
1148
|
maxRetries: z.coerce.number().optional()
|
|
1239
1149
|
})
|
|
1240
1150
|
};
|
|
1241
|
-
const response$
|
|
1151
|
+
const response$7 = z.object({ data: z.object({ job: jobSchema }) });
|
|
1242
1152
|
|
|
1243
1153
|
//#endregion
|
|
1244
1154
|
//#region ../models/src/api/jobs/create.ts
|
|
@@ -1246,12 +1156,12 @@ const baseBodySchema = z.object({
|
|
|
1246
1156
|
applicationId: cuidSchema.describe("Application ID to create the job in"),
|
|
1247
1157
|
query: z.string().min(1).max(maxExpertJobQueryLength),
|
|
1248
1158
|
provider: providerSchema,
|
|
1249
|
-
model:
|
|
1159
|
+
model: jobModelSchema.optional(),
|
|
1250
1160
|
reasoningBudget: reasoningBudgetSchema.optional(),
|
|
1251
1161
|
maxSteps: z.coerce.number().optional(),
|
|
1252
1162
|
maxRetries: z.coerce.number().optional()
|
|
1253
1163
|
});
|
|
1254
|
-
const request$
|
|
1164
|
+
const request$6 = { body: baseBodySchema.extend({
|
|
1255
1165
|
expertKey: expertKeyFieldSchema.optional(),
|
|
1256
1166
|
draftRefId: cuidSchema.describe("Draft ref ID to run the job with").optional()
|
|
1257
1167
|
}).refine((data) => {
|
|
@@ -1259,11 +1169,11 @@ const request$5 = { body: baseBodySchema.extend({
|
|
|
1259
1169
|
const hasDraftRefId = data.draftRefId !== void 0;
|
|
1260
1170
|
return hasExpertKey && !hasDraftRefId || !hasExpertKey && hasDraftRefId;
|
|
1261
1171
|
}, { message: "Either expertKey or draftRefId must be provided, but not both" }) };
|
|
1262
|
-
const response$
|
|
1172
|
+
const response$6 = z.object({ data: z.object({ job: jobSchema }) });
|
|
1263
1173
|
|
|
1264
1174
|
//#endregion
|
|
1265
1175
|
//#region ../models/src/api/jobs/getAll.ts
|
|
1266
|
-
const request$
|
|
1176
|
+
const request$5 = { query: z.object({
|
|
1267
1177
|
sort: z.enum(["createdAt", "updatedAt"]).optional(),
|
|
1268
1178
|
order: z.enum(["asc", "desc"]).optional(),
|
|
1269
1179
|
take: z.coerce.number().min(1).max(100).default(20),
|
|
@@ -1274,18 +1184,139 @@ const request$4 = { query: z.object({
|
|
|
1274
1184
|
statuses: z.preprocess((val) => typeof val === "string" ? val.split(",") : val, z.array(jobStatusSchema).optional()),
|
|
1275
1185
|
expertKeyFilter: z.string().max(100).optional()
|
|
1276
1186
|
}) };
|
|
1277
|
-
const response$
|
|
1187
|
+
const response$5 = z.object({
|
|
1278
1188
|
data: z.object({ jobs: z.array(jobSchema) }),
|
|
1279
1189
|
meta: paginationMeta
|
|
1280
1190
|
});
|
|
1281
1191
|
|
|
1282
1192
|
//#endregion
|
|
1283
|
-
//#region ../models/src/
|
|
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
|
|
1284
1307
|
const request$3 = {
|
|
1285
1308
|
params: z.object({ jobId: cuidSchema }),
|
|
1286
|
-
|
|
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
|
+
})
|
|
1287
1315
|
};
|
|
1288
|
-
const response$3 = z.object({
|
|
1316
|
+
const response$3 = z.object({
|
|
1317
|
+
data: z.object({ runs: z.array(runSchema) }),
|
|
1318
|
+
meta: paginationMeta
|
|
1319
|
+
});
|
|
1289
1320
|
|
|
1290
1321
|
//#endregion
|
|
1291
1322
|
//#region ../models/src/domain/providerSetting.ts
|
|
@@ -1397,13 +1428,82 @@ const request = {
|
|
|
1397
1428
|
const response = z.object({ data: z.object({ providerSetting: providerSettingResponseSchema }) });
|
|
1398
1429
|
|
|
1399
1430
|
//#endregion
|
|
1400
|
-
//#region src/endpoints/
|
|
1401
|
-
|
|
1402
|
-
|
|
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) {
|
|
1403
1503
|
return {
|
|
1404
1504
|
async list(params, options) {
|
|
1405
1505
|
if (params) {
|
|
1406
|
-
const result = request$
|
|
1506
|
+
const result = request$5.query.safeParse(params);
|
|
1407
1507
|
if (!result.success) return {
|
|
1408
1508
|
ok: false,
|
|
1409
1509
|
error: createValidationError(result.error)
|
|
@@ -1415,110 +1515,166 @@ function createApplicationsApi(fetcher) {
|
|
|
1415
1515
|
async get(id, options) {
|
|
1416
1516
|
return fetcher.get(`${BASE_PATH$5}/${id}`, options);
|
|
1417
1517
|
},
|
|
1418
|
-
async
|
|
1419
|
-
const result = request$
|
|
1518
|
+
async start(input, options) {
|
|
1519
|
+
const result = request$6.body.safeParse(input);
|
|
1420
1520
|
if (!result.success) return {
|
|
1421
1521
|
ok: false,
|
|
1422
1522
|
error: createValidationError(result.error)
|
|
1423
1523
|
};
|
|
1424
1524
|
return fetcher.post(BASE_PATH$5, input, options);
|
|
1425
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
|
+
},
|
|
1426
1582
|
async update(id, input, options) {
|
|
1427
|
-
const result = request$
|
|
1583
|
+
const result = request$15.body.safeParse(input);
|
|
1428
1584
|
if (!result.success) return {
|
|
1429
1585
|
ok: false,
|
|
1430
1586
|
error: createValidationError(result.error)
|
|
1431
1587
|
};
|
|
1432
|
-
return fetcher.post(`${BASE_PATH$
|
|
1588
|
+
return fetcher.post(`${BASE_PATH$4}/${id}`, input, options);
|
|
1433
1589
|
},
|
|
1434
1590
|
async delete(id, options) {
|
|
1435
|
-
return fetcher.delete(`${BASE_PATH$
|
|
1591
|
+
return fetcher.delete(`${BASE_PATH$4}/${id}`, options);
|
|
1436
1592
|
}
|
|
1437
1593
|
};
|
|
1438
1594
|
}
|
|
1439
1595
|
|
|
1440
1596
|
//#endregion
|
|
1441
1597
|
//#region src/endpoints/env-secrets.ts
|
|
1442
|
-
const BASE_PATH$
|
|
1598
|
+
const BASE_PATH$3 = "/api/v1/env/secrets";
|
|
1443
1599
|
function createSecretsApi(fetcher) {
|
|
1444
1600
|
return {
|
|
1445
1601
|
async list(params, options) {
|
|
1446
1602
|
if (params) {
|
|
1447
|
-
const result = request$
|
|
1603
|
+
const result = request$13.query.safeParse(params);
|
|
1448
1604
|
if (!result.success) return {
|
|
1449
1605
|
ok: false,
|
|
1450
1606
|
error: createValidationError(result.error)
|
|
1451
1607
|
};
|
|
1452
1608
|
}
|
|
1453
1609
|
const queryString = buildQueryString(params);
|
|
1454
|
-
return fetcher.get(`${BASE_PATH$
|
|
1610
|
+
return fetcher.get(`${BASE_PATH$3}${queryString}`, options);
|
|
1455
1611
|
},
|
|
1456
1612
|
async get(name, options) {
|
|
1457
1613
|
const encodedName = encodeURIComponent(name);
|
|
1458
|
-
return fetcher.get(`${BASE_PATH$
|
|
1614
|
+
return fetcher.get(`${BASE_PATH$3}/${encodedName}`, options);
|
|
1459
1615
|
},
|
|
1460
1616
|
async create(input, options) {
|
|
1461
|
-
const result = request$
|
|
1617
|
+
const result = request$14.body.safeParse(input);
|
|
1462
1618
|
if (!result.success) return {
|
|
1463
1619
|
ok: false,
|
|
1464
1620
|
error: createValidationError(result.error)
|
|
1465
1621
|
};
|
|
1466
|
-
return fetcher.post(BASE_PATH$
|
|
1622
|
+
return fetcher.post(BASE_PATH$3, input, options);
|
|
1467
1623
|
},
|
|
1468
1624
|
async update(name, input, options) {
|
|
1469
|
-
const result = request$
|
|
1625
|
+
const result = request$12.body.safeParse(input);
|
|
1470
1626
|
if (!result.success) return {
|
|
1471
1627
|
ok: false,
|
|
1472
1628
|
error: createValidationError(result.error)
|
|
1473
1629
|
};
|
|
1474
1630
|
const encodedName = encodeURIComponent(name);
|
|
1475
|
-
return fetcher.put(`${BASE_PATH$
|
|
1631
|
+
return fetcher.put(`${BASE_PATH$3}/${encodedName}`, input, options);
|
|
1476
1632
|
},
|
|
1477
1633
|
async delete(name, options) {
|
|
1478
1634
|
const encodedName = encodeURIComponent(name);
|
|
1479
|
-
return fetcher.deleteNoContent(`${BASE_PATH$
|
|
1635
|
+
return fetcher.deleteNoContent(`${BASE_PATH$3}/${encodedName}`, options);
|
|
1480
1636
|
}
|
|
1481
1637
|
};
|
|
1482
1638
|
}
|
|
1483
1639
|
|
|
1484
1640
|
//#endregion
|
|
1485
1641
|
//#region src/endpoints/env-variables.ts
|
|
1486
|
-
const BASE_PATH$
|
|
1642
|
+
const BASE_PATH$2 = "/api/v1/env/variables";
|
|
1487
1643
|
function createVariablesApi(fetcher) {
|
|
1488
1644
|
return {
|
|
1489
1645
|
async list(params, options) {
|
|
1490
|
-
const result = request$
|
|
1646
|
+
const result = request$10.query.safeParse(params);
|
|
1491
1647
|
if (!result.success) return {
|
|
1492
1648
|
ok: false,
|
|
1493
1649
|
error: createValidationError(result.error)
|
|
1494
1650
|
};
|
|
1495
1651
|
const queryString = buildQueryString(params);
|
|
1496
|
-
return fetcher.get(`${BASE_PATH$
|
|
1652
|
+
return fetcher.get(`${BASE_PATH$2}${queryString}`, options);
|
|
1497
1653
|
},
|
|
1498
1654
|
async get(name, options) {
|
|
1499
1655
|
const encodedName = encodeURIComponent(name);
|
|
1500
|
-
return fetcher.get(`${BASE_PATH$
|
|
1656
|
+
return fetcher.get(`${BASE_PATH$2}/${encodedName}`, options);
|
|
1501
1657
|
},
|
|
1502
1658
|
async create(input, options) {
|
|
1503
|
-
const result = request$
|
|
1659
|
+
const result = request$11.body.safeParse(input);
|
|
1504
1660
|
if (!result.success) return {
|
|
1505
1661
|
ok: false,
|
|
1506
1662
|
error: createValidationError(result.error)
|
|
1507
1663
|
};
|
|
1508
|
-
return fetcher.post(BASE_PATH$
|
|
1664
|
+
return fetcher.post(BASE_PATH$2, input, options);
|
|
1509
1665
|
},
|
|
1510
1666
|
async update(name, input, options) {
|
|
1511
|
-
const result = request$
|
|
1667
|
+
const result = request$9.body.safeParse(input);
|
|
1512
1668
|
if (!result.success) return {
|
|
1513
1669
|
ok: false,
|
|
1514
1670
|
error: createValidationError(result.error)
|
|
1515
1671
|
};
|
|
1516
1672
|
const encodedName = encodeURIComponent(name);
|
|
1517
|
-
return fetcher.put(`${BASE_PATH$
|
|
1673
|
+
return fetcher.put(`${BASE_PATH$2}/${encodedName}`, input, options);
|
|
1518
1674
|
},
|
|
1519
1675
|
async delete(name, options) {
|
|
1520
1676
|
const encodedName = encodeURIComponent(name);
|
|
1521
|
-
return fetcher.deleteNoContent(`${BASE_PATH$
|
|
1677
|
+
return fetcher.deleteNoContent(`${BASE_PATH$2}/${encodedName}`, options);
|
|
1522
1678
|
}
|
|
1523
1679
|
};
|
|
1524
1680
|
}
|
|
@@ -1543,198 +1699,44 @@ function createVersionsApi(fetcher, basePath) {
|
|
|
1543
1699
|
|
|
1544
1700
|
//#endregion
|
|
1545
1701
|
//#region src/endpoints/experts.ts
|
|
1546
|
-
const BASE_PATH$
|
|
1702
|
+
const BASE_PATH$1 = "/api/v1/experts";
|
|
1547
1703
|
function createExpertsApi(fetcher) {
|
|
1548
1704
|
return {
|
|
1549
1705
|
async list(params, options) {
|
|
1550
1706
|
if (params) {
|
|
1551
|
-
const result = request$
|
|
1707
|
+
const result = request$8.query.safeParse(params);
|
|
1552
1708
|
if (!result.success) return {
|
|
1553
1709
|
ok: false,
|
|
1554
1710
|
error: createValidationError(result.error)
|
|
1555
1711
|
};
|
|
1556
1712
|
}
|
|
1557
1713
|
const queryString = buildQueryString(params);
|
|
1558
|
-
return fetcher.get(`${BASE_PATH$
|
|
1714
|
+
return fetcher.get(`${BASE_PATH$1}${queryString}`, options);
|
|
1559
1715
|
},
|
|
1560
1716
|
async get(key, options) {
|
|
1561
1717
|
const encodedKey = encodeURIComponent(key);
|
|
1562
|
-
return fetcher.get(`${BASE_PATH$
|
|
1718
|
+
return fetcher.get(`${BASE_PATH$1}/${encodedKey}`, options);
|
|
1563
1719
|
},
|
|
1564
1720
|
async getFeatured(options) {
|
|
1565
|
-
return fetcher.get(`${BASE_PATH$
|
|
1721
|
+
return fetcher.get(`${BASE_PATH$1}/featured`, options);
|
|
1566
1722
|
},
|
|
1567
1723
|
async getMeta(key, options) {
|
|
1568
1724
|
const encodedKey = encodeURIComponent(key);
|
|
1569
|
-
return fetcher.get(`${BASE_PATH$
|
|
1725
|
+
return fetcher.get(`${BASE_PATH$1}/${encodedKey}/meta`, options);
|
|
1570
1726
|
},
|
|
1571
1727
|
async publish(scopeName, options) {
|
|
1572
1728
|
const encodedScopeName = encodeURIComponent(scopeName);
|
|
1573
|
-
return fetcher.post(`${BASE_PATH$
|
|
1729
|
+
return fetcher.post(`${BASE_PATH$1}/${encodedScopeName}/publish`, {}, options);
|
|
1574
1730
|
},
|
|
1575
1731
|
async unpublish(scopeName, options) {
|
|
1576
1732
|
const encodedScopeName = encodeURIComponent(scopeName);
|
|
1577
|
-
return fetcher.post(`${BASE_PATH$
|
|
1733
|
+
return fetcher.post(`${BASE_PATH$1}/${encodedScopeName}/unpublish`, {}, options);
|
|
1578
1734
|
},
|
|
1579
1735
|
async yank(key, options) {
|
|
1580
1736
|
const encodedKey = encodeURIComponent(key);
|
|
1581
|
-
return fetcher.delete(`${BASE_PATH$
|
|
1582
|
-
},
|
|
1583
|
-
versions: createVersionsApi(fetcher, BASE_PATH$2)
|
|
1584
|
-
};
|
|
1585
|
-
}
|
|
1586
|
-
|
|
1587
|
-
//#endregion
|
|
1588
|
-
//#region src/endpoints/jobs-checkpoints.ts
|
|
1589
|
-
function isErrorEventData(data) {
|
|
1590
|
-
return typeof data === "object" && data !== null && "type" in data && typeof data.type === "string" && "jobId" in data && typeof data.jobId === "string";
|
|
1591
|
-
}
|
|
1592
|
-
function isCompleteEventData(data) {
|
|
1593
|
-
return typeof data === "object" && data !== null && "status" in data && typeof data.status === "string" && "jobId" in data && typeof data.jobId === "string";
|
|
1594
|
-
}
|
|
1595
|
-
function createCheckpointsApi(fetcher, basePath) {
|
|
1596
|
-
return {
|
|
1597
|
-
async list(jobId, params, options) {
|
|
1598
|
-
if (params) {
|
|
1599
|
-
const result = request$7.query.safeParse(params);
|
|
1600
|
-
if (!result.success) return {
|
|
1601
|
-
ok: false,
|
|
1602
|
-
error: createValidationError(result.error)
|
|
1603
|
-
};
|
|
1604
|
-
}
|
|
1605
|
-
const queryString = buildQueryString(params);
|
|
1606
|
-
return fetcher.get(`${basePath}/${jobId}/checkpoints${queryString}`, options);
|
|
1607
|
-
},
|
|
1608
|
-
async get(jobId, checkpointId, options) {
|
|
1609
|
-
return fetcher.get(`${basePath}/${jobId}/checkpoints/${checkpointId}`, options);
|
|
1610
|
-
},
|
|
1611
|
-
async create(jobId, input, options) {
|
|
1612
|
-
const result = request$8.body.safeParse(input);
|
|
1613
|
-
if (!result.success) return {
|
|
1614
|
-
ok: false,
|
|
1615
|
-
error: createValidationError(result.error)
|
|
1616
|
-
};
|
|
1617
|
-
return fetcher.post(`${basePath}/${jobId}/checkpoints`, input, options);
|
|
1618
|
-
},
|
|
1619
|
-
async *stream(jobId, options) {
|
|
1620
|
-
const result = await fetcher.getStream(`${basePath}/${jobId}/checkpoints/stream`, options);
|
|
1621
|
-
if (!result.ok) {
|
|
1622
|
-
yield {
|
|
1623
|
-
ok: false,
|
|
1624
|
-
error: result.error
|
|
1625
|
-
};
|
|
1626
|
-
return;
|
|
1627
|
-
}
|
|
1628
|
-
const reader = result.data.getReader();
|
|
1629
|
-
try {
|
|
1630
|
-
for await (const checkpoint of parseSSE(reader)) yield {
|
|
1631
|
-
ok: true,
|
|
1632
|
-
data: checkpoint
|
|
1633
|
-
};
|
|
1634
|
-
} catch (error) {
|
|
1635
|
-
if (error instanceof DOMException && error.name === "AbortError") yield {
|
|
1636
|
-
ok: false,
|
|
1637
|
-
error: createAbortError()
|
|
1638
|
-
};
|
|
1639
|
-
else yield {
|
|
1640
|
-
ok: false,
|
|
1641
|
-
error: createNetworkError(error)
|
|
1642
|
-
};
|
|
1643
|
-
}
|
|
1644
|
-
},
|
|
1645
|
-
async *streamEvents(jobId, options) {
|
|
1646
|
-
const result = await fetcher.getStream(`${basePath}/${jobId}/checkpoints/stream`, options);
|
|
1647
|
-
if (!result.ok) {
|
|
1648
|
-
yield {
|
|
1649
|
-
ok: false,
|
|
1650
|
-
error: result.error
|
|
1651
|
-
};
|
|
1652
|
-
return;
|
|
1653
|
-
}
|
|
1654
|
-
const reader = result.data.getReader();
|
|
1655
|
-
try {
|
|
1656
|
-
for await (const sseEvent of parseSSEEvents(reader)) if (sseEvent.event === "message") yield {
|
|
1657
|
-
ok: true,
|
|
1658
|
-
data: {
|
|
1659
|
-
event: "message",
|
|
1660
|
-
data: sseEvent.data
|
|
1661
|
-
}
|
|
1662
|
-
};
|
|
1663
|
-
else if (sseEvent.event === "error" && isErrorEventData(sseEvent.data)) yield {
|
|
1664
|
-
ok: true,
|
|
1665
|
-
data: {
|
|
1666
|
-
event: "error",
|
|
1667
|
-
data: sseEvent.data
|
|
1668
|
-
}
|
|
1669
|
-
};
|
|
1670
|
-
else if (sseEvent.event === "complete" && isCompleteEventData(sseEvent.data)) yield {
|
|
1671
|
-
ok: true,
|
|
1672
|
-
data: {
|
|
1673
|
-
event: "complete",
|
|
1674
|
-
data: sseEvent.data
|
|
1675
|
-
}
|
|
1676
|
-
};
|
|
1677
|
-
} catch (error) {
|
|
1678
|
-
if (error instanceof DOMException && error.name === "AbortError") yield {
|
|
1679
|
-
ok: false,
|
|
1680
|
-
error: createAbortError()
|
|
1681
|
-
};
|
|
1682
|
-
else yield {
|
|
1683
|
-
ok: false,
|
|
1684
|
-
error: createNetworkError(error)
|
|
1685
|
-
};
|
|
1686
|
-
}
|
|
1687
|
-
}
|
|
1688
|
-
};
|
|
1689
|
-
}
|
|
1690
|
-
|
|
1691
|
-
//#endregion
|
|
1692
|
-
//#region src/endpoints/jobs.ts
|
|
1693
|
-
const BASE_PATH$1 = "/api/v1/jobs";
|
|
1694
|
-
function createJobsApi(fetcher) {
|
|
1695
|
-
return {
|
|
1696
|
-
async list(params, options) {
|
|
1697
|
-
if (params) {
|
|
1698
|
-
const result = request$4.query.safeParse(params);
|
|
1699
|
-
if (!result.success) return {
|
|
1700
|
-
ok: false,
|
|
1701
|
-
error: createValidationError(result.error)
|
|
1702
|
-
};
|
|
1703
|
-
}
|
|
1704
|
-
const queryString = buildQueryString(params);
|
|
1705
|
-
return fetcher.get(`${BASE_PATH$1}${queryString}`, options);
|
|
1706
|
-
},
|
|
1707
|
-
async get(id, options) {
|
|
1708
|
-
return fetcher.get(`${BASE_PATH$1}/${id}`, options);
|
|
1709
|
-
},
|
|
1710
|
-
async start(input, options) {
|
|
1711
|
-
const result = request$5.body.safeParse(input);
|
|
1712
|
-
if (!result.success) return {
|
|
1713
|
-
ok: false,
|
|
1714
|
-
error: createValidationError(result.error)
|
|
1715
|
-
};
|
|
1716
|
-
return fetcher.post(BASE_PATH$1, input, options);
|
|
1717
|
-
},
|
|
1718
|
-
async update(id, input, options) {
|
|
1719
|
-
const result = request$3.body.safeParse(input);
|
|
1720
|
-
if (!result.success) return {
|
|
1721
|
-
ok: false,
|
|
1722
|
-
error: createValidationError(result.error)
|
|
1723
|
-
};
|
|
1724
|
-
return fetcher.post(`${BASE_PATH$1}/${id}`, input, options);
|
|
1725
|
-
},
|
|
1726
|
-
async continue(id, input, options) {
|
|
1727
|
-
const result = request$6.body.safeParse(input);
|
|
1728
|
-
if (!result.success) return {
|
|
1729
|
-
ok: false,
|
|
1730
|
-
error: createValidationError(result.error)
|
|
1731
|
-
};
|
|
1732
|
-
return fetcher.post(`${BASE_PATH$1}/${id}/continue`, input, options);
|
|
1733
|
-
},
|
|
1734
|
-
async cancel(id, options) {
|
|
1735
|
-
return fetcher.post(`${BASE_PATH$1}/${id}/cancel`, {}, options);
|
|
1737
|
+
return fetcher.delete(`${BASE_PATH$1}/${encodedKey}`, options);
|
|
1736
1738
|
},
|
|
1737
|
-
|
|
1739
|
+
versions: createVersionsApi(fetcher, BASE_PATH$1)
|
|
1738
1740
|
};
|
|
1739
1741
|
}
|
|
1740
1742
|
|
|
@@ -1806,5 +1808,5 @@ function createApiClient(config) {
|
|
|
1806
1808
|
}
|
|
1807
1809
|
|
|
1808
1810
|
//#endregion
|
|
1809
|
-
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 };
|
|
1810
1812
|
//# sourceMappingURL=index.mjs.map
|