@perstack/core 0.0.22 → 0.0.24

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
@@ -1,12 +1,226 @@
1
- import { z } from 'zod';
1
+ import { spawn } from 'child_process';
2
2
  import { createId } from '@paralleldrive/cuid2';
3
+ import { z } from 'zod';
4
+
5
+ // src/adapters/base-adapter.ts
6
+ var BaseAdapter = class {
7
+ convertExpert(expert) {
8
+ return { instruction: expert.instruction };
9
+ }
10
+ execCommand(args) {
11
+ return new Promise((resolve) => {
12
+ const [cmd, ...cmdArgs] = args;
13
+ if (!cmd) {
14
+ resolve({ stdout: "", stderr: "", exitCode: 127 });
15
+ return;
16
+ }
17
+ const proc = spawn(cmd, cmdArgs, { cwd: process.cwd(), stdio: ["pipe", "pipe", "pipe"] });
18
+ let stdout = "";
19
+ let stderr = "";
20
+ proc.stdout.on("data", (data) => {
21
+ stdout += data.toString();
22
+ });
23
+ proc.stderr.on("data", (data) => {
24
+ stderr += data.toString();
25
+ });
26
+ proc.on("close", (code) => {
27
+ resolve({ stdout, stderr, exitCode: code ?? 127 });
28
+ });
29
+ proc.on("error", () => {
30
+ resolve({ stdout: "", stderr: "", exitCode: 127 });
31
+ });
32
+ });
33
+ }
34
+ executeWithTimeout(proc, timeout) {
35
+ return new Promise((resolve, reject) => {
36
+ let stdout = "";
37
+ let stderr = "";
38
+ const timer = setTimeout(() => {
39
+ proc.kill("SIGTERM");
40
+ reject(new Error(`${this.name} timed out after ${timeout}ms`));
41
+ }, timeout);
42
+ proc.stdout?.on("data", (data) => {
43
+ stdout += data.toString();
44
+ });
45
+ proc.stderr?.on("data", (data) => {
46
+ stderr += data.toString();
47
+ });
48
+ proc.on("close", (code) => {
49
+ clearTimeout(timer);
50
+ resolve({ stdout, stderr, exitCode: code ?? 127 });
51
+ });
52
+ proc.on("error", (err) => {
53
+ clearTimeout(timer);
54
+ reject(err);
55
+ });
56
+ });
57
+ }
58
+ };
59
+ function createEmptyUsage() {
60
+ return {
61
+ inputTokens: 0,
62
+ outputTokens: 0,
63
+ reasoningTokens: 0,
64
+ totalTokens: 0,
65
+ cachedInputTokens: 0
66
+ };
67
+ }
68
+ function createNormalizedCheckpoint(params) {
69
+ const { jobId, runId, expert, output, runtime } = params;
70
+ const checkpointId = createId();
71
+ const expertMessage = {
72
+ id: createId(),
73
+ type: "expertMessage",
74
+ contents: [{ type: "textPart", id: createId(), text: output }]
75
+ };
76
+ return {
77
+ id: checkpointId,
78
+ jobId,
79
+ runId,
80
+ status: "completed",
81
+ stepNumber: 1,
82
+ messages: [expertMessage],
83
+ expert: { key: expert.key, name: expert.name, version: expert.version },
84
+ usage: createEmptyUsage(),
85
+ metadata: { runtime }
86
+ };
87
+ }
88
+ function createStartRunEvent(jobId, runId, expertKey, checkpoint) {
89
+ return {
90
+ type: "startRun",
91
+ id: createId(),
92
+ expertKey,
93
+ timestamp: Date.now(),
94
+ jobId,
95
+ runId,
96
+ stepNumber: checkpoint.stepNumber,
97
+ initialCheckpoint: checkpoint,
98
+ inputMessages: []
99
+ };
100
+ }
101
+ function createRuntimeInitEvent(jobId, runId, expertName, runtime, version, query) {
102
+ return {
103
+ type: "initializeRuntime",
104
+ id: createId(),
105
+ timestamp: Date.now(),
106
+ jobId,
107
+ runId,
108
+ runtimeVersion: version,
109
+ runtime,
110
+ expertName,
111
+ experts: [],
112
+ model: `${runtime}:default`,
113
+ temperature: 0,
114
+ maxRetries: 0,
115
+ timeout: 0,
116
+ query
117
+ };
118
+ }
119
+ function createCompleteRunEvent(jobId, runId, expertKey, checkpoint, output, startedAt) {
120
+ const lastMessage = checkpoint.messages[checkpoint.messages.length - 1];
121
+ return {
122
+ type: "completeRun",
123
+ id: createId(),
124
+ expertKey,
125
+ timestamp: Date.now(),
126
+ jobId,
127
+ runId,
128
+ stepNumber: checkpoint.stepNumber,
129
+ checkpoint,
130
+ step: {
131
+ stepNumber: checkpoint.stepNumber,
132
+ newMessages: lastMessage ? [lastMessage] : [],
133
+ usage: createEmptyUsage(),
134
+ startedAt: startedAt ?? Date.now()
135
+ },
136
+ text: output,
137
+ usage: createEmptyUsage()
138
+ };
139
+ }
140
+ function createStreamingTextEvent(jobId, runId, text) {
141
+ return {
142
+ type: "streamingText",
143
+ id: createId(),
144
+ timestamp: Date.now(),
145
+ jobId,
146
+ runId,
147
+ text
148
+ };
149
+ }
150
+ function createCallToolsEvent(jobId, runId, expertKey, stepNumber, toolCalls, _checkpoint) {
151
+ const expertMessage = {
152
+ id: createId(),
153
+ type: "expertMessage",
154
+ contents: []
155
+ };
156
+ return {
157
+ type: "callTools",
158
+ id: createId(),
159
+ expertKey,
160
+ timestamp: Date.now(),
161
+ jobId,
162
+ runId,
163
+ stepNumber,
164
+ newMessage: expertMessage,
165
+ toolCalls,
166
+ usage: createEmptyUsage()
167
+ };
168
+ }
169
+ function createResolveToolResultsEvent(jobId, runId, expertKey, stepNumber, toolResults) {
170
+ return {
171
+ type: "resolveToolResults",
172
+ id: createId(),
173
+ expertKey,
174
+ timestamp: Date.now(),
175
+ jobId,
176
+ runId,
177
+ stepNumber,
178
+ toolResults
179
+ };
180
+ }
181
+ function createToolMessage(toolCallId, toolName, resultText) {
182
+ return {
183
+ id: createId(),
184
+ type: "toolMessage",
185
+ contents: [
186
+ {
187
+ type: "toolResultPart",
188
+ id: createId(),
189
+ toolCallId,
190
+ toolName,
191
+ contents: [{ type: "textPart", id: createId(), text: resultText }]
192
+ }
193
+ ]
194
+ };
195
+ }
196
+
197
+ // src/adapters/registry.ts
198
+ var adapters = /* @__PURE__ */ new Map();
199
+ function registerAdapter(runtime, factory) {
200
+ adapters.set(runtime, factory);
201
+ }
202
+ function getAdapter(runtime) {
203
+ const factory = adapters.get(runtime);
204
+ if (!factory) {
205
+ throw new Error(
206
+ `Runtime "${runtime}" is not registered. Available runtimes: ${Array.from(adapters.keys()).join(", ")}`
207
+ );
208
+ }
209
+ return factory();
210
+ }
211
+ function isAdapterAvailable(runtime) {
212
+ return adapters.has(runtime);
213
+ }
214
+ function getRegisteredRuntimes() {
215
+ return Array.from(adapters.keys());
216
+ }
3
217
 
