@qwen-code/qwen-code 0.18.0 → 0.18.1-nightly.20260616.a68b2e1e7

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 (113) hide show
  1. package/bundled/loop/SKILL.md +2 -1
  2. package/bundled/qc-helper/docs/common-workflow.md +4 -4
  3. package/bundled/qc-helper/docs/configuration/auth.md +1 -1
  4. package/bundled/qc-helper/docs/configuration/model-providers.md +13 -6
  5. package/bundled/qc-helper/docs/configuration/settings.md +90 -87
  6. package/bundled/qc-helper/docs/features/dual-output.md +37 -3
  7. package/bundled/qc-helper/docs/features/skills.md +29 -3
  8. package/bundled/qc-helper/docs/features/sub-agents.md +2 -1
  9. package/bundled/qc-helper/docs/qwen-serve.md +32 -23
  10. package/bundled/qc-helper/docs/reference/keyboard-shortcuts.md +30 -30
  11. package/chunks/{agent-LOTJK6AH.js → agent-PXMT2XR5.js} +21 -20
  12. package/chunks/{agent-headless-TU3EPMYU.js → agent-headless-SY7VJUHV.js} +21 -20
  13. package/chunks/{anthropicContentGenerator-2HBRNQ3B.js → anthropicContentGenerator-DCI26OQF.js} +4 -4
  14. package/chunks/{askUserQuestion-OGCMIBQM.js → askUserQuestion-NDNFGC35.js} +2 -2
  15. package/chunks/{ca-BARBRL6N.js → ca-RK4QPLIX.js} +18 -1
  16. package/chunks/{chunk-BIVG75CP.js → chunk-26QELEL2.js} +1 -1
  17. package/chunks/{chunk-ZTZ4DDQE.js → chunk-3NRO6NHX.js} +2 -2
  18. package/chunks/{chunk-XV4HCEVI.js → chunk-6WPY6ES3.js} +41 -22
  19. package/chunks/{chunk-6YIUGZTC.js → chunk-A3OEZT2F.js} +281 -132
  20. package/chunks/{chunk-LBP46COL.js → chunk-ABRZC6FA.js} +83 -15
  21. package/chunks/{chunk-A7B4ISQP.js → chunk-B4ZF2KSI.js} +1 -1
  22. package/chunks/chunk-BJ5HQ23U.js +178 -0
  23. package/chunks/{chunk-OHEGWO4L.js → chunk-CPVI5J2L.js} +1 -1
  24. package/chunks/{chunk-SEGYWKIH.js → chunk-FIQECJTQ.js} +1 -1
  25. package/chunks/{chunk-IWAYOW5Q.js → chunk-H4ZDM3N6.js} +6588 -4196
  26. package/chunks/{chunk-HR7SV7AY.js → chunk-HA2UEYZP.js} +6 -2
  27. package/chunks/{chunk-2Y5SYSD3.js → chunk-IDYDPBBN.js} +3 -3
  28. package/chunks/{chunk-3HTIVKZE.js → chunk-IQHSD7K5.js} +1 -1
  29. package/chunks/{chunk-MFBBBTNY.js → chunk-JZFEL3RB.js} +1 -1
  30. package/chunks/{chunk-B7HXHOHU.js → chunk-LXYWINWF.js} +1 -1
  31. package/chunks/{chunk-IDX6COTE.js → chunk-LYRSMKLS.js} +2 -2
  32. package/chunks/{chunk-M6VTDSVR.js → chunk-LYSND7KR.js} +9 -4
  33. package/chunks/{chunk-7BCMOPIM.js → chunk-M5PJ5QAF.js} +31 -12
  34. package/chunks/{chunk-EYENRK4D.js → chunk-NNIYWQIS.js} +1 -1
  35. package/chunks/chunk-OMX7CUOE.js +356 -0
  36. package/chunks/{chunk-R7ODSGTK.js → chunk-OT6JA3KQ.js} +2 -2
  37. package/chunks/{chunk-72LDN5PP.js → chunk-QP4R5FTG.js} +1 -1
  38. package/chunks/{chunk-3DHXZ6EV.js → chunk-SFRV6BGY.js} +6 -4
  39. package/chunks/{chunk-LEJ42GNY.js → chunk-TSBXGR73.js} +6 -6
  40. package/chunks/{chunk-PL3MVCWD.js → chunk-UOB6KPGG.js} +11 -11
  41. package/chunks/{chunk-JTQAQBTV.js → chunk-VU6A2OBJ.js} +20 -6
  42. package/chunks/{chunk-HLPLOD42.js → chunk-VXHYMZXW.js} +1 -1
  43. package/chunks/{chunk-J5MDQKJL.js → chunk-WPTCDQN6.js} +2 -347
  44. package/chunks/{chunk-SNGELLWX.js → chunk-ZMIBJS45.js} +1 -1
  45. package/chunks/{chunk-XBY7E2FX.js → chunk-ZOFNJQNJ.js} +6 -4
  46. package/chunks/computer-use-7SEQDSHB.js +2052 -0
  47. package/chunks/{contextCommand-K347QT6O.js → contextCommand-KM5OWV65.js} +23 -22
  48. package/chunks/cron-create-7CXEAJ2K.js +184 -0
  49. package/chunks/{cron-delete-WKWSJZQA.js → cron-delete-2FQYYNQ6.js} +27 -4
  50. package/chunks/{cron-list-B52XEXAZ.js → cron-list-QCAJ73XE.js} +39 -6
  51. package/chunks/{de-YGKK2BC4.js → de-FGPM4KW5.js} +18 -1
  52. package/chunks/{dist-4LXD6L6X.js → dist-2UCAYOX7.js} +2 -2
  53. package/chunks/{dist-H6ONXVLG.js → dist-33LHH26D.js} +1 -1
  54. package/chunks/{dist-PK7DFCAW.js → dist-KF43SZZV.js} +1 -1
  55. package/chunks/{dist-KAZ3SEBX.js → dist-PF2IYSMD.js} +1 -1
  56. package/chunks/{edit-KU4PJGEX.js → edit-BMUKPLA7.js} +23 -24
  57. package/chunks/{en-DHGYHIHX.js → en-VP6XPGEC.js} +5 -2
  58. package/chunks/{enter-worktree-PPYIDCWI.js → enter-worktree-LXJ5WJ5A.js} +21 -20
  59. package/chunks/{enterPlanMode-5CZDMCB4.js → enterPlanMode-QWRZ54ZF.js} +21 -20
  60. package/chunks/{exit-worktree-UY3CGHKC.js → exit-worktree-5HTQPNZO.js} +21 -20
  61. package/chunks/{exitPlanMode-3DN4QNSG.js → exitPlanMode-5WQAXNDA.js} +71 -31
  62. package/chunks/{fr-JXBKPJKQ.js → fr-ATYBVCLT.js} +18 -1
  63. package/chunks/{geminiContentGenerator-7A6I2RWB.js → geminiContentGenerator-CAKHT5YE.js} +4 -4
  64. package/chunks/{glob-OFNQSS52.js → glob-5DN6NSCD.js} +21 -20
  65. package/chunks/{grep-6J2MSUM5.js → grep-BJILOLCD.js} +30 -26
  66. package/chunks/{ja-TGPZSP2B.js → ja-W2QEA2OI.js} +18 -1
  67. package/chunks/{keychain-token-storage-6IU6ORQN.js → keychain-token-storage-QSTRHKKL.js} +2 -2
  68. package/chunks/{ls-V3O6A5PT.js → ls-XVGXRYWD.js} +3 -3
  69. package/chunks/{lsp-G2OCIFUA.js → lsp-S6SHPULC.js} +2 -2
  70. package/chunks/{monitor-FKLHV423.js → monitor-SUEMSRN3.js} +21 -20
  71. package/chunks/{notebook-edit-KTBYFKWG.js → notebook-edit-6F6Z5P6U.js} +22 -21
  72. package/chunks/{openaiContentGenerator-L5KSWQY7.js → openaiContentGenerator-DO27LL6O.js} +11 -11
  73. package/chunks/{pt-TIBG6BIO.js → pt-ZKEWJFBW.js} +18 -1
  74. package/chunks/{qwenContentGenerator-PYOXLMBW.js → qwenContentGenerator-DQLGLQSH.js} +23 -22
  75. package/chunks/{qwenOAuth2-2KCKWDCF.js → qwenOAuth2-KK433U33.js} +4 -4
  76. package/chunks/{read-file-JQVRK4NU.js → read-file-3TBLYTOQ.js} +8 -8
  77. package/chunks/{ripGrep-2L4LPNAJ.js → ripGrep-3INYT3QV.js} +21 -20
  78. package/chunks/{ru-JBCHCK4L.js → ru-VEKTPJ74.js} +18 -1
  79. package/chunks/{scheduler-FGNXY4JQ.js → scheduler-23KQW6CX.js} +21 -20
  80. package/chunks/{send-message-SZFWNOCL.js → send-message-SMNR5DBG.js} +2 -2
  81. package/chunks/{serve-N2IBLA3G.js → serve-Y5E4LKUI.js} +998 -278
  82. package/chunks/{shell-PTEG6UX4.js → shell-4H6XQXVY.js} +21 -20
  83. package/chunks/{skill-X4NTK4NH.js → skill-SE6FECZR.js} +10 -10
  84. package/chunks/{src-GLLQ3R5W.js → src-76DUBH3A.js} +42 -26
  85. package/chunks/{syntheticOutput-IKAY5F6X.js → syntheticOutput-KMNF7YG6.js} +3 -3
  86. package/chunks/{task-create-MQICOJFV.js → task-create-LIJHK75G.js} +7 -6
  87. package/chunks/{task-list-RIHJCH32.js → task-list-S4GNSILM.js} +6 -5
  88. package/chunks/{task-stop-FWZRFANS.js → task-stop-3GBRYJHM.js} +2 -2
  89. package/chunks/{task-update-2LHPXOYM.js → task-update-F3UTVJMS.js} +7 -6
  90. package/chunks/{team-create-2E4PF4KN.js → team-create-Q5DTDDH4.js} +21 -20
  91. package/chunks/{team-delete-DAUDQS4J.js → team-delete-54434EB7.js} +6 -5
  92. package/chunks/{todoWrite-HTUACZES.js → todoWrite-4ENGSBUX.js} +4 -4
  93. package/chunks/{tool-search-KTVULRES.js → tool-search-ABZMSDTU.js} +8 -8
  94. package/chunks/{web-fetch-CZ7LLKPE.js → web-fetch-RHZMF3MP.js} +4 -4
  95. package/chunks/{workflow-L2ZUUDT2.js → workflow-NEMDQB75.js} +503 -49
  96. package/chunks/{write-file-ZEB2JDYH.js → write-file-VAEHZPSL.js} +22 -21
  97. package/chunks/{zh-7H5OQC4I.js → zh-OIXDDQHB.js} +5 -2
  98. package/chunks/{zh-TW-P4IDHD3M.js → zh-TW-6YFNCKTA.js} +5 -2
  99. package/cli-entry.js +19 -0
  100. package/cli.js +6643 -4971
  101. package/locales/ca.js +20 -2
  102. package/locales/de.js +21 -2
  103. package/locales/en.js +7 -4
  104. package/locales/fr.js +22 -2
  105. package/locales/ja.js +22 -2
  106. package/locales/pt.js +21 -2
  107. package/locales/ru.js +20 -2
  108. package/locales/zh-TW.js +6 -4
  109. package/locales/zh.js +6 -4
  110. package/package.json +4 -3
  111. package/chunks/chunk-SKBPNJEW.js +0 -45
  112. package/chunks/computer-use-3RH2DOM6.js +0 -825
  113. package/chunks/cron-create-YJL3KFWI.js +0 -140
