@foldrun/core 24.8.1 → 24.9.1

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.
@@ -1,4 +1,5 @@
1
1
  import { type EngineTool, type ToolOutcome } from "./engine-tools.ts";
2
+ import { type McpSpec } from "./engine-mcp.ts";
2
3
  export declare const DEFAULT_MAX_TOKENS = 16000;
3
4
  export interface Usage {
4
5
  input_tokens: number;
@@ -49,6 +50,21 @@ export interface LoopOptions {
49
50
  role: string;
50
51
  content: Block[];
51
52
  }[];
53
+ /** The step's MCP servers (engine-mcp.ts), connected when the loop starts. */
54
+ mcpServers: Record<string, McpSpec>;
55
+ /** MCP tools the step was granted by name, with the server each names:
56
+ * each must be offered by that server once connected, or the step is refused. */
57
+ mcpGranted: {
58
+ name: string;
59
+ server: string;
60
+ }[];
61
+ /** Compaction (engine-compact.ts): the model's context window, and false
62
+ * when the caller turned it off (`compaction: false`). */
63
+ compaction: {
64
+ contextWindow: number;
65
+ reserveTokens: number;
66
+ keepRecentTokens: number;
67
+ } | false;
52
68
  }
53
69
  export declare function hookFns(hooks: unknown, event: string): HookFn[];
54
70
  /** The SDK's options, as this engine reads them. What it cannot honour it
@@ -5,6 +5,8 @@
5
5
  // limit or confinement check differently. Internal: not part of
6
6
  // @foldrun/core's public API.
7
7
  import { ENGINE_TOOLS } from "./engine-tools.js";
8
+ import { checkMcpSpecs, grantedServer } from "./engine-mcp.js";
9
+ import { COMPACTION_DEFAULTS, MIN_CONTEXT_WINDOW, compactionFor } from "./engine-compact.js";
8
10
  export const DEFAULT_MAX_TOKENS = 16_000;
9
11
  export const emptyUsage = () => ({ input_tokens: 0, output_tokens: 0, cache_creation_input_tokens: 0, cache_read_input_tokens: 0 });
10
12
  export function addUsage(into, u) {
@@ -34,14 +36,27 @@ export function hookFns(hooks, event) {
34
36
  /** `engine` names the loop in what it refuses. */