4
218
  // src/constants/constants.ts
5
219
  var defaultPerstackApiBaseUrl = "https://api.perstack.ai";
6
- var organizationNameRegex = /^[a-z0-9][a-z0-9_\.-]*$/;
220
+ var organizationNameRegex = /^[a-z0-9][a-z0-9_.-]*$/;
7
221
  var maxOrganizationNameLength = 128;
8
222
  var maxApplicationNameLength = 255;
9
- 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_\.-]*))?$/;
223
+ 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_.-]*))?$/;
10
224
  var expertNameRegex = /^(@[a-z0-9][a-z0-9_-]*\/)?[a-z0-9][a-z0-9_-]*$/;
11
225
  var expertVersionRegex = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\w.-]+)?(?:\+[\w.-]+)?$/;
12
226
  var tagNameRegex = /^[a-z0-9][a-z0-9_-]*$/;
@@ -19,12 +233,12 @@ var maxExpertSkillItems = 255;
19
233
  var maxExpertDelegateItems = 255;
20
234
  var maxExpertTagItems = 8;
21
235
  var defaultTemperature = 0;
22
- var defaultMaxSteps = void 0;
236
+ var defaultMaxSteps = 100;
23
237
  var defaultMaxRetries = 5;
24
238
  var defaultTimeout = 5 * 1e3 * 60;
