snow-ai 0.5.3 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bundle/cli.mjs +198 -47
  2. package/package.json +1 -1
package/bundle/cli.mjs CHANGED
@@ -47397,6 +47397,23 @@ var init_en = __esm({
47397
47397
  timeout: "Timeout:",
47398
47398
  customTimeout: "(custom)"
47399
47399
  },
47400
+ fileRollback: {
47401
+ title: "File Rollback Confirmation",
47402
+ description: "This checkpoint has",
47403
+ question: "Do you want to rollback the files as well?",
47404
+ yesRollbackFiles: "Yes, rollback files and conversation",
47405
+ noConversationOnly: "No, rollback conversation only",
47406
+ moreAbove: "more above...",
47407
+ moreBelow: "more below...",
47408
+ andMoreFiles: "and",
47409
+ viewAllHint: "Tab view all",
47410
+ selectHint: "\u2191\u2193 select",
47411
+ confirmHint: "Enter confirm",
47412
+ cancelHint: "ESC cancel",
47413
+ scrollHint: "\u2191\u2193 scroll",
47414
+ backHint: "Tab back",
47415
+ closeHint: "ESC close"
47416
+ },
47400
47417
  usagePanel: {
47401
47418
  title: "Token Usage Statistics",
47402
47419
  granularity: {
@@ -48243,6 +48260,23 @@ var init_zh = __esm({
48243
48260
  timeout: "\u8D85\u65F6\u65F6\u95F4:",
48244
48261
  customTimeout: "(\u81EA\u5B9A\u4E49)"
48245
48262
  },
48263
+ fileRollback: {
48264
+ title: "\u6587\u4EF6\u56DE\u6EDA\u786E\u8BA4",
48265
+ description: "\u6B64\u68C0\u67E5\u70B9\u5305\u542B",
48266
+ question: "\u662F\u5426\u540C\u65F6\u56DE\u6EDA\u6587\u4EF6\uFF1F",
48267
+ yesRollbackFiles: "\u662F\uFF0C\u56DE\u6EDA\u6587\u4EF6\u548C\u5BF9\u8BDD",
48268
+ noConversationOnly: "\u5426\uFF0C\u4EC5\u56DE\u6EDA\u5BF9\u8BDD",
48269
+ moreAbove: "\u66F4\u591A...",
48270
+ moreBelow: "\u66F4\u591A...",
48271
+ andMoreFiles: "\u4EE5\u53CA",
48272
+ viewAllHint: "Tab \u67E5\u770B\u5168\u90E8",
48273
+ selectHint: "\u2191\u2193 \u9009\u62E9",
48274
+ confirmHint: "Enter \u786E\u8BA4",
48275
+ cancelHint: "ESC \u53D6\u6D88",
48276
+ scrollHint: "\u2191\u2193 \u6EDA\u52A8",
48277
+ backHint: "Tab \u8FD4\u56DE",
48278
+ closeHint: "ESC \u5173\u95ED"
48279
+ },
48246
48280
  usagePanel: {
48247
48281
  title: "Token \u4F7F\u7528\u7EDF\u8BA1",
48248
48282
  granularity: {
@@ -49088,6 +49122,23 @@ var init_zh_TW = __esm({
49088
49122
  timeout: "\u903E\u6642\u6642\u9593:",
49089
49123
  customTimeout: "(\u81EA\u8A02)"
49090
49124
  },
49125
+ fileRollback: {
49126
+ title: "\u6A94\u6848\u56DE\u6EFE\u78BA\u8A8D",
49127
+ description: "\u6B64\u6AA2\u67E5\u9EDE\u5305\u542B",
49128
+ question: "\u662F\u5426\u540C\u6642\u56DE\u6EFE\u6A94\u6848\uFF1F",
49129
+ yesRollbackFiles: "\u662F\uFF0C\u56DE\u6EFE\u6A94\u6848\u548C\u5C0D\u8A71",
49130
+ noConversationOnly: "\u5426\uFF0C\u50C5\u56DE\u6EFE\u5C0D\u8A71",
49131
+ moreAbove: "\u66F4\u591A...",
49132
+ moreBelow: "\u66F4\u591A...",
49133
+ andMoreFiles: "\u4EE5\u53CA",
49134
+ viewAllHint: "Tab \u67E5\u770B\u5168\u90E8",
49135
+ selectHint: "\u2191\u2193 \u9078\u64C7",
49136
+ confirmHint: "Enter \u78BA\u8A8D",
49137
+ cancelHint: "ESC \u53D6\u6D88",
49138
+ scrollHint: "\u2191\u2193 \u6EFE\u52D5",
49139
+ backHint: "Tab \u8FD4\u56DE",
49140
+ closeHint: "ESC \u95DC\u9589"
49141
+ },
49091
49142
  usagePanel: {
49092
49143
  title: "Token \u4F7F\u7528\u7D71\u8A08",
49093
49144
  granularity: {
@@ -49929,6 +49980,23 @@ var init_ja = __esm({
49929
49980
  timeout: "\u30BF\u30A4\u30E0\u30A2\u30A6\u30C8:",
49930
49981
  customTimeout: "(\u30AB\u30B9\u30BF\u30E0)"
49931
49982
  },
49983
+ fileRollback: {
49984
+ title: "\u30D5\u30A1\u30A4\u30EB\u30ED\u30FC\u30EB\u30D0\u30C3\u30AF\u78BA\u8A8D",
49985
+ description: "\u3053\u306E\u30C1\u30A7\u30C3\u30AF\u30DD\u30A4\u30F3\u30C8\u306B\u306F",
49986
+ question: "\u30D5\u30A1\u30A4\u30EB\u3082\u30ED\u30FC\u30EB\u30D0\u30C3\u30AF\u3057\u307E\u3059\u304B\uFF1F",
49987
+ yesRollbackFiles: "\u306F\u3044\u3001\u30D5\u30A1\u30A4\u30EB\u3068\u4F1A\u8A71\u3092\u30ED\u30FC\u30EB\u30D0\u30C3\u30AF",
49988
+ noConversationOnly: "\u3044\u3044\u3048\u3001\u4F1A\u8A71\u306E\u307F\u30ED\u30FC\u30EB\u30D0\u30C3\u30AF",
49989
+ moreAbove: "\u4E0A\u306B\u3082\u3063\u3068...",
49990
+ moreBelow: "\u4E0B\u306B\u3082\u3063\u3068...",
49991
+ andMoreFiles: "\u304A\u3088\u3073",
49992
+ viewAllHint: "Tab \u3059\u3079\u3066\u8868\u793A",
49993
+ selectHint: "\u2191\u2193 \u9078\u629E",
49994
+ confirmHint: "Enter \u78BA\u8A8D",
49995
+ cancelHint: "ESC \u30AD\u30E3\u30F3\u30BB\u30EB",
49996
+ scrollHint: "\u2191\u2193 \u30B9\u30AF\u30ED\u30FC\u30EB",
49997
+ backHint: "Tab \u623B\u308B",
49998
+ closeHint: "ESC \u9589\u3058\u308B"
49999
+ },
49932
50000
  usagePanel: {
49933
50001
  title: "\u30C8\u30FC\u30AF\u30F3\u4F7F\u7528\u7D71\u8A08",
49934
50002
  granularity: {
@@ -50770,6 +50838,23 @@ var init_ko = __esm({
50770
50838
  timeout: "\uD0C0\uC784\uC544\uC6C3:",
50771
50839
  customTimeout: "(\uC0AC\uC6A9\uC790 \uC9C0\uC815)"
50772
50840
  },
50841
+ fileRollback: {
50842
+ title: "\uD30C\uC77C \uB864\uBC31 \uD655\uC778",
50843
+ description: "\uC774 \uCCB4\uD06C\uD3EC\uC778\uD2B8\uC5D0\uB294",
50844
+ question: "\uD30C\uC77C\uB3C4 \uB864\uBC31\uD558\uC2DC\uACA0\uC2B5\uB2C8\uAE4C?",
50845
+ yesRollbackFiles: "\uC608, \uD30C\uC77C\uACFC \uB300\uD654 \uB864\uBC31",
50846
+ noConversationOnly: "\uC544\uB2C8\uC694, \uB300\uD654\uB9CC \uB864\uBC31",
50847
+ moreAbove: "\uC704\uC5D0 \uB354 \uB9CE\uC774...",
50848
+ moreBelow: "\uC544\uB798\uC5D0 \uB354 \uB9CE\uC774...",
50849
+ andMoreFiles: "\uBC0F",
50850
+ viewAllHint: "Tab \uC804\uCCB4 \uBCF4\uAE30",
50851
+ selectHint: "\u2191\u2193 \uC120\uD0DD",
50852
+ confirmHint: "Enter \uD655\uC778",
50853
+ cancelHint: "ESC \uCDE8\uC18C",
50854
+ scrollHint: "\u2191\u2193 \uC2A4\uD06C\uB864",
50855
+ backHint: "Tab \uB3CC\uC544\uAC00\uAE30",
50856
+ closeHint: "ESC \uB2EB\uAE30"
50857
+ },
50773
50858
  usagePanel: {
50774
50859
  title: "\uD1A0\uD070 \uC0AC\uC6A9 \uD1B5\uACC4",
50775
50860
  granularity: {
@@ -51611,6 +51696,23 @@ var init_es = __esm({
51611
51696
  timeout: "Tiempo l\xEDmite:",
51612
51697
  customTimeout: "(personalizado)"
51613
51698
  },
51699
+ fileRollback: {
51700
+ title: "Confirmaci\xF3n de Reversi\xF3n de Archivos",
51701
+ description: "Este punto de control tiene",
51702
+ question: "\xBFDesea revertir los archivos tambi\xE9n?",
51703
+ yesRollbackFiles: "S\xED, revertir archivos y conversaci\xF3n",
51704
+ noConversationOnly: "No, revertir solo conversaci\xF3n",
51705
+ moreAbove: "m\xE1s arriba...",
51706
+ moreBelow: "m\xE1s abajo...",
51707
+ andMoreFiles: "y",
51708
+ viewAllHint: "Tab ver todos",
51709
+ selectHint: "\u2191\u2193 seleccionar",
51710
+ confirmHint: "Enter confirmar",
51711
+ cancelHint: "ESC cancelar",
51712
+ scrollHint: "\u2191\u2193 desplazar",
51713
+ backHint: "Tab volver",
51714
+ closeHint: "ESC cerrar"
51715
+ },
51614
51716
  usagePanel: {
51615
51717
  title: "Estad\xEDsticas de Uso de Tokens",
51616
51718
  granularity: {
@@ -425873,9 +425975,9 @@ var init_codebaseSearch = __esm({
425873
425975
  return dotProduct / (Math.sqrt(normA) * Math.sqrt(normB));
425874
425976
  }
425875
425977
  /**
425876
- * Search codebase using semantic similarity with retry logic
425877
- */
425878
- async search(query, topN = 10) {
425978
+ * Search codebase using semantic similarity with retry logic
425979
+ */
425980
+ async search(query, topN = 10, abortSignal) {
425879
425981
  const config3 = loadCodebaseConfig();
425880
425982
  const enableAgentReview = config3.enableAgentReview;
425881
425983
  const { available, reason } = await this.isCodebaseIndexAvailable();
@@ -425943,7 +426045,7 @@ var init_codebaseSearch = __esm({
425943
426045
  role: msg.role,
425944
426046
  content: msg.content
425945
426047
  })).slice(-10)) || [];
425946
- const reviewResult = await codebaseReviewAgent.reviewResults(query, formattedResults, conversationContext.length > 0 ? conversationContext : void 0);
426048
+ const reviewResult = await codebaseReviewAgent.reviewResults(query, formattedResults, conversationContext.length > 0 ? conversationContext : void 0, abortSignal);
425947
426049
  finalResults = reviewResult.filteredResults;
425948
426050
  reviewFailed = reviewResult.reviewFailed || false;
425949
426051
  removedCount = reviewResult.removedCount;
@@ -433746,7 +433848,7 @@ AI Tip: Provide searchContent (string) and replaceContent (string).`);
433746
433848
  const { codebaseSearchService: codebaseSearchService2 } = await Promise.resolve().then(() => (init_codebaseSearch(), codebaseSearch_exports));
433747
433849
  switch (actualToolName) {
433748
433850
  case "search":
433749
- result2 = await codebaseSearchService2.search(args2.query, args2.topN);
433851
+ result2 = await codebaseSearchService2.search(args2.query, args2.topN, abortSignal);
433750
433852
  break;
433751
433853
  default:
433752
433854
  throw new Error(`Unknown codebase tool: ${actualToolName}`);
@@ -433839,9 +433941,13 @@ ${combinedOutput}`);
433839
433941
  async function executeOnExternalMCPService(serviceName, server, toolName, args2) {
433840
433942
  const client = await getPersistentClient(serviceName, server);
433841
433943
  logger.debug(`Using persistent MCP client for ${serviceName} tool ${toolName}`);
433944
+ const timeout2 = server.timeout ?? 3e5;
433842
433945
  const result2 = await client.callTool({
433843
433946
  name: toolName,
433844
433947
  arguments: args2
433948
+ }, void 0, {
433949
+ timeout: timeout2,
433950
+ resetTimeoutOnProgress: true
433845
433951
  });
433846
433952
  logger.debug(`result from ${serviceName} tool ${toolName}:`, result2);
433847
433953
  return result2.content;
@@ -440559,7 +440665,7 @@ function useKeyboardInput(options3) {
440559
440665
  }
440560
440666
  return;
440561
440667
  }
440562
- const isProfileSwitchShortcut = process.platform === "win32" ? key.meta && input2 === "p" : key.ctrl && input2 === "p";
440668
+ const isProfileSwitchShortcut = process.platform === "darwin" ? key.ctrl && input2 === "p" : key.meta && input2 === "p";
440563
440669
  if (isProfileSwitchShortcut) {
440564
440670
  if (onSwitchProfile) {
440565
440671
  onSwitchProfile();
@@ -446372,12 +446478,13 @@ var init_BashCommandConfirmation = __esm({
446372
446478
 
446373
446479
  // dist/ui/components/tools/FileRollbackConfirmation.js
446374
446480
  function FileRollbackConfirmation({ fileCount, filePaths, onConfirm }) {
446481
+ const { t } = useI18n();
446375
446482
  const [selectedIndex, setSelectedIndex] = (0, import_react98.useState)(0);
446376
446483
  const [showFullList, setShowFullList] = (0, import_react98.useState)(false);
446377
446484
  const [fileScrollIndex, setFileScrollIndex] = (0, import_react98.useState)(0);
446378
446485
  const options3 = [
446379
- { label: "Yes, rollback files and conversation", value: true },
446380
- { label: "No, rollback conversation only", value: false }
446486
+ { label: t.fileRollback.yesRollbackFiles, value: true },
446487
+ { label: t.fileRollback.noConversationOnly, value: false }
446381
446488
  ];
446382
446489
  use_input_default((_3, key) => {
446383
446490
  var _a21;
@@ -446433,7 +446540,12 @@ function FileRollbackConfirmation({ fileCount, filePaths, onConfirm }) {
446433
446540
  import_react98.default.createElement(
446434
446541
  Box_default,
446435
446542
  { marginBottom: 1 },
446436
- import_react98.default.createElement(Text, { color: "yellow", bold: true }, "\u26A0 File Rollback Confirmation")
446543
+ import_react98.default.createElement(
446544
+ Text,
446545
+ { color: "yellow", bold: true },
446546
+ "\u26A0 ",
446547
+ t.fileRollback.title
446548
+ )
446437
446549
  ),
446438
446550
  import_react98.default.createElement(
446439
446551
  Box_default,
@@ -446441,7 +446553,8 @@ function FileRollbackConfirmation({ fileCount, filePaths, onConfirm }) {
446441
446553
  import_react98.default.createElement(
446442
446554
  Text,
446443
446555
  { color: "white" },
446444
- "This checkpoint has ",
446556
+ t.fileRollback.description,
446557
+ " ",
446445
446558
  fileCount,
446446
446559
  " file",
446447
446560
  fileCount > 1 ? "s" : "",
@@ -446456,7 +446569,8 @@ function FileRollbackConfirmation({ fileCount, filePaths, onConfirm }) {
446456
446569
  { color: "gray", dimColor: true },
446457
446570
  "\u2191 ",
446458
446571
  fileScrollIndex,
446459
- " more above..."
446572
+ " ",
446573
+ t.fileRollback.moreAbove
446460
446574
  ),
446461
446575
  displayFiles.map((file, index) => import_react98.default.createElement(
446462
446576
  Text,
@@ -446469,12 +446583,15 @@ function FileRollbackConfirmation({ fileCount, filePaths, onConfirm }) {
446469
446583
  { color: "gray", dimColor: true },
446470
446584
  "\u2193 ",
446471
446585
  filePaths.length - (fileScrollIndex + maxFilesToShowFull),
446472
- " more below..."
446586
+ " ",
446587
+ t.fileRollback.moreBelow
446473
446588
  ),
446474
446589
  !showFullList && remainingCountCompact > 0 && import_react98.default.createElement(
446475
446590
  Text,
446476
446591
  { color: "gray", dimColor: true },
446477
- "... and ",
446592
+ "... ",
446593
+ t.fileRollback.andMoreFiles,
446594
+ " ",
446478
446595
  remainingCountCompact,
446479
446596
  " more file",
446480
446597
  remainingCountCompact > 1 ? "s" : ""
@@ -446486,7 +446603,7 @@ function FileRollbackConfirmation({ fileCount, filePaths, onConfirm }) {
446486
446603
  import_react98.default.createElement(
446487
446604
  Box_default,
446488
446605
  { marginBottom: 1 },
446489
- import_react98.default.createElement(Text, { color: "gray", dimColor: true }, "Do you want to rollback the files as well?")
446606
+ import_react98.default.createElement(Text, { color: "gray", dimColor: true }, t.fileRollback.question)
446490
446607
  ),
446491
446608
  import_react98.default.createElement(Box_default, { flexDirection: "column", marginBottom: 1 }, options3.map((option, index) => import_react98.default.createElement(
446492
446609
  Box_default,
@@ -446502,7 +446619,7 @@ function FileRollbackConfirmation({ fileCount, filePaths, onConfirm }) {
446502
446619
  import_react98.default.createElement(
446503
446620
  Box_default,
446504
446621
  null,
446505
- import_react98.default.createElement(Text, { color: "gray", dimColor: true }, showFullList ? "\u2191\u2193 scroll \xB7 Tab back \xB7 ESC close" : fileCount > maxFilesToShowCompact ? `\u2191\u2193 select \xB7 Tab view all (${fileCount} files) \xB7 Enter confirm \xB7 ESC cancel` : "\u2191\u2193 select \xB7 Enter confirm \xB7 ESC cancel")
446622
+ import_react98.default.createElement(Text, { color: "gray", dimColor: true }, showFullList ? `${t.fileRollback.scrollHint} \xB7 ${t.fileRollback.backHint} \xB7 ${t.fileRollback.closeHint}` : fileCount > maxFilesToShowCompact ? `${t.fileRollback.selectHint} \xB7 ${t.fileRollback.viewAllHint} (${fileCount} files) \xB7 ${t.fileRollback.confirmHint} \xB7 ${t.fileRollback.cancelHint}` : `${t.fileRollback.selectHint} \xB7 ${t.fileRollback.confirmHint} \xB7 ${t.fileRollback.cancelHint}`)
446506
446623
  )
446507
446624
  );
446508
446625
  }
@@ -446512,6 +446629,7 @@ var init_FileRollbackConfirmation = __esm({
446512
446629
  "use strict";
446513
446630
  import_react98 = __toESM(require_react(), 1);
446514
446631
  await init_build2();
446632
+ init_I18nContext();
446515
446633
  }
446516
446634
  });
446517
446635
 
@@ -522124,7 +522242,7 @@ var init_StatusLine = __esm({
522124
522242
  init_i18n();
522125
522243
  init_ThemeContext();
522126
522244
  init_themeConfig();
522127
- getProfileShortcut = () => process.platform === "win32" ? "Alt+P" : "Ctrl+P";
522245
+ getProfileShortcut = () => process.platform === "darwin" ? "Ctrl+P" : "Alt+P";
522128
522246
  }
522129
522247
  });
522130
522248
 
@@ -523811,40 +523929,80 @@ function findPreserveStartIndex(messages) {
523811
523929
  return messages.length;
523812
523930
  }
523813
523931
  function cleanOrphanedToolCalls(messages) {
523814
- const toolResultIds = /* @__PURE__ */ new Set();
523815
- for (const msg of messages) {
523816
- if (msg.role === "tool" && msg.tool_call_id) {
523817
- toolResultIds.add(msg.tool_call_id);
523818
- }
523819
- }
523820
- const declaredToolCallIds = /* @__PURE__ */ new Set();
523821
- for (const msg of messages) {
523822
- if (msg.role === "assistant" && msg.tool_calls) {
523823
- for (const tc of msg.tool_calls) {
523824
- declaredToolCallIds.add(tc.id);
523825
- }
523826
- }
523827
- }
523828
523932
  const indicesToRemove = [];
523829
- for (let i = messages.length - 1; i >= 0; i--) {
523933
+ for (let i = 0; i < messages.length; i++) {
523830
523934
  const msg = messages[i];
523831
523935
  if (!msg)
523832
523936
  continue;
523833
- if (msg.role === "assistant" && msg.tool_calls) {
523834
- const hasAllResults = msg.tool_calls.every((tc) => toolResultIds.has(tc.id));
523835
- if (!hasAllResults) {
523836
- const orphanedIds = msg.tool_calls.filter((tc) => !toolResultIds.has(tc.id)).map((tc) => tc.id);
523837
- console.warn("[contextCompressor:cleanOrphanedToolCalls] Removing assistant message with orphaned tool_calls", {
523937
+ if (msg.role === "assistant" && msg.tool_calls && msg.tool_calls.length > 0) {
523938
+ const nextMsg = messages[i + 1];
523939
+ if (!nextMsg || nextMsg.role !== "tool") {
523940
+ console.warn("[contextCompressor:cleanOrphanedToolCalls] Removing assistant message - next message is not tool result", {
523838
523941
  messageIndex: i,
523839
523942
  toolCallIds: msg.tool_calls.map((tc) => tc.id),
523840
- orphanedIds
523943
+ nextMessageRole: (nextMsg == null ? void 0 : nextMsg.role) || "none"
523944
+ });
523945
+ indicesToRemove.push(i);
523946
+ continue;
523947
+ }
523948
+ const expectedToolCallIds = new Set(msg.tool_calls.map((tc) => tc.id));
523949
+ const foundToolCallIds = /* @__PURE__ */ new Set();
523950
+ for (let j = i + 1; j < messages.length; j++) {
523951
+ const followingMsg = messages[j];
523952
+ if (!followingMsg)
523953
+ continue;
523954
+ if (followingMsg.role === "tool") {
523955
+ if (followingMsg.tool_call_id) {
523956
+ foundToolCallIds.add(followingMsg.tool_call_id);
523957
+ }
523958
+ } else {
523959
+ break;
523960
+ }
523961
+ }
523962
+ const missingIds = Array.from(expectedToolCallIds).filter((id) => !foundToolCallIds.has(id));
523963
+ if (missingIds.length > 0) {
523964
+ console.warn("[contextCompressor:cleanOrphanedToolCalls] Removing assistant message - missing immediate tool results", {
523965
+ messageIndex: i,
523966
+ toolCallIds: msg.tool_calls.map((tc) => tc.id),
523967
+ missingIds
523841
523968
  });
523842
523969
  indicesToRemove.push(i);
523843
523970
  }
523844
523971
  }
523845
523972
  if (msg.role === "tool" && msg.tool_call_id) {
523846
- if (!declaredToolCallIds.has(msg.tool_call_id)) {
523847
- console.warn("[contextCompressor:cleanOrphanedToolCalls] Removing orphaned tool result", {
523973
+ let foundCorrespondingAssistant = false;
523974
+ for (let j = i - 1; j >= 0; j--) {
523975
+ const prevMsg = messages[j];
523976
+ if (!prevMsg)
523977
+ continue;
523978
+ if (prevMsg.role === "assistant" && prevMsg.tool_calls) {
523979
+ const hasToolCall = prevMsg.tool_calls.some((tc) => tc.id === msg.tool_call_id);
523980
+ if (hasToolCall) {
523981
+ foundCorrespondingAssistant = true;
523982
+ let isImmediatelyAfter = true;
523983
+ for (let k = j + 1; k < i; k++) {
523984
+ const betweenMsg = messages[k];
523985
+ if (betweenMsg && betweenMsg.role !== "tool") {
523986
+ isImmediatelyAfter = false;
523987
+ break;
523988
+ }
523989
+ }
523990
+ if (!isImmediatelyAfter) {
523991
+ console.warn("[contextCompressor:cleanOrphanedToolCalls] Removing tool result - not immediately after assistant", {
523992
+ messageIndex: i,
523993
+ toolCallId: msg.tool_call_id,
523994
+ assistantIndex: j
523995
+ });
523996
+ indicesToRemove.push(i);
523997
+ }
523998
+ break;
523999
+ }
524000
+ } else if (prevMsg.role !== "tool") {
524001
+ break;
524002
+ }
524003
+ }
524004
+ if (!foundCorrespondingAssistant) {
524005
+ console.warn("[contextCompressor:cleanOrphanedToolCalls] Removing orphaned tool result - no corresponding assistant", {
523848
524006
  messageIndex: i,
523849
524007
  toolCallId: msg.tool_call_id
523850
524008
  });
@@ -523852,6 +524010,7 @@ function cleanOrphanedToolCalls(messages) {
523852
524010
  }
523853
524011
  }
523854
524012
  }
524013
+ indicesToRemove.sort((a, b) => b - a);
523855
524014
  for (const idx2 of indicesToRemove) {
523856
524015
  messages.splice(idx2, 1);
523857
524016
  }
@@ -525604,14 +525763,6 @@ async function handleConversationWithTools(options3) {
525604
525763
  );
525605
525764
  if (controller.signal.aborted) {
525606
525765
  if (receivedToolCalls && receivedToolCalls.length > 0) {
525607
- const assistantMsgWithTools = conversationMessages.find((msg) => msg.role === "assistant" && msg.tool_calls && msg.tool_calls.some((tc) => receivedToolCalls.some((rtc) => rtc.id === tc.id)));
525608
- if (assistantMsgWithTools) {
525609
- try {
525610
- await saveMessage(assistantMsgWithTools);
525611
- } catch (error) {
525612
- console.error("Failed to save assistant message before abort:", error);
525613
- }
525614
- }
525615
525766
  for (const toolCall of receivedToolCalls) {
525616
525767
  const abortedResult = {
525617
525768
  role: "tool",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-ai",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "description": "Intelligent Command Line Assistant powered by AI",
5
5
  "license": "MIT",
6
6
  "bin": {