@probelabs/probe 0.6.0-rc262 → 0.6.0-rc264
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-rc264-aarch64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc264-aarch64-unknown-linux-musl.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc264-x86_64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc264-x86_64-pc-windows-msvc.zip +0 -0
- package/bin/binaries/probe-v0.6.0-rc264-x86_64-unknown-linux-musl.tar.gz +0 -0
- package/build/agent/bashExecutor.js +233 -7
- package/build/agent/index.js +228 -67
- package/build/agent/schemaUtils.js +29 -5
- package/cjs/agent/ProbeAgent.cjs +394 -80
- package/cjs/index.cjs +394 -80
- package/package.json +1 -1
- package/src/agent/bashExecutor.js +233 -7
- package/src/agent/schemaUtils.js +29 -5
- package/bin/binaries/probe-v0.6.0-rc262-aarch64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc262-aarch64-unknown-linux-musl.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc262-x86_64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc262-x86_64-pc-windows-msvc.zip +0 -0
- package/bin/binaries/probe-v0.6.0-rc262-x86_64-unknown-linux-musl.tar.gz +0 -0
package/build/agent/index.js
CHANGED
|
@@ -12935,6 +12935,122 @@ var init_bashPermissions = __esm({
|
|
|
12935
12935
|
import { spawn as spawn2 } from "child_process";
|
|
12936
12936
|
import { resolve as resolve3, join } from "path";
|
|
12937
12937
|
import { existsSync as existsSync2 } from "fs";
|
|
12938
|
+
function splitCommandComponents(command) {
|
|
12939
|
+
const parts = [];
|
|
12940
|
+
let current2 = "";
|
|
12941
|
+
let inQuote = false;
|
|
12942
|
+
let quoteChar = "";
|
|
12943
|
+
for (let i = 0; i < command.length; i++) {
|
|
12944
|
+
const c = command[i];
|
|
12945
|
+
const next = command[i + 1] || "";
|
|
12946
|
+
if (c === "\\" && !inQuote) {
|
|
12947
|
+
current2 += c + next;
|
|
12948
|
+
i++;
|
|
12949
|
+
continue;
|
|
12950
|
+
}
|
|
12951
|
+
if (inQuote && quoteChar === '"' && c === "\\" && next) {
|
|
12952
|
+
current2 += c + next;
|
|
12953
|
+
i++;
|
|
12954
|
+
continue;
|
|
12955
|
+
}
|
|
12956
|
+
if (!inQuote && (c === '"' || c === "'")) {
|
|
12957
|
+
inQuote = true;
|
|
12958
|
+
quoteChar = c;
|
|
12959
|
+
current2 += c;
|
|
12960
|
+
continue;
|
|
12961
|
+
}
|
|
12962
|
+
if (inQuote && c === quoteChar) {
|
|
12963
|
+
inQuote = false;
|
|
12964
|
+
current2 += c;
|
|
12965
|
+
continue;
|
|
12966
|
+
}
|
|
12967
|
+
if (!inQuote) {
|
|
12968
|
+
if (c === "&" && next === "&" || c === "|" && next === "|") {
|
|
12969
|
+
if (current2.trim()) parts.push(current2.trim());
|
|
12970
|
+
current2 = "";
|
|
12971
|
+
i++;
|
|
12972
|
+
continue;
|
|
12973
|
+
}
|
|
12974
|
+
if (c === "|" || c === ";") {
|
|
12975
|
+
if (current2.trim()) parts.push(current2.trim());
|
|
12976
|
+
current2 = "";
|
|
12977
|
+
continue;
|
|
12978
|
+
}
|
|
12979
|
+
}
|
|
12980
|
+
current2 += c;
|
|
12981
|
+
}
|
|
12982
|
+
if (current2.trim()) parts.push(current2.trim());
|
|
12983
|
+
return parts;
|
|
12984
|
+
}
|
|
12985
|
+
function checkSingleCommandInteractive(command) {
|
|
12986
|
+
let effective = command.trim();
|
|
12987
|
+
while (/^\w+=\S*\s/.test(effective)) {
|
|
12988
|
+
effective = effective.replace(/^\w+=\S*\s+/, "");
|
|
12989
|
+
}
|
|
12990
|
+
const parts = effective.split(/\s+/);
|
|
12991
|
+
const base2 = parts[0];
|
|
12992
|
+
const args = parts.slice(1);
|
|
12993
|
+
if (["vi", "vim", "nvim", "nano", "emacs", "pico", "joe", "mcedit"].includes(base2)) {
|
|
12994
|
+
return `'${base2}' is an interactive editor and cannot run without a terminal. Use non-interactive file manipulation commands instead.`;
|
|
12995
|
+
}
|
|
12996
|
+
if (["less", "more"].includes(base2)) {
|
|
12997
|
+
return `'${base2}' is an interactive pager. Use 'cat', 'head', or 'tail' instead.`;
|
|
12998
|
+
}
|
|
12999
|
+
if (base2 === "git") {
|
|
13000
|
+
const sub = args[0];
|
|
13001
|
+
if (sub === "commit") {
|
|
13002
|
+
const hasNonInteractiveFlag = args.some(
|
|
13003
|
+
(a) => a === "-m" || a.startsWith("--message") || a === "-C" || a === "-c" || a.startsWith("--fixup") || a.startsWith("--squash") || a === "--allow-empty-message" || a === "--no-edit"
|
|
13004
|
+
);
|
|
13005
|
+
if (!hasNonInteractiveFlag) {
|
|
13006
|
+
return `Interactive command: 'git commit' opens an editor for the commit message. Use 'git commit -m "your message"' instead.`;
|
|
13007
|
+
}
|
|
13008
|
+
}
|
|
13009
|
+
if (sub === "rebase" && (args.includes("--continue") || args.includes("--skip"))) {
|
|
13010
|
+
return "Interactive command: 'git rebase --continue' opens an editor. Set environment variable GIT_EDITOR=true to accept default messages, e.g. pass env: {GIT_EDITOR: 'true'} or prepend GIT_EDITOR=true to the command.";
|
|
13011
|
+
}
|
|
13012
|
+
if (sub === "rebase" && (args.includes("-i") || args.includes("--interactive"))) {
|
|
13013
|
+
return "Interactive command: 'git rebase -i' requires an interactive editor. Interactive rebase cannot run without a terminal.";
|
|
13014
|
+
}
|
|
13015
|
+
if (sub === "merge" && !args.includes("--no-edit") && !args.includes("--no-commit") && !args.includes("--ff-only")) {
|
|
13016
|
+
return "Interactive command: 'git merge' may open an editor for the merge commit message. Add '--no-edit' to accept the default message.";
|
|
13017
|
+
}
|
|
13018
|
+
if (sub === "cherry-pick" && !args.includes("--no-edit")) {
|
|
13019
|
+
return "Interactive command: 'git cherry-pick' may open an editor. Add '--no-edit' to accept the default message.";
|
|
13020
|
+
}
|
|
13021
|
+
if (sub === "revert" && !args.includes("--no-edit")) {
|
|
13022
|
+
return "Interactive command: 'git revert' opens an editor. Add '--no-edit' to accept the default message.";
|
|
13023
|
+
}
|
|
13024
|
+
if (sub === "tag" && args.includes("-a") && !args.some((a) => a === "-m" || a.startsWith("--message"))) {
|
|
13025
|
+
return `Interactive command: 'git tag -a' opens an editor for the tag message. Use 'git tag -a <name> -m "message"' instead.`;
|
|
13026
|
+
}
|
|
13027
|
+
if (sub === "add" && (args.includes("-i") || args.includes("--interactive") || args.includes("-p") || args.includes("--patch"))) {
|
|
13028
|
+
return "Interactive command: 'git add -i/-p' requires interactive input. Use 'git add <files>' to stage specific files instead.";
|
|
13029
|
+
}
|
|
13030
|
+
}
|
|
13031
|
+
if (["python", "python3", "node", "irb", "ghci", "lua", "R", "ruby"].includes(base2) && args.length === 0) {
|
|
13032
|
+
return `Interactive command: '${base2}' without arguments starts an interactive REPL. Provide a script file or use '-c'/'--eval' for inline code.`;
|
|
13033
|
+
}
|
|
13034
|
+
if (base2 === "mysql" && !args.some((a) => a === "-e" || a.startsWith("--execute"))) {
|
|
13035
|
+
return `Interactive command: 'mysql' without -e flag starts an interactive session. Use 'mysql -e "SQL QUERY"' instead.`;
|
|
13036
|
+
}
|
|
13037
|
+
if (base2 === "psql" && !args.some((a) => a === "-c" || a.startsWith("--command") || a === "-f" || a.startsWith("--file"))) {
|
|
13038
|
+
return `Interactive command: 'psql' without -c flag starts an interactive session. Use 'psql -c "SQL QUERY"' instead.`;
|
|
13039
|
+
}
|
|
13040
|
+
if (["top", "htop", "btop", "nmon"].includes(base2)) {
|
|
13041
|
+
return `Interactive command: '${base2}' is an interactive TUI tool. Use 'ps aux' or 'top -b -n 1' for non-interactive process listing.`;
|
|
13042
|
+
}
|
|
13043
|
+
return null;
|
|
13044
|
+
}
|
|
13045
|
+
function checkInteractiveCommand(command) {
|
|
13046
|
+
if (!command || typeof command !== "string") return null;
|
|
13047
|
+
const components = splitCommandComponents(command.trim());
|
|
13048
|
+
for (const component of components) {
|
|
13049
|
+
const result = checkSingleCommandInteractive(component);
|
|
13050
|
+
if (result) return result;
|
|
13051
|
+
}
|
|
13052
|
+
return null;
|
|
13053
|
+
}
|
|
12938
13054
|
async function executeBashCommand(command, options = {}) {
|
|
12939
13055
|
const {
|
|
12940
13056
|
workingDirectory = process.cwd(),
|
|
@@ -12964,6 +13080,24 @@ async function executeBashCommand(command, options = {}) {
|
|
|
12964
13080
|
};
|
|
12965
13081
|
}
|
|
12966
13082
|
const startTime = Date.now();
|
|
13083
|
+
const interactiveError = checkInteractiveCommand(command);
|
|
13084
|
+
if (interactiveError) {
|
|
13085
|
+
if (debug) {
|
|
13086
|
+
console.log(`[BashExecutor] Blocked interactive command: "${command}"`);
|
|
13087
|
+
console.log(`[BashExecutor] Reason: ${interactiveError}`);
|
|
13088
|
+
}
|
|
13089
|
+
return {
|
|
13090
|
+
success: false,
|
|
13091
|
+
error: interactiveError,
|
|
13092
|
+
stdout: "",
|
|
13093
|
+
stderr: interactiveError,
|
|
13094
|
+
exitCode: 1,
|
|
13095
|
+
command,
|
|
13096
|
+
workingDirectory: cwd,
|
|
13097
|
+
duration: 0,
|
|
13098
|
+
interactive: true
|
|
13099
|
+
};
|
|
13100
|
+
}
|
|
12967
13101
|
if (debug) {
|
|
12968
13102
|
console.log(`[BashExecutor] Executing command: "${command}"`);
|
|
12969
13103
|
console.log(`[BashExecutor] Working directory: "${cwd}"`);
|
|
@@ -12974,6 +13108,8 @@ async function executeBashCommand(command, options = {}) {
|
|
|
12974
13108
|
...process.env,
|
|
12975
13109
|
...env
|
|
12976
13110
|
};
|
|
13111
|
+
if (!processEnv.GIT_EDITOR) processEnv.GIT_EDITOR = "true";
|
|
13112
|
+
if (!processEnv.GIT_TERMINAL_PROMPT) processEnv.GIT_TERMINAL_PROMPT = "0";
|
|
12977
13113
|
const isComplex = isComplexCommand(command);
|
|
12978
13114
|
let cmd, cmdArgs, useShell;
|
|
12979
13115
|
if (isComplex) {
|
|
@@ -13008,20 +13144,32 @@ async function executeBashCommand(command, options = {}) {
|
|
|
13008
13144
|
// stdin ignored, capture stdout/stderr
|
|
13009
13145
|
shell: useShell,
|
|
13010
13146
|
// false for security
|
|
13147
|
+
detached: true,
|
|
13148
|
+
// new session — no controlling terminal
|
|
13011
13149
|
windowsHide: true
|
|
13012
13150
|
});
|
|
13013
13151
|
let stdout = "";
|
|
13014
13152
|
let stderr = "";
|
|
13015
13153
|
let killed = false;
|
|
13016
13154
|
let timeoutHandle;
|
|
13155
|
+
const killProcessGroup = (signal) => {
|
|
13156
|
+
try {
|
|
13157
|
+
if (child.pid) process.kill(-child.pid, signal);
|
|
13158
|
+
} catch {
|
|
13159
|
+
try {
|
|
13160
|
+
child.kill(signal);
|
|
13161
|
+
} catch {
|
|
13162
|
+
}
|
|
13163
|
+
}
|
|
13164
|
+
};
|
|
13017
13165
|
if (timeout > 0) {
|
|
13018
13166
|
timeoutHandle = setTimeout(() => {
|
|
13019
13167
|
if (!killed) {
|
|
13020
13168
|
killed = true;
|
|
13021
|
-
|
|
13169
|
+
killProcessGroup("SIGTERM");
|
|
13022
13170
|
setTimeout(() => {
|
|
13023
13171
|
if (child.exitCode === null) {
|
|
13024
|
-
|
|
13172
|
+
killProcessGroup("SIGKILL");
|
|
13025
13173
|
}
|
|
13026
13174
|
}, 5e3);
|
|
13027
13175
|
}
|
|
@@ -13034,7 +13182,7 @@ async function executeBashCommand(command, options = {}) {
|
|
|
13034
13182
|
} else {
|
|
13035
13183
|
if (!killed) {
|
|
13036
13184
|
killed = true;
|
|
13037
|
-
|
|
13185
|
+
killProcessGroup("SIGTERM");
|
|
13038
13186
|
}
|
|
13039
13187
|
}
|
|
13040
13188
|
});
|
|
@@ -13045,7 +13193,7 @@ async function executeBashCommand(command, options = {}) {
|
|
|
13045
13193
|
} else {
|
|
13046
13194
|
if (!killed) {
|
|
13047
13195
|
killed = true;
|
|
13048
|
-
|
|
13196
|
+
killProcessGroup("SIGTERM");
|
|
13049
13197
|
}
|
|
13050
13198
|
}
|
|
13051
13199
|
});
|
|
@@ -39381,7 +39529,6 @@ var init_reg_exp = __esm({
|
|
|
39381
39529
|
// node_modules/chevrotain/lib/src/scan/lexer.js
|
|
39382
39530
|
function analyzeTokenTypes(tokenTypes, options) {
|
|
39383
39531
|
options = defaults_default(options, {
|
|
39384
|
-
useSticky: SUPPORT_STICKY,
|
|
39385
39532
|
debug: false,
|
|
39386
39533
|
safeMode: false,
|
|
39387
39534
|
positionTracking: "full",
|
|
@@ -39430,7 +39577,7 @@ function analyzeTokenTypes(tokenTypes, options) {
|
|
|
39430
39577
|
], regExpSource[1])) {
|
|
39431
39578
|
return regExpSource[1];
|
|
39432
39579
|
} else {
|
|
39433
|
-
return
|
|
39580
|
+
return addStickyFlag(currPattern);
|
|
39434
39581
|
}
|
|
39435
39582
|
} else if (isFunction_default(currPattern)) {
|
|
39436
39583
|
hasCustom = true;
|
|
@@ -39444,7 +39591,7 @@ function analyzeTokenTypes(tokenTypes, options) {
|
|
|
39444
39591
|
} else {
|
|
39445
39592
|
const escapedRegExpString = currPattern.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&");
|
|
39446
39593
|
const wrappedRegExp = new RegExp(escapedRegExpString);
|
|
39447
|
-
return
|
|
39594
|
+
return addStickyFlag(wrappedRegExp);
|
|
39448
39595
|
}
|
|
39449
39596
|
} else {
|
|
39450
39597
|
throw Error("non exhaustive match");
|
|
@@ -39848,10 +39995,6 @@ function noMetaChar(regExp) {
|
|
|
39848
39995
|
function usesLookAheadOrBehind(regExp) {
|
|
39849
39996
|
return /(\(\?=)|(\(\?!)|(\(\?<=)|(\(\?<!)/.test(regExp.source);
|
|
39850
39997
|
}
|
|
39851
|
-
function addStartOfInput(pattern) {
|
|
39852
|
-
const flags = pattern.ignoreCase ? "i" : "";
|
|
39853
|
-
return new RegExp(`^(?:${pattern.source})`, flags);
|
|
39854
|
-
}
|
|
39855
39998
|
function addStickyFlag(pattern) {
|
|
39856
39999
|
const flags = pattern.ignoreCase ? "iy" : "y";
|
|
39857
40000
|
return new RegExp(`${pattern.source}`, flags);
|
|
@@ -40040,7 +40183,7 @@ function initCharCodeToOptimizedIndexMap() {
|
|
|
40040
40183
|
}
|
|
40041
40184
|
}
|
|
40042
40185
|
}
|
|
40043
|
-
var PATTERN, DEFAULT_MODE, MODES,
|
|
40186
|
+
var PATTERN, DEFAULT_MODE, MODES, end_of_input, start_of_input, LineTerminatorOptimizedTester, minOptimizationVal, charCodeToOptimizedIdxMap;
|
|
40044
40187
|
var init_lexer = __esm({
|
|
40045
40188
|
"node_modules/chevrotain/lib/src/scan/lexer.js"() {
|
|
40046
40189
|
init_api3();
|
|
@@ -40052,7 +40195,6 @@ var init_lexer = __esm({
|
|
|
40052
40195
|
PATTERN = "PATTERN";
|
|
40053
40196
|
DEFAULT_MODE = "defaultMode";
|
|
40054
40197
|
MODES = "modes";
|
|
40055
|
-
SUPPORT_STICKY = typeof new RegExp("(?:)").sticky === "boolean";
|
|
40056
40198
|
end_of_input = /[^\\][$]/;
|
|
40057
40199
|
start_of_input = /[^\\[][\^]|^\^/;
|
|
40058
40200
|
LineTerminatorOptimizedTester = {
|
|
@@ -40368,13 +40510,6 @@ var init_lexer_public = __esm({
|
|
|
40368
40510
|
PRINT_WARNING(warningDescriptor.message);
|
|
40369
40511
|
});
|
|
40370
40512
|
this.TRACE_INIT("Choosing sub-methods implementations", () => {
|
|
40371
|
-
if (SUPPORT_STICKY) {
|
|
40372
|
-
this.chopInput = identity_default;
|
|
40373
|
-
this.match = this.matchWithTest;
|
|
40374
|
-
} else {
|
|
40375
|
-
this.updateLastIndex = noop_default;
|
|
40376
|
-
this.match = this.matchWithExec;
|
|
40377
|
-
}
|
|
40378
40513
|
if (hasOnlySingleMode) {
|
|
40379
40514
|
this.handleModes = noop_default;
|
|
40380
40515
|
}
|
|
@@ -40437,7 +40572,7 @@ var init_lexer_public = __esm({
|
|
|
40437
40572
|
// this method also used quite a bit of `!` none null assertions because it is too optimized
|
|
40438
40573
|
// for `tsc` to always understand it is "safe"
|
|
40439
40574
|
tokenizeInternal(text, initialMode) {
|
|
40440
|
-
let i, j, k, matchAltImage, longerAlt, matchedImage, payload, altPayload, imageLength, group, tokType, newToken, errLength,
|
|
40575
|
+
let i, j, k, matchAltImage, longerAlt, matchedImage, payload, altPayload, imageLength, group, tokType, newToken, errLength, msg, match2;
|
|
40441
40576
|
const orgText = text;
|
|
40442
40577
|
const orgLength = orgText.length;
|
|
40443
40578
|
let offset2 = 0;
|
|
@@ -40456,19 +40591,7 @@ var init_lexer_public = __esm({
|
|
|
40456
40591
|
const modeStack = [];
|
|
40457
40592
|
const emptyArray = [];
|
|
40458
40593
|
Object.freeze(emptyArray);
|
|
40459
|
-
let
|
|
40460
|
-
function getPossiblePatternsSlow() {
|
|
40461
|
-
return patternIdxToConfig;
|
|
40462
|
-
}
|
|
40463
|
-
function getPossiblePatternsOptimized(charCode) {
|
|
40464
|
-
const optimizedCharIdx = charCodeToOptimizedIndex(charCode);
|
|
40465
|
-
const possiblePatterns = currCharCodeToPatternIdxToConfig[optimizedCharIdx];
|
|
40466
|
-
if (possiblePatterns === void 0) {
|
|
40467
|
-
return emptyArray;
|
|
40468
|
-
} else {
|
|
40469
|
-
return possiblePatterns;
|
|
40470
|
-
}
|
|
40471
|
-
}
|
|
40594
|
+
let isOptimizedMode = false;
|
|
40472
40595
|
const pop_mode = (popToken) => {
|
|
40473
40596
|
if (modeStack.length === 1 && // if we have both a POP_MODE and a PUSH_MODE this is in-fact a "transition"
|
|
40474
40597
|
// So no error should occur.
|
|
@@ -40489,9 +40612,9 @@ var init_lexer_public = __esm({
|
|
|
40489
40612
|
currModePatternsLength = patternIdxToConfig.length;
|
|
40490
40613
|
const modeCanBeOptimized = this.canModeBeOptimized[newMode] && this.config.safeMode === false;
|
|
40491
40614
|
if (currCharCodeToPatternIdxToConfig && modeCanBeOptimized) {
|
|
40492
|
-
|
|
40615
|
+
isOptimizedMode = true;
|
|
40493
40616
|
} else {
|
|
40494
|
-
|
|
40617
|
+
isOptimizedMode = false;
|
|
40495
40618
|
}
|
|
40496
40619
|
}
|
|
40497
40620
|
};
|
|
@@ -40503,9 +40626,9 @@ var init_lexer_public = __esm({
|
|
|
40503
40626
|
currModePatternsLength = patternIdxToConfig.length;
|
|
40504
40627
|
const modeCanBeOptimized = this.canModeBeOptimized[newMode] && this.config.safeMode === false;
|
|
40505
40628
|
if (currCharCodeToPatternIdxToConfig && modeCanBeOptimized) {
|
|
40506
|
-
|
|
40629
|
+
isOptimizedMode = true;
|
|
40507
40630
|
} else {
|
|
40508
|
-
|
|
40631
|
+
isOptimizedMode = false;
|
|
40509
40632
|
}
|
|
40510
40633
|
}
|
|
40511
40634
|
push_mode.call(this, initialMode);
|
|
@@ -40513,8 +40636,16 @@ var init_lexer_public = __esm({
|
|
|
40513
40636
|
const recoveryEnabled = this.config.recoveryEnabled;
|
|
40514
40637
|
while (offset2 < orgLength) {
|
|
40515
40638
|
matchedImage = null;
|
|
40639
|
+
imageLength = -1;
|
|
40516
40640
|
const nextCharCode = orgText.charCodeAt(offset2);
|
|
40517
|
-
|
|
40641
|
+
let chosenPatternIdxToConfig;
|
|
40642
|
+
if (isOptimizedMode) {
|
|
40643
|
+
const optimizedCharIdx = charCodeToOptimizedIndex(nextCharCode);
|
|
40644
|
+
const possiblePatterns = currCharCodeToPatternIdxToConfig[optimizedCharIdx];
|
|
40645
|
+
chosenPatternIdxToConfig = possiblePatterns !== void 0 ? possiblePatterns : emptyArray;
|
|
40646
|
+
} else {
|
|
40647
|
+
chosenPatternIdxToConfig = patternIdxToConfig;
|
|
40648
|
+
}
|
|
40518
40649
|
const chosenPatternsLength = chosenPatternIdxToConfig.length;
|
|
40519
40650
|
for (i = 0; i < chosenPatternsLength; i++) {
|
|
40520
40651
|
currConfig = chosenPatternIdxToConfig[i];
|
|
@@ -40523,12 +40654,14 @@ var init_lexer_public = __esm({
|
|
|
40523
40654
|
const singleCharCode = currConfig.short;
|
|
40524
40655
|
if (singleCharCode !== false) {
|
|
40525
40656
|
if (nextCharCode === singleCharCode) {
|
|
40657
|
+
imageLength = 1;
|
|
40526
40658
|
matchedImage = currPattern;
|
|
40527
40659
|
}
|
|
40528
40660
|
} else if (currConfig.isCustom === true) {
|
|
40529
40661
|
match2 = currPattern.exec(orgText, offset2, matchedTokens, groups);
|
|
40530
40662
|
if (match2 !== null) {
|
|
40531
40663
|
matchedImage = match2[0];
|
|
40664
|
+
imageLength = matchedImage.length;
|
|
40532
40665
|
if (match2.payload !== void 0) {
|
|
40533
40666
|
payload = match2.payload;
|
|
40534
40667
|
}
|
|
@@ -40536,12 +40669,13 @@ var init_lexer_public = __esm({
|
|
|
40536
40669
|
matchedImage = null;
|
|
40537
40670
|
}
|
|
40538
40671
|
} else {
|
|
40539
|
-
|
|
40540
|
-
|
|
40672
|
+
currPattern.lastIndex = offset2;
|
|
40673
|
+
imageLength = this.matchLength(currPattern, text, offset2);
|
|
40541
40674
|
}
|
|
40542
|
-
if (
|
|
40675
|
+
if (imageLength !== -1) {
|
|
40543
40676
|
longerAlt = currConfig.longerAlt;
|
|
40544
40677
|
if (longerAlt !== void 0) {
|
|
40678
|
+
matchedImage = text.substring(offset2, offset2 + imageLength);
|
|
40545
40679
|
const longerAltLength = longerAlt.length;
|
|
40546
40680
|
for (k = 0; k < longerAltLength; k++) {
|
|
40547
40681
|
const longerAltConfig = patternIdxToConfig[longerAlt[k]];
|
|
@@ -40558,11 +40692,12 @@ var init_lexer_public = __esm({
|
|
|
40558
40692
|
matchAltImage = null;
|
|
40559
40693
|
}
|
|
40560
40694
|
} else {
|
|
40561
|
-
|
|
40695
|
+
longerAltPattern.lastIndex = offset2;
|
|
40562
40696
|
matchAltImage = this.match(longerAltPattern, text, offset2);
|
|
40563
40697
|
}
|
|
40564
40698
|
if (matchAltImage && matchAltImage.length > matchedImage.length) {
|
|
40565
40699
|
matchedImage = matchAltImage;
|
|
40700
|
+
imageLength = matchAltImage.length;
|
|
40566
40701
|
payload = altPayload;
|
|
40567
40702
|
currConfig = longerAltConfig;
|
|
40568
40703
|
break;
|
|
@@ -40572,10 +40707,10 @@ var init_lexer_public = __esm({
|
|
|
40572
40707
|
break;
|
|
40573
40708
|
}
|
|
40574
40709
|
}
|
|
40575
|
-
if (
|
|
40576
|
-
imageLength = matchedImage.length;
|
|
40710
|
+
if (imageLength !== -1) {
|
|
40577
40711
|
group = currConfig.group;
|
|
40578
40712
|
if (group !== void 0) {
|
|
40713
|
+
matchedImage = matchedImage !== null ? matchedImage : text.substring(offset2, offset2 + imageLength);
|
|
40579
40714
|
tokType = currConfig.tokenTypeIdx;
|
|
40580
40715
|
newToken = this.createTokenInstance(matchedImage, offset2, tokType, currConfig.tokenType, line, column, imageLength);
|
|
40581
40716
|
this.handlePayload(newToken, payload);
|
|
@@ -40585,15 +40720,13 @@ var init_lexer_public = __esm({
|
|
|
40585
40720
|
groups[group].push(newToken);
|
|
40586
40721
|
}
|
|
40587
40722
|
}
|
|
40588
|
-
text = this.chopInput(text, imageLength);
|
|
40589
|
-
offset2 = offset2 + imageLength;
|
|
40590
|
-
column = this.computeNewColumn(column, imageLength);
|
|
40591
40723
|
if (trackLines === true && currConfig.canLineTerminator === true) {
|
|
40592
40724
|
let numOfLTsInMatch = 0;
|
|
40593
40725
|
let foundTerminator;
|
|
40594
40726
|
let lastLTEndOffset;
|
|
40595
40727
|
lineTerminatorPattern.lastIndex = 0;
|
|
40596
40728
|
do {
|
|
40729
|
+
matchedImage = matchedImage !== null ? matchedImage : text.substring(offset2, offset2 + imageLength);
|
|
40597
40730
|
foundTerminator = lineTerminatorPattern.test(matchedImage);
|
|
40598
40731
|
if (foundTerminator === true) {
|
|
40599
40732
|
lastLTEndOffset = lineTerminatorPattern.lastIndex - 1;
|
|
@@ -40604,8 +40737,13 @@ var init_lexer_public = __esm({
|
|
|
40604
40737
|
line = line + numOfLTsInMatch;
|
|
40605
40738
|
column = imageLength - lastLTEndOffset;
|
|
40606
40739
|
this.updateTokenEndLineColumnLocation(newToken, group, lastLTEndOffset, numOfLTsInMatch, line, column, imageLength);
|
|
40740
|
+
} else {
|
|
40741
|
+
column = this.computeNewColumn(column, imageLength);
|
|
40607
40742
|
}
|
|
40743
|
+
} else {
|
|
40744
|
+
column = this.computeNewColumn(column, imageLength);
|
|
40608
40745
|
}
|
|
40746
|
+
offset2 = offset2 + imageLength;
|
|
40609
40747
|
this.handleModes(currConfig, pop_mode, push_mode, newToken);
|
|
40610
40748
|
} else {
|
|
40611
40749
|
const errorStartOffset = offset2;
|
|
@@ -40613,7 +40751,6 @@ var init_lexer_public = __esm({
|
|
|
40613
40751
|
const errorColumn = column;
|
|
40614
40752
|
let foundResyncPoint = recoveryEnabled === false;
|
|
40615
40753
|
while (foundResyncPoint === false && offset2 < orgLength) {
|
|
40616
|
-
text = this.chopInput(text, 1);
|
|
40617
40754
|
offset2++;
|
|
40618
40755
|
for (j = 0; j < currModePatternsLength; j++) {
|
|
40619
40756
|
const currConfig2 = patternIdxToConfig[j];
|
|
@@ -40626,7 +40763,7 @@ var init_lexer_public = __esm({
|
|
|
40626
40763
|
} else if (currConfig2.isCustom === true) {
|
|
40627
40764
|
foundResyncPoint = currPattern.exec(orgText, offset2, matchedTokens, groups) !== null;
|
|
40628
40765
|
} else {
|
|
40629
|
-
|
|
40766
|
+
currPattern.lastIndex = offset2;
|
|
40630
40767
|
foundResyncPoint = currPattern.exec(text) !== null;
|
|
40631
40768
|
}
|
|
40632
40769
|
if (foundResyncPoint === true) {
|
|
@@ -40669,12 +40806,6 @@ var init_lexer_public = __esm({
|
|
|
40669
40806
|
push_mode.call(this, config.push);
|
|
40670
40807
|
}
|
|
40671
40808
|
}
|
|
40672
|
-
chopInput(text, length) {
|
|
40673
|
-
return text.substring(length);
|
|
40674
|
-
}
|
|
40675
|
-
updateLastIndex(regExp, newLastIndex) {
|
|
40676
|
-
regExp.lastIndex = newLastIndex;
|
|
40677
|
-
}
|
|
40678
40809
|
// TODO: decrease this under 600 characters? inspect stripping comments option in TSC compiler
|
|
40679
40810
|
updateTokenEndLineColumnLocation(newToken, group, lastLTIdx, numOfLTsInMatch, line, column, imageLength) {
|
|
40680
40811
|
let lastCharIsLT, fixForEndingInLT;
|
|
@@ -40737,16 +40868,19 @@ var init_lexer_public = __esm({
|
|
|
40737
40868
|
token.payload = payload;
|
|
40738
40869
|
}
|
|
40739
40870
|
}
|
|
40740
|
-
|
|
40871
|
+
match(pattern, text, offset2) {
|
|
40741
40872
|
const found = pattern.test(text);
|
|
40742
40873
|
if (found === true) {
|
|
40743
40874
|
return text.substring(offset2, pattern.lastIndex);
|
|
40744
40875
|
}
|
|
40745
40876
|
return null;
|
|
40746
40877
|
}
|
|
40747
|
-
|
|
40748
|
-
const
|
|
40749
|
-
|
|
40878
|
+
matchLength(pattern, text, offset2) {
|
|
40879
|
+
const found = pattern.test(text);
|
|
40880
|
+
if (found === true) {
|
|
40881
|
+
return pattern.lastIndex - offset2;
|
|
40882
|
+
}
|
|
40883
|
+
return -1;
|
|
40750
40884
|
}
|
|
40751
40885
|
};
|
|
40752
40886
|
Lexer.SKIPPED = "This marks a skipped Token pattern, this means each token identified by it will be consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.";
|
|
@@ -40938,12 +41072,20 @@ For Further details.`;
|
|
|
40938
41072
|
return errMsg;
|
|
40939
41073
|
},
|
|
40940
41074
|
buildAlternationAmbiguityError(options) {
|
|
40941
|
-
const pathMsg = map_default(options.prefixPath, (currtok) => tokenLabel2(currtok)).join(", ");
|
|
40942
41075
|
const occurrence = options.alternation.idx === 0 ? "" : options.alternation.idx;
|
|
41076
|
+
const isEmptyPath = options.prefixPath.length === 0;
|
|
40943
41077
|
let currMessage = `Ambiguous Alternatives Detected: <${options.ambiguityIndices.join(" ,")}> in <OR${occurrence}> inside <${options.topLevelRule.name}> Rule,
|
|
40944
|
-
<${pathMsg}> may appears as a prefix path in all these alternatives.
|
|
40945
41078
|
`;
|
|
40946
|
-
|
|
41079
|
+
if (isEmptyPath) {
|
|
41080
|
+
currMessage += `These alternatives are all empty (match no tokens), making them indistinguishable.
|
|
41081
|
+
Only the last alternative may be empty.
|
|
41082
|
+
`;
|
|
41083
|
+
} else {
|
|
41084
|
+
const pathMsg = map_default(options.prefixPath, (currtok) => tokenLabel2(currtok)).join(", ");
|
|
41085
|
+
currMessage += `<${pathMsg}> may appears as a prefix path in all these alternatives.
|
|
41086
|
+
`;
|
|
41087
|
+
}
|
|
41088
|
+
currMessage += `See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
|
|
40947
41089
|
For Further details.`;
|
|
40948
41090
|
return currMessage;
|
|
40949
41091
|
},
|
|
@@ -70182,12 +70324,31 @@ function cleanSchemaResponse(response) {
|
|
|
70182
70324
|
const closeChar = openChar === "{" ? "}" : "]";
|
|
70183
70325
|
let bracketCount = 1;
|
|
70184
70326
|
let endIndex = startIndex + 1;
|
|
70327
|
+
let inString = false;
|
|
70328
|
+
let escapeNext = false;
|
|
70185
70329
|
while (endIndex < trimmed.length && bracketCount > 0) {
|
|
70186
70330
|
const char = trimmed[endIndex];
|
|
70187
|
-
if (
|
|
70188
|
-
|
|
70189
|
-
|
|
70190
|
-
|
|
70331
|
+
if (escapeNext) {
|
|
70332
|
+
escapeNext = false;
|
|
70333
|
+
endIndex++;
|
|
70334
|
+
continue;
|
|
70335
|
+
}
|
|
70336
|
+
if (char === "\\" && inString) {
|
|
70337
|
+
escapeNext = true;
|
|
70338
|
+
endIndex++;
|
|
70339
|
+
continue;
|
|
70340
|
+
}
|
|
70341
|
+
if (char === '"') {
|
|
70342
|
+
inString = !inString;
|
|
70343
|
+
endIndex++;
|
|
70344
|
+
continue;
|
|
70345
|
+
}
|
|
70346
|
+
if (!inString) {
|
|
70347
|
+
if (char === openChar) {
|
|
70348
|
+
bracketCount++;
|
|
70349
|
+
} else if (char === closeChar) {
|
|
70350
|
+
bracketCount--;
|
|
70351
|
+
}
|
|
70191
70352
|
}
|
|
70192
70353
|
endIndex++;
|
|
70193
70354
|
}
|
|
@@ -387,18 +387,42 @@ export function cleanSchemaResponse(response) {
|
|
|
387
387
|
if (codeBlockMatch && !isCodeBlockEmbeddedInDocument(trimmed, codeBlockMatch)) {
|
|
388
388
|
const startIndex = codeBlockMatch.index + codeBlockMatch[0].length - 1; // Position of the bracket
|
|
389
389
|
|
|
390
|
-
// Find the matching closing bracket
|
|
390
|
+
// Find the matching closing bracket (string-aware to avoid miscounting
|
|
391
|
+
// brackets inside JSON string values)
|
|
391
392
|
const openChar = codeBlockMatch[1];
|
|
392
393
|
const closeChar = openChar === '{' ? '}' : ']';
|
|
393
394
|
let bracketCount = 1;
|
|
394
395
|
let endIndex = startIndex + 1;
|
|
396
|
+
let inString = false;
|
|
397
|
+
let escapeNext = false;
|
|
395
398
|
|
|
396
399
|
while (endIndex < trimmed.length && bracketCount > 0) {
|
|
397
400
|
const char = trimmed[endIndex];
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
401
|
+
|
|
402
|
+
if (escapeNext) {
|
|
403
|
+
escapeNext = false;
|
|
404
|
+
endIndex++;
|
|
405
|
+
continue;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
if (char === '\\' && inString) {
|
|
409
|
+
escapeNext = true;
|
|
410
|
+
endIndex++;
|
|
411
|
+
continue;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
if (char === '"') {
|
|
415
|
+
inString = !inString;
|
|
416
|
+
endIndex++;
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
if (!inString) {
|
|
421
|
+
if (char === openChar) {
|
|
422
|
+
bracketCount++;
|
|
423
|
+
} else if (char === closeChar) {
|
|
424
|
+
bracketCount--;
|
|
425
|
+
}
|
|
402
426
|
}
|
|
403
427
|
endIndex++;
|
|
404
428
|
}
|