@codexhost/cli-linux-arm64 0.21.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +3333 -249
- package/app/console-web.js +9884 -2837
- package/app/desktop-controller.mjs +3139 -310
- package/app/host-runtime.mjs +6652 -2111
- package/app/plugins/antigravity/plugin.mjs +1796 -1338
- package/app/plugins/claude-code/plugin.mjs +1272 -238
- package/app/plugins/codebuddy/plugin.mjs +588 -109
- package/app/plugins/codex-usage/plugin.mjs +533 -88
- package/app/plugins/copilot/plugin.mjs +533 -88
- package/app/plugins/cursor-cli/plugin.mjs +588 -109
- package/app/plugins/deepseek-harness/plugin.mjs +875 -218
- package/app/plugins/devin/plugin.mjs +533 -88
- package/app/plugins/grok/plugin.mjs +778 -272
- package/app/plugins/hermes/plugin.mjs +533 -88
- package/app/plugins/kimi-code/plugin.mjs +533 -88
- package/app/plugins/kiro-cli/plugin.mjs +533 -88
- package/app/plugins/omp/plugin.mjs +640 -110
- package/app/plugins/opencode/plugin.mjs +533 -88
- package/app/plugins/pi/plugin.mjs +657 -116
- package/app/plugins/qoder/plugin.mjs +533 -88
- package/app/plugins/qoder-cn/plugin.mjs +533 -88
- package/app/plugins/qwen-code/plugin.mjs +533 -88
- package/app/plugins/workbuddy/plugin.mjs +646 -120
- package/app/plugins/zcode/plugin.mjs +540 -95
- package/app/renderer-extension.js +12947 -4450
- package/app/web/assets/index-Dyh1KzAB.js +201 -0
- package/app/web/codexhost-settings.js +9794 -2934
- package/app/web/index.html +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +69 -69
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +74 -74
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +3 -3
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +90 -90
- package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-browser/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +79 -79
- package/app/web-modules/licenses/werift-NOTICES.txt +123 -0
- package/app/web-modules/licenses/werift-libwebrtc-NOTICES.txt +58 -0
- package/app/web-modules/server.mjs +34958 -2911
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/package.json +1 -1
- package/app/web/assets/index-BdmZfTRW.js +0 -201
package/app/console-server.mjs
CHANGED
|
@@ -1,11 +1,1623 @@
|
|
|
1
|
+
import { createRequire as __codexhostCreateRequire } from "node:module"; const require = __codexhostCreateRequire(import.meta.url);
|
|
2
|
+
var __create = Object.create;
|
|
1
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
9
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
10
|
+
}) : x)(function(x) {
|
|
11
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
+
});
|
|
14
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
15
|
+
try {
|
|
16
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
17
|
+
} catch (e) {
|
|
18
|
+
throw mod = 0, e;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
2
21
|
var __export = (target2, all) => {
|
|
3
22
|
for (var name in all)
|
|
4
23
|
__defProp(target2, name, { get: all[name], enumerable: true });
|
|
5
24
|
};
|
|
25
|
+
var __copyProps = (to, from, except, desc) => {
|
|
26
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
27
|
+
for (let key of __getOwnPropNames(from))
|
|
28
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
29
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
30
|
+
}
|
|
31
|
+
return to;
|
|
32
|
+
};
|
|
33
|
+
var __toESM = (mod, isNodeMode, target2) => (target2 = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
34
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
35
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
36
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
37
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
38
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target2, "default", { value: mod, enumerable: true }) : target2,
|
|
39
|
+
mod
|
|
40
|
+
));
|
|
41
|
+
|
|
42
|
+
// node_modules/graceful-fs/polyfills.js
|
|
43
|
+
var require_polyfills = __commonJS({
|
|
44
|
+
"node_modules/graceful-fs/polyfills.js"(exports, module) {
|
|
45
|
+
var constants2 = __require("constants");
|
|
46
|
+
var origCwd = process.cwd;
|
|
47
|
+
var cwd = null;
|
|
48
|
+
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
|
|
49
|
+
process.cwd = function() {
|
|
50
|
+
if (!cwd)
|
|
51
|
+
cwd = origCwd.call(process);
|
|
52
|
+
return cwd;
|
|
53
|
+
};
|
|
54
|
+
try {
|
|
55
|
+
process.cwd();
|
|
56
|
+
} catch (er) {
|
|
57
|
+
}
|
|
58
|
+
if (typeof process.chdir === "function") {
|
|
59
|
+
chdir = process.chdir;
|
|
60
|
+
process.chdir = function(d) {
|
|
61
|
+
cwd = null;
|
|
62
|
+
chdir.call(process, d);
|
|
63
|
+
};
|
|
64
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
|
|
65
|
+
}
|
|
66
|
+
var chdir;
|
|
67
|
+
module.exports = patch;
|
|
68
|
+
function patch(fs) {
|
|
69
|
+
if (constants2.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
70
|
+
patchLchmod(fs);
|
|
71
|
+
}
|
|
72
|
+
if (!fs.lutimes) {
|
|
73
|
+
patchLutimes(fs);
|
|
74
|
+
}
|
|
75
|
+
fs.chown = chownFix(fs.chown);
|
|
76
|
+
fs.fchown = chownFix(fs.fchown);
|
|
77
|
+
fs.lchown = chownFix(fs.lchown);
|
|
78
|
+
fs.chmod = chmodFix(fs.chmod);
|
|
79
|
+
fs.fchmod = chmodFix(fs.fchmod);
|
|
80
|
+
fs.lchmod = chmodFix(fs.lchmod);
|
|
81
|
+
fs.chownSync = chownFixSync(fs.chownSync);
|
|
82
|
+
fs.fchownSync = chownFixSync(fs.fchownSync);
|
|
83
|
+
fs.lchownSync = chownFixSync(fs.lchownSync);
|
|
84
|
+
fs.chmodSync = chmodFixSync(fs.chmodSync);
|
|
85
|
+
fs.fchmodSync = chmodFixSync(fs.fchmodSync);
|
|
86
|
+
fs.lchmodSync = chmodFixSync(fs.lchmodSync);
|
|
87
|
+
fs.stat = statFix(fs.stat);
|
|
88
|
+
fs.fstat = statFix(fs.fstat);
|
|
89
|
+
fs.lstat = statFix(fs.lstat);
|
|
90
|
+
fs.statSync = statFixSync(fs.statSync);
|
|
91
|
+
fs.fstatSync = statFixSync(fs.fstatSync);
|
|
92
|
+
fs.lstatSync = statFixSync(fs.lstatSync);
|
|
93
|
+
if (fs.chmod && !fs.lchmod) {
|
|
94
|
+
fs.lchmod = function(path24, mode, cb) {
|
|
95
|
+
if (cb) process.nextTick(cb);
|
|
96
|
+
};
|
|
97
|
+
fs.lchmodSync = function() {
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
if (fs.chown && !fs.lchown) {
|
|
101
|
+
fs.lchown = function(path24, uid, gid, cb) {
|
|
102
|
+
if (cb) process.nextTick(cb);
|
|
103
|
+
};
|
|
104
|
+
fs.lchownSync = function() {
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
if (platform === "win32") {
|
|
108
|
+
fs.rename = typeof fs.rename !== "function" ? fs.rename : (function(fs$rename) {
|
|
109
|
+
function rename6(from, to, cb) {
|
|
110
|
+
var start = Date.now();
|
|
111
|
+
var backoff = 0;
|
|
112
|
+
fs$rename(from, to, function CB(er) {
|
|
113
|
+
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
|
|
114
|
+
setTimeout(function() {
|
|
115
|
+
fs.stat(to, function(stater, st) {
|
|
116
|
+
if (stater && stater.code === "ENOENT")
|
|
117
|
+
fs$rename(from, to, CB);
|
|
118
|
+
else
|
|
119
|
+
cb(er);
|
|
120
|
+
});
|
|
121
|
+
}, backoff);
|
|
122
|
+
if (backoff < 100)
|
|
123
|
+
backoff += 10;
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (cb) cb(er);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(rename6, fs$rename);
|
|
130
|
+
return rename6;
|
|
131
|
+
})(fs.rename);
|
|
132
|
+
}
|
|
133
|
+
fs.read = typeof fs.read !== "function" ? fs.read : (function(fs$read) {
|
|
134
|
+
function read(fd, buffer, offset, length, position, callback_) {
|
|
135
|
+
var callback;
|
|
136
|
+
if (callback_ && typeof callback_ === "function") {
|
|
137
|
+
var eagCounter = 0;
|
|
138
|
+
callback = function(er, _, __) {
|
|
139
|
+
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
|
140
|
+
eagCounter++;
|
|
141
|
+
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
|
|
142
|
+
}
|
|
143
|
+
callback_.apply(this, arguments);
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
|
|
147
|
+
}
|
|
148
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
|
|
149
|
+
return read;
|
|
150
|
+
})(fs.read);
|
|
151
|
+
fs.readSync = typeof fs.readSync !== "function" ? fs.readSync : /* @__PURE__ */ (function(fs$readSync) {
|
|
152
|
+
return function(fd, buffer, offset, length, position) {
|
|
153
|
+
var eagCounter = 0;
|
|
154
|
+
while (true) {
|
|
155
|
+
try {
|
|
156
|
+
return fs$readSync.call(fs, fd, buffer, offset, length, position);
|
|
157
|
+
} catch (er) {
|
|
158
|
+
if (er.code === "EAGAIN" && eagCounter < 10) {
|
|
159
|
+
eagCounter++;
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
throw er;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
})(fs.readSync);
|
|
167
|
+
function patchLchmod(fs2) {
|
|
168
|
+
fs2.lchmod = function(path24, mode, callback) {
|
|
169
|
+
fs2.open(
|
|
170
|
+
path24,
|
|
171
|
+
constants2.O_WRONLY | constants2.O_SYMLINK,
|
|
172
|
+
mode,
|
|
173
|
+
function(err, fd) {
|
|
174
|
+
if (err) {
|
|
175
|
+
if (callback) callback(err);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
fs2.fchmod(fd, mode, function(err2) {
|
|
179
|
+
fs2.close(fd, function(err22) {
|
|
180
|
+
if (callback) callback(err2 || err22);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
};
|
|
186
|
+
fs2.lchmodSync = function(path24, mode) {
|
|
187
|
+
var fd = fs2.openSync(path24, constants2.O_WRONLY | constants2.O_SYMLINK, mode);
|
|
188
|
+
var threw = true;
|
|
189
|
+
var ret;
|
|
190
|
+
try {
|
|
191
|
+
ret = fs2.fchmodSync(fd, mode);
|
|
192
|
+
threw = false;
|
|
193
|
+
} finally {
|
|
194
|
+
if (threw) {
|
|
195
|
+
try {
|
|
196
|
+
fs2.closeSync(fd);
|
|
197
|
+
} catch (er) {
|
|
198
|
+
}
|
|
199
|
+
} else {
|
|
200
|
+
fs2.closeSync(fd);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return ret;
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function patchLutimes(fs2) {
|
|
207
|
+
if (constants2.hasOwnProperty("O_SYMLINK") && fs2.futimes) {
|
|
208
|
+
fs2.lutimes = function(path24, at, mt, cb) {
|
|
209
|
+
fs2.open(path24, constants2.O_SYMLINK, function(er, fd) {
|
|
210
|
+
if (er) {
|
|
211
|
+
if (cb) cb(er);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
fs2.futimes(fd, at, mt, function(er2) {
|
|
215
|
+
fs2.close(fd, function(er22) {
|
|
216
|
+
if (cb) cb(er2 || er22);
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
};
|
|
221
|
+
fs2.lutimesSync = function(path24, at, mt) {
|
|
222
|
+
var fd = fs2.openSync(path24, constants2.O_SYMLINK);
|
|
223
|
+
var ret;
|
|
224
|
+
var threw = true;
|
|
225
|
+
try {
|
|
226
|
+
ret = fs2.futimesSync(fd, at, mt);
|
|
227
|
+
threw = false;
|
|
228
|
+
} finally {
|
|
229
|
+
if (threw) {
|
|
230
|
+
try {
|
|
231
|
+
fs2.closeSync(fd);
|
|
232
|
+
} catch (er) {
|
|
233
|
+
}
|
|
234
|
+
} else {
|
|
235
|
+
fs2.closeSync(fd);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return ret;
|
|
239
|
+
};
|
|
240
|
+
} else if (fs2.futimes) {
|
|
241
|
+
fs2.lutimes = function(_a3, _b, _c, cb) {
|
|
242
|
+
if (cb) process.nextTick(cb);
|
|
243
|
+
};
|
|
244
|
+
fs2.lutimesSync = function() {
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
function chmodFix(orig) {
|
|
249
|
+
if (!orig) return orig;
|
|
250
|
+
return function(target2, mode, cb) {
|
|
251
|
+
return orig.call(fs, target2, mode, function(er) {
|
|
252
|
+
if (chownErOk(er)) er = null;
|
|
253
|
+
if (cb) cb.apply(this, arguments);
|
|
254
|
+
});
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
function chmodFixSync(orig) {
|
|
258
|
+
if (!orig) return orig;
|
|
259
|
+
return function(target2, mode) {
|
|
260
|
+
try {
|
|
261
|
+
return orig.call(fs, target2, mode);
|
|
262
|
+
} catch (er) {
|
|
263
|
+
if (!chownErOk(er)) throw er;
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
function chownFix(orig) {
|
|
268
|
+
if (!orig) return orig;
|
|
269
|
+
return function(target2, uid, gid, cb) {
|
|
270
|
+
return orig.call(fs, target2, uid, gid, function(er) {
|
|
271
|
+
if (chownErOk(er)) er = null;
|
|
272
|
+
if (cb) cb.apply(this, arguments);
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
function chownFixSync(orig) {
|
|
277
|
+
if (!orig) return orig;
|
|
278
|
+
return function(target2, uid, gid) {
|
|
279
|
+
try {
|
|
280
|
+
return orig.call(fs, target2, uid, gid);
|
|
281
|
+
} catch (er) {
|
|
282
|
+
if (!chownErOk(er)) throw er;
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function statFix(orig) {
|
|
287
|
+
if (!orig) return orig;
|
|
288
|
+
return function(target2, options, cb) {
|
|
289
|
+
if (typeof options === "function") {
|
|
290
|
+
cb = options;
|
|
291
|
+
options = null;
|
|
292
|
+
}
|
|
293
|
+
function callback(er, stats) {
|
|
294
|
+
if (stats) {
|
|
295
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
296
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
297
|
+
}
|
|
298
|
+
if (cb) cb.apply(this, arguments);
|
|
299
|
+
}
|
|
300
|
+
return options ? orig.call(fs, target2, options, callback) : orig.call(fs, target2, callback);
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
function statFixSync(orig) {
|
|
304
|
+
if (!orig) return orig;
|
|
305
|
+
return function(target2, options) {
|
|
306
|
+
var stats = options ? orig.call(fs, target2, options) : orig.call(fs, target2);
|
|
307
|
+
if (stats) {
|
|
308
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
309
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
310
|
+
}
|
|
311
|
+
return stats;
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function chownErOk(er) {
|
|
315
|
+
if (!er)
|
|
316
|
+
return true;
|
|
317
|
+
if (er.code === "ENOSYS")
|
|
318
|
+
return true;
|
|
319
|
+
var nonroot = !process.getuid || process.getuid() !== 0;
|
|
320
|
+
if (nonroot) {
|
|
321
|
+
if (er.code === "EINVAL" || er.code === "EPERM")
|
|
322
|
+
return true;
|
|
323
|
+
}
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
// node_modules/graceful-fs/legacy-streams.js
|
|
331
|
+
var require_legacy_streams = __commonJS({
|
|
332
|
+
"node_modules/graceful-fs/legacy-streams.js"(exports, module) {
|
|
333
|
+
var Stream = __require("stream").Stream;
|
|
334
|
+
module.exports = legacy;
|
|
335
|
+
function legacy(fs) {
|
|
336
|
+
return {
|
|
337
|
+
ReadStream,
|
|
338
|
+
WriteStream
|
|
339
|
+
};
|
|
340
|
+
function ReadStream(path24, options) {
|
|
341
|
+
if (!(this instanceof ReadStream)) return new ReadStream(path24, options);
|
|
342
|
+
Stream.call(this);
|
|
343
|
+
var self = this;
|
|
344
|
+
this.path = path24;
|
|
345
|
+
this.fd = null;
|
|
346
|
+
this.readable = true;
|
|
347
|
+
this.paused = false;
|
|
348
|
+
this.flags = "r";
|
|
349
|
+
this.mode = 438;
|
|
350
|
+
this.bufferSize = 64 * 1024;
|
|
351
|
+
options = options || {};
|
|
352
|
+
var keys = Object.keys(options);
|
|
353
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
354
|
+
var key = keys[index];
|
|
355
|
+
this[key] = options[key];
|
|
356
|
+
}
|
|
357
|
+
if (this.encoding) this.setEncoding(this.encoding);
|
|
358
|
+
if (this.start !== void 0) {
|
|
359
|
+
if ("number" !== typeof this.start) {
|
|
360
|
+
throw TypeError("start must be a Number");
|
|
361
|
+
}
|
|
362
|
+
if (this.end === void 0) {
|
|
363
|
+
this.end = Infinity;
|
|
364
|
+
} else if ("number" !== typeof this.end) {
|
|
365
|
+
throw TypeError("end must be a Number");
|
|
366
|
+
}
|
|
367
|
+
if (this.start > this.end) {
|
|
368
|
+
throw new Error("start must be <= end");
|
|
369
|
+
}
|
|
370
|
+
this.pos = this.start;
|
|
371
|
+
}
|
|
372
|
+
if (this.fd !== null) {
|
|
373
|
+
process.nextTick(function() {
|
|
374
|
+
self._read();
|
|
375
|
+
});
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
fs.open(this.path, this.flags, this.mode, function(err, fd) {
|
|
379
|
+
if (err) {
|
|
380
|
+
self.emit("error", err);
|
|
381
|
+
self.readable = false;
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
self.fd = fd;
|
|
385
|
+
self.emit("open", fd);
|
|
386
|
+
self._read();
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
function WriteStream(path24, options) {
|
|
390
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path24, options);
|
|
391
|
+
Stream.call(this);
|
|
392
|
+
this.path = path24;
|
|
393
|
+
this.fd = null;
|
|
394
|
+
this.writable = true;
|
|
395
|
+
this.flags = "w";
|
|
396
|
+
this.encoding = "binary";
|
|
397
|
+
this.mode = 438;
|
|
398
|
+
this.bytesWritten = 0;
|
|
399
|
+
options = options || {};
|
|
400
|
+
var keys = Object.keys(options);
|
|
401
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
402
|
+
var key = keys[index];
|
|
403
|
+
this[key] = options[key];
|
|
404
|
+
}
|
|
405
|
+
if (this.start !== void 0) {
|
|
406
|
+
if ("number" !== typeof this.start) {
|
|
407
|
+
throw TypeError("start must be a Number");
|
|
408
|
+
}
|
|
409
|
+
if (this.start < 0) {
|
|
410
|
+
throw new Error("start must be >= zero");
|
|
411
|
+
}
|
|
412
|
+
this.pos = this.start;
|
|
413
|
+
}
|
|
414
|
+
this.busy = false;
|
|
415
|
+
this._queue = [];
|
|
416
|
+
if (this.fd === null) {
|
|
417
|
+
this._open = fs.open;
|
|
418
|
+
this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
|
|
419
|
+
this.flush();
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
// node_modules/graceful-fs/clone.js
|
|
427
|
+
var require_clone = __commonJS({
|
|
428
|
+
"node_modules/graceful-fs/clone.js"(exports, module) {
|
|
429
|
+
"use strict";
|
|
430
|
+
module.exports = clone2;
|
|
431
|
+
var getPrototypeOf = Object.getPrototypeOf || function(obj) {
|
|
432
|
+
return obj.__proto__;
|
|
433
|
+
};
|
|
434
|
+
function clone2(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
|
+
}
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
// node_modules/graceful-fs/graceful-fs.js
|
|
450
|
+
var require_graceful_fs = __commonJS({
|
|
451
|
+
"node_modules/graceful-fs/graceful-fs.js"(exports, module) {
|
|
452
|
+
var fs = __require("fs");
|
|
453
|
+
var polyfills = require_polyfills();
|
|
454
|
+
var legacy = require_legacy_streams();
|
|
455
|
+
var clone2 = require_clone();
|
|
456
|
+
var util = __require("util");
|
|
457
|
+
var gracefulQueue;
|
|
458
|
+
var previousSymbol;
|
|
459
|
+
if (typeof Symbol === "function" && typeof Symbol.for === "function") {
|
|
460
|
+
gracefulQueue = /* @__PURE__ */ Symbol.for("graceful-fs.queue");
|
|
461
|
+
previousSymbol = /* @__PURE__ */ Symbol.for("graceful-fs.previous");
|
|
462
|
+
} else {
|
|
463
|
+
gracefulQueue = "___graceful-fs.queue";
|
|
464
|
+
previousSymbol = "___graceful-fs.previous";
|
|
465
|
+
}
|
|
466
|
+
function noop() {
|
|
467
|
+
}
|
|
468
|
+
function publishQueue(context, queue2) {
|
|
469
|
+
Object.defineProperty(context, gracefulQueue, {
|
|
470
|
+
get: function() {
|
|
471
|
+
return queue2;
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
var debug = noop;
|
|
476
|
+
if (util.debuglog)
|
|
477
|
+
debug = util.debuglog("gfs4");
|
|
478
|
+
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
|
|
479
|
+
debug = function() {
|
|
480
|
+
var m = util.format.apply(util, arguments);
|
|
481
|
+
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
|
|
482
|
+
console.error(m);
|
|
483
|
+
};
|
|
484
|
+
if (!fs[gracefulQueue]) {
|
|
485
|
+
queue = global[gracefulQueue] || [];
|
|
486
|
+
publishQueue(fs, queue);
|
|
487
|
+
fs.close = (function(fs$close) {
|
|
488
|
+
function close(fd, cb) {
|
|
489
|
+
return fs$close.call(fs, fd, function(err) {
|
|
490
|
+
if (!err) {
|
|
491
|
+
resetQueue();
|
|
492
|
+
}
|
|
493
|
+
if (typeof cb === "function")
|
|
494
|
+
cb.apply(this, arguments);
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
Object.defineProperty(close, previousSymbol, {
|
|
498
|
+
value: fs$close
|
|
499
|
+
});
|
|
500
|
+
return close;
|
|
501
|
+
})(fs.close);
|
|
502
|
+
fs.closeSync = (function(fs$closeSync) {
|
|
503
|
+
function closeSync(fd) {
|
|
504
|
+
fs$closeSync.apply(fs, arguments);
|
|
505
|
+
resetQueue();
|
|
506
|
+
}
|
|
507
|
+
Object.defineProperty(closeSync, previousSymbol, {
|
|
508
|
+
value: fs$closeSync
|
|
509
|
+
});
|
|
510
|
+
return closeSync;
|
|
511
|
+
})(fs.closeSync);
|
|
512
|
+
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
|
|
513
|
+
process.on("exit", function() {
|
|
514
|
+
debug(fs[gracefulQueue]);
|
|
515
|
+
__require("assert").equal(fs[gracefulQueue].length, 0);
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
var queue;
|
|
520
|
+
if (!global[gracefulQueue]) {
|
|
521
|
+
publishQueue(global, fs[gracefulQueue]);
|
|
522
|
+
}
|
|
523
|
+
module.exports = patch(clone2(fs));
|
|
524
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
|
|
525
|
+
module.exports = patch(fs);
|
|
526
|
+
fs.__patched = true;
|
|
527
|
+
}
|
|
528
|
+
function patch(fs2) {
|
|
529
|
+
polyfills(fs2);
|
|
530
|
+
fs2.gracefulify = patch;
|
|
531
|
+
fs2.createReadStream = createReadStream2;
|
|
532
|
+
fs2.createWriteStream = createWriteStream;
|
|
533
|
+
var fs$readFile = fs2.readFile;
|
|
534
|
+
fs2.readFile = readFile11;
|
|
535
|
+
function readFile11(path24, options, cb) {
|
|
536
|
+
if (typeof options === "function")
|
|
537
|
+
cb = options, options = null;
|
|
538
|
+
return go$readFile(path24, options, cb);
|
|
539
|
+
function go$readFile(path25, options2, cb2, startTime) {
|
|
540
|
+
return fs$readFile(path25, options2, function(err) {
|
|
541
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
542
|
+
enqueue([go$readFile, [path25, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
543
|
+
else {
|
|
544
|
+
if (typeof cb2 === "function")
|
|
545
|
+
cb2.apply(this, arguments);
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
var fs$writeFile = fs2.writeFile;
|
|
551
|
+
fs2.writeFile = writeFile6;
|
|
552
|
+
function writeFile6(path24, data, options, cb) {
|
|
553
|
+
if (typeof options === "function")
|
|
554
|
+
cb = options, options = null;
|
|
555
|
+
return go$writeFile(path24, data, options, cb);
|
|
556
|
+
function go$writeFile(path25, data2, options2, cb2, startTime) {
|
|
557
|
+
return fs$writeFile(path25, data2, options2, function(err) {
|
|
558
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
559
|
+
enqueue([go$writeFile, [path25, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
560
|
+
else {
|
|
561
|
+
if (typeof cb2 === "function")
|
|
562
|
+
cb2.apply(this, arguments);
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
var fs$appendFile = fs2.appendFile;
|
|
568
|
+
if (fs$appendFile)
|
|
569
|
+
fs2.appendFile = appendFile;
|
|
570
|
+
function appendFile(path24, data, options, cb) {
|
|
571
|
+
if (typeof options === "function")
|
|
572
|
+
cb = options, options = null;
|
|
573
|
+
return go$appendFile(path24, data, options, cb);
|
|
574
|
+
function go$appendFile(path25, data2, options2, cb2, startTime) {
|
|
575
|
+
return fs$appendFile(path25, data2, options2, function(err) {
|
|
576
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
577
|
+
enqueue([go$appendFile, [path25, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
578
|
+
else {
|
|
579
|
+
if (typeof cb2 === "function")
|
|
580
|
+
cb2.apply(this, arguments);
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
var fs$copyFile = fs2.copyFile;
|
|
586
|
+
if (fs$copyFile)
|
|
587
|
+
fs2.copyFile = copyFile2;
|
|
588
|
+
function copyFile2(src, dest, flags, cb) {
|
|
589
|
+
if (typeof flags === "function") {
|
|
590
|
+
cb = flags;
|
|
591
|
+
flags = 0;
|
|
592
|
+
}
|
|
593
|
+
return go$copyFile(src, dest, flags, cb);
|
|
594
|
+
function go$copyFile(src2, dest2, flags2, cb2, startTime) {
|
|
595
|
+
return fs$copyFile(src2, dest2, flags2, function(err) {
|
|
596
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
597
|
+
enqueue([go$copyFile, [src2, dest2, flags2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
598
|
+
else {
|
|
599
|
+
if (typeof cb2 === "function")
|
|
600
|
+
cb2.apply(this, arguments);
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
var fs$readdir = fs2.readdir;
|
|
606
|
+
fs2.readdir = readdir7;
|
|
607
|
+
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
608
|
+
function readdir7(path24, options, cb) {
|
|
609
|
+
if (typeof options === "function")
|
|
610
|
+
cb = options, options = null;
|
|
611
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path25, options2, cb2, startTime) {
|
|
612
|
+
return fs$readdir(path25, fs$readdirCallback(
|
|
613
|
+
path25,
|
|
614
|
+
options2,
|
|
615
|
+
cb2,
|
|
616
|
+
startTime
|
|
617
|
+
));
|
|
618
|
+
} : function go$readdir2(path25, options2, cb2, startTime) {
|
|
619
|
+
return fs$readdir(path25, options2, fs$readdirCallback(
|
|
620
|
+
path25,
|
|
621
|
+
options2,
|
|
622
|
+
cb2,
|
|
623
|
+
startTime
|
|
624
|
+
));
|
|
625
|
+
};
|
|
626
|
+
return go$readdir(path24, options, cb);
|
|
627
|
+
function fs$readdirCallback(path25, options2, cb2, startTime) {
|
|
628
|
+
return function(err, files) {
|
|
629
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
630
|
+
enqueue([
|
|
631
|
+
go$readdir,
|
|
632
|
+
[path25, options2, cb2],
|
|
633
|
+
err,
|
|
634
|
+
startTime || Date.now(),
|
|
635
|
+
Date.now()
|
|
636
|
+
]);
|
|
637
|
+
else {
|
|
638
|
+
if (files && files.sort)
|
|
639
|
+
files.sort();
|
|
640
|
+
if (typeof cb2 === "function")
|
|
641
|
+
cb2.call(this, err, files);
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
if (process.version.substr(0, 4) === "v0.8") {
|
|
647
|
+
var legStreams = legacy(fs2);
|
|
648
|
+
ReadStream = legStreams.ReadStream;
|
|
649
|
+
WriteStream = legStreams.WriteStream;
|
|
650
|
+
}
|
|
651
|
+
var fs$ReadStream = fs2.ReadStream;
|
|
652
|
+
if (fs$ReadStream) {
|
|
653
|
+
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
|
|
654
|
+
ReadStream.prototype.open = ReadStream$open;
|
|
655
|
+
}
|
|
656
|
+
var fs$WriteStream = fs2.WriteStream;
|
|
657
|
+
if (fs$WriteStream) {
|
|
658
|
+
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
|
659
|
+
WriteStream.prototype.open = WriteStream$open;
|
|
660
|
+
}
|
|
661
|
+
Object.defineProperty(fs2, "ReadStream", {
|
|
662
|
+
get: function() {
|
|
663
|
+
return ReadStream;
|
|
664
|
+
},
|
|
665
|
+
set: function(val) {
|
|
666
|
+
ReadStream = val;
|
|
667
|
+
},
|
|
668
|
+
enumerable: true,
|
|
669
|
+
configurable: true
|
|
670
|
+
});
|
|
671
|
+
Object.defineProperty(fs2, "WriteStream", {
|
|
672
|
+
get: function() {
|
|
673
|
+
return WriteStream;
|
|
674
|
+
},
|
|
675
|
+
set: function(val) {
|
|
676
|
+
WriteStream = val;
|
|
677
|
+
},
|
|
678
|
+
enumerable: true,
|
|
679
|
+
configurable: true
|
|
680
|
+
});
|
|
681
|
+
var FileReadStream = ReadStream;
|
|
682
|
+
Object.defineProperty(fs2, "FileReadStream", {
|
|
683
|
+
get: function() {
|
|
684
|
+
return FileReadStream;
|
|
685
|
+
},
|
|
686
|
+
set: function(val) {
|
|
687
|
+
FileReadStream = val;
|
|
688
|
+
},
|
|
689
|
+
enumerable: true,
|
|
690
|
+
configurable: true
|
|
691
|
+
});
|
|
692
|
+
var FileWriteStream = WriteStream;
|
|
693
|
+
Object.defineProperty(fs2, "FileWriteStream", {
|
|
694
|
+
get: function() {
|
|
695
|
+
return FileWriteStream;
|
|
696
|
+
},
|
|
697
|
+
set: function(val) {
|
|
698
|
+
FileWriteStream = val;
|
|
699
|
+
},
|
|
700
|
+
enumerable: true,
|
|
701
|
+
configurable: true
|
|
702
|
+
});
|
|
703
|
+
function ReadStream(path24, options) {
|
|
704
|
+
if (this instanceof ReadStream)
|
|
705
|
+
return fs$ReadStream.apply(this, arguments), this;
|
|
706
|
+
else
|
|
707
|
+
return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
|
|
708
|
+
}
|
|
709
|
+
function ReadStream$open() {
|
|
710
|
+
var that = this;
|
|
711
|
+
open7(that.path, that.flags, that.mode, function(err, fd) {
|
|
712
|
+
if (err) {
|
|
713
|
+
if (that.autoClose)
|
|
714
|
+
that.destroy();
|
|
715
|
+
that.emit("error", err);
|
|
716
|
+
} else {
|
|
717
|
+
that.fd = fd;
|
|
718
|
+
that.emit("open", fd);
|
|
719
|
+
that.read();
|
|
720
|
+
}
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
function WriteStream(path24, options) {
|
|
724
|
+
if (this instanceof WriteStream)
|
|
725
|
+
return fs$WriteStream.apply(this, arguments), this;
|
|
726
|
+
else
|
|
727
|
+
return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
|
|
728
|
+
}
|
|
729
|
+
function WriteStream$open() {
|
|
730
|
+
var that = this;
|
|
731
|
+
open7(that.path, that.flags, that.mode, function(err, fd) {
|
|
732
|
+
if (err) {
|
|
733
|
+
that.destroy();
|
|
734
|
+
that.emit("error", err);
|
|
735
|
+
} else {
|
|
736
|
+
that.fd = fd;
|
|
737
|
+
that.emit("open", fd);
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
function createReadStream2(path24, options) {
|
|
742
|
+
return new fs2.ReadStream(path24, options);
|
|
743
|
+
}
|
|
744
|
+
function createWriteStream(path24, options) {
|
|
745
|
+
return new fs2.WriteStream(path24, options);
|
|
746
|
+
}
|
|
747
|
+
var fs$open = fs2.open;
|
|
748
|
+
fs2.open = open7;
|
|
749
|
+
function open7(path24, flags, mode, cb) {
|
|
750
|
+
if (typeof mode === "function")
|
|
751
|
+
cb = mode, mode = null;
|
|
752
|
+
return go$open(path24, flags, mode, cb);
|
|
753
|
+
function go$open(path25, flags2, mode2, cb2, startTime) {
|
|
754
|
+
return fs$open(path25, flags2, mode2, function(err, fd) {
|
|
755
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
756
|
+
enqueue([go$open, [path25, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
757
|
+
else {
|
|
758
|
+
if (typeof cb2 === "function")
|
|
759
|
+
cb2.apply(this, arguments);
|
|
760
|
+
}
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
return fs2;
|
|
765
|
+
}
|
|
766
|
+
function enqueue(elem) {
|
|
767
|
+
debug("ENQUEUE", elem[0].name, elem[1]);
|
|
768
|
+
fs[gracefulQueue].push(elem);
|
|
769
|
+
retry();
|
|
770
|
+
}
|
|
771
|
+
var retryTimer;
|
|
772
|
+
function resetQueue() {
|
|
773
|
+
var now = Date.now();
|
|
774
|
+
for (var i = 0; i < fs[gracefulQueue].length; ++i) {
|
|
775
|
+
if (fs[gracefulQueue][i].length > 2) {
|
|
776
|
+
fs[gracefulQueue][i][3] = now;
|
|
777
|
+
fs[gracefulQueue][i][4] = now;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
retry();
|
|
781
|
+
}
|
|
782
|
+
function retry() {
|
|
783
|
+
clearTimeout(retryTimer);
|
|
784
|
+
retryTimer = void 0;
|
|
785
|
+
if (fs[gracefulQueue].length === 0)
|
|
786
|
+
return;
|
|
787
|
+
var elem = fs[gracefulQueue].shift();
|
|
788
|
+
var fn = elem[0];
|
|
789
|
+
var args = elem[1];
|
|
790
|
+
var err = elem[2];
|
|
791
|
+
var startTime = elem[3];
|
|
792
|
+
var lastTime = elem[4];
|
|
793
|
+
if (startTime === void 0) {
|
|
794
|
+
debug("RETRY", fn.name, args);
|
|
795
|
+
fn.apply(null, args);
|
|
796
|
+
} else if (Date.now() - startTime >= 6e4) {
|
|
797
|
+
debug("TIMEOUT", fn.name, args);
|
|
798
|
+
var cb = args.pop();
|
|
799
|
+
if (typeof cb === "function")
|
|
800
|
+
cb.call(null, err);
|
|
801
|
+
} else {
|
|
802
|
+
var sinceAttempt = Date.now() - lastTime;
|
|
803
|
+
var sinceStart = Math.max(lastTime - startTime, 1);
|
|
804
|
+
var desiredDelay = Math.min(sinceStart * 1.2, 100);
|
|
805
|
+
if (sinceAttempt >= desiredDelay) {
|
|
806
|
+
debug("RETRY", fn.name, args);
|
|
807
|
+
fn.apply(null, args.concat([startTime]));
|
|
808
|
+
} else {
|
|
809
|
+
fs[gracefulQueue].push(elem);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
if (retryTimer === void 0) {
|
|
813
|
+
retryTimer = setTimeout(retry, 0);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
});
|
|
818
|
+
|
|
819
|
+
// node_modules/retry/lib/retry_operation.js
|
|
820
|
+
var require_retry_operation = __commonJS({
|
|
821
|
+
"node_modules/retry/lib/retry_operation.js"(exports, module) {
|
|
822
|
+
function RetryOperation(timeouts, options) {
|
|
823
|
+
if (typeof options === "boolean") {
|
|
824
|
+
options = { forever: options };
|
|
825
|
+
}
|
|
826
|
+
this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
|
|
827
|
+
this._timeouts = timeouts;
|
|
828
|
+
this._options = options || {};
|
|
829
|
+
this._maxRetryTime = options && options.maxRetryTime || Infinity;
|
|
830
|
+
this._fn = null;
|
|
831
|
+
this._errors = [];
|
|
832
|
+
this._attempts = 1;
|
|
833
|
+
this._operationTimeout = null;
|
|
834
|
+
this._operationTimeoutCb = null;
|
|
835
|
+
this._timeout = null;
|
|
836
|
+
this._operationStart = null;
|
|
837
|
+
if (this._options.forever) {
|
|
838
|
+
this._cachedTimeouts = this._timeouts.slice(0);
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
module.exports = RetryOperation;
|
|
842
|
+
RetryOperation.prototype.reset = function() {
|
|
843
|
+
this._attempts = 1;
|
|
844
|
+
this._timeouts = this._originalTimeouts;
|
|
845
|
+
};
|
|
846
|
+
RetryOperation.prototype.stop = function() {
|
|
847
|
+
if (this._timeout) {
|
|
848
|
+
clearTimeout(this._timeout);
|
|
849
|
+
}
|
|
850
|
+
this._timeouts = [];
|
|
851
|
+
this._cachedTimeouts = null;
|
|
852
|
+
};
|
|
853
|
+
RetryOperation.prototype.retry = function(err) {
|
|
854
|
+
if (this._timeout) {
|
|
855
|
+
clearTimeout(this._timeout);
|
|
856
|
+
}
|
|
857
|
+
if (!err) {
|
|
858
|
+
return false;
|
|
859
|
+
}
|
|
860
|
+
var currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
861
|
+
if (err && currentTime - this._operationStart >= this._maxRetryTime) {
|
|
862
|
+
this._errors.unshift(new Error("RetryOperation timeout occurred"));
|
|
863
|
+
return false;
|
|
864
|
+
}
|
|
865
|
+
this._errors.push(err);
|
|
866
|
+
var timeout = this._timeouts.shift();
|
|
867
|
+
if (timeout === void 0) {
|
|
868
|
+
if (this._cachedTimeouts) {
|
|
869
|
+
this._errors.splice(this._errors.length - 1, this._errors.length);
|
|
870
|
+
this._timeouts = this._cachedTimeouts.slice(0);
|
|
871
|
+
timeout = this._timeouts.shift();
|
|
872
|
+
} else {
|
|
873
|
+
return false;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
var self = this;
|
|
877
|
+
var timer = setTimeout(function() {
|
|
878
|
+
self._attempts++;
|
|
879
|
+
if (self._operationTimeoutCb) {
|
|
880
|
+
self._timeout = setTimeout(function() {
|
|
881
|
+
self._operationTimeoutCb(self._attempts);
|
|
882
|
+
}, self._operationTimeout);
|
|
883
|
+
if (self._options.unref) {
|
|
884
|
+
self._timeout.unref();
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
self._fn(self._attempts);
|
|
888
|
+
}, timeout);
|
|
889
|
+
if (this._options.unref) {
|
|
890
|
+
timer.unref();
|
|
891
|
+
}
|
|
892
|
+
return true;
|
|
893
|
+
};
|
|
894
|
+
RetryOperation.prototype.attempt = function(fn, timeoutOps) {
|
|
895
|
+
this._fn = fn;
|
|
896
|
+
if (timeoutOps) {
|
|
897
|
+
if (timeoutOps.timeout) {
|
|
898
|
+
this._operationTimeout = timeoutOps.timeout;
|
|
899
|
+
}
|
|
900
|
+
if (timeoutOps.cb) {
|
|
901
|
+
this._operationTimeoutCb = timeoutOps.cb;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
var self = this;
|
|
905
|
+
if (this._operationTimeoutCb) {
|
|
906
|
+
this._timeout = setTimeout(function() {
|
|
907
|
+
self._operationTimeoutCb();
|
|
908
|
+
}, self._operationTimeout);
|
|
909
|
+
}
|
|
910
|
+
this._operationStart = (/* @__PURE__ */ new Date()).getTime();
|
|
911
|
+
this._fn(this._attempts);
|
|
912
|
+
};
|
|
913
|
+
RetryOperation.prototype.try = function(fn) {
|
|
914
|
+
console.log("Using RetryOperation.try() is deprecated");
|
|
915
|
+
this.attempt(fn);
|
|
916
|
+
};
|
|
917
|
+
RetryOperation.prototype.start = function(fn) {
|
|
918
|
+
console.log("Using RetryOperation.start() is deprecated");
|
|
919
|
+
this.attempt(fn);
|
|
920
|
+
};
|
|
921
|
+
RetryOperation.prototype.start = RetryOperation.prototype.try;
|
|
922
|
+
RetryOperation.prototype.errors = function() {
|
|
923
|
+
return this._errors;
|
|
924
|
+
};
|
|
925
|
+
RetryOperation.prototype.attempts = function() {
|
|
926
|
+
return this._attempts;
|
|
927
|
+
};
|
|
928
|
+
RetryOperation.prototype.mainError = function() {
|
|
929
|
+
if (this._errors.length === 0) {
|
|
930
|
+
return null;
|
|
931
|
+
}
|
|
932
|
+
var counts = {};
|
|
933
|
+
var mainError = null;
|
|
934
|
+
var mainErrorCount = 0;
|
|
935
|
+
for (var i = 0; i < this._errors.length; i++) {
|
|
936
|
+
var error51 = this._errors[i];
|
|
937
|
+
var message = error51.message;
|
|
938
|
+
var count2 = (counts[message] || 0) + 1;
|
|
939
|
+
counts[message] = count2;
|
|
940
|
+
if (count2 >= mainErrorCount) {
|
|
941
|
+
mainError = error51;
|
|
942
|
+
mainErrorCount = count2;
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
return mainError;
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
});
|
|
949
|
+
|
|
950
|
+
// node_modules/retry/lib/retry.js
|
|
951
|
+
var require_retry = __commonJS({
|
|
952
|
+
"node_modules/retry/lib/retry.js"(exports) {
|
|
953
|
+
var RetryOperation = require_retry_operation();
|
|
954
|
+
exports.operation = function(options) {
|
|
955
|
+
var timeouts = exports.timeouts(options);
|
|
956
|
+
return new RetryOperation(timeouts, {
|
|
957
|
+
forever: options && options.forever,
|
|
958
|
+
unref: options && options.unref,
|
|
959
|
+
maxRetryTime: options && options.maxRetryTime
|
|
960
|
+
});
|
|
961
|
+
};
|
|
962
|
+
exports.timeouts = function(options) {
|
|
963
|
+
if (options instanceof Array) {
|
|
964
|
+
return [].concat(options);
|
|
965
|
+
}
|
|
966
|
+
var opts = {
|
|
967
|
+
retries: 10,
|
|
968
|
+
factor: 2,
|
|
969
|
+
minTimeout: 1 * 1e3,
|
|
970
|
+
maxTimeout: Infinity,
|
|
971
|
+
randomize: false
|
|
972
|
+
};
|
|
973
|
+
for (var key in options) {
|
|
974
|
+
opts[key] = options[key];
|
|
975
|
+
}
|
|
976
|
+
if (opts.minTimeout > opts.maxTimeout) {
|
|
977
|
+
throw new Error("minTimeout is greater than maxTimeout");
|
|
978
|
+
}
|
|
979
|
+
var timeouts = [];
|
|
980
|
+
for (var i = 0; i < opts.retries; i++) {
|
|
981
|
+
timeouts.push(this.createTimeout(i, opts));
|
|
982
|
+
}
|
|
983
|
+
if (options && options.forever && !timeouts.length) {
|
|
984
|
+
timeouts.push(this.createTimeout(i, opts));
|
|
985
|
+
}
|
|
986
|
+
timeouts.sort(function(a, b) {
|
|
987
|
+
return a - b;
|
|
988
|
+
});
|
|
989
|
+
return timeouts;
|
|
990
|
+
};
|
|
991
|
+
exports.createTimeout = function(attempt, opts) {
|
|
992
|
+
var random = opts.randomize ? Math.random() + 1 : 1;
|
|
993
|
+
var timeout = Math.round(random * opts.minTimeout * Math.pow(opts.factor, attempt));
|
|
994
|
+
timeout = Math.min(timeout, opts.maxTimeout);
|
|
995
|
+
return timeout;
|
|
996
|
+
};
|
|
997
|
+
exports.wrap = function(obj, options, methods) {
|
|
998
|
+
if (options instanceof Array) {
|
|
999
|
+
methods = options;
|
|
1000
|
+
options = null;
|
|
1001
|
+
}
|
|
1002
|
+
if (!methods) {
|
|
1003
|
+
methods = [];
|
|
1004
|
+
for (var key in obj) {
|
|
1005
|
+
if (typeof obj[key] === "function") {
|
|
1006
|
+
methods.push(key);
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
for (var i = 0; i < methods.length; i++) {
|
|
1011
|
+
var method = methods[i];
|
|
1012
|
+
var original = obj[method];
|
|
1013
|
+
obj[method] = function retryWrapper(original2) {
|
|
1014
|
+
var op = exports.operation(options);
|
|
1015
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
|
1016
|
+
var callback = args.pop();
|
|
1017
|
+
args.push(function(err) {
|
|
1018
|
+
if (op.retry(err)) {
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
if (err) {
|
|
1022
|
+
arguments[0] = op.mainError();
|
|
1023
|
+
}
|
|
1024
|
+
callback.apply(this, arguments);
|
|
1025
|
+
});
|
|
1026
|
+
op.attempt(function() {
|
|
1027
|
+
original2.apply(obj, args);
|
|
1028
|
+
});
|
|
1029
|
+
}.bind(obj, original);
|
|
1030
|
+
obj[method].options = options;
|
|
1031
|
+
}
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
});
|
|
1035
|
+
|
|
1036
|
+
// node_modules/retry/index.js
|
|
1037
|
+
var require_retry2 = __commonJS({
|
|
1038
|
+
"node_modules/retry/index.js"(exports, module) {
|
|
1039
|
+
module.exports = require_retry();
|
|
1040
|
+
}
|
|
1041
|
+
});
|
|
1042
|
+
|
|
1043
|
+
// node_modules/signal-exit/signals.js
|
|
1044
|
+
var require_signals = __commonJS({
|
|
1045
|
+
"node_modules/signal-exit/signals.js"(exports, module) {
|
|
1046
|
+
module.exports = [
|
|
1047
|
+
"SIGABRT",
|
|
1048
|
+
"SIGALRM",
|
|
1049
|
+
"SIGHUP",
|
|
1050
|
+
"SIGINT",
|
|
1051
|
+
"SIGTERM"
|
|
1052
|
+
];
|
|
1053
|
+
if (process.platform !== "win32") {
|
|
1054
|
+
module.exports.push(
|
|
1055
|
+
"SIGVTALRM",
|
|
1056
|
+
"SIGXCPU",
|
|
1057
|
+
"SIGXFSZ",
|
|
1058
|
+
"SIGUSR2",
|
|
1059
|
+
"SIGTRAP",
|
|
1060
|
+
"SIGSYS",
|
|
1061
|
+
"SIGQUIT",
|
|
1062
|
+
"SIGIOT"
|
|
1063
|
+
// should detect profiler and enable/disable accordingly.
|
|
1064
|
+
// see #21
|
|
1065
|
+
// 'SIGPROF'
|
|
1066
|
+
);
|
|
1067
|
+
}
|
|
1068
|
+
if (process.platform === "linux") {
|
|
1069
|
+
module.exports.push(
|
|
1070
|
+
"SIGIO",
|
|
1071
|
+
"SIGPOLL",
|
|
1072
|
+
"SIGPWR",
|
|
1073
|
+
"SIGSTKFLT",
|
|
1074
|
+
"SIGUNUSED"
|
|
1075
|
+
);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
});
|
|
1079
|
+
|
|
1080
|
+
// node_modules/signal-exit/index.js
|
|
1081
|
+
var require_signal_exit = __commonJS({
|
|
1082
|
+
"node_modules/signal-exit/index.js"(exports, module) {
|
|
1083
|
+
var process3 = global.process;
|
|
1084
|
+
var processOk = function(process4) {
|
|
1085
|
+
return process4 && typeof process4 === "object" && typeof process4.removeListener === "function" && typeof process4.emit === "function" && typeof process4.reallyExit === "function" && typeof process4.listeners === "function" && typeof process4.kill === "function" && typeof process4.pid === "number" && typeof process4.on === "function";
|
|
1086
|
+
};
|
|
1087
|
+
if (!processOk(process3)) {
|
|
1088
|
+
module.exports = function() {
|
|
1089
|
+
return function() {
|
|
1090
|
+
};
|
|
1091
|
+
};
|
|
1092
|
+
} else {
|
|
1093
|
+
assert2 = __require("assert");
|
|
1094
|
+
signals = require_signals();
|
|
1095
|
+
isWin = /^win/i.test(process3.platform);
|
|
1096
|
+
EE = __require("events");
|
|
1097
|
+
if (typeof EE !== "function") {
|
|
1098
|
+
EE = EE.EventEmitter;
|
|
1099
|
+
}
|
|
1100
|
+
if (process3.__signal_exit_emitter__) {
|
|
1101
|
+
emitter = process3.__signal_exit_emitter__;
|
|
1102
|
+
} else {
|
|
1103
|
+
emitter = process3.__signal_exit_emitter__ = new EE();
|
|
1104
|
+
emitter.count = 0;
|
|
1105
|
+
emitter.emitted = {};
|
|
1106
|
+
}
|
|
1107
|
+
if (!emitter.infinite) {
|
|
1108
|
+
emitter.setMaxListeners(Infinity);
|
|
1109
|
+
emitter.infinite = true;
|
|
1110
|
+
}
|
|
1111
|
+
module.exports = function(cb, opts) {
|
|
1112
|
+
if (!processOk(global.process)) {
|
|
1113
|
+
return function() {
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
assert2.equal(typeof cb, "function", "a callback must be provided for exit handler");
|
|
1117
|
+
if (loaded === false) {
|
|
1118
|
+
load();
|
|
1119
|
+
}
|
|
1120
|
+
var ev = "exit";
|
|
1121
|
+
if (opts && opts.alwaysLast) {
|
|
1122
|
+
ev = "afterexit";
|
|
1123
|
+
}
|
|
1124
|
+
var remove = function() {
|
|
1125
|
+
emitter.removeListener(ev, cb);
|
|
1126
|
+
if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
|
|
1127
|
+
unload();
|
|
1128
|
+
}
|
|
1129
|
+
};
|
|
1130
|
+
emitter.on(ev, cb);
|
|
1131
|
+
return remove;
|
|
1132
|
+
};
|
|
1133
|
+
unload = function unload2() {
|
|
1134
|
+
if (!loaded || !processOk(global.process)) {
|
|
1135
|
+
return;
|
|
1136
|
+
}
|
|
1137
|
+
loaded = false;
|
|
1138
|
+
signals.forEach(function(sig) {
|
|
1139
|
+
try {
|
|
1140
|
+
process3.removeListener(sig, sigListeners[sig]);
|
|
1141
|
+
} catch (er) {
|
|
1142
|
+
}
|
|
1143
|
+
});
|
|
1144
|
+
process3.emit = originalProcessEmit;
|
|
1145
|
+
process3.reallyExit = originalProcessReallyExit;
|
|
1146
|
+
emitter.count -= 1;
|
|
1147
|
+
};
|
|
1148
|
+
module.exports.unload = unload;
|
|
1149
|
+
emit = function emit2(event, code, signal) {
|
|
1150
|
+
if (emitter.emitted[event]) {
|
|
1151
|
+
return;
|
|
1152
|
+
}
|
|
1153
|
+
emitter.emitted[event] = true;
|
|
1154
|
+
emitter.emit(event, code, signal);
|
|
1155
|
+
};
|
|
1156
|
+
sigListeners = {};
|
|
1157
|
+
signals.forEach(function(sig) {
|
|
1158
|
+
sigListeners[sig] = function listener() {
|
|
1159
|
+
if (!processOk(global.process)) {
|
|
1160
|
+
return;
|
|
1161
|
+
}
|
|
1162
|
+
var listeners = process3.listeners(sig);
|
|
1163
|
+
if (listeners.length === emitter.count) {
|
|
1164
|
+
unload();
|
|
1165
|
+
emit("exit", null, sig);
|
|
1166
|
+
emit("afterexit", null, sig);
|
|
1167
|
+
if (isWin && sig === "SIGHUP") {
|
|
1168
|
+
sig = "SIGINT";
|
|
1169
|
+
}
|
|
1170
|
+
process3.kill(process3.pid, sig);
|
|
1171
|
+
}
|
|
1172
|
+
};
|
|
1173
|
+
});
|
|
1174
|
+
module.exports.signals = function() {
|
|
1175
|
+
return signals;
|
|
1176
|
+
};
|
|
1177
|
+
loaded = false;
|
|
1178
|
+
load = function load2() {
|
|
1179
|
+
if (loaded || !processOk(global.process)) {
|
|
1180
|
+
return;
|
|
1181
|
+
}
|
|
1182
|
+
loaded = true;
|
|
1183
|
+
emitter.count += 1;
|
|
1184
|
+
signals = signals.filter(function(sig) {
|
|
1185
|
+
try {
|
|
1186
|
+
process3.on(sig, sigListeners[sig]);
|
|
1187
|
+
return true;
|
|
1188
|
+
} catch (er) {
|
|
1189
|
+
return false;
|
|
1190
|
+
}
|
|
1191
|
+
});
|
|
1192
|
+
process3.emit = processEmit;
|
|
1193
|
+
process3.reallyExit = processReallyExit;
|
|
1194
|
+
};
|
|
1195
|
+
module.exports.load = load;
|
|
1196
|
+
originalProcessReallyExit = process3.reallyExit;
|
|
1197
|
+
processReallyExit = function processReallyExit2(code) {
|
|
1198
|
+
if (!processOk(global.process)) {
|
|
1199
|
+
return;
|
|
1200
|
+
}
|
|
1201
|
+
process3.exitCode = code || /* istanbul ignore next */
|
|
1202
|
+
0;
|
|
1203
|
+
emit("exit", process3.exitCode, null);
|
|
1204
|
+
emit("afterexit", process3.exitCode, null);
|
|
1205
|
+
originalProcessReallyExit.call(process3, process3.exitCode);
|
|
1206
|
+
};
|
|
1207
|
+
originalProcessEmit = process3.emit;
|
|
1208
|
+
processEmit = function processEmit2(ev, arg) {
|
|
1209
|
+
if (ev === "exit" && processOk(global.process)) {
|
|
1210
|
+
if (arg !== void 0) {
|
|
1211
|
+
process3.exitCode = arg;
|
|
1212
|
+
}
|
|
1213
|
+
var ret = originalProcessEmit.apply(this, arguments);
|
|
1214
|
+
emit("exit", process3.exitCode, null);
|
|
1215
|
+
emit("afterexit", process3.exitCode, null);
|
|
1216
|
+
return ret;
|
|
1217
|
+
} else {
|
|
1218
|
+
return originalProcessEmit.apply(this, arguments);
|
|
1219
|
+
}
|
|
1220
|
+
};
|
|
1221
|
+
}
|
|
1222
|
+
var assert2;
|
|
1223
|
+
var signals;
|
|
1224
|
+
var isWin;
|
|
1225
|
+
var EE;
|
|
1226
|
+
var emitter;
|
|
1227
|
+
var unload;
|
|
1228
|
+
var emit;
|
|
1229
|
+
var sigListeners;
|
|
1230
|
+
var loaded;
|
|
1231
|
+
var load;
|
|
1232
|
+
var originalProcessReallyExit;
|
|
1233
|
+
var processReallyExit;
|
|
1234
|
+
var originalProcessEmit;
|
|
1235
|
+
var processEmit;
|
|
1236
|
+
}
|
|
1237
|
+
});
|
|
1238
|
+
|
|
1239
|
+
// node_modules/proper-lockfile/lib/mtime-precision.js
|
|
1240
|
+
var require_mtime_precision = __commonJS({
|
|
1241
|
+
"node_modules/proper-lockfile/lib/mtime-precision.js"(exports, module) {
|
|
1242
|
+
"use strict";
|
|
1243
|
+
var cacheSymbol = /* @__PURE__ */ Symbol();
|
|
1244
|
+
function probe(file2, fs, callback) {
|
|
1245
|
+
const cachedPrecision = fs[cacheSymbol];
|
|
1246
|
+
if (cachedPrecision) {
|
|
1247
|
+
return fs.stat(file2, (err, stat6) => {
|
|
1248
|
+
if (err) {
|
|
1249
|
+
return callback(err);
|
|
1250
|
+
}
|
|
1251
|
+
callback(null, stat6.mtime, cachedPrecision);
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
const mtime = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
|
|
1255
|
+
fs.utimes(file2, mtime, mtime, (err) => {
|
|
1256
|
+
if (err) {
|
|
1257
|
+
return callback(err);
|
|
1258
|
+
}
|
|
1259
|
+
fs.stat(file2, (err2, stat6) => {
|
|
1260
|
+
if (err2) {
|
|
1261
|
+
return callback(err2);
|
|
1262
|
+
}
|
|
1263
|
+
const precision = stat6.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
|
|
1264
|
+
Object.defineProperty(fs, cacheSymbol, { value: precision });
|
|
1265
|
+
callback(null, stat6.mtime, precision);
|
|
1266
|
+
});
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1269
|
+
function getMtime(precision) {
|
|
1270
|
+
let now = Date.now();
|
|
1271
|
+
if (precision === "s") {
|
|
1272
|
+
now = Math.ceil(now / 1e3) * 1e3;
|
|
1273
|
+
}
|
|
1274
|
+
return new Date(now);
|
|
1275
|
+
}
|
|
1276
|
+
module.exports.probe = probe;
|
|
1277
|
+
module.exports.getMtime = getMtime;
|
|
1278
|
+
}
|
|
1279
|
+
});
|
|
1280
|
+
|
|
1281
|
+
// node_modules/proper-lockfile/lib/lockfile.js
|
|
1282
|
+
var require_lockfile = __commonJS({
|
|
1283
|
+
"node_modules/proper-lockfile/lib/lockfile.js"(exports, module) {
|
|
1284
|
+
"use strict";
|
|
1285
|
+
var path24 = __require("path");
|
|
1286
|
+
var fs = require_graceful_fs();
|
|
1287
|
+
var retry = require_retry2();
|
|
1288
|
+
var onExit = require_signal_exit();
|
|
1289
|
+
var mtimePrecision = require_mtime_precision();
|
|
1290
|
+
var locks = {};
|
|
1291
|
+
function getLockFile(file2, options) {
|
|
1292
|
+
return options.lockfilePath || `${file2}.lock`;
|
|
1293
|
+
}
|
|
1294
|
+
function resolveCanonicalPath(file2, options, callback) {
|
|
1295
|
+
if (!options.realpath) {
|
|
1296
|
+
return callback(null, path24.resolve(file2));
|
|
1297
|
+
}
|
|
1298
|
+
options.fs.realpath(file2, callback);
|
|
1299
|
+
}
|
|
1300
|
+
function acquireLock(file2, options, callback) {
|
|
1301
|
+
const lockfilePath = getLockFile(file2, options);
|
|
1302
|
+
options.fs.mkdir(lockfilePath, (err) => {
|
|
1303
|
+
if (!err) {
|
|
1304
|
+
return mtimePrecision.probe(lockfilePath, options.fs, (err2, mtime, mtimePrecision2) => {
|
|
1305
|
+
if (err2) {
|
|
1306
|
+
options.fs.rmdir(lockfilePath, () => {
|
|
1307
|
+
});
|
|
1308
|
+
return callback(err2);
|
|
1309
|
+
}
|
|
1310
|
+
callback(null, mtime, mtimePrecision2);
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
if (err.code !== "EEXIST") {
|
|
1314
|
+
return callback(err);
|
|
1315
|
+
}
|
|
1316
|
+
if (options.stale <= 0) {
|
|
1317
|
+
return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file: file2 }));
|
|
1318
|
+
}
|
|
1319
|
+
options.fs.stat(lockfilePath, (err2, stat6) => {
|
|
1320
|
+
if (err2) {
|
|
1321
|
+
if (err2.code === "ENOENT") {
|
|
1322
|
+
return acquireLock(file2, { ...options, stale: 0 }, callback);
|
|
1323
|
+
}
|
|
1324
|
+
return callback(err2);
|
|
1325
|
+
}
|
|
1326
|
+
if (!isLockStale(stat6, options)) {
|
|
1327
|
+
return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file: file2 }));
|
|
1328
|
+
}
|
|
1329
|
+
removeLock(file2, options, (err3) => {
|
|
1330
|
+
if (err3) {
|
|
1331
|
+
return callback(err3);
|
|
1332
|
+
}
|
|
1333
|
+
acquireLock(file2, { ...options, stale: 0 }, callback);
|
|
1334
|
+
});
|
|
1335
|
+
});
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
1338
|
+
function isLockStale(stat6, options) {
|
|
1339
|
+
return stat6.mtime.getTime() < Date.now() - options.stale;
|
|
1340
|
+
}
|
|
1341
|
+
function removeLock(file2, options, callback) {
|
|
1342
|
+
options.fs.rmdir(getLockFile(file2, options), (err) => {
|
|
1343
|
+
if (err && err.code !== "ENOENT") {
|
|
1344
|
+
return callback(err);
|
|
1345
|
+
}
|
|
1346
|
+
callback();
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
1349
|
+
function updateLock(file2, options) {
|
|
1350
|
+
const lock2 = locks[file2];
|
|
1351
|
+
if (lock2.updateTimeout) {
|
|
1352
|
+
return;
|
|
1353
|
+
}
|
|
1354
|
+
lock2.updateDelay = lock2.updateDelay || options.update;
|
|
1355
|
+
lock2.updateTimeout = setTimeout(() => {
|
|
1356
|
+
lock2.updateTimeout = null;
|
|
1357
|
+
options.fs.stat(lock2.lockfilePath, (err, stat6) => {
|
|
1358
|
+
const isOverThreshold = lock2.lastUpdate + options.stale < Date.now();
|
|
1359
|
+
if (err) {
|
|
1360
|
+
if (err.code === "ENOENT" || isOverThreshold) {
|
|
1361
|
+
return setLockAsCompromised(file2, lock2, Object.assign(err, { code: "ECOMPROMISED" }));
|
|
1362
|
+
}
|
|
1363
|
+
lock2.updateDelay = 1e3;
|
|
1364
|
+
return updateLock(file2, options);
|
|
1365
|
+
}
|
|
1366
|
+
const isMtimeOurs = lock2.mtime.getTime() === stat6.mtime.getTime();
|
|
1367
|
+
if (!isMtimeOurs) {
|
|
1368
|
+
return setLockAsCompromised(
|
|
1369
|
+
file2,
|
|
1370
|
+
lock2,
|
|
1371
|
+
Object.assign(
|
|
1372
|
+
new Error("Unable to update lock within the stale threshold"),
|
|
1373
|
+
{ code: "ECOMPROMISED" }
|
|
1374
|
+
)
|
|
1375
|
+
);
|
|
1376
|
+
}
|
|
1377
|
+
const mtime = mtimePrecision.getMtime(lock2.mtimePrecision);
|
|
1378
|
+
options.fs.utimes(lock2.lockfilePath, mtime, mtime, (err2) => {
|
|
1379
|
+
const isOverThreshold2 = lock2.lastUpdate + options.stale < Date.now();
|
|
1380
|
+
if (lock2.released) {
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1383
|
+
if (err2) {
|
|
1384
|
+
if (err2.code === "ENOENT" || isOverThreshold2) {
|
|
1385
|
+
return setLockAsCompromised(file2, lock2, Object.assign(err2, { code: "ECOMPROMISED" }));
|
|
1386
|
+
}
|
|
1387
|
+
lock2.updateDelay = 1e3;
|
|
1388
|
+
return updateLock(file2, options);
|
|
1389
|
+
}
|
|
1390
|
+
lock2.mtime = mtime;
|
|
1391
|
+
lock2.lastUpdate = Date.now();
|
|
1392
|
+
lock2.updateDelay = null;
|
|
1393
|
+
updateLock(file2, options);
|
|
1394
|
+
});
|
|
1395
|
+
});
|
|
1396
|
+
}, lock2.updateDelay);
|
|
1397
|
+
if (lock2.updateTimeout.unref) {
|
|
1398
|
+
lock2.updateTimeout.unref();
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
function setLockAsCompromised(file2, lock2, err) {
|
|
1402
|
+
lock2.released = true;
|
|
1403
|
+
if (lock2.updateTimeout) {
|
|
1404
|
+
clearTimeout(lock2.updateTimeout);
|
|
1405
|
+
}
|
|
1406
|
+
if (locks[file2] === lock2) {
|
|
1407
|
+
delete locks[file2];
|
|
1408
|
+
}
|
|
1409
|
+
lock2.options.onCompromised(err);
|
|
1410
|
+
}
|
|
1411
|
+
function lock(file2, options, callback) {
|
|
1412
|
+
options = {
|
|
1413
|
+
stale: 1e4,
|
|
1414
|
+
update: null,
|
|
1415
|
+
realpath: true,
|
|
1416
|
+
retries: 0,
|
|
1417
|
+
fs,
|
|
1418
|
+
onCompromised: (err) => {
|
|
1419
|
+
throw err;
|
|
1420
|
+
},
|
|
1421
|
+
...options
|
|
1422
|
+
};
|
|
1423
|
+
options.retries = options.retries || 0;
|
|
1424
|
+
options.retries = typeof options.retries === "number" ? { retries: options.retries } : options.retries;
|
|
1425
|
+
options.stale = Math.max(options.stale || 0, 2e3);
|
|
1426
|
+
options.update = options.update == null ? options.stale / 2 : options.update || 0;
|
|
1427
|
+
options.update = Math.max(Math.min(options.update, options.stale / 2), 1e3);
|
|
1428
|
+
resolveCanonicalPath(file2, options, (err, file3) => {
|
|
1429
|
+
if (err) {
|
|
1430
|
+
return callback(err);
|
|
1431
|
+
}
|
|
1432
|
+
const operation = retry.operation(options.retries);
|
|
1433
|
+
operation.attempt(() => {
|
|
1434
|
+
acquireLock(file3, options, (err2, mtime, mtimePrecision2) => {
|
|
1435
|
+
if (operation.retry(err2)) {
|
|
1436
|
+
return;
|
|
1437
|
+
}
|
|
1438
|
+
if (err2) {
|
|
1439
|
+
return callback(operation.mainError());
|
|
1440
|
+
}
|
|
1441
|
+
const lock2 = locks[file3] = {
|
|
1442
|
+
lockfilePath: getLockFile(file3, options),
|
|
1443
|
+
mtime,
|
|
1444
|
+
mtimePrecision: mtimePrecision2,
|
|
1445
|
+
options,
|
|
1446
|
+
lastUpdate: Date.now()
|
|
1447
|
+
};
|
|
1448
|
+
updateLock(file3, options);
|
|
1449
|
+
callback(null, (releasedCallback) => {
|
|
1450
|
+
if (lock2.released) {
|
|
1451
|
+
return releasedCallback && releasedCallback(Object.assign(new Error("Lock is already released"), { code: "ERELEASED" }));
|
|
1452
|
+
}
|
|
1453
|
+
unlock(file3, { ...options, realpath: false }, releasedCallback);
|
|
1454
|
+
});
|
|
1455
|
+
});
|
|
1456
|
+
});
|
|
1457
|
+
});
|
|
1458
|
+
}
|
|
1459
|
+
function unlock(file2, options, callback) {
|
|
1460
|
+
options = {
|
|
1461
|
+
fs,
|
|
1462
|
+
realpath: true,
|
|
1463
|
+
...options
|
|
1464
|
+
};
|
|
1465
|
+
resolveCanonicalPath(file2, options, (err, file3) => {
|
|
1466
|
+
if (err) {
|
|
1467
|
+
return callback(err);
|
|
1468
|
+
}
|
|
1469
|
+
const lock2 = locks[file3];
|
|
1470
|
+
if (!lock2) {
|
|
1471
|
+
return callback(Object.assign(new Error("Lock is not acquired/owned by you"), { code: "ENOTACQUIRED" }));
|
|
1472
|
+
}
|
|
1473
|
+
lock2.updateTimeout && clearTimeout(lock2.updateTimeout);
|
|
1474
|
+
lock2.released = true;
|
|
1475
|
+
delete locks[file3];
|
|
1476
|
+
removeLock(file3, options, callback);
|
|
1477
|
+
});
|
|
1478
|
+
}
|
|
1479
|
+
function check3(file2, options, callback) {
|
|
1480
|
+
options = {
|
|
1481
|
+
stale: 1e4,
|
|
1482
|
+
realpath: true,
|
|
1483
|
+
fs,
|
|
1484
|
+
...options
|
|
1485
|
+
};
|
|
1486
|
+
options.stale = Math.max(options.stale || 0, 2e3);
|
|
1487
|
+
resolveCanonicalPath(file2, options, (err, file3) => {
|
|
1488
|
+
if (err) {
|
|
1489
|
+
return callback(err);
|
|
1490
|
+
}
|
|
1491
|
+
options.fs.stat(getLockFile(file3, options), (err2, stat6) => {
|
|
1492
|
+
if (err2) {
|
|
1493
|
+
return err2.code === "ENOENT" ? callback(null, false) : callback(err2);
|
|
1494
|
+
}
|
|
1495
|
+
return callback(null, !isLockStale(stat6, options));
|
|
1496
|
+
});
|
|
1497
|
+
});
|
|
1498
|
+
}
|
|
1499
|
+
function getLocks() {
|
|
1500
|
+
return locks;
|
|
1501
|
+
}
|
|
1502
|
+
onExit(() => {
|
|
1503
|
+
for (const file2 in locks) {
|
|
1504
|
+
const options = locks[file2].options;
|
|
1505
|
+
try {
|
|
1506
|
+
options.fs.rmdirSync(getLockFile(file2, options));
|
|
1507
|
+
} catch (e) {
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
});
|
|
1511
|
+
module.exports.lock = lock;
|
|
1512
|
+
module.exports.unlock = unlock;
|
|
1513
|
+
module.exports.check = check3;
|
|
1514
|
+
module.exports.getLocks = getLocks;
|
|
1515
|
+
}
|
|
1516
|
+
});
|
|
1517
|
+
|
|
1518
|
+
// node_modules/proper-lockfile/lib/adapter.js
|
|
1519
|
+
var require_adapter = __commonJS({
|
|
1520
|
+
"node_modules/proper-lockfile/lib/adapter.js"(exports, module) {
|
|
1521
|
+
"use strict";
|
|
1522
|
+
var fs = require_graceful_fs();
|
|
1523
|
+
function createSyncFs(fs2) {
|
|
1524
|
+
const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
|
|
1525
|
+
const newFs = { ...fs2 };
|
|
1526
|
+
methods.forEach((method) => {
|
|
1527
|
+
newFs[method] = (...args) => {
|
|
1528
|
+
const callback = args.pop();
|
|
1529
|
+
let ret;
|
|
1530
|
+
try {
|
|
1531
|
+
ret = fs2[`${method}Sync`](...args);
|
|
1532
|
+
} catch (err) {
|
|
1533
|
+
return callback(err);
|
|
1534
|
+
}
|
|
1535
|
+
callback(null, ret);
|
|
1536
|
+
};
|
|
1537
|
+
});
|
|
1538
|
+
return newFs;
|
|
1539
|
+
}
|
|
1540
|
+
function toPromise(method) {
|
|
1541
|
+
return (...args) => new Promise((resolve, reject) => {
|
|
1542
|
+
args.push((err, result) => {
|
|
1543
|
+
if (err) {
|
|
1544
|
+
reject(err);
|
|
1545
|
+
} else {
|
|
1546
|
+
resolve(result);
|
|
1547
|
+
}
|
|
1548
|
+
});
|
|
1549
|
+
method(...args);
|
|
1550
|
+
});
|
|
1551
|
+
}
|
|
1552
|
+
function toSync(method) {
|
|
1553
|
+
return (...args) => {
|
|
1554
|
+
let err;
|
|
1555
|
+
let result;
|
|
1556
|
+
args.push((_err, _result) => {
|
|
1557
|
+
err = _err;
|
|
1558
|
+
result = _result;
|
|
1559
|
+
});
|
|
1560
|
+
method(...args);
|
|
1561
|
+
if (err) {
|
|
1562
|
+
throw err;
|
|
1563
|
+
}
|
|
1564
|
+
return result;
|
|
1565
|
+
};
|
|
1566
|
+
}
|
|
1567
|
+
function toSyncOptions(options) {
|
|
1568
|
+
options = { ...options };
|
|
1569
|
+
options.fs = createSyncFs(options.fs || fs);
|
|
1570
|
+
if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
|
|
1571
|
+
throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
|
|
1572
|
+
}
|
|
1573
|
+
return options;
|
|
1574
|
+
}
|
|
1575
|
+
module.exports = {
|
|
1576
|
+
toPromise,
|
|
1577
|
+
toSync,
|
|
1578
|
+
toSyncOptions
|
|
1579
|
+
};
|
|
1580
|
+
}
|
|
1581
|
+
});
|
|
1582
|
+
|
|
1583
|
+
// node_modules/proper-lockfile/index.js
|
|
1584
|
+
var require_proper_lockfile = __commonJS({
|
|
1585
|
+
"node_modules/proper-lockfile/index.js"(exports, module) {
|
|
1586
|
+
"use strict";
|
|
1587
|
+
var lockfile2 = require_lockfile();
|
|
1588
|
+
var { toPromise, toSync, toSyncOptions } = require_adapter();
|
|
1589
|
+
async function lock(file2, options) {
|
|
1590
|
+
const release = await toPromise(lockfile2.lock)(file2, options);
|
|
1591
|
+
return toPromise(release);
|
|
1592
|
+
}
|
|
1593
|
+
function lockSync(file2, options) {
|
|
1594
|
+
const release = toSync(lockfile2.lock)(file2, toSyncOptions(options));
|
|
1595
|
+
return toSync(release);
|
|
1596
|
+
}
|
|
1597
|
+
function unlock(file2, options) {
|
|
1598
|
+
return toPromise(lockfile2.unlock)(file2, options);
|
|
1599
|
+
}
|
|
1600
|
+
function unlockSync(file2, options) {
|
|
1601
|
+
return toSync(lockfile2.unlock)(file2, toSyncOptions(options));
|
|
1602
|
+
}
|
|
1603
|
+
function check3(file2, options) {
|
|
1604
|
+
return toPromise(lockfile2.check)(file2, options);
|
|
1605
|
+
}
|
|
1606
|
+
function checkSync(file2, options) {
|
|
1607
|
+
return toSync(lockfile2.check)(file2, toSyncOptions(options));
|
|
1608
|
+
}
|
|
1609
|
+
module.exports = lock;
|
|
1610
|
+
module.exports.lock = lock;
|
|
1611
|
+
module.exports.unlock = unlock;
|
|
1612
|
+
module.exports.lockSync = lockSync;
|
|
1613
|
+
module.exports.unlockSync = unlockSync;
|
|
1614
|
+
module.exports.check = check3;
|
|
1615
|
+
module.exports.checkSync = checkSync;
|
|
1616
|
+
}
|
|
1617
|
+
});
|
|
6
1618
|
|
|
7
1619
|
// packages/console-server/src/main.ts
|
|
8
|
-
import
|
|
1620
|
+
import path23 from "node:path";
|
|
9
1621
|
import { fileURLToPath } from "node:url";
|
|
10
1622
|
|
|
11
1623
|
// packages/update-manager/dist/runtime-metadata.js
|
|
@@ -634,7 +2246,7 @@ async function verifyDownloadedArtifact(source, filePath, result) {
|
|
|
634
2246
|
|
|
635
2247
|
// packages/update-manager/dist/updater-ready.js
|
|
636
2248
|
import { setTimeout as delay } from "node:timers/promises";
|
|
637
|
-
async function waitForUpdaterReady(child,
|
|
2249
|
+
async function waitForUpdaterReady(child, readStatus2, timeoutMs = 1e4, beforeWait) {
|
|
638
2250
|
let failure;
|
|
639
2251
|
const onError = (error51) => {
|
|
640
2252
|
failure = error51;
|
|
@@ -648,7 +2260,7 @@ async function waitForUpdaterReady(child, readStatus, timeoutMs = 1e4, beforeWai
|
|
|
648
2260
|
try {
|
|
649
2261
|
await beforeWait?.();
|
|
650
2262
|
while (true) {
|
|
651
|
-
const status = await
|
|
2263
|
+
const status = await readStatus2();
|
|
652
2264
|
if (status?.phase === "failed")
|
|
653
2265
|
throw new Error(status.error ?? "Background Updater failed");
|
|
654
2266
|
if (failure)
|
|
@@ -963,7 +2575,7 @@ function createBackgroundUpdateManager(dependencies = {}) {
|
|
|
963
2575
|
}
|
|
964
2576
|
|
|
965
2577
|
// packages/console-server/src/harnesses.ts
|
|
966
|
-
import
|
|
2578
|
+
import path14 from "node:path";
|
|
967
2579
|
|
|
968
2580
|
// packages/harness-plugin-files/dist/discovery.js
|
|
969
2581
|
import { readdir as readdir2, realpath as realpath2 } from "node:fs/promises";
|
|
@@ -1735,10 +3347,10 @@ function mergeDefs(...defs) {
|
|
|
1735
3347
|
function cloneDef(schema) {
|
|
1736
3348
|
return mergeDefs(schema._zod.def);
|
|
1737
3349
|
}
|
|
1738
|
-
function getElementAtPath(obj,
|
|
1739
|
-
if (!
|
|
3350
|
+
function getElementAtPath(obj, path24) {
|
|
3351
|
+
if (!path24)
|
|
1740
3352
|
return obj;
|
|
1741
|
-
return
|
|
3353
|
+
return path24.reduce((acc, key) => acc?.[key], obj);
|
|
1742
3354
|
}
|
|
1743
3355
|
function promiseAllObject(promisesObj) {
|
|
1744
3356
|
const keys = Object.keys(promisesObj);
|
|
@@ -2147,11 +3759,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
2147
3759
|
}
|
|
2148
3760
|
return false;
|
|
2149
3761
|
}
|
|
2150
|
-
function prefixIssues(
|
|
3762
|
+
function prefixIssues(path24, issues) {
|
|
2151
3763
|
return issues.map((iss) => {
|
|
2152
3764
|
var _a3;
|
|
2153
3765
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
2154
|
-
iss.path.unshift(
|
|
3766
|
+
iss.path.unshift(path24);
|
|
2155
3767
|
return iss;
|
|
2156
3768
|
});
|
|
2157
3769
|
}
|
|
@@ -2298,16 +3910,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
2298
3910
|
}
|
|
2299
3911
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
2300
3912
|
const fieldErrors = { _errors: [] };
|
|
2301
|
-
const processError = (error52,
|
|
3913
|
+
const processError = (error52, path24 = []) => {
|
|
2302
3914
|
for (const issue2 of error52.issues) {
|
|
2303
3915
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
2304
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
3916
|
+
issue2.errors.map((issues) => processError({ issues }, [...path24, ...issue2.path]));
|
|
2305
3917
|
} else if (issue2.code === "invalid_key") {
|
|
2306
|
-
processError({ issues: issue2.issues }, [...
|
|
3918
|
+
processError({ issues: issue2.issues }, [...path24, ...issue2.path]);
|
|
2307
3919
|
} else if (issue2.code === "invalid_element") {
|
|
2308
|
-
processError({ issues: issue2.issues }, [...
|
|
3920
|
+
processError({ issues: issue2.issues }, [...path24, ...issue2.path]);
|
|
2309
3921
|
} else {
|
|
2310
|
-
const fullpath = [...
|
|
3922
|
+
const fullpath = [...path24, ...issue2.path];
|
|
2311
3923
|
if (fullpath.length === 0) {
|
|
2312
3924
|
fieldErrors._errors.push(mapper(issue2));
|
|
2313
3925
|
} else {
|
|
@@ -2334,17 +3946,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
2334
3946
|
}
|
|
2335
3947
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
2336
3948
|
const result = { errors: [] };
|
|
2337
|
-
const processError = (error52,
|
|
3949
|
+
const processError = (error52, path24 = []) => {
|
|
2338
3950
|
var _a3, _b;
|
|
2339
3951
|
for (const issue2 of error52.issues) {
|
|
2340
3952
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
2341
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
3953
|
+
issue2.errors.map((issues) => processError({ issues }, [...path24, ...issue2.path]));
|
|
2342
3954
|
} else if (issue2.code === "invalid_key") {
|
|
2343
|
-
processError({ issues: issue2.issues }, [...
|
|
3955
|
+
processError({ issues: issue2.issues }, [...path24, ...issue2.path]);
|
|
2344
3956
|
} else if (issue2.code === "invalid_element") {
|
|
2345
|
-
processError({ issues: issue2.issues }, [...
|
|
3957
|
+
processError({ issues: issue2.issues }, [...path24, ...issue2.path]);
|
|
2346
3958
|
} else {
|
|
2347
|
-
const fullpath = [...
|
|
3959
|
+
const fullpath = [...path24, ...issue2.path];
|
|
2348
3960
|
if (fullpath.length === 0) {
|
|
2349
3961
|
result.errors.push(mapper(issue2));
|
|
2350
3962
|
continue;
|
|
@@ -2376,8 +3988,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
2376
3988
|
}
|
|
2377
3989
|
function toDotPath(_path) {
|
|
2378
3990
|
const segs = [];
|
|
2379
|
-
const
|
|
2380
|
-
for (const seg of
|
|
3991
|
+
const path24 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
3992
|
+
for (const seg of path24) {
|
|
2381
3993
|
if (typeof seg === "number")
|
|
2382
3994
|
segs.push(`[${seg}]`);
|
|
2383
3995
|
else if (typeof seg === "symbol")
|
|
@@ -13745,8 +15357,8 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
13745
15357
|
reg.add(this, meta3);
|
|
13746
15358
|
return this;
|
|
13747
15359
|
},
|
|
13748
|
-
refine(
|
|
13749
|
-
return this.check(refine(
|
|
15360
|
+
refine(check3, params) {
|
|
15361
|
+
return this.check(refine(check3, params));
|
|
13750
15362
|
},
|
|
13751
15363
|
superRefine(refinement, params) {
|
|
13752
15364
|
return this.check(superRefine(refinement, params));
|
|
@@ -15069,13 +16681,13 @@ function resolveRef(ref, ctx) {
|
|
|
15069
16681
|
if (!ref.startsWith("#")) {
|
|
15070
16682
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
15071
16683
|
}
|
|
15072
|
-
const
|
|
15073
|
-
if (
|
|
16684
|
+
const path24 = ref.slice(1).split("/").filter(Boolean);
|
|
16685
|
+
if (path24.length === 0) {
|
|
15074
16686
|
return ctx.rootSchema;
|
|
15075
16687
|
}
|
|
15076
16688
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
15077
|
-
if (
|
|
15078
|
-
const key =
|
|
16689
|
+
if (path24[0] === defsKey) {
|
|
16690
|
+
const key = path24[1];
|
|
15079
16691
|
if (!key || !ctx.defs[key]) {
|
|
15080
16692
|
throw new Error(`Reference not found: ${ref}`);
|
|
15081
16693
|
}
|
|
@@ -15483,6 +17095,87 @@ function date4(params) {
|
|
|
15483
17095
|
// node_modules/zod/v4/classic/external.js
|
|
15484
17096
|
config(en_default());
|
|
15485
17097
|
|
|
17098
|
+
// packages/shared-contracts/dist/ids.js
|
|
17099
|
+
var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
17100
|
+
message: "Identifier must not be empty or whitespace"
|
|
17101
|
+
});
|
|
17102
|
+
var harnessIdSchema = opaqueIdSchema.brand();
|
|
17103
|
+
var hostThreadIdSchema = opaqueIdSchema.brand();
|
|
17104
|
+
var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
17105
|
+
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
17106
|
+
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
17107
|
+
|
|
17108
|
+
// packages/shared-contracts/dist/harness-plugins.js
|
|
17109
|
+
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
17110
|
+
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
17111
|
+
var HARNESS_PLUGIN_LIMIT = 128;
|
|
17112
|
+
var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
|
|
17113
|
+
var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
|
|
17114
|
+
var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id) => id !== "codex", "The official Codex identity is reserved");
|
|
17115
|
+
var pluginRelativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
|
|
17116
|
+
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
17117
|
+
var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
|
|
17118
|
+
var harnessInstallationGuideSchema = external_exports.object({
|
|
17119
|
+
commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
|
|
17120
|
+
before: localizedTextSchema.optional(),
|
|
17121
|
+
after: localizedTextSchema.optional(),
|
|
17122
|
+
downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
|
|
17123
|
+
}).strict();
|
|
17124
|
+
var pluginPresentationShape = {
|
|
17125
|
+
id: installedHarnessPluginIdSchema,
|
|
17126
|
+
name: external_exports.string().trim().min(1).max(128),
|
|
17127
|
+
version: external_exports.string().min(1).max(128),
|
|
17128
|
+
/** Capability-only plugin; omitted for existing session-capable plugins. */
|
|
17129
|
+
kind: external_exports.literal("usage").optional(),
|
|
17130
|
+
/** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
|
|
17131
|
+
iconStyle: external_exports.object({
|
|
17132
|
+
vector: external_exports.object({
|
|
17133
|
+
viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
|
|
17134
|
+
color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
|
|
17135
|
+
paths: external_exports.array(external_exports.object({
|
|
17136
|
+
d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
|
|
17137
|
+
fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
|
|
17138
|
+
fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
|
|
17139
|
+
}).strict()).min(1).max(32)
|
|
17140
|
+
}).strict().optional(),
|
|
17141
|
+
background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
|
|
17142
|
+
borderRadius: external_exports.number().min(0).max(50).optional(),
|
|
17143
|
+
paddingRatio: external_exports.number().min(0).max(0.25).optional()
|
|
17144
|
+
}).strict().optional(),
|
|
17145
|
+
installation: harnessInstallationGuideSchema.optional(),
|
|
17146
|
+
notice: localizedTextSchema.optional(),
|
|
17147
|
+
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
17148
|
+
launchCommand: external_exports.literal(true).optional(),
|
|
17149
|
+
links: external_exports.object({
|
|
17150
|
+
website: documentationUrlSchema.optional(),
|
|
17151
|
+
documentation: documentationUrlSchema.optional(),
|
|
17152
|
+
installation: documentationUrlSchema.optional()
|
|
17153
|
+
}).strict().optional()
|
|
17154
|
+
};
|
|
17155
|
+
var harnessPluginManifestSchema = external_exports.object({
|
|
17156
|
+
manifestVersion: external_exports.literal(1),
|
|
17157
|
+
...pluginPresentationShape,
|
|
17158
|
+
adapterApiVersion: external_exports.number().int().positive(),
|
|
17159
|
+
entry: pluginRelativeResourceSchema,
|
|
17160
|
+
icon: pluginRelativeResourceSchema.optional()
|
|
17161
|
+
}).strict();
|
|
17162
|
+
var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
|
|
17163
|
+
var harnessPluginDescriptorSchema = external_exports.object({
|
|
17164
|
+
...pluginPresentationShape,
|
|
17165
|
+
icon: harnessPluginIconSchema.optional()
|
|
17166
|
+
}).strict();
|
|
17167
|
+
var harnessPluginListParamsSchema = external_exports.object({}).strict();
|
|
17168
|
+
var harnessPluginListResultSchema = external_exports.object({
|
|
17169
|
+
plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
|
|
17170
|
+
}).strict();
|
|
17171
|
+
var harnessPluginConfigurationSchema = external_exports.object({
|
|
17172
|
+
version: external_exports.literal(1),
|
|
17173
|
+
enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
17174
|
+
}).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
|
|
17175
|
+
message: "Enabled plugin IDs must be unique",
|
|
17176
|
+
path: ["enabled"]
|
|
17177
|
+
});
|
|
17178
|
+
|
|
15486
17179
|
// packages/shared-contracts/dist/json-value.js
|
|
15487
17180
|
function rejectExplicitUndefined(keys) {
|
|
15488
17181
|
return (value, context) => {
|
|
@@ -15542,6 +17235,379 @@ var jsonValueSchema = nonCircularSchema.pipe(recursiveJsonValueSchema);
|
|
|
15542
17235
|
var jsonArraySchema = nonCircularSchema.pipe(external_exports.array(recursiveJsonValueSchema));
|
|
15543
17236
|
var jsonObjectSchema = nonCircularSchema.pipe(external_exports.record(external_exports.string(), recursiveJsonValueSchema));
|
|
15544
17237
|
|
|
17238
|
+
// packages/shared-contracts/dist/desktop-extensions.js
|
|
17239
|
+
var DESKTOP_EXTENSION_API_VERSION = 1;
|
|
17240
|
+
var DESKTOP_EXTENSION_LIMIT = 64;
|
|
17241
|
+
var DESKTOP_EXTENSION_ZIP_MAX_BYTES = 64 * 1024 * 1024;
|
|
17242
|
+
var DESKTOP_EXTENSION_ZIP_MAX_BASE64_LENGTH = 4 * Math.ceil(DESKTOP_EXTENSION_ZIP_MAX_BYTES / 3);
|
|
17243
|
+
var DESKTOP_EXTENSION_MANIFEST_MAX_BYTES = 128 * 1024;
|
|
17244
|
+
var DESKTOP_EXTENSION_SCRIPT_MAX_BYTES = 2 * 1024 * 1024;
|
|
17245
|
+
var DESKTOP_EXTENSION_STYLE_MAX_BYTES = 256 * 1024;
|
|
17246
|
+
var DESKTOP_EXTENSION_ICON_MAX_BYTES = 128 * 1024;
|
|
17247
|
+
var DESKTOP_EXTENSION_SCREENSHOT_LIMIT = 4;
|
|
17248
|
+
var DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES = 512 * 1024;
|
|
17249
|
+
var DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES = 8 * 1024 * 1024;
|
|
17250
|
+
var DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES = 8 * 1024 * 1024;
|
|
17251
|
+
var DESKTOP_EXTENSION_ASSET_MAX_BYTES = 16 * 1024 * 1024;
|
|
17252
|
+
var DESKTOP_EXTENSION_SETTINGS_MAX_BYTES = 1024 * 1024;
|
|
17253
|
+
var desktopExtensionIdSchema = installedPluginIdSchema;
|
|
17254
|
+
var desktopExtensionSlotSchema = external_exports.enum([
|
|
17255
|
+
"sidebar.thread-layout",
|
|
17256
|
+
"sidebar.thread-badge",
|
|
17257
|
+
"appearance.theme"
|
|
17258
|
+
]);
|
|
17259
|
+
var desktopExtensionCategorySchema = external_exports.enum([
|
|
17260
|
+
"appearance",
|
|
17261
|
+
"interface",
|
|
17262
|
+
"workflow",
|
|
17263
|
+
"analytics",
|
|
17264
|
+
"integrations",
|
|
17265
|
+
"tools"
|
|
17266
|
+
]);
|
|
17267
|
+
var extensionName = external_exports.string().trim().min(1).max(128);
|
|
17268
|
+
function desktopExtensionScreenshotMimeType(resource) {
|
|
17269
|
+
switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
|
|
17270
|
+
case "png":
|
|
17271
|
+
return "image/png";
|
|
17272
|
+
case "jpg":
|
|
17273
|
+
case "jpeg":
|
|
17274
|
+
return "image/jpeg";
|
|
17275
|
+
case "webp":
|
|
17276
|
+
return "image/webp";
|
|
17277
|
+
default:
|
|
17278
|
+
return void 0;
|
|
17279
|
+
}
|
|
17280
|
+
}
|
|
17281
|
+
function desktopExtensionAssetMimeType(resource) {
|
|
17282
|
+
switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
|
|
17283
|
+
case "gif":
|
|
17284
|
+
return "image/gif";
|
|
17285
|
+
case "svg":
|
|
17286
|
+
return "image/svg+xml";
|
|
17287
|
+
case "woff2":
|
|
17288
|
+
return "font/woff2";
|
|
17289
|
+
case "json":
|
|
17290
|
+
return "application/json";
|
|
17291
|
+
case "css":
|
|
17292
|
+
return "text/css";
|
|
17293
|
+
default:
|
|
17294
|
+
return desktopExtensionScreenshotMimeType(resource);
|
|
17295
|
+
}
|
|
17296
|
+
}
|
|
17297
|
+
var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
|
|
17298
|
+
var desktopExtensionAssetPathSchema = pluginRelativeResourceSchema.refine((resource) => hasPortableSegments(resource) && desktopExtensionAssetMimeType(resource) !== void 0, "Expected a relative Desktop extension asset path with a supported suffix");
|
|
17299
|
+
var imagePathSchema = pluginRelativeResourceSchema.refine((resource) => desktopExtensionScreenshotMimeType(resource) !== void 0 && hasPortableSegments(resource), "Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space");
|
|
17300
|
+
var desktopExtensionHttpUrlSchema = external_exports.string().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu, "Expected an HTTP(S) URL").pipe(external_exports.url({ protocol: /^https?$/u })).refine((value) => {
|
|
17301
|
+
const { username, password } = new URL(value);
|
|
17302
|
+
return !username && !password && !/[\\\s]/u.test(value);
|
|
17303
|
+
}, "URL must not contain credentials, backslashes, or whitespace");
|
|
17304
|
+
function localizedText(text) {
|
|
17305
|
+
return external_exports.strictObject({ en: text, "zh-CN": text });
|
|
17306
|
+
}
|
|
17307
|
+
var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
|
|
17308
|
+
var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
|
|
17309
|
+
var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
|
|
17310
|
+
var settingField = {
|
|
17311
|
+
key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
|
|
17312
|
+
label: desktopExtensionLocalizedTextSchema,
|
|
17313
|
+
description: desktopExtensionLocalizedTextSchema.optional()
|
|
17314
|
+
};
|
|
17315
|
+
var numericSetting = {
|
|
17316
|
+
...settingField,
|
|
17317
|
+
step: external_exports.number().positive().optional(),
|
|
17318
|
+
default: external_exports.number().optional()
|
|
17319
|
+
};
|
|
17320
|
+
var settingOption = external_exports.strictObject({
|
|
17321
|
+
value: external_exports.string(),
|
|
17322
|
+
label: desktopExtensionLocalizedTextSchema
|
|
17323
|
+
});
|
|
17324
|
+
var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
|
|
17325
|
+
external_exports.strictObject({
|
|
17326
|
+
...settingField,
|
|
17327
|
+
type: external_exports.literal("boolean"),
|
|
17328
|
+
default: external_exports.boolean().optional()
|
|
17329
|
+
}),
|
|
17330
|
+
external_exports.strictObject({
|
|
17331
|
+
...settingField,
|
|
17332
|
+
type: external_exports.literal("string"),
|
|
17333
|
+
placeholder: desktopExtensionLocalizedTextSchema.optional(),
|
|
17334
|
+
default: external_exports.string().optional()
|
|
17335
|
+
}),
|
|
17336
|
+
external_exports.strictObject({
|
|
17337
|
+
...numericSetting,
|
|
17338
|
+
type: external_exports.literal("number"),
|
|
17339
|
+
min: external_exports.number().optional(),
|
|
17340
|
+
max: external_exports.number().optional()
|
|
17341
|
+
}),
|
|
17342
|
+
external_exports.strictObject({
|
|
17343
|
+
...numericSetting,
|
|
17344
|
+
type: external_exports.literal("range"),
|
|
17345
|
+
min: external_exports.number(),
|
|
17346
|
+
max: external_exports.number()
|
|
17347
|
+
}),
|
|
17348
|
+
external_exports.strictObject({
|
|
17349
|
+
...settingField,
|
|
17350
|
+
type: external_exports.literal("select"),
|
|
17351
|
+
options: external_exports.array(settingOption).min(1),
|
|
17352
|
+
default: external_exports.string().optional()
|
|
17353
|
+
})
|
|
17354
|
+
]).superRefine((field2, ctx) => {
|
|
17355
|
+
const issue2 = (path24, message) => ctx.addIssue({ code: "custom", path: [path24], message });
|
|
17356
|
+
if (field2.type === "number" || field2.type === "range") {
|
|
17357
|
+
const { min = -Infinity, max = Infinity, default: value } = field2;
|
|
17358
|
+
if (min > max)
|
|
17359
|
+
issue2("max", "Must be at least min");
|
|
17360
|
+
if (value !== void 0 && (value < min || value > max))
|
|
17361
|
+
issue2("default", "Must be within min and max");
|
|
17362
|
+
} else if (field2.type === "select") {
|
|
17363
|
+
const values = new Set(field2.options.map(({ value }) => value));
|
|
17364
|
+
if (values.size !== field2.options.length)
|
|
17365
|
+
issue2("options", "Duplicate option values");
|
|
17366
|
+
if (field2.default !== void 0 && !values.has(field2.default))
|
|
17367
|
+
issue2("default", "Must match an option value");
|
|
17368
|
+
}
|
|
17369
|
+
});
|
|
17370
|
+
var manifestHeader = external_exports.object({
|
|
17371
|
+
manifestVersion: external_exports.int().positive(),
|
|
17372
|
+
id: desktopExtensionIdSchema,
|
|
17373
|
+
name: external_exports.union([extensionName, localizedText(extensionName)]),
|
|
17374
|
+
version: external_exports.string().min(1).max(128),
|
|
17375
|
+
desktopApi: external_exports.int().positive()
|
|
17376
|
+
}).passthrough();
|
|
17377
|
+
var desktopExtensionManifestSchema = manifestHeader.extend({
|
|
17378
|
+
manifestVersion: external_exports.literal(1),
|
|
17379
|
+
desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
|
|
17380
|
+
description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
|
|
17381
|
+
author: external_exports.string().trim().min(1).max(128).optional(),
|
|
17382
|
+
repository: desktopExtensionHttpUrlSchema.optional(),
|
|
17383
|
+
details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
|
|
17384
|
+
icon: imagePathSchema.optional(),
|
|
17385
|
+
screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
|
|
17386
|
+
desktop: external_exports.strictObject({
|
|
17387
|
+
script: pluginRelativeResourceSchema,
|
|
17388
|
+
style: pluginRelativeResourceSchema.optional()
|
|
17389
|
+
}).optional(),
|
|
17390
|
+
backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
|
|
17391
|
+
slots: slotsSchema.default(() => []),
|
|
17392
|
+
settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
|
|
17393
|
+
categories: categoriesSchema.optional()
|
|
17394
|
+
}).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
|
|
17395
|
+
function parseDesktopExtensionManifest(value) {
|
|
17396
|
+
const header = manifestHeader.safeParse(value);
|
|
17397
|
+
if (!header.success)
|
|
17398
|
+
return { state: "invalid", error: external_exports.prettifyError(header.error) };
|
|
17399
|
+
if (header.data.desktopApi > DESKTOP_EXTENSION_API_VERSION) {
|
|
17400
|
+
return {
|
|
17401
|
+
state: "incompatible",
|
|
17402
|
+
error: `Desktop API ${header.data.desktopApi} requires a newer codexhost`
|
|
17403
|
+
};
|
|
17404
|
+
}
|
|
17405
|
+
const manifest = desktopExtensionManifestSchema.safeParse(value);
|
|
17406
|
+
return manifest.success ? { state: "valid", manifest: manifest.data } : { state: "invalid", error: external_exports.prettifyError(manifest.error) };
|
|
17407
|
+
}
|
|
17408
|
+
var desktopExtensionConfigurationSchema = external_exports.strictObject({
|
|
17409
|
+
version: external_exports.literal(1),
|
|
17410
|
+
revision: external_exports.int().nonnegative(),
|
|
17411
|
+
enabled: external_exports.array(desktopExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs"),
|
|
17412
|
+
reloadToken: external_exports.uuid().optional()
|
|
17413
|
+
});
|
|
17414
|
+
var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
|
|
17415
|
+
var desktopExtensionStatusSchema = external_exports.strictObject({
|
|
17416
|
+
state: external_exports.enum([
|
|
17417
|
+
"running",
|
|
17418
|
+
"disabled",
|
|
17419
|
+
"invalid",
|
|
17420
|
+
"incompatible",
|
|
17421
|
+
"conflict",
|
|
17422
|
+
"failed",
|
|
17423
|
+
"waiting"
|
|
17424
|
+
]),
|
|
17425
|
+
hash: desktopExtensionHashSchema.optional(),
|
|
17426
|
+
error: external_exports.string().optional(),
|
|
17427
|
+
conflictWith: desktopExtensionIdSchema.optional()
|
|
17428
|
+
});
|
|
17429
|
+
var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
|
|
17430
|
+
controllerPid: external_exports.int().positive(),
|
|
17431
|
+
targetId: external_exports.string().nullable(),
|
|
17432
|
+
updatedAt: external_exports.iso.datetime(),
|
|
17433
|
+
handledReloadToken: external_exports.uuid().optional(),
|
|
17434
|
+
extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema)
|
|
17435
|
+
});
|
|
17436
|
+
var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
|
|
17437
|
+
function isGitHubDesktopExtensionZipballUrl(url2) {
|
|
17438
|
+
return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
|
|
17439
|
+
}
|
|
17440
|
+
var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
|
|
17441
|
+
const url2 = new URL(input);
|
|
17442
|
+
return /\.zip$/iu.test(url2.pathname) || isGitHubDesktopExtensionZipballUrl(url2) || url2.origin === "https://github.com" && /^\/[\w-]+\/[\w.-]+\/zipball(?:\/.+)?\/?$/u.test(url2.pathname) || url2.origin === "https://codeload.github.com" && /^\/[\w-]+\/[\w.-]+\/(?:zip|zipball|legacy\.zip)\/.+$/u.test(url2.pathname);
|
|
17443
|
+
}, "Expected a .zip download URL or a GitHub zipball URL");
|
|
17444
|
+
var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
|
|
17445
|
+
id: desktopExtensionIdSchema,
|
|
17446
|
+
version: external_exports.string().trim().min(1).max(128),
|
|
17447
|
+
name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
|
|
17448
|
+
description: localizedText(external_exports.string().trim().min(1).max(4096)),
|
|
17449
|
+
details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
|
|
17450
|
+
author: external_exports.string().trim().min(1).max(128),
|
|
17451
|
+
repository: desktopExtensionHttpUrlSchema,
|
|
17452
|
+
stars: external_exports.number().int().min(0).optional(),
|
|
17453
|
+
downloads: external_exports.number().int().min(0).optional(),
|
|
17454
|
+
categories: categoriesSchema.optional(),
|
|
17455
|
+
trustTier: desktopExtensionTrustTierSchema.default("community"),
|
|
17456
|
+
icon: desktopExtensionHttpUrlSchema.optional(),
|
|
17457
|
+
screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
17458
|
+
downloadUrl: desktopExtensionZipUrlSchema,
|
|
17459
|
+
sha256: desktopExtensionHashSchema,
|
|
17460
|
+
slots: slotsSchema.optional(),
|
|
17461
|
+
publishedAt: external_exports.string().optional(),
|
|
17462
|
+
updatedAt: external_exports.string().optional(),
|
|
17463
|
+
minCodexHostVersion: external_exports.string().optional()
|
|
17464
|
+
});
|
|
17465
|
+
var desktopExtensionCatalogSchema = external_exports.strictObject({
|
|
17466
|
+
schemaVersion: external_exports.literal(1),
|
|
17467
|
+
generatedAt: external_exports.string(),
|
|
17468
|
+
extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, "Duplicate extension IDs")
|
|
17469
|
+
});
|
|
17470
|
+
function resolveDesktopExtensionSlots(enabledOrder, manifests) {
|
|
17471
|
+
const byId = new Map(Array.from(manifests, ({ id, slots = [] }) => [id, slots]));
|
|
17472
|
+
const owners = /* @__PURE__ */ new Map();
|
|
17473
|
+
const conflicts = /* @__PURE__ */ new Map();
|
|
17474
|
+
const active = [];
|
|
17475
|
+
for (const id of new Set(enabledOrder)) {
|
|
17476
|
+
const slots = byId.get(id);
|
|
17477
|
+
if (!slots)
|
|
17478
|
+
continue;
|
|
17479
|
+
const conflictWith = slots.map((slot) => owners.get(slot)).find((owner) => owner !== void 0);
|
|
17480
|
+
if (conflictWith !== void 0) {
|
|
17481
|
+
conflicts.set(id, conflictWith);
|
|
17482
|
+
continue;
|
|
17483
|
+
}
|
|
17484
|
+
for (const slot of slots)
|
|
17485
|
+
owners.set(slot, id);
|
|
17486
|
+
active.push(id);
|
|
17487
|
+
}
|
|
17488
|
+
return { active, conflicts };
|
|
17489
|
+
}
|
|
17490
|
+
var DESKTOP_EXTENSIONS_ASSET_METHOD = "codexhost/desktop/extensions/asset";
|
|
17491
|
+
var DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD = "codexhost/desktop/extensions/settings/get";
|
|
17492
|
+
var DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD = "codexhost/desktop/extensions/settings/set";
|
|
17493
|
+
var DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD = "codexhost/desktop/extensions/backend/invoke";
|
|
17494
|
+
var extensionIdParams = { id: desktopExtensionIdSchema };
|
|
17495
|
+
var desktopExtensionsAssetParamsSchema = external_exports.strictObject({
|
|
17496
|
+
...extensionIdParams,
|
|
17497
|
+
path: desktopExtensionAssetPathSchema
|
|
17498
|
+
});
|
|
17499
|
+
var desktopExtensionsAssetResultSchema = external_exports.strictObject({
|
|
17500
|
+
mimeType: external_exports.string(),
|
|
17501
|
+
dataUrl: external_exports.string()
|
|
17502
|
+
});
|
|
17503
|
+
var desktopExtensionsSettingsGetParamsSchema = external_exports.strictObject(extensionIdParams);
|
|
17504
|
+
var desktopExtensionsSettingsSetParamsSchema = external_exports.strictObject({
|
|
17505
|
+
...extensionIdParams,
|
|
17506
|
+
values: jsonObjectSchema
|
|
17507
|
+
});
|
|
17508
|
+
var desktopExtensionsSettingsResultSchema = external_exports.strictObject({ values: jsonObjectSchema });
|
|
17509
|
+
var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
|
|
17510
|
+
var desktopExtensionsBackendInvokeParamsSchema = external_exports.strictObject({
|
|
17511
|
+
...extensionIdParams,
|
|
17512
|
+
method: desktopExtensionBackendMethodSchema,
|
|
17513
|
+
params: jsonValueSchema.optional()
|
|
17514
|
+
});
|
|
17515
|
+
var desktopExtensionsBackendInvokeResultSchema = external_exports.strictObject({
|
|
17516
|
+
result: jsonValueSchema
|
|
17517
|
+
});
|
|
17518
|
+
|
|
17519
|
+
// packages/shared-contracts/dist/desktop-extension-management.js
|
|
17520
|
+
var DESKTOP_EXTENSIONS_LIST_METHOD = "codexhost/desktop/extensions/list";
|
|
17521
|
+
var DESKTOP_EXTENSIONS_ENABLE_METHOD = "codexhost/desktop/extensions/enable";
|
|
17522
|
+
var DESKTOP_EXTENSIONS_DISABLE_METHOD = "codexhost/desktop/extensions/disable";
|
|
17523
|
+
var DESKTOP_EXTENSIONS_CATALOG_METHOD = "codexhost/desktop/extensions/catalog";
|
|
17524
|
+
var DESKTOP_EXTENSIONS_INSTALL_METHOD = "codexhost/desktop/extensions/install";
|
|
17525
|
+
var DESKTOP_EXTENSIONS_UNINSTALL_METHOD = "codexhost/desktop/extensions/uninstall";
|
|
17526
|
+
var DESKTOP_EXTENSIONS_RECOVER_METHOD = "codexhost/desktop/extensions/disable-all-and-reload";
|
|
17527
|
+
var DESKTOP_EXTENSION_MANAGEMENT_METHODS = [
|
|
17528
|
+
DESKTOP_EXTENSIONS_LIST_METHOD,
|
|
17529
|
+
DESKTOP_EXTENSIONS_ENABLE_METHOD,
|
|
17530
|
+
DESKTOP_EXTENSIONS_DISABLE_METHOD,
|
|
17531
|
+
DESKTOP_EXTENSIONS_RECOVER_METHOD,
|
|
17532
|
+
DESKTOP_EXTENSIONS_CATALOG_METHOD,
|
|
17533
|
+
DESKTOP_EXTENSIONS_INSTALL_METHOD,
|
|
17534
|
+
DESKTOP_EXTENSIONS_UNINSTALL_METHOD,
|
|
17535
|
+
DESKTOP_EXTENSIONS_ASSET_METHOD,
|
|
17536
|
+
DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD,
|
|
17537
|
+
DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD,
|
|
17538
|
+
DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD
|
|
17539
|
+
];
|
|
17540
|
+
var revisionSchema = external_exports.int().nonnegative();
|
|
17541
|
+
var desktopExtensionsListParamsSchema = external_exports.strictObject({});
|
|
17542
|
+
var desktopExtensionSelectionParamsSchema = external_exports.strictObject({
|
|
17543
|
+
id: desktopExtensionIdSchema,
|
|
17544
|
+
expectedRevision: revisionSchema
|
|
17545
|
+
});
|
|
17546
|
+
var desktopExtensionsRecoveryParamsSchema = external_exports.strictObject({
|
|
17547
|
+
expectedRevision: revisionSchema.optional()
|
|
17548
|
+
});
|
|
17549
|
+
var rasterDataUrlSchema = (maxBytes) => external_exports.string().max("data:image/jpeg;base64,".length + 4 * Math.ceil(maxBytes / 3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u);
|
|
17550
|
+
var desktopExtensionListItemSchema = external_exports.strictObject({
|
|
17551
|
+
// An invalid discovery can have a directory name that isn't a valid extension ID.
|
|
17552
|
+
id: external_exports.string().min(1),
|
|
17553
|
+
manifest: desktopExtensionManifestSchema.optional(),
|
|
17554
|
+
iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
|
|
17555
|
+
screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
17556
|
+
enabled: external_exports.boolean(),
|
|
17557
|
+
status: desktopExtensionStatusSchema
|
|
17558
|
+
});
|
|
17559
|
+
var desktopExtensionsListResultSchema = external_exports.strictObject({
|
|
17560
|
+
configuration: desktopExtensionConfigurationSchema,
|
|
17561
|
+
desktopConnected: external_exports.boolean(),
|
|
17562
|
+
diagnostics: external_exports.array(external_exports.string()),
|
|
17563
|
+
extensions: external_exports.array(desktopExtensionListItemSchema)
|
|
17564
|
+
});
|
|
17565
|
+
var desktopExtensionsCatalogParamsSchema = external_exports.strictObject({
|
|
17566
|
+
forceRefresh: external_exports.boolean().optional()
|
|
17567
|
+
});
|
|
17568
|
+
var desktopExtensionsCatalogResultSchema = external_exports.strictObject({
|
|
17569
|
+
catalogUrl: external_exports.string(),
|
|
17570
|
+
source: external_exports.enum(["remote", "fallback"]),
|
|
17571
|
+
fetchedAt: external_exports.string(),
|
|
17572
|
+
cached: external_exports.boolean(),
|
|
17573
|
+
extensions: desktopExtensionCatalogSchema.shape.extensions,
|
|
17574
|
+
error: external_exports.string().optional()
|
|
17575
|
+
});
|
|
17576
|
+
var desktopExtensionsInstallParamsSchema = external_exports.strictObject({
|
|
17577
|
+
source: external_exports.discriminatedUnion("type", [
|
|
17578
|
+
external_exports.strictObject({ type: external_exports.literal("catalog"), id: desktopExtensionIdSchema }),
|
|
17579
|
+
external_exports.strictObject({
|
|
17580
|
+
type: external_exports.literal("url"),
|
|
17581
|
+
url: desktopExtensionHttpUrlSchema,
|
|
17582
|
+
expectedSha256: desktopExtensionHashSchema.optional()
|
|
17583
|
+
}),
|
|
17584
|
+
external_exports.strictObject({
|
|
17585
|
+
type: external_exports.literal("zip-base64"),
|
|
17586
|
+
fileName: external_exports.string().trim().min(1).max(255),
|
|
17587
|
+
contentBase64: external_exports.string().min(4).max(DESKTOP_EXTENSION_ZIP_MAX_BASE64_LENGTH).refine((value) => value.length % 4 === 0 && /^[A-Za-z0-9+/]+={0,2}$/u.test(value), "Expected standard padded base64")
|
|
17588
|
+
})
|
|
17589
|
+
])
|
|
17590
|
+
});
|
|
17591
|
+
var desktopExtensionsInstallResultSchema = external_exports.strictObject({
|
|
17592
|
+
extensionId: desktopExtensionIdSchema,
|
|
17593
|
+
version: external_exports.string().min(1),
|
|
17594
|
+
replaced: external_exports.boolean(),
|
|
17595
|
+
installedPath: external_exports.string(),
|
|
17596
|
+
list: desktopExtensionsListResultSchema
|
|
17597
|
+
});
|
|
17598
|
+
var desktopExtensionsUninstallParamsSchema = external_exports.strictObject({
|
|
17599
|
+
id: desktopExtensionIdSchema
|
|
17600
|
+
});
|
|
17601
|
+
var desktopExtensionsUninstallResultSchema = external_exports.strictObject({
|
|
17602
|
+
removedId: desktopExtensionIdSchema,
|
|
17603
|
+
list: desktopExtensionsListResultSchema
|
|
17604
|
+
});
|
|
17605
|
+
var desktopExtensionMutationResultSchema = external_exports.discriminatedUnion("state", [
|
|
17606
|
+
external_exports.strictObject({ state: external_exports.literal("saved"), configuration: desktopExtensionConfigurationSchema }),
|
|
17607
|
+
external_exports.strictObject({ state: external_exports.literal("slot-conflict"), conflictWith: desktopExtensionIdSchema }),
|
|
17608
|
+
external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: revisionSchema })
|
|
17609
|
+
]);
|
|
17610
|
+
|
|
15545
17611
|
// packages/shared-contracts/dist/errors.js
|
|
15546
17612
|
var codexhostErrorSchema = external_exports.strictObject({
|
|
15547
17613
|
code: external_exports.string().min(1),
|
|
@@ -15562,16 +17628,6 @@ var harnessLocalizationsSchema = external_exports.record(localeSchema, external_
|
|
|
15562
17628
|
}).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
|
|
15563
17629
|
var harnessLocalizedTextSchema = external_exports.record(localeSchema, displayText(4096)).refine((entries) => typeof entries.en === "string", "English fallback is required").refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
|
|
15564
17630
|
|
|
15565
|
-
// packages/shared-contracts/dist/ids.js
|
|
15566
|
-
var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
15567
|
-
message: "Identifier must not be empty or whitespace"
|
|
15568
|
-
});
|
|
15569
|
-
var harnessIdSchema = opaqueIdSchema.brand();
|
|
15570
|
-
var hostThreadIdSchema = opaqueIdSchema.brand();
|
|
15571
|
-
var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
15572
|
-
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
15573
|
-
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
15574
|
-
|
|
15575
17631
|
// packages/shared-contracts/dist/harness-permission-modes.js
|
|
15576
17632
|
var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
|
|
15577
17633
|
var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
|
|
@@ -15771,6 +17827,13 @@ var accountCreditsSnapshotSchema = external_exports.object({
|
|
|
15771
17827
|
productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
|
|
15772
17828
|
resetCredits: accountResetCreditsSchema.optional()
|
|
15773
17829
|
}).strict();
|
|
17830
|
+
var accountBalanceSnapshotSchema = external_exports.object({
|
|
17831
|
+
amount: external_exports.number().finite().nonnegative(),
|
|
17832
|
+
/** ISO 4217 code as reported by the Provider, for example `CNY`. */
|
|
17833
|
+
currency: external_exports.string().trim().min(1).max(8),
|
|
17834
|
+
/** Native label when the Harness exposes several Billing Sources. */
|
|
17835
|
+
label: external_exports.string().trim().min(1).max(128).optional()
|
|
17836
|
+
}).strict();
|
|
15774
17837
|
var threadUsageInspectionParamsSchema = external_exports.object({
|
|
15775
17838
|
threadId: hostThreadIdSchema,
|
|
15776
17839
|
refresh: external_exports.literal("exact").optional()
|
|
@@ -15779,7 +17842,10 @@ var threadUsageInspectionSchema = external_exports.object({
|
|
|
15779
17842
|
threadId: hostThreadIdSchema,
|
|
15780
17843
|
usage: threadUsageSnapshotSchema.nullable(),
|
|
15781
17844
|
accountCredits: accountCreditsSnapshotSchema.optional(),
|
|
15782
|
-
/**
|
|
17845
|
+
/** Prepaid funds for the Thread's Billing Source; shown only when no percentage quota exists. */
|
|
17846
|
+
accountBalance: accountBalanceSnapshotSchema.optional(),
|
|
17847
|
+
/** Whether this source can provide cached account quota (credits or a prepaid balance)
|
|
17848
|
+
* independently of usage. */
|
|
15783
17849
|
accountCreditsSupported: external_exports.boolean().optional()
|
|
15784
17850
|
}).strict();
|
|
15785
17851
|
|
|
@@ -16071,12 +18137,89 @@ var threadSteeringInspectResultSchema = external_exports.object({
|
|
|
16071
18137
|
}).strict();
|
|
16072
18138
|
|
|
16073
18139
|
// packages/shared-contracts/dist/thread-archive-confirm.js
|
|
18140
|
+
var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
|
|
16074
18141
|
var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
|
|
16075
18142
|
var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
|
|
16076
18143
|
|
|
16077
18144
|
// packages/shared-contracts/dist/client-channel.js
|
|
16078
18145
|
var CLIENT_CHANNEL_VERSION = 1;
|
|
16079
18146
|
var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
|
|
18147
|
+
var CLIENT_CHANNEL_METHODS = [
|
|
18148
|
+
"codexhost/skills/list",
|
|
18149
|
+
"codexhost/voice/status",
|
|
18150
|
+
"codexhost/voice/transcribe",
|
|
18151
|
+
"codexhost/harness/display-settings/get",
|
|
18152
|
+
"codexhost/harness/display-settings/set",
|
|
18153
|
+
"codexhost/harness/display-settings/capabilities",
|
|
18154
|
+
"codexhost/harness/preferences/get",
|
|
18155
|
+
"codexhost/harness/preferences/patch",
|
|
18156
|
+
"thread/list",
|
|
18157
|
+
"codexhost/thread/catalog/read",
|
|
18158
|
+
"thread/read",
|
|
18159
|
+
"thread/resume",
|
|
18160
|
+
"thread/fork",
|
|
18161
|
+
"thread/turns/list",
|
|
18162
|
+
"thread/revert",
|
|
18163
|
+
"thread/items/list",
|
|
18164
|
+
"thread/start",
|
|
18165
|
+
"thread/name/set",
|
|
18166
|
+
"codexhost/thread/title/generate",
|
|
18167
|
+
"thread/archive",
|
|
18168
|
+
THREAD_ARCHIVE_CONFIRM_METHOD,
|
|
18169
|
+
"thread/unarchive",
|
|
18170
|
+
"turn/start",
|
|
18171
|
+
"turn/interrupt",
|
|
18172
|
+
"turn/steer",
|
|
18173
|
+
"thread/queue/list",
|
|
18174
|
+
"thread/queue/add",
|
|
18175
|
+
"thread/queue/update",
|
|
18176
|
+
"thread/queue/delete",
|
|
18177
|
+
"thread/queue/reorder",
|
|
18178
|
+
"thread/queue/start",
|
|
18179
|
+
"codexhost/thread/queue/send-now",
|
|
18180
|
+
"codexhost/workspace/read",
|
|
18181
|
+
"codexhost/thread/tree/read",
|
|
18182
|
+
"codexhost/thread/pins/list",
|
|
18183
|
+
"codexhost/thread/pins/set",
|
|
18184
|
+
"codexhost/harness/plugins/list",
|
|
18185
|
+
"codexhost/harness/inspect",
|
|
18186
|
+
"codexhost/thread/inspect",
|
|
18187
|
+
"codexhost/thread/usage/inspect",
|
|
18188
|
+
"codexhost/thread/ownership/list",
|
|
18189
|
+
"codexhost/thread/model/select",
|
|
18190
|
+
"codexhost/thread/thinking/select",
|
|
18191
|
+
"codexhost/thread/permission-mode/select",
|
|
18192
|
+
"codexhost/thread/commands/inspect",
|
|
18193
|
+
"codexhost/harness/commands/inspect",
|
|
18194
|
+
"codexhost/thread/command/execute",
|
|
18195
|
+
"codexhost/thread/fork",
|
|
18196
|
+
"codexhost/harness/session-import/sources",
|
|
18197
|
+
"codexhost/harness/session-import/list",
|
|
18198
|
+
"codexhost/harness/session-import/import",
|
|
18199
|
+
// Host settings shared across Desktop and Web.
|
|
18200
|
+
...DESKTOP_EXTENSION_MANAGEMENT_METHODS,
|
|
18201
|
+
"codexhost/harness/installation",
|
|
18202
|
+
"codexhost/harness/installation/start",
|
|
18203
|
+
"codexhost/harness/installation/status",
|
|
18204
|
+
"codexhost/harness/launch-settings/get",
|
|
18205
|
+
"codexhost/harness/launch-settings/set",
|
|
18206
|
+
"codexhost/harness/web-ui/open",
|
|
18207
|
+
"codexhost/harness/accounts/sources",
|
|
18208
|
+
"codexhost/harness/accounts/list",
|
|
18209
|
+
"codexhost/harness/accounts/inspect",
|
|
18210
|
+
"codexhost/harness/credential-imports",
|
|
18211
|
+
"codexhost/account/list",
|
|
18212
|
+
"codexhost/account/refresh",
|
|
18213
|
+
"codexhost/account/usage/inspect",
|
|
18214
|
+
"codexhost/usage/model-prices/get",
|
|
18215
|
+
"codexhost/usage/model-prices/set",
|
|
18216
|
+
"codexhost/usage/model-prices/default",
|
|
18217
|
+
"codexhost/usage/statistics/get",
|
|
18218
|
+
"codexhost/update/check",
|
|
18219
|
+
"codexhost/update/start",
|
|
18220
|
+
"codexhost/update/status",
|
|
18221
|
+
"codexhost/sessions/loaded/list"
|
|
18222
|
+
];
|
|
16080
18223
|
var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
|
|
16081
18224
|
var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
|
|
16082
18225
|
var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
|
|
@@ -16290,6 +18433,29 @@ var threadCatalogReadResultSchema = external_exports.object({
|
|
|
16290
18433
|
officialCursor: external_exports.object({ live: external_exports.string().nullable(), archived: external_exports.string().nullable().optional() }).strict().optional()
|
|
16291
18434
|
}).strict();
|
|
16292
18435
|
|
|
18436
|
+
// packages/shared-contracts/dist/thread-tree-watch.js
|
|
18437
|
+
var THREAD_TREE_MAX_NODES = 5e3;
|
|
18438
|
+
var threadTreeStatusSchema = external_exports.enum(["running", "waiting", "idle", "unknown"]);
|
|
18439
|
+
var threadTreeNodeSchema = external_exports.strictObject({
|
|
18440
|
+
harnessId: harnessIdSchema,
|
|
18441
|
+
title: external_exports.string().optional(),
|
|
18442
|
+
status: threadTreeStatusSchema,
|
|
18443
|
+
archived: external_exports.boolean()
|
|
18444
|
+
});
|
|
18445
|
+
var threadTreeSnapshotSchema = external_exports.strictObject({
|
|
18446
|
+
revision: external_exports.int().nonnegative(),
|
|
18447
|
+
parents: external_exports.record(hostThreadIdSchema, hostThreadIdSchema),
|
|
18448
|
+
nodes: external_exports.record(hostThreadIdSchema, threadTreeNodeSchema),
|
|
18449
|
+
truncated: external_exports.boolean()
|
|
18450
|
+
}).refine((snapshot) => Object.keys(snapshot.nodes).length <= THREAD_TREE_MAX_NODES, "Too many Thread tree nodes").refine(({ parents, nodes }) => Object.entries(parents).every(([child, parent]) => Object.hasOwn(nodes, child) && Object.hasOwn(nodes, parent)), "Missing Thread tree node");
|
|
18451
|
+
var subscriptionId = external_exports.string().min(1).max(128);
|
|
18452
|
+
var threadTreeWatchParamsSchema = external_exports.strictObject({});
|
|
18453
|
+
var threadTreeUnwatchParamsSchema = external_exports.strictObject({ subscriptionId });
|
|
18454
|
+
var threadTreeUnwatchResultSchema = external_exports.strictObject({});
|
|
18455
|
+
var threadTreeWatchResultSchema = threadTreeUnwatchParamsSchema.extend({
|
|
18456
|
+
snapshot: threadTreeSnapshotSchema
|
|
18457
|
+
});
|
|
18458
|
+
|
|
16293
18459
|
// packages/shared-contracts/dist/voice.js
|
|
16294
18460
|
var VOICE_AUDIO_MAX_BYTES = 10 * 1024 * 1024;
|
|
16295
18461
|
var voiceAudioMimeTypeSchema = external_exports.string().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);
|
|
@@ -16923,13 +19089,6 @@ var threadManualCompactionStartedSchema = external_exports.strictObject({
|
|
|
16923
19089
|
});
|
|
16924
19090
|
|
|
16925
19091
|
// packages/shared-contracts/dist/harness-accounts.js
|
|
16926
|
-
var accountBalanceSnapshotSchema = external_exports.object({
|
|
16927
|
-
amount: external_exports.number().finite().nonnegative(),
|
|
16928
|
-
/** ISO 4217 code as reported by the Provider, for example `CNY`. */
|
|
16929
|
-
currency: external_exports.string().trim().min(1).max(8),
|
|
16930
|
-
/** Native label when the Harness exposes several Billing Sources. */
|
|
16931
|
-
label: external_exports.string().trim().min(1).max(128).optional()
|
|
16932
|
-
}).strict();
|
|
16933
19092
|
var harnessAccountSnapshotObject = external_exports.object({
|
|
16934
19093
|
email: external_exports.string().trim().min(1).max(320).optional(),
|
|
16935
19094
|
label: external_exports.string().trim().min(1).max(256).optional(),
|
|
@@ -16963,76 +19122,6 @@ var harnessAccountListResultSchema = external_exports.object({
|
|
|
16963
19122
|
accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
|
|
16964
19123
|
}).strict();
|
|
16965
19124
|
|
|
16966
|
-
// packages/shared-contracts/dist/harness-plugins.js
|
|
16967
|
-
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
16968
|
-
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
16969
|
-
var HARNESS_PLUGIN_LIMIT = 128;
|
|
16970
|
-
var installedHarnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).pipe(harnessIdSchema);
|
|
16971
|
-
var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id) => id !== "codex", "The official Codex identity is reserved");
|
|
16972
|
-
var relativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
|
|
16973
|
-
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
16974
|
-
var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
|
|
16975
|
-
var harnessInstallationGuideSchema = external_exports.object({
|
|
16976
|
-
commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
|
|
16977
|
-
before: localizedTextSchema.optional(),
|
|
16978
|
-
after: localizedTextSchema.optional(),
|
|
16979
|
-
downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
|
|
16980
|
-
}).strict();
|
|
16981
|
-
var pluginPresentationShape = {
|
|
16982
|
-
id: installedHarnessPluginIdSchema,
|
|
16983
|
-
name: external_exports.string().trim().min(1).max(128),
|
|
16984
|
-
version: external_exports.string().min(1).max(128),
|
|
16985
|
-
/** Capability-only plugin; omitted for existing session-capable plugins. */
|
|
16986
|
-
kind: external_exports.literal("usage").optional(),
|
|
16987
|
-
/** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
|
|
16988
|
-
iconStyle: external_exports.object({
|
|
16989
|
-
vector: external_exports.object({
|
|
16990
|
-
viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
|
|
16991
|
-
color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
|
|
16992
|
-
paths: external_exports.array(external_exports.object({
|
|
16993
|
-
d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
|
|
16994
|
-
fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
|
|
16995
|
-
fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
|
|
16996
|
-
}).strict()).min(1).max(32)
|
|
16997
|
-
}).strict().optional(),
|
|
16998
|
-
background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
|
|
16999
|
-
borderRadius: external_exports.number().min(0).max(50).optional(),
|
|
17000
|
-
paddingRatio: external_exports.number().min(0).max(0.25).optional()
|
|
17001
|
-
}).strict().optional(),
|
|
17002
|
-
installation: harnessInstallationGuideSchema.optional(),
|
|
17003
|
-
notice: localizedTextSchema.optional(),
|
|
17004
|
-
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
17005
|
-
launchCommand: external_exports.literal(true).optional(),
|
|
17006
|
-
links: external_exports.object({
|
|
17007
|
-
website: documentationUrlSchema.optional(),
|
|
17008
|
-
documentation: documentationUrlSchema.optional(),
|
|
17009
|
-
installation: documentationUrlSchema.optional()
|
|
17010
|
-
}).strict().optional()
|
|
17011
|
-
};
|
|
17012
|
-
var harnessPluginManifestSchema = external_exports.object({
|
|
17013
|
-
manifestVersion: external_exports.literal(1),
|
|
17014
|
-
...pluginPresentationShape,
|
|
17015
|
-
adapterApiVersion: external_exports.number().int().positive(),
|
|
17016
|
-
entry: relativeResourceSchema,
|
|
17017
|
-
icon: relativeResourceSchema.optional()
|
|
17018
|
-
}).strict();
|
|
17019
|
-
var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
|
|
17020
|
-
var harnessPluginDescriptorSchema = external_exports.object({
|
|
17021
|
-
...pluginPresentationShape,
|
|
17022
|
-
icon: harnessPluginIconSchema.optional()
|
|
17023
|
-
}).strict();
|
|
17024
|
-
var harnessPluginListParamsSchema = external_exports.object({}).strict();
|
|
17025
|
-
var harnessPluginListResultSchema = external_exports.object({
|
|
17026
|
-
plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
|
|
17027
|
-
}).strict();
|
|
17028
|
-
var harnessPluginConfigurationSchema = external_exports.object({
|
|
17029
|
-
version: external_exports.literal(1),
|
|
17030
|
-
enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
17031
|
-
}).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
|
|
17032
|
-
message: "Enabled plugin IDs must be unique",
|
|
17033
|
-
path: ["enabled"]
|
|
17034
|
-
});
|
|
17035
|
-
|
|
17036
19125
|
// packages/shared-contracts/dist/harness-route.js
|
|
17037
19126
|
var harnessPluginRouteSchema = external_exports.object({
|
|
17038
19127
|
harnessId: harnessPluginIdSchema,
|
|
@@ -17472,6 +19561,7 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
|
17472
19561
|
message: "A history continuation requires its connection epoch"
|
|
17473
19562
|
}).optional()
|
|
17474
19563
|
}),
|
|
19564
|
+
external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
|
|
17475
19565
|
external_exports.strictObject({
|
|
17476
19566
|
kind: external_exports.literal("configure"),
|
|
17477
19567
|
...thread,
|
|
@@ -17723,117 +19813,1009 @@ async function discoverHarnessPlugins(configuredRoots, diagnose = () => void 0,
|
|
|
17723
19813
|
diagnose("invalidRoot");
|
|
17724
19814
|
}
|
|
17725
19815
|
}
|
|
17726
|
-
return { plugins, enabledIds };
|
|
19816
|
+
return { plugins, enabledIds };
|
|
19817
|
+
}
|
|
19818
|
+
|
|
19819
|
+
// packages/harness-plugin-files/dist/launch-settings.js
|
|
19820
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
19821
|
+
import { mkdir as mkdir3, readFile as readFile4, rename as rename3, rm as rm3, stat as stat2, writeFile as writeFile3 } from "node:fs/promises";
|
|
19822
|
+
import os from "node:os";
|
|
19823
|
+
import path8 from "node:path";
|
|
19824
|
+
var HarnessLaunchSettingsStore = class {
|
|
19825
|
+
#directory;
|
|
19826
|
+
#initial = /* @__PURE__ */ new Map();
|
|
19827
|
+
constructor(environment) {
|
|
19828
|
+
this.#directory = path8.join(environment.CODEXHOST_DATA_DIR ? path8.resolve(environment.CODEXHOST_DATA_DIR) : path8.join(os.homedir(), ".codexhost"), "harness-launch-settings");
|
|
19829
|
+
}
|
|
19830
|
+
#file(id) {
|
|
19831
|
+
return path8.join(this.#directory, `${harnessPluginIdSchema.parse(id)}.json`);
|
|
19832
|
+
}
|
|
19833
|
+
async #read(id) {
|
|
19834
|
+
const file2 = this.#file(id);
|
|
19835
|
+
let text;
|
|
19836
|
+
try {
|
|
19837
|
+
text = await readFile4(file2, "utf8");
|
|
19838
|
+
} catch (error51) {
|
|
19839
|
+
if (error51 && typeof error51 === "object" && "code" in error51 && error51.code === "ENOENT")
|
|
19840
|
+
return null;
|
|
19841
|
+
throw new Error(`Could not read Harness launch settings at ${file2}`, { cause: error51 });
|
|
19842
|
+
}
|
|
19843
|
+
let parsed;
|
|
19844
|
+
try {
|
|
19845
|
+
parsed = harnessLaunchPathSchema.parse(JSON.parse(text));
|
|
19846
|
+
} catch {
|
|
19847
|
+
}
|
|
19848
|
+
if (parsed === void 0 || !path8.isAbsolute(parsed)) {
|
|
19849
|
+
throw new Error(`Could not read Harness launch settings at ${file2}: expected an absolute installation path; save a new path or reset it`);
|
|
19850
|
+
}
|
|
19851
|
+
return parsed;
|
|
19852
|
+
}
|
|
19853
|
+
#snapshot(id) {
|
|
19854
|
+
let initial = this.#initial.get(id);
|
|
19855
|
+
if (!initial) {
|
|
19856
|
+
initial = this.#read(id).then((value) => ({ path: value }), (error51) => ({ error: error51 instanceof Error ? error51 : new Error(String(error51)) }));
|
|
19857
|
+
this.#initial.set(id, initial);
|
|
19858
|
+
}
|
|
19859
|
+
return initial;
|
|
19860
|
+
}
|
|
19861
|
+
/**
|
|
19862
|
+
* Capture the value used to construct this Host's Adapter; changes require a restart. A failed
|
|
19863
|
+
* read is remembered for restart reporting but not reused: the next call reads the file again.
|
|
19864
|
+
*/
|
|
19865
|
+
async initialCommand(id) {
|
|
19866
|
+
const cached2 = this.#initial.get(id);
|
|
19867
|
+
if (cached2 && "error" in await cached2)
|
|
19868
|
+
this.#initial.delete(id);
|
|
19869
|
+
const snapshot = await this.#snapshot(id);
|
|
19870
|
+
if ("error" in snapshot)
|
|
19871
|
+
throw snapshot.error;
|
|
19872
|
+
return snapshot.path ?? void 0;
|
|
19873
|
+
}
|
|
19874
|
+
/** The Adapter was built without a readable setting, so any saved value needs a restart. */
|
|
19875
|
+
#restartRequired(snapshot, value) {
|
|
19876
|
+
return "error" in snapshot || value !== snapshot.path;
|
|
19877
|
+
}
|
|
19878
|
+
async get(id) {
|
|
19879
|
+
const snapshot = await this.#snapshot(id);
|
|
19880
|
+
const value = await this.#read(id);
|
|
19881
|
+
return { path: value, restartRequired: this.#restartRequired(snapshot, value) };
|
|
19882
|
+
}
|
|
19883
|
+
/** Replaces the file without reading it, so an unreadable file can always be repaired. */
|
|
19884
|
+
async set(id, value) {
|
|
19885
|
+
const snapshot = await this.#snapshot(id);
|
|
19886
|
+
const file2 = this.#file(id);
|
|
19887
|
+
if (value === null) {
|
|
19888
|
+
await rm3(file2, { force: true });
|
|
19889
|
+
} else {
|
|
19890
|
+
value = harnessLaunchPathSchema.parse(value);
|
|
19891
|
+
if (!path8.isAbsolute(value))
|
|
19892
|
+
throw new Error("Use an absolute entrypoint path without arguments");
|
|
19893
|
+
const metadata = await stat2(value).catch(() => void 0);
|
|
19894
|
+
if (!metadata?.isDirectory() && !metadata?.isFile())
|
|
19895
|
+
throw new Error("The installation path must be an existing directory on this Host");
|
|
19896
|
+
await mkdir3(this.#directory, { recursive: true, mode: 448 });
|
|
19897
|
+
const temporary = `${file2}.${randomUUID3()}.tmp`;
|
|
19898
|
+
try {
|
|
19899
|
+
await writeFile3(temporary, `${JSON.stringify(value)}
|
|
19900
|
+
`, { mode: 384, flag: "wx" });
|
|
19901
|
+
await rename3(temporary, file2);
|
|
19902
|
+
} finally {
|
|
19903
|
+
await rm3(temporary, { force: true });
|
|
19904
|
+
}
|
|
19905
|
+
}
|
|
19906
|
+
return { path: value, restartRequired: this.#restartRequired(snapshot, value) };
|
|
19907
|
+
}
|
|
19908
|
+
};
|
|
19909
|
+
|
|
19910
|
+
// packages/harness-plugin-files/dist/extension-discovery.js
|
|
19911
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
19912
|
+
import { lstat as lstat4, readdir as readdir3, realpath as realpath3, stat as stat3 } from "node:fs/promises";
|
|
19913
|
+
import path9 from "node:path";
|
|
19914
|
+
var DESKTOP_EXTENSION_CONFIGURATION_LOCK = ".enabled.lock";
|
|
19915
|
+
function desktopExtensionsRoot(dataDirectory2) {
|
|
19916
|
+
return path9.join(dataDirectory2, "desktop-extensions");
|
|
19917
|
+
}
|
|
19918
|
+
function desktopExtensionsStatusPath(dataDirectory2) {
|
|
19919
|
+
return path9.join(dataDirectory2, "diagnostics", "desktop-extensions-v1.json");
|
|
19920
|
+
}
|
|
19921
|
+
function extensionFileMissing(error51) {
|
|
19922
|
+
return error51 instanceof Error && "code" in error51 && error51.code === "ENOENT";
|
|
19923
|
+
}
|
|
19924
|
+
async function privateEntry(file2, directory) {
|
|
19925
|
+
const info = await lstat4(file2);
|
|
19926
|
+
if (directory ? !info.isDirectory() : !info.isFile())
|
|
19927
|
+
throw new Error(`${path9.basename(file2)} must be a regular ${directory ? "directory" : "file"}`);
|
|
19928
|
+
if (process.getuid && (info.uid !== process.getuid() || (info.mode & 18) !== 0))
|
|
19929
|
+
throw new Error(`${path9.basename(file2)} must belong to the current user and not permit group/other writes`);
|
|
19930
|
+
}
|
|
19931
|
+
async function privateExtensionDirectory(directory) {
|
|
19932
|
+
await privateEntry(directory, true);
|
|
19933
|
+
return realpath3(directory);
|
|
19934
|
+
}
|
|
19935
|
+
async function checkedExtensionResource(root, relative) {
|
|
19936
|
+
const resource = await pluginResourcePath(root, relative);
|
|
19937
|
+
for (const candidate of /* @__PURE__ */ new Set([resource, path9.resolve(root, relative)])) {
|
|
19938
|
+
let dir = path9.dirname(candidate);
|
|
19939
|
+
while (dir !== root) {
|
|
19940
|
+
await privateEntry(dir, true);
|
|
19941
|
+
dir = path9.dirname(dir);
|
|
19942
|
+
}
|
|
19943
|
+
}
|
|
19944
|
+
await privateEntry(resource, false);
|
|
19945
|
+
return resource;
|
|
19946
|
+
}
|
|
19947
|
+
async function readExtensionResource(root, relative, max) {
|
|
19948
|
+
return readPluginFile(await checkedExtensionResource(root, relative), max);
|
|
19949
|
+
}
|
|
19950
|
+
async function readDesktopExtensionBackend(directory, script) {
|
|
19951
|
+
try {
|
|
19952
|
+
const scriptPath = await checkedExtensionResource(directory, script);
|
|
19953
|
+
const bytes = await readPluginFile(scriptPath, DESKTOP_EXTENSION_SCRIPT_MAX_BYTES);
|
|
19954
|
+
const { dev, ino } = await stat3(directory, { bigint: true });
|
|
19955
|
+
return {
|
|
19956
|
+
directory,
|
|
19957
|
+
scriptPath,
|
|
19958
|
+
hash: createHash2("sha256").update(bytes).digest("hex"),
|
|
19959
|
+
installation: `${dev}:${ino}`
|
|
19960
|
+
};
|
|
19961
|
+
} catch (error51) {
|
|
19962
|
+
if (!extensionFileMissing(error51))
|
|
19963
|
+
throw error51;
|
|
19964
|
+
throw new Error(`Missing backend entry file ${script}`, { cause: error51 });
|
|
19965
|
+
}
|
|
19966
|
+
}
|
|
19967
|
+
var pngSignature = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
|
|
19968
|
+
var jpegSignature = Buffer.from([255, 216, 255]);
|
|
19969
|
+
var riffSignature = Buffer.from("RIFF");
|
|
19970
|
+
var webpSignature = Buffer.from("WEBP");
|
|
19971
|
+
async function readDesktopExtensionImage(root, relative, maxBytes, label) {
|
|
19972
|
+
try {
|
|
19973
|
+
const mime = desktopExtensionScreenshotMimeType(relative);
|
|
19974
|
+
if (!mime)
|
|
19975
|
+
throw new Error("Unsupported image extension");
|
|
19976
|
+
const bytes = await readExtensionResource(root, relative, maxBytes);
|
|
19977
|
+
const matches = mime === "image/png" ? bytes.subarray(0, 8).equals(pngSignature) : mime === "image/jpeg" ? bytes.subarray(0, 3).equals(jpegSignature) : bytes.subarray(0, 4).equals(riffSignature) && bytes.subarray(8, 12).equals(webpSignature);
|
|
19978
|
+
if (!matches)
|
|
19979
|
+
throw new Error(`File signature does not match ${mime}`);
|
|
19980
|
+
return { bytes, mime };
|
|
19981
|
+
} catch (error51) {
|
|
19982
|
+
const reason = extensionFileMissing(error51) ? "file not found" : error51 instanceof Error ? error51.message : String(error51);
|
|
19983
|
+
throw new Error(`${label} ${JSON.stringify(relative)}: ${reason}`, { cause: error51 });
|
|
19984
|
+
}
|
|
19985
|
+
}
|
|
19986
|
+
function readDesktopExtensionIcon(root, relative) {
|
|
19987
|
+
return readDesktopExtensionImage(root, relative, DESKTOP_EXTENSION_ICON_MAX_BYTES, "Icon");
|
|
19988
|
+
}
|
|
19989
|
+
function readDesktopExtensionScreenshot(root, relative) {
|
|
19990
|
+
return readDesktopExtensionImage(root, relative, DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES, "Screenshot");
|
|
19991
|
+
}
|
|
19992
|
+
function toImageDataUrl({ bytes, mime }) {
|
|
19993
|
+
return `data:${mime};base64,${bytes.toString("base64")}`;
|
|
19994
|
+
}
|
|
19995
|
+
function isDesktopExtensionTransactionEntry(name) {
|
|
19996
|
+
return name === DESKTOP_EXTENSION_CONFIGURATION_LOCK || /^\.(?:staging|backup)-/u.test(name);
|
|
19997
|
+
}
|
|
19998
|
+
async function discover(root, id, screenshotBudget) {
|
|
19999
|
+
try {
|
|
20000
|
+
if (!desktopExtensionIdSchema.safeParse(id).success)
|
|
20001
|
+
throw new Error("Invalid extension directory name");
|
|
20002
|
+
const directory = await privateExtensionDirectory(path9.join(root, id));
|
|
20003
|
+
const bytes = await readExtensionResource(directory, "manifest.json", DESKTOP_EXTENSION_MANIFEST_MAX_BYTES);
|
|
20004
|
+
const data = JSON.parse(bytes.toString("utf8"));
|
|
20005
|
+
if (!data || typeof data !== "object" || !("id" in data) || data.id !== id)
|
|
20006
|
+
throw new Error("Manifest id must match the directory name");
|
|
20007
|
+
const parsed = parseDesktopExtensionManifest(data);
|
|
20008
|
+
if (parsed.state !== "valid")
|
|
20009
|
+
return { id, ...parsed };
|
|
20010
|
+
const { desktop, backend } = parsed.manifest;
|
|
20011
|
+
const [script, style, backendEntry] = await Promise.all([
|
|
20012
|
+
desktop ? readExtensionResource(directory, desktop.script, DESKTOP_EXTENSION_SCRIPT_MAX_BYTES) : void 0,
|
|
20013
|
+
desktop?.style ? readExtensionResource(directory, desktop.style, DESKTOP_EXTENSION_STYLE_MAX_BYTES) : void 0,
|
|
20014
|
+
backend ? readDesktopExtensionBackend(directory, backend.script) : void 0
|
|
20015
|
+
]);
|
|
20016
|
+
const zero = Buffer.from([0]);
|
|
20017
|
+
const hash2 = createHash2("sha256").update(bytes).update(zero);
|
|
20018
|
+
if (script)
|
|
20019
|
+
hash2.update(script);
|
|
20020
|
+
hash2.update(zero);
|
|
20021
|
+
if (style)
|
|
20022
|
+
hash2.update(style);
|
|
20023
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
20024
|
+
const item = {
|
|
20025
|
+
id,
|
|
20026
|
+
state: "valid",
|
|
20027
|
+
manifest: parsed.manifest,
|
|
20028
|
+
hash: hash2.digest("hex"),
|
|
20029
|
+
...script ? { script: decoder.decode(script) } : {},
|
|
20030
|
+
...style ? { style: decoder.decode(style) } : {},
|
|
20031
|
+
...backendEntry ? { backend: backendEntry } : {}
|
|
20032
|
+
};
|
|
20033
|
+
if (parsed.manifest.icon) {
|
|
20034
|
+
const icon = await readDesktopExtensionIcon(directory, parsed.manifest.icon).catch(() => void 0);
|
|
20035
|
+
if (icon)
|
|
20036
|
+
item.iconDataUrl = toImageDataUrl(icon);
|
|
20037
|
+
}
|
|
20038
|
+
const screenshots = [];
|
|
20039
|
+
let screenshotBytes = 0;
|
|
20040
|
+
for (const relative of parsed.manifest.screenshots ?? []) {
|
|
20041
|
+
const screenshot = await readDesktopExtensionScreenshot(directory, relative);
|
|
20042
|
+
screenshots.push(screenshot);
|
|
20043
|
+
screenshotBytes += screenshot.bytes.length;
|
|
20044
|
+
}
|
|
20045
|
+
if (screenshotBytes > screenshotBudget.remaining) {
|
|
20046
|
+
screenshotBudget.omitted = true;
|
|
20047
|
+
} else if (screenshots.length) {
|
|
20048
|
+
screenshotBudget.remaining -= screenshotBytes;
|
|
20049
|
+
item.screenshotDataUrls = screenshots.map(toImageDataUrl);
|
|
20050
|
+
}
|
|
20051
|
+
return item;
|
|
20052
|
+
} catch (error51) {
|
|
20053
|
+
return { id, state: "invalid", error: error51 instanceof Error ? error51.message : String(error51) };
|
|
20054
|
+
}
|
|
20055
|
+
}
|
|
20056
|
+
async function discoverDesktopExtensions(configuredRoot) {
|
|
20057
|
+
try {
|
|
20058
|
+
const root = await privateExtensionDirectory(configuredRoot);
|
|
20059
|
+
const names = (await readdir3(root, { withFileTypes: true })).filter((entry) => !isDesktopExtensionTransactionEntry(entry.name) && (entry.isDirectory() || entry.isSymbolicLink())).map((entry) => entry.name).sort();
|
|
20060
|
+
if (names.length > DESKTOP_EXTENSION_LIMIT)
|
|
20061
|
+
return {
|
|
20062
|
+
extensions: [],
|
|
20063
|
+
diagnostic: `At most ${DESKTOP_EXTENSION_LIMIT} extensions are supported`
|
|
20064
|
+
};
|
|
20065
|
+
const extensions = [];
|
|
20066
|
+
const screenshotBudget = {
|
|
20067
|
+
remaining: DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES,
|
|
20068
|
+
omitted: false
|
|
20069
|
+
};
|
|
20070
|
+
for (const id of names)
|
|
20071
|
+
extensions.push(await discover(root, id, screenshotBudget));
|
|
20072
|
+
return {
|
|
20073
|
+
extensions,
|
|
20074
|
+
...screenshotBudget.omitted ? {
|
|
20075
|
+
diagnostic: "Desktop extension screenshot list size limit exceeded; some previews were omitted"
|
|
20076
|
+
} : {}
|
|
20077
|
+
};
|
|
20078
|
+
} catch (error51) {
|
|
20079
|
+
return {
|
|
20080
|
+
extensions: [],
|
|
20081
|
+
...extensionFileMissing(error51) ? {} : { diagnostic: error51 instanceof Error ? error51.message : String(error51) }
|
|
20082
|
+
};
|
|
20083
|
+
}
|
|
20084
|
+
}
|
|
20085
|
+
|
|
20086
|
+
// packages/harness-plugin-files/dist/extension-configuration.js
|
|
20087
|
+
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
20088
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
20089
|
+
import { mkdir as mkdir4, rename as rename4, rm as rm4, writeFile as writeFile4 } from "node:fs/promises";
|
|
20090
|
+
import path10 from "node:path";
|
|
20091
|
+
var CONFIG_FILE = "enabled.json";
|
|
20092
|
+
function missingDesktopExtensionConfiguration(error51) {
|
|
20093
|
+
const configuration = { version: 1, revision: 0, enabled: [] };
|
|
20094
|
+
return extensionFileMissing(error51) ? { configuration } : {
|
|
20095
|
+
configuration,
|
|
20096
|
+
diagnostic: `Invalid extension configuration: ${error51 instanceof Error ? error51.message : String(error51)}`
|
|
20097
|
+
};
|
|
20098
|
+
}
|
|
20099
|
+
async function readDesktopExtensionConfiguration(root) {
|
|
20100
|
+
try {
|
|
20101
|
+
const directory = await privateExtensionDirectory(root);
|
|
20102
|
+
const bytes = await readExtensionResource(directory, CONFIG_FILE, DESKTOP_EXTENSION_MANIFEST_MAX_BYTES);
|
|
20103
|
+
return {
|
|
20104
|
+
configuration: desktopExtensionConfigurationSchema.parse(JSON.parse(bytes.toString("utf8")))
|
|
20105
|
+
};
|
|
20106
|
+
} catch (error51) {
|
|
20107
|
+
return missingDesktopExtensionConfiguration(error51);
|
|
20108
|
+
}
|
|
20109
|
+
}
|
|
20110
|
+
var DesktopExtensionRevisionConflict = class extends Error {
|
|
20111
|
+
revision;
|
|
20112
|
+
constructor(revision) {
|
|
20113
|
+
super("Extension selection changed; refresh and try again");
|
|
20114
|
+
this.revision = revision;
|
|
20115
|
+
}
|
|
20116
|
+
};
|
|
20117
|
+
async function writeDesktopExtensionConfiguration(root, expectedRevision, update) {
|
|
20118
|
+
return withDesktopExtensionConfiguration(root, async ({ configuration, save }) => {
|
|
20119
|
+
if (expectedRevision !== void 0 && expectedRevision !== configuration.revision)
|
|
20120
|
+
throw new DesktopExtensionRevisionConflict(configuration.revision);
|
|
20121
|
+
return save(await update(configuration));
|
|
20122
|
+
});
|
|
20123
|
+
}
|
|
20124
|
+
async function withDesktopExtensionConfiguration(root, operation) {
|
|
20125
|
+
await mkdir4(root, { recursive: true, mode: 448 });
|
|
20126
|
+
const directory = await privateExtensionDirectory(root);
|
|
20127
|
+
return withDesktopExtensionDirectoryLock(directory, async (assertLocked) => {
|
|
20128
|
+
const { configuration } = await readDesktopExtensionConfiguration(directory);
|
|
20129
|
+
return operation({
|
|
20130
|
+
directory,
|
|
20131
|
+
configuration,
|
|
20132
|
+
async save(update) {
|
|
20133
|
+
const next = desktopExtensionConfigurationSchema.parse({
|
|
20134
|
+
...configuration,
|
|
20135
|
+
...update,
|
|
20136
|
+
revision: configuration.revision + 1
|
|
20137
|
+
});
|
|
20138
|
+
const temporary = path10.join(directory, `.enabled-${randomUUID4()}.tmp`);
|
|
20139
|
+
try {
|
|
20140
|
+
await writeFile4(temporary, `${JSON.stringify(next)}
|
|
20141
|
+
`, { mode: 384, flag: "wx" });
|
|
20142
|
+
assertLocked();
|
|
20143
|
+
await rename4(temporary, path10.join(directory, CONFIG_FILE));
|
|
20144
|
+
} catch (error51) {
|
|
20145
|
+
await rm4(temporary, { force: true }).catch(() => void 0);
|
|
20146
|
+
throw error51;
|
|
20147
|
+
}
|
|
20148
|
+
return next;
|
|
20149
|
+
}
|
|
20150
|
+
});
|
|
20151
|
+
});
|
|
20152
|
+
}
|
|
20153
|
+
async function withDesktopExtensionDirectoryLock(directory, operation) {
|
|
20154
|
+
let compromised;
|
|
20155
|
+
const release = await import_proper_lockfile.default.lock(directory, {
|
|
20156
|
+
lockfilePath: path10.join(directory, DESKTOP_EXTENSION_CONFIGURATION_LOCK),
|
|
20157
|
+
retries: { retries: 24, minTimeout: 50, maxTimeout: 500 },
|
|
20158
|
+
onCompromised(error51) {
|
|
20159
|
+
compromised = error51;
|
|
20160
|
+
}
|
|
20161
|
+
});
|
|
20162
|
+
const assertLocked = () => {
|
|
20163
|
+
if (compromised)
|
|
20164
|
+
throw compromised;
|
|
20165
|
+
};
|
|
20166
|
+
try {
|
|
20167
|
+
const result = await operation(assertLocked);
|
|
20168
|
+
assertLocked();
|
|
20169
|
+
return result;
|
|
20170
|
+
} finally {
|
|
20171
|
+
if (!compromised)
|
|
20172
|
+
await release();
|
|
20173
|
+
}
|
|
17727
20174
|
}
|
|
17728
20175
|
|
|
17729
|
-
// packages/harness-plugin-files/dist/
|
|
17730
|
-
import { randomUUID as
|
|
17731
|
-
import {
|
|
17732
|
-
|
|
17733
|
-
|
|
17734
|
-
|
|
17735
|
-
|
|
17736
|
-
|
|
17737
|
-
constructor(
|
|
17738
|
-
|
|
20176
|
+
// packages/harness-plugin-files/dist/extension-management.js
|
|
20177
|
+
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
20178
|
+
import { readFile as readFile5 } from "node:fs/promises";
|
|
20179
|
+
var MAX_STATUS_AGE_MS = 15e3;
|
|
20180
|
+
var DesktopExtensionSelectionError = class extends Error {
|
|
20181
|
+
};
|
|
20182
|
+
var DesktopExtensionSlotConflict = class extends Error {
|
|
20183
|
+
conflictWith;
|
|
20184
|
+
constructor(conflictWith) {
|
|
20185
|
+
super(`Slot already occupied by ${conflictWith}`);
|
|
20186
|
+
this.conflictWith = conflictWith;
|
|
17739
20187
|
}
|
|
17740
|
-
|
|
17741
|
-
|
|
20188
|
+
};
|
|
20189
|
+
async function readDesktopExtensionSnapshot(root, { skipScanIfNoneEnabled = false } = {}) {
|
|
20190
|
+
let directory;
|
|
20191
|
+
try {
|
|
20192
|
+
directory = await privateExtensionDirectory(root);
|
|
20193
|
+
} catch (error51) {
|
|
20194
|
+
return {
|
|
20195
|
+
selection: missingDesktopExtensionConfiguration(error51),
|
|
20196
|
+
discovery: {
|
|
20197
|
+
extensions: [],
|
|
20198
|
+
...!extensionFileMissing(error51) && {
|
|
20199
|
+
diagnostic: error51 instanceof Error ? error51.message : String(error51)
|
|
20200
|
+
}
|
|
20201
|
+
}
|
|
20202
|
+
};
|
|
17742
20203
|
}
|
|
17743
|
-
async
|
|
17744
|
-
const
|
|
17745
|
-
|
|
20204
|
+
return withDesktopExtensionDirectoryLock(directory, async () => {
|
|
20205
|
+
const selection = await readDesktopExtensionConfiguration(directory);
|
|
20206
|
+
const discovery = skipScanIfNoneEnabled && !selection.configuration.enabled.length ? { extensions: [] } : await discoverDesktopExtensions(directory);
|
|
20207
|
+
return { selection, discovery };
|
|
20208
|
+
});
|
|
20209
|
+
}
|
|
20210
|
+
async function listDesktopExtensions(dataDirectory2) {
|
|
20211
|
+
const [{ discovery, selection: { configuration, diagnostic } }, status] = await Promise.all([
|
|
20212
|
+
readDesktopExtensionSnapshot(desktopExtensionsRoot(dataDirectory2)),
|
|
20213
|
+
readStatus(dataDirectory2)
|
|
20214
|
+
]);
|
|
20215
|
+
const { conflicts } = resolveDesktopExtensionSlots(configuration.enabled, discovery.extensions.flatMap((item) => item.state === "valid" ? [item.manifest] : []));
|
|
20216
|
+
const extensions = discovery.extensions.map((item) => {
|
|
20217
|
+
const enabled = configuration.enabled.includes(item.id);
|
|
20218
|
+
if (item.state !== "valid")
|
|
20219
|
+
return { id: item.id, enabled, status: { state: item.state, error: item.error } };
|
|
20220
|
+
const active = status && Object.hasOwn(status.extensions, item.id) ? status.extensions[item.id] : void 0;
|
|
20221
|
+
const conflictWith = conflicts.get(item.id);
|
|
20222
|
+
const observed = !enabled ? {
|
|
20223
|
+
state: "disabled",
|
|
20224
|
+
...active?.state === "disabled" && active.error ? { error: active.error } : {}
|
|
20225
|
+
} : conflictWith ? { state: "conflict", conflictWith } : active?.hash === item.hash ? active : { state: "waiting" };
|
|
20226
|
+
return {
|
|
20227
|
+
id: item.id,
|
|
20228
|
+
manifest: item.manifest,
|
|
20229
|
+
...item.iconDataUrl ? { iconDataUrl: item.iconDataUrl } : {},
|
|
20230
|
+
...item.screenshotDataUrls ? { screenshotDataUrls: item.screenshotDataUrls } : {},
|
|
20231
|
+
enabled,
|
|
20232
|
+
status: observed
|
|
20233
|
+
};
|
|
20234
|
+
});
|
|
20235
|
+
for (const id of configuration.enabled)
|
|
20236
|
+
if (!extensions.some((item) => item.id === id))
|
|
20237
|
+
extensions.push({
|
|
20238
|
+
id,
|
|
20239
|
+
enabled: true,
|
|
20240
|
+
status: { state: "invalid", error: "Extension directory not found" }
|
|
20241
|
+
});
|
|
20242
|
+
return {
|
|
20243
|
+
configuration,
|
|
20244
|
+
desktopConnected: status !== null,
|
|
20245
|
+
diagnostics: [discovery.diagnostic, diagnostic].filter((value) => value !== void 0),
|
|
20246
|
+
extensions
|
|
20247
|
+
};
|
|
20248
|
+
}
|
|
20249
|
+
async function updateDesktopExtensionSelection(dataDirectory2, change) {
|
|
20250
|
+
const root = desktopExtensionsRoot(dataDirectory2);
|
|
20251
|
+
try {
|
|
20252
|
+
const configuration = await writeDesktopExtensionConfiguration(root, change.expectedRevision, async ({ enabled }) => {
|
|
20253
|
+
if (change.action === "recover")
|
|
20254
|
+
return { enabled: [], reloadToken: randomUUID5() };
|
|
20255
|
+
if (change.action === "disable")
|
|
20256
|
+
return { enabled: enabled.filter((id) => id !== change.id) };
|
|
20257
|
+
const { extensions } = await discoverDesktopExtensions(root);
|
|
20258
|
+
const item = extensions.find((item2) => item2.id === change.id);
|
|
20259
|
+
if (!item || item.state !== "valid")
|
|
20260
|
+
throw new DesktopExtensionSelectionError(item?.error ?? "Extension not found");
|
|
20261
|
+
const next = enabled.includes(change.id) ? enabled : [...enabled, change.id];
|
|
20262
|
+
const { conflicts } = resolveDesktopExtensionSlots(next, extensions.flatMap((item2) => item2.state === "valid" ? [item2.manifest] : []));
|
|
20263
|
+
const conflict = conflicts.get(change.id);
|
|
20264
|
+
if (conflict)
|
|
20265
|
+
throw new DesktopExtensionSlotConflict(conflict);
|
|
20266
|
+
return { enabled: next };
|
|
20267
|
+
});
|
|
20268
|
+
return { state: "saved", configuration };
|
|
20269
|
+
} catch (error51) {
|
|
20270
|
+
if (error51 instanceof DesktopExtensionRevisionConflict)
|
|
20271
|
+
return { state: "revision-conflict", revision: error51.revision };
|
|
20272
|
+
if (error51 instanceof DesktopExtensionSlotConflict)
|
|
20273
|
+
return { state: "slot-conflict", conflictWith: error51.conflictWith };
|
|
20274
|
+
throw error51;
|
|
20275
|
+
}
|
|
20276
|
+
}
|
|
20277
|
+
async function readStatus(dataDirectory2) {
|
|
20278
|
+
try {
|
|
20279
|
+
const value = desktopExtensionsDiagnosticSchema.parse(JSON.parse(await readFile5(desktopExtensionsStatusPath(dataDirectory2), "utf8")));
|
|
20280
|
+
const age = Date.now() - Date.parse(value.updatedAt);
|
|
20281
|
+
if (!value.targetId || age < 0 || age > MAX_STATUS_AGE_MS)
|
|
20282
|
+
return null;
|
|
17746
20283
|
try {
|
|
17747
|
-
|
|
20284
|
+
process.kill(value.controllerPid, 0);
|
|
17748
20285
|
} catch (error51) {
|
|
17749
|
-
if (error51
|
|
20286
|
+
if (error51.code !== "EPERM")
|
|
17750
20287
|
return null;
|
|
17751
|
-
throw new Error(`Could not read Harness launch settings at ${file2}`, { cause: error51 });
|
|
17752
20288
|
}
|
|
17753
|
-
|
|
20289
|
+
return value;
|
|
20290
|
+
} catch {
|
|
20291
|
+
return null;
|
|
20292
|
+
}
|
|
20293
|
+
}
|
|
20294
|
+
|
|
20295
|
+
// packages/harness-plugin-files/dist/desktop-extension-catalog.js
|
|
20296
|
+
import { constants } from "node:fs";
|
|
20297
|
+
import { open as open4 } from "node:fs/promises";
|
|
20298
|
+
import path11 from "node:path";
|
|
20299
|
+
|
|
20300
|
+
// packages/harness-plugin-files/dist/desktop-extension-seed-catalog.json
|
|
20301
|
+
var desktop_extension_seed_catalog_default = {
|
|
20302
|
+
schemaVersion: 1,
|
|
20303
|
+
generatedAt: "2026-01-01T00:00:00.000Z",
|
|
20304
|
+
extensions: []
|
|
20305
|
+
};
|
|
20306
|
+
|
|
20307
|
+
// packages/harness-plugin-files/dist/desktop-extension-download.js
|
|
20308
|
+
var githubHeaders = {
|
|
20309
|
+
accept: "application/vnd.github+json",
|
|
20310
|
+
"user-agent": "codexhost-desktop-extensions"
|
|
20311
|
+
};
|
|
20312
|
+
var DesktopExtensionPackageError = class extends Error {
|
|
20313
|
+
};
|
|
20314
|
+
var ExtensionHttpError = class extends DesktopExtensionPackageError {
|
|
20315
|
+
status;
|
|
20316
|
+
constructor(status) {
|
|
20317
|
+
super(`Download returned HTTP ${status}`);
|
|
20318
|
+
this.status = status;
|
|
20319
|
+
}
|
|
20320
|
+
};
|
|
20321
|
+
async function downloadExtensionBytes(url2, limit, headers) {
|
|
20322
|
+
const parsed = desktopExtensionHttpUrlSchema.safeParse(url2);
|
|
20323
|
+
if (!parsed.success)
|
|
20324
|
+
throw new DesktopExtensionPackageError("Expected a credential-free HTTP(S) URL");
|
|
20325
|
+
try {
|
|
20326
|
+
if (isGitHubDesktopExtensionZipballUrl(new URL(parsed.data)))
|
|
20327
|
+
headers ??= githubHeaders;
|
|
20328
|
+
const response = await fetch(parsed.data, {
|
|
20329
|
+
signal: AbortSignal.timeout(12e3),
|
|
20330
|
+
redirect: "follow",
|
|
20331
|
+
...headers ? { headers } : {}
|
|
20332
|
+
});
|
|
20333
|
+
const body = response.body;
|
|
20334
|
+
if (!response.ok || !body || Number(response.headers.get("content-length")) > limit) {
|
|
20335
|
+
await body?.cancel().catch(() => void 0);
|
|
20336
|
+
if (!response.ok)
|
|
20337
|
+
throw new ExtensionHttpError(response.status);
|
|
20338
|
+
throw new DesktopExtensionPackageError("Download is empty or exceeds the size limit");
|
|
20339
|
+
}
|
|
20340
|
+
const reader = body.getReader();
|
|
20341
|
+
const chunks = [];
|
|
20342
|
+
let size = 0;
|
|
17754
20343
|
try {
|
|
17755
|
-
|
|
17756
|
-
|
|
20344
|
+
for (; ; ) {
|
|
20345
|
+
const { done, value } = await reader.read();
|
|
20346
|
+
if (done)
|
|
20347
|
+
break;
|
|
20348
|
+
size += value.byteLength;
|
|
20349
|
+
if (size > limit)
|
|
20350
|
+
throw new DesktopExtensionPackageError("Download exceeds the size limit");
|
|
20351
|
+
chunks.push(value);
|
|
20352
|
+
}
|
|
20353
|
+
} finally {
|
|
20354
|
+
await reader.cancel().catch(() => void 0);
|
|
17757
20355
|
}
|
|
17758
|
-
|
|
17759
|
-
|
|
20356
|
+
return Buffer.concat(chunks, size);
|
|
20357
|
+
} catch (error51) {
|
|
20358
|
+
if (error51 instanceof DesktopExtensionPackageError)
|
|
20359
|
+
throw error51;
|
|
20360
|
+
throw new DesktopExtensionPackageError("Download failed or timed out", { cause: error51 });
|
|
20361
|
+
}
|
|
20362
|
+
}
|
|
20363
|
+
async function resolveDesktopExtensionDownload(input) {
|
|
20364
|
+
const url2 = desktopExtensionHttpUrlSchema.safeParse(input);
|
|
20365
|
+
if (!url2.success)
|
|
20366
|
+
throw new DesktopExtensionPackageError("Expected a credential-free HTTP(S) URL");
|
|
20367
|
+
const parsed = new URL(url2.data);
|
|
20368
|
+
const pathname = /^https:\/\/[^/?#]+([^?#]*)/iu.exec(url2.data)?.[1] ?? "";
|
|
20369
|
+
const repository = parsed.origin === "https://github.com" && /^\/([\w-]+)\/([\w-][\w.-]*)(?:\/tree\/([^/]+)(?:\/(.+?))?)?\/?$/u.exec(pathname);
|
|
20370
|
+
if (!repository) {
|
|
20371
|
+
if (desktopExtensionZipUrlSchema.safeParse(url2.data).success)
|
|
20372
|
+
return { url: url2.data };
|
|
20373
|
+
throw new DesktopExtensionPackageError("Use a .zip download URL, GitHub repository homepage, or GitHub tree URL");
|
|
20374
|
+
}
|
|
20375
|
+
const [, owner, repositoryName, encodedRef, encodedSubpath] = repository;
|
|
20376
|
+
const repo = repositoryName?.replace(/\.git$/iu, "");
|
|
20377
|
+
const api = `https://api.github.com/repos/${owner}/${repo}`;
|
|
20378
|
+
if (encodedRef !== void 0) {
|
|
20379
|
+
try {
|
|
20380
|
+
const ref = decodeURIComponent(encodedRef);
|
|
20381
|
+
const parts = encodedSubpath?.split("/").map(decodeURIComponent);
|
|
20382
|
+
if (/[\x00-\x1f\x7f\\]/u.test(ref) || ref.split("/").some((part) => !part || part === "." || part === "..") || parts?.some((part) => !part || part === "." || part === ".." || /[\x00-\x1f\x7f/\\]/u.test(part)))
|
|
20383
|
+
throw new Error("Invalid ref or subdirectory");
|
|
20384
|
+
return {
|
|
20385
|
+
url: `${api}/zipball/${encodeURIComponent(ref)}`,
|
|
20386
|
+
...parts ? { subpath: parts.join("/") } : {}
|
|
20387
|
+
};
|
|
20388
|
+
} catch (error51) {
|
|
20389
|
+
throw new DesktopExtensionPackageError("Invalid GitHub tree ref or subdirectory", {
|
|
20390
|
+
cause: error51
|
|
20391
|
+
});
|
|
17760
20392
|
}
|
|
17761
|
-
return parsed;
|
|
17762
20393
|
}
|
|
17763
|
-
|
|
17764
|
-
|
|
17765
|
-
|
|
17766
|
-
|
|
17767
|
-
|
|
20394
|
+
const zipball = { url: `${api}/zipball` };
|
|
20395
|
+
let release;
|
|
20396
|
+
try {
|
|
20397
|
+
release = JSON.parse((await downloadExtensionBytes(`${api}/releases/latest`, 1024 * 1024, githubHeaders)).toString("utf8"));
|
|
20398
|
+
} catch (error51) {
|
|
20399
|
+
if (error51 instanceof ExtensionHttpError && error51.status === 404)
|
|
20400
|
+
return zipball;
|
|
20401
|
+
if (error51 instanceof DesktopExtensionPackageError)
|
|
20402
|
+
throw error51;
|
|
20403
|
+
throw new DesktopExtensionPackageError("Invalid GitHub Release response", { cause: error51 });
|
|
20404
|
+
}
|
|
20405
|
+
const assets = release && typeof release === "object" && "assets" in release && release.assets;
|
|
20406
|
+
if (Array.isArray(assets)) {
|
|
20407
|
+
for (const asset of assets) {
|
|
20408
|
+
if (typeof asset?.name !== "string" || !/\.zip$/iu.test(asset.name))
|
|
20409
|
+
continue;
|
|
20410
|
+
const download2 = desktopExtensionZipUrlSchema.safeParse(asset.browser_download_url);
|
|
20411
|
+
if (download2.success) {
|
|
20412
|
+
const assetUrl = new URL(download2.data);
|
|
20413
|
+
if (assetUrl.origin === "https://github.com" && /\.zip$/iu.test(assetUrl.pathname))
|
|
20414
|
+
return { url: download2.data };
|
|
20415
|
+
}
|
|
17768
20416
|
}
|
|
17769
|
-
return initial;
|
|
17770
20417
|
}
|
|
17771
|
-
|
|
17772
|
-
|
|
17773
|
-
|
|
17774
|
-
|
|
17775
|
-
|
|
17776
|
-
|
|
17777
|
-
|
|
17778
|
-
|
|
17779
|
-
|
|
17780
|
-
|
|
17781
|
-
|
|
17782
|
-
|
|
20418
|
+
return zipball;
|
|
20419
|
+
}
|
|
20420
|
+
|
|
20421
|
+
// packages/harness-plugin-files/dist/desktop-extension-catalog.js
|
|
20422
|
+
var PRIMARY = "https://raw.githubusercontent.com/BytePioneer-AI/codexhost-extensions-registry/main/catalog.json";
|
|
20423
|
+
var MIRROR = "https://cdn.jsdelivr.net/gh/BytePioneer-AI/codexhost-extensions-registry@main/catalog.json";
|
|
20424
|
+
var MAX_BYTES = 2 * 1024 * 1024;
|
|
20425
|
+
var TTL = 5 * 60 * 1e3;
|
|
20426
|
+
var fallback = desktopExtensionCatalogSchema.parse(desktop_extension_seed_catalog_default).extensions;
|
|
20427
|
+
async function readLocalCatalog(file2) {
|
|
20428
|
+
const handle = await open4(file2, constants.O_RDONLY | (constants.O_NONBLOCK ?? 0));
|
|
20429
|
+
try {
|
|
20430
|
+
const info = await handle.stat();
|
|
20431
|
+
if (!info.isFile() || info.size > MAX_BYTES)
|
|
20432
|
+
throw new Error("Invalid local catalog file");
|
|
20433
|
+
const buffer = Buffer.alloc(MAX_BYTES + 1);
|
|
20434
|
+
let offset = 0;
|
|
20435
|
+
while (offset < buffer.length) {
|
|
20436
|
+
const { bytesRead } = await handle.read(buffer, offset, buffer.length - offset, offset);
|
|
20437
|
+
if (!bytesRead)
|
|
20438
|
+
break;
|
|
20439
|
+
offset += bytesRead;
|
|
20440
|
+
}
|
|
20441
|
+
if (offset > MAX_BYTES)
|
|
20442
|
+
throw new Error("Local catalog exceeds the size limit");
|
|
20443
|
+
return buffer.subarray(0, offset);
|
|
20444
|
+
} finally {
|
|
20445
|
+
await handle.close();
|
|
17783
20446
|
}
|
|
17784
|
-
|
|
17785
|
-
|
|
17786
|
-
|
|
20447
|
+
}
|
|
20448
|
+
async function fetchCandidate(catalogUrl) {
|
|
20449
|
+
const data = path11.isAbsolute(catalogUrl) ? await readLocalCatalog(catalogUrl) : await downloadExtensionBytes(catalogUrl, MAX_BYTES, { accept: "application/json" });
|
|
20450
|
+
const { extensions } = desktopExtensionCatalogSchema.parse(JSON.parse(data.toString("utf8")));
|
|
20451
|
+
return {
|
|
20452
|
+
catalogUrl,
|
|
20453
|
+
source: "remote",
|
|
20454
|
+
fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
20455
|
+
cached: false,
|
|
20456
|
+
extensions
|
|
20457
|
+
};
|
|
20458
|
+
}
|
|
20459
|
+
async function refreshCatalog(override) {
|
|
20460
|
+
const candidates = override ? [override] : [PRIMARY, MIRROR];
|
|
20461
|
+
try {
|
|
20462
|
+
return await Promise.any(candidates.map(fetchCandidate));
|
|
20463
|
+
} catch {
|
|
17787
20464
|
}
|
|
17788
|
-
|
|
17789
|
-
|
|
17790
|
-
|
|
17791
|
-
|
|
20465
|
+
return {
|
|
20466
|
+
catalogUrl: override ?? PRIMARY,
|
|
20467
|
+
source: "fallback",
|
|
20468
|
+
fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
20469
|
+
cached: false,
|
|
20470
|
+
extensions: fallback,
|
|
20471
|
+
error: "Desktop extension catalog unavailable"
|
|
20472
|
+
};
|
|
20473
|
+
}
|
|
20474
|
+
var cache;
|
|
20475
|
+
var pending;
|
|
20476
|
+
async function fetchDesktopExtensionCatalog({ forceRefresh, environment = process.env } = {}) {
|
|
20477
|
+
const key = environment.CODEXHOST_DESKTOP_EXTENSIONS_CATALOG_URL?.trim() || void 0;
|
|
20478
|
+
if (!forceRefresh && cache && cache.key === key && Date.now() < cache.expires)
|
|
20479
|
+
return { ...structuredClone(cache.result), cached: true };
|
|
20480
|
+
if (!forceRefresh && pending && pending.key === key)
|
|
20481
|
+
return structuredClone(await pending.promise);
|
|
20482
|
+
const request = { key, promise: refreshCatalog(key) };
|
|
20483
|
+
pending = request;
|
|
20484
|
+
try {
|
|
20485
|
+
const result = await request.promise;
|
|
20486
|
+
if (pending === request)
|
|
20487
|
+
cache = { key, result, expires: Date.now() + TTL };
|
|
20488
|
+
return structuredClone(result);
|
|
20489
|
+
} finally {
|
|
20490
|
+
if (pending === request)
|
|
20491
|
+
pending = void 0;
|
|
17792
20492
|
}
|
|
17793
|
-
|
|
17794
|
-
|
|
17795
|
-
|
|
17796
|
-
|
|
17797
|
-
|
|
17798
|
-
|
|
20493
|
+
}
|
|
20494
|
+
|
|
20495
|
+
// packages/harness-plugin-files/dist/desktop-extension-installer.js
|
|
20496
|
+
import { createHash as createHash3, randomUUID as randomUUID6 } from "node:crypto";
|
|
20497
|
+
import { lstat as lstat5, mkdir as mkdir5, mkdtemp, readdir as readdir4, rename as rename5, rm as rm5, writeFile as writeFile5 } from "node:fs/promises";
|
|
20498
|
+
import path12 from "node:path";
|
|
20499
|
+
import { Script } from "node:vm";
|
|
20500
|
+
|
|
20501
|
+
// packages/harness-plugin-files/dist/desktop-extension-zip.js
|
|
20502
|
+
import { crc32, inflateRawSync } from "node:zlib";
|
|
20503
|
+
var MAX_UNPACKED_BYTES = 256 * 1024 * 1024;
|
|
20504
|
+
var MAX_ENTRIES = 1e4;
|
|
20505
|
+
var EXPANSION_RATIO = 200;
|
|
20506
|
+
var EXPANSION_FLOOR_BYTES = 16 * 1024 * 1024;
|
|
20507
|
+
var END = 101010256;
|
|
20508
|
+
var CENTRAL = 33639248;
|
|
20509
|
+
var LOCAL = 67324752;
|
|
20510
|
+
var utf8 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
20511
|
+
function check2(condition, message) {
|
|
20512
|
+
if (!condition)
|
|
20513
|
+
throw new Error(`Invalid Desktop extension ZIP: ${message}`);
|
|
20514
|
+
}
|
|
20515
|
+
function safeName(name, directory) {
|
|
20516
|
+
check2(name.length <= 512, "entry path is too long");
|
|
20517
|
+
const parts = (directory ? name.slice(0, -1) : name).split("/");
|
|
20518
|
+
check2(parts.every((part) => part && part !== "." && part !== ".." && !/[. ]$/u.test(part) && !/[\x00-\x1f\x7f\\<>:"|?*]/u.test(part) && !/^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu.test(part)), "unsafe entry path");
|
|
20519
|
+
return parts.join("/");
|
|
20520
|
+
}
|
|
20521
|
+
function readDesktopExtensionZip(zip, subpath) {
|
|
20522
|
+
check2(zip.length <= DESKTOP_EXTENSION_ZIP_MAX_BYTES, "archive exceeds the safety size limit");
|
|
20523
|
+
const subdirectory = subpath === void 0 ? void 0 : safeName(subpath, false);
|
|
20524
|
+
const u16 = (offset) => zip.readUInt16LE(offset);
|
|
20525
|
+
const u32 = (offset) => zip.readUInt32LE(offset);
|
|
20526
|
+
let end = zip.length - 22;
|
|
20527
|
+
const earliest = Math.max(0, end - 65535);
|
|
20528
|
+
while (end >= earliest && (u32(end) !== END || end + 22 + u16(end + 20) !== zip.length))
|
|
20529
|
+
end--;
|
|
20530
|
+
check2(end >= earliest, "missing end of central directory");
|
|
20531
|
+
const count2 = u16(end + 10);
|
|
20532
|
+
const start = u32(end + 16);
|
|
20533
|
+
check2(u16(end + 4) === 0 && u16(end + 6) === 0 && u16(end + 8) === count2, "multi-disk archive");
|
|
20534
|
+
check2(start + u32(end + 12) === end, "invalid central directory bounds (ZIP64 is unsupported)");
|
|
20535
|
+
check2(count2 > 0 && count2 <= MAX_ENTRIES, `expected 1–${MAX_ENTRIES} entries`);
|
|
20536
|
+
const files = /* @__PURE__ */ new Map();
|
|
20537
|
+
const paths = /* @__PURE__ */ new Map();
|
|
20538
|
+
const ranges = [];
|
|
20539
|
+
let total = 0;
|
|
20540
|
+
let central = start;
|
|
20541
|
+
for (let index = 0; index < count2; index++) {
|
|
20542
|
+
check2(central + 46 <= end && u32(central) === CENTRAL, "truncated central entry");
|
|
20543
|
+
const flags = u16(central + 8);
|
|
20544
|
+
const method = u16(central + 10);
|
|
20545
|
+
const crc = u32(central + 16);
|
|
20546
|
+
const compressed = u32(central + 20);
|
|
20547
|
+
const size = u32(central + 24);
|
|
20548
|
+
const nameLength = u16(central + 28);
|
|
20549
|
+
const next = central + 46 + nameLength + u16(central + 30) + u16(central + 32);
|
|
20550
|
+
const attr = u32(central + 38);
|
|
20551
|
+
const type = attr >>> 16 & 61440;
|
|
20552
|
+
const local = u32(central + 42);
|
|
20553
|
+
check2(next <= end && u16(central + 34) === 0, "invalid central entry bounds");
|
|
20554
|
+
check2((flags & ~2062) === 0 && (method === 0 || method === 8), "unsupported ZIP flags or compression");
|
|
20555
|
+
const rawName = zip.subarray(central + 46, central + 46 + nameLength);
|
|
20556
|
+
const name = utf8.decode(rawName).replaceAll("\\", "/");
|
|
20557
|
+
const directory = name.endsWith("/");
|
|
20558
|
+
check2(type === 0 || type === (directory ? 16384 : 32768), "symlink or special file");
|
|
20559
|
+
check2(directory || !(attr & 16), "inconsistent directory attribute");
|
|
20560
|
+
const relative = safeName(name, directory);
|
|
20561
|
+
const parts = relative.split("/");
|
|
20562
|
+
for (let i = 1; i <= parts.length; i++) {
|
|
20563
|
+
const segment = parts.slice(0, i).join("/");
|
|
20564
|
+
const key = segment.normalize("NFC").toLowerCase();
|
|
20565
|
+
const explicit = i === parts.length;
|
|
20566
|
+
const isDirectory = !explicit || directory;
|
|
20567
|
+
const previous = paths.get(key);
|
|
20568
|
+
check2(!previous || previous.name === segment && previous.directory === isDirectory && !(previous.explicit && explicit), "duplicate or conflicting entry path");
|
|
20569
|
+
if (!previous || explicit)
|
|
20570
|
+
paths.set(key, { name: segment, directory: isDirectory, explicit });
|
|
20571
|
+
}
|
|
20572
|
+
check2(local + 30 <= start && u32(local) === LOCAL, "invalid local header");
|
|
20573
|
+
const data = local + 30 + nameLength + u16(local + 28);
|
|
20574
|
+
check2(data + compressed <= start && u16(local + 26) === nameLength && u16(local + 6) === flags && u16(local + 8) === method && zip.subarray(local + 30, local + 30 + nameLength).equals(rawName), "local header disagrees with central directory");
|
|
20575
|
+
let localEnd = data + compressed;
|
|
20576
|
+
if (flags & 8) {
|
|
20577
|
+
const matches = (offset) => offset + 12 <= start && u32(offset) === crc && u32(offset + 4) === compressed && u32(offset + 8) === size;
|
|
20578
|
+
if (localEnd + 4 <= start && u32(localEnd) === 134695760 && matches(localEnd + 4))
|
|
20579
|
+
localEnd += 16;
|
|
20580
|
+
else {
|
|
20581
|
+
check2(matches(localEnd), "invalid data descriptor");
|
|
20582
|
+
localEnd += 12;
|
|
20583
|
+
}
|
|
17799
20584
|
} else {
|
|
17800
|
-
|
|
17801
|
-
|
|
17802
|
-
|
|
17803
|
-
|
|
17804
|
-
|
|
17805
|
-
|
|
17806
|
-
|
|
17807
|
-
|
|
20585
|
+
check2(u32(local + 14) === crc && u32(local + 18) === compressed && u32(local + 22) === size, "local entry sizes or CRC disagree");
|
|
20586
|
+
}
|
|
20587
|
+
ranges.push({ start: local, end: localEnd });
|
|
20588
|
+
total += size;
|
|
20589
|
+
check2(total <= MAX_UNPACKED_BYTES, "unpacked data exceeds the safety size limit");
|
|
20590
|
+
check2(size <= Math.max(EXPANSION_FLOOR_BYTES, compressed * EXPANSION_RATIO), "entry exceeds the safety compression ratio");
|
|
20591
|
+
check2(!directory || size === 0, "directory contains file data");
|
|
20592
|
+
const input = zip.subarray(data, data + compressed);
|
|
20593
|
+
const bytes = method === 0 ? input : inflateRawSync(input, { maxOutputLength: Math.max(1, size) });
|
|
20594
|
+
check2(bytes.length === size && crc32(bytes) === crc, "entry size or CRC mismatch");
|
|
20595
|
+
if (!directory)
|
|
20596
|
+
files.set(relative, bytes);
|
|
20597
|
+
central = next;
|
|
20598
|
+
}
|
|
20599
|
+
check2(central === end, "incorrect central directory size");
|
|
20600
|
+
ranges.sort((a, b) => a.start - b.start);
|
|
20601
|
+
let previousEnd = 0;
|
|
20602
|
+
for (const { start: start2, end: end2 } of ranges) {
|
|
20603
|
+
check2(previousEnd <= start2, "overlapping local entries");
|
|
20604
|
+
previousEnd = end2;
|
|
20605
|
+
}
|
|
20606
|
+
if (subdirectory === void 0 && files.has("manifest.json"))
|
|
20607
|
+
return files;
|
|
20608
|
+
const roots = [...paths.values()].filter(({ name }) => !name.includes("/"));
|
|
20609
|
+
const [wrapper] = roots;
|
|
20610
|
+
const prefix = wrapper && `${wrapper.name}/${subdirectory ? `${subdirectory}/` : ""}`;
|
|
20611
|
+
check2(roots.length === 1 && wrapper?.directory && prefix && files.has(`${prefix}manifest.json`), subdirectory ? `missing manifest.json in repository subdirectory ${subdirectory}` : "missing manifest.json at the root or inside a single top-level directory");
|
|
20612
|
+
const selected = /* @__PURE__ */ new Map();
|
|
20613
|
+
for (const [name, bytes] of files)
|
|
20614
|
+
if (name.startsWith(prefix))
|
|
20615
|
+
selected.set(name.slice(prefix.length), bytes);
|
|
20616
|
+
return selected;
|
|
20617
|
+
}
|
|
20618
|
+
|
|
20619
|
+
// packages/harness-plugin-files/dist/desktop-extension-installer.js
|
|
20620
|
+
var utf82 = new TextDecoder("utf-8", { fatal: true });
|
|
20621
|
+
function assertPortableId(id) {
|
|
20622
|
+
if (!desktopExtensionIdSchema.safeParse(id).success || id === "enabled.json" || /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/iu.test(id))
|
|
20623
|
+
throw new DesktopExtensionPackageError("Invalid or reserved extension ID");
|
|
20624
|
+
}
|
|
20625
|
+
async function pathExists(file2) {
|
|
20626
|
+
try {
|
|
20627
|
+
const info = await lstat5(file2);
|
|
20628
|
+
if (!info.isDirectory() && !info.isSymbolicLink())
|
|
20629
|
+
throw new DesktopExtensionPackageError("Extension installation path must be a directory or symlink");
|
|
20630
|
+
return true;
|
|
20631
|
+
} catch (error51) {
|
|
20632
|
+
if (extensionFileMissing(error51))
|
|
20633
|
+
return false;
|
|
20634
|
+
throw error51;
|
|
20635
|
+
}
|
|
20636
|
+
}
|
|
20637
|
+
async function withInstallationBackup(installed, operation) {
|
|
20638
|
+
const backup = path12.join(path12.dirname(installed), `.backup-${path12.basename(installed)}-${randomUUID6()}`);
|
|
20639
|
+
const replaced = await pathExists(installed);
|
|
20640
|
+
if (replaced)
|
|
20641
|
+
await rename5(installed, backup);
|
|
20642
|
+
let result;
|
|
20643
|
+
try {
|
|
20644
|
+
result = await operation(replaced);
|
|
20645
|
+
} catch (error51) {
|
|
20646
|
+
if (replaced) {
|
|
17808
20647
|
try {
|
|
17809
|
-
await
|
|
17810
|
-
|
|
17811
|
-
|
|
17812
|
-
|
|
17813
|
-
|
|
20648
|
+
await rename5(backup, installed);
|
|
20649
|
+
} catch (rollbackError) {
|
|
20650
|
+
throw new Error(`Rollback failed; previous extension preserved at ${backup}`, {
|
|
20651
|
+
cause: new AggregateError([error51, rollbackError])
|
|
20652
|
+
});
|
|
17814
20653
|
}
|
|
17815
20654
|
}
|
|
17816
|
-
|
|
20655
|
+
throw error51;
|
|
17817
20656
|
}
|
|
17818
|
-
|
|
20657
|
+
if (replaced)
|
|
20658
|
+
await rm5(backup, { recursive: true, force: true }).catch(() => void 0);
|
|
20659
|
+
return result;
|
|
20660
|
+
}
|
|
20661
|
+
async function installFromZipBuffer({ extensionsRoot, zipBuffer, expectedSha256, subpath }, expected) {
|
|
20662
|
+
if (expectedSha256 !== void 0 && createHash3("sha256").update(zipBuffer).digest("hex") !== expectedSha256)
|
|
20663
|
+
throw new DesktopExtensionPackageError("Desktop extension ZIP SHA-256 mismatch");
|
|
20664
|
+
let files;
|
|
20665
|
+
try {
|
|
20666
|
+
files = readDesktopExtensionZip(zipBuffer, subpath);
|
|
20667
|
+
} catch (error51) {
|
|
20668
|
+
throw new DesktopExtensionPackageError(error51 instanceof Error ? error51.message : "Invalid ZIP", {
|
|
20669
|
+
cause: error51
|
|
20670
|
+
});
|
|
20671
|
+
}
|
|
20672
|
+
await mkdir5(extensionsRoot, { recursive: true, mode: 448 });
|
|
20673
|
+
const root = await privateExtensionDirectory(extensionsRoot);
|
|
20674
|
+
const staging = await mkdtemp(path12.join(root, ".staging-"));
|
|
20675
|
+
try {
|
|
20676
|
+
for (const [relative, bytes] of files) {
|
|
20677
|
+
const target2 = path12.join(staging, relative);
|
|
20678
|
+
await mkdir5(path12.dirname(target2), { recursive: true, mode: 448 });
|
|
20679
|
+
await writeFile5(target2, bytes, { flag: "wx", mode: 384 });
|
|
20680
|
+
}
|
|
20681
|
+
const manifest = await (async () => {
|
|
20682
|
+
try {
|
|
20683
|
+
const bytes = await readExtensionResource(staging, "manifest.json", DESKTOP_EXTENSION_MANIFEST_MAX_BYTES);
|
|
20684
|
+
const manifest2 = desktopExtensionManifestSchema.parse(JSON.parse(utf82.decode(bytes)));
|
|
20685
|
+
if (expected && (manifest2.id !== expected.id || manifest2.version !== expected.version))
|
|
20686
|
+
throw new Error("Manifest id or version does not match the catalog entry");
|
|
20687
|
+
if (manifest2.desktop) {
|
|
20688
|
+
const { script, style } = manifest2.desktop;
|
|
20689
|
+
const scriptBytes = await readExtensionResource(staging, script, DESKTOP_EXTENSION_SCRIPT_MAX_BYTES).catch((error51) => {
|
|
20690
|
+
if (!extensionFileMissing(error51))
|
|
20691
|
+
throw error51;
|
|
20692
|
+
throw new Error(`Missing entry file ${script}. Commit the built JavaScript entry or publish a Release .zip.`, { cause: error51 });
|
|
20693
|
+
});
|
|
20694
|
+
const source = utf82.decode(scriptBytes);
|
|
20695
|
+
new Script(`(function(define) { "use strict";
|
|
20696
|
+
${source}
|
|
20697
|
+
})`);
|
|
20698
|
+
if (style)
|
|
20699
|
+
utf82.decode(await readExtensionResource(staging, style, DESKTOP_EXTENSION_STYLE_MAX_BYTES));
|
|
20700
|
+
}
|
|
20701
|
+
if (manifest2.backend)
|
|
20702
|
+
await readDesktopExtensionBackend(staging, manifest2.backend.script);
|
|
20703
|
+
if (manifest2.icon)
|
|
20704
|
+
await readDesktopExtensionIcon(staging, manifest2.icon);
|
|
20705
|
+
for (const screenshot of manifest2.screenshots ?? [])
|
|
20706
|
+
await readDesktopExtensionScreenshot(staging, screenshot);
|
|
20707
|
+
return manifest2;
|
|
20708
|
+
} catch (error51) {
|
|
20709
|
+
const reason = error51 instanceof Error ? error51.message : "Invalid manifest or resources";
|
|
20710
|
+
throw new DesktopExtensionPackageError(`Invalid extension package: ${reason.slice(0, 768)}`, { cause: error51 });
|
|
20711
|
+
}
|
|
20712
|
+
})();
|
|
20713
|
+
const { id, version: version2 } = manifest;
|
|
20714
|
+
assertPortableId(id);
|
|
20715
|
+
return await withDesktopExtensionConfiguration(root, async ({ directory, configuration, save }) => {
|
|
20716
|
+
const installedPath = path12.join(directory, id);
|
|
20717
|
+
if (!await pathExists(installedPath)) {
|
|
20718
|
+
const entries = await readdir4(directory, { withFileTypes: true });
|
|
20719
|
+
if (entries.filter((entry) => !isDesktopExtensionTransactionEntry(entry.name) && (entry.isDirectory() || entry.isSymbolicLink())).length >= DESKTOP_EXTENSION_LIMIT)
|
|
20720
|
+
throw new DesktopExtensionPackageError(`At most ${DESKTOP_EXTENSION_LIMIT} extensions are supported`);
|
|
20721
|
+
}
|
|
20722
|
+
await save({ enabled: configuration.enabled });
|
|
20723
|
+
return withInstallationBackup(installedPath, async (replaced) => {
|
|
20724
|
+
await rename5(staging, installedPath);
|
|
20725
|
+
return { extensionId: id, version: version2, replaced, installedPath };
|
|
20726
|
+
});
|
|
20727
|
+
});
|
|
20728
|
+
} finally {
|
|
20729
|
+
await rm5(staging, { recursive: true, force: true }).catch(() => void 0);
|
|
20730
|
+
}
|
|
20731
|
+
}
|
|
20732
|
+
async function installFromUrl({ extensionsRoot, url: url2, expectedSha256 }) {
|
|
20733
|
+
const download2 = await resolveDesktopExtensionDownload(url2);
|
|
20734
|
+
const zipBuffer = await downloadExtensionBytes(download2.url, DESKTOP_EXTENSION_ZIP_MAX_BYTES);
|
|
20735
|
+
return installFromZipBuffer({
|
|
20736
|
+
extensionsRoot,
|
|
20737
|
+
zipBuffer,
|
|
20738
|
+
expectedSha256,
|
|
20739
|
+
subpath: download2.subpath
|
|
20740
|
+
});
|
|
20741
|
+
}
|
|
20742
|
+
var DEFAULT_DESKTOP_EXTENSION_STATS_URL = "https://ext-stats.chost.dev";
|
|
20743
|
+
function resolveDesktopExtensionStatsUrl(environment = process.env) {
|
|
20744
|
+
const configured = environment.CODEXHOST_DESKTOP_EXTENSIONS_STATS_URL;
|
|
20745
|
+
if (configured !== void 0) {
|
|
20746
|
+
const trimmed = configured.trim();
|
|
20747
|
+
if (!trimmed || /^(?:off|none|false|0)$/iu.test(trimmed))
|
|
20748
|
+
return void 0;
|
|
20749
|
+
return trimmed;
|
|
20750
|
+
}
|
|
20751
|
+
if (environment.CODEXHOST_DESKTOP_EXTENSIONS_CATALOG_URL?.trim())
|
|
20752
|
+
return void 0;
|
|
20753
|
+
return DEFAULT_DESKTOP_EXTENSION_STATS_URL;
|
|
20754
|
+
}
|
|
20755
|
+
async function reportDesktopExtensionInstall(id, statsUrl) {
|
|
20756
|
+
try {
|
|
20757
|
+
const { data } = desktopExtensionHttpUrlSchema.safeParse(statsUrl);
|
|
20758
|
+
if (data === void 0)
|
|
20759
|
+
return;
|
|
20760
|
+
const url2 = new URL(data);
|
|
20761
|
+
url2.pathname = `${url2.pathname.replace(/\/+$/u, "")}/install/${encodeURIComponent(id)}`;
|
|
20762
|
+
url2.search = "";
|
|
20763
|
+
url2.hash = "";
|
|
20764
|
+
const response = await fetch(url2, {
|
|
20765
|
+
method: "POST",
|
|
20766
|
+
credentials: "omit",
|
|
20767
|
+
redirect: "error",
|
|
20768
|
+
signal: AbortSignal.timeout(2e3)
|
|
20769
|
+
});
|
|
20770
|
+
await response.body?.cancel();
|
|
20771
|
+
} catch {
|
|
20772
|
+
}
|
|
20773
|
+
}
|
|
20774
|
+
async function installFromCatalog({ extensionsRoot, id, ...options }) {
|
|
20775
|
+
const { extensions } = await fetchDesktopExtensionCatalog(options);
|
|
20776
|
+
const entry = extensions.find((entry2) => entry2.id === id);
|
|
20777
|
+
if (!entry)
|
|
20778
|
+
throw new DesktopExtensionPackageError("Extension ID was not found in the catalog");
|
|
20779
|
+
const zipBuffer = await downloadExtensionBytes(entry.downloadUrl, DESKTOP_EXTENSION_ZIP_MAX_BYTES);
|
|
20780
|
+
const installed = await installFromZipBuffer({ extensionsRoot, zipBuffer, expectedSha256: entry.sha256 }, entry);
|
|
20781
|
+
void reportDesktopExtensionInstall(installed.extensionId, resolveDesktopExtensionStatsUrl(options.environment ?? process.env));
|
|
20782
|
+
return installed;
|
|
20783
|
+
}
|
|
20784
|
+
async function installDesktopExtension(dataDir, { source }, environment = process.env) {
|
|
20785
|
+
const extensionsRoot = desktopExtensionsRoot(dataDir);
|
|
20786
|
+
const installed = source.type === "catalog" ? await installFromCatalog({ extensionsRoot, id: source.id, environment }) : source.type === "url" ? await installFromUrl({ extensionsRoot, ...source }) : await installFromZipBuffer({
|
|
20787
|
+
extensionsRoot,
|
|
20788
|
+
zipBuffer: Buffer.from(source.contentBase64, "base64")
|
|
20789
|
+
});
|
|
20790
|
+
return { ...installed, list: await listDesktopExtensions(dataDir) };
|
|
20791
|
+
}
|
|
20792
|
+
async function uninstallDesktopExtension({ dataDir, id }) {
|
|
20793
|
+
assertPortableId(id);
|
|
20794
|
+
await withDesktopExtensionConfiguration(desktopExtensionsRoot(dataDir), async ({ directory, configuration, save }) => {
|
|
20795
|
+
await withInstallationBackup(path12.join(directory, id), async () => {
|
|
20796
|
+
await save({ enabled: configuration.enabled.filter((entry) => entry !== id) });
|
|
20797
|
+
});
|
|
20798
|
+
});
|
|
20799
|
+
return { removedId: id, list: await listDesktopExtensions(dataDir) };
|
|
20800
|
+
}
|
|
17819
20801
|
|
|
17820
20802
|
// packages/console-server/src/paths.ts
|
|
17821
20803
|
import os2 from "node:os";
|
|
17822
|
-
import
|
|
20804
|
+
import path13 from "node:path";
|
|
17823
20805
|
var DEFAULT_CONSOLE_PORT = 4399;
|
|
17824
20806
|
var CONSOLE_PORT_ENV = "CODEXHOST_CONSOLE_PORT";
|
|
17825
20807
|
var LAUNCHER_EXECUTABLE_ENV = "CODEXHOST_LAUNCHER_EXECUTABLE";
|
|
17826
20808
|
function dataDirectory(environment = process.env) {
|
|
17827
|
-
return environment.CODEXHOST_DATA_DIR ?
|
|
20809
|
+
return environment.CODEXHOST_DATA_DIR ? path13.resolve(environment.CODEXHOST_DATA_DIR) : path13.join(os2.homedir(), ".codexhost");
|
|
17828
20810
|
}
|
|
17829
20811
|
function consolePaths(environment = process.env) {
|
|
17830
20812
|
const root = dataDirectory(environment);
|
|
17831
20813
|
return {
|
|
17832
20814
|
dataDirectory: root,
|
|
17833
|
-
startupRecordFile:
|
|
17834
|
-
controllerStatusFile:
|
|
17835
|
-
logsDirectory:
|
|
17836
|
-
hostDescriptorDirectory:
|
|
20815
|
+
startupRecordFile: path13.join(root, "diagnostics", "launcher-startup-v1.json"),
|
|
20816
|
+
controllerStatusFile: path13.join(root, "diagnostics", "desktop-controller-v1.json"),
|
|
20817
|
+
logsDirectory: path13.join(root, "logs"),
|
|
20818
|
+
hostDescriptorDirectory: path13.join(root, "console", "hosts")
|
|
17837
20819
|
};
|
|
17838
20820
|
}
|
|
17839
20821
|
function consolePort(environment = process.env) {
|
|
@@ -17849,10 +20831,10 @@ function consolePort(environment = process.env) {
|
|
|
17849
20831
|
// packages/console-server/src/harnesses.ts
|
|
17850
20832
|
var HARNESS_PLUGIN_DIRECTORY_ENV = "CODEXHOST_PLUGIN_DIRECTORY";
|
|
17851
20833
|
function harnessPluginRoots(appDirectory2, sourceCheckout, environment = process.env) {
|
|
17852
|
-
const bundled = sourceCheckout ?
|
|
20834
|
+
const bundled = sourceCheckout ? path14.resolve(appDirectory2, "..", "..", "host-runtime", "dist", "plugins") : path14.join(appDirectory2, "plugins");
|
|
17853
20835
|
return [
|
|
17854
20836
|
bundled,
|
|
17855
|
-
environment[HARNESS_PLUGIN_DIRECTORY_ENV] ??
|
|
20837
|
+
environment[HARNESS_PLUGIN_DIRECTORY_ENV] ?? path14.join(dataDirectory(environment), "plugins")
|
|
17856
20838
|
];
|
|
17857
20839
|
}
|
|
17858
20840
|
var ConsoleHarnessError = class extends Error {
|
|
@@ -17918,20 +20900,20 @@ function createConsoleHarnesses(roots, environment = process.env) {
|
|
|
17918
20900
|
}
|
|
17919
20901
|
|
|
17920
20902
|
// packages/console-server/src/host-client.ts
|
|
17921
|
-
import { readdir as
|
|
17922
|
-
import
|
|
20903
|
+
import { readdir as readdir6, readFile as readFile7, realpath as realpath4, rm as rm6 } from "node:fs/promises";
|
|
20904
|
+
import path16 from "node:path";
|
|
17923
20905
|
|
|
17924
20906
|
// packages/console-server/src/diagnostics.ts
|
|
17925
|
-
import { open as
|
|
17926
|
-
import
|
|
20907
|
+
import { open as open5, readdir as readdir5, readFile as readFile6, stat as stat4 } from "node:fs/promises";
|
|
20908
|
+
import path15 from "node:path";
|
|
17927
20909
|
var MAX_DIAGNOSTIC_FILE_BYTES = 256 * 1024;
|
|
17928
20910
|
var MAX_LOG_TAIL_BYTES = 256 * 1024;
|
|
17929
20911
|
var LOG_FILE_PATTERN = /^host-runtime-\d{1,10}\.log(?:\.1)?$/u;
|
|
17930
20912
|
async function readBoundedJson(filePath) {
|
|
17931
20913
|
try {
|
|
17932
|
-
const metadata = await
|
|
20914
|
+
const metadata = await stat4(filePath);
|
|
17933
20915
|
if (!metadata.isFile() || metadata.size > MAX_DIAGNOSTIC_FILE_BYTES) return null;
|
|
17934
|
-
return JSON.parse(await
|
|
20916
|
+
return JSON.parse(await readFile6(filePath, "utf8"));
|
|
17935
20917
|
} catch {
|
|
17936
20918
|
return null;
|
|
17937
20919
|
}
|
|
@@ -17995,14 +20977,14 @@ function isLogFileName(name) {
|
|
|
17995
20977
|
async function listLogFiles(logsDirectory) {
|
|
17996
20978
|
let names;
|
|
17997
20979
|
try {
|
|
17998
|
-
names = await
|
|
20980
|
+
names = await readdir5(logsDirectory);
|
|
17999
20981
|
} catch {
|
|
18000
20982
|
return [];
|
|
18001
20983
|
}
|
|
18002
20984
|
const entries = await Promise.all(
|
|
18003
20985
|
names.filter(isLogFileName).map(async (name) => {
|
|
18004
20986
|
try {
|
|
18005
|
-
const metadata = await
|
|
20987
|
+
const metadata = await stat4(path15.join(logsDirectory, name));
|
|
18006
20988
|
return metadata.isFile() ? { name, size: metadata.size, modifiedAt: metadata.mtimeMs } : null;
|
|
18007
20989
|
} catch {
|
|
18008
20990
|
return null;
|
|
@@ -18016,7 +20998,7 @@ async function readLogTail(logsDirectory, name, maxBytes = MAX_LOG_TAIL_BYTES) {
|
|
|
18016
20998
|
const limit = Math.max(1, Math.min(maxBytes, MAX_LOG_TAIL_BYTES));
|
|
18017
20999
|
let handle;
|
|
18018
21000
|
try {
|
|
18019
|
-
handle = await
|
|
21001
|
+
handle = await open5(path15.join(logsDirectory, name), "r");
|
|
18020
21002
|
} catch {
|
|
18021
21003
|
return null;
|
|
18022
21004
|
}
|
|
@@ -18091,26 +21073,26 @@ function parseDescriptor(value) {
|
|
|
18091
21073
|
port: record4.port,
|
|
18092
21074
|
token: record4.token,
|
|
18093
21075
|
startedAt: record4.startedAt,
|
|
18094
|
-
...typeof record4.runtimePath === "string" &&
|
|
21076
|
+
...typeof record4.runtimePath === "string" && path16.isAbsolute(record4.runtimePath) ? { runtimePath: record4.runtimePath } : {}
|
|
18095
21077
|
};
|
|
18096
21078
|
}
|
|
18097
21079
|
async function findHost(descriptorDirectory, isAlive = processIsAlive2) {
|
|
18098
21080
|
let names;
|
|
18099
21081
|
try {
|
|
18100
|
-
names = await
|
|
21082
|
+
names = await readdir6(descriptorDirectory);
|
|
18101
21083
|
} catch {
|
|
18102
21084
|
return null;
|
|
18103
21085
|
}
|
|
18104
21086
|
const hosts = [];
|
|
18105
21087
|
for (const name of names.filter((candidate) => DESCRIPTOR_PATTERN.test(candidate))) {
|
|
18106
|
-
const filePath =
|
|
21088
|
+
const filePath = path16.join(descriptorDirectory, name);
|
|
18107
21089
|
try {
|
|
18108
|
-
const text = await
|
|
21090
|
+
const text = await readFile7(filePath, "utf8");
|
|
18109
21091
|
if (text.length > DESCRIPTOR_MAX_BYTES) continue;
|
|
18110
21092
|
const endpoint = parseDescriptor(JSON.parse(text));
|
|
18111
21093
|
if (!endpoint) continue;
|
|
18112
21094
|
if (isAlive(endpoint.pid)) hosts.push(endpoint);
|
|
18113
|
-
else await
|
|
21095
|
+
else await rm6(filePath, { force: true });
|
|
18114
21096
|
} catch {
|
|
18115
21097
|
continue;
|
|
18116
21098
|
}
|
|
@@ -18140,8 +21122,8 @@ function createConsoleHostClient(descriptorDirectory, options = {}) {
|
|
|
18140
21122
|
"The running Host does not identify its installation; restart it before updating"
|
|
18141
21123
|
);
|
|
18142
21124
|
const [hostDirectory, requestedDirectory] = await Promise.all([
|
|
18143
|
-
|
|
18144
|
-
|
|
21125
|
+
realpath4(path16.dirname(host.runtimePath)),
|
|
21126
|
+
realpath4(options.updateAppDirectory)
|
|
18145
21127
|
]).catch(() => {
|
|
18146
21128
|
throw new Error("The running Host installation could not be verified");
|
|
18147
21129
|
});
|
|
@@ -18188,12 +21170,12 @@ function createHostUpdates(host) {
|
|
|
18188
21170
|
// packages/console-server/src/installation.ts
|
|
18189
21171
|
import { execFile as execFile2 } from "node:child_process";
|
|
18190
21172
|
import { existsSync } from "node:fs";
|
|
18191
|
-
import { readFile as
|
|
18192
|
-
import
|
|
21173
|
+
import { readFile as readFile8 } from "node:fs/promises";
|
|
21174
|
+
import path17 from "node:path";
|
|
18193
21175
|
async function readDistribution(appDirectory2) {
|
|
18194
21176
|
try {
|
|
18195
21177
|
return parseDistributionMetadata(
|
|
18196
|
-
JSON.parse(await
|
|
21178
|
+
JSON.parse(await readFile8(path17.join(appDirectory2, "codexhost-distribution.json"), "utf8"))
|
|
18197
21179
|
);
|
|
18198
21180
|
} catch (error51) {
|
|
18199
21181
|
if (error51.code === "ENOENT") return null;
|
|
@@ -18201,17 +21183,17 @@ async function readDistribution(appDirectory2) {
|
|
|
18201
21183
|
}
|
|
18202
21184
|
}
|
|
18203
21185
|
function installedLauncherCandidates(appDirectory2, platform = process.platform) {
|
|
18204
|
-
const resourcesRoot =
|
|
21186
|
+
const resourcesRoot = path17.dirname(appDirectory2);
|
|
18205
21187
|
const suffix = platform === "win32" ? ".exe" : "";
|
|
18206
|
-
const candidates = [
|
|
18207
|
-
if (platform === "darwin" &&
|
|
18208
|
-
candidates.unshift(
|
|
21188
|
+
const candidates = [path17.join(resourcesRoot, "bin", `codexhost${suffix}`)];
|
|
21189
|
+
if (platform === "darwin" && path17.basename(resourcesRoot) === "Resources") {
|
|
21190
|
+
candidates.unshift(path17.join(path17.dirname(resourcesRoot), "MacOS", "codexhost"));
|
|
18209
21191
|
}
|
|
18210
21192
|
return candidates;
|
|
18211
21193
|
}
|
|
18212
21194
|
function resolveLauncherExecutable(appDirectory2, environment = process.env, platform = process.platform, exists = existsSync) {
|
|
18213
21195
|
const configured = environment[LAUNCHER_EXECUTABLE_ENV];
|
|
18214
|
-
if (configured &&
|
|
21196
|
+
if (configured && path17.isAbsolute(configured) && exists(configured)) return configured;
|
|
18215
21197
|
return installedLauncherCandidates(appDirectory2, platform).find(exists) ?? null;
|
|
18216
21198
|
}
|
|
18217
21199
|
async function resolveInstallation(appDirectory2, environment = process.env) {
|
|
@@ -18253,7 +21235,7 @@ function launchCommand(installation, environment = process.env) {
|
|
|
18253
21235
|
if (installation.distribution?.distribution === "npm") {
|
|
18254
21236
|
const node = environment.CODEXHOST_NPM_NODE_PATH;
|
|
18255
21237
|
const wrapper = environment.CODEXHOST_NPM_LAUNCHER_PATH;
|
|
18256
|
-
if (node && wrapper &&
|
|
21238
|
+
if (node && wrapper && path17.isAbsolute(node) && path17.isAbsolute(wrapper)) {
|
|
18257
21239
|
return { command: node, args: [wrapper] };
|
|
18258
21240
|
}
|
|
18259
21241
|
return null;
|
|
@@ -18263,12 +21245,12 @@ function launchCommand(installation, environment = process.env) {
|
|
|
18263
21245
|
|
|
18264
21246
|
// packages/console-server/src/open.ts
|
|
18265
21247
|
import { spawn as spawn4 } from "node:child_process";
|
|
18266
|
-
import { stat as
|
|
18267
|
-
import
|
|
21248
|
+
import { stat as stat5 } from "node:fs/promises";
|
|
21249
|
+
import path22 from "node:path";
|
|
18268
21250
|
|
|
18269
21251
|
// packages/console-server/src/page.ts
|
|
18270
|
-
import { readFile as
|
|
18271
|
-
import
|
|
21252
|
+
import { readFile as readFile9 } from "node:fs/promises";
|
|
21253
|
+
import path18 from "node:path";
|
|
18272
21254
|
var CONSOLE_PAGE_HTML = `<!doctype html>
|
|
18273
21255
|
<html lang="en">
|
|
18274
21256
|
<head>
|
|
@@ -18289,14 +21271,14 @@ var MISSING_BUNDLE_SCRIPT = `document.body.textContent = "codexhost console asse
|
|
|
18289
21271
|
`;
|
|
18290
21272
|
function consoleBundleCandidates(appDirectory2) {
|
|
18291
21273
|
return [
|
|
18292
|
-
|
|
18293
|
-
|
|
21274
|
+
path18.join(appDirectory2, "console-web.js"),
|
|
21275
|
+
path18.resolve(appDirectory2, "..", "..", "renderer-extension", "dist", "console.js")
|
|
18294
21276
|
];
|
|
18295
21277
|
}
|
|
18296
21278
|
async function loadConsoleBundle(appDirectory2) {
|
|
18297
21279
|
for (const candidate of consoleBundleCandidates(appDirectory2)) {
|
|
18298
21280
|
try {
|
|
18299
|
-
return await
|
|
21281
|
+
return await readFile9(candidate, "utf8");
|
|
18300
21282
|
} catch {
|
|
18301
21283
|
continue;
|
|
18302
21284
|
}
|
|
@@ -18475,8 +21457,94 @@ function issueUrl(report, home) {
|
|
|
18475
21457
|
return url2;
|
|
18476
21458
|
}
|
|
18477
21459
|
|
|
21460
|
+
// packages/console-server/src/extensions.ts
|
|
21461
|
+
var INSTALL = "POST /api/extensions/install";
|
|
21462
|
+
var UNINSTALL = "POST /api/extensions/uninstall";
|
|
21463
|
+
var CATALOG = "GET /api/extensions/catalog";
|
|
21464
|
+
var ENABLE = "POST /api/extensions/enable";
|
|
21465
|
+
var DISABLE = "POST /api/extensions/disable";
|
|
21466
|
+
var RECOVERY = "POST /api/extensions/disable-all-and-reload";
|
|
21467
|
+
async function extensionsRoute(route, body, dataDirectory2, query, environment = process.env) {
|
|
21468
|
+
if (route === "GET /api/extensions")
|
|
21469
|
+
return { status: 200, body: await listDesktopExtensions(dataDirectory2) };
|
|
21470
|
+
if (route === CATALOG) {
|
|
21471
|
+
const value = query.get("forceRefresh");
|
|
21472
|
+
const params = desktopExtensionsCatalogParamsSchema.safeParse(
|
|
21473
|
+
value === null ? {} : { forceRefresh: value === "true" ? true : value === "false" ? false : value }
|
|
21474
|
+
);
|
|
21475
|
+
if (!params.success) return { status: 400, body: { error: "Invalid forceRefresh" } };
|
|
21476
|
+
return {
|
|
21477
|
+
status: 200,
|
|
21478
|
+
body: await fetchDesktopExtensionCatalog({ ...params.data, environment })
|
|
21479
|
+
};
|
|
21480
|
+
}
|
|
21481
|
+
if (route === INSTALL || route === UNINSTALL) {
|
|
21482
|
+
try {
|
|
21483
|
+
if (route === INSTALL) {
|
|
21484
|
+
const params2 = desktopExtensionsInstallParamsSchema.safeParse(body);
|
|
21485
|
+
if (!params2.success)
|
|
21486
|
+
return { status: 400, body: { error: "Invalid extension install parameters" } };
|
|
21487
|
+
return {
|
|
21488
|
+
status: 200,
|
|
21489
|
+
body: await installDesktopExtension(dataDirectory2, params2.data, environment)
|
|
21490
|
+
};
|
|
21491
|
+
}
|
|
21492
|
+
const params = desktopExtensionsUninstallParamsSchema.safeParse(body);
|
|
21493
|
+
if (!params.success) return { status: 400, body: { error: "Invalid extension ID" } };
|
|
21494
|
+
return {
|
|
21495
|
+
status: 200,
|
|
21496
|
+
body: await uninstallDesktopExtension({ dataDir: dataDirectory2, id: params.data.id })
|
|
21497
|
+
};
|
|
21498
|
+
} catch (error51) {
|
|
21499
|
+
return error51 instanceof DesktopExtensionPackageError ? { status: 400, body: { error: error51.message } } : { status: 500, body: { error: "Could not install or uninstall Desktop extension" } };
|
|
21500
|
+
}
|
|
21501
|
+
}
|
|
21502
|
+
if (route !== ENABLE && route !== DISABLE && route !== RECOVERY) return;
|
|
21503
|
+
try {
|
|
21504
|
+
const result = await (async () => {
|
|
21505
|
+
if (route === RECOVERY) {
|
|
21506
|
+
const params2 = desktopExtensionsRecoveryParamsSchema.safeParse(body);
|
|
21507
|
+
if (!params2.success) throw new DesktopExtensionSelectionError("Invalid expectedRevision");
|
|
21508
|
+
return updateDesktopExtensionSelection(dataDirectory2, {
|
|
21509
|
+
...params2.data,
|
|
21510
|
+
action: "recover"
|
|
21511
|
+
});
|
|
21512
|
+
}
|
|
21513
|
+
const params = desktopExtensionSelectionParamsSchema.safeParse(body);
|
|
21514
|
+
if (!params.success)
|
|
21515
|
+
throw new DesktopExtensionSelectionError("Invalid extension ID or expectedRevision");
|
|
21516
|
+
return updateDesktopExtensionSelection(dataDirectory2, {
|
|
21517
|
+
...params.data,
|
|
21518
|
+
action: route === ENABLE ? "enable" : "disable"
|
|
21519
|
+
});
|
|
21520
|
+
})();
|
|
21521
|
+
switch (result.state) {
|
|
21522
|
+
case "saved":
|
|
21523
|
+
return { status: 200, body: { configuration: result.configuration } };
|
|
21524
|
+
case "slot-conflict":
|
|
21525
|
+
return {
|
|
21526
|
+
status: 409,
|
|
21527
|
+
body: {
|
|
21528
|
+
error: `Slot already occupied by ${result.conflictWith}`,
|
|
21529
|
+
conflictWith: result.conflictWith
|
|
21530
|
+
}
|
|
21531
|
+
};
|
|
21532
|
+
case "revision-conflict":
|
|
21533
|
+
return {
|
|
21534
|
+
status: 409,
|
|
21535
|
+
body: {
|
|
21536
|
+
error: "Extension selection changed; refresh and try again",
|
|
21537
|
+
revision: result.revision
|
|
21538
|
+
}
|
|
21539
|
+
};
|
|
21540
|
+
}
|
|
21541
|
+
} catch (error51) {
|
|
21542
|
+
return error51 instanceof DesktopExtensionSelectionError ? { status: 400, body: { error: error51.message } } : { status: 500, body: { error: "Could not save Desktop extension selection" } };
|
|
21543
|
+
}
|
|
21544
|
+
}
|
|
21545
|
+
|
|
18478
21546
|
// packages/console-server/src/updates.ts
|
|
18479
|
-
import
|
|
21547
|
+
import path19 from "node:path";
|
|
18480
21548
|
var ERROR_MAX_LENGTH = 500;
|
|
18481
21549
|
var ConsoleUpdateError = class extends Error {
|
|
18482
21550
|
constructor(code, message) {
|
|
@@ -18510,13 +21578,13 @@ function installationKind(metadata) {
|
|
|
18510
21578
|
}
|
|
18511
21579
|
function absoluteEnvironmentPath(environment, name) {
|
|
18512
21580
|
const value = environment[name];
|
|
18513
|
-
if (!value || !
|
|
21581
|
+
if (!value || !path19.isAbsolute(value)) {
|
|
18514
21582
|
throw new ConsoleUpdateError(
|
|
18515
21583
|
"unsupported",
|
|
18516
21584
|
`${name} is unavailable; run 'codexhost console' from the npm command to update`
|
|
18517
21585
|
);
|
|
18518
21586
|
}
|
|
18519
|
-
return
|
|
21587
|
+
return path19.normalize(value);
|
|
18520
21588
|
}
|
|
18521
21589
|
function createConsoleUpdates(options) {
|
|
18522
21590
|
const environment = options.environment ?? process.env;
|
|
@@ -18560,13 +21628,13 @@ function createConsoleUpdates(options) {
|
|
|
18560
21628
|
}
|
|
18561
21629
|
}
|
|
18562
21630
|
async function prepare(metadata, target2, release, onPrepared) {
|
|
18563
|
-
const resourcesRoot =
|
|
21631
|
+
const resourcesRoot = path19.dirname(target2.appDirectory);
|
|
18564
21632
|
const common = {
|
|
18565
21633
|
version: release.version,
|
|
18566
21634
|
launcherPid: options.processId ?? process.pid,
|
|
18567
21635
|
launcherExecutable: options.processExecutable ?? process.execPath,
|
|
18568
21636
|
runtimeDescriptorPath: target2.runtimeDescriptorPath,
|
|
18569
|
-
updaterExecutable:
|
|
21637
|
+
updaterExecutable: path19.join(
|
|
18570
21638
|
resourcesRoot,
|
|
18571
21639
|
"libexec",
|
|
18572
21640
|
platform === "win32" ? "codexhost-updater.exe" : "codexhost-updater"
|
|
@@ -18603,13 +21671,13 @@ function createConsoleUpdates(options) {
|
|
|
18603
21671
|
if (kind === "windows-installer") {
|
|
18604
21672
|
return manager.prepareWindowsInstaller({ ...common, artifact, installRoot: resourcesRoot });
|
|
18605
21673
|
}
|
|
18606
|
-
const appPath =
|
|
21674
|
+
const appPath = path19.dirname(path19.dirname(resourcesRoot));
|
|
18607
21675
|
return manager.prepareMacOsDmg({ ...common, artifact, appPath });
|
|
18608
21676
|
}
|
|
18609
21677
|
return Object.freeze({
|
|
18610
21678
|
async check(target2, signal) {
|
|
18611
21679
|
const metadata = target2.distribution;
|
|
18612
|
-
const runtime = metadata ? null : await readRuntimeMetadata(
|
|
21680
|
+
const runtime = metadata ? null : await readRuntimeMetadata(path19.join(target2.appDirectory, "main.js"), environment).catch(
|
|
18613
21681
|
() => null
|
|
18614
21682
|
);
|
|
18615
21683
|
const empty = {
|
|
@@ -18660,7 +21728,7 @@ function createConsoleUpdates(options) {
|
|
|
18660
21728
|
if (!metadata) {
|
|
18661
21729
|
throw new ConsoleUpdateError("unsupported", "A source checkout cannot update itself");
|
|
18662
21730
|
}
|
|
18663
|
-
if (!target2.runtimeDescriptorPath || !
|
|
21731
|
+
if (!target2.runtimeDescriptorPath || !path19.isAbsolute(target2.runtimeDescriptorPath)) {
|
|
18664
21732
|
throw new ConsoleUpdateError("unsupported", "The Launcher runtime path is unavailable");
|
|
18665
21733
|
}
|
|
18666
21734
|
if (handedOff) {
|
|
@@ -18731,12 +21799,12 @@ function createConsoleUpdates(options) {
|
|
|
18731
21799
|
// packages/console-server/src/services.ts
|
|
18732
21800
|
import { spawn as spawn2 } from "node:child_process";
|
|
18733
21801
|
import { existsSync as existsSync2 } from "node:fs";
|
|
18734
|
-
import
|
|
21802
|
+
import path20 from "node:path";
|
|
18735
21803
|
function serviceCommand(installation, action, options = {}) {
|
|
18736
21804
|
if (!installation.launcherExecutable) throw new Error("codexhost Launcher was not found");
|
|
18737
21805
|
const resource = (packaged, source) => {
|
|
18738
|
-
const bundled =
|
|
18739
|
-
return existsSync2(bundled) ? bundled :
|
|
21806
|
+
const bundled = path20.join(installation.appDirectory, packaged);
|
|
21807
|
+
return existsSync2(bundled) ? bundled : path20.resolve(installation.appDirectory, "..", "..", source, "dist", "main.js");
|
|
18740
21808
|
};
|
|
18741
21809
|
return {
|
|
18742
21810
|
command: installation.launcherExecutable,
|
|
@@ -18773,8 +21841,8 @@ function runServiceCommand(command2, args, environment) {
|
|
|
18773
21841
|
}
|
|
18774
21842
|
|
|
18775
21843
|
// packages/console-server/src/web-client.ts
|
|
18776
|
-
import { readFile as
|
|
18777
|
-
import
|
|
21844
|
+
import { readFile as readFile10 } from "node:fs/promises";
|
|
21845
|
+
import path21 from "node:path";
|
|
18778
21846
|
var WEB_CONNECTION_METHODS = [
|
|
18779
21847
|
"codexhost/accessTokenGet",
|
|
18780
21848
|
"codexhost/accessTokenRegenerate",
|
|
@@ -18790,7 +21858,7 @@ async function webConnectionRequest(dataDirectory2, method, args) {
|
|
|
18790
21858
|
let token;
|
|
18791
21859
|
try {
|
|
18792
21860
|
const ready = JSON.parse(
|
|
18793
|
-
await
|
|
21861
|
+
await readFile10(path21.join(dataDirectory2, "web-service-ready.json"), "utf8")
|
|
18794
21862
|
);
|
|
18795
21863
|
if (!processIsAlive2(ready.pid) || !processIsAlive2(ready.web_pid)) throw new Error();
|
|
18796
21864
|
const login = new URL(ready.loginUrl);
|
|
@@ -18822,6 +21890,7 @@ async function webConnectionRequest(dataDirectory2, method, args) {
|
|
|
18822
21890
|
// packages/console-server/src/server.ts
|
|
18823
21891
|
var CONSOLE_SERVICE = "codexhost-console";
|
|
18824
21892
|
var MAX_BODY_BYTES = 16 * 1024;
|
|
21893
|
+
var MAX_EXTENSION_INSTALL_BODY_BYTES = DESKTOP_EXTENSION_ZIP_MAX_BASE64_LENGTH + MAX_BODY_BYTES;
|
|
18825
21894
|
var INSPECT_CACHE_MS = 2e3;
|
|
18826
21895
|
var SECURITY_HEADERS = {
|
|
18827
21896
|
"cache-control": "no-store",
|
|
@@ -18847,13 +21916,13 @@ function sendJson(response, status, value) {
|
|
|
18847
21916
|
}
|
|
18848
21917
|
var RequestBodyError = class extends Error {
|
|
18849
21918
|
};
|
|
18850
|
-
async function readJsonBody(request) {
|
|
21919
|
+
async function readJsonBody(request, limit = MAX_BODY_BYTES) {
|
|
18851
21920
|
let size = 0;
|
|
18852
21921
|
const chunks = [];
|
|
18853
|
-
for await (const chunk of request) {
|
|
21922
|
+
for await (const chunk of request.iterator({ destroyOnReturn: false })) {
|
|
18854
21923
|
const buffer = chunk;
|
|
18855
21924
|
size += buffer.length;
|
|
18856
|
-
if (size >
|
|
21925
|
+
if (size > limit) throw new RequestBodyError("Request body is too large");
|
|
18857
21926
|
chunks.push(buffer);
|
|
18858
21927
|
}
|
|
18859
21928
|
if (size === 0) return {};
|
|
@@ -19070,12 +22139,27 @@ function startConsoleServer(options) {
|
|
|
19070
22139
|
return;
|
|
19071
22140
|
}
|
|
19072
22141
|
try {
|
|
19073
|
-
body = await readJsonBody(
|
|
22142
|
+
body = await readJsonBody(
|
|
22143
|
+
request,
|
|
22144
|
+
route === INSTALL ? MAX_EXTENSION_INSTALL_BODY_BYTES : MAX_BODY_BYTES
|
|
22145
|
+
);
|
|
19074
22146
|
} catch (error51) {
|
|
22147
|
+
if (!request.complete) response.setHeader("connection", "close");
|
|
19075
22148
|
sendJson(response, 400, { error: error51.message });
|
|
19076
22149
|
return;
|
|
19077
22150
|
}
|
|
19078
22151
|
}
|
|
22152
|
+
const extensions = await extensionsRoute(
|
|
22153
|
+
route,
|
|
22154
|
+
body,
|
|
22155
|
+
options.paths.dataDirectory,
|
|
22156
|
+
url2.searchParams,
|
|
22157
|
+
options.environment
|
|
22158
|
+
);
|
|
22159
|
+
if (extensions) {
|
|
22160
|
+
sendJson(response, extensions.status, extensions.body);
|
|
22161
|
+
return;
|
|
22162
|
+
}
|
|
19079
22163
|
if (route === "POST /api/shutdown") {
|
|
19080
22164
|
sendJson(response, 200, { ok: true });
|
|
19081
22165
|
if (stopping) shutdownRequested = true;
|
|
@@ -19313,10 +22397,10 @@ async function stopConsole(environment = process.env) {
|
|
|
19313
22397
|
return true;
|
|
19314
22398
|
}
|
|
19315
22399
|
async function consoleBuildId(entryPath2, environment = process.env) {
|
|
19316
|
-
const files = [entryPath2, ...consoleBundleCandidates(
|
|
22400
|
+
const files = [entryPath2, ...consoleBundleCandidates(path22.dirname(entryPath2))];
|
|
19317
22401
|
const parts = [];
|
|
19318
22402
|
for (const file2 of files) {
|
|
19319
|
-
const metadata = await
|
|
22403
|
+
const metadata = await stat5(file2).catch(() => null);
|
|
19320
22404
|
if (metadata) parts.push(`${Math.trunc(metadata.mtimeMs)}-${metadata.size}`);
|
|
19321
22405
|
}
|
|
19322
22406
|
const runtime = await readRuntimeMetadata(entryPath2, environment).catch(() => null);
|
|
@@ -19422,7 +22506,7 @@ async function updateFromCommand(appDirectory2, arguments_) {
|
|
|
19422
22506
|
var IDLE_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
19423
22507
|
var HANDOFF_EXIT_DELAY_MS = 500;
|
|
19424
22508
|
var entryPath = fileURLToPath(import.meta.url);
|
|
19425
|
-
var appDirectory =
|
|
22509
|
+
var appDirectory = path23.dirname(entryPath);
|
|
19426
22510
|
function usage() {
|
|
19427
22511
|
console.error(
|
|
19428
22512
|
"usage: console-server open [--no-browser] | console-server ensure | console-server serve | console-server stop | console-server update"
|
|
@@ -19470,7 +22554,7 @@ function parseOpenArguments(arguments_) {
|
|
|
19470
22554
|
}
|
|
19471
22555
|
return parsed;
|
|
19472
22556
|
}
|
|
19473
|
-
async function
|
|
22557
|
+
async function open6(arguments_) {
|
|
19474
22558
|
const parsed = parseOpenArguments(arguments_);
|
|
19475
22559
|
const installation = await resolveInstallation(appDirectory);
|
|
19476
22560
|
const url2 = await openConsole({
|
|
@@ -19491,7 +22575,7 @@ async function stop(arguments_) {
|
|
|
19491
22575
|
process.exitCode = await stopConsole() ? 0 : 3;
|
|
19492
22576
|
}
|
|
19493
22577
|
var [command, ...rest] = process.argv.slice(2);
|
|
19494
|
-
var run = command === "serve" ? serve() : command === "open" ?
|
|
22578
|
+
var run = command === "serve" ? serve() : command === "open" ? open6(rest) : command === "ensure" ? ensure(rest) : command === "stop" ? stop(rest) : command === "update" ? updateFromCommand(appDirectory, rest) : usage();
|
|
19495
22579
|
run.catch((error51) => {
|
|
19496
22580
|
console.error(`codexhost console: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
19497
22581
|
process.exit(1);
|