@@ -640,6 +640,9 @@ var Storage = class _Storage {
640
640
  const targetDir = path2.join(tempDir, hash);
641
641
  return targetDir;
642
642
  }
643
+ getToolResultsDir() {
644
+ return path2.join(this.getProjectTempDir(), "tool-results");
645
+ }
643
646
  ensureProjectTempDirExists() {
644
647
  fs2.mkdirSync(this.getProjectTempDir(), { recursive: true });
645
648
  }
@@ -810,9 +813,9 @@ var globalSession = null;
810
813
  var sessionContext = new AsyncLocalStorage2();
811
814
  function isDebugLogFileEnabled() {
812
815
  const value = process.env["QWEN_DEBUG_LOG_FILE"];
813
- if (!value) return true;
816
+ if (!value) return false;
814
817
  const normalized = value.trim().toLowerCase();
815
- return !["0", "false", "off", "no"].includes(normalized);
818
+ return !["", "0", "false", "off", "no"].includes(normalized);
816
819
  }
817
820
  __name(isDebugLogFileEnabled, "isDebugLogFileEnabled");
818
821
  function getActiveSession() {
@@ -964,6 +967,7 @@ export {
964
967
  updateSymlink,
965
968
  setSessionContext,
966
969
  getCurrentSessionId,
970
+ getActiveSpanTraceContext,
967
971
  getTraceContext,
968
972
  formatTraceparent,
969
973
  setShellTracePropagation,
@@ -2,17 +2,17 @@
2
2
  "use strict";
3
3
  import {
4
4
  formatFetchErrorForUser
5
- } from "./chunk-SEGYWKIH.js";
5
+ } from "./chunk-FIQECJTQ.js";
6
6
  import {
7
7
  combineAbortSignals
8
8
  } from "./chunk-64WXLC72.js";
9
9
  import {
10
10
  atomicWriteFile
11
- } from "./chunk-B7HXHOHU.js";
11
+ } from "./chunk-LXYWINWF.js";
12
12
  import {
13
13
  Storage,
14
14
  createDebugLogger
15
- } from "./chunk-HR7SV7AY.js";
15
+ } from "./chunk-HA2UEYZP.js";
16
16
  import {
17
17
  init_esbuild_shims
18
18
  } from "./chunk-A4BMJM77.js";
