@probelabs/probe 0.6.0-rc299 → 0.6.0-rc300
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/bin/binaries/{probe-v0.6.0-rc299-aarch64-apple-darwin.tar.gz → probe-v0.6.0-rc300-aarch64-apple-darwin.tar.gz} +0 -0
- package/bin/binaries/{probe-v0.6.0-rc299-aarch64-unknown-linux-musl.tar.gz → probe-v0.6.0-rc300-aarch64-unknown-linux-musl.tar.gz} +0 -0
- package/bin/binaries/{probe-v0.6.0-rc299-x86_64-apple-darwin.tar.gz → probe-v0.6.0-rc300-x86_64-apple-darwin.tar.gz} +0 -0
- package/bin/binaries/{probe-v0.6.0-rc299-x86_64-pc-windows-msvc.zip → probe-v0.6.0-rc300-x86_64-pc-windows-msvc.zip} +0 -0
- package/bin/binaries/{probe-v0.6.0-rc299-x86_64-unknown-linux-musl.tar.gz → probe-v0.6.0-rc300-x86_64-unknown-linux-musl.tar.gz} +0 -0
- package/build/agent/ProbeAgent.js +8 -3
- package/build/agent/simpleTelemetry.js +25 -3
- package/build/tools/vercel.js +7 -0
- package/cjs/agent/ProbeAgent.cjs +181 -159
- package/cjs/agent/simpleTelemetry.cjs +19 -3
- package/cjs/index.cjs +926 -898
- package/package.json +1 -1
- package/src/agent/ProbeAgent.js +8 -3
- package/src/agent/simpleTelemetry.js +25 -3
- package/src/tools/vercel.js +7 -0
package/cjs/agent/ProbeAgent.cjs
CHANGED
|
@@ -24013,6 +24013,35 @@ var init_tokenCounter = __esm({
|
|
|
24013
24013
|
}
|
|
24014
24014
|
});
|
|
24015
24015
|
|
|
24016
|
+
// src/agent/otelLogBridge.js
|
|
24017
|
+
var import_module, _require;
|
|
24018
|
+
var init_otelLogBridge = __esm({
|
|
24019
|
+
"src/agent/otelLogBridge.js"() {
|
|
24020
|
+
"use strict";
|
|
24021
|
+
import_module = require("module");
|
|
24022
|
+
_require = (0, import_module.createRequire)("file:///");
|
|
24023
|
+
}
|
|
24024
|
+
});
|
|
24025
|
+
|
|
24026
|
+
// src/agent/simpleTelemetry.js
|
|
24027
|
+
function truncateForSpan(text, maxLen = 4096) {
|
|
24028
|
+
if (!text || text.length <= maxLen) return text || "";
|
|
24029
|
+
const half = Math.floor((maxLen - 40) / 2);
|
|
24030
|
+
const omitted = text.length - half * 2;
|
|
24031
|
+
return text.substring(0, half) + `
|
|
24032
|
+
... [${omitted} chars omitted] ...
|
|
24033
|
+
` + text.substring(text.length - half);
|
|
24034
|
+
}
|
|
24035
|
+
var import_fs, import_path;
|
|
24036
|
+
var init_simpleTelemetry = __esm({
|
|
24037
|
+
"src/agent/simpleTelemetry.js"() {
|
|
24038
|
+
"use strict";
|
|
24039
|
+
import_fs = require("fs");
|
|
24040
|
+
import_path = require("path");
|
|
24041
|
+
init_otelLogBridge();
|
|
24042
|
+
}
|
|
24043
|
+
});
|
|
24044
|
+
|
|
24016
24045
|
// src/agent/storage/StorageAdapter.js
|
|
24017
24046
|
var StorageAdapter;
|
|
24018
24047
|
var init_StorageAdapter = __esm({
|
|
@@ -24286,7 +24315,7 @@ async function getPackageBinDir() {
|
|
|
24286
24315
|
}
|
|
24287
24316
|
const binaryPath = process.env.PROBE_BINARY_PATH;
|
|
24288
24317
|
if (await import_fs_extra.default.pathExists(binaryPath)) {
|
|
24289
|
-
const binDir =
|
|
24318
|
+
const binDir = import_path2.default.dirname(binaryPath);
|
|
24290
24319
|
if (await canWriteToDirectory(binDir)) {
|
|
24291
24320
|
if (debug) {
|
|
24292
24321
|
console.log(`DEBUG: Using PROBE_BINARY_PATH directory: ${binDir}`);
|
|
@@ -24301,7 +24330,7 @@ async function getPackageBinDir() {
|
|
|
24301
24330
|
if (debug) {
|
|
24302
24331
|
console.log(`DEBUG: Checking PROBE_CACHE_DIR: ${process.env.PROBE_CACHE_DIR}`);
|
|
24303
24332
|
}
|
|
24304
|
-
const cacheDir =
|
|
24333
|
+
const cacheDir = import_path2.default.join(process.env.PROBE_CACHE_DIR, "bin");
|
|
24305
24334
|
if (await ensureDirectory(cacheDir)) {
|
|
24306
24335
|
if (debug) {
|
|
24307
24336
|
console.log(`DEBUG: Using PROBE_CACHE_DIR: ${cacheDir}`);
|
|
@@ -24314,7 +24343,7 @@ async function getPackageBinDir() {
|
|
|
24314
24343
|
if (debug) {
|
|
24315
24344
|
console.log(`DEBUG: Found package root: ${packageRoot}`);
|
|
24316
24345
|
}
|
|
24317
|
-
const packageBinDir =
|
|
24346
|
+
const packageBinDir = import_path2.default.join(packageRoot, "bin");
|
|
24318
24347
|
if (await ensureDirectory(packageBinDir) && await canWriteToDirectory(packageBinDir)) {
|
|
24319
24348
|
if (debug) {
|
|
24320
24349
|
console.log(`DEBUG: Using package bin directory: ${packageBinDir}`);
|
|
@@ -24324,7 +24353,7 @@ async function getPackageBinDir() {
|
|
|
24324
24353
|
console.log(`DEBUG: Package bin directory ${packageBinDir} not writable, trying fallbacks`);
|
|
24325
24354
|
}
|
|
24326
24355
|
}
|
|
24327
|
-
const homeCache =
|
|
24356
|
+
const homeCache = import_path2.default.join(import_os.default.homedir(), ".probe", "bin");
|
|
24328
24357
|
if (debug) {
|
|
24329
24358
|
console.log(`DEBUG: Trying home cache directory: ${homeCache}`);
|
|
24330
24359
|
}
|
|
@@ -24334,7 +24363,7 @@ async function getPackageBinDir() {
|
|
|
24334
24363
|
}
|
|
24335
24364
|
return homeCache;
|
|
24336
24365
|
}
|
|
24337
|
-
const tempCache =
|
|
24366
|
+
const tempCache = import_path2.default.join(import_os.default.tmpdir(), "probe-cache", "bin");
|
|
24338
24367
|
if (debug) {
|
|
24339
24368
|
console.log(`DEBUG: Trying temp cache directory: ${tempCache}`);
|
|
24340
24369
|
}
|
|
@@ -24347,7 +24376,7 @@ async function getPackageBinDir() {
|
|
|
24347
24376
|
const errorMessage = [
|
|
24348
24377
|
"Could not find a writable directory for probe binary.",
|
|
24349
24378
|
"Tried the following locations:",
|
|
24350
|
-
packageRoot ? `- Package bin directory: ${
|
|
24379
|
+
packageRoot ? `- Package bin directory: ${import_path2.default.join(packageRoot, "bin")}` : "- Package root not found",
|
|
24351
24380
|
`- Home cache directory: ${homeCache}`,
|
|
24352
24381
|
`- Temp cache directory: ${tempCache}`,
|
|
24353
24382
|
"",
|
|
@@ -24360,12 +24389,12 @@ async function getPackageBinDir() {
|
|
|
24360
24389
|
async function findPackageRoot() {
|
|
24361
24390
|
const debug = process.env.DEBUG === "1" || process.env.VERBOSE === "1";
|
|
24362
24391
|
let currentDir = __dirname;
|
|
24363
|
-
const rootDir =
|
|
24392
|
+
const rootDir = import_path2.default.parse(currentDir).root;
|
|
24364
24393
|
if (debug) {
|
|
24365
24394
|
console.log(`DEBUG: Starting package root search from: ${currentDir}`);
|
|
24366
24395
|
}
|
|
24367
24396
|
while (currentDir !== rootDir) {
|
|
24368
|
-
const packageJsonPath =
|
|
24397
|
+
const packageJsonPath = import_path2.default.join(currentDir, "package.json");
|
|
24369
24398
|
try {
|
|
24370
24399
|
if (await import_fs_extra.default.pathExists(packageJsonPath)) {
|
|
24371
24400
|
const packageJson = await import_fs_extra.default.readJson(packageJsonPath);
|
|
@@ -24384,7 +24413,7 @@ async function findPackageRoot() {
|
|
|
24384
24413
|
console.log(`DEBUG: Error reading package.json at ${packageJsonPath}: ${err.message}`);
|
|
24385
24414
|
}
|
|
24386
24415
|
}
|
|
24387
|
-
currentDir =
|
|
24416
|
+
currentDir = import_path2.default.dirname(currentDir);
|
|
24388
24417
|
}
|
|
24389
24418
|
if (debug) {
|
|
24390
24419
|
console.log("DEBUG: Package root not found, reached filesystem root");
|
|
@@ -24395,7 +24424,7 @@ async function ensureDirectory(dirPath) {
|
|
|
24395
24424
|
const debug = process.env.DEBUG === "1" || process.env.VERBOSE === "1";
|
|
24396
24425
|
try {
|
|
24397
24426
|
await import_fs_extra.default.ensureDir(dirPath);
|
|
24398
|
-
const testFile =
|
|
24427
|
+
const testFile = import_path2.default.join(dirPath, ".probe-write-test");
|
|
24399
24428
|
await import_fs_extra.default.writeFile(testFile, "test");
|
|
24400
24429
|
await import_fs_extra.default.remove(testFile);
|
|
24401
24430
|
if (debug) {
|
|
@@ -24419,7 +24448,7 @@ async function canWriteToDirectory(dirPath) {
|
|
|
24419
24448
|
}
|
|
24420
24449
|
return false;
|
|
24421
24450
|
}
|
|
24422
|
-
const testFile =
|
|
24451
|
+
const testFile = import_path2.default.join(dirPath, ".probe-write-test");
|
|
24423
24452
|
await import_fs_extra.default.writeFile(testFile, "test");
|
|
24424
24453
|
await import_fs_extra.default.remove(testFile);
|
|
24425
24454
|
if (debug) {
|
|
@@ -24433,23 +24462,23 @@ async function canWriteToDirectory(dirPath) {
|
|
|
24433
24462
|
return false;
|
|
24434
24463
|
}
|
|
24435
24464
|
}
|
|
24436
|
-
var
|
|
24465
|
+
var import_path2, import_os, import_fs_extra, import_url, __filename, __dirname;
|
|
24437
24466
|
var init_directory_resolver = __esm({
|
|
24438
24467
|
"src/directory-resolver.js"() {
|
|
24439
24468
|
"use strict";
|
|
24440
|
-
|
|
24469
|
+
import_path2 = __toESM(require("path"), 1);
|
|
24441
24470
|
import_os = __toESM(require("os"), 1);
|
|
24442
24471
|
import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
24443
24472
|
import_url = require("url");
|
|
24444
24473
|
__filename = (0, import_url.fileURLToPath)("file:///");
|
|
24445
|
-
__dirname =
|
|
24474
|
+
__dirname = import_path2.default.dirname(__filename);
|
|
24446
24475
|
}
|
|
24447
24476
|
});
|
|
24448
24477
|
|
|
24449
24478
|
// src/utils/symlink-utils.js
|
|
24450
24479
|
async function getEntryType(entry, fullPath) {
|
|
24451
24480
|
try {
|
|
24452
|
-
const stats = await
|
|
24481
|
+
const stats = await import_fs3.promises.stat(fullPath);
|
|
24453
24482
|
return {
|
|
24454
24483
|
isFile: stats.isFile(),
|
|
24455
24484
|
isDirectory: stats.isDirectory(),
|
|
@@ -24465,7 +24494,7 @@ async function getEntryType(entry, fullPath) {
|
|
|
24465
24494
|
}
|
|
24466
24495
|
function getEntryTypeSync(entry, fullPath) {
|
|
24467
24496
|
try {
|
|
24468
|
-
const stats =
|
|
24497
|
+
const stats = import_fs2.default.statSync(fullPath);
|
|
24469
24498
|
return {
|
|
24470
24499
|
isFile: stats.isFile(),
|
|
24471
24500
|
isDirectory: stats.isDirectory(),
|
|
@@ -24479,12 +24508,12 @@ function getEntryTypeSync(entry, fullPath) {
|
|
|
24479
24508
|
};
|
|
24480
24509
|
}
|
|
24481
24510
|
}
|
|
24482
|
-
var
|
|
24511
|
+
var import_fs2, import_fs3;
|
|
24483
24512
|
var init_symlink_utils = __esm({
|
|
24484
24513
|
"src/utils/symlink-utils.js"() {
|
|
24485
24514
|
"use strict";
|
|
24486
|
-
|
|
24487
|
-
|
|
24515
|
+
import_fs2 = __toESM(require("fs"), 1);
|
|
24516
|
+
import_fs3 = require("fs");
|
|
24488
24517
|
}
|
|
24489
24518
|
});
|
|
24490
24519
|
|
|
@@ -24913,7 +24942,7 @@ function findBestAsset(assets, osInfo, archInfo) {
|
|
|
24913
24942
|
}
|
|
24914
24943
|
async function downloadAsset(asset, outputDir) {
|
|
24915
24944
|
await import_fs_extra2.default.ensureDir(outputDir);
|
|
24916
|
-
const assetPath =
|
|
24945
|
+
const assetPath = import_path3.default.join(outputDir, asset.name);
|
|
24917
24946
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
24918
24947
|
console.log(`Downloading ${asset.name}...`);
|
|
24919
24948
|
}
|
|
@@ -24927,7 +24956,7 @@ async function downloadAsset(asset, outputDir) {
|
|
|
24927
24956
|
console.log(`Downloading checksum...`);
|
|
24928
24957
|
}
|
|
24929
24958
|
const checksumResponse = await import_axios.default.get(checksumUrl);
|
|
24930
|
-
checksumPath =
|
|
24959
|
+
checksumPath = import_path3.default.join(outputDir, checksumFileName);
|
|
24931
24960
|
await import_fs_extra2.default.writeFile(checksumPath, checksumResponse.data);
|
|
24932
24961
|
} catch (error40) {
|
|
24933
24962
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
@@ -24960,14 +24989,14 @@ async function verifyChecksum(assetPath, checksumPath) {
|
|
|
24960
24989
|
}
|
|
24961
24990
|
async function extractBinary(assetPath, outputDir) {
|
|
24962
24991
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
24963
|
-
console.log(`Extracting ${
|
|
24992
|
+
console.log(`Extracting ${import_path3.default.basename(assetPath)}...`);
|
|
24964
24993
|
}
|
|
24965
|
-
const assetName =
|
|
24994
|
+
const assetName = import_path3.default.basename(assetPath);
|
|
24966
24995
|
const isWindows = import_os2.default.platform() === "win32";
|
|
24967
24996
|
const binaryName = isWindows ? `${BINARY_NAME}.exe` : `${BINARY_NAME}-binary`;
|
|
24968
|
-
const binaryPath =
|
|
24997
|
+
const binaryPath = import_path3.default.join(outputDir, binaryName);
|
|
24969
24998
|
try {
|
|
24970
|
-
const extractDir =
|
|
24999
|
+
const extractDir = import_path3.default.join(outputDir, "temp_extract");
|
|
24971
25000
|
await import_fs_extra2.default.ensureDir(extractDir);
|
|
24972
25001
|
if (assetName.endsWith(".tar.gz") || assetName.endsWith(".tgz")) {
|
|
24973
25002
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
@@ -25006,7 +25035,7 @@ async function extractBinary(assetPath, outputDir) {
|
|
|
25006
25035
|
const findBinary = async (dir) => {
|
|
25007
25036
|
const entries = await import_fs_extra2.default.readdir(dir, { withFileTypes: true });
|
|
25008
25037
|
for (const entry of entries) {
|
|
25009
|
-
const fullPath =
|
|
25038
|
+
const fullPath = import_path3.default.join(dir, entry.name);
|
|
25010
25039
|
const entryType = await getEntryType(entry, fullPath);
|
|
25011
25040
|
if (entryType.isDirectory) {
|
|
25012
25041
|
const result = await findBinary(fullPath);
|
|
@@ -25045,7 +25074,7 @@ async function extractBinary(assetPath, outputDir) {
|
|
|
25045
25074
|
}
|
|
25046
25075
|
async function getVersionInfo(binDir) {
|
|
25047
25076
|
try {
|
|
25048
|
-
const versionInfoPath =
|
|
25077
|
+
const versionInfoPath = import_path3.default.join(binDir, "version-info.json");
|
|
25049
25078
|
if (await import_fs_extra2.default.pathExists(versionInfoPath)) {
|
|
25050
25079
|
const content = await import_fs_extra2.default.readFile(versionInfoPath, "utf-8");
|
|
25051
25080
|
return JSON.parse(content);
|
|
@@ -25061,7 +25090,7 @@ async function saveVersionInfo(version3, binDir) {
|
|
|
25061
25090
|
version: version3,
|
|
25062
25091
|
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
25063
25092
|
};
|
|
25064
|
-
const versionInfoPath =
|
|
25093
|
+
const versionInfoPath = import_path3.default.join(binDir, "version-info.json");
|
|
25065
25094
|
await import_fs_extra2.default.writeFile(versionInfoPath, JSON.stringify(versionInfo, null, 2));
|
|
25066
25095
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
25067
25096
|
console.log(`Version info saved: ${version3} at ${versionInfoPath}`);
|
|
@@ -25070,9 +25099,9 @@ async function saveVersionInfo(version3, binDir) {
|
|
|
25070
25099
|
async function getPackageVersion() {
|
|
25071
25100
|
try {
|
|
25072
25101
|
const possiblePaths = [
|
|
25073
|
-
|
|
25102
|
+
import_path3.default.resolve(__dirname2, "..", "package.json"),
|
|
25074
25103
|
// When installed from npm: src/../package.json
|
|
25075
|
-
|
|
25104
|
+
import_path3.default.resolve(__dirname2, "..", "..", "package.json")
|
|
25076
25105
|
// In development: src/../../package.json
|
|
25077
25106
|
];
|
|
25078
25107
|
for (const packageJsonPath of possiblePaths) {
|
|
@@ -25107,7 +25136,7 @@ async function doDownload(version3) {
|
|
|
25107
25136
|
}
|
|
25108
25137
|
const isWindows = import_os2.default.platform() === "win32";
|
|
25109
25138
|
const binaryName = isWindows ? `${BINARY_NAME}.exe` : `${BINARY_NAME}-binary`;
|
|
25110
|
-
const binaryPath =
|
|
25139
|
+
const binaryPath = import_path3.default.join(localDir, binaryName);
|
|
25111
25140
|
const { os: osInfo, arch: archInfo } = detectOsArch();
|
|
25112
25141
|
let versionToUse = version3;
|
|
25113
25142
|
let bestAsset;
|
|
@@ -25159,7 +25188,7 @@ async function downloadProbeBinary(version3) {
|
|
|
25159
25188
|
}
|
|
25160
25189
|
const isWindows = import_os2.default.platform() === "win32";
|
|
25161
25190
|
const binaryName = isWindows ? `${BINARY_NAME}.exe` : `${BINARY_NAME}-binary`;
|
|
25162
|
-
const binaryPath =
|
|
25191
|
+
const binaryPath = import_path3.default.join(localDir, binaryName);
|
|
25163
25192
|
if (await import_fs_extra2.default.pathExists(binaryPath)) {
|
|
25164
25193
|
const versionInfo = await getVersionInfo(localDir);
|
|
25165
25194
|
if (versionInfo && versionInfo.version === version3) {
|
|
@@ -25172,7 +25201,7 @@ async function downloadProbeBinary(version3) {
|
|
|
25172
25201
|
console.log(`Existing binary version (${versionInfo?.version || "unknown"}) doesn't match requested version (${version3}). Downloading new version...`);
|
|
25173
25202
|
}
|
|
25174
25203
|
}
|
|
25175
|
-
const lockPath =
|
|
25204
|
+
const lockPath = import_path3.default.join(localDir, `.probe-download-${version3}.lock`);
|
|
25176
25205
|
const maxRetries = 3;
|
|
25177
25206
|
for (let retry = 0; retry < maxRetries; retry++) {
|
|
25178
25207
|
const lockAcquired = await acquireFileLock(lockPath, version3);
|
|
@@ -25209,13 +25238,13 @@ async function downloadProbeBinary(version3) {
|
|
|
25209
25238
|
throw sanitizeError(error40);
|
|
25210
25239
|
}
|
|
25211
25240
|
}
|
|
25212
|
-
var import_axios, import_fs_extra2,
|
|
25241
|
+
var import_axios, import_fs_extra2, import_path3, import_crypto, import_util8, import_child_process, import_tar, import_os2, import_url2, exec, REPO_OWNER, REPO_NAME, BINARY_NAME, __filename2, __dirname2, downloadLocks, LOCK_TIMEOUT_MS, LOCK_POLL_INTERVAL_MS, MAX_LOCK_WAIT_MS;
|
|
25213
25242
|
var init_downloader = __esm({
|
|
25214
25243
|
"src/downloader.js"() {
|
|
25215
25244
|
"use strict";
|
|
25216
25245
|
import_axios = __toESM(require("axios"), 1);
|
|
25217
25246
|
import_fs_extra2 = __toESM(require("fs-extra"), 1);
|
|
25218
|
-
|
|
25247
|
+
import_path3 = __toESM(require("path"), 1);
|
|
25219
25248
|
import_crypto = require("crypto");
|
|
25220
25249
|
import_util8 = require("util");
|
|
25221
25250
|
import_child_process = require("child_process");
|
|
@@ -25230,7 +25259,7 @@ var init_downloader = __esm({
|
|
|
25230
25259
|
REPO_NAME = "probe";
|
|
25231
25260
|
BINARY_NAME = "probe";
|
|
25232
25261
|
__filename2 = (0, import_url2.fileURLToPath)("file:///");
|
|
25233
|
-
__dirname2 =
|
|
25262
|
+
__dirname2 = import_path3.default.dirname(__filename2);
|
|
25234
25263
|
downloadLocks = /* @__PURE__ */ new Map();
|
|
25235
25264
|
LOCK_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
25236
25265
|
LOCK_POLL_INTERVAL_MS = 1e3;
|
|
@@ -25252,14 +25281,14 @@ async function getBinaryPath(options = {}) {
|
|
|
25252
25281
|
}
|
|
25253
25282
|
const isWindows = process.platform === "win32";
|
|
25254
25283
|
const binaryName = isWindows ? "probe.exe" : "probe-binary";
|
|
25255
|
-
const localPackageBin =
|
|
25256
|
-
const localBinaryPath =
|
|
25284
|
+
const localPackageBin = import_path4.default.resolve(__dirname3, "..", "bin");
|
|
25285
|
+
const localBinaryPath = import_path4.default.join(localPackageBin, binaryName);
|
|
25257
25286
|
if (import_fs_extra3.default.existsSync(localBinaryPath) && !forceDownload) {
|
|
25258
25287
|
probeBinaryPath = localBinaryPath;
|
|
25259
25288
|
return probeBinaryPath;
|
|
25260
25289
|
}
|
|
25261
25290
|
const binDir = await getPackageBinDir();
|
|
25262
|
-
const binaryPath =
|
|
25291
|
+
const binaryPath = import_path4.default.join(binDir, binaryName);
|
|
25263
25292
|
if (import_fs_extra3.default.existsSync(binaryPath) && !forceDownload) {
|
|
25264
25293
|
probeBinaryPath = binaryPath;
|
|
25265
25294
|
return probeBinaryPath;
|
|
@@ -25295,17 +25324,17 @@ function escapeString(str) {
|
|
|
25295
25324
|
return `'${str.replace(/'/g, "'\\''")}'`;
|
|
25296
25325
|
}
|
|
25297
25326
|
}
|
|
25298
|
-
var
|
|
25327
|
+
var import_path4, import_fs_extra3, import_url3, __filename3, __dirname3, probeBinaryPath;
|
|
25299
25328
|
var init_utils = __esm({
|
|
25300
25329
|
"src/utils.js"() {
|
|
25301
25330
|
"use strict";
|
|
25302
|
-
|
|
25331
|
+
import_path4 = __toESM(require("path"), 1);
|
|
25303
25332
|
import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
25304
25333
|
import_url3 = require("url");
|
|
25305
25334
|
init_downloader();
|
|
25306
25335
|
init_directory_resolver();
|
|
25307
25336
|
__filename3 = (0, import_url3.fileURLToPath)("file:///");
|
|
25308
|
-
__dirname3 =
|
|
25337
|
+
__dirname3 = import_path4.default.dirname(__filename3);
|
|
25309
25338
|
probeBinaryPath = "";
|
|
25310
25339
|
}
|
|
25311
25340
|
});
|
|
@@ -25529,16 +25558,16 @@ var init_error_types = __esm({
|
|
|
25529
25558
|
// src/utils/path-validation.js
|
|
25530
25559
|
function safeRealpath(inputPath) {
|
|
25531
25560
|
try {
|
|
25532
|
-
return (0,
|
|
25561
|
+
return (0, import_fs4.realpathSync)(inputPath);
|
|
25533
25562
|
} catch (error40) {
|
|
25534
|
-
const normalized =
|
|
25535
|
-
const parts = normalized.split(
|
|
25563
|
+
const normalized = import_path5.default.normalize(inputPath);
|
|
25564
|
+
const parts = normalized.split(import_path5.default.sep);
|
|
25536
25565
|
for (let i = parts.length - 1; i >= 0; i--) {
|
|
25537
|
-
const ancestorPath = parts.slice(0, i).join(
|
|
25566
|
+
const ancestorPath = parts.slice(0, i).join(import_path5.default.sep) || import_path5.default.sep;
|
|
25538
25567
|
try {
|
|
25539
|
-
const resolvedAncestor = (0,
|
|
25568
|
+
const resolvedAncestor = (0, import_fs4.realpathSync)(ancestorPath);
|
|
25540
25569
|
const remainingParts = parts.slice(i);
|
|
25541
|
-
return
|
|
25570
|
+
return import_path5.default.join(resolvedAncestor, ...remainingParts);
|
|
25542
25571
|
} catch (ancestorError) {
|
|
25543
25572
|
continue;
|
|
25544
25573
|
}
|
|
@@ -25548,14 +25577,14 @@ function safeRealpath(inputPath) {
|
|
|
25548
25577
|
}
|
|
25549
25578
|
async function validateCwdPath(inputPath, defaultPath = process.cwd()) {
|
|
25550
25579
|
const targetPath = inputPath || defaultPath;
|
|
25551
|
-
const normalizedPath =
|
|
25580
|
+
const normalizedPath = import_path5.default.normalize(import_path5.default.resolve(targetPath));
|
|
25552
25581
|
try {
|
|
25553
|
-
const stats = await
|
|
25582
|
+
const stats = await import_fs4.promises.stat(normalizedPath);
|
|
25554
25583
|
if (!stats.isDirectory()) {
|
|
25555
25584
|
const resolvedPath = safeRealpath(normalizedPath);
|
|
25556
|
-
const dirPath =
|
|
25585
|
+
const dirPath = import_path5.default.dirname(resolvedPath);
|
|
25557
25586
|
try {
|
|
25558
|
-
const dirStats = await
|
|
25587
|
+
const dirStats = await import_fs4.promises.stat(dirPath);
|
|
25559
25588
|
if (dirStats.isDirectory()) {
|
|
25560
25589
|
return safeRealpath(dirPath);
|
|
25561
25590
|
}
|
|
@@ -25609,7 +25638,7 @@ function getCommonPrefix(folders) {
|
|
|
25609
25638
|
return safeRealpath(folders[0]);
|
|
25610
25639
|
}
|
|
25611
25640
|
const normalized = folders.map((f) => safeRealpath(f));
|
|
25612
|
-
const segments = normalized.map((f) => f.split(
|
|
25641
|
+
const segments = normalized.map((f) => f.split(import_path5.default.sep));
|
|
25613
25642
|
const minLen = Math.min(...segments.map((s) => s.length));
|
|
25614
25643
|
const commonSegments = [];
|
|
25615
25644
|
for (let i = 0; i < minLen; i++) {
|
|
@@ -25629,7 +25658,7 @@ function getCommonPrefix(folders) {
|
|
|
25629
25658
|
if (commonSegments.length === 1 && commonSegments[0] === "") {
|
|
25630
25659
|
return normalized[0];
|
|
25631
25660
|
}
|
|
25632
|
-
return commonSegments.join(
|
|
25661
|
+
return commonSegments.join(import_path5.default.sep);
|
|
25633
25662
|
}
|
|
25634
25663
|
function toRelativePath(absolutePath, workspaceRoot) {
|
|
25635
25664
|
if (!absolutePath || !workspaceRoot) {
|
|
@@ -25637,23 +25666,23 @@ function toRelativePath(absolutePath, workspaceRoot) {
|
|
|
25637
25666
|
}
|
|
25638
25667
|
let normalized = safeRealpath(absolutePath);
|
|
25639
25668
|
let normalizedRoot = safeRealpath(workspaceRoot);
|
|
25640
|
-
while (normalizedRoot.length > 1 && normalizedRoot.endsWith(
|
|
25669
|
+
while (normalizedRoot.length > 1 && normalizedRoot.endsWith(import_path5.default.sep)) {
|
|
25641
25670
|
normalizedRoot = normalizedRoot.slice(0, -1);
|
|
25642
25671
|
}
|
|
25643
25672
|
if (normalized === normalizedRoot) {
|
|
25644
25673
|
return ".";
|
|
25645
25674
|
}
|
|
25646
|
-
if (normalized.startsWith(normalizedRoot +
|
|
25647
|
-
return
|
|
25675
|
+
if (normalized.startsWith(normalizedRoot + import_path5.default.sep)) {
|
|
25676
|
+
return import_path5.default.relative(normalizedRoot, normalized);
|
|
25648
25677
|
}
|
|
25649
25678
|
return absolutePath;
|
|
25650
25679
|
}
|
|
25651
|
-
var
|
|
25680
|
+
var import_path5, import_fs4;
|
|
25652
25681
|
var init_path_validation = __esm({
|
|
25653
25682
|
"src/utils/path-validation.js"() {
|
|
25654
25683
|
"use strict";
|
|
25655
|
-
|
|
25656
|
-
|
|
25684
|
+
import_path5 = __toESM(require("path"), 1);
|
|
25685
|
+
import_fs4 = require("fs");
|
|
25657
25686
|
init_error_types();
|
|
25658
25687
|
}
|
|
25659
25688
|
});
|
|
@@ -27182,8 +27211,8 @@ function parseAndResolvePaths(pathStr, cwd) {
|
|
|
27182
27211
|
if (/["']/.test(pathStr)) {
|
|
27183
27212
|
const paths2 = splitQuotedString(pathStr);
|
|
27184
27213
|
return paths2.map((p) => {
|
|
27185
|
-
if ((0,
|
|
27186
|
-
return cwd ? (0,
|
|
27214
|
+
if ((0, import_path6.isAbsolute)(p)) return p;
|
|
27215
|
+
return cwd ? (0, import_path6.resolve)(cwd, p) : p;
|
|
27187
27216
|
});
|
|
27188
27217
|
}
|
|
27189
27218
|
let paths = pathStr.split(",").map((p) => p.trim()).filter((p) => p.length > 0);
|
|
@@ -27195,8 +27224,8 @@ function parseAndResolvePaths(pathStr, cwd) {
|
|
|
27195
27224
|
return allLookLikePaths ? parts : [p];
|
|
27196
27225
|
});
|
|
27197
27226
|
return paths.map((p) => {
|
|
27198
|
-
if ((0,
|
|
27199
|
-
return cwd ? (0,
|
|
27227
|
+
if ((0, import_path6.isAbsolute)(p)) return p;
|
|
27228
|
+
return cwd ? (0, import_path6.resolve)(cwd, p) : p;
|
|
27200
27229
|
});
|
|
27201
27230
|
}
|
|
27202
27231
|
function resolveTargetPath(target, cwd) {
|
|
@@ -27214,17 +27243,17 @@ function resolveTargetPath(target, cwd) {
|
|
|
27214
27243
|
filePart = target;
|
|
27215
27244
|
suffix = "";
|
|
27216
27245
|
}
|
|
27217
|
-
if (!(0,
|
|
27218
|
-
filePart = (0,
|
|
27246
|
+
if (!(0, import_path6.isAbsolute)(filePart) && cwd) {
|
|
27247
|
+
filePart = (0, import_path6.resolve)(cwd, filePart);
|
|
27219
27248
|
}
|
|
27220
27249
|
return filePart + suffix;
|
|
27221
27250
|
}
|
|
27222
|
-
var
|
|
27251
|
+
var import_path6, searchSchema, searchAllSchema, querySchema, extractSchema, delegateSchema, listSkillsSchema, useSkillSchema, listFilesSchema, searchFilesSchema, readImageSchema, bashSchema, analyzeAllSchema, executePlanSchema, cleanupExecutePlanSchema, searchDescription, searchDelegateDescription, queryDescription, extractDescription, delegateDescription, analyzeAllDescription;
|
|
27223
27252
|
var init_common = __esm({
|
|
27224
27253
|
"src/tools/common.js"() {
|
|
27225
27254
|
"use strict";
|
|
27226
27255
|
init_zod();
|
|
27227
|
-
|
|
27256
|
+
import_path6 = require("path");
|
|
27228
27257
|
searchSchema = external_exports2.object({
|
|
27229
27258
|
query: external_exports2.string().describe("Search query \u2014 natural language questions or Elasticsearch-style keywords both work. For keywords: use quotes for exact phrases, AND/OR for boolean logic, - for negation. Probe handles stemming and camelCase/snake_case splitting automatically, so do NOT try case or style variations of the same keyword."),
|
|
27230
27259
|
path: external_exports2.string().optional().default(".").describe('Path to search in. For dependencies use "go:github.com/owner/repo", "js:package_name", or "rust:cargo_name" etc.'),
|
|
@@ -27639,7 +27668,7 @@ function buildSearchDelegateTask({ searchQuery, searchPath, exact, language, all
|
|
|
27639
27668
|
"Remember: if your search returned relevant results, use nextPage=true to check for more before outputting."
|
|
27640
27669
|
].join("\n");
|
|
27641
27670
|
}
|
|
27642
|
-
var import_ai,
|
|
27671
|
+
var import_ai, import_fs5, CODE_SEARCH_SCHEMA, searchTool, queryTool, extractTool, delegateTool, analyzeAllTool;
|
|
27643
27672
|
var init_vercel = __esm({
|
|
27644
27673
|
"src/tools/vercel.js"() {
|
|
27645
27674
|
"use strict";
|
|
@@ -27650,9 +27679,10 @@ var init_vercel = __esm({
|
|
|
27650
27679
|
init_delegate();
|
|
27651
27680
|
init_analyzeAll();
|
|
27652
27681
|
init_common();
|
|
27653
|
-
|
|
27682
|
+
import_fs5 = require("fs");
|
|
27654
27683
|
init_error_types();
|
|
27655
27684
|
init_hashline();
|
|
27685
|
+
init_simpleTelemetry();
|
|
27656
27686
|
CODE_SEARCH_SCHEMA = {
|
|
27657
27687
|
type: "object",
|
|
27658
27688
|
properties: {
|
|
@@ -27818,6 +27848,12 @@ var init_vercel = __esm({
|
|
|
27818
27848
|
const delegateResult = options.tracer?.withSpan ? await options.tracer.withSpan("search.delegate", runDelegation, {
|
|
27819
27849
|
"search.query": searchQuery,
|
|
27820
27850
|
"search.path": searchPath
|
|
27851
|
+
}, (span, result) => {
|
|
27852
|
+
const text = typeof result === "string" ? result : "";
|
|
27853
|
+
span.setAttributes({
|
|
27854
|
+
"search.delegate.output": truncateForSpan(text),
|
|
27855
|
+
"search.delegate.output_length": text.length
|
|
27856
|
+
});
|
|
27821
27857
|
}) : await runDelegation();
|
|
27822
27858
|
const targets = parseDelegatedTargets(delegateResult);
|
|
27823
27859
|
if (!targets.length) {
|
|
@@ -27837,7 +27873,7 @@ var init_vercel = __esm({
|
|
|
27837
27873
|
const validatedTargets = [];
|
|
27838
27874
|
for (const target of resolvedTargets) {
|
|
27839
27875
|
const { filePart, suffix } = splitTargetSuffix(target);
|
|
27840
|
-
if ((0,
|
|
27876
|
+
if ((0, import_fs5.existsSync)(filePart)) {
|
|
27841
27877
|
validatedTargets.push(target);
|
|
27842
27878
|
continue;
|
|
27843
27879
|
}
|
|
@@ -27846,7 +27882,7 @@ var init_vercel = __esm({
|
|
|
27846
27882
|
for (let i = 0; i < parts.length - 1; i++) {
|
|
27847
27883
|
if (parts[i] === parts[i + 1]) {
|
|
27848
27884
|
const candidate = "/" + [...parts.slice(0, i), ...parts.slice(i + 1)].join("/");
|
|
27849
|
-
if ((0,
|
|
27885
|
+
if ((0, import_fs5.existsSync)(candidate)) {
|
|
27850
27886
|
validatedTargets.push(candidate + suffix);
|
|
27851
27887
|
if (debug) console.error(`[search-delegate] Fixed doubled path segment: ${filePart} \u2192 ${candidate}`);
|
|
27852
27888
|
fixed = true;
|
|
@@ -27859,7 +27895,7 @@ var init_vercel = __esm({
|
|
|
27859
27895
|
if (altBase === delegateBase) continue;
|
|
27860
27896
|
const altResolved = resolveTargetPath(target, altBase);
|
|
27861
27897
|
const { filePart: altFile } = splitTargetSuffix(altResolved);
|
|
27862
|
-
if ((0,
|
|
27898
|
+
if ((0, import_fs5.existsSync)(altFile)) {
|
|
27863
27899
|
validatedTargets.push(altResolved);
|
|
27864
27900
|
if (debug) console.error(`[search-delegate] Resolved with alt base: ${filePart} \u2192 ${altFile}`);
|
|
27865
27901
|
fixed = true;
|
|
@@ -27984,13 +28020,13 @@ var init_vercel = __esm({
|
|
|
27984
28020
|
const { join: pathJoin, sep: pathSep } = await import("path");
|
|
27985
28021
|
extractFiles = extractFiles.map((target) => {
|
|
27986
28022
|
const { filePart, suffix } = splitTargetSuffix(target);
|
|
27987
|
-
if ((0,
|
|
28023
|
+
if ((0, import_fs5.existsSync)(filePart)) return target;
|
|
27988
28024
|
const cwdPrefix = effectiveCwd.endsWith(pathSep) ? effectiveCwd : effectiveCwd + pathSep;
|
|
27989
28025
|
const relativePart = filePart.startsWith(cwdPrefix) ? filePart.slice(cwdPrefix.length) : null;
|
|
27990
28026
|
if (relativePart) {
|
|
27991
28027
|
for (const folder of options.allowedFolders) {
|
|
27992
28028
|
const candidate = pathJoin(folder, relativePart);
|
|
27993
|
-
if ((0,
|
|
28029
|
+
if ((0, import_fs5.existsSync)(candidate)) {
|
|
27994
28030
|
if (debug) console.error(`[extract] Auto-fixed path: ${filePart} \u2192 ${candidate}`);
|
|
27995
28031
|
return candidate + suffix;
|
|
27996
28032
|
}
|
|
@@ -28003,7 +28039,7 @@ var init_vercel = __esm({
|
|
|
28003
28039
|
if (filePart.startsWith(wsParent)) {
|
|
28004
28040
|
const tail = filePart.slice(wsParent.length);
|
|
28005
28041
|
const candidate = pathJoin(folderPrefix, tail);
|
|
28006
|
-
if (candidate !== filePart && (0,
|
|
28042
|
+
if (candidate !== filePart && (0, import_fs5.existsSync)(candidate)) {
|
|
28007
28043
|
if (debug) console.error(`[extract] Auto-fixed path via workspace: ${filePart} \u2192 ${candidate}`);
|
|
28008
28044
|
return candidate + suffix;
|
|
28009
28045
|
}
|
|
@@ -29601,8 +29637,8 @@ async function executeBashCommand(command, options = {}) {
|
|
|
29601
29637
|
} = options;
|
|
29602
29638
|
let cwd = workingDirectory;
|
|
29603
29639
|
try {
|
|
29604
|
-
cwd = (0,
|
|
29605
|
-
if (!(0,
|
|
29640
|
+
cwd = (0, import_path7.resolve)(cwd);
|
|
29641
|
+
if (!(0, import_fs6.existsSync)(cwd)) {
|
|
29606
29642
|
throw new Error(`Working directory does not exist: ${cwd}`);
|
|
29607
29643
|
}
|
|
29608
29644
|
} catch (error40) {
|
|
@@ -29858,7 +29894,7 @@ function validateExecutionOptions(options = {}) {
|
|
|
29858
29894
|
if (options.workingDirectory) {
|
|
29859
29895
|
if (typeof options.workingDirectory !== "string") {
|
|
29860
29896
|
errors.push("workingDirectory must be a string");
|
|
29861
|
-
} else if (!(0,
|
|
29897
|
+
} else if (!(0, import_fs6.existsSync)(options.workingDirectory)) {
|
|
29862
29898
|
errors.push(`workingDirectory does not exist: ${options.workingDirectory}`);
|
|
29863
29899
|
}
|
|
29864
29900
|
}
|
|
@@ -29871,24 +29907,24 @@ function validateExecutionOptions(options = {}) {
|
|
|
29871
29907
|
warnings
|
|
29872
29908
|
};
|
|
29873
29909
|
}
|
|
29874
|
-
var import_child_process6,
|
|
29910
|
+
var import_child_process6, import_path7, import_fs6;
|
|
29875
29911
|
var init_bashExecutor = __esm({
|
|
29876
29912
|
"src/agent/bashExecutor.js"() {
|
|
29877
29913
|
"use strict";
|
|
29878
29914
|
import_child_process6 = require("child_process");
|
|
29879
|
-
|
|
29880
|
-
|
|
29915
|
+
import_path7 = require("path");
|
|
29916
|
+
import_fs6 = require("fs");
|
|
29881
29917
|
init_bashCommandUtils();
|
|
29882
29918
|
}
|
|
29883
29919
|
});
|
|
29884
29920
|
|
|
29885
29921
|
// src/tools/bash.js
|
|
29886
|
-
var import_ai2,
|
|
29922
|
+
var import_ai2, import_path8, bashTool;
|
|
29887
29923
|
var init_bash = __esm({
|
|
29888
29924
|
"src/tools/bash.js"() {
|
|
29889
29925
|
"use strict";
|
|
29890
29926
|
import_ai2 = require("ai");
|
|
29891
|
-
|
|
29927
|
+
import_path8 = require("path");
|
|
29892
29928
|
init_bashPermissions();
|
|
29893
29929
|
init_bashExecutor();
|
|
29894
29930
|
init_path_validation();
|
|
@@ -30005,12 +30041,12 @@ For code exploration, try these safe alternatives:
|
|
|
30005
30041
|
- npm list, pip list for package information`;
|
|
30006
30042
|
}
|
|
30007
30043
|
const defaultDir = getDefaultWorkingDirectory();
|
|
30008
|
-
const workingDir = workingDirectory ? (0,
|
|
30044
|
+
const workingDir = workingDirectory ? (0, import_path8.isAbsolute)(workingDirectory) ? (0, import_path8.resolve)(workingDirectory) : (0, import_path8.resolve)(defaultDir, workingDirectory) : defaultDir;
|
|
30009
30045
|
if (allowedFolders && allowedFolders.length > 0) {
|
|
30010
30046
|
const resolvedWorkingDir = safeRealpath(workingDir);
|
|
30011
30047
|
const isAllowed = allowedFolders.some((folder) => {
|
|
30012
30048
|
const resolvedFolder = safeRealpath(folder);
|
|
30013
|
-
return resolvedWorkingDir === resolvedFolder || resolvedWorkingDir.startsWith(resolvedFolder +
|
|
30049
|
+
return resolvedWorkingDir === resolvedFolder || resolvedWorkingDir.startsWith(resolvedFolder + import_path8.sep);
|
|
30014
30050
|
});
|
|
30015
30051
|
if (!isAllowed) {
|
|
30016
30052
|
const relativeDir = toRelativePath(workingDir, workspaceRoot);
|
|
@@ -30422,12 +30458,12 @@ function isPathAllowed(filePath, allowedFolders) {
|
|
|
30422
30458
|
if (!allowedFolders || allowedFolders.length === 0) {
|
|
30423
30459
|
const resolvedPath2 = safeRealpath(filePath);
|
|
30424
30460
|
const cwd = safeRealpath(process.cwd());
|
|
30425
|
-
return resolvedPath2 === cwd || resolvedPath2.startsWith(cwd +
|
|
30461
|
+
return resolvedPath2 === cwd || resolvedPath2.startsWith(cwd + import_path9.sep);
|
|
30426
30462
|
}
|
|
30427
30463
|
const resolvedPath = safeRealpath(filePath);
|
|
30428
30464
|
return allowedFolders.some((folder) => {
|
|
30429
30465
|
const allowedPath = safeRealpath(folder);
|
|
30430
|
-
return resolvedPath === allowedPath || resolvedPath.startsWith(allowedPath +
|
|
30466
|
+
return resolvedPath === allowedPath || resolvedPath.startsWith(allowedPath + import_path9.sep);
|
|
30431
30467
|
});
|
|
30432
30468
|
}
|
|
30433
30469
|
function parseFileToolOptions(options = {}) {
|
|
@@ -30467,7 +30503,7 @@ Example: <edit><file_path>${file_path}</file_path><symbol>${allMatches[0].qualif
|
|
|
30467
30503
|
return `Error editing ${file_path}: Symbol "${symbol17}" has changed since you last read it. Use the extract tool with targets="${file_path}#${symbol17}" to re-read the current content, then retry.`;
|
|
30468
30504
|
}
|
|
30469
30505
|
}
|
|
30470
|
-
const content = await
|
|
30506
|
+
const content = await import_fs7.promises.readFile(resolvedPath, "utf-8");
|
|
30471
30507
|
const lines = content.split("\n");
|
|
30472
30508
|
if (position) {
|
|
30473
30509
|
const refIndent = detectBaseIndent(symbolInfo.code);
|
|
@@ -30478,7 +30514,7 @@ Example: <edit><file_path>${file_path}</file_path><symbol>${allMatches[0].qualif
|
|
|
30478
30514
|
} else {
|
|
30479
30515
|
lines.splice(symbolInfo.startLine - 1, 0, ...newLines, "");
|
|
30480
30516
|
}
|
|
30481
|
-
await
|
|
30517
|
+
await import_fs7.promises.writeFile(resolvedPath, lines.join("\n"), "utf-8");
|
|
30482
30518
|
if (fileTracker) {
|
|
30483
30519
|
const updated = await findSymbol(resolvedPath, symbol17, cwd || process.cwd());
|
|
30484
30520
|
if (updated) {
|
|
@@ -30496,7 +30532,7 @@ Example: <edit><file_path>${file_path}</file_path><symbol>${allMatches[0].qualif
|
|
|
30496
30532
|
const reindented = reindent(new_string, originalIndent);
|
|
30497
30533
|
const newLines = reindented.split("\n");
|
|
30498
30534
|
lines.splice(symbolInfo.startLine - 1, symbolInfo.endLine - symbolInfo.startLine + 1, ...newLines);
|
|
30499
|
-
await
|
|
30535
|
+
await import_fs7.promises.writeFile(resolvedPath, lines.join("\n"), "utf-8");
|
|
30500
30536
|
if (fileTracker) {
|
|
30501
30537
|
const updated = await findSymbol(resolvedPath, symbol17, cwd || process.cwd());
|
|
30502
30538
|
if (updated) {
|
|
@@ -30551,7 +30587,7 @@ async function handleLineEdit({ resolvedPath, file_path, start_line, end_line, n
|
|
|
30551
30587
|
if (position !== void 0 && position !== null && position !== "before" && position !== "after") {
|
|
30552
30588
|
return 'Error editing file: Invalid position - must be "before" or "after". Use position="before" to insert before the line, or position="after" to insert after it.';
|
|
30553
30589
|
}
|
|
30554
|
-
const content = await
|
|
30590
|
+
const content = await import_fs7.promises.readFile(resolvedPath, "utf-8");
|
|
30555
30591
|
const fileLines = content.split("\n");
|
|
30556
30592
|
if (startLine > fileLines.length) {
|
|
30557
30593
|
return `Error editing file: Line ${startLine} is beyond file length (${fileLines.length} lines). Use 'extract' to read the current file content.`;
|
|
@@ -30580,20 +30616,20 @@ async function handleLineEdit({ resolvedPath, file_path, start_line, end_line, n
|
|
|
30580
30616
|
const newLines = cleaned === "" ? [] : cleaned.split("\n");
|
|
30581
30617
|
if (position === "after") {
|
|
30582
30618
|
fileLines.splice(startLine, 0, ...newLines);
|
|
30583
|
-
await
|
|
30619
|
+
await import_fs7.promises.writeFile(resolvedPath, fileLines.join("\n"), "utf-8");
|
|
30584
30620
|
if (fileTracker) await fileTracker.trackFileAfterWrite(resolvedPath);
|
|
30585
30621
|
const action = `${newLines.length} line${newLines.length !== 1 ? "s" : ""} inserted after line ${startLine}`;
|
|
30586
30622
|
return buildLineEditResponse(file_path, startLine, startLine, newLines.length, fileLines, startLine, action, modifications);
|
|
30587
30623
|
} else if (position === "before") {
|
|
30588
30624
|
fileLines.splice(startLine - 1, 0, ...newLines);
|
|
30589
|
-
await
|
|
30625
|
+
await import_fs7.promises.writeFile(resolvedPath, fileLines.join("\n"), "utf-8");
|
|
30590
30626
|
if (fileTracker) await fileTracker.trackFileAfterWrite(resolvedPath);
|
|
30591
30627
|
const action = `${newLines.length} line${newLines.length !== 1 ? "s" : ""} inserted before line ${startLine}`;
|
|
30592
30628
|
return buildLineEditResponse(file_path, startLine, startLine, newLines.length, fileLines, startLine - 1, action, modifications);
|
|
30593
30629
|
} else {
|
|
30594
30630
|
const replacedCount = endLine - startLine + 1;
|
|
30595
30631
|
fileLines.splice(startLine - 1, replacedCount, ...newLines);
|
|
30596
|
-
await
|
|
30632
|
+
await import_fs7.promises.writeFile(resolvedPath, fileLines.join("\n"), "utf-8");
|
|
30597
30633
|
if (fileTracker) await fileTracker.trackFileAfterWrite(resolvedPath);
|
|
30598
30634
|
let action;
|
|
30599
30635
|
if (newLines.length === 0) {
|
|
@@ -30606,14 +30642,14 @@ async function handleLineEdit({ resolvedPath, file_path, start_line, end_line, n
|
|
|
30606
30642
|
return buildLineEditResponse(file_path, startLine, endLine, newLines.length, fileLines, startLine - 1, action, modifications);
|
|
30607
30643
|
}
|
|
30608
30644
|
}
|
|
30609
|
-
var import_ai3,
|
|
30645
|
+
var import_ai3, import_fs7, import_path9, import_fs8, editTool, createTool, multiEditTool, editSchema, createSchema, multiEditSchema, editDescription, createDescription, multiEditDescription, editToolDefinition, createToolDefinition, multiEditToolDefinition;
|
|
30610
30646
|
var init_edit = __esm({
|
|
30611
30647
|
"src/tools/edit.js"() {
|
|
30612
30648
|
"use strict";
|
|
30613
30649
|
import_ai3 = require("ai");
|
|
30614
|
-
import_fs6 = require("fs");
|
|
30615
|
-
import_path8 = require("path");
|
|
30616
30650
|
import_fs7 = require("fs");
|
|
30651
|
+
import_path9 = require("path");
|
|
30652
|
+
import_fs8 = require("fs");
|
|
30617
30653
|
init_path_validation();
|
|
30618
30654
|
init_fuzzyMatch();
|
|
30619
30655
|
init_symbolEdit();
|
|
@@ -30689,7 +30725,7 @@ Parameters:
|
|
|
30689
30725
|
return `Error editing file: Invalid new_string - must be a string. Provide the replacement content as a string value (empty string "" is valid for deletions).`;
|
|
30690
30726
|
}
|
|
30691
30727
|
const effectiveCwd = workingDirectory || cwd || process.cwd();
|
|
30692
|
-
const resolvedPath = (0,
|
|
30728
|
+
const resolvedPath = (0, import_path9.isAbsolute)(file_path) ? file_path : (0, import_path9.resolve)(effectiveCwd, file_path);
|
|
30693
30729
|
if (debug) {
|
|
30694
30730
|
console.error(`[Edit] Attempting to edit file: ${resolvedPath}`);
|
|
30695
30731
|
}
|
|
@@ -30697,7 +30733,7 @@ Parameters:
|
|
|
30697
30733
|
const relativePath = toRelativePath(resolvedPath, workspaceRoot);
|
|
30698
30734
|
return `Error editing file: Permission denied - ${relativePath} is outside allowed directories. Use a file path within the project workspace.`;
|
|
30699
30735
|
}
|
|
30700
|
-
if (!(0,
|
|
30736
|
+
if (!(0, import_fs8.existsSync)(resolvedPath)) {
|
|
30701
30737
|
return `Error editing file: File not found - ${file_path}. Verify the path is correct and the file exists. Use 'search' to find files by name, or 'create' to make a new file.`;
|
|
30702
30738
|
}
|
|
30703
30739
|
if (options.fileTracker && !options.fileTracker.isFileSeen(resolvedPath)) {
|
|
@@ -30725,7 +30761,7 @@ Parameters:
|
|
|
30725
30761
|
Use the extract tool with targets="${displayPath}" to re-read the file, then retry.`;
|
|
30726
30762
|
}
|
|
30727
30763
|
}
|
|
30728
|
-
const content = await
|
|
30764
|
+
const content = await import_fs7.promises.readFile(resolvedPath, "utf-8");
|
|
30729
30765
|
let matchTarget = old_string;
|
|
30730
30766
|
let matchStrategy = "exact";
|
|
30731
30767
|
if (!content.includes(old_string)) {
|
|
@@ -30757,7 +30793,7 @@ Use the extract tool with targets="${displayPath}" to re-read the file, then ret
|
|
|
30757
30793
|
if (newContent === content) {
|
|
30758
30794
|
return `Error editing file: No changes made - the replacement result is identical to the original. Verify that old_string and new_string are actually different. If fuzzy matching was used, the matched text may already equal new_string.`;
|
|
30759
30795
|
}
|
|
30760
|
-
await
|
|
30796
|
+
await import_fs7.promises.writeFile(resolvedPath, newContent, "utf-8");
|
|
30761
30797
|
if (options.fileTracker) {
|
|
30762
30798
|
await options.fileTracker.trackFileAfterWrite(resolvedPath);
|
|
30763
30799
|
options.fileTracker.recordTextEdit(resolvedPath);
|
|
@@ -30820,7 +30856,7 @@ Important:
|
|
|
30820
30856
|
return `Error creating file: Invalid content - must be a string. Provide the file content as a string value (empty string "" is valid for an empty file).`;
|
|
30821
30857
|
}
|
|
30822
30858
|
const effectiveCwd = workingDirectory || cwd || process.cwd();
|
|
30823
|
-
const resolvedPath = (0,
|
|
30859
|
+
const resolvedPath = (0, import_path9.isAbsolute)(file_path) ? file_path : (0, import_path9.resolve)(effectiveCwd, file_path);
|
|
30824
30860
|
if (debug) {
|
|
30825
30861
|
console.error(`[Create] Attempting to create file: ${resolvedPath}`);
|
|
30826
30862
|
}
|
|
@@ -30828,13 +30864,13 @@ Important:
|
|
|
30828
30864
|
const relativePath = toRelativePath(resolvedPath, workspaceRoot);
|
|
30829
30865
|
return `Error creating file: Permission denied - ${relativePath} is outside allowed directories. Use a file path within the project workspace.`;
|
|
30830
30866
|
}
|
|
30831
|
-
if ((0,
|
|
30867
|
+
if ((0, import_fs8.existsSync)(resolvedPath) && !overwrite) {
|
|
30832
30868
|
return `Error creating file: File already exists - ${file_path}. Use overwrite: true to replace it.`;
|
|
30833
30869
|
}
|
|
30834
|
-
const existed = (0,
|
|
30835
|
-
const dir = (0,
|
|
30836
|
-
await
|
|
30837
|
-
await
|
|
30870
|
+
const existed = (0, import_fs8.existsSync)(resolvedPath);
|
|
30871
|
+
const dir = (0, import_path9.dirname)(resolvedPath);
|
|
30872
|
+
await import_fs7.promises.mkdir(dir, { recursive: true });
|
|
30873
|
+
await import_fs7.promises.writeFile(resolvedPath, content, "utf-8");
|
|
30838
30874
|
if (options.fileTracker) await options.fileTracker.trackFileAfterWrite(resolvedPath);
|
|
30839
30875
|
const action = existed && overwrite ? "overwrote" : "created";
|
|
30840
30876
|
const bytes = Buffer.byteLength(content, "utf-8");
|
|
@@ -45181,22 +45217,22 @@ var init_esm3 = __esm({
|
|
|
45181
45217
|
});
|
|
45182
45218
|
|
|
45183
45219
|
// node_modules/path-scurry/dist/esm/index.js
|
|
45184
|
-
var import_node_path, import_node_url,
|
|
45220
|
+
var import_node_path, import_node_url, import_fs9, actualFS, import_promises, realpathSync2, defaultFS, fsFromOption, uncDriveRegexp, uncToDrive, eitherSep, UNKNOWN, IFIFO, IFCHR, IFDIR, IFBLK, IFREG, IFLNK, IFSOCK, IFMT, IFMT_UNKNOWN, READDIR_CALLED, LSTAT_CALLED, ENOTDIR, ENOENT, ENOREADLINK, ENOREALPATH, ENOCHILD, TYPEMASK, entToType, normalizeCache, normalize, normalizeNocaseCache, normalizeNocase, ResolveCache, ChildrenCache, setAsCwd, PathBase, PathWin32, PathPosix, PathScurryBase, PathScurryWin32, PathScurryPosix, PathScurryDarwin, Path, PathScurry;
|
|
45185
45221
|
var init_esm4 = __esm({
|
|
45186
45222
|
"node_modules/path-scurry/dist/esm/index.js"() {
|
|
45187
45223
|
init_esm2();
|
|
45188
45224
|
import_node_path = require("node:path");
|
|
45189
45225
|
import_node_url = require("node:url");
|
|
45190
|
-
|
|
45226
|
+
import_fs9 = require("fs");
|
|
45191
45227
|
actualFS = __toESM(require("node:fs"), 1);
|
|
45192
45228
|
import_promises = require("node:fs/promises");
|
|
45193
45229
|
init_esm3();
|
|
45194
|
-
realpathSync2 =
|
|
45230
|
+
realpathSync2 = import_fs9.realpathSync.native;
|
|
45195
45231
|
defaultFS = {
|
|
45196
|
-
lstatSync:
|
|
45197
|
-
readdir:
|
|
45198
|
-
readdirSync:
|
|
45199
|
-
readlinkSync:
|
|
45232
|
+
lstatSync: import_fs9.lstatSync,
|
|
45233
|
+
readdir: import_fs9.readdir,
|
|
45234
|
+
readdirSync: import_fs9.readdirSync,
|
|
45235
|
+
readlinkSync: import_fs9.readlinkSync,
|
|
45200
45236
|
realpathSync: realpathSync2,
|
|
45201
45237
|
promises: {
|
|
45202
45238
|
lstat: import_promises.lstat,
|
|
@@ -48725,10 +48761,10 @@ async function listFilesByLevel(options) {
|
|
|
48725
48761
|
maxFiles = 100,
|
|
48726
48762
|
respectGitignore = true
|
|
48727
48763
|
} = options;
|
|
48728
|
-
if (!
|
|
48764
|
+
if (!import_fs10.default.existsSync(directory)) {
|
|
48729
48765
|
throw new Error(`Directory does not exist: ${directory}`);
|
|
48730
48766
|
}
|
|
48731
|
-
const gitDirExists =
|
|
48767
|
+
const gitDirExists = import_fs10.default.existsSync(import_path10.default.join(directory, ".git"));
|
|
48732
48768
|
if (gitDirExists && respectGitignore) {
|
|
48733
48769
|
try {
|
|
48734
48770
|
return await listFilesUsingGit(directory, maxFiles);
|
|
@@ -48743,8 +48779,8 @@ async function listFilesUsingGit(directory, maxFiles) {
|
|
|
48743
48779
|
const { stdout } = await execAsync3("git ls-files", { cwd: directory });
|
|
48744
48780
|
const files = stdout.split("\n").filter(Boolean);
|
|
48745
48781
|
const sortedFiles = files.sort((a, b) => {
|
|
48746
|
-
const depthA = a.split(
|
|
48747
|
-
const depthB = b.split(
|
|
48782
|
+
const depthA = a.split(import_path10.default.sep).length;
|
|
48783
|
+
const depthB = b.split(import_path10.default.sep).length;
|
|
48748
48784
|
return depthA - depthB;
|
|
48749
48785
|
});
|
|
48750
48786
|
return sortedFiles.slice(0, maxFiles);
|
|
@@ -48759,25 +48795,25 @@ async function listFilesByLevelManually(directory, maxFiles, respectGitignore) {
|
|
|
48759
48795
|
while (queue.length > 0 && result.length < maxFiles) {
|
|
48760
48796
|
const { dir, level } = queue.shift();
|
|
48761
48797
|
try {
|
|
48762
|
-
const entries =
|
|
48798
|
+
const entries = import_fs10.default.readdirSync(dir, { withFileTypes: true });
|
|
48763
48799
|
const files = entries.filter((entry) => {
|
|
48764
|
-
const fullPath =
|
|
48800
|
+
const fullPath = import_path10.default.join(dir, entry.name);
|
|
48765
48801
|
return getEntryTypeSync(entry, fullPath).isFile;
|
|
48766
48802
|
});
|
|
48767
48803
|
for (const file2 of files) {
|
|
48768
48804
|
if (result.length >= maxFiles) break;
|
|
48769
|
-
const filePath =
|
|
48770
|
-
const relativePath =
|
|
48805
|
+
const filePath = import_path10.default.join(dir, file2.name);
|
|
48806
|
+
const relativePath = import_path10.default.relative(directory, filePath);
|
|
48771
48807
|
if (shouldIgnore(relativePath, ignorePatterns)) continue;
|
|
48772
48808
|
result.push(relativePath);
|
|
48773
48809
|
}
|
|
48774
48810
|
const dirs = entries.filter((entry) => {
|
|
48775
|
-
const fullPath =
|
|
48811
|
+
const fullPath = import_path10.default.join(dir, entry.name);
|
|
48776
48812
|
return getEntryTypeSync(entry, fullPath).isDirectory;
|
|
48777
48813
|
});
|
|
48778
48814
|
for (const subdir of dirs) {
|
|
48779
|
-
const subdirPath =
|
|
48780
|
-
const relativeSubdirPath =
|
|
48815
|
+
const subdirPath = import_path10.default.join(dir, subdir.name);
|
|
48816
|
+
const relativeSubdirPath = import_path10.default.relative(directory, subdirPath);
|
|
48781
48817
|
if (shouldIgnore(relativeSubdirPath, ignorePatterns)) continue;
|
|
48782
48818
|
if (subdir.name === "node_modules" || subdir.name === ".git") continue;
|
|
48783
48819
|
queue.push({ dir: subdirPath, level: level + 1 });
|
|
@@ -48789,12 +48825,12 @@ async function listFilesByLevelManually(directory, maxFiles, respectGitignore) {
|
|
|
48789
48825
|
return result;
|
|
48790
48826
|
}
|
|
48791
48827
|
function loadGitignorePatterns(directory) {
|
|
48792
|
-
const gitignorePath =
|
|
48793
|
-
if (!
|
|
48828
|
+
const gitignorePath = import_path10.default.join(directory, ".gitignore");
|
|
48829
|
+
if (!import_fs10.default.existsSync(gitignorePath)) {
|
|
48794
48830
|
return [];
|
|
48795
48831
|
}
|
|
48796
48832
|
try {
|
|
48797
|
-
const content =
|
|
48833
|
+
const content = import_fs10.default.readFileSync(gitignorePath, "utf8");
|
|
48798
48834
|
return content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
48799
48835
|
} catch (error40) {
|
|
48800
48836
|
console.error(`Warning: Could not read .gitignore: ${error40.message}`);
|
|
@@ -48812,12 +48848,12 @@ function shouldIgnore(filePath, ignorePatterns) {
|
|
|
48812
48848
|
}
|
|
48813
48849
|
return false;
|
|
48814
48850
|
}
|
|
48815
|
-
var
|
|
48851
|
+
var import_fs10, import_path10, import_util13, import_child_process7, execAsync3;
|
|
48816
48852
|
var init_file_lister = __esm({
|
|
48817
48853
|
"src/utils/file-lister.js"() {
|
|
48818
48854
|
"use strict";
|
|
48819
|
-
|
|
48820
|
-
|
|
48855
|
+
import_fs10 = __toESM(require("fs"), 1);
|
|
48856
|
+
import_path10 = __toESM(require("path"), 1);
|
|
48821
48857
|
import_util13 = require("util");
|
|
48822
48858
|
import_child_process7 = require("child_process");
|
|
48823
48859
|
init_symlink_utils();
|
|
@@ -48828,7 +48864,7 @@ var init_file_lister = __esm({
|
|
|
48828
48864
|
// src/tools/fileTracker.js
|
|
48829
48865
|
function normalizePath(filePath) {
|
|
48830
48866
|
if (!filePath) return filePath;
|
|
48831
|
-
return (0,
|
|
48867
|
+
return (0, import_path11.resolve)(filePath);
|
|
48832
48868
|
}
|
|
48833
48869
|
function computeContentHash(content) {
|
|
48834
48870
|
const normalized = (content || "").split("\n").map((l) => l.trimEnd()).join("\n");
|
|
@@ -48868,12 +48904,12 @@ function parseFilePathsFromOutput(output) {
|
|
|
48868
48904
|
}
|
|
48869
48905
|
return paths;
|
|
48870
48906
|
}
|
|
48871
|
-
var import_crypto3,
|
|
48907
|
+
var import_crypto3, import_path11, FileTracker;
|
|
48872
48908
|
var init_fileTracker = __esm({
|
|
48873
48909
|
"src/tools/fileTracker.js"() {
|
|
48874
48910
|
"use strict";
|
|
48875
48911
|
import_crypto3 = require("crypto");
|
|
48876
|
-
|
|
48912
|
+
import_path11 = require("path");
|
|
48877
48913
|
init_symbolEdit();
|
|
48878
48914
|
FileTracker = class {
|
|
48879
48915
|
/**
|
|
@@ -48974,7 +49010,7 @@ var init_fileTracker = __esm({
|
|
|
48974
49010
|
const symbolPromises = [];
|
|
48975
49011
|
for (const target of targets) {
|
|
48976
49012
|
const filePath = extractFilePath(target);
|
|
48977
|
-
const resolved = (0,
|
|
49013
|
+
const resolved = (0, import_path11.isAbsolute)(filePath) ? filePath : (0, import_path11.resolve)(cwd, filePath);
|
|
48978
49014
|
if (!seenPaths.has(resolved)) {
|
|
48979
49015
|
seenPaths.add(resolved);
|
|
48980
49016
|
this.markFileSeen(resolved);
|
|
@@ -49014,7 +49050,7 @@ var init_fileTracker = __esm({
|
|
|
49014
49050
|
async trackFilesFromOutput(output, cwd) {
|
|
49015
49051
|
const paths = parseFilePathsFromOutput(output);
|
|
49016
49052
|
for (const filePath of paths) {
|
|
49017
|
-
const resolved = (0,
|
|
49053
|
+
const resolved = (0, import_path11.isAbsolute)(filePath) ? filePath : (0, import_path11.resolve)(cwd, filePath);
|
|
49018
49054
|
this.markFileSeen(resolved);
|
|
49019
49055
|
}
|
|
49020
49056
|
}
|
|
@@ -49122,27 +49158,6 @@ var init_fileTracker = __esm({
|
|
|
49122
49158
|
}
|
|
49123
49159
|
});
|
|
49124
49160
|
|
|
49125
|
-
// src/agent/otelLogBridge.js
|
|
49126
|
-
var import_module, _require;
|
|
49127
|
-
var init_otelLogBridge = __esm({
|
|
49128
|
-
"src/agent/otelLogBridge.js"() {
|
|
49129
|
-
"use strict";
|
|
49130
|
-
import_module = require("module");
|
|
49131
|
-
_require = (0, import_module.createRequire)("file:///");
|
|
49132
|
-
}
|
|
49133
|
-
});
|
|
49134
|
-
|
|
49135
|
-
// src/agent/simpleTelemetry.js
|
|
49136
|
-
var import_fs10, import_path11;
|
|
49137
|
-
var init_simpleTelemetry = __esm({
|
|
49138
|
-
"src/agent/simpleTelemetry.js"() {
|
|
49139
|
-
"use strict";
|
|
49140
|
-
import_fs10 = require("fs");
|
|
49141
|
-
import_path11 = require("path");
|
|
49142
|
-
init_otelLogBridge();
|
|
49143
|
-
}
|
|
49144
|
-
});
|
|
49145
|
-
|
|
49146
49161
|
// src/agent/probeTool.js
|
|
49147
49162
|
function isSessionCancelled(sessionId) {
|
|
49148
49163
|
return activeToolExecutions.get(sessionId)?.cancelled || false;
|
|
@@ -100006,6 +100021,7 @@ var init_ProbeAgent = __esm({
|
|
|
100006
100021
|
import_promises6 = require("fs/promises");
|
|
100007
100022
|
import_path18 = require("path");
|
|
100008
100023
|
init_tokenCounter();
|
|
100024
|
+
init_simpleTelemetry();
|
|
100009
100025
|
init_InMemoryStorageAdapter();
|
|
100010
100026
|
init_HookManager();
|
|
100011
100027
|
init_imageConfig();
|
|
@@ -103344,7 +103360,7 @@ Double-check your response based on the criteria above. If everything looks good
|
|
|
103344
103360
|
};
|
|
103345
103361
|
let aiResult;
|
|
103346
103362
|
if (this.tracer) {
|
|
103347
|
-
const inputPreview = message
|
|
103363
|
+
const inputPreview = truncateForSpan(message, 4096);
|
|
103348
103364
|
aiResult = await this.tracer.withSpan("ai.request", executeAIRequest, {
|
|
103349
103365
|
"ai.model": this.model,
|
|
103350
103366
|
"ai.provider": this.clientApiProvider || "auto",
|
|
@@ -103354,6 +103370,12 @@ Double-check your response based on the criteria above. If everything looks good
|
|
|
103354
103370
|
"max_tokens": maxResponseTokens,
|
|
103355
103371
|
"temperature": 0.3,
|
|
103356
103372
|
"message_count": currentMessages.length
|
|
103373
|
+
}, (span, result) => {
|
|
103374
|
+
const text = result?.finalText || "";
|
|
103375
|
+
span.setAttributes({
|
|
103376
|
+
"ai.output": truncateForSpan(text),
|
|
103377
|
+
"ai.output_length": text.length
|
|
103378
|
+
});
|
|
103357
103379
|
});
|
|
103358
103380
|
} else {
|
|
103359
103381
|
aiResult = await executeAIRequest();
|