snow-ai 0.6.40 → 0.6.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.
package/bundle/cli.mjs CHANGED
@@ -46302,6 +46302,22 @@ var init_compact = __esm({
46302
46302
  }
46303
46303
  });
46304
46304
 
46305
+ // dist/utils/commands/copyLast.js
46306
+ var init_copyLast = __esm({
46307
+ "dist/utils/commands/copyLast.js"() {
46308
+ "use strict";
46309
+ init_commandExecutor();
46310
+ registerCommand("copy-last", {
46311
+ execute: () => {
46312
+ return {
46313
+ success: true,
46314
+ action: "copyLastMessage"
46315
+ };
46316
+ }
46317
+ });
46318
+ }
46319
+ });
46320
+
46305
46321
  // dist/utils/commands/custom.js
46306
46322
  var custom_exports = {};
46307
46323
  __export(custom_exports, {
@@ -48298,6 +48314,9 @@ async function delay(ms, abortSignal) {
48298
48314
  });
48299
48315
  }
48300
48316
  function isRetriableError(error) {
48317
+ if (error.name === "StreamIdleTimeoutError") {
48318
+ return true;
48319
+ }
48301
48320
  const errorMessage = error.message.toLowerCase();
48302
48321
  if (errorMessage.includes("network") || errorMessage.includes("econnrefused") || errorMessage.includes("econnreset") || errorMessage.includes("etimedout") || errorMessage.includes("timeout")) {
48303
48322
  return true;
@@ -48375,7 +48394,8 @@ async function* withRetryGenerator(fn, options3 = {}) {
48375
48394
  if (lastError.name === "AbortError" || lastError.message === "Aborted") {
48376
48395
  throw lastError;
48377
48396
  }
48378
- if (hasYielded) {
48397
+ const isStreamInterruption = /Stream terminated unexpectedly|incomplete data|reader error|^terminated$|idle timeout/i.test(lastError.message);
48398
+ if (hasYielded && !isStreamInterruption) {
48379
48399
  throw lastError;
48380
48400
  }
48381
48401
  if (attempt >= maxRetries) {
@@ -48494,6 +48514,99 @@ var init_retryUtils = __esm({
48494
48514
  }
48495
48515
  });
48496
48516
 
48517
+ // dist/utils/core/streamGuards.js
48518
+ function createIdleTimeoutGuard({ reader, onTimeout, idleTimeoutMs = STREAM_IDLE_TIMEOUT_MS }) {
48519
+ let isAbandoned = false;
48520
+ let lastChunkTime = Date.now();
48521
+ let idleTimer = null;
48522
+ let timeoutError = null;
48523
+ idleTimer = setInterval(() => {
48524
+ try {
48525
+ if (isAbandoned)
48526
+ return;
48527
+ if (Date.now() - lastChunkTime <= idleTimeoutMs)
48528
+ return;
48529
+ isAbandoned = true;
48530
+ if (!timeoutError) {
48531
+ timeoutError = new StreamIdleTimeoutError(`No data received for ${idleTimeoutMs}ms`, idleTimeoutMs);
48532
+ }
48533
+ try {
48534
+ reader == null ? void 0 : reader.cancel().catch(() => {
48535
+ });
48536
+ } catch {
48537
+ }
48538
+ try {
48539
+ logger.warn(`Stream idle timeout detected after ${idleTimeoutMs}ms`);
48540
+ } catch {
48541
+ }
48542
+ if (onTimeout) {
48543
+ try {
48544
+ onTimeout();
48545
+ } catch (error) {
48546
+ timeoutError = error instanceof Error ? error : new Error(String(error));
48547
+ }
48548
+ }
48549
+ } catch (error) {
48550
+ isAbandoned = true;
48551
+ if (!timeoutError) {
48552
+ timeoutError = error instanceof Error ? error : new Error(String(error));
48553
+ }
48554
+ try {
48555
+ reader == null ? void 0 : reader.cancel().catch(() => {
48556
+ });
48557
+ } catch {
48558
+ }
48559
+ }
48560
+ }, 5e3);
48561
+ return {
48562
+ abandon: () => {
48563
+ isAbandoned = true;
48564
+ try {
48565
+ reader == null ? void 0 : reader.cancel().catch(() => {
48566
+ });
48567
+ } catch {
48568
+ }
48569
+ },
48570
+ isAbandoned: () => isAbandoned,
48571
+ // 检查是否有超时错误需要抛出,在读取循环中调用以确保异常被正确捕获
48572
+ getTimeoutError: () => timeoutError,
48573
+ touch: () => {
48574
+ lastChunkTime = Date.now();
48575
+ },
48576
+ dispose: () => {
48577
+ if (idleTimer) {
48578
+ clearInterval(idleTimer);
48579
+ idleTimer = null;
48580
+ }
48581
+ }
48582
+ };
48583
+ }
48584
+ var STREAM_IDLE_TIMEOUT_MS, StreamIdleTimeoutError;
48585
+ var init_streamGuards = __esm({
48586
+ "dist/utils/core/streamGuards.js"() {
48587
+ "use strict";
48588
+ init_logger();
48589
+ STREAM_IDLE_TIMEOUT_MS = 18e4;
48590
+ StreamIdleTimeoutError = class extends Error {
48591
+ constructor(message, idleMs = STREAM_IDLE_TIMEOUT_MS) {
48592
+ super(`[API_ERROR] [RETRIABLE] Stream idle timeout: ${message}`);
48593
+ Object.defineProperty(this, "idleMs", {
48594
+ enumerable: true,
48595
+ configurable: true,
48596
+ writable: true,
48597
+ value: idleMs
48598
+ });
48599
+ Object.defineProperty(this, "name", {
48600
+ enumerable: true,
48601
+ configurable: true,
48602
+ writable: true,
48603
+ value: "StreamIdleTimeoutError"
48604
+ });
48605
+ }
48606
+ };
48607
+ }
48608
+ });
48609
+
48497
48610
  // dist/utils/config/proxyConfig.js
48498
48611
  import { homedir as homedir3 } from "os";
48499
48612
  import { join as join2 } from "path";
@@ -71424,15 +71537,43 @@ function convertToOpenAIMessages(messages, includeBuiltinSystemPrompt = true, cu
71424
71537
  }
71425
71538
  function resetOpenAIClient() {
71426
71539
  }
71427
- async function* parseSSEStream(reader) {
71540
+ async function* parseSSEStream(reader, abortSignal, idleTimeoutMs) {
71541
+ var _a21;
71428
71542
  const decoder = new TextDecoder();
71429
71543
  let buffer = "";
71544
+ let dataCount = 0;
71545
+ let lastEventType = "";
71546
+ const guard = createIdleTimeoutGuard({
71547
+ reader,
71548
+ idleTimeoutMs,
71549
+ onTimeout: () => {
71550
+ throw new StreamIdleTimeoutError(`No data received for ${idleTimeoutMs}ms`, idleTimeoutMs);
71551
+ }
71552
+ });
71430
71553
  try {
71431
71554
  while (true) {
71555
+ if (abortSignal == null ? void 0 : abortSignal.aborted) {
71556
+ guard.abandon();
71557
+ return;
71558
+ }
71432
71559
  const { done, value } = await reader.read();
71560
+ const timeoutError = guard.getTimeoutError();
71561
+ if (timeoutError) {
71562
+ throw timeoutError;
71563
+ }
71564
+ if (guard.isAbandoned()) {
71565
+ continue;
71566
+ }
71433
71567
  if (done) {
71434
71568
  if (buffer.trim()) {
71435
- throw new Error(`Stream terminated unexpectedly with incomplete data: ${buffer.substring(0, 100)}...`);
71569
+ const errorContext2 = {
71570
+ dataCount,
71571
+ lastEventType,
71572
+ bufferLength: buffer.length,
71573
+ bufferPreview: buffer.substring(0, 200)
71574
+ };
71575
+ const errorMessage = `[API_ERROR] [RETRIABLE] OpenAI stream terminated unexpectedly with incomplete data`;
71576
+ throw new Error(`${errorMessage}. Context: ${JSON.stringify(errorContext2)}`);
71436
71577
  }
71437
71578
  break;
71438
71579
  }
@@ -71447,6 +71588,7 @@ async function* parseSSEStream(reader) {
71447
71588
  return;
71448
71589
  }
71449
71590
  if (trimmed.startsWith("event:")) {
71591
+ lastEventType = trimmed.startsWith("event: ") ? trimmed.slice(7) : trimmed.slice(6);
71450
71592
  continue;
71451
71593
  }
71452
71594
  if (trimmed.startsWith("data:")) {
@@ -71457,18 +71599,35 @@ async function* parseSSEStream(reader) {
71457
71599
  logError: true
71458
71600
  });
71459
71601
  if (parseResult.success) {
71460
- yield parseResult.data;
71602
+ const chunk2 = parseResult.data;
71603
+ const hasBusinessDelta = !!((_a21 = chunk2 == null ? void 0 : chunk2.choices) == null ? void 0 : _a21.some((choice) => {
71604
+ const delta = choice == null ? void 0 : choice.delta;
71605
+ return Boolean((delta == null ? void 0 : delta.content) || (delta == null ? void 0 : delta.reasoning_content) || (delta == null ? void 0 : delta.tool_calls) && delta.tool_calls.length > 0);
71606
+ }));
71607
+ if (hasBusinessDelta) {
71608
+ guard.touch();
71609
+ }
71610
+ dataCount++;
71611
+ if (!guard.isAbandoned()) {
71612
+ yield chunk2;
71613
+ }
71461
71614
  }
71462
71615
  }
71463
71616
  }
71464
71617
  }
71465
71618
  } catch (error) {
71466
71619
  const { logger: logger2 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
71467
- logger2.error("SSE stream parsing error:", {
71620
+ const errorContext2 = {
71468
71621
  error: error instanceof Error ? error.message : "Unknown error",
71469
- remainingBuffer: buffer.substring(0, 200)
71470
- });
71622
+ dataCount,
71623
+ lastEventType,
71624
+ bufferLength: buffer.length,
71625
+ bufferPreview: buffer.substring(0, 200)
71626
+ };
71627
+ logger2.error("[API_ERROR] [RETRIABLE] OpenAI SSE stream parsing error with checkpoint context:", errorContext2);
71471
71628
  throw error;
71629
+ } finally {
71630
+ guard.dispose();
71472
71631
  }
71473
71632
  }
71474
71633
  async function* createStreamingChatCompletion(options3, abortSignal, onRetry) {
@@ -71503,7 +71662,7 @@ async function* createStreamingChatCompletion(options3, abortSignal, onRetry) {
71503
71662
  }
71504
71663
  customSystemPromptContent || (customSystemPromptContent = getCustomSystemPromptForConfig(config3));
71505
71664
  yield* withRetryGenerator(async function* () {
71506
- var _a21, _b14, _c6, _d4, _e2, _f;
71665
+ var _a21, _b14, _c6, _d4, _e2, _f, _g;
71507
71666
  const requestBody = {
71508
71667
  model: options3.model || config3.advancedModel,
71509
71668
  messages: convertToOpenAIMessages(
@@ -71559,10 +71718,8 @@ Possible causes: Network unavailable, DNS resolution failed, proxy issues, or se
71559
71718
  let usageData;
71560
71719
  let reasoningStarted = false;
71561
71720
  let reasoningContentBuffer = "";
71562
- for await (const chunk2 of parseSSEStream(response.body.getReader())) {
71563
- if (abortSignal == null ? void 0 : abortSignal.aborted) {
71564
- return;
71565
- }
71721
+ const idleTimeoutMs = (config3.streamIdleTimeoutSec ?? 180) * 1e3;
71722
+ for await (const chunk2 of parseSSEStream(response.body.getReader(), abortSignal, idleTimeoutMs)) {
71566
71723
  const usageValue = chunk2.usage;
71567
71724
  if (usageValue !== null && usageValue !== void 0) {
71568
71725
  usageData = {
@@ -71573,11 +71730,14 @@ Possible causes: Network unavailable, DNS resolution failed, proxy issues, or se
71573
71730
  cached_tokens: (_a21 = usageValue.prompt_tokens_details) == null ? void 0 : _a21.cached_tokens
71574
71731
  };
71575
71732
  }
71576
- const choice = chunk2.choices[0];
71733
+ const choice = (_b14 = chunk2.choices) == null ? void 0 : _b14[0];
71577
71734
  if (!choice) {
71735
+ if (chunk2.usage) {
71736
+ break;
71737
+ }
71578
71738
  continue;
71579
71739
  }
71580
- const content = (_b14 = choice.delta) == null ? void 0 : _b14.content;
71740
+ const content = (_c6 = choice.delta) == null ? void 0 : _c6.content;
71581
71741
  if (content) {
71582
71742
  contentBuffer += content;
71583
71743
  yield {
@@ -71585,7 +71745,7 @@ Possible causes: Network unavailable, DNS resolution failed, proxy issues, or se
71585
71745
  content
71586
71746
  };
71587
71747
  }
71588
- const reasoningContent = (_c6 = choice.delta) == null ? void 0 : _c6.reasoning_content;
71748
+ const reasoningContent = (_d4 = choice.delta) == null ? void 0 : _d4.reasoning_content;
71589
71749
  if (reasoningContent) {
71590
71750
  reasoningContentBuffer += reasoningContent;
71591
71751
  if (!reasoningStarted) {
@@ -71599,7 +71759,7 @@ Possible causes: Network unavailable, DNS resolution failed, proxy issues, or se
71599
71759
  delta: reasoningContent
71600
71760
  };
71601
71761
  }
71602
- const deltaToolCalls = (_d4 = choice.delta) == null ? void 0 : _d4.tool_calls;
71762
+ const deltaToolCalls = (_e2 = choice.delta) == null ? void 0 : _e2.tool_calls;
71603
71763
  if (deltaToolCalls) {
71604
71764
  hasToolCalls = true;
71605
71765
  for (const deltaCall of deltaToolCalls) {
@@ -71618,11 +71778,11 @@ Possible causes: Network unavailable, DNS resolution failed, proxy issues, or se
71618
71778
  toolCallsBuffer[index].id = deltaCall.id;
71619
71779
  }
71620
71780
  let deltaText = "";
71621
- if ((_e2 = deltaCall.function) == null ? void 0 : _e2.name) {
71781
+ if ((_f = deltaCall.function) == null ? void 0 : _f.name) {
71622
71782
  toolCallsBuffer[index].function.name += deltaCall.function.name;
71623
71783
  deltaText += deltaCall.function.name;
71624
71784
  }
71625
- if ((_f = deltaCall.function) == null ? void 0 : _f.arguments) {
71785
+ if ((_g = deltaCall.function) == null ? void 0 : _g.arguments) {
71626
71786
  toolCallsBuffer[index].function.arguments += deltaCall.function.arguments;
71627
71787
  deltaText += deltaCall.function.arguments;
71628
71788
  }
@@ -71635,7 +71795,7 @@ Possible causes: Network unavailable, DNS resolution failed, proxy issues, or se
71635
71795
  }
71636
71796
  }
71637
71797
  if (choice.finish_reason) {
71638
- break;
71798
+ continue;
71639
71799
  }
71640
71800
  }
71641
71801
  if (hasToolCalls) {
@@ -71666,6 +71826,7 @@ var init_chat = __esm({
71666
71826
  init_apiConfig();
71667
71827
  init_systemPrompt();
71668
71828
  init_retryUtils();
71829
+ init_streamGuards();
71669
71830
  init_proxyUtils();
71670
71831
  init_usageLogger();
71671
71832
  init_version();
@@ -71860,12 +72021,31 @@ function convertToResponseInput(messages, includeBuiltinSystemPrompt = true, cus
71860
72021
  }
71861
72022
  return { input: result2, systemInstructions };
71862
72023
  }
71863
- async function* parseSSEStream2(reader) {
72024
+ async function* parseSSEStream2(reader, abortSignal, idleTimeoutMs) {
72025
+ var _a21;
71864
72026
  const decoder = new TextDecoder();
71865
72027
  let buffer = "";
72028
+ const guard = createIdleTimeoutGuard({
72029
+ reader,
72030
+ idleTimeoutMs,
72031
+ onTimeout: () => {
72032
+ throw new StreamIdleTimeoutError(`No data received for ${idleTimeoutMs}ms`, idleTimeoutMs);
72033
+ }
72034
+ });
71866
72035
  try {
71867
72036
  while (true) {
72037
+ if (abortSignal == null ? void 0 : abortSignal.aborted) {
72038
+ guard.abandon();
72039
+ return;
72040
+ }
71868
72041
  const { done, value } = await reader.read();
72042
+ const timeoutError = guard.getTimeoutError();
72043
+ if (timeoutError) {
72044
+ throw timeoutError;
72045
+ }
72046
+ if (guard.isAbandoned()) {
72047
+ continue;
72048
+ }
71869
72049
  if (done) {
71870
72050
  if (buffer.trim()) {
71871
72051
  throw new Error(`Stream terminated unexpectedly with incomplete data: ${buffer.substring(0, 100)}...`);
@@ -71888,12 +72068,19 @@ async function* parseSSEStream2(reader) {
71888
72068
  if (trimmed.startsWith("data:")) {
71889
72069
  const data = trimmed.startsWith("data: ") ? trimmed.slice(6) : trimmed.slice(5);
71890
72070
  const parseResult = parseJsonWithFix(data, {
71891
- toolName: "Responses API SSE stream",
72071
+ toolName: "Responses API SSE \u6D41",
71892
72072
  logWarning: false,
71893
72073
  logError: true
71894
72074
  });
71895
72075
  if (parseResult.success) {
71896
- yield parseResult.data;
72076
+ const event = parseResult.data;
72077
+ const hasBusinessDelta = (event == null ? void 0 : event.type) === "response.output_text.delta" && (event == null ? void 0 : event.delta) || (event == null ? void 0 : event.type) === "response.reasoning_summary_text.delta" && (event == null ? void 0 : event.delta) || (event == null ? void 0 : event.type) === "response.function_call_arguments.delta" && (event == null ? void 0 : event.delta) || (event == null ? void 0 : event.type) === "response.output_item.added" && ((_a21 = event == null ? void 0 : event.item) == null ? void 0 : _a21.type) === "function_call";
72078
+ if (hasBusinessDelta) {
72079
+ guard.touch();
72080
+ }
72081
+ if (!guard.isAbandoned()) {
72082
+ yield event;
72083
+ }
71897
72084
  }
71898
72085
  }
71899
72086
  }
@@ -71905,6 +72092,8 @@ async function* parseSSEStream2(reader) {
71905
72092
  remainingBuffer: buffer.substring(0, 200)
71906
72093
  });
71907
72094
  throw error;
72095
+ } finally {
72096
+ guard.dispose();
71908
72097
  }
71909
72098
  }
71910
72099
  async function* createStreamingResponse(options3, abortSignal, onRetry) {
@@ -72005,10 +72194,8 @@ Possible causes: Network unavailable, DNS resolution failed, proxy issues, or se
72005
72194
  let currentFunctionCallId = null;
72006
72195
  let usageData;
72007
72196
  let reasoningData;
72008
- for await (const chunk2 of parseSSEStream2(response.body.getReader())) {
72009
- if (abortSignal == null ? void 0 : abortSignal.aborted) {
72010
- return;
72011
- }
72197
+ const idleTimeoutMs = (config3.streamIdleTimeoutSec ?? 180) * 1e3;
72198
+ for await (const chunk2 of parseSSEStream2(response.body.getReader(), abortSignal, idleTimeoutMs)) {
72012
72199
  const eventType = chunk2.type;
72013
72200
  if (eventType === "response.created" || eventType === "response.in_progress") {
72014
72201
  continue;
@@ -72144,6 +72331,7 @@ var init_responses = __esm({
72144
72331
  init_apiConfig();
72145
72332
  init_systemPrompt();
72146
72333
  init_retryUtils();
72334
+ init_streamGuards();
72147
72335
  init_proxyUtils();
72148
72336
  init_usageLogger();
72149
72337
  init_version();
@@ -72390,7 +72578,7 @@ async function* createStreamingGeminiCompletion(options3, abortSignal, onRetry)
72390
72578
  }
72391
72579
  customSystemPromptContent || (customSystemPromptContent = getCustomSystemPromptForConfig(config3));
72392
72580
  yield* withRetryGenerator(async function* () {
72393
- var _a21;
72581
+ var _a21, _b14;
72394
72582
  const { systemInstruction, contents } = convertToGeminiMessages(
72395
72583
  options3.messages,
72396
72584
  options3.includeBuiltinSystemPrompt !== false,
@@ -72461,18 +72649,36 @@ Possible causes: Network unavailable, DNS resolution failed, proxy issues, or se
72461
72649
  const reader = response.body.getReader();
72462
72650
  const decoder = new TextDecoder();
72463
72651
  let buffer = "";
72652
+ const idleTimeoutMs = (config3.streamIdleTimeoutSec ?? 180) * 1e3;
72653
+ const guard = createIdleTimeoutGuard({
72654
+ reader,
72655
+ idleTimeoutMs,
72656
+ onTimeout: () => {
72657
+ throw new StreamIdleTimeoutError(`No data received for ${idleTimeoutMs}ms`, idleTimeoutMs);
72658
+ }
72659
+ });
72464
72660
  try {
72465
72661
  while (true) {
72662
+ if (abortSignal == null ? void 0 : abortSignal.aborted) {
72663
+ guard.abandon();
72664
+ return;
72665
+ }
72466
72666
  const { done, value } = await reader.read();
72667
+ const timeoutError = guard.getTimeoutError();
72668
+ if (timeoutError) {
72669
+ throw timeoutError;
72670
+ }
72671
+ if (guard.isAbandoned()) {
72672
+ continue;
72673
+ }
72467
72674
  if (done) {
72468
72675
  if (buffer.trim()) {
72469
- throw new Error(`Stream terminated unexpectedly with incomplete data: ${buffer.substring(0, 100)}...`);
72676
+ const errorMsg = `[API_ERROR] [RETRIABLE] Gemini stream terminated unexpectedly with incomplete data`;
72677
+ const bufferPreview = buffer.substring(0, 100);
72678
+ throw new Error(`${errorMsg}: ${bufferPreview}...`);
72470
72679
  }
72471
72680
  break;
72472
72681
  }
72473
- if (abortSignal == null ? void 0 : abortSignal.aborted) {
72474
- return;
72475
- }
72476
72682
  buffer += decoder.decode(value, { stream: true });
72477
72683
  const lines = buffer.split("\n");
72478
72684
  buffer = lines.pop() || "";
@@ -72495,22 +72701,33 @@ Possible causes: Network unavailable, DNS resolution failed, proxy issues, or se
72495
72701
  });
72496
72702
  if (parseResult.success) {
72497
72703
  const chunk2 = parseResult.data;
72704
+ const hasBusinessDelta = !!((_b14 = chunk2 == null ? void 0 : chunk2.candidates) == null ? void 0 : _b14.some((candidate) => {
72705
+ var _a22, _b15;
72706
+ return (_b15 = (_a22 = candidate == null ? void 0 : candidate.content) == null ? void 0 : _a22.parts) == null ? void 0 : _b15.some((part) => Boolean((part == null ? void 0 : part.text) || (part == null ? void 0 : part.functionCall)));
72707
+ }));
72708
+ if (hasBusinessDelta) {
72709
+ guard.touch();
72710
+ }
72498
72711
  if (chunk2.candidates && chunk2.candidates.length > 0) {
72499
72712
  const candidate = chunk2.candidates[0];
72500
72713
  if (candidate.content && candidate.content.parts) {
72501
72714
  for (const part of candidate.content.parts) {
72502
72715
  if (part.thought === true && part.text) {
72503
72716
  thinkingTextBuffer += part.text;
72504
- yield {
72505
- type: "reasoning_delta",
72506
- delta: part.text
72507
- };
72717
+ if (!guard.isAbandoned()) {
72718
+ yield {
72719
+ type: "reasoning_delta",
72720
+ delta: part.text
72721
+ };
72722
+ }
72508
72723
  } else if (part.text) {
72509
72724
  contentBuffer += part.text;
72510
- yield {
72511
- type: "content",
72512
- content: part.text
72513
- };
72725
+ if (!guard.isAbandoned()) {
72726
+ yield {
72727
+ type: "content",
72728
+ content: part.text
72729
+ };
72730
+ }
72514
72731
  }
72515
72732
  if (part.functionCall) {
72516
72733
  hasToolCalls = true;
@@ -72560,6 +72777,8 @@ Possible causes: Network unavailable, DNS resolution failed, proxy issues, or se
72560
72777
  remainingBuffer: buffer.substring(0, 200)
72561
72778
  });
72562
72779
  throw error;
72780
+ } finally {
72781
+ guard.dispose();
72563
72782
  }
72564
72783
  if (hasToolCalls && toolCallsBuffer.length > 0) {
72565
72784
  yield {
@@ -72599,6 +72818,7 @@ var init_gemini = __esm({
72599
72818
  init_apiConfig();
72600
72819
  init_systemPrompt();
72601
72820
  init_retryUtils();
72821
+ init_streamGuards();
72602
72822
  init_proxyUtils();
72603
72823
  init_usageLogger();
72604
72824
  init_version();
@@ -74484,7 +74704,14 @@ function migrateLegacyConfig() {
74484
74704
  }
74485
74705
  }
74486
74706
  }
74707
+ function normalizeStreamIdleTimeoutSec(value) {
74708
+ if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
74709
+ return DEFAULT_STREAM_IDLE_TIMEOUT_SEC;
74710
+ }
74711
+ return value;
74712
+ }
74487
74713
  function loadProfile(profileName) {
74714
+ var _a21;
74488
74715
  ensureProfilesDirectory();
74489
74716
  migrateLegacyConfig();
74490
74717
  const profilePath = getProfilePath(profileName);
@@ -74499,7 +74726,8 @@ function loadProfile(profileName) {
74499
74726
  ...parsedConfig,
74500
74727
  snowcfg: {
74501
74728
  ...DEFAULT_CONFIG2.snowcfg,
74502
- ...parsedConfig.snowcfg || {}
74729
+ ...parsedConfig.snowcfg || {},
74730
+ streamIdleTimeoutSec: normalizeStreamIdleTimeoutSec((_a21 = parsedConfig.snowcfg) == null ? void 0 : _a21.streamIdleTimeoutSec)
74503
74731
  }
74504
74732
  };
74505
74733
  return mergedConfig;
@@ -74692,6 +74920,7 @@ var init_configManager = __esm({
74692
74920
  var apiConfig_exports = {};
74693
74921
  __export(apiConfig_exports, {
74694
74922
  DEFAULT_CONFIG: () => DEFAULT_CONFIG2,
74923
+ DEFAULT_STREAM_IDLE_TIMEOUT_SEC: () => DEFAULT_STREAM_IDLE_TIMEOUT_SEC,
74695
74924
  clearConfigCache: () => clearConfigCache,
74696
74925
  getCustomHeaders: () => getCustomHeaders,
74697
74926
  getCustomHeadersConfig: () => getCustomHeadersConfig,
@@ -74715,6 +74944,12 @@ __export(apiConfig_exports, {
74715
74944
  import { homedir as homedir6 } from "os";
74716
74945
  import { join as join7 } from "path";
74717
74946
  import { readFileSync as readFileSync7, writeFileSync as writeFileSync4, existsSync as existsSync7, mkdirSync as mkdirSync4, unlinkSync as unlinkSync2 } from "fs";
74947
+ function normalizeStreamIdleTimeoutSec2(value) {
74948
+ if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
74949
+ return DEFAULT_STREAM_IDLE_TIMEOUT_SEC;
74950
+ }
74951
+ return value;
74952
+ }
74718
74953
  function migrateProxyConfigToNewFile(legacyProxy) {
74719
74954
  try {
74720
74955
  if (!existsSync7(PROXY_CONFIG_FILE2)) {
@@ -74768,18 +75003,21 @@ function loadConfig() {
74768
75003
  apiConfig = {
74769
75004
  ...DEFAULT_CONFIG2.snowcfg,
74770
75005
  ...configWithoutMcp.snowcfg,
74771
- requestMethod: normalizeRequestMethod(configWithoutMcp.snowcfg.requestMethod)
75006
+ requestMethod: normalizeRequestMethod(configWithoutMcp.snowcfg.requestMethod),
75007
+ streamIdleTimeoutSec: normalizeStreamIdleTimeoutSec2(configWithoutMcp.snowcfg.streamIdleTimeoutSec)
74772
75008
  };
74773
75009
  } else if (configWithoutMcp.openai) {
74774
75010
  apiConfig = {
74775
75011
  ...DEFAULT_CONFIG2.snowcfg,
74776
75012
  ...configWithoutMcp.openai,
74777
- requestMethod: normalizeRequestMethod(configWithoutMcp.openai.requestMethod)
75013
+ requestMethod: normalizeRequestMethod(configWithoutMcp.openai.requestMethod),
75014
+ streamIdleTimeoutSec: normalizeStreamIdleTimeoutSec2(configWithoutMcp.openai.streamIdleTimeoutSec)
74778
75015
  };
74779
75016
  } else {
74780
75017
  apiConfig = {
74781
75018
  ...DEFAULT_CONFIG2.snowcfg,
74782
- requestMethod: DEFAULT_CONFIG2.snowcfg.requestMethod
75019
+ requestMethod: DEFAULT_CONFIG2.snowcfg.requestMethod,
75020
+ streamIdleTimeoutSec: DEFAULT_STREAM_IDLE_TIMEOUT_SEC
74783
75021
  };
74784
75022
  }
74785
75023
  const mergedConfig = {
@@ -74820,9 +75058,14 @@ function reloadConfig() {
74820
75058
  }
74821
75059
  async function updateOpenAiConfig(apiConfig) {
74822
75060
  const currentConfig = loadConfig();
75061
+ const normalizedIdleTimeoutSec = normalizeStreamIdleTimeoutSec2(apiConfig.streamIdleTimeoutSec ?? currentConfig.snowcfg.streamIdleTimeoutSec);
74823
75062
  const updatedConfig = {
74824
75063
  ...currentConfig,
74825
- snowcfg: { ...currentConfig.snowcfg, ...apiConfig }
75064
+ snowcfg: {
75065
+ ...currentConfig.snowcfg,
75066
+ ...apiConfig,
75067
+ streamIdleTimeoutSec: normalizedIdleTimeoutSec
75068
+ }
74826
75069
  };
74827
75070
  saveConfig(updatedConfig);
74828
75071
  try {
@@ -75089,10 +75332,11 @@ function saveCustomHeadersConfig(config3) {
75089
75332
  throw new Error(`Failed to save custom headers config: ${error}`);
75090
75333
  }
75091
75334
  }
75092
- var DEFAULT_CONFIG2, DEFAULT_MCP_CONFIG, CONFIG_DIR3, PROXY_CONFIG_FILE2, SYSTEM_PROMPT_FILE, SYSTEM_PROMPT_JSON_FILE, CUSTOM_HEADERS_FILE, CONFIG_FILE, MCP_CONFIG_FILE, configCache;
75335
+ var DEFAULT_STREAM_IDLE_TIMEOUT_SEC, DEFAULT_CONFIG2, DEFAULT_MCP_CONFIG, CONFIG_DIR3, PROXY_CONFIG_FILE2, SYSTEM_PROMPT_FILE, SYSTEM_PROMPT_JSON_FILE, CUSTOM_HEADERS_FILE, CONFIG_FILE, MCP_CONFIG_FILE, configCache;
75093
75336
  var init_apiConfig = __esm({
75094
75337
  "dist/utils/config/apiConfig.js"() {
75095
75338
  "use strict";
75339
+ DEFAULT_STREAM_IDLE_TIMEOUT_SEC = 180;
75096
75340
  DEFAULT_CONFIG2 = {
75097
75341
  snowcfg: {
75098
75342
  baseUrl: "https://api.openai.com/v1",
@@ -75103,6 +75347,7 @@ var init_apiConfig = __esm({
75103
75347
  maxContextTokens: 12e4,
75104
75348
  maxTokens: 32e3,
75105
75349
  anthropicBeta: false,
75350
+ streamIdleTimeoutSec: DEFAULT_STREAM_IDLE_TIMEOUT_SEC,
75106
75351
  editSimilarityThreshold: 0.75
75107
75352
  }
75108
75353
  };
@@ -75232,7 +75477,15 @@ function convertToAnthropicMessages(messages, includeBuiltinSystemPrompt = true,
75232
75477
  const customSystemPrompts = customSystemPromptOverride;
75233
75478
  let systemContents;
75234
75479
  const anthropicMessages = [];
75480
+ const toolResults = [];
75235
75481
  for (const msg of messages) {
75482
+ if (msg.role !== "tool" && toolResults.length > 0) {
75483
+ anthropicMessages.push({
75484
+ role: "user",
75485
+ content: [...toolResults]
75486
+ });
75487
+ toolResults.length = 0;
75488
+ }
75236
75489
  if (msg.role === "system") {
75237
75490
  systemContents = [msg.content];
75238
75491
  continue;
@@ -75270,15 +75523,10 @@ function convertToAnthropicMessages(messages, includeBuiltinSystemPrompt = true,
75270
75523
  } else {
75271
75524
  toolResultContent = msg.content;
75272
75525
  }
75273
- anthropicMessages.push({
75274
- role: "user",
75275
- content: [
75276
- {
75277
- type: "tool_result",
75278
- tool_use_id: msg.tool_call_id,
75279
- content: toolResultContent
75280
- }
75281
- ]
75526
+ toolResults.push({
75527
+ type: "tool_result",
75528
+ tool_use_id: msg.tool_call_id,
75529
+ content: toolResultContent
75282
75530
  });
75283
75531
  continue;
75284
75532
  }
@@ -75362,6 +75610,13 @@ function convertToAnthropicMessages(messages, includeBuiltinSystemPrompt = true,
75362
75610
  }
75363
75611
  }
75364
75612
  }
75613
+ if (toolResults.length > 0) {
75614
+ anthropicMessages.push({
75615
+ role: "user",
75616
+ content: [...toolResults]
75617
+ });
75618
+ toolResults.length = 0;
75619
+ }
75365
75620
  if (customSystemPrompts && customSystemPrompts.length > 0) {
75366
75621
  systemContents = customSystemPrompts;
75367
75622
  if (includeBuiltinSystemPrompt) {
@@ -75418,15 +75673,44 @@ function convertToAnthropicMessages(messages, includeBuiltinSystemPrompt = true,
75418
75673
  })) : void 0;
75419
75674
  return { system, messages: anthropicMessages };
75420
75675
  }
75421
- async function* parseSSEStream3(reader) {
75676
+ async function* parseSSEStream3(reader, abortSignal, idleTimeoutMs) {
75677
+ var _a21, _b14, _c6, _d4, _e2, _f, _g;
75422
75678
  const decoder = new TextDecoder();
75423
75679
  let buffer = "";
75680
+ let dataCount = 0;
75681
+ let lastEventType = "";
75682
+ const guard = createIdleTimeoutGuard({
75683
+ reader,
75684
+ idleTimeoutMs,
75685
+ onTimeout: () => {
75686
+ throw new StreamIdleTimeoutError(`No data received for ${idleTimeoutMs}ms`, idleTimeoutMs);
75687
+ }
75688
+ });
75424
75689
  try {
75425
75690
  while (true) {
75691
+ if (abortSignal == null ? void 0 : abortSignal.aborted) {
75692
+ guard.abandon();
75693
+ return;
75694
+ }
75426
75695
  const { done, value } = await reader.read();
75696
+ const timeoutError = guard.getTimeoutError();
75697
+ if (timeoutError) {
75698
+ throw timeoutError;
75699
+ }
75700
+ if (guard.isAbandoned()) {
75701
+ continue;
75702
+ }
75427
75703
  if (done) {
75428
75704
  if (buffer.trim()) {
75429
- throw new Error(`Stream terminated unexpectedly with incomplete data: ${buffer.substring(0, 100)}...`);
75705
+ const errorContext2 = {
75706
+ dataCount,
75707
+ lastEventType,
75708
+ bufferLength: buffer.length,
75709
+ bufferPreview: buffer.substring(0, 200)
75710
+ };
75711
+ const errorMessage = `[API_ERROR] [RETRIABLE] Anthropic stream terminated unexpectedly with incomplete data`;
75712
+ logger.error(errorMessage, errorContext2);
75713
+ throw new Error(`${errorMessage}. Context: ${JSON.stringify(errorContext2)}`);
75430
75714
  }
75431
75715
  break;
75432
75716
  }
@@ -75441,6 +75725,7 @@ async function* parseSSEStream3(reader) {
75441
75725
  return;
75442
75726
  }
75443
75727
  if (trimmed.startsWith("event:")) {
75728
+ lastEventType = trimmed.startsWith("event: ") ? trimmed.slice(7) : trimmed.slice(6);
75444
75729
  continue;
75445
75730
  }
75446
75731
  if (trimmed.startsWith("data:")) {
@@ -75451,18 +75736,32 @@ async function* parseSSEStream3(reader) {
75451
75736
  logError: true
75452
75737
  });
75453
75738
  if (parseResult.success) {
75454
- yield parseResult.data;
75739
+ const event = parseResult.data;
75740
+ const hasBusinessDelta = (event == null ? void 0 : event.type) === "content_block_start" && ((_a21 = event == null ? void 0 : event.content_block) == null ? void 0 : _a21.type) === "tool_use" || (event == null ? void 0 : event.type) === "content_block_delta" && (((_b14 = event == null ? void 0 : event.delta) == null ? void 0 : _b14.type) === "text_delta" && ((_c6 = event == null ? void 0 : event.delta) == null ? void 0 : _c6.text) || ((_d4 = event == null ? void 0 : event.delta) == null ? void 0 : _d4.type) === "thinking_delta" && ((_e2 = event == null ? void 0 : event.delta) == null ? void 0 : _e2.thinking) || ((_f = event == null ? void 0 : event.delta) == null ? void 0 : _f.type) === "input_json_delta" && ((_g = event == null ? void 0 : event.delta) == null ? void 0 : _g.partial_json));
75741
+ if (hasBusinessDelta) {
75742
+ guard.touch();
75743
+ }
75744
+ dataCount++;
75745
+ if (!guard.isAbandoned()) {
75746
+ yield event;
75747
+ }
75455
75748
  }
75456
75749
  }
75457
75750
  }
75458
75751
  }
75459
75752
  } catch (error) {
75460
75753
  const { logger: logger2 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
75461
- logger2.error("SSE stream parsing error:", {
75754
+ const errorContext2 = {
75462
75755
  error: error instanceof Error ? error.message : "Unknown error",
75463
- remainingBuffer: buffer.substring(0, 200)
75464
- });
75756
+ dataCount,
75757
+ lastEventType,
75758
+ bufferLength: buffer.length,
75759
+ bufferPreview: buffer.substring(0, 200)
75760
+ };
75761
+ logger2.error("[API_ERROR] [RETRIABLE] Anthropic SSE stream parsing error with checkpoint context:", errorContext2);
75465
75762
  throw error;
75763
+ } finally {
75764
+ guard.dispose();
75466
75765
  }
75467
75766
  }
75468
75767
  async function* createStreamingAnthropicCompletion(options3, abortSignal, onRetry) {
@@ -75527,10 +75826,19 @@ async function* createStreamingAnthropicCompletion(options3, abortSignal, onRetr
75527
75826
  disableThinking: options3.disableThinking,
75528
75827
  willEnableThinking: config3.thinking && !options3.disableThinking
75529
75828
  });
75530
- }
75531
- if (config3.thinking && !options3.disableThinking) {
75532
- requestBody.thinking = config3.thinking;
75533
- requestBody.temperature = 1;
75829
+ if (config3.thinking && !options3.disableThinking) {
75830
+ if (config3.thinking.type === "adaptive") {
75831
+ requestBody.thinking = {
75832
+ type: "adaptive"
75833
+ };
75834
+ requestBody.output_config = {
75835
+ effort: config3.thinking.effort || "high"
75836
+ };
75837
+ } else {
75838
+ requestBody.thinking = config3.thinking;
75839
+ }
75840
+ requestBody.temperature = 1;
75841
+ }
75534
75842
  }
75535
75843
  const customHeaders = options3.customHeaders || getCustomHeadersForConfig(config3);
75536
75844
  const headers = {
@@ -75576,10 +75884,8 @@ Possible causes: Network unavailable, DNS resolution failed, proxy issues, or se
75576
75884
  let blockIndexToId = /* @__PURE__ */ new Map();
75577
75885
  let blockIndexToType = /* @__PURE__ */ new Map();
75578
75886
  let completedToolBlocks = /* @__PURE__ */ new Set();
75579
- for await (const event of parseSSEStream3(response.body.getReader())) {
75580
- if (abortSignal == null ? void 0 : abortSignal.aborted) {
75581
- return;
75582
- }
75887
+ const idleTimeoutMs = (config3.streamIdleTimeoutSec ?? 180) * 1e3;
75888
+ for await (const event of parseSSEStream3(response.body.getReader(), abortSignal, idleTimeoutMs)) {
75583
75889
  if (event.type === "content_block_start") {
75584
75890
  const block3 = event.content_block;
75585
75891
  const blockIndex = event.index;
@@ -75743,6 +76049,7 @@ var init_anthropic = __esm({
75743
76049
  init_apiConfig();
75744
76050
  init_systemPrompt();
75745
76051
  init_retryUtils();
76052
+ init_streamGuards();
75746
76053
  init_logger();
75747
76054
  init_proxyUtils();
75748
76055
  init_usageLogger();
@@ -77676,6 +77983,7 @@ var init_utils = __esm({
77676
77983
  init_agent();
77677
77984
  init_clear();
77678
77985
  init_compact();
77986
+ init_copyLast();
77679
77987
  init_custom();
77680
77988
  init_diff2();
77681
77989
  init_export();
@@ -81152,7 +81460,11 @@ var init_en = __esm({
81152
81460
  enableAutoCompress: "Enable Auto Compression:",
81153
81461
  showThinking: "Show Thinking Process:",
81154
81462
  thinkingEnabled: "Thinking Enabled:",
81463
+ thinkingMode: "Thinking Mode:",
81464
+ thinkingModeTokens: "Input Tokens",
81465
+ thinkingModeAdaptive: "Adaptive",
81155
81466
  thinkingBudgetTokens: "Thinking Budget Tokens:",
81467
+ thinkingEffort: "Thinking Effort:",
81156
81468
  geminiThinkingEnabled: "Gemini Thinking Enabled:",
81157
81469
  geminiThinkingBudget: "Gemini Thinking Budget:",
81158
81470
  responsesReasoningEnabled: "Responses Reasoning Enabled:",
@@ -81161,6 +81473,7 @@ var init_en = __esm({
81161
81473
  basicModel: "Basic Model(Type to search):",
81162
81474
  maxContextTokens: "Max Context Tokens:",
81163
81475
  maxTokens: "Max Tokens:",
81476
+ streamIdleTimeoutSec: "Stream Idle Timeout(sec):",
81164
81477
  toolResultTokenLimit: "Tool Result Token Limit:",
81165
81478
  editSimilarityThreshold: "Edit Similarity Threshold(0-1, change with caution):",
81166
81479
  notSet: "Not set",
@@ -81183,7 +81496,7 @@ var init_en = __esm({
81183
81496
  manualInputSubtitle: "Enter model name manually",
81184
81497
  manualInputHint: "Press Enter to confirm, Esc to cancel",
81185
81498
  loadingError: "\u26A0 Failed to load models from API",
81186
- requestMethodChat: "Chat Completions - Modern chat API (GPT-4, GPT-3.5-turbo)",
81499
+ requestMethodChat: "Chat Completions - Modern chat API (DeepSeek)",
81187
81500
  requestMethodResponses: "Responses - New responses API (2025, with built-in tools)",
81188
81501
  requestMethodGemini: "Gemini - Google Gemini API",
81189
81502
  requestMethodAnthropic: "Anthropic - Claude API",
@@ -81439,6 +81752,7 @@ var init_en = __esm({
81439
81752
  commands: {
81440
81753
  help: "Show keyboard shortcuts and help information",
81441
81754
  clear: "Clear chat context and conversation history",
81755
+ copyLast: "Copy last AI message to clipboard",
81442
81756
  resume: "Resume a conversation",
81443
81757
  mcp: "Show Model Context Protocol services and tools",
81444
81758
  yolo: "Toggle unattended mode (auto-approve all tools)",
@@ -81467,6 +81781,13 @@ var init_en = __esm({
81467
81781
  worktree: "Open Git branch management panel for switching, creating and deleting branches",
81468
81782
  diff: "Review file changes from a conversation in IDE diff view",
81469
81783
  quit: "Exit the application"
81784
+ },
81785
+ copyLastFeedback: {
81786
+ noAssistantMessage: "No AI assistant message found to copy.",
81787
+ emptyAssistantMessage: "The last AI assistant message has no content to copy.",
81788
+ copySuccess: "\u2713 Last AI message copied to clipboard",
81789
+ copyFailedPrefix: "\u2717 Failed to copy to clipboard",
81790
+ unknownError: "Unknown error"
81470
81791
  }
81471
81792
  },
81472
81793
  permissionsPanel: {
@@ -81496,6 +81817,7 @@ var init_en = __esm({
81496
81817
  requestMethod: "Request Method:",
81497
81818
  showThinkingProcess: "Show Thinking Process:",
81498
81819
  enableThinking: "Enable Thinking:",
81820
+ thinkingMode: "Thinking Mode:",
81499
81821
  thinkingStrength: "Thinking Strength:",
81500
81822
  inputNumberHint: "Enter number, press Enter to save",
81501
81823
  escCancel: "Esc to cancel",
@@ -82421,7 +82743,11 @@ var init_zh = __esm({
82421
82743
  enableAutoCompress: "\u542F\u7528\u81EA\u52A8\u538B\u7F29:",
82422
82744
  showThinking: "\u663E\u793A\u601D\u8003\u8FC7\u7A0B:",
82423
82745
  thinkingEnabled: "\u542F\u7528\u601D\u8003\u6A21\u5F0F:",
82746
+ thinkingMode: "\u601D\u8003\u6A21\u5F0F:",
82747
+ thinkingModeTokens: "\u8F93\u5165\u4EE4\u724C\u6570",
82748
+ thinkingModeAdaptive: "\u81EA\u9002\u5E94",
82424
82749
  thinkingBudgetTokens: "\u601D\u8003\u9884\u7B97\u4EE4\u724C\u6570:",
82750
+ thinkingEffort: "\u601D\u8003\u5F3A\u5EA6:",
82425
82751
  geminiThinkingEnabled: "\u542F\u7528 Gemini \u601D\u8003:",
82426
82752
  geminiThinkingBudget: "Gemini \u601D\u8003\u9884\u7B97:",
82427
82753
  responsesReasoningEnabled: "\u542F\u7528 Responses \u63A8\u7406:",
@@ -82430,6 +82756,7 @@ var init_zh = __esm({
82430
82756
  basicModel: "\u57FA\u7840\u6A21\u578B(\u952E\u5165\u53EF\u641C\u7D22):",
82431
82757
  maxContextTokens: "\u6700\u5927\u4E0A\u4E0B\u6587\u4EE4\u724C:",
82432
82758
  maxTokens: "\u6700\u5927\u56DE\u590D\u4EE4\u724C\u6570:",
82759
+ streamIdleTimeoutSec: "\u6D41\u5F0F\u7A7A\u95F2\u8D85\u65F6(\u79D2):",
82433
82760
  toolResultTokenLimit: "\u5DE5\u5177\u8FD4\u56DEToken\u9650\u5236:",
82434
82761
  editSimilarityThreshold: "\u6587\u4EF6\u7F16\u8F91\u76F8\u4F3C\u5EA6\u9608\u503C(0-1, \u975E\u5FC5\u8981\u4E0D\u6539):",
82435
82762
  notSet: "\u672A\u8BBE\u7F6E",
@@ -82452,7 +82779,7 @@ var init_zh = __esm({
82452
82779
  manualInputSubtitle: "\u624B\u52A8\u8F93\u5165\u6A21\u578B\u540D\u79F0",
82453
82780
  manualInputHint: "\u6309 Enter \u786E\u8BA4,Esc \u53D6\u6D88",
82454
82781
  loadingError: "\u26A0 \u65E0\u6CD5\u4ECE API \u52A0\u8F7D\u6A21\u578B",
82455
- requestMethodChat: "Chat Completions - \u73B0\u4EE3\u804A\u5929 API (GPT-4, GPT-3.5-turbo)",
82782
+ requestMethodChat: "Chat Completions - \u73B0\u4EE3\u804A\u5929 API (DeepSeek)",
82456
82783
  requestMethodResponses: "Responses - \u65B0 Responses API (2025, \u5185\u7F6E\u5DE5\u5177)",
82457
82784
  requestMethodGemini: "Gemini - Google Gemini API",
82458
82785
  requestMethodAnthropic: "Anthropic - Claude API",
@@ -82708,6 +83035,7 @@ var init_zh = __esm({
82708
83035
  commands: {
82709
83036
  help: "\u663E\u793A\u5FEB\u6377\u952E\u548C\u5E2E\u52A9\u4FE1\u606F",
82710
83037
  clear: "\u6E05\u7A7A\u804A\u5929\u4E0A\u4E0B\u6587\u548C\u5BF9\u8BDD\u5386\u53F2",
83038
+ copyLast: "\u590D\u5236\u6700\u540E\u4E00\u6761AI\u56DE\u590D\u5230\u526A\u8D34\u677F",
82711
83039
  resume: "\u6062\u590D\u5BF9\u8BDD",
82712
83040
  mcp: "\u663E\u793A\u6A21\u578B\u4E0A\u4E0B\u6587\u534F\u8BAE\u670D\u52A1\u548C\u5DE5\u5177",
82713
83041
  yolo: "\u5207\u6362\u65E0\u4EBA\u503C\u5B88\u6A21\u5F0F(\u81EA\u52A8\u6279\u51C6\u6240\u6709\u5DE5\u5177)",
@@ -82736,6 +83064,13 @@ var init_zh = __esm({
82736
83064
  profiles: "\u6253\u5F00\u914D\u7F6E\u6587\u4EF6\u5207\u6362\u9762\u677F",
82737
83065
  models: "\u6253\u5F00\u6A21\u578B\u5207\u6362\u9762\u677F",
82738
83066
  quit: "\u9000\u51FA\u5E94\u7528\u7A0B\u5E8F"
83067
+ },
83068
+ copyLastFeedback: {
83069
+ noAssistantMessage: "\u672A\u627E\u5230\u53EF\u590D\u5236\u7684 AI \u52A9\u624B\u6D88\u606F\u3002",
83070
+ emptyAssistantMessage: "\u6700\u540E\u4E00\u6761 AI \u52A9\u624B\u6D88\u606F\u6CA1\u6709\u53EF\u590D\u5236\u7684\u5185\u5BB9\u3002",
83071
+ copySuccess: "\u2713 \u5DF2\u590D\u5236\u6700\u540E\u4E00\u6761 AI \u6D88\u606F\u5230\u526A\u8D34\u677F",
83072
+ copyFailedPrefix: "\u2717 \u590D\u5236\u5230\u526A\u8D34\u677F\u5931\u8D25",
83073
+ unknownError: "\u672A\u77E5\u9519\u8BEF"
82739
83074
  }
82740
83075
  },
82741
83076
  permissionsPanel: {
@@ -82765,6 +83100,7 @@ var init_zh = __esm({
82765
83100
  requestMethod: "\u8BF7\u6C42\u65B9\u5F0F:",
82766
83101
  showThinkingProcess: "\u663E\u793A\u601D\u8003\u8FC7\u7A0B:",
82767
83102
  enableThinking: "\u542F\u7528\u601D\u8003:",
83103
+ thinkingMode: "\u601D\u8003\u6A21\u5F0F:",
82768
83104
  thinkingStrength: "\u601D\u8003\u5F3A\u5EA6:",
82769
83105
  inputNumberHint: "\u8F93\u5165\u6570\u5B57\uFF0C\u56DE\u8F66\u4FDD\u5B58",
82770
83106
  escCancel: "Esc \u53D6\u6D88",
@@ -83689,7 +84025,11 @@ var init_zh_TW = __esm({
83689
84025
  enableAutoCompress: "\u555F\u7528\u81EA\u52D5\u58D3\u7E2E:",
83690
84026
  showThinking: "\u986F\u793A\u601D\u8003\u904E\u7A0B:",
83691
84027
  thinkingEnabled: "\u555F\u7528\u601D\u8003\u6A21\u5F0F:",
84028
+ thinkingMode: "\u601D\u8003\u6A21\u5F0F:",
84029
+ thinkingModeTokens: "\u8F38\u5165\u4EE4\u724C\u6578",
84030
+ thinkingModeAdaptive: "\u81EA\u9069\u61C9",
83692
84031
  thinkingBudgetTokens: "\u601D\u8003\u9810\u7B97\u4EE4\u724C\u6578:",
84032
+ thinkingEffort: "\u601D\u8003\u5F37\u5EA6:",
83693
84033
  geminiThinkingEnabled: "\u555F\u7528 Gemini \u601D\u8003:",
83694
84034
  geminiThinkingBudget: "Gemini \u601D\u8003\u9810\u7B97:",
83695
84035
  responsesReasoningEnabled: "\u555F\u7528 Responses \u63A8\u7406:",
@@ -83698,6 +84038,7 @@ var init_zh_TW = __esm({
83698
84038
  basicModel: "\u57FA\u790E\u6A21\u578B(\u8F38\u5165\u5F8C\u53EF\u4EE5\u641C\u5C0B):",
83699
84039
  maxContextTokens: "\u6700\u5927\u4E0A\u4E0B\u6587\u4EE4\u724C:",
83700
84040
  maxTokens: "\u6700\u5927\u56DE\u590D\u4EE4\u724C\u6578:",
84041
+ streamIdleTimeoutSec: "\u6D41\u5F0F\u9592\u7F6E\u8D85\u6642(\u79D2):",
83701
84042
  toolResultTokenLimit: "\u5DE5\u5177\u8FD4\u56DEToken\u9650\u5236:",
83702
84043
  editSimilarityThreshold: "\u6A94\u6848\u7DE8\u8F2F\u76F8\u4F3C\u5EA6\u95BE\u503C(0-1, \u975E\u5FC5\u8981\u4E0D\u6539):",
83703
84044
  notSet: "\u672A\u8A2D\u5B9A",
@@ -83720,7 +84061,7 @@ var init_zh_TW = __esm({
83720
84061
  manualInputSubtitle: "\u624B\u52D5\u8F38\u5165\u6A21\u578B\u540D\u7A31",
83721
84062
  manualInputHint: "\u6309 Enter \u78BA\u8A8D,Esc \u53D6\u6D88",
83722
84063
  loadingError: "\u26A0 \u7121\u6CD5\u5F9E API \u8F09\u5165\u6A21\u578B",
83723
- requestMethodChat: "Chat Completions - \u73FE\u4EE3\u804A\u5929 API (GPT-4, GPT-3.5-turbo)",
84064
+ requestMethodChat: "Chat Completions - \u73FE\u4EE3\u804A\u5929 API (DeepSeek)",
83724
84065
  requestMethodResponses: "Responses - \u65B0 Responses API (2025, \u5167\u5EFA\u5DE5\u5177)",
83725
84066
  requestMethodGemini: "Gemini - Google Gemini API",
83726
84067
  requestMethodAnthropic: "Anthropic - Claude API",
@@ -83976,6 +84317,7 @@ var init_zh_TW = __esm({
83976
84317
  commands: {
83977
84318
  help: "\u986F\u793A\u5FEB\u6377\u9375\u548C\u8AAA\u660E\u8CC7\u8A0A",
83978
84319
  clear: "\u6E05\u7A7A\u804A\u5929\u4E0A\u4E0B\u6587\u548C\u5C0D\u8A71\u6B77\u53F2",
84320
+ copyLast: "\u8907\u88FD\u6700\u5F8C\u4E00\u689DAI\u56DE\u8986\u5230\u526A\u8CBC\u7C3F",
83979
84321
  resume: "\u6062\u5FA9\u5C0D\u8A71",
83980
84322
  mcp: "\u986F\u793A\u6A21\u578B\u4E0A\u4E0B\u6587\u5354\u5B9A\u670D\u52D9\u548C\u5DE5\u5177",
83981
84323
  yolo: "\u5207\u63DB\u7121\u4EBA\u503C\u5B88\u6A21\u5F0F(\u81EA\u52D5\u6279\u51C6\u6240\u6709\u5DE5\u5177)",
@@ -84004,6 +84346,13 @@ var init_zh_TW = __esm({
84004
84346
  profiles: "\u958B\u555F\u8A2D\u5B9A\u6A94\u5207\u63DB\u9762\u677F",
84005
84347
  models: "\u958B\u555F\u6A21\u578B\u5207\u63DB\u9762\u677F",
84006
84348
  quit: "\u9000\u51FA\u61C9\u7528\u7A0B\u5F0F"
84349
+ },
84350
+ copyLastFeedback: {
84351
+ noAssistantMessage: "\u672A\u627E\u5230\u53EF\u8907\u88FD\u7684 AI \u52A9\u624B\u8A0A\u606F\u3002",
84352
+ emptyAssistantMessage: "\u6700\u5F8C\u4E00\u689D AI \u52A9\u624B\u8A0A\u606F\u6C92\u6709\u53EF\u8907\u88FD\u7684\u5167\u5BB9\u3002",
84353
+ copySuccess: "\u2713 \u5DF2\u8907\u88FD\u6700\u5F8C\u4E00\u689D AI \u8A0A\u606F\u5230\u526A\u8CBC\u7C3F",
84354
+ copyFailedPrefix: "\u2717 \u8907\u88FD\u5230\u526A\u8CBC\u7C3F\u5931\u6557",
84355
+ unknownError: "\u672A\u77E5\u932F\u8AA4"
84007
84356
  }
84008
84357
  },
84009
84358
  permissionsPanel: {
@@ -84033,6 +84382,7 @@ var init_zh_TW = __esm({
84033
84382
  requestMethod: "\u8ACB\u6C42\u65B9\u5F0F:",
84034
84383
  showThinkingProcess: "\u986F\u793A\u601D\u8003\u904E\u7A0B:",
84035
84384
  enableThinking: "\u555F\u7528\u601D\u8003:",
84385
+ thinkingMode: "\u601D\u8003\u6A21\u5F0F:",
84036
84386
  thinkingStrength: "\u601D\u8003\u5F37\u5EA6:",
84037
84387
  inputNumberHint: "\u8F38\u5165\u6578\u5B57,Enter\u5132\u5B58",
84038
84388
  escCancel: "Esc \u53D6\u6D88",
@@ -89908,7 +90258,9 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
89908
90258
  const [enableAutoCompress, setEnableAutoCompress] = (0, import_react64.useState)(true);
89909
90259
  const [showThinking, setShowThinking] = (0, import_react64.useState)(true);
89910
90260
  const [thinkingEnabled, setThinkingEnabled] = (0, import_react64.useState)(false);
90261
+ const [thinkingMode, setThinkingMode] = (0, import_react64.useState)("tokens");
89911
90262
  const [thinkingBudgetTokens, setThinkingBudgetTokens] = (0, import_react64.useState)(1e4);
90263
+ const [thinkingEffort, setThinkingEffort] = (0, import_react64.useState)("high");
89912
90264
  const [geminiThinkingEnabled, setGeminiThinkingEnabled] = (0, import_react64.useState)(false);
89913
90265
  const [geminiThinkingBudget, setGeminiThinkingBudget] = (0, import_react64.useState)(1024);
89914
90266
  const [responsesReasoningEnabled, setResponsesReasoningEnabled] = (0, import_react64.useState)(false);
@@ -89917,6 +90269,7 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
89917
90269
  const [basicModel, setBasicModel] = (0, import_react64.useState)("");
89918
90270
  const [maxContextTokens, setMaxContextTokens] = (0, import_react64.useState)(4e3);
89919
90271
  const [maxTokens, setMaxTokens] = (0, import_react64.useState)(4096);
90272
+ const [streamIdleTimeoutSec, setStreamIdleTimeoutSec] = (0, import_react64.useState)(180);
89920
90273
  const [toolResultTokenLimit, setToolResultTokenLimit] = (0, import_react64.useState)(1e5);
89921
90274
  const [editSimilarityThreshold, setEditSimilarityThreshold] = (0, import_react64.useState)(0.75);
89922
90275
  const [currentField, setCurrentField] = (0, import_react64.useState)("profile");
@@ -89964,7 +90317,9 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
89964
90317
  "anthropicBeta",
89965
90318
  "anthropicCacheTTL",
89966
90319
  "thinkingEnabled",
89967
- "thinkingBudgetTokens"
90320
+ "thinkingMode",
90321
+ ...thinkingEnabled && thinkingMode === "tokens" ? ["thinkingBudgetTokens"] : [],
90322
+ ...thinkingEnabled && thinkingMode === "adaptive" ? ["thinkingEffort"] : []
89968
90323
  ] : requestMethod === "gemini" ? [
89969
90324
  "geminiThinkingEnabled",
89970
90325
  "geminiThinkingBudget"
@@ -89976,6 +90331,7 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
89976
90331
  "basicModel",
89977
90332
  "maxContextTokens",
89978
90333
  "maxTokens",
90334
+ "streamIdleTimeoutSec",
89979
90335
  "toolResultTokenLimit",
89980
90336
  "editSimilarityThreshold"
89981
90337
  ];
@@ -90031,7 +90387,7 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
90031
90387
  supportsXHigh
90032
90388
  ]);
90033
90389
  const loadProfilesAndConfig = () => {
90034
- var _a21, _b14, _c6, _d4, _e2, _f;
90390
+ var _a21, _b14, _c6, _d4, _e2, _f, _g, _h, _i;
90035
90391
  const loadedProfiles = getAllProfiles();
90036
90392
  setProfiles(loadedProfiles);
90037
90393
  const config3 = getOpenAiConfig();
@@ -90044,16 +90400,19 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
90044
90400
  setAnthropicCacheTTL(config3.anthropicCacheTTL || "5m");
90045
90401
  setEnableAutoCompress(config3.enableAutoCompress !== false);
90046
90402
  setShowThinking(config3.showThinking !== false);
90047
- setThinkingEnabled(((_a21 = config3.thinking) == null ? void 0 : _a21.type) === "enabled" || false);
90048
- setThinkingBudgetTokens(((_b14 = config3.thinking) == null ? void 0 : _b14.budget_tokens) || 1e4);
90049
- setGeminiThinkingEnabled(((_c6 = config3.geminiThinking) == null ? void 0 : _c6.enabled) || false);
90050
- setGeminiThinkingBudget(((_d4 = config3.geminiThinking) == null ? void 0 : _d4.budget) || 1024);
90051
- setResponsesReasoningEnabled(((_e2 = config3.responsesReasoning) == null ? void 0 : _e2.enabled) || false);
90052
- setResponsesReasoningEffort(((_f = config3.responsesReasoning) == null ? void 0 : _f.effort) || "high");
90403
+ setThinkingEnabled(((_a21 = config3.thinking) == null ? void 0 : _a21.type) === "enabled" || ((_b14 = config3.thinking) == null ? void 0 : _b14.type) === "adaptive" || false);
90404
+ setThinkingMode(((_c6 = config3.thinking) == null ? void 0 : _c6.type) === "adaptive" ? "adaptive" : "tokens");
90405
+ setThinkingBudgetTokens(((_d4 = config3.thinking) == null ? void 0 : _d4.budget_tokens) || 1e4);
90406
+ setThinkingEffort(((_e2 = config3.thinking) == null ? void 0 : _e2.effort) || "high");
90407
+ setGeminiThinkingEnabled(((_f = config3.geminiThinking) == null ? void 0 : _f.enabled) || false);
90408
+ setGeminiThinkingBudget(((_g = config3.geminiThinking) == null ? void 0 : _g.budget) || 1024);
90409
+ setResponsesReasoningEnabled(((_h = config3.responsesReasoning) == null ? void 0 : _h.enabled) || false);
90410
+ setResponsesReasoningEffort(((_i = config3.responsesReasoning) == null ? void 0 : _i.effort) || "high");
90053
90411
  setAdvancedModel(config3.advancedModel || "");
90054
90412
  setBasicModel(config3.basicModel || "");
90055
90413
  setMaxContextTokens(config3.maxContextTokens || 4e3);
90056
90414
  setMaxTokens(config3.maxTokens || 4096);
90415
+ setStreamIdleTimeoutSec(config3.streamIdleTimeoutSec || 180);
90057
90416
  setToolResultTokenLimit(config3.toolResultTokenLimit || 1e5);
90058
90417
  setEditSimilarityThreshold(config3.editSimilarityThreshold ?? 0.75);
90059
90418
  const systemPromptConfig = getSystemPromptConfig();
@@ -90110,12 +90469,18 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
90110
90469
  return maxContextTokens.toString();
90111
90470
  if (currentField === "maxTokens")
90112
90471
  return maxTokens.toString();
90472
+ if (currentField === "streamIdleTimeoutSec")
90473
+ return streamIdleTimeoutSec.toString();
90113
90474
  if (currentField === "toolResultTokenLimit")
90114
90475
  return toolResultTokenLimit.toString();
90115
90476
  if (currentField === "editSimilarityThreshold")
90116
90477
  return editSimilarityThreshold.toString();
90117
90478
  if (currentField === "thinkingBudgetTokens")
90118
90479
  return thinkingBudgetTokens.toString();
90480
+ if (currentField === "thinkingMode")
90481
+ return thinkingMode;
90482
+ if (currentField === "thinkingEffort")
90483
+ return thinkingEffort;
90119
90484
  if (currentField === "geminiThinkingBudget")
90120
90485
  return geminiThinkingBudget.toString();
90121
90486
  if (currentField === "responsesReasoningEffort")
@@ -90241,11 +90606,12 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
90241
90606
  anthropicCacheTTL,
90242
90607
  enableAutoCompress,
90243
90608
  showThinking,
90244
- thinking: thinkingEnabled ? { type: "enabled", budget_tokens: thinkingBudgetTokens } : void 0,
90609
+ thinking: thinkingEnabled ? thinkingMode === "adaptive" ? { type: "adaptive", effort: thinkingEffort } : { type: "enabled", budget_tokens: thinkingBudgetTokens } : void 0,
90245
90610
  advancedModel,
90246
90611
  basicModel,
90247
90612
  maxContextTokens,
90248
90613
  maxTokens,
90614
+ streamIdleTimeoutSec,
90249
90615
  toolResultTokenLimit
90250
90616
  }
90251
90617
  };
@@ -90330,11 +90696,15 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
90330
90696
  basicModel,
90331
90697
  maxContextTokens,
90332
90698
  maxTokens,
90699
+ streamIdleTimeoutSec,
90333
90700
  toolResultTokenLimit,
90334
90701
  editSimilarityThreshold
90335
90702
  };
90336
90703
  if (thinkingEnabled) {
90337
- config3.thinking = {
90704
+ config3.thinking = thinkingMode === "adaptive" ? {
90705
+ type: "adaptive",
90706
+ effort: thinkingEffort
90707
+ } : {
90338
90708
  type: "enabled",
90339
90709
  budget_tokens: thinkingBudgetTokens
90340
90710
  };
@@ -90366,7 +90736,10 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
90366
90736
  anthropicCacheTTL,
90367
90737
  enableAutoCompress,
90368
90738
  showThinking,
90369
- thinking: thinkingEnabled ? { type: "enabled", budget_tokens: thinkingBudgetTokens } : void 0,
90739
+ thinking: thinkingEnabled ? thinkingMode === "adaptive" ? { type: "adaptive", effort: thinkingEffort } : {
90740
+ type: "enabled",
90741
+ budget_tokens: thinkingBudgetTokens
90742
+ } : void 0,
90370
90743
  geminiThinking: geminiThinkingEnabled ? { enabled: true, budget: geminiThinkingBudget } : void 0,
90371
90744
  responsesReasoning: {
90372
90745
  enabled: responsesReasoningEnabled,
@@ -90376,6 +90749,7 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
90376
90749
  basicModel,
90377
90750
  maxContextTokens,
90378
90751
  maxTokens,
90752
+ streamIdleTimeoutSec,
90379
90753
  toolResultTokenLimit,
90380
90754
  editSimilarityThreshold
90381
90755
  }
@@ -90643,7 +91017,25 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
90643
91017
  )
90644
91018
  )
90645
91019
  );
91020
+ case "thinkingMode":
91021
+ return import_react64.default.createElement(
91022
+ Box_default,
91023
+ { key: field, flexDirection: "column" },
91024
+ import_react64.default.createElement(
91025
+ Text,
91026
+ { color: isActive ? theme14.colors.menuSelected : theme14.colors.menuNormal },
91027
+ isActive ? "\u276F " : " ",
91028
+ t.configScreen.thinkingMode
91029
+ ),
91030
+ import_react64.default.createElement(
91031
+ Box_default,
91032
+ { marginLeft: 3 },
91033
+ import_react64.default.createElement(Text, { color: theme14.colors.menuSecondary }, thinkingMode === "tokens" ? t.configScreen.thinkingModeTokens : t.configScreen.thinkingModeAdaptive)
91034
+ )
91035
+ );
90646
91036
  case "thinkingBudgetTokens":
91037
+ if (thinkingMode !== "tokens")
91038
+ return null;
90647
91039
  return import_react64.default.createElement(
90648
91040
  Box_default,
90649
91041
  { key: field, flexDirection: "column" },
@@ -90670,6 +91062,24 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
90670
91062
  import_react64.default.createElement(Text, { color: theme14.colors.menuSecondary }, thinkingBudgetTokens)
90671
91063
  )
90672
91064
  );
91065
+ case "thinkingEffort":
91066
+ if (thinkingMode !== "adaptive")
91067
+ return null;
91068
+ return import_react64.default.createElement(
91069
+ Box_default,
91070
+ { key: field, flexDirection: "column" },
91071
+ import_react64.default.createElement(
91072
+ Text,
91073
+ { color: isActive ? theme14.colors.menuSelected : theme14.colors.menuNormal },
91074
+ isActive ? "\u276F " : " ",
91075
+ t.configScreen.thinkingEffort
91076
+ ),
91077
+ import_react64.default.createElement(
91078
+ Box_default,
91079
+ { marginLeft: 3 },
91080
+ import_react64.default.createElement(Text, { color: theme14.colors.menuSecondary }, thinkingEffort)
91081
+ )
91082
+ );
90673
91083
  case "geminiThinkingEnabled":
90674
91084
  return import_react64.default.createElement(
90675
91085
  Box_default,
@@ -90856,6 +91266,33 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
90856
91266
  import_react64.default.createElement(Text, { color: theme14.colors.menuSecondary }, maxTokens)
90857
91267
  )
90858
91268
  );
91269
+ case "streamIdleTimeoutSec":
91270
+ return import_react64.default.createElement(
91271
+ Box_default,
91272
+ { key: field, flexDirection: "column" },
91273
+ import_react64.default.createElement(
91274
+ Text,
91275
+ { color: isActive ? theme14.colors.menuSelected : theme14.colors.menuNormal },
91276
+ isActive ? "\u276F " : " ",
91277
+ t.configScreen.streamIdleTimeoutSec
91278
+ ),
91279
+ isCurrentlyEditing && import_react64.default.createElement(
91280
+ Box_default,
91281
+ { marginLeft: 3 },
91282
+ import_react64.default.createElement(
91283
+ Text,
91284
+ { color: theme14.colors.menuInfo },
91285
+ t.configScreen.enterValue,
91286
+ " ",
91287
+ streamIdleTimeoutSec
91288
+ )
91289
+ ),
91290
+ !isCurrentlyEditing && import_react64.default.createElement(
91291
+ Box_default,
91292
+ { marginLeft: 3 },
91293
+ import_react64.default.createElement(Text, { color: theme14.colors.menuSecondary }, streamIdleTimeoutSec)
91294
+ )
91295
+ );
90859
91296
  case "toolResultTokenLimit":
90860
91297
  return import_react64.default.createElement(
90861
91298
  Box_default,
@@ -90992,7 +91429,7 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
90992
91429
  }
90993
91430
  return;
90994
91431
  }
90995
- if (isEditing && (currentField === "profile" || currentField === "requestMethod" || currentField === "systemPromptId" || currentField === "customHeadersSchemeId" || currentField === "anthropicCacheTTL" || currentField === "advancedModel" || currentField === "basicModel" || currentField === "responsesReasoningEffort") && key.escape) {
91432
+ if (isEditing && (currentField === "profile" || currentField === "requestMethod" || currentField === "systemPromptId" || currentField === "customHeadersSchemeId" || currentField === "anthropicCacheTTL" || currentField === "advancedModel" || currentField === "basicModel" || currentField === "thinkingMode" || currentField === "thinkingEffort" || currentField === "responsesReasoningEffort") && key.escape) {
90996
91433
  setIsEditing(false);
90997
91434
  setSearchTerm("");
90998
91435
  if (currentField === "systemPromptId") {
@@ -91008,7 +91445,7 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
91008
91445
  }
91009
91446
  return;
91010
91447
  }
91011
- if (currentField === "maxContextTokens" || currentField === "maxTokens" || currentField === "toolResultTokenLimit" || currentField === "thinkingBudgetTokens" || currentField === "geminiThinkingBudget" || currentField === "editSimilarityThreshold") {
91448
+ if (currentField === "maxContextTokens" || currentField === "maxTokens" || currentField === "streamIdleTimeoutSec" || currentField === "toolResultTokenLimit" || currentField === "thinkingBudgetTokens" || currentField === "geminiThinkingBudget" || currentField === "editSimilarityThreshold") {
91012
91449
  if (currentField === "editSimilarityThreshold") {
91013
91450
  if (input2 && input2.match(/[0-9.]/)) {
91014
91451
  const currentStr = editingThresholdValue || editSimilarityThreshold.toString();
@@ -91038,13 +91475,15 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
91038
91475
  return;
91039
91476
  }
91040
91477
  if (input2 && input2.match(/[0-9]/)) {
91041
- const currentValue = currentField === "maxContextTokens" ? maxContextTokens : currentField === "maxTokens" ? maxTokens : currentField === "toolResultTokenLimit" ? toolResultTokenLimit : currentField === "thinkingBudgetTokens" ? thinkingBudgetTokens : geminiThinkingBudget;
91478
+ const currentValue = currentField === "maxContextTokens" ? maxContextTokens : currentField === "maxTokens" ? maxTokens : currentField === "streamIdleTimeoutSec" ? streamIdleTimeoutSec : currentField === "toolResultTokenLimit" ? toolResultTokenLimit : currentField === "thinkingBudgetTokens" ? thinkingBudgetTokens : geminiThinkingBudget;
91042
91479
  const newValue = parseInt(currentValue.toString() + input2, 10);
91043
91480
  if (!isNaN(newValue)) {
91044
91481
  if (currentField === "maxContextTokens") {
91045
91482
  setMaxContextTokens(newValue);
91046
91483
  } else if (currentField === "maxTokens") {
91047
91484
  setMaxTokens(newValue);
91485
+ } else if (currentField === "streamIdleTimeoutSec") {
91486
+ setStreamIdleTimeoutSec(newValue);
91048
91487
  } else if (currentField === "toolResultTokenLimit") {
91049
91488
  setToolResultTokenLimit(newValue);
91050
91489
  } else if (currentField === "thinkingBudgetTokens") {
@@ -91054,7 +91493,7 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
91054
91493
  }
91055
91494
  }
91056
91495
  } else if (key.backspace || key.delete) {
91057
- const currentValue = currentField === "maxContextTokens" ? maxContextTokens : currentField === "maxTokens" ? maxTokens : currentField === "toolResultTokenLimit" ? toolResultTokenLimit : currentField === "thinkingBudgetTokens" ? thinkingBudgetTokens : geminiThinkingBudget;
91496
+ const currentValue = currentField === "maxContextTokens" ? maxContextTokens : currentField === "maxTokens" ? maxTokens : currentField === "streamIdleTimeoutSec" ? streamIdleTimeoutSec : currentField === "toolResultTokenLimit" ? toolResultTokenLimit : currentField === "thinkingBudgetTokens" ? thinkingBudgetTokens : geminiThinkingBudget;
91058
91497
  const currentStr = currentValue.toString();
91059
91498
  const newStr = currentStr.slice(0, -1);
91060
91499
  const newValue = parseInt(newStr, 10);
@@ -91062,6 +91501,8 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
91062
91501
  setMaxContextTokens(!isNaN(newValue) ? newValue : 0);
91063
91502
  } else if (currentField === "maxTokens") {
91064
91503
  setMaxTokens(!isNaN(newValue) ? newValue : 0);
91504
+ } else if (currentField === "streamIdleTimeoutSec") {
91505
+ setStreamIdleTimeoutSec(!isNaN(newValue) ? newValue : 0);
91065
91506
  } else if (currentField === "toolResultTokenLimit") {
91066
91507
  setToolResultTokenLimit(!isNaN(newValue) ? newValue : 0);
91067
91508
  } else if (currentField === "thinkingBudgetTokens") {
@@ -91070,13 +91511,15 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
91070
91511
  setGeminiThinkingBudget(!isNaN(newValue) ? newValue : 0);
91071
91512
  }
91072
91513
  } else if (key.return) {
91073
- const minValue = currentField === "maxContextTokens" ? 4e3 : currentField === "maxTokens" ? 100 : currentField === "toolResultTokenLimit" ? 1e3 : currentField === "thinkingBudgetTokens" ? 1e3 : 1;
91074
- const currentValue = currentField === "maxContextTokens" ? maxContextTokens : currentField === "maxTokens" ? maxTokens : currentField === "toolResultTokenLimit" ? toolResultTokenLimit : currentField === "thinkingBudgetTokens" ? thinkingBudgetTokens : geminiThinkingBudget;
91514
+ const minValue = currentField === "maxContextTokens" ? 4e3 : currentField === "maxTokens" ? 100 : currentField === "streamIdleTimeoutSec" ? 1 : currentField === "toolResultTokenLimit" ? 1e3 : currentField === "thinkingBudgetTokens" ? 1e3 : 1;
91515
+ const currentValue = currentField === "maxContextTokens" ? maxContextTokens : currentField === "maxTokens" ? maxTokens : currentField === "streamIdleTimeoutSec" ? streamIdleTimeoutSec : currentField === "toolResultTokenLimit" ? toolResultTokenLimit : currentField === "thinkingBudgetTokens" ? thinkingBudgetTokens : geminiThinkingBudget;
91075
91516
  const finalValue = currentValue < minValue ? minValue : currentValue;
91076
91517
  if (currentField === "maxContextTokens") {
91077
91518
  setMaxContextTokens(finalValue);
91078
91519
  } else if (currentField === "maxTokens") {
91079
91520
  setMaxTokens(finalValue);
91521
+ } else if (currentField === "streamIdleTimeoutSec") {
91522
+ setStreamIdleTimeoutSec(finalValue);
91080
91523
  } else if (currentField === "toolResultTokenLimit") {
91081
91524
  setToolResultTokenLimit(finalValue);
91082
91525
  } else if (currentField === "thinkingBudgetTokens") {
@@ -91117,11 +91560,15 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
91117
91560
  setShowThinking(!showThinking);
91118
91561
  } else if (currentField === "thinkingEnabled") {
91119
91562
  setThinkingEnabled(!thinkingEnabled);
91563
+ } else if (currentField === "thinkingMode") {
91564
+ setIsEditing(true);
91565
+ } else if (currentField === "thinkingEffort") {
91566
+ setIsEditing(true);
91120
91567
  } else if (currentField === "geminiThinkingEnabled") {
91121
91568
  setGeminiThinkingEnabled(!geminiThinkingEnabled);
91122
91569
  } else if (currentField === "responsesReasoningEnabled") {
91123
91570
  setResponsesReasoningEnabled(!responsesReasoningEnabled);
91124
- } else if (currentField === "maxContextTokens" || currentField === "maxTokens" || currentField === "toolResultTokenLimit" || currentField === "thinkingBudgetTokens" || currentField === "geminiThinkingBudget") {
91571
+ } else if (currentField === "maxContextTokens" || currentField === "maxTokens" || currentField === "streamIdleTimeoutSec" || currentField === "toolResultTokenLimit" || currentField === "thinkingBudgetTokens" || currentField === "geminiThinkingBudget") {
91125
91572
  setIsEditing(true);
91126
91573
  } else if (currentField === "editSimilarityThreshold") {
91127
91574
  setEditingThresholdValue("");
@@ -91382,7 +91829,7 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
91382
91829
  )
91383
91830
  )
91384
91831
  ),
91385
- isEditing && (currentField === "profile" || currentField === "requestMethod" || currentField === "systemPromptId" || currentField === "customHeadersSchemeId" || currentField === "advancedModel" || currentField === "basicModel" || currentField === "responsesReasoningEffort") ? import_react64.default.createElement(
91832
+ isEditing && (currentField === "profile" || currentField === "requestMethod" || currentField === "systemPromptId" || currentField === "customHeadersSchemeId" || currentField === "advancedModel" || currentField === "basicModel" || currentField === "thinkingMode" || currentField === "thinkingEffort" || currentField === "responsesReasoningEffort") ? import_react64.default.createElement(
91386
91833
  Box_default,
91387
91834
  { flexDirection: "column" },
91388
91835
  import_react64.default.createElement(
@@ -91394,6 +91841,8 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
91394
91841
  currentField === "requestMethod" && t.configScreen.requestMethod.replace(":", ""),
91395
91842
  currentField === "advancedModel" && t.configScreen.advancedModel.replace(":", ""),
91396
91843
  currentField === "basicModel" && t.configScreen.basicModel.replace(":", ""),
91844
+ currentField === "thinkingMode" && t.configScreen.thinkingMode.replace(":", ""),
91845
+ currentField === "thinkingEffort" && t.configScreen.thinkingEffort.replace(":", ""),
91397
91846
  currentField === "responsesReasoningEffort" && t.configScreen.responsesReasoningEffort.replace(":", ""),
91398
91847
  currentField === "systemPromptId" && t.configScreen.systemPrompt,
91399
91848
  currentField === "customHeadersSchemeId" && t.configScreen.customHeadersField
@@ -91545,6 +91994,25 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
91545
91994
  handleModelChange(item.value);
91546
91995
  } })
91547
91996
  ),
91997
+ currentField === "thinkingMode" && import_react64.default.createElement(ScrollableSelectInput, { items: [
91998
+ { label: t.configScreen.thinkingModeTokens, value: "tokens" },
91999
+ {
92000
+ label: t.configScreen.thinkingModeAdaptive,
92001
+ value: "adaptive"
92002
+ }
92003
+ ], initialIndex: thinkingMode === "tokens" ? 0 : 1, isFocused: true, onSelect: (item) => {
92004
+ setThinkingMode(item.value);
92005
+ setIsEditing(false);
92006
+ } }),
92007
+ currentField === "thinkingEffort" && import_react64.default.createElement(ScrollableSelectInput, { items: [
92008
+ { label: "low", value: "low" },
92009
+ { label: "medium", value: "medium" },
92010
+ { label: "high", value: "high" },
92011
+ { label: "max", value: "max" }
92012
+ ], initialIndex: thinkingEffort === "low" ? 0 : thinkingEffort === "medium" ? 1 : thinkingEffort === "high" ? 2 : 3, isFocused: true, onSelect: (item) => {
92013
+ setThinkingEffort(item.value);
92014
+ setIsEditing(false);
92015
+ } }),
91548
92016
  currentField === "responsesReasoningEffort" && import_react64.default.createElement(ScrollableSelectInput, { items: [
91549
92017
  { label: "LOW", value: "low" },
91550
92018
  { label: "MEDIUM", value: "medium" },
@@ -91573,7 +92041,7 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
91573
92041
  error
91574
92042
  ))
91575
92043
  ),
91576
- !(isEditing && (currentField === "profile" || currentField === "requestMethod" || currentField === "systemPromptId" || currentField === "customHeadersSchemeId" || currentField === "advancedModel" || currentField === "basicModel" || currentField === "responsesReasoningEffort")) && import_react64.default.createElement(
92044
+ !!!(isEditing && (currentField === "profile" || currentField === "requestMethod" || currentField === "systemPromptId" || currentField === "customHeadersSchemeId" || currentField === "advancedModel" || currentField === "basicModel" || currentField === "thinkingMode" || currentField === "thinkingEffort" || currentField === "responsesReasoningEffort")) && import_react64.default.createElement(
91577
92045
  Box_default,
91578
92046
  { flexDirection: "column", marginTop: 1 },
91579
92047
  import_react64.default.createElement(Alert, { variant: "info" }, isEditing ? `${currentField === "maxContextTokens" || currentField === "maxTokens" ? t.configScreen.editingHintNumeric : t.configScreen.editingHintGeneral}
@@ -553939,6 +554407,10 @@ function useCommandPanel(buffer, isProcessing = false) {
553939
554407
  const builtInCommands = (0, import_react86.useMemo)(() => [
553940
554408
  { name: "help", description: t.commandPanel.commands.help },
553941
554409
  { name: "clear", description: t.commandPanel.commands.clear },
554410
+ {
554411
+ name: "copy-last",
554412
+ description: t.commandPanel.commands.copyLast || "Copy last AI message to clipboard"
554413
+ },
553942
554414
  { name: "resume", description: t.commandPanel.commands.resume },
553943
554415
  { name: "mcp", description: t.commandPanel.commands.mcp },
553944
554416
  { name: "yolo", description: t.commandPanel.commands.yolo },
@@ -563927,7 +564399,9 @@ var init_ModelsPanel = __esm({
563927
564399
  const [requestMethod, setRequestMethod] = (0, import_react127.useState)("chat");
563928
564400
  const [showThinking, setShowThinking] = (0, import_react127.useState)(true);
563929
564401
  const [thinkingEnabled, setThinkingEnabled] = (0, import_react127.useState)(false);
564402
+ const [thinkingMode, setThinkingMode] = (0, import_react127.useState)("tokens");
563930
564403
  const [thinkingBudgetTokens, setThinkingBudgetTokens] = (0, import_react127.useState)(1e4);
564404
+ const [thinkingEffort, setThinkingEffort] = (0, import_react127.useState)("high");
563931
564405
  const [geminiThinkingEnabled, setGeminiThinkingEnabled] = (0, import_react127.useState)(false);
563932
564406
  const [geminiThinkingBudget, setGeminiThinkingBudget] = (0, import_react127.useState)(1024);
563933
564407
  const [responsesReasoningEnabled, setResponsesReasoningEnabled] = (0, import_react127.useState)(false);
@@ -563935,9 +564409,10 @@ var init_ModelsPanel = __esm({
563935
564409
  const [thinkingFocusIndex, setThinkingFocusIndex] = (0, import_react127.useState)(0);
563936
564410
  const [thinkingInputMode, setThinkingInputMode] = (0, import_react127.useState)(null);
563937
564411
  const [thinkingInputValue, setThinkingInputValue] = (0, import_react127.useState)("");
564412
+ const [isThinkingModeSelecting, setIsThinkingModeSelecting] = (0, import_react127.useState)(false);
563938
564413
  const [isThinkingEffortSelecting, setIsThinkingEffortSelecting] = (0, import_react127.useState)(false);
563939
564414
  (0, import_react127.useEffect)(() => {
563940
- var _a21, _b14, _c6, _d4, _e2, _f;
564415
+ var _a21, _b14, _c6, _d4, _e2, _f, _g, _h, _i;
563941
564416
  if (!visible) {
563942
564417
  return;
563943
564418
  }
@@ -563957,12 +564432,14 @@ var init_ModelsPanel = __esm({
563957
564432
  const cfg = getOpenAiConfig();
563958
564433
  setRequestMethod(cfg.requestMethod || "chat");
563959
564434
  setShowThinking(cfg.showThinking !== false);
563960
- setThinkingEnabled(((_a21 = cfg.thinking) == null ? void 0 : _a21.type) === "enabled" || false);
563961
- setThinkingBudgetTokens(((_b14 = cfg.thinking) == null ? void 0 : _b14.budget_tokens) || 1e4);
563962
- setGeminiThinkingEnabled(((_c6 = cfg.geminiThinking) == null ? void 0 : _c6.enabled) || false);
563963
- setGeminiThinkingBudget(((_d4 = cfg.geminiThinking) == null ? void 0 : _d4.budget) || 1024);
563964
- setResponsesReasoningEnabled(((_e2 = cfg.responsesReasoning) == null ? void 0 : _e2.enabled) || false);
563965
- setResponsesReasoningEffort(((_f = cfg.responsesReasoning) == null ? void 0 : _f.effort) || "high");
564435
+ setThinkingEnabled(((_a21 = cfg.thinking) == null ? void 0 : _a21.type) === "enabled" || ((_b14 = cfg.thinking) == null ? void 0 : _b14.type) === "adaptive" || false);
564436
+ setThinkingMode(((_c6 = cfg.thinking) == null ? void 0 : _c6.type) === "adaptive" ? "adaptive" : "tokens");
564437
+ setThinkingBudgetTokens(((_d4 = cfg.thinking) == null ? void 0 : _d4.budget_tokens) || 1e4);
564438
+ setThinkingEffort(((_e2 = cfg.thinking) == null ? void 0 : _e2.effort) || "high");
564439
+ setGeminiThinkingEnabled(((_f = cfg.geminiThinking) == null ? void 0 : _f.enabled) || false);
564440
+ setGeminiThinkingBudget(((_g = cfg.geminiThinking) == null ? void 0 : _g.budget) || 1024);
564441
+ setResponsesReasoningEnabled(((_h = cfg.responsesReasoning) == null ? void 0 : _h.enabled) || false);
564442
+ setResponsesReasoningEffort(((_i = cfg.responsesReasoning) == null ? void 0 : _i.effort) || "high");
563966
564443
  }, [visible, advancedModel, basicModel]);
563967
564444
  const modelTarget = activeTab === "basic" ? "basic" : activeTab === "thinking" ? "thinking" : "advanced";
563968
564445
  const currentModel = modelTarget === "advanced" ? localAdvancedModel : modelTarget === "basic" ? localBasicModel : "";
@@ -564049,7 +564526,7 @@ var init_ModelsPanel = __esm({
564049
564526
  ]);
564050
564527
  const thinkingStrengthValue = (0, import_react127.useMemo)(() => {
564051
564528
  if (requestMethod === "anthropic") {
564052
- return String(thinkingBudgetTokens);
564529
+ return thinkingMode === "adaptive" ? thinkingEffort : String(thinkingBudgetTokens);
564053
564530
  }
564054
564531
  if (requestMethod === "gemini") {
564055
564532
  return String(geminiThinkingBudget);
@@ -564060,7 +564537,9 @@ var init_ModelsPanel = __esm({
564060
564537
  return t.modelsPanel.notSupported;
564061
564538
  }, [
564062
564539
  requestMethod,
564540
+ thinkingMode,
564063
564541
  thinkingBudgetTokens,
564542
+ thinkingEffort,
564064
564543
  geminiThinkingBudget,
564065
564544
  responsesReasoningEffort,
564066
564545
  t
@@ -564085,7 +564564,10 @@ var init_ModelsPanel = __esm({
564085
564564
  if (requestMethod === "anthropic") {
564086
564565
  setThinkingEnabled(next);
564087
564566
  await updateOpenAiConfig({
564088
- thinking: next ? { type: "enabled", budget_tokens: thinkingBudgetTokens } : void 0
564567
+ thinking: next ? thinkingMode === "adaptive" ? { type: "adaptive", effort: thinkingEffort } : {
564568
+ type: "enabled",
564569
+ budget_tokens: thinkingBudgetTokens
564570
+ } : void 0
564089
564571
  });
564090
564572
  return;
564091
564573
  }
@@ -564113,7 +564595,9 @@ var init_ModelsPanel = __esm({
564113
564595
  }
564114
564596
  }, [
564115
564597
  requestMethod,
564598
+ thinkingMode,
564116
564599
  thinkingBudgetTokens,
564600
+ thinkingEffort,
564117
564601
  geminiThinkingBudget,
564118
564602
  responsesReasoningEffort
564119
564603
  ]);
@@ -564122,7 +564606,31 @@ var init_ModelsPanel = __esm({
564122
564606
  try {
564123
564607
  setThinkingBudgetTokens(next);
564124
564608
  await updateOpenAiConfig({
564125
- thinking: thinkingEnabled ? { type: "enabled", budget_tokens: next } : void 0
564609
+ thinking: thinkingEnabled ? thinkingMode === "adaptive" ? { type: "adaptive", effort: thinkingEffort } : { type: "enabled", budget_tokens: next } : void 0
564610
+ });
564611
+ } catch (err) {
564612
+ const message = err instanceof Error ? err.message : t.modelsPanel.saveFailed;
564613
+ setErrorMessage(message);
564614
+ }
564615
+ }, [thinkingEnabled, thinkingMode, thinkingEffort]);
564616
+ const applyThinkingMode = (0, import_react127.useCallback)(async (next) => {
564617
+ setErrorMessage("");
564618
+ try {
564619
+ setThinkingMode(next);
564620
+ await updateOpenAiConfig({
564621
+ thinking: thinkingEnabled ? next === "adaptive" ? { type: "adaptive", effort: thinkingEffort } : { type: "enabled", budget_tokens: thinkingBudgetTokens } : void 0
564622
+ });
564623
+ } catch (err) {
564624
+ const message = err instanceof Error ? err.message : t.modelsPanel.saveFailed;
564625
+ setErrorMessage(message);
564626
+ }
564627
+ }, [thinkingEnabled, thinkingEffort, thinkingBudgetTokens]);
564628
+ const applyThinkingEffort = (0, import_react127.useCallback)(async (next) => {
564629
+ setErrorMessage("");
564630
+ try {
564631
+ setThinkingEffort(next);
564632
+ await updateOpenAiConfig({
564633
+ thinking: thinkingEnabled ? { type: "adaptive", effort: next } : void 0
564126
564634
  });
564127
564635
  } catch (err) {
564128
564636
  const message = err instanceof Error ? err.message : t.modelsPanel.saveFailed;
@@ -564168,6 +564676,10 @@ var init_ModelsPanel = __esm({
564168
564676
  setThinkingInputValue("");
564169
564677
  return;
564170
564678
  }
564679
+ if (isThinkingModeSelecting) {
564680
+ setIsThinkingModeSelecting(false);
564681
+ return;
564682
+ }
564171
564683
  if (isThinkingEffortSelecting) {
564172
564684
  setIsThinkingEffortSelecting(false);
564173
564685
  return;
@@ -564239,7 +564751,7 @@ var init_ModelsPanel = __esm({
564239
564751
  }
564240
564752
  return;
564241
564753
  }
564242
- if (isThinkingEffortSelecting) {
564754
+ if (isThinkingModeSelecting || isThinkingEffortSelecting) {
564243
564755
  return;
564244
564756
  }
564245
564757
  if (key.tab) {
@@ -564248,11 +564760,13 @@ var init_ModelsPanel = __esm({
564248
564760
  }
564249
564761
  if (activeTab === "thinking") {
564250
564762
  if (key.upArrow) {
564251
- setThinkingFocusIndex((prev) => prev === 0 ? 2 : prev - 1);
564763
+ const maxIndex = requestMethod === "anthropic" ? 3 : 2;
564764
+ setThinkingFocusIndex((prev) => prev === 0 ? maxIndex : prev - 1);
564252
564765
  return;
564253
564766
  }
564254
564767
  if (key.downArrow) {
564255
- setThinkingFocusIndex((prev) => prev === 2 ? 0 : prev + 1);
564768
+ const maxIndex = requestMethod === "anthropic" ? 3 : 2;
564769
+ setThinkingFocusIndex((prev) => prev === maxIndex ? 0 : prev + 1);
564256
564770
  return;
564257
564771
  }
564258
564772
  if (key.return) {
@@ -564260,10 +564774,16 @@ var init_ModelsPanel = __esm({
564260
564774
  void applyShowThinking(!showThinking);
564261
564775
  } else if (thinkingFocusIndex === 1) {
564262
564776
  void applyThinkingEnabled(!thinkingEnabledValue);
564263
- } else if (thinkingFocusIndex === 2) {
564777
+ } else if (thinkingFocusIndex === 2 && requestMethod === "anthropic") {
564778
+ setIsThinkingModeSelecting(true);
564779
+ } else if (thinkingFocusIndex === 3 && requestMethod === "anthropic" || thinkingFocusIndex === 2 && requestMethod !== "anthropic") {
564264
564780
  if (requestMethod === "anthropic") {
564265
- setThinkingInputMode("anthropicBudgetTokens");
564266
- setThinkingInputValue(thinkingBudgetTokens.toString());
564781
+ if (thinkingMode === "tokens") {
564782
+ setThinkingInputMode("anthropicBudgetTokens");
564783
+ setThinkingInputValue(thinkingBudgetTokens.toString());
564784
+ } else {
564785
+ setIsThinkingEffortSelecting(true);
564786
+ }
564267
564787
  } else if (requestMethod === "gemini") {
564268
564788
  setThinkingInputMode("geminiThinkingBudget");
564269
564789
  setThinkingInputValue(geminiThinkingBudget.toString());
@@ -564376,13 +564896,29 @@ var init_ModelsPanel = __esm({
564376
564896
  thinkingEnabledValue ? "[\u2713]" : "[ ]"
564377
564897
  )
564378
564898
  ),
564379
- import_react127.default.createElement(
564899
+ requestMethod === "anthropic" && import_react127.default.createElement(
564380
564900
  Box_default,
564381
564901
  null,
564382
564902
  import_react127.default.createElement(
564383
564903
  Text,
564384
564904
  { color: thinkingFocusIndex === 2 ? theme14.colors.menuSelected : theme14.colors.menuNormal },
564385
564905
  thinkingFocusIndex === 2 ? "\u276F " : " ",
564906
+ t.configScreen.thinkingMode
564907
+ ),
564908
+ import_react127.default.createElement(
564909
+ Text,
564910
+ { color: theme14.colors.menuSelected },
564911
+ " ",
564912
+ thinkingMode === "tokens" ? t.configScreen.thinkingModeTokens : t.configScreen.thinkingModeAdaptive
564913
+ )
564914
+ ),
564915
+ import_react127.default.createElement(
564916
+ Box_default,
564917
+ null,
564918
+ import_react127.default.createElement(
564919
+ Text,
564920
+ { color: thinkingFocusIndex === 3 ? theme14.colors.menuSelected : theme14.colors.menuNormal },
564921
+ thinkingFocusIndex === 3 ? "\u276F " : " ",
564386
564922
  t.modelsPanel.thinkingStrength
564387
564923
  ),
564388
564924
  import_react127.default.createElement(
@@ -564412,23 +564948,46 @@ var init_ModelsPanel = __esm({
564412
564948
  import_react127.default.createElement(Text, { dimColor: true, color: theme14.colors.menuSecondary }, t.modelsPanel.escCancel)
564413
564949
  )
564414
564950
  ),
564415
- isThinkingEffortSelecting && import_react127.default.createElement(
564951
+ isThinkingModeSelecting && import_react127.default.createElement(
564416
564952
  Box_default,
564417
564953
  { marginTop: 1 },
564418
564954
  import_react127.default.createElement(ScrollableSelectInput, { items: [
564955
+ { label: t.configScreen.thinkingModeTokens, value: "tokens" },
564956
+ {
564957
+ label: t.configScreen.thinkingModeAdaptive,
564958
+ value: "adaptive"
564959
+ }
564960
+ ], initialIndex: thinkingMode === "tokens" ? 0 : 1, isFocused: true, onSelect: (item) => {
564961
+ void applyThinkingMode(item.value);
564962
+ setIsThinkingModeSelecting(false);
564963
+ } })
564964
+ ),
564965
+ isThinkingEffortSelecting && import_react127.default.createElement(
564966
+ Box_default,
564967
+ { marginTop: 1 },
564968
+ import_react127.default.createElement(ScrollableSelectInput, { items: (requestMethod === "anthropic" ? [
564969
+ { label: "low", value: "low" },
564970
+ { label: "medium", value: "medium" },
564971
+ { label: "high", value: "high" },
564972
+ { label: "max", value: "max" }
564973
+ ] : [
564419
564974
  { label: "low", value: "low" },
564420
564975
  { label: "medium", value: "medium" },
564421
564976
  { label: "high", value: "high" },
564422
564977
  { label: "xhigh", value: "xhigh" }
564423
- ].map((i) => ({
564978
+ ]).map((i) => ({
564424
564979
  label: i.label,
564425
564980
  value: i.value
564426
- })), limit: 6, disableNumberShortcuts: true, initialIndex: Math.max(0, ["low", "medium", "high", "xhigh"].indexOf(responsesReasoningEffort)), isFocused: true, onSelect: (item) => {
564427
- void applyResponsesEffort(item.value);
564981
+ })), limit: 6, disableNumberShortcuts: true, initialIndex: Math.max(0, requestMethod === "anthropic" ? ["low", "medium", "high", "max"].indexOf(thinkingEffort) : ["low", "medium", "high", "xhigh"].indexOf(responsesReasoningEffort)), isFocused: true, onSelect: (item) => {
564982
+ if (requestMethod === "anthropic") {
564983
+ void applyThinkingEffort(item.value);
564984
+ } else {
564985
+ void applyResponsesEffort(item.value);
564986
+ }
564428
564987
  setIsThinkingEffortSelecting(false);
564429
564988
  } })
564430
564989
  ),
564431
- !thinkingInputMode && !isThinkingEffortSelecting && import_react127.default.createElement(
564990
+ !thinkingInputMode && !isThinkingModeSelecting && !isThinkingEffortSelecting && import_react127.default.createElement(
564432
564991
  Box_default,
564433
564992
  { marginTop: 1 },
564434
564993
  import_react127.default.createElement(Text, { dimColor: true, color: theme14.colors.menuSecondary }, t.modelsPanel.navigationHint)
@@ -568216,6 +568775,65 @@ var init_chatExporter = __esm({
568216
568775
  }
568217
568776
  });
568218
568777
 
568778
+ // dist/utils/core/clipboard.js
568779
+ import { execSync as execSync7 } from "child_process";
568780
+ async function copyToClipboard(content) {
568781
+ return new Promise((resolve12, reject2) => {
568782
+ try {
568783
+ const base64Content = Buffer.from(content, "utf-8").toString("base64");
568784
+ if (process.platform === "win32") {
568785
+ execSync7(`powershell -NoProfile -Command "[Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${base64Content}')) | Set-Clipboard"`, { encoding: "utf-8" });
568786
+ resolve12();
568787
+ } else if (process.platform === "darwin") {
568788
+ execSync7(`echo "${base64Content}" | base64 -d | pbcopy`, {
568789
+ encoding: "utf-8"
568790
+ });
568791
+ resolve12();
568792
+ } else {
568793
+ try {
568794
+ execSync7(`echo "${base64Content}" | base64 -d | xclip -selection clipboard`, { encoding: "utf-8" });
568795
+ resolve12();
568796
+ } catch {
568797
+ try {
568798
+ execSync7(`echo "${base64Content}" | base64 -d | xsel --clipboard --input`, { encoding: "utf-8" });
568799
+ resolve12();
568800
+ } catch {
568801
+ return;
568802
+ }
568803
+ }
568804
+ }
568805
+ } catch (error) {
568806
+ if (!(error instanceof Error)) {
568807
+ reject2(new Error("Failed to copy to clipboard: Unknown error"));
568808
+ return;
568809
+ }
568810
+ const errorMsg = error.message;
568811
+ if (errorMsg.includes("command not found") || errorMsg.includes("not found") || errorMsg.includes("spawn ENOENT") || /spawn.*not found/.test(errorMsg)) {
568812
+ let toolName = "clipboard tool";
568813
+ if (process.platform === "win32") {
568814
+ toolName = "PowerShell";
568815
+ } else if (process.platform === "darwin") {
568816
+ toolName = "pbcopy";
568817
+ } else {
568818
+ toolName = "xclip/xsel";
568819
+ }
568820
+ reject2(new Error(`Clipboard tool not found: ${toolName} is not available. Please install ${toolName}.`));
568821
+ return;
568822
+ }
568823
+ if (errorMsg.includes("EACCES") || errorMsg.includes("EPERM") || errorMsg.includes("Access denied") || errorMsg.includes("permission denied") || errorMsg.includes("Permission denied")) {
568824
+ reject2(new Error("Permission denied: Cannot access clipboard. Please check your permissions."));
568825
+ return;
568826
+ }
568827
+ reject2(new Error(`Failed to copy to clipboard: ${errorMsg}`));
568828
+ }
568829
+ });
568830
+ }
568831
+ var init_clipboard = __esm({
568832
+ "dist/utils/core/clipboard.js"() {
568833
+ "use strict";
568834
+ }
568835
+ });
568836
+
568219
568837
  // dist/hooks/conversation/useCommandHandler.js
568220
568838
  async function executeContextCompression(sessionId) {
568221
568839
  try {
@@ -568364,6 +568982,7 @@ ${msg.content}`;
568364
568982
  }
568365
568983
  function useCommandHandler(options3) {
568366
568984
  const { stdout } = use_stdout_default();
568985
+ const { t } = useI18n();
568367
568986
  const handleCommandExecution = (0, import_react137.useCallback)(async (commandName, result2) => {
568368
568987
  if (commandName === "compact" && result2.success && result2.action === "compact") {
568369
568988
  options3.setIsCompressing(true);
@@ -568813,6 +569432,52 @@ ${filePath}`,
568813
569432
  options3.setMessages((prev) => [...prev, errorMessage]);
568814
569433
  }
568815
569434
  }
569435
+ } else if (result2.success && result2.action === "copyLastMessage") {
569436
+ try {
569437
+ const messages = options3.messages;
569438
+ let lastAssistantMessage;
569439
+ for (let i = messages.length - 1; i >= 0; i--) {
569440
+ const msg = messages[i];
569441
+ if (msg && msg.role === "assistant" && !msg.subAgentInternal) {
569442
+ lastAssistantMessage = msg;
569443
+ break;
569444
+ }
569445
+ }
569446
+ if (!lastAssistantMessage) {
569447
+ const errorMessage = {
569448
+ role: "command",
569449
+ content: t.commandPanel.copyLastFeedback.noAssistantMessage,
569450
+ commandName
569451
+ };
569452
+ options3.setMessages((prev) => [...prev, errorMessage]);
569453
+ return;
569454
+ }
569455
+ const contentToCopy = lastAssistantMessage.content || "";
569456
+ if (!contentToCopy) {
569457
+ const errorMessage = {
569458
+ role: "command",
569459
+ content: t.commandPanel.copyLastFeedback.emptyAssistantMessage,
569460
+ commandName
569461
+ };
569462
+ options3.setMessages((prev) => [...prev, errorMessage]);
569463
+ return;
569464
+ }
569465
+ await copyToClipboard(contentToCopy);
569466
+ const successMessage = {
569467
+ role: "command",
569468
+ content: t.commandPanel.copyLastFeedback.copySuccess,
569469
+ commandName
569470
+ };
569471
+ options3.setMessages((prev) => [...prev, successMessage]);
569472
+ } catch (error) {
569473
+ const errorMsg = error instanceof Error ? error.message : t.commandPanel.copyLastFeedback.unknownError;
569474
+ const errorMessage = {
569475
+ role: "command",
569476
+ content: `${t.commandPanel.copyLastFeedback.copyFailedPrefix}: ${errorMsg}`,
569477
+ commandName
569478
+ };
569479
+ options3.setMessages((prev) => [...prev, errorMessage]);
569480
+ }
568816
569481
  } else if (result2.success && result2.action === "toggleCodebase") {
568817
569482
  if (options3.onToggleCodebase) {
568818
569483
  try {
@@ -568835,7 +569500,7 @@ ${filePath}`,
568835
569500
  };
568836
569501
  options3.setMessages((prev) => [...prev, commandMessage]);
568837
569502
  }
568838
- }, [stdout, options3]);
569503
+ }, [stdout, options3, t]);
568839
569504
  return { handleCommandExecution };
568840
569505
  }
568841
569506
  var import_react137;
@@ -568851,6 +569516,8 @@ var init_useCommandHandler = __esm({
568851
569516
  init_terminal();
568852
569517
  init_fileDialog();
568853
569518
  init_chatExporter();
569519
+ init_clipboard();
569520
+ init_i18n();
568854
569521
  }
568855
569522
  });
568856
569523
 
@@ -577703,14 +578370,14 @@ var MCPConfigScreen_exports = {};
577703
578370
  __export(MCPConfigScreen_exports, {
577704
578371
  default: () => MCPConfigScreen
577705
578372
  });
577706
- import { spawn as spawn11, execSync as execSync7 } from "child_process";
578373
+ import { spawn as spawn11, execSync as execSync8 } from "child_process";
577707
578374
  import { writeFileSync as writeFileSync14, readFileSync as readFileSync22, existsSync as existsSync26 } from "fs";
577708
578375
  import { join as join31 } from "path";
577709
578376
  import { homedir as homedir18, platform as platform5 } from "os";
577710
578377
  function checkCommandExists3(command) {
577711
578378
  if (platform5() === "win32") {
577712
578379
  try {
577713
- execSync7(`where ${command}`, {
578380
+ execSync8(`where ${command}`, {
577714
578381
  stdio: "ignore",
577715
578382
  windowsHide: true
577716
578383
  });
@@ -577722,7 +578389,7 @@ function checkCommandExists3(command) {
577722
578389
  const shells = ["/bin/sh", "/bin/bash", "/bin/zsh"];
577723
578390
  for (const shell of shells) {
577724
578391
  try {
577725
- execSync7(`command -v ${command}`, {
578392
+ execSync8(`command -v ${command}`, {
577726
578393
  stdio: "ignore",
577727
578394
  shell,
577728
578395
  env: process.env
@@ -578310,7 +578977,7 @@ __export(sseDaemon_exports, {
578310
578977
  startDaemon: () => startDaemon,
578311
578978
  stopDaemon: () => stopDaemon
578312
578979
  });
578313
- import { spawn as spawn12, execSync as execSync8 } from "child_process";
578980
+ import { spawn as spawn12, execSync as execSync9 } from "child_process";
578314
578981
  import { existsSync as existsSync27, readFileSync as readFileSync23, writeFileSync as writeFileSync15, unlinkSync as unlinkSync4, readdirSync as readdirSync4, mkdirSync as mkdirSync13 } from "fs";
578315
578982
  import { join as join32 } from "path";
578316
578983
  import { homedir as homedir19 } from "os";
@@ -578482,7 +579149,7 @@ function killProcess(pid, pidFile) {
578482
579149
  try {
578483
579150
  if (process.platform === "win32") {
578484
579151
  try {
578485
- execSync8(`taskkill /PID ${pid} /T /F`, { stdio: "ignore" });
579152
+ execSync9(`taskkill /PID ${pid} /T /F`, { stdio: "ignore" });
578486
579153
  console.log(t.daemonStopped);
578487
579154
  } catch (error) {
578488
579155
  try {