@qwen-code/qwen-code 0.18.0-preview.1 → 0.18.0

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 (141) hide show
  1. package/bundled/qc-helper/SKILL.md +1 -2
  2. package/bundled/qc-helper/docs/_meta.ts +1 -0
  3. package/bundled/qc-helper/docs/configuration/settings.md +20 -24
  4. package/bundled/qc-helper/docs/features/_meta.ts +0 -3
  5. package/bundled/qc-helper/docs/features/approval-mode.md +10 -14
  6. package/bundled/qc-helper/docs/features/commands.md +47 -23
  7. package/bundled/qc-helper/docs/features/followup-suggestions.md +2 -2
  8. package/bundled/qc-helper/docs/features/scheduled-tasks.md +1 -1
  9. package/bundled/qc-helper/docs/features/sub-agents.md +60 -0
  10. package/bundled/qc-helper/docs/qwen-serve-deploy-local.md +221 -0
  11. package/bundled/qc-helper/docs/qwen-serve.md +234 -24
  12. package/chunks/{agent-SXS4NQWS.js → agent-LOTJK6AH.js} +25 -19
  13. package/chunks/agent-headless-TU3EPMYU.js +50 -0
  14. package/chunks/{anthropicContentGenerator-4QBVSFSJ.js → anthropicContentGenerator-2HBRNQ3B.js} +7 -7
  15. package/chunks/{askUserQuestion-NOOLRWCJ.js → askUserQuestion-OGCMIBQM.js} +45 -3
  16. package/chunks/{ca-WRHFBIDH.js → ca-BARBRL6N.js} +48 -1
  17. package/chunks/{chunk-JMLIPZUU.js → chunk-2Y5SYSD3.js} +361 -583
  18. package/chunks/chunk-3DHXZ6EV.js +241 -0
  19. package/chunks/{chunk-AVLOK27J.js → chunk-3HTIVKZE.js} +1 -1
  20. package/chunks/{chunk-BNESGOSJ.js → chunk-55ZMG67I.js} +1 -1
  21. package/chunks/chunk-64WXLC72.js +98 -0
  22. package/chunks/{chunk-F6FLCHCS.js → chunk-6YIUGZTC.js} +1069 -211
  23. package/chunks/{chunk-C6WMLUNB.js → chunk-72LDN5PP.js} +1 -1
  24. package/chunks/{chunk-ERREX2ES.js → chunk-7BCMOPIM.js} +64 -24
  25. package/chunks/{chunk-6VFG3EUJ.js → chunk-A7B4ISQP.js} +1 -1
  26. package/chunks/{chunk-F5ORN4YO.js → chunk-B7HXHOHU.js} +1 -1
  27. package/chunks/{chunk-5RNZ2QKF.js → chunk-BIVG75CP.js} +1 -1
  28. package/chunks/{chunk-MVX64PNU.js → chunk-EYENRK4D.js} +1 -1
  29. package/chunks/{chunk-SZOEIL6S.js → chunk-H6BD2ELD.js} +1 -0
  30. package/chunks/{chunk-SCHRFI7O.js → chunk-HLPLOD42.js} +1 -1
  31. package/chunks/{chunk-R5PDRHEF.js → chunk-HR7SV7AY.js} +68 -47
  32. package/chunks/{chunk-JSYEZAYV.js → chunk-IDX6COTE.js} +2 -2
  33. package/chunks/{chunk-6KH2Q7XN.js → chunk-IWAYOW5Q.js} +17482 -11669
  34. package/chunks/chunk-J5MDQKJL.js +2230 -0
  35. package/chunks/{chunk-USE2VQ5P.js → chunk-JTQAQBTV.js} +21 -0
  36. package/chunks/{chunk-ZW7GBCRE.js → chunk-LBP46COL.js} +1014 -163
  37. package/chunks/chunk-LD2XBG6Z.js +102 -0
  38. package/chunks/{chunk-KOA52UTF.js → chunk-LEJ42GNY.js} +14 -14
  39. package/chunks/{chunk-D46KOV3C.js → chunk-M6VTDSVR.js} +1 -1
  40. package/chunks/{chunk-SHUT5MQY.js → chunk-MFBBBTNY.js} +1 -1
  41. package/chunks/{chunk-PLYZAP4W.js → chunk-OHEGWO4L.js} +101 -23
  42. package/chunks/{chunk-NQZ33PWX.js → chunk-PL3MVCWD.js} +11 -11
  43. package/chunks/chunk-QQDPRDVW.js +25 -0
  44. package/chunks/chunk-R7ODSGTK.js +159 -0
  45. package/chunks/{chunk-GBEPNWYB.js → chunk-SEGYWKIH.js} +1 -1
  46. package/chunks/chunk-SKBPNJEW.js +45 -0
  47. package/chunks/{chunk-UABFCMPA.js → chunk-SNGELLWX.js} +3 -1
  48. package/chunks/chunk-XBY7E2FX.js +605 -0
  49. package/chunks/{chunk-G763GDO6.js → chunk-XV4HCEVI.js} +36 -3
  50. package/chunks/{chunk-WFVXF3OM.js → chunk-Z2Z3GUXZ.js} +1 -0
  51. package/chunks/{chunk-BBTV54KB.js → chunk-ZTZ4DDQE.js} +2 -2
  52. package/chunks/{computer-use-CT6MU6P3.js → computer-use-3RH2DOM6.js} +25 -19
  53. package/chunks/contextCommand-K347QT6O.js +52 -0
  54. package/chunks/{cron-create-PIPMXQN4.js → cron-create-YJL3KFWI.js} +3 -3
  55. package/chunks/{cron-delete-6Y5XIDMS.js → cron-delete-WKWSJZQA.js} +3 -3
  56. package/chunks/{cron-list-A4WNRUWZ.js → cron-list-B52XEXAZ.js} +3 -3
  57. package/chunks/{de-M5RPB2NB.js → de-YGKK2BC4.js} +48 -1
  58. package/chunks/{devtools-IXE4UP72.js → devtools-FM6GJPYG.js} +1 -1
  59. package/chunks/{dist-R2SXPG74.js → dist-4LXD6L6X.js} +2 -2
  60. package/chunks/{dist-TE5QKMGR.js → dist-H6ONXVLG.js} +1 -1
  61. package/chunks/{dist-ZMQ4TXD5.js → dist-KAZ3SEBX.js} +2 -2
  62. package/chunks/{dist-BXDUQ2QY.js → dist-PK7DFCAW.js} +1 -1
  63. package/chunks/{edit-A4YK7AIB.js → edit-KU4PJGEX.js} +26 -20
  64. package/chunks/{en-UMYKQAZE.js → en-DHGYHIHX.js} +77 -2
  65. package/chunks/{enter-worktree-VNEQINLC.js → enter-worktree-PPYIDCWI.js} +25 -19
  66. package/chunks/enterPlanMode-5CZDMCB4.js +158 -0
  67. package/chunks/{exit-worktree-AVSMXC33.js → exit-worktree-UY3CGHKC.js} +25 -19
  68. package/chunks/exitPlanMode-3DN4QNSG.js +703 -0
  69. package/chunks/{fr-MPYXXXPW.js → fr-JXBKPJKQ.js} +48 -1
  70. package/chunks/{geminiContentGenerator-CR2WGARL.js → geminiContentGenerator-7A6I2RWB.js} +7 -7
  71. package/chunks/{getMachineId-bsd-F7GNPTER.js → getMachineId-bsd-4CASPIU4.js} +1 -1
  72. package/chunks/{getMachineId-darwin-T73DJL27.js → getMachineId-darwin-HPQPEMZR.js} +1 -1
  73. package/chunks/{getMachineId-linux-MKQTFPQM.js → getMachineId-linux-AUARKYHL.js} +1 -1
  74. package/chunks/{getMachineId-unsupported-MUR5KOQE.js → getMachineId-unsupported-S32ZDA2T.js} +1 -1
  75. package/chunks/{getMachineId-win-CDYFC6ZM.js → getMachineId-win-4EFLHYIJ.js} +1 -1
  76. package/chunks/{glob-5V32KOG5.js → glob-OFNQSS52.js} +25 -19
  77. package/chunks/{grep-PUTEPBR4.js → grep-6J2MSUM5.js} +28 -19
  78. package/chunks/{ja-NFZ32AB3.js → ja-TGPZSP2B.js} +48 -1
  79. package/chunks/{keychain-token-storage-UHGOCDD6.js → keychain-token-storage-6IU6ORQN.js} +3 -3
  80. package/chunks/{ls-34DLNYCD.js → ls-V3O6A5PT.js} +4 -4
  81. package/chunks/{lsp-NCDEHH3V.js → lsp-G2OCIFUA.js} +3 -3
  82. package/chunks/{monitor-EJBR5VCR.js → monitor-FKLHV423.js} +25 -19
  83. package/chunks/{notebook-edit-DZHGPP2L.js → notebook-edit-KTBYFKWG.js} +26 -20
  84. package/chunks/{openaiContentGenerator-4QNV3CHM.js → openaiContentGenerator-L5KSWQY7.js} +15 -14
  85. package/chunks/{pt-BR43FRBA.js → pt-TIBG6BIO.js} +48 -1
  86. package/chunks/{qwenContentGenerator-3XOCEMQO.js → qwenContentGenerator-PYOXLMBW.js} +27 -21
  87. package/chunks/{qwenOAuth2-KRJT35QH.js → qwenOAuth2-2KCKWDCF.js} +6 -5
  88. package/chunks/{read-file-VZ2SQQIX.js → read-file-JQVRK4NU.js} +11 -11
  89. package/chunks/ripGrep-2L4LPNAJ.js +48 -0
  90. package/chunks/{ru-DQCW2KHD.js → ru-JBCHCK4L.js} +48 -1
  91. package/chunks/{scheduler-H32DZVDV.js → scheduler-FGNXY4JQ.js} +25 -19
  92. package/chunks/send-message-SZFWNOCL.js +244 -0
  93. package/chunks/{serve-56G4B5W6.js → serve-N2IBLA3G.js} +13592 -4979
  94. package/chunks/{shell-Q77KNP4N.js → shell-PTEG6UX4.js} +25 -19
  95. package/chunks/{skill-CLWFJYBG.js → skill-X4NTK4NH.js} +64 -113
  96. package/chunks/{src-47L2LUOU.js → src-GLLQ3R5W.js} +307 -32
  97. package/chunks/{syntheticOutput-T5SWX3YF.js → syntheticOutput-IKAY5F6X.js} +4 -4
  98. package/chunks/task-create-MQICOJFV.js +19 -0
  99. package/chunks/task-list-RIHJCH32.js +151 -0
  100. package/chunks/{task-stop-3VHAQMYM.js → task-stop-FWZRFANS.js} +3 -3
  101. package/chunks/task-update-2LHPXOYM.js +408 -0
  102. package/chunks/team-create-2E4PF4KN.js +314 -0
  103. package/chunks/team-delete-DAUDQS4J.js +116 -0
  104. package/chunks/{todoWrite-EAGJGKO5.js → todoWrite-HTUACZES.js} +5 -5
  105. package/chunks/{tool-search-Q75AYDTP.js → tool-search-KTVULRES.js} +11 -11
  106. package/chunks/{web-fetch-SS6IKK6N.js → web-fetch-CZ7LLKPE.js} +5 -5
  107. package/chunks/workflow-L2ZUUDT2.js +960 -0
  108. package/chunks/{write-file-RENGC25N.js → write-file-ZEB2JDYH.js} +26 -20
  109. package/chunks/{zh-6VFXOAR5.js → zh-7H5OQC4I.js} +82 -7
  110. package/chunks/{zh-TW-IQZ4AD5M.js → zh-TW-P4IDHD3M.js} +79 -7
  111. package/cli.js +11248 -5119
  112. package/examples/agent/qwen-extension.json +1 -0
  113. package/examples/commands/qwen-extension.json +1 -0
  114. package/examples/context/qwen-extension.json +1 -0
  115. package/examples/mcp-server/qwen-extension.json +1 -0
  116. package/examples/skills/qwen-extension.json +1 -0
  117. package/examples/starter/QWEN.md +30 -0
  118. package/examples/starter/README.md +59 -0
  119. package/examples/starter/agents/diary.md +86 -0
  120. package/examples/starter/commands/writing/polish.md +13 -0
  121. package/examples/starter/example.ts +64 -0
  122. package/examples/starter/package.json +18 -0
  123. package/examples/starter/qwen-extension.json +12 -0
  124. package/examples/starter/skills/synonyms/SKILL.md +48 -0
  125. package/examples/starter/tsconfig.json +13 -0
  126. package/fzfWorker.js +1083 -0
  127. package/locales/ca.js +51 -0
  128. package/locales/de.js +51 -0
  129. package/locales/en.js +89 -2
  130. package/locales/fr.js +53 -2
  131. package/locales/ja.js +52 -2
  132. package/locales/pt.js +52 -2
  133. package/locales/ru.js +53 -2
  134. package/locales/zh-TW.js +90 -11
  135. package/locales/zh.js +94 -11
  136. package/package.json +3 -2
  137. package/bundled/qc-helper/docs/features/checkpointing.md +0 -77
  138. package/chunks/contextCommand-YODJQYIV.js +0 -46
  139. package/chunks/exitPlanMode-5SQYVROD.js +0 -229
  140. package/chunks/ripGrep-SBIZCPOL.js +0 -42
  141. package/chunks/send-message-YYF56TS7.js +0 -151
