@perstack/core 0.0.42 → 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/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, runtime } = params;
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, runtime, version, query) {
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: `${runtime}:default`,
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),
@@ -720,7 +672,8 @@ var checkpointStatusSchema = z.enum([
720
672
  "stoppedByInteractiveTool",
721
673
  "stoppedByDelegate",
722
674
  "stoppedByExceededMaxSteps",
723
- "stoppedByError"
675
+ "stoppedByError",
676
+ "stoppedByCancellation"
724
677
  ]);
725
678
  var delegationTargetSchema = z.object({
726
679
  expert: z.object({
@@ -761,9 +714,7 @@ var checkpointSchema = z.object({
761
714
  contextWindowUsage: z.number().optional(),
762
715
  pendingToolCalls: z.array(toolCallSchema).optional(),
763
716
  partialToolResults: z.array(toolResultSchema).optional(),
764
- metadata: z.object({
765
- runtime: runtimeNameSchema.optional()
766
- }).passthrough().optional(),
717
+ metadata: z.object({}).passthrough().optional(),
767
718
  error: z.object({
768
719
  name: z.string(),
769
720
  message: z.string(),
@@ -828,10 +779,7 @@ var providerToolOptionsSchema = z.object({
828
779
  webFetch: webFetchOptionsSchema.optional(),
829
780
  fileSearch: fileSearchOptionsSchema.optional()
830
781
  }).optional();
831
- function hasCustomProviderSkills(skills) {
832
- return skills?.some((skill) => skill.type === "custom") ?? false;
833
- }
834
- var runtimeVersionSchema = z.enum(["v1.0"]);
782
+ var runtimeVersionSchema = z.string().regex(/^v\d+\.\d+$/, 'Runtime version must be in format "vX.Y" (e.g., "v1.0")').transform((v) => v);
835
783
  function isPrivateOrLocalIP(hostname) {
836
784
  if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname === "0.0.0.0") {
837
785
  return true;
@@ -968,7 +916,8 @@ var jobStatusSchema = z.enum([
968
916
  "completed",
969
917
  "stoppedByMaxSteps",
970
918
  "stoppedByInteractiveTool",
971
- "stoppedByError"
919
+ "stoppedByError",
920
+ "stoppedByCancellation"
972
921
  ]);
973
922
  var jobSchema = z.object({
974
923
  id: z.string(),
@@ -1095,39 +1044,12 @@ var domainPatternSchema = z.string().regex(domainPatternRegex, {
1095
1044
  }).refine((domain) => !punycodeRegex.test(domain), {
1096
1045
  message: "Punycode domains (xn--) are not allowed to prevent homograph attacks. Use ASCII domains only."
1097
1046
  });
1098
- function isPrivateOrLocalIP2(hostname) {
1099
- if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname === "0.0.0.0") {
1100
- return true;
1101
- }
1102
- const ipv4Match = hostname.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
1103
- if (ipv4Match) {
1104
- const a = Number(ipv4Match[1]);
1105
- const b = Number(ipv4Match[2]);
1106
- if (a === 10) return true;
1107
- if (a === 172 && b >= 16 && b <= 31) return true;
1108
- if (a === 192 && b === 168) return true;
1109
- if (a === 169 && b === 254) return true;
1110
- if (a === 127) return true;
1111
- }
1112
- if (hostname.includes(":")) {
1113
- if (hostname.startsWith("fe80:") || hostname.startsWith("fc") || hostname.startsWith("fd")) {
1114
- return true;
1115
- }
1116
- }
1117
- if (hostname.startsWith("::ffff:")) {
1118
- const ipv4Part = hostname.slice(7);
1119
- if (isPrivateOrLocalIP2(ipv4Part)) {
1120
- return true;
1121
- }
1122
- }
1123
- return false;
1124
- }
1125
1047
  var sseEndpointSchema2 = z.string().url().refine(
1126
1048
  (url) => {
1127
1049
  try {
1128
1050
  const parsed = new URL(url);
1129
1051
  if (parsed.protocol !== "https:") return false;
1130
- if (isPrivateOrLocalIP2(parsed.hostname)) return false;
1052
+ if (isPrivateOrLocalIP(parsed.hostname)) return false;
1131
1053
  return true;
1132
1054
  } catch {
1133
1055
  return false;
@@ -1213,7 +1135,6 @@ var perstackConfigSchema = z.object({
1213
1135
  provider: providerTableSchema.optional(),
1214
1136
  model: z.string().optional(),
1215
1137
  reasoningBudget: reasoningBudgetSchema.optional(),
1216
- runtime: runtimeNameSchema.optional(),
1217
1138
  maxSteps: z.number().optional(),
1218
1139
  maxRetries: z.number().optional(),
1219
1140
  timeout: z.number().optional(),
@@ -1308,15 +1229,11 @@ var commandOptionsSchema = z.object({
1308
1229
  jobId: z.string().optional(),
1309
1230
  runId: z.string().optional(),
1310
1231
  envPath: z.array(z.string()).optional().transform((value) => value && value.length > 0 ? value : void 0),
1311
- env: z.array(z.string()).optional().transform((value) => value && value.length > 0 ? value : void 0),
1312
1232
  verbose: z.boolean().optional(),
1313
1233
  continue: z.boolean().optional(),
1314
1234
  continueJob: z.string().optional(),
1315
1235
  resumeFrom: z.string().optional(),
1316
1236
  interactiveToolCallResult: z.boolean().optional(),
1317
- runtime: runtimeNameSchema.optional(),
1318
- workspace: z.string().optional(),
1319
- volume: z.array(z.string()).optional().transform((value) => value && value.length > 0 ? value : void 0),
1320
1237
  filter: z.string().optional().transform((value) => {
1321
1238
  if (value === void 0) return void 0;
1322
1239
  return value.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
@@ -1501,10 +1418,7 @@ var RUNTIME_EVENT_TYPES = /* @__PURE__ */ new Set([
1501
1418
  "skillStarting",
1502
1419
  "skillConnected",
1503
1420
  "skillStderr",
1504
- "skillDisconnected",
1505
- "dockerBuildProgress",
1506
- "dockerContainerStatus",
1507
- "proxyAccess"
1421
+ "skillDisconnected"
1508
1422
  ]);
1509
1423
  function isValidEventType(type) {
1510
1424
  return EXPERT_STATE_EVENT_TYPES.has(type) || STREAMING_EVENT_TYPES.has(type);
@@ -2073,6 +1987,6 @@ function parseWithFriendlyError(schema, data, context) {
2073
1987
  throw new Error(`${prefix}${formatZodError(result.error)}`);
2074
1988
  }
2075
1989
 
2076
- 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, envNameRegex, errorActivitySchema, execActivitySchema, expertKeyRegex, expertMessageSchema, expertNameRegex, expertSchema, expertVersionRegex, fileBinaryPartSchema, fileInlinePartSchema, fileSearchOptionsSchema, fileUrlPartSchema, finishMcpTools, finishToolCall, formatZodError, generalToolActivitySchema, getActivities, getAdapter, getFileInfoActivitySchema, getFilteredEnv, getRegisteredRuntimes, googleGenerativeAiProviderConfigSchema, googleProviderToolNameSchema, googleVertexProviderConfigSchema, hasCustomProviderSkills, headersSchema, imageBinaryPartSchema, imageInlinePartSchema, imageUrlPartSchema, instructionMessageSchema, interactiveSkillSchema, interactiveToolActivitySchema, interactiveToolSchema, isAdapterAvailable, isValidEventType, isValidRuntimeEventType, jobSchema, jobStatusSchema, knownModels, listDirectoryActivitySchema, 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, moveFileActivitySchema, ollamaProviderConfigSchema, openAiProviderConfigSchema, openaiProviderToolNameSchema, organizationNameRegex, packageWithVersionRegex, parallelActivitiesGroupSchema, parseExpertKey, parseWithFriendlyError, perstackConfigSchema, proceedToInteractiveTools, providerConfigSchema, providerNameSchema, providerTableSchema, providerToolOptionsSchema, queryActivitySchema, readImageFileActivitySchema, readPdfFileActivitySchema, readTextFileActivitySchema, reasoningBudgetSchema, registerAdapter, resolveToolResults, resumeFromStop, resumeToolCalls, retry, retryActivitySchema, runCommandInputSchema, runParamsSchema, runSettingSchema, runtimeNameSchema, runtimeVersionSchema, skillSchema, skipDelegates, startCommandInputSchema, startGeneration, startRun, stepSchema, stopRunByDelegate, stopRunByError, stopRunByExceededMaxSteps, stopRunByInteractiveTool, tagNameRegex, textPartSchema, thinkingPartSchema, todoActivitySchema, toolCallPartSchema, toolCallSchema, toolMessageSchema, toolResultPartSchema, toolResultSchema, urlSafeRegex, usageSchema, userMessageSchema, validateEventFilter, vertexProviderToolNameSchema, webFetchOptionsSchema, webSearchOptionsSchema, writeTextFileActivitySchema };
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 };
2077
1991
  //# sourceMappingURL=index.js.map
2078
1992
  //# sourceMappingURL=index.js.map