@perstack/core 0.0.45 → 0.0.47

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
@@ -140,12 +140,25 @@ var defaultTimeout = 5 * 1e3 * 60;
140
140
  var maxSkillNameLength = 255;
141
141
  var maxSkillToolNameLength = 255;
142
142
 
143
+ // src/errors.ts
144
+ var PerstackError = class extends Error {
145
+ constructor(message) {
146
+ super(message);
147
+ this.name = "PerstackError";
148
+ }
149
+ };
150
+
143
151
  // src/known-models/index.ts
144
152
  var knownModels = [
145
153
  {
146
154
  provider: "anthropic",
147
155
  models: [
148
156
  // https://docs.claude.com/en/docs/about-claude/models/overview#model-comparison-table
157
+ {
158
+ name: "claude-opus-4-6",
159
+ contextWindow: 2e5,
160
+ maxOutputTokens: 128e3
161
+ },
149
162
  {
150
163
  name: "claude-opus-4-5",
151
164
  contextWindow: 2e5,
@@ -191,6 +204,12 @@ var knownModels = [
191
204
  {
192
205
  provider: "google",
193
206
  models: [
207
+ // https://ai.google.dev/gemini-api/docs/models#gemini-3-flash
208
+ {
209
+ name: "gemini-3-flash-preview",
210
+ contextWindow: 1048576,
211
+ maxOutputTokens: 65536
212
+ },
194
213
  // https://ai.google.dev/gemini-api/docs/models#gemini-3-pro
195
214
  {
196
215
  name: "gemini-3-pro-preview",
@@ -238,6 +257,24 @@ var knownModels = [
238
257
  contextWindow: 4e5,
239
258
  maxOutputTokens: 128e3
240
259
  },
260
+ // https://platform.openai.com/docs/models/gpt-5.2
261
+ {
262
+ name: "gpt-5.2",
263
+ contextWindow: 4e5,
264
+ maxOutputTokens: 128e3
265
+ },
266
+ // https://platform.openai.com/docs/models/gpt-5.2-pro
267
+ {
268
+ name: "gpt-5.2-pro",
269
+ contextWindow: 4e5,
270
+ maxOutputTokens: 128e3
271
+ },
272
+ // https://platform.openai.com/docs/models/gpt-5.1
273
+ {
274
+ name: "gpt-5.1",
275
+ contextWindow: 4e5,
276
+ maxOutputTokens: 128e3
277
+ },
241
278
  // https://platform.openai.com/docs/models/gpt-5-chat-latest
242
279
  {
243
280
  name: "gpt-5-chat-latest",
@@ -471,72 +508,12 @@ var editTextFileActivitySchema = baseActivitySchema.extend({
471
508
  oldText: z.string(),
472
509
  error: z.string().optional()
473
510
  });
474
- var appendTextFileActivitySchema = baseActivitySchema.extend({
475
- type: z.literal("appendTextFile"),
476
- path: z.string(),
477
- text: z.string(),
478
- error: z.string().optional()
479
- });
480
511
  var writeTextFileActivitySchema = baseActivitySchema.extend({
481
512
  type: z.literal("writeTextFile"),
482
513
  path: z.string(),
483
514
  text: z.string(),
484
515
  error: z.string().optional()
485
516
  });
486
- var deleteFileActivitySchema = baseActivitySchema.extend({
487
- type: z.literal("deleteFile"),
488
- path: z.string(),
489
- error: z.string().optional()
490
- });
491
- var deleteDirectoryActivitySchema = baseActivitySchema.extend({
492
- type: z.literal("deleteDirectory"),
493
- path: z.string(),
494
- recursive: z.boolean().optional(),
495
- error: z.string().optional()
496
- });
497
- var moveFileActivitySchema = baseActivitySchema.extend({
498
- type: z.literal("moveFile"),
499
- source: z.string(),
500
- destination: z.string(),
501
- error: z.string().optional()
502
- });
503
- var getFileInfoActivitySchema = baseActivitySchema.extend({
504
- type: z.literal("getFileInfo"),
505
- path: z.string(),
506
- info: z.object({
507
- exists: z.boolean(),
508
- name: z.string(),
509
- directory: z.string(),
510
- extension: z.string().nullable(),
511
- type: z.enum(["file", "directory"]),
512
- mimeType: z.string().nullable(),
513
- size: z.number(),
514
- sizeFormatted: z.string(),
515
- created: z.string(),
516
- modified: z.string(),
517
- accessed: z.string()
518
- }).optional(),
519
- error: z.string().optional()
520
- });
521
- var createDirectoryActivitySchema = baseActivitySchema.extend({
522
- type: z.literal("createDirectory"),
523
- path: z.string(),
524
- error: z.string().optional()
525
- });
526
- var listDirectoryActivitySchema = baseActivitySchema.extend({
527
- type: z.literal("listDirectory"),
528
- path: z.string(),
529
- items: z.array(
530
- z.object({
531
- name: z.string(),
532
- path: z.string(),
533
- type: z.enum(["file", "directory"]),
534
- size: z.number(),
535
- modified: z.string()
536
- })
537
- ).optional(),
538
- error: z.string().optional()
539
- });
540
517
  var execActivitySchema = baseActivitySchema.extend({
541
518
  type: z.literal("exec"),
542
519
  command: z.string(),
@@ -582,14 +559,7 @@ var activitySchema = z.discriminatedUnion("type", [
582
559
  readPdfFileActivitySchema,
583
560
  readTextFileActivitySchema,
584
561
  editTextFileActivitySchema,
585
- appendTextFileActivitySchema,
586
562
  writeTextFileActivitySchema,
587
- deleteFileActivitySchema,
588
- deleteDirectoryActivitySchema,
589
- moveFileActivitySchema,
590
- getFileInfoActivitySchema,
591
- createDirectoryActivitySchema,
592
- listDirectoryActivitySchema,
593
563
  execActivitySchema,
594
564
  delegateActivitySchema,
595
565
  delegationCompleteActivitySchema,
@@ -1252,11 +1222,11 @@ var startCommandInputSchema = z.object({
1252
1222
  function parseExpertKey(expertKey) {
1253
1223
  const match = expertKey.match(expertKeyRegex);
1254
1224
  if (!match) {
1255
- throw new Error(`Invalid expert key format: ${expertKey}`);
1225
+ throw new PerstackError(`Invalid expert key format: ${expertKey}`);
1256
1226
  }
1257
1227
  const [key, name, version, tag] = match;
1258
1228
  if (!name) {
1259
- throw new Error(`Invalid expert key format: ${expertKey}`);
1229
+ throw new PerstackError(`Invalid expert key format: ${expertKey}`);
1260
1230
  }
1261
1231
  return { key, name, version, tag };
1262
1232
  }
@@ -1688,14 +1658,6 @@ function createBaseToolActivity(toolName, toolCall, toolResult, reasoning) {
1688
1658
  oldText: String(args["oldText"] ?? ""),
1689
1659
  error: errorText
1690
1660
  };
1691
- case "appendTextFile":
1692
- return {
1693
- type: "appendTextFile",
1694
- ...baseFields,
1695
- path: String(args["path"] ?? ""),
1696
- text: String(args["text"] ?? ""),
1697
- error: errorText
1698
- };
1699
1661
  case "writeTextFile":
1700
1662
  return {
1701
1663
  type: "writeTextFile",
@@ -1704,52 +1666,6 @@ function createBaseToolActivity(toolName, toolCall, toolResult, reasoning) {
1704
1666
  text: String(args["text"] ?? ""),
1705
1667
  error: errorText
1706
1668
  };
1707
- case "deleteFile":
1708
- return {
1709
- type: "deleteFile",
1710
- ...baseFields,
1711
- path: String(args["path"] ?? ""),
1712
- error: errorText
1713
- };
1714
- case "deleteDirectory":
1715
- return {
1716
- type: "deleteDirectory",
1717
- ...baseFields,
1718
- path: String(args["path"] ?? ""),
1719
- recursive: typeof args["recursive"] === "boolean" ? args["recursive"] : void 0,
1720
- error: errorText
1721
- };
1722
- case "moveFile":
1723
- return {
1724
- type: "moveFile",
1725
- ...baseFields,
1726
- source: String(args["source"] ?? ""),
1727
- destination: String(args["destination"] ?? ""),
1728
- error: errorText
1729
- };
1730
- case "getFileInfo":
1731
- return {
1732
- type: "getFileInfo",
1733
- ...baseFields,
1734
- path: String(args["path"] ?? ""),
1735
- info: parseFileInfoFromResult(resultContents),
1736
- error: errorText
1737
- };
1738
- case "createDirectory":
1739
- return {
1740
- type: "createDirectory",
1741
- ...baseFields,
1742
- path: String(args["path"] ?? ""),
1743
- error: errorText
1744
- };
1745
- case "listDirectory":
1746
- return {
1747
- type: "listDirectory",
1748
- ...baseFields,
1749
- path: String(args["path"] ?? ""),
1750
- items: parseListDirectoryFromResult(resultContents),
1751
- error: errorText
1752
- };
1753
1669
  case "exec":
1754
1670
  return {
1755
1671
  type: "exec",
@@ -1859,47 +1775,6 @@ function parseTodosFromResult(result) {
1859
1775
  }
1860
1776
  return [];
1861
1777
  }
1862
- function parseFileInfoFromResult(result) {
1863
- const textPart = result.find((p) => p.type === "textPart");
1864
- if (!textPart?.text) return void 0;
1865
- try {
1866
- const parsed = JSON.parse(textPart.text);
1867
- return {
1868
- exists: typeof parsed.exists === "boolean" ? parsed.exists : true,
1869
- name: String(parsed.name ?? ""),
1870
- directory: String(parsed.directory ?? ""),
1871
- extension: typeof parsed.extension === "string" ? parsed.extension : null,
1872
- type: parsed.type === "directory" ? "directory" : "file",
1873
- mimeType: typeof parsed.mimeType === "string" ? parsed.mimeType : null,
1874
- size: typeof parsed.size === "number" ? parsed.size : 0,
1875
- sizeFormatted: String(parsed.sizeFormatted ?? ""),
1876
- created: String(parsed.created ?? ""),
1877
- modified: String(parsed.modified ?? ""),
1878
- accessed: String(parsed.accessed ?? "")
1879
- };
1880
- } catch {
1881
- return void 0;
1882
- }
1883
- }
1884
- function parseListDirectoryFromResult(result) {
1885
- const textPart = result.find((p) => p.type === "textPart");
1886
- if (!textPart?.text) return void 0;
1887
- try {
1888
- const parsed = JSON.parse(textPart.text);
1889
- if (!Array.isArray(parsed.items)) return void 0;
1890
- return parsed.items.map(
1891
- (item) => ({
1892
- name: String(item.name ?? ""),
1893
- path: String(item.path ?? ""),
1894
- type: item.type === "directory" ? "directory" : "file",
1895
- size: typeof item.size === "number" ? item.size : 0,
1896
- modified: String(item.modified ?? "")
1897
- })
1898
- );
1899
- } catch {
1900
- return void 0;
1901
- }
1902
- }
1903
1778
 
1904
1779
  // src/utils/env-filter.ts
1905
1780
  var SAFE_ENV_VARS = [
@@ -1955,7 +1830,7 @@ function getFilteredEnv(additional) {
1955
1830
  function validateEventFilter(filter) {
1956
1831
  const invalid = filter.filter((type) => !isValidEventType(type) && !isValidRuntimeEventType(type));
1957
1832
  if (invalid.length > 0) {
1958
- throw new Error(
1833
+ throw new PerstackError(
1959
1834
  `Invalid event type(s): ${invalid.join(", ")}. Valid event types are: startRun, completeRun, stopRunByError, callTools, etc. See documentation for full list.`
1960
1835
  );
1961
1836
  }
@@ -1984,9 +1859,9 @@ function parseWithFriendlyError(schema, data, context) {
1984
1859
  return result.data;
1985
1860
  }
1986
1861
  const prefix = context ? `${context}: ` : "";
1987
- throw new Error(`${prefix}${formatZodError(result.error)}`);
1862
+ throw new PerstackError(`${prefix}${formatZodError(result.error)}`);
1988
1863
  }
1989
1864
 
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 };
1865
+ export { BASE_SKILL_PREFIX, PerstackError, SAFE_ENV_VARS, activityOrGroupSchema, activitySchema, amazonBedrockProviderConfigSchema, anthropicProviderConfigSchema, anthropicProviderSkillSchema, anthropicProviderToolNameSchema, attemptCompletion, attemptCompletionActivitySchema, azureOpenAIProviderToolNameSchema, azureOpenAiProviderConfigSchema, basePartSchema, builtinAnthropicSkillSchema, callTools, checkpointSchema, checkpointStatusSchema, clearTodoActivitySchema, completeActivitySchema, completeRun, continueToNextStep, createBaseToolActivity, createCallToolsEvent, createCompleteRunEvent, createEmptyUsage, createEvent, createFilteredEventListener, createGeneralToolActivity, createNormalizedCheckpoint, createResolveToolResultsEvent, createRuntimeEvent, createRuntimeInitEvent, createStartRunEvent, createStreamingEvent, createToolMessage, customAnthropicSkillSchema, deepseekProviderConfigSchema, defaultMaxRetries, defaultMaxSteps, defaultPerstackApiBaseUrl, defaultReasoningBudget, defaultTimeout, delegateActivitySchema, delegationCompleteActivitySchema, delegationTargetSchema, domainPatternSchema, editTextFileActivitySchema, errorActivitySchema, execActivitySchema, expertKeyRegex, expertMessageSchema, expertNameRegex, expertSchema, expertVersionRegex, fileBinaryPartSchema, fileInlinePartSchema, fileSearchOptionsSchema, fileUrlPartSchema, finishMcpTools, finishToolCall, formatZodError, generalToolActivitySchema, getActivities, getFilteredEnv, googleGenerativeAiProviderConfigSchema, googleProviderToolNameSchema, googleVertexProviderConfigSchema, headersSchema, imageBinaryPartSchema, imageInlinePartSchema, imageUrlPartSchema, instructionMessageSchema, interactiveSkillSchema, interactiveToolActivitySchema, interactiveToolSchema, isPrivateOrLocalIP, isValidEventType, isValidRuntimeEventType, jobSchema, jobStatusSchema, knownModels, lockfileExpertSchema, lockfileSchema, lockfileToolDefinitionSchema, maxExpertNameLength, maxSkillNameLength, maxSkillToolNameLength, mcpSseSkillSchema, mcpStdioSkillSchema, messagePartSchema, messageSchema, 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 };
1991
1866
  //# sourceMappingURL=index.js.map
1992
1867
  //# sourceMappingURL=index.js.map