@codexhost/cli-linux-arm64 0.22.0 → 0.24.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 +3117 -274
- package/app/console-web.js +15645 -4413
- package/app/desktop-controller.mjs +14057 -969
- package/app/host-runtime.mjs +11518 -8277
- package/app/plugins/antigravity/plugin.mjs +2030 -678
- package/app/plugins/claude-code/plugin.mjs +2116 -929
- package/app/plugins/codebuddy/plugin.mjs +1247 -353
- package/app/plugins/codex-usage/plugin.mjs +786 -163
- package/app/plugins/copilot/plugin.mjs +938 -296
- package/app/plugins/cursor-cli/plugin.mjs +1021 -232
- package/app/plugins/deepseek-harness/plugin.mjs +1552 -664
- package/app/plugins/devin/plugin.mjs +826 -185
- package/app/plugins/grok/plugin.mjs +1083 -424
- package/app/plugins/hermes/plugin.mjs +961 -338
- package/app/plugins/kimi-code/plugin.mjs +854 -237
- package/app/plugins/kiro-cli/plugin.mjs +821 -184
- package/app/plugins/omp/plugin.mjs +1316 -633
- package/app/plugins/opencode/plugin.mjs +1293 -606
- package/app/plugins/pi/plugin.mjs +1540 -867
- package/app/plugins/qoder/plugin.mjs +961 -332
- package/app/plugins/qoder-cn/plugin.mjs +961 -332
- package/app/plugins/qwen-code/plugin.mjs +937 -321
- package/app/plugins/workbuddy/plugin.mjs +1311 -370
- package/app/plugins/zcode/plugin.mjs +1516 -423
- package/app/renderer-extension.js +21297 -9060
- package/app/web/assets/index-CTCFIQbU.css +1 -0
- package/app/web/assets/index-IvFk9KT-.js +203 -0
- package/app/web/codexhost-settings.js +6753 -31616
- package/app/web/index.html +2 -2
- 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-approval/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +14 -14
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +75 -64
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +94 -91
- package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/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-sidebar-documentpreview/client.js +9 -9
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-right/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-theme/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +79 -79
- package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +3 -3
- package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +7 -7
- package/app/web/sw.js +8 -1
- 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 +40416 -11283
- 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
- package/app/web/assets/index-DJW4bmyx.css +0 -1
package/app/console-server.mjs
CHANGED
|
@@ -1,11 +1,1623 @@
|
|
|
1
|
+
import { createRequire as __codexhostCreateRequire } from "node:module"; const require = __codexhostCreateRequire(import.meta.url);
|
|
2
|
+
var __create = Object.create;
|
|
1
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
9
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
10
|
+
}) : x)(function(x) {
|
|
11
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
+
});
|
|
14
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
15
|
+
try {
|
|
16
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
17
|
+
} catch (e) {
|
|
18
|
+
throw mod = 0, e;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
2
21
|
var __export = (target2, all) => {
|
|
3
22
|
for (var name in all)
|
|
4
23
|
__defProp(target2, name, { get: all[name], enumerable: true });
|
|
5
24
|
};
|
|
25
|
+
var __copyProps = (to, from, except, desc) => {
|
|
26
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
27
|
+
for (let key of __getOwnPropNames(from))
|
|
28
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
29
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
30
|
+
}
|
|
31
|
+
return to;
|
|
32
|
+
};
|
|
33
|
+
var __toESM = (mod, isNodeMode, target2) => (target2 = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
34
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
35
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
36
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
37
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
38
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target2, "default", { value: mod, enumerable: true }) : target2,
|
|
39
|
+
mod
|
|
40
|
+
));
|
|
41
|
+
|
|
42
|
+
// node_modules/graceful-fs/polyfills.js
|
|
43
|
+
var require_polyfills = __commonJS({
|
|
44
|
+
"node_modules/graceful-fs/polyfills.js"(exports, module) {
|
|
45
|
+
var constants2 = __require("constants");
|
|
46
|
+
var origCwd = process.cwd;
|
|
47
|
+
var cwd = null;
|
|
48
|
+
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
|
|
49
|
+
process.cwd = function() {
|
|
50
|
+
if (!cwd)
|
|
51
|
+
cwd = origCwd.call(process);
|
|
52
|
+
return cwd;
|
|
53
|
+
};
|
|
54
|
+
try {
|
|
55
|
+
process.cwd();
|
|
56
|
+
} catch (er) {
|
|
57
|
+
}
|
|
58
|
+
if (typeof process.chdir === "function") {
|
|
59
|
+
chdir = process.chdir;
|
|
60
|
+
process.chdir = function(d) {
|
|
61
|
+
cwd = null;
|
|
62
|
+
chdir.call(process, d);
|
|
63
|
+
};
|
|
64
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
|
|
65
|
+
}
|
|
66
|
+
var chdir;
|
|
67
|
+
module.exports = patch;
|
|
68
|
+
function patch(fs) {
|
|
69
|
+
if (constants2.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
70
|
+
patchLchmod(fs);
|
|
71
|
+
}
|
|
72
|
+
if (!fs.lutimes) {
|
|
73
|
+
patchLutimes(fs);
|
|
74
|
+
}
|
|
75
|
+
fs.chown = chownFix(fs.chown);
|
|
76
|
+
fs.fchown = chownFix(fs.fchown);
|
|
77
|
+
fs.lchown = chownFix(fs.lchown);
|
|
78
|
+
fs.chmod = chmodFix(fs.chmod);
|
|
79
|
+
fs.fchmod = chmodFix(fs.fchmod);
|
|
80
|
+
fs.lchmod = chmodFix(fs.lchmod);
|
|
81
|
+
fs.chownSync = chownFixSync(fs.chownSync);
|
|
82
|
+
fs.fchownSync = chownFixSync(fs.fchownSync);
|
|
83
|
+
fs.lchownSync = chownFixSync(fs.lchownSync);
|
|
84
|
+
fs.chmodSync = chmodFixSync(fs.chmodSync);
|
|
85
|
+
fs.fchmodSync = chmodFixSync(fs.fchmodSync);
|
|
86
|
+
fs.lchmodSync = chmodFixSync(fs.lchmodSync);
|
|
87
|
+
fs.stat = statFix(fs.stat);
|
|
88
|
+
fs.fstat = statFix(fs.fstat);
|
|
89
|
+
fs.lstat = statFix(fs.lstat);
|
|
90
|
+
fs.statSync = statFixSync(fs.statSync);
|
|
91
|
+
fs.fstatSync = statFixSync(fs.fstatSync);
|
|
92
|
+
fs.lstatSync = statFixSync(fs.lstatSync);
|
|
93
|
+
if (fs.chmod && !fs.lchmod) {
|
|
94
|
+
fs.lchmod = function(path22, 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(path22, uid, gid, cb) {
|
|
102
|
+
if (cb) process.nextTick(cb);
|
|
103
|
+
};
|
|
104
|
+
fs.lchownSync = function() {
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
if (platform === "win32") {
|
|
108
|
+
fs.rename = typeof fs.rename !== "function" ? fs.rename : (function(fs$rename) {
|
|
109
|
+
function rename6(from, to, cb) {
|
|
110
|
+
var start = Date.now();
|
|
111
|
+
var backoff = 0;
|
|
112
|
+
fs$rename(from, to, function CB(er) {
|
|
113
|
+
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
|
|
114
|
+
setTimeout(function() {
|
|
115
|
+
fs.stat(to, function(stater, st) {
|
|
116
|
+
if (stater && stater.code === "ENOENT")
|
|
117
|
+
fs$rename(from, to, CB);
|
|
118
|
+
else
|
|
119
|
+
cb(er);
|
|
120
|
+
});
|
|
121
|
+
}, backoff);
|
|
122
|
+
if (backoff < 100)
|
|
123
|
+
backoff += 10;
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (cb) cb(er);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(rename6, fs$rename);
|
|
130
|
+
return rename6;
|
|
131
|
+
})(fs.rename);
|
|
132
|
+
}
|
|
133
|
+
fs.read = typeof fs.read !== "function" ? fs.read : (function(fs$read) {
|
|
134
|
+
function read(fd, buffer, offset, length, position, callback_) {
|
|
135
|
+
var callback;
|
|
136
|
+
if (callback_ && typeof callback_ === "function") {
|
|
137
|
+
var eagCounter = 0;
|
|
138
|
+
callback = function(er, _, __) {
|
|
139
|
+
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
|
140
|
+
eagCounter++;
|
|
141
|
+
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
|
|
142
|
+
}
|
|
143
|
+
callback_.apply(this, arguments);
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
|
|
147
|
+
}
|
|
148
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
|
|
149
|
+
return read;
|
|
150
|
+
})(fs.read);
|
|
151
|
+
fs.readSync = typeof fs.readSync !== "function" ? fs.readSync : /* @__PURE__ */ (function(fs$readSync) {
|
|
152
|
+
return function(fd, buffer, offset, length, position) {
|
|
153
|
+
var eagCounter = 0;
|
|
154
|
+
while (true) {
|
|
155
|
+
try {
|
|
156
|
+
return fs$readSync.call(fs, fd, buffer, offset, length, position);
|
|
157
|
+
} catch (er) {
|
|
158
|
+
if (er.code === "EAGAIN" && eagCounter < 10) {
|
|
159
|
+
eagCounter++;
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
throw er;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
})(fs.readSync);
|
|
167
|
+
function patchLchmod(fs2) {
|
|
168
|
+
fs2.lchmod = function(path22, mode, callback) {
|
|
169
|
+
fs2.open(
|
|
170
|
+
path22,
|
|
171
|
+
constants2.O_WRONLY | constants2.O_SYMLINK,
|
|
172
|
+
mode,
|
|
173
|
+
function(err, fd) {
|
|
174
|
+
if (err) {
|
|
175
|
+
if (callback) callback(err);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
fs2.fchmod(fd, mode, function(err2) {
|
|
179
|
+
fs2.close(fd, function(err22) {
|
|
180
|
+
if (callback) callback(err2 || err22);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
};
|
|
186
|
+
fs2.lchmodSync = function(path22, mode) {
|
|
187
|
+
var fd = fs2.openSync(path22, constants2.O_WRONLY | constants2.O_SYMLINK, mode);
|
|
188
|
+
var threw = true;
|
|
189
|
+
var ret;
|
|
190
|
+
try {
|
|
191
|
+
ret = fs2.fchmodSync(fd, mode);
|
|
192
|
+
threw = false;
|
|
193
|
+
} finally {
|
|
194
|
+
if (threw) {
|
|
195
|
+
try {
|
|
196
|
+
fs2.closeSync(fd);
|
|
197
|
+
} catch (er) {
|
|
198
|
+
}
|
|
199
|
+
} else {
|
|
200
|
+
fs2.closeSync(fd);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return ret;
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function patchLutimes(fs2) {
|
|
207
|
+
if (constants2.hasOwnProperty("O_SYMLINK") && fs2.futimes) {
|
|
208
|
+
fs2.lutimes = function(path22, at, mt, cb) {
|
|
209
|
+
fs2.open(path22, constants2.O_SYMLINK, function(er, fd) {
|
|
210
|
+
if (er) {
|
|
211
|
+
if (cb) cb(er);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
fs2.futimes(fd, at, mt, function(er2) {
|
|
215
|
+
fs2.close(fd, function(er22) {
|
|
216
|
+
if (cb) cb(er2 || er22);
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
};
|
|
221
|
+
fs2.lutimesSync = function(path22, at, mt) {
|
|
222
|
+
var fd = fs2.openSync(path22, constants2.O_SYMLINK);
|
|
223
|
+
var ret;
|
|
224
|
+
var threw = true;
|
|
225
|
+
try {
|
|
226
|
+
ret = fs2.futimesSync(fd, at, mt);
|
|
227
|
+
threw = false;
|
|
228
|
+
} finally {
|
|
229
|
+
if (threw) {
|
|
230
|
+
try {
|
|
231
|
+
fs2.closeSync(fd);
|
|
232
|
+
} catch (er) {
|
|
233
|
+
}
|
|
234
|
+
} else {
|
|
235
|
+
fs2.closeSync(fd);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return ret;
|
|
239
|
+
};
|
|
240
|
+
} else if (fs2.futimes) {
|
|
241
|
+
fs2.lutimes = function(_a3, _b, _c, cb) {
|
|
242
|
+
if (cb) process.nextTick(cb);
|
|
243
|
+
};
|
|
244
|
+
fs2.lutimesSync = function() {
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
function chmodFix(orig) {
|
|
249
|
+
if (!orig) return orig;
|
|
250
|
+
return function(target2, mode, cb) {
|
|
251
|
+
return orig.call(fs, target2, mode, function(er) {
|
|
252
|
+
if (chownErOk(er)) er = null;
|
|
253
|
+
if (cb) cb.apply(this, arguments);
|
|
254
|
+
});
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
function chmodFixSync(orig) {
|
|
258
|
+
if (!orig) return orig;
|
|
259
|
+
return function(target2, mode) {
|
|
260
|
+
try {
|
|
261
|
+
return orig.call(fs, target2, mode);
|
|
262
|
+
} catch (er) {
|
|
263
|
+
if (!chownErOk(er)) throw er;
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
function chownFix(orig) {
|
|
268
|
+
if (!orig) return orig;
|
|
269
|
+
return function(target2, uid, gid, cb) {
|
|
270
|
+
return orig.call(fs, target2, uid, gid, function(er) {
|
|
271
|
+
if (chownErOk(er)) er = null;
|
|
272
|
+
if (cb) cb.apply(this, arguments);
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
function chownFixSync(orig) {
|
|
277
|
+
if (!orig) return orig;
|
|
278
|
+
return function(target2, uid, gid) {
|
|
279
|
+
try {
|
|
280
|
+
return orig.call(fs, target2, uid, gid);
|
|
281
|
+
} catch (er) {
|
|
282
|
+
if (!chownErOk(er)) throw er;
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function statFix(orig) {
|
|
287
|
+
if (!orig) return orig;
|
|
288
|
+
return function(target2, options, cb) {
|
|
289
|
+
if (typeof options === "function") {
|
|
290
|
+
cb = options;
|
|
291
|
+
options = null;
|
|
292
|
+
}
|
|
293
|
+
function callback(er, stats) {
|
|
294
|
+
if (stats) {
|
|
295
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
296
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
297
|
+
}
|
|
298
|
+
if (cb) cb.apply(this, arguments);
|
|
299
|
+
}
|
|
300
|
+
return options ? orig.call(fs, target2, options, callback) : orig.call(fs, target2, callback);
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
function statFixSync(orig) {
|
|
304
|
+
if (!orig) return orig;
|
|
305
|
+
return function(target2, options) {
|
|
306
|
+
var stats = options ? orig.call(fs, target2, options) : orig.call(fs, target2);
|
|
307
|
+
if (stats) {
|
|
308
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
309
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
310
|
+
}
|
|
311
|
+
return stats;
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function chownErOk(er) {
|
|
315
|
+
if (!er)
|
|
316
|
+
return true;
|
|
317
|
+
if (er.code === "ENOSYS")
|
|
318
|
+
return true;
|
|
319
|
+
var nonroot = !process.getuid || process.getuid() !== 0;
|
|
320
|
+
if (nonroot) {
|
|
321
|
+
if (er.code === "EINVAL" || er.code === "EPERM")
|
|
322
|
+
return true;
|
|
323
|
+
}
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
// node_modules/graceful-fs/legacy-streams.js
|
|
331
|
+
var require_legacy_streams = __commonJS({
|
|
332
|
+
"node_modules/graceful-fs/legacy-streams.js"(exports, module) {
|
|
333
|
+
var Stream = __require("stream").Stream;
|
|
334
|
+
module.exports = legacy2;
|
|
335
|
+
function legacy2(fs) {
|
|
336
|
+
return {
|
|
337
|
+
ReadStream,
|
|
338
|
+
WriteStream
|
|
339
|
+
};
|
|
340
|
+
function ReadStream(path22, options) {
|
|
341
|
+
if (!(this instanceof ReadStream)) return new ReadStream(path22, options);
|
|
342
|
+
Stream.call(this);
|
|
343
|
+
var self = this;
|
|
344
|
+
this.path = path22;
|
|
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(path22, options) {
|
|
390
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path22, options);
|
|
391
|
+
Stream.call(this);
|
|
392
|
+
this.path = path22;
|
|
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 legacy2 = require_legacy_streams();
|
|
455
|
+
var clone2 = require_clone();
|
|
456
|
+
var util = __require("util");
|
|
457
|
+
var gracefulQueue;
|
|
458
|
+
var previousSymbol;
|
|
459
|
+
if (typeof Symbol === "function" && typeof Symbol.for === "function") {
|
|
460
|
+
gracefulQueue = /* @__PURE__ */ Symbol.for("graceful-fs.queue");
|
|
461
|
+
previousSymbol = /* @__PURE__ */ Symbol.for("graceful-fs.previous");
|
|
462
|
+
} else {
|
|
463
|
+
gracefulQueue = "___graceful-fs.queue";
|
|
464
|
+
previousSymbol = "___graceful-fs.previous";
|
|
465
|
+
}
|
|
466
|
+
function noop() {
|
|
467
|
+
}
|
|
468
|
+
function publishQueue(context, queue2) {
|
|
469
|
+
Object.defineProperty(context, gracefulQueue, {
|
|
470
|
+
get: function() {
|
|
471
|
+
return queue2;
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
var debug = noop;
|
|
476
|
+
if (util.debuglog)
|
|
477
|
+
debug = util.debuglog("gfs4");
|
|
478
|
+
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
|
|
479
|
+
debug = function() {
|
|
480
|
+
var m = util.format.apply(util, arguments);
|
|
481
|
+
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
|
|
482
|
+
console.error(m);
|
|
483
|
+
};
|
|
484
|
+
if (!fs[gracefulQueue]) {
|
|
485
|
+
queue = global[gracefulQueue] || [];
|
|
486
|
+
publishQueue(fs, queue);
|
|
487
|
+
fs.close = (function(fs$close) {
|
|
488
|
+
function close(fd, cb) {
|
|
489
|
+
return fs$close.call(fs, fd, function(err) {
|
|
490
|
+
if (!err) {
|
|
491
|
+
resetQueue();
|
|
492
|
+
}
|
|
493
|
+
if (typeof cb === "function")
|
|
494
|
+
cb.apply(this, arguments);
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
Object.defineProperty(close, previousSymbol, {
|
|
498
|
+
value: fs$close
|
|
499
|
+
});
|
|
500
|
+
return close;
|
|
501
|
+
})(fs.close);
|
|
502
|
+
fs.closeSync = (function(fs$closeSync) {
|
|
503
|
+
function closeSync(fd) {
|
|
504
|
+
fs$closeSync.apply(fs, arguments);
|
|
505
|
+
resetQueue();
|
|
506
|
+
}
|
|
507
|
+
Object.defineProperty(closeSync, previousSymbol, {
|
|
508
|
+
value: fs$closeSync
|
|
509
|
+
});
|
|
510
|
+
return closeSync;
|
|
511
|
+
})(fs.closeSync);
|
|
512
|
+
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
|
|
513
|
+
process.on("exit", function() {
|
|
514
|
+
debug(fs[gracefulQueue]);
|
|
515
|
+
__require("assert").equal(fs[gracefulQueue].length, 0);
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
var queue;
|
|
520
|
+
if (!global[gracefulQueue]) {
|
|
521
|
+
publishQueue(global, fs[gracefulQueue]);
|
|
522
|
+
}
|
|
523
|
+
module.exports = patch(clone2(fs));
|
|
524
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
|
|
525
|
+
module.exports = patch(fs);
|
|
526
|
+
fs.__patched = true;
|
|
527
|
+
}
|
|
528
|
+
function patch(fs2) {
|
|
529
|
+
polyfills(fs2);
|
|
530
|
+
fs2.gracefulify = patch;
|
|
531
|
+
fs2.createReadStream = createReadStream2;
|
|
532
|
+
fs2.createWriteStream = createWriteStream;
|
|
533
|
+
var fs$readFile = fs2.readFile;
|
|
534
|
+
fs2.readFile = readFile10;
|
|
535
|
+
function readFile10(path22, options, cb) {
|
|
536
|
+
if (typeof options === "function")
|
|
537
|
+
cb = options, options = null;
|
|
538
|
+
return go$readFile(path22, options, cb);
|
|
539
|
+
function go$readFile(path23, options2, cb2, startTime) {
|
|
540
|
+
return fs$readFile(path23, options2, function(err) {
|
|
541
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
542
|
+
enqueue([go$readFile, [path23, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
543
|
+
else {
|
|
544
|
+
if (typeof cb2 === "function")
|
|
545
|
+
cb2.apply(this, arguments);
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
var fs$writeFile = fs2.writeFile;
|
|
551
|
+
fs2.writeFile = writeFile6;
|
|
552
|
+
function writeFile6(path22, data, options, cb) {
|
|
553
|
+
if (typeof options === "function")
|
|
554
|
+
cb = options, options = null;
|
|
555
|
+
return go$writeFile(path22, data, options, cb);
|
|
556
|
+
function go$writeFile(path23, data2, options2, cb2, startTime) {
|
|
557
|
+
return fs$writeFile(path23, data2, options2, function(err) {
|
|
558
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
559
|
+
enqueue([go$writeFile, [path23, 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(path22, data, options, cb) {
|
|
571
|
+
if (typeof options === "function")
|
|
572
|
+
cb = options, options = null;
|
|
573
|
+
return go$appendFile(path22, data, options, cb);
|
|
574
|
+
function go$appendFile(path23, data2, options2, cb2, startTime) {
|
|
575
|
+
return fs$appendFile(path23, data2, options2, function(err) {
|
|
576
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
577
|
+
enqueue([go$appendFile, [path23, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
578
|
+
else {
|
|
579
|
+
if (typeof cb2 === "function")
|
|
580
|
+
cb2.apply(this, arguments);
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
var fs$copyFile = fs2.copyFile;
|
|
586
|
+
if (fs$copyFile)
|
|
587
|
+
fs2.copyFile = copyFile2;
|
|
588
|
+
function copyFile2(src, dest, flags, cb) {
|
|
589
|
+
if (typeof flags === "function") {
|
|
590
|
+
cb = flags;
|
|
591
|
+
flags = 0;
|
|
592
|
+
}
|
|
593
|
+
return go$copyFile(src, dest, flags, cb);
|
|
594
|
+
function go$copyFile(src2, dest2, flags2, cb2, startTime) {
|
|
595
|
+
return fs$copyFile(src2, dest2, flags2, function(err) {
|
|
596
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
597
|
+
enqueue([go$copyFile, [src2, dest2, flags2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
598
|
+
else {
|
|
599
|
+
if (typeof cb2 === "function")
|
|
600
|
+
cb2.apply(this, arguments);
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
var fs$readdir = fs2.readdir;
|
|
606
|
+
fs2.readdir = readdir6;
|
|
607
|
+
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
608
|
+
function readdir6(path22, options, cb) {
|
|
609
|
+
if (typeof options === "function")
|
|
610
|
+
cb = options, options = null;
|
|
611
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path23, options2, cb2, startTime) {
|
|
612
|
+
return fs$readdir(path23, fs$readdirCallback(
|
|
613
|
+
path23,
|
|
614
|
+
options2,
|
|
615
|
+
cb2,
|
|
616
|
+
startTime
|
|
617
|
+
));
|
|
618
|
+
} : function go$readdir2(path23, options2, cb2, startTime) {
|
|
619
|
+
return fs$readdir(path23, options2, fs$readdirCallback(
|
|
620
|
+
path23,
|
|
621
|
+
options2,
|
|
622
|
+
cb2,
|
|
623
|
+
startTime
|
|
624
|
+
));
|
|
625
|
+
};
|
|
626
|
+
return go$readdir(path22, options, cb);
|
|
627
|
+
function fs$readdirCallback(path23, options2, cb2, startTime) {
|
|
628
|
+
return function(err, files) {
|
|
629
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
630
|
+
enqueue([
|
|
631
|
+
go$readdir,
|
|
632
|
+
[path23, 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 = legacy2(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(path22, options) {
|
|
704
|
+
if (this instanceof ReadStream)
|
|
705
|
+
return fs$ReadStream.apply(this, arguments), this;
|
|
706
|
+
else
|
|
707
|
+
return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
|
|
708
|
+
}
|
|
709
|
+
function ReadStream$open() {
|
|
710
|
+
var that = this;
|
|
711
|
+
open7(that.path, that.flags, that.mode, function(err, fd) {
|
|
712
|
+
if (err) {
|
|
713
|
+
if (that.autoClose)
|
|
714
|
+
that.destroy();
|
|
715
|
+
that.emit("error", err);
|
|
716
|
+
} else {
|
|
717
|
+
that.fd = fd;
|
|
718
|
+
that.emit("open", fd);
|
|
719
|
+
that.read();
|
|
720
|
+
}
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
function WriteStream(path22, options) {
|
|
724
|
+
if (this instanceof WriteStream)
|
|
725
|
+
return fs$WriteStream.apply(this, arguments), this;
|
|
726
|
+
else
|
|
727
|
+
return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
|
|
728
|
+
}
|
|
729
|
+
function WriteStream$open() {
|
|
730
|
+
var that = this;
|
|
731
|
+
open7(that.path, that.flags, that.mode, function(err, fd) {
|
|
732
|
+
if (err) {
|
|
733
|
+
that.destroy();
|
|
734
|
+
that.emit("error", err);
|
|
735
|
+
} else {
|
|
736
|
+
that.fd = fd;
|
|
737
|
+
that.emit("open", fd);
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
function createReadStream2(path22, options) {
|
|
742
|
+
return new fs2.ReadStream(path22, options);
|
|
743
|
+
}
|
|
744
|
+
function createWriteStream(path22, options) {
|
|
745
|
+
return new fs2.WriteStream(path22, options);
|
|
746
|
+
}
|
|
747
|
+
var fs$open = fs2.open;
|
|
748
|
+
fs2.open = open7;
|
|
749
|
+
function open7(path22, flags, mode, cb) {
|
|
750
|
+
if (typeof mode === "function")
|
|
751
|
+
cb = mode, mode = null;
|
|
752
|
+
return go$open(path22, flags, mode, cb);
|
|
753
|
+
function go$open(path23, flags2, mode2, cb2, startTime) {
|
|
754
|
+
return fs$open(path23, flags2, mode2, function(err, fd) {
|
|
755
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
756
|
+
enqueue([go$open, [path23, 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, methods3) {
|
|
998
|
+
if (options instanceof Array) {
|
|
999
|
+
methods3 = options;
|
|
1000
|
+
options = null;
|
|
1001
|
+
}
|
|
1002
|
+
if (!methods3) {
|
|
1003
|
+
methods3 = [];
|
|
1004
|
+
for (var key in obj) {
|
|
1005
|
+
if (typeof obj[key] === "function") {
|
|
1006
|
+
methods3.push(key);
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
for (var i = 0; i < methods3.length; i++) {
|
|
1011
|
+
var method = methods3[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, stat5) => {
|
|
1248
|
+
if (err) {
|
|
1249
|
+
return callback(err);
|
|
1250
|
+
}
|
|
1251
|
+
callback(null, stat5.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, stat5) => {
|
|
1260
|
+
if (err2) {
|
|
1261
|
+
return callback(err2);
|
|
1262
|
+
}
|
|
1263
|
+
const precision = stat5.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
|
|
1264
|
+
Object.defineProperty(fs, cacheSymbol, { value: precision });
|
|
1265
|
+
callback(null, stat5.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 path22 = __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, path22.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, stat5) => {
|
|
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(stat5, 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(stat5, options) {
|
|
1339
|
+
return stat5.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, stat5) => {
|
|
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() === stat5.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, stat5) => {
|
|
1492
|
+
if (err2) {
|
|
1493
|
+
return err2.code === "ENOENT" ? callback(null, false) : callback(err2);
|
|
1494
|
+
}
|
|
1495
|
+
return callback(null, !isLockStale(stat5, 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 methods3 = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
|
|
1525
|
+
const newFs = { ...fs2 };
|
|
1526
|
+
methods3.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/console-server/src/main.ts
|
|
8
|
-
import
|
|
1620
|
+
import path21 from "node:path";
|
|
9
1621
|
import { fileURLToPath } from "node:url";
|
|
10
1622
|
|
|
11
1623
|
// packages/update-manager/dist/runtime-metadata.js
|
|
@@ -255,8 +1867,8 @@ function selectInstallerReleaseArtifact(release, target2) {
|
|
|
255
1867
|
if (!asset)
|
|
256
1868
|
throw new Error(`GitHub Release must contain exactly one ${name}`);
|
|
257
1869
|
const digest = asset.digest === null ? null : SHA256_DIGEST_PATTERN.exec(asset.digest);
|
|
258
|
-
const
|
|
259
|
-
if (!
|
|
1870
|
+
const sha2562 = digest?.[1];
|
|
1871
|
+
if (!sha2562)
|
|
260
1872
|
throw new Error(`GitHub Release asset ${name} has no valid SHA-256 digest`);
|
|
261
1873
|
const expectedPrefix = `${DOWNLOAD_URL_PREFIX}v${release.version}/`;
|
|
262
1874
|
if (!asset.downloadUrl.startsWith(expectedPrefix) || !asset.downloadUrl.endsWith(`/${name}`)) {
|
|
@@ -264,7 +1876,7 @@ function selectInstallerReleaseArtifact(release, target2) {
|
|
|
264
1876
|
}
|
|
265
1877
|
return Object.freeze({
|
|
266
1878
|
name,
|
|
267
|
-
source: Object.freeze({ url: asset.downloadUrl, sha256, size: asset.size })
|
|
1879
|
+
source: Object.freeze({ url: asset.downloadUrl, sha256: sha2562, size: asset.size })
|
|
268
1880
|
});
|
|
269
1881
|
}
|
|
270
1882
|
|
|
@@ -351,9 +1963,9 @@ import path4 from "node:path";
|
|
|
351
1963
|
var LOCK_FILE = "active-update-v1.lock";
|
|
352
1964
|
var STATUS_FILE = "status-v1.json";
|
|
353
1965
|
var TERMINAL_PHASES = /* @__PURE__ */ new Set(["succeeded", "failed"]);
|
|
354
|
-
async function regularFile(
|
|
1966
|
+
async function regularFile(filePath2) {
|
|
355
1967
|
try {
|
|
356
|
-
const metadata = await lstat(
|
|
1968
|
+
const metadata = await lstat(filePath2);
|
|
357
1969
|
return metadata.isFile() && !metadata.isSymbolicLink();
|
|
358
1970
|
} catch (error51) {
|
|
359
1971
|
if (error51.code === "ENOENT")
|
|
@@ -605,18 +2217,18 @@ async function downloadArtifact(source, destination, onProgress) {
|
|
|
605
2217
|
}
|
|
606
2218
|
return { bytes, finalUrl: finalUrl.toString() };
|
|
607
2219
|
}
|
|
608
|
-
async function sha256File(
|
|
2220
|
+
async function sha256File(filePath2) {
|
|
609
2221
|
const hash2 = createHash("sha256");
|
|
610
2222
|
await new Promise((resolve, reject) => {
|
|
611
|
-
const stream = createReadStream(
|
|
2223
|
+
const stream = createReadStream(filePath2);
|
|
612
2224
|
stream.on("data", (chunk) => hash2.update(chunk));
|
|
613
2225
|
stream.once("error", reject);
|
|
614
2226
|
stream.once("end", resolve);
|
|
615
2227
|
});
|
|
616
2228
|
return hash2.digest("hex");
|
|
617
2229
|
}
|
|
618
|
-
async function verifyDownloadedArtifact(source,
|
|
619
|
-
const metadata = await lstat2(
|
|
2230
|
+
async function verifyDownloadedArtifact(source, filePath2, result) {
|
|
2231
|
+
const metadata = await lstat2(filePath2);
|
|
620
2232
|
if (!metadata.isFile() || metadata.isSymbolicLink() || metadata.size === 0) {
|
|
621
2233
|
throw new Error("downloaded update artifact is not a non-empty regular file");
|
|
622
2234
|
}
|
|
@@ -626,7 +2238,7 @@ async function verifyDownloadedArtifact(source, filePath, result) {
|
|
|
626
2238
|
if (source.size !== void 0 && metadata.size !== source.size) {
|
|
627
2239
|
throw new Error(`update artifact size mismatch: expected ${source.size}, got ${metadata.size}`);
|
|
628
2240
|
}
|
|
629
|
-
const actual = await sha256File(
|
|
2241
|
+
const actual = await sha256File(filePath2);
|
|
630
2242
|
if (actual !== source.sha256) {
|
|
631
2243
|
throw new Error(`update artifact SHA-256 mismatch: expected ${source.sha256}, got ${actual}`);
|
|
632
2244
|
}
|
|
@@ -710,14 +2322,14 @@ function requireAbsolutePath(value, label) {
|
|
|
710
2322
|
return path5.normalize(value);
|
|
711
2323
|
}
|
|
712
2324
|
async function requireRegularFile(value, label) {
|
|
713
|
-
const
|
|
714
|
-
const metadata = await lstat3(
|
|
2325
|
+
const filePath2 = requireAbsolutePath(value, label);
|
|
2326
|
+
const metadata = await lstat3(filePath2).catch((error51) => {
|
|
715
2327
|
throw new Error(`${label} is unavailable: ${errorMessage(error51)}`);
|
|
716
2328
|
});
|
|
717
2329
|
if (!metadata.isFile() || metadata.isSymbolicLink()) {
|
|
718
2330
|
throw new Error(`${label} must be a regular file`);
|
|
719
2331
|
}
|
|
720
|
-
return
|
|
2332
|
+
return filePath2;
|
|
721
2333
|
}
|
|
722
2334
|
function requireLauncherPid(value) {
|
|
723
2335
|
if (!Number.isSafeInteger(value) || value <= 0) {
|
|
@@ -725,8 +2337,8 @@ function requireLauncherPid(value) {
|
|
|
725
2337
|
}
|
|
726
2338
|
return value;
|
|
727
2339
|
}
|
|
728
|
-
async function writePrivateJson(
|
|
729
|
-
await writeFile2(
|
|
2340
|
+
async function writePrivateJson(filePath2, value) {
|
|
2341
|
+
await writeFile2(filePath2, `${JSON.stringify(value)}
|
|
730
2342
|
`, {
|
|
731
2343
|
encoding: "utf8",
|
|
732
2344
|
mode: 384,
|
|
@@ -963,7 +2575,7 @@ function createBackgroundUpdateManager(dependencies = {}) {
|
|
|
963
2575
|
}
|
|
964
2576
|
|
|
965
2577
|
// packages/console-server/src/harnesses.ts
|
|
966
|
-
import
|
|
2578
|
+
import path12 from "node:path";
|
|
967
2579
|
|
|
968
2580
|
// packages/harness-plugin-files/dist/discovery.js
|
|
969
2581
|
import { readdir as readdir2, realpath as realpath2 } from "node:fs/promises";
|
|
@@ -1735,10 +3347,10 @@ function mergeDefs(...defs) {
|
|
|
1735
3347
|
function cloneDef(schema) {
|
|
1736
3348
|
return mergeDefs(schema._zod.def);
|
|
1737
3349
|
}
|
|
1738
|
-
function getElementAtPath(obj,
|
|
1739
|
-
if (!
|
|
3350
|
+
function getElementAtPath(obj, path22) {
|
|
3351
|
+
if (!path22)
|
|
1740
3352
|
return obj;
|
|
1741
|
-
return
|
|
3353
|
+
return path22.reduce((acc, key) => acc?.[key], obj);
|
|
1742
3354
|
}
|
|
1743
3355
|
function promiseAllObject(promisesObj) {
|
|
1744
3356
|
const keys = Object.keys(promisesObj);
|
|
@@ -2147,11 +3759,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
2147
3759
|
}
|
|
2148
3760
|
return false;
|
|
2149
3761
|
}
|
|
2150
|
-
function prefixIssues(
|
|
3762
|
+
function prefixIssues(path22, issues) {
|
|
2151
3763
|
return issues.map((iss) => {
|
|
2152
3764
|
var _a3;
|
|
2153
3765
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
2154
|
-
iss.path.unshift(
|
|
3766
|
+
iss.path.unshift(path22);
|
|
2155
3767
|
return iss;
|
|
2156
3768
|
});
|
|
2157
3769
|
}
|
|
@@ -2222,8 +3834,8 @@ function cleanEnum(obj) {
|
|
|
2222
3834
|
return Number.isNaN(Number.parseInt(k, 10));
|
|
2223
3835
|
}).map((el) => el[1]);
|
|
2224
3836
|
}
|
|
2225
|
-
function base64ToUint8Array(
|
|
2226
|
-
const binaryString = atob(
|
|
3837
|
+
function base64ToUint8Array(base644) {
|
|
3838
|
+
const binaryString = atob(base644);
|
|
2227
3839
|
const bytes = new Uint8Array(binaryString.length);
|
|
2228
3840
|
for (let i = 0; i < binaryString.length; i++) {
|
|
2229
3841
|
bytes[i] = binaryString.charCodeAt(i);
|
|
@@ -2238,9 +3850,9 @@ function uint8ArrayToBase64(bytes) {
|
|
|
2238
3850
|
return btoa(binaryString);
|
|
2239
3851
|
}
|
|
2240
3852
|
function base64urlToUint8Array(base64url3) {
|
|
2241
|
-
const
|
|
2242
|
-
const padding = "=".repeat((4 -
|
|
2243
|
-
return base64ToUint8Array(
|
|
3853
|
+
const base644 = base64url3.replace(/-/g, "+").replace(/_/g, "/");
|
|
3854
|
+
const padding = "=".repeat((4 - base644.length % 4) % 4);
|
|
3855
|
+
return base64ToUint8Array(base644 + padding);
|
|
2244
3856
|
}
|
|
2245
3857
|
function uint8ArrayToBase64url(bytes) {
|
|
2246
3858
|
return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
@@ -2298,16 +3910,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
2298
3910
|
}
|
|
2299
3911
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
2300
3912
|
const fieldErrors = { _errors: [] };
|
|
2301
|
-
const processError = (error52,
|
|
3913
|
+
const processError = (error52, path22 = []) => {
|
|
2302
3914
|
for (const issue2 of error52.issues) {
|
|
2303
3915
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
2304
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
3916
|
+
issue2.errors.map((issues) => processError({ issues }, [...path22, ...issue2.path]));
|
|
2305
3917
|
} else if (issue2.code === "invalid_key") {
|
|
2306
|
-
processError({ issues: issue2.issues }, [...
|
|
3918
|
+
processError({ issues: issue2.issues }, [...path22, ...issue2.path]);
|
|
2307
3919
|
} else if (issue2.code === "invalid_element") {
|
|
2308
|
-
processError({ issues: issue2.issues }, [...
|
|
3920
|
+
processError({ issues: issue2.issues }, [...path22, ...issue2.path]);
|
|
2309
3921
|
} else {
|
|
2310
|
-
const fullpath = [...
|
|
3922
|
+
const fullpath = [...path22, ...issue2.path];
|
|
2311
3923
|
if (fullpath.length === 0) {
|
|
2312
3924
|
fieldErrors._errors.push(mapper(issue2));
|
|
2313
3925
|
} else {
|
|
@@ -2334,17 +3946,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
2334
3946
|
}
|
|
2335
3947
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
2336
3948
|
const result = { errors: [] };
|
|
2337
|
-
const processError = (error52,
|
|
3949
|
+
const processError = (error52, path22 = []) => {
|
|
2338
3950
|
var _a3, _b;
|
|
2339
3951
|
for (const issue2 of error52.issues) {
|
|
2340
3952
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
2341
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
3953
|
+
issue2.errors.map((issues) => processError({ issues }, [...path22, ...issue2.path]));
|
|
2342
3954
|
} else if (issue2.code === "invalid_key") {
|
|
2343
|
-
processError({ issues: issue2.issues }, [...
|
|
3955
|
+
processError({ issues: issue2.issues }, [...path22, ...issue2.path]);
|
|
2344
3956
|
} else if (issue2.code === "invalid_element") {
|
|
2345
|
-
processError({ issues: issue2.issues }, [...
|
|
3957
|
+
processError({ issues: issue2.issues }, [...path22, ...issue2.path]);
|
|
2346
3958
|
} else {
|
|
2347
|
-
const fullpath = [...
|
|
3959
|
+
const fullpath = [...path22, ...issue2.path];
|
|
2348
3960
|
if (fullpath.length === 0) {
|
|
2349
3961
|
result.errors.push(mapper(issue2));
|
|
2350
3962
|
continue;
|
|
@@ -2376,8 +3988,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
2376
3988
|
}
|
|
2377
3989
|
function toDotPath(_path) {
|
|
2378
3990
|
const segs = [];
|
|
2379
|
-
const
|
|
2380
|
-
for (const seg of
|
|
3991
|
+
const path22 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
3992
|
+
for (const seg of path22) {
|
|
2381
3993
|
if (typeof seg === "number")
|
|
2382
3994
|
segs.push(`[${seg}]`);
|
|
2383
3995
|
else if (typeof seg === "symbol")
|
|
@@ -3606,8 +5218,8 @@ var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
|
3606
5218
|
function isValidBase64URL(data) {
|
|
3607
5219
|
if (!base64url.test(data))
|
|
3608
5220
|
return false;
|
|
3609
|
-
const
|
|
3610
|
-
const padded =
|
|
5221
|
+
const base644 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
5222
|
+
const padded = base644.padEnd(Math.ceil(base644.length / 4) * 4, "=");
|
|
3611
5223
|
return isValidBase64(padded);
|
|
3612
5224
|
}
|
|
3613
5225
|
var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
|
|
@@ -4061,42 +5673,42 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
4061
5673
|
}
|
|
4062
5674
|
doc.write(`const newResult = {};`);
|
|
4063
5675
|
for (const key of normalized.keys) {
|
|
4064
|
-
const
|
|
5676
|
+
const id2 = ids[key];
|
|
4065
5677
|
const k = esc(key);
|
|
4066
5678
|
const schema = shape[key];
|
|
4067
5679
|
const isOptionalIn = schema?._zod?.optin === "optional";
|
|
4068
5680
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
4069
|
-
doc.write(`const ${
|
|
5681
|
+
doc.write(`const ${id2} = ${parseStr(key)};`);
|
|
4070
5682
|
if (isOptionalIn && isOptionalOut) {
|
|
4071
5683
|
doc.write(`
|
|
4072
|
-
if (${
|
|
5684
|
+
if (${id2}.issues.length) {
|
|
4073
5685
|
if (${k} in input) {
|
|
4074
|
-
payload.issues = payload.issues.concat(${
|
|
5686
|
+
payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
|
|
4075
5687
|
...iss,
|
|
4076
5688
|
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
4077
5689
|
})));
|
|
4078
5690
|
}
|
|
4079
5691
|
}
|
|
4080
5692
|
|
|
4081
|
-
if (${
|
|
5693
|
+
if (${id2}.value === undefined) {
|
|
4082
5694
|
if (${k} in input) {
|
|
4083
5695
|
newResult[${k}] = undefined;
|
|
4084
5696
|
}
|
|
4085
5697
|
} else {
|
|
4086
|
-
newResult[${k}] = ${
|
|
5698
|
+
newResult[${k}] = ${id2}.value;
|
|
4087
5699
|
}
|
|
4088
5700
|
|
|
4089
5701
|
`);
|
|
4090
5702
|
} else if (!isOptionalIn) {
|
|
4091
5703
|
doc.write(`
|
|
4092
|
-
const ${
|
|
4093
|
-
if (${
|
|
4094
|
-
payload.issues = payload.issues.concat(${
|
|
5704
|
+
const ${id2}_present = ${k} in input;
|
|
5705
|
+
if (${id2}.issues.length) {
|
|
5706
|
+
payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
|
|
4095
5707
|
...iss,
|
|
4096
5708
|
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
4097
5709
|
})));
|
|
4098
5710
|
}
|
|
4099
|
-
if (!${
|
|
5711
|
+
if (!${id2}_present && !${id2}.issues.length) {
|
|
4100
5712
|
payload.issues.push({
|
|
4101
5713
|
code: "invalid_type",
|
|
4102
5714
|
expected: "nonoptional",
|
|
@@ -4105,30 +5717,30 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
4105
5717
|
});
|
|
4106
5718
|
}
|
|
4107
5719
|
|
|
4108
|
-
if (${
|
|
4109
|
-
if (${
|
|
5720
|
+
if (${id2}_present) {
|
|
5721
|
+
if (${id2}.value === undefined) {
|
|
4110
5722
|
newResult[${k}] = undefined;
|
|
4111
5723
|
} else {
|
|
4112
|
-
newResult[${k}] = ${
|
|
5724
|
+
newResult[${k}] = ${id2}.value;
|
|
4113
5725
|
}
|
|
4114
5726
|
}
|
|
4115
5727
|
|
|
4116
5728
|
`);
|
|
4117
5729
|
} else {
|
|
4118
5730
|
doc.write(`
|
|
4119
|
-
if (${
|
|
4120
|
-
payload.issues = payload.issues.concat(${
|
|
5731
|
+
if (${id2}.issues.length) {
|
|
5732
|
+
payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
|
|
4121
5733
|
...iss,
|
|
4122
5734
|
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
4123
5735
|
})));
|
|
4124
5736
|
}
|
|
4125
5737
|
|
|
4126
|
-
if (${
|
|
5738
|
+
if (${id2}.value === undefined) {
|
|
4127
5739
|
if (${k} in input) {
|
|
4128
5740
|
newResult[${k}] = undefined;
|
|
4129
5741
|
}
|
|
4130
5742
|
} else {
|
|
4131
|
-
newResult[${k}] = ${
|
|
5743
|
+
newResult[${k}] = ${id2}.value;
|
|
4132
5744
|
}
|
|
4133
5745
|
|
|
4134
5746
|
`);
|
|
@@ -12460,26 +14072,26 @@ function extractDefs(ctx, schema) {
|
|
|
12460
14072
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
12461
14073
|
const idToSchema = /* @__PURE__ */ new Map();
|
|
12462
14074
|
for (const entry of ctx.seen.entries()) {
|
|
12463
|
-
const
|
|
12464
|
-
if (
|
|
12465
|
-
const existing = idToSchema.get(
|
|
14075
|
+
const id2 = ctx.metadataRegistry.get(entry[0])?.id;
|
|
14076
|
+
if (id2) {
|
|
14077
|
+
const existing = idToSchema.get(id2);
|
|
12466
14078
|
if (existing && existing !== entry[0]) {
|
|
12467
|
-
throw new Error(`Duplicate schema id "${
|
|
14079
|
+
throw new Error(`Duplicate schema id "${id2}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
|
12468
14080
|
}
|
|
12469
|
-
idToSchema.set(
|
|
14081
|
+
idToSchema.set(id2, entry[0]);
|
|
12470
14082
|
}
|
|
12471
14083
|
}
|
|
12472
14084
|
const makeURI = (entry) => {
|
|
12473
14085
|
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
12474
14086
|
if (ctx.external) {
|
|
12475
14087
|
const externalId = ctx.external.registry.get(entry[0])?.id;
|
|
12476
|
-
const uriGenerator = ctx.external.uri ?? ((
|
|
14088
|
+
const uriGenerator = ctx.external.uri ?? ((id3) => id3);
|
|
12477
14089
|
if (externalId) {
|
|
12478
14090
|
return { ref: uriGenerator(externalId) };
|
|
12479
14091
|
}
|
|
12480
|
-
const
|
|
12481
|
-
entry[1].defId =
|
|
12482
|
-
return { defId:
|
|
14092
|
+
const id2 = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
|
|
14093
|
+
entry[1].defId = id2;
|
|
14094
|
+
return { defId: id2, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id2}` };
|
|
12483
14095
|
}
|
|
12484
14096
|
if (entry[1] === root) {
|
|
12485
14097
|
return { ref: "#" };
|
|
@@ -12527,8 +14139,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
12527
14139
|
continue;
|
|
12528
14140
|
}
|
|
12529
14141
|
}
|
|
12530
|
-
const
|
|
12531
|
-
if (
|
|
14142
|
+
const id2 = ctx.metadataRegistry.get(entry[0])?.id;
|
|
14143
|
+
if (id2) {
|
|
12532
14144
|
extractToDef(entry);
|
|
12533
14145
|
continue;
|
|
12534
14146
|
}
|
|
@@ -12624,10 +14236,10 @@ function finalize(ctx, schema) {
|
|
|
12624
14236
|
} else {
|
|
12625
14237
|
}
|
|
12626
14238
|
if (ctx.external?.uri) {
|
|
12627
|
-
const
|
|
12628
|
-
if (!
|
|
14239
|
+
const id2 = ctx.external.registry.get(schema)?.id;
|
|
14240
|
+
if (!id2)
|
|
12629
14241
|
throw new Error("Schema is missing an `id` property");
|
|
12630
|
-
result.$id = ctx.external.uri(
|
|
14242
|
+
result.$id = ctx.external.uri(id2);
|
|
12631
14243
|
}
|
|
12632
14244
|
Object.assign(result, root.def ?? root.schema);
|
|
12633
14245
|
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
@@ -12787,9 +14399,9 @@ var numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
12787
14399
|
json2.type = "number";
|
|
12788
14400
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
12789
14401
|
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
12790
|
-
const
|
|
14402
|
+
const legacy2 = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
12791
14403
|
if (exMin) {
|
|
12792
|
-
if (
|
|
14404
|
+
if (legacy2) {
|
|
12793
14405
|
json2.minimum = exclusiveMinimum;
|
|
12794
14406
|
json2.exclusiveMinimum = true;
|
|
12795
14407
|
} else {
|
|
@@ -12799,7 +14411,7 @@ var numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
12799
14411
|
json2.minimum = minimum;
|
|
12800
14412
|
}
|
|
12801
14413
|
if (exMax) {
|
|
12802
|
-
if (
|
|
14414
|
+
if (legacy2) {
|
|
12803
14415
|
json2.maximum = exclusiveMaximum;
|
|
12804
14416
|
json2.exclusiveMaximum = true;
|
|
12805
14417
|
} else {
|
|
@@ -13661,7 +15273,7 @@ var safeDecodeAsync2 = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
|
13661
15273
|
|
|
13662
15274
|
// node_modules/zod/v4/classic/schemas.js
|
|
13663
15275
|
var _installedGroups = /* @__PURE__ */ new WeakMap();
|
|
13664
|
-
function _installLazyMethods(inst, group,
|
|
15276
|
+
function _installLazyMethods(inst, group, methods3) {
|
|
13665
15277
|
const proto = Object.getPrototypeOf(inst);
|
|
13666
15278
|
let installed = _installedGroups.get(proto);
|
|
13667
15279
|
if (!installed) {
|
|
@@ -13671,8 +15283,8 @@ function _installLazyMethods(inst, group, methods) {
|
|
|
13671
15283
|
if (installed.has(group))
|
|
13672
15284
|
return;
|
|
13673
15285
|
installed.add(group);
|
|
13674
|
-
for (const key in
|
|
13675
|
-
const fn =
|
|
15286
|
+
for (const key in methods3) {
|
|
15287
|
+
const fn = methods3[key];
|
|
13676
15288
|
Object.defineProperty(proto, key, {
|
|
13677
15289
|
configurable: true,
|
|
13678
15290
|
enumerable: false,
|
|
@@ -15069,13 +16681,13 @@ function resolveRef(ref, ctx) {
|
|
|
15069
16681
|
if (!ref.startsWith("#")) {
|
|
15070
16682
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
15071
16683
|
}
|
|
15072
|
-
const
|
|
15073
|
-
if (
|
|
16684
|
+
const path22 = ref.slice(1).split("/").filter(Boolean);
|
|
16685
|
+
if (path22.length === 0) {
|
|
15074
16686
|
return ctx.rootSchema;
|
|
15075
16687
|
}
|
|
15076
16688
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
15077
|
-
if (
|
|
15078
|
-
const key =
|
|
16689
|
+
if (path22[0] === defsKey) {
|
|
16690
|
+
const key = path22[1];
|
|
15079
16691
|
if (!key || !ctx.defs[key]) {
|
|
15080
16692
|
throw new Error(`Reference not found: ${ref}`);
|
|
15081
16693
|
}
|
|
@@ -15616,6 +17228,9 @@ var threadPermissionModeSelectParamsSchema = external_exports.object({
|
|
|
15616
17228
|
permissionModeId: harnessPermissionModeIdSchema
|
|
15617
17229
|
}).strict();
|
|
15618
17230
|
|
|
17231
|
+
// packages/shared-contracts/dist/harness-route-limit.js
|
|
17232
|
+
var HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH = 8192;
|
|
17233
|
+
|
|
15619
17234
|
// packages/shared-contracts/dist/thread-usage.js
|
|
15620
17235
|
var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
|
|
15621
17236
|
var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
|
|
@@ -15648,7 +17263,7 @@ var composerIndicatorsSchema = external_exports.array(external_exports.object({
|
|
|
15648
17263
|
expiresAtUnix: nonNegativeSafeIntegerSchema,
|
|
15649
17264
|
label: indicatorTextSchema(256).optional(),
|
|
15650
17265
|
tooltip: indicatorTextSchema(1024).optional()
|
|
15651
|
-
}).strict()).max(2).refine((entries) => new Set(entries.map(({ id }) =>
|
|
17266
|
+
}).strict()).max(2).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, {
|
|
15652
17267
|
message: "Composer indicator IDs must be unique"
|
|
15653
17268
|
});
|
|
15654
17269
|
var threadUsageSnapshotSchema = external_exports.object({
|
|
@@ -15674,6 +17289,7 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
15674
17289
|
planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
|
|
15675
17290
|
sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
|
|
15676
17291
|
timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
|
|
17292
|
+
latestRequestTimeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
|
|
15677
17293
|
costSource: external_exports.enum(["publicPrice", "native"]).optional(),
|
|
15678
17294
|
unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
|
|
15679
17295
|
}).strict().superRefine((usage2, context) => {
|
|
@@ -15771,6 +17387,13 @@ var accountCreditsSnapshotSchema = external_exports.object({
|
|
|
15771
17387
|
productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
|
|
15772
17388
|
resetCredits: accountResetCreditsSchema.optional()
|
|
15773
17389
|
}).strict();
|
|
17390
|
+
var accountBalanceSnapshotSchema = external_exports.object({
|
|
17391
|
+
amount: external_exports.number().finite().nonnegative(),
|
|
17392
|
+
/** ISO 4217 code as reported by the Provider, for example `CNY`. */
|
|
17393
|
+
currency: external_exports.string().trim().min(1).max(8),
|
|
17394
|
+
/** Native label when the Harness exposes several Billing Sources. */
|
|
17395
|
+
label: external_exports.string().trim().min(1).max(128).optional()
|
|
17396
|
+
}).strict();
|
|
15774
17397
|
var threadUsageInspectionParamsSchema = external_exports.object({
|
|
15775
17398
|
threadId: hostThreadIdSchema,
|
|
15776
17399
|
refresh: external_exports.literal("exact").optional()
|
|
@@ -15779,7 +17402,10 @@ var threadUsageInspectionSchema = external_exports.object({
|
|
|
15779
17402
|
threadId: hostThreadIdSchema,
|
|
15780
17403
|
usage: threadUsageSnapshotSchema.nullable(),
|
|
15781
17404
|
accountCredits: accountCreditsSnapshotSchema.optional(),
|
|
15782
|
-
/**
|
|
17405
|
+
/** Prepaid funds for the Thread's Billing Source; shown only when no percentage quota exists. */
|
|
17406
|
+
accountBalance: accountBalanceSnapshotSchema.optional(),
|
|
17407
|
+
/** Whether this source can provide cached account quota (credits or a prepaid balance)
|
|
17408
|
+
* independently of usage. */
|
|
15783
17409
|
accountCreditsSupported: external_exports.boolean().optional()
|
|
15784
17410
|
}).strict();
|
|
15785
17411
|
|
|
@@ -15791,10 +17417,15 @@ var THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100;
|
|
|
15791
17417
|
var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
15792
17418
|
message: "Value must not be empty or whitespace"
|
|
15793
17419
|
});
|
|
15794
|
-
var harnessModelRefIdSchema =
|
|
17420
|
+
var harnessModelRefIdSchema = external_exports.string().min(1).max(HARNESS_MODEL_REF_MAX_LENGTH).refine((id2) => !new RegExp("\\p{Cc}", "u").test(id2), "Model Ref must not contain control characters").brand();
|
|
17421
|
+
var harnessModelServiceTierSchema = external_exports.enum(["priority", "ultrafast"]);
|
|
15795
17422
|
var harnessModelRefSchema = external_exports.object({
|
|
15796
|
-
id: harnessModelRefIdSchema
|
|
17423
|
+
id: harnessModelRefIdSchema,
|
|
17424
|
+
serviceTier: harnessModelServiceTierSchema.optional()
|
|
15797
17425
|
}).strict();
|
|
17426
|
+
function sameHarnessModelRef(left, right) {
|
|
17427
|
+
return left?.id === right?.id && left?.serviceTier === right?.serviceTier;
|
|
17428
|
+
}
|
|
15798
17429
|
var harnessThinkingOptionIdSchema = nonBlankTextSchema2.max(HARNESS_THINKING_OPTION_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Thinking option ID must use transport-safe characters").brand();
|
|
15799
17430
|
var harnessResolvedModelLabelSchema = nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
|
|
15800
17431
|
var harnessThinkingOptionSchema = external_exports.object({
|
|
@@ -15808,7 +17439,15 @@ var harnessModelSchema = external_exports.object({
|
|
|
15808
17439
|
/** Optional opaque selection for this same Model with priority processing enabled. */
|
|
15809
17440
|
fastModel: harnessModelRefSchema.optional(),
|
|
15810
17441
|
supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
|
|
15811
|
-
}).strict()
|
|
17442
|
+
}).strict().refine((model2) => model2.fastModel?.serviceTier === void 0 || model2.fastModel.id === model2.ref.id, {
|
|
17443
|
+
path: ["fastModel", "id"],
|
|
17444
|
+
message: "A tiered Fast Model must share the base Model ID"
|
|
17445
|
+
});
|
|
17446
|
+
function catalogModelForRef(catalog, ref) {
|
|
17447
|
+
if (!ref)
|
|
17448
|
+
return void 0;
|
|
17449
|
+
return catalog?.models.find((model2) => sameHarnessModelRef(model2.ref, ref) || sameHarnessModelRef(model2.fastModel, ref));
|
|
17450
|
+
}
|
|
15812
17451
|
var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
|
|
15813
17452
|
const ids = /* @__PURE__ */ new Set();
|
|
15814
17453
|
for (const [index, option] of options.entries()) {
|
|
@@ -15828,26 +17467,26 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
15828
17467
|
thinkingOptions: harnessThinkingOptionsSchema,
|
|
15829
17468
|
defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
|
|
15830
17469
|
}).strict().superRefine((catalog, context) => {
|
|
15831
|
-
const refs =
|
|
15832
|
-
const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) =>
|
|
17470
|
+
const refs = [];
|
|
17471
|
+
const thinkingIds = new Set(catalog.thinkingOptions.map(({ id: id2 }) => id2));
|
|
15833
17472
|
for (const [index, model2] of catalog.models.entries()) {
|
|
15834
|
-
if (refs.
|
|
17473
|
+
if (refs.some((ref) => sameHarnessModelRef(ref, model2.ref))) {
|
|
15835
17474
|
context.addIssue({
|
|
15836
17475
|
code: "custom",
|
|
15837
17476
|
message: "Model Catalog refs must be unique",
|
|
15838
17477
|
path: ["models", index, "ref", "id"]
|
|
15839
17478
|
});
|
|
15840
17479
|
}
|
|
15841
|
-
refs.
|
|
17480
|
+
refs.push(model2.ref);
|
|
15842
17481
|
if (model2.fastModel) {
|
|
15843
|
-
if (refs.
|
|
17482
|
+
if (refs.some((ref) => sameHarnessModelRef(ref, model2.fastModel))) {
|
|
15844
17483
|
context.addIssue({
|
|
15845
17484
|
code: "custom",
|
|
15846
17485
|
message: "Fast Model refs must be distinct and unique",
|
|
15847
17486
|
path: ["models", index, "fastModel"]
|
|
15848
17487
|
});
|
|
15849
17488
|
}
|
|
15850
|
-
refs.
|
|
17489
|
+
refs.push(model2.fastModel);
|
|
15851
17490
|
}
|
|
15852
17491
|
const supportedThinkingIds = /* @__PURE__ */ new Set();
|
|
15853
17492
|
for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
|
|
@@ -15868,7 +17507,7 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
15868
17507
|
}
|
|
15869
17508
|
}
|
|
15870
17509
|
}
|
|
15871
|
-
if (catalog.defaultModel && !
|
|
17510
|
+
if (catalog.defaultModel && !catalogModelForRef(catalog, catalog.defaultModel)) {
|
|
15872
17511
|
context.addIssue({
|
|
15873
17512
|
code: "custom",
|
|
15874
17513
|
message: "Default Model must exist in the Model Catalog",
|
|
@@ -15908,7 +17547,12 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
|
|
|
15908
17547
|
observe: external_exports.boolean()
|
|
15909
17548
|
}).strict().optional(),
|
|
15910
17549
|
/** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
|
|
15911
|
-
steer: external_exports.boolean().optional()
|
|
17550
|
+
steer: external_exports.boolean().optional(),
|
|
17551
|
+
/**
|
|
17552
|
+
* True when the native plan (task list) outlives the Turn that changed it, so a reopened
|
|
17553
|
+
* Thread gets its latest plan again. Otherwise a plan stays with the Turn that made it.
|
|
17554
|
+
*/
|
|
17555
|
+
persistentPlan: external_exports.boolean().optional()
|
|
15912
17556
|
}).strict();
|
|
15913
17557
|
var harnessConfigurationStateSchema = external_exports.object({
|
|
15914
17558
|
effectiveModel: harnessModelRefSchema.optional(),
|
|
@@ -15917,7 +17561,7 @@ var harnessConfigurationStateSchema = external_exports.object({
|
|
|
15917
17561
|
availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
|
|
15918
17562
|
effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
|
|
15919
17563
|
}).strict().superRefine((state, context) => {
|
|
15920
|
-
if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id }) =>
|
|
17564
|
+
if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id: id2 }) => id2 === state.effectiveThinkingOptionId)) {
|
|
15921
17565
|
context.addIssue({
|
|
15922
17566
|
code: "custom",
|
|
15923
17567
|
message: "Effective Thinking option must be currently available",
|
|
@@ -15957,7 +17601,8 @@ var harnessInspectParamsSchema = external_exports.object({
|
|
|
15957
17601
|
cwd: nonBlankTextSchema2.max(16384).optional(),
|
|
15958
17602
|
refresh: external_exports.boolean().optional(),
|
|
15959
17603
|
/** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
|
|
15960
|
-
purpose: external_exports.literal("availability").optional()
|
|
17604
|
+
purpose: external_exports.literal("availability").optional(),
|
|
17605
|
+
credentialAccess: external_exports.enum(["allow", "retry"]).optional()
|
|
15961
17606
|
}).strict();
|
|
15962
17607
|
var harnessWebUiOpenParamsSchema = external_exports.object({
|
|
15963
17608
|
harnessId: harnessIdSchema
|
|
@@ -15988,7 +17633,7 @@ var codexThreadInspectionSchema = external_exports.object({
|
|
|
15988
17633
|
var externalThreadInspectionSchema = external_exports.object({
|
|
15989
17634
|
owner: external_exports.literal("external"),
|
|
15990
17635
|
harnessId: nonBlankTextSchema2.max(256),
|
|
15991
|
-
transportModelId: nonBlankTextSchema2.max(
|
|
17636
|
+
transportModelId: nonBlankTextSchema2.max(HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH),
|
|
15992
17637
|
effectiveModel: harnessModelRefSchema.optional(),
|
|
15993
17638
|
resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
|
|
15994
17639
|
effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
@@ -16070,13 +17715,700 @@ var threadSteeringInspectResultSchema = external_exports.object({
|
|
|
16070
17715
|
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
16071
17716
|
}).strict();
|
|
16072
17717
|
|
|
17718
|
+
// packages/shared-contracts/dist/harness-plugins.js
|
|
17719
|
+
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
17720
|
+
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
17721
|
+
var HARNESS_PLUGIN_LIMIT = 128;
|
|
17722
|
+
var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
|
|
17723
|
+
var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
|
|
17724
|
+
var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id2) => id2 !== "codex", "The official Codex identity is reserved");
|
|
17725
|
+
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");
|
|
17726
|
+
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
17727
|
+
var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
|
|
17728
|
+
var harnessInstallationGuideSchema = external_exports.object({
|
|
17729
|
+
commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
|
|
17730
|
+
before: localizedTextSchema.optional(),
|
|
17731
|
+
after: localizedTextSchema.optional(),
|
|
17732
|
+
downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
|
|
17733
|
+
}).strict();
|
|
17734
|
+
var pluginPresentationShape = {
|
|
17735
|
+
id: installedHarnessPluginIdSchema,
|
|
17736
|
+
name: external_exports.string().trim().min(1).max(128),
|
|
17737
|
+
version: external_exports.string().min(1).max(128),
|
|
17738
|
+
/** Capability-only plugin; omitted for existing session-capable plugins. */
|
|
17739
|
+
kind: external_exports.literal("usage").optional(),
|
|
17740
|
+
/** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
|
|
17741
|
+
iconStyle: external_exports.object({
|
|
17742
|
+
vector: external_exports.object({
|
|
17743
|
+
viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
|
|
17744
|
+
color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
|
|
17745
|
+
paths: external_exports.array(external_exports.object({
|
|
17746
|
+
d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
|
|
17747
|
+
fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
|
|
17748
|
+
fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
|
|
17749
|
+
}).strict()).min(1).max(32)
|
|
17750
|
+
}).strict().optional(),
|
|
17751
|
+
background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
|
|
17752
|
+
borderRadius: external_exports.number().min(0).max(50).optional(),
|
|
17753
|
+
paddingRatio: external_exports.number().min(0).max(0.25).optional()
|
|
17754
|
+
}).strict().optional(),
|
|
17755
|
+
installation: harnessInstallationGuideSchema.optional(),
|
|
17756
|
+
notice: localizedTextSchema.optional(),
|
|
17757
|
+
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
17758
|
+
launchCommand: external_exports.literal(true).optional(),
|
|
17759
|
+
links: external_exports.object({
|
|
17760
|
+
website: documentationUrlSchema.optional(),
|
|
17761
|
+
documentation: documentationUrlSchema.optional(),
|
|
17762
|
+
installation: documentationUrlSchema.optional()
|
|
17763
|
+
}).strict().optional()
|
|
17764
|
+
};
|
|
17765
|
+
var harnessPluginManifestSchema = external_exports.object({
|
|
17766
|
+
manifestVersion: external_exports.literal(1),
|
|
17767
|
+
...pluginPresentationShape,
|
|
17768
|
+
adapterApiVersion: external_exports.number().int().positive(),
|
|
17769
|
+
entry: pluginRelativeResourceSchema,
|
|
17770
|
+
icon: pluginRelativeResourceSchema.optional()
|
|
17771
|
+
}).strict();
|
|
17772
|
+
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);
|
|
17773
|
+
var harnessPluginDescriptorSchema = external_exports.object({
|
|
17774
|
+
...pluginPresentationShape,
|
|
17775
|
+
icon: harnessPluginIconSchema.optional()
|
|
17776
|
+
}).strict();
|
|
17777
|
+
var harnessPluginListParamsSchema = external_exports.object({}).strict();
|
|
17778
|
+
var harnessPluginListResultSchema = external_exports.object({
|
|
17779
|
+
plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
|
|
17780
|
+
}).strict();
|
|
17781
|
+
var harnessPluginConfigurationSchema = external_exports.object({
|
|
17782
|
+
version: external_exports.literal(1),
|
|
17783
|
+
enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
17784
|
+
}).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
|
|
17785
|
+
message: "Enabled plugin IDs must be unique",
|
|
17786
|
+
path: ["enabled"]
|
|
17787
|
+
});
|
|
17788
|
+
|
|
17789
|
+
// packages/shared-contracts/dist/desktop-extensions.js
|
|
17790
|
+
var DESKTOP_EXTENSION_API_VERSION = 1;
|
|
17791
|
+
var DESKTOP_EXTENSION_LIMIT = 64;
|
|
17792
|
+
var DESKTOP_EXTENSION_ZIP_MAX_BYTES = 64 * 1024 * 1024;
|
|
17793
|
+
var DESKTOP_EXTENSION_MANIFEST_MAX_BYTES = 128 * 1024;
|
|
17794
|
+
var DESKTOP_EXTENSION_SCRIPT_MAX_BYTES = 2 * 1024 * 1024;
|
|
17795
|
+
var DESKTOP_EXTENSION_STYLE_MAX_BYTES = 256 * 1024;
|
|
17796
|
+
var DESKTOP_EXTENSION_ICON_MAX_BYTES = 128 * 1024;
|
|
17797
|
+
var DESKTOP_EXTENSION_SCREENSHOT_LIMIT = 4;
|
|
17798
|
+
var DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES = 512 * 1024;
|
|
17799
|
+
var DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES = 8 * 1024 * 1024;
|
|
17800
|
+
var DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES = 8 * 1024 * 1024;
|
|
17801
|
+
var DESKTOP_EXTENSION_ASSET_MAX_BYTES = 16 * 1024 * 1024;
|
|
17802
|
+
var DESKTOP_EXTENSION_SETTINGS_MAX_BYTES = 1024 * 1024;
|
|
17803
|
+
var desktopExtensionIdSchema = installedPluginIdSchema;
|
|
17804
|
+
var desktopExtensionSlotSchema = external_exports.enum([
|
|
17805
|
+
"sidebar.thread-layout",
|
|
17806
|
+
"sidebar.thread-badge",
|
|
17807
|
+
"appearance.theme"
|
|
17808
|
+
]);
|
|
17809
|
+
var desktopExtensionCategorySchema = external_exports.enum([
|
|
17810
|
+
"appearance",
|
|
17811
|
+
"interface",
|
|
17812
|
+
"workflow",
|
|
17813
|
+
"analytics",
|
|
17814
|
+
"integrations",
|
|
17815
|
+
"tools"
|
|
17816
|
+
]);
|
|
17817
|
+
var extensionName = external_exports.string().trim().min(1).max(128);
|
|
17818
|
+
function desktopExtensionScreenshotMimeType(resource) {
|
|
17819
|
+
switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
|
|
17820
|
+
case "png":
|
|
17821
|
+
return "image/png";
|
|
17822
|
+
case "jpg":
|
|
17823
|
+
case "jpeg":
|
|
17824
|
+
return "image/jpeg";
|
|
17825
|
+
case "webp":
|
|
17826
|
+
return "image/webp";
|
|
17827
|
+
default:
|
|
17828
|
+
return void 0;
|
|
17829
|
+
}
|
|
17830
|
+
}
|
|
17831
|
+
var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
|
|
17832
|
+
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");
|
|
17833
|
+
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) => {
|
|
17834
|
+
const { username, password } = new URL(value);
|
|
17835
|
+
return !username && !password && !/[\\\s]/u.test(value);
|
|
17836
|
+
}, "URL must not contain credentials, backslashes, or whitespace");
|
|
17837
|
+
function localizedText(text) {
|
|
17838
|
+
return external_exports.strictObject({ en: text, "zh-CN": text });
|
|
17839
|
+
}
|
|
17840
|
+
var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
|
|
17841
|
+
var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
|
|
17842
|
+
var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
|
|
17843
|
+
var settingField = {
|
|
17844
|
+
key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
|
|
17845
|
+
label: desktopExtensionLocalizedTextSchema,
|
|
17846
|
+
description: desktopExtensionLocalizedTextSchema.optional()
|
|
17847
|
+
};
|
|
17848
|
+
var numericSetting = {
|
|
17849
|
+
...settingField,
|
|
17850
|
+
step: external_exports.number().positive().optional(),
|
|
17851
|
+
default: external_exports.number().optional()
|
|
17852
|
+
};
|
|
17853
|
+
var settingOption = external_exports.strictObject({
|
|
17854
|
+
value: external_exports.string(),
|
|
17855
|
+
label: desktopExtensionLocalizedTextSchema
|
|
17856
|
+
});
|
|
17857
|
+
var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
|
|
17858
|
+
external_exports.strictObject({
|
|
17859
|
+
...settingField,
|
|
17860
|
+
type: external_exports.literal("boolean"),
|
|
17861
|
+
default: external_exports.boolean().optional()
|
|
17862
|
+
}),
|
|
17863
|
+
external_exports.strictObject({
|
|
17864
|
+
...settingField,
|
|
17865
|
+
type: external_exports.literal("string"),
|
|
17866
|
+
placeholder: desktopExtensionLocalizedTextSchema.optional(),
|
|
17867
|
+
default: external_exports.string().optional()
|
|
17868
|
+
}),
|
|
17869
|
+
external_exports.strictObject({
|
|
17870
|
+
...numericSetting,
|
|
17871
|
+
type: external_exports.literal("number"),
|
|
17872
|
+
min: external_exports.number().optional(),
|
|
17873
|
+
max: external_exports.number().optional()
|
|
17874
|
+
}),
|
|
17875
|
+
external_exports.strictObject({
|
|
17876
|
+
...numericSetting,
|
|
17877
|
+
type: external_exports.literal("range"),
|
|
17878
|
+
min: external_exports.number(),
|
|
17879
|
+
max: external_exports.number()
|
|
17880
|
+
}),
|
|
17881
|
+
external_exports.strictObject({
|
|
17882
|
+
...settingField,
|
|
17883
|
+
type: external_exports.literal("select"),
|
|
17884
|
+
options: external_exports.array(settingOption).min(1),
|
|
17885
|
+
default: external_exports.string().optional()
|
|
17886
|
+
})
|
|
17887
|
+
]).superRefine((field2, ctx) => {
|
|
17888
|
+
const issue2 = (path22, message) => ctx.addIssue({ code: "custom", path: [path22], message });
|
|
17889
|
+
if (field2.type === "number" || field2.type === "range") {
|
|
17890
|
+
const { min = -Infinity, max = Infinity, default: value } = field2;
|
|
17891
|
+
if (min > max)
|
|
17892
|
+
issue2("max", "Must be at least min");
|
|
17893
|
+
if (value !== void 0 && (value < min || value > max))
|
|
17894
|
+
issue2("default", "Must be within min and max");
|
|
17895
|
+
} else if (field2.type === "select") {
|
|
17896
|
+
const values = new Set(field2.options.map(({ value }) => value));
|
|
17897
|
+
if (values.size !== field2.options.length)
|
|
17898
|
+
issue2("options", "Duplicate option values");
|
|
17899
|
+
if (field2.default !== void 0 && !values.has(field2.default))
|
|
17900
|
+
issue2("default", "Must match an option value");
|
|
17901
|
+
}
|
|
17902
|
+
});
|
|
17903
|
+
var manifestHeader = external_exports.object({
|
|
17904
|
+
manifestVersion: external_exports.int().positive(),
|
|
17905
|
+
id: desktopExtensionIdSchema,
|
|
17906
|
+
name: external_exports.union([extensionName, localizedText(extensionName)]),
|
|
17907
|
+
version: external_exports.string().min(1).max(128),
|
|
17908
|
+
desktopApi: external_exports.int().positive()
|
|
17909
|
+
}).passthrough();
|
|
17910
|
+
var desktopExtensionManifestSchema = manifestHeader.extend({
|
|
17911
|
+
manifestVersion: external_exports.literal(1),
|
|
17912
|
+
desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
|
|
17913
|
+
description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
|
|
17914
|
+
author: external_exports.string().trim().min(1).max(128).optional(),
|
|
17915
|
+
repository: desktopExtensionHttpUrlSchema.optional(),
|
|
17916
|
+
details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
|
|
17917
|
+
icon: imagePathSchema.optional(),
|
|
17918
|
+
screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
|
|
17919
|
+
desktop: external_exports.strictObject({
|
|
17920
|
+
script: pluginRelativeResourceSchema,
|
|
17921
|
+
style: pluginRelativeResourceSchema.optional()
|
|
17922
|
+
}).optional(),
|
|
17923
|
+
backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
|
|
17924
|
+
slots: slotsSchema.default(() => []),
|
|
17925
|
+
settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
|
|
17926
|
+
categories: categoriesSchema.optional()
|
|
17927
|
+
}).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
|
|
17928
|
+
function parseDesktopExtensionManifest(value) {
|
|
17929
|
+
const header = manifestHeader.safeParse(value);
|
|
17930
|
+
if (!header.success)
|
|
17931
|
+
return { state: "invalid", error: external_exports.prettifyError(header.error) };
|
|
17932
|
+
if (header.data.desktopApi > DESKTOP_EXTENSION_API_VERSION) {
|
|
17933
|
+
return {
|
|
17934
|
+
state: "incompatible",
|
|
17935
|
+
error: `Desktop API ${header.data.desktopApi} requires a newer codexhost`
|
|
17936
|
+
};
|
|
17937
|
+
}
|
|
17938
|
+
const manifest = desktopExtensionManifestSchema.safeParse(value);
|
|
17939
|
+
return manifest.success ? { state: "valid", manifest: manifest.data } : { state: "invalid", error: external_exports.prettifyError(manifest.error) };
|
|
17940
|
+
}
|
|
17941
|
+
var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
|
|
17942
|
+
var desktopExtensionStatusSchema = external_exports.strictObject({
|
|
17943
|
+
state: external_exports.enum([
|
|
17944
|
+
"running",
|
|
17945
|
+
"disabled",
|
|
17946
|
+
"invalid",
|
|
17947
|
+
"incompatible",
|
|
17948
|
+
"conflict",
|
|
17949
|
+
"failed",
|
|
17950
|
+
"waiting"
|
|
17951
|
+
]),
|
|
17952
|
+
hash: desktopExtensionHashSchema.optional(),
|
|
17953
|
+
error: external_exports.string().optional(),
|
|
17954
|
+
conflictWith: desktopExtensionIdSchema.optional()
|
|
17955
|
+
});
|
|
17956
|
+
var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
|
|
17957
|
+
controllerPid: external_exports.int().positive(),
|
|
17958
|
+
targetId: external_exports.string().nullable(),
|
|
17959
|
+
updatedAt: external_exports.iso.datetime(),
|
|
17960
|
+
handledReloadToken: external_exports.uuid().optional(),
|
|
17961
|
+
extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema),
|
|
17962
|
+
surfaces: external_exports.record(external_exports.string(), desktopExtensionStatusSchema).optional()
|
|
17963
|
+
});
|
|
17964
|
+
var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
|
|
17965
|
+
function isGitHubDesktopExtensionZipballUrl(url2) {
|
|
17966
|
+
return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
|
|
17967
|
+
}
|
|
17968
|
+
var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
|
|
17969
|
+
const url2 = new URL(input);
|
|
17970
|
+
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);
|
|
17971
|
+
}, "Expected a .zip download URL or a GitHub zipball URL");
|
|
17972
|
+
var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
|
|
17973
|
+
id: desktopExtensionIdSchema,
|
|
17974
|
+
version: external_exports.string().trim().min(1).max(128),
|
|
17975
|
+
name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
|
|
17976
|
+
description: localizedText(external_exports.string().trim().min(1).max(4096)),
|
|
17977
|
+
details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
|
|
17978
|
+
author: external_exports.string().trim().min(1).max(128),
|
|
17979
|
+
repository: desktopExtensionHttpUrlSchema,
|
|
17980
|
+
stars: external_exports.number().int().min(0).optional(),
|
|
17981
|
+
downloads: external_exports.number().int().min(0).optional(),
|
|
17982
|
+
categories: categoriesSchema.optional(),
|
|
17983
|
+
trustTier: desktopExtensionTrustTierSchema.default("community"),
|
|
17984
|
+
icon: desktopExtensionHttpUrlSchema.optional(),
|
|
17985
|
+
screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
17986
|
+
downloadUrl: desktopExtensionZipUrlSchema,
|
|
17987
|
+
sha256: desktopExtensionHashSchema,
|
|
17988
|
+
slots: slotsSchema.optional(),
|
|
17989
|
+
publishedAt: external_exports.string().optional(),
|
|
17990
|
+
updatedAt: external_exports.string().optional(),
|
|
17991
|
+
minCodexHostVersion: external_exports.string().optional()
|
|
17992
|
+
});
|
|
17993
|
+
var desktopExtensionCatalogSchema = external_exports.strictObject({
|
|
17994
|
+
schemaVersion: external_exports.literal(1),
|
|
17995
|
+
generatedAt: external_exports.string(),
|
|
17996
|
+
extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
|
|
17997
|
+
});
|
|
17998
|
+
function resolveDesktopExtensionSlots(enabledOrder, manifests) {
|
|
17999
|
+
const byId = new Map(Array.from(manifests, ({ id: id2, slots = [] }) => [id2, slots]));
|
|
18000
|
+
const owners = /* @__PURE__ */ new Map();
|
|
18001
|
+
const conflicts = /* @__PURE__ */ new Map();
|
|
18002
|
+
const active2 = [];
|
|
18003
|
+
for (const id2 of new Set(enabledOrder)) {
|
|
18004
|
+
const slots = byId.get(id2);
|
|
18005
|
+
if (!slots)
|
|
18006
|
+
continue;
|
|
18007
|
+
const conflictWith = slots.map((slot) => owners.get(slot)).find((owner) => owner !== void 0);
|
|
18008
|
+
if (conflictWith !== void 0) {
|
|
18009
|
+
conflicts.set(id2, conflictWith);
|
|
18010
|
+
continue;
|
|
18011
|
+
}
|
|
18012
|
+
for (const slot of slots)
|
|
18013
|
+
owners.set(slot, id2);
|
|
18014
|
+
active2.push(id2);
|
|
18015
|
+
}
|
|
18016
|
+
return { active: active2, conflicts };
|
|
18017
|
+
}
|
|
18018
|
+
var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
|
|
18019
|
+
|
|
18020
|
+
// packages/shared-contracts/dist/host-extensions.js
|
|
18021
|
+
var reservedName = /^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu;
|
|
18022
|
+
var HOST_EXTENSION_PAGE_API_VERSION = 1;
|
|
18023
|
+
var hostExtensionIdSchema = desktopExtensionIdSchema.refine((id2) => !reservedName.test(id2), "Reserved extension ID");
|
|
18024
|
+
var hostExtensionTargetSchema = external_exports.enum(["desktop", "web"]);
|
|
18025
|
+
var hostExtensionDigestSchema = desktopExtensionHashSchema;
|
|
18026
|
+
var hostExtensionActivationIdSchema = external_exports.uuid();
|
|
18027
|
+
var hostExtensionResourcePathSchema = pluginRelativeResourceSchema.refine((resource) => !/[\x00-\x1f\x7f<>"|*]/u.test(resource) && resource.split("/").every((part) => !/[. ]$/u.test(part) && !reservedName.test(part)), "Expected a portable relative resource path").refine((path22) => path22.split("/").length <= 32, "Extension resources may be at most 32 segments deep");
|
|
18028
|
+
var legacy = desktopExtensionManifestSchema.shape;
|
|
18029
|
+
var localized = (max, min = 0) => external_exports.strictObject({
|
|
18030
|
+
en: external_exports.string().trim().min(min).max(max),
|
|
18031
|
+
"zh-CN": external_exports.string().trim().min(min).max(max)
|
|
18032
|
+
});
|
|
18033
|
+
var resourceWithSuffix = (suffix) => hostExtensionResourcePathSchema.refine((path22) => path22.endsWith(suffix), `Expected a ${suffix} file`);
|
|
18034
|
+
var moduleEntry = resourceWithSuffix(".mjs");
|
|
18035
|
+
var style = resourceWithSuffix(".css").optional();
|
|
18036
|
+
var hostExtensionCanonicalPath = (path22) => path22.normalize("NFC").toLowerCase();
|
|
18037
|
+
var hostExtensionManifestV2Schema = external_exports.strictObject({
|
|
18038
|
+
manifestVersion: external_exports.literal(2),
|
|
18039
|
+
id: hostExtensionIdSchema,
|
|
18040
|
+
name: localized(128, 1),
|
|
18041
|
+
version: external_exports.string().trim().min(1).max(128),
|
|
18042
|
+
description: localized(4096),
|
|
18043
|
+
details: localized(16384).optional(),
|
|
18044
|
+
author: legacy.author,
|
|
18045
|
+
repository: legacy.repository,
|
|
18046
|
+
icon: legacy.icon.refine((path22) => path22 === void 0 || hostExtensionResourcePathSchema.safeParse(path22).success),
|
|
18047
|
+
screenshots: legacy.screenshots.refine((paths) => paths === void 0 || paths.every((path22) => hostExtensionResourcePathSchema.safeParse(path22).success)),
|
|
18048
|
+
categories: legacy.categories,
|
|
18049
|
+
settingsSchema: legacy.settingsSchema,
|
|
18050
|
+
slots: legacy.slots.removeDefault().optional(),
|
|
18051
|
+
page: external_exports.strictObject({
|
|
18052
|
+
apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
|
|
18053
|
+
entry: moduleEntry,
|
|
18054
|
+
style,
|
|
18055
|
+
title: localized(128, 1).optional()
|
|
18056
|
+
}).optional(),
|
|
18057
|
+
widget: external_exports.strictObject({
|
|
18058
|
+
apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
|
|
18059
|
+
entry: moduleEntry,
|
|
18060
|
+
style
|
|
18061
|
+
}).optional(),
|
|
18062
|
+
desktop: external_exports.strictObject({ apiVersion: external_exports.literal(1), script: resourceWithSuffix(".js"), style }).optional(),
|
|
18063
|
+
web: external_exports.strictObject({ apiVersion: external_exports.literal(1), entry: moduleEntry.optional(), style }).refine(({ entry, style: style2 }) => entry !== void 0 || style2 !== void 0, "Expected a Web entry or style").optional(),
|
|
18064
|
+
backend: external_exports.strictObject({ apiVersion: external_exports.literal(1), entry: moduleEntry }).optional()
|
|
18065
|
+
}).refine(({ page, widget, desktop, web, backend }) => Boolean(page || widget || desktop || web || backend), "Expected at least one page, widget, desktop, web, or backend entry").refine(({ page, widget, web, backend }) => !backend || [page?.entry, widget?.entry, web?.entry].every((entry) => entry === void 0 || hostExtensionCanonicalPath(entry) !== hostExtensionCanonicalPath(backend.entry)), { path: ["backend", "entry"], message: "A backend entry cannot also be a frontend entry" });
|
|
18066
|
+
function normalizeText(value) {
|
|
18067
|
+
return typeof value === "string" ? { en: value, "zh-CN": value } : { en: value.en, "zh-CN": value["zh-CN"] ?? value.en };
|
|
18068
|
+
}
|
|
18069
|
+
function parseHostExtensionManifest(value) {
|
|
18070
|
+
const header = external_exports.object({ manifestVersion: external_exports.int().positive() }).safeParse(value);
|
|
18071
|
+
if (!header.success)
|
|
18072
|
+
return { state: "invalid", error: external_exports.prettifyError(header.error) };
|
|
18073
|
+
if (header.data.manifestVersion > 2)
|
|
18074
|
+
return {
|
|
18075
|
+
state: "incompatible",
|
|
18076
|
+
error: `Manifest version ${header.data.manifestVersion} requires a newer codexhost`
|
|
18077
|
+
};
|
|
18078
|
+
if (header.data.manifestVersion === 1) {
|
|
18079
|
+
const legacy2 = parseDesktopExtensionManifest(value);
|
|
18080
|
+
if (legacy2.state !== "valid")
|
|
18081
|
+
return legacy2;
|
|
18082
|
+
const { desktopApi, name, description, details, desktop, backend, ...metadata } = legacy2.manifest;
|
|
18083
|
+
value = {
|
|
18084
|
+
...metadata,
|
|
18085
|
+
manifestVersion: 2,
|
|
18086
|
+
name: normalizeText(name),
|
|
18087
|
+
description: normalizeText(description ?? ""),
|
|
18088
|
+
...details ? { details: normalizeText(details) } : {},
|
|
18089
|
+
...desktop ? { desktop: { apiVersion: desktopApi, ...desktop } } : {},
|
|
18090
|
+
...backend ? { backend: { apiVersion: 1, entry: backend.script } } : {}
|
|
18091
|
+
};
|
|
18092
|
+
}
|
|
18093
|
+
const manifest = hostExtensionManifestV2Schema.safeParse(value);
|
|
18094
|
+
return manifest.success ? { state: "valid", manifest: manifest.data } : { state: "invalid", error: external_exports.prettifyError(manifest.error) };
|
|
18095
|
+
}
|
|
18096
|
+
function targetsForCapabilities({ hasPage, hasWidget, hasDesktop, hasWeb, hasBackend }) {
|
|
18097
|
+
if (hasPage || hasWidget || hasBackend && !hasDesktop && !hasWeb)
|
|
18098
|
+
return ["desktop", "web"];
|
|
18099
|
+
const targets = [];
|
|
18100
|
+
if (hasDesktop)
|
|
18101
|
+
targets.push("desktop");
|
|
18102
|
+
if (hasWeb)
|
|
18103
|
+
targets.push("web");
|
|
18104
|
+
return targets;
|
|
18105
|
+
}
|
|
18106
|
+
var hostExtensionBackendMethodSchema = desktopExtensionBackendMethodSchema;
|
|
18107
|
+
|
|
18108
|
+
// packages/shared-contracts/dist/host-extension-management.js
|
|
18109
|
+
var HOST_EXTENSION_ZIP_MAX_BYTES = DESKTOP_EXTENSION_ZIP_MAX_BYTES;
|
|
18110
|
+
var HOST_EXTENSION_CATALOG_URL = "https://raw.githubusercontent.com/BytePioneer-AI/codexhost-extensions-registry/main/catalog.v2.json";
|
|
18111
|
+
var HOST_EXTENSION_CATALOG_MIRROR_URL = "https://cdn.jsdelivr.net/gh/BytePioneer-AI/codexhost-extensions-registry@main/catalog.v2.json";
|
|
18112
|
+
var hostExtensionRevisionSchema = external_exports.int().nonnegative();
|
|
18113
|
+
var hostExtensionConfigurationSchema = external_exports.strictObject({
|
|
18114
|
+
revision: hostExtensionRevisionSchema,
|
|
18115
|
+
enabled: external_exports.array(hostExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs")
|
|
18116
|
+
});
|
|
18117
|
+
var { downloadUrl, ...catalogMetadata } = desktopExtensionCatalogEntrySchema.shape;
|
|
18118
|
+
var hostExtensionCatalogEntrySchema = external_exports.object({
|
|
18119
|
+
...catalogMetadata,
|
|
18120
|
+
id: hostExtensionIdSchema,
|
|
18121
|
+
format: external_exports.literal("codexhost"),
|
|
18122
|
+
targets: external_exports.array(hostExtensionTargetSchema).min(1).max(2).refine((targets) => new Set(targets).size === targets.length, "Duplicate targets"),
|
|
18123
|
+
apis: external_exports.strictObject({
|
|
18124
|
+
page: external_exports.int().positive().optional(),
|
|
18125
|
+
widget: external_exports.int().positive().optional(),
|
|
18126
|
+
desktop: external_exports.int().positive().optional(),
|
|
18127
|
+
web: external_exports.int().positive().optional(),
|
|
18128
|
+
backend: external_exports.int().positive().optional()
|
|
18129
|
+
}),
|
|
18130
|
+
downloadUrl: downloadUrl.refine((url2) => url2.startsWith("https://"), "Expected HTTPS")
|
|
18131
|
+
}).refine(({ targets, apis }) => {
|
|
18132
|
+
const derived = targetsForCapabilities({
|
|
18133
|
+
hasPage: Boolean(apis.page),
|
|
18134
|
+
hasWidget: Boolean(apis.widget),
|
|
18135
|
+
hasDesktop: Boolean(apis.desktop),
|
|
18136
|
+
hasWeb: Boolean(apis.web),
|
|
18137
|
+
hasBackend: Boolean(apis.backend)
|
|
18138
|
+
});
|
|
18139
|
+
return targets.length === derived.length && derived.every((target2) => targets.includes(target2));
|
|
18140
|
+
}, "Catalog targets must match the declared APIs");
|
|
18141
|
+
var hostExtensionCatalogSchema = external_exports.object({
|
|
18142
|
+
schemaVersion: external_exports.literal(2),
|
|
18143
|
+
generatedAt: external_exports.string().min(1),
|
|
18144
|
+
extensions: external_exports.array(hostExtensionCatalogEntrySchema).max(1e4).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
|
|
18145
|
+
});
|
|
18146
|
+
var hostExtensionsCatalogResultSchema = hostExtensionCatalogSchema.extend({
|
|
18147
|
+
catalogUrl: desktopExtensionHttpUrlSchema,
|
|
18148
|
+
fetchedAt: external_exports.iso.datetime(),
|
|
18149
|
+
cached: external_exports.boolean()
|
|
18150
|
+
});
|
|
18151
|
+
var id = { id: hostExtensionIdSchema };
|
|
18152
|
+
var active = {
|
|
18153
|
+
...id,
|
|
18154
|
+
activationId: hostExtensionActivationIdSchema,
|
|
18155
|
+
digest: hostExtensionDigestSchema
|
|
18156
|
+
};
|
|
18157
|
+
var optionalActivation = { ...id, activationId: active.activationId.optional() };
|
|
18158
|
+
var filePath = external_exports.string().min(1).max(4096).refine((path22) => /^(?:\/|[a-z]:[/\\])/iu.test(path22) && !path22.includes("\0") && !path22.split(/[/\\]/u).some((part) => part === "." || part === ".."), "Expected an absolute local path without dot segments");
|
|
18159
|
+
var gitRef = external_exports.string().min(1).max(256).refine((ref) => ref.split("/").every((part) => part && /^[a-z0-9_.-]+$/iu.test(part) && part !== "." && part !== ".."), "Invalid GitHub ref");
|
|
18160
|
+
function base643(maxBytes) {
|
|
18161
|
+
return external_exports.string().max(4 * Math.ceil(maxBytes / 3)).refine((value) => {
|
|
18162
|
+
const padding = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0;
|
|
18163
|
+
return value.length % 4 === 0 && value.length * 3 / 4 - padding <= maxBytes && /^[A-Za-z0-9+/]*={0,2}$/u.test(value);
|
|
18164
|
+
}, "Expected bounded standard padded base64");
|
|
18165
|
+
}
|
|
18166
|
+
var hostExtensionGitHubSourceSchema = external_exports.strictObject({
|
|
18167
|
+
type: external_exports.literal("github"),
|
|
18168
|
+
repository: external_exports.string().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),
|
|
18169
|
+
ref: gitRef.optional(),
|
|
18170
|
+
tag: gitRef.optional(),
|
|
18171
|
+
asset: external_exports.string().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),
|
|
18172
|
+
subpath: hostExtensionResourcePathSchema.optional()
|
|
18173
|
+
}).refine(({ ref, tag, asset }) => !ref || !tag && !asset, "Use either a zipball ref or a release tag/asset");
|
|
18174
|
+
var hostExtensionInstallSourceSchema = external_exports.union([
|
|
18175
|
+
external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
|
|
18176
|
+
hostExtensionGitHubSourceSchema,
|
|
18177
|
+
external_exports.strictObject({ type: external_exports.literal("zip"), base64: base643(HOST_EXTENSION_ZIP_MAX_BYTES).min(4) }),
|
|
18178
|
+
external_exports.strictObject({ type: external_exports.literal("zip"), localZipPath: filePath }),
|
|
18179
|
+
external_exports.strictObject({ type: external_exports.literal("localDir"), localDir: filePath })
|
|
18180
|
+
]);
|
|
18181
|
+
var hostExtensionProvenanceSchema = external_exports.discriminatedUnion("type", [
|
|
18182
|
+
external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
|
|
18183
|
+
hostExtensionGitHubSourceSchema,
|
|
18184
|
+
external_exports.strictObject({ type: external_exports.literal("zip") }),
|
|
18185
|
+
external_exports.strictObject({ type: external_exports.literal("localDir") })
|
|
18186
|
+
]);
|
|
18187
|
+
var hostExtensionInstallationSchema = external_exports.strictObject({
|
|
18188
|
+
...active,
|
|
18189
|
+
manifest: hostExtensionManifestV2Schema,
|
|
18190
|
+
installedAt: external_exports.iso.datetime(),
|
|
18191
|
+
source: hostExtensionProvenanceSchema.optional()
|
|
18192
|
+
});
|
|
18193
|
+
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);
|
|
18194
|
+
var desktopConflict = { desktopConflictWith: hostExtensionIdSchema.optional() };
|
|
18195
|
+
var backendState = external_exports.enum(["none", "inactive", "starting", "running", "failed"]);
|
|
18196
|
+
var hostExtensionListItemSchema = external_exports.discriminatedUnion("state", [
|
|
18197
|
+
hostExtensionInstallationSchema.extend({
|
|
18198
|
+
state: external_exports.literal("valid"),
|
|
18199
|
+
enabled: external_exports.boolean(),
|
|
18200
|
+
...desktopConflict,
|
|
18201
|
+
iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
|
|
18202
|
+
screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
18203
|
+
backendState: backendState.optional(),
|
|
18204
|
+
backendError: external_exports.string().optional()
|
|
18205
|
+
}),
|
|
18206
|
+
external_exports.strictObject({
|
|
18207
|
+
state: external_exports.enum(["invalid", "incompatible"]),
|
|
18208
|
+
id: external_exports.string().min(1),
|
|
18209
|
+
enabled: external_exports.boolean(),
|
|
18210
|
+
error: external_exports.string()
|
|
18211
|
+
})
|
|
18212
|
+
]);
|
|
18213
|
+
var hostExtensionsListResultSchema = external_exports.strictObject({
|
|
18214
|
+
revision: hostExtensionRevisionSchema,
|
|
18215
|
+
configuration: hostExtensionConfigurationSchema,
|
|
18216
|
+
diagnostics: external_exports.array(external_exports.string()),
|
|
18217
|
+
extensions: external_exports.array(hostExtensionListItemSchema)
|
|
18218
|
+
});
|
|
18219
|
+
var hostExtensionRuntimeEntrySchema = hostExtensionInstallationSchema.extend({
|
|
18220
|
+
...desktopConflict,
|
|
18221
|
+
settingsRevision: hostExtensionRevisionSchema
|
|
18222
|
+
});
|
|
18223
|
+
var hostExtensionsSnapshotResultSchema = external_exports.strictObject({
|
|
18224
|
+
/** The Host publishes this revision in extensions-changed, independent of enabled.json's revision. */
|
|
18225
|
+
revision: hostExtensionRevisionSchema,
|
|
18226
|
+
// Enabled, valid activations only. A Desktop conflict does not hide other capabilities.
|
|
18227
|
+
extensions: external_exports.array(hostExtensionRuntimeEntrySchema).max(DESKTOP_EXTENSION_LIMIT)
|
|
18228
|
+
});
|
|
18229
|
+
var HOST_EXTENSIONS_RPC = {
|
|
18230
|
+
list: "codexhost/extensions/list",
|
|
18231
|
+
snapshot: "codexhost/extensions/snapshot",
|
|
18232
|
+
catalog: "codexhost/extensions/catalog",
|
|
18233
|
+
install: "codexhost/extensions/install",
|
|
18234
|
+
update: "codexhost/extensions/update",
|
|
18235
|
+
enable: "codexhost/extensions/enable",
|
|
18236
|
+
disable: "codexhost/extensions/disable",
|
|
18237
|
+
uninstall: "codexhost/extensions/uninstall",
|
|
18238
|
+
recover: "codexhost/extensions/recover",
|
|
18239
|
+
asset: "codexhost/extensions/asset",
|
|
18240
|
+
settingsGet: "codexhost/extensions/settings/get",
|
|
18241
|
+
settingsSet: "codexhost/extensions/settings/set",
|
|
18242
|
+
backendInvoke: "codexhost/extensions/backend/invoke"
|
|
18243
|
+
};
|
|
18244
|
+
var HOST_EXTENSION_MANAGEMENT_METHODS = Object.freeze(Object.values(HOST_EXTENSIONS_RPC));
|
|
18245
|
+
var methods = new Set(HOST_EXTENSION_MANAGEMENT_METHODS);
|
|
18246
|
+
var noParams = external_exports.strictObject({});
|
|
18247
|
+
var expectedRevision = { expectedRevision: hostExtensionRevisionSchema };
|
|
18248
|
+
var selection = external_exports.strictObject({ ...id, ...expectedRevision });
|
|
18249
|
+
var installationResult = hostExtensionInstallationSchema.extend({ replaced: external_exports.boolean() });
|
|
18250
|
+
var mutationResult = external_exports.discriminatedUnion("state", [
|
|
18251
|
+
external_exports.strictObject({ state: external_exports.literal("saved"), configuration: hostExtensionConfigurationSchema }),
|
|
18252
|
+
external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: hostExtensionRevisionSchema })
|
|
18253
|
+
]);
|
|
18254
|
+
var hostExtensionsAssetParamsSchema = external_exports.strictObject({
|
|
18255
|
+
...optionalActivation,
|
|
18256
|
+
digest: active.digest.optional(),
|
|
18257
|
+
path: hostExtensionResourcePathSchema
|
|
18258
|
+
});
|
|
18259
|
+
var hostExtensionsAssetResultSchema = external_exports.strictObject({
|
|
18260
|
+
mimeType: external_exports.string().min(1),
|
|
18261
|
+
base64: base643(DESKTOP_EXTENSION_ASSET_MAX_BYTES),
|
|
18262
|
+
digest: active.digest
|
|
18263
|
+
});
|
|
18264
|
+
var hostExtensionSettingsSchema = external_exports.strictObject({
|
|
18265
|
+
settingsRevision: hostExtensionRevisionSchema,
|
|
18266
|
+
values: jsonObjectSchema
|
|
18267
|
+
});
|
|
18268
|
+
var hostExtensionsRpcSchemas = {
|
|
18269
|
+
[HOST_EXTENSIONS_RPC.list]: { params: noParams, result: hostExtensionsListResultSchema },
|
|
18270
|
+
[HOST_EXTENSIONS_RPC.snapshot]: { params: noParams, result: hostExtensionsSnapshotResultSchema },
|
|
18271
|
+
[HOST_EXTENSIONS_RPC.catalog]: {
|
|
18272
|
+
params: external_exports.strictObject({ forceRefresh: external_exports.boolean().optional() }),
|
|
18273
|
+
result: hostExtensionsCatalogResultSchema
|
|
18274
|
+
},
|
|
18275
|
+
[HOST_EXTENSIONS_RPC.install]: {
|
|
18276
|
+
params: external_exports.strictObject({ source: hostExtensionInstallSourceSchema }),
|
|
18277
|
+
result: installationResult
|
|
18278
|
+
},
|
|
18279
|
+
[HOST_EXTENSIONS_RPC.update]: {
|
|
18280
|
+
params: external_exports.strictObject({
|
|
18281
|
+
...id,
|
|
18282
|
+
expectedDigest: active.digest,
|
|
18283
|
+
expectedActivationId: active.activationId.optional(),
|
|
18284
|
+
source: hostExtensionInstallSourceSchema.optional()
|
|
18285
|
+
}),
|
|
18286
|
+
result: installationResult
|
|
18287
|
+
},
|
|
18288
|
+
[HOST_EXTENSIONS_RPC.enable]: { params: selection, result: mutationResult },
|
|
18289
|
+
[HOST_EXTENSIONS_RPC.disable]: { params: selection, result: mutationResult },
|
|
18290
|
+
[HOST_EXTENSIONS_RPC.uninstall]: {
|
|
18291
|
+
params: external_exports.strictObject({
|
|
18292
|
+
...id,
|
|
18293
|
+
removeData: external_exports.boolean().optional(),
|
|
18294
|
+
expectedDigest: active.digest.optional()
|
|
18295
|
+
}),
|
|
18296
|
+
result: external_exports.strictObject({ ...id, removed: external_exports.boolean() })
|
|
18297
|
+
},
|
|
18298
|
+
[HOST_EXTENSIONS_RPC.recover]: {
|
|
18299
|
+
params: external_exports.strictObject({ expectedRevision: expectedRevision.expectedRevision.optional() }),
|
|
18300
|
+
result: mutationResult
|
|
18301
|
+
},
|
|
18302
|
+
[HOST_EXTENSIONS_RPC.asset]: {
|
|
18303
|
+
params: hostExtensionsAssetParamsSchema,
|
|
18304
|
+
result: hostExtensionsAssetResultSchema
|
|
18305
|
+
},
|
|
18306
|
+
[HOST_EXTENSIONS_RPC.settingsGet]: {
|
|
18307
|
+
params: external_exports.strictObject(optionalActivation),
|
|
18308
|
+
result: hostExtensionSettingsSchema
|
|
18309
|
+
},
|
|
18310
|
+
[HOST_EXTENSIONS_RPC.settingsSet]: {
|
|
18311
|
+
params: external_exports.strictObject({
|
|
18312
|
+
...optionalActivation,
|
|
18313
|
+
expectedSettingsRevision: hostExtensionRevisionSchema,
|
|
18314
|
+
values: jsonObjectSchema
|
|
18315
|
+
}),
|
|
18316
|
+
result: hostExtensionSettingsSchema
|
|
18317
|
+
},
|
|
18318
|
+
[HOST_EXTENSIONS_RPC.backendInvoke]: {
|
|
18319
|
+
params: external_exports.strictObject({
|
|
18320
|
+
...optionalActivation,
|
|
18321
|
+
method: hostExtensionBackendMethodSchema,
|
|
18322
|
+
params: jsonValueSchema.optional()
|
|
18323
|
+
}),
|
|
18324
|
+
result: external_exports.strictObject({ result: jsonValueSchema })
|
|
18325
|
+
}
|
|
18326
|
+
};
|
|
18327
|
+
|
|
16073
18328
|
// packages/shared-contracts/dist/thread-archive-confirm.js
|
|
18329
|
+
var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
|
|
16074
18330
|
var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
|
|
16075
18331
|
var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
|
|
16076
18332
|
|
|
16077
18333
|
// packages/shared-contracts/dist/client-channel.js
|
|
16078
18334
|
var CLIENT_CHANNEL_VERSION = 1;
|
|
16079
18335
|
var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
|
|
18336
|
+
var CLIENT_CHANNEL_METHODS = [
|
|
18337
|
+
"codexhost/skills/list",
|
|
18338
|
+
"codexhost/voice/status",
|
|
18339
|
+
"codexhost/voice/transcribe",
|
|
18340
|
+
"codexhost/harness/display-settings/get",
|
|
18341
|
+
"codexhost/harness/display-settings/set",
|
|
18342
|
+
"codexhost/harness/display-settings/capabilities",
|
|
18343
|
+
"codexhost/harness/preferences/get",
|
|
18344
|
+
"codexhost/harness/preferences/patch",
|
|
18345
|
+
"thread/list",
|
|
18346
|
+
"codexhost/thread/catalog/read",
|
|
18347
|
+
"thread/read",
|
|
18348
|
+
"thread/resume",
|
|
18349
|
+
"thread/fork",
|
|
18350
|
+
"thread/turns/list",
|
|
18351
|
+
"thread/revert",
|
|
18352
|
+
"thread/items/list",
|
|
18353
|
+
"thread/start",
|
|
18354
|
+
"thread/name/set",
|
|
18355
|
+
"codexhost/thread/title/generate",
|
|
18356
|
+
"thread/archive",
|
|
18357
|
+
THREAD_ARCHIVE_CONFIRM_METHOD,
|
|
18358
|
+
"thread/unarchive",
|
|
18359
|
+
"turn/start",
|
|
18360
|
+
"turn/interrupt",
|
|
18361
|
+
"turn/steer",
|
|
18362
|
+
"thread/queue/list",
|
|
18363
|
+
"thread/queue/add",
|
|
18364
|
+
"thread/queue/update",
|
|
18365
|
+
"thread/queue/delete",
|
|
18366
|
+
"thread/queue/reorder",
|
|
18367
|
+
"thread/queue/start",
|
|
18368
|
+
"codexhost/thread/queue/send-now",
|
|
18369
|
+
"codexhost/workspace/read",
|
|
18370
|
+
"codexhost/thread/tree/read",
|
|
18371
|
+
"codexhost/thread/pins/list",
|
|
18372
|
+
"codexhost/thread/pins/set",
|
|
18373
|
+
"codexhost/harness/plugins/list",
|
|
18374
|
+
"codexhost/harness/inspect",
|
|
18375
|
+
"codexhost/thread/inspect",
|
|
18376
|
+
"codexhost/thread/usage/inspect",
|
|
18377
|
+
"codexhost/thread/ownership/list",
|
|
18378
|
+
"codexhost/thread/model/select",
|
|
18379
|
+
"codexhost/thread/thinking/select",
|
|
18380
|
+
"codexhost/thread/permission-mode/select",
|
|
18381
|
+
"codexhost/thread/commands/inspect",
|
|
18382
|
+
"codexhost/harness/commands/inspect",
|
|
18383
|
+
"codexhost/thread/command/execute",
|
|
18384
|
+
"codexhost/thread/fork",
|
|
18385
|
+
"codexhost/harness/session-import/sources",
|
|
18386
|
+
"codexhost/harness/session-import/list",
|
|
18387
|
+
"codexhost/harness/session-import/import",
|
|
18388
|
+
// Host settings shared across Desktop and Web.
|
|
18389
|
+
...HOST_EXTENSION_MANAGEMENT_METHODS,
|
|
18390
|
+
"codexhost/harness/installation",
|
|
18391
|
+
"codexhost/harness/installation/start",
|
|
18392
|
+
"codexhost/harness/installation/status",
|
|
18393
|
+
"codexhost/harness/launch-settings/get",
|
|
18394
|
+
"codexhost/harness/launch-settings/set",
|
|
18395
|
+
"codexhost/harness/web-ui/open",
|
|
18396
|
+
"codexhost/harness/accounts/sources",
|
|
18397
|
+
"codexhost/harness/accounts/list",
|
|
18398
|
+
"codexhost/harness/accounts/inspect",
|
|
18399
|
+
"codexhost/harness/credential-imports",
|
|
18400
|
+
"codexhost/account/list",
|
|
18401
|
+
"codexhost/account/refresh",
|
|
18402
|
+
"codexhost/account/usage/inspect",
|
|
18403
|
+
"codexhost/usage/model-prices/get",
|
|
18404
|
+
"codexhost/usage/model-prices/set",
|
|
18405
|
+
"codexhost/usage/model-prices/default",
|
|
18406
|
+
"codexhost/usage/statistics/get",
|
|
18407
|
+
"codexhost/update/check",
|
|
18408
|
+
"codexhost/update/start",
|
|
18409
|
+
"codexhost/update/status",
|
|
18410
|
+
"codexhost/sessions/loaded/list"
|
|
18411
|
+
];
|
|
16080
18412
|
var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
|
|
16081
18413
|
var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
|
|
16082
18414
|
var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
|
|
@@ -16115,6 +18447,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
|
|
|
16115
18447
|
cursor: clientChannelCursorSchema,
|
|
16116
18448
|
revision: external_exports.number().int().nonnegative()
|
|
16117
18449
|
}),
|
|
18450
|
+
external_exports.object({
|
|
18451
|
+
type: external_exports.literal("extensions-changed"),
|
|
18452
|
+
cursor: clientChannelCursorSchema,
|
|
18453
|
+
revision: hostExtensionRevisionSchema
|
|
18454
|
+
}),
|
|
16118
18455
|
external_exports.object({
|
|
16119
18456
|
type: external_exports.literal("hello"),
|
|
16120
18457
|
version: external_exports.literal(1),
|
|
@@ -16290,6 +18627,29 @@ var threadCatalogReadResultSchema = external_exports.object({
|
|
|
16290
18627
|
officialCursor: external_exports.object({ live: external_exports.string().nullable(), archived: external_exports.string().nullable().optional() }).strict().optional()
|
|
16291
18628
|
}).strict();
|
|
16292
18629
|
|
|
18630
|
+
// packages/shared-contracts/dist/thread-tree-watch.js
|
|
18631
|
+
var THREAD_TREE_MAX_NODES = 5e3;
|
|
18632
|
+
var threadTreeStatusSchema = external_exports.enum(["running", "waiting", "idle", "unknown"]);
|
|
18633
|
+
var threadTreeNodeSchema = external_exports.strictObject({
|
|
18634
|
+
harnessId: harnessIdSchema,
|
|
18635
|
+
title: external_exports.string().optional(),
|
|
18636
|
+
status: threadTreeStatusSchema,
|
|
18637
|
+
archived: external_exports.boolean()
|
|
18638
|
+
});
|
|
18639
|
+
var threadTreeSnapshotSchema = external_exports.strictObject({
|
|
18640
|
+
revision: external_exports.int().nonnegative(),
|
|
18641
|
+
parents: external_exports.record(hostThreadIdSchema, hostThreadIdSchema),
|
|
18642
|
+
nodes: external_exports.record(hostThreadIdSchema, threadTreeNodeSchema),
|
|
18643
|
+
truncated: external_exports.boolean()
|
|
18644
|
+
}).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");
|
|
18645
|
+
var subscriptionId = external_exports.string().min(1).max(128);
|
|
18646
|
+
var threadTreeWatchParamsSchema = external_exports.strictObject({});
|
|
18647
|
+
var threadTreeUnwatchParamsSchema = external_exports.strictObject({ subscriptionId });
|
|
18648
|
+
var threadTreeUnwatchResultSchema = external_exports.strictObject({});
|
|
18649
|
+
var threadTreeWatchResultSchema = threadTreeUnwatchParamsSchema.extend({
|
|
18650
|
+
snapshot: threadTreeSnapshotSchema
|
|
18651
|
+
});
|
|
18652
|
+
|
|
16293
18653
|
// packages/shared-contracts/dist/voice.js
|
|
16294
18654
|
var VOICE_AUDIO_MAX_BYTES = 10 * 1024 * 1024;
|
|
16295
18655
|
var voiceAudioMimeTypeSchema = external_exports.string().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);
|
|
@@ -16528,7 +18888,7 @@ var DEFAULT_IDLE_RELEASE_SETTINGS = Object.freeze({
|
|
|
16528
18888
|
|
|
16529
18889
|
// packages/shared-contracts/dist/harness-preferences.js
|
|
16530
18890
|
var harnessPreferenceScopeSchema = external_exports.string().regex(/^external$/u);
|
|
16531
|
-
var preferenceHarnessKey = harnessIdSchema.transform((
|
|
18891
|
+
var preferenceHarnessKey = harnessIdSchema.transform((id2) => String(id2));
|
|
16532
18892
|
var harnessDefaultConfigurationSchema = external_exports.strictObject({
|
|
16533
18893
|
model: harnessModelRefSchema.optional(),
|
|
16534
18894
|
thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
@@ -16538,11 +18898,19 @@ var newThreadDefaultsSchema = external_exports.strictObject({
|
|
|
16538
18898
|
lastHarness: harnessIdSchema.optional(),
|
|
16539
18899
|
byHarness: external_exports.record(preferenceHarnessKey, harnessDefaultConfigurationSchema)
|
|
16540
18900
|
});
|
|
18901
|
+
var harnessDelegationDefaultSchema = external_exports.strictObject({
|
|
18902
|
+
model: harnessModelRefSchema.optional(),
|
|
18903
|
+
thinkingOptionId: harnessThinkingOptionIdSchema.optional()
|
|
18904
|
+
}).refine((value) => Boolean(value.model || value.thinkingOptionId), "A delegation default must contain a Model or Thinking option");
|
|
18905
|
+
var delegationDefaultsSchema = external_exports.strictObject({
|
|
18906
|
+
byHarness: external_exports.record(preferenceHarnessKey, harnessDelegationDefaultSchema)
|
|
18907
|
+
});
|
|
16541
18908
|
var modelId = external_exports.string().min(1).max(1024);
|
|
16542
18909
|
var harnessPreferenceValuesSchema = external_exports.strictObject({
|
|
16543
18910
|
idleRelease: idleReleaseSettingsSchema.optional(),
|
|
16544
18911
|
favorites: external_exports.record(preferenceHarnessKey, external_exports.array(modelId).max(2048)).default({}),
|
|
16545
|
-
newThread: newThreadDefaultsSchema.optional()
|
|
18912
|
+
newThread: newThreadDefaultsSchema.optional(),
|
|
18913
|
+
delegation: delegationDefaultsSchema.optional()
|
|
16546
18914
|
});
|
|
16547
18915
|
var harnessPreferenceSnapshotSchema = external_exports.strictObject({
|
|
16548
18916
|
scope: harnessPreferenceScopeSchema,
|
|
@@ -16570,6 +18938,11 @@ var harnessPreferenceOperationSchema = external_exports.discriminatedUnion("kind
|
|
|
16570
18938
|
lastHarness: harnessIdSchema.optional(),
|
|
16571
18939
|
harnessId: harnessIdSchema.optional(),
|
|
16572
18940
|
configuration: harnessDefaultConfigurationSchema.optional()
|
|
18941
|
+
}),
|
|
18942
|
+
external_exports.strictObject({
|
|
18943
|
+
kind: external_exports.literal("delegation"),
|
|
18944
|
+
harnessId: harnessIdSchema,
|
|
18945
|
+
configuration: harnessDelegationDefaultSchema.nullable()
|
|
16573
18946
|
})
|
|
16574
18947
|
]);
|
|
16575
18948
|
var harnessPreferencePatchSchema = external_exports.strictObject({
|
|
@@ -16923,13 +19296,6 @@ var threadManualCompactionStartedSchema = external_exports.strictObject({
|
|
|
16923
19296
|
});
|
|
16924
19297
|
|
|
16925
19298
|
// packages/shared-contracts/dist/harness-accounts.js
|
|
16926
|
-
var accountBalanceSnapshotSchema = external_exports.object({
|
|
16927
|
-
amount: external_exports.number().finite().nonnegative(),
|
|
16928
|
-
/** ISO 4217 code as reported by the Provider, for example `CNY`. */
|
|
16929
|
-
currency: external_exports.string().trim().min(1).max(8),
|
|
16930
|
-
/** Native label when the Harness exposes several Billing Sources. */
|
|
16931
|
-
label: external_exports.string().trim().min(1).max(128).optional()
|
|
16932
|
-
}).strict();
|
|
16933
19299
|
var harnessAccountSnapshotObject = external_exports.object({
|
|
16934
19300
|
email: external_exports.string().trim().min(1).max(320).optional(),
|
|
16935
19301
|
label: external_exports.string().trim().min(1).max(256).optional(),
|
|
@@ -16963,76 +19329,6 @@ var harnessAccountListResultSchema = external_exports.object({
|
|
|
16963
19329
|
accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
|
|
16964
19330
|
}).strict();
|
|
16965
19331
|
|
|
16966
|
-
// packages/shared-contracts/dist/harness-plugins.js
|
|
16967
|
-
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
16968
|
-
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
16969
|
-
var HARNESS_PLUGIN_LIMIT = 128;
|
|
16970
|
-
var installedHarnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).pipe(harnessIdSchema);
|
|
16971
|
-
var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id) => id !== "codex", "The official Codex identity is reserved");
|
|
16972
|
-
var relativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
|
|
16973
|
-
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
16974
|
-
var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
|
|
16975
|
-
var harnessInstallationGuideSchema = external_exports.object({
|
|
16976
|
-
commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
|
|
16977
|
-
before: localizedTextSchema.optional(),
|
|
16978
|
-
after: localizedTextSchema.optional(),
|
|
16979
|
-
downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
|
|
16980
|
-
}).strict();
|
|
16981
|
-
var pluginPresentationShape = {
|
|
16982
|
-
id: installedHarnessPluginIdSchema,
|
|
16983
|
-
name: external_exports.string().trim().min(1).max(128),
|
|
16984
|
-
version: external_exports.string().min(1).max(128),
|
|
16985
|
-
/** Capability-only plugin; omitted for existing session-capable plugins. */
|
|
16986
|
-
kind: external_exports.literal("usage").optional(),
|
|
16987
|
-
/** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
|
|
16988
|
-
iconStyle: external_exports.object({
|
|
16989
|
-
vector: external_exports.object({
|
|
16990
|
-
viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
|
|
16991
|
-
color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
|
|
16992
|
-
paths: external_exports.array(external_exports.object({
|
|
16993
|
-
d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
|
|
16994
|
-
fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
|
|
16995
|
-
fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
|
|
16996
|
-
}).strict()).min(1).max(32)
|
|
16997
|
-
}).strict().optional(),
|
|
16998
|
-
background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
|
|
16999
|
-
borderRadius: external_exports.number().min(0).max(50).optional(),
|
|
17000
|
-
paddingRatio: external_exports.number().min(0).max(0.25).optional()
|
|
17001
|
-
}).strict().optional(),
|
|
17002
|
-
installation: harnessInstallationGuideSchema.optional(),
|
|
17003
|
-
notice: localizedTextSchema.optional(),
|
|
17004
|
-
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
17005
|
-
launchCommand: external_exports.literal(true).optional(),
|
|
17006
|
-
links: external_exports.object({
|
|
17007
|
-
website: documentationUrlSchema.optional(),
|
|
17008
|
-
documentation: documentationUrlSchema.optional(),
|
|
17009
|
-
installation: documentationUrlSchema.optional()
|
|
17010
|
-
}).strict().optional()
|
|
17011
|
-
};
|
|
17012
|
-
var harnessPluginManifestSchema = external_exports.object({
|
|
17013
|
-
manifestVersion: external_exports.literal(1),
|
|
17014
|
-
...pluginPresentationShape,
|
|
17015
|
-
adapterApiVersion: external_exports.number().int().positive(),
|
|
17016
|
-
entry: relativeResourceSchema,
|
|
17017
|
-
icon: relativeResourceSchema.optional()
|
|
17018
|
-
}).strict();
|
|
17019
|
-
var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
|
|
17020
|
-
var harnessPluginDescriptorSchema = external_exports.object({
|
|
17021
|
-
...pluginPresentationShape,
|
|
17022
|
-
icon: harnessPluginIconSchema.optional()
|
|
17023
|
-
}).strict();
|
|
17024
|
-
var harnessPluginListParamsSchema = external_exports.object({}).strict();
|
|
17025
|
-
var harnessPluginListResultSchema = external_exports.object({
|
|
17026
|
-
plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
|
|
17027
|
-
}).strict();
|
|
17028
|
-
var harnessPluginConfigurationSchema = external_exports.object({
|
|
17029
|
-
version: external_exports.literal(1),
|
|
17030
|
-
enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
17031
|
-
}).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
|
|
17032
|
-
message: "Enabled plugin IDs must be unique",
|
|
17033
|
-
path: ["enabled"]
|
|
17034
|
-
});
|
|
17035
|
-
|
|
17036
19332
|
// packages/shared-contracts/dist/harness-route.js
|
|
17037
19333
|
var harnessPluginRouteSchema = external_exports.object({
|
|
17038
19334
|
harnessId: harnessPluginIdSchema,
|
|
@@ -17478,9 +19774,12 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
|
17478
19774
|
...thread,
|
|
17479
19775
|
epoch: identity,
|
|
17480
19776
|
modelId: identity.optional(),
|
|
19777
|
+
serviceTier: harnessModelServiceTierSchema.optional(),
|
|
17481
19778
|
thinkingOptionId: identity.optional(),
|
|
17482
19779
|
permissionModeId: identity.optional()
|
|
17483
|
-
}).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting"),
|
|
19780
|
+
}).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting").refine((value) => value.serviceTier === void 0 || value.modelId !== void 0, {
|
|
19781
|
+
message: "A service tier requires a Model ID"
|
|
19782
|
+
}),
|
|
17484
19783
|
external_exports.strictObject({
|
|
17485
19784
|
kind: external_exports.literal("prompt"),
|
|
17486
19785
|
...thread,
|
|
@@ -17530,7 +19829,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
|
|
|
17530
19829
|
external_exports.strictObject({ action: external_exports.literal("catalog") }),
|
|
17531
19830
|
external_exports.strictObject({
|
|
17532
19831
|
action: external_exports.literal("read-thread"),
|
|
17533
|
-
hostId: hostId.refine((
|
|
19832
|
+
hostId: hostId.refine((id2) => id2 !== "local"),
|
|
17534
19833
|
input: delegationReadParamsSchema
|
|
17535
19834
|
}),
|
|
17536
19835
|
external_exports.strictObject({
|
|
@@ -17544,7 +19843,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
|
|
|
17544
19843
|
external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
|
|
17545
19844
|
external_exports.strictObject({
|
|
17546
19845
|
action: external_exports.literal("update"),
|
|
17547
|
-
hostId: hostId.refine((
|
|
19846
|
+
hostId: hostId.refine((id2) => id2 !== "local"),
|
|
17548
19847
|
version: remoteUpdateParamsSchema.shape.version
|
|
17549
19848
|
})
|
|
17550
19849
|
]);
|
|
@@ -17701,8 +20000,8 @@ async function discoverHarnessPlugins(configuredRoots, diagnose = () => void 0,
|
|
|
17701
20000
|
diagnose("invalidConfiguration");
|
|
17702
20001
|
continue;
|
|
17703
20002
|
}
|
|
17704
|
-
for (const
|
|
17705
|
-
enabledIds.add(
|
|
20003
|
+
for (const id2 of enabled)
|
|
20004
|
+
enabledIds.add(id2);
|
|
17706
20005
|
try {
|
|
17707
20006
|
const directories = (await readdir2(root, { withFileTypes: true })).filter((entry) => entry.isDirectory() || entry.isSymbolicLink()).sort((a, b) => a.name.localeCompare(b.name));
|
|
17708
20007
|
if (directories.length > HARNESS_PLUGIN_LIMIT) {
|
|
@@ -17738,11 +20037,11 @@ var HarnessLaunchSettingsStore = class {
|
|
|
17738
20037
|
constructor(environment) {
|
|
17739
20038
|
this.#directory = path8.join(environment.CODEXHOST_DATA_DIR ? path8.resolve(environment.CODEXHOST_DATA_DIR) : path8.join(os.homedir(), ".codexhost"), "harness-launch-settings");
|
|
17740
20039
|
}
|
|
17741
|
-
#file(
|
|
17742
|
-
return path8.join(this.#directory, `${harnessPluginIdSchema.parse(
|
|
20040
|
+
#file(id2) {
|
|
20041
|
+
return path8.join(this.#directory, `${harnessPluginIdSchema.parse(id2)}.json`);
|
|
17743
20042
|
}
|
|
17744
|
-
async #read(
|
|
17745
|
-
const file2 = this.#file(
|
|
20043
|
+
async #read(id2) {
|
|
20044
|
+
const file2 = this.#file(id2);
|
|
17746
20045
|
let text;
|
|
17747
20046
|
try {
|
|
17748
20047
|
text = await readFile4(file2, "utf8");
|
|
@@ -17761,11 +20060,11 @@ var HarnessLaunchSettingsStore = class {
|
|
|
17761
20060
|
}
|
|
17762
20061
|
return parsed;
|
|
17763
20062
|
}
|
|
17764
|
-
#snapshot(
|
|
17765
|
-
let initial = this.#initial.get(
|
|
20063
|
+
#snapshot(id2) {
|
|
20064
|
+
let initial = this.#initial.get(id2);
|
|
17766
20065
|
if (!initial) {
|
|
17767
|
-
initial = this.#read(
|
|
17768
|
-
this.#initial.set(
|
|
20066
|
+
initial = this.#read(id2).then((value) => ({ path: value }), (error51) => ({ error: error51 instanceof Error ? error51 : new Error(String(error51)) }));
|
|
20067
|
+
this.#initial.set(id2, initial);
|
|
17769
20068
|
}
|
|
17770
20069
|
return initial;
|
|
17771
20070
|
}
|
|
@@ -17773,11 +20072,11 @@ var HarnessLaunchSettingsStore = class {
|
|
|
17773
20072
|
* Capture the value used to construct this Host's Adapter; changes require a restart. A failed
|
|
17774
20073
|
* read is remembered for restart reporting but not reused: the next call reads the file again.
|
|
17775
20074
|
*/
|
|
17776
|
-
async initialCommand(
|
|
17777
|
-
const cached2 = this.#initial.get(
|
|
20075
|
+
async initialCommand(id2) {
|
|
20076
|
+
const cached2 = this.#initial.get(id2);
|
|
17778
20077
|
if (cached2 && "error" in await cached2)
|
|
17779
|
-
this.#initial.delete(
|
|
17780
|
-
const snapshot = await this.#snapshot(
|
|
20078
|
+
this.#initial.delete(id2);
|
|
20079
|
+
const snapshot = await this.#snapshot(id2);
|
|
17781
20080
|
if ("error" in snapshot)
|
|
17782
20081
|
throw snapshot.error;
|
|
17783
20082
|
return snapshot.path ?? void 0;
|
|
@@ -17786,15 +20085,15 @@ var HarnessLaunchSettingsStore = class {
|
|
|
17786
20085
|
#restartRequired(snapshot, value) {
|
|
17787
20086
|
return "error" in snapshot || value !== snapshot.path;
|
|
17788
20087
|
}
|
|
17789
|
-
async get(
|
|
17790
|
-
const snapshot = await this.#snapshot(
|
|
17791
|
-
const value = await this.#read(
|
|
20088
|
+
async get(id2) {
|
|
20089
|
+
const snapshot = await this.#snapshot(id2);
|
|
20090
|
+
const value = await this.#read(id2);
|
|
17792
20091
|
return { path: value, restartRequired: this.#restartRequired(snapshot, value) };
|
|
17793
20092
|
}
|
|
17794
20093
|
/** Replaces the file without reading it, so an unreadable file can always be repaired. */
|
|
17795
|
-
async set(
|
|
17796
|
-
const snapshot = await this.#snapshot(
|
|
17797
|
-
const file2 = this.#file(
|
|
20094
|
+
async set(id2, value) {
|
|
20095
|
+
const snapshot = await this.#snapshot(id2);
|
|
20096
|
+
const file2 = this.#file(id2);
|
|
17798
20097
|
if (value === null) {
|
|
17799
20098
|
await rm3(file2, { force: true });
|
|
17800
20099
|
} else {
|
|
@@ -17818,23 +20117,467 @@ var HarnessLaunchSettingsStore = class {
|
|
|
17818
20117
|
}
|
|
17819
20118
|
};
|
|
17820
20119
|
|
|
20120
|
+
// packages/harness-plugin-files/dist/host-extension-io.js
|
|
20121
|
+
import { constants } from "node:fs";
|
|
20122
|
+
import { lstat as lstat4, mkdir as mkdir4, open as open4, realpath as realpath3, rename as rename4, rm as rm4, writeFile as writeFile4 } from "node:fs/promises";
|
|
20123
|
+
import path9 from "node:path";
|
|
20124
|
+
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
20125
|
+
function extensionFileMissing(error51) {
|
|
20126
|
+
return error51 instanceof Error && "code" in error51 && error51.code === "ENOENT";
|
|
20127
|
+
}
|
|
20128
|
+
function assertPrivateExtensionEntry(file2, info, directory) {
|
|
20129
|
+
if (directory ? !info.isDirectory() : !info.isFile())
|
|
20130
|
+
throw new Error(`${path9.basename(file2)} must be a regular ${directory ? "directory" : "file"}`);
|
|
20131
|
+
if (!privateMode(info))
|
|
20132
|
+
throw new Error(`${path9.basename(file2)} must belong to the current user and not permit group/other writes`);
|
|
20133
|
+
}
|
|
20134
|
+
async function privateExtensionDirectory(directory) {
|
|
20135
|
+
assertPrivateExtensionEntry(directory, await lstat4(directory), true);
|
|
20136
|
+
return realpath3(directory);
|
|
20137
|
+
}
|
|
20138
|
+
var hostExtensionsRoot = (dataDir) => path9.join(dataDir, "host-extensions");
|
|
20139
|
+
var utf8 = new TextDecoder("utf-8", { fatal: true });
|
|
20140
|
+
var errorMessage2 = (error51) => error51 instanceof Error ? error51.message : String(error51);
|
|
20141
|
+
async function ifMissing(operation) {
|
|
20142
|
+
try {
|
|
20143
|
+
return await operation();
|
|
20144
|
+
} catch (error51) {
|
|
20145
|
+
if (!extensionFileMissing(error51))
|
|
20146
|
+
throw error51;
|
|
20147
|
+
return void 0;
|
|
20148
|
+
}
|
|
20149
|
+
}
|
|
20150
|
+
async function storeRoot(root, create) {
|
|
20151
|
+
if (create)
|
|
20152
|
+
await mkdir4(root, { recursive: true, mode: 448 });
|
|
20153
|
+
return privateExtensionDirectory(root);
|
|
20154
|
+
}
|
|
20155
|
+
async function storeChild(root, name, create = false) {
|
|
20156
|
+
const directory = path9.join(root, name);
|
|
20157
|
+
if (create)
|
|
20158
|
+
await mkdir4(directory, { mode: 448 }).catch((error51) => {
|
|
20159
|
+
if (error51.code !== "EEXIST")
|
|
20160
|
+
throw error51;
|
|
20161
|
+
});
|
|
20162
|
+
return privateExtensionDirectory(directory);
|
|
20163
|
+
}
|
|
20164
|
+
async function readHostFile(root, relative, max, owned = true) {
|
|
20165
|
+
const parts = hostExtensionResourcePathSchema.parse(relative).split("/");
|
|
20166
|
+
const leaf = parts.pop();
|
|
20167
|
+
if (!leaf)
|
|
20168
|
+
throw new Error(`No file name for ${relative}`);
|
|
20169
|
+
let directory = root;
|
|
20170
|
+
for (const part of parts) {
|
|
20171
|
+
directory = path9.join(directory, part);
|
|
20172
|
+
const info2 = await lstat4(directory);
|
|
20173
|
+
if (!info2.isDirectory() || owned && !privateMode(info2))
|
|
20174
|
+
throw new Error(`Unsafe directory for ${relative}`);
|
|
20175
|
+
}
|
|
20176
|
+
const target2 = path9.join(directory, leaf);
|
|
20177
|
+
const info = await lstat4(target2);
|
|
20178
|
+
if (!info.isFile() || info.nlink !== 1 || owned && !privateMode(info))
|
|
20179
|
+
throw new Error(`Unsafe file: ${relative}`);
|
|
20180
|
+
const handle = await open4(target2, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
|
|
20181
|
+
try {
|
|
20182
|
+
const opened = await handle.stat();
|
|
20183
|
+
if (!opened.isFile() || opened.dev !== info.dev || opened.ino !== info.ino || opened.nlink !== 1 || owned && !privateMode(opened))
|
|
20184
|
+
throw new Error(`File changed while opening: ${relative}`);
|
|
20185
|
+
if (opened.size > max)
|
|
20186
|
+
throw new Error(`File exceeds its size limit: ${relative}`);
|
|
20187
|
+
const buffer = Buffer.allocUnsafe(opened.size + 1);
|
|
20188
|
+
let offset = 0;
|
|
20189
|
+
while (offset < buffer.length) {
|
|
20190
|
+
const { bytesRead } = await handle.read(buffer, offset, buffer.length - offset, offset);
|
|
20191
|
+
if (!bytesRead)
|
|
20192
|
+
break;
|
|
20193
|
+
offset += bytesRead;
|
|
20194
|
+
}
|
|
20195
|
+
if (offset !== opened.size)
|
|
20196
|
+
throw new Error(`File changed while reading: ${relative}`);
|
|
20197
|
+
return buffer.subarray(0, offset);
|
|
20198
|
+
} finally {
|
|
20199
|
+
await handle.close();
|
|
20200
|
+
}
|
|
20201
|
+
}
|
|
20202
|
+
function privateMode({ uid, mode }) {
|
|
20203
|
+
return !process.getuid || uid === process.getuid() && (mode & 18) === 0;
|
|
20204
|
+
}
|
|
20205
|
+
|
|
20206
|
+
// packages/harness-plugin-files/dist/desktop-extension-artwork.js
|
|
20207
|
+
var pngSignature = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
|
|
20208
|
+
var jpegSignature = Buffer.from([255, 216, 255]);
|
|
20209
|
+
var riffSignature = Buffer.from("RIFF");
|
|
20210
|
+
var webpSignature = Buffer.from("WEBP");
|
|
20211
|
+
|
|
20212
|
+
// packages/harness-plugin-files/dist/host-extension-files.js
|
|
20213
|
+
import { mkdir as mkdir5, mkdtemp, readdir as readdir3, rename as rename5, rm as rm5, writeFile as writeFile5 } from "node:fs/promises";
|
|
20214
|
+
|
|
20215
|
+
// packages/harness-plugin-files/dist/host-extension-package.js
|
|
20216
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
20217
|
+
import path10 from "node:path";
|
|
20218
|
+
var PACKAGE_INDEX = ".host-extension-generation.json";
|
|
20219
|
+
var MAX_INDEX_BYTES = 8 * 1024 * 1024;
|
|
20220
|
+
var MAX_PACKAGE_BYTES = 256 * 1024 * 1024;
|
|
20221
|
+
var MAX_ENTRIES = 1e4;
|
|
20222
|
+
var sha256 = (bytes) => createHash2("sha256").update(bytes).digest("hex");
|
|
20223
|
+
var allowedSuffix = /\.(?:js|mjs|cjs|css|json|png|jpe?g|webp|gif|woff2|md|txt|svg|ts|tsx|ya?ml)$/iu;
|
|
20224
|
+
function packageLimit(resource) {
|
|
20225
|
+
if (hostExtensionCanonicalPath(resource) === PACKAGE_INDEX || !(allowedSuffix.test(resource) || /^(?:licen[cs]e|notice|\.gitignore|\.gitattributes)$/iu.test(path10.posix.basename(resource))))
|
|
20226
|
+
throw new Error(`Unsupported extension package file: ${resource}`);
|
|
20227
|
+
if (resource === "manifest.json")
|
|
20228
|
+
return DESKTOP_EXTENSION_MANIFEST_MAX_BYTES;
|
|
20229
|
+
if (/\.[cm]?js$/iu.test(resource))
|
|
20230
|
+
return DESKTOP_EXTENSION_SCRIPT_MAX_BYTES;
|
|
20231
|
+
if (/\.css$/iu.test(resource))
|
|
20232
|
+
return DESKTOP_EXTENSION_STYLE_MAX_BYTES;
|
|
20233
|
+
return DESKTOP_EXTENSION_ASSET_MAX_BYTES;
|
|
20234
|
+
}
|
|
20235
|
+
async function readHostPackageIndex(directory, digest) {
|
|
20236
|
+
const bytes = await readHostFile(directory, PACKAGE_INDEX, MAX_INDEX_BYTES);
|
|
20237
|
+
if (sha256(bytes) !== digest)
|
|
20238
|
+
throw new Error("Extension package index digest mismatch");
|
|
20239
|
+
const entries = JSON.parse(utf8.decode(bytes));
|
|
20240
|
+
if (!Array.isArray(entries) || entries.length > MAX_ENTRIES)
|
|
20241
|
+
throw new Error("Invalid extension package index");
|
|
20242
|
+
const index = /* @__PURE__ */ new Map();
|
|
20243
|
+
for (const row of entries) {
|
|
20244
|
+
if (!Array.isArray(row) || row.length !== 2)
|
|
20245
|
+
throw new Error("Invalid extension package index entry");
|
|
20246
|
+
const resource = hostExtensionResourcePathSchema.parse(row[0]);
|
|
20247
|
+
packageLimit(resource);
|
|
20248
|
+
if (index.has(resource))
|
|
20249
|
+
throw new Error("Duplicate extension package index entry");
|
|
20250
|
+
index.set(resource, hostExtensionDigestSchema.parse(row[1]));
|
|
20251
|
+
}
|
|
20252
|
+
return index;
|
|
20253
|
+
}
|
|
20254
|
+
function indexedRead(directory, index) {
|
|
20255
|
+
return async (resource, limit) => {
|
|
20256
|
+
const hash2 = index.get(resource);
|
|
20257
|
+
if (!hash2)
|
|
20258
|
+
throw new Error(`File is missing from the package index: ${resource}`);
|
|
20259
|
+
const bytes = await readHostFile(directory, resource, limit);
|
|
20260
|
+
if (sha256(bytes) !== hash2)
|
|
20261
|
+
throw new Error(`Extension file digest mismatch: ${resource}`);
|
|
20262
|
+
return bytes;
|
|
20263
|
+
};
|
|
20264
|
+
}
|
|
20265
|
+
var InvalidHostExtensionManifest = class extends Error {
|
|
20266
|
+
state;
|
|
20267
|
+
constructor(state, message) {
|
|
20268
|
+
super(message);
|
|
20269
|
+
this.state = state;
|
|
20270
|
+
}
|
|
20271
|
+
};
|
|
20272
|
+
async function readHostManifest(read) {
|
|
20273
|
+
const result = parseHostExtensionManifest(JSON.parse(utf8.decode(await read("manifest.json", DESKTOP_EXTENSION_MANIFEST_MAX_BYTES))));
|
|
20274
|
+
if (result.state !== "valid")
|
|
20275
|
+
throw new InvalidHostExtensionManifest(result.state, result.error);
|
|
20276
|
+
return result.manifest;
|
|
20277
|
+
}
|
|
20278
|
+
function hostFrontendEntries({ page, widget, desktop, web }) {
|
|
20279
|
+
return [page?.entry, widget?.entry, desktop?.script, web?.entry];
|
|
20280
|
+
}
|
|
20281
|
+
function hostFrontendStyles({ page, widget, desktop, web }) {
|
|
20282
|
+
return [page?.style, widget?.style, desktop?.style, web?.style];
|
|
20283
|
+
}
|
|
20284
|
+
async function image(read, resource, limit) {
|
|
20285
|
+
const bytes = await read(resource, limit);
|
|
20286
|
+
const mime = desktopExtensionScreenshotMimeType(resource);
|
|
20287
|
+
const valid = mime === "image/png" ? bytes.subarray(0, 8).equals(Buffer.from("89504e470d0a1a0a", "hex")) : mime === "image/jpeg" ? bytes.subarray(0, 3).equals(Buffer.from("ffd8ff", "hex")) : mime === "image/webp" && bytes.toString("ascii", 0, 4) === "RIFF" && bytes.toString("ascii", 8, 12) === "WEBP";
|
|
20288
|
+
if (!valid)
|
|
20289
|
+
throw new Error(`Invalid image signature: ${resource}`);
|
|
20290
|
+
return { bytes, mime };
|
|
20291
|
+
}
|
|
20292
|
+
async function validateHostPackageEntries(manifest, read) {
|
|
20293
|
+
for (const script of [...hostFrontendEntries(manifest), manifest.backend?.entry])
|
|
20294
|
+
if (script)
|
|
20295
|
+
utf8.decode(await read(script, DESKTOP_EXTENSION_SCRIPT_MAX_BYTES));
|
|
20296
|
+
for (const style2 of hostFrontendStyles(manifest))
|
|
20297
|
+
if (style2)
|
|
20298
|
+
utf8.decode(await read(style2, DESKTOP_EXTENSION_STYLE_MAX_BYTES));
|
|
20299
|
+
const icon = manifest.icon && await image(read, manifest.icon, DESKTOP_EXTENSION_ICON_MAX_BYTES);
|
|
20300
|
+
const screenshots = [];
|
|
20301
|
+
for (const resource of manifest.screenshots ?? [])
|
|
20302
|
+
screenshots.push(await image(read, resource, DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES));
|
|
20303
|
+
return { icon, screenshots };
|
|
20304
|
+
}
|
|
20305
|
+
|
|
20306
|
+
// packages/harness-plugin-files/dist/host-extension-files.js
|
|
20307
|
+
var ACTIVE = "active.json";
|
|
20308
|
+
var ENABLED = "enabled.json";
|
|
20309
|
+
var activeFields = hostExtensionInstallationSchema.omit({ manifest: true, id: true });
|
|
20310
|
+
var activeSchema = activeFields.extend({ generation: hostExtensionActivationIdSchema });
|
|
20311
|
+
function hostExtensionInstallationMetadata({ id: id2, activationId, digest, manifest, installedAt, source }) {
|
|
20312
|
+
return { id: id2, activationId, digest, manifest, installedAt, ...source ? { source } : {} };
|
|
20313
|
+
}
|
|
20314
|
+
var readPointer = (directory) => ifMissing(async () => activeSchema.parse(JSON.parse(utf8.decode(await readHostFile(directory, ACTIVE, 8192)))));
|
|
20315
|
+
async function installationAt(parent, id2, active2) {
|
|
20316
|
+
const directory = await storeChild(parent, active2.generation);
|
|
20317
|
+
const index = await readHostPackageIndex(directory, active2.digest);
|
|
20318
|
+
const read = indexedRead(directory, index);
|
|
20319
|
+
const manifest = await readHostManifest(read);
|
|
20320
|
+
if (id2 !== manifest.id)
|
|
20321
|
+
throw new Error("Manifest id must match the installation directory");
|
|
20322
|
+
const installation = { ...active2, directory, id: id2, manifest };
|
|
20323
|
+
return { installation, read, index };
|
|
20324
|
+
}
|
|
20325
|
+
async function currentAt(root, id2) {
|
|
20326
|
+
const parent = await ifMissing(() => storeChild(root, id2));
|
|
20327
|
+
if (!parent)
|
|
20328
|
+
return;
|
|
20329
|
+
const active2 = await readPointer(parent);
|
|
20330
|
+
if (active2)
|
|
20331
|
+
return { parent, active: active2, ...await installationAt(parent, id2, active2) };
|
|
20332
|
+
}
|
|
20333
|
+
var emptyConfiguration = () => ({ revision: 0, enabled: [] });
|
|
20334
|
+
async function readConfiguration(root) {
|
|
20335
|
+
return await ifMissing(async () => hostExtensionConfigurationSchema.parse(JSON.parse(utf8.decode(await readHostFile(root, ENABLED, 32 * 1024))))) ?? emptyConfiguration();
|
|
20336
|
+
}
|
|
20337
|
+
async function readHostExtensionConfiguration(dataDir) {
|
|
20338
|
+
const root = await ifMissing(() => storeRoot(hostExtensionsRoot(dataDir), false));
|
|
20339
|
+
return root ? readConfiguration(root) : emptyConfiguration();
|
|
20340
|
+
}
|
|
20341
|
+
async function discoverHostExtensions(dataDir) {
|
|
20342
|
+
const diagnostics = [];
|
|
20343
|
+
const configuration = await readHostExtensionConfiguration(dataDir).catch((error51) => {
|
|
20344
|
+
diagnostics.push(`Invalid extension configuration: ${errorMessage2(error51)}`);
|
|
20345
|
+
return emptyConfiguration();
|
|
20346
|
+
});
|
|
20347
|
+
const installations = [];
|
|
20348
|
+
const extensions = [];
|
|
20349
|
+
const root = await ifMissing(() => storeRoot(hostExtensionsRoot(dataDir), false));
|
|
20350
|
+
if (!root)
|
|
20351
|
+
return { configuration, installations, extensions, diagnostics };
|
|
20352
|
+
const ids = (await readdir3(root, { withFileTypes: true })).filter((entry) => !entry.name.startsWith(".") && (entry.isDirectory() || entry.isSymbolicLink())).map(({ name }) => name).sort();
|
|
20353
|
+
let screenshotBudget = DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES;
|
|
20354
|
+
let omitted = false;
|
|
20355
|
+
for (const id2 of ids) {
|
|
20356
|
+
const enabled = configuration.enabled.includes(id2);
|
|
20357
|
+
try {
|
|
20358
|
+
hostExtensionIdSchema.parse(id2);
|
|
20359
|
+
const resolved = await currentAt(root, id2);
|
|
20360
|
+
if (!resolved)
|
|
20361
|
+
continue;
|
|
20362
|
+
const { installation, read } = resolved;
|
|
20363
|
+
const metadata = hostExtensionInstallationMetadata(installation);
|
|
20364
|
+
const { icon, screenshots } = await validateHostPackageEntries(metadata.manifest, read);
|
|
20365
|
+
const toDataUrl = ({ mime, bytes }) => `data:${mime};base64,${bytes.toString("base64")}`;
|
|
20366
|
+
const size = screenshots.reduce((sum, { bytes }) => sum + bytes.length, 0);
|
|
20367
|
+
const fits = size <= screenshotBudget;
|
|
20368
|
+
if (fits)
|
|
20369
|
+
screenshotBudget -= size;
|
|
20370
|
+
else
|
|
20371
|
+
omitted = true;
|
|
20372
|
+
extensions.push({
|
|
20373
|
+
state: "valid",
|
|
20374
|
+
...metadata,
|
|
20375
|
+
enabled,
|
|
20376
|
+
...icon ? { iconDataUrl: toDataUrl(icon) } : {},
|
|
20377
|
+
...fits && screenshots.length ? { screenshotDataUrls: screenshots.map(toDataUrl) } : {}
|
|
20378
|
+
});
|
|
20379
|
+
installations.push(installation);
|
|
20380
|
+
} catch (error51) {
|
|
20381
|
+
extensions.push({
|
|
20382
|
+
id: id2,
|
|
20383
|
+
enabled,
|
|
20384
|
+
state: error51 instanceof InvalidHostExtensionManifest ? error51.state : "invalid",
|
|
20385
|
+
error: errorMessage2(error51)
|
|
20386
|
+
});
|
|
20387
|
+
}
|
|
20388
|
+
}
|
|
20389
|
+
if (omitted)
|
|
20390
|
+
diagnostics.push("Extension screenshot budget exceeded; some previews were omitted");
|
|
20391
|
+
const { conflicts } = resolveDesktopExtensionSlots(configuration.enabled, installations.filter(({ manifest }) => manifest.desktop).map(({ id: id2, manifest }) => ({ id: id2, slots: manifest.slots ?? [] })));
|
|
20392
|
+
for (const extension of extensions) {
|
|
20393
|
+
const conflict = conflicts.get(extension.id);
|
|
20394
|
+
if (extension.state === "valid" && conflict)
|
|
20395
|
+
extension.desktopConflictWith = conflict;
|
|
20396
|
+
}
|
|
20397
|
+
return { configuration, installations, extensions, diagnostics };
|
|
20398
|
+
}
|
|
20399
|
+
|
|
20400
|
+
// packages/harness-plugin-files/dist/desktop-extension-download.js
|
|
20401
|
+
var githubHeaders = {
|
|
20402
|
+
accept: "application/vnd.github+json",
|
|
20403
|
+
"user-agent": "codexhost-desktop-extensions"
|
|
20404
|
+
};
|
|
20405
|
+
var ExtensionDownloadError = class extends Error {
|
|
20406
|
+
};
|
|
20407
|
+
var ExtensionHttpError = class extends ExtensionDownloadError {
|
|
20408
|
+
status;
|
|
20409
|
+
constructor(status) {
|
|
20410
|
+
super(`Download returned HTTP ${status}`);
|
|
20411
|
+
this.status = status;
|
|
20412
|
+
}
|
|
20413
|
+
};
|
|
20414
|
+
async function downloadExtensionBytes(url2, limit, headers, { signal: callerSignal, allowUrl }) {
|
|
20415
|
+
const parsed = desktopExtensionHttpUrlSchema.safeParse(url2);
|
|
20416
|
+
if (!parsed.success)
|
|
20417
|
+
throw new ExtensionDownloadError("Expected a credential-free HTTP(S) URL");
|
|
20418
|
+
try {
|
|
20419
|
+
let target2 = new URL(parsed.data);
|
|
20420
|
+
if (isGitHubDesktopExtensionZipballUrl(target2))
|
|
20421
|
+
headers ??= githubHeaders;
|
|
20422
|
+
const timeout = AbortSignal.timeout(12e3);
|
|
20423
|
+
const signal = callerSignal ? AbortSignal.any([timeout, callerSignal]) : timeout;
|
|
20424
|
+
let response;
|
|
20425
|
+
for (let redirects = 0; ; redirects++) {
|
|
20426
|
+
if (!allowUrl(target2))
|
|
20427
|
+
throw new ExtensionDownloadError("Unsafe download URL");
|
|
20428
|
+
response = await fetch(target2.href, {
|
|
20429
|
+
signal,
|
|
20430
|
+
redirect: "manual",
|
|
20431
|
+
...headers ? { headers } : {}
|
|
20432
|
+
});
|
|
20433
|
+
const location = response.headers.get("location");
|
|
20434
|
+
if (!location || ![301, 302, 303, 307, 308].includes(response.status))
|
|
20435
|
+
break;
|
|
20436
|
+
await response.body?.cancel();
|
|
20437
|
+
if (redirects >= 4)
|
|
20438
|
+
throw new ExtensionDownloadError("Too many download redirects");
|
|
20439
|
+
target2 = new URL(location, target2);
|
|
20440
|
+
}
|
|
20441
|
+
const body = response.body;
|
|
20442
|
+
if (!response.ok || !body || Number(response.headers.get("content-length")) > limit) {
|
|
20443
|
+
await body?.cancel().catch(() => void 0);
|
|
20444
|
+
if (!response.ok)
|
|
20445
|
+
throw new ExtensionHttpError(response.status);
|
|
20446
|
+
throw new ExtensionDownloadError("Download is empty or exceeds the size limit");
|
|
20447
|
+
}
|
|
20448
|
+
const reader = body.getReader();
|
|
20449
|
+
const chunks = [];
|
|
20450
|
+
let size = 0;
|
|
20451
|
+
try {
|
|
20452
|
+
for (; ; ) {
|
|
20453
|
+
const { done, value } = await reader.read();
|
|
20454
|
+
if (done)
|
|
20455
|
+
break;
|
|
20456
|
+
size += value.byteLength;
|
|
20457
|
+
if (size > limit)
|
|
20458
|
+
throw new ExtensionDownloadError("Download exceeds the size limit");
|
|
20459
|
+
chunks.push(value);
|
|
20460
|
+
}
|
|
20461
|
+
} finally {
|
|
20462
|
+
await reader.cancel().catch(() => void 0);
|
|
20463
|
+
}
|
|
20464
|
+
return Buffer.concat(chunks, size);
|
|
20465
|
+
} catch (error51) {
|
|
20466
|
+
if (error51 instanceof ExtensionDownloadError)
|
|
20467
|
+
throw error51;
|
|
20468
|
+
throw new ExtensionDownloadError("Download failed or timed out", { cause: error51 });
|
|
20469
|
+
}
|
|
20470
|
+
}
|
|
20471
|
+
|
|
20472
|
+
// packages/harness-plugin-files/dist/extension-zip.js
|
|
20473
|
+
import { promisify } from "node:util";
|
|
20474
|
+
import { crc32, inflateRaw, inflateRawSync } from "node:zlib";
|
|
20475
|
+
var MAX_UNPACKED_BYTES = 256 * 1024 * 1024;
|
|
20476
|
+
var EXPANSION_FLOOR_BYTES = 16 * 1024 * 1024;
|
|
20477
|
+
var utf82 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
20478
|
+
var inflate = promisify(inflateRaw);
|
|
20479
|
+
|
|
20480
|
+
// packages/harness-plugin-files/dist/host-extension-sources.js
|
|
20481
|
+
var TTL = 5 * 60 * 1e3;
|
|
20482
|
+
var httpsDownload = (url2) => url2.protocol === "https:" && !url2.username && !url2.password;
|
|
20483
|
+
var cache;
|
|
20484
|
+
var pending;
|
|
20485
|
+
var PRIMARY_GRACE_MS = 1500;
|
|
20486
|
+
var PRIMARY_FORCE_REFRESH_GRACE_MS = 3e3;
|
|
20487
|
+
function catalogGeneratedAtMs(result) {
|
|
20488
|
+
const parsed = Date.parse(result.generatedAt);
|
|
20489
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
20490
|
+
}
|
|
20491
|
+
function pickFresherCatalog(primary, mirror) {
|
|
20492
|
+
return catalogGeneratedAtMs(mirror) > catalogGeneratedAtMs(primary) ? mirror : primary;
|
|
20493
|
+
}
|
|
20494
|
+
async function fetchCatalogFrom(catalogUrl, signal, forceRefresh) {
|
|
20495
|
+
const bytes = await downloadExtensionBytes(catalogUrl, 2 * 1024 * 1024, {
|
|
20496
|
+
accept: "application/json",
|
|
20497
|
+
...forceRefresh ? { "cache-control": "no-cache" } : {}
|
|
20498
|
+
}, {
|
|
20499
|
+
signal,
|
|
20500
|
+
allowUrl: (url2) => url2.origin === new URL(catalogUrl).origin && httpsDownload(url2)
|
|
20501
|
+
});
|
|
20502
|
+
return {
|
|
20503
|
+
...hostExtensionCatalogSchema.parse(JSON.parse(utf8.decode(bytes))),
|
|
20504
|
+
catalogUrl,
|
|
20505
|
+
fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
20506
|
+
cached: false
|
|
20507
|
+
};
|
|
20508
|
+
}
|
|
20509
|
+
async function raceCatalog(forceRefresh) {
|
|
20510
|
+
const primaryController = new AbortController();
|
|
20511
|
+
const mirrorController = new AbortController();
|
|
20512
|
+
const primaryPromise = fetchCatalogFrom(HOST_EXTENSION_CATALOG_URL, primaryController.signal, forceRefresh);
|
|
20513
|
+
const mirrorPromise = fetchCatalogFrom(HOST_EXTENSION_CATALOG_MIRROR_URL, mirrorController.signal, forceRefresh);
|
|
20514
|
+
primaryPromise.catch(() => void 0);
|
|
20515
|
+
mirrorPromise.catch(() => void 0);
|
|
20516
|
+
try {
|
|
20517
|
+
const first = await Promise.any([
|
|
20518
|
+
primaryPromise.then((result) => ({ source: "primary", result })),
|
|
20519
|
+
mirrorPromise.then((result) => ({ source: "mirror", result }))
|
|
20520
|
+
]);
|
|
20521
|
+
if (first.source === "primary") {
|
|
20522
|
+
mirrorController.abort();
|
|
20523
|
+
return first.result;
|
|
20524
|
+
}
|
|
20525
|
+
const graceMs = forceRefresh ? PRIMARY_FORCE_REFRESH_GRACE_MS : PRIMARY_GRACE_MS;
|
|
20526
|
+
let timer;
|
|
20527
|
+
const primaryWithinGrace = await Promise.race([
|
|
20528
|
+
primaryPromise.catch(() => void 0),
|
|
20529
|
+
new Promise((resolve) => {
|
|
20530
|
+
timer = setTimeout(() => resolve(void 0), graceMs);
|
|
20531
|
+
})
|
|
20532
|
+
]).finally(() => {
|
|
20533
|
+
if (timer !== void 0)
|
|
20534
|
+
clearTimeout(timer);
|
|
20535
|
+
});
|
|
20536
|
+
if (primaryWithinGrace) {
|
|
20537
|
+
return pickFresherCatalog(primaryWithinGrace, first.result);
|
|
20538
|
+
}
|
|
20539
|
+
primaryController.abort();
|
|
20540
|
+
return first.result;
|
|
20541
|
+
} catch (cause) {
|
|
20542
|
+
throw new Error("Host extension catalog unavailable", { cause });
|
|
20543
|
+
} finally {
|
|
20544
|
+
primaryController.abort();
|
|
20545
|
+
mirrorController.abort();
|
|
20546
|
+
}
|
|
20547
|
+
}
|
|
20548
|
+
async function fetchHostExtensionCatalog({ forceRefresh = false } = {}) {
|
|
20549
|
+
if (!forceRefresh && cache && Date.now() < cache.expires)
|
|
20550
|
+
return { ...structuredClone(cache.result), cached: true };
|
|
20551
|
+
if (pending)
|
|
20552
|
+
return structuredClone(await pending);
|
|
20553
|
+
const request = raceCatalog(forceRefresh);
|
|
20554
|
+
pending = request;
|
|
20555
|
+
try {
|
|
20556
|
+
const result = await request;
|
|
20557
|
+
cache = { result, expires: Date.now() + TTL };
|
|
20558
|
+
return structuredClone(result);
|
|
20559
|
+
} finally {
|
|
20560
|
+
pending = void 0;
|
|
20561
|
+
}
|
|
20562
|
+
}
|
|
20563
|
+
|
|
17821
20564
|
// packages/console-server/src/paths.ts
|
|
17822
20565
|
import os2 from "node:os";
|
|
17823
|
-
import
|
|
20566
|
+
import path11 from "node:path";
|
|
17824
20567
|
var DEFAULT_CONSOLE_PORT = 4399;
|
|
17825
20568
|
var CONSOLE_PORT_ENV = "CODEXHOST_CONSOLE_PORT";
|
|
17826
20569
|
var LAUNCHER_EXECUTABLE_ENV = "CODEXHOST_LAUNCHER_EXECUTABLE";
|
|
17827
20570
|
function dataDirectory(environment = process.env) {
|
|
17828
|
-
return environment.CODEXHOST_DATA_DIR ?
|
|
20571
|
+
return environment.CODEXHOST_DATA_DIR ? path11.resolve(environment.CODEXHOST_DATA_DIR) : path11.join(os2.homedir(), ".codexhost");
|
|
17829
20572
|
}
|
|
17830
20573
|
function consolePaths(environment = process.env) {
|
|
17831
20574
|
const root = dataDirectory(environment);
|
|
17832
20575
|
return {
|
|
17833
20576
|
dataDirectory: root,
|
|
17834
|
-
startupRecordFile:
|
|
17835
|
-
controllerStatusFile:
|
|
17836
|
-
logsDirectory:
|
|
17837
|
-
hostDescriptorDirectory:
|
|
20577
|
+
startupRecordFile: path11.join(root, "diagnostics", "launcher-startup-v1.json"),
|
|
20578
|
+
controllerStatusFile: path11.join(root, "diagnostics", "desktop-controller-v1.json"),
|
|
20579
|
+
logsDirectory: path11.join(root, "logs"),
|
|
20580
|
+
hostDescriptorDirectory: path11.join(root, "console", "hosts")
|
|
17838
20581
|
};
|
|
17839
20582
|
}
|
|
17840
20583
|
function consolePort(environment = process.env) {
|
|
@@ -17850,10 +20593,10 @@ function consolePort(environment = process.env) {
|
|
|
17850
20593
|
// packages/console-server/src/harnesses.ts
|
|
17851
20594
|
var HARNESS_PLUGIN_DIRECTORY_ENV = "CODEXHOST_PLUGIN_DIRECTORY";
|
|
17852
20595
|
function harnessPluginRoots(appDirectory2, sourceCheckout, environment = process.env) {
|
|
17853
|
-
const bundled = sourceCheckout ?
|
|
20596
|
+
const bundled = sourceCheckout ? path12.resolve(appDirectory2, "..", "..", "host-runtime", "dist", "plugins") : path12.join(appDirectory2, "plugins");
|
|
17854
20597
|
return [
|
|
17855
20598
|
bundled,
|
|
17856
|
-
environment[HARNESS_PLUGIN_DIRECTORY_ENV] ??
|
|
20599
|
+
environment[HARNESS_PLUGIN_DIRECTORY_ENV] ?? path12.join(dataDirectory(environment), "plugins")
|
|
17857
20600
|
];
|
|
17858
20601
|
}
|
|
17859
20602
|
var ConsoleHarnessError = class extends Error {
|
|
@@ -17902,14 +20645,14 @@ function createConsoleHarnesses(roots, environment = process.env) {
|
|
|
17902
20645
|
};
|
|
17903
20646
|
return {
|
|
17904
20647
|
list,
|
|
17905
|
-
async setLaunchPath(
|
|
17906
|
-
const harness2 = (await list()).find((candidate) => candidate.id ===
|
|
17907
|
-
if (!harness2) throw new ConsoleHarnessError(404, `Harness '${
|
|
20648
|
+
async setLaunchPath(id2, value) {
|
|
20649
|
+
const harness2 = (await list()).find((candidate) => candidate.id === id2);
|
|
20650
|
+
if (!harness2) throw new ConsoleHarnessError(404, `Harness '${id2}' is not installed`);
|
|
17908
20651
|
if (!harness2.launchCommand) {
|
|
17909
|
-
throw new ConsoleHarnessError(400, `Harness '${
|
|
20652
|
+
throw new ConsoleHarnessError(400, `Harness '${id2}' does not accept an installation path`);
|
|
17910
20653
|
}
|
|
17911
20654
|
try {
|
|
17912
|
-
const settings = await store.set(
|
|
20655
|
+
const settings = await store.set(id2, value);
|
|
17913
20656
|
return { ...harness2, launchPath: settings.path, launchPathError: null };
|
|
17914
20657
|
} catch (error51) {
|
|
17915
20658
|
throw new ConsoleHarnessError(400, error51 instanceof Error ? error51.message : String(error51));
|
|
@@ -17919,20 +20662,20 @@ function createConsoleHarnesses(roots, environment = process.env) {
|
|
|
17919
20662
|
}
|
|
17920
20663
|
|
|
17921
20664
|
// packages/console-server/src/host-client.ts
|
|
17922
|
-
import { readdir as
|
|
17923
|
-
import
|
|
20665
|
+
import { readdir as readdir5, readFile as readFile6, realpath as realpath4, rm as rm6 } from "node:fs/promises";
|
|
20666
|
+
import path14 from "node:path";
|
|
17924
20667
|
|
|
17925
20668
|
// packages/console-server/src/diagnostics.ts
|
|
17926
|
-
import { open as
|
|
17927
|
-
import
|
|
20669
|
+
import { open as open5, readdir as readdir4, readFile as readFile5, stat as stat3 } from "node:fs/promises";
|
|
20670
|
+
import path13 from "node:path";
|
|
17928
20671
|
var MAX_DIAGNOSTIC_FILE_BYTES = 256 * 1024;
|
|
17929
20672
|
var MAX_LOG_TAIL_BYTES = 256 * 1024;
|
|
17930
20673
|
var LOG_FILE_PATTERN = /^host-runtime-\d{1,10}\.log(?:\.1)?$/u;
|
|
17931
|
-
async function readBoundedJson(
|
|
20674
|
+
async function readBoundedJson(filePath2) {
|
|
17932
20675
|
try {
|
|
17933
|
-
const metadata = await stat3(
|
|
20676
|
+
const metadata = await stat3(filePath2);
|
|
17934
20677
|
if (!metadata.isFile() || metadata.size > MAX_DIAGNOSTIC_FILE_BYTES) return null;
|
|
17935
|
-
return JSON.parse(await readFile5(
|
|
20678
|
+
return JSON.parse(await readFile5(filePath2, "utf8"));
|
|
17936
20679
|
} catch {
|
|
17937
20680
|
return null;
|
|
17938
20681
|
}
|
|
@@ -17960,15 +20703,15 @@ function parseStartupRecord(value) {
|
|
|
17960
20703
|
desktop: desktop && typeof desktop.version === "string" && typeof desktop.build === "string" && typeof desktop.installRoot === "string" ? { version: desktop.version, build: desktop.build, installRoot: desktop.installRoot } : null
|
|
17961
20704
|
};
|
|
17962
20705
|
}
|
|
17963
|
-
async function readStartupRecords(
|
|
17964
|
-
const document = await readBoundedJson(
|
|
20706
|
+
async function readStartupRecords(filePath2) {
|
|
20707
|
+
const document = await readBoundedJson(filePath2);
|
|
17965
20708
|
if (!isRecord(document) || document.schemaVersion !== 1 || !Array.isArray(document.records)) {
|
|
17966
20709
|
return [];
|
|
17967
20710
|
}
|
|
17968
20711
|
return document.records.map(parseStartupRecord).filter((record4) => record4 !== null);
|
|
17969
20712
|
}
|
|
17970
|
-
async function readControllerStatus(
|
|
17971
|
-
const document = await readBoundedJson(
|
|
20713
|
+
async function readControllerStatus(filePath2) {
|
|
20714
|
+
const document = await readBoundedJson(filePath2);
|
|
17972
20715
|
if (!isRecord(document) || document.schemaVersion !== 1 || !isRecord(document.renderer)) {
|
|
17973
20716
|
return null;
|
|
17974
20717
|
}
|
|
@@ -17996,14 +20739,14 @@ function isLogFileName(name) {
|
|
|
17996
20739
|
async function listLogFiles(logsDirectory) {
|
|
17997
20740
|
let names;
|
|
17998
20741
|
try {
|
|
17999
|
-
names = await
|
|
20742
|
+
names = await readdir4(logsDirectory);
|
|
18000
20743
|
} catch {
|
|
18001
20744
|
return [];
|
|
18002
20745
|
}
|
|
18003
20746
|
const entries = await Promise.all(
|
|
18004
20747
|
names.filter(isLogFileName).map(async (name) => {
|
|
18005
20748
|
try {
|
|
18006
|
-
const metadata = await stat3(
|
|
20749
|
+
const metadata = await stat3(path13.join(logsDirectory, name));
|
|
18007
20750
|
return metadata.isFile() ? { name, size: metadata.size, modifiedAt: metadata.mtimeMs } : null;
|
|
18008
20751
|
} catch {
|
|
18009
20752
|
return null;
|
|
@@ -18017,7 +20760,7 @@ async function readLogTail(logsDirectory, name, maxBytes = MAX_LOG_TAIL_BYTES) {
|
|
|
18017
20760
|
const limit = Math.max(1, Math.min(maxBytes, MAX_LOG_TAIL_BYTES));
|
|
18018
20761
|
let handle;
|
|
18019
20762
|
try {
|
|
18020
|
-
handle = await
|
|
20763
|
+
handle = await open5(path13.join(logsDirectory, name), "r");
|
|
18021
20764
|
} catch {
|
|
18022
20765
|
return null;
|
|
18023
20766
|
}
|
|
@@ -18092,26 +20835,26 @@ function parseDescriptor(value) {
|
|
|
18092
20835
|
port: record4.port,
|
|
18093
20836
|
token: record4.token,
|
|
18094
20837
|
startedAt: record4.startedAt,
|
|
18095
|
-
...typeof record4.runtimePath === "string" &&
|
|
20838
|
+
...typeof record4.runtimePath === "string" && path14.isAbsolute(record4.runtimePath) ? { runtimePath: record4.runtimePath } : {}
|
|
18096
20839
|
};
|
|
18097
20840
|
}
|
|
18098
20841
|
async function findHost(descriptorDirectory, isAlive = processIsAlive2) {
|
|
18099
20842
|
let names;
|
|
18100
20843
|
try {
|
|
18101
|
-
names = await
|
|
20844
|
+
names = await readdir5(descriptorDirectory);
|
|
18102
20845
|
} catch {
|
|
18103
20846
|
return null;
|
|
18104
20847
|
}
|
|
18105
20848
|
const hosts = [];
|
|
18106
20849
|
for (const name of names.filter((candidate) => DESCRIPTOR_PATTERN.test(candidate))) {
|
|
18107
|
-
const
|
|
20850
|
+
const filePath2 = path14.join(descriptorDirectory, name);
|
|
18108
20851
|
try {
|
|
18109
|
-
const text = await readFile6(
|
|
20852
|
+
const text = await readFile6(filePath2, "utf8");
|
|
18110
20853
|
if (text.length > DESCRIPTOR_MAX_BYTES) continue;
|
|
18111
20854
|
const endpoint = parseDescriptor(JSON.parse(text));
|
|
18112
20855
|
if (!endpoint) continue;
|
|
18113
20856
|
if (isAlive(endpoint.pid)) hosts.push(endpoint);
|
|
18114
|
-
else await
|
|
20857
|
+
else await rm6(filePath2, { force: true });
|
|
18115
20858
|
} catch {
|
|
18116
20859
|
continue;
|
|
18117
20860
|
}
|
|
@@ -18141,15 +20884,16 @@ function createConsoleHostClient(descriptorDirectory, options = {}) {
|
|
|
18141
20884
|
"The running Host does not identify its installation; restart it before updating"
|
|
18142
20885
|
);
|
|
18143
20886
|
const [hostDirectory, requestedDirectory] = await Promise.all([
|
|
18144
|
-
|
|
18145
|
-
|
|
20887
|
+
realpath4(path14.dirname(host.runtimePath)),
|
|
20888
|
+
realpath4(options.updateAppDirectory)
|
|
18146
20889
|
]).catch(() => {
|
|
18147
20890
|
throw new Error("The running Host installation could not be verified");
|
|
18148
20891
|
});
|
|
18149
20892
|
if (hostDirectory !== requestedDirectory)
|
|
18150
20893
|
throw new Error("The running Host belongs to a different codexhost installation");
|
|
18151
20894
|
}
|
|
18152
|
-
const
|
|
20895
|
+
const route = method === HOST_EXTENSIONS_RPC.install || method === HOST_EXTENSIONS_RPC.update ? "/extensions/rpc" : "/rpc";
|
|
20896
|
+
const response = await fetch(`http://127.0.0.1:${host.port}${route}`, {
|
|
18153
20897
|
method: "POST",
|
|
18154
20898
|
headers: { authorization: `Bearer ${host.token}`, "content-type": "application/json" },
|
|
18155
20899
|
body: JSON.stringify({ method, params: params ?? {} }),
|
|
@@ -18190,11 +20934,11 @@ function createHostUpdates(host) {
|
|
|
18190
20934
|
import { execFile as execFile2 } from "node:child_process";
|
|
18191
20935
|
import { existsSync } from "node:fs";
|
|
18192
20936
|
import { readFile as readFile7 } from "node:fs/promises";
|
|
18193
|
-
import
|
|
20937
|
+
import path15 from "node:path";
|
|
18194
20938
|
async function readDistribution(appDirectory2) {
|
|
18195
20939
|
try {
|
|
18196
20940
|
return parseDistributionMetadata(
|
|
18197
|
-
JSON.parse(await readFile7(
|
|
20941
|
+
JSON.parse(await readFile7(path15.join(appDirectory2, "codexhost-distribution.json"), "utf8"))
|
|
18198
20942
|
);
|
|
18199
20943
|
} catch (error51) {
|
|
18200
20944
|
if (error51.code === "ENOENT") return null;
|
|
@@ -18202,17 +20946,17 @@ async function readDistribution(appDirectory2) {
|
|
|
18202
20946
|
}
|
|
18203
20947
|
}
|
|
18204
20948
|
function installedLauncherCandidates(appDirectory2, platform = process.platform) {
|
|
18205
|
-
const resourcesRoot =
|
|
20949
|
+
const resourcesRoot = path15.dirname(appDirectory2);
|
|
18206
20950
|
const suffix = platform === "win32" ? ".exe" : "";
|
|
18207
|
-
const candidates = [
|
|
18208
|
-
if (platform === "darwin" &&
|
|
18209
|
-
candidates.unshift(
|
|
20951
|
+
const candidates = [path15.join(resourcesRoot, "bin", `codexhost${suffix}`)];
|
|
20952
|
+
if (platform === "darwin" && path15.basename(resourcesRoot) === "Resources") {
|
|
20953
|
+
candidates.unshift(path15.join(path15.dirname(resourcesRoot), "MacOS", "codexhost"));
|
|
18210
20954
|
}
|
|
18211
20955
|
return candidates;
|
|
18212
20956
|
}
|
|
18213
20957
|
function resolveLauncherExecutable(appDirectory2, environment = process.env, platform = process.platform, exists = existsSync) {
|
|
18214
20958
|
const configured = environment[LAUNCHER_EXECUTABLE_ENV];
|
|
18215
|
-
if (configured &&
|
|
20959
|
+
if (configured && path15.isAbsolute(configured) && exists(configured)) return configured;
|
|
18216
20960
|
return installedLauncherCandidates(appDirectory2, platform).find(exists) ?? null;
|
|
18217
20961
|
}
|
|
18218
20962
|
async function resolveInstallation(appDirectory2, environment = process.env) {
|
|
@@ -18254,7 +20998,7 @@ function launchCommand(installation, environment = process.env) {
|
|
|
18254
20998
|
if (installation.distribution?.distribution === "npm") {
|
|
18255
20999
|
const node = environment.CODEXHOST_NPM_NODE_PATH;
|
|
18256
21000
|
const wrapper = environment.CODEXHOST_NPM_LAUNCHER_PATH;
|
|
18257
|
-
if (node && wrapper &&
|
|
21001
|
+
if (node && wrapper && path15.isAbsolute(node) && path15.isAbsolute(wrapper)) {
|
|
18258
21002
|
return { command: node, args: [wrapper] };
|
|
18259
21003
|
}
|
|
18260
21004
|
return null;
|
|
@@ -18265,11 +21009,11 @@ function launchCommand(installation, environment = process.env) {
|
|
|
18265
21009
|
// packages/console-server/src/open.ts
|
|
18266
21010
|
import { spawn as spawn4 } from "node:child_process";
|
|
18267
21011
|
import { stat as stat4 } from "node:fs/promises";
|
|
18268
|
-
import
|
|
21012
|
+
import path20 from "node:path";
|
|
18269
21013
|
|
|
18270
21014
|
// packages/console-server/src/page.ts
|
|
18271
21015
|
import { readFile as readFile8 } from "node:fs/promises";
|
|
18272
|
-
import
|
|
21016
|
+
import path16 from "node:path";
|
|
18273
21017
|
var CONSOLE_PAGE_HTML = `<!doctype html>
|
|
18274
21018
|
<html lang="en">
|
|
18275
21019
|
<head>
|
|
@@ -18290,8 +21034,8 @@ var MISSING_BUNDLE_SCRIPT = `document.body.textContent = "codexhost console asse
|
|
|
18290
21034
|
`;
|
|
18291
21035
|
function consoleBundleCandidates(appDirectory2) {
|
|
18292
21036
|
return [
|
|
18293
|
-
|
|
18294
|
-
|
|
21037
|
+
path16.join(appDirectory2, "console-web.js"),
|
|
21038
|
+
path16.resolve(appDirectory2, "..", "..", "renderer-extension", "dist", "console.js")
|
|
18295
21039
|
];
|
|
18296
21040
|
}
|
|
18297
21041
|
async function loadConsoleBundle(appDirectory2) {
|
|
@@ -18476,8 +21220,91 @@ function issueUrl(report, home) {
|
|
|
18476
21220
|
return url2;
|
|
18477
21221
|
}
|
|
18478
21222
|
|
|
21223
|
+
// packages/console-server/src/extensions.ts
|
|
21224
|
+
var INSTALL = "POST /api/extensions/install";
|
|
21225
|
+
var UPDATE = "POST /api/extensions/update";
|
|
21226
|
+
var isExtensionUploadRoute = (route) => route === INSTALL || route === UPDATE;
|
|
21227
|
+
var methods2 = /* @__PURE__ */ new Map([
|
|
21228
|
+
["GET /api/extensions", HOST_EXTENSIONS_RPC.list],
|
|
21229
|
+
["GET /api/extensions/snapshot", HOST_EXTENSIONS_RPC.snapshot],
|
|
21230
|
+
["GET /api/extensions/catalog", HOST_EXTENSIONS_RPC.catalog],
|
|
21231
|
+
[INSTALL, HOST_EXTENSIONS_RPC.install],
|
|
21232
|
+
[UPDATE, HOST_EXTENSIONS_RPC.update],
|
|
21233
|
+
["POST /api/extensions/uninstall", HOST_EXTENSIONS_RPC.uninstall],
|
|
21234
|
+
["POST /api/extensions/enable", HOST_EXTENSIONS_RPC.enable],
|
|
21235
|
+
["POST /api/extensions/disable", HOST_EXTENSIONS_RPC.disable],
|
|
21236
|
+
["POST /api/extensions/recover", HOST_EXTENSIONS_RPC.recover],
|
|
21237
|
+
["POST /api/extensions/disable-all-and-reload", HOST_EXTENSIONS_RPC.recover]
|
|
21238
|
+
]);
|
|
21239
|
+
function consoleList(list) {
|
|
21240
|
+
return {
|
|
21241
|
+
...list,
|
|
21242
|
+
desktopConnected: false,
|
|
21243
|
+
extensions: list.extensions.map((item) => {
|
|
21244
|
+
if (item.state !== "valid")
|
|
21245
|
+
return { ...item, status: { state: item.state, error: item.error } };
|
|
21246
|
+
const { manifest, enabled, backendState: backendState2, backendError, desktopConflictWith } = item;
|
|
21247
|
+
return {
|
|
21248
|
+
...item,
|
|
21249
|
+
manifest: { ...manifest, slots: manifest.slots ?? [] },
|
|
21250
|
+
status: !enabled ? { state: "disabled" } : desktopConflictWith ? { state: "conflict", conflictWith: desktopConflictWith } : backendState2 === "failed" ? { state: "failed", error: backendError } : backendState2 === "running" || !manifest.desktop ? { state: "running" } : { state: "waiting" }
|
|
21251
|
+
};
|
|
21252
|
+
})
|
|
21253
|
+
};
|
|
21254
|
+
}
|
|
21255
|
+
async function extensionsRoute(route, body, dataDirectory2, query, host) {
|
|
21256
|
+
const method = methods2.get(route);
|
|
21257
|
+
if (!method) return;
|
|
21258
|
+
const refresh = query.get("forceRefresh");
|
|
21259
|
+
const input = method !== HOST_EXTENSIONS_RPC.catalog ? body : refresh === null ? {} : {
|
|
21260
|
+
forceRefresh: refresh === "true" ? true : refresh === "false" ? false : refresh
|
|
21261
|
+
};
|
|
21262
|
+
const params = hostExtensionsRpcSchemas[method].params.safeParse(input);
|
|
21263
|
+
if (!params.success) return { status: 400, body: { error: "Invalid extension parameters" } };
|
|
21264
|
+
if ("source" in params.data && params.data.source?.type === "zip" && "localZipPath" in params.data.source)
|
|
21265
|
+
return { status: 400, body: { error: "Use a base64 ZIP; local ZIP paths are not accepted" } };
|
|
21266
|
+
try {
|
|
21267
|
+
const reply = await host.request(method, params.data);
|
|
21268
|
+
if ("error" in reply)
|
|
21269
|
+
return {
|
|
21270
|
+
status: reply.error.code === -32602 ? 400 : reply.error.code === -32009 ? 409 : reply.error.code === -32601 ? 404 : 500,
|
|
21271
|
+
body: { error: reply.error.message }
|
|
21272
|
+
};
|
|
21273
|
+
if (method === HOST_EXTENSIONS_RPC.list)
|
|
21274
|
+
return { status: 200, body: consoleList(hostExtensionsRpcSchemas[HOST_EXTENSIONS_RPC.list].result.parse(reply.result)) };
|
|
21275
|
+
if (method === HOST_EXTENSIONS_RPC.enable || method === HOST_EXTENSIONS_RPC.disable || method === HOST_EXTENSIONS_RPC.recover) {
|
|
21276
|
+
const result = hostExtensionsRpcSchemas[method].result.parse(reply.result);
|
|
21277
|
+
if (result.state === "revision-conflict")
|
|
21278
|
+
return {
|
|
21279
|
+
status: 409,
|
|
21280
|
+
body: {
|
|
21281
|
+
error: "Extension selection changed; refresh and try again",
|
|
21282
|
+
revision: result.revision
|
|
21283
|
+
}
|
|
21284
|
+
};
|
|
21285
|
+
}
|
|
21286
|
+
return { status: 200, body: hostExtensionsRpcSchemas[method].result.parse(reply.result) };
|
|
21287
|
+
} catch (error51) {
|
|
21288
|
+
if (!(error51 instanceof HostUnavailableError))
|
|
21289
|
+
return { status: 500, body: { error: "Host extension request failed" } };
|
|
21290
|
+
if (method === HOST_EXTENSIONS_RPC.list) {
|
|
21291
|
+
const { configuration, diagnostics, extensions } = await discoverHostExtensions(dataDirectory2);
|
|
21292
|
+
return {
|
|
21293
|
+
status: 200,
|
|
21294
|
+
body: consoleList({ configuration, diagnostics, extensions, revision: 0 })
|
|
21295
|
+
};
|
|
21296
|
+
}
|
|
21297
|
+
if (method === HOST_EXTENSIONS_RPC.catalog)
|
|
21298
|
+
return {
|
|
21299
|
+
status: 200,
|
|
21300
|
+
body: await fetchHostExtensionCatalog(hostExtensionsRpcSchemas[HOST_EXTENSIONS_RPC.catalog].params.parse(input))
|
|
21301
|
+
};
|
|
21302
|
+
return { status: 503, body: { error: "The shared Host is not running" } };
|
|
21303
|
+
}
|
|
21304
|
+
}
|
|
21305
|
+
|
|
18479
21306
|
// packages/console-server/src/updates.ts
|
|
18480
|
-
import
|
|
21307
|
+
import path17 from "node:path";
|
|
18481
21308
|
var ERROR_MAX_LENGTH = 500;
|
|
18482
21309
|
var ConsoleUpdateError = class extends Error {
|
|
18483
21310
|
constructor(code, message) {
|
|
@@ -18511,13 +21338,13 @@ function installationKind(metadata) {
|
|
|
18511
21338
|
}
|
|
18512
21339
|
function absoluteEnvironmentPath(environment, name) {
|
|
18513
21340
|
const value = environment[name];
|
|
18514
|
-
if (!value || !
|
|
21341
|
+
if (!value || !path17.isAbsolute(value)) {
|
|
18515
21342
|
throw new ConsoleUpdateError(
|
|
18516
21343
|
"unsupported",
|
|
18517
21344
|
`${name} is unavailable; run 'codexhost console' from the npm command to update`
|
|
18518
21345
|
);
|
|
18519
21346
|
}
|
|
18520
|
-
return
|
|
21347
|
+
return path17.normalize(value);
|
|
18521
21348
|
}
|
|
18522
21349
|
function createConsoleUpdates(options) {
|
|
18523
21350
|
const environment = options.environment ?? process.env;
|
|
@@ -18539,12 +21366,12 @@ function createConsoleUpdates(options) {
|
|
|
18539
21366
|
let currentStatusPath = null;
|
|
18540
21367
|
async function latestStatus() {
|
|
18541
21368
|
if (!currentStatusPath) {
|
|
18542
|
-
const
|
|
18543
|
-
if (!
|
|
21369
|
+
const active2 = await discoverActiveUpdateStatus(stateDirectory());
|
|
21370
|
+
if (!active2) {
|
|
18544
21371
|
const completed = await discoverRecentCompletedUpdateStatus(stateDirectory());
|
|
18545
21372
|
return completed ? publicStatus(completed.status) : null;
|
|
18546
21373
|
}
|
|
18547
|
-
currentStatusPath =
|
|
21374
|
+
currentStatusPath = active2.statusPath;
|
|
18548
21375
|
}
|
|
18549
21376
|
const status = await manager.readStatus(currentStatusPath);
|
|
18550
21377
|
return status ? publicStatus(status) : null;
|
|
@@ -18561,13 +21388,13 @@ function createConsoleUpdates(options) {
|
|
|
18561
21388
|
}
|
|
18562
21389
|
}
|
|
18563
21390
|
async function prepare(metadata, target2, release, onPrepared) {
|
|
18564
|
-
const resourcesRoot =
|
|
21391
|
+
const resourcesRoot = path17.dirname(target2.appDirectory);
|
|
18565
21392
|
const common = {
|
|
18566
21393
|
version: release.version,
|
|
18567
21394
|
launcherPid: options.processId ?? process.pid,
|
|
18568
21395
|
launcherExecutable: options.processExecutable ?? process.execPath,
|
|
18569
21396
|
runtimeDescriptorPath: target2.runtimeDescriptorPath,
|
|
18570
|
-
updaterExecutable:
|
|
21397
|
+
updaterExecutable: path17.join(
|
|
18571
21398
|
resourcesRoot,
|
|
18572
21399
|
"libexec",
|
|
18573
21400
|
platform === "win32" ? "codexhost-updater.exe" : "codexhost-updater"
|
|
@@ -18604,13 +21431,13 @@ function createConsoleUpdates(options) {
|
|
|
18604
21431
|
if (kind === "windows-installer") {
|
|
18605
21432
|
return manager.prepareWindowsInstaller({ ...common, artifact, installRoot: resourcesRoot });
|
|
18606
21433
|
}
|
|
18607
|
-
const appPath =
|
|
21434
|
+
const appPath = path17.dirname(path17.dirname(resourcesRoot));
|
|
18608
21435
|
return manager.prepareMacOsDmg({ ...common, artifact, appPath });
|
|
18609
21436
|
}
|
|
18610
21437
|
return Object.freeze({
|
|
18611
21438
|
async check(target2, signal) {
|
|
18612
21439
|
const metadata = target2.distribution;
|
|
18613
|
-
const runtime = metadata ? null : await readRuntimeMetadata(
|
|
21440
|
+
const runtime = metadata ? null : await readRuntimeMetadata(path17.join(target2.appDirectory, "main.js"), environment).catch(
|
|
18614
21441
|
() => null
|
|
18615
21442
|
);
|
|
18616
21443
|
const empty = {
|
|
@@ -18661,7 +21488,7 @@ function createConsoleUpdates(options) {
|
|
|
18661
21488
|
if (!metadata) {
|
|
18662
21489
|
throw new ConsoleUpdateError("unsupported", "A source checkout cannot update itself");
|
|
18663
21490
|
}
|
|
18664
|
-
if (!target2.runtimeDescriptorPath || !
|
|
21491
|
+
if (!target2.runtimeDescriptorPath || !path17.isAbsolute(target2.runtimeDescriptorPath)) {
|
|
18665
21492
|
throw new ConsoleUpdateError("unsupported", "The Launcher runtime path is unavailable");
|
|
18666
21493
|
}
|
|
18667
21494
|
if (handedOff) {
|
|
@@ -18732,12 +21559,12 @@ function createConsoleUpdates(options) {
|
|
|
18732
21559
|
// packages/console-server/src/services.ts
|
|
18733
21560
|
import { spawn as spawn2 } from "node:child_process";
|
|
18734
21561
|
import { existsSync as existsSync2 } from "node:fs";
|
|
18735
|
-
import
|
|
21562
|
+
import path18 from "node:path";
|
|
18736
21563
|
function serviceCommand(installation, action, options = {}) {
|
|
18737
21564
|
if (!installation.launcherExecutable) throw new Error("codexhost Launcher was not found");
|
|
18738
21565
|
const resource = (packaged, source) => {
|
|
18739
|
-
const bundled =
|
|
18740
|
-
return existsSync2(bundled) ? bundled :
|
|
21566
|
+
const bundled = path18.join(installation.appDirectory, packaged);
|
|
21567
|
+
return existsSync2(bundled) ? bundled : path18.resolve(installation.appDirectory, "..", "..", source, "dist", "main.js");
|
|
18741
21568
|
};
|
|
18742
21569
|
return {
|
|
18743
21570
|
command: installation.launcherExecutable,
|
|
@@ -18775,7 +21602,7 @@ function runServiceCommand(command2, args, environment) {
|
|
|
18775
21602
|
|
|
18776
21603
|
// packages/console-server/src/web-client.ts
|
|
18777
21604
|
import { readFile as readFile9 } from "node:fs/promises";
|
|
18778
|
-
import
|
|
21605
|
+
import path19 from "node:path";
|
|
18779
21606
|
var WEB_CONNECTION_METHODS = [
|
|
18780
21607
|
"codexhost/accessTokenGet",
|
|
18781
21608
|
"codexhost/accessTokenRegenerate",
|
|
@@ -18791,7 +21618,7 @@ async function webConnectionRequest(dataDirectory2, method, args) {
|
|
|
18791
21618
|
let token;
|
|
18792
21619
|
try {
|
|
18793
21620
|
const ready = JSON.parse(
|
|
18794
|
-
await readFile9(
|
|
21621
|
+
await readFile9(path19.join(dataDirectory2, "web-service-ready.json"), "utf8")
|
|
18795
21622
|
);
|
|
18796
21623
|
if (!processIsAlive2(ready.pid) || !processIsAlive2(ready.web_pid)) throw new Error();
|
|
18797
21624
|
const login = new URL(ready.loginUrl);
|
|
@@ -18823,6 +21650,7 @@ async function webConnectionRequest(dataDirectory2, method, args) {
|
|
|
18823
21650
|
// packages/console-server/src/server.ts
|
|
18824
21651
|
var CONSOLE_SERVICE = "codexhost-console";
|
|
18825
21652
|
var MAX_BODY_BYTES = 16 * 1024;
|
|
21653
|
+
var MAX_EXTENSION_INSTALL_BODY_BYTES = 4 * Math.ceil(HOST_EXTENSION_ZIP_MAX_BYTES / 3) + MAX_BODY_BYTES;
|
|
18826
21654
|
var INSPECT_CACHE_MS = 2e3;
|
|
18827
21655
|
var SECURITY_HEADERS = {
|
|
18828
21656
|
"cache-control": "no-store",
|
|
@@ -18848,13 +21676,13 @@ function sendJson(response, status, value) {
|
|
|
18848
21676
|
}
|
|
18849
21677
|
var RequestBodyError = class extends Error {
|
|
18850
21678
|
};
|
|
18851
|
-
async function readJsonBody(request) {
|
|
21679
|
+
async function readJsonBody(request, limit = MAX_BODY_BYTES) {
|
|
18852
21680
|
let size = 0;
|
|
18853
21681
|
const chunks = [];
|
|
18854
|
-
for await (const chunk of request) {
|
|
21682
|
+
for await (const chunk of request.iterator({ destroyOnReturn: false })) {
|
|
18855
21683
|
const buffer = chunk;
|
|
18856
21684
|
size += buffer.length;
|
|
18857
|
-
if (size >
|
|
21685
|
+
if (size > limit) throw new RequestBodyError("Request body is too large");
|
|
18858
21686
|
chunks.push(buffer);
|
|
18859
21687
|
}
|
|
18860
21688
|
if (size === 0) return {};
|
|
@@ -19071,12 +21899,27 @@ function startConsoleServer(options) {
|
|
|
19071
21899
|
return;
|
|
19072
21900
|
}
|
|
19073
21901
|
try {
|
|
19074
|
-
body = await readJsonBody(
|
|
21902
|
+
body = await readJsonBody(
|
|
21903
|
+
request,
|
|
21904
|
+
isExtensionUploadRoute(route) ? MAX_EXTENSION_INSTALL_BODY_BYTES : MAX_BODY_BYTES
|
|
21905
|
+
);
|
|
19075
21906
|
} catch (error51) {
|
|
21907
|
+
if (!request.complete) response.setHeader("connection", "close");
|
|
19076
21908
|
sendJson(response, 400, { error: error51.message });
|
|
19077
21909
|
return;
|
|
19078
21910
|
}
|
|
19079
21911
|
}
|
|
21912
|
+
const extensions = await extensionsRoute(
|
|
21913
|
+
route,
|
|
21914
|
+
body,
|
|
21915
|
+
options.paths.dataDirectory,
|
|
21916
|
+
url2.searchParams,
|
|
21917
|
+
options.host
|
|
21918
|
+
);
|
|
21919
|
+
if (extensions) {
|
|
21920
|
+
sendJson(response, extensions.status, extensions.body);
|
|
21921
|
+
return;
|
|
21922
|
+
}
|
|
19080
21923
|
if (route === "POST /api/shutdown") {
|
|
19081
21924
|
sendJson(response, 200, { ok: true });
|
|
19082
21925
|
if (stopping) shutdownRequested = true;
|
|
@@ -19199,14 +22042,14 @@ function startConsoleServer(options) {
|
|
|
19199
22042
|
return;
|
|
19200
22043
|
}
|
|
19201
22044
|
if (route === "POST /api/harnesses/launch-path") {
|
|
19202
|
-
const
|
|
22045
|
+
const id2 = body.id;
|
|
19203
22046
|
const value = body.path;
|
|
19204
|
-
if (typeof
|
|
22047
|
+
if (typeof id2 !== "string" || !(value === null || typeof value === "string")) {
|
|
19205
22048
|
sendJson(response, 400, { error: "Expected { id, path }" });
|
|
19206
22049
|
return;
|
|
19207
22050
|
}
|
|
19208
22051
|
try {
|
|
19209
|
-
const harness2 = await options.harnesses.setLaunchPath(
|
|
22052
|
+
const harness2 = await options.harnesses.setLaunchPath(id2, value === "" ? null : value);
|
|
19210
22053
|
sendJson(response, 200, { harness: harness2 });
|
|
19211
22054
|
} catch (error51) {
|
|
19212
22055
|
sendJson(response, error51 instanceof ConsoleHarnessError ? error51.status : 500, {
|
|
@@ -19314,7 +22157,7 @@ async function stopConsole(environment = process.env) {
|
|
|
19314
22157
|
return true;
|
|
19315
22158
|
}
|
|
19316
22159
|
async function consoleBuildId(entryPath2, environment = process.env) {
|
|
19317
|
-
const files = [entryPath2, ...consoleBundleCandidates(
|
|
22160
|
+
const files = [entryPath2, ...consoleBundleCandidates(path20.dirname(entryPath2))];
|
|
19318
22161
|
const parts = [];
|
|
19319
22162
|
for (const file2 of files) {
|
|
19320
22163
|
const metadata = await stat4(file2).catch(() => null);
|
|
@@ -19423,7 +22266,7 @@ async function updateFromCommand(appDirectory2, arguments_) {
|
|
|
19423
22266
|
var IDLE_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
19424
22267
|
var HANDOFF_EXIT_DELAY_MS = 500;
|
|
19425
22268
|
var entryPath = fileURLToPath(import.meta.url);
|
|
19426
|
-
var appDirectory =
|
|
22269
|
+
var appDirectory = path21.dirname(entryPath);
|
|
19427
22270
|
function usage() {
|
|
19428
22271
|
console.error(
|
|
19429
22272
|
"usage: console-server open [--no-browser] | console-server ensure | console-server serve | console-server stop | console-server update"
|
|
@@ -19471,7 +22314,7 @@ function parseOpenArguments(arguments_) {
|
|
|
19471
22314
|
}
|
|
19472
22315
|
return parsed;
|
|
19473
22316
|
}
|
|
19474
|
-
async function
|
|
22317
|
+
async function open6(arguments_) {
|
|
19475
22318
|
const parsed = parseOpenArguments(arguments_);
|
|
19476
22319
|
const installation = await resolveInstallation(appDirectory);
|
|
19477
22320
|
const url2 = await openConsole({
|
|
@@ -19492,7 +22335,7 @@ async function stop(arguments_) {
|
|
|
19492
22335
|
process.exitCode = await stopConsole() ? 0 : 3;
|
|
19493
22336
|
}
|
|
19494
22337
|
var [command, ...rest] = process.argv.slice(2);
|
|
19495
|
-
var run = command === "serve" ? serve() : command === "open" ?
|
|
22338
|
+
var run = command === "serve" ? serve() : command === "open" ? open6(rest) : command === "ensure" ? ensure(rest) : command === "stop" ? stop(rest) : command === "update" ? updateFromCommand(appDirectory, rest) : usage();
|
|
19496
22339
|
run.catch((error51) => {
|
|
19497
22340
|
console.error(`codexhost console: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
19498
22341
|
process.exit(1);
|