@qwen-code/qwen-code 0.18.0-preview.0 → 0.18.0-preview.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundled/qc-helper/SKILL.md +1 -2
- package/bundled/qc-helper/docs/configuration/settings.md +17 -19
- package/bundled/qc-helper/docs/features/_meta.ts +0 -3
- package/bundled/qc-helper/docs/features/commands.md +14 -12
- package/bundled/qc-helper/docs/features/scheduled-tasks.md +1 -1
- package/bundled/qc-helper/docs/features/sub-agents.md +39 -0
- package/chunks/{agent-6J2FFD7S.js → agent-QB7TZ4HW.js} +22 -16
- package/chunks/agent-headless-APVHH7QM.js +50 -0
- package/chunks/{anthropicContentGenerator-4QBVSFSJ.js → anthropicContentGenerator-M45EVVRM.js} +4 -4
- package/chunks/{askUserQuestion-NOOLRWCJ.js → askUserQuestion-WM2KHM3K.js} +2 -2
- package/chunks/{ca-WRHFBIDH.js → ca-BARBRL6N.js} +48 -1
- package/chunks/{chunk-G763GDO6.js → chunk-2ZTWI7KH.js} +15 -3
- package/chunks/chunk-64WXLC72.js +98 -0
- package/chunks/{chunk-UQZQP5PA.js → chunk-7YKXFA3D.js} +11 -11
- package/chunks/chunk-AJIR24J2.js +59 -0
- package/chunks/{chunk-UXBKX55L.js → chunk-AVW55ZCO.js} +61 -23
- package/chunks/{chunk-SHUT5MQY.js → chunk-CNHFPN7T.js} +1 -1
- package/chunks/{chunk-5RNZ2QKF.js → chunk-CNSMKPK6.js} +1 -1
- package/chunks/{chunk-BBTV54KB.js → chunk-CWV3SJZS.js} +2 -2
- package/chunks/{chunk-GBEPNWYB.js → chunk-GX7VH5JQ.js} +1 -1
- package/chunks/chunk-HGJPQK33.js +2231 -0
- package/chunks/chunk-HV3ZZ7G4.js +159 -0
- package/chunks/{chunk-BPZQVC2P.js → chunk-HXJE7VOG.js} +25 -32
- package/chunks/{chunk-PLYZAP4W.js → chunk-ICOI4E4S.js} +1 -1
- package/chunks/{chunk-6VFG3EUJ.js → chunk-JUGRPQAB.js} +1 -1
- package/chunks/{chunk-AVLOK27J.js → chunk-JVQOQ3OU.js} +1 -1
- package/chunks/{chunk-R5PDRHEF.js → chunk-JXAZUMDW.js} +67 -45
- package/chunks/{chunk-UABFCMPA.js → chunk-KC6ZMJ5X.js} +3 -1
- package/chunks/chunk-LD2XBG6Z.js +102 -0
- package/chunks/{chunk-MVX64PNU.js → chunk-LR62TEET.js} +1 -1
- package/chunks/{chunk-JMLIPZUU.js → chunk-MVIVIPCU.js} +3 -3
- package/chunks/{chunk-IKOMHTCC.js → chunk-NW5QBUYO.js} +6 -6
- package/chunks/{chunk-JSYEZAYV.js → chunk-P4J26VDS.js} +2 -2
- package/chunks/{chunk-SCHRFI7O.js → chunk-PAEBHDIO.js} +1 -1
- package/chunks/{chunk-BUOJN3MM.js → chunk-QCG6KPNM.js} +3685 -1897
- package/chunks/chunk-SKBPNJEW.js +45 -0
- package/chunks/{chunk-F5ORN4YO.js → chunk-UAMOBVVW.js} +1 -1
- package/chunks/chunk-XBFVXFB2.js +216 -0
- package/chunks/{chunk-D46KOV3C.js → chunk-Y7R6H6FT.js} +1 -1
- package/chunks/{chunk-3H7ENG2Q.js → chunk-ZK4AMNIU.js} +113 -41
- package/chunks/{computer-use-6LZXL3UW.js → computer-use-B7VIUI7F.js} +22 -16
- package/chunks/contextCommand-63RZ3O5R.js +52 -0
- package/chunks/{cron-create-PIPMXQN4.js → cron-create-FI5LJVUS.js} +2 -2
- package/chunks/{cron-delete-6Y5XIDMS.js → cron-delete-ZGUXWBTG.js} +2 -2
- package/chunks/{cron-list-A4WNRUWZ.js → cron-list-QNNZGMN3.js} +2 -2
- package/chunks/{de-M5RPB2NB.js → de-YGKK2BC4.js} +48 -1
- package/chunks/{edit-J7D6VMPQ.js → edit-6UBTS2J5.js} +23 -17
- package/chunks/{en-UMYKQAZE.js → en-HSQQNQUB.js} +73 -2
- package/chunks/{enter-worktree-NDJTVGYJ.js → enter-worktree-NN7LIXCM.js} +22 -16
- package/chunks/{exit-worktree-UB6XYYAX.js → exit-worktree-GGSS5KIE.js} +22 -16
- package/chunks/{exitPlanMode-V6X2KL4X.js → exitPlanMode-H323NHB2.js} +22 -16
- package/chunks/{fr-MPYXXXPW.js → fr-JXBKPJKQ.js} +48 -1
- package/chunks/{geminiContentGenerator-3AKHMB3P.js → geminiContentGenerator-I4H2NLJG.js} +4 -4
- package/chunks/{glob-PBG5DRG4.js → glob-OLCX57MD.js} +22 -16
- package/chunks/{grep-VQ56EWQ7.js → grep-7HXIMDOW.js} +22 -16
- package/chunks/{ja-NFZ32AB3.js → ja-TGPZSP2B.js} +48 -1
- package/chunks/{keychain-token-storage-UHGOCDD6.js → keychain-token-storage-LB46DAEK.js} +2 -2
- package/chunks/{ls-34DLNYCD.js → ls-6PEZUK6O.js} +3 -3
- package/chunks/{lsp-NCDEHH3V.js → lsp-JZSJOVT7.js} +2 -2
- package/chunks/{monitor-J3YCSOEH.js → monitor-SQO7MVAV.js} +22 -16
- package/chunks/{notebook-edit-AL3CBYJ6.js → notebook-edit-72L3EBAL.js} +23 -17
- package/chunks/{openaiContentGenerator-3U6UARHS.js → openaiContentGenerator-FTR7CDWF.js} +12 -11
- package/chunks/{pt-BR43FRBA.js → pt-TIBG6BIO.js} +48 -1
- package/chunks/{qwenContentGenerator-JRFHJRH6.js → qwenContentGenerator-U5UFQ566.js} +24 -18
- package/chunks/{qwenOAuth2-KRJT35QH.js → qwenOAuth2-EFSECGHF.js} +4 -4
- package/chunks/{read-file-ZF6EIVE3.js → read-file-UA64EEQC.js} +8 -8
- package/chunks/{ripGrep-N2ZT7M6Z.js → ripGrep-WSYCWZVK.js} +22 -16
- package/chunks/{ru-DQCW2KHD.js → ru-JBCHCK4L.js} +48 -1
- package/chunks/{scheduler-OS37FUFT.js → scheduler-VBASHOCA.js} +22 -16
- package/chunks/send-message-OYJZ5TPG.js +244 -0
- package/chunks/{serve-ABOLLDNN.js → serve-A7E2OJDR.js} +45 -36
- package/chunks/{shell-XGN7IDUS.js → shell-3NFOT6F5.js} +22 -16
- package/chunks/{skill-YQQ6CR4U.js → skill-RA5YUREY.js} +10 -10
- package/chunks/{src-LORPPHWB.js → src-NFCMARMT.js} +186 -23
- package/chunks/{syntheticOutput-T5SWX3YF.js → syntheticOutput-DETQ2YM6.js} +3 -3
- package/chunks/task-create-Y3ZKTJIG.js +19 -0
- package/chunks/task-list-ONXJ3I3A.js +151 -0
- package/chunks/{task-stop-3VHAQMYM.js → task-stop-UHDC4N5B.js} +2 -2
- package/chunks/task-update-TCNOU3P5.js +397 -0
- package/chunks/team-create-6SR4OVRG.js +313 -0
- package/chunks/team-delete-EJ4U4DDP.js +114 -0
- package/chunks/{todoWrite-EAGJGKO5.js → todoWrite-TEYDRS5L.js} +4 -4
- package/chunks/{tool-search-PDOJPXJJ.js → tool-search-OD435A3X.js} +8 -8
- package/chunks/{web-fetch-SS6IKK6N.js → web-fetch-6W67H5PO.js} +4 -4
- package/chunks/workflow-62DHH4EO.js +708 -0
- package/chunks/{write-file-VWWCN7LI.js → write-file-475L5OPP.js} +23 -17
- package/chunks/{zh-TW-IQZ4AD5M.js → zh-TW-G3HFHVVT.js} +74 -6
- package/chunks/{zh-6VFXOAR5.js → zh-VCLWO26Y.js} +77 -6
- package/cli.js +6429 -3123
- package/examples/agent/qwen-extension.json +1 -0
- package/examples/commands/qwen-extension.json +1 -0
- package/examples/context/qwen-extension.json +1 -0
- package/examples/mcp-server/qwen-extension.json +1 -0
- package/examples/skills/qwen-extension.json +1 -0
- package/locales/ca.js +51 -0
- package/locales/de.js +51 -0
- package/locales/en.js +83 -2
- package/locales/fr.js +53 -2
- package/locales/ja.js +52 -2
- package/locales/pt.js +52 -2
- package/locales/ru.js +53 -2
- package/locales/zh-TW.js +85 -11
- package/locales/zh.js +89 -11
- package/package.json +2 -2
- package/bundled/qc-helper/docs/features/checkpointing.md +0 -77
- package/chunks/contextCommand-ZV5QQ2LA.js +0 -46
- package/chunks/send-message-YYF56TS7.js +0 -151
|
@@ -0,0 +1,2231 @@
|
|
|
1
|
+
// Force strict mode and setup for ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import {
|
|
4
|
+
getTasksDir
|
|
5
|
+
} from "./chunk-XBFVXFB2.js";
|
|
6
|
+
import {
|
|
7
|
+
atomicWriteJSON
|
|
8
|
+
} from "./chunk-UAMOBVVW.js";
|
|
9
|
+
import {
|
|
10
|
+
createDebugLogger,
|
|
11
|
+
isNodeError
|
|
12
|
+
} from "./chunk-JXAZUMDW.js";
|
|
13
|
+
import {
|
|
14
|
+
init_esbuild_shims
|
|
15
|
+
} from "./chunk-A4BMJM77.js";
|
|
16
|
+
import {
|
|
17
|
+
__commonJS,
|
|
18
|
+
__name,
|
|
19
|
+
__require,
|
|
20
|
+
__toESM
|
|
21
|
+
} from "./chunk-J2S4EL5Y.js";
|
|
22
|
+
|
|
23
|
+
// node_modules/graceful-fs/polyfills.js
|
|
24
|
+
var require_polyfills = __commonJS({
|
|
25
|
+
"node_modules/graceful-fs/polyfills.js"(exports, module) {
|
|
26
|
+
init_esbuild_shims();
|
|
27
|
+
var constants = __require("constants");
|
|
28
|
+
var origCwd = process.cwd;
|
|
29
|
+
var cwd = null;
|
|
30
|
+
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
|
|
31
|
+
process.cwd = function() {
|
|
32
|
+
if (!cwd)
|
|
33
|
+
cwd = origCwd.call(process);
|
|
34
|
+
return cwd;
|
|
35
|
+
};
|
|
36
|
+
try {
|
|
37
|
+
process.cwd();
|
|
38
|
+
} catch (er) {
|
|
39
|
+
}
|
|
40
|
+
if (typeof process.chdir === "function") {
|
|
41
|
+
chdir = process.chdir;
|
|
42
|
+
process.chdir = function(d) {
|
|
43
|
+
cwd = null;
|
|
44
|
+
chdir.call(process, d);
|
|
45
|
+
};
|
|
46
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
|
|
47
|
+
}
|
|
48
|
+
var chdir;
|
|
49
|
+
module.exports = patch;
|
|
50
|
+
function patch(fs2) {
|
|
51
|
+
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
52
|
+
patchLchmod(fs2);
|
|
53
|
+
}
|
|
54
|
+
if (!fs2.lutimes) {
|
|
55
|
+
patchLutimes(fs2);
|
|
56
|
+
}
|
|
57
|
+
fs2.chown = chownFix(fs2.chown);
|
|
58
|
+
fs2.fchown = chownFix(fs2.fchown);
|
|
59
|
+
fs2.lchown = chownFix(fs2.lchown);
|
|
60
|
+
fs2.chmod = chmodFix(fs2.chmod);
|
|
61
|
+
fs2.fchmod = chmodFix(fs2.fchmod);
|
|
62
|
+
fs2.lchmod = chmodFix(fs2.lchmod);
|
|
63
|
+
fs2.chownSync = chownFixSync(fs2.chownSync);
|
|
64
|
+
fs2.fchownSync = chownFixSync(fs2.fchownSync);
|
|
65
|
+
fs2.lchownSync = chownFixSync(fs2.lchownSync);
|
|
66
|
+
fs2.chmodSync = chmodFixSync(fs2.chmodSync);
|
|
67
|
+
fs2.fchmodSync = chmodFixSync(fs2.fchmodSync);
|
|
68
|
+
fs2.lchmodSync = chmodFixSync(fs2.lchmodSync);
|
|
69
|
+
fs2.stat = statFix(fs2.stat);
|
|
70
|
+
fs2.fstat = statFix(fs2.fstat);
|
|
71
|
+
fs2.lstat = statFix(fs2.lstat);
|
|
72
|
+
fs2.statSync = statFixSync(fs2.statSync);
|
|
73
|
+
fs2.fstatSync = statFixSync(fs2.fstatSync);
|
|
74
|
+
fs2.lstatSync = statFixSync(fs2.lstatSync);
|
|
75
|
+
if (fs2.chmod && !fs2.lchmod) {
|
|
76
|
+
fs2.lchmod = function(path2, mode, cb) {
|
|
77
|
+
if (cb) process.nextTick(cb);
|
|
78
|
+
};
|
|
79
|
+
fs2.lchmodSync = function() {
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if (fs2.chown && !fs2.lchown) {
|
|
83
|
+
fs2.lchown = function(path2, uid, gid, cb) {
|
|
84
|
+
if (cb) process.nextTick(cb);
|
|
85
|
+
};
|
|
86
|
+
fs2.lchownSync = function() {
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
if (platform === "win32") {
|
|
90
|
+
fs2.rename = typeof fs2.rename !== "function" ? fs2.rename : function(fs$rename) {
|
|
91
|
+
function rename2(from, to, cb) {
|
|
92
|
+
var start = Date.now();
|
|
93
|
+
var backoff = 0;
|
|
94
|
+
fs$rename(from, to, /* @__PURE__ */ __name(function CB(er) {
|
|
95
|
+
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
|
|
96
|
+
setTimeout(function() {
|
|
97
|
+
fs2.stat(to, function(stater, st) {
|
|
98
|
+
if (stater && stater.code === "ENOENT")
|
|
99
|
+
fs$rename(from, to, CB);
|
|
100
|
+
else
|
|
101
|
+
cb(er);
|
|
102
|
+
});
|
|
103
|
+
}, backoff);
|
|
104
|
+
if (backoff < 100)
|
|
105
|
+
backoff += 10;
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (cb) cb(er);
|
|
109
|
+
}, "CB"));
|
|
110
|
+
}
|
|
111
|
+
__name(rename2, "rename");
|
|
112
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(rename2, fs$rename);
|
|
113
|
+
return rename2;
|
|
114
|
+
}(fs2.rename);
|
|
115
|
+
}
|
|
116
|
+
fs2.read = typeof fs2.read !== "function" ? fs2.read : function(fs$read) {
|
|
117
|
+
function read(fd, buffer, offset, length, position, callback_) {
|
|
118
|
+
var callback;
|
|
119
|
+
if (callback_ && typeof callback_ === "function") {
|
|
120
|
+
var eagCounter = 0;
|
|
121
|
+
callback = /* @__PURE__ */ __name(function(er, _, __) {
|
|
122
|
+
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
|
123
|
+
eagCounter++;
|
|
124
|
+
return fs$read.call(fs2, fd, buffer, offset, length, position, callback);
|
|
125
|
+
}
|
|
126
|
+
callback_.apply(this, arguments);
|
|
127
|
+
}, "callback");
|
|
128
|
+
}
|
|
129
|
+
return fs$read.call(fs2, fd, buffer, offset, length, position, callback);
|
|
130
|
+
}
|
|
131
|
+
__name(read, "read");
|
|
132
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
|
|
133
|
+
return read;
|
|
134
|
+
}(fs2.read);
|
|
135
|
+
fs2.readSync = typeof fs2.readSync !== "function" ? fs2.readSync : /* @__PURE__ */ function(fs$readSync) {
|
|
136
|
+
return function(fd, buffer, offset, length, position) {
|
|
137
|
+
var eagCounter = 0;
|
|
138
|
+
while (true) {
|
|
139
|
+
try {
|
|
140
|
+
return fs$readSync.call(fs2, fd, buffer, offset, length, position);
|
|
141
|
+
} catch (er) {
|
|
142
|
+
if (er.code === "EAGAIN" && eagCounter < 10) {
|
|
143
|
+
eagCounter++;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
throw er;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
}(fs2.readSync);
|
|
151
|
+
function patchLchmod(fs3) {
|
|
152
|
+
fs3.lchmod = function(path2, mode, callback) {
|
|
153
|
+
fs3.open(
|
|
154
|
+
path2,
|
|
155
|
+
constants.O_WRONLY | constants.O_SYMLINK,
|
|
156
|
+
mode,
|
|
157
|
+
function(err, fd) {
|
|
158
|
+
if (err) {
|
|
159
|
+
if (callback) callback(err);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
fs3.fchmod(fd, mode, function(err2) {
|
|
163
|
+
fs3.close(fd, function(err22) {
|
|
164
|
+
if (callback) callback(err2 || err22);
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
};
|
|
170
|
+
fs3.lchmodSync = function(path2, mode) {
|
|
171
|
+
var fd = fs3.openSync(path2, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
172
|
+
var threw = true;
|
|
173
|
+
var ret;
|
|
174
|
+
try {
|
|
175
|
+
ret = fs3.fchmodSync(fd, mode);
|
|
176
|
+
threw = false;
|
|
177
|
+
} finally {
|
|
178
|
+
if (threw) {
|
|
179
|
+
try {
|
|
180
|
+
fs3.closeSync(fd);
|
|
181
|
+
} catch (er) {
|
|
182
|
+
}
|
|
183
|
+
} else {
|
|
184
|
+
fs3.closeSync(fd);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return ret;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
__name(patchLchmod, "patchLchmod");
|
|
191
|
+
function patchLutimes(fs3) {
|
|
192
|
+
if (constants.hasOwnProperty("O_SYMLINK") && fs3.futimes) {
|
|
193
|
+
fs3.lutimes = function(path2, at, mt, cb) {
|
|
194
|
+
fs3.open(path2, constants.O_SYMLINK, function(er, fd) {
|
|
195
|
+
if (er) {
|
|
196
|
+
if (cb) cb(er);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
fs3.futimes(fd, at, mt, function(er2) {
|
|
200
|
+
fs3.close(fd, function(er22) {
|
|
201
|
+
if (cb) cb(er2 || er22);
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
fs3.lutimesSync = function(path2, at, mt) {
|
|
207
|
+
var fd = fs3.openSync(path2, constants.O_SYMLINK);
|
|
208
|
+
var ret;
|
|
209
|
+
var threw = true;
|
|
210
|
+
try {
|
|
211
|
+
ret = fs3.futimesSync(fd, at, mt);
|
|
212
|
+
threw = false;
|
|
213
|
+
} finally {
|
|
214
|
+
if (threw) {
|
|
215
|
+
try {
|
|
216
|
+
fs3.closeSync(fd);
|
|
217
|
+
} catch (er) {
|
|
218
|
+
}
|
|
219
|
+
} else {
|
|
220
|
+
fs3.closeSync(fd);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return ret;
|
|
224
|
+
};
|
|
225
|
+
} else if (fs3.futimes) {
|
|
226
|
+
fs3.lutimes = function(_a, _b, _c, cb) {
|
|
227
|
+
if (cb) process.nextTick(cb);
|
|
228
|
+
};
|
|
229
|
+
fs3.lutimesSync = function() {
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
__name(patchLutimes, "patchLutimes");
|
|
234
|
+
function chmodFix(orig) {
|
|
235
|
+
if (!orig) return orig;
|
|
236
|
+
return function(target, mode, cb) {
|
|
237
|
+
return orig.call(fs2, target, mode, function(er) {
|
|
238
|
+
if (chownErOk(er)) er = null;
|
|
239
|
+
if (cb) cb.apply(this, arguments);
|
|
240
|
+
});
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
__name(chmodFix, "chmodFix");
|
|
244
|
+
function chmodFixSync(orig) {
|
|
245
|
+
if (!orig) return orig;
|
|
246
|
+
return function(target, mode) {
|
|
247
|
+
try {
|
|
248
|
+
return orig.call(fs2, target, mode);
|
|
249
|
+
} catch (er) {
|
|
250
|
+
if (!chownErOk(er)) throw er;
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
__name(chmodFixSync, "chmodFixSync");
|
|
255
|
+
function chownFix(orig) {
|
|
256
|
+
if (!orig) return orig;
|
|
257
|
+
return function(target, uid, gid, cb) {
|
|
258
|
+
return orig.call(fs2, target, uid, gid, function(er) {
|
|
259
|
+
if (chownErOk(er)) er = null;
|
|
260
|
+
if (cb) cb.apply(this, arguments);
|
|
261
|
+
});
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
__name(chownFix, "chownFix");
|
|
265
|
+
function chownFixSync(orig) {
|
|
266
|
+
if (!orig) return orig;
|
|
267
|
+
return function(target, uid, gid) {
|
|
268
|
+
try {
|
|
269
|
+
return orig.call(fs2, target, uid, gid);
|
|
270
|
+
} catch (er) {
|
|
271
|
+
if (!chownErOk(er)) throw er;
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
__name(chownFixSync, "chownFixSync");
|
|
276
|
+
function statFix(orig) {
|
|
277
|
+
if (!orig) return orig;
|
|
278
|
+
return function(target, options, cb) {
|
|
279
|
+
if (typeof options === "function") {
|
|
280
|
+
cb = options;
|
|
281
|
+
options = null;
|
|
282
|
+
}
|
|
283
|
+
function callback(er, stats) {
|
|
284
|
+
if (stats) {
|
|
285
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
286
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
287
|
+
}
|
|
288
|
+
if (cb) cb.apply(this, arguments);
|
|
289
|
+
}
|
|
290
|
+
__name(callback, "callback");
|
|
291
|
+
return options ? orig.call(fs2, target, options, callback) : orig.call(fs2, target, callback);
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
__name(statFix, "statFix");
|
|
295
|
+
function statFixSync(orig) {
|
|
296
|
+
if (!orig) return orig;
|
|
297
|
+
return function(target, options) {
|
|
298
|
+
var stats = options ? orig.call(fs2, target, options) : orig.call(fs2, target);
|
|
299
|
+
if (stats) {
|
|
300
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
301
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
302
|
+
}
|
|
303
|
+
return stats;
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
__name(statFixSync, "statFixSync");
|
|
307
|
+
function chownErOk(er) {
|
|
308
|
+
if (!er)
|
|
309
|
+
return true;
|
|
310
|
+
if (er.code === "ENOSYS")
|
|
311
|
+
return true;
|
|
312
|
+
var nonroot = !process.getuid || process.getuid() !== 0;
|
|
313
|
+
if (nonroot) {
|
|
314
|
+
if (er.code === "EINVAL" || er.code === "EPERM")
|
|
315
|
+
return true;
|
|
316
|
+
}
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
__name(chownErOk, "chownErOk");
|
|
320
|
+
}
|
|
321
|
+
__name(patch, "patch");
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
// node_modules/graceful-fs/legacy-streams.js
|
|
326
|
+
var require_legacy_streams = __commonJS({
|
|
327
|
+
"node_modules/graceful-fs/legacy-streams.js"(exports, module) {
|
|
328
|
+
init_esbuild_shims();
|
|
329
|
+
var Stream = __require("stream").Stream;
|
|
330
|
+
module.exports = legacy;
|
|
331
|
+
function legacy(fs2) {
|
|
332
|
+
return {
|
|
333
|
+
ReadStream,
|
|
334
|
+
WriteStream
|
|
335
|
+
};
|
|
336
|
+
function ReadStream(path2, options) {
|
|
337
|
+
if (!(this instanceof ReadStream)) return new ReadStream(path2, options);
|
|
338
|
+
Stream.call(this);
|
|
339
|
+
var self = this;
|
|
340
|
+
this.path = path2;
|
|
341
|
+
this.fd = null;
|
|
342
|
+
this.readable = true;
|
|
343
|
+
this.paused = false;
|
|
344
|
+
this.flags = "r";
|
|
345
|
+
this.mode = 438;
|
|
346
|
+
this.bufferSize = 64 * 1024;
|
|
347
|
+
options = options || {};
|
|
348
|
+
var keys = Object.keys(options);
|
|
349
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
350
|
+
var key = keys[index];
|
|
351
|
+
this[key] = options[key];
|
|
352
|
+
}
|
|
353
|
+
if (this.encoding) this.setEncoding(this.encoding);
|
|
354
|
+
if (this.start !== void 0) {
|
|
355
|
+
if ("number" !== typeof this.start) {
|
|
356
|
+
throw TypeError("start must be a Number");
|
|
357
|
+
}
|
|
358
|
+
if (this.end === void 0) {
|
|
359
|
+
this.end = Infinity;
|
|
360
|
+
} else if ("number" !== typeof this.end) {
|
|
361
|
+
throw TypeError("end must be a Number");
|
|
362
|
+
}
|
|
363
|
+
if (this.start > this.end) {
|
|
364
|
+
throw new Error("start must be <= end");
|
|
365
|
+
}
|
|
366
|
+
this.pos = this.start;
|
|
367
|
+
}
|
|
368
|
+
if (this.fd !== null) {
|
|
369
|
+
process.nextTick(function() {
|
|
370
|
+
self._read();
|
|
371
|
+
});
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
fs2.open(this.path, this.flags, this.mode, function(err, fd) {
|
|
375
|
+
if (err) {
|
|
376
|
+
self.emit("error", err);
|
|
377
|
+
self.readable = false;
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
self.fd = fd;
|
|
381
|
+
self.emit("open", fd);
|
|
382
|
+
self._read();
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
__name(ReadStream, "ReadStream");
|
|
386
|
+
function WriteStream(path2, options) {
|
|
387
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path2, options);
|
|
388
|
+
Stream.call(this);
|
|
389
|
+
this.path = path2;
|
|
390
|
+
this.fd = null;
|
|
391
|
+
this.writable = true;
|
|
392
|
+
this.flags = "w";
|
|
393
|
+
this.encoding = "binary";
|
|
394
|
+
this.mode = 438;
|
|
395
|
+
this.bytesWritten = 0;
|
|
396
|
+
options = options || {};
|
|
397
|
+
var keys = Object.keys(options);
|
|
398
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
399
|
+
var key = keys[index];
|
|
400
|
+
this[key] = options[key];
|
|
401
|
+
}
|
|
402
|
+
if (this.start !== void 0) {
|
|
403
|
+
if ("number" !== typeof this.start) {
|
|
404
|
+
throw TypeError("start must be a Number");
|
|
405
|
+
}
|
|
406
|
+
if (this.start < 0) {
|
|
407
|
+
throw new Error("start must be >= zero");
|
|
408
|
+
}
|
|
409
|
+
this.pos = this.start;
|
|
410
|
+
}
|
|
411
|
+
this.busy = false;
|
|
412
|
+
this._queue = [];
|
|
413
|
+
if (this.fd === null) {
|
|
414
|
+
this._open = fs2.open;
|
|
415
|
+
this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
|
|
416
|
+
this.flush();
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
__name(WriteStream, "WriteStream");
|
|
420
|
+
}
|
|
421
|
+
__name(legacy, "legacy");
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
// node_modules/graceful-fs/clone.js
|
|
426
|
+
var require_clone = __commonJS({
|
|
427
|
+
"node_modules/graceful-fs/clone.js"(exports, module) {
|
|
428
|
+
"use strict";
|
|
429
|
+
init_esbuild_shims();
|
|
430
|
+
module.exports = clone;
|
|
431
|
+
var getPrototypeOf = Object.getPrototypeOf || function(obj) {
|
|
432
|
+
return obj.__proto__;
|
|
433
|
+
};
|
|
434
|
+
function clone(obj) {
|
|
435
|
+
if (obj === null || typeof obj !== "object")
|
|
436
|
+
return obj;
|
|
437
|
+
if (obj instanceof Object)
|
|
438
|
+
var copy = { __proto__: getPrototypeOf(obj) };
|
|
439
|
+
else
|
|
440
|
+
var copy = /* @__PURE__ */ Object.create(null);
|
|
441
|
+
Object.getOwnPropertyNames(obj).forEach(function(key) {
|
|
442
|
+
Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
|
|
443
|
+
});
|
|
444
|
+
return copy;
|
|
445
|
+
}
|
|
446
|
+
__name(clone, "clone");
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
// node_modules/graceful-fs/graceful-fs.js
|
|
451
|
+
var require_graceful_fs = __commonJS({
|
|
452
|
+
"node_modules/graceful-fs/graceful-fs.js"(exports, module) {
|
|
453
|
+
init_esbuild_shims();
|
|
454
|
+
var fs2 = __require("fs");
|
|
455
|
+
var polyfills = require_polyfills();
|
|
456
|
+
var legacy = require_legacy_streams();
|
|
457
|
+
var clone = require_clone();
|
|
458
|
+
var util = __require("util");
|
|
459
|
+
var gracefulQueue;
|
|
460
|
+
var previousSymbol;
|
|
461
|
+
if (typeof Symbol === "function" && typeof Symbol.for === "function") {
|
|
462
|
+
gracefulQueue = Symbol.for("graceful-fs.queue");
|
|
463
|
+
previousSymbol = Symbol.for("graceful-fs.previous");
|
|
464
|
+
} else {
|
|
465
|
+
gracefulQueue = "___graceful-fs.queue";
|
|
466
|
+
previousSymbol = "___graceful-fs.previous";
|
|
467
|
+
}
|
|
468
|
+
function noop() {
|
|
469
|
+
}
|
|
470
|
+
__name(noop, "noop");
|
|
471
|
+
function publishQueue(context, queue2) {
|
|
472
|
+
Object.defineProperty(context, gracefulQueue, {
|
|
473
|
+
get: /* @__PURE__ */ __name(function() {
|
|
474
|
+
return queue2;
|
|
475
|
+
}, "get")
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
__name(publishQueue, "publishQueue");
|
|
479
|
+
var debug2 = noop;
|
|
480
|
+
if (util.debuglog)
|
|
481
|
+
debug2 = util.debuglog("gfs4");
|
|
482
|
+
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
|
|
483
|
+
debug2 = /* @__PURE__ */ __name(function() {
|
|
484
|
+
var m = util.format.apply(util, arguments);
|
|
485
|
+
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
|
|
486
|
+
console.error(m);
|
|
487
|
+
}, "debug");
|
|
488
|
+
if (!fs2[gracefulQueue]) {
|
|
489
|
+
queue = globalThis[gracefulQueue] || [];
|
|
490
|
+
publishQueue(fs2, queue);
|
|
491
|
+
fs2.close = function(fs$close) {
|
|
492
|
+
function close(fd, cb) {
|
|
493
|
+
return fs$close.call(fs2, fd, function(err) {
|
|
494
|
+
if (!err) {
|
|
495
|
+
resetQueue();
|
|
496
|
+
}
|
|
497
|
+
if (typeof cb === "function")
|
|
498
|
+
cb.apply(this, arguments);
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
__name(close, "close");
|
|
502
|
+
Object.defineProperty(close, previousSymbol, {
|
|
503
|
+
value: fs$close
|
|
504
|
+
});
|
|
505
|
+
return close;
|
|
506
|
+
}(fs2.close);
|
|
507
|
+
fs2.closeSync = function(fs$closeSync) {
|
|
508
|
+
function closeSync(fd) {
|
|
509
|
+
fs$closeSync.apply(fs2, arguments);
|
|
510
|
+
resetQueue();
|
|
511
|
+
}
|
|
512
|
+
__name(closeSync, "closeSync");
|
|
513
|
+
Object.defineProperty(closeSync, previousSymbol, {
|
|
514
|
+
value: fs$closeSync
|
|
515
|
+
});
|
|
516
|
+
return closeSync;
|
|
517
|
+
}(fs2.closeSync);
|
|
518
|
+
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
|
|
519
|
+
process.on("exit", function() {
|
|
520
|
+
debug2(fs2[gracefulQueue]);
|
|
521
|
+
__require("assert").equal(fs2[gracefulQueue].length, 0);
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
var queue;
|
|
526
|
+
if (!globalThis[gracefulQueue]) {
|
|
527
|
+
publishQueue(globalThis, fs2[gracefulQueue]);
|
|
528
|
+
}
|
|
529
|
+
module.exports = patch(clone(fs2));
|
|
530
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs2.__patched) {
|
|
531
|
+
module.exports = patch(fs2);
|
|
532
|
+
fs2.__patched = true;
|
|
533
|
+
}
|
|
534
|
+
function patch(fs3) {
|
|
535
|
+
polyfills(fs3);
|
|
536
|
+
fs3.gracefulify = patch;
|
|
537
|
+
fs3.createReadStream = createReadStream;
|
|
538
|
+
fs3.createWriteStream = createWriteStream;
|
|
539
|
+
var fs$readFile = fs3.readFile;
|
|
540
|
+
fs3.readFile = readFile2;
|
|
541
|
+
function readFile2(path2, options, cb) {
|
|
542
|
+
if (typeof options === "function")
|
|
543
|
+
cb = options, options = null;
|
|
544
|
+
return go$readFile(path2, options, cb);
|
|
545
|
+
function go$readFile(path3, options2, cb2, startTime) {
|
|
546
|
+
return fs$readFile(path3, options2, function(err) {
|
|
547
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
548
|
+
enqueue([go$readFile, [path3, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
549
|
+
else {
|
|
550
|
+
if (typeof cb2 === "function")
|
|
551
|
+
cb2.apply(this, arguments);
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
__name(go$readFile, "go$readFile");
|
|
556
|
+
}
|
|
557
|
+
__name(readFile2, "readFile");
|
|
558
|
+
var fs$writeFile = fs3.writeFile;
|
|
559
|
+
fs3.writeFile = writeFile;
|
|
560
|
+
function writeFile(path2, data, options, cb) {
|
|
561
|
+
if (typeof options === "function")
|
|
562
|
+
cb = options, options = null;
|
|
563
|
+
return go$writeFile(path2, data, options, cb);
|
|
564
|
+
function go$writeFile(path3, data2, options2, cb2, startTime) {
|
|
565
|
+
return fs$writeFile(path3, data2, options2, function(err) {
|
|
566
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
567
|
+
enqueue([go$writeFile, [path3, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
568
|
+
else {
|
|
569
|
+
if (typeof cb2 === "function")
|
|
570
|
+
cb2.apply(this, arguments);
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
__name(go$writeFile, "go$writeFile");
|
|
575
|
+
}
|
|
576
|
+
__name(writeFile, "writeFile");
|
|
577
|
+
var fs$appendFile = fs3.appendFile;
|
|
578
|
+
if (fs$appendFile)
|
|
579
|
+
fs3.appendFile = appendFile;
|
|
580
|
+
function appendFile(path2, data, options, cb) {
|
|
581
|
+
if (typeof options === "function")
|
|
582
|
+
cb = options, options = null;
|
|
583
|
+
return go$appendFile(path2, data, options, cb);
|
|
584
|
+
function go$appendFile(path3, data2, options2, cb2, startTime) {
|
|
585
|
+
return fs$appendFile(path3, data2, options2, function(err) {
|
|
586
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
587
|
+
enqueue([go$appendFile, [path3, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
588
|
+
else {
|
|
589
|
+
if (typeof cb2 === "function")
|
|
590
|
+
cb2.apply(this, arguments);
|
|
591
|
+
}
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
__name(go$appendFile, "go$appendFile");
|
|
595
|
+
}
|
|
596
|
+
__name(appendFile, "appendFile");
|
|
597
|
+
var fs$copyFile = fs3.copyFile;
|
|
598
|
+
if (fs$copyFile)
|
|
599
|
+
fs3.copyFile = copyFile;
|
|
600
|
+
function copyFile(src, dest, flags, cb) {
|
|
601
|
+
if (typeof flags === "function") {
|
|
602
|
+
cb = flags;
|
|
603
|
+
flags = 0;
|
|
604
|
+
}
|
|
605
|
+
return go$copyFile(src, dest, flags, cb);
|
|
606
|
+
function go$copyFile(src2, dest2, flags2, cb2, startTime) {
|
|
607
|
+
return fs$copyFile(src2, dest2, flags2, function(err) {
|
|
608
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
609
|
+
enqueue([go$copyFile, [src2, dest2, flags2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
610
|
+
else {
|
|
611
|
+
if (typeof cb2 === "function")
|
|
612
|
+
cb2.apply(this, arguments);
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
__name(go$copyFile, "go$copyFile");
|
|
617
|
+
}
|
|
618
|
+
__name(copyFile, "copyFile");
|
|
619
|
+
var fs$readdir = fs3.readdir;
|
|
620
|
+
fs3.readdir = readdir2;
|
|
621
|
+
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
622
|
+
function readdir2(path2, options, cb) {
|
|
623
|
+
if (typeof options === "function")
|
|
624
|
+
cb = options, options = null;
|
|
625
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? /* @__PURE__ */ __name(function go$readdir2(path3, options2, cb2, startTime) {
|
|
626
|
+
return fs$readdir(path3, fs$readdirCallback(
|
|
627
|
+
path3,
|
|
628
|
+
options2,
|
|
629
|
+
cb2,
|
|
630
|
+
startTime
|
|
631
|
+
));
|
|
632
|
+
}, "go$readdir") : /* @__PURE__ */ __name(function go$readdir2(path3, options2, cb2, startTime) {
|
|
633
|
+
return fs$readdir(path3, options2, fs$readdirCallback(
|
|
634
|
+
path3,
|
|
635
|
+
options2,
|
|
636
|
+
cb2,
|
|
637
|
+
startTime
|
|
638
|
+
));
|
|
639
|
+
}, "go$readdir");
|
|
640
|
+
return go$readdir(path2, options, cb);
|
|
641
|
+
function fs$readdirCallback(path3, options2, cb2, startTime) {
|
|
642
|
+
return function(err, files) {
|
|
643
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
644
|
+
enqueue([
|
|
645
|
+
go$readdir,
|
|
646
|
+
[path3, options2, cb2],
|
|
647
|
+
err,
|
|
648
|
+
startTime || Date.now(),
|
|
649
|
+
Date.now()
|
|
650
|
+
]);
|
|
651
|
+
else {
|
|
652
|
+
if (files && files.sort)
|
|
653
|
+
files.sort();
|
|
654
|
+
if (typeof cb2 === "function")
|
|
655
|
+
cb2.call(this, err, files);
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
__name(fs$readdirCallback, "fs$readdirCallback");
|
|
660
|
+
}
|
|
661
|
+
__name(readdir2, "readdir");
|
|
662
|
+
if (process.version.substr(0, 4) === "v0.8") {
|
|
663
|
+
var legStreams = legacy(fs3);
|
|
664
|
+
ReadStream = legStreams.ReadStream;
|
|
665
|
+
WriteStream = legStreams.WriteStream;
|
|
666
|
+
}
|
|
667
|
+
var fs$ReadStream = fs3.ReadStream;
|
|
668
|
+
if (fs$ReadStream) {
|
|
669
|
+
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
|
|
670
|
+
ReadStream.prototype.open = ReadStream$open;
|
|
671
|
+
}
|
|
672
|
+
var fs$WriteStream = fs3.WriteStream;
|
|
673
|
+
if (fs$WriteStream) {
|
|
674
|
+
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
|
675
|
+
WriteStream.prototype.open = WriteStream$open;
|
|
676
|
+
}
|
|
677
|
+
Object.defineProperty(fs3, "ReadStream", {
|
|
678
|
+
get: /* @__PURE__ */ __name(function() {
|
|
679
|
+
return ReadStream;
|
|
680
|
+
}, "get"),
|
|
681
|
+
set: /* @__PURE__ */ __name(function(val) {
|
|
682
|
+
ReadStream = val;
|
|
683
|
+
}, "set"),
|
|
684
|
+
enumerable: true,
|
|
685
|
+
configurable: true
|
|
686
|
+
});
|
|
687
|
+
Object.defineProperty(fs3, "WriteStream", {
|
|
688
|
+
get: /* @__PURE__ */ __name(function() {
|
|
689
|
+
return WriteStream;
|
|
690
|
+
}, "get"),
|
|
691
|
+
set: /* @__PURE__ */ __name(function(val) {
|
|
692
|
+
WriteStream = val;
|
|
693
|
+
}, "set"),
|
|
694
|
+
enumerable: true,
|
|
695
|
+
configurable: true
|
|
696
|
+
});
|
|
697
|
+
var FileReadStream = ReadStream;
|
|
698
|
+
Object.defineProperty(fs3, "FileReadStream", {
|
|
699
|
+
get: /* @__PURE__ */ __name(function() {
|
|
700
|
+
return FileReadStream;
|
|
701
|
+
}, "get"),
|
|
702
|
+
set: /* @__PURE__ */ __name(function(val) {
|
|
703
|
+
FileReadStream = val;
|
|
704
|
+
}, "set"),
|
|
705
|
+
enumerable: true,
|
|
706
|
+
configurable: true
|
|
707
|
+
});
|
|
708
|
+
var FileWriteStream = WriteStream;
|
|
709
|
+
Object.defineProperty(fs3, "FileWriteStream", {
|
|
710
|
+
get: /* @__PURE__ */ __name(function() {
|
|
711
|
+
return FileWriteStream;
|
|
712
|
+
}, "get"),
|
|
713
|
+
set: /* @__PURE__ */ __name(function(val) {
|
|
714
|
+
FileWriteStream = val;
|
|
715
|
+
}, "set"),
|
|
716
|
+
enumerable: true,
|
|
717
|
+
configurable: true
|
|
718
|
+
});
|
|
719
|
+
function ReadStream(path2, options) {
|
|
720
|
+
if (this instanceof ReadStream)
|
|
721
|
+
return fs$ReadStream.apply(this, arguments), this;
|
|
722
|
+
else
|
|
723
|
+
return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
|
|
724
|
+
}
|
|
725
|
+
__name(ReadStream, "ReadStream");
|
|
726
|
+
function ReadStream$open() {
|
|
727
|
+
var that = this;
|
|
728
|
+
open2(that.path, that.flags, that.mode, function(err, fd) {
|
|
729
|
+
if (err) {
|
|
730
|
+
if (that.autoClose)
|
|
731
|
+
that.destroy();
|
|
732
|
+
that.emit("error", err);
|
|
733
|
+
} else {
|
|
734
|
+
that.fd = fd;
|
|
735
|
+
that.emit("open", fd);
|
|
736
|
+
that.read();
|
|
737
|
+
}
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
__name(ReadStream$open, "ReadStream$open");
|
|
741
|
+
function WriteStream(path2, options) {
|
|
742
|
+
if (this instanceof WriteStream)
|
|
743
|
+
return fs$WriteStream.apply(this, arguments), this;
|
|
744
|
+
else
|
|
745
|
+
return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
|
|
746
|
+
}
|
|
747
|
+
__name(WriteStream, "WriteStream");
|
|
748
|
+
function WriteStream$open() {
|
|
749
|
+
var that = this;
|
|
750
|
+
open2(that.path, that.flags, that.mode, function(err, fd) {
|
|
751
|
+
if (err) {
|
|
752
|
+
that.destroy();
|
|
753
|
+
that.emit("error", err);
|
|
754
|
+
} else {
|
|
755
|
+
that.fd = fd;
|
|
756
|
+
that.emit("open", fd);
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
__name(WriteStream$open, "WriteStream$open");
|
|
761
|
+
function createReadStream(path2, options) {
|
|
762
|
+
return new fs3.ReadStream(path2, options);
|
|
763
|
+
}
|
|
764
|
+
__name(createReadStream, "createReadStream");
|
|
765
|
+
function createWriteStream(path2, options) {
|
|
766
|
+
return new fs3.WriteStream(path2, options);
|
|
767
|
+
}
|
|
768
|
+
__name(createWriteStream, "createWriteStream");
|
|
769
|
+
var fs$open = fs3.open;
|
|
770
|
+
fs3.open = open2;
|
|
771
|
+
function open2(path2, flags, mode, cb) {
|
|
772
|
+
if (typeof mode === "function")
|
|
773
|
+
cb = mode, mode = null;
|
|
774
|
+
return go$open(path2, flags, mode, cb);
|
|
775
|
+
function go$open(path3, flags2, mode2, cb2, startTime) {
|
|
776
|
+
return fs$open(path3, flags2, mode2, function(err, fd) {
|
|
777
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
778
|
+
enqueue([go$open, [path3, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
779
|
+
else {
|
|
780
|
+
if (typeof cb2 === "function")
|
|
781
|
+
cb2.apply(this, arguments);
|
|
782
|
+
}
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
__name(go$open, "go$open");
|
|
786
|
+
}
|
|
787
|
+
__name(open2, "open");
|
|
788
|
+
return fs3;
|
|
789
|
+
}
|
|
790
|
+
__name(patch, "patch");
|
|
791
|
+
function enqueue(elem) {
|
|
792
|
+
debug2("ENQUEUE", elem[0].name, elem[1]);
|
|
793
|
+
fs2[gracefulQueue].push(elem);
|
|
794
|
+
retry();
|
|
795
|
+
}
|
|
796
|
+
__name(enqueue, "enqueue");
|
|
797
|
+
var retryTimer;
|
|
798
|
+
function resetQueue() {
|
|
799
|
+
var now = Date.now();
|
|
800
|
+
for (var i = 0; i < fs2[gracefulQueue].length; ++i) {
|
|
801
|
+
if (fs2[gracefulQueue][i].length > 2) {
|
|
802
|
+
fs2[gracefulQueue][i][3] = now;
|
|
803
|
+
fs2[gracefulQueue][i][4] = now;
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
retry();
|
|
807
|
+
}
|
|
808
|
+
__name(resetQueue, "resetQueue");
|
|
809
|
+
function retry() {
|
|
810
|
+
clearTimeout(retryTimer);
|
|
811
|
+
retryTimer = void 0;
|
|
812
|
+
if (fs2[gracefulQueue].length === 0)
|
|
813
|
+
return;
|
|
814
|
+
var elem = fs2[gracefulQueue].shift();
|
|
815
|
+
var fn = elem[0];
|
|
816
|
+
var args = elem[1];
|
|
817
|
+
var err = elem[2];
|
|
818
|
+
var startTime = elem[3];
|
|
819
|
+
var lastTime = elem[4];
|
|
820
|
+
if (startTime === void 0) {
|
|
821
|
+
debug2("RETRY", fn.name, args);
|
|
822
|
+
fn.apply(null, args);
|
|
823
|
+
} else if (Date.now() - startTime >= 6e4) {
|
|
824
|
+
debug2("TIMEOUT", fn.name, args);
|
|
825
|
+
var cb = args.pop();
|
|
826
|
+
if (typeof cb === "function")
|
|
827
|
+
cb.call(null, err);
|
|
828
|
+
} else {
|
|
829
|
+
var sinceAttempt = Date.now() - lastTime;
|
|
830
|
+
var sinceStart = Math.max(lastTime - startTime, 1);
|
|
831
|
+
var desiredDelay = Math.min(sinceStart * 1.2, 100);
|
|
832
|
+
if (sinceAttempt >= desiredDelay) {
|
|
833
|
+
debug2("RETRY", fn.name, args);
|
|
834
|
+
fn.apply(null, args.concat([startTime]));
|
|
835
|
+
} else {
|
|
836
|
+
fs2[gracefulQueue].push(elem);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
if (retryTimer === void 0) {
|
|
840
|
+
retryTimer = setTimeout(retry, 0);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
__name(retry, "retry");
|
|
844
|
+
}
|
|
845
|
+
});
|
|
846
|
+
|
|
847
|
+
// node_modules/proper-lockfile/node_modules/retry/lib/retry_operation.js
|
|
848
|
+
var require_retry_operation = __commonJS({
|
|
849
|
+
"node_modules/proper-lockfile/node_modules/retry/lib/retry_operation.js"(exports, module) {
|
|
850
|
+
init_esbuild_shims();
|
|
851
|
+
function RetryOperation(timeouts, options) {
|
|
852
|
+
if (typeof options === "boolean") {
|
|
853
|
+
options = { forever: options };
|
|
854
|
+
}
|
|
855
|
+
this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
|
|
856
|
+
this._timeouts = timeouts;
|
|
857
|
+
this._options = options || {};
|
|
858
|
+
this._maxRetryTime = options && options.maxRetryTime || Infinity;
|
|
859
|
+
this._fn = null;
|
|
860
|
+
this._errors = [];
|
|
861
|
+
this._attempts = 1;
|
|
862
|
+
this._operationTimeout = null;
|
|
863
|
+
this._operationTimeoutCb = null;
|
|
864
|
+
this._timeout = null;
|
|
865
|
+
this._operationStart = null;
|
|
866
|
+
if (this._options.forever) {
|
|
867
|
+
this._cachedTimeouts = this._timeouts.slice(0);
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
__name(RetryOperation, "RetryOperation");
|
|
871
|
+
module.exports = RetryOperation;
|
|
872
|
+
RetryOperation.prototype.reset = function() {
|
|
873
|
+
this._attempts = 1;
|
|
874
|
+
this._timeouts = this._originalTimeouts;
|
|
875
|
+
};
|
|
876
|
+
RetryOperation.prototype.stop = function() {
|
|
877
|
+
if (this._timeout) {
|
|
878
|
+
clearTimeout(this._timeout);
|
|
879
|
+
}
|
|
880
|
+
this._timeouts = [];
|
|
881
|
+
this._cachedTimeouts = null;
|
|
882
|
+
};
|
|
883
|
+
RetryOperation.prototype.retry = function(err) {
|
|
884
|
+
if (this._timeout) {
|
|
885
|
+
clearTimeout(this._timeout);
|
|
886
|
+
}
|
|
887
|
+
if (!err) {
|
|
888
|
+
return false;
|
|
889
|
+
}
|
|
890
|
+
var currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
891
|
+
if (err && currentTime - this._operationStart >= this._maxRetryTime) {
|
|
892
|
+
this._errors.unshift(new Error("RetryOperation timeout occurred"));
|
|
893
|
+
return false;
|
|
894
|
+
}
|
|
895
|
+
this._errors.push(err);
|
|
896
|
+
var timeout = this._timeouts.shift();
|
|
897
|
+
if (timeout === void 0) {
|
|
898
|
+
if (this._cachedTimeouts) {
|
|
899
|
+
this._errors.splice(this._errors.length - 1, this._errors.length);
|
|
900
|
+
this._timeouts = this._cachedTimeouts.slice(0);
|
|
901
|
+
timeout = this._timeouts.shift();
|
|
902
|
+
} else {
|
|
903
|
+
return false;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
var self = this;
|
|
907
|
+
var timer = setTimeout(function() {
|
|
908
|
+
self._attempts++;
|
|
909
|
+
if (self._operationTimeoutCb) {
|
|
910
|
+
self._timeout = setTimeout(function() {
|
|
911
|
+
self._operationTimeoutCb(self._attempts);
|
|
912
|
+
}, self._operationTimeout);
|
|
913
|
+
if (self._options.unref) {
|
|
914
|
+
self._timeout.unref();
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
self._fn(self._attempts);
|
|
918
|
+
}, timeout);
|
|
919
|
+
if (this._options.unref) {
|
|
920
|
+
timer.unref();
|
|
921
|
+
}
|
|
922
|
+
return true;
|
|
923
|
+
};
|
|
924
|
+
RetryOperation.prototype.attempt = function(fn, timeoutOps) {
|
|
925
|
+
this._fn = fn;
|
|
926
|
+
if (timeoutOps) {
|
|
927
|
+
if (timeoutOps.timeout) {
|
|
928
|
+
this._operationTimeout = timeoutOps.timeout;
|
|
929
|
+
}
|
|
930
|
+
if (timeoutOps.cb) {
|
|
931
|
+
this._operationTimeoutCb = timeoutOps.cb;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
var self = this;
|
|
935
|
+
if (this._operationTimeoutCb) {
|
|
936
|
+
this._timeout = setTimeout(function() {
|
|
937
|
+
self._operationTimeoutCb();
|
|
938
|
+
}, self._operationTimeout);
|
|
939
|
+
}
|
|
940
|
+
this._operationStart = (/* @__PURE__ */ new Date()).getTime();
|
|
941
|
+
this._fn(this._attempts);
|
|
942
|
+
};
|
|
943
|
+
RetryOperation.prototype.try = function(fn) {
|
|
944
|
+
console.log("Using RetryOperation.try() is deprecated");
|
|
945
|
+
this.attempt(fn);
|
|
946
|
+
};
|
|
947
|
+
RetryOperation.prototype.start = function(fn) {
|
|
948
|
+
console.log("Using RetryOperation.start() is deprecated");
|
|
949
|
+
this.attempt(fn);
|
|
950
|
+
};
|
|
951
|
+
RetryOperation.prototype.start = RetryOperation.prototype.try;
|
|
952
|
+
RetryOperation.prototype.errors = function() {
|
|
953
|
+
return this._errors;
|
|
954
|
+
};
|
|
955
|
+
RetryOperation.prototype.attempts = function() {
|
|
956
|
+
return this._attempts;
|
|
957
|
+
};
|
|
958
|
+
RetryOperation.prototype.mainError = function() {
|
|
959
|
+
if (this._errors.length === 0) {
|
|
960
|
+
return null;
|
|
961
|
+
}
|
|
962
|
+
var counts = {};
|
|
963
|
+
var mainError = null;
|
|
964
|
+
var mainErrorCount = 0;
|
|
965
|
+
for (var i = 0; i < this._errors.length; i++) {
|
|
966
|
+
var error = this._errors[i];
|
|
967
|
+
var message = error.message;
|
|
968
|
+
var count = (counts[message] || 0) + 1;
|
|
969
|
+
counts[message] = count;
|
|
970
|
+
if (count >= mainErrorCount) {
|
|
971
|
+
mainError = error;
|
|
972
|
+
mainErrorCount = count;
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
return mainError;
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
});
|
|
979
|
+
|
|
980
|
+
// node_modules/proper-lockfile/node_modules/retry/lib/retry.js
|
|
981
|
+
var require_retry = __commonJS({
|
|
982
|
+
"node_modules/proper-lockfile/node_modules/retry/lib/retry.js"(exports) {
|
|
983
|
+
init_esbuild_shims();
|
|
984
|
+
var RetryOperation = require_retry_operation();
|
|
985
|
+
exports.operation = function(options) {
|
|
986
|
+
var timeouts = exports.timeouts(options);
|
|
987
|
+
return new RetryOperation(timeouts, {
|
|
988
|
+
forever: options && options.forever,
|
|
989
|
+
unref: options && options.unref,
|
|
990
|
+
maxRetryTime: options && options.maxRetryTime
|
|
991
|
+
});
|
|
992
|
+
};
|
|
993
|
+
exports.timeouts = function(options) {
|
|
994
|
+
if (options instanceof Array) {
|
|
995
|
+
return [].concat(options);
|
|
996
|
+
}
|
|
997
|
+
var opts = {
|
|
998
|
+
retries: 10,
|
|
999
|
+
factor: 2,
|
|
1000
|
+
minTimeout: 1 * 1e3,
|
|
1001
|
+
maxTimeout: Infinity,
|
|
1002
|
+
randomize: false
|
|
1003
|
+
};
|
|
1004
|
+
for (var key in options) {
|
|
1005
|
+
opts[key] = options[key];
|
|
1006
|
+
}
|
|
1007
|
+
if (opts.minTimeout > opts.maxTimeout) {
|
|
1008
|
+
throw new Error("minTimeout is greater than maxTimeout");
|
|
1009
|
+
}
|
|
1010
|
+
var timeouts = [];
|
|
1011
|
+
for (var i = 0; i < opts.retries; i++) {
|
|
1012
|
+
timeouts.push(this.createTimeout(i, opts));
|
|
1013
|
+
}
|
|
1014
|
+
if (options && options.forever && !timeouts.length) {
|
|
1015
|
+
timeouts.push(this.createTimeout(i, opts));
|
|
1016
|
+
}
|
|
1017
|
+
timeouts.sort(function(a, b) {
|
|
1018
|
+
return a - b;
|
|
1019
|
+
});
|
|
1020
|
+
return timeouts;
|
|
1021
|
+
};
|
|
1022
|
+
exports.createTimeout = function(attempt, opts) {
|
|
1023
|
+
var random = opts.randomize ? Math.random() + 1 : 1;
|
|
1024
|
+
var timeout = Math.round(random * opts.minTimeout * Math.pow(opts.factor, attempt));
|
|
1025
|
+
timeout = Math.min(timeout, opts.maxTimeout);
|
|
1026
|
+
return timeout;
|
|
1027
|
+
};
|
|
1028
|
+
exports.wrap = function(obj, options, methods) {
|
|
1029
|
+
if (options instanceof Array) {
|
|
1030
|
+
methods = options;
|
|
1031
|
+
options = null;
|
|
1032
|
+
}
|
|
1033
|
+
if (!methods) {
|
|
1034
|
+
methods = [];
|
|
1035
|
+
for (var key in obj) {
|
|
1036
|
+
if (typeof obj[key] === "function") {
|
|
1037
|
+
methods.push(key);
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
for (var i = 0; i < methods.length; i++) {
|
|
1042
|
+
var method = methods[i];
|
|
1043
|
+
var original = obj[method];
|
|
1044
|
+
obj[method] = (/* @__PURE__ */ __name(function retryWrapper(original2) {
|
|
1045
|
+
var op = exports.operation(options);
|
|
1046
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
|
1047
|
+
var callback = args.pop();
|
|
1048
|
+
args.push(function(err) {
|
|
1049
|
+
if (op.retry(err)) {
|
|
1050
|
+
return;
|
|
1051
|
+
}
|
|
1052
|
+
if (err) {
|
|
1053
|
+
arguments[0] = op.mainError();
|
|
1054
|
+
}
|
|
1055
|
+
callback.apply(this, arguments);
|
|
1056
|
+
});
|
|
1057
|
+
op.attempt(function() {
|
|
1058
|
+
original2.apply(obj, args);
|
|
1059
|
+
});
|
|
1060
|
+
}, "retryWrapper")).bind(obj, original);
|
|
1061
|
+
obj[method].options = options;
|
|
1062
|
+
}
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1065
|
+
});
|
|
1066
|
+
|
|
1067
|
+
// node_modules/proper-lockfile/node_modules/retry/index.js
|
|
1068
|
+
var require_retry2 = __commonJS({
|
|
1069
|
+
"node_modules/proper-lockfile/node_modules/retry/index.js"(exports, module) {
|
|
1070
|
+
init_esbuild_shims();
|
|
1071
|
+
module.exports = require_retry();
|
|
1072
|
+
}
|
|
1073
|
+
});
|
|
1074
|
+
|
|
1075
|
+
// node_modules/proper-lockfile/node_modules/signal-exit/signals.js
|
|
1076
|
+
var require_signals = __commonJS({
|
|
1077
|
+
"node_modules/proper-lockfile/node_modules/signal-exit/signals.js"(exports, module) {
|
|
1078
|
+
init_esbuild_shims();
|
|
1079
|
+
module.exports = [
|
|
1080
|
+
"SIGABRT",
|
|
1081
|
+
"SIGALRM",
|
|
1082
|
+
"SIGHUP",
|
|
1083
|
+
"SIGINT",
|
|
1084
|
+
"SIGTERM"
|
|
1085
|
+
];
|
|
1086
|
+
if (process.platform !== "win32") {
|
|
1087
|
+
module.exports.push(
|
|
1088
|
+
"SIGVTALRM",
|
|
1089
|
+
"SIGXCPU",
|
|
1090
|
+
"SIGXFSZ",
|
|
1091
|
+
"SIGUSR2",
|
|
1092
|
+
"SIGTRAP",
|
|
1093
|
+
"SIGSYS",
|
|
1094
|
+
"SIGQUIT",
|
|
1095
|
+
"SIGIOT"
|
|
1096
|
+
// should detect profiler and enable/disable accordingly.
|
|
1097
|
+
// see #21
|
|
1098
|
+
// 'SIGPROF'
|
|
1099
|
+
);
|
|
1100
|
+
}
|
|
1101
|
+
if (process.platform === "linux") {
|
|
1102
|
+
module.exports.push(
|
|
1103
|
+
"SIGIO",
|
|
1104
|
+
"SIGPOLL",
|
|
1105
|
+
"SIGPWR",
|
|
1106
|
+
"SIGSTKFLT",
|
|
1107
|
+
"SIGUNUSED"
|
|
1108
|
+
);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
});
|
|
1112
|
+
|
|
1113
|
+
// node_modules/proper-lockfile/node_modules/signal-exit/index.js
|
|
1114
|
+
var require_signal_exit = __commonJS({
|
|
1115
|
+
"node_modules/proper-lockfile/node_modules/signal-exit/index.js"(exports, module) {
|
|
1116
|
+
init_esbuild_shims();
|
|
1117
|
+
var process2 = globalThis.process;
|
|
1118
|
+
var processOk = /* @__PURE__ */ __name(function(process3) {
|
|
1119
|
+
return process3 && typeof process3 === "object" && typeof process3.removeListener === "function" && typeof process3.emit === "function" && typeof process3.reallyExit === "function" && typeof process3.listeners === "function" && typeof process3.kill === "function" && typeof process3.pid === "number" && typeof process3.on === "function";
|
|
1120
|
+
}, "processOk");
|
|
1121
|
+
if (!processOk(process2)) {
|
|
1122
|
+
module.exports = function() {
|
|
1123
|
+
return function() {
|
|
1124
|
+
};
|
|
1125
|
+
};
|
|
1126
|
+
} else {
|
|
1127
|
+
assert = __require("assert");
|
|
1128
|
+
signals = require_signals();
|
|
1129
|
+
isWin = /^win/i.test(process2.platform);
|
|
1130
|
+
EE = __require("events");
|
|
1131
|
+
if (typeof EE !== "function") {
|
|
1132
|
+
EE = EE.EventEmitter;
|
|
1133
|
+
}
|
|
1134
|
+
if (process2.__signal_exit_emitter__) {
|
|
1135
|
+
emitter = process2.__signal_exit_emitter__;
|
|
1136
|
+
} else {
|
|
1137
|
+
emitter = process2.__signal_exit_emitter__ = new EE();
|
|
1138
|
+
emitter.count = 0;
|
|
1139
|
+
emitter.emitted = {};
|
|
1140
|
+
}
|
|
1141
|
+
if (!emitter.infinite) {
|
|
1142
|
+
emitter.setMaxListeners(Infinity);
|
|
1143
|
+
emitter.infinite = true;
|
|
1144
|
+
}
|
|
1145
|
+
module.exports = function(cb, opts) {
|
|
1146
|
+
if (!processOk(globalThis.process)) {
|
|
1147
|
+
return function() {
|
|
1148
|
+
};
|
|
1149
|
+
}
|
|
1150
|
+
assert.equal(typeof cb, "function", "a callback must be provided for exit handler");
|
|
1151
|
+
if (loaded === false) {
|
|
1152
|
+
load();
|
|
1153
|
+
}
|
|
1154
|
+
var ev = "exit";
|
|
1155
|
+
if (opts && opts.alwaysLast) {
|
|
1156
|
+
ev = "afterexit";
|
|
1157
|
+
}
|
|
1158
|
+
var remove = /* @__PURE__ */ __name(function() {
|
|
1159
|
+
emitter.removeListener(ev, cb);
|
|
1160
|
+
if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
|
|
1161
|
+
unload();
|
|
1162
|
+
}
|
|
1163
|
+
}, "remove");
|
|
1164
|
+
emitter.on(ev, cb);
|
|
1165
|
+
return remove;
|
|
1166
|
+
};
|
|
1167
|
+
unload = /* @__PURE__ */ __name(function unload2() {
|
|
1168
|
+
if (!loaded || !processOk(globalThis.process)) {
|
|
1169
|
+
return;
|
|
1170
|
+
}
|
|
1171
|
+
loaded = false;
|
|
1172
|
+
signals.forEach(function(sig) {
|
|
1173
|
+
try {
|
|
1174
|
+
process2.removeListener(sig, sigListeners[sig]);
|
|
1175
|
+
} catch (er) {
|
|
1176
|
+
}
|
|
1177
|
+
});
|
|
1178
|
+
process2.emit = originalProcessEmit;
|
|
1179
|
+
process2.reallyExit = originalProcessReallyExit;
|
|
1180
|
+
emitter.count -= 1;
|
|
1181
|
+
}, "unload");
|
|
1182
|
+
module.exports.unload = unload;
|
|
1183
|
+
emit = /* @__PURE__ */ __name(function emit2(event, code, signal) {
|
|
1184
|
+
if (emitter.emitted[event]) {
|
|
1185
|
+
return;
|
|
1186
|
+
}
|
|
1187
|
+
emitter.emitted[event] = true;
|
|
1188
|
+
emitter.emit(event, code, signal);
|
|
1189
|
+
}, "emit");
|
|
1190
|
+
sigListeners = {};
|
|
1191
|
+
signals.forEach(function(sig) {
|
|
1192
|
+
sigListeners[sig] = /* @__PURE__ */ __name(function listener() {
|
|
1193
|
+
if (!processOk(globalThis.process)) {
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
var listeners2 = process2.listeners(sig);
|
|
1197
|
+
if (listeners2.length === emitter.count) {
|
|
1198
|
+
unload();
|
|
1199
|
+
emit("exit", null, sig);
|
|
1200
|
+
emit("afterexit", null, sig);
|
|
1201
|
+
if (isWin && sig === "SIGHUP") {
|
|
1202
|
+
sig = "SIGINT";
|
|
1203
|
+
}
|
|
1204
|
+
process2.kill(process2.pid, sig);
|
|
1205
|
+
}
|
|
1206
|
+
}, "listener");
|
|
1207
|
+
});
|
|
1208
|
+
module.exports.signals = function() {
|
|
1209
|
+
return signals;
|
|
1210
|
+
};
|
|
1211
|
+
loaded = false;
|
|
1212
|
+
load = /* @__PURE__ */ __name(function load2() {
|
|
1213
|
+
if (loaded || !processOk(globalThis.process)) {
|
|
1214
|
+
return;
|
|
1215
|
+
}
|
|
1216
|
+
loaded = true;
|
|
1217
|
+
emitter.count += 1;
|
|
1218
|
+
signals = signals.filter(function(sig) {
|
|
1219
|
+
try {
|
|
1220
|
+
process2.on(sig, sigListeners[sig]);
|
|
1221
|
+
return true;
|
|
1222
|
+
} catch (er) {
|
|
1223
|
+
return false;
|
|
1224
|
+
}
|
|
1225
|
+
});
|
|
1226
|
+
process2.emit = processEmit;
|
|
1227
|
+
process2.reallyExit = processReallyExit;
|
|
1228
|
+
}, "load");
|
|
1229
|
+
module.exports.load = load;
|
|
1230
|
+
originalProcessReallyExit = process2.reallyExit;
|
|
1231
|
+
processReallyExit = /* @__PURE__ */ __name(function processReallyExit2(code) {
|
|
1232
|
+
if (!processOk(globalThis.process)) {
|
|
1233
|
+
return;
|
|
1234
|
+
}
|
|
1235
|
+
process2.exitCode = code || /* istanbul ignore next */
|
|
1236
|
+
0;
|
|
1237
|
+
emit("exit", process2.exitCode, null);
|
|
1238
|
+
emit("afterexit", process2.exitCode, null);
|
|
1239
|
+
originalProcessReallyExit.call(process2, process2.exitCode);
|
|
1240
|
+
}, "processReallyExit");
|
|
1241
|
+
originalProcessEmit = process2.emit;
|
|
1242
|
+
processEmit = /* @__PURE__ */ __name(function processEmit2(ev, arg) {
|
|
1243
|
+
if (ev === "exit" && processOk(globalThis.process)) {
|
|
1244
|
+
if (arg !== void 0) {
|
|
1245
|
+
process2.exitCode = arg;
|
|
1246
|
+
}
|
|
1247
|
+
var ret = originalProcessEmit.apply(this, arguments);
|
|
1248
|
+
emit("exit", process2.exitCode, null);
|
|
1249
|
+
emit("afterexit", process2.exitCode, null);
|
|
1250
|
+
return ret;
|
|
1251
|
+
} else {
|
|
1252
|
+
return originalProcessEmit.apply(this, arguments);
|
|
1253
|
+
}
|
|
1254
|
+
}, "processEmit");
|
|
1255
|
+
}
|
|
1256
|
+
var assert;
|
|
1257
|
+
var signals;
|
|
1258
|
+
var isWin;
|
|
1259
|
+
var EE;
|
|
1260
|
+
var emitter;
|
|
1261
|
+
var unload;
|
|
1262
|
+
var emit;
|
|
1263
|
+
var sigListeners;
|
|
1264
|
+
var loaded;
|
|
1265
|
+
var load;
|
|
1266
|
+
var originalProcessReallyExit;
|
|
1267
|
+
var processReallyExit;
|
|
1268
|
+
var originalProcessEmit;
|
|
1269
|
+
var processEmit;
|
|
1270
|
+
}
|
|
1271
|
+
});
|
|
1272
|
+
|
|
1273
|
+
// node_modules/proper-lockfile/lib/mtime-precision.js
|
|
1274
|
+
var require_mtime_precision = __commonJS({
|
|
1275
|
+
"node_modules/proper-lockfile/lib/mtime-precision.js"(exports, module) {
|
|
1276
|
+
"use strict";
|
|
1277
|
+
init_esbuild_shims();
|
|
1278
|
+
var cacheSymbol = Symbol();
|
|
1279
|
+
function probe(file, fs2, callback) {
|
|
1280
|
+
const cachedPrecision = fs2[cacheSymbol];
|
|
1281
|
+
if (cachedPrecision) {
|
|
1282
|
+
return fs2.stat(file, (err, stat) => {
|
|
1283
|
+
if (err) {
|
|
1284
|
+
return callback(err);
|
|
1285
|
+
}
|
|
1286
|
+
callback(null, stat.mtime, cachedPrecision);
|
|
1287
|
+
});
|
|
1288
|
+
}
|
|
1289
|
+
const mtime = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
|
|
1290
|
+
fs2.utimes(file, mtime, mtime, (err) => {
|
|
1291
|
+
if (err) {
|
|
1292
|
+
return callback(err);
|
|
1293
|
+
}
|
|
1294
|
+
fs2.stat(file, (err2, stat) => {
|
|
1295
|
+
if (err2) {
|
|
1296
|
+
return callback(err2);
|
|
1297
|
+
}
|
|
1298
|
+
const precision = stat.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
|
|
1299
|
+
Object.defineProperty(fs2, cacheSymbol, { value: precision });
|
|
1300
|
+
callback(null, stat.mtime, precision);
|
|
1301
|
+
});
|
|
1302
|
+
});
|
|
1303
|
+
}
|
|
1304
|
+
__name(probe, "probe");
|
|
1305
|
+
function getMtime(precision) {
|
|
1306
|
+
let now = Date.now();
|
|
1307
|
+
if (precision === "s") {
|
|
1308
|
+
now = Math.ceil(now / 1e3) * 1e3;
|
|
1309
|
+
}
|
|
1310
|
+
return new Date(now);
|
|
1311
|
+
}
|
|
1312
|
+
__name(getMtime, "getMtime");
|
|
1313
|
+
module.exports.probe = probe;
|
|
1314
|
+
module.exports.getMtime = getMtime;
|
|
1315
|
+
}
|
|
1316
|
+
});
|
|
1317
|
+
|
|
1318
|
+
// node_modules/proper-lockfile/lib/lockfile.js
|
|
1319
|
+
var require_lockfile = __commonJS({
|
|
1320
|
+
"node_modules/proper-lockfile/lib/lockfile.js"(exports, module) {
|
|
1321
|
+
"use strict";
|
|
1322
|
+
init_esbuild_shims();
|
|
1323
|
+
var path2 = __require("path");
|
|
1324
|
+
var fs2 = require_graceful_fs();
|
|
1325
|
+
var retry = require_retry2();
|
|
1326
|
+
var onExit = require_signal_exit();
|
|
1327
|
+
var mtimePrecision = require_mtime_precision();
|
|
1328
|
+
var locks = {};
|
|
1329
|
+
function getLockFile(file, options) {
|
|
1330
|
+
return options.lockfilePath || `${file}.lock`;
|
|
1331
|
+
}
|
|
1332
|
+
__name(getLockFile, "getLockFile");
|
|
1333
|
+
function resolveCanonicalPath(file, options, callback) {
|
|
1334
|
+
if (!options.realpath) {
|
|
1335
|
+
return callback(null, path2.resolve(file));
|
|
1336
|
+
}
|
|
1337
|
+
options.fs.realpath(file, callback);
|
|
1338
|
+
}
|
|
1339
|
+
__name(resolveCanonicalPath, "resolveCanonicalPath");
|
|
1340
|
+
function acquireLock(file, options, callback) {
|
|
1341
|
+
const lockfilePath = getLockFile(file, options);
|
|
1342
|
+
options.fs.mkdir(lockfilePath, (err) => {
|
|
1343
|
+
if (!err) {
|
|
1344
|
+
return mtimePrecision.probe(lockfilePath, options.fs, (err2, mtime, mtimePrecision2) => {
|
|
1345
|
+
if (err2) {
|
|
1346
|
+
options.fs.rmdir(lockfilePath, () => {
|
|
1347
|
+
});
|
|
1348
|
+
return callback(err2);
|
|
1349
|
+
}
|
|
1350
|
+
callback(null, mtime, mtimePrecision2);
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1353
|
+
if (err.code !== "EEXIST") {
|
|
1354
|
+
return callback(err);
|
|
1355
|
+
}
|
|
1356
|
+
if (options.stale <= 0) {
|
|
1357
|
+
return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
|
|
1358
|
+
}
|
|
1359
|
+
options.fs.stat(lockfilePath, (err2, stat) => {
|
|
1360
|
+
if (err2) {
|
|
1361
|
+
if (err2.code === "ENOENT") {
|
|
1362
|
+
return acquireLock(file, { ...options, stale: 0 }, callback);
|
|
1363
|
+
}
|
|
1364
|
+
return callback(err2);
|
|
1365
|
+
}
|
|
1366
|
+
if (!isLockStale(stat, options)) {
|
|
1367
|
+
return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
|
|
1368
|
+
}
|
|
1369
|
+
removeLock(file, options, (err3) => {
|
|
1370
|
+
if (err3) {
|
|
1371
|
+
return callback(err3);
|
|
1372
|
+
}
|
|
1373
|
+
acquireLock(file, { ...options, stale: 0 }, callback);
|
|
1374
|
+
});
|
|
1375
|
+
});
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
1378
|
+
__name(acquireLock, "acquireLock");
|
|
1379
|
+
function isLockStale(stat, options) {
|
|
1380
|
+
return stat.mtime.getTime() < Date.now() - options.stale;
|
|
1381
|
+
}
|
|
1382
|
+
__name(isLockStale, "isLockStale");
|
|
1383
|
+
function removeLock(file, options, callback) {
|
|
1384
|
+
options.fs.rmdir(getLockFile(file, options), (err) => {
|
|
1385
|
+
if (err && err.code !== "ENOENT") {
|
|
1386
|
+
return callback(err);
|
|
1387
|
+
}
|
|
1388
|
+
callback();
|
|
1389
|
+
});
|
|
1390
|
+
}
|
|
1391
|
+
__name(removeLock, "removeLock");
|
|
1392
|
+
function updateLock(file, options) {
|
|
1393
|
+
const lock2 = locks[file];
|
|
1394
|
+
if (lock2.updateTimeout) {
|
|
1395
|
+
return;
|
|
1396
|
+
}
|
|
1397
|
+
lock2.updateDelay = lock2.updateDelay || options.update;
|
|
1398
|
+
lock2.updateTimeout = setTimeout(() => {
|
|
1399
|
+
lock2.updateTimeout = null;
|
|
1400
|
+
options.fs.stat(lock2.lockfilePath, (err, stat) => {
|
|
1401
|
+
const isOverThreshold = lock2.lastUpdate + options.stale < Date.now();
|
|
1402
|
+
if (err) {
|
|
1403
|
+
if (err.code === "ENOENT" || isOverThreshold) {
|
|
1404
|
+
return setLockAsCompromised(file, lock2, Object.assign(err, { code: "ECOMPROMISED" }));
|
|
1405
|
+
}
|
|
1406
|
+
lock2.updateDelay = 1e3;
|
|
1407
|
+
return updateLock(file, options);
|
|
1408
|
+
}
|
|
1409
|
+
const isMtimeOurs = lock2.mtime.getTime() === stat.mtime.getTime();
|
|
1410
|
+
if (!isMtimeOurs) {
|
|
1411
|
+
return setLockAsCompromised(
|
|
1412
|
+
file,
|
|
1413
|
+
lock2,
|
|
1414
|
+
Object.assign(
|
|
1415
|
+
new Error("Unable to update lock within the stale threshold"),
|
|
1416
|
+
{ code: "ECOMPROMISED" }
|
|
1417
|
+
)
|
|
1418
|
+
);
|
|
1419
|
+
}
|
|
1420
|
+
const mtime = mtimePrecision.getMtime(lock2.mtimePrecision);
|
|
1421
|
+
options.fs.utimes(lock2.lockfilePath, mtime, mtime, (err2) => {
|
|
1422
|
+
const isOverThreshold2 = lock2.lastUpdate + options.stale < Date.now();
|
|
1423
|
+
if (lock2.released) {
|
|
1424
|
+
return;
|
|
1425
|
+
}
|
|
1426
|
+
if (err2) {
|
|
1427
|
+
if (err2.code === "ENOENT" || isOverThreshold2) {
|
|
1428
|
+
return setLockAsCompromised(file, lock2, Object.assign(err2, { code: "ECOMPROMISED" }));
|
|
1429
|
+
}
|
|
1430
|
+
lock2.updateDelay = 1e3;
|
|
1431
|
+
return updateLock(file, options);
|
|
1432
|
+
}
|
|
1433
|
+
lock2.mtime = mtime;
|
|
1434
|
+
lock2.lastUpdate = Date.now();
|
|
1435
|
+
lock2.updateDelay = null;
|
|
1436
|
+
updateLock(file, options);
|
|
1437
|
+
});
|
|
1438
|
+
});
|
|
1439
|
+
}, lock2.updateDelay);
|
|
1440
|
+
if (lock2.updateTimeout.unref) {
|
|
1441
|
+
lock2.updateTimeout.unref();
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
__name(updateLock, "updateLock");
|
|
1445
|
+
function setLockAsCompromised(file, lock2, err) {
|
|
1446
|
+
lock2.released = true;
|
|
1447
|
+
if (lock2.updateTimeout) {
|
|
1448
|
+
clearTimeout(lock2.updateTimeout);
|
|
1449
|
+
}
|
|
1450
|
+
if (locks[file] === lock2) {
|
|
1451
|
+
delete locks[file];
|
|
1452
|
+
}
|
|
1453
|
+
lock2.options.onCompromised(err);
|
|
1454
|
+
}
|
|
1455
|
+
__name(setLockAsCompromised, "setLockAsCompromised");
|
|
1456
|
+
function lock(file, options, callback) {
|
|
1457
|
+
options = {
|
|
1458
|
+
stale: 1e4,
|
|
1459
|
+
update: null,
|
|
1460
|
+
realpath: true,
|
|
1461
|
+
retries: 0,
|
|
1462
|
+
fs: fs2,
|
|
1463
|
+
onCompromised: /* @__PURE__ */ __name((err) => {
|
|
1464
|
+
throw err;
|
|
1465
|
+
}, "onCompromised"),
|
|
1466
|
+
...options
|
|
1467
|
+
};
|
|
1468
|
+
options.retries = options.retries || 0;
|
|
1469
|
+
options.retries = typeof options.retries === "number" ? { retries: options.retries } : options.retries;
|
|
1470
|
+
options.stale = Math.max(options.stale || 0, 2e3);
|
|
1471
|
+
options.update = options.update == null ? options.stale / 2 : options.update || 0;
|
|
1472
|
+
options.update = Math.max(Math.min(options.update, options.stale / 2), 1e3);
|
|
1473
|
+
resolveCanonicalPath(file, options, (err, file2) => {
|
|
1474
|
+
if (err) {
|
|
1475
|
+
return callback(err);
|
|
1476
|
+
}
|
|
1477
|
+
const operation = retry.operation(options.retries);
|
|
1478
|
+
operation.attempt(() => {
|
|
1479
|
+
acquireLock(file2, options, (err2, mtime, mtimePrecision2) => {
|
|
1480
|
+
if (operation.retry(err2)) {
|
|
1481
|
+
return;
|
|
1482
|
+
}
|
|
1483
|
+
if (err2) {
|
|
1484
|
+
return callback(operation.mainError());
|
|
1485
|
+
}
|
|
1486
|
+
const lock2 = locks[file2] = {
|
|
1487
|
+
lockfilePath: getLockFile(file2, options),
|
|
1488
|
+
mtime,
|
|
1489
|
+
mtimePrecision: mtimePrecision2,
|
|
1490
|
+
options,
|
|
1491
|
+
lastUpdate: Date.now()
|
|
1492
|
+
};
|
|
1493
|
+
updateLock(file2, options);
|
|
1494
|
+
callback(null, (releasedCallback) => {
|
|
1495
|
+
if (lock2.released) {
|
|
1496
|
+
return releasedCallback && releasedCallback(Object.assign(new Error("Lock is already released"), { code: "ERELEASED" }));
|
|
1497
|
+
}
|
|
1498
|
+
unlock(file2, { ...options, realpath: false }, releasedCallback);
|
|
1499
|
+
});
|
|
1500
|
+
});
|
|
1501
|
+
});
|
|
1502
|
+
});
|
|
1503
|
+
}
|
|
1504
|
+
__name(lock, "lock");
|
|
1505
|
+
function unlock(file, options, callback) {
|
|
1506
|
+
options = {
|
|
1507
|
+
fs: fs2,
|
|
1508
|
+
realpath: true,
|
|
1509
|
+
...options
|
|
1510
|
+
};
|
|
1511
|
+
resolveCanonicalPath(file, options, (err, file2) => {
|
|
1512
|
+
if (err) {
|
|
1513
|
+
return callback(err);
|
|
1514
|
+
}
|
|
1515
|
+
const lock2 = locks[file2];
|
|
1516
|
+
if (!lock2) {
|
|
1517
|
+
return callback(Object.assign(new Error("Lock is not acquired/owned by you"), { code: "ENOTACQUIRED" }));
|
|
1518
|
+
}
|
|
1519
|
+
lock2.updateTimeout && clearTimeout(lock2.updateTimeout);
|
|
1520
|
+
lock2.released = true;
|
|
1521
|
+
delete locks[file2];
|
|
1522
|
+
removeLock(file2, options, callback);
|
|
1523
|
+
});
|
|
1524
|
+
}
|
|
1525
|
+
__name(unlock, "unlock");
|
|
1526
|
+
function check(file, options, callback) {
|
|
1527
|
+
options = {
|
|
1528
|
+
stale: 1e4,
|
|
1529
|
+
realpath: true,
|
|
1530
|
+
fs: fs2,
|
|
1531
|
+
...options
|
|
1532
|
+
};
|
|
1533
|
+
options.stale = Math.max(options.stale || 0, 2e3);
|
|
1534
|
+
resolveCanonicalPath(file, options, (err, file2) => {
|
|
1535
|
+
if (err) {
|
|
1536
|
+
return callback(err);
|
|
1537
|
+
}
|
|
1538
|
+
options.fs.stat(getLockFile(file2, options), (err2, stat) => {
|
|
1539
|
+
if (err2) {
|
|
1540
|
+
return err2.code === "ENOENT" ? callback(null, false) : callback(err2);
|
|
1541
|
+
}
|
|
1542
|
+
return callback(null, !isLockStale(stat, options));
|
|
1543
|
+
});
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1546
|
+
__name(check, "check");
|
|
1547
|
+
function getLocks() {
|
|
1548
|
+
return locks;
|
|
1549
|
+
}
|
|
1550
|
+
__name(getLocks, "getLocks");
|
|
1551
|
+
onExit(() => {
|
|
1552
|
+
for (const file in locks) {
|
|
1553
|
+
const options = locks[file].options;
|
|
1554
|
+
try {
|
|
1555
|
+
options.fs.rmdirSync(getLockFile(file, options));
|
|
1556
|
+
} catch (e) {
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
});
|
|
1560
|
+
module.exports.lock = lock;
|
|
1561
|
+
module.exports.unlock = unlock;
|
|
1562
|
+
module.exports.check = check;
|
|
1563
|
+
module.exports.getLocks = getLocks;
|
|
1564
|
+
}
|
|
1565
|
+
});
|
|
1566
|
+
|
|
1567
|
+
// node_modules/proper-lockfile/lib/adapter.js
|
|
1568
|
+
var require_adapter = __commonJS({
|
|
1569
|
+
"node_modules/proper-lockfile/lib/adapter.js"(exports, module) {
|
|
1570
|
+
"use strict";
|
|
1571
|
+
init_esbuild_shims();
|
|
1572
|
+
var fs2 = require_graceful_fs();
|
|
1573
|
+
function createSyncFs(fs3) {
|
|
1574
|
+
const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
|
|
1575
|
+
const newFs = { ...fs3 };
|
|
1576
|
+
methods.forEach((method) => {
|
|
1577
|
+
newFs[method] = (...args) => {
|
|
1578
|
+
const callback = args.pop();
|
|
1579
|
+
let ret;
|
|
1580
|
+
try {
|
|
1581
|
+
ret = fs3[`${method}Sync`](...args);
|
|
1582
|
+
} catch (err) {
|
|
1583
|
+
return callback(err);
|
|
1584
|
+
}
|
|
1585
|
+
callback(null, ret);
|
|
1586
|
+
};
|
|
1587
|
+
});
|
|
1588
|
+
return newFs;
|
|
1589
|
+
}
|
|
1590
|
+
__name(createSyncFs, "createSyncFs");
|
|
1591
|
+
function toPromise(method) {
|
|
1592
|
+
return (...args) => new Promise((resolve, reject) => {
|
|
1593
|
+
args.push((err, result) => {
|
|
1594
|
+
if (err) {
|
|
1595
|
+
reject(err);
|
|
1596
|
+
} else {
|
|
1597
|
+
resolve(result);
|
|
1598
|
+
}
|
|
1599
|
+
});
|
|
1600
|
+
method(...args);
|
|
1601
|
+
});
|
|
1602
|
+
}
|
|
1603
|
+
__name(toPromise, "toPromise");
|
|
1604
|
+
function toSync(method) {
|
|
1605
|
+
return (...args) => {
|
|
1606
|
+
let err;
|
|
1607
|
+
let result;
|
|
1608
|
+
args.push((_err, _result) => {
|
|
1609
|
+
err = _err;
|
|
1610
|
+
result = _result;
|
|
1611
|
+
});
|
|
1612
|
+
method(...args);
|
|
1613
|
+
if (err) {
|
|
1614
|
+
throw err;
|
|
1615
|
+
}
|
|
1616
|
+
return result;
|
|
1617
|
+
};
|
|
1618
|
+
}
|
|
1619
|
+
__name(toSync, "toSync");
|
|
1620
|
+
function toSyncOptions(options) {
|
|
1621
|
+
options = { ...options };
|
|
1622
|
+
options.fs = createSyncFs(options.fs || fs2);
|
|
1623
|
+
if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
|
|
1624
|
+
throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
|
|
1625
|
+
}
|
|
1626
|
+
return options;
|
|
1627
|
+
}
|
|
1628
|
+
__name(toSyncOptions, "toSyncOptions");
|
|
1629
|
+
module.exports = {
|
|
1630
|
+
toPromise,
|
|
1631
|
+
toSync,
|
|
1632
|
+
toSyncOptions
|
|
1633
|
+
};
|
|
1634
|
+
}
|
|
1635
|
+
});
|
|
1636
|
+
|
|
1637
|
+
// node_modules/proper-lockfile/index.js
|
|
1638
|
+
var require_proper_lockfile = __commonJS({
|
|
1639
|
+
"node_modules/proper-lockfile/index.js"(exports, module) {
|
|
1640
|
+
"use strict";
|
|
1641
|
+
init_esbuild_shims();
|
|
1642
|
+
var lockfile2 = require_lockfile();
|
|
1643
|
+
var { toPromise, toSync, toSyncOptions } = require_adapter();
|
|
1644
|
+
async function lock(file, options) {
|
|
1645
|
+
const release = await toPromise(lockfile2.lock)(file, options);
|
|
1646
|
+
return toPromise(release);
|
|
1647
|
+
}
|
|
1648
|
+
__name(lock, "lock");
|
|
1649
|
+
function lockSync(file, options) {
|
|
1650
|
+
const release = toSync(lockfile2.lock)(file, toSyncOptions(options));
|
|
1651
|
+
return toSync(release);
|
|
1652
|
+
}
|
|
1653
|
+
__name(lockSync, "lockSync");
|
|
1654
|
+
function unlock(file, options) {
|
|
1655
|
+
return toPromise(lockfile2.unlock)(file, options);
|
|
1656
|
+
}
|
|
1657
|
+
__name(unlock, "unlock");
|
|
1658
|
+
function unlockSync(file, options) {
|
|
1659
|
+
return toSync(lockfile2.unlock)(file, toSyncOptions(options));
|
|
1660
|
+
}
|
|
1661
|
+
__name(unlockSync, "unlockSync");
|
|
1662
|
+
function check(file, options) {
|
|
1663
|
+
return toPromise(lockfile2.check)(file, options);
|
|
1664
|
+
}
|
|
1665
|
+
__name(check, "check");
|
|
1666
|
+
function checkSync(file, options) {
|
|
1667
|
+
return toSync(lockfile2.check)(file, toSyncOptions(options));
|
|
1668
|
+
}
|
|
1669
|
+
__name(checkSync, "checkSync");
|
|
1670
|
+
module.exports = lock;
|
|
1671
|
+
module.exports.lock = lock;
|
|
1672
|
+
module.exports.unlock = unlock;
|
|
1673
|
+
module.exports.lockSync = lockSync;
|
|
1674
|
+
module.exports.unlockSync = unlockSync;
|
|
1675
|
+
module.exports.check = check;
|
|
1676
|
+
module.exports.checkSync = checkSync;
|
|
1677
|
+
}
|
|
1678
|
+
});
|
|
1679
|
+
|
|
1680
|
+
// packages/core/src/agents/team/tasks.ts
|
|
1681
|
+
init_esbuild_shims();
|
|
1682
|
+
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
1683
|
+
import * as fs from "node:fs/promises";
|
|
1684
|
+
import { constants as fsConstants } from "node:fs";
|
|
1685
|
+
import * as path from "node:path";
|
|
1686
|
+
var debug = createDebugLogger("AGENTS_TEAM_TASKS");
|
|
1687
|
+
var MAX_METADATA_BYTES = 32768;
|
|
1688
|
+
var MAX_PARALLEL_TASK_READS = 16;
|
|
1689
|
+
function assertMetadataWithinLimit(metadata) {
|
|
1690
|
+
if (!metadata) return;
|
|
1691
|
+
const size = Buffer.byteLength(JSON.stringify(metadata), "utf-8");
|
|
1692
|
+
if (size > MAX_METADATA_BYTES) {
|
|
1693
|
+
throw new Error(
|
|
1694
|
+
`Task metadata is too large (${size} bytes; max ${MAX_METADATA_BYTES}). Trim the payload or store the bulk content elsewhere.`
|
|
1695
|
+
);
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
__name(assertMetadataWithinLimit, "assertMetadataWithinLimit");
|
|
1699
|
+
var LOCK_OPTIONS = {
|
|
1700
|
+
retries: {
|
|
1701
|
+
retries: 30,
|
|
1702
|
+
minTimeout: 5,
|
|
1703
|
+
maxTimeout: 100,
|
|
1704
|
+
factor: 2
|
|
1705
|
+
},
|
|
1706
|
+
stale: 5e3,
|
|
1707
|
+
onCompromised: /* @__PURE__ */ __name((err) => {
|
|
1708
|
+
debug.warn("task lock compromised:", err?.message ?? err);
|
|
1709
|
+
}, "onCompromised")
|
|
1710
|
+
};
|
|
1711
|
+
function assertValidTaskId(taskId) {
|
|
1712
|
+
if (!/^[1-9]\d*$/.test(taskId)) {
|
|
1713
|
+
throw new Error(
|
|
1714
|
+
`Invalid task ID "${taskId}". Task IDs must be positive integers.`
|
|
1715
|
+
);
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
__name(assertValidTaskId, "assertValidTaskId");
|
|
1719
|
+
function getTaskPath(teamName, taskId) {
|
|
1720
|
+
assertValidTaskId(taskId);
|
|
1721
|
+
return path.join(getTasksDir(teamName), `${taskId}.json`);
|
|
1722
|
+
}
|
|
1723
|
+
__name(getTaskPath, "getTaskPath");
|
|
1724
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
1725
|
+
function onTasksUpdated(listener) {
|
|
1726
|
+
listeners.add(listener);
|
|
1727
|
+
return () => {
|
|
1728
|
+
listeners.delete(listener);
|
|
1729
|
+
};
|
|
1730
|
+
}
|
|
1731
|
+
__name(onTasksUpdated, "onTasksUpdated");
|
|
1732
|
+
function notifyTasksUpdated(teamName) {
|
|
1733
|
+
for (const listener of listeners) {
|
|
1734
|
+
try {
|
|
1735
|
+
listener(teamName);
|
|
1736
|
+
} catch (err) {
|
|
1737
|
+
debug.warn(`task update listener failed: ${err}`);
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
__name(notifyTasksUpdated, "notifyTasksUpdated");
|
|
1742
|
+
async function createTask(teamName, opts) {
|
|
1743
|
+
assertMetadataWithinLimit(opts.metadata);
|
|
1744
|
+
const dir = getTasksDir(teamName);
|
|
1745
|
+
await fs.mkdir(dir, { recursive: true });
|
|
1746
|
+
const MAX_RETRIES = 15;
|
|
1747
|
+
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
|
1748
|
+
const nextId = await getNextTaskId(dir);
|
|
1749
|
+
const task = {
|
|
1750
|
+
id: nextId,
|
|
1751
|
+
subject: opts.subject,
|
|
1752
|
+
description: opts.description,
|
|
1753
|
+
activeForm: opts.activeForm,
|
|
1754
|
+
owner: opts.owner,
|
|
1755
|
+
status: "pending",
|
|
1756
|
+
blocks: [],
|
|
1757
|
+
blockedBy: [],
|
|
1758
|
+
metadata: opts.metadata
|
|
1759
|
+
};
|
|
1760
|
+
const taskPath = path.join(dir, `${nextId}.json`);
|
|
1761
|
+
try {
|
|
1762
|
+
const handle = await fs.open(
|
|
1763
|
+
taskPath,
|
|
1764
|
+
fsConstants.O_WRONLY | fsConstants.O_CREAT | fsConstants.O_EXCL
|
|
1765
|
+
);
|
|
1766
|
+
await handle.close();
|
|
1767
|
+
} catch (err) {
|
|
1768
|
+
if (isNodeError(err) && err.code === "EEXIST") {
|
|
1769
|
+
continue;
|
|
1770
|
+
}
|
|
1771
|
+
throw err;
|
|
1772
|
+
}
|
|
1773
|
+
try {
|
|
1774
|
+
await atomicWriteJSON(taskPath, task);
|
|
1775
|
+
} catch (err) {
|
|
1776
|
+
await fs.unlink(taskPath).catch(() => {
|
|
1777
|
+
});
|
|
1778
|
+
throw err;
|
|
1779
|
+
}
|
|
1780
|
+
notifyTasksUpdated(teamName);
|
|
1781
|
+
return task;
|
|
1782
|
+
}
|
|
1783
|
+
throw new Error(
|
|
1784
|
+
`Failed to create task after ${MAX_RETRIES} attempts (ID contention).`
|
|
1785
|
+
);
|
|
1786
|
+
}
|
|
1787
|
+
__name(createTask, "createTask");
|
|
1788
|
+
async function getTask(teamName, taskId) {
|
|
1789
|
+
const taskPath = getTaskPath(teamName, taskId);
|
|
1790
|
+
try {
|
|
1791
|
+
const raw = await fs.readFile(taskPath, "utf-8");
|
|
1792
|
+
return JSON.parse(raw);
|
|
1793
|
+
} catch (err) {
|
|
1794
|
+
if (isNodeError(err) && err.code === "ENOENT") return void 0;
|
|
1795
|
+
throw err;
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
__name(getTask, "getTask");
|
|
1799
|
+
var TaskOwnershipError = class extends Error {
|
|
1800
|
+
constructor(taskId, callerName, actualOwner) {
|
|
1801
|
+
super(
|
|
1802
|
+
`Task #${taskId} is owned by "${actualOwner}". Only the leader or the owner can change status / owner / subject / description / blocks.`
|
|
1803
|
+
);
|
|
1804
|
+
this.taskId = taskId;
|
|
1805
|
+
this.callerName = callerName;
|
|
1806
|
+
this.actualOwner = actualOwner;
|
|
1807
|
+
this.name = "TaskOwnershipError";
|
|
1808
|
+
}
|
|
1809
|
+
static {
|
|
1810
|
+
__name(this, "TaskOwnershipError");
|
|
1811
|
+
}
|
|
1812
|
+
};
|
|
1813
|
+
async function updateTask(teamName, taskId, updates, opts) {
|
|
1814
|
+
const taskPath = getTaskPath(teamName, taskId);
|
|
1815
|
+
let release;
|
|
1816
|
+
try {
|
|
1817
|
+
release = await import_proper_lockfile.default.lock(taskPath, LOCK_OPTIONS);
|
|
1818
|
+
} catch (err) {
|
|
1819
|
+
if (isNodeError(err) && err.code === "ENOENT") return void 0;
|
|
1820
|
+
throw err;
|
|
1821
|
+
}
|
|
1822
|
+
try {
|
|
1823
|
+
let raw;
|
|
1824
|
+
try {
|
|
1825
|
+
raw = await fs.readFile(taskPath, "utf-8");
|
|
1826
|
+
} catch (err) {
|
|
1827
|
+
if (isNodeError(err) && err.code === "ENOENT") return void 0;
|
|
1828
|
+
throw err;
|
|
1829
|
+
}
|
|
1830
|
+
const task = JSON.parse(raw);
|
|
1831
|
+
if (opts?.callerName !== void 0) {
|
|
1832
|
+
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;
|
|
1833
|
+
if (restrictsOwnership && task.owner && task.owner !== opts.callerName) {
|
|
1834
|
+
throw new TaskOwnershipError(taskId, opts.callerName, task.owner);
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
if (updates.addBlocks?.length) {
|
|
1838
|
+
const blockSet = new Set(task.blocks);
|
|
1839
|
+
for (const id of updates.addBlocks) blockSet.add(id);
|
|
1840
|
+
task.blocks = Array.from(blockSet);
|
|
1841
|
+
}
|
|
1842
|
+
if (updates.addBlockedBy?.length) {
|
|
1843
|
+
const blockedBySet = new Set(task.blockedBy);
|
|
1844
|
+
for (const id of updates.addBlockedBy) blockedBySet.add(id);
|
|
1845
|
+
task.blockedBy = Array.from(blockedBySet);
|
|
1846
|
+
}
|
|
1847
|
+
if (updates.status !== void 0) {
|
|
1848
|
+
task.status = updates.status;
|
|
1849
|
+
if (updates.status === "completed" && task.blocks.length > 0) {
|
|
1850
|
+
await unblockDependents(teamName, taskId, task.blocks);
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
if (updates.owner !== void 0) {
|
|
1854
|
+
task.owner = updates.owner ? updates.owner : void 0;
|
|
1855
|
+
}
|
|
1856
|
+
if (updates.subject !== void 0) {
|
|
1857
|
+
task.subject = updates.subject;
|
|
1858
|
+
}
|
|
1859
|
+
if (updates.description !== void 0) {
|
|
1860
|
+
task.description = updates.description;
|
|
1861
|
+
}
|
|
1862
|
+
if (updates.activeForm !== void 0) {
|
|
1863
|
+
task.activeForm = updates.activeForm ?? void 0;
|
|
1864
|
+
}
|
|
1865
|
+
if (updates.metadata !== void 0) {
|
|
1866
|
+
task.metadata = task.metadata ?? {};
|
|
1867
|
+
for (const [key, value] of Object.entries(updates.metadata)) {
|
|
1868
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
1869
|
+
continue;
|
|
1870
|
+
}
|
|
1871
|
+
if (value === null) {
|
|
1872
|
+
delete task.metadata[key];
|
|
1873
|
+
} else {
|
|
1874
|
+
task.metadata[key] = value;
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
if (Object.keys(task.metadata).length === 0) {
|
|
1878
|
+
task.metadata = void 0;
|
|
1879
|
+
}
|
|
1880
|
+
assertMetadataWithinLimit(task.metadata);
|
|
1881
|
+
}
|
|
1882
|
+
await atomicWriteJSON(taskPath, task);
|
|
1883
|
+
notifyTasksUpdated(teamName);
|
|
1884
|
+
return task;
|
|
1885
|
+
} finally {
|
|
1886
|
+
await release?.();
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
__name(updateTask, "updateTask");
|
|
1890
|
+
async function deleteTask(teamName, taskId, opts) {
|
|
1891
|
+
const taskPath = getTaskPath(teamName, taskId);
|
|
1892
|
+
let release;
|
|
1893
|
+
try {
|
|
1894
|
+
release = await import_proper_lockfile.default.lock(taskPath, LOCK_OPTIONS);
|
|
1895
|
+
} catch (err) {
|
|
1896
|
+
if (isNodeError(err) && err.code === "ENOENT") return false;
|
|
1897
|
+
throw err;
|
|
1898
|
+
}
|
|
1899
|
+
let dependentIds = /* @__PURE__ */ new Set();
|
|
1900
|
+
try {
|
|
1901
|
+
let task;
|
|
1902
|
+
try {
|
|
1903
|
+
const raw = await fs.readFile(taskPath, "utf-8");
|
|
1904
|
+
task = JSON.parse(raw);
|
|
1905
|
+
} catch (err) {
|
|
1906
|
+
if (isNodeError(err) && err.code === "ENOENT") return false;
|
|
1907
|
+
throw err;
|
|
1908
|
+
}
|
|
1909
|
+
if (opts?.callerName !== void 0 && task.owner && task.owner !== opts.callerName) {
|
|
1910
|
+
throw new TaskOwnershipError(taskId, opts.callerName, task.owner);
|
|
1911
|
+
}
|
|
1912
|
+
dependentIds = /* @__PURE__ */ new Set([...task.blocks, ...task.blockedBy]);
|
|
1913
|
+
dependentIds.delete(taskId);
|
|
1914
|
+
try {
|
|
1915
|
+
await fs.unlink(taskPath);
|
|
1916
|
+
} catch (err) {
|
|
1917
|
+
if (isNodeError(err) && err.code === "ENOENT") return false;
|
|
1918
|
+
throw err;
|
|
1919
|
+
}
|
|
1920
|
+
} finally {
|
|
1921
|
+
await release();
|
|
1922
|
+
}
|
|
1923
|
+
const results = await Promise.allSettled(
|
|
1924
|
+
Array.from(dependentIds).map(
|
|
1925
|
+
(depId) => removeEdgesReferencing(teamName, depId, taskId)
|
|
1926
|
+
)
|
|
1927
|
+
);
|
|
1928
|
+
for (const r of results) {
|
|
1929
|
+
if (r.status === "rejected") {
|
|
1930
|
+
debug.warn(`deleteTask(${taskId}): edge cleanup failed: ${r.reason}`);
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
notifyTasksUpdated(teamName);
|
|
1934
|
+
return true;
|
|
1935
|
+
}
|
|
1936
|
+
__name(deleteTask, "deleteTask");
|
|
1937
|
+
async function removeEdgesReferencing(teamName, targetId, referencedId) {
|
|
1938
|
+
const depPath = getTaskPath(teamName, targetId);
|
|
1939
|
+
let release;
|
|
1940
|
+
try {
|
|
1941
|
+
release = await import_proper_lockfile.default.lock(depPath, LOCK_OPTIONS);
|
|
1942
|
+
} catch (err) {
|
|
1943
|
+
if (isNodeError(err) && err.code === "ENOENT") return;
|
|
1944
|
+
throw err;
|
|
1945
|
+
}
|
|
1946
|
+
try {
|
|
1947
|
+
const raw = await fs.readFile(depPath, "utf-8");
|
|
1948
|
+
const task = JSON.parse(raw);
|
|
1949
|
+
const beforeBlocks = task.blocks.length;
|
|
1950
|
+
const beforeBlockedBy = task.blockedBy.length;
|
|
1951
|
+
task.blocks = task.blocks.filter((id) => id !== referencedId);
|
|
1952
|
+
task.blockedBy = task.blockedBy.filter((id) => id !== referencedId);
|
|
1953
|
+
if (task.blocks.length === beforeBlocks && task.blockedBy.length === beforeBlockedBy) {
|
|
1954
|
+
return;
|
|
1955
|
+
}
|
|
1956
|
+
await atomicWriteJSON(depPath, task);
|
|
1957
|
+
} catch (err) {
|
|
1958
|
+
if (isNodeError(err) && err.code === "ENOENT") return;
|
|
1959
|
+
throw err;
|
|
1960
|
+
} finally {
|
|
1961
|
+
await release?.();
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
__name(removeEdgesReferencing, "removeEdgesReferencing");
|
|
1965
|
+
async function listTasks(teamName, filters) {
|
|
1966
|
+
const dir = getTasksDir(teamName);
|
|
1967
|
+
let entries;
|
|
1968
|
+
try {
|
|
1969
|
+
entries = await fs.readdir(dir);
|
|
1970
|
+
} catch (err) {
|
|
1971
|
+
if (isNodeError(err) && err.code === "ENOENT") return [];
|
|
1972
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
1973
|
+
debug.warn(`Failed to list tasks dir ${dir}: ${errMsg}`);
|
|
1974
|
+
throw err instanceof Error ? err : new Error(errMsg);
|
|
1975
|
+
}
|
|
1976
|
+
const jsonEntries = entries.filter((e) => e.endsWith(".json"));
|
|
1977
|
+
const reads = [];
|
|
1978
|
+
for (let i = 0; i < jsonEntries.length; i += MAX_PARALLEL_TASK_READS) {
|
|
1979
|
+
const batch = jsonEntries.slice(i, i + MAX_PARALLEL_TASK_READS);
|
|
1980
|
+
const batchReads = await Promise.all(
|
|
1981
|
+
batch.map(async (entry) => {
|
|
1982
|
+
const filePath = path.join(dir, entry);
|
|
1983
|
+
let raw;
|
|
1984
|
+
try {
|
|
1985
|
+
raw = await fs.readFile(filePath, "utf-8");
|
|
1986
|
+
} catch (err) {
|
|
1987
|
+
if (isNodeError(err) && err.code === "ENOENT") return void 0;
|
|
1988
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
1989
|
+
debug.warn(`Failed to read task file ${filePath}: ${errMsg}`);
|
|
1990
|
+
return void 0;
|
|
1991
|
+
}
|
|
1992
|
+
if (raw.trim() === "") {
|
|
1993
|
+
return void 0;
|
|
1994
|
+
}
|
|
1995
|
+
try {
|
|
1996
|
+
return JSON.parse(raw);
|
|
1997
|
+
} catch (err) {
|
|
1998
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
1999
|
+
debug.warn(`Quarantining corrupt task file ${filePath}: ${errMsg}`);
|
|
2000
|
+
const quarantined = `${filePath}.corrupt-${Date.now()}`;
|
|
2001
|
+
try {
|
|
2002
|
+
await fs.rename(filePath, quarantined);
|
|
2003
|
+
} catch (renameErr) {
|
|
2004
|
+
const renameMsg = renameErr instanceof Error ? renameErr.message : String(renameErr);
|
|
2005
|
+
debug.warn(`Failed to quarantine ${filePath}: ${renameMsg}`);
|
|
2006
|
+
}
|
|
2007
|
+
return void 0;
|
|
2008
|
+
}
|
|
2009
|
+
})
|
|
2010
|
+
);
|
|
2011
|
+
reads.push(...batchReads);
|
|
2012
|
+
}
|
|
2013
|
+
const tasks = reads.filter((t) => t !== void 0);
|
|
2014
|
+
tasks.sort((a, b) => Number(a.id) - Number(b.id));
|
|
2015
|
+
if (!filters) return tasks;
|
|
2016
|
+
return tasks.filter((t) => {
|
|
2017
|
+
if (filters.status !== void 0 && t.status !== filters.status) {
|
|
2018
|
+
return false;
|
|
2019
|
+
}
|
|
2020
|
+
if (filters.owner !== void 0 && t.owner !== filters.owner) {
|
|
2021
|
+
return false;
|
|
2022
|
+
}
|
|
2023
|
+
if (filters.blockedBy !== void 0 && !t.blockedBy.includes(filters.blockedBy)) {
|
|
2024
|
+
return false;
|
|
2025
|
+
}
|
|
2026
|
+
return true;
|
|
2027
|
+
});
|
|
2028
|
+
}
|
|
2029
|
+
__name(listTasks, "listTasks");
|
|
2030
|
+
async function resetTaskList(teamName) {
|
|
2031
|
+
const dir = getTasksDir(teamName);
|
|
2032
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
2033
|
+
notifyTasksUpdated(teamName);
|
|
2034
|
+
}
|
|
2035
|
+
__name(resetTaskList, "resetTaskList");
|
|
2036
|
+
async function unblockDependents(teamName, completedId, dependentIds) {
|
|
2037
|
+
const results = await Promise.allSettled(
|
|
2038
|
+
dependentIds.map(async (depId) => {
|
|
2039
|
+
const depPath = getTaskPath(teamName, depId);
|
|
2040
|
+
let release;
|
|
2041
|
+
try {
|
|
2042
|
+
release = await import_proper_lockfile.default.lock(depPath, LOCK_OPTIONS);
|
|
2043
|
+
} catch (err) {
|
|
2044
|
+
if (isNodeError(err) && err.code === "ENOENT") return;
|
|
2045
|
+
throw err;
|
|
2046
|
+
}
|
|
2047
|
+
try {
|
|
2048
|
+
const raw = await fs.readFile(depPath, "utf-8");
|
|
2049
|
+
const task = JSON.parse(raw);
|
|
2050
|
+
const before = task.blockedBy.length;
|
|
2051
|
+
task.blockedBy = task.blockedBy.filter((id) => id !== completedId);
|
|
2052
|
+
if (task.blockedBy.length === before) return;
|
|
2053
|
+
await atomicWriteJSON(depPath, task);
|
|
2054
|
+
} finally {
|
|
2055
|
+
await release?.();
|
|
2056
|
+
}
|
|
2057
|
+
})
|
|
2058
|
+
);
|
|
2059
|
+
for (const r of results) {
|
|
2060
|
+
if (r.status === "rejected") {
|
|
2061
|
+
debug.warn(`unblockDependents(${completedId}): ${r.reason}`);
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
notifyTasksUpdated(teamName);
|
|
2065
|
+
}
|
|
2066
|
+
__name(unblockDependents, "unblockDependents");
|
|
2067
|
+
async function blockTask(teamName, fromId, toId) {
|
|
2068
|
+
await updateTask(teamName, fromId, { addBlocks: [toId] });
|
|
2069
|
+
await updateTask(teamName, toId, { addBlockedBy: [fromId] });
|
|
2070
|
+
}
|
|
2071
|
+
__name(blockTask, "blockTask");
|
|
2072
|
+
async function claimTask(teamName, taskId, agentId, opts) {
|
|
2073
|
+
if (opts?.checkAgentBusy) {
|
|
2074
|
+
const busy = await isAgentBusy(teamName, agentId);
|
|
2075
|
+
if (busy) return void 0;
|
|
2076
|
+
}
|
|
2077
|
+
const taskPath = getTaskPath(teamName, taskId);
|
|
2078
|
+
let release;
|
|
2079
|
+
try {
|
|
2080
|
+
release = await import_proper_lockfile.default.lock(taskPath, LOCK_OPTIONS);
|
|
2081
|
+
} catch (err) {
|
|
2082
|
+
if (isNodeError(err) && err.code === "ENOENT") return void 0;
|
|
2083
|
+
throw err;
|
|
2084
|
+
}
|
|
2085
|
+
try {
|
|
2086
|
+
let raw;
|
|
2087
|
+
try {
|
|
2088
|
+
raw = await fs.readFile(taskPath, "utf-8");
|
|
2089
|
+
} catch (err) {
|
|
2090
|
+
if (isNodeError(err) && err.code === "ENOENT") return void 0;
|
|
2091
|
+
throw err;
|
|
2092
|
+
}
|
|
2093
|
+
const task = JSON.parse(raw);
|
|
2094
|
+
if (task.status !== "pending") return void 0;
|
|
2095
|
+
if (task.owner) return void 0;
|
|
2096
|
+
task.owner = opts?.ownerName ?? agentId;
|
|
2097
|
+
task.status = "in_progress";
|
|
2098
|
+
await atomicWriteJSON(taskPath, task);
|
|
2099
|
+
notifyTasksUpdated(teamName);
|
|
2100
|
+
return task;
|
|
2101
|
+
} finally {
|
|
2102
|
+
await release?.();
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
__name(claimTask, "claimTask");
|
|
2106
|
+
async function isAgentBusy(teamName, agentId) {
|
|
2107
|
+
const inProgress = await listTasks(teamName, {
|
|
2108
|
+
status: "in_progress"
|
|
2109
|
+
});
|
|
2110
|
+
const bareName = agentId.split("@")[0];
|
|
2111
|
+
return inProgress.some((t) => t.owner === agentId || t.owner === bareName);
|
|
2112
|
+
}
|
|
2113
|
+
__name(isAgentBusy, "isAgentBusy");
|
|
2114
|
+
async function releaseOwnedTask(teamName, taskId, expectedOwner) {
|
|
2115
|
+
const taskPath = getTaskPath(teamName, taskId);
|
|
2116
|
+
let release;
|
|
2117
|
+
try {
|
|
2118
|
+
release = await import_proper_lockfile.default.lock(taskPath, LOCK_OPTIONS);
|
|
2119
|
+
} catch (err) {
|
|
2120
|
+
if (isNodeError(err) && err.code === "ENOENT") return false;
|
|
2121
|
+
throw err;
|
|
2122
|
+
}
|
|
2123
|
+
try {
|
|
2124
|
+
let raw;
|
|
2125
|
+
try {
|
|
2126
|
+
raw = await fs.readFile(taskPath, "utf-8");
|
|
2127
|
+
} catch (err) {
|
|
2128
|
+
if (isNodeError(err) && err.code === "ENOENT") return false;
|
|
2129
|
+
throw err;
|
|
2130
|
+
}
|
|
2131
|
+
const task = JSON.parse(raw);
|
|
2132
|
+
if (task.status !== "in_progress") return false;
|
|
2133
|
+
if (task.owner !== expectedOwner) return false;
|
|
2134
|
+
task.owner = void 0;
|
|
2135
|
+
task.status = "pending";
|
|
2136
|
+
await atomicWriteJSON(taskPath, task);
|
|
2137
|
+
return true;
|
|
2138
|
+
} finally {
|
|
2139
|
+
await release?.();
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
__name(releaseOwnedTask, "releaseOwnedTask");
|
|
2143
|
+
async function unassignTeammateTasks(teamName, agentId) {
|
|
2144
|
+
const bareName = agentId.split("@")[0];
|
|
2145
|
+
const inProgress = await listTasks(teamName, {
|
|
2146
|
+
status: "in_progress"
|
|
2147
|
+
});
|
|
2148
|
+
const owned = inProgress.filter(
|
|
2149
|
+
(task) => task.owner === agentId || task.owner === bareName
|
|
2150
|
+
);
|
|
2151
|
+
const results = await Promise.allSettled(
|
|
2152
|
+
owned.map((task) => releaseOwnedTask(teamName, task.id, task.owner))
|
|
2153
|
+
);
|
|
2154
|
+
const failed = results.filter((r) => r.status === "rejected");
|
|
2155
|
+
if (failed.length > 0) {
|
|
2156
|
+
debug.warn(
|
|
2157
|
+
`unassignTeammateTasks: ${failed.length}/${owned.length} task(s) failed to unassign for ${agentId}`
|
|
2158
|
+
);
|
|
2159
|
+
}
|
|
2160
|
+
const released = results.filter(
|
|
2161
|
+
(r) => r.status === "fulfilled" && r.value === true
|
|
2162
|
+
).length;
|
|
2163
|
+
if (released > 0) {
|
|
2164
|
+
notifyTasksUpdated(teamName);
|
|
2165
|
+
}
|
|
2166
|
+
return released;
|
|
2167
|
+
}
|
|
2168
|
+
__name(unassignTeammateTasks, "unassignTeammateTasks");
|
|
2169
|
+
async function getAgentStatuses(teamName) {
|
|
2170
|
+
const tasks = await listTasks(teamName);
|
|
2171
|
+
const statuses = /* @__PURE__ */ new Map();
|
|
2172
|
+
for (const task of tasks) {
|
|
2173
|
+
if (!task.owner) continue;
|
|
2174
|
+
const entry = statuses.get(task.owner) ?? {
|
|
2175
|
+
inProgress: 0,
|
|
2176
|
+
completed: 0
|
|
2177
|
+
};
|
|
2178
|
+
if (task.status === "in_progress") {
|
|
2179
|
+
entry.inProgress++;
|
|
2180
|
+
} else if (task.status === "completed") {
|
|
2181
|
+
entry.completed++;
|
|
2182
|
+
}
|
|
2183
|
+
statuses.set(task.owner, entry);
|
|
2184
|
+
}
|
|
2185
|
+
return statuses;
|
|
2186
|
+
}
|
|
2187
|
+
__name(getAgentStatuses, "getAgentStatuses");
|
|
2188
|
+
async function getNextTaskId(dir) {
|
|
2189
|
+
let entries;
|
|
2190
|
+
try {
|
|
2191
|
+
entries = await fs.readdir(dir);
|
|
2192
|
+
} catch {
|
|
2193
|
+
return "1";
|
|
2194
|
+
}
|
|
2195
|
+
let maxId = 0;
|
|
2196
|
+
for (const entry of entries) {
|
|
2197
|
+
if (!entry.endsWith(".json")) continue;
|
|
2198
|
+
const num = parseInt(entry.replace(".json", ""), 10);
|
|
2199
|
+
if (!isNaN(num) && num > maxId) {
|
|
2200
|
+
maxId = num;
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
return String(maxId + 1);
|
|
2204
|
+
}
|
|
2205
|
+
__name(getNextTaskId, "getNextTaskId");
|
|
2206
|
+
|
|
2207
|
+
export {
|
|
2208
|
+
require_graceful_fs,
|
|
2209
|
+
require_proper_lockfile,
|
|
2210
|
+
assertValidTaskId,
|
|
2211
|
+
getTaskPath,
|
|
2212
|
+
onTasksUpdated,
|
|
2213
|
+
notifyTasksUpdated,
|
|
2214
|
+
createTask,
|
|
2215
|
+
getTask,
|
|
2216
|
+
TaskOwnershipError,
|
|
2217
|
+
updateTask,
|
|
2218
|
+
deleteTask,
|
|
2219
|
+
listTasks,
|
|
2220
|
+
resetTaskList,
|
|
2221
|
+
blockTask,
|
|
2222
|
+
claimTask,
|
|
2223
|
+
releaseOwnedTask,
|
|
2224
|
+
unassignTeammateTasks,
|
|
2225
|
+
getAgentStatuses
|
|
2226
|
+
};
|
|
2227
|
+
/**
|
|
2228
|
+
* @license
|
|
2229
|
+
* Copyright 2025 Qwen
|
|
2230
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
2231
|
+
*/
|