@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.js
CHANGED
|
@@ -1988,8 +1988,8 @@ function toolResultBudget(tool) {
|
|
|
1988
1988
|
return globalBudgetChars() ?? TOOL_MAX_CHARS[tool] ?? DEFAULT_TOOL_RESULT_MAX_CHARS;
|
|
1989
1989
|
}
|
|
1990
1990
|
function toolResultDir() {
|
|
1991
|
-
const
|
|
1992
|
-
return
|
|
1991
|
+
const env2 = process.env.TOOL_RESULT_DIR?.trim();
|
|
1992
|
+
return env2 || path2.join(stateDir(), "tool-results");
|
|
1993
1993
|
}
|
|
1994
1994
|
function clipText(text, budget) {
|
|
1995
1995
|
if (text.length <= budget) return text;
|
|
@@ -3954,21 +3954,21 @@ import OpenAI from "openai";
|
|
|
3954
3954
|
|
|
3955
3955
|
// src/terminal.ts
|
|
3956
3956
|
function detectEmojiSupport(input = {}) {
|
|
3957
|
-
const
|
|
3957
|
+
const env2 = input.env ?? process.env;
|
|
3958
3958
|
const platform = input.platform ?? process.platform;
|
|
3959
3959
|
const isTTY = input.isTTY ?? Boolean(process.stdout.isTTY);
|
|
3960
|
-
const flag = (
|
|
3960
|
+
const flag = (env2.ZQAGENT_EMOJI ?? "").trim().toLowerCase();
|
|
3961
3961
|
if (["0", "false", "no", "off"].includes(flag)) return false;
|
|
3962
3962
|
if (["1", "true", "yes", "on"].includes(flag)) return true;
|
|
3963
|
-
if (
|
|
3964
|
-
if (
|
|
3963
|
+
if (env2.ZQAGENT_ASCII && env2.ZQAGENT_ASCII !== "0") return false;
|
|
3964
|
+
if (env2.NO_EMOJI && env2.NO_EMOJI !== "0") return false;
|
|
3965
3965
|
if (platform !== "win32") return true;
|
|
3966
3966
|
if (!isTTY) return true;
|
|
3967
|
-
if (
|
|
3968
|
-
const termProgram = (
|
|
3967
|
+
if (env2.WT_SESSION) return true;
|
|
3968
|
+
const termProgram = (env2.TERM_PROGRAM ?? "").toLowerCase();
|
|
3969
3969
|
if (termProgram === "vscode" || termProgram === "windows-terminal") return true;
|
|
3970
|
-
if ((
|
|
3971
|
-
const term = (
|
|
3970
|
+
if ((env2.ConEmuANSI ?? "").toUpperCase() === "ON") return true;
|
|
3971
|
+
const term = (env2.TERM ?? "").toLowerCase();
|
|
3972
3972
|
if (term.includes("xterm") || term.includes("mintty")) return true;
|
|
3973
3973
|
return false;
|
|
3974
3974
|
}
|
|
@@ -5839,7 +5839,7 @@ function defaultPermissionConfig() {
|
|
|
5839
5839
|
vcs: { mode: "auto" }
|
|
5840
5840
|
};
|
|
5841
5841
|
}
|
|
5842
|
-
function loadPermissionConfig(workspace,
|
|
5842
|
+
function loadPermissionConfig(workspace, env2 = process.env) {
|
|
5843
5843
|
const cfg = defaultPermissionConfig();
|
|
5844
5844
|
const file = path8.join(workspace, PERMISSION_CONFIG_FILE);
|
|
5845
5845
|
let raw = null;
|
|
@@ -5879,7 +5879,7 @@ function loadPermissionConfig(workspace, env = process.env) {
|
|
|
5879
5879
|
if (VCS_MODES.has(m)) cfg.vcs.mode = m;
|
|
5880
5880
|
}
|
|
5881
5881
|
}
|
|
5882
|
-
const envPolicy = String(
|
|
5882
|
+
const envPolicy = String(env2.ZQAGENT_SHELL_POLICY ?? "").trim().toLowerCase();
|
|
5883
5883
|
if (SHELL_POLICIES.has(envPolicy)) cfg.shellPolicy = envPolicy;
|
|
5884
5884
|
return cfg;
|
|
5885
5885
|
}
|
|
@@ -5889,20 +5889,20 @@ import { spawnSync } from "child_process";
|
|
|
5889
5889
|
import * as fs7 from "fs";
|
|
5890
5890
|
import * as os3 from "os";
|
|
5891
5891
|
import * as path9 from "path";
|
|
5892
|
-
function expandHome(p,
|
|
5893
|
-
if (p === "~") return
|
|
5892
|
+
function expandHome(p, env2) {
|
|
5893
|
+
if (p === "~") return env2.HOME ?? p;
|
|
5894
5894
|
if (p.startsWith("~/") || p.startsWith("~\\")) {
|
|
5895
|
-
return path9.join(
|
|
5895
|
+
return path9.join(env2.HOME ?? "~", p.slice(2));
|
|
5896
5896
|
}
|
|
5897
5897
|
return p;
|
|
5898
5898
|
}
|
|
5899
|
-
function toolchainWritable(platform,
|
|
5900
|
-
const home =
|
|
5899
|
+
function toolchainWritable(platform, env2) {
|
|
5900
|
+
const home = env2.HOME ?? os3.homedir();
|
|
5901
5901
|
const rel = platform === "darwin" ? ["Library/pnpm", "Library/Caches", ".npm", ".cache"] : [".npm", ".cache", ".local/share/pnpm", ".local/state/pnpm", ".pnpm-store"];
|
|
5902
5902
|
return rel.map((r) => path9.join(home, r));
|
|
5903
5903
|
}
|
|
5904
|
-
function addToolchainWritable(platform,
|
|
5905
|
-
for (const dir of toolchainWritable(platform,
|
|
5904
|
+
function addToolchainWritable(platform, env2, add, exists) {
|
|
5905
|
+
for (const dir of toolchainWritable(platform, env2)) {
|
|
5906
5906
|
if (exists(dir)) add(dir);
|
|
5907
5907
|
}
|
|
5908
5908
|
}
|
|
@@ -5955,9 +5955,9 @@ function normalizeMode(raw) {
|
|
|
5955
5955
|
var planCache = /* @__PURE__ */ new Map();
|
|
5956
5956
|
function resolveSandbox(opts = {}) {
|
|
5957
5957
|
const platform = opts.platform ?? process.platform;
|
|
5958
|
-
const
|
|
5958
|
+
const env2 = opts.env ?? process.env;
|
|
5959
5959
|
const workspace = path9.resolve(opts.workspace ?? process.cwd());
|
|
5960
|
-
const mode = normalizeMode(opts.mode ??
|
|
5960
|
+
const mode = normalizeMode(opts.mode ?? env2.ZQAGENT_SANDBOX);
|
|
5961
5961
|
const extraWritable = opts.extraWritable ?? [];
|
|
5962
5962
|
const pathExists = opts.fileExists ?? ((p) => {
|
|
5963
5963
|
try {
|
|
@@ -5970,7 +5970,7 @@ function resolveSandbox(opts = {}) {
|
|
|
5970
5970
|
workspace,
|
|
5971
5971
|
extraWritable,
|
|
5972
5972
|
platform,
|
|
5973
|
-
env,
|
|
5973
|
+
env: env2,
|
|
5974
5974
|
exists: pathExists
|
|
5975
5975
|
});
|
|
5976
5976
|
const cacheKey = [
|
|
@@ -6089,8 +6089,502 @@ function resetSandboxCache() {
|
|
|
6089
6089
|
planCache.clear();
|
|
6090
6090
|
}
|
|
6091
6091
|
|
|
6092
|
+
// ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
6093
|
+
var ANSI_BACKGROUND_OFFSET = 10;
|
|
6094
|
+
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
6095
|
+
var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
|
6096
|
+
var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
|
|
6097
|
+
var styles = {
|
|
6098
|
+
modifier: {
|
|
6099
|
+
reset: [0, 0],
|
|
6100
|
+
// 21 isn't widely supported and 22 does the same thing
|
|
6101
|
+
bold: [1, 22],
|
|
6102
|
+
dim: [2, 22],
|
|
6103
|
+
italic: [3, 23],
|
|
6104
|
+
underline: [4, 24],
|
|
6105
|
+
overline: [53, 55],
|
|
6106
|
+
inverse: [7, 27],
|
|
6107
|
+
hidden: [8, 28],
|
|
6108
|
+
strikethrough: [9, 29]
|
|
6109
|
+
},
|
|
6110
|
+
color: {
|
|
6111
|
+
black: [30, 39],
|
|
6112
|
+
red: [31, 39],
|
|
6113
|
+
green: [32, 39],
|
|
6114
|
+
yellow: [33, 39],
|
|
6115
|
+
blue: [34, 39],
|
|
6116
|
+
magenta: [35, 39],
|
|
6117
|
+
cyan: [36, 39],
|
|
6118
|
+
white: [37, 39],
|
|
6119
|
+
// Bright color
|
|
6120
|
+
blackBright: [90, 39],
|
|
6121
|
+
gray: [90, 39],
|
|
6122
|
+
// Alias of `blackBright`
|
|
6123
|
+
grey: [90, 39],
|
|
6124
|
+
// Alias of `blackBright`
|
|
6125
|
+
redBright: [91, 39],
|
|
6126
|
+
greenBright: [92, 39],
|
|
6127
|
+
yellowBright: [93, 39],
|
|
6128
|
+
blueBright: [94, 39],
|
|
6129
|
+
magentaBright: [95, 39],
|
|
6130
|
+
cyanBright: [96, 39],
|
|
6131
|
+
whiteBright: [97, 39]
|
|
6132
|
+
},
|
|
6133
|
+
bgColor: {
|
|
6134
|
+
bgBlack: [40, 49],
|
|
6135
|
+
bgRed: [41, 49],
|
|
6136
|
+
bgGreen: [42, 49],
|
|
6137
|
+
bgYellow: [43, 49],
|
|
6138
|
+
bgBlue: [44, 49],
|
|
6139
|
+
bgMagenta: [45, 49],
|
|
6140
|
+
bgCyan: [46, 49],
|
|
6141
|
+
bgWhite: [47, 49],
|
|
6142
|
+
// Bright color
|
|
6143
|
+
bgBlackBright: [100, 49],
|
|
6144
|
+
bgGray: [100, 49],
|
|
6145
|
+
// Alias of `bgBlackBright`
|
|
6146
|
+
bgGrey: [100, 49],
|
|
6147
|
+
// Alias of `bgBlackBright`
|
|
6148
|
+
bgRedBright: [101, 49],
|
|
6149
|
+
bgGreenBright: [102, 49],
|
|
6150
|
+
bgYellowBright: [103, 49],
|
|
6151
|
+
bgBlueBright: [104, 49],
|
|
6152
|
+
bgMagentaBright: [105, 49],
|
|
6153
|
+
bgCyanBright: [106, 49],
|
|
6154
|
+
bgWhiteBright: [107, 49]
|
|
6155
|
+
}
|
|
6156
|
+
};
|
|
6157
|
+
var modifierNames = Object.keys(styles.modifier);
|
|
6158
|
+
var foregroundColorNames = Object.keys(styles.color);
|
|
6159
|
+
var backgroundColorNames = Object.keys(styles.bgColor);
|
|
6160
|
+
var colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
|
6161
|
+
function assembleStyles() {
|
|
6162
|
+
const codes = /* @__PURE__ */ new Map();
|
|
6163
|
+
for (const [groupName, group] of Object.entries(styles)) {
|
|
6164
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
6165
|
+
styles[styleName] = {
|
|
6166
|
+
open: `\x1B[${style[0]}m`,
|
|
6167
|
+
close: `\x1B[${style[1]}m`
|
|
6168
|
+
};
|
|
6169
|
+
group[styleName] = styles[styleName];
|
|
6170
|
+
codes.set(style[0], style[1]);
|
|
6171
|
+
}
|
|
6172
|
+
Object.defineProperty(styles, groupName, {
|
|
6173
|
+
value: group,
|
|
6174
|
+
enumerable: false
|
|
6175
|
+
});
|
|
6176
|
+
}
|
|
6177
|
+
Object.defineProperty(styles, "codes", {
|
|
6178
|
+
value: codes,
|
|
6179
|
+
enumerable: false
|
|
6180
|
+
});
|
|
6181
|
+
styles.color.close = "\x1B[39m";
|
|
6182
|
+
styles.bgColor.close = "\x1B[49m";
|
|
6183
|
+
styles.color.ansi = wrapAnsi16();
|
|
6184
|
+
styles.color.ansi256 = wrapAnsi256();
|
|
6185
|
+
styles.color.ansi16m = wrapAnsi16m();
|
|
6186
|
+
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
6187
|
+
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
|
6188
|
+
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
6189
|
+
Object.defineProperties(styles, {
|
|
6190
|
+
rgbToAnsi256: {
|
|
6191
|
+
value(red, green, blue) {
|
|
6192
|
+
if (red === green && green === blue) {
|
|
6193
|
+
if (red < 8) {
|
|
6194
|
+
return 16;
|
|
6195
|
+
}
|
|
6196
|
+
if (red > 248) {
|
|
6197
|
+
return 231;
|
|
6198
|
+
}
|
|
6199
|
+
return Math.round((red - 8) / 247 * 24) + 232;
|
|
6200
|
+
}
|
|
6201
|
+
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
|
|
6202
|
+
},
|
|
6203
|
+
enumerable: false
|
|
6204
|
+
},
|
|
6205
|
+
hexToRgb: {
|
|
6206
|
+
value(hex) {
|
|
6207
|
+
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
6208
|
+
if (!matches) {
|
|
6209
|
+
return [0, 0, 0];
|
|
6210
|
+
}
|
|
6211
|
+
let [colorString] = matches;
|
|
6212
|
+
if (colorString.length === 3) {
|
|
6213
|
+
colorString = [...colorString].map((character) => character + character).join("");
|
|
6214
|
+
}
|
|
6215
|
+
const integer = Number.parseInt(colorString, 16);
|
|
6216
|
+
return [
|
|
6217
|
+
/* eslint-disable no-bitwise */
|
|
6218
|
+
integer >> 16 & 255,
|
|
6219
|
+
integer >> 8 & 255,
|
|
6220
|
+
integer & 255
|
|
6221
|
+
/* eslint-enable no-bitwise */
|
|
6222
|
+
];
|
|
6223
|
+
},
|
|
6224
|
+
enumerable: false
|
|
6225
|
+
},
|
|
6226
|
+
hexToAnsi256: {
|
|
6227
|
+
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
|
6228
|
+
enumerable: false
|
|
6229
|
+
},
|
|
6230
|
+
ansi256ToAnsi: {
|
|
6231
|
+
value(code) {
|
|
6232
|
+
if (code < 8) {
|
|
6233
|
+
return 30 + code;
|
|
6234
|
+
}
|
|
6235
|
+
if (code < 16) {
|
|
6236
|
+
return 90 + (code - 8);
|
|
6237
|
+
}
|
|
6238
|
+
let red;
|
|
6239
|
+
let green;
|
|
6240
|
+
let blue;
|
|
6241
|
+
if (code >= 232) {
|
|
6242
|
+
red = ((code - 232) * 10 + 8) / 255;
|
|
6243
|
+
green = red;
|
|
6244
|
+
blue = red;
|
|
6245
|
+
} else {
|
|
6246
|
+
code -= 16;
|
|
6247
|
+
const remainder = code % 36;
|
|
6248
|
+
red = Math.floor(code / 36) / 5;
|
|
6249
|
+
green = Math.floor(remainder / 6) / 5;
|
|
6250
|
+
blue = remainder % 6 / 5;
|
|
6251
|
+
}
|
|
6252
|
+
const value = Math.max(red, green, blue) * 2;
|
|
6253
|
+
if (value === 0) {
|
|
6254
|
+
return 30;
|
|
6255
|
+
}
|
|
6256
|
+
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
|
|
6257
|
+
if (value === 2) {
|
|
6258
|
+
result += 60;
|
|
6259
|
+
}
|
|
6260
|
+
return result;
|
|
6261
|
+
},
|
|
6262
|
+
enumerable: false
|
|
6263
|
+
},
|
|
6264
|
+
rgbToAnsi: {
|
|
6265
|
+
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
|
6266
|
+
enumerable: false
|
|
6267
|
+
},
|
|
6268
|
+
hexToAnsi: {
|
|
6269
|
+
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
|
6270
|
+
enumerable: false
|
|
6271
|
+
}
|
|
6272
|
+
});
|
|
6273
|
+
return styles;
|
|
6274
|
+
}
|
|
6275
|
+
var ansiStyles = assembleStyles();
|
|
6276
|
+
var ansi_styles_default = ansiStyles;
|
|
6277
|
+
|
|
6278
|
+
// ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.js
|
|
6279
|
+
import process2 from "process";
|
|
6280
|
+
import os4 from "os";
|
|
6281
|
+
import tty from "tty";
|
|
6282
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) {
|
|
6283
|
+
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
6284
|
+
const position = argv.indexOf(prefix + flag);
|
|
6285
|
+
const terminatorPosition = argv.indexOf("--");
|
|
6286
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
6287
|
+
}
|
|
6288
|
+
var { env } = process2;
|
|
6289
|
+
var flagForceColor;
|
|
6290
|
+
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
6291
|
+
flagForceColor = 0;
|
|
6292
|
+
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
6293
|
+
flagForceColor = 1;
|
|
6294
|
+
}
|
|
6295
|
+
function envForceColor() {
|
|
6296
|
+
if ("FORCE_COLOR" in env) {
|
|
6297
|
+
if (env.FORCE_COLOR === "true") {
|
|
6298
|
+
return 1;
|
|
6299
|
+
}
|
|
6300
|
+
if (env.FORCE_COLOR === "false") {
|
|
6301
|
+
return 0;
|
|
6302
|
+
}
|
|
6303
|
+
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
6304
|
+
}
|
|
6305
|
+
}
|
|
6306
|
+
function translateLevel(level) {
|
|
6307
|
+
if (level === 0) {
|
|
6308
|
+
return false;
|
|
6309
|
+
}
|
|
6310
|
+
return {
|
|
6311
|
+
level,
|
|
6312
|
+
hasBasic: true,
|
|
6313
|
+
has256: level >= 2,
|
|
6314
|
+
has16m: level >= 3
|
|
6315
|
+
};
|
|
6316
|
+
}
|
|
6317
|
+
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
6318
|
+
const noFlagForceColor = envForceColor();
|
|
6319
|
+
if (noFlagForceColor !== void 0) {
|
|
6320
|
+
flagForceColor = noFlagForceColor;
|
|
6321
|
+
}
|
|
6322
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
6323
|
+
if (forceColor === 0) {
|
|
6324
|
+
return 0;
|
|
6325
|
+
}
|
|
6326
|
+
if (sniffFlags) {
|
|
6327
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
6328
|
+
return 3;
|
|
6329
|
+
}
|
|
6330
|
+
if (hasFlag("color=256")) {
|
|
6331
|
+
return 2;
|
|
6332
|
+
}
|
|
6333
|
+
}
|
|
6334
|
+
if ("TF_BUILD" in env && "AGENT_NAME" in env) {
|
|
6335
|
+
return 1;
|
|
6336
|
+
}
|
|
6337
|
+
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
6338
|
+
return 0;
|
|
6339
|
+
}
|
|
6340
|
+
const min = forceColor || 0;
|
|
6341
|
+
if (env.TERM === "dumb") {
|
|
6342
|
+
return min;
|
|
6343
|
+
}
|
|
6344
|
+
if (process2.platform === "win32") {
|
|
6345
|
+
const osRelease = os4.release().split(".");
|
|
6346
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
6347
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
6348
|
+
}
|
|
6349
|
+
return 1;
|
|
6350
|
+
}
|
|
6351
|
+
if ("CI" in env) {
|
|
6352
|
+
if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
|
|
6353
|
+
return 3;
|
|
6354
|
+
}
|
|
6355
|
+
if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
6356
|
+
return 1;
|
|
6357
|
+
}
|
|
6358
|
+
return min;
|
|
6359
|
+
}
|
|
6360
|
+
if ("TEAMCITY_VERSION" in env) {
|
|
6361
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
6362
|
+
}
|
|
6363
|
+
if (env.COLORTERM === "truecolor") {
|
|
6364
|
+
return 3;
|
|
6365
|
+
}
|
|
6366
|
+
if (env.TERM === "xterm-kitty") {
|
|
6367
|
+
return 3;
|
|
6368
|
+
}
|
|
6369
|
+
if (env.TERM === "xterm-ghostty") {
|
|
6370
|
+
return 3;
|
|
6371
|
+
}
|
|
6372
|
+
if (env.TERM === "wezterm") {
|
|
6373
|
+
return 3;
|
|
6374
|
+
}
|
|
6375
|
+
if ("TERM_PROGRAM" in env) {
|
|
6376
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
6377
|
+
switch (env.TERM_PROGRAM) {
|
|
6378
|
+
case "iTerm.app": {
|
|
6379
|
+
return version >= 3 ? 3 : 2;
|
|
6380
|
+
}
|
|
6381
|
+
case "Apple_Terminal": {
|
|
6382
|
+
return 2;
|
|
6383
|
+
}
|
|
6384
|
+
}
|
|
6385
|
+
}
|
|
6386
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
6387
|
+
return 2;
|
|
6388
|
+
}
|
|
6389
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
6390
|
+
return 1;
|
|
6391
|
+
}
|
|
6392
|
+
if ("COLORTERM" in env) {
|
|
6393
|
+
return 1;
|
|
6394
|
+
}
|
|
6395
|
+
return min;
|
|
6396
|
+
}
|
|
6397
|
+
function createSupportsColor(stream, options = {}) {
|
|
6398
|
+
const level = _supportsColor(stream, {
|
|
6399
|
+
streamIsTTY: stream && stream.isTTY,
|
|
6400
|
+
...options
|
|
6401
|
+
});
|
|
6402
|
+
return translateLevel(level);
|
|
6403
|
+
}
|
|
6404
|
+
var supportsColor = {
|
|
6405
|
+
stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
|
|
6406
|
+
stderr: createSupportsColor({ isTTY: tty.isatty(2) })
|
|
6407
|
+
};
|
|
6408
|
+
var supports_color_default = supportsColor;
|
|
6409
|
+
|
|
6410
|
+
// ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/utilities.js
|
|
6411
|
+
function stringReplaceAll(string, substring, replacer) {
|
|
6412
|
+
let index = string.indexOf(substring);
|
|
6413
|
+
if (index === -1) {
|
|
6414
|
+
return string;
|
|
6415
|
+
}
|
|
6416
|
+
const substringLength = substring.length;
|
|
6417
|
+
let endIndex = 0;
|
|
6418
|
+
let returnValue = "";
|
|
6419
|
+
do {
|
|
6420
|
+
returnValue += string.slice(endIndex, index) + substring + replacer;
|
|
6421
|
+
endIndex = index + substringLength;
|
|
6422
|
+
index = string.indexOf(substring, endIndex);
|
|
6423
|
+
} while (index !== -1);
|
|
6424
|
+
returnValue += string.slice(endIndex);
|
|
6425
|
+
return returnValue;
|
|
6426
|
+
}
|
|
6427
|
+
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
6428
|
+
let endIndex = 0;
|
|
6429
|
+
let returnValue = "";
|
|
6430
|
+
do {
|
|
6431
|
+
const gotCR = string[index - 1] === "\r";
|
|
6432
|
+
returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
6433
|
+
endIndex = index + 1;
|
|
6434
|
+
index = string.indexOf("\n", endIndex);
|
|
6435
|
+
} while (index !== -1);
|
|
6436
|
+
returnValue += string.slice(endIndex);
|
|
6437
|
+
return returnValue;
|
|
6438
|
+
}
|
|
6439
|
+
|
|
6440
|
+
// ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.js
|
|
6441
|
+
var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
|
|
6442
|
+
var GENERATOR = /* @__PURE__ */ Symbol("GENERATOR");
|
|
6443
|
+
var STYLER = /* @__PURE__ */ Symbol("STYLER");
|
|
6444
|
+
var IS_EMPTY = /* @__PURE__ */ Symbol("IS_EMPTY");
|
|
6445
|
+
var levelMapping = [
|
|
6446
|
+
"ansi",
|
|
6447
|
+
"ansi",
|
|
6448
|
+
"ansi256",
|
|
6449
|
+
"ansi16m"
|
|
6450
|
+
];
|
|
6451
|
+
var styles2 = /* @__PURE__ */ Object.create(null);
|
|
6452
|
+
var applyOptions = (object, options = {}) => {
|
|
6453
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
6454
|
+
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
6455
|
+
}
|
|
6456
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
6457
|
+
object.level = options.level === void 0 ? colorLevel : options.level;
|
|
6458
|
+
};
|
|
6459
|
+
var chalkFactory = (options) => {
|
|
6460
|
+
const chalk2 = (...strings) => strings.join(" ");
|
|
6461
|
+
applyOptions(chalk2, options);
|
|
6462
|
+
Object.setPrototypeOf(chalk2, createChalk.prototype);
|
|
6463
|
+
return chalk2;
|
|
6464
|
+
};
|
|
6465
|
+
function createChalk(options) {
|
|
6466
|
+
return chalkFactory(options);
|
|
6467
|
+
}
|
|
6468
|
+
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
6469
|
+
for (const [styleName, style] of Object.entries(ansi_styles_default)) {
|
|
6470
|
+
styles2[styleName] = {
|
|
6471
|
+
get() {
|
|
6472
|
+
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
|
6473
|
+
Object.defineProperty(this, styleName, { value: builder });
|
|
6474
|
+
return builder;
|
|
6475
|
+
}
|
|
6476
|
+
};
|
|
6477
|
+
}
|
|
6478
|
+
styles2.visible = {
|
|
6479
|
+
get() {
|
|
6480
|
+
const builder = createBuilder(this, this[STYLER], true);
|
|
6481
|
+
Object.defineProperty(this, "visible", { value: builder });
|
|
6482
|
+
return builder;
|
|
6483
|
+
}
|
|
6484
|
+
};
|
|
6485
|
+
var getModelAnsi = (model, level, type, ...arguments_) => {
|
|
6486
|
+
if (model === "rgb") {
|
|
6487
|
+
if (level === "ansi16m") {
|
|
6488
|
+
return ansi_styles_default[type].ansi16m(...arguments_);
|
|
6489
|
+
}
|
|
6490
|
+
if (level === "ansi256") {
|
|
6491
|
+
return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
|
|
6492
|
+
}
|
|
6493
|
+
return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
|
|
6494
|
+
}
|
|
6495
|
+
if (model === "hex") {
|
|
6496
|
+
return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
|
|
6497
|
+
}
|
|
6498
|
+
return ansi_styles_default[type][model](...arguments_);
|
|
6499
|
+
};
|
|
6500
|
+
var usedModels = ["rgb", "hex", "ansi256"];
|
|
6501
|
+
for (const model of usedModels) {
|
|
6502
|
+
styles2[model] = {
|
|
6503
|
+
get() {
|
|
6504
|
+
const { level } = this;
|
|
6505
|
+
return function(...arguments_) {
|
|
6506
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
|
|
6507
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
6508
|
+
};
|
|
6509
|
+
}
|
|
6510
|
+
};
|
|
6511
|
+
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
6512
|
+
styles2[bgModel] = {
|
|
6513
|
+
get() {
|
|
6514
|
+
const { level } = this;
|
|
6515
|
+
return function(...arguments_) {
|
|
6516
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
|
|
6517
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
6518
|
+
};
|
|
6519
|
+
}
|
|
6520
|
+
};
|
|
6521
|
+
}
|
|
6522
|
+
var proto = Object.defineProperties(() => {
|
|
6523
|
+
}, {
|
|
6524
|
+
...styles2,
|
|
6525
|
+
level: {
|
|
6526
|
+
enumerable: true,
|
|
6527
|
+
get() {
|
|
6528
|
+
return this[GENERATOR].level;
|
|
6529
|
+
},
|
|
6530
|
+
set(level) {
|
|
6531
|
+
this[GENERATOR].level = level;
|
|
6532
|
+
}
|
|
6533
|
+
}
|
|
6534
|
+
});
|
|
6535
|
+
var createStyler = (open, close, parent) => {
|
|
6536
|
+
let openAll;
|
|
6537
|
+
let closeAll;
|
|
6538
|
+
if (parent === void 0) {
|
|
6539
|
+
openAll = open;
|
|
6540
|
+
closeAll = close;
|
|
6541
|
+
} else {
|
|
6542
|
+
openAll = parent.openAll + open;
|
|
6543
|
+
closeAll = close + parent.closeAll;
|
|
6544
|
+
}
|
|
6545
|
+
return {
|
|
6546
|
+
open,
|
|
6547
|
+
close,
|
|
6548
|
+
openAll,
|
|
6549
|
+
closeAll,
|
|
6550
|
+
parent
|
|
6551
|
+
};
|
|
6552
|
+
};
|
|
6553
|
+
var createBuilder = (self, _styler, _isEmpty) => {
|
|
6554
|
+
const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
6555
|
+
Object.setPrototypeOf(builder, proto);
|
|
6556
|
+
builder[GENERATOR] = self;
|
|
6557
|
+
builder[STYLER] = _styler;
|
|
6558
|
+
builder[IS_EMPTY] = _isEmpty;
|
|
6559
|
+
return builder;
|
|
6560
|
+
};
|
|
6561
|
+
var applyStyle = (self, string) => {
|
|
6562
|
+
if (self.level <= 0 || !string) {
|
|
6563
|
+
return self[IS_EMPTY] ? "" : string;
|
|
6564
|
+
}
|
|
6565
|
+
let styler = self[STYLER];
|
|
6566
|
+
if (styler === void 0) {
|
|
6567
|
+
return string;
|
|
6568
|
+
}
|
|
6569
|
+
const { openAll, closeAll } = styler;
|
|
6570
|
+
if (string.includes("\x1B")) {
|
|
6571
|
+
while (styler !== void 0) {
|
|
6572
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
|
6573
|
+
styler = styler.parent;
|
|
6574
|
+
}
|
|
6575
|
+
}
|
|
6576
|
+
const lfIndex = string.indexOf("\n");
|
|
6577
|
+
if (lfIndex !== -1) {
|
|
6578
|
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
6579
|
+
}
|
|
6580
|
+
return openAll + string + closeAll;
|
|
6581
|
+
};
|
|
6582
|
+
Object.defineProperties(createChalk.prototype, styles2);
|
|
6583
|
+
var chalk = createChalk();
|
|
6584
|
+
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
6585
|
+
var source_default = chalk;
|
|
6586
|
+
|
|
6092
6587
|
// src/engine/MarkdownRenderer.ts
|
|
6093
|
-
import chalk from "chalk";
|
|
6094
6588
|
import { highlight } from "cli-highlight";
|
|
6095
6589
|
import Table from "cli-table3";
|
|
6096
6590
|
import MarkdownIt from "markdown-it";
|
|
@@ -6150,7 +6644,7 @@ var MarkdownRenderer = class {
|
|
|
6150
6644
|
/** 当前链接 href(link_open 记录,link_close 消费) */
|
|
6151
6645
|
_pendingLinkHref = "";
|
|
6152
6646
|
constructor(opts = {}) {
|
|
6153
|
-
this._color = opts.color ??
|
|
6647
|
+
this._color = opts.color ?? source_default.level > 0;
|
|
6154
6648
|
this._unicode = opts.unicode ?? true;
|
|
6155
6649
|
this._gray = opts.gray ?? false;
|
|
6156
6650
|
}
|
|
@@ -7150,7 +7644,7 @@ import {
|
|
|
7150
7644
|
|
|
7151
7645
|
// src/mcp/builtin/ocrEngine.ts
|
|
7152
7646
|
import fs10 from "fs";
|
|
7153
|
-
import
|
|
7647
|
+
import os5 from "os";
|
|
7154
7648
|
import path12 from "path";
|
|
7155
7649
|
import { execFile } from "child_process";
|
|
7156
7650
|
import OpenAI2 from "openai";
|
|
@@ -7270,14 +7764,14 @@ function resolveRequested(requested, ctx, execPath) {
|
|
|
7270
7764
|
}
|
|
7271
7765
|
function resolveShellSpec(opts = {}) {
|
|
7272
7766
|
const platform = opts.platform ?? process.platform;
|
|
7273
|
-
const
|
|
7767
|
+
const env2 = opts.env ?? process.env;
|
|
7274
7768
|
const execPath = opts.execPath ?? process.execPath;
|
|
7275
7769
|
const ctx = {
|
|
7276
7770
|
platform,
|
|
7277
|
-
env,
|
|
7771
|
+
env: env2,
|
|
7278
7772
|
fileExists: opts.fileExists ?? defaultFileExists
|
|
7279
7773
|
};
|
|
7280
|
-
const requested = (
|
|
7774
|
+
const requested = (env2.ZQAGENT_SHELL ?? "").trim();
|
|
7281
7775
|
if (requested && requested.toLowerCase() !== "auto") {
|
|
7282
7776
|
return resolveRequested(requested, ctx, execPath);
|
|
7283
7777
|
}
|
|
@@ -7290,7 +7784,7 @@ function resolveShellSpec(opts = {}) {
|
|
|
7290
7784
|
if (bash) return makeSpec("sh", bash, "bash (Git for Windows)");
|
|
7291
7785
|
const shell = findExecutable("pwsh", ctx) ?? findExecutable("powershell", ctx);
|
|
7292
7786
|
if (shell) return makeSpec("powershell", shell, "PowerShell");
|
|
7293
|
-
return makeSpec("default", null,
|
|
7787
|
+
return makeSpec("default", null, env2.ComSpec ?? env2.COMSPEC ?? "cmd.exe");
|
|
7294
7788
|
}
|
|
7295
7789
|
function wrapCommand(kind, command, platform = process.platform) {
|
|
7296
7790
|
if (kind === "powershell") {
|
|
@@ -7439,8 +7933,8 @@ ${stderr.trim()}` : ""}`;
|
|
|
7439
7933
|
function makeRuntime(ctx) {
|
|
7440
7934
|
const overrides = ctx.ocr ?? {};
|
|
7441
7935
|
const platform = overrides.platform ?? process.platform;
|
|
7442
|
-
const
|
|
7443
|
-
const workspace = ctx.workspace ??
|
|
7936
|
+
const env2 = overrides.env ?? ctx.env ?? process.env;
|
|
7937
|
+
const workspace = ctx.workspace ?? env2.WORKSPACE ?? process.cwd();
|
|
7444
7938
|
const fileExists = overrides.fileExists ?? ((p) => {
|
|
7445
7939
|
try {
|
|
7446
7940
|
return fs10.statSync(p).isFile();
|
|
@@ -7448,10 +7942,10 @@ function makeRuntime(ctx) {
|
|
|
7448
7942
|
return false;
|
|
7449
7943
|
}
|
|
7450
7944
|
});
|
|
7451
|
-
const which = overrides.which ?? ((name) => findExecutable(name, { platform, env, fileExists }));
|
|
7945
|
+
const which = overrides.which ?? ((name) => findExecutable(name, { platform, env: env2, fileExists }));
|
|
7452
7946
|
return {
|
|
7453
7947
|
platform,
|
|
7454
|
-
env,
|
|
7948
|
+
env: env2,
|
|
7455
7949
|
workspace,
|
|
7456
7950
|
llm: ctx.llm,
|
|
7457
7951
|
overrides,
|
|
@@ -7522,7 +8016,7 @@ async function downloadToFile(url, dest, runtime) {
|
|
|
7522
8016
|
fs10.writeFileSync(dest, Buffer.from(await res.arrayBuffer()));
|
|
7523
8017
|
}
|
|
7524
8018
|
async function materializeInput(input, runtime) {
|
|
7525
|
-
const root = runtime.overrides.tmpDir ??
|
|
8019
|
+
const root = runtime.overrides.tmpDir ?? os5.tmpdir();
|
|
7526
8020
|
const tmpDir = fs10.mkdtempSync(path12.join(root, "zqagent-ocr-"));
|
|
7527
8021
|
const cleanup = () => {
|
|
7528
8022
|
try {
|
|
@@ -8301,9 +8795,9 @@ var McpManager = class {
|
|
|
8301
8795
|
const cfg = this.options.lazy ?? {};
|
|
8302
8796
|
if (cfg.enabled === true) return true;
|
|
8303
8797
|
if (cfg.enabled === false) return false;
|
|
8304
|
-
const
|
|
8305
|
-
if (["1", "true", "on", "yes"].includes(
|
|
8306
|
-
if (["0", "false", "off", "no"].includes(
|
|
8798
|
+
const env2 = (process.env.ZQAGENT_MCP_LAZY ?? "").toLowerCase();
|
|
8799
|
+
if (["1", "true", "on", "yes"].includes(env2)) return true;
|
|
8800
|
+
if (["0", "false", "off", "no"].includes(env2)) return false;
|
|
8307
8801
|
let count = 0;
|
|
8308
8802
|
let chars = 0;
|
|
8309
8803
|
for (const tools of this.toolIndex.values()) {
|
|
@@ -8624,11 +9118,11 @@ function splitCommandLine(input) {
|
|
|
8624
9118
|
if (cur) out.push(cur);
|
|
8625
9119
|
return out;
|
|
8626
9120
|
}
|
|
8627
|
-
function expandEnv(value,
|
|
9121
|
+
function expandEnv(value, env2, name, warnings) {
|
|
8628
9122
|
return value.replace(
|
|
8629
9123
|
/\$\{(?:env:)?([A-Za-z_][A-Za-z0-9_]*)\}/g,
|
|
8630
9124
|
(_m, key) => {
|
|
8631
|
-
const v =
|
|
9125
|
+
const v = env2[key];
|
|
8632
9126
|
if (v === void 0) {
|
|
8633
9127
|
warnings.push(`"${name}" \u5F15\u7528\u4E86\u672A\u5B9A\u4E49\u7684\u73AF\u5883\u53D8\u91CF \${${key}}`);
|
|
8634
9128
|
return "";
|
|
@@ -8637,7 +9131,7 @@ function expandEnv(value, env, name, warnings) {
|
|
|
8637
9131
|
}
|
|
8638
9132
|
);
|
|
8639
9133
|
}
|
|
8640
|
-
function toStringMap(raw, field, name,
|
|
9134
|
+
function toStringMap(raw, field, name, env2, warnings) {
|
|
8641
9135
|
if (raw === void 0 || raw === null) return void 0;
|
|
8642
9136
|
if (typeof raw !== "object" || Array.isArray(raw)) {
|
|
8643
9137
|
warnings.push(`"${name}".${field} \u5E94\u4E3A\u5BF9\u8C61\uFF0C\u5DF2\u5FFD\u7565`);
|
|
@@ -8646,7 +9140,7 @@ function toStringMap(raw, field, name, env, warnings) {
|
|
|
8646
9140
|
const out = {};
|
|
8647
9141
|
for (const [k, v] of Object.entries(raw)) {
|
|
8648
9142
|
if (v === void 0 || v === null) continue;
|
|
8649
|
-
if (typeof v === "string") out[k] = expandEnv(v,
|
|
9143
|
+
if (typeof v === "string") out[k] = expandEnv(v, env2, name, warnings);
|
|
8650
9144
|
else if (typeof v === "number" || typeof v === "boolean")
|
|
8651
9145
|
out[k] = String(v);
|
|
8652
9146
|
else warnings.push(`"${name}".${field}.${k} \u4E0D\u662F\u5B57\u7B26\u4E32\uFF0C\u5DF2\u5FFD\u7565`);
|
|
@@ -8654,7 +9148,7 @@ function toStringMap(raw, field, name, env, warnings) {
|
|
|
8654
9148
|
return Object.keys(out).length > 0 ? out : void 0;
|
|
8655
9149
|
}
|
|
8656
9150
|
function normalizeMcpConfig(raw, fallbackName, opts = {}, warnings = []) {
|
|
8657
|
-
const
|
|
9151
|
+
const env2 = opts.env ?? process.env;
|
|
8658
9152
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
8659
9153
|
warnings.push(`MCP \u914D\u7F6E\u6761\u76EE${fallbackName ? ` "${fallbackName}"` : ""} \u4E0D\u662F\u5BF9\u8C61\uFF0C\u5DF2\u8DF3\u8FC7`);
|
|
8660
9154
|
return null;
|
|
@@ -8702,10 +9196,10 @@ function normalizeMcpConfig(raw, fallbackName, opts = {}, warnings = []) {
|
|
|
8702
9196
|
warnings.push(`MCP "${name}" \u7F3A\u5C11 command\uFF0C\u5DF2\u8DF3\u8FC7`);
|
|
8703
9197
|
return null;
|
|
8704
9198
|
}
|
|
8705
|
-
config.command = command.map((c) => expandEnv(c,
|
|
9199
|
+
config.command = command.map((c) => expandEnv(c, env2, name, warnings));
|
|
8706
9200
|
if (typeof o.cwd === "string" && o.cwd.trim())
|
|
8707
|
-
config.cwd = expandEnv(o.cwd,
|
|
8708
|
-
const stdioEnv = toStringMap(o.env, "env", name,
|
|
9201
|
+
config.cwd = expandEnv(o.cwd, env2, name, warnings);
|
|
9202
|
+
const stdioEnv = toStringMap(o.env, "env", name, env2, warnings);
|
|
8709
9203
|
if (stdioEnv) config.env = stdioEnv;
|
|
8710
9204
|
} else if (type === "builtin") {
|
|
8711
9205
|
config.builtin = typeof o.builtin === "string" && o.builtin.trim() ? o.builtin.trim() : name;
|
|
@@ -8714,8 +9208,8 @@ function normalizeMcpConfig(raw, fallbackName, opts = {}, warnings = []) {
|
|
|
8714
9208
|
warnings.push(`MCP "${name}" \u7F3A\u5C11 url\uFF0C\u5DF2\u8DF3\u8FC7`);
|
|
8715
9209
|
return null;
|
|
8716
9210
|
}
|
|
8717
|
-
config.url = expandEnv(o.url.trim(),
|
|
8718
|
-
const headers = toStringMap(o.headers, "headers", name,
|
|
9211
|
+
config.url = expandEnv(o.url.trim(), env2, name, warnings);
|
|
9212
|
+
const headers = toStringMap(o.headers, "headers", name, env2, warnings);
|
|
8719
9213
|
if (headers) config.headers = headers;
|
|
8720
9214
|
}
|
|
8721
9215
|
return config;
|
|
@@ -9372,24 +9866,24 @@ async function runGit(plan, args, opts = {}) {
|
|
|
9372
9866
|
if (!plan.gitDir) {
|
|
9373
9867
|
return { status: null, stdout: "", stderr: "", error: "\u53D8\u66F4\u8FFD\u8E2A\u672A\u542F\u7528" };
|
|
9374
9868
|
}
|
|
9375
|
-
const
|
|
9869
|
+
const env2 = {
|
|
9376
9870
|
...process.env,
|
|
9377
9871
|
// 固定输出编码,避免非 ASCII 路径被转义成八进制
|
|
9378
9872
|
GIT_PAGER: "cat"
|
|
9379
9873
|
};
|
|
9380
9874
|
if (!opts.isolated) {
|
|
9381
|
-
|
|
9382
|
-
|
|
9875
|
+
env2.GIT_DIR = plan.gitDir;
|
|
9876
|
+
env2.GIT_WORK_TREE = plan.workTree;
|
|
9383
9877
|
} else {
|
|
9384
|
-
delete
|
|
9385
|
-
delete
|
|
9386
|
-
delete
|
|
9878
|
+
delete env2.GIT_DIR;
|
|
9879
|
+
delete env2.GIT_WORK_TREE;
|
|
9880
|
+
delete env2.GIT_INDEX_FILE;
|
|
9387
9881
|
}
|
|
9388
|
-
if (opts.index)
|
|
9389
|
-
|
|
9882
|
+
if (opts.index) env2.GIT_INDEX_FILE = opts.index;
|
|
9883
|
+
env2.GIT_TERMINAL_PROMPT = "0";
|
|
9390
9884
|
const result = await execAsync("git", [...IDENTITY, ...args], {
|
|
9391
9885
|
cwd: opts.cwd ?? plan.workTree,
|
|
9392
|
-
env,
|
|
9886
|
+
env: env2,
|
|
9393
9887
|
...opts.input !== void 0 ? { input: opts.input } : {},
|
|
9394
9888
|
timeoutMs: opts.timeoutMs ?? 3e4
|
|
9395
9889
|
});
|
|
@@ -9957,9 +10451,9 @@ function makeRunShell(workspace, spec, tasks, scope, sandbox, sessionKey) {
|
|
|
9957
10451
|
resolveInvocation(spec, prepared),
|
|
9958
10452
|
{ cwd: session.cwd }
|
|
9959
10453
|
);
|
|
9960
|
-
const
|
|
10454
|
+
const env2 = shellEnv();
|
|
9961
10455
|
if (background) {
|
|
9962
|
-
const snap = tasks.start({ command, file, argv, cwd: session.cwd, env, scope });
|
|
10456
|
+
const snap = tasks.start({ command, file, argv, cwd: session.cwd, env: env2, scope });
|
|
9963
10457
|
return {
|
|
9964
10458
|
task_id: snap.task_id,
|
|
9965
10459
|
status: snap.status,
|
|
@@ -9971,7 +10465,7 @@ function makeRunShell(workspace, spec, tasks, scope, sandbox, sessionKey) {
|
|
|
9971
10465
|
cwd: session.cwd,
|
|
9972
10466
|
timeoutMs: timeout,
|
|
9973
10467
|
maxBuffer: MAX_BUFFER2,
|
|
9974
|
-
env,
|
|
10468
|
+
env: env2,
|
|
9975
10469
|
signal: ctx?.signal
|
|
9976
10470
|
});
|
|
9977
10471
|
const stdout = decodeOutput(result.stdout).slice(-MAX_STDOUT);
|
|
@@ -10165,7 +10659,7 @@ function nodeGrep(opts) {
|
|
|
10165
10659
|
|
|
10166
10660
|
// src/tools/ripgrep.ts
|
|
10167
10661
|
import * as fs18 from "fs";
|
|
10168
|
-
import * as
|
|
10662
|
+
import * as os6 from "os";
|
|
10169
10663
|
import * as path19 from "path";
|
|
10170
10664
|
import { createRequire } from "module";
|
|
10171
10665
|
var cached2;
|
|
@@ -10176,7 +10670,7 @@ function extractBundledRipgrep() {
|
|
|
10176
10670
|
if (!sea?.isSea?.() || typeof sea.getAsset !== "function") return null;
|
|
10177
10671
|
const asset = sea.getAsset("rg");
|
|
10178
10672
|
if (!asset) return null;
|
|
10179
|
-
const dir = fs18.mkdtempSync(path19.join(
|
|
10673
|
+
const dir = fs18.mkdtempSync(path19.join(os6.tmpdir(), "zqagent-rg-"));
|
|
10180
10674
|
const file = path19.join(dir, process.platform === "win32" ? "rg.exe" : "rg");
|
|
10181
10675
|
fs18.writeFileSync(file, Buffer.from(asset));
|
|
10182
10676
|
fs18.chmodSync(file, 493);
|
|
@@ -11481,7 +11975,7 @@ import * as path23 from "path";
|
|
|
11481
11975
|
|
|
11482
11976
|
// src/tools/ffmpegRuntime.ts
|
|
11483
11977
|
import * as fs21 from "fs";
|
|
11484
|
-
import * as
|
|
11978
|
+
import * as os7 from "os";
|
|
11485
11979
|
import * as path22 from "path";
|
|
11486
11980
|
import { createRequire as createRequire2 } from "module";
|
|
11487
11981
|
import { createHash as createHash2 } from "crypto";
|
|
@@ -11523,7 +12017,7 @@ function extractBundled(name, platform) {
|
|
|
11523
12017
|
if (!sea?.isSea?.() || typeof sea.getAsset !== "function") return null;
|
|
11524
12018
|
const asset = sea.getAsset(name);
|
|
11525
12019
|
if (!asset) return null;
|
|
11526
|
-
const dir = fs21.mkdtempSync(path22.join(
|
|
12020
|
+
const dir = fs21.mkdtempSync(path22.join(os7.tmpdir(), `zqagent-${name}-`));
|
|
11527
12021
|
const file = path22.join(dir, exeName(name, platform));
|
|
11528
12022
|
fs21.writeFileSync(file, Buffer.from(asset));
|
|
11529
12023
|
fs21.chmodSync(file, 493);
|
|
@@ -11750,7 +12244,7 @@ async function downloadFfmpeg(workspace, opts = {}) {
|
|
|
11750
12244
|
error: `\u6682\u4E0D\u652F\u6301\u81EA\u52A8\u4E0B\u8F7D\u7684\u5E73\u53F0: ${platform}/${arch}`
|
|
11751
12245
|
};
|
|
11752
12246
|
}
|
|
11753
|
-
const tmp = fs21.mkdtempSync(path22.join(
|
|
12247
|
+
const tmp = fs21.mkdtempSync(path22.join(os7.tmpdir(), "zqagent-ffmpeg-"));
|
|
11754
12248
|
const binDir = agentBinDir(workspace);
|
|
11755
12249
|
const installed = {};
|
|
11756
12250
|
try {
|