@@ -0,0 +1,605 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import {
4
+ Mutex,
5
+ getTasksDir,
6
+ require_proper_lockfile
7
+ } from "./chunk-J5MDQKJL.js";
8
+ import {
9
+ atomicWriteJSON
10
+ } from "./chunk-B7HXHOHU.js";
11
+ import {
12
+ createDebugLogger,
13
+ isNodeError
14
+ } from "./chunk-HR7SV7AY.js";
15
+ import {
16
+ init_esbuild_shims
17
+ } from "./chunk-A4BMJM77.js";
18
+ import {
19
+ __name,
20
+ __toESM
21
+ } from "./chunk-J2S4EL5Y.js";
22
+
23
+ // packages/core/src/agents/team/tasks.ts
24
+ init_esbuild_shims();
25
+ var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
26
+ import * as fs from "node:fs/promises";
27
+ import { constants as fsConstants } from "node:fs";
28
+ import * as path from "node:path";
29
+ var debug = createDebugLogger("AGENTS_TEAM_TASKS");
30
+ var MAX_METADATA_BYTES = 32768;
31
+ var MAX_PARALLEL_TASK_READS = 16;
32
+ function assertMetadataWithinLimit(metadata) {
33
+ if (!metadata) return;
34
+ const size = Buffer.byteLength(JSON.stringify(metadata), "utf-8");
35
+ if (size > MAX_METADATA_BYTES) {
36
+ throw new Error(
37
+ `Task metadata is too large (${size} bytes; max ${MAX_METADATA_BYTES}). Trim the payload or store the bulk content elsewhere.`
38
+ );
39
+ }
40
+ }
41
+ __name(assertMetadataWithinLimit, "assertMetadataWithinLimit");
42
+ var LOCK_OPTIONS = {
43
+ retries: {
44
+ retries: 30,
45
+ minTimeout: 5,
46
+ maxTimeout: 100,
47
+ factor: 2,
48
+ // Jitter the backoff so in-process and cross-process contenders
49
+ // don't retry in lockstep (thundering herd) and starve each other
50
+ // out of the retry budget — mirrors mailbox.ts. The most acute case
51
+ // is scanIdleAgentsForTasks racing up to MAX_TEAMMATES claimants at
52
+ // the same first-pending task file.
53
+ randomize: true
54
+ },
55
+ stale: 5e3,
56
+ onCompromised: /* @__PURE__ */ __name((err) => {
57
+ debug.warn("task lock compromised:", err?.message ?? err);
58
+ }, "onCompromised")
59
+ };
60
+ var taskFileLocks = /* @__PURE__ */ new Map();
61
+ function getTaskFileLock(taskPath) {
62
+ let lock = taskFileLocks.get(taskPath);
63
+ if (!lock) {
64
+ lock = new Mutex();
65
+ taskFileLocks.set(taskPath, lock);
66
+ }
67
+ return lock;
68
+ }
69
+ __name(getTaskFileLock, "getTaskFileLock");
70
+ async function withTaskFileLock(taskPath, fn, onMissing) {
71
+ return getTaskFileLock(taskPath).runExclusive(async () => {
72
+ let release;
73
+ try {
74
+ release = await import_proper_lockfile.default.lock(taskPath, LOCK_OPTIONS);
75
+ } catch (err) {
76
+ if (isNodeError(err) && err.code === "ENOENT") return onMissing();
77
+ throw err;
78
+ }
79
+ try {
80
+ return await fn();
81
+ } finally {
82
+ await release();
83
+ }
84
+ });
85
+ }
86
+ __name(withTaskFileLock, "withTaskFileLock");
87
+ var RECIPROCAL_CALLER = "__reciprocal__";
88
+ var agentClaimLocks = /* @__PURE__ */ new Map();
89
+ function getAgentClaimLock(agentId) {
90
+ let lock = agentClaimLocks.get(agentId);
91
+ if (!lock) {
92
+ lock = new Mutex();
93
+ agentClaimLocks.set(agentId, lock);
94
+ }
95
+ return lock;
96
+ }
97
+ __name(getAgentClaimLock, "getAgentClaimLock");
98
+ function assertValidTaskId(taskId) {
99
+ if (!/^[1-9]\d*$/.test(taskId)) {
100
+ throw new Error(
101
+ `Invalid task ID "${taskId}". Task IDs must be positive integers.`
102
+ );
103
+ }
104
+ }
105
+ __name(assertValidTaskId, "assertValidTaskId");
106
+ function getTaskPath(teamName, taskId) {
107
+ assertValidTaskId(taskId);
108
+ return path.join(getTasksDir(teamName), `${taskId}.json`);
109
+ }
110
+ __name(getTaskPath, "getTaskPath");
111
+ var listeners = /* @__PURE__ */ new Set();
112
+ function onTasksUpdated(listener) {
113
+ listeners.add(listener);
114
+ return () => {
115
+ listeners.delete(listener);
116
+ };
117
+ }
118
+ __name(onTasksUpdated, "onTasksUpdated");
119
+ function notifyTasksUpdated(teamName) {
120
+ for (const listener of listeners) {
121
+ try {
122
+ listener(teamName);
123
+ } catch (err) {
124
+ debug.warn(`task update listener failed: ${err}`);
125
+ }
126
+ }
127
+ }
128
+ __name(notifyTasksUpdated, "notifyTasksUpdated");
129
+ async function createTask(teamName, opts) {
130
+ assertMetadataWithinLimit(opts.metadata);
131
+ const dir = getTasksDir(teamName);
132
+ await fs.mkdir(dir, { recursive: true });
133
+ const MAX_RETRIES = 15;
134
+ for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
135
+ const nextId = await getNextTaskId(dir);
136
+ const task = {
137
+ id: nextId,
138
+ subject: opts.subject,
139
+ description: opts.description,
140
+ activeForm: opts.activeForm,
141
+ owner: opts.owner,
142
+ status: "pending",
143
+ blocks: [],
144
+ blockedBy: [],
145
+ metadata: opts.metadata
146
+ };
147
+ const taskPath = path.join(dir, `${nextId}.json`);
148
+ try {
149
+ const handle = await fs.open(
150
+ taskPath,
151
+ fsConstants.O_WRONLY | fsConstants.O_CREAT | fsConstants.O_EXCL
152
+ );
153
+ await handle.close();
154
+ } catch (err) {
155
+ if (isNodeError(err) && err.code === "EEXIST") {
156
+ continue;
157
+ }
158
+ throw err;
159
+ }
160
+ try {
161
+ await atomicWriteJSON(taskPath, task);
162
+ } catch (err) {
163
+ await fs.unlink(taskPath).catch(() => {
164
+ });
165
+ throw err;
166
+ }
167
+ notifyTasksUpdated(teamName);
168
+ return task;
169
+ }
170
+ throw new Error(
171
+ `Failed to create task after ${MAX_RETRIES} attempts (ID contention).`
172
+ );
173
+ }
174
+ __name(createTask, "createTask");
175
+ async function getTask(teamName, taskId) {
176
+ const taskPath = getTaskPath(teamName, taskId);
177
+ try {
178
+ const raw = await fs.readFile(taskPath, "utf-8");
179
+ return JSON.parse(raw);
180
+ } catch (err) {
181
+ if (isNodeError(err) && err.code === "ENOENT") return void 0;
182
+ throw err;
183
+ }
184
+ }
185
+ __name(getTask, "getTask");
186
+ var TaskOwnershipError = class extends Error {
187
+ constructor(taskId, callerName, actualOwner) {
188
+ super(
189
+ `Task #${taskId} is owned by "${actualOwner}". Only the leader or the owner can change status / owner / subject / description / blocks.`
190
+ );
191
+ this.taskId = taskId;
192
+ this.callerName = callerName;
193
+ this.actualOwner = actualOwner;
194
+ this.name = "TaskOwnershipError";
195
+ }
196
+ static {
197
+ __name(this, "TaskOwnershipError");
198
+ }
199
+ };
200
+ async function updateTask(teamName, taskId, updates, opts) {
201
+ const taskPath = getTaskPath(teamName, taskId);
202
+ return withTaskFileLock(
203
+ taskPath,
204
+ async () => {
205
+ let raw;
206
+ try {
207
+ raw = await fs.readFile(taskPath, "utf-8");
208
+ } catch (err) {
209
+ if (isNodeError(err) && err.code === "ENOENT") return void 0;
210
+ throw err;
211
+ }
212
+ const task = JSON.parse(raw);
213
+ if (opts?.callerName !== void 0 && opts.callerName !== RECIPROCAL_CALLER) {
214
+ const restrictsOwnership = updates.status !== void 0 || updates.owner !== void 0 || updates.subject !== void 0 || updates.description !== void 0 || (updates.addBlocks?.length ?? 0) > 0 || (updates.addBlockedBy?.length ?? 0) > 0;
215
+ if (restrictsOwnership && task.owner && task.owner !== opts.callerName) {
216
+ throw new TaskOwnershipError(taskId, opts.callerName, task.owner);
217
+ }
218
+ }
219
+ if (updates.addBlocks?.length) {
220
+ const blockSet = new Set(task.blocks);
221
+ for (const id of updates.addBlocks) blockSet.add(id);
222
+ task.blocks = Array.from(blockSet);
223
+ }
224
+ if (updates.addBlockedBy?.length) {
225
+ const blockedBySet = new Set(task.blockedBy);
226
+ for (const id of updates.addBlockedBy) blockedBySet.add(id);
227
+ task.blockedBy = Array.from(blockedBySet);
228
+ }
229
+ if (updates.status !== void 0) {
230
+ task.status = updates.status;
231
+ if (updates.status === "completed" && task.blocks.length > 0) {
232
+ await unblockDependents(teamName, taskId, task.blocks);
233
+ }
234
+ }
235
+ if (updates.owner !== void 0) {
236
+ task.owner = updates.owner ? updates.owner : void 0;
237
+ }
238
+ if (updates.subject !== void 0) {
239
+ task.subject = updates.subject;
240
+ }
241
+ if (updates.description !== void 0) {
242
+ task.description = updates.description;
243
+ }
244
+ if (updates.activeForm !== void 0) {
245
+ task.activeForm = updates.activeForm ?? void 0;
246
+ }
247
+ if (updates.metadata !== void 0) {
248
+ task.metadata = task.metadata ?? {};
249
+ for (const [key, value] of Object.entries(updates.metadata)) {
250
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
251
+ continue;
252
+ }
253
+ if (value === null) {
254
+ delete task.metadata[key];
255
+ } else {
256
+ task.metadata[key] = value;
257
+ }
258
+ }
259
+ if (Object.keys(task.metadata).length === 0) {
260
+ task.metadata = void 0;
261
+ }
262
+ assertMetadataWithinLimit(task.metadata);
263
+ }
264
+ await atomicWriteJSON(taskPath, task);
265
+ notifyTasksUpdated(teamName);
266
+ return task;
267
+ },
268
+ () => void 0
269
+ );
270
+ }
271
+ __name(updateTask, "updateTask");
272
+ async function deleteTask(teamName, taskId, opts) {
273
+ const taskPath = getTaskPath(teamName, taskId);
274
+ const dependentIds = await withTaskFileLock(
275
+ taskPath,
276
+ async () => {
277
+ let task;
278
+ try {
279
+ const raw = await fs.readFile(taskPath, "utf-8");
280
+ task = JSON.parse(raw);
281
+ } catch (err) {
282
+ if (isNodeError(err) && err.code === "ENOENT") return null;
283
+ throw err;
284
+ }
285
+ if (opts?.callerName !== void 0 && task.owner && task.owner !== opts.callerName) {
286
+ throw new TaskOwnershipError(taskId, opts.callerName, task.owner);
287
+ }
288
+ const deps = /* @__PURE__ */ new Set([...task.blocks, ...task.blockedBy]);
289
+ deps.delete(taskId);
290
+ try {
291
+ await fs.unlink(taskPath);
292
+ } catch (err) {
293
+ if (isNodeError(err) && err.code === "ENOENT") return null;
294
+ throw err;
295
+ }
296
+ return deps;
297
+ },
298
+ () => null
299
+ );
300
+ if (dependentIds === null) return false;
301
+ const results = await Promise.allSettled(
302
+ Array.from(dependentIds).map(
303
+ (depId) => removeEdgesReferencing(teamName, depId, taskId)
304
+ )
305
+ );
306
+ for (const r of results) {
307
+ if (r.status === "rejected") {
308
+ debug.warn(`deleteTask(${taskId}): edge cleanup failed: ${r.reason}`);
309
+ }
310
+ }
311
+ notifyTasksUpdated(teamName);
312
+ return true;
313
+ }
314
+ __name(deleteTask, "deleteTask");
315
+ async function removeEdgesReferencing(teamName, targetId, referencedId) {
316
+ const depPath = getTaskPath(teamName, targetId);
317
+ await withTaskFileLock(
318
+ depPath,
319
+ async () => {
320
+ try {
321
+ const raw = await fs.readFile(depPath, "utf-8");
322
+ const task = JSON.parse(raw);
323
+ const beforeBlocks = task.blocks.length;
324
+ const beforeBlockedBy = task.blockedBy.length;
325
+ task.blocks = task.blocks.filter((id) => id !== referencedId);
326
+ task.blockedBy = task.blockedBy.filter((id) => id !== referencedId);
327
+ if (task.blocks.length === beforeBlocks && task.blockedBy.length === beforeBlockedBy) {
328
+ return;
329
+ }
330
+ await atomicWriteJSON(depPath, task);
331
+ } catch (err) {
332
+ if (isNodeError(err) && err.code === "ENOENT") return;
333
+ throw err;
334
+ }
335
+ },
336
+ () => void 0
337
+ );
338
+ }
339
+ __name(removeEdgesReferencing, "removeEdgesReferencing");
340
+ async function listTasks(teamName, filters) {
341
+ const dir = getTasksDir(teamName);
342
+ let entries;
343
+ try {
344
+ entries = await fs.readdir(dir);
345
+ } catch (err) {
346
+ if (isNodeError(err) && err.code === "ENOENT") return [];
347
+ const errMsg = err instanceof Error ? err.message : String(err);
348
+ debug.warn(`Failed to list tasks dir ${dir}: ${errMsg}`);
349
+ throw err instanceof Error ? err : new Error(errMsg);
350
+ }
351
+ const jsonEntries = entries.filter((e) => e.endsWith(".json"));
352
+ const reads = [];
353
+ for (let i = 0; i < jsonEntries.length; i += MAX_PARALLEL_TASK_READS) {
354
+ const batch = jsonEntries.slice(i, i + MAX_PARALLEL_TASK_READS);
355
+ const batchReads = await Promise.all(
356
+ batch.map(async (entry) => {
357
+ const filePath = path.join(dir, entry);
358
+ let raw;
359
+ try {
360
+ raw = await fs.readFile(filePath, "utf-8");
361
+ } catch (err) {
362
+ if (isNodeError(err) && err.code === "ENOENT") return void 0;
363
+ const errMsg = err instanceof Error ? err.message : String(err);
364
+ debug.warn(`Failed to read task file ${filePath}: ${errMsg}`);
365
+ return void 0;
366
+ }
367
+ if (raw.trim() === "") {
368
+ return void 0;
369
+ }
370
+ try {
371
+ return JSON.parse(raw);
372
+ } catch (err) {
373
+ const errMsg = err instanceof Error ? err.message : String(err);
374
+ debug.warn(`Quarantining corrupt task file ${filePath}: ${errMsg}`);
375
+ const quarantined = `${filePath}.corrupt-${Date.now()}`;
376
+ try {
377
+ await fs.rename(filePath, quarantined);
378
+ } catch (renameErr) {
379
+ const renameMsg = renameErr instanceof Error ? renameErr.message : String(renameErr);
380
+ debug.warn(`Failed to quarantine ${filePath}: ${renameMsg}`);
381
+ }
382
+ return void 0;
383
+ }
384
+ })
385
+ );
386
+ reads.push(...batchReads);
387
+ }
388
+ const tasks = reads.filter((t) => t !== void 0);
389
+ tasks.sort((a, b) => Number(a.id) - Number(b.id));
390
+ if (!filters) return tasks;
391
+ return tasks.filter((t) => {
392
+ if (filters.status !== void 0 && t.status !== filters.status) {
393
+ return false;
394
+ }
395
+ if (filters.owner !== void 0 && t.owner !== filters.owner) {
396
+ return false;
397
+ }
398
+ if (filters.blockedBy !== void 0 && !t.blockedBy.includes(filters.blockedBy)) {
399
+ return false;
400
+ }
401
+ return true;
402
+ });
403
+ }
404
+ __name(listTasks, "listTasks");
405
+ async function resetTaskList(teamName) {
406
+ const dir = getTasksDir(teamName);
407
+ await fs.rm(dir, { recursive: true, force: true });
408
+ notifyTasksUpdated(teamName);
409
+ }
410
+ __name(resetTaskList, "resetTaskList");
411
+ async function unblockDependents(teamName, completedId, dependentIds) {
412
+ const results = await Promise.allSettled(
413
+ dependentIds.map(async (depId) => {
414
+ const depPath = getTaskPath(teamName, depId);
415
+ await withTaskFileLock(
416
+ depPath,
417
+ async () => {
418
+ let raw;
419
+ try {
420
+ raw = await fs.readFile(depPath, "utf-8");
421
+ } catch (err) {
422
+ if (isNodeError(err) && err.code === "ENOENT") return;
423
+ throw err;
424
+ }
425
+ const task = JSON.parse(raw);
426
+ const before = task.blockedBy.length;
427
+ task.blockedBy = task.blockedBy.filter((id) => id !== completedId);
428
+ if (task.blockedBy.length === before) return;
429
+ await atomicWriteJSON(depPath, task);
430
+ },
431
+ () => void 0
432
+ );
433
+ })
434
+ );
435
+ for (const r of results) {
436
+ if (r.status === "rejected") {
437
+ debug.warn(`unblockDependents(${completedId}): ${r.reason}`);
438
+ }
439
+ }
440
+ notifyTasksUpdated(teamName);
441
+ }
442
+ __name(unblockDependents, "unblockDependents");
443
+ async function blockTask(teamName, fromId, toId) {
444
+ await updateTask(teamName, fromId, { addBlocks: [toId] });
445
+ await updateTask(teamName, toId, { addBlockedBy: [fromId] });
446
+ }
447
+ __name(blockTask, "blockTask");
448
+ async function claimTask(teamName, taskId, agentId, opts) {
449
+ if (opts?.checkAgentBusy) {
450
+ return getAgentClaimLock(agentId).runExclusive(
451
+ () => claimTaskLocked(teamName, taskId, agentId, opts, true)
452
+ );
453
+ }
454
+ return claimTaskLocked(teamName, taskId, agentId, opts, false);
455
+ }
456
+ __name(claimTask, "claimTask");
457
+ async function claimTaskLocked(teamName, taskId, agentId, opts, checkBusy) {
458
+ if (checkBusy) {
459
+ const busy = await isAgentBusy(teamName, agentId);
460
+ if (busy) return void 0;
461
+ }
462
+ const taskPath = getTaskPath(teamName, taskId);
463
+ return withTaskFileLock(
464
+ taskPath,
465
+ async () => {
466
+ let raw;
467
+ try {
468
+ raw = await fs.readFile(taskPath, "utf-8");
469
+ } catch (err) {
470
+ if (isNodeError(err) && err.code === "ENOENT") return void 0;
471
+ throw err;
472
+ }
473
+ const task = JSON.parse(raw);
474
+ if (task.status !== "pending") return void 0;
475
+ if (task.owner) return void 0;
476
+ task.owner = opts?.ownerName ?? agentId;
477
+ task.status = "in_progress";
478
+ await atomicWriteJSON(taskPath, task);
479
+ notifyTasksUpdated(teamName);
480
+ return task;
481
+ },
482
+ () => void 0
483
+ );
484
+ }
485
+ __name(claimTaskLocked, "claimTaskLocked");
486
+ async function isAgentBusy(teamName, agentId) {
487
+ const inProgress = await listTasks(teamName, {
488
+ status: "in_progress"
489
+ });
490
+ const bareName = agentId.split("@")[0];
491
+ return inProgress.some((t) => t.owner === agentId || t.owner === bareName);
492
+ }
493
+ __name(isAgentBusy, "isAgentBusy");
494
+ async function releaseOwnedTask(teamName, taskId, expectedOwner) {
495
+ const taskPath = getTaskPath(teamName, taskId);
496
+ return withTaskFileLock(
497
+ taskPath,
498
+ async () => {
499
+ let raw;
500
+ try {
501
+ raw = await fs.readFile(taskPath, "utf-8");
502
+ } catch (err) {
503
+ if (isNodeError(err) && err.code === "ENOENT") return false;
504
+ throw err;
505
+ }
506
+ const task = JSON.parse(raw);
507
+ if (task.status !== "in_progress") return false;
508
+ if (task.owner !== expectedOwner) return false;
509
+ task.owner = void 0;
510
+ task.status = "pending";
511
+ await atomicWriteJSON(taskPath, task);
512
+ return true;
513
+ },
514
+ () => false
515
+ );
516
+ }
517
+ __name(releaseOwnedTask, "releaseOwnedTask");
518
+ async function unassignTeammateTasks(teamName, agentId) {
519
+ const bareName = agentId.split("@")[0];
520
+ const inProgress = await listTasks(teamName, {
521
+ status: "in_progress"
522
+ });
523
+ const owned = inProgress.filter(
524
+ (task) => task.owner === agentId || task.owner === bareName
525
+ );
526
+ const results = await Promise.allSettled(
527
+ owned.map((task) => releaseOwnedTask(teamName, task.id, task.owner))
528
+ );
529
+ const failed = results.filter((r) => r.status === "rejected");
530
+ if (failed.length > 0) {
531
+ debug.warn(
532
+ `unassignTeammateTasks: ${failed.length}/${owned.length} task(s) failed to unassign for ${agentId}`
533
+ );
534
+ }
535
+ const released = results.filter(
536
+ (r) => r.status === "fulfilled" && r.value === true
537
+ ).length;
538
+ if (released > 0) {
539
+ notifyTasksUpdated(teamName);
540
+ }
541
+ return released;
542
+ }
543
+ __name(unassignTeammateTasks, "unassignTeammateTasks");
544
+ async function getAgentStatuses(teamName) {
545
+ const tasks = await listTasks(teamName);
546
+ const statuses = /* @__PURE__ */ new Map();
547
+ for (const task of tasks) {
548
+ if (!task.owner) continue;
549
+ const entry = statuses.get(task.owner) ?? {
550
+ inProgress: 0,
551
+ completed: 0
552
+ };
553
+ if (task.status === "in_progress") {
554
+ entry.inProgress++;
555
+ } else if (task.status === "completed") {
556
+ entry.completed++;
557
+ }
558
+ statuses.set(task.owner, entry);
559
+ }
560
+ return statuses;
561
+ }
562
+ __name(getAgentStatuses, "getAgentStatuses");
563
+ async function getNextTaskId(dir) {
564
+ let entries;
565
+ try {
566
+ entries = await fs.readdir(dir);
567
+ } catch {
568
+ return "1";
569
+ }
570
+ let maxId = 0;
571
+ for (const entry of entries) {
572
+ if (!entry.endsWith(".json")) continue;
573
+ const num = parseInt(entry.replace(".json", ""), 10);
574
+ if (!isNaN(num) && num > maxId) {
575
+ maxId = num;
576
+ }
577
+ }
578
+ return String(maxId + 1);
579
+ }
580
+ __name(getNextTaskId, "getNextTaskId");
581
+
582
+ export {
583
+ RECIPROCAL_CALLER,
584
+ assertValidTaskId,
585
+ getTaskPath,
586
+ onTasksUpdated,
587
+ notifyTasksUpdated,
588
+ createTask,
589
+ getTask,
590
+ TaskOwnershipError,
591
+ updateTask,
592
+ deleteTask,
593
+ listTasks,
594
+ resetTaskList,
595
+ blockTask,
596
+ claimTask,
597
+ releaseOwnedTask,
598
+ unassignTeammateTasks,
599
+ getAgentStatuses
600
+ };
601
+ /**
602
+ * @license
603
+ * Copyright 2025 Qwen
604
+ * SPDX-License-Identifier: Apache-2.0
605
+ */
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
  import {
4
4
  createDebugLogger
5
- } from "./chunk-R5PDRHEF.js";
5
+ } from "./chunk-HR7SV7AY.js";
6
6
  import {
7
7
  init_esbuild_shims
8
8
  } from "./chunk-A4BMJM77.js";
