@zqagent/core 0.3.6 → 0.3.8
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/dist/index.cjs +558 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +558 -64
- package/dist/index.js.map +1 -1
- package/dist/internal/update/controller.cjs +1 -1
- package/dist/internal/update/controller.js +1 -1
- package/dist/internal/update/platform.cjs +1 -1
- package/dist/internal/update/platform.js +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2117,8 +2117,8 @@ function toolResultBudget(tool) {
|
|
|
2117
2117
|
return globalBudgetChars() ?? TOOL_MAX_CHARS[tool] ?? DEFAULT_TOOL_RESULT_MAX_CHARS;
|
|
2118
2118
|
}
|
|
2119
2119
|
function toolResultDir() {
|
|
2120
|
-
const
|
|
2121
|
-
return
|
|
2120
|
+
const env2 = process.env.TOOL_RESULT_DIR?.trim();
|
|
2121
|
+
return env2 || path2.join(stateDir(), "tool-results");
|
|
2122
2122
|
}
|
|
2123
2123
|
function clipText(text, budget) {
|
|
2124
2124
|
if (text.length <= budget) return text;
|
|
@@ -4081,21 +4081,21 @@ var import_openai = __toESM(require("openai"), 1);
|
|
|
4081
4081
|
|
|
4082
4082
|
// src/terminal.ts
|
|
4083
4083
|
function detectEmojiSupport(input = {}) {
|
|
4084
|
-
const
|
|
4084
|
+
const env2 = input.env ?? process.env;
|
|
4085
4085
|
const platform = input.platform ?? process.platform;
|
|
4086
4086
|
const isTTY = input.isTTY ?? Boolean(process.stdout.isTTY);
|
|
4087
|
-
const flag = (
|
|
4087
|
+
const flag = (env2.ZQAGENT_EMOJI ?? "").trim().toLowerCase();
|
|
4088
4088
|
if (["0", "false", "no", "off"].includes(flag)) return false;
|
|
4089
4089
|
if (["1", "true", "yes", "on"].includes(flag)) return true;
|
|
4090
|
-
if (
|
|
4091
|
-
if (
|
|
4090
|
+
if (env2.ZQAGENT_ASCII && env2.ZQAGENT_ASCII !== "0") return false;
|
|
4091
|
+
if (env2.NO_EMOJI && env2.NO_EMOJI !== "0") return false;
|
|
4092
4092
|
if (platform !== "win32") return true;
|
|
4093
4093
|
if (!isTTY) return true;
|
|
4094
|
-
if (
|
|
4095
|
-
const termProgram = (
|
|
4094
|
+
if (env2.WT_SESSION) return true;
|
|
4095
|
+
const termProgram = (env2.TERM_PROGRAM ?? "").toLowerCase();
|
|
4096
4096
|
if (termProgram === "vscode" || termProgram === "windows-terminal") return true;
|
|
4097
|
-
if ((
|
|
4098
|
-
const term = (
|
|
4097
|
+
if ((env2.ConEmuANSI ?? "").toUpperCase() === "ON") return true;
|
|
4098
|
+
const term = (env2.TERM ?? "").toLowerCase();
|
|
4099
4099
|
if (term.includes("xterm") || term.includes("mintty")) return true;
|
|
4100
4100
|
return false;
|
|
4101
4101
|
}
|
|
@@ -5966,7 +5966,7 @@ function defaultPermissionConfig() {
|
|
|
5966
5966
|
vcs: { mode: "auto" }
|
|
5967
5967
|
};
|
|
5968
5968
|
}
|
|
5969
|
-
function loadPermissionConfig(workspace,
|
|
5969
|
+
function loadPermissionConfig(workspace, env2 = process.env) {
|
|
5970
5970
|
const cfg = defaultPermissionConfig();
|
|
5971
5971
|
const file = path8.join(workspace, PERMISSION_CONFIG_FILE);
|
|
5972
5972
|
let raw = null;
|
|
@@ -6006,7 +6006,7 @@ function loadPermissionConfig(workspace, env = process.env) {
|
|
|
6006
6006
|
if (VCS_MODES.has(m)) cfg.vcs.mode = m;
|
|
6007
6007
|
}
|
|
6008
6008
|
}
|
|
6009
|
-
const envPolicy = String(
|
|
6009
|
+
const envPolicy = String(env2.ZQAGENT_SHELL_POLICY ?? "").trim().toLowerCase();
|
|
6010
6010
|
if (SHELL_POLICIES.has(envPolicy)) cfg.shellPolicy = envPolicy;
|
|
6011
6011
|
return cfg;
|
|
6012
6012
|
}
|
|
@@ -6016,20 +6016,20 @@ var import_node_child_process = require("child_process");
|
|
|
6016
6016
|
var fs7 = __toESM(require("fs"), 1);
|
|
6017
6017
|
var os3 = __toESM(require("os"), 1);
|
|
6018
6018
|
var path9 = __toESM(require("path"), 1);
|
|
6019
|
-
function expandHome(p,
|
|
6020
|
-
if (p === "~") return
|
|
6019
|
+
function expandHome(p, env2) {
|
|
6020
|
+
if (p === "~") return env2.HOME ?? p;
|
|
6021
6021
|
if (p.startsWith("~/") || p.startsWith("~\\")) {
|
|
6022
|
-
return path9.join(
|
|
6022
|
+
return path9.join(env2.HOME ?? "~", p.slice(2));
|
|
6023
6023
|
}
|
|
6024
6024
|
return p;
|
|
6025
6025
|
}
|
|
6026
|
-
function toolchainWritable(platform,
|
|
6027
|
-
const home =
|
|
6026
|
+
function toolchainWritable(platform, env2) {
|
|
6027
|
+
const home = env2.HOME ?? os3.homedir();
|
|
6028
6028
|
const rel = platform === "darwin" ? ["Library/pnpm", "Library/Caches", ".npm", ".cache"] : [".npm", ".cache", ".local/share/pnpm", ".local/state/pnpm", ".pnpm-store"];
|
|
6029
6029
|
return rel.map((r) => path9.join(home, r));
|
|
6030
6030
|
}
|
|
6031
|
-
function addToolchainWritable(platform,
|
|
6032
|
-
for (const dir of toolchainWritable(platform,
|
|
6031
|
+
function addToolchainWritable(platform, env2, add, exists) {
|
|
6032
|
+
for (const dir of toolchainWritable(platform, env2)) {
|
|
6033
6033
|
if (exists(dir)) add(dir);
|
|
6034
6034
|
}
|
|
6035
6035
|
}
|
|
@@ -6082,9 +6082,9 @@ function normalizeMode(raw) {
|
|
|
6082
6082
|
var planCache = /* @__PURE__ */ new Map();
|
|
6083
6083
|
function resolveSandbox(opts = {}) {
|
|
6084
6084
|
const platform = opts.platform ?? process.platform;
|
|
6085
|
-
const
|
|
6085
|
+
const env2 = opts.env ?? process.env;
|
|
6086
6086
|
const workspace = path9.resolve(opts.workspace ?? process.cwd());
|
|
6087
|
-
const mode = normalizeMode(opts.mode ??
|
|
6087
|
+
const mode = normalizeMode(opts.mode ?? env2.ZQAGENT_SANDBOX);
|
|
6088
6088
|
const extraWritable = opts.extraWritable ?? [];
|
|
6089
6089
|
const pathExists = opts.fileExists ?? ((p) => {
|
|
6090
6090
|
try {
|
|
@@ -6097,7 +6097,7 @@ function resolveSandbox(opts = {}) {
|
|
|
6097
6097
|
workspace,
|
|
6098
6098
|
extraWritable,
|
|
6099
6099
|
platform,
|
|
6100
|
-
env,
|
|
6100
|
+
env: env2,
|
|
6101
6101
|
exists: pathExists
|
|
6102
6102
|
});
|
|
6103
6103
|
const cacheKey = [
|
|
@@ -6216,8 +6216,502 @@ function resetSandboxCache() {
|
|
|
6216
6216
|
planCache.clear();
|
|
6217
6217
|
}
|
|
6218
6218
|
|
|
6219
|
+
// ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
6220
|
+
var ANSI_BACKGROUND_OFFSET = 10;
|
|
6221
|
+
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
6222
|
+
var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
|
6223
|
+
var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
|
|
6224
|
+
var styles = {
|
|
6225
|
+
modifier: {
|
|
6226
|
+
reset: [0, 0],
|
|
6227
|
+
// 21 isn't widely supported and 22 does the same thing
|
|
6228
|
+
bold: [1, 22],
|
|
6229
|
+
dim: [2, 22],
|
|
6230
|
+
italic: [3, 23],
|
|
6231
|
+
underline: [4, 24],
|
|
6232
|
+
overline: [53, 55],
|
|
6233
|
+
inverse: [7, 27],
|
|
6234
|
+
hidden: [8, 28],
|
|
6235
|
+
strikethrough: [9, 29]
|
|
6236
|
+
},
|
|
6237
|
+
color: {
|
|
6238
|
+
black: [30, 39],
|
|
6239
|
+
red: [31, 39],
|
|
6240
|
+
green: [32, 39],
|
|
6241
|
+
yellow: [33, 39],
|
|
6242
|
+
blue: [34, 39],
|
|
6243
|
+
magenta: [35, 39],
|
|
6244
|
+
cyan: [36, 39],
|
|
6245
|
+
white: [37, 39],
|
|
6246
|
+
// Bright color
|
|
6247
|
+
blackBright: [90, 39],
|
|
6248
|
+
gray: [90, 39],
|
|
6249
|
+
// Alias of `blackBright`
|
|
6250
|
+
grey: [90, 39],
|
|
6251
|
+
// Alias of `blackBright`
|
|
6252
|
+
redBright: [91, 39],
|
|
6253
|
+
greenBright: [92, 39],
|
|
6254
|
+
yellowBright: [93, 39],
|
|
6255
|
+
blueBright: [94, 39],
|
|
6256
|
+
magentaBright: [95, 39],
|
|
6257
|
+
cyanBright: [96, 39],
|
|
6258
|
+
whiteBright: [97, 39]
|
|
6259
|
+
},
|
|
6260
|
+
bgColor: {
|
|
6261
|
+
bgBlack: [40, 49],
|
|
6262
|
+
bgRed: [41, 49],
|
|
6263
|
+
bgGreen: [42, 49],
|
|
6264
|
+
bgYellow: [43, 49],
|
|
6265
|
+
bgBlue: [44, 49],
|
|
6266
|
+
bgMagenta: [45, 49],
|
|
6267
|
+
bgCyan: [46, 49],
|
|
6268
|
+
bgWhite: [47, 49],
|
|
6269
|
+
// Bright color
|
|
6270
|
+
bgBlackBright: [100, 49],
|
|
6271
|
+
bgGray: [100, 49],
|
|
6272
|
+
// Alias of `bgBlackBright`
|
|
6273
|
+
bgGrey: [100, 49],
|
|
6274
|
+
// Alias of `bgBlackBright`
|
|
6275
|
+
bgRedBright: [101, 49],
|
|
6276
|
+
bgGreenBright: [102, 49],
|
|
6277
|
+
bgYellowBright: [103, 49],
|
|
6278
|
+
bgBlueBright: [104, 49],
|
|
6279
|
+
bgMagentaBright: [105, 49],
|
|
6280
|
+
bgCyanBright: [106, 49],
|
|
6281
|
+
bgWhiteBright: [107, 49]
|
|
6282
|
+
}
|
|
6283
|
+
};
|
|
6284
|
+
var modifierNames = Object.keys(styles.modifier);
|
|
6285
|
+
var foregroundColorNames = Object.keys(styles.color);
|
|
6286
|
+
var backgroundColorNames = Object.keys(styles.bgColor);
|
|
6287
|
+
var colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
|
6288
|
+
function assembleStyles() {
|
|
6289
|
+
const codes = /* @__PURE__ */ new Map();
|
|
6290
|
+
for (const [groupName, group] of Object.entries(styles)) {
|
|
6291
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
6292
|
+
styles[styleName] = {
|
|
6293
|
+
open: `\x1B[${style[0]}m`,
|
|
6294
|
+
close: `\x1B[${style[1]}m`
|
|
6295
|
+
};
|
|
6296
|
+
group[styleName] = styles[styleName];
|
|
6297
|
+
codes.set(style[0], style[1]);
|
|
6298
|
+
}
|
|
6299
|
+
Object.defineProperty(styles, groupName, {
|
|
6300
|
+
value: group,
|
|
6301
|
+
enumerable: false
|
|
6302
|
+
});
|
|
6303
|
+
}
|
|
6304
|
+
Object.defineProperty(styles, "codes", {
|
|
6305
|
+
value: codes,
|
|
6306
|
+
enumerable: false
|
|
6307
|
+
});
|
|
6308
|
+
styles.color.close = "\x1B[39m";
|
|
6309
|
+
styles.bgColor.close = "\x1B[49m";
|
|
6310
|
+
styles.color.ansi = wrapAnsi16();
|
|
6311
|
+
styles.color.ansi256 = wrapAnsi256();
|
|
6312
|
+
styles.color.ansi16m = wrapAnsi16m();
|
|
6313
|
+
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
6314
|
+
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
|
6315
|
+
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
6316
|
+
Object.defineProperties(styles, {
|
|
6317
|
+
rgbToAnsi256: {
|
|
6318
|
+
value(red, green, blue) {
|
|
6319
|
+
if (red === green && green === blue) {
|
|
6320
|
+
if (red < 8) {
|
|
6321
|
+
return 16;
|
|
6322
|
+
}
|
|
6323
|
+
if (red > 248) {
|
|
6324
|
+
return 231;
|
|
6325
|
+
}
|
|
6326
|
+
return Math.round((red - 8) / 247 * 24) + 232;
|
|
6327
|
+
}
|
|
6328
|
+
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
|
|
6329
|
+
},
|
|
6330
|
+
enumerable: false
|
|
6331
|
+
},
|
|
6332
|
+
hexToRgb: {
|
|
6333
|
+
value(hex) {
|
|
6334
|
+
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
6335
|
+
if (!matches) {
|
|
6336
|
+
return [0, 0, 0];
|
|
6337
|
+
}
|
|
6338
|
+
let [colorString] = matches;
|
|
6339
|
+
if (colorString.length === 3) {
|
|
6340
|
+
colorString = [...colorString].map((character) => character + character).join("");
|
|
6341
|
+
}
|
|
6342
|
+
const integer = Number.parseInt(colorString, 16);
|
|
6343
|
+
return [
|
|
6344
|
+
/* eslint-disable no-bitwise */
|
|
6345
|
+
integer >> 16 & 255,
|
|
6346
|
+
integer >> 8 & 255,
|
|
6347
|
+
integer & 255
|
|
6348
|
+
/* eslint-enable no-bitwise */
|
|
6349
|
+
];
|
|
6350
|
+
},
|
|
6351
|
+
enumerable: false
|
|
6352
|
+
},
|
|
6353
|
+
hexToAnsi256: {
|
|
6354
|
+
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
|
6355
|
+
enumerable: false
|
|
6356
|
+
},
|
|
6357
|
+
ansi256ToAnsi: {
|
|
6358
|
+
value(code) {
|
|
6359
|
+
if (code < 8) {
|
|
6360
|
+
return 30 + code;
|
|
6361
|
+
}
|
|
6362
|
+
if (code < 16) {
|
|
6363
|
+
return 90 + (code - 8);
|
|
6364
|
+
}
|
|
6365
|
+
let red;
|
|
6366
|
+
let green;
|
|
6367
|
+
let blue;
|
|
6368
|
+
if (code >= 232) {
|
|
6369
|
+
red = ((code - 232) * 10 + 8) / 255;
|
|
6370
|
+
green = red;
|
|
6371
|
+
blue = red;
|
|
6372
|
+
} else {
|
|
6373
|
+
code -= 16;
|
|
6374
|
+
const remainder = code % 36;
|
|
6375
|
+
red = Math.floor(code / 36) / 5;
|
|
6376
|
+
green = Math.floor(remainder / 6) / 5;
|
|
6377
|
+
blue = remainder % 6 / 5;
|
|
6378
|
+
}
|
|
6379
|
+
const value = Math.max(red, green, blue) * 2;
|
|
6380
|
+
if (value === 0) {
|
|
6381
|
+
return 30;
|
|
6382
|
+
}
|
|
6383
|
+
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
|
|
6384
|
+
if (value === 2) {
|
|
6385
|
+
result += 60;
|
|
6386
|
+
}
|
|
6387
|
+
return result;
|
|
6388
|
+
},
|
|
6389
|
+
enumerable: false
|
|
6390
|
+
},
|
|
6391
|
+
rgbToAnsi: {
|
|
6392
|
+
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
|
6393
|
+
enumerable: false
|
|
6394
|
+
},
|
|
6395
|
+
hexToAnsi: {
|
|
6396
|
+
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
|
6397
|
+
enumerable: false
|
|
6398
|
+
}
|
|
6399
|
+
});
|
|
6400
|
+
return styles;
|
|
6401
|
+
}
|
|
6402
|
+
var ansiStyles = assembleStyles();
|
|
6403
|
+
var ansi_styles_default = ansiStyles;
|
|
6404
|
+
|
|
6405
|
+
// ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.js
|
|
6406
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
6407
|
+
var import_node_os = __toESM(require("os"), 1);
|
|
6408
|
+
var import_node_tty = __toESM(require("tty"), 1);
|
|
6409
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
|
|
6410
|
+
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
6411
|
+
const position = argv.indexOf(prefix + flag);
|
|
6412
|
+
const terminatorPosition = argv.indexOf("--");
|
|
6413
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
6414
|
+
}
|
|
6415
|
+
var { env } = import_node_process.default;
|
|
6416
|
+
var flagForceColor;
|
|
6417
|
+
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
6418
|
+
flagForceColor = 0;
|
|
6419
|
+
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
6420
|
+
flagForceColor = 1;
|
|
6421
|
+
}
|
|
6422
|
+
function envForceColor() {
|
|
6423
|
+
if ("FORCE_COLOR" in env) {
|
|
6424
|
+
if (env.FORCE_COLOR === "true") {
|
|
6425
|
+
return 1;
|
|
6426
|
+
}
|
|
6427
|
+
if (env.FORCE_COLOR === "false") {
|
|
6428
|
+
return 0;
|
|
6429
|
+
}
|
|
6430
|
+
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
6431
|
+
}
|
|
6432
|
+
}
|
|
6433
|
+
function translateLevel(level) {
|
|
6434
|
+
if (level === 0) {
|
|
6435
|
+
return false;
|
|
6436
|
+
}
|
|
6437
|
+
return {
|
|
6438
|
+
level,
|
|
6439
|
+
hasBasic: true,
|
|
6440
|
+
has256: level >= 2,
|
|
6441
|
+
has16m: level >= 3
|
|
6442
|
+
};
|
|
6443
|
+
}
|
|
6444
|
+
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
6445
|
+
const noFlagForceColor = envForceColor();
|
|
6446
|
+
if (noFlagForceColor !== void 0) {
|
|
6447
|
+
flagForceColor = noFlagForceColor;
|
|
6448
|
+
}
|
|
6449
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
6450
|
+
if (forceColor === 0) {
|
|
6451
|
+
return 0;
|
|
6452
|
+
}
|
|
6453
|
+
if (sniffFlags) {
|
|
6454
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
6455
|
+
return 3;
|
|
6456
|
+
}
|
|
6457
|
+
if (hasFlag("color=256")) {
|
|
6458
|
+
return 2;
|
|
6459
|
+
}
|
|
6460
|
+
}
|
|
6461
|
+
if ("TF_BUILD" in env && "AGENT_NAME" in env) {
|
|
6462
|
+
return 1;
|
|
6463
|
+
}
|
|
6464
|
+
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
6465
|
+
return 0;
|
|
6466
|
+
}
|
|
6467
|
+
const min = forceColor || 0;
|
|
6468
|
+
if (env.TERM === "dumb") {
|
|
6469
|
+
return min;
|
|
6470
|
+
}
|
|
6471
|
+
if (import_node_process.default.platform === "win32") {
|
|
6472
|
+
const osRelease = import_node_os.default.release().split(".");
|
|
6473
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
6474
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
6475
|
+
}
|
|
6476
|
+
return 1;
|
|
6477
|
+
}
|
|
6478
|
+
if ("CI" in env) {
|
|
6479
|
+
if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
|
|
6480
|
+
return 3;
|
|
6481
|
+
}
|
|
6482
|
+
if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
6483
|
+
return 1;
|
|
6484
|
+
}
|
|
6485
|
+
return min;
|
|
6486
|
+
}
|
|
6487
|
+
if ("TEAMCITY_VERSION" in env) {
|
|
6488
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
6489
|
+
}
|
|
6490
|
+
if (env.COLORTERM === "truecolor") {
|
|
6491
|
+
return 3;
|
|
6492
|
+
}
|
|
6493
|
+
if (env.TERM === "xterm-kitty") {
|
|
6494
|
+
return 3;
|
|
6495
|
+
}
|
|
6496
|
+
if (env.TERM === "xterm-ghostty") {
|
|
6497
|
+
return 3;
|
|
6498
|
+
}
|
|
6499
|
+
if (env.TERM === "wezterm") {
|
|
6500
|
+
return 3;
|
|
6501
|
+
}
|
|
6502
|
+
if ("TERM_PROGRAM" in env) {
|
|
6503
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
6504
|
+
switch (env.TERM_PROGRAM) {
|
|
6505
|
+
case "iTerm.app": {
|
|
6506
|
+
return version >= 3 ? 3 : 2;
|
|
6507
|
+
}
|
|
6508
|
+
case "Apple_Terminal": {
|
|
6509
|
+
return 2;
|
|
6510
|
+
}
|
|
6511
|
+
}
|
|
6512
|
+
}
|
|
6513
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
6514
|
+
return 2;
|
|
6515
|
+
}
|
|
6516
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
6517
|
+
return 1;
|
|
6518
|
+
}
|
|
6519
|
+
if ("COLORTERM" in env) {
|
|
6520
|
+
return 1;
|
|
6521
|
+
}
|
|
6522
|
+
return min;
|
|
6523
|
+
}
|
|
6524
|
+
function createSupportsColor(stream, options = {}) {
|
|
6525
|
+
const level = _supportsColor(stream, {
|
|
6526
|
+
streamIsTTY: stream && stream.isTTY,
|
|
6527
|
+
...options
|
|
6528
|
+
});
|
|
6529
|
+
return translateLevel(level);
|
|
6530
|
+
}
|
|
6531
|
+
var supportsColor = {
|
|
6532
|
+
stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
|
|
6533
|
+
stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
|
|
6534
|
+
};
|
|
6535
|
+
var supports_color_default = supportsColor;
|
|
6536
|
+
|
|
6537
|
+
// ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/utilities.js
|
|
6538
|
+
function stringReplaceAll(string, substring, replacer) {
|
|
6539
|
+
let index = string.indexOf(substring);
|
|
6540
|
+
if (index === -1) {
|
|
6541
|
+
return string;
|
|
6542
|
+
}
|
|
6543
|
+
const substringLength = substring.length;
|
|
6544
|
+
let endIndex = 0;
|
|
6545
|
+
let returnValue = "";
|
|
6546
|
+
do {
|
|
6547
|
+
returnValue += string.slice(endIndex, index) + substring + replacer;
|
|
6548
|
+
endIndex = index + substringLength;
|
|
6549
|
+
index = string.indexOf(substring, endIndex);
|
|
6550
|
+
} while (index !== -1);
|
|
6551
|
+
returnValue += string.slice(endIndex);
|
|
6552
|
+
return returnValue;
|
|
6553
|
+
}
|
|
6554
|
+
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
6555
|
+
let endIndex = 0;
|
|
6556
|
+
let returnValue = "";
|
|
6557
|
+
do {
|
|
6558
|
+
const gotCR = string[index - 1] === "\r";
|
|
6559
|
+
returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
6560
|
+
endIndex = index + 1;
|
|
6561
|
+
index = string.indexOf("\n", endIndex);
|
|
6562
|
+
} while (index !== -1);
|
|
6563
|
+
returnValue += string.slice(endIndex);
|
|
6564
|
+
return returnValue;
|
|
6565
|
+
}
|
|
6566
|
+
|
|
6567
|
+
// ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.js
|
|
6568
|
+
var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
|
|
6569
|
+
var GENERATOR = /* @__PURE__ */ Symbol("GENERATOR");
|
|
6570
|
+
var STYLER = /* @__PURE__ */ Symbol("STYLER");
|
|
6571
|
+
var IS_EMPTY = /* @__PURE__ */ Symbol("IS_EMPTY");
|
|
6572
|
+
var levelMapping = [
|
|
6573
|
+
"ansi",
|
|
6574
|
+
"ansi",
|
|
6575
|
+
"ansi256",
|
|
6576
|
+
"ansi16m"
|
|
6577
|
+
];
|
|
6578
|
+
var styles2 = /* @__PURE__ */ Object.create(null);
|
|
6579
|
+
var applyOptions = (object, options = {}) => {
|
|
6580
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
6581
|
+
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
6582
|
+
}
|
|
6583
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
6584
|
+
object.level = options.level === void 0 ? colorLevel : options.level;
|
|
6585
|
+
};
|
|
6586
|
+
var chalkFactory = (options) => {
|
|
6587
|
+
const chalk2 = (...strings) => strings.join(" ");
|
|
6588
|
+
applyOptions(chalk2, options);
|
|
6589
|
+
Object.setPrototypeOf(chalk2, createChalk.prototype);
|
|
6590
|
+
return chalk2;
|
|
6591
|
+
};
|
|
6592
|
+
function createChalk(options) {
|
|
6593
|
+
return chalkFactory(options);
|
|
6594
|
+
}
|
|
6595
|
+
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
6596
|
+
for (const [styleName, style] of Object.entries(ansi_styles_default)) {
|
|
6597
|
+
styles2[styleName] = {
|
|
6598
|
+
get() {
|
|
6599
|
+
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
|
6600
|
+
Object.defineProperty(this, styleName, { value: builder });
|
|
6601
|
+
return builder;
|
|
6602
|
+
}
|
|
6603
|
+
};
|
|
6604
|
+
}
|
|
6605
|
+
styles2.visible = {
|
|
6606
|
+
get() {
|
|
6607
|
+
const builder = createBuilder(this, this[STYLER], true);
|
|
6608
|
+
Object.defineProperty(this, "visible", { value: builder });
|
|
6609
|
+
return builder;
|
|
6610
|
+
}
|
|
6611
|
+
};
|
|
6612
|
+
var getModelAnsi = (model, level, type, ...arguments_) => {
|
|
6613
|
+
if (model === "rgb") {
|
|
6614
|
+
if (level === "ansi16m") {
|
|
6615
|
+
return ansi_styles_default[type].ansi16m(...arguments_);
|
|
6616
|
+
}
|
|
6617
|
+
if (level === "ansi256") {
|
|
6618
|
+
return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
|
|
6619
|
+
}
|
|
6620
|
+
return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
|
|
6621
|
+
}
|
|
6622
|
+
if (model === "hex") {
|
|
6623
|
+
return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
|
|
6624
|
+
}
|
|
6625
|
+
return ansi_styles_default[type][model](...arguments_);
|
|
6626
|
+
};
|
|
6627
|
+
var usedModels = ["rgb", "hex", "ansi256"];
|
|
6628
|
+
for (const model of usedModels) {
|
|
6629
|
+
styles2[model] = {
|
|
6630
|
+
get() {
|
|
6631
|
+
const { level } = this;
|
|
6632
|
+
return function(...arguments_) {
|
|
6633
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
|
|
6634
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
6635
|
+
};
|
|
6636
|
+
}
|
|
6637
|
+
};
|
|
6638
|
+
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
6639
|
+
styles2[bgModel] = {
|
|
6640
|
+
get() {
|
|
6641
|
+
const { level } = this;
|
|
6642
|
+
return function(...arguments_) {
|
|
6643
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
|
|
6644
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
6645
|
+
};
|
|
6646
|
+
}
|
|
6647
|
+
};
|
|
6648
|
+
}
|
|
6649
|
+
var proto = Object.defineProperties(() => {
|
|
6650
|
+
}, {
|
|
6651
|
+
...styles2,
|
|
6652
|
+
level: {
|
|
6653
|
+
enumerable: true,
|
|
6654
|
+
get() {
|
|
6655
|
+
return this[GENERATOR].level;
|
|
6656
|
+
},
|
|
6657
|
+
set(level) {
|
|
6658
|
+
this[GENERATOR].level = level;
|
|
6659
|
+
}
|
|
6660
|
+
}
|
|
6661
|
+
});
|
|
6662
|
+
var createStyler = (open, close, parent) => {
|
|
6663
|
+
let openAll;
|
|
6664
|
+
let closeAll;
|
|
6665
|
+
if (parent === void 0) {
|
|
6666
|
+
openAll = open;
|
|
6667
|
+
closeAll = close;
|
|
6668
|
+
} else {
|
|
6669
|
+
openAll = parent.openAll + open;
|
|
6670
|
+
closeAll = close + parent.closeAll;
|
|
6671
|
+
}
|
|
6672
|
+
return {
|
|
6673
|
+
open,
|
|
6674
|
+
close,
|
|
6675
|
+
openAll,
|
|
6676
|
+
closeAll,
|
|
6677
|
+
parent
|
|
6678
|
+
};
|
|
6679
|
+
};
|
|
6680
|
+
var createBuilder = (self, _styler, _isEmpty) => {
|
|
6681
|
+
const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
6682
|
+
Object.setPrototypeOf(builder, proto);
|
|
6683
|
+
builder[GENERATOR] = self;
|
|
6684
|
+
builder[STYLER] = _styler;
|
|
6685
|
+
builder[IS_EMPTY] = _isEmpty;
|
|
6686
|
+
return builder;
|
|
6687
|
+
};
|
|
6688
|
+
var applyStyle = (self, string) => {
|
|
6689
|
+
if (self.level <= 0 || !string) {
|
|
6690
|
+
return self[IS_EMPTY] ? "" : string;
|
|
6691
|
+
}
|
|
6692
|
+
let styler = self[STYLER];
|
|
6693
|
+
if (styler === void 0) {
|
|
6694
|
+
return string;
|
|
6695
|
+
}
|
|
6696
|
+
const { openAll, closeAll } = styler;
|
|
6697
|
+
if (string.includes("\x1B")) {
|
|
6698
|
+
while (styler !== void 0) {
|
|
6699
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
|
6700
|
+
styler = styler.parent;
|
|
6701
|
+
}
|
|
6702
|
+
}
|
|
6703
|
+
const lfIndex = string.indexOf("\n");
|
|
6704
|
+
if (lfIndex !== -1) {
|
|
6705
|
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
6706
|
+
}
|
|
6707
|
+
return openAll + string + closeAll;
|
|
6708
|
+
};
|
|
6709
|
+
Object.defineProperties(createChalk.prototype, styles2);
|
|
6710
|
+
var chalk = createChalk();
|
|
6711
|
+
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
6712
|
+
var source_default = chalk;
|
|
6713
|
+
|
|
6219
6714
|
// src/engine/MarkdownRenderer.ts
|
|
6220
|
-
var import_chalk = __toESM(require("chalk"), 1);
|
|
6221
6715
|
var import_cli_highlight = require("cli-highlight");
|
|
6222
6716
|
var import_cli_table3 = __toESM(require("cli-table3"), 1);
|
|
6223
6717
|
var import_markdown_it = __toESM(require("markdown-it"), 1);
|
|
@@ -6277,7 +6771,7 @@ var MarkdownRenderer = class {
|
|
|
6277
6771
|
/** 当前链接 href(link_open 记录,link_close 消费) */
|
|
6278
6772
|
_pendingLinkHref = "";
|
|
6279
6773
|
constructor(opts = {}) {
|
|
6280
|
-
this._color = opts.color ??
|
|
6774
|
+
this._color = opts.color ?? source_default.level > 0;
|
|
6281
6775
|
this._unicode = opts.unicode ?? true;
|
|
6282
6776
|
this._gray = opts.gray ?? false;
|
|
6283
6777
|
}
|
|
@@ -7273,7 +7767,7 @@ var import_types3 = require("@modelcontextprotocol/sdk/types.js");
|
|
|
7273
7767
|
|
|
7274
7768
|
// src/mcp/builtin/ocrEngine.ts
|
|
7275
7769
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
7276
|
-
var
|
|
7770
|
+
var import_node_os2 = __toESM(require("os"), 1);
|
|
7277
7771
|
var import_node_path = __toESM(require("path"), 1);
|
|
7278
7772
|
var import_node_child_process2 = require("child_process");
|
|
7279
7773
|
var import_openai2 = __toESM(require("openai"), 1);
|
|
@@ -7393,14 +7887,14 @@ function resolveRequested(requested, ctx, execPath) {
|
|
|
7393
7887
|
}
|
|
7394
7888
|
function resolveShellSpec(opts = {}) {
|
|
7395
7889
|
const platform = opts.platform ?? process.platform;
|
|
7396
|
-
const
|
|
7890
|
+
const env2 = opts.env ?? process.env;
|
|
7397
7891
|
const execPath = opts.execPath ?? process.execPath;
|
|
7398
7892
|
const ctx = {
|
|
7399
7893
|
platform,
|
|
7400
|
-
env,
|
|
7894
|
+
env: env2,
|
|
7401
7895
|
fileExists: opts.fileExists ?? defaultFileExists
|
|
7402
7896
|
};
|
|
7403
|
-
const requested = (
|
|
7897
|
+
const requested = (env2.ZQAGENT_SHELL ?? "").trim();
|
|
7404
7898
|
if (requested && requested.toLowerCase() !== "auto") {
|
|
7405
7899
|
return resolveRequested(requested, ctx, execPath);
|
|
7406
7900
|
}
|
|
@@ -7413,7 +7907,7 @@ function resolveShellSpec(opts = {}) {
|
|
|
7413
7907
|
if (bash) return makeSpec("sh", bash, "bash (Git for Windows)");
|
|
7414
7908
|
const shell = findExecutable("pwsh", ctx) ?? findExecutable("powershell", ctx);
|
|
7415
7909
|
if (shell) return makeSpec("powershell", shell, "PowerShell");
|
|
7416
|
-
return makeSpec("default", null,
|
|
7910
|
+
return makeSpec("default", null, env2.ComSpec ?? env2.COMSPEC ?? "cmd.exe");
|
|
7417
7911
|
}
|
|
7418
7912
|
function wrapCommand(kind, command, platform = process.platform) {
|
|
7419
7913
|
if (kind === "powershell") {
|
|
@@ -7562,8 +8056,8 @@ ${stderr.trim()}` : ""}`;
|
|
|
7562
8056
|
function makeRuntime(ctx) {
|
|
7563
8057
|
const overrides = ctx.ocr ?? {};
|
|
7564
8058
|
const platform = overrides.platform ?? process.platform;
|
|
7565
|
-
const
|
|
7566
|
-
const workspace = ctx.workspace ??
|
|
8059
|
+
const env2 = overrides.env ?? ctx.env ?? process.env;
|
|
8060
|
+
const workspace = ctx.workspace ?? env2.WORKSPACE ?? process.cwd();
|
|
7567
8061
|
const fileExists = overrides.fileExists ?? ((p) => {
|
|
7568
8062
|
try {
|
|
7569
8063
|
return import_node_fs.default.statSync(p).isFile();
|
|
@@ -7571,10 +8065,10 @@ function makeRuntime(ctx) {
|
|
|
7571
8065
|
return false;
|
|
7572
8066
|
}
|
|
7573
8067
|
});
|
|
7574
|
-
const which = overrides.which ?? ((name) => findExecutable(name, { platform, env, fileExists }));
|
|
8068
|
+
const which = overrides.which ?? ((name) => findExecutable(name, { platform, env: env2, fileExists }));
|
|
7575
8069
|
return {
|
|
7576
8070
|
platform,
|
|
7577
|
-
env,
|
|
8071
|
+
env: env2,
|
|
7578
8072
|
workspace,
|
|
7579
8073
|
llm: ctx.llm,
|
|
7580
8074
|
overrides,
|
|
@@ -7645,7 +8139,7 @@ async function downloadToFile(url, dest, runtime) {
|
|
|
7645
8139
|
import_node_fs.default.writeFileSync(dest, Buffer.from(await res.arrayBuffer()));
|
|
7646
8140
|
}
|
|
7647
8141
|
async function materializeInput(input, runtime) {
|
|
7648
|
-
const root = runtime.overrides.tmpDir ??
|
|
8142
|
+
const root = runtime.overrides.tmpDir ?? import_node_os2.default.tmpdir();
|
|
7649
8143
|
const tmpDir = import_node_fs.default.mkdtempSync(import_node_path.default.join(root, "zqagent-ocr-"));
|
|
7650
8144
|
const cleanup = () => {
|
|
7651
8145
|
try {
|
|
@@ -8424,9 +8918,9 @@ var McpManager = class {
|
|
|
8424
8918
|
const cfg = this.options.lazy ?? {};
|
|
8425
8919
|
if (cfg.enabled === true) return true;
|
|
8426
8920
|
if (cfg.enabled === false) return false;
|
|
8427
|
-
const
|
|
8428
|
-
if (["1", "true", "on", "yes"].includes(
|
|
8429
|
-
if (["0", "false", "off", "no"].includes(
|
|
8921
|
+
const env2 = (process.env.ZQAGENT_MCP_LAZY ?? "").toLowerCase();
|
|
8922
|
+
if (["1", "true", "on", "yes"].includes(env2)) return true;
|
|
8923
|
+
if (["0", "false", "off", "no"].includes(env2)) return false;
|
|
8430
8924
|
let count = 0;
|
|
8431
8925
|
let chars = 0;
|
|
8432
8926
|
for (const tools of this.toolIndex.values()) {
|
|
@@ -8747,11 +9241,11 @@ function splitCommandLine(input) {
|
|
|
8747
9241
|
if (cur) out.push(cur);
|
|
8748
9242
|
return out;
|
|
8749
9243
|
}
|
|
8750
|
-
function expandEnv(value,
|
|
9244
|
+
function expandEnv(value, env2, name, warnings) {
|
|
8751
9245
|
return value.replace(
|
|
8752
9246
|
/\$\{(?:env:)?([A-Za-z_][A-Za-z0-9_]*)\}/g,
|
|
8753
9247
|
(_m, key) => {
|
|
8754
|
-
const v =
|
|
9248
|
+
const v = env2[key];
|
|
8755
9249
|
if (v === void 0) {
|
|
8756
9250
|
warnings.push(`"${name}" \u5F15\u7528\u4E86\u672A\u5B9A\u4E49\u7684\u73AF\u5883\u53D8\u91CF \${${key}}`);
|
|
8757
9251
|
return "";
|
|
@@ -8760,7 +9254,7 @@ function expandEnv(value, env, name, warnings) {
|
|
|
8760
9254
|
}
|
|
8761
9255
|
);
|
|
8762
9256
|
}
|
|
8763
|
-
function toStringMap(raw, field, name,
|
|
9257
|
+
function toStringMap(raw, field, name, env2, warnings) {
|
|
8764
9258
|
if (raw === void 0 || raw === null) return void 0;
|
|
8765
9259
|
if (typeof raw !== "object" || Array.isArray(raw)) {
|
|
8766
9260
|
warnings.push(`"${name}".${field} \u5E94\u4E3A\u5BF9\u8C61\uFF0C\u5DF2\u5FFD\u7565`);
|
|
@@ -8769,7 +9263,7 @@ function toStringMap(raw, field, name, env, warnings) {
|
|
|
8769
9263
|
const out = {};
|
|
8770
9264
|
for (const [k, v] of Object.entries(raw)) {
|
|
8771
9265
|
if (v === void 0 || v === null) continue;
|
|
8772
|
-
if (typeof v === "string") out[k] = expandEnv(v,
|
|
9266
|
+
if (typeof v === "string") out[k] = expandEnv(v, env2, name, warnings);
|
|
8773
9267
|
else if (typeof v === "number" || typeof v === "boolean")
|
|
8774
9268
|
out[k] = String(v);
|
|
8775
9269
|
else warnings.push(`"${name}".${field}.${k} \u4E0D\u662F\u5B57\u7B26\u4E32\uFF0C\u5DF2\u5FFD\u7565`);
|
|
@@ -8777,7 +9271,7 @@ function toStringMap(raw, field, name, env, warnings) {
|
|
|
8777
9271
|
return Object.keys(out).length > 0 ? out : void 0;
|
|
8778
9272
|
}
|
|
8779
9273
|
function normalizeMcpConfig(raw, fallbackName, opts = {}, warnings = []) {
|
|
8780
|
-
const
|
|
9274
|
+
const env2 = opts.env ?? process.env;
|
|
8781
9275
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
8782
9276
|
warnings.push(`MCP \u914D\u7F6E\u6761\u76EE${fallbackName ? ` "${fallbackName}"` : ""} \u4E0D\u662F\u5BF9\u8C61\uFF0C\u5DF2\u8DF3\u8FC7`);
|
|
8783
9277
|
return null;
|
|
@@ -8825,10 +9319,10 @@ function normalizeMcpConfig(raw, fallbackName, opts = {}, warnings = []) {
|
|
|
8825
9319
|
warnings.push(`MCP "${name}" \u7F3A\u5C11 command\uFF0C\u5DF2\u8DF3\u8FC7`);
|
|
8826
9320
|
return null;
|
|
8827
9321
|
}
|
|
8828
|
-
config.command = command.map((c) => expandEnv(c,
|
|
9322
|
+
config.command = command.map((c) => expandEnv(c, env2, name, warnings));
|
|
8829
9323
|
if (typeof o.cwd === "string" && o.cwd.trim())
|
|
8830
|
-
config.cwd = expandEnv(o.cwd,
|
|
8831
|
-
const stdioEnv = toStringMap(o.env, "env", name,
|
|
9324
|
+
config.cwd = expandEnv(o.cwd, env2, name, warnings);
|
|
9325
|
+
const stdioEnv = toStringMap(o.env, "env", name, env2, warnings);
|
|
8832
9326
|
if (stdioEnv) config.env = stdioEnv;
|
|
8833
9327
|
} else if (type === "builtin") {
|
|
8834
9328
|
config.builtin = typeof o.builtin === "string" && o.builtin.trim() ? o.builtin.trim() : name;
|
|
@@ -8837,8 +9331,8 @@ function normalizeMcpConfig(raw, fallbackName, opts = {}, warnings = []) {
|
|
|
8837
9331
|
warnings.push(`MCP "${name}" \u7F3A\u5C11 url\uFF0C\u5DF2\u8DF3\u8FC7`);
|
|
8838
9332
|
return null;
|
|
8839
9333
|
}
|
|
8840
|
-
config.url = expandEnv(o.url.trim(),
|
|
8841
|
-
const headers = toStringMap(o.headers, "headers", name,
|
|
9334
|
+
config.url = expandEnv(o.url.trim(), env2, name, warnings);
|
|
9335
|
+
const headers = toStringMap(o.headers, "headers", name, env2, warnings);
|
|
8842
9336
|
if (headers) config.headers = headers;
|
|
8843
9337
|
}
|
|
8844
9338
|
return config;
|
|
@@ -9495,24 +9989,24 @@ async function runGit(plan, args, opts = {}) {
|
|
|
9495
9989
|
if (!plan.gitDir) {
|
|
9496
9990
|
return { status: null, stdout: "", stderr: "", error: "\u53D8\u66F4\u8FFD\u8E2A\u672A\u542F\u7528" };
|
|
9497
9991
|
}
|
|
9498
|
-
const
|
|
9992
|
+
const env2 = {
|
|
9499
9993
|
...process.env,
|
|
9500
9994
|
// 固定输出编码,避免非 ASCII 路径被转义成八进制
|
|
9501
9995
|
GIT_PAGER: "cat"
|
|
9502
9996
|
};
|
|
9503
9997
|
if (!opts.isolated) {
|
|
9504
|
-
|
|
9505
|
-
|
|
9998
|
+
env2.GIT_DIR = plan.gitDir;
|
|
9999
|
+
env2.GIT_WORK_TREE = plan.workTree;
|
|
9506
10000
|
} else {
|
|
9507
|
-
delete
|
|
9508
|
-
delete
|
|
9509
|
-
delete
|
|
10001
|
+
delete env2.GIT_DIR;
|
|
10002
|
+
delete env2.GIT_WORK_TREE;
|
|
10003
|
+
delete env2.GIT_INDEX_FILE;
|
|
9510
10004
|
}
|
|
9511
|
-
if (opts.index)
|
|
9512
|
-
|
|
10005
|
+
if (opts.index) env2.GIT_INDEX_FILE = opts.index;
|
|
10006
|
+
env2.GIT_TERMINAL_PROMPT = "0";
|
|
9513
10007
|
const result = await execAsync("git", [...IDENTITY, ...args], {
|
|
9514
10008
|
cwd: opts.cwd ?? plan.workTree,
|
|
9515
|
-
env,
|
|
10009
|
+
env: env2,
|
|
9516
10010
|
...opts.input !== void 0 ? { input: opts.input } : {},
|
|
9517
10011
|
timeoutMs: opts.timeoutMs ?? 3e4
|
|
9518
10012
|
});
|
|
@@ -10080,9 +10574,9 @@ function makeRunShell(workspace, spec, tasks, scope, sandbox, sessionKey) {
|
|
|
10080
10574
|
resolveInvocation(spec, prepared),
|
|
10081
10575
|
{ cwd: session.cwd }
|
|
10082
10576
|
);
|
|
10083
|
-
const
|
|
10577
|
+
const env2 = shellEnv();
|
|
10084
10578
|
if (background) {
|
|
10085
|
-
const snap = tasks.start({ command, file, argv, cwd: session.cwd, env, scope });
|
|
10579
|
+
const snap = tasks.start({ command, file, argv, cwd: session.cwd, env: env2, scope });
|
|
10086
10580
|
return {
|
|
10087
10581
|
task_id: snap.task_id,
|
|
10088
10582
|
status: snap.status,
|
|
@@ -10094,7 +10588,7 @@ function makeRunShell(workspace, spec, tasks, scope, sandbox, sessionKey) {
|
|
|
10094
10588
|
cwd: session.cwd,
|
|
10095
10589
|
timeoutMs: timeout,
|
|
10096
10590
|
maxBuffer: MAX_BUFFER2,
|
|
10097
|
-
env,
|
|
10591
|
+
env: env2,
|
|
10098
10592
|
signal: ctx?.signal
|
|
10099
10593
|
});
|
|
10100
10594
|
const stdout = decodeOutput(result.stdout).slice(-MAX_STDOUT);
|
|
@@ -10288,7 +10782,7 @@ function nodeGrep(opts) {
|
|
|
10288
10782
|
|
|
10289
10783
|
// src/tools/ripgrep.ts
|
|
10290
10784
|
var fs18 = __toESM(require("fs"), 1);
|
|
10291
|
-
var
|
|
10785
|
+
var os6 = __toESM(require("os"), 1);
|
|
10292
10786
|
var path19 = __toESM(require("path"), 1);
|
|
10293
10787
|
var import_node_module = require("module");
|
|
10294
10788
|
var cached2;
|
|
@@ -10299,7 +10793,7 @@ function extractBundledRipgrep() {
|
|
|
10299
10793
|
if (!sea?.isSea?.() || typeof sea.getAsset !== "function") return null;
|
|
10300
10794
|
const asset = sea.getAsset("rg");
|
|
10301
10795
|
if (!asset) return null;
|
|
10302
|
-
const dir = fs18.mkdtempSync(path19.join(
|
|
10796
|
+
const dir = fs18.mkdtempSync(path19.join(os6.tmpdir(), "zqagent-rg-"));
|
|
10303
10797
|
const file = path19.join(dir, process.platform === "win32" ? "rg.exe" : "rg");
|
|
10304
10798
|
fs18.writeFileSync(file, Buffer.from(asset));
|
|
10305
10799
|
fs18.chmodSync(file, 493);
|
|
@@ -11604,7 +12098,7 @@ var path23 = __toESM(require("path"), 1);
|
|
|
11604
12098
|
|
|
11605
12099
|
// src/tools/ffmpegRuntime.ts
|
|
11606
12100
|
var fs21 = __toESM(require("fs"), 1);
|
|
11607
|
-
var
|
|
12101
|
+
var os7 = __toESM(require("os"), 1);
|
|
11608
12102
|
var path22 = __toESM(require("path"), 1);
|
|
11609
12103
|
var import_node_module2 = require("module");
|
|
11610
12104
|
var import_node_crypto2 = require("crypto");
|
|
@@ -11646,7 +12140,7 @@ function extractBundled(name, platform) {
|
|
|
11646
12140
|
if (!sea?.isSea?.() || typeof sea.getAsset !== "function") return null;
|
|
11647
12141
|
const asset = sea.getAsset(name);
|
|
11648
12142
|
if (!asset) return null;
|
|
11649
|
-
const dir = fs21.mkdtempSync(path22.join(
|
|
12143
|
+
const dir = fs21.mkdtempSync(path22.join(os7.tmpdir(), `zqagent-${name}-`));
|
|
11650
12144
|
const file = path22.join(dir, exeName(name, platform));
|
|
11651
12145
|
fs21.writeFileSync(file, Buffer.from(asset));
|
|
11652
12146
|
fs21.chmodSync(file, 493);
|
|
@@ -11873,7 +12367,7 @@ async function downloadFfmpeg(workspace, opts = {}) {
|
|
|
11873
12367
|
error: `\u6682\u4E0D\u652F\u6301\u81EA\u52A8\u4E0B\u8F7D\u7684\u5E73\u53F0: ${platform}/${arch}`
|
|
11874
12368
|
};
|
|
11875
12369
|
}
|
|
11876
|
-
const tmp = fs21.mkdtempSync(path22.join(
|
|
12370
|
+
const tmp = fs21.mkdtempSync(path22.join(os7.tmpdir(), "zqagent-ffmpeg-"));
|
|
11877
12371
|
const binDir = agentBinDir(workspace);
|
|
11878
12372
|
const installed = {};
|
|
11879
12373
|
try {
|