@perstack/core 0.0.25 → 0.0.27
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/README.md +36 -5
- package/dist/src/index.d.ts +685 -30
- package/dist/src/index.js +126 -17
- package/dist/src/index.js.map +1 -1
- package/package.json +4 -4
package/dist/src/index.js
CHANGED
|
@@ -110,7 +110,6 @@ function createRuntimeInitEvent(jobId, runId, expertName, runtime, version, quer
|
|
|
110
110
|
expertName,
|
|
111
111
|
experts: [],
|
|
112
112
|
model: `${runtime}:default`,
|
|
113
|
-
temperature: 0,
|
|
114
113
|
maxRetries: 0,
|
|
115
114
|
timeout: 0,
|
|
116
115
|
query
|
|
@@ -232,7 +231,6 @@ var maxExpertInstructionLength = 1024 * 20;
|
|
|
232
231
|
var maxExpertSkillItems = 255;
|
|
233
232
|
var maxExpertDelegateItems = 255;
|
|
234
233
|
var maxExpertTagItems = 8;
|
|
235
|
-
var defaultTemperature = 0;
|
|
236
234
|
var defaultMaxSteps = 100;
|
|
237
235
|
var defaultMaxRetries = 5;
|
|
238
236
|
var defaultTimeout = 5 * 1e3 * 60;
|
|
@@ -483,6 +481,11 @@ var toolCallPartSchema = basePartSchema.extend({
|
|
|
483
481
|
toolName: z.string(),
|
|
484
482
|
args: z.unknown()
|
|
485
483
|
});
|
|
484
|
+
var thinkingPartSchema = basePartSchema.extend({
|
|
485
|
+
type: z.literal("thinkingPart"),
|
|
486
|
+
thinking: z.string(),
|
|
487
|
+
signature: z.string().optional()
|
|
488
|
+
});
|
|
486
489
|
var toolResultPartSchema = basePartSchema.extend({
|
|
487
490
|
type: z.literal("toolResultPart"),
|
|
488
491
|
toolCallId: z.string(),
|
|
@@ -499,7 +502,8 @@ var messagePartSchema = z.discriminatedUnion("type", [
|
|
|
499
502
|
fileInlinePartSchema,
|
|
500
503
|
fileBinaryPartSchema,
|
|
501
504
|
toolCallPartSchema,
|
|
502
|
-
toolResultPartSchema
|
|
505
|
+
toolResultPartSchema,
|
|
506
|
+
thinkingPartSchema
|
|
503
507
|
]);
|
|
504
508
|
|
|
505
509
|
// src/schemas/message.ts
|
|
@@ -528,7 +532,7 @@ var userMessageSchema = baseMessageSchema.extend({
|
|
|
528
532
|
});
|
|
529
533
|
var expertMessageSchema = baseMessageSchema.extend({
|
|
530
534
|
type: z.literal("expertMessage"),
|
|
531
|
-
contents: z.array(z.union([textPartSchema, toolCallPartSchema])),
|
|
535
|
+
contents: z.array(z.union([textPartSchema, toolCallPartSchema, thinkingPartSchema])),
|
|
532
536
|
cache: z.boolean().optional()
|
|
533
537
|
});
|
|
534
538
|
var toolMessageSchema = baseMessageSchema.extend({
|
|
@@ -613,8 +617,74 @@ var checkpointSchema = z.object({
|
|
|
613
617
|
partialToolResults: z.array(toolResultSchema).optional(),
|
|
614
618
|
metadata: z.object({
|
|
615
619
|
runtime: runtimeNameSchema.optional()
|
|
616
|
-
}).passthrough().optional()
|
|
620
|
+
}).passthrough().optional(),
|
|
621
|
+
error: z.object({
|
|
622
|
+
name: z.string(),
|
|
623
|
+
message: z.string(),
|
|
624
|
+
statusCode: z.number().optional(),
|
|
625
|
+
isRetryable: z.boolean()
|
|
626
|
+
}).optional(),
|
|
627
|
+
retryCount: z.number().optional()
|
|
628
|
+
});
|
|
629
|
+
var anthropicProviderToolNameSchema = z.enum(["webSearch", "webFetch", "codeExecution"]);
|
|
630
|
+
var builtinAnthropicSkillSchema = z.object({
|
|
631
|
+
type: z.literal("builtin"),
|
|
632
|
+
skillId: z.enum(["pdf", "docx", "pptx", "xlsx"])
|
|
633
|
+
});
|
|
634
|
+
var customAnthropicSkillSchema = z.object({
|
|
635
|
+
type: z.literal("custom"),
|
|
636
|
+
name: z.string().min(1),
|
|
637
|
+
definition: z.string().min(1)
|
|
638
|
+
});
|
|
639
|
+
var anthropicProviderSkillSchema = z.discriminatedUnion("type", [
|
|
640
|
+
builtinAnthropicSkillSchema,
|
|
641
|
+
customAnthropicSkillSchema
|
|
642
|
+
]);
|
|
643
|
+
var openaiProviderToolNameSchema = z.enum([
|
|
644
|
+
"webSearch",
|
|
645
|
+
"fileSearch",
|
|
646
|
+
"codeInterpreter",
|
|
647
|
+
"imageGeneration"
|
|
648
|
+
]);
|
|
649
|
+
var googleProviderToolNameSchema = z.enum([
|
|
650
|
+
"googleSearch",
|
|
651
|
+
"codeExecution",
|
|
652
|
+
"urlContext",
|
|
653
|
+
"fileSearch",
|
|
654
|
+
"googleMaps"
|
|
655
|
+
]);
|
|
656
|
+
var azureOpenAIProviderToolNameSchema = z.enum([
|
|
657
|
+
"webSearchPreview",
|
|
658
|
+
"fileSearch",
|
|
659
|
+
"codeInterpreter",
|
|
660
|
+
"imageGeneration"
|
|
661
|
+
]);
|
|
662
|
+
var vertexProviderToolNameSchema = z.enum([
|
|
663
|
+
"codeExecution",
|
|
664
|
+
"urlContext",
|
|
665
|
+
"googleSearch",
|
|
666
|
+
"enterpriseWebSearch",
|
|
667
|
+
"googleMaps"
|
|
668
|
+
]);
|
|
669
|
+
var webSearchOptionsSchema = z.object({
|
|
670
|
+
maxUses: z.number().int().positive().optional(),
|
|
671
|
+
allowedDomains: z.array(z.string()).optional()
|
|
672
|
+
});
|
|
673
|
+
var webFetchOptionsSchema = z.object({
|
|
674
|
+
maxUses: z.number().int().positive().optional()
|
|
675
|
+
});
|
|
676
|
+
var fileSearchOptionsSchema = z.object({
|
|
677
|
+
vectorStoreIds: z.array(z.string()).optional(),
|
|
678
|
+
maxNumResults: z.number().int().positive().optional()
|
|
617
679
|
});
|
|
680
|
+
var providerToolOptionsSchema = z.object({
|
|
681
|
+
webSearch: webSearchOptionsSchema.optional(),
|
|
682
|
+
webFetch: webFetchOptionsSchema.optional(),
|
|
683
|
+
fileSearch: fileSearchOptionsSchema.optional()
|
|
684
|
+
}).optional();
|
|
685
|
+
function hasCustomProviderSkills(skills) {
|
|
686
|
+
return skills?.some((skill) => skill.type === "custom") ?? false;
|
|
687
|
+
}
|
|
618
688
|
function isPrivateOrLocalIP(hostname) {
|
|
619
689
|
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname === "0.0.0.0") {
|
|
620
690
|
return true;
|
|
@@ -666,7 +736,7 @@ var mcpStdioSkillSchema = z.object({
|
|
|
666
736
|
packageName: z.string().optional(),
|
|
667
737
|
args: z.array(z.string()).optional().default([]),
|
|
668
738
|
requiredEnv: z.array(z.string()).optional().default([]),
|
|
669
|
-
lazyInit: z.boolean().optional().default(
|
|
739
|
+
lazyInit: z.boolean().optional().default(false)
|
|
670
740
|
});
|
|
671
741
|
var mcpSseSkillSchema = z.object({
|
|
672
742
|
type: z.literal("mcpSseSkill"),
|
|
@@ -740,7 +810,10 @@ var expertSchema = z.object({
|
|
|
740
810
|
);
|
|
741
811
|
}),
|
|
742
812
|
delegates: z.array(z.string().regex(expertKeyRegex).min(1)).optional().default([]),
|
|
743
|
-
tags: z.array(z.string().regex(tagNameRegex).min(1)).optional().default([])
|
|
813
|
+
tags: z.array(z.string().regex(tagNameRegex).min(1)).optional().default([]),
|
|
814
|
+
providerTools: z.array(z.string()).optional(),
|
|
815
|
+
providerSkills: z.array(anthropicProviderSkillSchema).optional(),
|
|
816
|
+
providerToolOptions: providerToolOptionsSchema
|
|
744
817
|
});
|
|
745
818
|
var jobStatusSchema = z.enum([
|
|
746
819
|
"running",
|
|
@@ -759,6 +832,29 @@ var jobSchema = z.object({
|
|
|
759
832
|
startedAt: z.number(),
|
|
760
833
|
finishedAt: z.number().optional()
|
|
761
834
|
});
|
|
835
|
+
var lockfileToolDefinitionSchema = z.object({
|
|
836
|
+
skillName: z.string(),
|
|
837
|
+
name: z.string(),
|
|
838
|
+
description: z.string().optional(),
|
|
839
|
+
inputSchema: z.record(z.string(), z.unknown())
|
|
840
|
+
});
|
|
841
|
+
var lockfileExpertSchema = z.object({
|
|
842
|
+
key: z.string(),
|
|
843
|
+
name: z.string(),
|
|
844
|
+
version: z.string(),
|
|
845
|
+
description: z.string().optional(),
|
|
846
|
+
instruction: z.string(),
|
|
847
|
+
skills: z.record(z.string(), skillSchema),
|
|
848
|
+
delegates: z.array(z.string()),
|
|
849
|
+
tags: z.array(z.string()),
|
|
850
|
+
toolDefinitions: z.array(lockfileToolDefinitionSchema)
|
|
851
|
+
});
|
|
852
|
+
var lockfileSchema = z.object({
|
|
853
|
+
version: z.literal("1"),
|
|
854
|
+
generatedAt: z.number(),
|
|
855
|
+
configPath: z.string(),
|
|
856
|
+
experts: z.record(z.string(), lockfileExpertSchema)
|
|
857
|
+
});
|
|
762
858
|
var headersSchema = z.record(z.string(), z.string()).optional();
|
|
763
859
|
var providerNameSchema = z.enum([
|
|
764
860
|
"anthropic",
|
|
@@ -837,6 +933,12 @@ var providerConfigSchema = z.discriminatedUnion("providerName", [
|
|
|
837
933
|
]);
|
|
838
934
|
|
|
839
935
|
// src/schemas/perstack-toml.ts
|
|
936
|
+
var defaultReasoningBudget = "low";
|
|
937
|
+
var reasoningBudgetSchema = z.union([
|
|
938
|
+
z.enum(["none", "minimal", "low", "medium", "high"]),
|
|
939
|
+
z.number().int().nonnegative()
|
|
940
|
+
// 0 disables reasoning (same as "none")
|
|
941
|
+
]);
|
|
840
942
|
var domainPatternRegex = /^(\*\.)?[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)*$/;
|
|
841
943
|
var punycodeRegex = /(?:^|\.)(xn--)/i;
|
|
842
944
|
var domainPatternSchema = z.string().regex(domainPatternRegex, {
|
|
@@ -961,7 +1063,7 @@ var providerTableSchema = z.discriminatedUnion("providerName", [
|
|
|
961
1063
|
var perstackConfigSchema = z.object({
|
|
962
1064
|
provider: providerTableSchema.optional(),
|
|
963
1065
|
model: z.string().optional(),
|
|
964
|
-
|
|
1066
|
+
reasoningBudget: reasoningBudgetSchema.optional(),
|
|
965
1067
|
runtime: runtimeNameSchema.optional(),
|
|
966
1068
|
maxSteps: z.number().optional(),
|
|
967
1069
|
maxRetries: z.number().optional(),
|
|
@@ -986,7 +1088,8 @@ var perstackConfigSchema = z.object({
|
|
|
986
1088
|
packageName: z.string().optional(),
|
|
987
1089
|
args: z.array(z.string()).optional(),
|
|
988
1090
|
requiredEnv: z.array(z.string()).optional(),
|
|
989
|
-
allowedDomains: z.array(domainPatternSchema).optional()
|
|
1091
|
+
allowedDomains: z.array(domainPatternSchema).optional(),
|
|
1092
|
+
lazyInit: z.boolean().optional().default(false)
|
|
990
1093
|
}),
|
|
991
1094
|
z.object({
|
|
992
1095
|
type: z.literal("mcpSseSkill"),
|
|
@@ -1012,7 +1115,10 @@ var perstackConfigSchema = z.object({
|
|
|
1012
1115
|
])
|
|
1013
1116
|
).optional(),
|
|
1014
1117
|
delegates: z.array(z.string()).optional(),
|
|
1015
|
-
tags: z.array(z.string()).optional()
|
|
1118
|
+
tags: z.array(z.string()).optional(),
|
|
1119
|
+
providerTools: z.array(z.string()).optional(),
|
|
1120
|
+
providerSkills: z.array(anthropicProviderSkillSchema).optional(),
|
|
1121
|
+
providerToolOptions: providerToolOptionsSchema
|
|
1016
1122
|
})
|
|
1017
1123
|
).optional(),
|
|
1018
1124
|
perstackApiBaseUrl: z.url().refine((url) => url.startsWith("https://"), { message: "perstackApiBaseUrl must use HTTPS" }).optional(),
|
|
@@ -1023,12 +1129,15 @@ var commandOptionsSchema = z.object({
|
|
|
1023
1129
|
config: z.string().optional(),
|
|
1024
1130
|
provider: providerNameSchema.optional(),
|
|
1025
1131
|
model: z.string().optional(),
|
|
1026
|
-
|
|
1132
|
+
reasoningBudget: z.string().optional().transform((value) => {
|
|
1027
1133
|
if (value === void 0) return void 0;
|
|
1028
|
-
|
|
1134
|
+
if (["none", "minimal", "low", "medium", "high"].includes(value)) {
|
|
1135
|
+
return value;
|
|
1136
|
+
}
|
|
1137
|
+
const parsedValue = Number.parseInt(value, 10);
|
|
1029
1138
|
if (Number.isNaN(parsedValue)) return void 0;
|
|
1030
1139
|
return parsedValue;
|
|
1031
|
-
}),
|
|
1140
|
+
}).pipe(reasoningBudgetSchema.optional()),
|
|
1032
1141
|
maxSteps: z.string().optional().transform((value) => {
|
|
1033
1142
|
if (value === void 0) return void 0;
|
|
1034
1143
|
const parsedValue = Number.parseInt(value, 10);
|
|
@@ -1096,7 +1205,7 @@ var runSettingSchema = z.object({
|
|
|
1096
1205
|
}).optional()
|
|
1097
1206
|
}),
|
|
1098
1207
|
experts: z.record(z.string(), expertSchema),
|
|
1099
|
-
|
|
1208
|
+
reasoningBudget: reasoningBudgetSchema.default(defaultReasoningBudget),
|
|
1100
1209
|
maxSteps: z.number().min(1).optional().default(defaultMaxSteps),
|
|
1101
1210
|
maxRetries: z.number().min(0),
|
|
1102
1211
|
timeout: z.number().min(0),
|
|
@@ -1136,7 +1245,7 @@ var runParamsSchema = z.object({
|
|
|
1136
1245
|
])
|
|
1137
1246
|
)
|
|
1138
1247
|
),
|
|
1139
|
-
|
|
1248
|
+
reasoningBudget: reasoningBudgetSchema.optional().default(defaultReasoningBudget),
|
|
1140
1249
|
maxSteps: z.number().min(1).optional().default(defaultMaxSteps),
|
|
1141
1250
|
maxRetries: z.number().min(0).optional().default(defaultMaxRetries),
|
|
1142
1251
|
timeout: z.number().min(0).optional().default(defaultTimeout),
|
|
@@ -1172,7 +1281,6 @@ var callTools = createEvent("callTools");
|
|
|
1172
1281
|
var callInteractiveTool = createEvent("callInteractiveTool");
|
|
1173
1282
|
var callDelegate = createEvent("callDelegate");
|
|
1174
1283
|
var resolveToolResults = createEvent("resolveToolResults");
|
|
1175
|
-
var resolveThought = createEvent("resolveThought");
|
|
1176
1284
|
var attemptCompletion = createEvent("attemptCompletion");
|
|
1177
1285
|
var finishToolCall = createEvent("finishToolCall");
|
|
1178
1286
|
var resumeToolCalls = createEvent("resumeToolCalls");
|
|
@@ -1181,6 +1289,7 @@ var completeRun = createEvent("completeRun");
|
|
|
1181
1289
|
var stopRunByInteractiveTool = createEvent("stopRunByInteractiveTool");
|
|
1182
1290
|
var stopRunByDelegate = createEvent("stopRunByDelegate");
|
|
1183
1291
|
var stopRunByExceededMaxSteps = createEvent("stopRunByExceededMaxSteps");
|
|
1292
|
+
var stopRunByError = createEvent("stopRunByError");
|
|
1184
1293
|
var continueToNextStep = createEvent("continueToNextStep");
|
|
1185
1294
|
function createRuntimeEvent(type, jobId, runId, data) {
|
|
1186
1295
|
return {
|
|
@@ -1273,6 +1382,6 @@ function parseWithFriendlyError(schema, data, context) {
|
|
|
1273
1382
|
throw new Error(`${prefix}${formatZodError(result.error)}`);
|
|
1274
1383
|
}
|
|
1275
1384
|
|
|
1276
|
-
export { BaseAdapter, SAFE_ENV_VARS, amazonBedrockProviderConfigSchema, anthropicProviderConfigSchema, attemptCompletion, azureOpenAiProviderConfigSchema, basePartSchema, callDelegate, callInteractiveTool, callTools, checkpointSchema, checkpointStatusSchema, completeRun, continueToNextStep, createCallToolsEvent, createCompleteRunEvent, createEmptyUsage, createEvent, createNormalizedCheckpoint, createResolveToolResultsEvent, createRuntimeEvent, createRuntimeInitEvent, createStartRunEvent, createStreamingTextEvent, createToolMessage, deepseekProviderConfigSchema, defaultMaxRetries, defaultMaxSteps, defaultPerstackApiBaseUrl,
|
|
1385
|
+
export { BaseAdapter, SAFE_ENV_VARS, amazonBedrockProviderConfigSchema, anthropicProviderConfigSchema, anthropicProviderSkillSchema, anthropicProviderToolNameSchema, attemptCompletion, azureOpenAIProviderToolNameSchema, azureOpenAiProviderConfigSchema, basePartSchema, builtinAnthropicSkillSchema, callDelegate, callInteractiveTool, callTools, checkpointSchema, checkpointStatusSchema, completeRun, continueToNextStep, createCallToolsEvent, createCompleteRunEvent, createEmptyUsage, createEvent, createNormalizedCheckpoint, createResolveToolResultsEvent, createRuntimeEvent, createRuntimeInitEvent, createStartRunEvent, createStreamingTextEvent, createToolMessage, customAnthropicSkillSchema, deepseekProviderConfigSchema, defaultMaxRetries, defaultMaxSteps, defaultPerstackApiBaseUrl, defaultReasoningBudget, defaultTimeout, delegationTargetSchema, domainPatternSchema, envNameRegex, expertKeyRegex, expertMessageSchema, expertNameRegex, expertSchema, expertVersionRegex, fileBinaryPartSchema, fileInlinePartSchema, fileSearchOptionsSchema, fileUrlPartSchema, finishAllToolCalls, finishToolCall, formatZodError, getAdapter, getFilteredEnv, getRegisteredRuntimes, googleGenerativeAiProviderConfigSchema, googleProviderToolNameSchema, googleVertexProviderConfigSchema, hasCustomProviderSkills, headersSchema, imageBinaryPartSchema, imageInlinePartSchema, imageUrlPartSchema, instructionMessageSchema, interactiveSkillSchema, interactiveToolSchema, isAdapterAvailable, jobSchema, jobStatusSchema, knownModels, lockfileExpertSchema, lockfileSchema, lockfileToolDefinitionSchema, maxApplicationNameLength, maxCheckpointToolCallIdLength, maxEnvNameLength, maxExpertDelegateItems, maxExpertDescriptionLength, maxExpertInstructionLength, maxExpertJobFileNameLength, maxExpertJobQueryLength, maxExpertKeyLength, maxExpertNameLength, maxExpertSkillItems, maxExpertTagItems, maxExpertVersionTagLength, maxOrganizationNameLength, maxSkillDescriptionLength, maxSkillEndpointLength, maxSkillInputJsonSchemaLength, maxSkillNameLength, maxSkillPickOmitItems, maxSkillRequiredEnvItems, maxSkillRuleLength, maxSkillToolItems, maxSkillToolNameLength, mcpSseSkillSchema, mcpStdioSkillSchema, messagePartSchema, messageSchema, ollamaProviderConfigSchema, openAiProviderConfigSchema, openaiProviderToolNameSchema, organizationNameRegex, packageWithVersionRegex, parseExpertKey, parseWithFriendlyError, perstackConfigSchema, providerConfigSchema, providerNameSchema, providerTableSchema, providerToolOptionsSchema, reasoningBudgetSchema, registerAdapter, resolveToolResults, resumeToolCalls, retry, runCommandInputSchema, runParamsSchema, runSettingSchema, runtimeNameSchema, skillSchema, startCommandInputSchema, startGeneration, startRun, stepSchema, stopRunByDelegate, stopRunByError, stopRunByExceededMaxSteps, stopRunByInteractiveTool, tagNameRegex, textPartSchema, thinkingPartSchema, toolCallPartSchema, toolCallSchema, toolMessageSchema, toolResultPartSchema, toolResultSchema, urlSafeRegex, usageSchema, userMessageSchema, vertexProviderToolNameSchema, webFetchOptionsSchema, webSearchOptionsSchema };
|
|
1277
1386
|
//# sourceMappingURL=index.js.map
|
|
1278
1387
|
//# sourceMappingURL=index.js.map
|