@@ -5,7 +5,7 @@ import {
5
5
  Storage,
6
6
  resolvePath,
7
7
  sanitizeCwd
8
- } from "./chunk-HR7SV7AY.js";
8
+ } from "./chunk-HA2UEYZP.js";
9
9
  import {
10
10
  init_esbuild_shims
11
11
  } from "./chunk-A4BMJM77.js";
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
  import {
4
4
  ToolNames
5
- } from "./chunk-XV4HCEVI.js";
5
+ } from "./chunk-6WPY6ES3.js";
6
6
  import {
7
7
  init_esbuild_shims
8
8
  } from "./chunk-A4BMJM77.js";
@@ -3,7 +3,7 @@
3
3
  import {
4
4
  createDebugLogger,
5
5
  isNodeError
6
- } from "./chunk-HR7SV7AY.js";
6
+ } from "./chunk-HA2UEYZP.js";
7
7
  import {
8
8
  init_esbuild_shims
9
9
  } from "./chunk-A4BMJM77.js";
@@ -2,11 +2,11 @@
2
2
  "use strict";
3
3
  import {
4
4
  atomicWriteFileSync
5
- } from "./chunk-B7HXHOHU.js";
5
+ } from "./chunk-LXYWINWF.js";
6
6
  import {
7
7
  Storage,
8
8
  createDebugLogger
9
- } from "./chunk-HR7SV7AY.js";
9
+ } from "./chunk-HA2UEYZP.js";
10
10
  import {
11
11
  init_esbuild_shims
12
12
  } from "./chunk-A4BMJM77.js";
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
  import {
4
4
  createDebugLogger
5
- } from "./chunk-HR7SV7AY.js";
5
+ } from "./chunk-HA2UEYZP.js";
6
6
  import {
7
7
  init_esbuild_shims
8
8
  } from "./chunk-A4BMJM77.js";
