@codexhost/cli-darwin-x64 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
|
@@ -1,12 +1,1624 @@
|
|
|
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 constants = __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 (constants.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(path7, 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(path7, 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 rename3(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(rename3, fs$rename);
|
|
130
|
+
return rename3;
|
|
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(path7, mode, callback) {
|
|
169
|
+
fs2.open(
|
|
170
|
+
path7,
|
|
171
|
+
constants.O_WRONLY | constants.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(path7, mode) {
|
|
187
|
+
var fd = fs2.openSync(path7, constants.O_WRONLY | constants.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 (constants.hasOwnProperty("O_SYMLINK") && fs2.futimes) {
|
|
208
|
+
fs2.lutimes = function(path7, at, mt, cb) {
|
|
209
|
+
fs2.open(path7, constants.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(path7, at, mt) {
|
|
222
|
+
var fd = fs2.openSync(path7, constants.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(path7, options) {
|
|
341
|
+
if (!(this instanceof ReadStream)) return new ReadStream(path7, options);
|
|
342
|
+
Stream.call(this);
|
|
343
|
+
var self = this;
|
|
344
|
+
this.path = path7;
|
|
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(path7, options) {
|
|
390
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path7, options);
|
|
391
|
+
Stream.call(this);
|
|
392
|
+
this.path = path7;
|
|
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 = createReadStream;
|
|
532
|
+
fs2.createWriteStream = createWriteStream;
|
|
533
|
+
var fs$readFile = fs2.readFile;
|
|
534
|
+
fs2.readFile = readFile3;
|
|
535
|
+
function readFile3(path7, options, cb) {
|
|
536
|
+
if (typeof options === "function")
|
|
537
|
+
cb = options, options = null;
|
|
538
|
+
return go$readFile(path7, options, cb);
|
|
539
|
+
function go$readFile(path8, options2, cb2, startTime) {
|
|
540
|
+
return fs$readFile(path8, options2, function(err) {
|
|
541
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
542
|
+
enqueue([go$readFile, [path8, 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 = writeFile3;
|
|
552
|
+
function writeFile3(path7, data, options, cb) {
|
|
553
|
+
if (typeof options === "function")
|
|
554
|
+
cb = options, options = null;
|
|
555
|
+
return go$writeFile(path7, data, options, cb);
|
|
556
|
+
function go$writeFile(path8, data2, options2, cb2, startTime) {
|
|
557
|
+
return fs$writeFile(path8, data2, options2, function(err) {
|
|
558
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
559
|
+
enqueue([go$writeFile, [path8, 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(path7, data, options, cb) {
|
|
571
|
+
if (typeof options === "function")
|
|
572
|
+
cb = options, options = null;
|
|
573
|
+
return go$appendFile(path7, data, options, cb);
|
|
574
|
+
function go$appendFile(path8, data2, options2, cb2, startTime) {
|
|
575
|
+
return fs$appendFile(path8, data2, options2, function(err) {
|
|
576
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
577
|
+
enqueue([go$appendFile, [path8, 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 = copyFile;
|
|
588
|
+
function copyFile(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 = readdir2;
|
|
607
|
+
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
608
|
+
function readdir2(path7, options, cb) {
|
|
609
|
+
if (typeof options === "function")
|
|
610
|
+
cb = options, options = null;
|
|
611
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path8, options2, cb2, startTime) {
|
|
612
|
+
return fs$readdir(path8, fs$readdirCallback(
|
|
613
|
+
path8,
|
|
614
|
+
options2,
|
|
615
|
+
cb2,
|
|
616
|
+
startTime
|
|
617
|
+
));
|
|
618
|
+
} : function go$readdir2(path8, options2, cb2, startTime) {
|
|
619
|
+
return fs$readdir(path8, options2, fs$readdirCallback(
|
|
620
|
+
path8,
|
|
621
|
+
options2,
|
|
622
|
+
cb2,
|
|
623
|
+
startTime
|
|
624
|
+
));
|
|
625
|
+
};
|
|
626
|
+
return go$readdir(path7, options, cb);
|
|
627
|
+
function fs$readdirCallback(path8, options2, cb2, startTime) {
|
|
628
|
+
return function(err, files) {
|
|
629
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
630
|
+
enqueue([
|
|
631
|
+
go$readdir,
|
|
632
|
+
[path8, 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(path7, 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
|
+
open2(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(path7, 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
|
+
open2(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 createReadStream(path7, options) {
|
|
742
|
+
return new fs2.ReadStream(path7, options);
|
|
743
|
+
}
|
|
744
|
+
function createWriteStream(path7, options) {
|
|
745
|
+
return new fs2.WriteStream(path7, options);
|
|
746
|
+
}
|
|
747
|
+
var fs$open = fs2.open;
|
|
748
|
+
fs2.open = open2;
|
|
749
|
+
function open2(path7, flags, mode, cb) {
|
|
750
|
+
if (typeof mode === "function")
|
|
751
|
+
cb = mode, mode = null;
|
|
752
|
+
return go$open(path7, flags, mode, cb);
|
|
753
|
+
function go$open(path8, flags2, mode2, cb2, startTime) {
|
|
754
|
+
return fs$open(path8, flags2, mode2, function(err, fd) {
|
|
755
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
756
|
+
enqueue([go$open, [path8, 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, stat3) => {
|
|
1248
|
+
if (err) {
|
|
1249
|
+
return callback(err);
|
|
1250
|
+
}
|
|
1251
|
+
callback(null, stat3.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, stat3) => {
|
|
1260
|
+
if (err2) {
|
|
1261
|
+
return callback(err2);
|
|
1262
|
+
}
|
|
1263
|
+
const precision = stat3.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
|
|
1264
|
+
Object.defineProperty(fs, cacheSymbol, { value: precision });
|
|
1265
|
+
callback(null, stat3.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 path7 = __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, path7.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, stat3) => {
|
|
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(stat3, 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(stat3, options) {
|
|
1339
|
+
return stat3.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, stat3) => {
|
|
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() === stat3.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 check2(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, stat3) => {
|
|
1492
|
+
if (err2) {
|
|
1493
|
+
return err2.code === "ENOENT" ? callback(null, false) : callback(err2);
|
|
1494
|
+
}
|
|
1495
|
+
return callback(null, !isLockStale(stat3, 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 = check2;
|
|
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 check2(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 = check2;
|
|
1615
|
+
module.exports.checkSync = checkSync;
|
|
1616
|
+
}
|
|
1617
|
+
});
|
|
6
1618
|
|
|
7
1619
|
// packages/desktop-control/src/production-controller.ts
|
|
8
|
-
import { readFile } from "node:fs/promises";
|
|
9
|
-
import
|
|
1620
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
1621
|
+
import path6 from "node:path";
|
|
10
1622
|
|
|
11
1623
|
// packages/desktop-control/src/renderer-local-page.ts
|
|
12
1624
|
import { randomUUID } from "node:crypto";
|
|
@@ -71,12 +1683,12 @@ var CdpConnectionClosedError = class extends Error {
|
|
|
71
1683
|
this.name = "CdpConnectionClosedError";
|
|
72
1684
|
}
|
|
73
1685
|
};
|
|
74
|
-
function cdpExceptionMessage(details,
|
|
1686
|
+
function cdpExceptionMessage(details, fallback2) {
|
|
75
1687
|
const exception = details.exception;
|
|
76
1688
|
if (isRecord(exception) && typeof exception.description === "string" && exception.description) {
|
|
77
1689
|
return exception.description;
|
|
78
1690
|
}
|
|
79
|
-
return typeof details.text === "string" && details.text ? details.text :
|
|
1691
|
+
return typeof details.text === "string" && details.text ? details.text : fallback2;
|
|
80
1692
|
}
|
|
81
1693
|
function isRecord(value) {
|
|
82
1694
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -431,6 +2043,8 @@ async function rendererRemoteSession(target2, operation) {
|
|
|
431
2043
|
})
|
|
432
2044
|
);
|
|
433
2045
|
const threadId = operation.threadId;
|
|
2046
|
+
if (operation.kind === "usage")
|
|
2047
|
+
return read(() => manager.sendRequest("codexhost/thread/usage/inspect", { threadId }));
|
|
434
2048
|
if (operation.kind === "status") {
|
|
435
2049
|
const result = await read(
|
|
436
2050
|
() => manager.sendRequest("thread/read", {
|
|
@@ -1464,10 +3078,10 @@ function mergeDefs(...defs) {
|
|
|
1464
3078
|
function cloneDef(schema) {
|
|
1465
3079
|
return mergeDefs(schema._zod.def);
|
|
1466
3080
|
}
|
|
1467
|
-
function getElementAtPath(obj,
|
|
1468
|
-
if (!
|
|
3081
|
+
function getElementAtPath(obj, path7) {
|
|
3082
|
+
if (!path7)
|
|
1469
3083
|
return obj;
|
|
1470
|
-
return
|
|
3084
|
+
return path7.reduce((acc, key) => acc?.[key], obj);
|
|
1471
3085
|
}
|
|
1472
3086
|
function promiseAllObject(promisesObj) {
|
|
1473
3087
|
const keys = Object.keys(promisesObj);
|
|
@@ -1876,11 +3490,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
1876
3490
|
}
|
|
1877
3491
|
return false;
|
|
1878
3492
|
}
|
|
1879
|
-
function prefixIssues(
|
|
3493
|
+
function prefixIssues(path7, issues) {
|
|
1880
3494
|
return issues.map((iss) => {
|
|
1881
3495
|
var _a3;
|
|
1882
3496
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
1883
|
-
iss.path.unshift(
|
|
3497
|
+
iss.path.unshift(path7);
|
|
1884
3498
|
return iss;
|
|
1885
3499
|
});
|
|
1886
3500
|
}
|
|
@@ -2027,16 +3641,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
2027
3641
|
}
|
|
2028
3642
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
2029
3643
|
const fieldErrors = { _errors: [] };
|
|
2030
|
-
const processError = (error52,
|
|
3644
|
+
const processError = (error52, path7 = []) => {
|
|
2031
3645
|
for (const issue2 of error52.issues) {
|
|
2032
3646
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
2033
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
3647
|
+
issue2.errors.map((issues) => processError({ issues }, [...path7, ...issue2.path]));
|
|
2034
3648
|
} else if (issue2.code === "invalid_key") {
|
|
2035
|
-
processError({ issues: issue2.issues }, [...
|
|
3649
|
+
processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
|
|
2036
3650
|
} else if (issue2.code === "invalid_element") {
|
|
2037
|
-
processError({ issues: issue2.issues }, [...
|
|
3651
|
+
processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
|
|
2038
3652
|
} else {
|
|
2039
|
-
const fullpath = [...
|
|
3653
|
+
const fullpath = [...path7, ...issue2.path];
|
|
2040
3654
|
if (fullpath.length === 0) {
|
|
2041
3655
|
fieldErrors._errors.push(mapper(issue2));
|
|
2042
3656
|
} else {
|
|
@@ -2063,17 +3677,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
2063
3677
|
}
|
|
2064
3678
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
2065
3679
|
const result = { errors: [] };
|
|
2066
|
-
const processError = (error52,
|
|
3680
|
+
const processError = (error52, path7 = []) => {
|
|
2067
3681
|
var _a3, _b;
|
|
2068
3682
|
for (const issue2 of error52.issues) {
|
|
2069
3683
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
2070
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
3684
|
+
issue2.errors.map((issues) => processError({ issues }, [...path7, ...issue2.path]));
|
|
2071
3685
|
} else if (issue2.code === "invalid_key") {
|
|
2072
|
-
processError({ issues: issue2.issues }, [...
|
|
3686
|
+
processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
|
|
2073
3687
|
} else if (issue2.code === "invalid_element") {
|
|
2074
|
-
processError({ issues: issue2.issues }, [...
|
|
3688
|
+
processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
|
|
2075
3689
|
} else {
|
|
2076
|
-
const fullpath = [...
|
|
3690
|
+
const fullpath = [...path7, ...issue2.path];
|
|
2077
3691
|
if (fullpath.length === 0) {
|
|
2078
3692
|
result.errors.push(mapper(issue2));
|
|
2079
3693
|
continue;
|
|
@@ -2105,8 +3719,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
2105
3719
|
}
|
|
2106
3720
|
function toDotPath(_path) {
|
|
2107
3721
|
const segs = [];
|
|
2108
|
-
const
|
|
2109
|
-
for (const seg of
|
|
3722
|
+
const path7 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
3723
|
+
for (const seg of path7) {
|
|
2110
3724
|
if (typeof seg === "number")
|
|
2111
3725
|
segs.push(`[${seg}]`);
|
|
2112
3726
|
else if (typeof seg === "symbol")
|
|
@@ -14798,13 +16412,13 @@ function resolveRef(ref, ctx) {
|
|
|
14798
16412
|
if (!ref.startsWith("#")) {
|
|
14799
16413
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
14800
16414
|
}
|
|
14801
|
-
const
|
|
14802
|
-
if (
|
|
16415
|
+
const path7 = ref.slice(1).split("/").filter(Boolean);
|
|
16416
|
+
if (path7.length === 0) {
|
|
14803
16417
|
return ctx.rootSchema;
|
|
14804
16418
|
}
|
|
14805
16419
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
14806
|
-
if (
|
|
14807
|
-
const key =
|
|
16420
|
+
if (path7[0] === defsKey) {
|
|
16421
|
+
const key = path7[1];
|
|
14808
16422
|
if (!key || !ctx.defs[key]) {
|
|
14809
16423
|
throw new Error(`Reference not found: ${ref}`);
|
|
14810
16424
|
}
|
|
@@ -15193,24 +16807,105 @@ __export(coerce_exports, {
|
|
|
15193
16807
|
number: () => number3,
|
|
15194
16808
|
string: () => string3
|
|
15195
16809
|
});
|
|
15196
|
-
function string3(params) {
|
|
15197
|
-
return _coercedString(ZodString, params);
|
|
15198
|
-
}
|
|
15199
|
-
function number3(params) {
|
|
15200
|
-
return _coercedNumber(ZodNumber, params);
|
|
15201
|
-
}
|
|
15202
|
-
function boolean3(params) {
|
|
15203
|
-
return _coercedBoolean(ZodBoolean, params);
|
|
15204
|
-
}
|
|
15205
|
-
function bigint3(params) {
|
|
15206
|
-
return _coercedBigint(ZodBigInt, params);
|
|
15207
|
-
}
|
|
15208
|
-
function date4(params) {
|
|
15209
|
-
return _coercedDate(ZodDate, params);
|
|
15210
|
-
}
|
|
15211
|
-
|
|
15212
|
-
// node_modules/zod/v4/classic/external.js
|
|
15213
|
-
config(en_default());
|
|
16810
|
+
function string3(params) {
|
|
16811
|
+
return _coercedString(ZodString, params);
|
|
16812
|
+
}
|
|
16813
|
+
function number3(params) {
|
|
16814
|
+
return _coercedNumber(ZodNumber, params);
|
|
16815
|
+
}
|
|
16816
|
+
function boolean3(params) {
|
|
16817
|
+
return _coercedBoolean(ZodBoolean, params);
|
|
16818
|
+
}
|
|
16819
|
+
function bigint3(params) {
|
|
16820
|
+
return _coercedBigint(ZodBigInt, params);
|
|
16821
|
+
}
|
|
16822
|
+
function date4(params) {
|
|
16823
|
+
return _coercedDate(ZodDate, params);
|
|
16824
|
+
}
|
|
16825
|
+
|
|
16826
|
+
// node_modules/zod/v4/classic/external.js
|
|
16827
|
+
config(en_default());
|
|
16828
|
+
|
|
16829
|
+
// packages/shared-contracts/dist/ids.js
|
|
16830
|
+
var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
16831
|
+
message: "Identifier must not be empty or whitespace"
|
|
16832
|
+
});
|
|
16833
|
+
var harnessIdSchema = opaqueIdSchema.brand();
|
|
16834
|
+
var hostThreadIdSchema = opaqueIdSchema.brand();
|
|
16835
|
+
var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
16836
|
+
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
16837
|
+
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
16838
|
+
|
|
16839
|
+
// packages/shared-contracts/dist/harness-plugins.js
|
|
16840
|
+
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
16841
|
+
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
16842
|
+
var HARNESS_PLUGIN_LIMIT = 128;
|
|
16843
|
+
var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
|
|
16844
|
+
var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
|
|
16845
|
+
var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id) => id !== "codex", "The official Codex identity is reserved");
|
|
16846
|
+
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");
|
|
16847
|
+
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
16848
|
+
var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
|
|
16849
|
+
var harnessInstallationGuideSchema = external_exports.object({
|
|
16850
|
+
commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
|
|
16851
|
+
before: localizedTextSchema.optional(),
|
|
16852
|
+
after: localizedTextSchema.optional(),
|
|
16853
|
+
downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
|
|
16854
|
+
}).strict();
|
|
16855
|
+
var pluginPresentationShape = {
|
|
16856
|
+
id: installedHarnessPluginIdSchema,
|
|
16857
|
+
name: external_exports.string().trim().min(1).max(128),
|
|
16858
|
+
version: external_exports.string().min(1).max(128),
|
|
16859
|
+
/** Capability-only plugin; omitted for existing session-capable plugins. */
|
|
16860
|
+
kind: external_exports.literal("usage").optional(),
|
|
16861
|
+
/** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
|
|
16862
|
+
iconStyle: external_exports.object({
|
|
16863
|
+
vector: external_exports.object({
|
|
16864
|
+
viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
|
|
16865
|
+
color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
|
|
16866
|
+
paths: external_exports.array(external_exports.object({
|
|
16867
|
+
d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
|
|
16868
|
+
fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
|
|
16869
|
+
fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
|
|
16870
|
+
}).strict()).min(1).max(32)
|
|
16871
|
+
}).strict().optional(),
|
|
16872
|
+
background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
|
|
16873
|
+
borderRadius: external_exports.number().min(0).max(50).optional(),
|
|
16874
|
+
paddingRatio: external_exports.number().min(0).max(0.25).optional()
|
|
16875
|
+
}).strict().optional(),
|
|
16876
|
+
installation: harnessInstallationGuideSchema.optional(),
|
|
16877
|
+
notice: localizedTextSchema.optional(),
|
|
16878
|
+
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
16879
|
+
launchCommand: external_exports.literal(true).optional(),
|
|
16880
|
+
links: external_exports.object({
|
|
16881
|
+
website: documentationUrlSchema.optional(),
|
|
16882
|
+
documentation: documentationUrlSchema.optional(),
|
|
16883
|
+
installation: documentationUrlSchema.optional()
|
|
16884
|
+
}).strict().optional()
|
|
16885
|
+
};
|
|
16886
|
+
var harnessPluginManifestSchema = external_exports.object({
|
|
16887
|
+
manifestVersion: external_exports.literal(1),
|
|
16888
|
+
...pluginPresentationShape,
|
|
16889
|
+
adapterApiVersion: external_exports.number().int().positive(),
|
|
16890
|
+
entry: pluginRelativeResourceSchema,
|
|
16891
|
+
icon: pluginRelativeResourceSchema.optional()
|
|
16892
|
+
}).strict();
|
|
16893
|
+
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);
|
|
16894
|
+
var harnessPluginDescriptorSchema = external_exports.object({
|
|
16895
|
+
...pluginPresentationShape,
|
|
16896
|
+
icon: harnessPluginIconSchema.optional()
|
|
16897
|
+
}).strict();
|
|
16898
|
+
var harnessPluginListParamsSchema = external_exports.object({}).strict();
|
|
16899
|
+
var harnessPluginListResultSchema = external_exports.object({
|
|
16900
|
+
plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
|
|
16901
|
+
}).strict();
|
|
16902
|
+
var harnessPluginConfigurationSchema = external_exports.object({
|
|
16903
|
+
version: external_exports.literal(1),
|
|
16904
|
+
enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
16905
|
+
}).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
|
|
16906
|
+
message: "Enabled plugin IDs must be unique",
|
|
16907
|
+
path: ["enabled"]
|
|
16908
|
+
});
|
|
15214
16909
|
|
|
15215
16910
|
// packages/shared-contracts/dist/json-value.js
|
|
15216
16911
|
function rejectExplicitUndefined(keys) {
|
|
@@ -15271,6 +16966,379 @@ var jsonValueSchema = nonCircularSchema.pipe(recursiveJsonValueSchema);
|
|
|
15271
16966
|
var jsonArraySchema = nonCircularSchema.pipe(external_exports.array(recursiveJsonValueSchema));
|
|
15272
16967
|
var jsonObjectSchema = nonCircularSchema.pipe(external_exports.record(external_exports.string(), recursiveJsonValueSchema));
|
|
15273
16968
|
|
|
16969
|
+
// packages/shared-contracts/dist/desktop-extensions.js
|
|
16970
|
+
var DESKTOP_EXTENSION_API_VERSION = 1;
|
|
16971
|
+
var DESKTOP_EXTENSION_LIMIT = 64;
|
|
16972
|
+
var DESKTOP_EXTENSION_ZIP_MAX_BYTES = 64 * 1024 * 1024;
|
|
16973
|
+
var DESKTOP_EXTENSION_ZIP_MAX_BASE64_LENGTH = 4 * Math.ceil(DESKTOP_EXTENSION_ZIP_MAX_BYTES / 3);
|
|
16974
|
+
var DESKTOP_EXTENSION_MANIFEST_MAX_BYTES = 128 * 1024;
|
|
16975
|
+
var DESKTOP_EXTENSION_SCRIPT_MAX_BYTES = 2 * 1024 * 1024;
|
|
16976
|
+
var DESKTOP_EXTENSION_STYLE_MAX_BYTES = 256 * 1024;
|
|
16977
|
+
var DESKTOP_EXTENSION_ICON_MAX_BYTES = 128 * 1024;
|
|
16978
|
+
var DESKTOP_EXTENSION_SCREENSHOT_LIMIT = 4;
|
|
16979
|
+
var DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES = 512 * 1024;
|
|
16980
|
+
var DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES = 8 * 1024 * 1024;
|
|
16981
|
+
var DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES = 8 * 1024 * 1024;
|
|
16982
|
+
var DESKTOP_EXTENSION_ASSET_MAX_BYTES = 16 * 1024 * 1024;
|
|
16983
|
+
var DESKTOP_EXTENSION_SETTINGS_MAX_BYTES = 1024 * 1024;
|
|
16984
|
+
var desktopExtensionIdSchema = installedPluginIdSchema;
|
|
16985
|
+
var desktopExtensionSlotSchema = external_exports.enum([
|
|
16986
|
+
"sidebar.thread-layout",
|
|
16987
|
+
"sidebar.thread-badge",
|
|
16988
|
+
"appearance.theme"
|
|
16989
|
+
]);
|
|
16990
|
+
var desktopExtensionCategorySchema = external_exports.enum([
|
|
16991
|
+
"appearance",
|
|
16992
|
+
"interface",
|
|
16993
|
+
"workflow",
|
|
16994
|
+
"analytics",
|
|
16995
|
+
"integrations",
|
|
16996
|
+
"tools"
|
|
16997
|
+
]);
|
|
16998
|
+
var extensionName = external_exports.string().trim().min(1).max(128);
|
|
16999
|
+
function desktopExtensionScreenshotMimeType(resource) {
|
|
17000
|
+
switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
|
|
17001
|
+
case "png":
|
|
17002
|
+
return "image/png";
|
|
17003
|
+
case "jpg":
|
|
17004
|
+
case "jpeg":
|
|
17005
|
+
return "image/jpeg";
|
|
17006
|
+
case "webp":
|
|
17007
|
+
return "image/webp";
|
|
17008
|
+
default:
|
|
17009
|
+
return void 0;
|
|
17010
|
+
}
|
|
17011
|
+
}
|
|
17012
|
+
function desktopExtensionAssetMimeType(resource) {
|
|
17013
|
+
switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
|
|
17014
|
+
case "gif":
|
|
17015
|
+
return "image/gif";
|
|
17016
|
+
case "svg":
|
|
17017
|
+
return "image/svg+xml";
|
|
17018
|
+
case "woff2":
|
|
17019
|
+
return "font/woff2";
|
|
17020
|
+
case "json":
|
|
17021
|
+
return "application/json";
|
|
17022
|
+
case "css":
|
|
17023
|
+
return "text/css";
|
|
17024
|
+
default:
|
|
17025
|
+
return desktopExtensionScreenshotMimeType(resource);
|
|
17026
|
+
}
|
|
17027
|
+
}
|
|
17028
|
+
var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
|
|
17029
|
+
var desktopExtensionAssetPathSchema = pluginRelativeResourceSchema.refine((resource) => hasPortableSegments(resource) && desktopExtensionAssetMimeType(resource) !== void 0, "Expected a relative Desktop extension asset path with a supported suffix");
|
|
17030
|
+
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");
|
|
17031
|
+
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) => {
|
|
17032
|
+
const { username, password } = new URL(value);
|
|
17033
|
+
return !username && !password && !/[\\\s]/u.test(value);
|
|
17034
|
+
}, "URL must not contain credentials, backslashes, or whitespace");
|
|
17035
|
+
function localizedText(text) {
|
|
17036
|
+
return external_exports.strictObject({ en: text, "zh-CN": text });
|
|
17037
|
+
}
|
|
17038
|
+
var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
|
|
17039
|
+
var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
|
|
17040
|
+
var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
|
|
17041
|
+
var settingField = {
|
|
17042
|
+
key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
|
|
17043
|
+
label: desktopExtensionLocalizedTextSchema,
|
|
17044
|
+
description: desktopExtensionLocalizedTextSchema.optional()
|
|
17045
|
+
};
|
|
17046
|
+
var numericSetting = {
|
|
17047
|
+
...settingField,
|
|
17048
|
+
step: external_exports.number().positive().optional(),
|
|
17049
|
+
default: external_exports.number().optional()
|
|
17050
|
+
};
|
|
17051
|
+
var settingOption = external_exports.strictObject({
|
|
17052
|
+
value: external_exports.string(),
|
|
17053
|
+
label: desktopExtensionLocalizedTextSchema
|
|
17054
|
+
});
|
|
17055
|
+
var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
|
|
17056
|
+
external_exports.strictObject({
|
|
17057
|
+
...settingField,
|
|
17058
|
+
type: external_exports.literal("boolean"),
|
|
17059
|
+
default: external_exports.boolean().optional()
|
|
17060
|
+
}),
|
|
17061
|
+
external_exports.strictObject({
|
|
17062
|
+
...settingField,
|
|
17063
|
+
type: external_exports.literal("string"),
|
|
17064
|
+
placeholder: desktopExtensionLocalizedTextSchema.optional(),
|
|
17065
|
+
default: external_exports.string().optional()
|
|
17066
|
+
}),
|
|
17067
|
+
external_exports.strictObject({
|
|
17068
|
+
...numericSetting,
|
|
17069
|
+
type: external_exports.literal("number"),
|
|
17070
|
+
min: external_exports.number().optional(),
|
|
17071
|
+
max: external_exports.number().optional()
|
|
17072
|
+
}),
|
|
17073
|
+
external_exports.strictObject({
|
|
17074
|
+
...numericSetting,
|
|
17075
|
+
type: external_exports.literal("range"),
|
|
17076
|
+
min: external_exports.number(),
|
|
17077
|
+
max: external_exports.number()
|
|
17078
|
+
}),
|
|
17079
|
+
external_exports.strictObject({
|
|
17080
|
+
...settingField,
|
|
17081
|
+
type: external_exports.literal("select"),
|
|
17082
|
+
options: external_exports.array(settingOption).min(1),
|
|
17083
|
+
default: external_exports.string().optional()
|
|
17084
|
+
})
|
|
17085
|
+
]).superRefine((field2, ctx) => {
|
|
17086
|
+
const issue2 = (path7, message) => ctx.addIssue({ code: "custom", path: [path7], message });
|
|
17087
|
+
if (field2.type === "number" || field2.type === "range") {
|
|
17088
|
+
const { min = -Infinity, max = Infinity, default: value } = field2;
|
|
17089
|
+
if (min > max)
|
|
17090
|
+
issue2("max", "Must be at least min");
|
|
17091
|
+
if (value !== void 0 && (value < min || value > max))
|
|
17092
|
+
issue2("default", "Must be within min and max");
|
|
17093
|
+
} else if (field2.type === "select") {
|
|
17094
|
+
const values = new Set(field2.options.map(({ value }) => value));
|
|
17095
|
+
if (values.size !== field2.options.length)
|
|
17096
|
+
issue2("options", "Duplicate option values");
|
|
17097
|
+
if (field2.default !== void 0 && !values.has(field2.default))
|
|
17098
|
+
issue2("default", "Must match an option value");
|
|
17099
|
+
}
|
|
17100
|
+
});
|
|
17101
|
+
var manifestHeader = external_exports.object({
|
|
17102
|
+
manifestVersion: external_exports.int().positive(),
|
|
17103
|
+
id: desktopExtensionIdSchema,
|
|
17104
|
+
name: external_exports.union([extensionName, localizedText(extensionName)]),
|
|
17105
|
+
version: external_exports.string().min(1).max(128),
|
|
17106
|
+
desktopApi: external_exports.int().positive()
|
|
17107
|
+
}).passthrough();
|
|
17108
|
+
var desktopExtensionManifestSchema = manifestHeader.extend({
|
|
17109
|
+
manifestVersion: external_exports.literal(1),
|
|
17110
|
+
desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
|
|
17111
|
+
description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
|
|
17112
|
+
author: external_exports.string().trim().min(1).max(128).optional(),
|
|
17113
|
+
repository: desktopExtensionHttpUrlSchema.optional(),
|
|
17114
|
+
details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
|
|
17115
|
+
icon: imagePathSchema.optional(),
|
|
17116
|
+
screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
|
|
17117
|
+
desktop: external_exports.strictObject({
|
|
17118
|
+
script: pluginRelativeResourceSchema,
|
|
17119
|
+
style: pluginRelativeResourceSchema.optional()
|
|
17120
|
+
}).optional(),
|
|
17121
|
+
backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
|
|
17122
|
+
slots: slotsSchema.default(() => []),
|
|
17123
|
+
settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
|
|
17124
|
+
categories: categoriesSchema.optional()
|
|
17125
|
+
}).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
|
|
17126
|
+
function parseDesktopExtensionManifest(value) {
|
|
17127
|
+
const header = manifestHeader.safeParse(value);
|
|
17128
|
+
if (!header.success)
|
|
17129
|
+
return { state: "invalid", error: external_exports.prettifyError(header.error) };
|
|
17130
|
+
if (header.data.desktopApi > DESKTOP_EXTENSION_API_VERSION) {
|
|
17131
|
+
return {
|
|
17132
|
+
state: "incompatible",
|
|
17133
|
+
error: `Desktop API ${header.data.desktopApi} requires a newer codexhost`
|
|
17134
|
+
};
|
|
17135
|
+
}
|
|
17136
|
+
const manifest = desktopExtensionManifestSchema.safeParse(value);
|
|
17137
|
+
return manifest.success ? { state: "valid", manifest: manifest.data } : { state: "invalid", error: external_exports.prettifyError(manifest.error) };
|
|
17138
|
+
}
|
|
17139
|
+
var desktopExtensionConfigurationSchema = external_exports.strictObject({
|
|
17140
|
+
version: external_exports.literal(1),
|
|
17141
|
+
revision: external_exports.int().nonnegative(),
|
|
17142
|
+
enabled: external_exports.array(desktopExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs"),
|
|
17143
|
+
reloadToken: external_exports.uuid().optional()
|
|
17144
|
+
});
|
|
17145
|
+
var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
|
|
17146
|
+
var desktopExtensionStatusSchema = external_exports.strictObject({
|
|
17147
|
+
state: external_exports.enum([
|
|
17148
|
+
"running",
|
|
17149
|
+
"disabled",
|
|
17150
|
+
"invalid",
|
|
17151
|
+
"incompatible",
|
|
17152
|
+
"conflict",
|
|
17153
|
+
"failed",
|
|
17154
|
+
"waiting"
|
|
17155
|
+
]),
|
|
17156
|
+
hash: desktopExtensionHashSchema.optional(),
|
|
17157
|
+
error: external_exports.string().optional(),
|
|
17158
|
+
conflictWith: desktopExtensionIdSchema.optional()
|
|
17159
|
+
});
|
|
17160
|
+
var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
|
|
17161
|
+
controllerPid: external_exports.int().positive(),
|
|
17162
|
+
targetId: external_exports.string().nullable(),
|
|
17163
|
+
updatedAt: external_exports.iso.datetime(),
|
|
17164
|
+
handledReloadToken: external_exports.uuid().optional(),
|
|
17165
|
+
extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema)
|
|
17166
|
+
});
|
|
17167
|
+
var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
|
|
17168
|
+
function isGitHubDesktopExtensionZipballUrl(url2) {
|
|
17169
|
+
return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
|
|
17170
|
+
}
|
|
17171
|
+
var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
|
|
17172
|
+
const url2 = new URL(input);
|
|
17173
|
+
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);
|
|
17174
|
+
}, "Expected a .zip download URL or a GitHub zipball URL");
|
|
17175
|
+
var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
|
|
17176
|
+
id: desktopExtensionIdSchema,
|
|
17177
|
+
version: external_exports.string().trim().min(1).max(128),
|
|
17178
|
+
name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
|
|
17179
|
+
description: localizedText(external_exports.string().trim().min(1).max(4096)),
|
|
17180
|
+
details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
|
|
17181
|
+
author: external_exports.string().trim().min(1).max(128),
|
|
17182
|
+
repository: desktopExtensionHttpUrlSchema,
|
|
17183
|
+
stars: external_exports.number().int().min(0).optional(),
|
|
17184
|
+
downloads: external_exports.number().int().min(0).optional(),
|
|
17185
|
+
categories: categoriesSchema.optional(),
|
|
17186
|
+
trustTier: desktopExtensionTrustTierSchema.default("community"),
|
|
17187
|
+
icon: desktopExtensionHttpUrlSchema.optional(),
|
|
17188
|
+
screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
17189
|
+
downloadUrl: desktopExtensionZipUrlSchema,
|
|
17190
|
+
sha256: desktopExtensionHashSchema,
|
|
17191
|
+
slots: slotsSchema.optional(),
|
|
17192
|
+
publishedAt: external_exports.string().optional(),
|
|
17193
|
+
updatedAt: external_exports.string().optional(),
|
|
17194
|
+
minCodexHostVersion: external_exports.string().optional()
|
|
17195
|
+
});
|
|
17196
|
+
var desktopExtensionCatalogSchema = external_exports.strictObject({
|
|
17197
|
+
schemaVersion: external_exports.literal(1),
|
|
17198
|
+
generatedAt: external_exports.string(),
|
|
17199
|
+
extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, "Duplicate extension IDs")
|
|
17200
|
+
});
|
|
17201
|
+
function resolveDesktopExtensionSlots(enabledOrder, manifests) {
|
|
17202
|
+
const byId = new Map(Array.from(manifests, ({ id, slots = [] }) => [id, slots]));
|
|
17203
|
+
const owners = /* @__PURE__ */ new Map();
|
|
17204
|
+
const conflicts = /* @__PURE__ */ new Map();
|
|
17205
|
+
const active = [];
|
|
17206
|
+
for (const id of new Set(enabledOrder)) {
|
|
17207
|
+
const slots = byId.get(id);
|
|
17208
|
+
if (!slots)
|
|
17209
|
+
continue;
|
|
17210
|
+
const conflictWith = slots.map((slot) => owners.get(slot)).find((owner) => owner !== void 0);
|
|
17211
|
+
if (conflictWith !== void 0) {
|
|
17212
|
+
conflicts.set(id, conflictWith);
|
|
17213
|
+
continue;
|
|
17214
|
+
}
|
|
17215
|
+
for (const slot of slots)
|
|
17216
|
+
owners.set(slot, id);
|
|
17217
|
+
active.push(id);
|
|
17218
|
+
}
|
|
17219
|
+
return { active, conflicts };
|
|
17220
|
+
}
|
|
17221
|
+
var DESKTOP_EXTENSIONS_ASSET_METHOD = "codexhost/desktop/extensions/asset";
|
|
17222
|
+
var DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD = "codexhost/desktop/extensions/settings/get";
|
|
17223
|
+
var DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD = "codexhost/desktop/extensions/settings/set";
|
|
17224
|
+
var DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD = "codexhost/desktop/extensions/backend/invoke";
|
|
17225
|
+
var extensionIdParams = { id: desktopExtensionIdSchema };
|
|
17226
|
+
var desktopExtensionsAssetParamsSchema = external_exports.strictObject({
|
|
17227
|
+
...extensionIdParams,
|
|
17228
|
+
path: desktopExtensionAssetPathSchema
|
|
17229
|
+
});
|
|
17230
|
+
var desktopExtensionsAssetResultSchema = external_exports.strictObject({
|
|
17231
|
+
mimeType: external_exports.string(),
|
|
17232
|
+
dataUrl: external_exports.string()
|
|
17233
|
+
});
|
|
17234
|
+
var desktopExtensionsSettingsGetParamsSchema = external_exports.strictObject(extensionIdParams);
|
|
17235
|
+
var desktopExtensionsSettingsSetParamsSchema = external_exports.strictObject({
|
|
17236
|
+
...extensionIdParams,
|
|
17237
|
+
values: jsonObjectSchema
|
|
17238
|
+
});
|
|
17239
|
+
var desktopExtensionsSettingsResultSchema = external_exports.strictObject({ values: jsonObjectSchema });
|
|
17240
|
+
var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
|
|
17241
|
+
var desktopExtensionsBackendInvokeParamsSchema = external_exports.strictObject({
|
|
17242
|
+
...extensionIdParams,
|
|
17243
|
+
method: desktopExtensionBackendMethodSchema,
|
|
17244
|
+
params: jsonValueSchema.optional()
|
|
17245
|
+
});
|
|
17246
|
+
var desktopExtensionsBackendInvokeResultSchema = external_exports.strictObject({
|
|
17247
|
+
result: jsonValueSchema
|
|
17248
|
+
});
|
|
17249
|
+
|
|
17250
|
+
// packages/shared-contracts/dist/desktop-extension-management.js
|
|
17251
|
+
var DESKTOP_EXTENSIONS_LIST_METHOD = "codexhost/desktop/extensions/list";
|
|
17252
|
+
var DESKTOP_EXTENSIONS_ENABLE_METHOD = "codexhost/desktop/extensions/enable";
|
|
17253
|
+
var DESKTOP_EXTENSIONS_DISABLE_METHOD = "codexhost/desktop/extensions/disable";
|
|
17254
|
+
var DESKTOP_EXTENSIONS_CATALOG_METHOD = "codexhost/desktop/extensions/catalog";
|
|
17255
|
+
var DESKTOP_EXTENSIONS_INSTALL_METHOD = "codexhost/desktop/extensions/install";
|
|
17256
|
+
var DESKTOP_EXTENSIONS_UNINSTALL_METHOD = "codexhost/desktop/extensions/uninstall";
|
|
17257
|
+
var DESKTOP_EXTENSIONS_RECOVER_METHOD = "codexhost/desktop/extensions/disable-all-and-reload";
|
|
17258
|
+
var DESKTOP_EXTENSION_MANAGEMENT_METHODS = [
|
|
17259
|
+
DESKTOP_EXTENSIONS_LIST_METHOD,
|
|
17260
|
+
DESKTOP_EXTENSIONS_ENABLE_METHOD,
|
|
17261
|
+
DESKTOP_EXTENSIONS_DISABLE_METHOD,
|
|
17262
|
+
DESKTOP_EXTENSIONS_RECOVER_METHOD,
|
|
17263
|
+
DESKTOP_EXTENSIONS_CATALOG_METHOD,
|
|
17264
|
+
DESKTOP_EXTENSIONS_INSTALL_METHOD,
|
|
17265
|
+
DESKTOP_EXTENSIONS_UNINSTALL_METHOD,
|
|
17266
|
+
DESKTOP_EXTENSIONS_ASSET_METHOD,
|
|
17267
|
+
DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD,
|
|
17268
|
+
DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD,
|
|
17269
|
+
DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD
|
|
17270
|
+
];
|
|
17271
|
+
var revisionSchema = external_exports.int().nonnegative();
|
|
17272
|
+
var desktopExtensionsListParamsSchema = external_exports.strictObject({});
|
|
17273
|
+
var desktopExtensionSelectionParamsSchema = external_exports.strictObject({
|
|
17274
|
+
id: desktopExtensionIdSchema,
|
|
17275
|
+
expectedRevision: revisionSchema
|
|
17276
|
+
});
|
|
17277
|
+
var desktopExtensionsRecoveryParamsSchema = external_exports.strictObject({
|
|
17278
|
+
expectedRevision: revisionSchema.optional()
|
|
17279
|
+
});
|
|
17280
|
+
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);
|
|
17281
|
+
var desktopExtensionListItemSchema = external_exports.strictObject({
|
|
17282
|
+
// An invalid discovery can have a directory name that isn't a valid extension ID.
|
|
17283
|
+
id: external_exports.string().min(1),
|
|
17284
|
+
manifest: desktopExtensionManifestSchema.optional(),
|
|
17285
|
+
iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
|
|
17286
|
+
screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
17287
|
+
enabled: external_exports.boolean(),
|
|
17288
|
+
status: desktopExtensionStatusSchema
|
|
17289
|
+
});
|
|
17290
|
+
var desktopExtensionsListResultSchema = external_exports.strictObject({
|
|
17291
|
+
configuration: desktopExtensionConfigurationSchema,
|
|
17292
|
+
desktopConnected: external_exports.boolean(),
|
|
17293
|
+
diagnostics: external_exports.array(external_exports.string()),
|
|
17294
|
+
extensions: external_exports.array(desktopExtensionListItemSchema)
|
|
17295
|
+
});
|
|
17296
|
+
var desktopExtensionsCatalogParamsSchema = external_exports.strictObject({
|
|
17297
|
+
forceRefresh: external_exports.boolean().optional()
|
|
17298
|
+
});
|
|
17299
|
+
var desktopExtensionsCatalogResultSchema = external_exports.strictObject({
|
|
17300
|
+
catalogUrl: external_exports.string(),
|
|
17301
|
+
source: external_exports.enum(["remote", "fallback"]),
|
|
17302
|
+
fetchedAt: external_exports.string(),
|
|
17303
|
+
cached: external_exports.boolean(),
|
|
17304
|
+
extensions: desktopExtensionCatalogSchema.shape.extensions,
|
|
17305
|
+
error: external_exports.string().optional()
|
|
17306
|
+
});
|
|
17307
|
+
var desktopExtensionsInstallParamsSchema = external_exports.strictObject({
|
|
17308
|
+
source: external_exports.discriminatedUnion("type", [
|
|
17309
|
+
external_exports.strictObject({ type: external_exports.literal("catalog"), id: desktopExtensionIdSchema }),
|
|
17310
|
+
external_exports.strictObject({
|
|
17311
|
+
type: external_exports.literal("url"),
|
|
17312
|
+
url: desktopExtensionHttpUrlSchema,
|
|
17313
|
+
expectedSha256: desktopExtensionHashSchema.optional()
|
|
17314
|
+
}),
|
|
17315
|
+
external_exports.strictObject({
|
|
17316
|
+
type: external_exports.literal("zip-base64"),
|
|
17317
|
+
fileName: external_exports.string().trim().min(1).max(255),
|
|
17318
|
+
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")
|
|
17319
|
+
})
|
|
17320
|
+
])
|
|
17321
|
+
});
|
|
17322
|
+
var desktopExtensionsInstallResultSchema = external_exports.strictObject({
|
|
17323
|
+
extensionId: desktopExtensionIdSchema,
|
|
17324
|
+
version: external_exports.string().min(1),
|
|
17325
|
+
replaced: external_exports.boolean(),
|
|
17326
|
+
installedPath: external_exports.string(),
|
|
17327
|
+
list: desktopExtensionsListResultSchema
|
|
17328
|
+
});
|
|
17329
|
+
var desktopExtensionsUninstallParamsSchema = external_exports.strictObject({
|
|
17330
|
+
id: desktopExtensionIdSchema
|
|
17331
|
+
});
|
|
17332
|
+
var desktopExtensionsUninstallResultSchema = external_exports.strictObject({
|
|
17333
|
+
removedId: desktopExtensionIdSchema,
|
|
17334
|
+
list: desktopExtensionsListResultSchema
|
|
17335
|
+
});
|
|
17336
|
+
var desktopExtensionMutationResultSchema = external_exports.discriminatedUnion("state", [
|
|
17337
|
+
external_exports.strictObject({ state: external_exports.literal("saved"), configuration: desktopExtensionConfigurationSchema }),
|
|
17338
|
+
external_exports.strictObject({ state: external_exports.literal("slot-conflict"), conflictWith: desktopExtensionIdSchema }),
|
|
17339
|
+
external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: revisionSchema })
|
|
17340
|
+
]);
|
|
17341
|
+
|
|
15274
17342
|
// packages/shared-contracts/dist/errors.js
|
|
15275
17343
|
var codexhostErrorSchema = external_exports.strictObject({
|
|
15276
17344
|
code: external_exports.string().min(1),
|
|
@@ -15291,16 +17359,6 @@ var harnessLocalizationsSchema = external_exports.record(localeSchema, external_
|
|
|
15291
17359
|
}).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
|
|
15292
17360
|
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");
|
|
15293
17361
|
|
|
15294
|
-
// packages/shared-contracts/dist/ids.js
|
|
15295
|
-
var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
15296
|
-
message: "Identifier must not be empty or whitespace"
|
|
15297
|
-
});
|
|
15298
|
-
var harnessIdSchema = opaqueIdSchema.brand();
|
|
15299
|
-
var hostThreadIdSchema = opaqueIdSchema.brand();
|
|
15300
|
-
var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
15301
|
-
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
15302
|
-
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
15303
|
-
|
|
15304
17362
|
// packages/shared-contracts/dist/harness-permission-modes.js
|
|
15305
17363
|
var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
|
|
15306
17364
|
var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
|
|
@@ -15500,6 +17558,13 @@ var accountCreditsSnapshotSchema = external_exports.object({
|
|
|
15500
17558
|
productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
|
|
15501
17559
|
resetCredits: accountResetCreditsSchema.optional()
|
|
15502
17560
|
}).strict();
|
|
17561
|
+
var accountBalanceSnapshotSchema = external_exports.object({
|
|
17562
|
+
amount: external_exports.number().finite().nonnegative(),
|
|
17563
|
+
/** ISO 4217 code as reported by the Provider, for example `CNY`. */
|
|
17564
|
+
currency: external_exports.string().trim().min(1).max(8),
|
|
17565
|
+
/** Native label when the Harness exposes several Billing Sources. */
|
|
17566
|
+
label: external_exports.string().trim().min(1).max(128).optional()
|
|
17567
|
+
}).strict();
|
|
15503
17568
|
var threadUsageInspectionParamsSchema = external_exports.object({
|
|
15504
17569
|
threadId: hostThreadIdSchema,
|
|
15505
17570
|
refresh: external_exports.literal("exact").optional()
|
|
@@ -15508,7 +17573,10 @@ var threadUsageInspectionSchema = external_exports.object({
|
|
|
15508
17573
|
threadId: hostThreadIdSchema,
|
|
15509
17574
|
usage: threadUsageSnapshotSchema.nullable(),
|
|
15510
17575
|
accountCredits: accountCreditsSnapshotSchema.optional(),
|
|
15511
|
-
/**
|
|
17576
|
+
/** Prepaid funds for the Thread's Billing Source; shown only when no percentage quota exists. */
|
|
17577
|
+
accountBalance: accountBalanceSnapshotSchema.optional(),
|
|
17578
|
+
/** Whether this source can provide cached account quota (credits or a prepaid balance)
|
|
17579
|
+
* independently of usage. */
|
|
15512
17580
|
accountCreditsSupported: external_exports.boolean().optional()
|
|
15513
17581
|
}).strict();
|
|
15514
17582
|
|
|
@@ -15800,12 +17868,89 @@ var threadSteeringInspectResultSchema = external_exports.object({
|
|
|
15800
17868
|
}).strict();
|
|
15801
17869
|
|
|
15802
17870
|
// packages/shared-contracts/dist/thread-archive-confirm.js
|
|
17871
|
+
var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
|
|
15803
17872
|
var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
|
|
15804
17873
|
var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
|
|
15805
17874
|
|
|
15806
17875
|
// packages/shared-contracts/dist/client-channel.js
|
|
15807
17876
|
var CLIENT_CHANNEL_VERSION = 1;
|
|
15808
17877
|
var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
|
|
17878
|
+
var CLIENT_CHANNEL_METHODS = [
|
|
17879
|
+
"codexhost/skills/list",
|
|
17880
|
+
"codexhost/voice/status",
|
|
17881
|
+
"codexhost/voice/transcribe",
|
|
17882
|
+
"codexhost/harness/display-settings/get",
|
|
17883
|
+
"codexhost/harness/display-settings/set",
|
|
17884
|
+
"codexhost/harness/display-settings/capabilities",
|
|
17885
|
+
"codexhost/harness/preferences/get",
|
|
17886
|
+
"codexhost/harness/preferences/patch",
|
|
17887
|
+
"thread/list",
|
|
17888
|
+
"codexhost/thread/catalog/read",
|
|
17889
|
+
"thread/read",
|
|
17890
|
+
"thread/resume",
|
|
17891
|
+
"thread/fork",
|
|
17892
|
+
"thread/turns/list",
|
|
17893
|
+
"thread/revert",
|
|
17894
|
+
"thread/items/list",
|
|
17895
|
+
"thread/start",
|
|
17896
|
+
"thread/name/set",
|
|
17897
|
+
"codexhost/thread/title/generate",
|
|
17898
|
+
"thread/archive",
|
|
17899
|
+
THREAD_ARCHIVE_CONFIRM_METHOD,
|
|
17900
|
+
"thread/unarchive",
|
|
17901
|
+
"turn/start",
|
|
17902
|
+
"turn/interrupt",
|
|
17903
|
+
"turn/steer",
|
|
17904
|
+
"thread/queue/list",
|
|
17905
|
+
"thread/queue/add",
|
|
17906
|
+
"thread/queue/update",
|
|
17907
|
+
"thread/queue/delete",
|
|
17908
|
+
"thread/queue/reorder",
|
|
17909
|
+
"thread/queue/start",
|
|
17910
|
+
"codexhost/thread/queue/send-now",
|
|
17911
|
+
"codexhost/workspace/read",
|
|
17912
|
+
"codexhost/thread/tree/read",
|
|
17913
|
+
"codexhost/thread/pins/list",
|
|
17914
|
+
"codexhost/thread/pins/set",
|
|
17915
|
+
"codexhost/harness/plugins/list",
|
|
17916
|
+
"codexhost/harness/inspect",
|
|
17917
|
+
"codexhost/thread/inspect",
|
|
17918
|
+
"codexhost/thread/usage/inspect",
|
|
17919
|
+
"codexhost/thread/ownership/list",
|
|
17920
|
+
"codexhost/thread/model/select",
|
|
17921
|
+
"codexhost/thread/thinking/select",
|
|
17922
|
+
"codexhost/thread/permission-mode/select",
|
|
17923
|
+
"codexhost/thread/commands/inspect",
|
|
17924
|
+
"codexhost/harness/commands/inspect",
|
|
17925
|
+
"codexhost/thread/command/execute",
|
|
17926
|
+
"codexhost/thread/fork",
|
|
17927
|
+
"codexhost/harness/session-import/sources",
|
|
17928
|
+
"codexhost/harness/session-import/list",
|
|
17929
|
+
"codexhost/harness/session-import/import",
|
|
17930
|
+
// Host settings shared across Desktop and Web.
|
|
17931
|
+
...DESKTOP_EXTENSION_MANAGEMENT_METHODS,
|
|
17932
|
+
"codexhost/harness/installation",
|
|
17933
|
+
"codexhost/harness/installation/start",
|
|
17934
|
+
"codexhost/harness/installation/status",
|
|
17935
|
+
"codexhost/harness/launch-settings/get",
|
|
17936
|
+
"codexhost/harness/launch-settings/set",
|
|
17937
|
+
"codexhost/harness/web-ui/open",
|
|
17938
|
+
"codexhost/harness/accounts/sources",
|
|
17939
|
+
"codexhost/harness/accounts/list",
|
|
17940
|
+
"codexhost/harness/accounts/inspect",
|
|
17941
|
+
"codexhost/harness/credential-imports",
|
|
17942
|
+
"codexhost/account/list",
|
|
17943
|
+
"codexhost/account/refresh",
|
|
17944
|
+
"codexhost/account/usage/inspect",
|
|
17945
|
+
"codexhost/usage/model-prices/get",
|
|
17946
|
+
"codexhost/usage/model-prices/set",
|
|
17947
|
+
"codexhost/usage/model-prices/default",
|
|
17948
|
+
"codexhost/usage/statistics/get",
|
|
17949
|
+
"codexhost/update/check",
|
|
17950
|
+
"codexhost/update/start",
|
|
17951
|
+
"codexhost/update/status",
|
|
17952
|
+
"codexhost/sessions/loaded/list"
|
|
17953
|
+
];
|
|
15809
17954
|
var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
|
|
15810
17955
|
var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
|
|
15811
17956
|
var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
|
|
@@ -16019,6 +18164,29 @@ var threadCatalogReadResultSchema = external_exports.object({
|
|
|
16019
18164
|
officialCursor: external_exports.object({ live: external_exports.string().nullable(), archived: external_exports.string().nullable().optional() }).strict().optional()
|
|
16020
18165
|
}).strict();
|
|
16021
18166
|
|
|
18167
|
+
// packages/shared-contracts/dist/thread-tree-watch.js
|
|
18168
|
+
var THREAD_TREE_MAX_NODES = 5e3;
|
|
18169
|
+
var threadTreeStatusSchema = external_exports.enum(["running", "waiting", "idle", "unknown"]);
|
|
18170
|
+
var threadTreeNodeSchema = external_exports.strictObject({
|
|
18171
|
+
harnessId: harnessIdSchema,
|
|
18172
|
+
title: external_exports.string().optional(),
|
|
18173
|
+
status: threadTreeStatusSchema,
|
|
18174
|
+
archived: external_exports.boolean()
|
|
18175
|
+
});
|
|
18176
|
+
var threadTreeSnapshotSchema = external_exports.strictObject({
|
|
18177
|
+
revision: external_exports.int().nonnegative(),
|
|
18178
|
+
parents: external_exports.record(hostThreadIdSchema, hostThreadIdSchema),
|
|
18179
|
+
nodes: external_exports.record(hostThreadIdSchema, threadTreeNodeSchema),
|
|
18180
|
+
truncated: external_exports.boolean()
|
|
18181
|
+
}).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");
|
|
18182
|
+
var subscriptionId = external_exports.string().min(1).max(128);
|
|
18183
|
+
var threadTreeWatchParamsSchema = external_exports.strictObject({});
|
|
18184
|
+
var threadTreeUnwatchParamsSchema = external_exports.strictObject({ subscriptionId });
|
|
18185
|
+
var threadTreeUnwatchResultSchema = external_exports.strictObject({});
|
|
18186
|
+
var threadTreeWatchResultSchema = threadTreeUnwatchParamsSchema.extend({
|
|
18187
|
+
snapshot: threadTreeSnapshotSchema
|
|
18188
|
+
});
|
|
18189
|
+
|
|
16022
18190
|
// packages/shared-contracts/dist/voice.js
|
|
16023
18191
|
var VOICE_AUDIO_MAX_BYTES = 10 * 1024 * 1024;
|
|
16024
18192
|
var voiceAudioMimeTypeSchema = external_exports.string().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);
|
|
@@ -16633,132 +18801,55 @@ var loadedSessionReasonSchema = external_exports.enum([
|
|
|
16633
18801
|
"identity",
|
|
16634
18802
|
"persistence",
|
|
16635
18803
|
"closeFailed"
|
|
16636
|
-
]);
|
|
16637
|
-
var loadedSessionsSchema = external_exports.array(external_exports.strictObject({
|
|
16638
|
-
threadId: external_exports.string(),
|
|
16639
|
-
title: external_exports.string(),
|
|
16640
|
-
harnessId: external_exports.string(),
|
|
16641
|
-
state: loadedSessionStateSchema,
|
|
16642
|
-
reason: loadedSessionReasonSchema,
|
|
16643
|
-
inactiveMs: external_exports.number().nonnegative()
|
|
16644
|
-
}));
|
|
16645
|
-
|
|
16646
|
-
// packages/shared-contracts/dist/manual-compaction.js
|
|
16647
|
-
var threadManualCompactionStartedSchema = external_exports.strictObject({
|
|
16648
|
-
threadId: hostThreadIdSchema,
|
|
16649
|
-
turnId: hostTurnIdSchema
|
|
16650
|
-
});
|
|
16651
|
-
|
|
16652
|
-
// packages/shared-contracts/dist/harness-accounts.js
|
|
16653
|
-
var
|
|
16654
|
-
|
|
16655
|
-
|
|
16656
|
-
|
|
16657
|
-
|
|
16658
|
-
|
|
16659
|
-
}).strict();
|
|
16660
|
-
var harnessAccountSnapshotObject = external_exports.object({
|
|
16661
|
-
email: external_exports.string().trim().min(1).max(320).optional(),
|
|
16662
|
-
label: external_exports.string().trim().min(1).max(256).optional(),
|
|
16663
|
-
plan: external_exports.string().trim().min(1).max(128).optional(),
|
|
16664
|
-
credits: accountCreditsSnapshotSchema.optional(),
|
|
16665
|
-
balance: accountBalanceSnapshotSchema.optional()
|
|
16666
|
-
}).strict();
|
|
16667
|
-
function requireReportedQuota(schema) {
|
|
16668
|
-
return schema.refine((value) => {
|
|
16669
|
-
const reported = value;
|
|
16670
|
-
return reported.credits !== void 0 || reported.balance !== void 0;
|
|
16671
|
-
}, { message: "Account must report either credits or a balance" });
|
|
16672
|
-
}
|
|
16673
|
-
var harnessAccountSnapshotSchema = requireReportedQuota(harnessAccountSnapshotObject);
|
|
16674
|
-
var harnessAccountIdentityShape = {
|
|
16675
|
-
harnessId: harnessIdSchema,
|
|
16676
|
-
harnessName: external_exports.string().trim().min(1).max(128)
|
|
16677
|
-
};
|
|
16678
|
-
var harnessAccountSourceSchema = external_exports.object(harnessAccountIdentityShape).strict();
|
|
16679
|
-
var harnessAccountSourceListParamsSchema = external_exports.object({}).strict();
|
|
16680
|
-
var harnessAccountSourceListResultSchema = external_exports.object({ sources: external_exports.array(harnessAccountSourceSchema).max(128) }).strict();
|
|
16681
|
-
var harnessAccountInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema, refresh: external_exports.boolean().optional() }).strict();
|
|
16682
|
-
var harnessAccountInspectResultSchema = external_exports.object({
|
|
16683
|
-
...harnessAccountIdentityShape,
|
|
16684
|
-
account: harnessAccountSnapshotSchema.nullable(),
|
|
16685
|
-
/** Every Billing Source from one Harness; `account` remains the first for older clients. */
|
|
16686
|
-
accounts: external_exports.array(harnessAccountSnapshotSchema).max(8).optional()
|
|
16687
|
-
}).strict();
|
|
16688
|
-
var harnessAccountListParamsSchema = external_exports.object({ refresh: external_exports.boolean().optional() }).strict();
|
|
16689
|
-
var harnessAccountListResultSchema = external_exports.object({
|
|
16690
|
-
accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
|
|
16691
|
-
}).strict();
|
|
16692
|
-
|
|
16693
|
-
// packages/shared-contracts/dist/harness-plugins.js
|
|
16694
|
-
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
16695
|
-
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
16696
|
-
var HARNESS_PLUGIN_LIMIT = 128;
|
|
16697
|
-
var installedHarnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).pipe(harnessIdSchema);
|
|
16698
|
-
var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id) => id !== "codex", "The official Codex identity is reserved");
|
|
16699
|
-
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");
|
|
16700
|
-
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
16701
|
-
var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
|
|
16702
|
-
var harnessInstallationGuideSchema = external_exports.object({
|
|
16703
|
-
commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
|
|
16704
|
-
before: localizedTextSchema.optional(),
|
|
16705
|
-
after: localizedTextSchema.optional(),
|
|
16706
|
-
downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
|
|
16707
|
-
}).strict();
|
|
16708
|
-
var pluginPresentationShape = {
|
|
16709
|
-
id: installedHarnessPluginIdSchema,
|
|
16710
|
-
name: external_exports.string().trim().min(1).max(128),
|
|
16711
|
-
version: external_exports.string().min(1).max(128),
|
|
16712
|
-
/** Capability-only plugin; omitted for existing session-capable plugins. */
|
|
16713
|
-
kind: external_exports.literal("usage").optional(),
|
|
16714
|
-
/** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
|
|
16715
|
-
iconStyle: external_exports.object({
|
|
16716
|
-
vector: external_exports.object({
|
|
16717
|
-
viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
|
|
16718
|
-
color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
|
|
16719
|
-
paths: external_exports.array(external_exports.object({
|
|
16720
|
-
d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
|
|
16721
|
-
fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
|
|
16722
|
-
fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
|
|
16723
|
-
}).strict()).min(1).max(32)
|
|
16724
|
-
}).strict().optional(),
|
|
16725
|
-
background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
|
|
16726
|
-
borderRadius: external_exports.number().min(0).max(50).optional(),
|
|
16727
|
-
paddingRatio: external_exports.number().min(0).max(0.25).optional()
|
|
16728
|
-
}).strict().optional(),
|
|
16729
|
-
installation: harnessInstallationGuideSchema.optional(),
|
|
16730
|
-
notice: localizedTextSchema.optional(),
|
|
16731
|
-
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
16732
|
-
launchCommand: external_exports.literal(true).optional(),
|
|
16733
|
-
links: external_exports.object({
|
|
16734
|
-
website: documentationUrlSchema.optional(),
|
|
16735
|
-
documentation: documentationUrlSchema.optional(),
|
|
16736
|
-
installation: documentationUrlSchema.optional()
|
|
16737
|
-
}).strict().optional()
|
|
16738
|
-
};
|
|
16739
|
-
var harnessPluginManifestSchema = external_exports.object({
|
|
16740
|
-
manifestVersion: external_exports.literal(1),
|
|
16741
|
-
...pluginPresentationShape,
|
|
16742
|
-
adapterApiVersion: external_exports.number().int().positive(),
|
|
16743
|
-
entry: relativeResourceSchema,
|
|
16744
|
-
icon: relativeResourceSchema.optional()
|
|
18804
|
+
]);
|
|
18805
|
+
var loadedSessionsSchema = external_exports.array(external_exports.strictObject({
|
|
18806
|
+
threadId: external_exports.string(),
|
|
18807
|
+
title: external_exports.string(),
|
|
18808
|
+
harnessId: external_exports.string(),
|
|
18809
|
+
state: loadedSessionStateSchema,
|
|
18810
|
+
reason: loadedSessionReasonSchema,
|
|
18811
|
+
inactiveMs: external_exports.number().nonnegative()
|
|
18812
|
+
}));
|
|
18813
|
+
|
|
18814
|
+
// packages/shared-contracts/dist/manual-compaction.js
|
|
18815
|
+
var threadManualCompactionStartedSchema = external_exports.strictObject({
|
|
18816
|
+
threadId: hostThreadIdSchema,
|
|
18817
|
+
turnId: hostTurnIdSchema
|
|
18818
|
+
});
|
|
18819
|
+
|
|
18820
|
+
// packages/shared-contracts/dist/harness-accounts.js
|
|
18821
|
+
var harnessAccountSnapshotObject = external_exports.object({
|
|
18822
|
+
email: external_exports.string().trim().min(1).max(320).optional(),
|
|
18823
|
+
label: external_exports.string().trim().min(1).max(256).optional(),
|
|
18824
|
+
plan: external_exports.string().trim().min(1).max(128).optional(),
|
|
18825
|
+
credits: accountCreditsSnapshotSchema.optional(),
|
|
18826
|
+
balance: accountBalanceSnapshotSchema.optional()
|
|
16745
18827
|
}).strict();
|
|
16746
|
-
|
|
16747
|
-
|
|
16748
|
-
|
|
16749
|
-
|
|
18828
|
+
function requireReportedQuota(schema) {
|
|
18829
|
+
return schema.refine((value) => {
|
|
18830
|
+
const reported = value;
|
|
18831
|
+
return reported.credits !== void 0 || reported.balance !== void 0;
|
|
18832
|
+
}, { message: "Account must report either credits or a balance" });
|
|
18833
|
+
}
|
|
18834
|
+
var harnessAccountSnapshotSchema = requireReportedQuota(harnessAccountSnapshotObject);
|
|
18835
|
+
var harnessAccountIdentityShape = {
|
|
18836
|
+
harnessId: harnessIdSchema,
|
|
18837
|
+
harnessName: external_exports.string().trim().min(1).max(128)
|
|
18838
|
+
};
|
|
18839
|
+
var harnessAccountSourceSchema = external_exports.object(harnessAccountIdentityShape).strict();
|
|
18840
|
+
var harnessAccountSourceListParamsSchema = external_exports.object({}).strict();
|
|
18841
|
+
var harnessAccountSourceListResultSchema = external_exports.object({ sources: external_exports.array(harnessAccountSourceSchema).max(128) }).strict();
|
|
18842
|
+
var harnessAccountInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema, refresh: external_exports.boolean().optional() }).strict();
|
|
18843
|
+
var harnessAccountInspectResultSchema = external_exports.object({
|
|
18844
|
+
...harnessAccountIdentityShape,
|
|
18845
|
+
account: harnessAccountSnapshotSchema.nullable(),
|
|
18846
|
+
/** Every Billing Source from one Harness; `account` remains the first for older clients. */
|
|
18847
|
+
accounts: external_exports.array(harnessAccountSnapshotSchema).max(8).optional()
|
|
16750
18848
|
}).strict();
|
|
16751
|
-
var
|
|
16752
|
-
var
|
|
16753
|
-
|
|
18849
|
+
var harnessAccountListParamsSchema = external_exports.object({ refresh: external_exports.boolean().optional() }).strict();
|
|
18850
|
+
var harnessAccountListResultSchema = external_exports.object({
|
|
18851
|
+
accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
|
|
16754
18852
|
}).strict();
|
|
16755
|
-
var harnessPluginConfigurationSchema = external_exports.object({
|
|
16756
|
-
version: external_exports.literal(1),
|
|
16757
|
-
enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
16758
|
-
}).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
|
|
16759
|
-
message: "Enabled plugin IDs must be unique",
|
|
16760
|
-
path: ["enabled"]
|
|
16761
|
-
});
|
|
16762
18853
|
|
|
16763
18854
|
// packages/shared-contracts/dist/harness-route.js
|
|
16764
18855
|
var harnessPluginRouteSchema = external_exports.object({
|
|
@@ -17189,6 +19280,7 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
|
17189
19280
|
message: "A history continuation requires its connection epoch"
|
|
17190
19281
|
}).optional()
|
|
17191
19282
|
}),
|
|
19283
|
+
external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
|
|
17192
19284
|
external_exports.strictObject({
|
|
17193
19285
|
kind: external_exports.literal("configure"),
|
|
17194
19286
|
...thread,
|
|
@@ -17348,7 +19440,7 @@ function isLocalPageUrl(value) {
|
|
|
17348
19440
|
return false;
|
|
17349
19441
|
}
|
|
17350
19442
|
}
|
|
17351
|
-
async function serveLocalPage(socket, url2,
|
|
19443
|
+
async function serveLocalPage(socket, url2, open2) {
|
|
17352
19444
|
let page;
|
|
17353
19445
|
let buffer = "";
|
|
17354
19446
|
let operation = Promise.resolve();
|
|
@@ -17380,7 +19472,7 @@ async function serveLocalPage(socket, url2, open) {
|
|
|
17380
19472
|
}
|
|
17381
19473
|
};
|
|
17382
19474
|
try {
|
|
17383
|
-
page = await
|
|
19475
|
+
page = await open2(url2);
|
|
17384
19476
|
if (socket.destroyed) return;
|
|
17385
19477
|
socket.on("data", receive);
|
|
17386
19478
|
socket.write("ready\n");
|
|
@@ -17634,6 +19726,9 @@ function createControllerStatusPublisher(filePath = defaultControllerStatusPath(
|
|
|
17634
19726
|
};
|
|
17635
19727
|
}
|
|
17636
19728
|
|
|
19729
|
+
// packages/desktop-control/src/renderer-cdp-control-session.ts
|
|
19730
|
+
import { createHash } from "node:crypto";
|
|
19731
|
+
|
|
17637
19732
|
// packages/desktop-control/src/renderer-react-ownership.ts
|
|
17638
19733
|
function committedReactAncestors(value) {
|
|
17639
19734
|
const MAX_VISITED_FIBERS = 2e5;
|
|
@@ -17663,13 +19758,13 @@ function committedReactAncestors(value) {
|
|
|
17663
19758
|
const current = fiber(rootState.current);
|
|
17664
19759
|
if (!current) return [];
|
|
17665
19760
|
const alternate = fiber(first.alternate);
|
|
17666
|
-
const
|
|
19761
|
+
const path7 = [current];
|
|
17667
19762
|
seen.clear();
|
|
17668
19763
|
seen.add(current);
|
|
17669
19764
|
for (let index = previous.length - 2; index >= 0; index -= 1) {
|
|
17670
19765
|
const expected = previous[index];
|
|
17671
19766
|
const expectedAlternate = fiber(expected?.alternate);
|
|
17672
|
-
let child = fiber(
|
|
19767
|
+
let child = fiber(path7.at(-1)?.child);
|
|
17673
19768
|
let matched = false;
|
|
17674
19769
|
while (child && !seen.has(child) && seen.size < MAX_VISITED_FIBERS) {
|
|
17675
19770
|
seen.add(child);
|
|
@@ -17680,10 +19775,10 @@ function committedReactAncestors(value) {
|
|
|
17680
19775
|
child = fiber(child.sibling);
|
|
17681
19776
|
}
|
|
17682
19777
|
if (!matched || !child) break;
|
|
17683
|
-
|
|
19778
|
+
path7.push(child);
|
|
17684
19779
|
}
|
|
17685
|
-
if (
|
|
17686
|
-
return
|
|
19780
|
+
if (path7.length === previous.length && (path7.at(-1) === first || path7.at(-1) === alternate)) {
|
|
19781
|
+
return path7.reverse();
|
|
17687
19782
|
}
|
|
17688
19783
|
const stack = [{ node: current, parent: null }];
|
|
17689
19784
|
seen.clear();
|
|
@@ -17758,20 +19853,20 @@ function retainRendererHostResponses(client, hostId2, target2) {
|
|
|
17758
19853
|
|
|
17759
19854
|
// packages/desktop-control/src/renderer-prewarm-consumption.ts
|
|
17760
19855
|
function isolateRendererPrewarmConsumption(manager, discardExternal) {
|
|
17761
|
-
const
|
|
17762
|
-
if (!
|
|
19856
|
+
const record5 = (value) => value !== null && typeof value === "object";
|
|
19857
|
+
if (!record5(manager) || !record5(manager.threadCreation)) return null;
|
|
17763
19858
|
const creation = manager.threadCreation;
|
|
17764
19859
|
const originalStart = manager.startConversation;
|
|
17765
19860
|
const original = creation.createConversation;
|
|
17766
19861
|
const params = creation.params;
|
|
17767
|
-
if (typeof originalStart !== "function" || typeof original !== "function" || !
|
|
19862
|
+
if (typeof originalStart !== "function" || typeof original !== "function" || !record5(params))
|
|
17768
19863
|
return null;
|
|
17769
19864
|
const prototype = Object.getPrototypeOf(creation);
|
|
17770
|
-
if (!
|
|
19865
|
+
if (!record5(prototype) || typeof prototype.constructor !== "function") return null;
|
|
17771
19866
|
if (Object.keys(creation).some((key) => key !== "params" && typeof creation[key] !== "function") || /#[A-Za-z_$]/u.test(Function.prototype.toString.call(prototype.constructor)))
|
|
17772
19867
|
return null;
|
|
17773
19868
|
const pool = params.prewarmedThreadManager;
|
|
17774
|
-
if (!
|
|
19869
|
+
if (!record5(pool) || typeof pool.hasPrewarmedThread !== "function" || typeof pool.consumePrewarmedThread !== "function" || typeof pool.deletePrewarmedThread !== "function")
|
|
17775
19870
|
return null;
|
|
17776
19871
|
const consume = pool.consumePrewarmedThread;
|
|
17777
19872
|
const hasPrewarm = pool.hasPrewarmedThread;
|
|
@@ -17779,14 +19874,14 @@ function isolateRendererPrewarmConsumption(manager, discardExternal) {
|
|
|
17779
19874
|
const draftIdentity = /* @__PURE__ */ Symbol("codexhost draft creation");
|
|
17780
19875
|
const external = (model2) => typeof model2 === "string" && model2.startsWith("codexhost/");
|
|
17781
19876
|
const routedStart = function(input, options, ...args) {
|
|
17782
|
-
const draftId =
|
|
17783
|
-
const mode =
|
|
19877
|
+
const draftId = record5(options) ? options.clientThreadId : null;
|
|
19878
|
+
const mode = record5(input) && record5(input.collaborationMode) ? input.collaborationMode : null;
|
|
17784
19879
|
const origin = mode ? Reflect.get(mode, draftIdentity) : void 0;
|
|
17785
|
-
if (mode &&
|
|
19880
|
+
if (mode && record5(mode.settings) && external(mode.settings.model))
|
|
17786
19881
|
return originalStart.call(this, input, options, ...args);
|
|
17787
19882
|
const model2 = (typeof draftId === "string" ? draftModels.get(draftId) : void 0) ?? (typeof origin === "string" ? draftModels.get(origin) : void 0);
|
|
17788
19883
|
if (!model2) return originalStart.call(this, input, options, ...args);
|
|
17789
|
-
if (!
|
|
19884
|
+
if (!record5(input) || !record5(input.collaborationMode) || !record5(input.collaborationMode.settings))
|
|
17790
19885
|
throw new Error("External draft creation is missing its native Model settings");
|
|
17791
19886
|
const routed = {
|
|
17792
19887
|
...input,
|
|
@@ -17798,17 +19893,17 @@ function isolateRendererPrewarmConsumption(manager, discardExternal) {
|
|
|
17798
19893
|
return originalStart.call(this, routed, options, ...args);
|
|
17799
19894
|
};
|
|
17800
19895
|
const wrapped = function(input, ...args) {
|
|
17801
|
-
const mode =
|
|
17802
|
-
const expected = mode &&
|
|
19896
|
+
const mode = record5(input) && record5(input.collaborationMode) ? input.collaborationMode : null;
|
|
19897
|
+
const expected = mode && record5(mode.settings) ? mode.settings.model : null;
|
|
17803
19898
|
const scopedPool = Object.create(pool);
|
|
17804
19899
|
scopedPool.hasPrewarmedThread = (...parameters) => hasPrewarm.apply(pool, parameters);
|
|
17805
19900
|
scopedPool.consumePrewarmedThread = async (...consumeArgs) => {
|
|
17806
19901
|
const warmed = await consume.apply(pool, consumeArgs);
|
|
17807
|
-
if (!
|
|
19902
|
+
if (!record5(warmed) || !record5(warmed.response)) return warmed;
|
|
17808
19903
|
const response = warmed.response;
|
|
17809
19904
|
if (!external(expected) && !external(response.model)) return warmed;
|
|
17810
19905
|
if (external(expected) && expected === response.model) return warmed;
|
|
17811
|
-
if (
|
|
19906
|
+
if (record5(response.thread) && typeof response.thread.id === "string") {
|
|
17812
19907
|
const threadId = response.thread.id;
|
|
17813
19908
|
if (external(response.model)) discardExternal(threadId);
|
|
17814
19909
|
else
|
|
@@ -18230,15 +20325,35 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target2, prewa
|
|
|
18230
20325
|
if (threadId && knownOfficialThreadIds.has(threadId)) return false;
|
|
18231
20326
|
return selectedModel !== null && (method.startsWith("thread/") || method.startsWith("turn/") || method.startsWith("review/"));
|
|
18232
20327
|
};
|
|
20328
|
+
const inspectKnownOfficialThread = (threadId) => Promise.resolve(
|
|
20329
|
+
originalSend.call(bridge, "thread/read", { threadId, includeTurns: false })
|
|
20330
|
+
).then((value) => {
|
|
20331
|
+
const thread2 = isRecord3(value) ? value.thread : null;
|
|
20332
|
+
if (!isRecord3(thread2) || thread2.id !== threadId || typeof thread2.modelProvider !== "string" || !thread2.modelProvider || thread2.modelProvider === "codexhost" || typeof thread2.cliVersion !== "string" || !thread2.cliVersion || thread2.cliVersion === "codexhost") {
|
|
20333
|
+
knownOfficialThreadIds.delete(threadId);
|
|
20334
|
+
throw transportError("Native Thread response cannot establish Codex ownership");
|
|
20335
|
+
}
|
|
20336
|
+
return { owner: "codex", locked: true };
|
|
20337
|
+
});
|
|
18233
20338
|
const routedSend = (method, parameters, options) => {
|
|
20339
|
+
const threadId = threadIdFromParameters(parameters);
|
|
18234
20340
|
if (method === "turn/start" || method === "thread/resume" || method === "codexhost/thread/command/execute") {
|
|
18235
|
-
const threadId = threadIdFromParameters(parameters);
|
|
18236
20341
|
if (threadId) externalPrewarms.delete(threadId);
|
|
18237
20342
|
}
|
|
18238
20343
|
const sendBridged = () => initializeBridge().then(
|
|
18239
20344
|
() => enqueueBridgeRequest(method, parameters, options)
|
|
18240
20345
|
);
|
|
18241
20346
|
const sendDirect = () => options === void 0 ? originalSend.call(bridge, method, parameters) : originalSend.call(bridge, method, parameters, options);
|
|
20347
|
+
if (isRemoteControlHost && method === "codexhost/thread/inspect" && threadId) {
|
|
20348
|
+
if (knownOfficialThreadIds.has(threadId)) return inspectKnownOfficialThread(threadId);
|
|
20349
|
+
return sendBridged().catch((error51) => {
|
|
20350
|
+
if (!isUnsupportedPosixBridgeSpawn(error51)) throw error51;
|
|
20351
|
+
return inspectKnownOfficialThread(threadId).then((inspection) => {
|
|
20352
|
+
knownOfficialThreadIds.add(threadId);
|
|
20353
|
+
return inspection;
|
|
20354
|
+
});
|
|
20355
|
+
});
|
|
20356
|
+
}
|
|
18242
20357
|
const unresolvedThreadId = shouldResolveThreadOwnership(method, parameters);
|
|
18243
20358
|
if (unresolvedThreadId) {
|
|
18244
20359
|
return resolveThreadOwnership(unresolvedThreadId).then(
|
|
@@ -18414,14 +20529,14 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target2, prewa
|
|
|
18414
20529
|
|
|
18415
20530
|
// packages/desktop-control/src/renderer-host-discovery.ts
|
|
18416
20531
|
function requestManagerFromHookState(value, hostId2) {
|
|
18417
|
-
const
|
|
20532
|
+
const record5 = (candidate) => typeof candidate === "object" && candidate !== null;
|
|
18418
20533
|
const manager = (candidate) => {
|
|
18419
|
-
if (!
|
|
20534
|
+
if (!record5(candidate) || !record5(candidate.requestClient) || !record5(candidate.prewarmedThreadManager))
|
|
18420
20535
|
return null;
|
|
18421
20536
|
const bridge = candidate.requestClient;
|
|
18422
20537
|
return typeof candidate.sendRequest === "function" && typeof bridge.sendRequest === "function" && typeof bridge.prewarmThreadStart === "function" && typeof bridge.enqueueRequest === "function" && typeof candidate.prewarmedThreadManager.discardAllPrewarmedThreads === "function" ? candidate : null;
|
|
18423
20538
|
};
|
|
18424
|
-
if (!
|
|
20539
|
+
if (!record5(value)) return null;
|
|
18425
20540
|
const direct = manager(value) ?? manager(value.manager);
|
|
18426
20541
|
if (direct) return direct;
|
|
18427
20542
|
if (!hostId2 || typeof value.addManager !== "function" || typeof value.getForHostId !== "function")
|
|
@@ -18496,7 +20611,7 @@ function resolveRendererHostManager(discovery, hostId2, managerFrom = requestMan
|
|
|
18496
20611
|
}
|
|
18497
20612
|
|
|
18498
20613
|
// packages/desktop-control/src/renderer-host-routing.ts
|
|
18499
|
-
function installRendererHostRouting(root, target2,
|
|
20614
|
+
function installRendererHostRouting(root, target2, discover2, resolve, createPolicy, readConnection, publishRouting = true) {
|
|
18500
20615
|
const existing = target2.__codexhostHostRoutingV1;
|
|
18501
20616
|
if (publishRouting && existing) return existing;
|
|
18502
20617
|
if (publishRouting)
|
|
@@ -18508,7 +20623,7 @@ function installRendererHostRouting(root, target2, discover, resolve, createPoli
|
|
|
18508
20623
|
const source = composer?.matches?.(
|
|
18509
20624
|
'[data-codex-composer], [contenteditable="true"][role="textbox"]'
|
|
18510
20625
|
) ? { querySelectorAll: () => [composer] } : composer ?? root;
|
|
18511
|
-
const discovery =
|
|
20626
|
+
const discovery = discover2(source);
|
|
18512
20627
|
if (composer) return discovery;
|
|
18513
20628
|
if (discovery.editorCount === 0 && lastDiscovery) return lastDiscovery;
|
|
18514
20629
|
lastDiscovery = discovery;
|
|
@@ -18652,15 +20767,15 @@ function installRendererHostRouting(root, target2, discover, resolve, createPoli
|
|
|
18652
20767
|
// packages/desktop-control/src/renderer-host-rpc-discovery.ts
|
|
18653
20768
|
function findRendererAppScopeStore(root) {
|
|
18654
20769
|
const MAX_VISITED_FIBERS = 5e4;
|
|
18655
|
-
const
|
|
20770
|
+
const record5 = (value) => typeof value === "object" && value !== null;
|
|
18656
20771
|
const container = root.getElementById?.("root");
|
|
18657
|
-
if (!
|
|
20772
|
+
if (!record5(container)) return null;
|
|
18658
20773
|
const key = Object.getOwnPropertyNames(container).find(
|
|
18659
20774
|
(name) => name.startsWith("__reactContainer$")
|
|
18660
20775
|
);
|
|
18661
20776
|
const first = key ? container[key] : null;
|
|
18662
|
-
if (!
|
|
18663
|
-
const isScopeHandle = (value) =>
|
|
20777
|
+
if (!record5(first)) return null;
|
|
20778
|
+
const isScopeHandle = (value) => record5(value) && record5(value.node) && "chain" in value && "scope" in value && typeof value.get === "function" && typeof value.set === "function" && typeof value.watch === "function";
|
|
18664
20779
|
const stack = [first];
|
|
18665
20780
|
const seen = /* @__PURE__ */ new Set();
|
|
18666
20781
|
while (stack.length && seen.size < MAX_VISITED_FIBERS) {
|
|
@@ -18668,44 +20783,44 @@ function findRendererAppScopeStore(root) {
|
|
|
18668
20783
|
if (seen.has(fiber)) continue;
|
|
18669
20784
|
seen.add(fiber);
|
|
18670
20785
|
let hook = fiber.memoizedState;
|
|
18671
|
-
for (let index = 0;
|
|
20786
|
+
for (let index = 0; record5(hook) && "next" in hook && index < 150; index += 1) {
|
|
18672
20787
|
const state = hook.memoizedState;
|
|
18673
|
-
const handle =
|
|
20788
|
+
const handle = record5(state) ? state.current : null;
|
|
18674
20789
|
if (isScopeHandle(handle)) {
|
|
18675
20790
|
let node = handle.node;
|
|
18676
20791
|
const nodes = /* @__PURE__ */ new Set();
|
|
18677
|
-
while (
|
|
20792
|
+
while (record5(node.parent) && !nodes.has(node.parent)) {
|
|
18678
20793
|
nodes.add(node);
|
|
18679
20794
|
node = node.parent;
|
|
18680
20795
|
}
|
|
18681
20796
|
const bindings = node.familyBindings;
|
|
18682
|
-
return
|
|
20797
|
+
return record5(bindings) && typeof bindings.get === "function" && typeof bindings.entries === "function" ? node : null;
|
|
18683
20798
|
}
|
|
18684
20799
|
hook = hook.next;
|
|
18685
20800
|
}
|
|
18686
|
-
if (
|
|
18687
|
-
if (
|
|
20801
|
+
if (record5(fiber.sibling)) stack.push(fiber.sibling);
|
|
20802
|
+
if (record5(fiber.child)) stack.push(fiber.child);
|
|
18688
20803
|
}
|
|
18689
20804
|
return null;
|
|
18690
20805
|
}
|
|
18691
20806
|
function findRendererHostRpcFamily(store) {
|
|
18692
|
-
const
|
|
20807
|
+
const record5 = (value) => typeof value === "object" && value !== null;
|
|
18693
20808
|
const families = /* @__PURE__ */ new Set();
|
|
18694
20809
|
for (const [definition, members] of store.familyBindings) {
|
|
18695
|
-
if (!
|
|
18696
|
-
if (!
|
|
20810
|
+
if (!record5(definition) || definition.kind !== "signal-family") continue;
|
|
20811
|
+
if (!record5(members) || typeof members.get !== "function") continue;
|
|
18697
20812
|
for (const [hostId2, member] of members) {
|
|
18698
20813
|
if (typeof hostId2 !== "string" || !/^(?:local$|durable$|remote[-:])/u.test(hostId2)) continue;
|
|
18699
|
-
if (!
|
|
20814
|
+
if (!record5(member)) continue;
|
|
18700
20815
|
const signal = member.value;
|
|
18701
|
-
if (!
|
|
20816
|
+
if (!record5(signal) || typeof signal.get !== "function") continue;
|
|
18702
20817
|
let value;
|
|
18703
20818
|
try {
|
|
18704
20819
|
value = signal.get();
|
|
18705
20820
|
} catch {
|
|
18706
20821
|
continue;
|
|
18707
20822
|
}
|
|
18708
|
-
if (
|
|
20823
|
+
if (record5(value) && Object.keys(value).length === 2 && typeof value.status === "string" && record5(value.client) && value.client.hostId === hostId2 && "rpc" in value.client) {
|
|
18709
20824
|
families.add(members);
|
|
18710
20825
|
break;
|
|
18711
20826
|
}
|
|
@@ -18716,34 +20831,34 @@ function findRendererHostRpcFamily(store) {
|
|
|
18716
20831
|
}
|
|
18717
20832
|
function resolveRendererHostRpc(discovery, hostId2) {
|
|
18718
20833
|
if (hostId2 === "durable") return null;
|
|
18719
|
-
const
|
|
20834
|
+
const record5 = (value2) => typeof value2 === "object" && value2 !== null;
|
|
18720
20835
|
const signal = discovery.family.get(hostId2)?.value;
|
|
18721
|
-
if (!
|
|
20836
|
+
if (!record5(signal) || typeof signal.get !== "function") return null;
|
|
18722
20837
|
let value;
|
|
18723
20838
|
try {
|
|
18724
20839
|
value = signal.get();
|
|
18725
20840
|
} catch {
|
|
18726
20841
|
return null;
|
|
18727
20842
|
}
|
|
18728
|
-
if (!
|
|
20843
|
+
if (!record5(value) || value.status !== "ready" || !record5(value.client) || value.client.hostId !== hostId2)
|
|
18729
20844
|
return null;
|
|
18730
20845
|
const rpc = value.client.rpc;
|
|
18731
|
-
return typeof rpc === "function" ||
|
|
20846
|
+
return typeof rpc === "function" || record5(rpc) ? rpc : null;
|
|
18732
20847
|
}
|
|
18733
20848
|
function rendererHostRpcHostIds(discovery) {
|
|
18734
|
-
const
|
|
20849
|
+
const record5 = (value) => typeof value === "object" && value !== null;
|
|
18735
20850
|
const hostIds = [];
|
|
18736
20851
|
for (const [hostId2, member] of discovery.family) {
|
|
18737
|
-
if (typeof hostId2 !== "string" || hostId2 === "durable" || !
|
|
20852
|
+
if (typeof hostId2 !== "string" || hostId2 === "durable" || !record5(member)) continue;
|
|
18738
20853
|
const signal = member.value;
|
|
18739
|
-
if (!
|
|
20854
|
+
if (!record5(signal) || typeof signal.get !== "function") continue;
|
|
18740
20855
|
let value;
|
|
18741
20856
|
try {
|
|
18742
20857
|
value = signal.get();
|
|
18743
20858
|
} catch {
|
|
18744
20859
|
continue;
|
|
18745
20860
|
}
|
|
18746
|
-
if (
|
|
20861
|
+
if (record5(value) && value.status === "ready" && record5(value.client) && value.client.hostId === hostId2 && (typeof value.client.rpc === "function" || record5(value.client.rpc))) {
|
|
18747
20862
|
hostIds.push(hostId2);
|
|
18748
20863
|
}
|
|
18749
20864
|
}
|
|
@@ -18825,25 +20940,25 @@ function installRendererHostRpcRouting(root, target2, dependencies) {
|
|
|
18825
20940
|
const expression = message[1];
|
|
18826
20941
|
if (!Array.isArray(expression) || expression.length !== 4 || expression[0] !== "pipeline")
|
|
18827
20942
|
return message;
|
|
18828
|
-
const [, importId,
|
|
18829
|
-
if (!Array.isArray(
|
|
20943
|
+
const [, importId, path7, args] = expression;
|
|
20944
|
+
if (!Array.isArray(path7) || path7.length !== 1 || !Array.isArray(args)) return message;
|
|
18830
20945
|
const [input, options] = args;
|
|
18831
20946
|
if (!isRecord3(input) || !isRecord3(input.collaborationMode)) return message;
|
|
18832
20947
|
const settings = input.collaborationMode.settings;
|
|
18833
20948
|
if (!isRecord3(settings)) return message;
|
|
18834
20949
|
const nativeModel = typeof settings.model === "string" ? settings.model : null;
|
|
18835
20950
|
let model2 = null;
|
|
18836
|
-
if (
|
|
20951
|
+
if (path7[0] === "startConversation") {
|
|
18837
20952
|
const draftId = isRecord3(options) ? options.clientThreadId : null;
|
|
18838
20953
|
model2 = typeof draftId === "string" ? externalDrafts.get(draftId)?.model ?? null : null;
|
|
18839
|
-
} else if (
|
|
20954
|
+
} else if (path7[0] === "prewarmConversation") {
|
|
18840
20955
|
if (input.ephemeral !== true) publishDraftWorkspace("local", input.cwd);
|
|
18841
20956
|
const selected = selectedModels.get("local") ?? null;
|
|
18842
20957
|
const carrier = nativeModel?.startsWith("codexhost/") ? nativeModel : selected;
|
|
18843
20958
|
model2 = carrier ? prewarmCarrier(carrier) : null;
|
|
18844
20959
|
}
|
|
18845
20960
|
if (!model2) return message;
|
|
18846
|
-
if (
|
|
20961
|
+
if (path7[0] === "startConversation" && nativeModel?.startsWith("codexhost/"))
|
|
18847
20962
|
model2 = nativeModel;
|
|
18848
20963
|
const config2 = input.config == null ? { model: model2 } : isRecord3(input.config) ? { model: model2, ...input.config } : input.config;
|
|
18849
20964
|
return [
|
|
@@ -18851,11 +20966,11 @@ function installRendererHostRpcRouting(root, target2, dependencies) {
|
|
|
18851
20966
|
[
|
|
18852
20967
|
"pipeline",
|
|
18853
20968
|
importId,
|
|
18854
|
-
|
|
20969
|
+
path7,
|
|
18855
20970
|
[
|
|
18856
20971
|
{
|
|
18857
20972
|
...input,
|
|
18858
|
-
...
|
|
20973
|
+
...path7[0] === "startConversation" ? { config: config2 } : {},
|
|
18859
20974
|
collaborationMode: { ...input.collaborationMode, settings: { ...settings, model: model2 } }
|
|
18860
20975
|
},
|
|
18861
20976
|
...args.slice(1)
|
|
@@ -19082,11 +21197,11 @@ function installRendererHostRpcRouting(root, target2, dependencies) {
|
|
|
19082
21197
|
// packages/desktop-control/src/renderer-connection-generation.ts
|
|
19083
21198
|
function readRendererConnectionGeneration(store, hostId2) {
|
|
19084
21199
|
if (!store) return void 0;
|
|
19085
|
-
const
|
|
21200
|
+
const record5 = (value) => value !== null && typeof value === "object";
|
|
19086
21201
|
const candidates = /* @__PURE__ */ new Set();
|
|
19087
21202
|
for (const members of store.familyBindings.values()) {
|
|
19088
21203
|
const value = members.get(hostId2)?.value;
|
|
19089
|
-
if (
|
|
21204
|
+
if (record5(value) && record5(value.state$) && record5(value.revision$) && record5(value.appServerVersion$) && typeof value.state$.get === "function" && typeof value.revision$.get === "function")
|
|
19090
21205
|
candidates.add(value);
|
|
19091
21206
|
}
|
|
19092
21207
|
if (!candidates.size) return void 0;
|
|
@@ -19210,7 +21325,7 @@ function nativeModuleCatalogExpression(urls, complete, owner) {
|
|
|
19210
21325
|
value: Object.freeze({ owner: ${JSON.stringify(owner)}, documentUrl: location.href, complete: ${complete}, urls: Object.freeze(${JSON.stringify(urls)}) })
|
|
19211
21326
|
}); void 0`;
|
|
19212
21327
|
}
|
|
19213
|
-
async function installRendererLoadedModules(renderer) {
|
|
21328
|
+
async function installRendererLoadedModules(renderer, onDesktopContext) {
|
|
19214
21329
|
const owner = crypto.randomUUID();
|
|
19215
21330
|
const contexts = /* @__PURE__ */ new Map();
|
|
19216
21331
|
const contextIds = /* @__PURE__ */ new Map();
|
|
@@ -19273,6 +21388,8 @@ async function installRendererLoadedModules(renderer) {
|
|
|
19273
21388
|
const context = record3(params) ? params.context : null;
|
|
19274
21389
|
if (!record3(context) || typeof context.id !== "number" || typeof context.uniqueId !== "string" || !record3(context.auxData) || context.auxData.isDefault !== true)
|
|
19275
21390
|
return;
|
|
21391
|
+
if (typeof context.origin === "string" && /^app:\/\/-\/?$/u.test(context.origin))
|
|
21392
|
+
onDesktopContext?.();
|
|
19276
21393
|
contextIds.set(context.id, context.uniqueId);
|
|
19277
21394
|
contexts.set(context.uniqueId, { urls: /* @__PURE__ */ new Set(), complete: true });
|
|
19278
21395
|
schedule(context.uniqueId);
|
|
@@ -19311,7 +21428,7 @@ async function installRendererLoadedModules(renderer) {
|
|
|
19311
21428
|
};
|
|
19312
21429
|
try {
|
|
19313
21430
|
await renderer.command("Runtime.enable");
|
|
19314
|
-
await renderer.command("Debugger.enable");
|
|
21431
|
+
await renderer.command("Debugger.enable", { maxScriptsCacheSize: 0 });
|
|
19315
21432
|
ready = true;
|
|
19316
21433
|
await flush();
|
|
19317
21434
|
return dispose;
|
|
@@ -19620,9 +21737,9 @@ function createNativeRemoteManager(components, hostId2, original, target2, creat
|
|
|
19620
21737
|
pending.add(result);
|
|
19621
21738
|
return result;
|
|
19622
21739
|
};
|
|
19623
|
-
const
|
|
21740
|
+
const record5 = (value) => value !== null && typeof value === "object";
|
|
19624
21741
|
const dispatch = (type, payload) => {
|
|
19625
|
-
if ((type === "mcp-request" || type === "thread-prewarm-start") &&
|
|
21742
|
+
if ((type === "mcp-request" || type === "thread-prewarm-start") && record5(payload) && record5(payload.request)) {
|
|
19626
21743
|
const request = payload.request;
|
|
19627
21744
|
const options = {};
|
|
19628
21745
|
for (const key of ["priority", "timeoutMs", "source", "trace", "threadAccess"])
|
|
@@ -19634,7 +21751,7 @@ function createNativeRemoteManager(components, hostId2, original, target2, creat
|
|
|
19634
21751
|
(error51) => {
|
|
19635
21752
|
if (!disposed)
|
|
19636
21753
|
client.onError(request.id, {
|
|
19637
|
-
code:
|
|
21754
|
+
code: record5(error51) ? error51.jsonRpcCode ?? error51.code ?? -32603 : -32603,
|
|
19638
21755
|
message: error51 instanceof Error ? error51.message : String(error51)
|
|
19639
21756
|
});
|
|
19640
21757
|
}
|
|
@@ -19681,13 +21798,13 @@ function createNativeRemoteManager(components, hostId2, original, target2, creat
|
|
|
19681
21798
|
interactions = nativeInteractions;
|
|
19682
21799
|
const notify = (event) => {
|
|
19683
21800
|
const { data, source: source2, origin } = event;
|
|
19684
|
-
if (disposed || source2 != null && source2 !== target2 || !
|
|
21801
|
+
if (disposed || source2 != null && source2 !== target2 || !record5(data) || data.hostId !== hostId2)
|
|
19685
21802
|
return;
|
|
19686
|
-
const ownOrigin =
|
|
21803
|
+
const ownOrigin = record5(target2.location) ? target2.location.origin : void 0;
|
|
19687
21804
|
if (source2 === target2 && ownOrigin && ownOrigin !== "null" && origin !== ownOrigin) return;
|
|
19688
21805
|
if (data.type === "mcp-notification" && typeof data.method === "string" && !data.method.startsWith("process/"))
|
|
19689
21806
|
owned.onNotification(data.method, data.params);
|
|
19690
|
-
if (data.type === "mcp-request") owned.onRequest(
|
|
21807
|
+
if (data.type === "mcp-request") owned.onRequest(record5(data.request) ? data.request : data);
|
|
19691
21808
|
};
|
|
19692
21809
|
target2.addEventListener?.("message", notify);
|
|
19693
21810
|
return {
|
|
@@ -19780,7 +21897,7 @@ function createNativeRpcService(components, createRemote) {
|
|
|
19780
21897
|
const routes = /* @__PURE__ */ new Map();
|
|
19781
21898
|
const subscriptions = /* @__PURE__ */ new Set();
|
|
19782
21899
|
let refs = 1;
|
|
19783
|
-
const
|
|
21900
|
+
const record5 = (value) => value !== null && typeof value === "object";
|
|
19784
21901
|
const connectionSignals = (hostId2) => {
|
|
19785
21902
|
let node = components.scope.node;
|
|
19786
21903
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -19791,7 +21908,7 @@ function createNativeRpcService(components, createRemote) {
|
|
|
19791
21908
|
const found = [];
|
|
19792
21909
|
for (const members of node.familyBindings.values()) {
|
|
19793
21910
|
const value = members.get(hostId2)?.value;
|
|
19794
|
-
if (
|
|
21911
|
+
if (record5(value) && Object.hasOwn(value, "state$") && Object.hasOwn(value, "revision$") && Object.hasOwn(value, "appServerVersion$"))
|
|
19795
21912
|
found.push({ state$: value.state$, revision$: value.revision$ });
|
|
19796
21913
|
}
|
|
19797
21914
|
return found.length === 1 ? found[0] : void 0;
|
|
@@ -19936,7 +22053,7 @@ function retainNativeRpcInteractions(upstream, manager, hostId2) {
|
|
|
19936
22053
|
const retained = /* @__PURE__ */ new Set();
|
|
19937
22054
|
const requests = /* @__PURE__ */ new Map();
|
|
19938
22055
|
const reads = /* @__PURE__ */ new Map();
|
|
19939
|
-
const
|
|
22056
|
+
const record5 = (value) => value !== null && typeof value === "object";
|
|
19940
22057
|
const read = (threadId) => {
|
|
19941
22058
|
const existing = reads.get(threadId);
|
|
19942
22059
|
if (existing) {
|
|
@@ -19953,12 +22070,12 @@ function retainNativeRpcInteractions(upstream, manager, hostId2) {
|
|
|
19953
22070
|
retained.add(pending);
|
|
19954
22071
|
try {
|
|
19955
22072
|
const conversation = await pending;
|
|
19956
|
-
if (disposed || entry.dirty || !
|
|
22073
|
+
if (disposed || entry.dirty || !record5(conversation) || !Array.isArray(conversation.requests))
|
|
19957
22074
|
continue;
|
|
19958
22075
|
const previous = requests.get(threadId) ?? /* @__PURE__ */ new Set();
|
|
19959
22076
|
const next = /* @__PURE__ */ new Set();
|
|
19960
22077
|
for (const request of conversation.requests) {
|
|
19961
|
-
if (!
|
|
22078
|
+
if (!record5(request) || typeof request.method !== "string" || !record5(request.params) || (request.params.threadId ?? request.params.conversationId) !== threadId || typeof request.id !== "string" && typeof request.id !== "number")
|
|
19962
22079
|
continue;
|
|
19963
22080
|
next.add(request.id);
|
|
19964
22081
|
if (!previous.has(request.id)) manager.onRequest(request);
|
|
@@ -19975,7 +22092,7 @@ function retainNativeRpcInteractions(upstream, manager, hostId2) {
|
|
|
19975
22092
|
return entry.promise;
|
|
19976
22093
|
};
|
|
19977
22094
|
const event = (value) => {
|
|
19978
|
-
if (disposed || !
|
|
22095
|
+
if (disposed || !record5(value) || typeof value.conversationId !== "string") return;
|
|
19979
22096
|
void read(value.conversationId).catch(() => void 0);
|
|
19980
22097
|
};
|
|
19981
22098
|
const subscribe = (input) => {
|
|
@@ -19998,7 +22115,7 @@ function retainNativeRpcInteractions(upstream, manager, hostId2) {
|
|
|
19998
22115
|
key: { hostId: hostId2 },
|
|
19999
22116
|
methods: ["serverRequest/resolved"],
|
|
20000
22117
|
listener(value) {
|
|
20001
|
-
if (
|
|
22118
|
+
if (record5(value) && record5(value.params) && typeof value.params.threadId === "string")
|
|
20002
22119
|
event({ conversationId: value.params.threadId });
|
|
20003
22120
|
}
|
|
20004
22121
|
})
|
|
@@ -20013,7 +22130,7 @@ function retainNativeRpcInteractions(upstream, manager, hostId2) {
|
|
|
20013
22130
|
if (!Array.isArray(work)) throw new Error("Native RPC interaction snapshot is unavailable");
|
|
20014
22131
|
const threadIds = new Set(
|
|
20015
22132
|
work.flatMap(
|
|
20016
|
-
(item) =>
|
|
22133
|
+
(item) => record5(item) && typeof item.conversationId === "string" ? [item.conversationId] : []
|
|
20017
22134
|
)
|
|
20018
22135
|
);
|
|
20019
22136
|
await Promise.all([...threadIds].map(read));
|
|
@@ -20218,8 +22335,8 @@ function discoveryTimeoutSignal(timeoutMs, signal) {
|
|
|
20218
22335
|
const timeout = AbortSignal.timeout(timeoutMs);
|
|
20219
22336
|
return signal ? AbortSignal.any([timeout, signal]) : timeout;
|
|
20220
22337
|
}
|
|
20221
|
-
function abortFailure(signal,
|
|
20222
|
-
return signal.reason instanceof Error ? signal.reason : new Error(
|
|
22338
|
+
function abortFailure(signal, fallback2) {
|
|
22339
|
+
return signal.reason instanceof Error ? signal.reason : new Error(fallback2);
|
|
20223
22340
|
}
|
|
20224
22341
|
function awaitWithSignal(promise2, signal, timeoutMessage) {
|
|
20225
22342
|
if (signal.aborted) return Promise.reject(abortFailure(signal, timeoutMessage));
|
|
@@ -20350,25 +22467,54 @@ async function waitForBinding(renderer, enabledAgents, timeoutMs, pollIntervalMs
|
|
|
20350
22467
|
const detail = lastError instanceof Error ? `: ${lastError.message}` : "";
|
|
20351
22468
|
throw new Error(`Production Renderer binding did not become ready${detail}`);
|
|
20352
22469
|
}
|
|
20353
|
-
|
|
22470
|
+
function reconnectableRendererSource(source) {
|
|
22471
|
+
const hash2 = JSON.stringify(createHash("sha256").update(source).digest("hex"));
|
|
22472
|
+
return `if (window.top === window && (window.__codexhostControllerBundleHash !== ${hash2} || !window.__codexhostRendererBindingProbeV1)) {
|
|
22473
|
+
${source}
|
|
22474
|
+
window.__codexhostControllerBundleHash = ${hash2};
|
|
22475
|
+
}`;
|
|
22476
|
+
}
|
|
22477
|
+
async function installTarget(target2, rendererSource, enabledAgents, timeoutMs, pollIntervalMs, operations, extensions, replacingSession = false) {
|
|
20354
22478
|
const renderer = await operations.connect(target2.webSocketDebuggerUrl);
|
|
20355
22479
|
let disposeModules;
|
|
22480
|
+
let detach;
|
|
22481
|
+
const attachExtensions = () => {
|
|
22482
|
+
detach ??= extensions?.attach(target2.id, renderer);
|
|
22483
|
+
};
|
|
20356
22484
|
try {
|
|
20357
|
-
disposeModules = await installRendererLoadedModules(
|
|
22485
|
+
disposeModules = await installRendererLoadedModules(
|
|
22486
|
+
renderer,
|
|
22487
|
+
extensions ? () => extensions.hint() : void 0
|
|
22488
|
+
);
|
|
20358
22489
|
await renderer.command("Page.enable");
|
|
20359
|
-
|
|
20360
|
-
await
|
|
22490
|
+
const source = extensions ? reconnectableRendererSource(rendererSource) : rendererSource;
|
|
22491
|
+
await renderer.command("Page.addScriptToEvaluateOnNewDocument", { source });
|
|
22492
|
+
if (!replacingSession) attachExtensions();
|
|
22493
|
+
await evaluateSource(renderer, source);
|
|
20361
22494
|
const draftPrewarmPolicy = await operations.installDraftPrewarmPolicy(renderer);
|
|
20362
22495
|
const binding = await waitForBinding(renderer, enabledAgents, timeoutMs, pollIntervalMs);
|
|
20363
|
-
|
|
22496
|
+
extensions?.hint();
|
|
22497
|
+
return {
|
|
22498
|
+
renderer,
|
|
22499
|
+
snapshot: { target: target2, draftPrewarmPolicy, binding },
|
|
22500
|
+
attachExtensions,
|
|
22501
|
+
disposeModules: () => {
|
|
22502
|
+
disposeModules?.();
|
|
22503
|
+
return detach?.();
|
|
22504
|
+
}
|
|
22505
|
+
};
|
|
20364
22506
|
} catch (error51) {
|
|
20365
22507
|
disposeModules?.();
|
|
20366
|
-
|
|
22508
|
+
try {
|
|
22509
|
+
await detach?.();
|
|
22510
|
+
} finally {
|
|
22511
|
+
renderer.close();
|
|
22512
|
+
}
|
|
20367
22513
|
throw error51;
|
|
20368
22514
|
}
|
|
20369
22515
|
}
|
|
20370
22516
|
var InstalledRendererCdpControlSession = class {
|
|
20371
|
-
constructor(renderer, rendererCdpEndpoint2, rendererSource, enabledAgents, timeoutMs, pollIntervalMs, operations, currentSnapshot, disposeModules) {
|
|
22517
|
+
constructor(renderer, rendererCdpEndpoint2, rendererSource, enabledAgents, timeoutMs, pollIntervalMs, operations, currentSnapshot, disposeModules, extensions) {
|
|
20372
22518
|
this.renderer = renderer;
|
|
20373
22519
|
this.rendererCdpEndpoint = rendererCdpEndpoint2;
|
|
20374
22520
|
this.rendererSource = rendererSource;
|
|
@@ -20378,6 +22524,7 @@ var InstalledRendererCdpControlSession = class {
|
|
|
20378
22524
|
this.operations = operations;
|
|
20379
22525
|
this.currentSnapshot = currentSnapshot;
|
|
20380
22526
|
this.disposeModules = disposeModules;
|
|
22527
|
+
this.extensions = extensions;
|
|
20381
22528
|
}
|
|
20382
22529
|
renderer;
|
|
20383
22530
|
rendererCdpEndpoint;
|
|
@@ -20388,6 +22535,7 @@ var InstalledRendererCdpControlSession = class {
|
|
|
20388
22535
|
operations;
|
|
20389
22536
|
currentSnapshot;
|
|
20390
22537
|
disposeModules;
|
|
22538
|
+
extensions;
|
|
20391
22539
|
#closed = false;
|
|
20392
22540
|
get snapshot() {
|
|
20393
22541
|
return this.currentSnapshot;
|
|
@@ -20401,50 +22549,49 @@ var InstalledRendererCdpControlSession = class {
|
|
|
20401
22549
|
this.pollIntervalMs,
|
|
20402
22550
|
this.currentSnapshot.target.id
|
|
20403
22551
|
);
|
|
20404
|
-
if (target2.id
|
|
20405
|
-
|
|
20406
|
-
|
|
20407
|
-
this.rendererSource
|
|
20408
|
-
this.
|
|
20409
|
-
|
|
20410
|
-
|
|
20411
|
-
|
|
20412
|
-
|
|
20413
|
-
|
|
20414
|
-
|
|
20415
|
-
|
|
20416
|
-
|
|
20417
|
-
|
|
20418
|
-
|
|
22552
|
+
if (target2.id === this.currentSnapshot.target.id) {
|
|
22553
|
+
try {
|
|
22554
|
+
const existing = await readBinding(this.renderer);
|
|
22555
|
+
if (existing === null) await evaluateSource(this.renderer, this.rendererSource);
|
|
22556
|
+
const draftPrewarmPolicy = await this.operations.installDraftPrewarmPolicy(this.renderer);
|
|
22557
|
+
const binding = await waitForBinding(
|
|
22558
|
+
this.renderer,
|
|
22559
|
+
this.enabledAgents,
|
|
22560
|
+
this.timeoutMs,
|
|
22561
|
+
this.pollIntervalMs
|
|
22562
|
+
);
|
|
22563
|
+
this.currentSnapshot = { target: target2, draftPrewarmPolicy, binding };
|
|
22564
|
+
this.extensions?.ensureInstalled();
|
|
22565
|
+
return this.currentSnapshot;
|
|
22566
|
+
} catch {
|
|
22567
|
+
}
|
|
20419
22568
|
}
|
|
22569
|
+
const replacement = await installTarget(
|
|
22570
|
+
target2,
|
|
22571
|
+
this.rendererSource,
|
|
22572
|
+
this.enabledAgents,
|
|
22573
|
+
this.timeoutMs,
|
|
22574
|
+
this.pollIntervalMs,
|
|
22575
|
+
this.operations,
|
|
22576
|
+
this.extensions,
|
|
22577
|
+
true
|
|
22578
|
+
);
|
|
20420
22579
|
try {
|
|
20421
|
-
|
|
20422
|
-
|
|
20423
|
-
|
|
20424
|
-
|
|
20425
|
-
|
|
20426
|
-
|
|
20427
|
-
|
|
20428
|
-
|
|
20429
|
-
);
|
|
20430
|
-
|
|
20431
|
-
return this.currentSnapshot;
|
|
20432
|
-
} catch {
|
|
20433
|
-
const replacement = await installTarget(
|
|
20434
|
-
target2,
|
|
20435
|
-
this.rendererSource,
|
|
20436
|
-
this.enabledAgents,
|
|
20437
|
-
this.timeoutMs,
|
|
20438
|
-
this.pollIntervalMs,
|
|
20439
|
-
this.operations
|
|
20440
|
-
);
|
|
20441
|
-
this.disposeModules();
|
|
20442
|
-
this.renderer.close();
|
|
20443
|
-
this.renderer = replacement.renderer;
|
|
20444
|
-
this.disposeModules = replacement.disposeModules;
|
|
20445
|
-
this.currentSnapshot = replacement.snapshot;
|
|
20446
|
-
return this.currentSnapshot;
|
|
22580
|
+
if (!this.#closed) {
|
|
22581
|
+
await this.disposeModules();
|
|
22582
|
+
this.renderer.close();
|
|
22583
|
+
}
|
|
22584
|
+
if (this.#closed) throw new Error("Renderer CDP Control Session is closed");
|
|
22585
|
+
replacement.attachExtensions();
|
|
22586
|
+
} catch (error51) {
|
|
22587
|
+
replacement.disposeModules();
|
|
22588
|
+
replacement.renderer.close();
|
|
22589
|
+
throw error51;
|
|
20447
22590
|
}
|
|
22591
|
+
this.renderer = replacement.renderer;
|
|
22592
|
+
this.disposeModules = replacement.disposeModules;
|
|
22593
|
+
this.currentSnapshot = replacement.snapshot;
|
|
22594
|
+
return this.currentSnapshot;
|
|
20448
22595
|
}
|
|
20449
22596
|
async activateDesktop() {
|
|
20450
22597
|
if (this.#closed) throw new Error("Renderer CDP Control Session is closed");
|
|
@@ -20458,8 +22605,14 @@ var InstalledRendererCdpControlSession = class {
|
|
|
20458
22605
|
close() {
|
|
20459
22606
|
if (this.#closed) return;
|
|
20460
22607
|
this.#closed = true;
|
|
20461
|
-
this.
|
|
20462
|
-
this.
|
|
22608
|
+
const renderer = this.renderer;
|
|
22609
|
+
const detached = this.disposeModules();
|
|
22610
|
+
if (detached)
|
|
22611
|
+
void detached.then(
|
|
22612
|
+
() => renderer.close(),
|
|
22613
|
+
() => renderer.close()
|
|
22614
|
+
);
|
|
22615
|
+
else renderer.close();
|
|
20463
22616
|
}
|
|
20464
22617
|
};
|
|
20465
22618
|
var defaultOperations = {
|
|
@@ -20491,7 +22644,8 @@ async function createRendererCdpControlSession(options) {
|
|
|
20491
22644
|
enabledAgents,
|
|
20492
22645
|
timeoutMs,
|
|
20493
22646
|
pollIntervalMs,
|
|
20494
|
-
operations
|
|
22647
|
+
operations,
|
|
22648
|
+
options.desktopExtensions
|
|
20495
22649
|
);
|
|
20496
22650
|
return new InstalledRendererCdpControlSession(
|
|
20497
22651
|
installed.renderer,
|
|
@@ -20502,13 +22656,679 @@ async function createRendererCdpControlSession(options) {
|
|
|
20502
22656
|
pollIntervalMs,
|
|
20503
22657
|
operations,
|
|
20504
22658
|
installed.snapshot,
|
|
20505
|
-
installed.disposeModules
|
|
22659
|
+
installed.disposeModules,
|
|
22660
|
+
options.desktopExtensions
|
|
20506
22661
|
);
|
|
20507
22662
|
}
|
|
20508
22663
|
function installRendererCdpControlSession(options) {
|
|
20509
22664
|
return createRendererCdpControlSession(options);
|
|
20510
22665
|
}
|
|
20511
22666
|
|
|
22667
|
+
// packages/desktop-control/src/renderer-desktop-extensions.ts
|
|
22668
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
22669
|
+
import { watch } from "node:fs";
|
|
22670
|
+
import { mkdir as mkdir2, readFile, rename as rename2, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
22671
|
+
import path5 from "node:path";
|
|
22672
|
+
import { Script } from "node:vm";
|
|
22673
|
+
|
|
22674
|
+
// packages/harness-plugin-files/dist/plugin-files.js
|
|
22675
|
+
import { open, realpath, stat } from "node:fs/promises";
|
|
22676
|
+
import path2 from "node:path";
|
|
22677
|
+
function inside(root, candidate) {
|
|
22678
|
+
const relative = path2.relative(root, candidate);
|
|
22679
|
+
return relative !== "" && !path2.isAbsolute(relative) && relative !== ".." && !relative.startsWith(`..${path2.sep}`);
|
|
22680
|
+
}
|
|
22681
|
+
async function pluginResourcePath(root, relative) {
|
|
22682
|
+
if (path2.isAbsolute(relative) || !inside(root, path2.resolve(root, relative))) {
|
|
22683
|
+
throw new Error("Plugin resource escapes its root");
|
|
22684
|
+
}
|
|
22685
|
+
const resolved = await realpath(path2.resolve(root, relative));
|
|
22686
|
+
if (!inside(root, resolved) || !(await stat(resolved)).isFile()) {
|
|
22687
|
+
throw new Error("Plugin resource must be a regular file inside its root");
|
|
22688
|
+
}
|
|
22689
|
+
return resolved;
|
|
22690
|
+
}
|
|
22691
|
+
async function readPluginFile(file2, maximum) {
|
|
22692
|
+
if (!(await stat(file2)).isFile())
|
|
22693
|
+
throw new Error("Plugin resource is not a regular file");
|
|
22694
|
+
const handle = await open(file2, "r");
|
|
22695
|
+
try {
|
|
22696
|
+
const info = await handle.stat();
|
|
22697
|
+
if (!info.isFile() || info.size > maximum)
|
|
22698
|
+
throw new Error("Plugin resource exceeds its limit");
|
|
22699
|
+
const buffer = Buffer.alloc(maximum + 1);
|
|
22700
|
+
let length = 0;
|
|
22701
|
+
while (length < buffer.length) {
|
|
22702
|
+
const { bytesRead } = await handle.read(buffer, length, buffer.length - length, length);
|
|
22703
|
+
if (bytesRead === 0)
|
|
22704
|
+
return buffer.subarray(0, length);
|
|
22705
|
+
length += bytesRead;
|
|
22706
|
+
}
|
|
22707
|
+
throw new Error("Plugin resource exceeds its limit");
|
|
22708
|
+
} finally {
|
|
22709
|
+
await handle.close();
|
|
22710
|
+
}
|
|
22711
|
+
}
|
|
22712
|
+
|
|
22713
|
+
// packages/harness-plugin-files/dist/extension-discovery.js
|
|
22714
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
22715
|
+
import { lstat, readdir, realpath as realpath2, stat as stat2 } from "node:fs/promises";
|
|
22716
|
+
import path3 from "node:path";
|
|
22717
|
+
var DESKTOP_EXTENSION_CONFIGURATION_LOCK = ".enabled.lock";
|
|
22718
|
+
function desktopExtensionsRoot(dataDirectory) {
|
|
22719
|
+
return path3.join(dataDirectory, "desktop-extensions");
|
|
22720
|
+
}
|
|
22721
|
+
function desktopExtensionsStatusPath(dataDirectory) {
|
|
22722
|
+
return path3.join(dataDirectory, "diagnostics", "desktop-extensions-v1.json");
|
|
22723
|
+
}
|
|
22724
|
+
function extensionFileMissing(error51) {
|
|
22725
|
+
return error51 instanceof Error && "code" in error51 && error51.code === "ENOENT";
|
|
22726
|
+
}
|
|
22727
|
+
async function privateEntry(file2, directory) {
|
|
22728
|
+
const info = await lstat(file2);
|
|
22729
|
+
if (directory ? !info.isDirectory() : !info.isFile())
|
|
22730
|
+
throw new Error(`${path3.basename(file2)} must be a regular ${directory ? "directory" : "file"}`);
|
|
22731
|
+
if (process.getuid && (info.uid !== process.getuid() || (info.mode & 18) !== 0))
|
|
22732
|
+
throw new Error(`${path3.basename(file2)} must belong to the current user and not permit group/other writes`);
|
|
22733
|
+
}
|
|
22734
|
+
async function privateExtensionDirectory(directory) {
|
|
22735
|
+
await privateEntry(directory, true);
|
|
22736
|
+
return realpath2(directory);
|
|
22737
|
+
}
|
|
22738
|
+
async function checkedExtensionResource(root, relative) {
|
|
22739
|
+
const resource = await pluginResourcePath(root, relative);
|
|
22740
|
+
for (const candidate of /* @__PURE__ */ new Set([resource, path3.resolve(root, relative)])) {
|
|
22741
|
+
let dir = path3.dirname(candidate);
|
|
22742
|
+
while (dir !== root) {
|
|
22743
|
+
await privateEntry(dir, true);
|
|
22744
|
+
dir = path3.dirname(dir);
|
|
22745
|
+
}
|
|
22746
|
+
}
|
|
22747
|
+
await privateEntry(resource, false);
|
|
22748
|
+
return resource;
|
|
22749
|
+
}
|
|
22750
|
+
async function readExtensionResource(root, relative, max) {
|
|
22751
|
+
return readPluginFile(await checkedExtensionResource(root, relative), max);
|
|
22752
|
+
}
|
|
22753
|
+
async function readDesktopExtensionBackend(directory, script) {
|
|
22754
|
+
try {
|
|
22755
|
+
const scriptPath = await checkedExtensionResource(directory, script);
|
|
22756
|
+
const bytes = await readPluginFile(scriptPath, DESKTOP_EXTENSION_SCRIPT_MAX_BYTES);
|
|
22757
|
+
const { dev, ino } = await stat2(directory, { bigint: true });
|
|
22758
|
+
return {
|
|
22759
|
+
directory,
|
|
22760
|
+
scriptPath,
|
|
22761
|
+
hash: createHash2("sha256").update(bytes).digest("hex"),
|
|
22762
|
+
installation: `${dev}:${ino}`
|
|
22763
|
+
};
|
|
22764
|
+
} catch (error51) {
|
|
22765
|
+
if (!extensionFileMissing(error51))
|
|
22766
|
+
throw error51;
|
|
22767
|
+
throw new Error(`Missing backend entry file ${script}`, { cause: error51 });
|
|
22768
|
+
}
|
|
22769
|
+
}
|
|
22770
|
+
var pngSignature = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
|
|
22771
|
+
var jpegSignature = Buffer.from([255, 216, 255]);
|
|
22772
|
+
var riffSignature = Buffer.from("RIFF");
|
|
22773
|
+
var webpSignature = Buffer.from("WEBP");
|
|
22774
|
+
async function readDesktopExtensionImage(root, relative, maxBytes, label) {
|
|
22775
|
+
try {
|
|
22776
|
+
const mime = desktopExtensionScreenshotMimeType(relative);
|
|
22777
|
+
if (!mime)
|
|
22778
|
+
throw new Error("Unsupported image extension");
|
|
22779
|
+
const bytes = await readExtensionResource(root, relative, maxBytes);
|
|
22780
|
+
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);
|
|
22781
|
+
if (!matches)
|
|
22782
|
+
throw new Error(`File signature does not match ${mime}`);
|
|
22783
|
+
return { bytes, mime };
|
|
22784
|
+
} catch (error51) {
|
|
22785
|
+
const reason = extensionFileMissing(error51) ? "file not found" : error51 instanceof Error ? error51.message : String(error51);
|
|
22786
|
+
throw new Error(`${label} ${JSON.stringify(relative)}: ${reason}`, { cause: error51 });
|
|
22787
|
+
}
|
|
22788
|
+
}
|
|
22789
|
+
function readDesktopExtensionIcon(root, relative) {
|
|
22790
|
+
return readDesktopExtensionImage(root, relative, DESKTOP_EXTENSION_ICON_MAX_BYTES, "Icon");
|
|
22791
|
+
}
|
|
22792
|
+
function readDesktopExtensionScreenshot(root, relative) {
|
|
22793
|
+
return readDesktopExtensionImage(root, relative, DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES, "Screenshot");
|
|
22794
|
+
}
|
|
22795
|
+
function toImageDataUrl({ bytes, mime }) {
|
|
22796
|
+
return `data:${mime};base64,${bytes.toString("base64")}`;
|
|
22797
|
+
}
|
|
22798
|
+
function isDesktopExtensionTransactionEntry(name) {
|
|
22799
|
+
return name === DESKTOP_EXTENSION_CONFIGURATION_LOCK || /^\.(?:staging|backup)-/u.test(name);
|
|
22800
|
+
}
|
|
22801
|
+
async function discover(root, id, screenshotBudget) {
|
|
22802
|
+
try {
|
|
22803
|
+
if (!desktopExtensionIdSchema.safeParse(id).success)
|
|
22804
|
+
throw new Error("Invalid extension directory name");
|
|
22805
|
+
const directory = await privateExtensionDirectory(path3.join(root, id));
|
|
22806
|
+
const bytes = await readExtensionResource(directory, "manifest.json", DESKTOP_EXTENSION_MANIFEST_MAX_BYTES);
|
|
22807
|
+
const data = JSON.parse(bytes.toString("utf8"));
|
|
22808
|
+
if (!data || typeof data !== "object" || !("id" in data) || data.id !== id)
|
|
22809
|
+
throw new Error("Manifest id must match the directory name");
|
|
22810
|
+
const parsed = parseDesktopExtensionManifest(data);
|
|
22811
|
+
if (parsed.state !== "valid")
|
|
22812
|
+
return { id, ...parsed };
|
|
22813
|
+
const { desktop, backend } = parsed.manifest;
|
|
22814
|
+
const [script, style, backendEntry] = await Promise.all([
|
|
22815
|
+
desktop ? readExtensionResource(directory, desktop.script, DESKTOP_EXTENSION_SCRIPT_MAX_BYTES) : void 0,
|
|
22816
|
+
desktop?.style ? readExtensionResource(directory, desktop.style, DESKTOP_EXTENSION_STYLE_MAX_BYTES) : void 0,
|
|
22817
|
+
backend ? readDesktopExtensionBackend(directory, backend.script) : void 0
|
|
22818
|
+
]);
|
|
22819
|
+
const zero = Buffer.from([0]);
|
|
22820
|
+
const hash2 = createHash2("sha256").update(bytes).update(zero);
|
|
22821
|
+
if (script)
|
|
22822
|
+
hash2.update(script);
|
|
22823
|
+
hash2.update(zero);
|
|
22824
|
+
if (style)
|
|
22825
|
+
hash2.update(style);
|
|
22826
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
22827
|
+
const item = {
|
|
22828
|
+
id,
|
|
22829
|
+
state: "valid",
|
|
22830
|
+
manifest: parsed.manifest,
|
|
22831
|
+
hash: hash2.digest("hex"),
|
|
22832
|
+
...script ? { script: decoder.decode(script) } : {},
|
|
22833
|
+
...style ? { style: decoder.decode(style) } : {},
|
|
22834
|
+
...backendEntry ? { backend: backendEntry } : {}
|
|
22835
|
+
};
|
|
22836
|
+
if (parsed.manifest.icon) {
|
|
22837
|
+
const icon = await readDesktopExtensionIcon(directory, parsed.manifest.icon).catch(() => void 0);
|
|
22838
|
+
if (icon)
|
|
22839
|
+
item.iconDataUrl = toImageDataUrl(icon);
|
|
22840
|
+
}
|
|
22841
|
+
const screenshots = [];
|
|
22842
|
+
let screenshotBytes = 0;
|
|
22843
|
+
for (const relative of parsed.manifest.screenshots ?? []) {
|
|
22844
|
+
const screenshot = await readDesktopExtensionScreenshot(directory, relative);
|
|
22845
|
+
screenshots.push(screenshot);
|
|
22846
|
+
screenshotBytes += screenshot.bytes.length;
|
|
22847
|
+
}
|
|
22848
|
+
if (screenshotBytes > screenshotBudget.remaining) {
|
|
22849
|
+
screenshotBudget.omitted = true;
|
|
22850
|
+
} else if (screenshots.length) {
|
|
22851
|
+
screenshotBudget.remaining -= screenshotBytes;
|
|
22852
|
+
item.screenshotDataUrls = screenshots.map(toImageDataUrl);
|
|
22853
|
+
}
|
|
22854
|
+
return item;
|
|
22855
|
+
} catch (error51) {
|
|
22856
|
+
return { id, state: "invalid", error: error51 instanceof Error ? error51.message : String(error51) };
|
|
22857
|
+
}
|
|
22858
|
+
}
|
|
22859
|
+
async function discoverDesktopExtensions(configuredRoot) {
|
|
22860
|
+
try {
|
|
22861
|
+
const root = await privateExtensionDirectory(configuredRoot);
|
|
22862
|
+
const names = (await readdir(root, { withFileTypes: true })).filter((entry) => !isDesktopExtensionTransactionEntry(entry.name) && (entry.isDirectory() || entry.isSymbolicLink())).map((entry) => entry.name).sort();
|
|
22863
|
+
if (names.length > DESKTOP_EXTENSION_LIMIT)
|
|
22864
|
+
return {
|
|
22865
|
+
extensions: [],
|
|
22866
|
+
diagnostic: `At most ${DESKTOP_EXTENSION_LIMIT} extensions are supported`
|
|
22867
|
+
};
|
|
22868
|
+
const extensions = [];
|
|
22869
|
+
const screenshotBudget = {
|
|
22870
|
+
remaining: DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES,
|
|
22871
|
+
omitted: false
|
|
22872
|
+
};
|
|
22873
|
+
for (const id of names)
|
|
22874
|
+
extensions.push(await discover(root, id, screenshotBudget));
|
|
22875
|
+
return {
|
|
22876
|
+
extensions,
|
|
22877
|
+
...screenshotBudget.omitted ? {
|
|
22878
|
+
diagnostic: "Desktop extension screenshot list size limit exceeded; some previews were omitted"
|
|
22879
|
+
} : {}
|
|
22880
|
+
};
|
|
22881
|
+
} catch (error51) {
|
|
22882
|
+
return {
|
|
22883
|
+
extensions: [],
|
|
22884
|
+
...extensionFileMissing(error51) ? {} : { diagnostic: error51 instanceof Error ? error51.message : String(error51) }
|
|
22885
|
+
};
|
|
22886
|
+
}
|
|
22887
|
+
}
|
|
22888
|
+
|
|
22889
|
+
// packages/harness-plugin-files/dist/extension-configuration.js
|
|
22890
|
+
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
22891
|
+
import path4 from "node:path";
|
|
22892
|
+
var CONFIG_FILE = "enabled.json";
|
|
22893
|
+
function missingDesktopExtensionConfiguration(error51) {
|
|
22894
|
+
const configuration = { version: 1, revision: 0, enabled: [] };
|
|
22895
|
+
return extensionFileMissing(error51) ? { configuration } : {
|
|
22896
|
+
configuration,
|
|
22897
|
+
diagnostic: `Invalid extension configuration: ${error51 instanceof Error ? error51.message : String(error51)}`
|
|
22898
|
+
};
|
|
22899
|
+
}
|
|
22900
|
+
async function readDesktopExtensionConfiguration(root) {
|
|
22901
|
+
try {
|
|
22902
|
+
const directory = await privateExtensionDirectory(root);
|
|
22903
|
+
const bytes = await readExtensionResource(directory, CONFIG_FILE, DESKTOP_EXTENSION_MANIFEST_MAX_BYTES);
|
|
22904
|
+
return {
|
|
22905
|
+
configuration: desktopExtensionConfigurationSchema.parse(JSON.parse(bytes.toString("utf8")))
|
|
22906
|
+
};
|
|
22907
|
+
} catch (error51) {
|
|
22908
|
+
return missingDesktopExtensionConfiguration(error51);
|
|
22909
|
+
}
|
|
22910
|
+
}
|
|
22911
|
+
async function withDesktopExtensionDirectoryLock(directory, operation) {
|
|
22912
|
+
let compromised;
|
|
22913
|
+
const release = await import_proper_lockfile.default.lock(directory, {
|
|
22914
|
+
lockfilePath: path4.join(directory, DESKTOP_EXTENSION_CONFIGURATION_LOCK),
|
|
22915
|
+
retries: { retries: 24, minTimeout: 50, maxTimeout: 500 },
|
|
22916
|
+
onCompromised(error51) {
|
|
22917
|
+
compromised = error51;
|
|
22918
|
+
}
|
|
22919
|
+
});
|
|
22920
|
+
const assertLocked = () => {
|
|
22921
|
+
if (compromised)
|
|
22922
|
+
throw compromised;
|
|
22923
|
+
};
|
|
22924
|
+
try {
|
|
22925
|
+
const result = await operation(assertLocked);
|
|
22926
|
+
assertLocked();
|
|
22927
|
+
return result;
|
|
22928
|
+
} finally {
|
|
22929
|
+
if (!compromised)
|
|
22930
|
+
await release();
|
|
22931
|
+
}
|
|
22932
|
+
}
|
|
22933
|
+
|
|
22934
|
+
// packages/harness-plugin-files/dist/extension-management.js
|
|
22935
|
+
async function readDesktopExtensionSnapshot(root, { skipScanIfNoneEnabled = false } = {}) {
|
|
22936
|
+
let directory;
|
|
22937
|
+
try {
|
|
22938
|
+
directory = await privateExtensionDirectory(root);
|
|
22939
|
+
} catch (error51) {
|
|
22940
|
+
return {
|
|
22941
|
+
selection: missingDesktopExtensionConfiguration(error51),
|
|
22942
|
+
discovery: {
|
|
22943
|
+
extensions: [],
|
|
22944
|
+
...!extensionFileMissing(error51) && {
|
|
22945
|
+
diagnostic: error51 instanceof Error ? error51.message : String(error51)
|
|
22946
|
+
}
|
|
22947
|
+
}
|
|
22948
|
+
};
|
|
22949
|
+
}
|
|
22950
|
+
return withDesktopExtensionDirectoryLock(directory, async () => {
|
|
22951
|
+
const selection = await readDesktopExtensionConfiguration(directory);
|
|
22952
|
+
const discovery = skipScanIfNoneEnabled && !selection.configuration.enabled.length ? { extensions: [] } : await discoverDesktopExtensions(directory);
|
|
22953
|
+
return { selection, discovery };
|
|
22954
|
+
});
|
|
22955
|
+
}
|
|
22956
|
+
|
|
22957
|
+
// packages/harness-plugin-files/dist/desktop-extension-seed-catalog.json
|
|
22958
|
+
var desktop_extension_seed_catalog_default = {
|
|
22959
|
+
schemaVersion: 1,
|
|
22960
|
+
generatedAt: "2026-01-01T00:00:00.000Z",
|
|
22961
|
+
extensions: []
|
|
22962
|
+
};
|
|
22963
|
+
|
|
22964
|
+
// packages/harness-plugin-files/dist/desktop-extension-catalog.js
|
|
22965
|
+
var MAX_BYTES = 2 * 1024 * 1024;
|
|
22966
|
+
var TTL = 5 * 60 * 1e3;
|
|
22967
|
+
var fallback = desktopExtensionCatalogSchema.parse(desktop_extension_seed_catalog_default).extensions;
|
|
22968
|
+
|
|
22969
|
+
// packages/harness-plugin-files/dist/desktop-extension-zip.js
|
|
22970
|
+
var MAX_UNPACKED_BYTES = 256 * 1024 * 1024;
|
|
22971
|
+
var EXPANSION_FLOOR_BYTES = 16 * 1024 * 1024;
|
|
22972
|
+
var utf8 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
22973
|
+
|
|
22974
|
+
// packages/harness-plugin-files/dist/desktop-extension-installer.js
|
|
22975
|
+
var utf82 = new TextDecoder("utf-8", { fatal: true });
|
|
22976
|
+
|
|
22977
|
+
// packages/desktop-control/src/renderer-desktop-extensions.ts
|
|
22978
|
+
var HOST = "window.__codexhostDesktopExtensionsV1";
|
|
22979
|
+
var STATUS = `${HOST}?.status() ?? null`;
|
|
22980
|
+
var RESCAN_MS = 3e4;
|
|
22981
|
+
var POLL_MS = 5e3;
|
|
22982
|
+
var DEBOUNCE_MS = 150;
|
|
22983
|
+
function record4(value) {
|
|
22984
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
22985
|
+
}
|
|
22986
|
+
function application(item) {
|
|
22987
|
+
const { id, hash: hash2, manifest, script, style } = item;
|
|
22988
|
+
if (script === void 0) return void 0;
|
|
22989
|
+
const reference = JSON.stringify({ id, hash: hash2, slots: manifest.slots });
|
|
22990
|
+
const factory = `(function (define) { "use strict";
|
|
22991
|
+
${script}
|
|
22992
|
+
})`;
|
|
22993
|
+
let expression;
|
|
22994
|
+
try {
|
|
22995
|
+
new Script(`({defineScript: ${factory}})`, {
|
|
22996
|
+
filename: `codexhost-extension://${id}/desktop.js`
|
|
22997
|
+
});
|
|
22998
|
+
expression = `{...${reference}, defineScript: ${factory},${style === void 0 ? "" : `style: ${JSON.stringify(style)},`}}`;
|
|
22999
|
+
} catch (cause) {
|
|
23000
|
+
expression = JSON.stringify({
|
|
23001
|
+
id,
|
|
23002
|
+
hash: hash2,
|
|
23003
|
+
slots: manifest.slots,
|
|
23004
|
+
error: cause instanceof Error ? cause.message : String(cause)
|
|
23005
|
+
});
|
|
23006
|
+
}
|
|
23007
|
+
return { id, hash: hash2, expression, reference };
|
|
23008
|
+
}
|
|
23009
|
+
function reconciliation(entries) {
|
|
23010
|
+
return `(() => {
|
|
23011
|
+
if (window.top !== window || location.protocol !== "app:" || location.host !== "-" || location.pathname !== "/index.html" || !${HOST}) return false;
|
|
23012
|
+
void ${HOST}.reconcile([${entries.join(",\n")}]); return true;
|
|
23013
|
+
})()`;
|
|
23014
|
+
}
|
|
23015
|
+
var RendererDesktopExtensions = class {
|
|
23016
|
+
constructor(dataDirectory, diagnose = () => void 0) {
|
|
23017
|
+
this.dataDirectory = dataDirectory;
|
|
23018
|
+
this.diagnose = diagnose;
|
|
23019
|
+
this.#root = desktopExtensionsRoot(dataDirectory);
|
|
23020
|
+
this.#statusPath = desktopExtensionsStatusPath(dataDirectory);
|
|
23021
|
+
this.#scan = setInterval(() => {
|
|
23022
|
+
void this.refresh();
|
|
23023
|
+
}, RESCAN_MS);
|
|
23024
|
+
this.#scan.unref();
|
|
23025
|
+
this.#poll = setInterval(() => this.#pollStatus(), POLL_MS);
|
|
23026
|
+
this.#poll.unref();
|
|
23027
|
+
}
|
|
23028
|
+
dataDirectory;
|
|
23029
|
+
diagnose;
|
|
23030
|
+
#root;
|
|
23031
|
+
#statusPath;
|
|
23032
|
+
#scan;
|
|
23033
|
+
#poll;
|
|
23034
|
+
#debounce;
|
|
23035
|
+
#watch;
|
|
23036
|
+
#watchingRoot = false;
|
|
23037
|
+
#target;
|
|
23038
|
+
#closed = false;
|
|
23039
|
+
#queue = Promise.resolve();
|
|
23040
|
+
#pendingScan;
|
|
23041
|
+
#pendingPoll = false;
|
|
23042
|
+
#lastEnsure = 0;
|
|
23043
|
+
#handled;
|
|
23044
|
+
#attempted;
|
|
23045
|
+
#loadedToken = false;
|
|
23046
|
+
attach(id, renderer) {
|
|
23047
|
+
const target2 = { id, renderer, enabled: false, extensions: {} };
|
|
23048
|
+
this.#target = target2;
|
|
23049
|
+
void this.#enqueue(() => this.#reconcile(target2));
|
|
23050
|
+
return () => {
|
|
23051
|
+
if (this.#target === target2) this.#target = void 0;
|
|
23052
|
+
this.#queue = this.#queue.then(() => this.#replaceSnapshot(target2, [])).catch(this.diagnose);
|
|
23053
|
+
return this.#queue;
|
|
23054
|
+
};
|
|
23055
|
+
}
|
|
23056
|
+
ensureInstalled() {
|
|
23057
|
+
const now = Date.now();
|
|
23058
|
+
if (now - this.#lastEnsure < POLL_MS) return;
|
|
23059
|
+
this.#lastEnsure = now;
|
|
23060
|
+
this.hint();
|
|
23061
|
+
}
|
|
23062
|
+
hint() {
|
|
23063
|
+
if (this.#closed) return;
|
|
23064
|
+
clearTimeout(this.#debounce);
|
|
23065
|
+
this.#debounce = setTimeout(() => {
|
|
23066
|
+
void this.refresh();
|
|
23067
|
+
}, DEBOUNCE_MS);
|
|
23068
|
+
this.#debounce.unref();
|
|
23069
|
+
}
|
|
23070
|
+
refresh() {
|
|
23071
|
+
if (this.#pendingScan) return this.#pendingScan;
|
|
23072
|
+
const promise2 = this.#enqueue(async () => {
|
|
23073
|
+
const target2 = this.#target;
|
|
23074
|
+
if (target2) await this.#reconcile(target2);
|
|
23075
|
+
});
|
|
23076
|
+
this.#pendingScan = promise2;
|
|
23077
|
+
void promise2.finally(() => {
|
|
23078
|
+
if (this.#pendingScan === promise2) this.#pendingScan = void 0;
|
|
23079
|
+
});
|
|
23080
|
+
return promise2;
|
|
23081
|
+
}
|
|
23082
|
+
close() {
|
|
23083
|
+
this.#closed = true;
|
|
23084
|
+
this.#target = void 0;
|
|
23085
|
+
clearTimeout(this.#debounce);
|
|
23086
|
+
clearInterval(this.#scan);
|
|
23087
|
+
clearInterval(this.#poll);
|
|
23088
|
+
this.#watch?.close();
|
|
23089
|
+
}
|
|
23090
|
+
#enqueue(operation) {
|
|
23091
|
+
this.#queue = this.#queue.then(async () => {
|
|
23092
|
+
if (!this.#closed) await operation();
|
|
23093
|
+
}).catch(this.diagnose);
|
|
23094
|
+
return this.#queue;
|
|
23095
|
+
}
|
|
23096
|
+
#ensureWatch() {
|
|
23097
|
+
if (this.#watchingRoot || this.#closed) return;
|
|
23098
|
+
const onChange = (event, filename) => {
|
|
23099
|
+
if (filename && isDesktopExtensionTransactionEntry(filename.split(path5.sep, 1)[0] ?? ""))
|
|
23100
|
+
return;
|
|
23101
|
+
if (event === "rename" && this.#watchingRoot) {
|
|
23102
|
+
this.#watch?.close();
|
|
23103
|
+
this.#watch = void 0;
|
|
23104
|
+
this.#watchingRoot = false;
|
|
23105
|
+
}
|
|
23106
|
+
this.hint();
|
|
23107
|
+
};
|
|
23108
|
+
const install = (directory, recursive) => {
|
|
23109
|
+
const watcher = watch(directory, { recursive, persistent: false }, onChange);
|
|
23110
|
+
watcher.on("error", () => {
|
|
23111
|
+
if (this.#watch !== watcher) return;
|
|
23112
|
+
watcher.close();
|
|
23113
|
+
this.#watch = void 0;
|
|
23114
|
+
this.#watchingRoot = false;
|
|
23115
|
+
});
|
|
23116
|
+
return watcher;
|
|
23117
|
+
};
|
|
23118
|
+
try {
|
|
23119
|
+
const root = install(this.#root, true);
|
|
23120
|
+
this.#watch?.close();
|
|
23121
|
+
this.#watch = root;
|
|
23122
|
+
this.#watchingRoot = true;
|
|
23123
|
+
} catch {
|
|
23124
|
+
if (!this.#watch) {
|
|
23125
|
+
try {
|
|
23126
|
+
this.#watch = install(this.dataDirectory, false);
|
|
23127
|
+
} catch {
|
|
23128
|
+
}
|
|
23129
|
+
}
|
|
23130
|
+
}
|
|
23131
|
+
}
|
|
23132
|
+
async #readRenderer(target2) {
|
|
23133
|
+
const value = await target2.renderer.evaluate(STATUS, 1e3);
|
|
23134
|
+
if (!record4(value)) return null;
|
|
23135
|
+
return Object.fromEntries(
|
|
23136
|
+
Object.entries(value).flatMap(([id, raw]) => {
|
|
23137
|
+
const status = desktopExtensionStatusSchema.safeParse(raw);
|
|
23138
|
+
return status.success ? [[id, status.data]] : [];
|
|
23139
|
+
})
|
|
23140
|
+
);
|
|
23141
|
+
}
|
|
23142
|
+
async #replaceSnapshot(target2, entries) {
|
|
23143
|
+
const fingerprint = JSON.stringify(entries.map(({ id, hash: hash2 }) => [id, hash2]));
|
|
23144
|
+
if (target2.fingerprint === fingerprint) return;
|
|
23145
|
+
if (target2.scriptId) {
|
|
23146
|
+
await target2.renderer.command("Page.removeScriptToEvaluateOnNewDocument", {
|
|
23147
|
+
identifier: target2.scriptId
|
|
23148
|
+
});
|
|
23149
|
+
delete target2.scriptId;
|
|
23150
|
+
delete target2.fingerprint;
|
|
23151
|
+
}
|
|
23152
|
+
if (this.#target !== target2 || this.#closed) return;
|
|
23153
|
+
if (entries.length) {
|
|
23154
|
+
const added = await target2.renderer.command("Page.addScriptToEvaluateOnNewDocument", {
|
|
23155
|
+
source: reconciliation(entries.map(({ expression }) => expression))
|
|
23156
|
+
});
|
|
23157
|
+
if (!record4(added) || typeof added.identifier !== "string")
|
|
23158
|
+
throw new Error("CDP did not identify the extension snapshot");
|
|
23159
|
+
target2.scriptId = added.identifier;
|
|
23160
|
+
}
|
|
23161
|
+
target2.fingerprint = fingerprint;
|
|
23162
|
+
}
|
|
23163
|
+
async #reconcile(target2) {
|
|
23164
|
+
if (this.#target !== target2 || this.#closed) return;
|
|
23165
|
+
this.#ensureWatch();
|
|
23166
|
+
if (!this.#loadedToken) {
|
|
23167
|
+
this.#loadedToken = true;
|
|
23168
|
+
try {
|
|
23169
|
+
this.#handled = desktopExtensionsDiagnosticSchema.parse(
|
|
23170
|
+
JSON.parse(await readFile(this.#statusPath, "utf8"))
|
|
23171
|
+
).handledReloadToken;
|
|
23172
|
+
} catch {
|
|
23173
|
+
}
|
|
23174
|
+
}
|
|
23175
|
+
const {
|
|
23176
|
+
selection: { configuration },
|
|
23177
|
+
discovery
|
|
23178
|
+
} = await readDesktopExtensionSnapshot(this.#root);
|
|
23179
|
+
if (this.#target !== target2 || this.#closed) return;
|
|
23180
|
+
target2.enabled = configuration.enabled.length > 0;
|
|
23181
|
+
const token = configuration.reloadToken;
|
|
23182
|
+
if (token && token !== this.#handled) {
|
|
23183
|
+
if (target2.enabled) {
|
|
23184
|
+
await this.#recordReloadToken(target2, token);
|
|
23185
|
+
} else {
|
|
23186
|
+
await this.#replaceSnapshot(target2, []);
|
|
23187
|
+
if (token !== this.#attempted) {
|
|
23188
|
+
await target2.renderer.evaluate(reconciliation([]), 1e3).catch(() => void 0);
|
|
23189
|
+
if (this.#target !== target2 || this.#closed) return;
|
|
23190
|
+
await target2.renderer.command("Page.reload");
|
|
23191
|
+
this.#attempted = token;
|
|
23192
|
+
}
|
|
23193
|
+
target2.extensions = {};
|
|
23194
|
+
await this.#recordReloadToken(target2, token);
|
|
23195
|
+
this.hint();
|
|
23196
|
+
return;
|
|
23197
|
+
}
|
|
23198
|
+
}
|
|
23199
|
+
const desired = [];
|
|
23200
|
+
const statuses = /* @__PURE__ */ new Map();
|
|
23201
|
+
const valid = /* @__PURE__ */ new Map();
|
|
23202
|
+
for (const item of discovery.extensions) {
|
|
23203
|
+
if (item.state === "valid") valid.set(item.id, item);
|
|
23204
|
+
else statuses.set(item.id, { state: item.state, error: item.error });
|
|
23205
|
+
}
|
|
23206
|
+
const { active, conflicts } = resolveDesktopExtensionSlots(
|
|
23207
|
+
configuration.enabled,
|
|
23208
|
+
[...valid.values()].map(({ manifest }) => manifest)
|
|
23209
|
+
);
|
|
23210
|
+
let remaining = DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES - 512;
|
|
23211
|
+
for (const id of active) {
|
|
23212
|
+
const installed = valid.get(id);
|
|
23213
|
+
const item = installed && application(installed);
|
|
23214
|
+
if (!item) continue;
|
|
23215
|
+
const bytes = Buffer.byteLength(item.expression) + 2;
|
|
23216
|
+
if (bytes > remaining)
|
|
23217
|
+
statuses.set(id, {
|
|
23218
|
+
state: "failed",
|
|
23219
|
+
hash: item.hash,
|
|
23220
|
+
error: "Desktop extension snapshot size limit exceeded"
|
|
23221
|
+
});
|
|
23222
|
+
else {
|
|
23223
|
+
remaining -= bytes;
|
|
23224
|
+
desired.push(item);
|
|
23225
|
+
}
|
|
23226
|
+
}
|
|
23227
|
+
for (const [id, conflictWith] of conflicts) {
|
|
23228
|
+
const item = valid.get(id);
|
|
23229
|
+
if (item) statuses.set(id, { state: "conflict", conflictWith, hash: item.hash });
|
|
23230
|
+
}
|
|
23231
|
+
for (const id of configuration.enabled)
|
|
23232
|
+
if (!valid.has(id) && !statuses.has(id))
|
|
23233
|
+
statuses.set(id, {
|
|
23234
|
+
state: "invalid",
|
|
23235
|
+
error: discovery.diagnostic ?? "Extension directory not found"
|
|
23236
|
+
});
|
|
23237
|
+
const before = await this.#readRenderer(target2).catch(() => null);
|
|
23238
|
+
if (this.#target !== target2 || this.#closed) return;
|
|
23239
|
+
await this.#replaceSnapshot(target2, desired);
|
|
23240
|
+
const matches = (item) => before && Object.hasOwn(before, item.id) && before[item.id]?.hash === item.hash && (before[item.id]?.state === "running" || before[item.id]?.state === "waiting");
|
|
23241
|
+
const activeIds = new Set(desired.map(({ id }) => id));
|
|
23242
|
+
const old = Object.entries(before ?? {}).some(
|
|
23243
|
+
([id, state]) => !activeIds.has(id) && state.state !== "disabled"
|
|
23244
|
+
);
|
|
23245
|
+
target2.cleanupPending = old;
|
|
23246
|
+
if (old || desired.some((item) => !matches(item))) {
|
|
23247
|
+
await target2.renderer.evaluate(
|
|
23248
|
+
reconciliation(desired.map((item) => matches(item) ? item.reference : item.expression)),
|
|
23249
|
+
1e3
|
|
23250
|
+
);
|
|
23251
|
+
}
|
|
23252
|
+
const observed = await this.#readRenderer(target2).catch(() => null);
|
|
23253
|
+
for (const item of desired) {
|
|
23254
|
+
const status = observed?.[item.id];
|
|
23255
|
+
statuses.set(
|
|
23256
|
+
item.id,
|
|
23257
|
+
status?.hash === item.hash ? status : { state: "waiting", hash: item.hash }
|
|
23258
|
+
);
|
|
23259
|
+
}
|
|
23260
|
+
for (const [id, status] of Object.entries(observed ?? {}))
|
|
23261
|
+
if (!statuses.has(id) && status.state === "disabled" && status.error)
|
|
23262
|
+
statuses.set(id, status);
|
|
23263
|
+
target2.extensions = Object.fromEntries(statuses);
|
|
23264
|
+
await this.#publish(target2);
|
|
23265
|
+
}
|
|
23266
|
+
async #recordReloadToken(target2, token) {
|
|
23267
|
+
if (this.#target !== target2 || this.#closed) return;
|
|
23268
|
+
const previous = this.#handled;
|
|
23269
|
+
this.#handled = token;
|
|
23270
|
+
try {
|
|
23271
|
+
await this.#publish(target2);
|
|
23272
|
+
} catch (error51) {
|
|
23273
|
+
this.#handled = previous;
|
|
23274
|
+
throw error51;
|
|
23275
|
+
}
|
|
23276
|
+
}
|
|
23277
|
+
#pollStatus() {
|
|
23278
|
+
if (this.#pendingPoll || !this.#target) return;
|
|
23279
|
+
this.#pendingPoll = true;
|
|
23280
|
+
void this.#enqueue(async () => {
|
|
23281
|
+
const target2 = this.#target;
|
|
23282
|
+
if (!target2) return;
|
|
23283
|
+
if (target2.enabled || target2.cleanupPending) {
|
|
23284
|
+
const observed = await this.#readRenderer(target2).catch(() => null);
|
|
23285
|
+
for (const [id, status] of Object.entries(observed ?? {})) {
|
|
23286
|
+
if (status.state === "disabled" && status.error && !Object.hasOwn(target2.extensions, id))
|
|
23287
|
+
Object.defineProperty(target2.extensions, id, {
|
|
23288
|
+
value: status,
|
|
23289
|
+
enumerable: true,
|
|
23290
|
+
configurable: true,
|
|
23291
|
+
writable: true
|
|
23292
|
+
});
|
|
23293
|
+
}
|
|
23294
|
+
if (observed)
|
|
23295
|
+
target2.cleanupPending = Object.entries(observed).some(
|
|
23296
|
+
([id, status]) => status.state !== "disabled" && !Object.hasOwn(target2.extensions, id)
|
|
23297
|
+
);
|
|
23298
|
+
for (const [id, item] of Object.entries(target2.extensions)) {
|
|
23299
|
+
if (item.state === "invalid" || item.state === "conflict" || item.state === "incompatible" || item.state === "disabled")
|
|
23300
|
+
continue;
|
|
23301
|
+
const status = observed && Object.hasOwn(observed, id) ? observed[id] : void 0;
|
|
23302
|
+
if (status && status.hash === item.hash) target2.extensions[id] = status;
|
|
23303
|
+
else if (item.state !== "failed")
|
|
23304
|
+
target2.extensions[id] = { state: "waiting", ...item.hash ? { hash: item.hash } : {} };
|
|
23305
|
+
}
|
|
23306
|
+
}
|
|
23307
|
+
await this.#publish(target2);
|
|
23308
|
+
}).finally(() => {
|
|
23309
|
+
this.#pendingPoll = false;
|
|
23310
|
+
});
|
|
23311
|
+
}
|
|
23312
|
+
async #publish(target2) {
|
|
23313
|
+
if (this.#target !== target2 || this.#closed) return;
|
|
23314
|
+
const doc = {
|
|
23315
|
+
controllerPid: process.pid,
|
|
23316
|
+
targetId: target2.id,
|
|
23317
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
23318
|
+
...this.#handled ? { handledReloadToken: this.#handled } : {},
|
|
23319
|
+
extensions: target2.extensions
|
|
23320
|
+
};
|
|
23321
|
+
await mkdir2(path5.dirname(this.#statusPath), { recursive: true, mode: 448 });
|
|
23322
|
+
const temporary = `${this.#statusPath}.${randomUUID2()}.tmp`;
|
|
23323
|
+
try {
|
|
23324
|
+
await writeFile2(temporary, JSON.stringify(doc), { mode: 384, flag: "wx" });
|
|
23325
|
+
await rename2(temporary, this.#statusPath);
|
|
23326
|
+
} finally {
|
|
23327
|
+
await rm2(temporary, { force: true });
|
|
23328
|
+
}
|
|
23329
|
+
}
|
|
23330
|
+
};
|
|
23331
|
+
|
|
20512
23332
|
// packages/desktop-control/src/production-controller.ts
|
|
20513
23333
|
var PRODUCTION_INSTALL_TIMEOUT_MS = 9e4;
|
|
20514
23334
|
var RENDERER_CSP_BOOTSTRAP = "globalThis.__zod_globalConfig ??= {}; globalThis.__zod_globalConfig.jitless = true;";
|
|
@@ -20551,7 +23371,7 @@ function serializeDesktopControllerReadiness(readiness) {
|
|
|
20551
23371
|
return line;
|
|
20552
23372
|
}
|
|
20553
23373
|
var defaultDependencies = {
|
|
20554
|
-
readRenderer: (filePath) =>
|
|
23374
|
+
readRenderer: (filePath) => readFile2(filePath, "utf8"),
|
|
20555
23375
|
install: installRendererCdpControlSession,
|
|
20556
23376
|
startAttachmentServer: startControllerAttachmentServer,
|
|
20557
23377
|
ready: (readiness) => {
|
|
@@ -20589,8 +23409,8 @@ function parseDesktopControllerArguments(arguments_) {
|
|
|
20589
23409
|
if (argument === "--renderer") {
|
|
20590
23410
|
if (rendererPath !== void 0) throw new Error("--renderer may only be provided once");
|
|
20591
23411
|
if (!value) throw new Error("--renderer requires a value");
|
|
20592
|
-
if (!
|
|
20593
|
-
rendererPath =
|
|
23412
|
+
if (!path6.isAbsolute(value)) throw new Error("--renderer must be an absolute path");
|
|
23413
|
+
rendererPath = path6.normalize(value);
|
|
20594
23414
|
index += 1;
|
|
20595
23415
|
continue;
|
|
20596
23416
|
}
|
|
@@ -20658,6 +23478,13 @@ async function installProductionSession(options, dependencies) {
|
|
|
20658
23478
|
}
|
|
20659
23479
|
async function runDesktopController(options, signal, dependencies = defaultDependencies) {
|
|
20660
23480
|
const now = dependencies.now ?? Date.now;
|
|
23481
|
+
const desktopExtensions = dependencies === defaultDependencies ? new RendererDesktopExtensions(
|
|
23482
|
+
path6.dirname(path6.dirname(defaultControllerStatusPath())),
|
|
23483
|
+
(error51) => {
|
|
23484
|
+
process.stderr.write(`codexhost Desktop extensions: ${String(error51)}
|
|
23485
|
+
`);
|
|
23486
|
+
}
|
|
23487
|
+
) : void 0;
|
|
20661
23488
|
let session;
|
|
20662
23489
|
let nextRecoveryAt = 0;
|
|
20663
23490
|
let recoveryDelayMs = RECOVERY_RETRY_INITIAL_MS;
|
|
@@ -20688,7 +23515,8 @@ async function runDesktopController(options, signal, dependencies = defaultDepen
|
|
|
20688
23515
|
${rendererSource}`,
|
|
20689
23516
|
// External Agents are discovered from each target Host after installation.
|
|
20690
23517
|
timeoutMs: PRODUCTION_INSTALL_TIMEOUT_MS,
|
|
20691
|
-
signal
|
|
23518
|
+
signal,
|
|
23519
|
+
...desktopExtensions ? { desktopExtensions } : {}
|
|
20692
23520
|
},
|
|
20693
23521
|
dependencies
|
|
20694
23522
|
);
|
|
@@ -20796,6 +23624,7 @@ ${rendererSource}`,
|
|
|
20796
23624
|
});
|
|
20797
23625
|
}
|
|
20798
23626
|
} finally {
|
|
23627
|
+
desktopExtensions?.close();
|
|
20799
23628
|
await attachmentServer?.close();
|
|
20800
23629
|
await settleWithin(operation, SHUTDOWN_OPERATION_WAIT_MS);
|
|
20801
23630
|
resetSession();
|