@foldrun/core 24.5.0 → 24.6.0

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.
@@ -22,6 +22,9 @@ type CanUseTool = (name: string, input: Json, extra: {
22
22
  interface LoopOptions {
23
23
  cwd: string;
24
24
  env: Record<string, string | undefined>;
25
+ /** What the tools (Bash) get; `env` when not given. foldrun code passes
26
+ * the person's own environment here, so the model key stays with the loop. */
27
+ shellEnv: Record<string, string | undefined>;
25
28
  model: string;
26
29
  systemPrompt: string;
27
30
  tools: EngineTool[];
@@ -78,6 +78,7 @@ function readOptions(options) {
78
78
  return {
79
79
  cwd: String(options.cwd ?? process.cwd()),
80
80
  env,
81
+ shellEnv: options.shellEnv && typeof options.shellEnv === "object" ? options.shellEnv : env,
81
82
  model: env[`ANTHROPIC_DEFAULT_${model.toUpperCase()}_MODEL`] || TIER_DEFAULTS[model] || model,
82
83
  systemPrompt: typeof options.systemPrompt === "string" ? options.systemPrompt : "",
83
84
  tools: names.map((n) => ENGINE_TOOLS[n]),
@@ -345,7 +346,7 @@ async function* run(prompt, o, signal, interrupted) {
345
346
  const sessionId = crypto.randomUUID();
346
347
  const startedAt = Date.now();
347
348
  const byName = new Map(o.tools.map((t) => [t.name, t]));
348
- const ctx = { cwd: o.cwd, env: o.env, signal, reads: new Map(), groups: new Set() };
349
+ const ctx = { cwd: o.cwd, env: o.shellEnv, signal, reads: new Map(), groups: new Set() };
349
350
  // An earlier conversation comes first (foldrun code's local turns carry
350
351
  // theirs, 19 Nov 2026); the prompt is always the newest user turn.
351
352
  if (o.history.length % 2 !== 0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foldrun/core",
3
- "version": "24.5.0",
3
+ "version": "24.6.0",
4
4
  "description": "Agents are just folders. The format, the runner, the checks.",
5
5
  "license": "FSL-1.1-ALv2",
6
6
  "type": "module",
@@ -71,6 +71,9 @@ interface Usage {
71
71
  interface LoopOptions {
72
72
  cwd: string;
73
73
  env: Record<string, string | undefined>;
74
+ /** What the tools (Bash) get; `env` when not given. foldrun code passes
75
+ * the person's own environment here, so the model key stays with the loop. */
76
+ shellEnv: Record<string, string | undefined>;
74
77
  model: string;
75
78
  systemPrompt: string;
76
79
  tools: EngineTool[];
@@ -116,6 +119,7 @@ function readOptions(options: Json): LoopOptions {
116
119
  return {
117
120
  cwd: String(options.cwd ?? process.cwd()),
118
121
  env,
122
+ shellEnv: options.shellEnv && typeof options.shellEnv === "object" ? (options.shellEnv as Record<string, string | undefined>) : env,
119
123
  model: env[`ANTHROPIC_DEFAULT_${model.toUpperCase()}_MODEL`] || TIER_DEFAULTS[model] || model,
120
124
  systemPrompt: typeof options.systemPrompt === "string" ? options.systemPrompt : "",
121
125
  tools: names.map((n) => ENGINE_TOOLS[n]),
@@ -364,7 +368,7 @@ async function* run(prompt: string, o: LoopOptions, signal: AbortSignal, interru
364
368
  const sessionId = crypto.randomUUID();
365
369
  const startedAt = Date.now();
366
370
  const byName = new Map(o.tools.map((t) => [t.name, t]));
367
- const ctx: ToolContext = { cwd: o.cwd, env: o.env, signal, reads: new Map(), groups: new Set() };
371
+ const ctx: ToolContext = { cwd: o.cwd, env: o.shellEnv, signal, reads: new Map(), groups: new Set() };
368
372
  // An earlier conversation comes first (foldrun code's local turns carry
369
373
  // theirs, 19 Nov 2026); the prompt is always the newest user turn.
370
374
  if (o.history.length % 2 !== 0) throw new Error("history must end with the model's turn, so the prompt is the next user turn");