@@ -467,10 +467,15 @@ var PATTERNS = [
467
467
  // -------------------
468
468
  // Zhipu GLM
469
469
  // -------------------
470
- [/^glm-5/, 202752],
471
- // GLM-5: exact vendor limit
470
+ // 1M context is the forward default for new GLM releases (GLM-5.2+, GLM-6.x,
471
+ // and beyond) so they need no future code change. Confirmed 200K families
472
+ // (GLM-5 / 5.0 / 5.1, GLM-4.x and older) are pinned explicitly first.
473
+ [/^glm-5(\.[01])?(-|$)/, 202752],
474
+ // GLM-5 / 5.0 / 5.1: 200K
475
+ [/^glm-(?:[5-9]|\d{2,})/, LIMITS["1m"]],
476
+ // GLM-5.2+, 6.x..9.x, 10.x+: 1M
472
477
  [/^glm-/, 202752],
473
- // GLM fallback: 128K
478
+ // GLM <=4.x / non-numeric fallback: 200K
474
479
  // -------------------
475
480
  // MiniMax
476
481
  // -------------------
@@ -2,19 +2,19 @@
2
2
  "use strict";
3
3
  import {
4
4
  RequestTokenizer
5
- } from "./chunk-ZTZ4DDQE.js";
5
+ } from "./chunk-3NRO6NHX.js";
6
6
  import {
7
7
  OpenAIContentConverter,
8
8
  TaggedThinkingParser,
9
9
  openaiRequestCaptureContext
10
- } from "./chunk-6YIUGZTC.js";
10
+ } from "./chunk-A3OEZT2F.js";
11
11
  import {
12
12
  createChildAbortController
13
13
  } from "./chunk-64WXLC72.js";
14
14
  import {
15
15
  buildRuntimeFetchOptions,
16
16
  redactProxyError
17
- } from "./chunk-EYENRK4D.js";
17
+ } from "./chunk-NNIYWQIS.js";
18
18
  import {
19
19
  CAPPED_DEFAULT_MAX_TOKENS,
20
20
  DASHSCOPE_PROXY_BASE_URL,
@@ -25,14 +25,14 @@ import {
25
25
  runtimeDiagnostics,
26
26
  safeJsonParse,
27
27
  tokenLimit
28
- } from "./chunk-M6VTDSVR.js";
28
+ } from "./chunk-LYSND7KR.js";
29
29
  import {
30
30
  GenerateContentResponse
31
31
  } from "./chunk-55ZMG67I.js";
32
32
  import {
33
33
  createDebugLogger,
34
34
  isAbortError
35
- } from "./chunk-HR7SV7AY.js";
35
+ } from "./chunk-HA2UEYZP.js";
36
36
  import {
37
37
  init_esbuild_shims
38
38
  } from "./chunk-A4BMJM77.js";
@@ -7608,6 +7608,7 @@ init_esbuild_shims();
7608
7608
 
7609
7609
  // packages/core/src/core/openaiContentGenerator/streamingToolCallParser.ts
7610
7610
  init_esbuild_shims();
