@pentoshi/clai 3.8.41 → 3.8.42

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.
Files changed (42) hide show
  1. package/dist/agent/runner.js +13 -4
  2. package/dist/agent/runner.js.map +1 -1
  3. package/dist/agent/session-title.js +5 -4
  4. package/dist/agent/session-title.js.map +1 -1
  5. package/dist/app/controllers/session-controller.js +2 -1
  6. package/dist/app/controllers/session-controller.js.map +1 -1
  7. package/dist/app/controllers/turn-controller.js +5 -21
  8. package/dist/app/controllers/turn-controller.js.map +1 -1
  9. package/dist/llm/adapters/gemini-tools.d.ts +3 -0
  10. package/dist/llm/adapters/gemini-tools.js +87 -3
  11. package/dist/llm/adapters/gemini-tools.js.map +1 -1
  12. package/dist/llm/anthropic.d.ts +2 -0
  13. package/dist/llm/anthropic.js +32 -11
  14. package/dist/llm/anthropic.js.map +1 -1
  15. package/dist/llm/aws-mantle.js +22 -18
  16. package/dist/llm/aws-mantle.js.map +1 -1
  17. package/dist/llm/gemini.js.map +1 -1
  18. package/dist/llm/http.d.ts +24 -0
  19. package/dist/llm/http.js +25 -3
  20. package/dist/llm/http.js.map +1 -1
  21. package/dist/llm/router.js +19 -10
  22. package/dist/llm/router.js.map +1 -1
  23. package/dist/tui-v2/components/transcript/notice-row.js +3 -1
  24. package/dist/tui-v2/components/transcript/notice-row.js.map +1 -1
  25. package/dist/tui-v2/composer/completion.d.ts +2 -0
  26. package/dist/tui-v2/composer/completion.js +19 -0
  27. package/dist/tui-v2/composer/completion.js.map +1 -1
  28. package/dist/tui-v2/composer/composer-editor.js +15 -6
  29. package/dist/tui-v2/composer/composer-editor.js.map +1 -1
  30. package/dist/tui-v2/composer/paste-placeholder.d.ts +1 -0
  31. package/dist/tui-v2/composer/paste-placeholder.js +3 -0
  32. package/dist/tui-v2/composer/paste-placeholder.js.map +1 -1
  33. package/dist/tui-v2/state/transcript-reducer.d.ts +2 -2
  34. package/dist/tui-v2/state/transcript-reducer.js +17 -94
  35. package/dist/tui-v2/state/transcript-reducer.js.map +1 -1
  36. package/dist/types.d.ts +9 -0
  37. package/dist/types.js.map +1 -1
  38. package/dist/ui/thinking.js +9 -7
  39. package/dist/ui/thinking.js.map +1 -1
  40. package/dist/version.generated.d.ts +2 -2
  41. package/dist/version.generated.js +2 -2
  42. package/package.json +1 -1
@@ -2358,20 +2358,20 @@ export async function runAgentTurn(prompt, options = {}) {
2358
2358
  }
2359
2359
  }
2360
2360
  }
2361
- if (!sawReasoning && /<think/i.test(token)) {
2361
+ if (!sawReasoning && /<think(?:ing)?\b/i.test(token)) {
2362
2362
  sawReasoning = true;
2363
2363
  inThinking = true;
2364
2364
  spinner.setLabel("thinking");
2365
2365
  if (!writesDirectly)
2366
2366
  emit({ type: "status", text: "thinking" });
2367
2367
  }
2368
- if (/<\/think>/i.test(token)) {
2368
+ if (/<\/think(?:ing)?>/i.test(token)) {
2369
2369
  inThinking = false;
2370
2370
  spinner.setLabel("generating response (0 tokens)");
2371
2371
  generatedTokens = 0;
2372
2372
  }
2373
2373
  if (inThinking) {
2374
- const cleaned = token.replace(/<\/?think[^>]*>/gi, "");
2374
+ const cleaned = token.replace(/<\/?think(?:ing)?[^>]*>/gi, "");
2375
2375
  if (cleaned) {
2376
2376
  spinner.pushPreview(cleaned);
2377
2377
  const approx = cleaned.split(/\s+/).filter(Boolean).length;
@@ -2433,7 +2433,16 @@ export async function runAgentTurn(prompt, options = {}) {
2433
2433
  (toolsAttached && !isTextOnlyModel(provider, model));
2434
2434
  const assistantTextResult = rememberThinkingFromText(completion.text);
2435
2435
  assistantText = assistantTextResult;
2436
- if (assistantText.hasThinking) {
2436
+ // Only emit a thinking-block event when the classic renderer is
2437
+ // active (writesDirectly / no deltaParser). In TUI v2 the
2438
+ // deltaParser already streamed thinking-delta events that created
2439
+ // the thinking item in the correct transcript position; emitting
2440
+ // a redundant thinking-block after tool-call events have cleared
2441
+ // pendingThinkingId causes the reducer to append a *duplicate*
2442
+ // thinking item at the end of the transcript — the root cause of
2443
+ // the "ghost thinking blocks below the response" bug seen with
2444
+ // models that use reasoning_content (e.g. Kimi K2-thinking).
2445
+ if (assistantText.hasThinking && !deltaParser) {
2437
2446
  writeThinkingBlock(assistantText.thinkContent);
2438
2447
  }
2439
2448
  // Native-first: prefer structured toolCalls from the provider.