@@ -14623,6 +14623,25 @@ var DeclarativeTool = class {
14623
14623
  parametersJsonSchema: this.parameterSchema
14624
14624
  };
14625
14625
  }
14626
+ /**
14627
+ * Max model-facing characters for this tool's output before the scheduler
14628
+ * spills it to disk (mirrors Claude Code's per-tool `maxResultSizeChars`).
14629
+ * - `undefined` → use the global truncation threshold.
14630
+ * - `Infinity` → self-managed (the tool does its own size control, e.g.
14631
+ * ReadFile's line-based paging), exempt from scheduler char truncation.
14632
+ * Override in subclasses to opt into a per-tool budget.
14633
+ */
14634
+ get maxOutputChars() {
14635
+ return void 0;
14636
+ }
14637
+ /**
14638
+ * Direction kept when this tool's oversized output is truncated: `'head'`
14639
+ * (beginning, e.g. shell), `'tail'` (end, e.g. background agents), or
14640
+ * `'both'` (first + last, the default).
14641
+ */
14642
+ get truncateKeep() {
14643
+ return "both";
14644
+ }
14626
14645
  /**
14627
14646
  * Projects tool params for the AUTO approval mode classifier.
14628
14647
  *
@@ -14861,6 +14880,7 @@ var ToolNames = {
14861
14880
  AGENT: "agent",
14862
14881
  SKILL: "skill",
14863
14882
  EXIT_PLAN_MODE: "exit_plan_mode",
14883
+ ENTER_PLAN_MODE: "enter_plan_mode",
14864
14884
  WEB_FETCH: "web_fetch",
14865
14885
  LS: "list_directory",
14866
14886
  LSP: "lsp",
@@ -14869,6 +14889,11 @@ var ToolNames = {
14869
14889
  CRON_LIST: "cron_list",
14870
14890
  CRON_DELETE: "cron_delete",
14871
14891
  TASK_STOP: "task_stop",
14892
+ TASK_CREATE: "task_create",
14893
+ TASK_UPDATE: "task_update",
14894
+ TASK_LIST: "task_list",
14895
+ TEAM_CREATE: "team_create",
14896
+ TEAM_DELETE: "team_delete",
14872
14897
  SEND_MESSAGE: "send_message",
14873
14898
  STRUCTURED_OUTPUT: "structured_output",
14874
14899
  MONITOR: "monitor",
@@ -14887,7 +14912,8 @@ var ToolNames = {
14887
14912
  COMPUTER_USE_DRAG: "computer_use__drag",
14888
14913
  COMPUTER_USE_TYPE_TEXT: "computer_use__type_text",
14889
14914
  COMPUTER_USE_PRESS_KEY: "computer_use__press_key",
14890
- COMPUTER_USE_SET_VALUE: "computer_use__set_value"
14915
+ COMPUTER_USE_SET_VALUE: "computer_use__set_value",
14916
+ WORKFLOW: "workflow"
14891
14917
  };
14892
14918
  var ToolDisplayNames = {
14893
14919
  EDIT: "Edit",
@@ -14901,6 +14927,7 @@ var ToolDisplayNames = {
14901
14927
  AGENT: "Agent",
14902
14928
  SKILL: "Skill",
14903
14929
  EXIT_PLAN_MODE: "ExitPlanMode",
14930
+ ENTER_PLAN_MODE: "EnterPlanMode",
14904
14931
  WEB_FETCH: "WebFetch",
14905
14932
  LS: "ListFiles",
14906
14933
  LSP: "Lsp",
@@ -14909,6 +14936,11 @@ var ToolDisplayNames = {
14909
14936
  CRON_LIST: "CronList",
14910
14937
  CRON_DELETE: "CronDelete",
14911
14938
  TASK_STOP: "TaskStop",
14939
+ TASK_CREATE: "TaskCreate",
14940
+ TASK_UPDATE: "TaskUpdate",
14941
+ TASK_LIST: "TaskList",
14942
+ TEAM_CREATE: "TeamCreate",
14943
+ TEAM_DELETE: "TeamDelete",
14912
14944
  SEND_MESSAGE: "SendMessage",
14913
14945
  STRUCTURED_OUTPUT: "StructuredOutput",
14914
14946
  MONITOR: "Monitor",
@@ -14924,7 +14956,8 @@ var ToolDisplayNames = {
14924
14956
  COMPUTER_USE_DRAG: "computer_use__drag",
14925
14957
  COMPUTER_USE_TYPE_TEXT: "computer_use__type_text",
14926
14958
  COMPUTER_USE_PRESS_KEY: "computer_use__press_key",
14927
- COMPUTER_USE_SET_VALUE: "computer_use__set_value"
14959
+ COMPUTER_USE_SET_VALUE: "computer_use__set_value",
14960
+ WORKFLOW: "Workflow"
14928
14961
  };
14929
14962
  var ToolNamesMigration = {
14930
14963
  search_file_content: ToolNames.GREP,
@@ -1755,6 +1755,7 @@ export {
1755
1755
  context,
1756
1756
  diag2 as diag,
1757
1757
  metrics,
1758
+ propagation,
1758
1759
  trace,
1759
1760
  esm_exports,
1760
1761
  init_esm