@qwen-code/qwen-code 0.18.2 → 0.18.3-nightly.20260618.bc3e0b405

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 (36) hide show
  1. package/chunks/{agent-P5U6QLWL.js → agent-ACIWYWX7.js} +2 -2
  2. package/chunks/{agent-headless-24356DC7.js → agent-headless-3OQZEB2S.js} +2 -2
  3. package/chunks/{chunk-JZEKEWO5.js → chunk-753BG2JJ.js} +3 -3
  4. package/chunks/{chunk-25FFAMED.js → chunk-BPJAFPPD.js} +3 -3
  5. package/chunks/{chunk-EQ5NHJBY.js → chunk-RMFCNRER.js} +110575 -109595
  6. package/chunks/{chunk-M7OBURJM.js → chunk-SWMGBYC2.js} +1 -1
  7. package/chunks/{chunk-NGDXHX3A.js → chunk-UIH54N5X.js} +1 -1
  8. package/chunks/{chunk-QFJ67S5R.js → chunk-XFUQS3BO.js} +5 -5
  9. package/chunks/{computer-use-EGW2I2HZ.js → computer-use-Y3INMFGQ.js} +2 -2
  10. package/chunks/{contextCommand-HI2X2Y7I.js → contextCommand-4AF56TE5.js} +4 -4
  11. package/chunks/{edit-FJSOCDO2.js → edit-MO45GCL7.js} +4 -6
  12. package/chunks/{enter-worktree-X6MVFDLR.js → enter-worktree-Z3JI6PAT.js} +2 -2
  13. package/chunks/{enterPlanMode-MZAEQZH3.js → enterPlanMode-IK6VOFTA.js} +2 -2
  14. package/chunks/{exit-worktree-RM2UPOYQ.js → exit-worktree-N7VFZX2L.js} +2 -2
  15. package/chunks/{exitPlanMode-7BVY3CWJ.js → exitPlanMode-I3KHESPG.js} +6 -5
  16. package/chunks/{geminiContentGenerator-A6JHLUHK.js → geminiContentGenerator-SCL4XVAS.js} +1 -1
  17. package/chunks/{glob-L3AZLCV6.js → glob-F2B2SE3K.js} +2 -2
  18. package/chunks/{grep-SNCPCXIP.js → grep-4KQWN26D.js} +2 -2
  19. package/chunks/{monitor-TS6WL6DN.js → monitor-JLANELR3.js} +2 -2
  20. package/chunks/{notebook-edit-26RNH24J.js → notebook-edit-HDRKPHHG.js} +3 -5
  21. package/chunks/{openaiContentGenerator-7CA63X5G.js → openaiContentGenerator-BKTFJC2S.js} +2 -2
  22. package/chunks/{qwenContentGenerator-4WJTJXFZ.js → qwenContentGenerator-62BVT57E.js} +3 -3
  23. package/chunks/{read-file-EUIHK6HD.js → read-file-SFLRS3OC.js} +1 -1
  24. package/chunks/{ripGrep-7J5B22W2.js → ripGrep-H2MU4MC3.js} +2 -2
  25. package/chunks/{scheduler-J3OUGTTS.js → scheduler-2GZTWP5S.js} +2 -2
  26. package/chunks/{serve-VF4ZNUJP.js → serve-SYMKDBDG.js} +4 -4
  27. package/chunks/{shell-G6XCJAG3.js → shell-U46KHTLY.js} +2 -2
  28. package/chunks/{skill-7OVC6JIH.js → skill-VQMJOXNY.js} +1 -1
  29. package/chunks/{src-XV5MLRND.js → src-YBSBZZEL.js} +2 -2
  30. package/chunks/{team-create-JXSC7ROC.js → team-create-OA3IGBCE.js} +2 -2
  31. package/chunks/{tool-search-YRWSWA2H.js → tool-search-A57VE2JF.js} +1 -1
  32. package/chunks/{workflow-ZN3DYFMU.js → workflow-RWXT7YIU.js} +3 -3
  33. package/chunks/{write-file-355M4V7Z.js → write-file-46RW6BV4.js} +4 -6
  34. package/cli.js +246 -61
  35. package/package.json +2 -2
  36. package/chunks/chunk-C64WAJOC.js +0 -117
package/cli.js CHANGED
@@ -92,7 +92,7 @@ import {
92
92
  updateOutputLanguageFile,
93
93
  validateCustomTheme,
94
94
  writeOutputLanguageAndRegisterPath
95
- } from "./chunks/chunk-QFJ67S5R.js";
95
+ } from "./chunks/chunk-XFUQS3BO.js";
96
96
  import {
97
97
  AgentSideConnection,
98
98
  PROTOCOL_VERSION,
@@ -105,7 +105,7 @@ import {
105
105
  formatContextUsageText,
106
106
  isTerminalGoalStatusKind,
107
107
  require_react
108
- } from "./chunks/chunk-JZEKEWO5.js";
108
+ } from "./chunks/chunk-753BG2JJ.js";
109
109
  import {
110
110
  SUPPORTED_LANGUAGES,
111
111
  clearScreen,
@@ -118,7 +118,7 @@ import {
118
118
  ta,
119
119
  writeStderrLine,
120
120
  writeStdoutLine
121
- } from "./chunks/chunk-M7OBURJM.js";
121
+ } from "./chunks/chunk-SWMGBYC2.js";
122
122
  import {
123
123
  noteInteraction
124
124
  } from "./chunks/chunk-MRO43B25.js";
