@get-bb/plugin-sdk 0.4.47 → 0.4.50
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 +12 -0
- package/bundled-types/bb-plugin-sdk-app.d.ts +203 -28
- package/bundled-types/bb-plugin-sdk-environment-provider.d.ts +266 -0
- package/bundled-types/bb-plugin-sdk-host.d.ts +33 -2
- package/bundled-types/bb-plugin-sdk-internal-composer-customization-validation.d.ts +2 -1
- package/bundled-types/bb-plugin-sdk-internal-host-policy.d.ts +231 -8
- package/bundled-types/bb-plugin-sdk-internal-plugin-app-collector.d.ts +2 -1
- package/bundled-types/bb-plugin-sdk-provider-bridge-acp.d.ts +7 -0
- package/bundled-types/bb-plugin-sdk-provider-bridge-testing.d.ts +195 -1
- package/bundled-types/bb-plugin-sdk-provider-bridge.d.ts +202 -167
- package/bundled-types/bb-plugin-sdk-testing-app.d.ts +5 -1
- package/bundled-types/bb-plugin-sdk-testing.d.ts +308 -3
- package/bundled-types/bb-plugin-sdk.d.ts +1639 -572
- package/dist/app.js +6 -0
- package/dist/environment-provider.js +0 -0
- package/dist/host.js +734 -30
- package/dist/internal/composer-customization-validation.js +9 -0
- package/dist/internal/host-policy.js +233 -64
- package/dist/internal/plugin-app-collector.js +26 -0
- package/dist/provider-bridge-acp.js +46 -2
- package/dist/provider-bridge-testing.js +62 -1
- package/dist/provider-bridge.js +23 -1
- package/dist/testing/app.js +86 -1
- package/dist/testing/index.js +254 -72
- package/package.json +7 -1
package/dist/host.js
CHANGED
|
@@ -1,8 +1,539 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
+
});
|
|
13
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
14
|
+
try {
|
|
15
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
+
} catch (e) {
|
|
17
|
+
throw mod = 0, e;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
2
20
|
var __export = (target, all) => {
|
|
3
21
|
for (var name in all)
|
|
4
22
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
23
|
};
|
|
24
|
+
var __copyProps = (to, from, except, desc) => {
|
|
25
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
26
|
+
for (let key of __getOwnPropNames(from))
|
|
27
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
28
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
29
|
+
}
|
|
30
|
+
return to;
|
|
31
|
+
};
|
|
32
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
33
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
34
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
35
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
36
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
37
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
38
|
+
mod
|
|
39
|
+
));
|
|
40
|
+
|
|
41
|
+
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js
|
|
42
|
+
var require_windows = __commonJS({
|
|
43
|
+
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports, module) {
|
|
44
|
+
module.exports = isexe;
|
|
45
|
+
isexe.sync = sync;
|
|
46
|
+
var fs2 = __require("fs");
|
|
47
|
+
function checkPathExt(path2, options) {
|
|
48
|
+
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
49
|
+
if (!pathext) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
pathext = pathext.split(";");
|
|
53
|
+
if (pathext.indexOf("") !== -1) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
for (var i = 0; i < pathext.length; i++) {
|
|
57
|
+
var p = pathext[i].toLowerCase();
|
|
58
|
+
if (p && path2.substr(-p.length).toLowerCase() === p) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
function checkStat(stat, path2, options) {
|
|
65
|
+
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
return checkPathExt(path2, options);
|
|
69
|
+
}
|
|
70
|
+
function isexe(path2, options, cb) {
|
|
71
|
+
fs2.stat(path2, function(er, stat) {
|
|
72
|
+
cb(er, er ? false : checkStat(stat, path2, options));
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function sync(path2, options) {
|
|
76
|
+
return checkStat(fs2.statSync(path2), path2, options);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js
|
|
82
|
+
var require_mode = __commonJS({
|
|
83
|
+
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(exports, module) {
|
|
84
|
+
module.exports = isexe;
|
|
85
|
+
isexe.sync = sync;
|
|
86
|
+
var fs2 = __require("fs");
|
|
87
|
+
function isexe(path2, options, cb) {
|
|
88
|
+
fs2.stat(path2, function(er, stat) {
|
|
89
|
+
cb(er, er ? false : checkStat(stat, options));
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function sync(path2, options) {
|
|
93
|
+
return checkStat(fs2.statSync(path2), options);
|
|
94
|
+
}
|
|
95
|
+
function checkStat(stat, options) {
|
|
96
|
+
return stat.isFile() && checkMode(stat, options);
|
|
97
|
+
}
|
|
98
|
+
function checkMode(stat, options) {
|
|
99
|
+
var mod = stat.mode;
|
|
100
|
+
var uid = stat.uid;
|
|
101
|
+
var gid = stat.gid;
|
|
102
|
+
var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
|
|
103
|
+
var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
|
|
104
|
+
var u = parseInt("100", 8);
|
|
105
|
+
var g = parseInt("010", 8);
|
|
106
|
+
var o = parseInt("001", 8);
|
|
107
|
+
var ug = u | g;
|
|
108
|
+
var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
|
|
109
|
+
return ret;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
|
|
115
|
+
var require_isexe = __commonJS({
|
|
116
|
+
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports, module) {
|
|
117
|
+
var fs2 = __require("fs");
|
|
118
|
+
var core;
|
|
119
|
+
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
120
|
+
core = require_windows();
|
|
121
|
+
} else {
|
|
122
|
+
core = require_mode();
|
|
123
|
+
}
|
|
124
|
+
module.exports = isexe;
|
|
125
|
+
isexe.sync = sync;
|
|
126
|
+
function isexe(path2, options, cb) {
|
|
127
|
+
if (typeof options === "function") {
|
|
128
|
+
cb = options;
|
|
129
|
+
options = {};
|
|
130
|
+
}
|
|
131
|
+
if (!cb) {
|
|
132
|
+
if (typeof Promise !== "function") {
|
|
133
|
+
throw new TypeError("callback not provided");
|
|
134
|
+
}
|
|
135
|
+
return new Promise(function(resolve2, reject) {
|
|
136
|
+
isexe(path2, options || {}, function(er, is) {
|
|
137
|
+
if (er) {
|
|
138
|
+
reject(er);
|
|
139
|
+
} else {
|
|
140
|
+
resolve2(is);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
core(path2, options || {}, function(er, is) {
|
|
146
|
+
if (er) {
|
|
147
|
+
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
148
|
+
er = null;
|
|
149
|
+
is = false;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
cb(er, is);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
function sync(path2, options) {
|
|
156
|
+
try {
|
|
157
|
+
return core.sync(path2, options || {});
|
|
158
|
+
} catch (er) {
|
|
159
|
+
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
160
|
+
return false;
|
|
161
|
+
} else {
|
|
162
|
+
throw er;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// ../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js
|
|
170
|
+
var require_which = __commonJS({
|
|
171
|
+
"../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(exports, module) {
|
|
172
|
+
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
173
|
+
var path2 = __require("path");
|
|
174
|
+
var COLON = isWindows ? ";" : ":";
|
|
175
|
+
var isexe = require_isexe();
|
|
176
|
+
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
177
|
+
var getPathInfo = (cmd, opt) => {
|
|
178
|
+
const colon = opt.colon || COLON;
|
|
179
|
+
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
|
|
180
|
+
// windows always checks the cwd first
|
|
181
|
+
...isWindows ? [process.cwd()] : [],
|
|
182
|
+
...(opt.path || process.env.PATH || /* istanbul ignore next: very unusual */
|
|
183
|
+
"").split(colon)
|
|
184
|
+
];
|
|
185
|
+
const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
|
|
186
|
+
const pathExt = isWindows ? pathExtExe.split(colon) : [""];
|
|
187
|
+
if (isWindows) {
|
|
188
|
+
if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
|
|
189
|
+
pathExt.unshift("");
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
pathEnv,
|
|
193
|
+
pathExt,
|
|
194
|
+
pathExtExe
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
var which = (cmd, opt, cb) => {
|
|
198
|
+
if (typeof opt === "function") {
|
|
199
|
+
cb = opt;
|
|
200
|
+
opt = {};
|
|
201
|
+
}
|
|
202
|
+
if (!opt)
|
|
203
|
+
opt = {};
|
|
204
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
205
|
+
const found = [];
|
|
206
|
+
const step = (i) => new Promise((resolve2, reject) => {
|
|
207
|
+
if (i === pathEnv.length)
|
|
208
|
+
return opt.all && found.length ? resolve2(found) : reject(getNotFoundError(cmd));
|
|
209
|
+
const ppRaw = pathEnv[i];
|
|
210
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
211
|
+
const pCmd = path2.join(pathPart, cmd);
|
|
212
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
213
|
+
resolve2(subStep(p, i, 0));
|
|
214
|
+
});
|
|
215
|
+
const subStep = (p, i, ii) => new Promise((resolve2, reject) => {
|
|
216
|
+
if (ii === pathExt.length)
|
|
217
|
+
return resolve2(step(i + 1));
|
|
218
|
+
const ext = pathExt[ii];
|
|
219
|
+
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
220
|
+
if (!er && is) {
|
|
221
|
+
if (opt.all)
|
|
222
|
+
found.push(p + ext);
|
|
223
|
+
else
|
|
224
|
+
return resolve2(p + ext);
|
|
225
|
+
}
|
|
226
|
+
return resolve2(subStep(p, i, ii + 1));
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
230
|
+
};
|
|
231
|
+
var whichSync = (cmd, opt) => {
|
|
232
|
+
opt = opt || {};
|
|
233
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
234
|
+
const found = [];
|
|
235
|
+
for (let i = 0; i < pathEnv.length; i++) {
|
|
236
|
+
const ppRaw = pathEnv[i];
|
|
237
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
238
|
+
const pCmd = path2.join(pathPart, cmd);
|
|
239
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
240
|
+
for (let j = 0; j < pathExt.length; j++) {
|
|
241
|
+
const cur = p + pathExt[j];
|
|
242
|
+
try {
|
|
243
|
+
const is = isexe.sync(cur, { pathExt: pathExtExe });
|
|
244
|
+
if (is) {
|
|
245
|
+
if (opt.all)
|
|
246
|
+
found.push(cur);
|
|
247
|
+
else
|
|
248
|
+
return cur;
|
|
249
|
+
}
|
|
250
|
+
} catch (ex) {
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
if (opt.all && found.length)
|
|
255
|
+
return found;
|
|
256
|
+
if (opt.nothrow)
|
|
257
|
+
return null;
|
|
258
|
+
throw getNotFoundError(cmd);
|
|
259
|
+
};
|
|
260
|
+
module.exports = which;
|
|
261
|
+
which.sync = whichSync;
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
// ../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js
|
|
266
|
+
var require_path_key = __commonJS({
|
|
267
|
+
"../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js"(exports, module) {
|
|
268
|
+
"use strict";
|
|
269
|
+
var pathKey = (options = {}) => {
|
|
270
|
+
const environment = options.env || process.env;
|
|
271
|
+
const platform = options.platform || process.platform;
|
|
272
|
+
if (platform !== "win32") {
|
|
273
|
+
return "PATH";
|
|
274
|
+
}
|
|
275
|
+
return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
|
|
276
|
+
};
|
|
277
|
+
module.exports = pathKey;
|
|
278
|
+
module.exports.default = pathKey;
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js
|
|
283
|
+
var require_resolveCommand = __commonJS({
|
|
284
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
|
|
285
|
+
"use strict";
|
|
286
|
+
var path2 = __require("path");
|
|
287
|
+
var which = require_which();
|
|
288
|
+
var getPathKey = require_path_key();
|
|
289
|
+
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
290
|
+
const env = parsed.options.env || process.env;
|
|
291
|
+
const cwd = process.cwd();
|
|
292
|
+
const hasCustomCwd = parsed.options.cwd != null;
|
|
293
|
+
const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
|
|
294
|
+
if (shouldSwitchCwd) {
|
|
295
|
+
try {
|
|
296
|
+
process.chdir(parsed.options.cwd);
|
|
297
|
+
} catch (err) {
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
let resolved;
|
|
301
|
+
try {
|
|
302
|
+
resolved = which.sync(parsed.command, {
|
|
303
|
+
path: env[getPathKey({ env })],
|
|
304
|
+
pathExt: withoutPathExt ? path2.delimiter : void 0
|
|
305
|
+
});
|
|
306
|
+
} catch (e) {
|
|
307
|
+
} finally {
|
|
308
|
+
if (shouldSwitchCwd) {
|
|
309
|
+
process.chdir(cwd);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if (resolved) {
|
|
313
|
+
resolved = path2.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
314
|
+
}
|
|
315
|
+
return resolved;
|
|
316
|
+
}
|
|
317
|
+
function resolveCommand(parsed) {
|
|
318
|
+
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
|
|
319
|
+
}
|
|
320
|
+
module.exports = resolveCommand;
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js
|
|
325
|
+
var require_escape = __commonJS({
|
|
326
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js"(exports, module) {
|
|
327
|
+
"use strict";
|
|
328
|
+
var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
|
329
|
+
function escapeCommand(arg) {
|
|
330
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
331
|
+
return arg;
|
|
332
|
+
}
|
|
333
|
+
function escapeArgument(arg, doubleEscapeMetaChars) {
|
|
334
|
+
arg = `${arg}`;
|
|
335
|
+
arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
|
|
336
|
+
arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
|
|
337
|
+
arg = `"${arg}"`;
|
|
338
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
339
|
+
if (doubleEscapeMetaChars) {
|
|
340
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
341
|
+
}
|
|
342
|
+
return arg;
|
|
343
|
+
}
|
|
344
|
+
module.exports.command = escapeCommand;
|
|
345
|
+
module.exports.argument = escapeArgument;
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
// ../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js
|
|
350
|
+
var require_shebang_regex = __commonJS({
|
|
351
|
+
"../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js"(exports, module) {
|
|
352
|
+
"use strict";
|
|
353
|
+
module.exports = /^#!(.*)/;
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
// ../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js
|
|
358
|
+
var require_shebang_command = __commonJS({
|
|
359
|
+
"../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js"(exports, module) {
|
|
360
|
+
"use strict";
|
|
361
|
+
var shebangRegex = require_shebang_regex();
|
|
362
|
+
module.exports = (string4 = "") => {
|
|
363
|
+
const match = string4.match(shebangRegex);
|
|
364
|
+
if (!match) {
|
|
365
|
+
return null;
|
|
366
|
+
}
|
|
367
|
+
const [path2, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
368
|
+
const binary = path2.split("/").pop();
|
|
369
|
+
if (binary === "env") {
|
|
370
|
+
return argument;
|
|
371
|
+
}
|
|
372
|
+
return argument ? `${binary} ${argument}` : binary;
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js
|
|
378
|
+
var require_readShebang = __commonJS({
|
|
379
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
|
|
380
|
+
"use strict";
|
|
381
|
+
var fs2 = __require("fs");
|
|
382
|
+
var shebangCommand = require_shebang_command();
|
|
383
|
+
function readShebang(command) {
|
|
384
|
+
const size = 150;
|
|
385
|
+
const buffer = Buffer.alloc(size);
|
|
386
|
+
let fd;
|
|
387
|
+
try {
|
|
388
|
+
fd = fs2.openSync(command, "r");
|
|
389
|
+
fs2.readSync(fd, buffer, 0, size, 0);
|
|
390
|
+
fs2.closeSync(fd);
|
|
391
|
+
} catch (e) {
|
|
392
|
+
}
|
|
393
|
+
return shebangCommand(buffer.toString());
|
|
394
|
+
}
|
|
395
|
+
module.exports = readShebang;
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js
|
|
400
|
+
var require_parse = __commonJS({
|
|
401
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports, module) {
|
|
402
|
+
"use strict";
|
|
403
|
+
var path2 = __require("path");
|
|
404
|
+
var resolveCommand = require_resolveCommand();
|
|
405
|
+
var escape = require_escape();
|
|
406
|
+
var readShebang = require_readShebang();
|
|
407
|
+
var isWin = process.platform === "win32";
|
|
408
|
+
var isExecutableRegExp = /\.(?:com|exe)$/i;
|
|
409
|
+
var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
410
|
+
function detectShebang(parsed) {
|
|
411
|
+
parsed.file = resolveCommand(parsed);
|
|
412
|
+
const shebang = parsed.file && readShebang(parsed.file);
|
|
413
|
+
if (shebang) {
|
|
414
|
+
parsed.args.unshift(parsed.file);
|
|
415
|
+
parsed.command = shebang;
|
|
416
|
+
return resolveCommand(parsed);
|
|
417
|
+
}
|
|
418
|
+
return parsed.file;
|
|
419
|
+
}
|
|
420
|
+
function parseNonShell(parsed) {
|
|
421
|
+
if (!isWin) {
|
|
422
|
+
return parsed;
|
|
423
|
+
}
|
|
424
|
+
const commandFile = detectShebang(parsed);
|
|
425
|
+
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
426
|
+
if (parsed.options.forceShell || needsShell) {
|
|
427
|
+
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
428
|
+
parsed.command = path2.normalize(parsed.command);
|
|
429
|
+
parsed.command = escape.command(parsed.command);
|
|
430
|
+
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
|
|
431
|
+
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
432
|
+
parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
|
|
433
|
+
parsed.command = process.env.comspec || "cmd.exe";
|
|
434
|
+
parsed.options.windowsVerbatimArguments = true;
|
|
435
|
+
}
|
|
436
|
+
return parsed;
|
|
437
|
+
}
|
|
438
|
+
function parse3(command, args, options) {
|
|
439
|
+
if (args && !Array.isArray(args)) {
|
|
440
|
+
options = args;
|
|
441
|
+
args = null;
|
|
442
|
+
}
|
|
443
|
+
args = args ? args.slice(0) : [];
|
|
444
|
+
options = Object.assign({}, options);
|
|
445
|
+
const parsed = {
|
|
446
|
+
command,
|
|
447
|
+
args,
|
|
448
|
+
options,
|
|
449
|
+
file: void 0,
|
|
450
|
+
original: {
|
|
451
|
+
command,
|
|
452
|
+
args
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
return options.shell ? parsed : parseNonShell(parsed);
|
|
456
|
+
}
|
|
457
|
+
module.exports = parse3;
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js
|
|
462
|
+
var require_enoent = __commonJS({
|
|
463
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js"(exports, module) {
|
|
464
|
+
"use strict";
|
|
465
|
+
var isWin = process.platform === "win32";
|
|
466
|
+
function notFoundError(original, syscall) {
|
|
467
|
+
return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
|
|
468
|
+
code: "ENOENT",
|
|
469
|
+
errno: "ENOENT",
|
|
470
|
+
syscall: `${syscall} ${original.command}`,
|
|
471
|
+
path: original.command,
|
|
472
|
+
spawnargs: original.args
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
function hookChildProcess(cp, parsed) {
|
|
476
|
+
if (!isWin) {
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
const originalEmit = cp.emit;
|
|
480
|
+
cp.emit = function(name, arg1) {
|
|
481
|
+
if (name === "exit") {
|
|
482
|
+
const err = verifyENOENT(arg1, parsed);
|
|
483
|
+
if (err) {
|
|
484
|
+
return originalEmit.call(cp, "error", err);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
return originalEmit.apply(cp, arguments);
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
function verifyENOENT(status, parsed) {
|
|
491
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
492
|
+
return notFoundError(parsed.original, "spawn");
|
|
493
|
+
}
|
|
494
|
+
return null;
|
|
495
|
+
}
|
|
496
|
+
function verifyENOENTSync(status, parsed) {
|
|
497
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
498
|
+
return notFoundError(parsed.original, "spawnSync");
|
|
499
|
+
}
|
|
500
|
+
return null;
|
|
501
|
+
}
|
|
502
|
+
module.exports = {
|
|
503
|
+
hookChildProcess,
|
|
504
|
+
verifyENOENT,
|
|
505
|
+
verifyENOENTSync,
|
|
506
|
+
notFoundError
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js
|
|
512
|
+
var require_cross_spawn = __commonJS({
|
|
513
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js"(exports, module) {
|
|
514
|
+
"use strict";
|
|
515
|
+
var cp = __require("child_process");
|
|
516
|
+
var parse3 = require_parse();
|
|
517
|
+
var enoent = require_enoent();
|
|
518
|
+
function spawn(command, args, options) {
|
|
519
|
+
const parsed = parse3(command, args, options);
|
|
520
|
+
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
521
|
+
enoent.hookChildProcess(spawned, parsed);
|
|
522
|
+
return spawned;
|
|
523
|
+
}
|
|
524
|
+
function spawnSync(command, args, options) {
|
|
525
|
+
const parsed = parse3(command, args, options);
|
|
526
|
+
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
527
|
+
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
528
|
+
return result;
|
|
529
|
+
}
|
|
530
|
+
module.exports = spawn;
|
|
531
|
+
module.exports.spawn = spawn;
|
|
532
|
+
module.exports.sync = spawnSync;
|
|
533
|
+
module.exports._parse = parse3;
|
|
534
|
+
module.exports._enoent = enoent;
|
|
535
|
+
}
|
|
536
|
+
});
|
|
6
537
|
|
|
7
538
|
// src/host-contract.ts
|
|
8
539
|
function experimental_defineHostEntry(args) {
|
|
@@ -518,7 +1049,7 @@ __export(core_exports2, {
|
|
|
518
1049
|
parse: () => parse,
|
|
519
1050
|
parseAsync: () => parseAsync,
|
|
520
1051
|
prettifyError: () => prettifyError,
|
|
521
|
-
process: () =>
|
|
1052
|
+
process: () => process2,
|
|
522
1053
|
regexes: () => regexes_exports,
|
|
523
1054
|
registry: () => registry,
|
|
524
1055
|
safeDecode: () => safeDecode,
|
|
@@ -10919,7 +11450,7 @@ function initializeContext(params) {
|
|
|
10919
11450
|
external: params?.external ?? void 0
|
|
10920
11451
|
};
|
|
10921
11452
|
}
|
|
10922
|
-
function
|
|
11453
|
+
function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
10923
11454
|
var _a2;
|
|
10924
11455
|
const def = schema._zod.def;
|
|
10925
11456
|
const seen = ctx.seen.get(schema);
|
|
@@ -10956,7 +11487,7 @@ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
10956
11487
|
if (parent) {
|
|
10957
11488
|
if (!result.ref)
|
|
10958
11489
|
result.ref = parent;
|
|
10959
|
-
|
|
11490
|
+
process2(parent, ctx, params);
|
|
10960
11491
|
ctx.seen.get(parent).isParent = true;
|
|
10961
11492
|
}
|
|
10962
11493
|
}
|
|
@@ -11237,14 +11768,14 @@ function isTransforming(_schema, _ctx) {
|
|
|
11237
11768
|
}
|
|
11238
11769
|
var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
11239
11770
|
const ctx = initializeContext({ ...params, processors });
|
|
11240
|
-
|
|
11771
|
+
process2(schema, ctx);
|
|
11241
11772
|
extractDefs(ctx, schema);
|
|
11242
11773
|
return finalize(ctx, schema);
|
|
11243
11774
|
};
|
|
11244
11775
|
var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
11245
11776
|
const { libraryOptions, target } = params ?? {};
|
|
11246
11777
|
const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
|
|
11247
|
-
|
|
11778
|
+
process2(schema, ctx);
|
|
11248
11779
|
extractDefs(ctx, schema);
|
|
11249
11780
|
return finalize(ctx, schema);
|
|
11250
11781
|
};
|
|
@@ -11501,7 +12032,7 @@ var arrayProcessor = (schema, ctx, _json, params) => {
|
|
|
11501
12032
|
if (typeof maximum === "number")
|
|
11502
12033
|
json2.maxItems = maximum;
|
|
11503
12034
|
json2.type = "array";
|
|
11504
|
-
json2.items =
|
|
12035
|
+
json2.items = process2(def.element, ctx, { ...params, path: [...params.path, "items"] });
|
|
11505
12036
|
};
|
|
11506
12037
|
var objectProcessor = (schema, ctx, _json, params) => {
|
|
11507
12038
|
const json2 = _json;
|
|
@@ -11510,7 +12041,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
11510
12041
|
json2.properties = {};
|
|
11511
12042
|
const shape = def.shape;
|
|
11512
12043
|
for (const key in shape) {
|
|
11513
|
-
json2.properties[key] =
|
|
12044
|
+
json2.properties[key] = process2(shape[key], ctx, {
|
|
11514
12045
|
...params,
|
|
11515
12046
|
path: [...params.path, "properties", key]
|
|
11516
12047
|
});
|
|
@@ -11533,7 +12064,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
11533
12064
|
if (ctx.io === "output")
|
|
11534
12065
|
json2.additionalProperties = false;
|
|
11535
12066
|
} else if (def.catchall) {
|
|
11536
|
-
json2.additionalProperties =
|
|
12067
|
+
json2.additionalProperties = process2(def.catchall, ctx, {
|
|
11537
12068
|
...params,
|
|
11538
12069
|
path: [...params.path, "additionalProperties"]
|
|
11539
12070
|
});
|
|
@@ -11542,7 +12073,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
11542
12073
|
var unionProcessor = (schema, ctx, json2, params) => {
|
|
11543
12074
|
const def = schema._zod.def;
|
|
11544
12075
|
const isExclusive = def.inclusive === false;
|
|
11545
|
-
const options = def.options.map((x, i) =>
|
|
12076
|
+
const options = def.options.map((x, i) => process2(x, ctx, {
|
|
11546
12077
|
...params,
|
|
11547
12078
|
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
|
|
11548
12079
|
}));
|
|
@@ -11554,11 +12085,11 @@ var unionProcessor = (schema, ctx, json2, params) => {
|
|
|
11554
12085
|
};
|
|
11555
12086
|
var intersectionProcessor = (schema, ctx, json2, params) => {
|
|
11556
12087
|
const def = schema._zod.def;
|
|
11557
|
-
const a =
|
|
12088
|
+
const a = process2(def.left, ctx, {
|
|
11558
12089
|
...params,
|
|
11559
12090
|
path: [...params.path, "allOf", 0]
|
|
11560
12091
|
});
|
|
11561
|
-
const b =
|
|
12092
|
+
const b = process2(def.right, ctx, {
|
|
11562
12093
|
...params,
|
|
11563
12094
|
path: [...params.path, "allOf", 1]
|
|
11564
12095
|
});
|
|
@@ -11575,11 +12106,11 @@ var tupleProcessor = (schema, ctx, _json, params) => {
|
|
|
11575
12106
|
json2.type = "array";
|
|
11576
12107
|
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
11577
12108
|
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
11578
|
-
const prefixItems = def.items.map((x, i) =>
|
|
12109
|
+
const prefixItems = def.items.map((x, i) => process2(x, ctx, {
|
|
11579
12110
|
...params,
|
|
11580
12111
|
path: [...params.path, prefixPath, i]
|
|
11581
12112
|
}));
|
|
11582
|
-
const rest = def.rest ?
|
|
12113
|
+
const rest = def.rest ? process2(def.rest, ctx, {
|
|
11583
12114
|
...params,
|
|
11584
12115
|
path: [...params.path, restPath, ...ctx.target === "openapi-3.0" ? [def.items.length] : []]
|
|
11585
12116
|
}) : null;
|
|
@@ -11619,7 +12150,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
11619
12150
|
const keyBag = keyType._zod.bag;
|
|
11620
12151
|
const patterns = keyBag?.patterns;
|
|
11621
12152
|
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
11622
|
-
const valueSchema =
|
|
12153
|
+
const valueSchema = process2(def.valueType, ctx, {
|
|
11623
12154
|
...params,
|
|
11624
12155
|
path: [...params.path, "patternProperties", "*"]
|
|
11625
12156
|
});
|
|
@@ -11629,12 +12160,12 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
11629
12160
|
}
|
|
11630
12161
|
} else {
|
|
11631
12162
|
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
11632
|
-
json2.propertyNames =
|
|
12163
|
+
json2.propertyNames = process2(def.keyType, ctx, {
|
|
11633
12164
|
...params,
|
|
11634
12165
|
path: [...params.path, "propertyNames"]
|
|
11635
12166
|
});
|
|
11636
12167
|
}
|
|
11637
|
-
json2.additionalProperties =
|
|
12168
|
+
json2.additionalProperties = process2(def.valueType, ctx, {
|
|
11638
12169
|
...params,
|
|
11639
12170
|
path: [...params.path, "additionalProperties"]
|
|
11640
12171
|
});
|
|
@@ -11649,7 +12180,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
11649
12180
|
};
|
|
11650
12181
|
var nullableProcessor = (schema, ctx, json2, params) => {
|
|
11651
12182
|
const def = schema._zod.def;
|
|
11652
|
-
const inner =
|
|
12183
|
+
const inner = process2(def.innerType, ctx, params);
|
|
11653
12184
|
const seen = ctx.seen.get(schema);
|
|
11654
12185
|
if (ctx.target === "openapi-3.0") {
|
|
11655
12186
|
seen.ref = def.innerType;
|
|
@@ -11660,20 +12191,20 @@ var nullableProcessor = (schema, ctx, json2, params) => {
|
|
|
11660
12191
|
};
|
|
11661
12192
|
var nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
11662
12193
|
const def = schema._zod.def;
|
|
11663
|
-
|
|
12194
|
+
process2(def.innerType, ctx, params);
|
|
11664
12195
|
const seen = ctx.seen.get(schema);
|
|
11665
12196
|
seen.ref = def.innerType;
|
|
11666
12197
|
};
|
|
11667
12198
|
var defaultProcessor = (schema, ctx, json2, params) => {
|
|
11668
12199
|
const def = schema._zod.def;
|
|
11669
|
-
|
|
12200
|
+
process2(def.innerType, ctx, params);
|
|
11670
12201
|
const seen = ctx.seen.get(schema);
|
|
11671
12202
|
seen.ref = def.innerType;
|
|
11672
12203
|
json2.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
11673
12204
|
};
|
|
11674
12205
|
var prefaultProcessor = (schema, ctx, json2, params) => {
|
|
11675
12206
|
const def = schema._zod.def;
|
|
11676
|
-
|
|
12207
|
+
process2(def.innerType, ctx, params);
|
|
11677
12208
|
const seen = ctx.seen.get(schema);
|
|
11678
12209
|
seen.ref = def.innerType;
|
|
11679
12210
|
if (ctx.io === "input")
|
|
@@ -11681,7 +12212,7 @@ var prefaultProcessor = (schema, ctx, json2, params) => {
|
|
|
11681
12212
|
};
|
|
11682
12213
|
var catchProcessor = (schema, ctx, json2, params) => {
|
|
11683
12214
|
const def = schema._zod.def;
|
|
11684
|
-
|
|
12215
|
+
process2(def.innerType, ctx, params);
|
|
11685
12216
|
const seen = ctx.seen.get(schema);
|
|
11686
12217
|
seen.ref = def.innerType;
|
|
11687
12218
|
let catchValue;
|
|
@@ -11695,32 +12226,32 @@ var catchProcessor = (schema, ctx, json2, params) => {
|
|
|
11695
12226
|
var pipeProcessor = (schema, ctx, _json, params) => {
|
|
11696
12227
|
const def = schema._zod.def;
|
|
11697
12228
|
const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
|
|
11698
|
-
|
|
12229
|
+
process2(innerType, ctx, params);
|
|
11699
12230
|
const seen = ctx.seen.get(schema);
|
|
11700
12231
|
seen.ref = innerType;
|
|
11701
12232
|
};
|
|
11702
12233
|
var readonlyProcessor = (schema, ctx, json2, params) => {
|
|
11703
12234
|
const def = schema._zod.def;
|
|
11704
|
-
|
|
12235
|
+
process2(def.innerType, ctx, params);
|
|
11705
12236
|
const seen = ctx.seen.get(schema);
|
|
11706
12237
|
seen.ref = def.innerType;
|
|
11707
12238
|
json2.readOnly = true;
|
|
11708
12239
|
};
|
|
11709
12240
|
var promiseProcessor = (schema, ctx, _json, params) => {
|
|
11710
12241
|
const def = schema._zod.def;
|
|
11711
|
-
|
|
12242
|
+
process2(def.innerType, ctx, params);
|
|
11712
12243
|
const seen = ctx.seen.get(schema);
|
|
11713
12244
|
seen.ref = def.innerType;
|
|
11714
12245
|
};
|
|
11715
12246
|
var optionalProcessor = (schema, ctx, _json, params) => {
|
|
11716
12247
|
const def = schema._zod.def;
|
|
11717
|
-
|
|
12248
|
+
process2(def.innerType, ctx, params);
|
|
11718
12249
|
const seen = ctx.seen.get(schema);
|
|
11719
12250
|
seen.ref = def.innerType;
|
|
11720
12251
|
};
|
|
11721
12252
|
var lazyProcessor = (schema, ctx, _json, params) => {
|
|
11722
12253
|
const innerType = schema._zod.innerType;
|
|
11723
|
-
|
|
12254
|
+
process2(innerType, ctx, params);
|
|
11724
12255
|
const seen = ctx.seen.get(schema);
|
|
11725
12256
|
seen.ref = innerType;
|
|
11726
12257
|
};
|
|
@@ -11772,7 +12303,7 @@ function toJSONSchema(input, params) {
|
|
|
11772
12303
|
const defs = {};
|
|
11773
12304
|
for (const entry of registry2._idmap.entries()) {
|
|
11774
12305
|
const [_, schema] = entry;
|
|
11775
|
-
|
|
12306
|
+
process2(schema, ctx2);
|
|
11776
12307
|
}
|
|
11777
12308
|
const schemas = {};
|
|
11778
12309
|
const external = {
|
|
@@ -11795,7 +12326,7 @@ function toJSONSchema(input, params) {
|
|
|
11795
12326
|
return { schemas };
|
|
11796
12327
|
}
|
|
11797
12328
|
const ctx = initializeContext({ ...params, processors: allProcessors });
|
|
11798
|
-
|
|
12329
|
+
process2(input, ctx);
|
|
11799
12330
|
extractDefs(ctx, input);
|
|
11800
12331
|
return finalize(ctx, input);
|
|
11801
12332
|
}
|
|
@@ -11853,7 +12384,7 @@ var JSONSchemaGenerator = class {
|
|
|
11853
12384
|
* This must be called before emit().
|
|
11854
12385
|
*/
|
|
11855
12386
|
process(schema, _params = { path: [], schemaPath: [] }) {
|
|
11856
|
-
return
|
|
12387
|
+
return process2(schema, this.ctx, _params);
|
|
11857
12388
|
}
|
|
11858
12389
|
/**
|
|
11859
12390
|
* Emit the final JSON Schema after processing.
|
|
@@ -14548,12 +15079,185 @@ async function experimental_resolveClaudePluginRoots(args) {
|
|
|
14548
15079
|
});
|
|
14549
15080
|
return { claudeDir: dirs.claudeDir, ...roots };
|
|
14550
15081
|
}
|
|
15082
|
+
|
|
15083
|
+
// ../process-utils/src/index.ts
|
|
15084
|
+
var import_cross_spawn = __toESM(require_cross_spawn(), 1);
|
|
15085
|
+
import { lstat, readdir, readlink, realpath } from "node:fs/promises";
|
|
15086
|
+
import {
|
|
15087
|
+
basename,
|
|
15088
|
+
dirname,
|
|
15089
|
+
isAbsolute,
|
|
15090
|
+
join,
|
|
15091
|
+
relative,
|
|
15092
|
+
resolve,
|
|
15093
|
+
sep
|
|
15094
|
+
} from "node:path";
|
|
15095
|
+
function spawnPortableProcess(request) {
|
|
15096
|
+
return (0, import_cross_spawn.default)(request.command, request.args, {
|
|
15097
|
+
cwd: request.cwd,
|
|
15098
|
+
detached: request.detached,
|
|
15099
|
+
env: request.env,
|
|
15100
|
+
stdio: request.stdio
|
|
15101
|
+
});
|
|
15102
|
+
}
|
|
15103
|
+
function assertPortableOutputProcess(child) {
|
|
15104
|
+
if (child.stdin || !child.stdout || !child.stderr) {
|
|
15105
|
+
throw new Error("Portable child process did not attach output-only stdio");
|
|
15106
|
+
}
|
|
15107
|
+
}
|
|
15108
|
+
function spawnPortableOutputProcess(request) {
|
|
15109
|
+
const child = spawnPortableProcess({
|
|
15110
|
+
...request,
|
|
15111
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
15112
|
+
});
|
|
15113
|
+
assertPortableOutputProcess(child);
|
|
15114
|
+
return child;
|
|
15115
|
+
}
|
|
15116
|
+
function isPathUnderDirectory(candidate, directory) {
|
|
15117
|
+
const normalized = candidate.endsWith(" (deleted)") ? candidate.slice(0, -" (deleted)".length) : candidate;
|
|
15118
|
+
return normalized === directory || normalized.startsWith(`${directory}${sep}`);
|
|
15119
|
+
}
|
|
15120
|
+
async function listLinuxProcessCwds() {
|
|
15121
|
+
const entries = await readdir("/proc");
|
|
15122
|
+
const results = [];
|
|
15123
|
+
await Promise.all(
|
|
15124
|
+
entries.map(async (entry) => {
|
|
15125
|
+
if (!/^\d+$/.test(entry)) {
|
|
15126
|
+
return;
|
|
15127
|
+
}
|
|
15128
|
+
try {
|
|
15129
|
+
const cwd = await readlink(`/proc/${entry}/cwd`);
|
|
15130
|
+
results.push({ pid: Number(entry), cwd });
|
|
15131
|
+
} catch {
|
|
15132
|
+
}
|
|
15133
|
+
})
|
|
15134
|
+
);
|
|
15135
|
+
return results;
|
|
15136
|
+
}
|
|
15137
|
+
async function listLsofProcessCwds() {
|
|
15138
|
+
const child = spawnPortableOutputProcess({
|
|
15139
|
+
command: "lsof",
|
|
15140
|
+
args: ["-a", "-d", "cwd", "-F", "pn", "-w", "-n"]
|
|
15141
|
+
});
|
|
15142
|
+
const chunks = [];
|
|
15143
|
+
child.stdout.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
|
|
15144
|
+
child.stderr.resume();
|
|
15145
|
+
await new Promise((resolveExit) => {
|
|
15146
|
+
child.once("error", () => resolveExit());
|
|
15147
|
+
child.once("exit", () => resolveExit());
|
|
15148
|
+
});
|
|
15149
|
+
const results = [];
|
|
15150
|
+
let pid = null;
|
|
15151
|
+
for (const line of Buffer.concat(chunks).toString("utf8").split("\n")) {
|
|
15152
|
+
if (line.startsWith("p")) {
|
|
15153
|
+
pid = Number(line.slice(1));
|
|
15154
|
+
} else if (line.startsWith("n") && pid !== null) {
|
|
15155
|
+
results.push({ pid, cwd: line.slice(1) });
|
|
15156
|
+
}
|
|
15157
|
+
}
|
|
15158
|
+
return results;
|
|
15159
|
+
}
|
|
15160
|
+
async function resolveSweepDirectory(directory) {
|
|
15161
|
+
const resolved = resolve(directory);
|
|
15162
|
+
let parent = dirname(resolved);
|
|
15163
|
+
try {
|
|
15164
|
+
parent = await realpath(parent);
|
|
15165
|
+
} catch {
|
|
15166
|
+
}
|
|
15167
|
+
const canonical = join(parent, basename(resolved));
|
|
15168
|
+
try {
|
|
15169
|
+
if ((await lstat(canonical)).isSymbolicLink()) {
|
|
15170
|
+
return null;
|
|
15171
|
+
}
|
|
15172
|
+
} catch {
|
|
15173
|
+
}
|
|
15174
|
+
return canonical;
|
|
15175
|
+
}
|
|
15176
|
+
async function listProcessesWithCwdUnder(args) {
|
|
15177
|
+
if (process.platform === "win32") {
|
|
15178
|
+
return [];
|
|
15179
|
+
}
|
|
15180
|
+
const directory = await resolveSweepDirectory(args.directory);
|
|
15181
|
+
if (directory === null) {
|
|
15182
|
+
return [];
|
|
15183
|
+
}
|
|
15184
|
+
const all = process.platform === "linux" ? await listLinuxProcessCwds() : await listLsofProcessCwds();
|
|
15185
|
+
return all.filter(
|
|
15186
|
+
(entry) => entry.pid !== process.pid && isPathUnderDirectory(entry.cwd, directory)
|
|
15187
|
+
);
|
|
15188
|
+
}
|
|
15189
|
+
function isProcessAlive(pid) {
|
|
15190
|
+
try {
|
|
15191
|
+
process.kill(pid, 0);
|
|
15192
|
+
return true;
|
|
15193
|
+
} catch {
|
|
15194
|
+
return false;
|
|
15195
|
+
}
|
|
15196
|
+
}
|
|
15197
|
+
async function delay(ms) {
|
|
15198
|
+
await new Promise((resolveDelay) => setTimeout(resolveDelay, ms));
|
|
15199
|
+
}
|
|
15200
|
+
var MAX_CWD_SWEEP_ROUNDS = 5;
|
|
15201
|
+
function signalProcesses(targets, signal, signalled) {
|
|
15202
|
+
for (const target of targets) {
|
|
15203
|
+
try {
|
|
15204
|
+
process.kill(target.pid, signal);
|
|
15205
|
+
signalled.set(target.pid, target);
|
|
15206
|
+
} catch {
|
|
15207
|
+
}
|
|
15208
|
+
}
|
|
15209
|
+
}
|
|
15210
|
+
async function killProcessesWithCwdUnder(args) {
|
|
15211
|
+
const graceMs = args.graceMs ?? 2e3;
|
|
15212
|
+
const signalled = /* @__PURE__ */ new Map();
|
|
15213
|
+
for (let round = 0; round < MAX_CWD_SWEEP_ROUNDS; round += 1) {
|
|
15214
|
+
const targets = await listProcessesWithCwdUnder({
|
|
15215
|
+
directory: args.directory
|
|
15216
|
+
});
|
|
15217
|
+
if (targets.length === 0) {
|
|
15218
|
+
break;
|
|
15219
|
+
}
|
|
15220
|
+
signalProcesses(targets, "SIGTERM", signalled);
|
|
15221
|
+
const deadline = Date.now() + graceMs;
|
|
15222
|
+
while (Date.now() < deadline && targets.some((target) => isProcessAlive(target.pid))) {
|
|
15223
|
+
await delay(50);
|
|
15224
|
+
}
|
|
15225
|
+
const survivors = await listProcessesWithCwdUnder({
|
|
15226
|
+
directory: args.directory
|
|
15227
|
+
});
|
|
15228
|
+
if (survivors.length === 0) {
|
|
15229
|
+
break;
|
|
15230
|
+
}
|
|
15231
|
+
signalProcesses(survivors, "SIGKILL", signalled);
|
|
15232
|
+
await delay(50);
|
|
15233
|
+
}
|
|
15234
|
+
return Array.from(signalled.values());
|
|
15235
|
+
}
|
|
15236
|
+
function sanitizeInheritedChildProcessEnv(args) {
|
|
15237
|
+
const sanitizedEnv = {};
|
|
15238
|
+
for (const [key, value] of Object.entries(args.env)) {
|
|
15239
|
+
if (value === void 0) {
|
|
15240
|
+
continue;
|
|
15241
|
+
}
|
|
15242
|
+
if (key === "NODE_ENV" || key.startsWith("BB_")) {
|
|
15243
|
+
continue;
|
|
15244
|
+
}
|
|
15245
|
+
sanitizedEnv[key] = value;
|
|
15246
|
+
}
|
|
15247
|
+
if (args.shellPath !== void 0) {
|
|
15248
|
+
sanitizedEnv.PATH = args.shellPath;
|
|
15249
|
+
}
|
|
15250
|
+
return sanitizedEnv;
|
|
15251
|
+
}
|
|
14551
15252
|
export {
|
|
14552
15253
|
experimental_defineHostEntry,
|
|
14553
15254
|
experimental_filterResolvedNativeRoots,
|
|
15255
|
+
killProcessesWithCwdUnder as experimental_killProcessesWithCwdUnder,
|
|
14554
15256
|
experimental_nativeRootsHostContract,
|
|
14555
15257
|
experimental_nativeRootsResolveInputSchema,
|
|
14556
15258
|
experimental_nativeRootsResolveOutputSchema,
|
|
14557
15259
|
experimental_resolveClaudePluginRoots,
|
|
14558
|
-
experimental_resolveVendorPluginRoots
|
|
15260
|
+
experimental_resolveVendorPluginRoots,
|
|
15261
|
+
sanitizeInheritedChildProcessEnv as experimental_sanitizeInheritedChildProcessEnv,
|
|
15262
|
+
spawnPortableOutputProcess as experimental_spawnPortableOutputProcess
|
|
14559
15263
|
};
|