7611
+ var debugLogger2 = createDebugLogger("STREAMING_TOOL_CALL_PARSER");
7611
7612
  var StreamingToolCallParser = class {
7612
7613
  static {
7613
7614
  __name(this, "StreamingToolCallParser");
@@ -7644,6 +7645,7 @@ var StreamingToolCallParser = class {
7644
7645
  */
7645
7646
  addChunk(index, chunk, id, name) {
7646
7647
  let actualIndex = index;
7648
+ const isKnownId = Boolean(id && this.idToIndexMap.has(id));
7647
7649
  if (id) {
7648
7650
  if (this.idToIndexMap.has(id)) {
7649
7651
  actualIndex = this.idToIndexMap.get(id);
@@ -7685,11 +7687,21 @@ var StreamingToolCallParser = class {
7685
7687
  this.escapes.set(actualIndex, false);
7686
7688
  this.toolCallMeta.set(actualIndex, {});
7687
7689
  }
7690
+ const currentBuffer = this.buffers.get(actualIndex);
7691
+ const currentDepth = this.depths.get(actualIndex);
7692
+ if (isKnownId && currentBuffer.trim() && currentDepth === 0) {
7693
+ try {
7694
+ JSON.parse(currentBuffer);
7695
+ debugLogger2.debug(
7696
+ `Ignoring replay chunk for completed toolCall id=${id}`
7697
+ );
7698
+ return { complete: false };
7699
+ } catch {
7700
+ }
7701
+ }
7688
7702
  const meta = this.toolCallMeta.get(actualIndex);
7689
7703
  if (id) meta.id = id;
7690
7704
  if (name) meta.name = name;
7691
- const currentBuffer = this.buffers.get(actualIndex);
7692
- const currentDepth = this.depths.get(actualIndex);
7693
7705
  const currentInString = this.inStrings.get(actualIndex);
7694
7706
  const currentEscape = this.escapes.get(actualIndex);
7695
7707
  const newBuffer = currentBuffer + chunk;
@@ -7758,9 +7770,16 @@ var StreamingToolCallParser = class {
7758
7770
  */
7759
7771
  getCompletedToolCalls() {
7760
7772
  const completed = [];
7773
+ const emittedIds = /* @__PURE__ */ new Set();
7761
7774
  for (const [index, buffer] of this.buffers.entries()) {
7762
7775
  const meta = this.toolCallMeta.get(index);
7763
7776
  if (meta?.name && buffer.trim()) {
7777
+ if (meta.id) {
7778
+ if (emittedIds.has(meta.id)) {
7779
+ continue;
7780
+ }
7781
+ emittedIds.add(meta.id);
7782
+ }
7764
7783
  let args = {};
7765
7784
  try {
7766
7785
  args = JSON.parse(buffer);
@@ -8269,7 +8288,7 @@ var ContentGenerationPipeline = class {
8269
8288
 
8270
8289
  // packages/core/src/core/openaiContentGenerator/errorHandler.ts
8271
8290
  init_esbuild_shims();
8272
- var debugLogger2 = createDebugLogger("OPENAI_ERROR");
8291
+ var debugLogger3 = createDebugLogger("OPENAI_ERROR");
8273
8292
  var EnhancedErrorHandler = class {
8274
8293
  constructor(shouldSuppressLogging = () => false) {
8275
8294
  this.shouldSuppressLogging = shouldSuppressLogging;
@@ -8286,7 +8305,7 @@ var EnhancedErrorHandler = class {
8286
8305
  isTimeoutError
8287
8306
  );
8288
8307
  if (!this.shouldSuppressErrorLogging(redactedError, request)) {
8289
- debugLogger2.error("OpenAI API Error:", errorMessage);
8308
+ debugLogger3.error("OpenAI API Error:", errorMessage);
8290
8309
  }
8291
8310
  if (isTimeoutError) {
8292
8311
  throw new Error(
@@ -8326,7 +8345,7 @@ ${tips.join("\n")}`;
8326
8345
  };
8327
8346
 
8328
8347
  // packages/core/src/core/openaiContentGenerator/openaiContentGenerator.ts
8329
- var debugLogger3 = createDebugLogger("OPENAI");
8348
+ var debugLogger4 = createDebugLogger("OPENAI");
8330
8349
  var OpenAIContentGenerator = class {
8331
8350
  static {
8332
8351
  __name(this, "OpenAIContentGenerator");
@@ -8369,7 +8388,7 @@ var OpenAIContentGenerator = class {
8369
8388
  totalTokens: result.totalTokens
8370
8389
  };
8371
8390
  } catch (error) {
8372
- debugLogger3.warn(
8391
+ debugLogger4.warn(
8373
8392
  "Failed to calculate tokens with new tokenizer, falling back to simple method:",
8374
8393
  error
8375
8394
  );
@@ -8416,7 +8435,7 @@ var OpenAIContentGenerator = class {
8416
8435
  };
8417
8436
  } catch (error) {
8418
8437
  const redactedError = redactProxyError(error);
8419
- debugLogger3.error("OpenAI API Embedding Error:", redactedError);
8438
+ debugLogger4.error("OpenAI API Embedding Error:", redactedError);
8420
8439
  throw new Error(
8421
8440
  `OpenAI API error: ${redactedError instanceof Error ? redactedError.message : String(redactedError)}`
8422
8441
  );
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
  import {
4
4
  createDebugLogger
5
- } from "./chunk-HR7SV7AY.js";
5
+ } from "./chunk-HA2UEYZP.js";
6
6
  import {
7
7
  init_esbuild_shims
8
8
  } from "./chunk-A4BMJM77.js";
@@ -0,0 +1,356 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import {
4
+ init_esbuild_shims
5
+ } from "./chunk-A4BMJM77.js";
6
+ import {
7
+ __name
8
+ } from "./chunk-J2S4EL5Y.js";
9
+
10
+ // node_modules/async-mutex/index.mjs
11
+ init_esbuild_shims();
12
+ var E_TIMEOUT = new Error("timeout while waiting for mutex to become available");
13
+ var E_ALREADY_LOCKED = new Error("mutex already locked");
14
+ var E_CANCELED = new Error("request for lock canceled");
15
+ var __awaiter$2 = function(thisArg, _arguments, P, generator) {
16
+ function adopt(value) {
17
+ return value instanceof P ? value : new P(function(resolve) {
18
+ resolve(value);
19
+ });
20
+ }
21
+ __name(adopt, "adopt");
22
+ return new (P || (P = Promise))(function(resolve, reject) {
23
+ function fulfilled(value) {
24
+ try {
25
+ step(generator.next(value));
26
+ } catch (e) {
27
+ reject(e);
28
+ }
29
+ }
30
+ __name(fulfilled, "fulfilled");
31
+ function rejected(value) {
32
+ try {
33
+ step(generator["throw"](value));
34
+ } catch (e) {
35
+ reject(e);
36
+ }
37
+ }
38
+ __name(rejected, "rejected");
39
+ function step(result) {
40
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
41
+ }
42
+ __name(step, "step");
43
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
44
+ });
45
+ };
46
+ var Semaphore = class {
47
+ static {
48
+ __name(this, "Semaphore");
49
+ }
50
+ constructor(_value, _cancelError = E_CANCELED) {
51
+ this._value = _value;
52
+ this._cancelError = _cancelError;
53
+ this._queue = [];
54
+ this._weightedWaiters = [];
55
+ }
56
+ acquire(weight = 1, priority = 0) {
57
+ if (weight <= 0)
58
+ throw new Error(`invalid weight ${weight}: must be positive`);
59
+ return new Promise((resolve, reject) => {
60
+ const task = { resolve, reject, weight, priority };
61
+ const i = findIndexFromEnd(this._queue, (other) => priority <= other.priority);
62
+ if (i === -1 && weight <= this._value) {
63
+ this._dispatchItem(task);
64
+ } else {
65
+ this._queue.splice(i + 1, 0, task);
66
+ }
67
+ });
68
+ }
69
+ runExclusive(callback_1) {
70
+ return __awaiter$2(this, arguments, void 0, function* (callback, weight = 1, priority = 0) {
71
+ const [value, release] = yield this.acquire(weight, priority);
72
+ try {
73
+ return yield callback(value);
74
+ } finally {
75
+ release();
76
+ }
77
+ });
78
+ }
79
+ waitForUnlock(weight = 1, priority = 0) {
80
+ if (weight <= 0)
81
+ throw new Error(`invalid weight ${weight}: must be positive`);
82
+ if (this._couldLockImmediately(weight, priority)) {
83
+ return Promise.resolve();
84
+ } else {
85
+ return new Promise((resolve) => {
86
+ if (!this._weightedWaiters[weight - 1])
87
+ this._weightedWaiters[weight - 1] = [];
88
+ insertSorted(this._weightedWaiters[weight - 1], { resolve, priority });
89
+ });
90
+ }
91
+ }
92
+ isLocked() {
93
+ return this._value <= 0;
94
+ }
95
+ getValue() {
96
+ return this._value;
97
+ }
98
+ setValue(value) {
99
+ this._value = value;
100
+ this._dispatchQueue();
101
+ }
102
+ release(weight = 1) {
103
+ if (weight <= 0)
104
+ throw new Error(`invalid weight ${weight}: must be positive`);
105
+ this._value += weight;
106
+ this._dispatchQueue();
107
+ }
108
+ cancel() {
109
+ this._queue.forEach((entry) => entry.reject(this._cancelError));
110
+ this._queue = [];
111
+ }
112
+ _dispatchQueue() {
113
+ this._drainUnlockWaiters();
114
+ while (this._queue.length > 0 && this._queue[0].weight <= this._value) {
115
+ this._dispatchItem(this._queue.shift());
116
+ this._drainUnlockWaiters();
117
+ }
118
+ }
119
+ _dispatchItem(item) {
120
+ const previousValue = this._value;
121
+ this._value -= item.weight;
122
+ item.resolve([previousValue, this._newReleaser(item.weight)]);
123
+ }
124
+ _newReleaser(weight) {
125
+ let called = false;
126
+ return () => {
127
+ if (called)
128
+ return;
129
+ called = true;
130
+ this.release(weight);
131
+ };
132
+ }
133
+ _drainUnlockWaiters() {
134
+ if (this._queue.length === 0) {
135
+ for (let weight = this._value; weight > 0; weight--) {
136
+ const waiters = this._weightedWaiters[weight - 1];
137
+ if (!waiters)
138
+ continue;
139
+ waiters.forEach((waiter) => waiter.resolve());
140
+ this._weightedWaiters[weight - 1] = [];
141
+ }
142
+ } else {
143
+ const queuedPriority = this._queue[0].priority;
144
+ for (let weight = this._value; weight > 0; weight--) {
145
+ const waiters = this._weightedWaiters[weight - 1];
146
+ if (!waiters)
147
+ continue;
148
+ const i = waiters.findIndex((waiter) => waiter.priority <= queuedPriority);
149
+ (i === -1 ? waiters : waiters.splice(0, i)).forEach((waiter) => waiter.resolve());
150
+ }
151
+ }
152
+ }
153
+ _couldLockImmediately(weight, priority) {
154
+ return (this._queue.length === 0 || this._queue[0].priority < priority) && weight <= this._value;
155
+ }
156
+ };
157
+ function insertSorted(a, v) {
158
+ const i = findIndexFromEnd(a, (other) => v.priority <= other.priority);
159
+ a.splice(i + 1, 0, v);
160
+ }
161
+ __name(insertSorted, "insertSorted");
162
+ function findIndexFromEnd(a, predicate) {
163
+ for (let i = a.length - 1; i >= 0; i--) {
164
+ if (predicate(a[i])) {
165
+ return i;
166
+ }
167
+ }
168
+ return -1;
169
+ }
170
+ __name(findIndexFromEnd, "findIndexFromEnd");
171
+ var __awaiter$1 = function(thisArg, _arguments, P, generator) {
172
+ function adopt(value) {
173
+ return value instanceof P ? value : new P(function(resolve) {
174
+ resolve(value);
175
+ });
176
+ }
177
+ __name(adopt, "adopt");
178
+ return new (P || (P = Promise))(function(resolve, reject) {
179
+ function fulfilled(value) {
180
+ try {
181
+ step(generator.next(value));
182
+ } catch (e) {
183
+ reject(e);
184
+ }
185
+ }
186
+ __name(fulfilled, "fulfilled");
187
+ function rejected(value) {
188
+ try {
189
+ step(generator["throw"](value));
190
+ } catch (e) {
191
+ reject(e);
192
+ }
193
+ }
194
+ __name(rejected, "rejected");
195
+ function step(result) {
196
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
197
+ }
198
+ __name(step, "step");
199
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
200
+ });
201
+ };
202
+ var Mutex = class {
203
+ static {
204
+ __name(this, "Mutex");
205
+ }
206
+ constructor(cancelError) {
207
+ this._semaphore = new Semaphore(1, cancelError);
208
+ }
209
+ acquire() {
210
+ return __awaiter$1(this, arguments, void 0, function* (priority = 0) {
211
+ const [, releaser] = yield this._semaphore.acquire(1, priority);
212
+ return releaser;
213
+ });
214
+ }
215
+ runExclusive(callback, priority = 0) {
216
+ return this._semaphore.runExclusive(() => callback(), 1, priority);
217
+ }
218
+ isLocked() {
219
+ return this._semaphore.isLocked();
220
+ }
221
+ waitForUnlock(priority = 0) {
222
+ return this._semaphore.waitForUnlock(1, priority);
223
+ }
224
+ release() {
225
+ if (this._semaphore.isLocked())
226
+ this._semaphore.release();
227
+ }
228
+ cancel() {
229
+ return this._semaphore.cancel();
230
+ }
231
+ };
232
+ var __awaiter = function(thisArg, _arguments, P, generator) {
233
+ function adopt(value) {
234
+ return value instanceof P ? value : new P(function(resolve) {
235
+ resolve(value);
236
+ });
237
+ }
238
+ __name(adopt, "adopt");
239
+ return new (P || (P = Promise))(function(resolve, reject) {
240
+ function fulfilled(value) {
241
+ try {
242
+ step(generator.next(value));
243
+ } catch (e) {
244
+ reject(e);
245
+ }
246
+ }
247
+ __name(fulfilled, "fulfilled");
248
+ function rejected(value) {
249
+ try {
250
+ step(generator["throw"](value));
251
+ } catch (e) {
252
+ reject(e);
253
+ }
254
+ }
255
+ __name(rejected, "rejected");
256
+ function step(result) {
257
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
258
+ }
259
+ __name(step, "step");
260
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
261
+ });
262
+ };
263
+ function withTimeout(sync, timeout, timeoutError = E_TIMEOUT) {
264
+ return {
265
+ acquire: /* @__PURE__ */ __name((weightOrPriority, priority) => {
266
+ let weight;
267
+ if (isSemaphore(sync)) {
268
+ weight = weightOrPriority;
269
+ } else {
270
+ weight = void 0;
271
+ priority = weightOrPriority;
272
+ }
273
+ if (weight !== void 0 && weight <= 0) {
274
+ throw new Error(`invalid weight ${weight}: must be positive`);
275
+ }
276
+ return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
277
+ let isTimeout = false;
278
+ const handle = setTimeout(() => {
279
+ isTimeout = true;
280
+ reject(timeoutError);
281
+ }, timeout);
282
+ try {
283
+ const ticket = yield isSemaphore(sync) ? sync.acquire(weight, priority) : sync.acquire(priority);
284
+ if (isTimeout) {
285
+ const release = Array.isArray(ticket) ? ticket[1] : ticket;
286
+ release();
287
+ } else {
288
+ clearTimeout(handle);
289
+ resolve(ticket);
290
+ }
291
+ } catch (e) {
292
+ if (!isTimeout) {
293
+ clearTimeout(handle);
294
+ reject(e);
295
+ }
296
+ }
297
+ }));
298
+ }, "acquire"),
299
+ runExclusive(callback, weight, priority) {
300
+ return __awaiter(this, void 0, void 0, function* () {
301
+ let release = /* @__PURE__ */ __name(() => void 0, "release");
302
+ try {
303
+ const ticket = yield this.acquire(weight, priority);
304
+ if (Array.isArray(ticket)) {
305
+ release = ticket[1];
306
+ return yield callback(ticket[0]);
307
+ } else {
308
+ release = ticket;
309
+ return yield callback();
310
+ }
311
+ } finally {
312
+ release();
313
+ }
314
+ });
315
+ },
316
+ release(weight) {
317
+ sync.release(weight);
318
+ },
319
+ cancel() {
320
+ return sync.cancel();
321
+ },
322
+ waitForUnlock: /* @__PURE__ */ __name((weightOrPriority, priority) => {
323
+ let weight;
324
+ if (isSemaphore(sync)) {
325
+ weight = weightOrPriority;
326
+ } else {
327
+ weight = void 0;
328
+ priority = weightOrPriority;
329
+ }
330
+ if (weight !== void 0 && weight <= 0) {
331
+ throw new Error(`invalid weight ${weight}: must be positive`);
332
+ }
333
+ return new Promise((resolve, reject) => {
334
+ const handle = setTimeout(() => reject(timeoutError), timeout);
335
+ (isSemaphore(sync) ? sync.waitForUnlock(weight, priority) : sync.waitForUnlock(priority)).then(() => {
336
+ clearTimeout(handle);
337
+ resolve();
338
+ });
339
+ });
340
+ }, "waitForUnlock"),
341
+ isLocked: /* @__PURE__ */ __name(() => sync.isLocked(), "isLocked"),
342
+ getValue: /* @__PURE__ */ __name(() => sync.getValue(), "getValue"),
343
+ setValue: /* @__PURE__ */ __name((value) => sync.setValue(value), "setValue")
344
+ };
345
+ }
346
+ __name(withTimeout, "withTimeout");
347
+ function isSemaphore(sync) {
348
+ return sync.getValue !== void 0;
349
+ }
350
+ __name(isSemaphore, "isSemaphore");
351
+
352
+ export {
353
+ E_TIMEOUT,
354
+ Mutex,
355
+ withTimeout
356
+ };
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
  import {
4
4
  createTask
5
- } from "./chunk-XBY7E2FX.js";
5
+ } from "./chunk-ZOFNJQNJ.js";
6
6
  import {
7
7
  resolveActiveTeamName
8
8
  } from "./chunk-LD2XBG6Z.js";
@@ -11,7 +11,7 @@ import {
11
11
  BaseToolInvocation,
12
12
  ToolDisplayNames,
13
13
  ToolNames
14
- } from "./chunk-XV4HCEVI.js";
14
+ } from "./chunk-6WPY6ES3.js";
15
15
  import {
16
16
  init_esbuild_shims
17
17
  } from "./chunk-A4BMJM77.js";
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
  import {
4
4
  getGlobalQwenDir
5
- } from "./chunk-JTQAQBTV.js";
5
+ } from "./chunk-VU6A2OBJ.js";
6
6
  import {
7
7
  init_esbuild_shims
8
8
  } from "./chunk-A4BMJM77.js";
@@ -1,17 +1,19 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
3
  import {
4
- Mutex,
5
4
  getInboxesDir,
6
5
  require_proper_lockfile
7
- } from "./chunk-J5MDQKJL.js";
6
+ } from "./chunk-WPTCDQN6.js";
7
+ import {
8
+ Mutex
9
+ } from "./chunk-OMX7CUOE.js";
8
10
  import {
9
11
  atomicWriteJSON
10
- } from "./chunk-B7HXHOHU.js";
12
+ } from "./chunk-LXYWINWF.js";
11
13
  import {
12
14
  createDebugLogger,
13
15
  isNodeError
14
- } from "./chunk-HR7SV7AY.js";
16
+ } from "./chunk-HA2UEYZP.js";
15
17
  import {
16
18
  init_esbuild_shims
17
19
  } from "./chunk-A4BMJM77.js";