quick-acp 0.0.0-stage → 0.1.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.
@@ -0,0 +1,411 @@
1
+ /**
2
+ * Tool registry and local execution.
3
+ *
4
+ * SCOPE DECISION (matches the referenced guide):
5
+ * Quick already ships file read/write/list/search and apply_patch on the
6
+ * desktop surface — `desktop_windows.yaml` is `default_available: true`, so
7
+ * those tools are on by default. Re-implementing them here would only create a
8
+ * second, worse copy.
9
+ *
10
+ * What Quick does NOT give us is local shell execution: `device_shell` sits
11
+ * behind three gates (code_mode_enabled, outpost capability `deviceShell`,
12
+ * sandbox.available), and the guide's whole point is that people bolt on an
13
+ * external MCP server to get a shell. So:
14
+ *
15
+ * - shell_run NEW — the actual gap this bridge fills
16
+ * - file_read NEW — kept for turn-efficiency: one call instead of
17
+ * asking Quick to route it through its own loop
18
+ * - file_write NEW
19
+ * - file_list NEW
20
+ * - file_search NEW
21
+ *
22
+ * Every tool is confined to a workspace root and gated by an explicit policy,
23
+ * because an unconfined shell reachable from a model is a remote-code-execution
24
+ * primitive pointed at the user's machine.
25
+ */
26
+ import { spawn } from 'node:child_process';
27
+ import { promises as fs } from 'node:fs';
28
+ import { resolve, dirname, relative, isAbsolute, join, sep } from 'node:path';
29
+ export const DEFAULT_SHELL_DENY_PATTERNS = [
30
+ // Destructive filesystem operations that are almost never what a coding
31
+ // agent meant, and are unrecoverable when wrong.
32
+ /\brm\s+(-[a-zA-Z]*\s+)*\/(\s|$)/,
33
+ /\brm\s+-[a-zA-Z]*[rR][a-zA-Z]*\s+(-[a-zA-Z]*\s+)*~\//,
34
+ /\bmkfs(\.\w+)?\b/,
35
+ /\bdd\s+.*\bof=\/dev\//,
36
+ /\b(shutdown|reboot|halt|poweroff)\b/,
37
+ // Privilege escalation: the bridge never needs it, and it would let a model
38
+ // escape the workspace jail entirely.
39
+ /\bsudo\b/,
40
+ /\b(chmod|chown)\s+[ugoa+=-]*\s*\+?[rwxXst]*\s*\/(\s|$)/,
41
+ // Piping a download straight into an interpreter. Real supply-chain hazard.
42
+ /\b(curl|wget)\b[^|]*\|\s*(ba|z|k|da)?sh\b/,
43
+ ];
44
+ export function defaultPolicy(workspaceRoot) {
45
+ return {
46
+ workspaceRoot: resolve(workspaceRoot),
47
+ allowShell: process.env.QUICK_ACP_ALLOW_SHELL === '1',
48
+ shellDenyPatterns: DEFAULT_SHELL_DENY_PATTERNS,
49
+ shellTimeoutMs: 120_000,
50
+ maxOutputBytes: 400_000,
51
+ maxWriteBytes: 4_000_000,
52
+ };
53
+ }
54
+ // ---------------------------------------------------------------------------
55
+ // Tool definitions
56
+ // ---------------------------------------------------------------------------
57
+ export function toolDefs(policy) {
58
+ const defs = [
59
+ {
60
+ name: 'file_read',
61
+ description: 'Read a UTF-8 text file. Returns the content with a 1-based line offset. ' +
62
+ 'Paths are relative to the workspace root.',
63
+ inputSchema: {
64
+ type: 'object',
65
+ properties: {
66
+ path: { type: 'string', description: 'File path, relative to the workspace root.' },
67
+ offset: { type: 'number', description: '1-based first line to return. Default 1.' },
68
+ limit: { type: 'number', description: 'Maximum lines to return. Default 2000.' },
69
+ },
70
+ required: ['path'],
71
+ additionalProperties: false,
72
+ },
73
+ },
74
+ {
75
+ name: 'file_write',
76
+ description: 'Create or fully replace a UTF-8 text file, creating parent directories as needed. ' +
77
+ 'This replaces the whole file; it does not append.',
78
+ inputSchema: {
79
+ type: 'object',
80
+ properties: {
81
+ path: { type: 'string', description: 'File path, relative to the workspace root.' },
82
+ content: { type: 'string', description: 'Full new file content.' },
83
+ },
84
+ required: ['path', 'content'],
85
+ additionalProperties: false,
86
+ },
87
+ },
88
+ {
89
+ name: 'file_list',
90
+ description: 'List directory entries. Directories are marked with a trailing slash. ' +
91
+ 'Skips node_modules and .git by default.',
92
+ inputSchema: {
93
+ type: 'object',
94
+ properties: {
95
+ path: { type: 'string', description: 'Directory, relative to the workspace root. Default ".".' },
96
+ recursive: { type: 'boolean', description: 'Walk subdirectories. Default false.' },
97
+ },
98
+ additionalProperties: false,
99
+ },
100
+ },
101
+ {
102
+ name: 'file_search',
103
+ description: 'Search file contents with a regular expression and return matching lines ' +
104
+ 'as path:line:text. Bounded by maxResults and a size cap per file.',
105
+ inputSchema: {
106
+ type: 'object',
107
+ properties: {
108
+ pattern: { type: 'string', description: 'JavaScript regular expression source.' },
109
+ path: { type: 'string', description: 'Directory to search. Default ".".' },
110
+ glob: { type: 'string', description: 'Only consider files whose path contains this substring.' },
111
+ maxResults: { type: 'number', description: 'Maximum matches. Default 100.' },
112
+ },
113
+ required: ['pattern'],
114
+ additionalProperties: false,
115
+ },
116
+ },
117
+ ];
118
+ if (policy.allowShell) {
119
+ defs.push({
120
+ name: 'shell_run',
121
+ description: 'Run a shell command in the workspace root and return combined stdout/stderr and the ' +
122
+ 'exit code. Runs through the platform shell, so quoting follows that shell. ' +
123
+ 'Bounded by a timeout; destructive and privilege-escalating commands are refused.',
124
+ inputSchema: {
125
+ type: 'object',
126
+ properties: {
127
+ command: { type: 'string', description: 'The command line to run.' },
128
+ cwd: { type: 'string', description: 'Working directory, relative to the workspace root. Default ".".' },
129
+ timeoutMs: { type: 'number', description: 'Override the default timeout in milliseconds.' },
130
+ },
131
+ required: ['command'],
132
+ additionalProperties: false,
133
+ },
134
+ });
135
+ }
136
+ return defs;
137
+ }
138
+ export class ToolExecutor {
139
+ policy;
140
+ root;
141
+ constructor(policy) {
142
+ this.policy = policy;
143
+ this.root = resolve(policy.workspaceRoot);
144
+ }
145
+ /**
146
+ * Resolve a caller-supplied path inside the workspace.
147
+ * Absolute paths are accepted but must still land inside the root; anything
148
+ * that escapes (via `..`, a symlink target, a different drive) is refused.
149
+ */
150
+ resolveInside(input) {
151
+ const raw = typeof input === 'string' && input.length > 0 ? input : '.';
152
+ const abs = isAbsolute(raw) ? resolve(raw) : resolve(this.root, raw);
153
+ const rel = relative(this.root, abs);
154
+ if (rel.startsWith('..') || (isAbsolute(rel) && rel !== '')) {
155
+ throw new Error(`path escapes the workspace root: ${input}`);
156
+ }
157
+ if (rel !== '' && rel.split(sep).includes('..')) {
158
+ throw new Error(`path escapes the workspace root: ${input}`);
159
+ }
160
+ return abs;
161
+ }
162
+ async execute(name, args) {
163
+ try {
164
+ switch (name) {
165
+ case 'file_read':
166
+ return await this.fileRead(args);
167
+ case 'file_write':
168
+ return await this.fileWrite(args);
169
+ case 'file_list':
170
+ return await this.fileList(args);
171
+ case 'file_search':
172
+ return await this.fileSearch(args);
173
+ case 'shell_run':
174
+ return await this.shellRun(args);
175
+ default:
176
+ return { ok: false, content: `unknown tool: ${name}`, error: 'unknown_tool' };
177
+ }
178
+ }
179
+ catch (e) {
180
+ const message = e instanceof Error ? e.message : String(e);
181
+ return { ok: false, content: `error: ${message}`, error: message };
182
+ }
183
+ }
184
+ async fileRead(args) {
185
+ const path = this.resolveInside(String(args['path'] ?? ''));
186
+ const offset = positiveInt(args['offset'], 1);
187
+ const limit = positiveInt(args['limit'], 2000);
188
+ const text = await fs.readFile(path, 'utf8');
189
+ const lines = text.split(/\r?\n/);
190
+ const slice = lines.slice(offset - 1, offset - 1 + limit);
191
+ const numbered = slice.map((l, i) => `${offset + i}\t${l}`).join('\n');
192
+ return {
193
+ ok: true,
194
+ content: truncate(numbered, this.policy.maxOutputBytes, 'file_read'),
195
+ };
196
+ }
197
+ async fileWrite(args) {
198
+ const path = this.resolveInside(String(args['path'] ?? ''));
199
+ const content = String(args['content'] ?? '');
200
+ const bytes = Buffer.byteLength(content, 'utf8');
201
+ if (bytes > this.policy.maxWriteBytes) {
202
+ return {
203
+ ok: false,
204
+ content: `refused: content is ${bytes} bytes, over the ${this.policy.maxWriteBytes} byte limit`,
205
+ error: 'write_too_large',
206
+ };
207
+ }
208
+ await fs.mkdir(dirname(path), { recursive: true });
209
+ await fs.writeFile(path, content, 'utf8');
210
+ return { ok: true, content: `wrote ${bytes} bytes to ${relative(this.root, path)}` };
211
+ }
212
+ async fileList(args) {
213
+ const dir = this.resolveInside(String(args['path'] ?? '.'));
214
+ const recursive = args['recursive'] === true;
215
+ const skip = new Set(['node_modules', '.git', 'dist', '.next', '__pycache__']);
216
+ const out = [];
217
+ const walk = async (current, prefix, depth) => {
218
+ if (depth > 12)
219
+ return;
220
+ const entries = await fs.readdir(current, { withFileTypes: true });
221
+ entries.sort((a, b) => Number(b.isDirectory()) - Number(a.isDirectory()) || a.name.localeCompare(b.name));
222
+ for (const entry of entries) {
223
+ if (skip.has(entry.name))
224
+ continue;
225
+ const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
226
+ if (entry.isDirectory()) {
227
+ out.push(`${rel}/`);
228
+ if (recursive)
229
+ await walk(join(current, entry.name), rel, depth + 1);
230
+ }
231
+ else {
232
+ out.push(rel);
233
+ }
234
+ if (out.length > 5000)
235
+ return;
236
+ }
237
+ };
238
+ await walk(dir, '', 0);
239
+ return {
240
+ ok: true,
241
+ content: truncate(out.join('\n') || '(empty)', this.policy.maxOutputBytes, 'file_list'),
242
+ };
243
+ }
244
+ async fileSearch(args) {
245
+ const patternSource = String(args['pattern'] ?? '');
246
+ if (!patternSource)
247
+ return { ok: false, content: 'refused: empty pattern', error: 'bad_pattern' };
248
+ let re;
249
+ try {
250
+ re = new RegExp(patternSource, 'i');
251
+ }
252
+ catch (e) {
253
+ return { ok: false, content: `invalid regular expression: ${String(e)}`, error: 'bad_pattern' };
254
+ }
255
+ const dir = this.resolveInside(String(args['path'] ?? '.'));
256
+ const globFilter = typeof args['glob'] === 'string' ? args['glob'] : '';
257
+ const maxResults = positiveInt(args['maxResults'], 100);
258
+ const skip = new Set(['node_modules', '.git', 'dist', '.next', '__pycache__']);
259
+ const hits = [];
260
+ const walk = async (current, prefix, depth) => {
261
+ if (depth > 12 || hits.length >= maxResults)
262
+ return;
263
+ let entries;
264
+ try {
265
+ entries = await fs.readdir(current, { withFileTypes: true });
266
+ }
267
+ catch {
268
+ return;
269
+ }
270
+ for (const entry of entries) {
271
+ if (hits.length >= maxResults)
272
+ return;
273
+ if (skip.has(entry.name))
274
+ continue;
275
+ const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
276
+ if (entry.isDirectory()) {
277
+ await walk(join(current, entry.name), rel, depth + 1);
278
+ continue;
279
+ }
280
+ if (globFilter && !rel.includes(globFilter))
281
+ continue;
282
+ let stat;
283
+ try {
284
+ stat = await fs.stat(join(current, entry.name));
285
+ }
286
+ catch {
287
+ continue;
288
+ }
289
+ if (stat.size > 2_000_000)
290
+ continue; // skip large/binary files
291
+ let text;
292
+ try {
293
+ text = await fs.readFile(join(current, entry.name), 'utf8');
294
+ }
295
+ catch {
296
+ continue;
297
+ }
298
+ if (text.includes('\u0000'))
299
+ continue; // binary
300
+ const lines = text.split(/\r?\n/);
301
+ for (let i = 0; i < lines.length; i++) {
302
+ if (re.test(lines[i])) {
303
+ hits.push(`${rel}:${i + 1}:${lines[i]}`);
304
+ if (hits.length >= maxResults)
305
+ return;
306
+ }
307
+ }
308
+ }
309
+ };
310
+ await walk(dir, '', 0);
311
+ return {
312
+ ok: true,
313
+ content: truncate(hits.join('\n') || '(no matches)', this.policy.maxOutputBytes, 'file_search'),
314
+ };
315
+ }
316
+ async shellRun(args) {
317
+ if (!this.policy.allowShell) {
318
+ return {
319
+ ok: false,
320
+ content: 'refused: shell execution is disabled (set QUICK_ACP_ALLOW_SHELL=1 to enable)',
321
+ error: 'shell_disabled',
322
+ };
323
+ }
324
+ const command = String(args['command'] ?? '');
325
+ if (!command.trim())
326
+ return { ok: false, content: 'refused: empty command', error: 'bad_command' };
327
+ for (const deny of this.policy.shellDenyPatterns) {
328
+ if (deny.test(command)) {
329
+ return {
330
+ ok: false,
331
+ content: `refused: command matches a blocked pattern (${deny.source})`,
332
+ error: 'command_blocked',
333
+ };
334
+ }
335
+ }
336
+ const cwd = this.resolveInside(String(args['cwd'] ?? '.'));
337
+ const timeoutMs = clampTimeout(args['timeoutMs'], this.policy.shellTimeoutMs);
338
+ const isWindows = process.platform === 'win32';
339
+ return await new Promise((resolvePromise) => {
340
+ const child = spawn(command, {
341
+ cwd,
342
+ shell: isWindows ? true : '/bin/sh',
343
+ windowsHide: true,
344
+ env: { ...process.env },
345
+ });
346
+ let out = Buffer.alloc(0);
347
+ let killedByTimeout = false;
348
+ let killedBySize = false;
349
+ const append = (chunk) => {
350
+ out = Buffer.concat([out, chunk]);
351
+ if (out.length > this.policy.maxOutputBytes && !killedBySize) {
352
+ killedBySize = true;
353
+ try {
354
+ child.kill('SIGKILL');
355
+ }
356
+ catch {
357
+ /* already dead */
358
+ }
359
+ }
360
+ };
361
+ child.stdout?.on('data', append);
362
+ child.stderr?.on('data', append);
363
+ const timer = setTimeout(() => {
364
+ killedByTimeout = true;
365
+ try {
366
+ child.kill('SIGKILL');
367
+ }
368
+ catch {
369
+ /* already dead */
370
+ }
371
+ }, timeoutMs);
372
+ child.on('error', (err) => {
373
+ clearTimeout(timer);
374
+ resolvePromise({ ok: false, content: `failed to start: ${err.message}`, error: 'spawn_failed' });
375
+ });
376
+ child.on('close', (code, signal) => {
377
+ clearTimeout(timer);
378
+ let text = out.toString('utf8');
379
+ if (killedBySize)
380
+ text += `\n[output truncated at ${this.policy.maxOutputBytes} bytes]`;
381
+ if (killedByTimeout)
382
+ text += `\n[timed out after ${timeoutMs}ms]`;
383
+ const ok = code === 0 && !killedByTimeout;
384
+ resolvePromise({
385
+ ok,
386
+ content: text || '(no output)',
387
+ ...(ok ? {} : { error: killedByTimeout ? 'timeout' : `exit_${code ?? signal}` }),
388
+ });
389
+ });
390
+ });
391
+ }
392
+ }
393
+ // ---------------------------------------------------------------------------
394
+ function positiveInt(v, fallback) {
395
+ const n = typeof v === 'number' ? v : Number.parseInt(String(v ?? ''), 10);
396
+ return Number.isFinite(n) && n > 0 ? Math.trunc(n) : fallback;
397
+ }
398
+ function clampTimeout(v, fallback) {
399
+ const n = typeof v === 'number' ? v : Number.parseInt(String(v ?? ''), 10);
400
+ if (!Number.isFinite(n) || n <= 0)
401
+ return fallback;
402
+ // Never let a caller extend past the policy ceiling.
403
+ return Math.min(Math.trunc(n), fallback);
404
+ }
405
+ function truncate(text, maxBytes, tool) {
406
+ const buf = Buffer.from(text, 'utf8');
407
+ if (buf.length <= maxBytes)
408
+ return text;
409
+ return `${buf.subarray(0, maxBytes).toString('utf8')}\n[truncated by ${tool} at ${maxBytes} bytes]`;
410
+ }
411
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1,188 @@
1
+ /**
2
+ * The tool-invocation strategy.
3
+ *
4
+ * The Quick gateway gives a caller no tool channel: the model's tools belong to
5
+ * Quick's own agent loop. Bridging that takes one of two mechanisms, and this
6
+ * branch ships the only one that works without the desktop app installed.
7
+ *
8
+ * "inject" (this branch)
9
+ * Advertise the tools in the prompt as a JSON contract, parse a fenced block
10
+ * out of the reply, execute locally, feed the result back as the next user
11
+ * turn. Costs one extra turn per tool call and depends on the model
12
+ * complying, but needs nothing but the gateway: no outpost, no instance
13
+ * token, no Electron shell, no desktop app.
14
+ *
15
+ * WHY THERE IS NO `mcp` MODE HERE
16
+ * ------------------------------
17
+ * Running an MCP server locally and registering it into Quick over
18
+ * `/local/mcp/add` gives the model native tool calls: zero extra turns and no
19
+ * format-compliance problem. It is strictly better — when it works — but
20
+ * enabling a local MCP server is gated twice by the desktop app:
21
+ *
22
+ * 1. `/local/mcp/add|toggle|remove|reload` answer HTTP 503
23
+ * `permissions_pending` until the app has pulled the organisation's
24
+ * permissions. A global write gate: a brand-new non-existent id gets the
25
+ * same answer, and it does not clear on retry. Reads (`list`) stay 200.
26
+ *
27
+ * 2. `toggle` additionally needs an Ed25519-signed confirmation
28
+ * {nonce, signature, timestamp, jti, hashVersion, outpostId} produced by
29
+ * Electron's main process after a native OS dialog.
30
+ *
31
+ * Both belong to the desktop app, so `mcp` mode would be dead code on a clean
32
+ * machine — the very machine this project targets. It is kept on the
33
+ * `mcp-native` branch, together with notes on what a desktop-free version would
34
+ * need.
35
+ */
36
+ /**
37
+ * Which strategy to use.
38
+ *
39
+ * Only one exists on this branch. QUICK_ACP_TOOL_MODE is still read so a config
40
+ * copied from the `mcp-native` branch does not fail loudly; the value is ignored.
41
+ */
42
+ export function resolveToolMode() {
43
+ const raw = (process.env.QUICK_ACP_TOOL_MODE ?? '').toLowerCase();
44
+ if (raw === 'mcp') {
45
+ console.error('[quick-acp] QUICK_ACP_TOOL_MODE=mcp ignored: native MCP lives on the ' +
46
+ '"mcp-native" branch (it needs the Quick desktop app). Using inject.');
47
+ }
48
+ return 'inject';
49
+ }
50
+ // ---------------------------------------------------------------------------
51
+ // Strategy: inject
52
+ // ---------------------------------------------------------------------------
53
+ /** Marker the model is asked to emit. Chosen to be unlikely in prose. */
54
+ const CALL_OPEN = '```quick-tool-call';
55
+ const CALL_CLOSE = '```';
56
+ /**
57
+ * Build the prompt that teaches the model the tool contract.
58
+ *
59
+ * Kept separate from the user's text so the caller can see exactly what extra
60
+ * tokens are being spent, and so the contract can be cached upstream.
61
+ */
62
+ export function buildToolPrompt(tools, workspaceRoot) {
63
+ const spec = tools
64
+ .map((t) => {
65
+ return [
66
+ `### ${t.name}`,
67
+ t.description,
68
+ 'Arguments (JSON Schema):',
69
+ '```json',
70
+ JSON.stringify(t.inputSchema, null, 2),
71
+ '```',
72
+ ].join('\n');
73
+ })
74
+ .join('\n\n');
75
+ return [
76
+ 'You are operating with access to local tools through the caller.',
77
+ `The workspace root is: ${workspaceRoot}`,
78
+ '',
79
+ 'AVAILABLE TOOLS',
80
+ '',
81
+ spec,
82
+ '',
83
+ 'HOW TO CALL A TOOL',
84
+ '',
85
+ 'When you need a tool, reply with exactly one fenced block and nothing else:',
86
+ '',
87
+ CALL_OPEN,
88
+ '{"name": "<tool name>", "arguments": { ... }}',
89
+ CALL_CLOSE,
90
+ '',
91
+ 'Rules:',
92
+ '- Emit at most one tool call per reply.',
93
+ '- The block must contain only valid JSON.',
94
+ '- Do not wrap the JSON in extra prose inside the block.',
95
+ '- After the block, stop. The caller runs the tool and sends you the result.',
96
+ '- To finish without a tool, just answer normally with no such block.',
97
+ ].join('\n');
98
+ }
99
+ /**
100
+ * Extract a tool call from a model reply.
101
+ * Returns null when the reply is a normal answer, so the caller can treat it as
102
+ * the final assistant text.
103
+ */
104
+ export function parseToolCall(text) {
105
+ const open = text.indexOf(CALL_OPEN);
106
+ if (open < 0)
107
+ return null;
108
+ const afterOpen = open + CALL_OPEN.length;
109
+ const close = text.indexOf(CALL_CLOSE, afterOpen);
110
+ if (close < 0)
111
+ return null;
112
+ const body = text.slice(afterOpen, close).trim();
113
+ if (!body)
114
+ return null;
115
+ let parsed;
116
+ try {
117
+ parsed = JSON.parse(body);
118
+ }
119
+ catch {
120
+ return null; // model emitted malformed JSON; treat as prose
121
+ }
122
+ if (!parsed || typeof parsed !== 'object')
123
+ return null;
124
+ const obj = parsed;
125
+ const name = typeof obj['name'] === 'string' ? obj['name'] : '';
126
+ if (!name)
127
+ return null;
128
+ const args = obj['arguments'] && typeof obj['arguments'] === 'object'
129
+ ? obj['arguments']
130
+ : {};
131
+ return { name, arguments: args };
132
+ }
133
+ /** Render a tool result as the next user turn. */
134
+ export function formatToolResult(call, result) {
135
+ return [
136
+ `Tool result for ${call.name}:`,
137
+ '',
138
+ '```',
139
+ result.content,
140
+ '```',
141
+ '',
142
+ result.ok
143
+ ? 'Continue. Call another tool if needed, or give your final answer.'
144
+ : 'The tool failed. Adjust your approach or explain the problem.',
145
+ ].join('\n');
146
+ }
147
+ /**
148
+ * Drive a prompt loop with the inject strategy.
149
+ *
150
+ * The caller supplies a `turn` function that performs ONE gateway turn and
151
+ * returns the full assistant text; this function handles the tool round trips.
152
+ */
153
+ export async function runWithInjectedTools(opts) {
154
+ const preamble = buildToolPrompt(opts.tools, opts.workspaceRoot);
155
+ let pending = `${preamble}\n\n---\n\n${opts.userText}`;
156
+ let rounds = 0;
157
+ for (;;) {
158
+ const reply = await opts.turn(pending);
159
+ if (reply.cancelled) {
160
+ return { finalText: reply.text, cancelled: true, rounds };
161
+ }
162
+ const call = parseToolCall(reply.text);
163
+ if (!call) {
164
+ // Normal answer: this is the end of the turn.
165
+ opts.onAssistantText(reply.text);
166
+ return { finalText: reply.text, cancelled: false, rounds };
167
+ }
168
+ if (rounds >= opts.maxToolRounds) {
169
+ const stop = `Stopped after ${opts.maxToolRounds} tool rounds without a final answer. ` +
170
+ 'Raise QUICK_ACP_MAX_TOOL_ROUNDS or narrow the request.';
171
+ opts.onAssistantText(stop);
172
+ return { finalText: stop, cancelled: false, rounds };
173
+ }
174
+ rounds++;
175
+ const result = await opts.executor.execute(call.name, call.arguments);
176
+ opts.onToolCall(call, result);
177
+ pending = formatToolResult(call, result);
178
+ }
179
+ }
180
+ // ---------------------------------------------------------------------------
181
+ // Strategy: mcp
182
+ // ---------------------------------------------------------------------------
183
+ //
184
+ // Not present on this branch. The MCP server, its registration handshake, and
185
+ // the notes on what a desktop-free version would need all live on the
186
+ // `mcp-native` branch. Keeping the stub out of the build means `tsc` cannot be
187
+ // satisfied by code that cannot run on a clean machine.
188
+ //# sourceMappingURL=strategies.js.map