@miphamai/cli 0.7.4 → 0.7.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miphamai/cli",
3
- "version": "0.7.4",
3
+ "version": "0.7.6",
4
4
  "description": "Mipham Code — Multi-model open-core intelligent coding terminal by MiphamAI",
5
5
  "keywords": [
6
6
  "ai",
@@ -300,7 +300,7 @@ export class QueryEngine {
300
300
  }
301
301
 
302
302
  private async *continueWithTools(signal?: AbortSignal): AsyncGenerator<StreamChunk> {
303
- const MAX_TURNS = 10
303
+ const MAX_TURNS = 20
304
304
  const toolDefs = this.getToolDefinitions()
305
305
 
306
306
  for (let turn = 0; turn < MAX_TURNS; turn++) {
@@ -381,11 +381,34 @@ export class QueryEngine {
381
381
  this.context.addMessage(msg)
382
382
  }
383
383
 
384
- // Safety: prevent silent truncation when max turns reached
384
+ // Safety: when max turns reached with pending tools, ask model to summarize
385
385
  if (turn === MAX_TURNS - 1 && toolUses.length > 0) {
386
- yield {
387
- type: 'error',
388
- error: `Max tool-calling turns (${MAX_TURNS}) reached. Some tool calls were not executed.`,
386
+ this.context.addMessage({
387
+ role: 'user',
388
+ content:
389
+ `You've reached the maximum of ${MAX_TURNS} tool-calling rounds. ` +
390
+ `${toolUses.length} tool call(s) were not executed. ` +
391
+ 'Please summarize what you found so far and any next steps the user should take.',
392
+ })
393
+ // Give model one final chance to respond with a summary
394
+ try {
395
+ const finalSystemPrompt = this.context.getSystemPrompt()
396
+ const finalMessages = this.context.getMessages()
397
+ for await (const chunk of this.registry.chat({
398
+ model: this.registry.getActiveModel(),
399
+ messages: finalMessages,
400
+ systemPrompt: finalSystemPrompt,
401
+ tools: undefined, // no tools — force text-only summary
402
+ signal,
403
+ })) {
404
+ yield chunk
405
+ if (chunk.type === 'error') return
406
+ }
407
+ } catch {
408
+ yield {
409
+ type: 'error',
410
+ error: `Max tool-calling turns (${MAX_TURNS}) reached. Some tool calls were not executed.`,
411
+ }
389
412
  }
390
413
  return
391
414
  }
@@ -3,7 +3,7 @@ import type { JsonRpcRequest, JsonRpcResponse, JsonRpcNotification } from './typ
3
3
 
4
4
  type NotificationHandler = (notification: JsonRpcNotification) => void
5
5
 
6
- const REQUEST_TIMEOUT_MS = 30_000
6
+ const REQUEST_TIMEOUT_MS = 60_000
7
7
 
8
8
  // ── Environment variable security: block sensitive vars from MCP subprocess ──
9
9
  //