@perstack/core 0.0.43 → 0.0.44
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 +7 -40
- package/dist/src/index.d.ts +7 -232
- package/dist/src/index.js +8 -96
- package/dist/src/index.js.map +1 -1
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -12,7 +12,7 @@ function createEmptyUsage() {
|
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
function createNormalizedCheckpoint(params) {
|
|
15
|
-
const { jobId, runId, expert, output
|
|
15
|
+
const { jobId, runId, expert, output } = params;
|
|
16
16
|
const checkpointId = createId();
|
|
17
17
|
const expertMessage = {
|
|
18
18
|
id: createId(),
|
|
@@ -27,8 +27,7 @@ function createNormalizedCheckpoint(params) {
|
|
|
27
27
|
stepNumber: 1,
|
|
28
28
|
messages: [expertMessage],
|
|
29
29
|
expert: { key: expert.key, name: expert.name, version: expert.version },
|
|
30
|
-
usage: createEmptyUsage()
|
|
31
|
-
metadata: { runtime }
|
|
30
|
+
usage: createEmptyUsage()
|
|
32
31
|
};
|
|
33
32
|
}
|
|
34
33
|
function createStartRunEvent(jobId, runId, expertKey, checkpoint) {
|
|
@@ -44,7 +43,7 @@ function createStartRunEvent(jobId, runId, expertKey, checkpoint) {
|
|
|
44
43
|
inputMessages: []
|
|
45
44
|
};
|
|
46
45
|
}
|
|
47
|
-
function createRuntimeInitEvent(jobId, runId, expertName,
|
|
46
|
+
function createRuntimeInitEvent(jobId, runId, expertName, version, query) {
|
|
48
47
|
return {
|
|
49
48
|
type: "initializeRuntime",
|
|
50
49
|
id: createId(),
|
|
@@ -52,10 +51,9 @@ function createRuntimeInitEvent(jobId, runId, expertName, runtime, version, quer
|
|
|
52
51
|
jobId,
|
|
53
52
|
runId,
|
|
54
53
|
runtimeVersion: version,
|
|
55
|
-
runtime,
|
|
56
54
|
expertName,
|
|
57
55
|
experts: [],
|
|
58
|
-
model:
|
|
56
|
+
model: "local:default",
|
|
59
57
|
maxRetries: 0,
|
|
60
58
|
timeout: 0,
|
|
61
59
|
query
|
|
@@ -129,63 +127,18 @@ function createToolMessage(toolCallId, toolName, resultText) {
|
|
|
129
127
|
};
|
|
130
128
|
}
|
|
131
129
|
|
|
132
|
-
// src/adapters/registry.ts
|
|
133
|
-
var adapters = /* @__PURE__ */ new Map();
|
|
134
|
-
function registerAdapter(runtime, factory) {
|
|
135
|
-
adapters.set(runtime, factory);
|
|
136
|
-
}
|
|
137
|
-
function getAdapter(runtime) {
|
|
138
|
-
const factory = adapters.get(runtime);
|
|
139
|
-
if (!factory) {
|
|
140
|
-
throw new Error(
|
|
141
|
-
`Runtime "${runtime}" is not registered. Available runtimes: ${Array.from(adapters.keys()).join(", ")}`
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
return factory();
|
|
145
|
-
}
|
|
146
|
-
function isAdapterAvailable(runtime) {
|
|
147
|
-
return adapters.has(runtime);
|
|
148
|
-
}
|
|
149
|
-
function getRegisteredRuntimes() {
|
|
150
|
-
return Array.from(adapters.keys());
|
|
151
|
-
}
|
|
152
|
-
|
|
153
130
|
// src/constants/constants.ts
|
|
154
131
|
var defaultPerstackApiBaseUrl = "https://api.perstack.ai";
|
|
155
|
-
var organizationNameRegex = /^[a-z0-9][a-z0-9_.-]*$/;
|
|
156
|
-
var maxOrganizationNameLength = 128;
|
|
157
|
-
var maxApplicationNameLength = 255;
|
|
158
132
|
var expertKeyRegex = /^((?:@[a-z0-9][a-z0-9_.-]*\/)?[a-z0-9][a-z0-9_.-]*)(?:@((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\w.-]+)?(?:\+[\w.-]+)?)|@([a-z0-9][a-z0-9_.-]*))?$/;
|
|
159
133
|
var expertNameRegex = /^(@[a-z0-9][a-z0-9_-]*\/)?[a-z0-9][a-z0-9_-]*$/;
|
|
160
134
|
var expertVersionRegex = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\w.-]+)?(?:\+[\w.-]+)?$/;
|
|
161
135
|
var tagNameRegex = /^[a-z0-9][a-z0-9_-]*$/;
|
|
162
136
|
var maxExpertNameLength = 255;
|
|
163
|
-
var maxExpertVersionTagLength = 255;
|
|
164
|
-
var maxExpertKeyLength = 511;
|
|
165
|
-
var maxExpertDescriptionLength = 1024 * 2;
|
|
166
|
-
var maxExpertInstructionLength = 1024 * 20;
|
|
167
|
-
var maxExpertSkillItems = 255;
|
|
168
|
-
var maxExpertDelegateItems = 255;
|
|
169
|
-
var maxExpertTagItems = 8;
|
|
170
137
|
var defaultMaxSteps = 100;
|
|
171
138
|
var defaultMaxRetries = 5;
|
|
172
139
|
var defaultTimeout = 5 * 1e3 * 60;
|
|
173
|
-
var maxExpertJobQueryLength = 1024 * 20;
|
|
174
|
-
var maxExpertJobFileNameLength = 1024 * 10;
|
|
175
|
-
var packageWithVersionRegex = /^(?:@[a-z0-9][a-z0-9_.-]*\/)?[a-z0-9][a-z0-9_.-]*(?:@(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\w.-]+)?(?:\+[\w.-]+)?|@[a-z0-9][a-z0-9_.-]*)?$/;
|
|
176
|
-
var urlSafeRegex = /^[a-z0-9][a-z0-9_-]*$/;
|
|
177
140
|
var maxSkillNameLength = 255;
|
|
178
|
-
var maxSkillDescriptionLength = 1024 * 2;
|
|
179
|
-
var maxSkillRuleLength = 1024 * 2;
|
|
180
|
-
var maxSkillPickOmitItems = 255;
|
|
181
|
-
var maxSkillRequiredEnvItems = 255;
|
|
182
141
|
var maxSkillToolNameLength = 255;
|
|
183
|
-
var maxSkillEndpointLength = 1024 * 2;
|
|
184
|
-
var maxSkillInputJsonSchemaLength = 1024 * 20;
|
|
185
|
-
var maxSkillToolItems = 255;
|
|
186
|
-
var maxCheckpointToolCallIdLength = 255;
|
|
187
|
-
var envNameRegex = /^[a-zA-Z0-9][a-zA-Z0-9_-]*$/;
|
|
188
|
-
var maxEnvNameLength = 255;
|
|
189
142
|
|
|
190
143
|
// src/known-models/index.ts
|
|
191
144
|
var knownModels = [
|
|
@@ -691,7 +644,6 @@ var messageSchema = z.union([
|
|
|
691
644
|
expertMessageSchema,
|
|
692
645
|
toolMessageSchema
|
|
693
646
|
]);
|
|
694
|
-
var runtimeNameSchema = z.enum(["local", "cursor", "claude-code", "gemini", "docker"]);
|
|
695
647
|
var toolCallSchema = z.object({
|
|
696
648
|
id: z.string().min(1).max(255),
|
|
697
649
|
skillName: z.string().min(1).max(maxSkillNameLength),
|
|
@@ -762,9 +714,7 @@ var checkpointSchema = z.object({
|
|
|
762
714
|
contextWindowUsage: z.number().optional(),
|
|
763
715
|
pendingToolCalls: z.array(toolCallSchema).optional(),
|
|
764
716
|
partialToolResults: z.array(toolResultSchema).optional(),
|
|
765
|
-
metadata: z.object({
|
|
766
|
-
runtime: runtimeNameSchema.optional()
|
|
767
|
-
}).passthrough().optional(),
|
|
717
|
+
metadata: z.object({}).passthrough().optional(),
|
|
768
718
|
error: z.object({
|
|
769
719
|
name: z.string(),
|
|
770
720
|
message: z.string(),
|
|
@@ -829,9 +779,6 @@ var providerToolOptionsSchema = z.object({
|
|
|
829
779
|
webFetch: webFetchOptionsSchema.optional(),
|
|
830
780
|
fileSearch: fileSearchOptionsSchema.optional()
|
|
831
781
|
}).optional();
|
|
832
|
-
function hasCustomProviderSkills(skills) {
|
|
833
|
-
return skills?.some((skill) => skill.type === "custom") ?? false;
|
|
834
|
-
}
|
|
835
782
|
var runtimeVersionSchema = z.string().regex(/^v\d+\.\d+$/, 'Runtime version must be in format "vX.Y" (e.g., "v1.0")').transform((v) => v);
|
|
836
783
|
function isPrivateOrLocalIP(hostname) {
|
|
837
784
|
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname === "0.0.0.0") {
|
|
@@ -1097,39 +1044,12 @@ var domainPatternSchema = z.string().regex(domainPatternRegex, {
|
|
|
1097
1044
|
}).refine((domain) => !punycodeRegex.test(domain), {
|
|
1098
1045
|
message: "Punycode domains (xn--) are not allowed to prevent homograph attacks. Use ASCII domains only."
|
|
1099
1046
|
});
|
|
1100
|
-
function isPrivateOrLocalIP2(hostname) {
|
|
1101
|
-
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname === "0.0.0.0") {
|
|
1102
|
-
return true;
|
|
1103
|
-
}
|
|
1104
|
-
const ipv4Match = hostname.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
|
|
1105
|
-
if (ipv4Match) {
|
|
1106
|
-
const a = Number(ipv4Match[1]);
|
|
1107
|
-
const b = Number(ipv4Match[2]);
|
|
1108
|
-
if (a === 10) return true;
|
|
1109
|
-
if (a === 172 && b >= 16 && b <= 31) return true;
|
|
1110
|
-
if (a === 192 && b === 168) return true;
|
|
1111
|
-
if (a === 169 && b === 254) return true;
|
|
1112
|
-
if (a === 127) return true;
|
|
1113
|
-
}
|
|
1114
|
-
if (hostname.includes(":")) {
|
|
1115
|
-
if (hostname.startsWith("fe80:") || hostname.startsWith("fc") || hostname.startsWith("fd")) {
|
|
1116
|
-
return true;
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
if (hostname.startsWith("::ffff:")) {
|
|
1120
|
-
const ipv4Part = hostname.slice(7);
|
|
1121
|
-
if (isPrivateOrLocalIP2(ipv4Part)) {
|
|
1122
|
-
return true;
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1125
|
-
return false;
|
|
1126
|
-
}
|
|
1127
1047
|
var sseEndpointSchema2 = z.string().url().refine(
|
|
1128
1048
|
(url) => {
|
|
1129
1049
|
try {
|
|
1130
1050
|
const parsed = new URL(url);
|
|
1131
1051
|
if (parsed.protocol !== "https:") return false;
|
|
1132
|
-
if (
|
|
1052
|
+
if (isPrivateOrLocalIP(parsed.hostname)) return false;
|
|
1133
1053
|
return true;
|
|
1134
1054
|
} catch {
|
|
1135
1055
|
return false;
|
|
@@ -1215,7 +1135,6 @@ var perstackConfigSchema = z.object({
|
|
|
1215
1135
|
provider: providerTableSchema.optional(),
|
|
1216
1136
|
model: z.string().optional(),
|
|
1217
1137
|
reasoningBudget: reasoningBudgetSchema.optional(),
|
|
1218
|
-
runtime: runtimeNameSchema.optional(),
|
|
1219
1138
|
maxSteps: z.number().optional(),
|
|
1220
1139
|
maxRetries: z.number().optional(),
|
|
1221
1140
|
timeout: z.number().optional(),
|
|
@@ -1310,15 +1229,11 @@ var commandOptionsSchema = z.object({
|
|
|
1310
1229
|
jobId: z.string().optional(),
|
|
1311
1230
|
runId: z.string().optional(),
|
|
1312
1231
|
envPath: z.array(z.string()).optional().transform((value) => value && value.length > 0 ? value : void 0),
|
|
1313
|
-
env: z.array(z.string()).optional().transform((value) => value && value.length > 0 ? value : void 0),
|
|
1314
1232
|
verbose: z.boolean().optional(),
|
|
1315
1233
|
continue: z.boolean().optional(),
|
|
1316
1234
|
continueJob: z.string().optional(),
|
|
1317
1235
|
resumeFrom: z.string().optional(),
|
|
1318
1236
|
interactiveToolCallResult: z.boolean().optional(),
|
|
1319
|
-
runtime: runtimeNameSchema.optional(),
|
|
1320
|
-
workspace: z.string().optional(),
|
|
1321
|
-
volume: z.array(z.string()).optional().transform((value) => value && value.length > 0 ? value : void 0),
|
|
1322
1237
|
filter: z.string().optional().transform((value) => {
|
|
1323
1238
|
if (value === void 0) return void 0;
|
|
1324
1239
|
return value.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
@@ -1503,10 +1418,7 @@ var RUNTIME_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
|
1503
1418
|
"skillStarting",
|
|
1504
1419
|
"skillConnected",
|
|
1505
1420
|
"skillStderr",
|
|
1506
|
-
"skillDisconnected"
|
|
1507
|
-
"dockerBuildProgress",
|
|
1508
|
-
"dockerContainerStatus",
|
|
1509
|
-
"proxyAccess"
|
|
1421
|
+
"skillDisconnected"
|
|
1510
1422
|
]);
|
|
1511
1423
|
function isValidEventType(type) {
|
|
1512
1424
|
return EXPERT_STATE_EVENT_TYPES.has(type) || STREAMING_EVENT_TYPES.has(type);
|
|
@@ -2075,6 +1987,6 @@ function parseWithFriendlyError(schema, data, context) {
|
|
|
2075
1987
|
throw new Error(`${prefix}${formatZodError(result.error)}`);
|
|
2076
1988
|
}
|
|
2077
1989
|
|
|
2078
|
-
export { BASE_SKILL_PREFIX, SAFE_ENV_VARS, activityOrGroupSchema, activitySchema, amazonBedrockProviderConfigSchema, anthropicProviderConfigSchema, anthropicProviderSkillSchema, anthropicProviderToolNameSchema, appendTextFileActivitySchema, attemptCompletion, attemptCompletionActivitySchema, azureOpenAIProviderToolNameSchema, azureOpenAiProviderConfigSchema, basePartSchema, builtinAnthropicSkillSchema, callTools, checkpointSchema, checkpointStatusSchema, clearTodoActivitySchema, completeActivitySchema, completeRun, continueToNextStep, createBaseToolActivity, createCallToolsEvent, createCompleteRunEvent, createDirectoryActivitySchema, createEmptyUsage, createEvent, createFilteredEventListener, createGeneralToolActivity, createNormalizedCheckpoint, createResolveToolResultsEvent, createRuntimeEvent, createRuntimeInitEvent, createStartRunEvent, createStreamingEvent, createToolMessage, customAnthropicSkillSchema, deepseekProviderConfigSchema, defaultMaxRetries, defaultMaxSteps, defaultPerstackApiBaseUrl, defaultReasoningBudget, defaultTimeout, delegateActivitySchema, delegationCompleteActivitySchema, delegationTargetSchema, deleteDirectoryActivitySchema, deleteFileActivitySchema, domainPatternSchema, editTextFileActivitySchema,
|
|
1990
|
+
export { BASE_SKILL_PREFIX, SAFE_ENV_VARS, activityOrGroupSchema, activitySchema, amazonBedrockProviderConfigSchema, anthropicProviderConfigSchema, anthropicProviderSkillSchema, anthropicProviderToolNameSchema, appendTextFileActivitySchema, attemptCompletion, attemptCompletionActivitySchema, azureOpenAIProviderToolNameSchema, azureOpenAiProviderConfigSchema, basePartSchema, builtinAnthropicSkillSchema, callTools, checkpointSchema, checkpointStatusSchema, clearTodoActivitySchema, completeActivitySchema, completeRun, continueToNextStep, createBaseToolActivity, createCallToolsEvent, createCompleteRunEvent, createDirectoryActivitySchema, createEmptyUsage, createEvent, createFilteredEventListener, createGeneralToolActivity, createNormalizedCheckpoint, createResolveToolResultsEvent, createRuntimeEvent, createRuntimeInitEvent, createStartRunEvent, createStreamingEvent, createToolMessage, customAnthropicSkillSchema, deepseekProviderConfigSchema, defaultMaxRetries, defaultMaxSteps, defaultPerstackApiBaseUrl, defaultReasoningBudget, defaultTimeout, delegateActivitySchema, delegationCompleteActivitySchema, delegationTargetSchema, deleteDirectoryActivitySchema, deleteFileActivitySchema, domainPatternSchema, editTextFileActivitySchema, errorActivitySchema, execActivitySchema, expertKeyRegex, expertMessageSchema, expertNameRegex, expertSchema, expertVersionRegex, fileBinaryPartSchema, fileInlinePartSchema, fileSearchOptionsSchema, fileUrlPartSchema, finishMcpTools, finishToolCall, formatZodError, generalToolActivitySchema, getActivities, getFileInfoActivitySchema, getFilteredEnv, googleGenerativeAiProviderConfigSchema, googleProviderToolNameSchema, googleVertexProviderConfigSchema, headersSchema, imageBinaryPartSchema, imageInlinePartSchema, imageUrlPartSchema, instructionMessageSchema, interactiveSkillSchema, interactiveToolActivitySchema, interactiveToolSchema, isPrivateOrLocalIP, isValidEventType, isValidRuntimeEventType, jobSchema, jobStatusSchema, knownModels, listDirectoryActivitySchema, lockfileExpertSchema, lockfileSchema, lockfileToolDefinitionSchema, maxExpertNameLength, maxSkillNameLength, maxSkillToolNameLength, mcpSseSkillSchema, mcpStdioSkillSchema, messagePartSchema, messageSchema, moveFileActivitySchema, ollamaProviderConfigSchema, openAiProviderConfigSchema, openaiProviderToolNameSchema, parallelActivitiesGroupSchema, parseExpertKey, parseWithFriendlyError, perstackConfigSchema, proceedToInteractiveTools, providerConfigSchema, providerNameSchema, providerTableSchema, providerToolOptionsSchema, queryActivitySchema, readImageFileActivitySchema, readPdfFileActivitySchema, readTextFileActivitySchema, reasoningBudgetSchema, resolveToolResults, resumeFromStop, resumeToolCalls, retry, retryActivitySchema, runCommandInputSchema, runParamsSchema, runSettingSchema, runtimeVersionSchema, skillSchema, skipDelegates, startCommandInputSchema, startGeneration, startRun, stepSchema, stopRunByDelegate, stopRunByError, stopRunByExceededMaxSteps, stopRunByInteractiveTool, tagNameRegex, textPartSchema, thinkingPartSchema, todoActivitySchema, toolCallPartSchema, toolCallSchema, toolMessageSchema, toolResultPartSchema, toolResultSchema, usageSchema, userMessageSchema, validateEventFilter, vertexProviderToolNameSchema, webFetchOptionsSchema, webSearchOptionsSchema, writeTextFileActivitySchema };
|
|
2079
1991
|
//# sourceMappingURL=index.js.map
|
|
2080
1992
|
//# sourceMappingURL=index.js.map
|