@@ -342,7 +342,7 @@ import {
342
342
  writeRuntimeStatus,
343
343
  writeWorktreeSession,
344
344
  writeWorktreeSessionMarker
345
- } from "./chunks/chunk-EQ5NHJBY.js";
345
+ } from "./chunks/chunk-RMFCNRER.js";
346
346
  import {
347
347
  external_exports
348
348
  } from "./chunks/chunk-K5PGHDBN.js";
@@ -418,7 +418,7 @@ import {
418
418
  stripRuntimeSnapshotPrefix,
419
419
  uiTelemetryService,
420
420
  withInteractionSpan
421
- } from "./chunks/chunk-25FFAMED.js";
421
+ } from "./chunks/chunk-BPJAFPPD.js";
422
422
  import "./chunks/chunk-3PJXIDKI.js";
423
423
  import "./chunks/chunk-UWCTAVOD.js";
424
424
  import {
@@ -59189,7 +59189,7 @@ var serveCommand = {
59189
59189
  process.exit(1);
59190
59190
  }
59191
59191
  }
59192
- const { runQwenServe } = await import("./chunks/serve-VF4ZNUJP.js");
59192
+ const { runQwenServe } = await import("./chunks/serve-SYMKDBDG.js");
59193
59193
  try {
59194
59194
  await runQwenServe({
59195
59195
  port: argv.port,
@@ -72034,7 +72034,7 @@ async function extractMetadata(conversation, config) {
72034
72034
  const gitBranch = firstRecord?.gitBranch;
72035
72035
  let gitRepo;
72036
72036
  if (cwd5) {
72037
- const { getGitRepoName } = await import("./chunks/src-XV5MLRND.js");
72037
+ const { getGitRepoName } = await import("./chunks/src-YBSBZZEL.js");
72038
72038
  gitRepo = getGitRepoName(cwd5);
72039
72039
  }
72040
72040
  let model;
@@ -84233,7 +84233,7 @@ var SystemController = class extends BaseController {
84233
84233
  throw new Error("Request aborted");
84234
84234
  }
84235
84235
  try {
84236
- const mod = await import("./chunks/contextCommand-HI2X2Y7I.js");
84236
+ const mod = await import("./chunks/contextCommand-4AF56TE5.js");
84237
84237
  if (signal.aborted) {
84238
84238
  throw new Error("Request aborted");
84239
84239
  }
@@ -84759,11 +84759,13 @@ var PermissionController = class extends BaseController {
84759
84759
  label: "Deny",
84760
84760
  description: "Block this file edit"
84761
84761
  },
84762
- {
84763
- type: "modify",
84764
- label: "Review Changes",
84765
- description: "Review the proposed changes before applying"
84766
- }
84762
+ ...details["hideModify"] === true ? [] : [
84763
+ {
84764
+ type: "modify",
84765
+ label: "Review Changes",
84766
+ description: "Review the proposed changes before applying"
84767
+ }
84768
+ ]
84767
84769
  ];
84768
84770
  case "plan":
84769
84771
  return [
@@ -96892,7 +96894,7 @@ var ToolConfirmationMessage = /* @__PURE__ */ __name(({
96892
96894
  key: "Yes, allow always"
96893
96895
  });
96894
96896
  }
96895
- if ((!config.getIdeMode() || !isDiffingEnabled) && preferredEditor) {
96897
+ if (!confirmationDetails.hideModify && (!config.getIdeMode() || !isDiffingEnabled) && preferredEditor) {
96896
96898
  options.push({
96897
96899
  label: t("Modify with external editor"),
96898
96900
  value: "modify_with_editor" /* ModifyWithEditor */,
@@ -122011,6 +122013,10 @@ var PrepareLabel = import_react152.default.memo(_PrepareLabel);
122011
122013
  // packages/cli/src/ui/components/SuggestionsDisplay.tsx
122012
122014
  var import_jsx_runtime150 = __toESM(require_jsx_runtime(), 1);
122013
122015
  var MAX_SUGGESTIONS_TO_SHOW = 8;
122016
+ function normalizeDescription(description) {
122017
+ return description.replace(/\s+/g, " ").trim();
122018
+ }
122019
+ __name(normalizeDescription, "normalizeDescription");
122014
122020
  function SuggestionsDisplay({
122015
122021
  suggestions,
122016
122022
  activeIndex,
@@ -122087,7 +122093,7 @@ function SuggestionsDisplay({
122087
122093
  flexGrow: 1,
122088
122094
  flexShrink: 1,
122089
122095
  paddingLeft: 2,
122090
- children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(Text, { color: textColor, wrap: "wrap", children: suggestion.description })
122096
+ children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(Text, { color: textColor, wrap: "truncate-end", children: normalizeDescription(suggestion.description) })
122091
122097
  }
122092
122098
  ),
122093
122099
  isActive && isLong && /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(Box_default, { children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(Text, { color: Colors.Gray, children: isExpanded ? " \u2190 " : " \u2192 " }) })
@@ -143744,9 +143750,10 @@ __name(toPermissionOptions, "toPermissionOptions");
143744
143750
  // packages/cli/src/acp-integration/session/SubAgentTracker.ts
143745
143751
  var debugLogger75 = createDebugLogger("ACP_SUBAGENT_TRACKER");
143746
143752
  var SubAgentTracker = class {
143747
- constructor(ctx, client, parentToolCallId, subagentType) {
143753
+ constructor(ctx, client, parentToolCallId, subagentType, onAskUserQuestionCancel) {
143748
143754
  this.ctx = ctx;
143749
143755
  this.client = client;
143756
+ this.onAskUserQuestionCancel = onAskUserQuestionCancel;
143750
143757
  this.toolCallEmitter = new ToolCallEmitter(ctx);
143751
143758
  this.messageEmitter = new MessageEmitter(ctx);
143752
143759
  this.subagentMeta = { parentToolCallId, subagentType };
@@ -143876,12 +143883,25 @@ var SubAgentTracker = class {
143876
143883
  await event.respond(outcome, {
143877
143884
  answers: "answers" in output ? output.answers : void 0
143878
143885
  });
143886
+ if (outcome === "cancel" /* Cancel */ && event.name === ToolNames.ASK_USER_QUESTION) {
143887
+ this.onAskUserQuestionCancel?.();
143888
+ }
143879
143889
  } catch (error) {
143880
143890
  debugLogger75.error(
143881
143891
  `Permission request failed for subagent tool ${event.name}:`,
143882
143892
  error
143883
143893
  );
143884
- await event.respond("cancel" /* Cancel */);
143894
+ if (event.name === ToolNames.ASK_USER_QUESTION) {
143895
+ this.onAskUserQuestionCancel?.();
143896
+ }
143897
+ try {
143898
+ await event.respond("cancel" /* Cancel */);
143899
+ } catch (respondError) {
143900
+ debugLogger75.error(
143901
+ `Failed to cancel subagent tool ${event.name} after permission request failure:`,
143902
+ respondError
143903
+ );
143904
+ }
143885
143905
  }
143886
143906
  };
143887
143907
  }
@@ -144247,6 +144267,7 @@ function maskApiKeyForDisplay(apiKey) {
144247
144267
  return `${trimmed.slice(0, 3)}...${trimmed.slice(-4)}`;
144248
144268
  }
144249
144269
  __name(maskApiKeyForDisplay, "maskApiKeyForDisplay");
144270
+ var ASK_USER_QUESTION_CANCEL_SKIP_MESSAGE = "Skipped because ask_user_question was cancelled before the user answered; user input is required before continuing.";
144250
144271
  var MID_TURN_QUEUE_DRAIN_TIMEOUT_MS = 2e3;
144251
144272
  var MID_TURN_QUEUE_DRAIN_MAX_TIMEOUT_STRIKES = 3;
144252
144273
  var MidTurnDrainTimeoutError = class extends Error {
@@ -145045,15 +145066,21 @@ ${this.pendingWorktreeNotice}
145045
145066
  );
145046
145067
  }
145047
145068
  if (functionCalls.length > 0) {
145048
- const toolResponseParts = await this.runToolCalls(
145069
+ const toolRun = await this.runToolCalls(
145049
145070
  pendingSend.signal,
145050
145071
  promptId,
145051
145072
  functionCalls
145052
145073
  );
145074
+ if (toolRun.stopAfterUserQuestionCancel) {
145075
+ await this.#preserveCancelledAskUserQuestionToolRun(
145076
+ toolRun
145077
+ );
145078
+ return { stopReason: "end_turn" };
145079
+ }
145053
145080
  nextMessage = {
145054
145081
  role: "user",
145055
145082
  parts: [
145056
- ...toolResponseParts,
145083
+ ...toolRun.parts,
145057
145084
  ...await this.#drainMidTurnUserMessages()
145058
145085
  ]
145059
145086
  };
@@ -145231,15 +145258,19 @@ ${this.pendingWorktreeNotice}
145231
145258
  );
145232
145259
  }
145233
145260
  if (functionCalls.length > 0) {
145234
- const toolResponseParts = await this.runToolCalls(
145261
+ const toolRun = await this.runToolCalls(
145235
145262
  pendingSend.signal,
145236
145263
  promptId,
145237
145264
  functionCalls
145238
145265
  );
145266
+ if (toolRun.stopAfterUserQuestionCancel) {
145267
+ await this.#preserveCancelledAskUserQuestionToolRun(toolRun);
145268
+ return { stopReason: "end_turn" };
145269
+ }
145239
145270
  nextMessage = {
145240
145271
  role: "user",
145241
145272
  parts: [
145242
- ...toolResponseParts,
145273
+ ...toolRun.parts,
145243
145274
  ...await this.#drainMidTurnUserMessages()
145244
145275
  ]
145245
145276
  };
@@ -145363,6 +145394,16 @@ ${this.pendingWorktreeNotice}
145363
145394
  });
145364
145395
  }
145365
145396
  }
145397
+ async #preserveCancelledAskUserQuestionToolRun(toolRun) {
145398
+ this.#preserveUnsentMessageHistory(
145399
+ {
145400
+ role: "user",
145401
+ parts: [...toolRun.parts, ...await this.#drainMidTurnUserMessages()]
145402
+ },
145403
+ true
145404
+ );
145405
+ await this.messageRewriter?.waitForPendingRewrites();
145406
+ }
145366
145407
  #recordCompressionTokenCount(info) {
145367
145408
  this.#syncPromptTokenCountWithCurrentChat();
145368
145409
  const tokenCount = this.#extractCompressionTokenCount(info);
@@ -145642,15 +145683,21 @@ ${this.pendingWorktreeNotice}
145642
145683
  );
145643
145684
  }
145644
145685
  if (functionCalls.length > 0) {
145645
- const toolResponseParts = await this.runToolCalls(
145686
+ const toolRun = await this.runToolCalls(
145646
145687
  ac.signal,
145647
145688
  promptId,
145648
145689
  functionCalls
145649
145690
  );
145691
+ if (toolRun.stopAfterUserQuestionCancel) {
145692
+ await this.#preserveCancelledAskUserQuestionToolRun(
145693
+ toolRun
145694
+ );
145695
+ return;
145696
+ }
145650
145697
  nextMessage = {
145651
145698
  role: "user",
145652
145699
  parts: [
145653
- ...toolResponseParts,
145700
+ ...toolRun.parts,
145654
145701
  ...await this.#drainMidTurnUserMessages()
145655
145702
  ]
145656
145703
  };
@@ -145871,15 +145918,20 @@ ${this.pendingWorktreeNotice}
145871
145918
  );
145872
145919
  }
145873
145920
  if (functionCalls.length > 0) {
145874
- const toolResponseParts = await this.runToolCalls(
145921
+ const toolRun = await this.runToolCalls(
145875
145922
  ac.signal,
145876
145923
  promptId,
145877
145924
  functionCalls
145878
145925
  );
145926
+ if (toolRun.stopAfterUserQuestionCancel) {
145927
+ await this.#preserveCancelledAskUserQuestionToolRun(toolRun);
145928
+ await this.#emitBackgroundNotificationEndTurn("end_turn");
145929
+ return;
145930
+ }
145879
145931
  nextMessage = {
145880
145932
  role: "user",
145881
145933
  parts: [
145882
- ...toolResponseParts,
145934
+ ...toolRun.parts,
145883
145935
  ...await this.#drainMidTurnUserMessages()
145884
145936
  ]
145885
145937
  };
@@ -146116,8 +146168,9 @@ ${this.pendingWorktreeNotice}
146116
146168
  * on. Response-part ordering matches the original `functionCalls` order.
146117
146169
  */
146118
146170
  async runToolCalls(abortSignal, promptId, functionCalls) {
146171
+ const dedupedFunctionCalls = dedupeToolCallsById(functionCalls);
146119
146172
  const batches = [];
146120
- for (const fc of dedupeToolCallsById(functionCalls)) {
146173
+ for (const fc of dedupedFunctionCalls) {
146121
146174
  const isAgent = fc.name === ToolNames.AGENT;
146122
146175
  const last = batches[batches.length - 1];
146123
146176
  if (isAgent && last?.concurrent) {
@@ -146126,7 +146179,45 @@ ${this.pendingWorktreeNotice}
146126
146179
  batches.push({ concurrent: isAgent, calls: [fc] });
146127
146180
  }
146128
146181
  }
146129
- const runBounded = /* @__PURE__ */ __name(async (calls) => {
146182
+ let skippedToolCallCounter = 0;
146183
+ const recordSkippedToolCall = /* @__PURE__ */ __name(async (fc) => {
146184
+ const toolName = fc.name ?? "unknown_tool";
146185
+ const callId = fc.id ?? `${toolName}-skip-${++skippedToolCallCounter}`;
146186
+ const part = {
146187
+ functionResponse: {
146188
+ id: callId,
146189
+ name: toolName,
146190
+ response: { error: ASK_USER_QUESTION_CANCEL_SKIP_MESSAGE }
146191
+ }
146192
+ };
146193
+ const error = new Error(ASK_USER_QUESTION_CANCEL_SKIP_MESSAGE);
146194
+ try {
146195
+ this.config.getChatRecordingService()?.recordToolResult([part], {
146196
+ callId,
146197
+ status: "error",
146198
+ resultDisplay: void 0,
146199
+ error,
146200
+ errorType: void 0
146201
+ });
146202
+ await this.toolCallEmitter.emitStart({
146203
+ callId,
146204
+ toolName,
146205
+ args: fc.args ?? {},
146206
+ status: "pending"
146207
+ });
146208
+ await this.toolCallEmitter.emitError(callId, toolName, error);
146209
+ } catch (recordError) {
146210
+ debugLogger78.error("Failed to record skipped tool call:", recordError);
146211
+ }
146212
+ return part;
146213
+ }, "recordSkippedToolCall");
146214
+ const appendSkippedAfter = /* @__PURE__ */ __name(async (parts2, fc) => {
146215
+ const startIndex = dedupedFunctionCalls.indexOf(fc) + 1;
146216
+ for (const remainingCall of dedupedFunctionCalls.slice(startIndex)) {
146217
+ parts2.push(await recordSkippedToolCall(remainingCall));
146218
+ }
146219
+ }, "appendSkippedAfter");
146220
+ const runBounded = /* @__PURE__ */ __name(async (calls, runAbortSignal, onStopAfterUserQuestionCancel, shouldSkipUnstarted) => {
146130
146221
  const parsed = parseInt(
146131
146222
  process.env["QWEN_CODE_MAX_TOOL_CONCURRENCY"] || "",
146132
146223
  10
@@ -146136,7 +146227,19 @@ ${this.pendingWorktreeNotice}
146136
146227
  const executing = /* @__PURE__ */ new Set();
146137
146228
  for (let i = 0; i < calls.length; i++) {
146138
146229
  const idx = i;
146139
- const p = this.runTool(abortSignal, promptId, calls[idx]).then((r) => {
146230
+ if (runAbortSignal.aborted && shouldSkipUnstarted?.()) {
146231
+ results[idx] = {
146232
+ parts: [await recordSkippedToolCall(calls[idx])],
146233
+ stopAfterUserQuestionCancel: false
146234
+ };
146235
+ continue;
146236
+ }
146237
+ const p = this.runTool(
146238
+ runAbortSignal,
146239
+ promptId,
146240
+ calls[idx],
146241
+ onStopAfterUserQuestionCancel
146242
+ ).then((r) => {
146140
146243
  results[idx] = r;
146141
146244
  }).finally(() => {
146142
146245
  executing.delete(p);
@@ -146152,16 +146255,54 @@ ${this.pendingWorktreeNotice}
146152
146255
  const parts = [];
146153
146256
  for (const batch of batches) {
146154
146257
  if (batch.concurrent && batch.calls.length > 1) {
146155
- const results = await runBounded(batch.calls);
146156
- for (const r of results) parts.push(...r);
146258
+ const batchAbortController = new AbortController();
146259
+ let batchStopAfterUserQuestionCancel = false;
146260
+ const propagateAbort = /* @__PURE__ */ __name(() => {
146261
+ batchAbortController.abort(abortSignal.reason);
146262
+ }, "propagateAbort");
146263
+ if (abortSignal.aborted) {
146264
+ propagateAbort();
146265
+ } else {
146266
+ abortSignal.addEventListener("abort", propagateAbort, {
146267
+ once: true
146268
+ });
146269
+ }
146270
+ const stopBatchAfterUserQuestionCancel = /* @__PURE__ */ __name(() => {
146271
+ batchStopAfterUserQuestionCancel = true;
146272
+ batchAbortController.abort(USER_CANCEL_ABORT_REASON);
146273
+ }, "stopBatchAfterUserQuestionCancel");
146274
+ let results;
146275
+ try {
146276
+ results = await runBounded(
146277
+ batch.calls,
146278
+ batchAbortController.signal,
146279
+ stopBatchAfterUserQuestionCancel,
146280
+ () => batchStopAfterUserQuestionCancel
146281
+ );
146282
+ } finally {
146283
+ abortSignal.removeEventListener("abort", propagateAbort);
146284
+ }
146285
+ let shouldStop = false;
146286
+ for (const r of results) {
146287
+ parts.push(...r.parts);
146288
+ shouldStop ||= r.stopAfterUserQuestionCancel;
146289
+ }
146290
+ if (shouldStop) {
146291
+ await appendSkippedAfter(parts, batch.calls[batch.calls.length - 1]);
146292
+ return { parts, stopAfterUserQuestionCancel: true };
146293
+ }
146157
146294
  } else {
146158
146295
  for (const fc of batch.calls) {
146159
146296
  const r = await this.runTool(abortSignal, promptId, fc);
146160
- parts.push(...r);
146297
+ parts.push(...r.parts);
146298
+ if (r.stopAfterUserQuestionCancel) {
146299
+ await appendSkippedAfter(parts, fc);
146300
+ return { parts, stopAfterUserQuestionCancel: true };
146301
+ }
146161
146302
  }
146162
146303
  }
146163
146304
  }
146164
- return parts;
146305
+ return { parts, stopAfterUserQuestionCancel: false };
146165
146306
  }
146166
146307
  /**
146167
146308
  * Assemble the per-turn system reminders the model needs to see at the
@@ -146193,11 +146334,15 @@ ${this.pendingWorktreeNotice}
146193
146334
  }
146194
146335
  return reminders;
146195
146336
  }
146196
- async runTool(abortSignal, promptId, fc) {
146337
+ async runTool(abortSignal, promptId, fc, onStopAfterUserQuestionCancel) {
146197
146338
  const callId = fc.id ?? `${fc.name}-${Date.now()}`;
146198
146339
  let args = fc.args ?? {};
146199
146340
  const startTime = Date.now();
146200
146341
  let spanError;
146342
+ let activeToolAbortSignal = abortSignal;
146343
+ let nestedAskUserQuestionCancelled = false;
146344
+ let agentToolAbortController;
146345
+ let removeAgentToolAbortPropagation;
146201
146346
  const errorResponse = /* @__PURE__ */ __name((error) => {
146202
146347
  const durationMs = Date.now() - startTime;
146203
146348
  logToolCall(this.config, {
@@ -146208,7 +146353,7 @@ ${this.pendingWorktreeNotice}
146208
146353
  function_args: args,
146209
146354
  duration_ms: durationMs,
146210
146355
  // An aborted signal means the call was cancelled, not a genuine error.
146211
- status: abortSignal.aborted ? "cancelled" : "error",
146356
+ status: activeToolAbortSignal.aborted ? "cancelled" : "error",
146212
146357
  success: false,
146213
146358
  error: error.message,
146214
146359
  tool_type: typeof tool !== "undefined" && tool instanceof DiscoveredMCPTool ? "mcp" : "native"
@@ -146223,8 +146368,9 @@ ${this.pendingWorktreeNotice}
146223
146368
  }
146224
146369
  ];
146225
146370
  }, "errorResponse");
146226
- const earlyErrorResponse = /* @__PURE__ */ __name(async (error, toolName2 = fc.name ?? "unknown_tool") => {
146371
+ const earlyErrorResponse = /* @__PURE__ */ __name(async (error, toolName2 = fc.name ?? "unknown_tool", opts) => {
146227
146372
  spanError = error.message;
146373
+ removeAgentToolAbortPropagation?.();
146228
146374
  if (toolName2 !== ToolNames.TODO_WRITE) {
146229
146375
  await this.toolCallEmitter.emitError(callId, toolName2, error);
146230
146376
  }
@@ -146236,7 +146382,10 @@ ${this.pendingWorktreeNotice}
146236
146382
  error,
146237
146383
  errorType: void 0
146238
146384
  });
146239
- return errorParts;
146385
+ return {
146386
+ parts: errorParts,
146387
+ stopAfterUserQuestionCancel: opts?.stopAfterUserQuestionCancel ?? false
146388
+ };
146240
146389
  }, "earlyErrorResponse");
146241
146390
  if (!fc.name) {
146242
146391
  return earlyErrorResponse(new Error("Missing function name"));
@@ -146271,6 +146420,23 @@ ${this.pendingWorktreeNotice}
146271
146420
  const isAgentTool = tool.name === ToolNames.AGENT;
146272
146421
  const isExitPlanModeTool = tool.name === ToolNames.EXIT_PLAN_MODE;
146273
146422
  const isEnterPlanModeTool = tool.name === ToolNames.ENTER_PLAN_MODE;
146423
+ if (isAgentTool) {
146424
+ agentToolAbortController = new AbortController();
146425
+ activeToolAbortSignal = agentToolAbortController.signal;
146426
+ const propagateAbort = /* @__PURE__ */ __name(() => {
146427
+ agentToolAbortController?.abort(abortSignal.reason);
146428
+ }, "propagateAbort");
146429
+ if (abortSignal.aborted) {
146430
+ propagateAbort();
146431
+ } else {
146432
+ abortSignal.addEventListener("abort", propagateAbort, {
146433
+ once: true
146434
+ });
146435
+ removeAgentToolAbortPropagation = /* @__PURE__ */ __name(() => {
146436
+ abortSignal.removeEventListener("abort", propagateAbort);
146437
+ }, "removeAgentToolAbortPropagation");
146438
+ }
146439
+ }
146274
146440
  let subAgentCleanupFunctions = [];
146275
146441
  const toolUseId = generateToolUseId();
146276
146442
  const approvalMode = this.config.getApprovalMode();
@@ -146284,11 +146450,16 @@ ${this.pendingWorktreeNotice}
146284
146450
  this,
146285
146451
  this.client,
146286
146452
  parentToolCallId,
146287
- subagentType
146453
+ subagentType,
146454
+ () => {
146455
+ nestedAskUserQuestionCancelled = true;
146456
+ agentToolAbortController?.abort(USER_CANCEL_ABORT_REASON);
146457
+ onStopAfterUserQuestionCancel?.();
146458
+ }
146288
146459
  );
146289
146460
  subAgentCleanupFunctions = subSubAgentTracker.setup(
146290
146461
  taskEventEmitter,
146291
- abortSignal
146462
+ activeToolAbortSignal
146292
146463
  );
146293
146464
  }
146294
146465
  const isAskUserQuestionTool = toolName === ToolNames.ASK_USER_QUESTION;
@@ -146506,9 +146677,15 @@ ${this.pendingWorktreeNotice}
146506
146677
  }
146507
146678
  switch (outcome) {
146508
146679
  case "cancel" /* Cancel */:
146680
+ if (toolName === ToolNames.ASK_USER_QUESTION) {
146681
+ onStopAfterUserQuestionCancel?.();
146682
+ }
146509
146683
  return earlyErrorResponse(
146510
146684
  new Error(`Tool "${toolName}" was canceled by the user.`),
146511
- toolName
146685
+ toolName,
146686
+ {
146687
+ stopAfterUserQuestionCancel: toolName === ToolNames.ASK_USER_QUESTION
146688
+ }
146512
146689
  );
146513
146690
  case "proceed_once" /* ProceedOnce */:
146514
146691
  case "proceed_always" /* ProceedAlways */:
@@ -146545,7 +146722,7 @@ ${this.pendingWorktreeNotice}
146545
146722
  args,
146546
146723
  toolUseId,
146547
146724
  permissionMode,
146548
- abortSignal
146725
+ activeToolAbortSignal
146549
146726
  );
146550
146727
  if (!preHookResult.shouldProceed) {
146551
146728
  const blockReason = preHookResult.blockReason || "Blocked by PreToolUse hook";
@@ -146568,11 +146745,11 @@ ${this.pendingWorktreeNotice}
146568
146745
  `Qwen Code is executing tool ${toolName}`
146569
146746
  );
146570
146747
  try {
146571
- toolResult = await invocation.execute(abortSignal);
146748
+ toolResult = await invocation.execute(activeToolAbortSignal);
146572
146749
  } finally {
146573
146750
  sleepInhibitorHandle.release();
146574
146751
  }
146575
- const aborted2 = abortSignal.aborted;
146752
+ const aborted2 = activeToolAbortSignal.aborted;
146576
146753
  endToolExecutionSpan(execSpan, {
146577
146754
  success: !toolResult.error && !aborted2,
146578
146755
  error: aborted2 ? "tool_cancelled" : toolResult.error ? "tool_error" : void 0,
@@ -146581,12 +146758,13 @@ ${this.pendingWorktreeNotice}
146581
146758
  } catch (execError) {
146582
146759
  endToolExecutionSpan(execSpan, {
146583
146760
  success: false,
146584
- error: abortSignal.aborted ? "tool_cancelled" : "tool_exception",
146585
- cancelled: abortSignal.aborted
146761
+ error: activeToolAbortSignal.aborted ? "tool_cancelled" : "tool_exception",
146762
+ cancelled: activeToolAbortSignal.aborted
146586
146763
  });
146587
146764
  throw execError;
146588
146765
  }
146589
146766
  subAgentCleanupFunctions.forEach((cleanup) => cleanup());
146767
+ removeAgentToolAbortPropagation?.();
146590
146768
  if ((isEnterPlanModeTool || isExitPlanModeTool) && !didRequestPermission && !toolResult.error && this.config.getApprovalMode() !== approvalMode) {
146591
146769
  await this.sendUpdate({
146592
146770
  sessionUpdate: "current_mode_update",
@@ -146598,7 +146776,10 @@ ${this.pendingWorktreeNotice}
146598
146776
  callId,
146599
146777
  toolResult.llmContent
146600
146778
  );
146601
- if (hooksEnabledForTool && messageBusForTool && !toolResult.error) {
146779
+ const aborted = activeToolAbortSignal.aborted;
146780
+ const status = aborted ? "cancelled" : toolResult.error ? "error" : "success";
146781
+ const succeeded = status === "success";
146782
+ if (hooksEnabledForTool && messageBusForTool && !toolResult.error && !aborted && !nestedAskUserQuestionCancelled) {
146602
146783
  const toolResponse = {
146603
146784
  llmContent: toolResult.llmContent,
146604
146785
  returnDisplay: toolResult.returnDisplay
@@ -146610,7 +146791,7 @@ ${this.pendingWorktreeNotice}
146610
146791
  toolResponse,
146611
146792
  toolUseId,
146612
146793
  permissionMode,
146613
- abortSignal
146794
+ activeToolAbortSignal
146614
146795
  );
146615
146796
  if (postHookResult.shouldStop) {
146616
146797
  const stopMessage = postHookResult.stopReason || "Execution stopped by PostToolUse hook";
@@ -146623,17 +146804,17 @@ ${this.pendingWorktreeNotice}
146623
146804
  const contextPart = { text: postHookResult.additionalContext };
146624
146805
  responseParts.push(contextPart);
146625
146806
  }
146626
- } else if (hooksEnabledForTool && messageBusForTool && toolResult.error) {
146807
+ } else if (hooksEnabledForTool && messageBusForTool && (toolResult.error || aborted)) {
146808
+ const isInterrupt = aborted;
146627
146809
  const failureHookResult = await firePostToolUseFailureHook(
146628
146810
  messageBusForTool,
146629
146811
  toolUseId,
146630
146812
  toolName,
146631
146813
  args,
146632
- toolResult.error.message,
146633
- false,
146634
- // not an interrupt
146814
+ toolResult.error?.message ?? "Tool execution was cancelled",
146815
+ isInterrupt,
146635
146816
  permissionMode,
146636
- abortSignal
146817
+ activeToolAbortSignal
146637
146818
  );
146638
146819
  if (failureHookResult.additionalContext) {
146639
146820
  debugLogger78.debug(
@@ -146641,9 +146822,6 @@ ${this.pendingWorktreeNotice}
146641
146822
  );
146642
146823
  }
146643
146824
  }
146644
- const aborted = abortSignal.aborted;
146645
- const status = aborted ? "cancelled" : toolResult.error ? "error" : "success";
146646
- const succeeded = status === "success";
146647
146825
  if (isTodoWriteTool) {
146648
146826
  const todos = this.planEmitter.extractTodos(
146649
146827
  toolResult.returnDisplay,
@@ -146691,14 +146869,18 @@ ${this.pendingWorktreeNotice}
146691
146869
  } else if (aborted) {
146692
146870
  spanError = "Tool execution was cancelled";
146693
146871
  }
146694
- return responseParts;
146872
+ return {
146873
+ parts: responseParts,
146874
+ stopAfterUserQuestionCancel: nestedAskUserQuestionCancelled
146875
+ };
146695
146876
  } catch (e) {
146696
146877
  subAgentCleanupFunctions.forEach((cleanup) => cleanup());
146878
+ removeAgentToolAbortPropagation?.();
146697
146879
  const error = e instanceof Error ? e : new Error(String(e));
146698
146880
  spanError = error.message;
146699
146881
  const hooksEnabledForError = !this.config.getDisableAllHooks?.();
146700
146882
  const messageBusForError = this.config.getMessageBus?.();
146701
- const isInterrupt = abortSignal.aborted;
146883
+ const isInterrupt = activeToolAbortSignal.aborted;
146702
146884
  if (hooksEnabledForError && messageBusForError) {
146703
146885
  const failureHookResult = await firePostToolUseFailureHook(
146704
146886
  messageBusForError,
@@ -146708,7 +146890,7 @@ ${this.pendingWorktreeNotice}
146708
146890
  error.message,
146709
146891
  isInterrupt,
146710
146892
  String(approvalMode),
146711
- abortSignal
146893
+ activeToolAbortSignal
146712
146894
  );
146713
146895
  if (failureHookResult.additionalContext) {
146714
146896
  debugLogger78.debug(
@@ -146730,12 +146912,15 @@ ${this.pendingWorktreeNotice}
146730
146912
  callId,
146731
146913
  // A throw caused by abort (e.g. AbortError) is a cancellation, not
146732
146914
  // a genuine tool error — keep it consistent with the success path.
146733
- status: abortSignal.aborted ? "cancelled" : "error",
146915
+ status: activeToolAbortSignal.aborted ? "cancelled" : "error",
146734
146916
  resultDisplay: void 0,
146735
146917
  error,
146736
146918
  errorType: void 0
146737
146919
  });
146738
- return errorResponse(error);
146920
+ return {
146921
+ parts: errorResponse(error),
146922
+ stopAfterUserQuestionCancel: nestedAskUserQuestionCancelled
146923
+ };
146739
146924
  }
146740
146925
  });
146741
146926
  } finally {
@@ -148782,7 +148967,7 @@ var QwenAgent = class {
148782
148967
  async initialize(args) {
148783
148968
  this.clientCapabilities = args.clientCapabilities;
148784
148969
  const authMethods = buildAuthMethods();
148785
- const version = "0.18.2";
148970
+ const version = "0.18.3-nightly.20260618.bc3e0b405";
148786
148971
  return {
148787
148972
  protocolVersion: PROTOCOL_VERSION,
148788
148973
  agentInfo: {
@@ -152870,7 +153055,7 @@ ${finalArgs[promptIndex + 1]}`;
152870
153055
  process.exit(0);
152871
153056
  }
152872
153057
  if (config.isInteractive()) {
152873
- void import("./chunks/scheduler-J3OUGTTS.js").then((m) => m.startBackgroundHousekeeping(config, settings)).catch((err) => {
153058
+ void import("./chunks/scheduler-2GZTWP5S.js").then((m) => m.startBackgroundHousekeeping(config, settings)).catch((err) => {
152874
153059
  debugLogger80.warn("failed to start background housekeeping:", err);
152875
153060
  });
152876
153061
  }