25
239
  var maxExpertJobQueryLength = 1024 * 20;
26
240
  var maxExpertJobFileNameLength = 1024 * 10;
27
- 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_\.-]*)?$/;
241
+ 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_.-]*)?$/;
28
242
  var urlSafeRegex = /^[a-z0-9][a-z0-9_-]*$/;
29
243
  var maxSkillNameLength = 255;
30
244
  var maxSkillDescriptionLength = 1024 * 2;
@@ -328,6 +542,7 @@ var messageSchema = z.union([
328
542
  expertMessageSchema,
329
543
  toolMessageSchema
330
544
  ]);
545
+ var runtimeNameSchema = z.enum(["local", "cursor", "claude-code", "gemini", "docker"]);
331
546
  var toolCallSchema = z.object({
332
547
  id: z.string().min(1).max(255),
333
548
  skillName: z.string().min(1).max(maxSkillNameLength),
@@ -395,8 +610,51 @@ var checkpointSchema = z.object({
395
610
  contextWindow: z.number().optional(),
396
611
  contextWindowUsage: z.number().optional(),
397
612
  pendingToolCalls: z.array(toolCallSchema).optional(),
398
- partialToolResults: z.array(toolResultSchema).optional()
613
+ partialToolResults: z.array(toolResultSchema).optional(),
614
+ metadata: z.object({
615
+ runtime: runtimeNameSchema.optional()
616
+ }).passthrough().optional()
399
617
  });
618
+ function isPrivateOrLocalIP(hostname) {
619
+ if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname === "0.0.0.0") {
620
+ return true;
621
+ }
622
+ const ipv4Match = hostname.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
623
+ if (ipv4Match) {
624
+ const a = Number(ipv4Match[1]);
625
+ const b = Number(ipv4Match[2]);
626
+ if (a === 10) return true;
627
+ if (a === 172 && b >= 16 && b <= 31) return true;
628
+ if (a === 192 && b === 168) return true;
629
+ if (a === 169 && b === 254) return true;
630
+ if (a === 127) return true;
631
+ }
632
+ if (hostname.includes(":")) {
633
+ if (hostname.startsWith("fe80:") || hostname.startsWith("fc") || hostname.startsWith("fd")) {
634
+ return true;
635
+ }
636
+ }
637
+ if (hostname.startsWith("::ffff:")) {
638
+ const ipv4Part = hostname.slice(7);
639
+ if (isPrivateOrLocalIP(ipv4Part)) {
640
+ return true;
641
+ }
642
+ }
643
+ return false;
644
+ }
645
+ var sseEndpointSchema = z.string().url().refine(
646
+ (url) => {
647
+ try {
648
+ const parsed = new URL(url);
649
+ if (parsed.protocol !== "https:") return false;
650
+ if (isPrivateOrLocalIP(parsed.hostname)) return false;
651
+ return true;
652
+ } catch {
653
+ return false;
654
+ }
655
+ },
656
+ { message: "Endpoint must be a public HTTPS URL" }
657
+ );
400
658
  var mcpStdioSkillSchema = z.object({
401
659
  type: z.literal("mcpStdioSkill"),
402
660
  name: z.string(),
@@ -417,7 +675,7 @@ var mcpSseSkillSchema = z.object({
417
675
  rule: z.string().optional(),
418
676
  pick: z.array(z.string()).optional().default([]),
419
677
  omit: z.array(z.string()).optional().default([]),
420
- endpoint: z.string()
678
+ endpoint: sseEndpointSchema
421
679
  });
422
680
  var interactiveToolSchema = z.object({
423
681
  name: z.string(),
@@ -579,16 +837,64 @@ var providerConfigSchema = z.discriminatedUnion("providerName", [
579
837
  ]);
580
838
 
581
839
  // src/schemas/perstack-toml.ts
840
+ 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
+ var punycodeRegex = /(?:^|\.)(xn--)/i;
842
+ var domainPatternSchema = z.string().regex(domainPatternRegex, {
843
+ message: "Invalid domain pattern. Use exact domain (example.com) or wildcard prefix (*.example.com)"
844
+ }).refine((domain) => !punycodeRegex.test(domain), {
845
+ message: "Punycode domains (xn--) are not allowed to prevent homograph attacks. Use ASCII domains only."
846
+ });
847
+ function isPrivateOrLocalIP2(hostname) {
848
+ if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname === "0.0.0.0") {
849
+ return true;
850
+ }
851
+ const ipv4Match = hostname.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
852
+ if (ipv4Match) {
853
+ const a = Number(ipv4Match[1]);
854
+ const b = Number(ipv4Match[2]);
855
+ if (a === 10) return true;
856
+ if (a === 172 && b >= 16 && b <= 31) return true;
857
+ if (a === 192 && b === 168) return true;
858
+ if (a === 169 && b === 254) return true;
859
+ if (a === 127) return true;
860
+ }
861
+ if (hostname.includes(":")) {
862
+ if (hostname.startsWith("fe80:") || hostname.startsWith("fc") || hostname.startsWith("fd")) {
863
+ return true;
864
+ }
865
+ }
866
+ if (hostname.startsWith("::ffff:")) {
867
+ const ipv4Part = hostname.slice(7);
868
+ if (isPrivateOrLocalIP2(ipv4Part)) {
869
+ return true;
870
+ }
871
+ }
872
+ return false;
873
+ }
874
+ var sseEndpointSchema2 = z.string().url().refine(
875
+ (url) => {
876
+ try {
877
+ const parsed = new URL(url);
878
+ if (parsed.protocol !== "https:") return false;
879
+ if (isPrivateOrLocalIP2(parsed.hostname)) return false;
880
+ return true;
881
+ } catch {
882
+ return false;
883
+ }
884
+ },
885
+ { message: "SSE endpoint must be a public HTTPS URL" }
886
+ );
887
+ var httpsUrlSchema = z.string().url().refine((url) => url.startsWith("https://"), { message: "URL must use HTTPS" });
582
888
  var anthropicSettingSchema = z.object({
583
- baseUrl: z.string().optional(),
889
+ baseUrl: httpsUrlSchema.optional(),
584
890
  headers: headersSchema
585
891
  });
586
892
  var googleSettingSchema = z.object({
587
- baseUrl: z.string().optional(),
893
+ baseUrl: httpsUrlSchema.optional(),
588
894
  headers: headersSchema
589
895
  });
590
896
  var openAiSettingSchema = z.object({
591
- baseUrl: z.string().optional(),
897
+ baseUrl: httpsUrlSchema.optional(),
592
898
  organization: z.string().optional(),
593
899
  project: z.string().optional(),
594
900
  name: z.string().optional(),
@@ -601,7 +907,7 @@ var ollamaSettingSchema = z.object({
601
907
  var azureOpenAiSettingSchema = z.object({
602
908
  resourceName: z.string().optional(),
603
909
  apiVersion: z.string().optional(),
604
- baseUrl: z.string().optional(),
910
+ baseUrl: httpsUrlSchema.optional(),
605
911
  headers: headersSchema,
606
912
  useDeploymentBasedUrls: z.boolean().optional()
607
913
  });
@@ -611,11 +917,11 @@ var amazonBedrockSettingSchema = z.object({
611
917
  var googleVertexSettingSchema = z.object({
612
918
  project: z.string().optional(),
613
919
  location: z.string().optional(),
614
- baseUrl: z.string().optional(),
920
+ baseUrl: httpsUrlSchema.optional(),
615
921
  headers: headersSchema
616
922
  });
617
923
  var deepseekSettingSchema = z.object({
618
- baseUrl: z.string().optional(),
924
+ baseUrl: httpsUrlSchema.optional(),
619
925
  headers: headersSchema
620
926
  });
621
927
  var providerTableSchema = z.discriminatedUnion("providerName", [
@@ -656,6 +962,7 @@ var perstackConfigSchema = z.object({
656
962
  provider: providerTableSchema.optional(),
657
963
  model: z.string().optional(),
658
964
  temperature: z.number().optional(),
965
+ runtime: runtimeNameSchema.optional(),
659
966
  maxSteps: z.number().optional(),
660
967
  maxRetries: z.number().optional(),
661
968
  timeout: z.number().optional(),
@@ -678,7 +985,8 @@ var perstackConfigSchema = z.object({
678
985
  command: z.string(),
679
986
  packageName: z.string().optional(),
680
987
  args: z.array(z.string()).optional(),
681
- requiredEnv: z.array(z.string()).optional()
988
+ requiredEnv: z.array(z.string()).optional(),
989
+ allowedDomains: z.array(domainPatternSchema).optional()
682
990
  }),
683
991
  z.object({
684
992
  type: z.literal("mcpSseSkill"),
@@ -686,7 +994,8 @@ var perstackConfigSchema = z.object({
686
994
  rule: z.string().optional(),
687
995
  pick: z.array(z.string()).optional(),
688
996
  omit: z.array(z.string()).optional(),
689
- endpoint: z.string()
997
+ endpoint: sseEndpointSchema2,
998
+ allowedDomains: z.array(domainPatternSchema).optional()
690
999
  }),
691
1000
  z.object({
692
1001
  type: z.literal("interactiveSkill"),
@@ -706,7 +1015,7 @@ var perstackConfigSchema = z.object({
706
1015
  tags: z.array(z.string()).optional()
707
1016
  })
708
1017
  ).optional(),
709
- perstackApiBaseUrl: z.url().optional(),
1018
+ perstackApiBaseUrl: z.url().refine((url) => url.startsWith("https://"), { message: "perstackApiBaseUrl must use HTTPS" }).optional(),
710
1019
  perstackBaseSkillCommand: z.array(z.string()).optional(),
711
1020
  envPath: z.array(z.string()).optional()
712
1021
  });
@@ -740,12 +1049,14 @@ var commandOptionsSchema = z.object({
740
1049
  }),
741
1050
  jobId: z.string().optional(),
742
1051
  runId: z.string().optional(),
743
- envPath: z.array(z.string()).optional(),
1052
+ envPath: z.array(z.string()).optional().transform((value) => value && value.length > 0 ? value : void 0),
744
1053
  verbose: z.boolean().optional(),
745
1054
  continue: z.boolean().optional(),
746
1055
  continueJob: z.string().optional(),
747
1056
  resumeFrom: z.string().optional(),
748
- interactiveToolCallResult: z.boolean().optional()
1057
+ interactiveToolCallResult: z.boolean().optional(),
1058
+ runtime: runtimeNameSchema.optional(),
1059
+ workspace: z.string().optional()
749
1060
  });
750
1061
  var runCommandInputSchema = z.object({
751
1062
  expertKey: z.string(),
@@ -785,7 +1096,7 @@ var runSettingSchema = z.object({
785
1096
  }),
786
1097
  experts: z.record(z.string(), expertSchema),
787
1098
  temperature: z.number().min(0).max(1),
788
- maxSteps: z.number().min(1).optional(),
1099
+ maxSteps: z.number().min(1).optional().default(defaultMaxSteps),
789
1100
  maxRetries: z.number().min(0),
790
1101
  timeout: z.number().min(0),
791
1102
  startedAt: z.number(),
@@ -793,7 +1104,9 @@ var runSettingSchema = z.object({
793
1104
  perstackApiBaseUrl: z.string().url(),
794
1105
  perstackApiKey: z.string().optional(),
795
1106
  perstackBaseSkillCommand: z.array(z.string()).optional(),
796
- env: z.record(z.string(), z.string())
1107
+ env: z.record(z.string(), z.string()),
1108
+ proxyUrl: z.string().optional(),
1109
+ verbose: z.boolean().optional()
797
1110
  });
798
1111
  var runParamsSchema = z.object({
799
1112
  setting: z.object({
@@ -823,7 +1136,7 @@ var runParamsSchema = z.object({
823
1136
  )
824
1137
  ),
825
1138
  temperature: z.number().min(0).max(1).optional().default(defaultTemperature),
826
- maxSteps: z.number().min(1).optional(),
1139
+ maxSteps: z.number().min(1).optional().default(defaultMaxSteps),
827
1140
  maxRetries: z.number().min(0).optional().default(defaultMaxRetries),
828
1141
  timeout: z.number().min(0).optional().default(defaultTimeout),
829
1142
  startedAt: z.number().optional().default(Date.now()),
@@ -831,7 +1144,9 @@ var runParamsSchema = z.object({
831
1144
  perstackApiBaseUrl: z.url().optional().default(defaultPerstackApiBaseUrl),
832
1145
  perstackApiKey: z.string().optional(),
833
1146
  perstackBaseSkillCommand: z.array(z.string()).optional(),
834
- env: z.record(z.string(), z.string()).optional().default({})
1147
+ env: z.record(z.string(), z.string()).optional().default({}),
1148
+ proxyUrl: z.string().optional(),
1149
+ verbose: z.boolean().optional()
835
1150
  }),
836
1151
  checkpoint: checkpointSchema.optional()
837
1152
  });
@@ -889,6 +1204,56 @@ var stepSchema = z.object({
889
1204
  finishedAt: z.number().optional()
890
1205
  });
891
1206
 
1207
+ // src/utils/env-filter.ts
1208
+ var SAFE_ENV_VARS = [
1209
+ // System
1210
+ "PATH",
1211
+ "HOME",
1212
+ "SHELL",
1213
+ "TERM",
1214
+ "NODE_PATH",
1215
+ // Proxy
1216
+ "HTTP_PROXY",
1217
+ "HTTPS_PROXY",
1218
+ "http_proxy",
1219
+ "https_proxy",
1220
+ "NO_PROXY",
1221
+ "no_proxy",
1222
+ "PERSTACK_PROXY_URL",
1223
+ "NPM_CONFIG_PROXY",
1224
+ "NPM_CONFIG_HTTPS_PROXY"
1225
+ ];
1226
+ var PROTECTED_ENV_VARS = /* @__PURE__ */ new Set([
1227
+ "PATH",
1228
+ "HOME",
1229
+ "SHELL",
1230
+ "NODE_PATH",
1231
+ "LD_PRELOAD",
1232
+ "LD_LIBRARY_PATH",
1233
+ "DYLD_INSERT_LIBRARIES",
1234
+ "DYLD_LIBRARY_PATH",
1235
+ "NODE_OPTIONS",
1236
+ "PYTHONPATH",
1237
+ "PERL5LIB",
1238
+ "RUBYLIB"
1239
+ ]);
1240
+ function getFilteredEnv(additional) {
1241
+ const filtered = {};
1242
+ for (const key of SAFE_ENV_VARS) {
1243
+ if (process.env[key]) {
1244
+ filtered[key] = process.env[key];
1245
+ }
1246
+ }
1247
+ if (additional) {
1248
+ for (const [key, value] of Object.entries(additional)) {
1249
+ if (!PROTECTED_ENV_VARS.has(key.toUpperCase())) {
1250
+ filtered[key] = value;
1251
+ }
1252
+ }
1253
+ }
1254
+ return filtered;
1255
+ }
1256
+
892
1257
  // src/utils/zod-error.ts
893
1258
  function formatZodError(error) {
894
1259
  const issues = error.issues.map((issue) => {
@@ -907,6 +1272,6 @@ function parseWithFriendlyError(schema, data, context) {
907
1272
  throw new Error(`${prefix}${formatZodError(result.error)}`);
908
1273
  }
909
1274
 
910
- export { amazonBedrockProviderConfigSchema, anthropicProviderConfigSchema, attemptCompletion, azureOpenAiProviderConfigSchema, basePartSchema, callDelegate, callInteractiveTool, callTools, checkpointSchema, checkpointStatusSchema, completeRun, continueToNextStep, createEvent, createRuntimeEvent, deepseekProviderConfigSchema, defaultMaxRetries, defaultMaxSteps, defaultPerstackApiBaseUrl, defaultTemperature, defaultTimeout, delegationTargetSchema, envNameRegex, expertKeyRegex, expertMessageSchema, expertNameRegex, expertSchema, expertVersionRegex, fileBinaryPartSchema, fileInlinePartSchema, fileUrlPartSchema, finishAllToolCalls, finishToolCall, formatZodError, googleGenerativeAiProviderConfigSchema, googleVertexProviderConfigSchema, headersSchema, imageBinaryPartSchema, imageInlinePartSchema, imageUrlPartSchema, instructionMessageSchema, interactiveSkillSchema, interactiveToolSchema, jobSchema, jobStatusSchema, knownModels, 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, organizationNameRegex, packageWithVersionRegex, parseExpertKey, parseWithFriendlyError, perstackConfigSchema, providerConfigSchema, providerNameSchema, providerTableSchema, resolveThought, resolveToolResults, resumeToolCalls, retry, runCommandInputSchema, runParamsSchema, runSettingSchema, skillSchema, startCommandInputSchema, startGeneration, startRun, stepSchema, stopRunByDelegate, stopRunByExceededMaxSteps, stopRunByInteractiveTool, tagNameRegex, textPartSchema, toolCallPartSchema, toolCallSchema, toolMessageSchema, toolResultPartSchema, toolResultSchema, urlSafeRegex, usageSchema, userMessageSchema };
1275
+ 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, defaultTemperature, defaultTimeout, delegationTargetSchema, domainPatternSchema, envNameRegex, expertKeyRegex, expertMessageSchema, expertNameRegex, expertSchema, expertVersionRegex, fileBinaryPartSchema, fileInlinePartSchema, fileUrlPartSchema, finishAllToolCalls, finishToolCall, formatZodError, getAdapter, getFilteredEnv, getRegisteredRuntimes, googleGenerativeAiProviderConfigSchema, googleVertexProviderConfigSchema, headersSchema, imageBinaryPartSchema, imageInlinePartSchema, imageUrlPartSchema, instructionMessageSchema, interactiveSkillSchema, interactiveToolSchema, isAdapterAvailable, jobSchema, jobStatusSchema, knownModels, 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, organizationNameRegex, packageWithVersionRegex, parseExpertKey, parseWithFriendlyError, perstackConfigSchema, providerConfigSchema, providerNameSchema, providerTableSchema, registerAdapter, resolveThought, resolveToolResults, resumeToolCalls, retry, runCommandInputSchema, runParamsSchema, runSettingSchema, runtimeNameSchema, skillSchema, startCommandInputSchema, startGeneration, startRun, stepSchema, stopRunByDelegate, stopRunByExceededMaxSteps, stopRunByInteractiveTool, tagNameRegex, textPartSchema, toolCallPartSchema, toolCallSchema, toolMessageSchema, toolResultPartSchema, toolResultSchema, urlSafeRegex, usageSchema, userMessageSchema };
911
1276
  //# sourceMappingURL=index.js.map
912
1277
  //# sourceMappingURL=index.js.map