@codexhost/cli-linux-arm64 0.22.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 +3332 -249
- package/app/console-web.js +9883 -2837
- package/app/desktop-controller.mjs +3135 -309
- package/app/host-runtime.mjs +6571 -2095
- package/app/plugins/antigravity/plugin.mjs +682 -114
- package/app/plugins/claude-code/plugin.mjs +883 -154
- package/app/plugins/codebuddy/plugin.mjs +587 -109
- package/app/plugins/codex-usage/plugin.mjs +532 -88
- package/app/plugins/copilot/plugin.mjs +532 -88
- package/app/plugins/cursor-cli/plugin.mjs +587 -109
- package/app/plugins/deepseek-harness/plugin.mjs +874 -218
- package/app/plugins/devin/plugin.mjs +532 -88
- package/app/plugins/grok/plugin.mjs +596 -105
- package/app/plugins/hermes/plugin.mjs +532 -88
- package/app/plugins/kimi-code/plugin.mjs +532 -88
- package/app/plugins/kiro-cli/plugin.mjs +532 -88
- package/app/plugins/omp/plugin.mjs +532 -88
- package/app/plugins/opencode/plugin.mjs +532 -88
- package/app/plugins/pi/plugin.mjs +538 -93
- package/app/plugins/qoder/plugin.mjs +532 -88
- package/app/plugins/qoder-cn/plugin.mjs +532 -88
- package/app/plugins/qwen-code/plugin.mjs +532 -88
- package/app/plugins/workbuddy/plugin.mjs +645 -120
- package/app/plugins/zcode/plugin.mjs +539 -95
- package/app/renderer-extension.js +12946 -4450
- package/app/web/assets/index-Dyh1KzAB.js +201 -0
- package/app/web/codexhost-settings.js +9793 -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 +34991 -3000
- 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-CN4a4sj0.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);
|
|
@@ -1466,10 +3078,10 @@ function mergeDefs(...defs) {
|
|
|
1466
3078
|
function cloneDef(schema) {
|
|
1467
3079
|
return mergeDefs(schema._zod.def);
|
|
1468
3080
|
}
|
|
1469
|
-
function getElementAtPath(obj,
|
|
1470
|
-
if (!
|
|
3081
|
+
function getElementAtPath(obj, path7) {
|
|
3082
|
+
if (!path7)
|
|
1471
3083
|
return obj;
|
|
1472
|
-
return
|
|
3084
|
+
return path7.reduce((acc, key) => acc?.[key], obj);
|
|
1473
3085
|
}
|
|
1474
3086
|
function promiseAllObject(promisesObj) {
|
|
1475
3087
|
const keys = Object.keys(promisesObj);
|
|
@@ -1878,11 +3490,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
1878
3490
|
}
|
|
1879
3491
|
return false;
|
|
1880
3492
|
}
|
|
1881
|
-
function prefixIssues(
|
|
3493
|
+
function prefixIssues(path7, issues) {
|
|
1882
3494
|
return issues.map((iss) => {
|
|
1883
3495
|
var _a3;
|
|
1884
3496
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
1885
|
-
iss.path.unshift(
|
|
3497
|
+
iss.path.unshift(path7);
|
|
1886
3498
|
return iss;
|
|
1887
3499
|
});
|
|
1888
3500
|
}
|
|
@@ -2029,16 +3641,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
2029
3641
|
}
|
|
2030
3642
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
2031
3643
|
const fieldErrors = { _errors: [] };
|
|
2032
|
-
const processError = (error52,
|
|
3644
|
+
const processError = (error52, path7 = []) => {
|
|
2033
3645
|
for (const issue2 of error52.issues) {
|
|
2034
3646
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
2035
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
3647
|
+
issue2.errors.map((issues) => processError({ issues }, [...path7, ...issue2.path]));
|
|
2036
3648
|
} else if (issue2.code === "invalid_key") {
|
|
2037
|
-
processError({ issues: issue2.issues }, [...
|
|
3649
|
+
processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
|
|
2038
3650
|
} else if (issue2.code === "invalid_element") {
|
|
2039
|
-
processError({ issues: issue2.issues }, [...
|
|
3651
|
+
processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
|
|
2040
3652
|
} else {
|
|
2041
|
-
const fullpath = [...
|
|
3653
|
+
const fullpath = [...path7, ...issue2.path];
|
|
2042
3654
|
if (fullpath.length === 0) {
|
|
2043
3655
|
fieldErrors._errors.push(mapper(issue2));
|
|
2044
3656
|
} else {
|
|
@@ -2065,17 +3677,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
2065
3677
|
}
|
|
2066
3678
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
2067
3679
|
const result = { errors: [] };
|
|
2068
|
-
const processError = (error52,
|
|
3680
|
+
const processError = (error52, path7 = []) => {
|
|
2069
3681
|
var _a3, _b;
|
|
2070
3682
|
for (const issue2 of error52.issues) {
|
|
2071
3683
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
2072
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
3684
|
+
issue2.errors.map((issues) => processError({ issues }, [...path7, ...issue2.path]));
|
|
2073
3685
|
} else if (issue2.code === "invalid_key") {
|
|
2074
|
-
processError({ issues: issue2.issues }, [...
|
|
3686
|
+
processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
|
|
2075
3687
|
} else if (issue2.code === "invalid_element") {
|
|
2076
|
-
processError({ issues: issue2.issues }, [...
|
|
3688
|
+
processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
|
|
2077
3689
|
} else {
|
|
2078
|
-
const fullpath = [...
|
|
3690
|
+
const fullpath = [...path7, ...issue2.path];
|
|
2079
3691
|
if (fullpath.length === 0) {
|
|
2080
3692
|
result.errors.push(mapper(issue2));
|
|
2081
3693
|
continue;
|
|
@@ -2107,8 +3719,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
2107
3719
|
}
|
|
2108
3720
|
function toDotPath(_path) {
|
|
2109
3721
|
const segs = [];
|
|
2110
|
-
const
|
|
2111
|
-
for (const seg of
|
|
3722
|
+
const path7 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
3723
|
+
for (const seg of path7) {
|
|
2112
3724
|
if (typeof seg === "number")
|
|
2113
3725
|
segs.push(`[${seg}]`);
|
|
2114
3726
|
else if (typeof seg === "symbol")
|
|
@@ -14800,13 +16412,13 @@ function resolveRef(ref, ctx) {
|
|
|
14800
16412
|
if (!ref.startsWith("#")) {
|
|
14801
16413
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
14802
16414
|
}
|
|
14803
|
-
const
|
|
14804
|
-
if (
|
|
16415
|
+
const path7 = ref.slice(1).split("/").filter(Boolean);
|
|
16416
|
+
if (path7.length === 0) {
|
|
14805
16417
|
return ctx.rootSchema;
|
|
14806
16418
|
}
|
|
14807
16419
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
14808
|
-
if (
|
|
14809
|
-
const key =
|
|
16420
|
+
if (path7[0] === defsKey) {
|
|
16421
|
+
const key = path7[1];
|
|
14810
16422
|
if (!key || !ctx.defs[key]) {
|
|
14811
16423
|
throw new Error(`Reference not found: ${ref}`);
|
|
14812
16424
|
}
|
|
@@ -15195,24 +16807,105 @@ __export(coerce_exports, {
|
|
|
15195
16807
|
number: () => number3,
|
|
15196
16808
|
string: () => string3
|
|
15197
16809
|
});
|
|
15198
|
-
function string3(params) {
|
|
15199
|
-
return _coercedString(ZodString, params);
|
|
15200
|
-
}
|
|
15201
|
-
function number3(params) {
|
|
15202
|
-
return _coercedNumber(ZodNumber, params);
|
|
15203
|
-
}
|
|
15204
|
-
function boolean3(params) {
|
|
15205
|
-
return _coercedBoolean(ZodBoolean, params);
|
|
15206
|
-
}
|
|
15207
|
-
function bigint3(params) {
|
|
15208
|
-
return _coercedBigint(ZodBigInt, params);
|
|
15209
|
-
}
|
|
15210
|
-
function date4(params) {
|
|
15211
|
-
return _coercedDate(ZodDate, params);
|
|
15212
|
-
}
|
|
15213
|
-
|
|
15214
|
-
// node_modules/zod/v4/classic/external.js
|
|
15215
|
-
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
|
+
});
|
|
15216
16909
|
|
|
15217
16910
|
// packages/shared-contracts/dist/json-value.js
|
|
15218
16911
|
function rejectExplicitUndefined(keys) {
|
|
@@ -15273,6 +16966,379 @@ var jsonValueSchema = nonCircularSchema.pipe(recursiveJsonValueSchema);
|
|
|
15273
16966
|
var jsonArraySchema = nonCircularSchema.pipe(external_exports.array(recursiveJsonValueSchema));
|
|
15274
16967
|
var jsonObjectSchema = nonCircularSchema.pipe(external_exports.record(external_exports.string(), recursiveJsonValueSchema));
|
|
15275
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
|
+
|
|
15276
17342
|
// packages/shared-contracts/dist/errors.js
|
|
15277
17343
|
var codexhostErrorSchema = external_exports.strictObject({
|
|
15278
17344
|
code: external_exports.string().min(1),
|
|
@@ -15293,16 +17359,6 @@ var harnessLocalizationsSchema = external_exports.record(localeSchema, external_
|
|
|
15293
17359
|
}).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
|
|
15294
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");
|
|
15295
17361
|
|
|
15296
|
-
// packages/shared-contracts/dist/ids.js
|
|
15297
|
-
var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
15298
|
-
message: "Identifier must not be empty or whitespace"
|
|
15299
|
-
});
|
|
15300
|
-
var harnessIdSchema = opaqueIdSchema.brand();
|
|
15301
|
-
var hostThreadIdSchema = opaqueIdSchema.brand();
|
|
15302
|
-
var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
15303
|
-
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
15304
|
-
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
15305
|
-
|
|
15306
17362
|
// packages/shared-contracts/dist/harness-permission-modes.js
|
|
15307
17363
|
var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
|
|
15308
17364
|
var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
|
|
@@ -15502,6 +17558,13 @@ var accountCreditsSnapshotSchema = external_exports.object({
|
|
|
15502
17558
|
productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
|
|
15503
17559
|
resetCredits: accountResetCreditsSchema.optional()
|
|
15504
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();
|
|
15505
17568
|
var threadUsageInspectionParamsSchema = external_exports.object({
|
|
15506
17569
|
threadId: hostThreadIdSchema,
|
|
15507
17570
|
refresh: external_exports.literal("exact").optional()
|
|
@@ -15510,7 +17573,10 @@ var threadUsageInspectionSchema = external_exports.object({
|
|
|
15510
17573
|
threadId: hostThreadIdSchema,
|
|
15511
17574
|
usage: threadUsageSnapshotSchema.nullable(),
|
|
15512
17575
|
accountCredits: accountCreditsSnapshotSchema.optional(),
|
|
15513
|
-
/**
|
|
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. */
|
|
15514
17580
|
accountCreditsSupported: external_exports.boolean().optional()
|
|
15515
17581
|
}).strict();
|
|
15516
17582
|
|
|
@@ -15802,12 +17868,89 @@ var threadSteeringInspectResultSchema = external_exports.object({
|
|
|
15802
17868
|
}).strict();
|
|
15803
17869
|
|
|
15804
17870
|
// packages/shared-contracts/dist/thread-archive-confirm.js
|
|
17871
|
+
var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
|
|
15805
17872
|
var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
|
|
15806
17873
|
var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
|
|
15807
17874
|
|
|
15808
17875
|
// packages/shared-contracts/dist/client-channel.js
|
|
15809
17876
|
var CLIENT_CHANNEL_VERSION = 1;
|
|
15810
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
|
+
];
|
|
15811
17954
|
var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
|
|
15812
17955
|
var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
|
|
15813
17956
|
var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
|
|
@@ -16021,6 +18164,29 @@ var threadCatalogReadResultSchema = external_exports.object({
|
|
|
16021
18164
|
officialCursor: external_exports.object({ live: external_exports.string().nullable(), archived: external_exports.string().nullable().optional() }).strict().optional()
|
|
16022
18165
|
}).strict();
|
|
16023
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
|
+
|
|
16024
18190
|
// packages/shared-contracts/dist/voice.js
|
|
16025
18191
|
var VOICE_AUDIO_MAX_BYTES = 10 * 1024 * 1024;
|
|
16026
18192
|
var voiceAudioMimeTypeSchema = external_exports.string().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);
|
|
@@ -16635,132 +18801,55 @@ var loadedSessionReasonSchema = external_exports.enum([
|
|
|
16635
18801
|
"identity",
|
|
16636
18802
|
"persistence",
|
|
16637
18803
|
"closeFailed"
|
|
16638
|
-
]);
|
|
16639
|
-
var loadedSessionsSchema = external_exports.array(external_exports.strictObject({
|
|
16640
|
-
threadId: external_exports.string(),
|
|
16641
|
-
title: external_exports.string(),
|
|
16642
|
-
harnessId: external_exports.string(),
|
|
16643
|
-
state: loadedSessionStateSchema,
|
|
16644
|
-
reason: loadedSessionReasonSchema,
|
|
16645
|
-
inactiveMs: external_exports.number().nonnegative()
|
|
16646
|
-
}));
|
|
16647
|
-
|
|
16648
|
-
// packages/shared-contracts/dist/manual-compaction.js
|
|
16649
|
-
var threadManualCompactionStartedSchema = external_exports.strictObject({
|
|
16650
|
-
threadId: hostThreadIdSchema,
|
|
16651
|
-
turnId: hostTurnIdSchema
|
|
16652
|
-
});
|
|
16653
|
-
|
|
16654
|
-
// packages/shared-contracts/dist/harness-accounts.js
|
|
16655
|
-
var
|
|
16656
|
-
|
|
16657
|
-
|
|
16658
|
-
|
|
16659
|
-
|
|
16660
|
-
|
|
16661
|
-
}).strict();
|
|
16662
|
-
var harnessAccountSnapshotObject = external_exports.object({
|
|
16663
|
-
email: external_exports.string().trim().min(1).max(320).optional(),
|
|
16664
|
-
label: external_exports.string().trim().min(1).max(256).optional(),
|
|
16665
|
-
plan: external_exports.string().trim().min(1).max(128).optional(),
|
|
16666
|
-
credits: accountCreditsSnapshotSchema.optional(),
|
|
16667
|
-
balance: accountBalanceSnapshotSchema.optional()
|
|
16668
|
-
}).strict();
|
|
16669
|
-
function requireReportedQuota(schema) {
|
|
16670
|
-
return schema.refine((value) => {
|
|
16671
|
-
const reported = value;
|
|
16672
|
-
return reported.credits !== void 0 || reported.balance !== void 0;
|
|
16673
|
-
}, { message: "Account must report either credits or a balance" });
|
|
16674
|
-
}
|
|
16675
|
-
var harnessAccountSnapshotSchema = requireReportedQuota(harnessAccountSnapshotObject);
|
|
16676
|
-
var harnessAccountIdentityShape = {
|
|
16677
|
-
harnessId: harnessIdSchema,
|
|
16678
|
-
harnessName: external_exports.string().trim().min(1).max(128)
|
|
16679
|
-
};
|
|
16680
|
-
var harnessAccountSourceSchema = external_exports.object(harnessAccountIdentityShape).strict();
|
|
16681
|
-
var harnessAccountSourceListParamsSchema = external_exports.object({}).strict();
|
|
16682
|
-
var harnessAccountSourceListResultSchema = external_exports.object({ sources: external_exports.array(harnessAccountSourceSchema).max(128) }).strict();
|
|
16683
|
-
var harnessAccountInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema, refresh: external_exports.boolean().optional() }).strict();
|
|
16684
|
-
var harnessAccountInspectResultSchema = external_exports.object({
|
|
16685
|
-
...harnessAccountIdentityShape,
|
|
16686
|
-
account: harnessAccountSnapshotSchema.nullable(),
|
|
16687
|
-
/** Every Billing Source from one Harness; `account` remains the first for older clients. */
|
|
16688
|
-
accounts: external_exports.array(harnessAccountSnapshotSchema).max(8).optional()
|
|
16689
|
-
}).strict();
|
|
16690
|
-
var harnessAccountListParamsSchema = external_exports.object({ refresh: external_exports.boolean().optional() }).strict();
|
|
16691
|
-
var harnessAccountListResultSchema = external_exports.object({
|
|
16692
|
-
accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
|
|
16693
|
-
}).strict();
|
|
16694
|
-
|
|
16695
|
-
// packages/shared-contracts/dist/harness-plugins.js
|
|
16696
|
-
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
16697
|
-
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
16698
|
-
var HARNESS_PLUGIN_LIMIT = 128;
|
|
16699
|
-
var installedHarnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).pipe(harnessIdSchema);
|
|
16700
|
-
var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id) => id !== "codex", "The official Codex identity is reserved");
|
|
16701
|
-
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");
|
|
16702
|
-
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
16703
|
-
var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
|
|
16704
|
-
var harnessInstallationGuideSchema = external_exports.object({
|
|
16705
|
-
commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
|
|
16706
|
-
before: localizedTextSchema.optional(),
|
|
16707
|
-
after: localizedTextSchema.optional(),
|
|
16708
|
-
downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
|
|
16709
|
-
}).strict();
|
|
16710
|
-
var pluginPresentationShape = {
|
|
16711
|
-
id: installedHarnessPluginIdSchema,
|
|
16712
|
-
name: external_exports.string().trim().min(1).max(128),
|
|
16713
|
-
version: external_exports.string().min(1).max(128),
|
|
16714
|
-
/** Capability-only plugin; omitted for existing session-capable plugins. */
|
|
16715
|
-
kind: external_exports.literal("usage").optional(),
|
|
16716
|
-
/** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
|
|
16717
|
-
iconStyle: external_exports.object({
|
|
16718
|
-
vector: external_exports.object({
|
|
16719
|
-
viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
|
|
16720
|
-
color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
|
|
16721
|
-
paths: external_exports.array(external_exports.object({
|
|
16722
|
-
d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
|
|
16723
|
-
fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
|
|
16724
|
-
fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
|
|
16725
|
-
}).strict()).min(1).max(32)
|
|
16726
|
-
}).strict().optional(),
|
|
16727
|
-
background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
|
|
16728
|
-
borderRadius: external_exports.number().min(0).max(50).optional(),
|
|
16729
|
-
paddingRatio: external_exports.number().min(0).max(0.25).optional()
|
|
16730
|
-
}).strict().optional(),
|
|
16731
|
-
installation: harnessInstallationGuideSchema.optional(),
|
|
16732
|
-
notice: localizedTextSchema.optional(),
|
|
16733
|
-
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
16734
|
-
launchCommand: external_exports.literal(true).optional(),
|
|
16735
|
-
links: external_exports.object({
|
|
16736
|
-
website: documentationUrlSchema.optional(),
|
|
16737
|
-
documentation: documentationUrlSchema.optional(),
|
|
16738
|
-
installation: documentationUrlSchema.optional()
|
|
16739
|
-
}).strict().optional()
|
|
16740
|
-
};
|
|
16741
|
-
var harnessPluginManifestSchema = external_exports.object({
|
|
16742
|
-
manifestVersion: external_exports.literal(1),
|
|
16743
|
-
...pluginPresentationShape,
|
|
16744
|
-
adapterApiVersion: external_exports.number().int().positive(),
|
|
16745
|
-
entry: relativeResourceSchema,
|
|
16746
|
-
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()
|
|
16747
18827
|
}).strict();
|
|
16748
|
-
|
|
16749
|
-
|
|
16750
|
-
|
|
16751
|
-
|
|
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()
|
|
16752
18848
|
}).strict();
|
|
16753
|
-
var
|
|
16754
|
-
var
|
|
16755
|
-
|
|
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)
|
|
16756
18852
|
}).strict();
|
|
16757
|
-
var harnessPluginConfigurationSchema = external_exports.object({
|
|
16758
|
-
version: external_exports.literal(1),
|
|
16759
|
-
enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
16760
|
-
}).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
|
|
16761
|
-
message: "Enabled plugin IDs must be unique",
|
|
16762
|
-
path: ["enabled"]
|
|
16763
|
-
});
|
|
16764
18853
|
|
|
16765
18854
|
// packages/shared-contracts/dist/harness-route.js
|
|
16766
18855
|
var harnessPluginRouteSchema = external_exports.object({
|
|
@@ -17351,7 +19440,7 @@ function isLocalPageUrl(value) {
|
|
|
17351
19440
|
return false;
|
|
17352
19441
|
}
|
|
17353
19442
|
}
|
|
17354
|
-
async function serveLocalPage(socket, url2,
|
|
19443
|
+
async function serveLocalPage(socket, url2, open2) {
|
|
17355
19444
|
let page;
|
|
17356
19445
|
let buffer = "";
|
|
17357
19446
|
let operation = Promise.resolve();
|
|
@@ -17383,7 +19472,7 @@ async function serveLocalPage(socket, url2, open) {
|
|
|
17383
19472
|
}
|
|
17384
19473
|
};
|
|
17385
19474
|
try {
|
|
17386
|
-
page = await
|
|
19475
|
+
page = await open2(url2);
|
|
17387
19476
|
if (socket.destroyed) return;
|
|
17388
19477
|
socket.on("data", receive);
|
|
17389
19478
|
socket.write("ready\n");
|
|
@@ -17637,6 +19726,9 @@ function createControllerStatusPublisher(filePath = defaultControllerStatusPath(
|
|
|
17637
19726
|
};
|
|
17638
19727
|
}
|
|
17639
19728
|
|
|
19729
|
+
// packages/desktop-control/src/renderer-cdp-control-session.ts
|
|
19730
|
+
import { createHash } from "node:crypto";
|
|
19731
|
+
|
|
17640
19732
|
// packages/desktop-control/src/renderer-react-ownership.ts
|
|
17641
19733
|
function committedReactAncestors(value) {
|
|
17642
19734
|
const MAX_VISITED_FIBERS = 2e5;
|
|
@@ -17666,13 +19758,13 @@ function committedReactAncestors(value) {
|
|
|
17666
19758
|
const current = fiber(rootState.current);
|
|
17667
19759
|
if (!current) return [];
|
|
17668
19760
|
const alternate = fiber(first.alternate);
|
|
17669
|
-
const
|
|
19761
|
+
const path7 = [current];
|
|
17670
19762
|
seen.clear();
|
|
17671
19763
|
seen.add(current);
|
|
17672
19764
|
for (let index = previous.length - 2; index >= 0; index -= 1) {
|
|
17673
19765
|
const expected = previous[index];
|
|
17674
19766
|
const expectedAlternate = fiber(expected?.alternate);
|
|
17675
|
-
let child = fiber(
|
|
19767
|
+
let child = fiber(path7.at(-1)?.child);
|
|
17676
19768
|
let matched = false;
|
|
17677
19769
|
while (child && !seen.has(child) && seen.size < MAX_VISITED_FIBERS) {
|
|
17678
19770
|
seen.add(child);
|
|
@@ -17683,10 +19775,10 @@ function committedReactAncestors(value) {
|
|
|
17683
19775
|
child = fiber(child.sibling);
|
|
17684
19776
|
}
|
|
17685
19777
|
if (!matched || !child) break;
|
|
17686
|
-
|
|
19778
|
+
path7.push(child);
|
|
17687
19779
|
}
|
|
17688
|
-
if (
|
|
17689
|
-
return
|
|
19780
|
+
if (path7.length === previous.length && (path7.at(-1) === first || path7.at(-1) === alternate)) {
|
|
19781
|
+
return path7.reverse();
|
|
17690
19782
|
}
|
|
17691
19783
|
const stack = [{ node: current, parent: null }];
|
|
17692
19784
|
seen.clear();
|
|
@@ -17761,20 +19853,20 @@ function retainRendererHostResponses(client, hostId2, target2) {
|
|
|
17761
19853
|
|
|
17762
19854
|
// packages/desktop-control/src/renderer-prewarm-consumption.ts
|
|
17763
19855
|
function isolateRendererPrewarmConsumption(manager, discardExternal) {
|
|
17764
|
-
const
|
|
17765
|
-
if (!
|
|
19856
|
+
const record5 = (value) => value !== null && typeof value === "object";
|
|
19857
|
+
if (!record5(manager) || !record5(manager.threadCreation)) return null;
|
|
17766
19858
|
const creation = manager.threadCreation;
|
|
17767
19859
|
const originalStart = manager.startConversation;
|
|
17768
19860
|
const original = creation.createConversation;
|
|
17769
19861
|
const params = creation.params;
|
|
17770
|
-
if (typeof originalStart !== "function" || typeof original !== "function" || !
|
|
19862
|
+
if (typeof originalStart !== "function" || typeof original !== "function" || !record5(params))
|
|
17771
19863
|
return null;
|
|
17772
19864
|
const prototype = Object.getPrototypeOf(creation);
|
|
17773
|
-
if (!
|
|
19865
|
+
if (!record5(prototype) || typeof prototype.constructor !== "function") return null;
|
|
17774
19866
|
if (Object.keys(creation).some((key) => key !== "params" && typeof creation[key] !== "function") || /#[A-Za-z_$]/u.test(Function.prototype.toString.call(prototype.constructor)))
|
|
17775
19867
|
return null;
|
|
17776
19868
|
const pool = params.prewarmedThreadManager;
|
|
17777
|
-
if (!
|
|
19869
|
+
if (!record5(pool) || typeof pool.hasPrewarmedThread !== "function" || typeof pool.consumePrewarmedThread !== "function" || typeof pool.deletePrewarmedThread !== "function")
|
|
17778
19870
|
return null;
|
|
17779
19871
|
const consume = pool.consumePrewarmedThread;
|
|
17780
19872
|
const hasPrewarm = pool.hasPrewarmedThread;
|
|
@@ -17782,14 +19874,14 @@ function isolateRendererPrewarmConsumption(manager, discardExternal) {
|
|
|
17782
19874
|
const draftIdentity = /* @__PURE__ */ Symbol("codexhost draft creation");
|
|
17783
19875
|
const external = (model2) => typeof model2 === "string" && model2.startsWith("codexhost/");
|
|
17784
19876
|
const routedStart = function(input, options, ...args) {
|
|
17785
|
-
const draftId =
|
|
17786
|
-
const mode =
|
|
19877
|
+
const draftId = record5(options) ? options.clientThreadId : null;
|
|
19878
|
+
const mode = record5(input) && record5(input.collaborationMode) ? input.collaborationMode : null;
|
|
17787
19879
|
const origin = mode ? Reflect.get(mode, draftIdentity) : void 0;
|
|
17788
|
-
if (mode &&
|
|
19880
|
+
if (mode && record5(mode.settings) && external(mode.settings.model))
|
|
17789
19881
|
return originalStart.call(this, input, options, ...args);
|
|
17790
19882
|
const model2 = (typeof draftId === "string" ? draftModels.get(draftId) : void 0) ?? (typeof origin === "string" ? draftModels.get(origin) : void 0);
|
|
17791
19883
|
if (!model2) return originalStart.call(this, input, options, ...args);
|
|
17792
|
-
if (!
|
|
19884
|
+
if (!record5(input) || !record5(input.collaborationMode) || !record5(input.collaborationMode.settings))
|
|
17793
19885
|
throw new Error("External draft creation is missing its native Model settings");
|
|
17794
19886
|
const routed = {
|
|
17795
19887
|
...input,
|
|
@@ -17801,17 +19893,17 @@ function isolateRendererPrewarmConsumption(manager, discardExternal) {
|
|
|
17801
19893
|
return originalStart.call(this, routed, options, ...args);
|
|
17802
19894
|
};
|
|
17803
19895
|
const wrapped = function(input, ...args) {
|
|
17804
|
-
const mode =
|
|
17805
|
-
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;
|
|
17806
19898
|
const scopedPool = Object.create(pool);
|
|
17807
19899
|
scopedPool.hasPrewarmedThread = (...parameters) => hasPrewarm.apply(pool, parameters);
|
|
17808
19900
|
scopedPool.consumePrewarmedThread = async (...consumeArgs) => {
|
|
17809
19901
|
const warmed = await consume.apply(pool, consumeArgs);
|
|
17810
|
-
if (!
|
|
19902
|
+
if (!record5(warmed) || !record5(warmed.response)) return warmed;
|
|
17811
19903
|
const response = warmed.response;
|
|
17812
19904
|
if (!external(expected) && !external(response.model)) return warmed;
|
|
17813
19905
|
if (external(expected) && expected === response.model) return warmed;
|
|
17814
|
-
if (
|
|
19906
|
+
if (record5(response.thread) && typeof response.thread.id === "string") {
|
|
17815
19907
|
const threadId = response.thread.id;
|
|
17816
19908
|
if (external(response.model)) discardExternal(threadId);
|
|
17817
19909
|
else
|
|
@@ -18233,15 +20325,35 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target2, prewa
|
|
|
18233
20325
|
if (threadId && knownOfficialThreadIds.has(threadId)) return false;
|
|
18234
20326
|
return selectedModel !== null && (method.startsWith("thread/") || method.startsWith("turn/") || method.startsWith("review/"));
|
|
18235
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
|
+
});
|
|
18236
20338
|
const routedSend = (method, parameters, options) => {
|
|
20339
|
+
const threadId = threadIdFromParameters(parameters);
|
|
18237
20340
|
if (method === "turn/start" || method === "thread/resume" || method === "codexhost/thread/command/execute") {
|
|
18238
|
-
const threadId = threadIdFromParameters(parameters);
|
|
18239
20341
|
if (threadId) externalPrewarms.delete(threadId);
|
|
18240
20342
|
}
|
|
18241
20343
|
const sendBridged = () => initializeBridge().then(
|
|
18242
20344
|
() => enqueueBridgeRequest(method, parameters, options)
|
|
18243
20345
|
);
|
|
18244
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
|
+
}
|
|
18245
20357
|
const unresolvedThreadId = shouldResolveThreadOwnership(method, parameters);
|
|
18246
20358
|
if (unresolvedThreadId) {
|
|
18247
20359
|
return resolveThreadOwnership(unresolvedThreadId).then(
|
|
@@ -18417,14 +20529,14 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target2, prewa
|
|
|
18417
20529
|
|
|
18418
20530
|
// packages/desktop-control/src/renderer-host-discovery.ts
|
|
18419
20531
|
function requestManagerFromHookState(value, hostId2) {
|
|
18420
|
-
const
|
|
20532
|
+
const record5 = (candidate) => typeof candidate === "object" && candidate !== null;
|
|
18421
20533
|
const manager = (candidate) => {
|
|
18422
|
-
if (!
|
|
20534
|
+
if (!record5(candidate) || !record5(candidate.requestClient) || !record5(candidate.prewarmedThreadManager))
|
|
18423
20535
|
return null;
|
|
18424
20536
|
const bridge = candidate.requestClient;
|
|
18425
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;
|
|
18426
20538
|
};
|
|
18427
|
-
if (!
|
|
20539
|
+
if (!record5(value)) return null;
|
|
18428
20540
|
const direct = manager(value) ?? manager(value.manager);
|
|
18429
20541
|
if (direct) return direct;
|
|
18430
20542
|
if (!hostId2 || typeof value.addManager !== "function" || typeof value.getForHostId !== "function")
|
|
@@ -18499,7 +20611,7 @@ function resolveRendererHostManager(discovery, hostId2, managerFrom = requestMan
|
|
|
18499
20611
|
}
|
|
18500
20612
|
|
|
18501
20613
|
// packages/desktop-control/src/renderer-host-routing.ts
|
|
18502
|
-
function installRendererHostRouting(root, target2,
|
|
20614
|
+
function installRendererHostRouting(root, target2, discover2, resolve, createPolicy, readConnection, publishRouting = true) {
|
|
18503
20615
|
const existing = target2.__codexhostHostRoutingV1;
|
|
18504
20616
|
if (publishRouting && existing) return existing;
|
|
18505
20617
|
if (publishRouting)
|
|
@@ -18511,7 +20623,7 @@ function installRendererHostRouting(root, target2, discover, resolve, createPoli
|
|
|
18511
20623
|
const source = composer?.matches?.(
|
|
18512
20624
|
'[data-codex-composer], [contenteditable="true"][role="textbox"]'
|
|
18513
20625
|
) ? { querySelectorAll: () => [composer] } : composer ?? root;
|
|
18514
|
-
const discovery =
|
|
20626
|
+
const discovery = discover2(source);
|
|
18515
20627
|
if (composer) return discovery;
|
|
18516
20628
|
if (discovery.editorCount === 0 && lastDiscovery) return lastDiscovery;
|
|
18517
20629
|
lastDiscovery = discovery;
|
|
@@ -18655,15 +20767,15 @@ function installRendererHostRouting(root, target2, discover, resolve, createPoli
|
|
|
18655
20767
|
// packages/desktop-control/src/renderer-host-rpc-discovery.ts
|
|
18656
20768
|
function findRendererAppScopeStore(root) {
|
|
18657
20769
|
const MAX_VISITED_FIBERS = 5e4;
|
|
18658
|
-
const
|
|
20770
|
+
const record5 = (value) => typeof value === "object" && value !== null;
|
|
18659
20771
|
const container = root.getElementById?.("root");
|
|
18660
|
-
if (!
|
|
20772
|
+
if (!record5(container)) return null;
|
|
18661
20773
|
const key = Object.getOwnPropertyNames(container).find(
|
|
18662
20774
|
(name) => name.startsWith("__reactContainer$")
|
|
18663
20775
|
);
|
|
18664
20776
|
const first = key ? container[key] : null;
|
|
18665
|
-
if (!
|
|
18666
|
-
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";
|
|
18667
20779
|
const stack = [first];
|
|
18668
20780
|
const seen = /* @__PURE__ */ new Set();
|
|
18669
20781
|
while (stack.length && seen.size < MAX_VISITED_FIBERS) {
|
|
@@ -18671,44 +20783,44 @@ function findRendererAppScopeStore(root) {
|
|
|
18671
20783
|
if (seen.has(fiber)) continue;
|
|
18672
20784
|
seen.add(fiber);
|
|
18673
20785
|
let hook = fiber.memoizedState;
|
|
18674
|
-
for (let index = 0;
|
|
20786
|
+
for (let index = 0; record5(hook) && "next" in hook && index < 150; index += 1) {
|
|
18675
20787
|
const state = hook.memoizedState;
|
|
18676
|
-
const handle =
|
|
20788
|
+
const handle = record5(state) ? state.current : null;
|
|
18677
20789
|
if (isScopeHandle(handle)) {
|
|
18678
20790
|
let node = handle.node;
|
|
18679
20791
|
const nodes = /* @__PURE__ */ new Set();
|
|
18680
|
-
while (
|
|
20792
|
+
while (record5(node.parent) && !nodes.has(node.parent)) {
|
|
18681
20793
|
nodes.add(node);
|
|
18682
20794
|
node = node.parent;
|
|
18683
20795
|
}
|
|
18684
20796
|
const bindings = node.familyBindings;
|
|
18685
|
-
return
|
|
20797
|
+
return record5(bindings) && typeof bindings.get === "function" && typeof bindings.entries === "function" ? node : null;
|
|
18686
20798
|
}
|
|
18687
20799
|
hook = hook.next;
|
|
18688
20800
|
}
|
|
18689
|
-
if (
|
|
18690
|
-
if (
|
|
20801
|
+
if (record5(fiber.sibling)) stack.push(fiber.sibling);
|
|
20802
|
+
if (record5(fiber.child)) stack.push(fiber.child);
|
|
18691
20803
|
}
|
|
18692
20804
|
return null;
|
|
18693
20805
|
}
|
|
18694
20806
|
function findRendererHostRpcFamily(store) {
|
|
18695
|
-
const
|
|
20807
|
+
const record5 = (value) => typeof value === "object" && value !== null;
|
|
18696
20808
|
const families = /* @__PURE__ */ new Set();
|
|
18697
20809
|
for (const [definition, members] of store.familyBindings) {
|
|
18698
|
-
if (!
|
|
18699
|
-
if (!
|
|
20810
|
+
if (!record5(definition) || definition.kind !== "signal-family") continue;
|
|
20811
|
+
if (!record5(members) || typeof members.get !== "function") continue;
|
|
18700
20812
|
for (const [hostId2, member] of members) {
|
|
18701
20813
|
if (typeof hostId2 !== "string" || !/^(?:local$|durable$|remote[-:])/u.test(hostId2)) continue;
|
|
18702
|
-
if (!
|
|
20814
|
+
if (!record5(member)) continue;
|
|
18703
20815
|
const signal = member.value;
|
|
18704
|
-
if (!
|
|
20816
|
+
if (!record5(signal) || typeof signal.get !== "function") continue;
|
|
18705
20817
|
let value;
|
|
18706
20818
|
try {
|
|
18707
20819
|
value = signal.get();
|
|
18708
20820
|
} catch {
|
|
18709
20821
|
continue;
|
|
18710
20822
|
}
|
|
18711
|
-
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) {
|
|
18712
20824
|
families.add(members);
|
|
18713
20825
|
break;
|
|
18714
20826
|
}
|
|
@@ -18719,34 +20831,34 @@ function findRendererHostRpcFamily(store) {
|
|
|
18719
20831
|
}
|
|
18720
20832
|
function resolveRendererHostRpc(discovery, hostId2) {
|
|
18721
20833
|
if (hostId2 === "durable") return null;
|
|
18722
|
-
const
|
|
20834
|
+
const record5 = (value2) => typeof value2 === "object" && value2 !== null;
|
|
18723
20835
|
const signal = discovery.family.get(hostId2)?.value;
|
|
18724
|
-
if (!
|
|
20836
|
+
if (!record5(signal) || typeof signal.get !== "function") return null;
|
|
18725
20837
|
let value;
|
|
18726
20838
|
try {
|
|
18727
20839
|
value = signal.get();
|
|
18728
20840
|
} catch {
|
|
18729
20841
|
return null;
|
|
18730
20842
|
}
|
|
18731
|
-
if (!
|
|
20843
|
+
if (!record5(value) || value.status !== "ready" || !record5(value.client) || value.client.hostId !== hostId2)
|
|
18732
20844
|
return null;
|
|
18733
20845
|
const rpc = value.client.rpc;
|
|
18734
|
-
return typeof rpc === "function" ||
|
|
20846
|
+
return typeof rpc === "function" || record5(rpc) ? rpc : null;
|
|
18735
20847
|
}
|
|
18736
20848
|
function rendererHostRpcHostIds(discovery) {
|
|
18737
|
-
const
|
|
20849
|
+
const record5 = (value) => typeof value === "object" && value !== null;
|
|
18738
20850
|
const hostIds = [];
|
|
18739
20851
|
for (const [hostId2, member] of discovery.family) {
|
|
18740
|
-
if (typeof hostId2 !== "string" || hostId2 === "durable" || !
|
|
20852
|
+
if (typeof hostId2 !== "string" || hostId2 === "durable" || !record5(member)) continue;
|
|
18741
20853
|
const signal = member.value;
|
|
18742
|
-
if (!
|
|
20854
|
+
if (!record5(signal) || typeof signal.get !== "function") continue;
|
|
18743
20855
|
let value;
|
|
18744
20856
|
try {
|
|
18745
20857
|
value = signal.get();
|
|
18746
20858
|
} catch {
|
|
18747
20859
|
continue;
|
|
18748
20860
|
}
|
|
18749
|
-
if (
|
|
20861
|
+
if (record5(value) && value.status === "ready" && record5(value.client) && value.client.hostId === hostId2 && (typeof value.client.rpc === "function" || record5(value.client.rpc))) {
|
|
18750
20862
|
hostIds.push(hostId2);
|
|
18751
20863
|
}
|
|
18752
20864
|
}
|
|
@@ -18828,25 +20940,25 @@ function installRendererHostRpcRouting(root, target2, dependencies) {
|
|
|
18828
20940
|
const expression = message[1];
|
|
18829
20941
|
if (!Array.isArray(expression) || expression.length !== 4 || expression[0] !== "pipeline")
|
|
18830
20942
|
return message;
|
|
18831
|
-
const [, importId,
|
|
18832
|
-
if (!Array.isArray(
|
|
20943
|
+
const [, importId, path7, args] = expression;
|
|
20944
|
+
if (!Array.isArray(path7) || path7.length !== 1 || !Array.isArray(args)) return message;
|
|
18833
20945
|
const [input, options] = args;
|
|
18834
20946
|
if (!isRecord3(input) || !isRecord3(input.collaborationMode)) return message;
|
|
18835
20947
|
const settings = input.collaborationMode.settings;
|
|
18836
20948
|
if (!isRecord3(settings)) return message;
|
|
18837
20949
|
const nativeModel = typeof settings.model === "string" ? settings.model : null;
|
|
18838
20950
|
let model2 = null;
|
|
18839
|
-
if (
|
|
20951
|
+
if (path7[0] === "startConversation") {
|
|
18840
20952
|
const draftId = isRecord3(options) ? options.clientThreadId : null;
|
|
18841
20953
|
model2 = typeof draftId === "string" ? externalDrafts.get(draftId)?.model ?? null : null;
|
|
18842
|
-
} else if (
|
|
20954
|
+
} else if (path7[0] === "prewarmConversation") {
|
|
18843
20955
|
if (input.ephemeral !== true) publishDraftWorkspace("local", input.cwd);
|
|
18844
20956
|
const selected = selectedModels.get("local") ?? null;
|
|
18845
20957
|
const carrier = nativeModel?.startsWith("codexhost/") ? nativeModel : selected;
|
|
18846
20958
|
model2 = carrier ? prewarmCarrier(carrier) : null;
|
|
18847
20959
|
}
|
|
18848
20960
|
if (!model2) return message;
|
|
18849
|
-
if (
|
|
20961
|
+
if (path7[0] === "startConversation" && nativeModel?.startsWith("codexhost/"))
|
|
18850
20962
|
model2 = nativeModel;
|
|
18851
20963
|
const config2 = input.config == null ? { model: model2 } : isRecord3(input.config) ? { model: model2, ...input.config } : input.config;
|
|
18852
20964
|
return [
|
|
@@ -18854,11 +20966,11 @@ function installRendererHostRpcRouting(root, target2, dependencies) {
|
|
|
18854
20966
|
[
|
|
18855
20967
|
"pipeline",
|
|
18856
20968
|
importId,
|
|
18857
|
-
|
|
20969
|
+
path7,
|
|
18858
20970
|
[
|
|
18859
20971
|
{
|
|
18860
20972
|
...input,
|
|
18861
|
-
...
|
|
20973
|
+
...path7[0] === "startConversation" ? { config: config2 } : {},
|
|
18862
20974
|
collaborationMode: { ...input.collaborationMode, settings: { ...settings, model: model2 } }
|
|
18863
20975
|
},
|
|
18864
20976
|
...args.slice(1)
|
|
@@ -19085,11 +21197,11 @@ function installRendererHostRpcRouting(root, target2, dependencies) {
|
|
|
19085
21197
|
// packages/desktop-control/src/renderer-connection-generation.ts
|
|
19086
21198
|
function readRendererConnectionGeneration(store, hostId2) {
|
|
19087
21199
|
if (!store) return void 0;
|
|
19088
|
-
const
|
|
21200
|
+
const record5 = (value) => value !== null && typeof value === "object";
|
|
19089
21201
|
const candidates = /* @__PURE__ */ new Set();
|
|
19090
21202
|
for (const members of store.familyBindings.values()) {
|
|
19091
21203
|
const value = members.get(hostId2)?.value;
|
|
19092
|
-
if (
|
|
21204
|
+
if (record5(value) && record5(value.state$) && record5(value.revision$) && record5(value.appServerVersion$) && typeof value.state$.get === "function" && typeof value.revision$.get === "function")
|
|
19093
21205
|
candidates.add(value);
|
|
19094
21206
|
}
|
|
19095
21207
|
if (!candidates.size) return void 0;
|
|
@@ -19213,7 +21325,7 @@ function nativeModuleCatalogExpression(urls, complete, owner) {
|
|
|
19213
21325
|
value: Object.freeze({ owner: ${JSON.stringify(owner)}, documentUrl: location.href, complete: ${complete}, urls: Object.freeze(${JSON.stringify(urls)}) })
|
|
19214
21326
|
}); void 0`;
|
|
19215
21327
|
}
|
|
19216
|
-
async function installRendererLoadedModules(renderer) {
|
|
21328
|
+
async function installRendererLoadedModules(renderer, onDesktopContext) {
|
|
19217
21329
|
const owner = crypto.randomUUID();
|
|
19218
21330
|
const contexts = /* @__PURE__ */ new Map();
|
|
19219
21331
|
const contextIds = /* @__PURE__ */ new Map();
|
|
@@ -19276,6 +21388,8 @@ async function installRendererLoadedModules(renderer) {
|
|
|
19276
21388
|
const context = record3(params) ? params.context : null;
|
|
19277
21389
|
if (!record3(context) || typeof context.id !== "number" || typeof context.uniqueId !== "string" || !record3(context.auxData) || context.auxData.isDefault !== true)
|
|
19278
21390
|
return;
|
|
21391
|
+
if (typeof context.origin === "string" && /^app:\/\/-\/?$/u.test(context.origin))
|
|
21392
|
+
onDesktopContext?.();
|
|
19279
21393
|
contextIds.set(context.id, context.uniqueId);
|
|
19280
21394
|
contexts.set(context.uniqueId, { urls: /* @__PURE__ */ new Set(), complete: true });
|
|
19281
21395
|
schedule(context.uniqueId);
|
|
@@ -19623,9 +21737,9 @@ function createNativeRemoteManager(components, hostId2, original, target2, creat
|
|
|
19623
21737
|
pending.add(result);
|
|
19624
21738
|
return result;
|
|
19625
21739
|
};
|
|
19626
|
-
const
|
|
21740
|
+
const record5 = (value) => value !== null && typeof value === "object";
|
|
19627
21741
|
const dispatch = (type, payload) => {
|
|
19628
|
-
if ((type === "mcp-request" || type === "thread-prewarm-start") &&
|
|
21742
|
+
if ((type === "mcp-request" || type === "thread-prewarm-start") && record5(payload) && record5(payload.request)) {
|
|
19629
21743
|
const request = payload.request;
|
|
19630
21744
|
const options = {};
|
|
19631
21745
|
for (const key of ["priority", "timeoutMs", "source", "trace", "threadAccess"])
|
|
@@ -19637,7 +21751,7 @@ function createNativeRemoteManager(components, hostId2, original, target2, creat
|
|
|
19637
21751
|
(error51) => {
|
|
19638
21752
|
if (!disposed)
|
|
19639
21753
|
client.onError(request.id, {
|
|
19640
|
-
code:
|
|
21754
|
+
code: record5(error51) ? error51.jsonRpcCode ?? error51.code ?? -32603 : -32603,
|
|
19641
21755
|
message: error51 instanceof Error ? error51.message : String(error51)
|
|
19642
21756
|
});
|
|
19643
21757
|
}
|
|
@@ -19684,13 +21798,13 @@ function createNativeRemoteManager(components, hostId2, original, target2, creat
|
|
|
19684
21798
|
interactions = nativeInteractions;
|
|
19685
21799
|
const notify = (event) => {
|
|
19686
21800
|
const { data, source: source2, origin } = event;
|
|
19687
|
-
if (disposed || source2 != null && source2 !== target2 || !
|
|
21801
|
+
if (disposed || source2 != null && source2 !== target2 || !record5(data) || data.hostId !== hostId2)
|
|
19688
21802
|
return;
|
|
19689
|
-
const ownOrigin =
|
|
21803
|
+
const ownOrigin = record5(target2.location) ? target2.location.origin : void 0;
|
|
19690
21804
|
if (source2 === target2 && ownOrigin && ownOrigin !== "null" && origin !== ownOrigin) return;
|
|
19691
21805
|
if (data.type === "mcp-notification" && typeof data.method === "string" && !data.method.startsWith("process/"))
|
|
19692
21806
|
owned.onNotification(data.method, data.params);
|
|
19693
|
-
if (data.type === "mcp-request") owned.onRequest(
|
|
21807
|
+
if (data.type === "mcp-request") owned.onRequest(record5(data.request) ? data.request : data);
|
|
19694
21808
|
};
|
|
19695
21809
|
target2.addEventListener?.("message", notify);
|
|
19696
21810
|
return {
|
|
@@ -19783,7 +21897,7 @@ function createNativeRpcService(components, createRemote) {
|
|
|
19783
21897
|
const routes = /* @__PURE__ */ new Map();
|
|
19784
21898
|
const subscriptions = /* @__PURE__ */ new Set();
|
|
19785
21899
|
let refs = 1;
|
|
19786
|
-
const
|
|
21900
|
+
const record5 = (value) => value !== null && typeof value === "object";
|
|
19787
21901
|
const connectionSignals = (hostId2) => {
|
|
19788
21902
|
let node = components.scope.node;
|
|
19789
21903
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -19794,7 +21908,7 @@ function createNativeRpcService(components, createRemote) {
|
|
|
19794
21908
|
const found = [];
|
|
19795
21909
|
for (const members of node.familyBindings.values()) {
|
|
19796
21910
|
const value = members.get(hostId2)?.value;
|
|
19797
|
-
if (
|
|
21911
|
+
if (record5(value) && Object.hasOwn(value, "state$") && Object.hasOwn(value, "revision$") && Object.hasOwn(value, "appServerVersion$"))
|
|
19798
21912
|
found.push({ state$: value.state$, revision$: value.revision$ });
|
|
19799
21913
|
}
|
|
19800
21914
|
return found.length === 1 ? found[0] : void 0;
|
|
@@ -19939,7 +22053,7 @@ function retainNativeRpcInteractions(upstream, manager, hostId2) {
|
|
|
19939
22053
|
const retained = /* @__PURE__ */ new Set();
|
|
19940
22054
|
const requests = /* @__PURE__ */ new Map();
|
|
19941
22055
|
const reads = /* @__PURE__ */ new Map();
|
|
19942
|
-
const
|
|
22056
|
+
const record5 = (value) => value !== null && typeof value === "object";
|
|
19943
22057
|
const read = (threadId) => {
|
|
19944
22058
|
const existing = reads.get(threadId);
|
|
19945
22059
|
if (existing) {
|
|
@@ -19956,12 +22070,12 @@ function retainNativeRpcInteractions(upstream, manager, hostId2) {
|
|
|
19956
22070
|
retained.add(pending);
|
|
19957
22071
|
try {
|
|
19958
22072
|
const conversation = await pending;
|
|
19959
|
-
if (disposed || entry.dirty || !
|
|
22073
|
+
if (disposed || entry.dirty || !record5(conversation) || !Array.isArray(conversation.requests))
|
|
19960
22074
|
continue;
|
|
19961
22075
|
const previous = requests.get(threadId) ?? /* @__PURE__ */ new Set();
|
|
19962
22076
|
const next = /* @__PURE__ */ new Set();
|
|
19963
22077
|
for (const request of conversation.requests) {
|
|
19964
|
-
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")
|
|
19965
22079
|
continue;
|
|
19966
22080
|
next.add(request.id);
|
|
19967
22081
|
if (!previous.has(request.id)) manager.onRequest(request);
|
|
@@ -19978,7 +22092,7 @@ function retainNativeRpcInteractions(upstream, manager, hostId2) {
|
|
|
19978
22092
|
return entry.promise;
|
|
19979
22093
|
};
|
|
19980
22094
|
const event = (value) => {
|
|
19981
|
-
if (disposed || !
|
|
22095
|
+
if (disposed || !record5(value) || typeof value.conversationId !== "string") return;
|
|
19982
22096
|
void read(value.conversationId).catch(() => void 0);
|
|
19983
22097
|
};
|
|
19984
22098
|
const subscribe = (input) => {
|
|
@@ -20001,7 +22115,7 @@ function retainNativeRpcInteractions(upstream, manager, hostId2) {
|
|
|
20001
22115
|
key: { hostId: hostId2 },
|
|
20002
22116
|
methods: ["serverRequest/resolved"],
|
|
20003
22117
|
listener(value) {
|
|
20004
|
-
if (
|
|
22118
|
+
if (record5(value) && record5(value.params) && typeof value.params.threadId === "string")
|
|
20005
22119
|
event({ conversationId: value.params.threadId });
|
|
20006
22120
|
}
|
|
20007
22121
|
})
|
|
@@ -20016,7 +22130,7 @@ function retainNativeRpcInteractions(upstream, manager, hostId2) {
|
|
|
20016
22130
|
if (!Array.isArray(work)) throw new Error("Native RPC interaction snapshot is unavailable");
|
|
20017
22131
|
const threadIds = new Set(
|
|
20018
22132
|
work.flatMap(
|
|
20019
|
-
(item) =>
|
|
22133
|
+
(item) => record5(item) && typeof item.conversationId === "string" ? [item.conversationId] : []
|
|
20020
22134
|
)
|
|
20021
22135
|
);
|
|
20022
22136
|
await Promise.all([...threadIds].map(read));
|
|
@@ -20221,8 +22335,8 @@ function discoveryTimeoutSignal(timeoutMs, signal) {
|
|
|
20221
22335
|
const timeout = AbortSignal.timeout(timeoutMs);
|
|
20222
22336
|
return signal ? AbortSignal.any([timeout, signal]) : timeout;
|
|
20223
22337
|
}
|
|
20224
|
-
function abortFailure(signal,
|
|
20225
|
-
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);
|
|
20226
22340
|
}
|
|
20227
22341
|
function awaitWithSignal(promise2, signal, timeoutMessage) {
|
|
20228
22342
|
if (signal.aborted) return Promise.reject(abortFailure(signal, timeoutMessage));
|
|
@@ -20353,25 +22467,54 @@ async function waitForBinding(renderer, enabledAgents, timeoutMs, pollIntervalMs
|
|
|
20353
22467
|
const detail = lastError instanceof Error ? `: ${lastError.message}` : "";
|
|
20354
22468
|
throw new Error(`Production Renderer binding did not become ready${detail}`);
|
|
20355
22469
|
}
|
|
20356
|
-
|
|
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) {
|
|
20357
22478
|
const renderer = await operations.connect(target2.webSocketDebuggerUrl);
|
|
20358
22479
|
let disposeModules;
|
|
22480
|
+
let detach;
|
|
22481
|
+
const attachExtensions = () => {
|
|
22482
|
+
detach ??= extensions?.attach(target2.id, renderer);
|
|
22483
|
+
};
|
|
20359
22484
|
try {
|
|
20360
|
-
disposeModules = await installRendererLoadedModules(
|
|
22485
|
+
disposeModules = await installRendererLoadedModules(
|
|
22486
|
+
renderer,
|
|
22487
|
+
extensions ? () => extensions.hint() : void 0
|
|
22488
|
+
);
|
|
20361
22489
|
await renderer.command("Page.enable");
|
|
20362
|
-
|
|
20363
|
-
await
|
|
22490
|
+
const source = extensions ? reconnectableRendererSource(rendererSource) : rendererSource;
|
|
22491
|
+
await renderer.command("Page.addScriptToEvaluateOnNewDocument", { source });
|
|
22492
|
+
if (!replacingSession) attachExtensions();
|
|
22493
|
+
await evaluateSource(renderer, source);
|
|
20364
22494
|
const draftPrewarmPolicy = await operations.installDraftPrewarmPolicy(renderer);
|
|
20365
22495
|
const binding = await waitForBinding(renderer, enabledAgents, timeoutMs, pollIntervalMs);
|
|
20366
|
-
|
|
22496
|
+
extensions?.hint();
|
|
22497
|
+
return {
|
|
22498
|
+
renderer,
|
|
22499
|
+
snapshot: { target: target2, draftPrewarmPolicy, binding },
|
|
22500
|
+
attachExtensions,
|
|
22501
|
+
disposeModules: () => {
|
|
22502
|
+
disposeModules?.();
|
|
22503
|
+
return detach?.();
|
|
22504
|
+
}
|
|
22505
|
+
};
|
|
20367
22506
|
} catch (error51) {
|
|
20368
22507
|
disposeModules?.();
|
|
20369
|
-
|
|
22508
|
+
try {
|
|
22509
|
+
await detach?.();
|
|
22510
|
+
} finally {
|
|
22511
|
+
renderer.close();
|
|
22512
|
+
}
|
|
20370
22513
|
throw error51;
|
|
20371
22514
|
}
|
|
20372
22515
|
}
|
|
20373
22516
|
var InstalledRendererCdpControlSession = class {
|
|
20374
|
-
constructor(renderer, rendererCdpEndpoint2, rendererSource, enabledAgents, timeoutMs, pollIntervalMs, operations, currentSnapshot, disposeModules) {
|
|
22517
|
+
constructor(renderer, rendererCdpEndpoint2, rendererSource, enabledAgents, timeoutMs, pollIntervalMs, operations, currentSnapshot, disposeModules, extensions) {
|
|
20375
22518
|
this.renderer = renderer;
|
|
20376
22519
|
this.rendererCdpEndpoint = rendererCdpEndpoint2;
|
|
20377
22520
|
this.rendererSource = rendererSource;
|
|
@@ -20381,6 +22524,7 @@ var InstalledRendererCdpControlSession = class {
|
|
|
20381
22524
|
this.operations = operations;
|
|
20382
22525
|
this.currentSnapshot = currentSnapshot;
|
|
20383
22526
|
this.disposeModules = disposeModules;
|
|
22527
|
+
this.extensions = extensions;
|
|
20384
22528
|
}
|
|
20385
22529
|
renderer;
|
|
20386
22530
|
rendererCdpEndpoint;
|
|
@@ -20391,6 +22535,7 @@ var InstalledRendererCdpControlSession = class {
|
|
|
20391
22535
|
operations;
|
|
20392
22536
|
currentSnapshot;
|
|
20393
22537
|
disposeModules;
|
|
22538
|
+
extensions;
|
|
20394
22539
|
#closed = false;
|
|
20395
22540
|
get snapshot() {
|
|
20396
22541
|
return this.currentSnapshot;
|
|
@@ -20404,50 +22549,49 @@ var InstalledRendererCdpControlSession = class {
|
|
|
20404
22549
|
this.pollIntervalMs,
|
|
20405
22550
|
this.currentSnapshot.target.id
|
|
20406
22551
|
);
|
|
20407
|
-
if (target2.id
|
|
20408
|
-
|
|
20409
|
-
|
|
20410
|
-
this.rendererSource
|
|
20411
|
-
this.
|
|
20412
|
-
|
|
20413
|
-
|
|
20414
|
-
|
|
20415
|
-
|
|
20416
|
-
|
|
20417
|
-
|
|
20418
|
-
|
|
20419
|
-
|
|
20420
|
-
|
|
20421
|
-
|
|
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
|
+
}
|
|
20422
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
|
+
);
|
|
20423
22579
|
try {
|
|
20424
|
-
|
|
20425
|
-
|
|
20426
|
-
|
|
20427
|
-
|
|
20428
|
-
|
|
20429
|
-
|
|
20430
|
-
|
|
20431
|
-
|
|
20432
|
-
);
|
|
20433
|
-
|
|
20434
|
-
return this.currentSnapshot;
|
|
20435
|
-
} catch {
|
|
20436
|
-
const replacement = await installTarget(
|
|
20437
|
-
target2,
|
|
20438
|
-
this.rendererSource,
|
|
20439
|
-
this.enabledAgents,
|
|
20440
|
-
this.timeoutMs,
|
|
20441
|
-
this.pollIntervalMs,
|
|
20442
|
-
this.operations
|
|
20443
|
-
);
|
|
20444
|
-
this.disposeModules();
|
|
20445
|
-
this.renderer.close();
|
|
20446
|
-
this.renderer = replacement.renderer;
|
|
20447
|
-
this.disposeModules = replacement.disposeModules;
|
|
20448
|
-
this.currentSnapshot = replacement.snapshot;
|
|
20449
|
-
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;
|
|
20450
22590
|
}
|
|
22591
|
+
this.renderer = replacement.renderer;
|
|
22592
|
+
this.disposeModules = replacement.disposeModules;
|
|
22593
|
+
this.currentSnapshot = replacement.snapshot;
|
|
22594
|
+
return this.currentSnapshot;
|
|
20451
22595
|
}
|
|
20452
22596
|
async activateDesktop() {
|
|
20453
22597
|
if (this.#closed) throw new Error("Renderer CDP Control Session is closed");
|
|
@@ -20461,8 +22605,14 @@ var InstalledRendererCdpControlSession = class {
|
|
|
20461
22605
|
close() {
|
|
20462
22606
|
if (this.#closed) return;
|
|
20463
22607
|
this.#closed = true;
|
|
20464
|
-
this.
|
|
20465
|
-
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();
|
|
20466
22616
|
}
|
|
20467
22617
|
};
|
|
20468
22618
|
var defaultOperations = {
|
|
@@ -20494,7 +22644,8 @@ async function createRendererCdpControlSession(options) {
|
|
|
20494
22644
|
enabledAgents,
|
|
20495
22645
|
timeoutMs,
|
|
20496
22646
|
pollIntervalMs,
|
|
20497
|
-
operations
|
|
22647
|
+
operations,
|
|
22648
|
+
options.desktopExtensions
|
|
20498
22649
|
);
|
|
20499
22650
|
return new InstalledRendererCdpControlSession(
|
|
20500
22651
|
installed.renderer,
|
|
@@ -20505,13 +22656,679 @@ async function createRendererCdpControlSession(options) {
|
|
|
20505
22656
|
pollIntervalMs,
|
|
20506
22657
|
operations,
|
|
20507
22658
|
installed.snapshot,
|
|
20508
|
-
installed.disposeModules
|
|
22659
|
+
installed.disposeModules,
|
|
22660
|
+
options.desktopExtensions
|
|
20509
22661
|
);
|
|
20510
22662
|
}
|
|
20511
22663
|
function installRendererCdpControlSession(options) {
|
|
20512
22664
|
return createRendererCdpControlSession(options);
|
|
20513
22665
|
}
|
|
20514
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
|
+
|
|
20515
23332
|
// packages/desktop-control/src/production-controller.ts
|
|
20516
23333
|
var PRODUCTION_INSTALL_TIMEOUT_MS = 9e4;
|
|
20517
23334
|
var RENDERER_CSP_BOOTSTRAP = "globalThis.__zod_globalConfig ??= {}; globalThis.__zod_globalConfig.jitless = true;";
|
|
@@ -20554,7 +23371,7 @@ function serializeDesktopControllerReadiness(readiness) {
|
|
|
20554
23371
|
return line;
|
|
20555
23372
|
}
|
|
20556
23373
|
var defaultDependencies = {
|
|
20557
|
-
readRenderer: (filePath) =>
|
|
23374
|
+
readRenderer: (filePath) => readFile2(filePath, "utf8"),
|
|
20558
23375
|
install: installRendererCdpControlSession,
|
|
20559
23376
|
startAttachmentServer: startControllerAttachmentServer,
|
|
20560
23377
|
ready: (readiness) => {
|
|
@@ -20592,8 +23409,8 @@ function parseDesktopControllerArguments(arguments_) {
|
|
|
20592
23409
|
if (argument === "--renderer") {
|
|
20593
23410
|
if (rendererPath !== void 0) throw new Error("--renderer may only be provided once");
|
|
20594
23411
|
if (!value) throw new Error("--renderer requires a value");
|
|
20595
|
-
if (!
|
|
20596
|
-
rendererPath =
|
|
23412
|
+
if (!path6.isAbsolute(value)) throw new Error("--renderer must be an absolute path");
|
|
23413
|
+
rendererPath = path6.normalize(value);
|
|
20597
23414
|
index += 1;
|
|
20598
23415
|
continue;
|
|
20599
23416
|
}
|
|
@@ -20661,6 +23478,13 @@ async function installProductionSession(options, dependencies) {
|
|
|
20661
23478
|
}
|
|
20662
23479
|
async function runDesktopController(options, signal, dependencies = defaultDependencies) {
|
|
20663
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;
|
|
20664
23488
|
let session;
|
|
20665
23489
|
let nextRecoveryAt = 0;
|
|
20666
23490
|
let recoveryDelayMs = RECOVERY_RETRY_INITIAL_MS;
|
|
@@ -20691,7 +23515,8 @@ async function runDesktopController(options, signal, dependencies = defaultDepen
|
|
|
20691
23515
|
${rendererSource}`,
|
|
20692
23516
|
// External Agents are discovered from each target Host after installation.
|
|
20693
23517
|
timeoutMs: PRODUCTION_INSTALL_TIMEOUT_MS,
|
|
20694
|
-
signal
|
|
23518
|
+
signal,
|
|
23519
|
+
...desktopExtensions ? { desktopExtensions } : {}
|
|
20695
23520
|
},
|
|
20696
23521
|
dependencies
|
|
20697
23522
|
);
|
|
@@ -20799,6 +23624,7 @@ ${rendererSource}`,
|
|
|
20799
23624
|
});
|
|
20800
23625
|
}
|
|
20801
23626
|
} finally {
|
|
23627
|
+
desktopExtensions?.close();
|
|
20802
23628
|
await attachmentServer?.close();
|
|
20803
23629
|
await settleWithin(operation, SHUTDOWN_OPERATION_WAIT_MS);
|
|
20804
23630
|
resetSession();
|