35
37
  export function readOptions(options, engine = "foldrun") {
36
38
  const env = options.env ?? process.env;
37
- const names = Array.isArray(options.tools) ? options.tools.map(String) : [];
39
+ const listed = Array.isArray(options.tools) ? options.tools.map(String) : [];
40
+ // A granted MCP tool (`mcp__<server>__<tool>`, what the runner lists for
41
+ // web, apis, scripts, a2a, ask…) comes from its server, connected when the
42
+ // loop starts; its server must be one of the step's.
43
+ const mcpGranted = listed.filter((n) => n.startsWith("mcp__"));
44
+ const names = listed.filter((n) => !n.startsWith("mcp__"));
38
45
  const unsupported = names.filter((n) => !ENGINE_TOOLS[n]);
39
46
  if (unsupported.length) {
40
47
  throw new Error(`the ${engine} engine has no tool named ${unsupported.join(", ")} yet — it has ${Object.keys(ENGINE_TOOLS).join(", ")}. Run this agent on the default engine.`);
41
48
  }
42
- const servers = Object.keys(options.mcpServers ?? {});
43
- if (servers.length) {
44
- throw new Error(`the ${engine} engine does not connect MCP servers yet (${servers.join(", ")}) — run this agent on the default engine.`);
49
+ // MCP servers: checked here, connected when the loop starts (engine-mcp.ts).
50
+ const mcpServers = checkMcpSpecs(options.mcpServers ?? {}, engine);
51
+ // A whole server granted (`mcp__crm`, `mcp__crm__*`) needs only the
52
+ // server; a tool granted by name must be offered by it once connected.
53
+ const mcpTools = [];
54
+ for (const n of mcpGranted) {
55
+ const g = grantedServer(n, Object.keys(mcpServers));
56
+ if (!g)
57
+ throw new Error(`the tool ${n} was granted, but the step has no MCP server for it`);
58
+ if (g.tool)
59
+ mcpTools.push({ name: g.tool, server: g.server });
45
60
  }
46
61
  if (options.agents && Object.keys(options.agents).length) {
47
62
  throw new Error(`the ${engine} engine does not run sub-agents yet — run this agent on the default engine.`);
@@ -81,6 +96,9 @@ export function readOptions(options, engine = "foldrun") {
81
96
  canUseTool: typeof options.canUseTool === "function" ? options.canUseTool : null,
82
97
  outer: options.abortController?.signal ?? null,
83
98
  history: readHistory(options.history),
99
+ mcpServers,
100
+ mcpGranted: mcpTools,
101
+ compaction: options.compaction === false ? false : compactionFor(typeof options.contextWindow === "number" && Number.isFinite(options.contextWindow) && options.contextWindow >= MIN_CONTEXT_WINDOW ? Math.floor(options.contextWindow) : COMPACTION_DEFAULTS.contextWindow),
84
102
  };
85
103
  }
86
104
  /** An earlier conversation, checked: user and assistant turns that
@@ -0,0 +1,61 @@
1
+ type Json = Record<string, unknown>;
2
+ type Block = Json & {
3
+ type: string;
4
+ };
5
+ export type Message = {
6
+ role: string;
7
+ content: Block[];
8
+ };
9
+ /** What the loop uses unless a caller says otherwise: Pi's defaults, and
10
+ * the context window of the Claude models foldrun's tiers name. A model
11
+ * with a smaller window is still caught when the endpoint says the prompt
12
+ * is too long (the loop compacts then and asks again, once). */
13
+ export declare const COMPACTION_DEFAULTS: {
14
+ contextWindow: number;
15
+ reserveTokens: number;
16
+ keepRecentTokens: number;
17
+ };
18
+ /** The smallest window compaction will work in. */
19
+ export declare const MIN_CONTEXT_WINDOW = 8192;
20
+ /** Pi's numbers for a large window; a small one keeps a quarter for the
21
+ * reply and summarises down to about a third of it. */
22
+ export declare function compactionFor(contextWindow: number): {
23
+ contextWindow: number;
24
+ reserveTokens: number;
25
+ keepRecentTokens: number;
26
+ };
27
+ export declare const SUMMARY_PREFIX = "The conversation history before this point was compacted into the following summary:\n\n<summary>\n";
28
+ export declare const SUMMARIZATION_SYSTEM_PROMPT = "You are a context summarization assistant. Your task is to read a conversation between a user and an AI assistant, then produce a structured summary following the exact format specified.\n\nDo NOT continue the conversation. Do NOT respond to any questions in the conversation. ONLY output the structured summary.";
29
+ /** Tokens a message comes to, by four characters a token: an overestimate,
30
+ * which is the safe side here. */
31
+ export declare function estimateTokens(m: Message): number;
32
+ /** Every place a cut may go, after the first message. */
33
+ export declare function cutPoints(messages: Message[]): number[];
34
+ /** Where the kept part starts: walking back from the newest message until
35
+ * `keep` tokens are behind, then forward to the first place a cut may go.
36
+ * When even the newest messages come to less than `keep`, everything from
37
+ * the first place a cut may go is kept (a large first message is what
38
+ * gets summarised). A kept part larger than `maxKeep` moves to a later
39
+ * cut, so a summary actually makes room. -1 when there is nowhere to cut. */
40
+ export declare function findCut(messages: Message[], keep: number, maxKeep?: number): number;
41
+ /** The conversation as text, so the summarising model reads it rather than
42
+ * continuing it. Thinking is left out; tool results are cut to 2,000
43
+ * characters each; the earlier summary's own block is left to the update
44
+ * prompt. */
45
+ export declare function serializeConversation(messages: Message[], maxChars?: number): string;
46
+ /** The earlier summary, when the conversation starts with one. */
47
+ export declare function previousSummary(messages: Message[]): string | null;
48
+ /** The text the summarising model is sent. */
49
+ export declare function summaryRequest(toSummarize: Message[], earlier: string | null, maxChars?: number): string;
50
+ /** The files the summary lists after it: read only, and changed. */
51
+ export declare function fileLists(read: Set<string>, changed: Set<string>): string;
52
+ /** The conversation after compaction: the summary, then the kept part. The
53
+ * summary leads the first user turn (the turns must alternate, starting
54
+ * with the user's): it joins the kept part's first message when that is
55
+ * the user's, or comes before it as its own when the kept part opens on a
56
+ * model turn. */
57
+ export declare function compacted(summary: string, kept: Message[]): Message[];
58
+ /** An endpoint's refusal that means the prompt did not fit: a 400 or 413
59
+ * that says so. Any other status is not, whatever its words. */
60
+ export declare function isContextOverflow(status: number | undefined, message: string): boolean;
61
+ export {};
@@ -0,0 +1,293 @@
1
+ // Compaction for foldrun's own loop (FOL-213): a conversation nearing the
2
+ // model's context window has its older part summarised, so a long session
3
+ // goes on instead of failing with "the conversation filled the model's
4
+ // context window".
5
+ //
6
+ // The approach and the summary prompts are Pi's (earendil-works/pi,
7
+ // packages/coding-agent, core/compaction), ported to the loop's
8
+ // Anthropic-shaped messages:
9
+ // - keep the newest ~20k tokens as they are;
10
+ // - cut only at a user turn or a model turn — never between a tool call
11
+ // and its result, which must follow it;
12
+ // - the model writes a structured checkpoint (Goal, Constraints, Progress,
13
+ // Decisions, Next steps, Critical context) of everything before the cut;
14
+ // a later compaction updates the earlier summary rather than summarising
15
+ // a summary;
16
+ // - the files read and changed are listed after it, from the calls that
17
+ // actually ran (the input as the hooks left it, and only calls that did
18
+ // not fail) — not from what the model asked for.
19
+ //
20
+ // Pi is under the MIT licence:
21
+ //
22
+ // MIT License
23
+ //
24
+ // Copyright (c) 2025 Mario Zechner
25
+ //
26
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
27
+ // of this software and associated documentation files (the "Software"), to deal
28
+ // in the Software without restriction, including without limitation the rights
29
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
30
+ // copies of the Software, and to permit persons to whom the Software is
31
+ // furnished to do so, subject to the following conditions:
32
+ //
33
+ // The above copyright notice and this permission notice shall be included in all
34
+ // copies or substantial portions of the Software.
35
+ //
36
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
37
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
38
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
39
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
40
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
41
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
42
+ // SOFTWARE.
43
+ /** What the loop uses unless a caller says otherwise: Pi's defaults, and
44
+ * the context window of the Claude models foldrun's tiers name. A model
45
+ * with a smaller window is still caught when the endpoint says the prompt
46
+ * is too long (the loop compacts then and asks again, once). */
47
+ export const COMPACTION_DEFAULTS = { contextWindow: 200_000, reserveTokens: 16_384, keepRecentTokens: 20_000 };
48
+ /** The smallest window compaction will work in. */
49
+ export const MIN_CONTEXT_WINDOW = 8_192;
50
+ /** Pi's numbers for a large window; a small one keeps a quarter for the
51
+ * reply and summarises down to about a third of it. */
52
+ export function compactionFor(contextWindow) {
53
+ return {
54
+ contextWindow,
55
+ reserveTokens: Math.min(COMPACTION_DEFAULTS.reserveTokens, Math.floor(contextWindow / 4)),
56
+ keepRecentTokens: Math.min(COMPACTION_DEFAULTS.keepRecentTokens, Math.floor(contextWindow * 0.3)),
57
+ };
58
+ }
59
+ export const SUMMARY_PREFIX = "The conversation history before this point was compacted into the following summary:\n\n<summary>\n";
60
+ const SUMMARY_SUFFIX = "\n</summary>";
61
+ export const SUMMARIZATION_SYSTEM_PROMPT = `You are a context summarization assistant. Your task is to read a conversation between a user and an AI assistant, then produce a structured summary following the exact format specified.
62
+
63
+ Do NOT continue the conversation. Do NOT respond to any questions in the conversation. ONLY output the structured summary.`;
64
+ const FORMAT = `## Goal
65
+ [What is the user trying to accomplish? Can be multiple items if the session covers different tasks.]
66
+
67
+ ## Constraints & Preferences
68
+ - [Any constraints, preferences, or requirements mentioned by user]
69
+ - [Or "(none)" if none were mentioned]
70
+
71
+ ## Progress
72
+ ### Done
73
+ - [x] [Completed tasks/changes]
74
+
75
+ ### In Progress
76
+ - [ ] [Current work]
77
+
78
+ ### Blocked
79
+ - [Issues preventing progress, if any]
80
+
81
+ ## Key Decisions
82
+ - **[Decision]**: [Brief rationale]
83
+
84
+ ## Next Steps
85
+ 1. [Ordered list of what should happen next]
86
+
87
+ ## Critical Context
88
+ - [Any data, examples, or references needed to continue]
89
+ - [Or "(none)" if not applicable]
90
+
91
+ Keep each section concise. Preserve exact file paths, function names, and error messages.`;
92
+ const SUMMARIZATION_PROMPT = `The messages above are a conversation to summarize. Create a structured context checkpoint summary that another LLM will use to continue the work.
93
+
94
+ Use this EXACT format:
95
+
96
+ ${FORMAT}`;
97
+ const UPDATE_PROMPT = `The messages above are NEW conversation messages to incorporate into the existing summary provided in <previous-summary> tags.
98
+
99
+ Update the existing structured summary with new information. RULES:
100
+ - PRESERVE all existing information from the previous summary
101
+ - ADD new progress, decisions, and context from the new messages
102
+ - UPDATE the Progress section: move items from "In Progress" to "Done" when completed
103
+ - UPDATE "Next Steps" based on what was accomplished
104
+ - PRESERVE exact file paths, function names, and error messages
105
+ - If something is no longer relevant, you may remove it
106
+
107
+ Use this EXACT format:
108
+
109
+ ${FORMAT}`;
110
+ const IMAGE_CHARS = 4800;
111
+ const TOOL_RESULT_MAX_CHARS = 2000;
112
+ /** A message's own words in the summarising request, at most. */
113
+ const MESSAGE_MAX_CHARS = 20_000;
114
+ const isSummaryBlock = (b) => b?.type === "text" && String(b.text ?? "").startsWith(SUMMARY_PREFIX);
115
+ function blockChars(b) {
116
+ if (b.type === "text")
117
+ return String(b.text ?? "").length;
118
+ if (b.type === "thinking")
119
+ return String(b.thinking ?? "").length;
120
+ if (b.type === "image")
121
+ return IMAGE_CHARS;
122
+ if (b.type === "tool_use")
123
+ return String(b.name ?? "").length + JSON.stringify(b.input ?? {}).length;
124
+ if (b.type === "tool_result") {
125
+ const c = b.content;
126
+ return typeof c === "string" ? c.length : Array.isArray(c) ? c.reduce((n, x) => n + blockChars(x), 0) : 0;
127
+ }
128
+ return JSON.stringify(b).length;
129
+ }
130
+ /** Tokens a message comes to, by four characters a token: an overestimate,
131
+ * which is the safe side here. */
132
+ export function estimateTokens(m) {
133
+ return Math.ceil(m.content.reduce((n, b) => n + blockChars(b), 0) / 4);
134
+ }
135
+ /** Every place a cut may go, after the first message. */
136
+ export function cutPoints(messages) {
137
+ const cuts = [];
138
+ for (let j = 1; j < messages.length; j++)
139
+ if (isCutPoint(messages[j]))
140
+ cuts.push(j);
141
+ return cuts;
142
+ }
143
+ /** A message may begin the kept part when it is a model turn or a user turn
144
+ * that answers no tool call: a tool result must stay after its call. */
145
+ function isCutPoint(m) {
146
+ if (m.role === "assistant")
147
+ return true;
148
+ return m.role === "user" && !m.content.some((b) => b.type === "tool_result");
149
+ }
150
+ /** Where the kept part starts: walking back from the newest message until
151
+ * `keep` tokens are behind, then forward to the first place a cut may go.
152
+ * When even the newest messages come to less than `keep`, everything from
153
+ * the first place a cut may go is kept (a large first message is what
154
+ * gets summarised). A kept part larger than `maxKeep` moves to a later
155
+ * cut, so a summary actually makes room. -1 when there is nowhere to cut. */
156
+ export function findCut(messages, keep, maxKeep = Infinity) {
157
+ const cuts = cutPoints(messages);
158
+ if (!cuts.length)
159
+ return -1;
160
+ // Each message's estimate once; what is kept from j on is suffix[j].
161
+ const suffix = new Array(messages.length + 1).fill(0);
162
+ for (let i = messages.length - 1; i >= 0; i--)
163
+ suffix[i] = suffix[i + 1] + estimateTokens(messages[i]);
164
+ const tail = (j) => suffix[j];
165
+ let chosen = cuts[0];
166
+ let acc = 0;
167
+ for (let i = messages.length - 1; i >= 1; i--) {
168
+ acc += estimateTokens(messages[i]);
169
+ if (acc >= keep) {
170
+ // The nearest cut at or after it; past the last one (one large tool
171
+ // result alone over the budget), the call with its result, as Pi does.
172
+ chosen = cuts.find((j) => j >= i) ?? cuts[cuts.length - 1];
173
+ break;
174
+ }
175
+ }
176
+ for (const j of cuts)
177
+ if (j > chosen && tail(chosen) > maxKeep)
178
+ chosen = j;
179
+ return chosen;
180
+ }
181
+ function truncate(text, max) {
182
+ if (text.length <= max)
183
+ return text;
184
+ let end = max;
185
+ if (/[\uD800-\uDBFF]/.test(text[end - 1] ?? ""))
186
+ end--;
187
+ return `${text.slice(0, end)}\n\n[... ${text.length - end} more characters truncated]`;
188
+ }
189
+ function textOf(c) {
190
+ if (typeof c === "string")
191
+ return c;
192
+ if (!Array.isArray(c))
193
+ return "";
194
+ return c.map((b) => (b.type === "text" ? String(b.text ?? "") : b.type === "image" ? "[image]" : "")).filter(Boolean).join("\n");
195
+ }
196
+ /** The conversation as text, so the summarising model reads it rather than
197
+ * continuing it. Thinking is left out; tool results are cut to 2,000
198
+ * characters each; the earlier summary's own block is left to the update
199
+ * prompt. */
200
+ export function serializeConversation(messages, maxChars = Infinity) {
201
+ const parts = [];
202
+ messages.forEach((m, at) => {
203
+ if (m.role === "user") {
204
+ const said = [];
205
+ m.content.forEach((b, k) => {
206
+ if (b.type === "tool_result") {
207
+ const t = textOf(b.content);
208
+ if (t)
209
+ parts.push(`[Tool result${b.is_error ? " (error)" : ""}]: ${truncate(t, TOOL_RESULT_MAX_CHARS)}`);
210
+ }
211
+ else if (b.type === "text") {
212
+ // The earlier summary is the update prompt's, not conversation —
213
+ // only where compaction puts it: the first block of the first turn.
214
+ if (!(at === 0 && k === 0 && isSummaryBlock(b)))
215
+ said.push(String(b.text ?? ""));
216
+ }
217
+ else if (b.type === "image")
218
+ said.push("[image]");
219
+ });
220
+ // The cap is the message's, across its blocks.
221
+ if (said.join("").trim())
222
+ parts.push(`[User]: ${truncate(said.join("\n"), MESSAGE_MAX_CHARS)}`);
223
+ }
224
+ else if (m.role === "assistant") {
225
+ const text = m.content.filter((b) => b.type === "text").map((b) => String(b.text ?? "")).join("\n").trim();
226
+ if (text)
227
+ parts.push(`[Assistant]: ${truncate(text, MESSAGE_MAX_CHARS)}`);
228
+ const calls = m.content.filter((b) => b.type === "tool_use").map((b) => {
229
+ const args = Object.entries((b.input ?? {})).map(([k, v]) => `${k}=${JSON.stringify(v)}`).join(", ");
230
+ return `${String(b.name)}(${args})`;
231
+ });
232
+ if (calls.length)
233
+ parts.push(`[Assistant tool calls]: ${truncate(calls.join("; "), MESSAGE_MAX_CHARS)}`);
234
+ }
235
+ });
236
+ // Still too long for the summarising request: the newest part is kept,
237
+ // what is cut is said.
238
+ let text = parts.join("\n\n");
239
+ if (text.length > maxChars) {
240
+ let start = text.length - maxChars;
241
+ if (/[\uDC00-\uDFFF]/.test(text[start] ?? ""))
242
+ start++;
243
+ text = `[... the first ${start} characters of the conversation are left out]\n\n${text.slice(start)}`;
244
+ }
245
+ return text;
246
+ }
247
+ /** The earlier summary, when the conversation starts with one. */
248
+ export function previousSummary(messages) {
249
+ const first = messages[0]?.content[0];
250
+ if (!first || !isSummaryBlock(first))
251
+ return null;
252
+ const t = String(first.text);
253
+ return t.slice(SUMMARY_PREFIX.length, t.endsWith(SUMMARY_SUFFIX) ? t.length - SUMMARY_SUFFIX.length : undefined);
254
+ }
255
+ /** The text the summarising model is sent. */
256
+ export function summaryRequest(toSummarize, earlier, maxChars = Infinity) {
257
+ // The earlier summary counts against the same budget: at most half of
258
+ // it, the conversation the rest.
259
+ const prior = earlier && Number.isFinite(maxChars) ? truncate(earlier, Math.floor(maxChars / 2)) : earlier;
260
+ const left = Number.isFinite(maxChars) ? Math.max(1_000, maxChars - (prior?.length ?? 0)) : Infinity;
261
+ let text = `<conversation>\n${serializeConversation(toSummarize, left)}\n</conversation>\n\n`;
262
+ if (prior)
263
+ text += `<previous-summary>\n${prior}\n</previous-summary>\n\n`;
264
+ return text + (earlier ? UPDATE_PROMPT : SUMMARIZATION_PROMPT);
265
+ }
266
+ /** The files the summary lists after it: read only, and changed. */
267
+ export function fileLists(read, changed) {
268
+ const readOnly = [...read].filter((f) => !changed.has(f)).sort();
269
+ const sections = [];
270
+ if (readOnly.length)
271
+ sections.push(`<read-files>\n${readOnly.join("\n")}\n</read-files>`);
272
+ if (changed.size)
273
+ sections.push(`<modified-files>\n${[...changed].sort().join("\n")}\n</modified-files>`);
274
+ return sections.length ? `\n\n${sections.join("\n\n")}` : "";
275
+ }
276
+ /** The conversation after compaction: the summary, then the kept part. The
277
+ * summary leads the first user turn (the turns must alternate, starting
278
+ * with the user's): it joins the kept part's first message when that is
279
+ * the user's, or comes before it as its own when the kept part opens on a
280
+ * model turn. */
281
+ export function compacted(summary, kept) {
282
+ const block = { type: "text", text: `${SUMMARY_PREFIX}${summary}${SUMMARY_SUFFIX}` };
283
+ if (kept[0]?.role === "user")
284
+ return [{ role: "user", content: [block, ...kept[0].content] }, ...kept.slice(1)];
285
+ return [{ role: "user", content: [block] }, ...kept];
286
+ }
287
+ /** An endpoint's refusal that means the prompt did not fit: a 400 or 413
288
+ * that says so. Any other status is not, whatever its words. */
289
+ export function isContextOverflow(status, message) {
290
+ if (status !== 400 && status !== 413)
291
+ return false;
292
+ return /prompt is too long|input is too long|maximum context length|context length exceeded|(exceeds?|exceeded) (the )?(model's )?(maximum )?context( window| length)?|too many (input )?tokens/i.test(message);
293
+ }
@@ -19,6 +19,6 @@ export declare function endOf(stopReason: string | null, calls: number): {
19
19
  export declare function buildRequest(o: Pick<LoopOptions, "model" | "systemPrompt" | "tools" | "env">, messages: {
20
20
  role: string;
21
21
  content: Block[];
22
- }[]): Json;
22
+ }[], cache?: boolean, maxTokens?: number): Json;
23
23
  /** The foldrun engine, as executeStep's model loop. */
24
24
  export declare const foldrunQuery: QueryFn;