@cybedefend/vibedefend 1.4.2 → 1.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/auth/auth-store.js +5 -6
- package/dist/auth/auth-store.js.map +1 -1
- package/dist/clients/claude-code.js +4 -1
- package/dist/clients/claude-code.js.map +1 -1
- package/dist/clients/codex.js +4 -2
- package/dist/clients/codex.js.map +1 -1
- package/dist/diagnostics.js +3 -1
- package/dist/diagnostics.js.map +1 -1
- package/dist/hook-runner.js +1669 -1340
- package/dist/hooks/runtime/emit.js +25 -12
- package/dist/hooks/runtime/emit.js.map +1 -1
- package/dist/hooks/runtime/fetch-rules.js +41 -13
- package/dist/hooks/runtime/fetch-rules.js.map +1 -1
- package/dist/hooks/runtime/hook-refresh-trigger.js +76 -0
- package/dist/hooks/runtime/hook-refresh-trigger.js.map +1 -0
- package/dist/hooks/runtime/resolve.js +89 -64
- package/dist/hooks/runtime/resolve.js.map +1 -1
- package/dist/hooks/runtime/session-start.js +17 -7
- package/dist/hooks/runtime/session-start.js.map +1 -1
- package/dist/hooks/runtime/shell-writes.js +311 -0
- package/dist/hooks/runtime/shell-writes.js.map +1 -0
- package/dist/hooks/runtime/sniff.js +84 -5
- package/dist/hooks/runtime/sniff.js.map +1 -1
- package/dist/hooks/runtime/user-prompt-submit.js +3 -1
- package/dist/hooks/runtime/user-prompt-submit.js.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/refresh-hooks.js +74 -0
- package/dist/refresh-hooks.js.map +1 -0
- package/dist/update.js +4 -0
- package/dist/update.js.map +1 -1
- package/package.json +2 -2
package/dist/hook-runner.js
CHANGED
|
@@ -39,475 +39,880 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
39
39
|
mod
|
|
40
40
|
));
|
|
41
41
|
|
|
42
|
-
// node_modules/.pnpm/
|
|
43
|
-
var
|
|
44
|
-
"node_modules/.pnpm/
|
|
45
|
-
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
42
|
+
// node_modules/.pnpm/shell-quote@1.10.0/node_modules/shell-quote/quote.js
|
|
43
|
+
var require_quote = __commonJS({
|
|
44
|
+
"node_modules/.pnpm/shell-quote@1.10.0/node_modules/shell-quote/quote.js"(exports, module) {
|
|
45
|
+
"use strict";
|
|
46
|
+
var OPS = (
|
|
47
|
+
/** @type {const} */
|
|
48
|
+
[
|
|
49
|
+
"||",
|
|
50
|
+
"&&",
|
|
51
|
+
";;",
|
|
52
|
+
"|&",
|
|
53
|
+
"<(",
|
|
54
|
+
"<<<",
|
|
55
|
+
">>",
|
|
56
|
+
">&",
|
|
57
|
+
"<&",
|
|
58
|
+
"&",
|
|
59
|
+
";",
|
|
60
|
+
"(",
|
|
61
|
+
")",
|
|
62
|
+
"|",
|
|
63
|
+
"<",
|
|
64
|
+
">"
|
|
65
|
+
]
|
|
66
|
+
);
|
|
67
|
+
var LINE_TERMINATORS = /[\n\r\u2028\u2029]/;
|
|
68
|
+
var GLOB_SHELL_SPECIAL = /[\s#!"$&'():;<=>@\\^`|]/g;
|
|
69
|
+
module.exports = function quote(xs) {
|
|
70
|
+
return xs.map(function(s) {
|
|
71
|
+
if (s === "") {
|
|
72
|
+
return (
|
|
73
|
+
/** @type {const} */
|
|
74
|
+
"''"
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
if (s && typeof s === "object") {
|
|
78
|
+
if ("op" in s && s.op === "glob") {
|
|
79
|
+
if (typeof s.pattern !== "string") {
|
|
80
|
+
throw new TypeError("glob token requires a string `pattern`");
|
|
81
|
+
}
|
|
82
|
+
if (LINE_TERMINATORS.test(s.pattern)) {
|
|
83
|
+
throw new TypeError("glob `pattern` must not contain line terminators");
|
|
84
|
+
}
|
|
85
|
+
return s.pattern.replace(GLOB_SHELL_SPECIAL, "\\$&");
|
|
86
|
+
}
|
|
87
|
+
if ("op" in s && typeof s.op === "string") {
|
|
88
|
+
if (OPS.indexOf(s.op) < 0) {
|
|
89
|
+
throw new TypeError("invalid `op` value: " + JSON.stringify(s.op));
|
|
90
|
+
}
|
|
91
|
+
return s.op.replace(/[\s\S]/g, "\\$&");
|
|
92
|
+
}
|
|
93
|
+
if ("comment" in s && typeof s.comment === "string") {
|
|
94
|
+
if (LINE_TERMINATORS.test(s.comment)) {
|
|
95
|
+
throw new TypeError("`comment` must not contain line terminators");
|
|
96
|
+
}
|
|
97
|
+
return "#" + s.comment;
|
|
98
|
+
}
|
|
99
|
+
throw new TypeError("unrecognized object token shape");
|
|
100
|
+
}
|
|
101
|
+
if (/["\s\\]/.test(s) && !/'/.test(s)) {
|
|
102
|
+
return "'" + s.replace(/(['])/g, "\\$1") + "'";
|
|
103
|
+
}
|
|
104
|
+
if (/["'\s]/.test(s)) {
|
|
105
|
+
return '"' + s.replace(/(["\\$`!])/g, "\\$1") + '"';
|
|
106
|
+
}
|
|
107
|
+
return String(s).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}~])/g, "$1\\$2");
|
|
108
|
+
}).join(" ");
|
|
57
109
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// node_modules/.pnpm/shell-quote@1.10.0/node_modules/shell-quote/parse.js
|
|
114
|
+
var require_parse = __commonJS({
|
|
115
|
+
"node_modules/.pnpm/shell-quote@1.10.0/node_modules/shell-quote/parse.js"(exports, module) {
|
|
116
|
+
"use strict";
|
|
117
|
+
var CONTROL = (
|
|
118
|
+
/** @type {const} */
|
|
119
|
+
"(?:" + /** @type {const} */
|
|
120
|
+
[
|
|
121
|
+
"\\|\\|",
|
|
122
|
+
"\\&\\&",
|
|
123
|
+
";;",
|
|
124
|
+
"\\|\\&",
|
|
125
|
+
"\\<\\(",
|
|
126
|
+
"\\<\\<\\<",
|
|
127
|
+
">>",
|
|
128
|
+
">\\&",
|
|
129
|
+
"<\\&",
|
|
130
|
+
"[&;()|<>]"
|
|
131
|
+
].join(
|
|
132
|
+
/** @type {const} */
|
|
133
|
+
"|"
|
|
134
|
+
) + /** @type {const} */
|
|
135
|
+
")"
|
|
136
|
+
);
|
|
137
|
+
var controlRE = new RegExp("^" + CONTROL + "$");
|
|
138
|
+
var META = (
|
|
139
|
+
/** @type {const} */
|
|
140
|
+
"|&;()<> \\t"
|
|
141
|
+
);
|
|
142
|
+
var SINGLE_QUOTE = (
|
|
143
|
+
/** @type {const} */
|
|
144
|
+
"'([^']*?)'"
|
|
145
|
+
);
|
|
146
|
+
var DOUBLE_QUOTE = (
|
|
147
|
+
/** @type {const} */
|
|
148
|
+
'"((\\\\"|[^"])*?)"'
|
|
149
|
+
);
|
|
150
|
+
var hash = /^#$/;
|
|
151
|
+
var SQ = (
|
|
152
|
+
/** @type {const} */
|
|
153
|
+
"'"
|
|
154
|
+
);
|
|
155
|
+
var DQ = (
|
|
156
|
+
/** @type {const} */
|
|
157
|
+
'"'
|
|
158
|
+
);
|
|
159
|
+
var DS = (
|
|
160
|
+
/** @type {const} */
|
|
161
|
+
"$"
|
|
162
|
+
);
|
|
163
|
+
var TOKEN = "";
|
|
164
|
+
var mult = (
|
|
165
|
+
/** @type {const} */
|
|
166
|
+
4294967296
|
|
167
|
+
);
|
|
168
|
+
for (i = 0; i < 4; i++) {
|
|
169
|
+
TOKEN += (mult * Math.random()).toString(16);
|
|
68
170
|
}
|
|
69
|
-
var
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
171
|
+
var i;
|
|
172
|
+
var startsWithToken = new RegExp("^" + TOKEN);
|
|
173
|
+
function matchAll(s, r) {
|
|
174
|
+
var origIndex = r.lastIndex;
|
|
175
|
+
var matches = [];
|
|
176
|
+
var matchObj;
|
|
177
|
+
while (matchObj = r.exec(s)) {
|
|
178
|
+
matches[matches.length] = matchObj;
|
|
179
|
+
if (r.lastIndex === matchObj.index) {
|
|
180
|
+
r.lastIndex += 1;
|
|
181
|
+
}
|
|
73
182
|
}
|
|
74
|
-
|
|
183
|
+
r.lastIndex = origIndex;
|
|
184
|
+
return matches;
|
|
75
185
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (ENVIRONMENT_IS_NODE) {
|
|
83
|
-
if (ENVIRONMENT_IS_WORKER) {
|
|
84
|
-
scriptDirectory = __require("path").dirname(scriptDirectory) + "/";
|
|
85
|
-
} else {
|
|
86
|
-
scriptDirectory = __dirname + "/";
|
|
87
|
-
}
|
|
88
|
-
read_ = function shell_read(filename, binary) {
|
|
89
|
-
if (!nodeFS) nodeFS = __require("fs");
|
|
90
|
-
if (!nodePath) nodePath = __require("path");
|
|
91
|
-
filename = nodePath["normalize"](filename);
|
|
92
|
-
return nodeFS["readFileSync"](filename, binary ? null : "utf8");
|
|
93
|
-
};
|
|
94
|
-
readBinary = function readBinary2(filename) {
|
|
95
|
-
var ret = read_(filename, true);
|
|
96
|
-
if (!ret.buffer) {
|
|
97
|
-
ret = new Uint8Array(ret);
|
|
98
|
-
}
|
|
99
|
-
assert(ret.buffer);
|
|
100
|
-
return ret;
|
|
101
|
-
};
|
|
102
|
-
if (process["argv"].length > 1) {
|
|
103
|
-
thisProgram = process["argv"][1].replace(/\\/g, "/");
|
|
186
|
+
function getVar(env, pre, key) {
|
|
187
|
+
var r = typeof env === "function" ? env(key) : env[key];
|
|
188
|
+
if (typeof r === "undefined" && key != "") {
|
|
189
|
+
r = "";
|
|
190
|
+
} else if (typeof r === "undefined") {
|
|
191
|
+
r = "$";
|
|
104
192
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
module["exports"] = Module;
|
|
193
|
+
if (typeof r === "object") {
|
|
194
|
+
return pre + TOKEN + JSON.stringify(r) + TOKEN;
|
|
108
195
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
};
|
|
115
|
-
} else if (ENVIRONMENT_IS_SHELL) {
|
|
116
|
-
if (typeof read != "undefined") {
|
|
117
|
-
read_ = function shell_read(f) {
|
|
118
|
-
return read(f);
|
|
119
|
-
};
|
|
196
|
+
return pre + r;
|
|
197
|
+
}
|
|
198
|
+
function parseInternal(string, env, opts) {
|
|
199
|
+
if (!opts) {
|
|
200
|
+
opts = {};
|
|
120
201
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (
|
|
131
|
-
|
|
132
|
-
} else if (typeof arguments != "undefined") {
|
|
133
|
-
arguments_ = arguments;
|
|
202
|
+
var BS = opts.escape || "\\";
|
|
203
|
+
var ifs = opts.splitUnquoted === true ? " \n" : typeof opts.splitUnquoted === "string" ? opts.splitUnquoted : "";
|
|
204
|
+
var BAREWORD = "(\\" + BS + `['"` + META + `]|[^\\s'"` + META + "])+";
|
|
205
|
+
var chunker = new RegExp([
|
|
206
|
+
"(" + CONTROL + ")",
|
|
207
|
+
// control chars
|
|
208
|
+
"(" + BAREWORD + "|" + DOUBLE_QUOTE + "|" + SINGLE_QUOTE + ")+"
|
|
209
|
+
].join("|"), "g");
|
|
210
|
+
var matches = matchAll(string, chunker);
|
|
211
|
+
if (matches.length === 0) {
|
|
212
|
+
return [];
|
|
134
213
|
}
|
|
135
|
-
if (
|
|
136
|
-
|
|
137
|
-
quit(status);
|
|
138
|
-
};
|
|
214
|
+
if (!env) {
|
|
215
|
+
env = {};
|
|
139
216
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
console.warn = console.error = /** @type{!function(this:Console, ...*): undefined} */
|
|
146
|
-
typeof printErr !== "undefined" ? printErr : print;
|
|
147
|
-
}
|
|
148
|
-
} else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
|
|
149
|
-
if (ENVIRONMENT_IS_WORKER) {
|
|
150
|
-
scriptDirectory = self.location.href;
|
|
151
|
-
} else if (typeof document !== "undefined" && document.currentScript) {
|
|
152
|
-
scriptDirectory = document.currentScript.src;
|
|
153
|
-
}
|
|
154
|
-
if (scriptDirectory.indexOf("blob:") !== 0) {
|
|
155
|
-
scriptDirectory = scriptDirectory.substr(0, scriptDirectory.lastIndexOf("/") + 1);
|
|
156
|
-
} else {
|
|
157
|
-
scriptDirectory = "";
|
|
158
|
-
}
|
|
159
|
-
{
|
|
160
|
-
read_ = function shell_read(url) {
|
|
161
|
-
var xhr = new XMLHttpRequest();
|
|
162
|
-
xhr.open("GET", url, false);
|
|
163
|
-
xhr.send(null);
|
|
164
|
-
return xhr.responseText;
|
|
165
|
-
};
|
|
166
|
-
if (ENVIRONMENT_IS_WORKER) {
|
|
167
|
-
readBinary = function readBinary2(url) {
|
|
168
|
-
var xhr = new XMLHttpRequest();
|
|
169
|
-
xhr.open("GET", url, false);
|
|
170
|
-
xhr.responseType = "arraybuffer";
|
|
171
|
-
xhr.send(null);
|
|
172
|
-
return new Uint8Array(
|
|
173
|
-
/** @type{!ArrayBuffer} */
|
|
174
|
-
xhr.response
|
|
175
|
-
);
|
|
176
|
-
};
|
|
217
|
+
var commented = false;
|
|
218
|
+
return matches.map(function(match) {
|
|
219
|
+
var s = match[0];
|
|
220
|
+
if (!s || commented) {
|
|
221
|
+
return void 0;
|
|
177
222
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
223
|
+
if (controlRE.test(s)) {
|
|
224
|
+
return (
|
|
225
|
+
/** @type {ControlOperator} */
|
|
226
|
+
{ op: s }
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
var quote = false;
|
|
230
|
+
var esc = false;
|
|
231
|
+
var out = "";
|
|
232
|
+
var words = [];
|
|
233
|
+
var sawQuote = false;
|
|
234
|
+
var pendingNw = null;
|
|
235
|
+
var isGlob = false;
|
|
236
|
+
var i2;
|
|
237
|
+
function parseEnvVar() {
|
|
238
|
+
i2 += 1;
|
|
239
|
+
var varend;
|
|
240
|
+
var varname;
|
|
241
|
+
var char = s.charAt(i2);
|
|
242
|
+
if (char === "{") {
|
|
243
|
+
i2 += 1;
|
|
244
|
+
if (s.charAt(i2) === "}") {
|
|
245
|
+
throw new Error("Bad substitution: " + s.slice(i2 - 2, i2 + 1));
|
|
186
246
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
moduleOverrides = null;
|
|
207
|
-
if (Module["arguments"]) arguments_ = Module["arguments"];
|
|
208
|
-
if (!Object.getOwnPropertyDescriptor(Module, "arguments")) Object.defineProperty(Module, "arguments", { configurable: true, get: function() {
|
|
209
|
-
abort("Module.arguments has been replaced with plain arguments_ (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)");
|
|
210
|
-
} });
|
|
211
|
-
if (Module["thisProgram"]) thisProgram = Module["thisProgram"];
|
|
212
|
-
if (!Object.getOwnPropertyDescriptor(Module, "thisProgram")) Object.defineProperty(Module, "thisProgram", { configurable: true, get: function() {
|
|
213
|
-
abort("Module.thisProgram has been replaced with plain thisProgram (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)");
|
|
214
|
-
} });
|
|
215
|
-
if (Module["quit"]) quit_ = Module["quit"];
|
|
216
|
-
if (!Object.getOwnPropertyDescriptor(Module, "quit")) Object.defineProperty(Module, "quit", { configurable: true, get: function() {
|
|
217
|
-
abort("Module.quit has been replaced with plain quit_ (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)");
|
|
218
|
-
} });
|
|
219
|
-
assert(typeof Module["memoryInitializerPrefixURL"] === "undefined", "Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead");
|
|
220
|
-
assert(typeof Module["pthreadMainPrefixURL"] === "undefined", "Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead");
|
|
221
|
-
assert(typeof Module["cdInitializerPrefixURL"] === "undefined", "Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead");
|
|
222
|
-
assert(typeof Module["filePackagePrefixURL"] === "undefined", "Module.filePackagePrefixURL option was removed, use Module.locateFile instead");
|
|
223
|
-
assert(typeof Module["read"] === "undefined", "Module.read option was removed (modify read_ in JS)");
|
|
224
|
-
assert(typeof Module["readAsync"] === "undefined", "Module.readAsync option was removed (modify readAsync in JS)");
|
|
225
|
-
assert(typeof Module["readBinary"] === "undefined", "Module.readBinary option was removed (modify readBinary in JS)");
|
|
226
|
-
assert(typeof Module["setWindowTitle"] === "undefined", "Module.setWindowTitle option was removed (modify setWindowTitle in JS)");
|
|
227
|
-
assert(typeof Module["TOTAL_MEMORY"] === "undefined", "Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY");
|
|
228
|
-
if (!Object.getOwnPropertyDescriptor(Module, "read")) Object.defineProperty(Module, "read", { configurable: true, get: function() {
|
|
229
|
-
abort("Module.read has been replaced with plain read_ (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)");
|
|
230
|
-
} });
|
|
231
|
-
if (!Object.getOwnPropertyDescriptor(Module, "readAsync")) Object.defineProperty(Module, "readAsync", { configurable: true, get: function() {
|
|
232
|
-
abort("Module.readAsync has been replaced with plain readAsync (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)");
|
|
233
|
-
} });
|
|
234
|
-
if (!Object.getOwnPropertyDescriptor(Module, "readBinary")) Object.defineProperty(Module, "readBinary", { configurable: true, get: function() {
|
|
235
|
-
abort("Module.readBinary has been replaced with plain readBinary (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)");
|
|
236
|
-
} });
|
|
237
|
-
if (!Object.getOwnPropertyDescriptor(Module, "setWindowTitle")) Object.defineProperty(Module, "setWindowTitle", { configurable: true, get: function() {
|
|
238
|
-
abort("Module.setWindowTitle has been replaced with plain setWindowTitle (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)");
|
|
239
|
-
} });
|
|
240
|
-
function warnOnce(text) {
|
|
241
|
-
if (!warnOnce.shown) warnOnce.shown = {};
|
|
242
|
-
if (!warnOnce.shown[text]) {
|
|
243
|
-
warnOnce.shown[text] = 1;
|
|
244
|
-
err(text);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
var tempRet0 = 0;
|
|
248
|
-
var setTempRet0 = function(value) {
|
|
249
|
-
tempRet0 = value;
|
|
250
|
-
};
|
|
251
|
-
var wasmBinary;
|
|
252
|
-
if (Module["wasmBinary"]) wasmBinary = Module["wasmBinary"];
|
|
253
|
-
if (!Object.getOwnPropertyDescriptor(Module, "wasmBinary")) Object.defineProperty(Module, "wasmBinary", { configurable: true, get: function() {
|
|
254
|
-
abort("Module.wasmBinary has been replaced with plain wasmBinary (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)");
|
|
255
|
-
} });
|
|
256
|
-
var noExitRuntime;
|
|
257
|
-
if (Module["noExitRuntime"]) noExitRuntime = Module["noExitRuntime"];
|
|
258
|
-
if (!Object.getOwnPropertyDescriptor(Module, "noExitRuntime")) Object.defineProperty(Module, "noExitRuntime", { configurable: true, get: function() {
|
|
259
|
-
abort("Module.noExitRuntime has been replaced with plain noExitRuntime (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)");
|
|
260
|
-
} });
|
|
261
|
-
if (typeof WebAssembly !== "object") {
|
|
262
|
-
abort("no native wasm support detected");
|
|
263
|
-
}
|
|
264
|
-
var wasmMemory;
|
|
265
|
-
var ABORT = false;
|
|
266
|
-
var EXITSTATUS = 0;
|
|
267
|
-
function assert(condition, text) {
|
|
268
|
-
if (!condition) {
|
|
269
|
-
abort("Assertion failed: " + text);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
var UTF8Decoder = typeof TextDecoder !== "undefined" ? new TextDecoder("utf8") : void 0;
|
|
273
|
-
function UTF8ArrayToString(heap, idx, maxBytesToRead) {
|
|
274
|
-
var endIdx = idx + maxBytesToRead;
|
|
275
|
-
var endPtr = idx;
|
|
276
|
-
while (heap[endPtr] && !(endPtr >= endIdx)) ++endPtr;
|
|
277
|
-
if (endPtr - idx > 16 && heap.subarray && UTF8Decoder) {
|
|
278
|
-
return UTF8Decoder.decode(heap.subarray(idx, endPtr));
|
|
279
|
-
} else {
|
|
280
|
-
var str3 = "";
|
|
281
|
-
while (idx < endPtr) {
|
|
282
|
-
var u0 = heap[idx++];
|
|
283
|
-
if (!(u0 & 128)) {
|
|
284
|
-
str3 += String.fromCharCode(u0);
|
|
285
|
-
continue;
|
|
286
|
-
}
|
|
287
|
-
var u1 = heap[idx++] & 63;
|
|
288
|
-
if ((u0 & 224) == 192) {
|
|
289
|
-
str3 += String.fromCharCode((u0 & 31) << 6 | u1);
|
|
290
|
-
continue;
|
|
291
|
-
}
|
|
292
|
-
var u2 = heap[idx++] & 63;
|
|
293
|
-
if ((u0 & 240) == 224) {
|
|
294
|
-
u0 = (u0 & 15) << 12 | u1 << 6 | u2;
|
|
247
|
+
var depth = 1;
|
|
248
|
+
varend = i2;
|
|
249
|
+
while (depth > 0 && varend < s.length) {
|
|
250
|
+
if (s.charAt(varend) === "{" && s.charAt(varend - 1) === "$") {
|
|
251
|
+
depth += 1;
|
|
252
|
+
} else if (s.charAt(varend) === "}") {
|
|
253
|
+
depth -= 1;
|
|
254
|
+
}
|
|
255
|
+
varend += 1;
|
|
256
|
+
}
|
|
257
|
+
if (depth !== 0) {
|
|
258
|
+
throw new Error("Bad substitution: " + s.slice(i2));
|
|
259
|
+
}
|
|
260
|
+
varend -= 1;
|
|
261
|
+
varname = s.slice(i2, varend);
|
|
262
|
+
i2 = varend;
|
|
263
|
+
} else if (/[*@#?$!_-]/.test(char)) {
|
|
264
|
+
varname = char;
|
|
265
|
+
i2 += 1;
|
|
295
266
|
} else {
|
|
296
|
-
|
|
297
|
-
|
|
267
|
+
var slicedFromI = s.slice(i2);
|
|
268
|
+
varend = slicedFromI.match(/[^\w\d_]/);
|
|
269
|
+
if (!varend) {
|
|
270
|
+
varname = slicedFromI;
|
|
271
|
+
i2 = s.length;
|
|
272
|
+
} else {
|
|
273
|
+
varname = slicedFromI.slice(0, varend.index);
|
|
274
|
+
i2 += /** @type {number} */
|
|
275
|
+
varend.index - 1;
|
|
276
|
+
}
|
|
298
277
|
}
|
|
299
|
-
|
|
300
|
-
|
|
278
|
+
return getVar(
|
|
279
|
+
/** @type {NonNullable<typeof env>} */
|
|
280
|
+
env,
|
|
281
|
+
"",
|
|
282
|
+
varname
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
function flushRun() {
|
|
286
|
+
if (pendingNw === null) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
if (pendingNw === 0) {
|
|
290
|
+
if (out !== "") {
|
|
291
|
+
words[words.length] = out;
|
|
292
|
+
out = "";
|
|
293
|
+
}
|
|
301
294
|
} else {
|
|
302
|
-
|
|
303
|
-
|
|
295
|
+
words[words.length] = out;
|
|
296
|
+
out = "";
|
|
297
|
+
for (var fe = 1; fe < pendingNw; fe += 1) {
|
|
298
|
+
words[words.length] = "";
|
|
299
|
+
}
|
|
304
300
|
}
|
|
301
|
+
pendingNw = null;
|
|
305
302
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
303
|
+
for (i2 = 0; i2 < s.length; i2++) {
|
|
304
|
+
var c = s.charAt(i2);
|
|
305
|
+
if (ifs && c !== DS) {
|
|
306
|
+
flushRun();
|
|
307
|
+
}
|
|
308
|
+
isGlob = isGlob || !quote && (c === "*" || c === "?");
|
|
309
|
+
if (esc) {
|
|
310
|
+
out += c;
|
|
311
|
+
esc = false;
|
|
312
|
+
} else if (quote) {
|
|
313
|
+
if (c === quote) {
|
|
314
|
+
quote = false;
|
|
315
|
+
} else if (quote == SQ) {
|
|
316
|
+
out += c;
|
|
317
|
+
} else {
|
|
318
|
+
if (c === BS) {
|
|
319
|
+
i2 += 1;
|
|
320
|
+
c = s.charAt(i2);
|
|
321
|
+
if (c === DQ || c === BS || c === DS) {
|
|
322
|
+
out += c;
|
|
323
|
+
} else {
|
|
324
|
+
out += BS + c;
|
|
325
|
+
}
|
|
326
|
+
} else if (c === DS) {
|
|
327
|
+
out += parseEnvVar();
|
|
328
|
+
} else {
|
|
329
|
+
out += c;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
} else if (c === DQ || c === SQ) {
|
|
333
|
+
quote = c;
|
|
334
|
+
sawQuote = true;
|
|
335
|
+
} else if (controlRE.test(c)) {
|
|
336
|
+
return (
|
|
337
|
+
/** @type {ControlOperator} */
|
|
338
|
+
{ op: s }
|
|
339
|
+
);
|
|
340
|
+
} else if (hash.test(c)) {
|
|
341
|
+
commented = true;
|
|
342
|
+
var commentObj = { comment: string.slice(match.index + i2 + 1) };
|
|
343
|
+
if (out.length) {
|
|
344
|
+
return (
|
|
345
|
+
/** @type {const} */
|
|
346
|
+
[out, commentObj]
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
return (
|
|
350
|
+
/** @type {const} */
|
|
351
|
+
[commentObj]
|
|
352
|
+
);
|
|
353
|
+
} else if (c === BS) {
|
|
354
|
+
esc = true;
|
|
355
|
+
} else if (c === DS) {
|
|
356
|
+
var value = parseEnvVar();
|
|
357
|
+
if (!ifs) {
|
|
358
|
+
out += value;
|
|
359
|
+
} else {
|
|
360
|
+
for (var vi = 0; vi < value.length; vi += 1) {
|
|
361
|
+
var vc = value.charAt(vi);
|
|
362
|
+
if (ifs.indexOf(vc) < 0) {
|
|
363
|
+
flushRun();
|
|
364
|
+
out += vc;
|
|
365
|
+
} else if (pendingNw === null) {
|
|
366
|
+
pendingNw = vc === " " || vc === " " || vc === "\n" ? 0 : 1;
|
|
367
|
+
} else if (vc !== " " && vc !== " " && vc !== "\n") {
|
|
368
|
+
pendingNw += 1;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
} else {
|
|
373
|
+
out += c;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (isGlob) {
|
|
377
|
+
return (
|
|
378
|
+
/** @type {GlobPattern} */
|
|
379
|
+
{ op: "glob", pattern: out }
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
if (ifs) {
|
|
383
|
+
if (pendingNw !== null && pendingNw > 0) {
|
|
384
|
+
words[words.length] = out;
|
|
385
|
+
out = "";
|
|
386
|
+
for (var te = 1; te < pendingNw; te += 1) {
|
|
387
|
+
words[words.length] = "";
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
if (out !== "" || sawQuote && words.length === 0) {
|
|
391
|
+
words[words.length] = out;
|
|
392
|
+
}
|
|
393
|
+
return words;
|
|
342
394
|
}
|
|
395
|
+
return out;
|
|
396
|
+
}).reduce(
|
|
397
|
+
function(prev, arg) {
|
|
398
|
+
if (typeof arg === "undefined") {
|
|
399
|
+
return prev;
|
|
400
|
+
}
|
|
401
|
+
[].concat(arg).forEach(function(entry) {
|
|
402
|
+
prev[prev.length] = entry;
|
|
403
|
+
});
|
|
404
|
+
return prev;
|
|
405
|
+
},
|
|
406
|
+
/** @type {ParseEntry[]} */
|
|
407
|
+
[]
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
module.exports = function parse(s, env, opts) {
|
|
411
|
+
var mapped = parseInternal(s, env, opts);
|
|
412
|
+
if (typeof env !== "function") {
|
|
413
|
+
return mapped;
|
|
414
|
+
}
|
|
415
|
+
return mapped.reduce(
|
|
416
|
+
function(acc, s2) {
|
|
417
|
+
if (typeof s2 === "object") {
|
|
418
|
+
acc[acc.length] = s2;
|
|
419
|
+
return acc;
|
|
420
|
+
}
|
|
421
|
+
var xs = s2.split(RegExp("(" + TOKEN + ".*?" + TOKEN + ")", "g"));
|
|
422
|
+
if (xs.length === 1) {
|
|
423
|
+
acc[acc.length] = xs[0];
|
|
424
|
+
return acc;
|
|
425
|
+
}
|
|
426
|
+
xs.filter(Boolean).forEach(function(x) {
|
|
427
|
+
acc[acc.length] = startsWithToken.test(x) ? JSON.parse(x.split(TOKEN)[1]) : x;
|
|
428
|
+
});
|
|
429
|
+
return acc;
|
|
430
|
+
},
|
|
431
|
+
/** @type {ParseEntry[]} */
|
|
432
|
+
[]
|
|
433
|
+
);
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
// node_modules/.pnpm/shell-quote@1.10.0/node_modules/shell-quote/index.js
|
|
439
|
+
var require_shell_quote = __commonJS({
|
|
440
|
+
"node_modules/.pnpm/shell-quote@1.10.0/node_modules/shell-quote/index.js"(exports) {
|
|
441
|
+
"use strict";
|
|
442
|
+
exports.quote = require_quote();
|
|
443
|
+
exports.parse = require_parse();
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
// node_modules/.pnpm/re2-wasm@1.0.2/node_modules/re2-wasm/build/wasm/re2.js
|
|
448
|
+
var require_re2 = __commonJS({
|
|
449
|
+
"node_modules/.pnpm/re2-wasm@1.0.2/node_modules/re2-wasm/build/wasm/re2.js"(exports, module) {
|
|
450
|
+
var Module = typeof Module !== "undefined" ? Module : {};
|
|
451
|
+
var moduleOverrides = {};
|
|
452
|
+
var key;
|
|
453
|
+
for (key in Module) {
|
|
454
|
+
if (Module.hasOwnProperty(key)) {
|
|
455
|
+
moduleOverrides[key] = Module[key];
|
|
343
456
|
}
|
|
344
|
-
heap[outIdx] = 0;
|
|
345
|
-
return outIdx - startIdx;
|
|
346
457
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
458
|
+
var arguments_ = [];
|
|
459
|
+
var thisProgram = "./this.program";
|
|
460
|
+
var quit_ = function(status, toThrow) {
|
|
461
|
+
throw toThrow;
|
|
462
|
+
};
|
|
463
|
+
var ENVIRONMENT_IS_WEB = false;
|
|
464
|
+
var ENVIRONMENT_IS_WORKER = false;
|
|
465
|
+
var ENVIRONMENT_IS_NODE = false;
|
|
466
|
+
var ENVIRONMENT_IS_SHELL = false;
|
|
467
|
+
ENVIRONMENT_IS_WEB = typeof window === "object";
|
|
468
|
+
ENVIRONMENT_IS_WORKER = typeof importScripts === "function";
|
|
469
|
+
ENVIRONMENT_IS_NODE = typeof process === "object" && typeof process.versions === "object" && typeof process.versions.node === "string";
|
|
470
|
+
ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
|
|
471
|
+
if (Module["ENVIRONMENT"]) {
|
|
472
|
+
throw new Error("Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -s ENVIRONMENT=web or -s ENVIRONMENT=node)");
|
|
350
473
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
if (u >= 55296 && u <= 57343) u = 65536 + ((u & 1023) << 10) | str3.charCodeAt(++i) & 1023;
|
|
356
|
-
if (u <= 127) ++len;
|
|
357
|
-
else if (u <= 2047) len += 2;
|
|
358
|
-
else if (u <= 65535) len += 3;
|
|
359
|
-
else len += 4;
|
|
474
|
+
var scriptDirectory = "";
|
|
475
|
+
function locateFile(path) {
|
|
476
|
+
if (Module["locateFile"]) {
|
|
477
|
+
return Module["locateFile"](path, scriptDirectory);
|
|
360
478
|
}
|
|
361
|
-
return
|
|
479
|
+
return scriptDirectory + path;
|
|
362
480
|
}
|
|
363
|
-
var
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr));
|
|
481
|
+
var read_;
|
|
482
|
+
var readAsync;
|
|
483
|
+
var readBinary;
|
|
484
|
+
var setWindowTitle;
|
|
485
|
+
var nodeFS;
|
|
486
|
+
var nodePath;
|
|
487
|
+
if (ENVIRONMENT_IS_NODE) {
|
|
488
|
+
if (ENVIRONMENT_IS_WORKER) {
|
|
489
|
+
scriptDirectory = __require("path").dirname(scriptDirectory) + "/";
|
|
373
490
|
} else {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
491
|
+
scriptDirectory = __dirname + "/";
|
|
492
|
+
}
|
|
493
|
+
read_ = function shell_read(filename, binary) {
|
|
494
|
+
if (!nodeFS) nodeFS = __require("fs");
|
|
495
|
+
if (!nodePath) nodePath = __require("path");
|
|
496
|
+
filename = nodePath["normalize"](filename);
|
|
497
|
+
return nodeFS["readFileSync"](filename, binary ? null : "utf8");
|
|
498
|
+
};
|
|
499
|
+
readBinary = function readBinary2(filename) {
|
|
500
|
+
var ret = read_(filename, true);
|
|
501
|
+
if (!ret.buffer) {
|
|
502
|
+
ret = new Uint8Array(ret);
|
|
379
503
|
}
|
|
380
|
-
|
|
504
|
+
assert(ret.buffer);
|
|
505
|
+
return ret;
|
|
506
|
+
};
|
|
507
|
+
if (process["argv"].length > 1) {
|
|
508
|
+
thisProgram = process["argv"][1].replace(/\\/g, "/");
|
|
381
509
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
assert(typeof maxBytesToWrite == "number", "stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!");
|
|
386
|
-
if (maxBytesToWrite === void 0) {
|
|
387
|
-
maxBytesToWrite = 2147483647;
|
|
510
|
+
arguments_ = process["argv"].slice(2);
|
|
511
|
+
if (typeof module !== "undefined") {
|
|
512
|
+
module["exports"] = Module;
|
|
388
513
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
514
|
+
quit_ = function(status) {
|
|
515
|
+
process["exit"](status);
|
|
516
|
+
};
|
|
517
|
+
Module["inspect"] = function() {
|
|
518
|
+
return "[Emscripten Module object]";
|
|
519
|
+
};
|
|
520
|
+
} else if (ENVIRONMENT_IS_SHELL) {
|
|
521
|
+
if (typeof read != "undefined") {
|
|
522
|
+
read_ = function shell_read(f) {
|
|
523
|
+
return read(f);
|
|
524
|
+
};
|
|
397
525
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
return str3.length * 2;
|
|
403
|
-
}
|
|
404
|
-
function UTF32ToString(ptr, maxBytesToRead) {
|
|
405
|
-
assert(ptr % 4 == 0, "Pointer passed to UTF32ToString must be aligned to four bytes!");
|
|
406
|
-
var i = 0;
|
|
407
|
-
var str3 = "";
|
|
408
|
-
while (!(i >= maxBytesToRead / 4)) {
|
|
409
|
-
var utf32 = HEAP32[ptr + i * 4 >> 2];
|
|
410
|
-
if (utf32 == 0) break;
|
|
411
|
-
++i;
|
|
412
|
-
if (utf32 >= 65536) {
|
|
413
|
-
var ch = utf32 - 65536;
|
|
414
|
-
str3 += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023);
|
|
415
|
-
} else {
|
|
416
|
-
str3 += String.fromCharCode(utf32);
|
|
526
|
+
readBinary = function readBinary2(f) {
|
|
527
|
+
var data;
|
|
528
|
+
if (typeof readbuffer === "function") {
|
|
529
|
+
return new Uint8Array(readbuffer(f));
|
|
417
530
|
}
|
|
531
|
+
data = read(f, "binary");
|
|
532
|
+
assert(typeof data === "object");
|
|
533
|
+
return data;
|
|
534
|
+
};
|
|
535
|
+
if (typeof scriptArgs != "undefined") {
|
|
536
|
+
arguments_ = scriptArgs;
|
|
537
|
+
} else if (typeof arguments != "undefined") {
|
|
538
|
+
arguments_ = arguments;
|
|
418
539
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
assert(typeof maxBytesToWrite == "number", "stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!");
|
|
424
|
-
if (maxBytesToWrite === void 0) {
|
|
425
|
-
maxBytesToWrite = 2147483647;
|
|
540
|
+
if (typeof quit === "function") {
|
|
541
|
+
quit_ = function(status) {
|
|
542
|
+
quit(status);
|
|
543
|
+
};
|
|
426
544
|
}
|
|
427
|
-
if (
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
545
|
+
if (typeof print !== "undefined") {
|
|
546
|
+
if (typeof console === "undefined") console = /** @type{!Console} */
|
|
547
|
+
{};
|
|
548
|
+
console.log = /** @type{!function(this:Console, ...*): undefined} */
|
|
549
|
+
print;
|
|
550
|
+
console.warn = console.error = /** @type{!function(this:Console, ...*): undefined} */
|
|
551
|
+
typeof printErr !== "undefined" ? printErr : print;
|
|
552
|
+
}
|
|
553
|
+
} else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
|
|
554
|
+
if (ENVIRONMENT_IS_WORKER) {
|
|
555
|
+
scriptDirectory = self.location.href;
|
|
556
|
+
} else if (typeof document !== "undefined" && document.currentScript) {
|
|
557
|
+
scriptDirectory = document.currentScript.src;
|
|
558
|
+
}
|
|
559
|
+
if (scriptDirectory.indexOf("blob:") !== 0) {
|
|
560
|
+
scriptDirectory = scriptDirectory.substr(0, scriptDirectory.lastIndexOf("/") + 1);
|
|
561
|
+
} else {
|
|
562
|
+
scriptDirectory = "";
|
|
563
|
+
}
|
|
564
|
+
{
|
|
565
|
+
read_ = function shell_read(url) {
|
|
566
|
+
var xhr = new XMLHttpRequest();
|
|
567
|
+
xhr.open("GET", url, false);
|
|
568
|
+
xhr.send(null);
|
|
569
|
+
return xhr.responseText;
|
|
570
|
+
};
|
|
571
|
+
if (ENVIRONMENT_IS_WORKER) {
|
|
572
|
+
readBinary = function readBinary2(url) {
|
|
573
|
+
var xhr = new XMLHttpRequest();
|
|
574
|
+
xhr.open("GET", url, false);
|
|
575
|
+
xhr.responseType = "arraybuffer";
|
|
576
|
+
xhr.send(null);
|
|
577
|
+
return new Uint8Array(
|
|
578
|
+
/** @type{!ArrayBuffer} */
|
|
579
|
+
xhr.response
|
|
580
|
+
);
|
|
581
|
+
};
|
|
435
582
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
583
|
+
readAsync = function readAsync2(url, onload, onerror) {
|
|
584
|
+
var xhr = new XMLHttpRequest();
|
|
585
|
+
xhr.open("GET", url, true);
|
|
586
|
+
xhr.responseType = "arraybuffer";
|
|
587
|
+
xhr.onload = function xhr_onload() {
|
|
588
|
+
if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
|
|
589
|
+
onload(xhr.response);
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
onerror();
|
|
593
|
+
};
|
|
594
|
+
xhr.onerror = onerror;
|
|
595
|
+
xhr.send(null);
|
|
596
|
+
};
|
|
439
597
|
}
|
|
440
|
-
|
|
441
|
-
|
|
598
|
+
setWindowTitle = function(title) {
|
|
599
|
+
document.title = title;
|
|
600
|
+
};
|
|
601
|
+
} else {
|
|
602
|
+
throw new Error("environment detection error");
|
|
442
603
|
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
len += 4;
|
|
604
|
+
var out = Module["print"] || console.log.bind(console);
|
|
605
|
+
var err = Module["printErr"] || console.warn.bind(console);
|
|
606
|
+
for (key in moduleOverrides) {
|
|
607
|
+
if (moduleOverrides.hasOwnProperty(key)) {
|
|
608
|
+
Module[key] = moduleOverrides[key];
|
|
449
609
|
}
|
|
450
|
-
return len;
|
|
451
|
-
}
|
|
452
|
-
function writeArrayToMemory(array, buffer2) {
|
|
453
|
-
assert(array.length >= 0, "writeArrayToMemory array must have a length (should be an array or typed array)");
|
|
454
|
-
HEAP8.set(array, buffer2);
|
|
455
610
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
611
|
+
moduleOverrides = null;
|
|
612
|
+
if (Module["arguments"]) arguments_ = Module["arguments"];
|
|
613
|
+
if (!Object.getOwnPropertyDescriptor(Module, "arguments")) Object.defineProperty(Module, "arguments", { configurable: true, get: function() {
|
|
614
|
+
abort("Module.arguments has been replaced with plain arguments_ (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)");
|
|
615
|
+
} });
|
|
616
|
+
if (Module["thisProgram"]) thisProgram = Module["thisProgram"];
|
|
617
|
+
if (!Object.getOwnPropertyDescriptor(Module, "thisProgram")) Object.defineProperty(Module, "thisProgram", { configurable: true, get: function() {
|
|
618
|
+
abort("Module.thisProgram has been replaced with plain thisProgram (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)");
|
|
619
|
+
} });
|
|
620
|
+
if (Module["quit"]) quit_ = Module["quit"];
|
|
621
|
+
if (!Object.getOwnPropertyDescriptor(Module, "quit")) Object.defineProperty(Module, "quit", { configurable: true, get: function() {
|
|
622
|
+
abort("Module.quit has been replaced with plain quit_ (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)");
|
|
623
|
+
} });
|
|
624
|
+
assert(typeof Module["memoryInitializerPrefixURL"] === "undefined", "Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead");
|
|
625
|
+
assert(typeof Module["pthreadMainPrefixURL"] === "undefined", "Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead");
|
|
626
|
+
assert(typeof Module["cdInitializerPrefixURL"] === "undefined", "Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead");
|
|
627
|
+
assert(typeof Module["filePackagePrefixURL"] === "undefined", "Module.filePackagePrefixURL option was removed, use Module.locateFile instead");
|
|
628
|
+
assert(typeof Module["read"] === "undefined", "Module.read option was removed (modify read_ in JS)");
|
|
629
|
+
assert(typeof Module["readAsync"] === "undefined", "Module.readAsync option was removed (modify readAsync in JS)");
|
|
630
|
+
assert(typeof Module["readBinary"] === "undefined", "Module.readBinary option was removed (modify readBinary in JS)");
|
|
631
|
+
assert(typeof Module["setWindowTitle"] === "undefined", "Module.setWindowTitle option was removed (modify setWindowTitle in JS)");
|
|
632
|
+
assert(typeof Module["TOTAL_MEMORY"] === "undefined", "Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY");
|
|
633
|
+
if (!Object.getOwnPropertyDescriptor(Module, "read")) Object.defineProperty(Module, "read", { configurable: true, get: function() {
|
|
634
|
+
abort("Module.read has been replaced with plain read_ (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)");
|
|
635
|
+
} });
|
|
636
|
+
if (!Object.getOwnPropertyDescriptor(Module, "readAsync")) Object.defineProperty(Module, "readAsync", { configurable: true, get: function() {
|
|
637
|
+
abort("Module.readAsync has been replaced with plain readAsync (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)");
|
|
638
|
+
} });
|
|
639
|
+
if (!Object.getOwnPropertyDescriptor(Module, "readBinary")) Object.defineProperty(Module, "readBinary", { configurable: true, get: function() {
|
|
640
|
+
abort("Module.readBinary has been replaced with plain readBinary (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)");
|
|
641
|
+
} });
|
|
642
|
+
if (!Object.getOwnPropertyDescriptor(Module, "setWindowTitle")) Object.defineProperty(Module, "setWindowTitle", { configurable: true, get: function() {
|
|
643
|
+
abort("Module.setWindowTitle has been replaced with plain setWindowTitle (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)");
|
|
644
|
+
} });
|
|
645
|
+
function warnOnce(text) {
|
|
646
|
+
if (!warnOnce.shown) warnOnce.shown = {};
|
|
647
|
+
if (!warnOnce.shown[text]) {
|
|
648
|
+
warnOnce.shown[text] = 1;
|
|
649
|
+
err(text);
|
|
460
650
|
}
|
|
461
|
-
if (!dontAddNull) HEAP8[buffer2 >> 0] = 0;
|
|
462
|
-
}
|
|
463
|
-
var buffer;
|
|
464
|
-
var HEAP8;
|
|
465
|
-
var HEAPU8;
|
|
466
|
-
var HEAP16;
|
|
467
|
-
var HEAPU16;
|
|
468
|
-
var HEAP32;
|
|
469
|
-
var HEAPU32;
|
|
470
|
-
var HEAPF32;
|
|
471
|
-
var HEAPF64;
|
|
472
|
-
function updateGlobalBufferAndViews(buf) {
|
|
473
|
-
buffer = buf;
|
|
474
|
-
Module["HEAP8"] = HEAP8 = new Int8Array(buf);
|
|
475
|
-
Module["HEAP16"] = HEAP16 = new Int16Array(buf);
|
|
476
|
-
Module["HEAP32"] = HEAP32 = new Int32Array(buf);
|
|
477
|
-
Module["HEAPU8"] = HEAPU8 = new Uint8Array(buf);
|
|
478
|
-
Module["HEAPU16"] = HEAPU16 = new Uint16Array(buf);
|
|
479
|
-
Module["HEAPU32"] = HEAPU32 = new Uint32Array(buf);
|
|
480
|
-
Module["HEAPF32"] = HEAPF32 = new Float32Array(buf);
|
|
481
|
-
Module["HEAPF64"] = HEAPF64 = new Float64Array(buf);
|
|
482
651
|
}
|
|
483
|
-
var
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
652
|
+
var tempRet0 = 0;
|
|
653
|
+
var setTempRet0 = function(value) {
|
|
654
|
+
tempRet0 = value;
|
|
655
|
+
};
|
|
656
|
+
var wasmBinary;
|
|
657
|
+
if (Module["wasmBinary"]) wasmBinary = Module["wasmBinary"];
|
|
658
|
+
if (!Object.getOwnPropertyDescriptor(Module, "wasmBinary")) Object.defineProperty(Module, "wasmBinary", { configurable: true, get: function() {
|
|
659
|
+
abort("Module.wasmBinary has been replaced with plain wasmBinary (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)");
|
|
488
660
|
} });
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
"
|
|
493
|
-
);
|
|
494
|
-
if (
|
|
495
|
-
|
|
496
|
-
} else {
|
|
497
|
-
wasmMemory = new WebAssembly.Memory({
|
|
498
|
-
"initial": INITIAL_MEMORY / 65536,
|
|
499
|
-
"maximum": INITIAL_MEMORY / 65536
|
|
500
|
-
});
|
|
661
|
+
var noExitRuntime;
|
|
662
|
+
if (Module["noExitRuntime"]) noExitRuntime = Module["noExitRuntime"];
|
|
663
|
+
if (!Object.getOwnPropertyDescriptor(Module, "noExitRuntime")) Object.defineProperty(Module, "noExitRuntime", { configurable: true, get: function() {
|
|
664
|
+
abort("Module.noExitRuntime has been replaced with plain noExitRuntime (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)");
|
|
665
|
+
} });
|
|
666
|
+
if (typeof WebAssembly !== "object") {
|
|
667
|
+
abort("no native wasm support detected");
|
|
501
668
|
}
|
|
502
|
-
|
|
503
|
-
|
|
669
|
+
var wasmMemory;
|
|
670
|
+
var ABORT = false;
|
|
671
|
+
var EXITSTATUS = 0;
|
|
672
|
+
function assert(condition, text) {
|
|
673
|
+
if (!condition) {
|
|
674
|
+
abort("Assertion failed: " + text);
|
|
675
|
+
}
|
|
504
676
|
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
677
|
+
var UTF8Decoder = typeof TextDecoder !== "undefined" ? new TextDecoder("utf8") : void 0;
|
|
678
|
+
function UTF8ArrayToString(heap, idx, maxBytesToRead) {
|
|
679
|
+
var endIdx = idx + maxBytesToRead;
|
|
680
|
+
var endPtr = idx;
|
|
681
|
+
while (heap[endPtr] && !(endPtr >= endIdx)) ++endPtr;
|
|
682
|
+
if (endPtr - idx > 16 && heap.subarray && UTF8Decoder) {
|
|
683
|
+
return UTF8Decoder.decode(heap.subarray(idx, endPtr));
|
|
684
|
+
} else {
|
|
685
|
+
var str3 = "";
|
|
686
|
+
while (idx < endPtr) {
|
|
687
|
+
var u0 = heap[idx++];
|
|
688
|
+
if (!(u0 & 128)) {
|
|
689
|
+
str3 += String.fromCharCode(u0);
|
|
690
|
+
continue;
|
|
691
|
+
}
|
|
692
|
+
var u1 = heap[idx++] & 63;
|
|
693
|
+
if ((u0 & 224) == 192) {
|
|
694
|
+
str3 += String.fromCharCode((u0 & 31) << 6 | u1);
|
|
695
|
+
continue;
|
|
696
|
+
}
|
|
697
|
+
var u2 = heap[idx++] & 63;
|
|
698
|
+
if ((u0 & 240) == 224) {
|
|
699
|
+
u0 = (u0 & 15) << 12 | u1 << 6 | u2;
|
|
700
|
+
} else {
|
|
701
|
+
if ((u0 & 248) != 240) warnOnce("Invalid UTF-8 leading byte 0x" + u0.toString(16) + " encountered when deserializing a UTF-8 string on the asm.js/wasm heap to a JS string!");
|
|
702
|
+
u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heap[idx++] & 63;
|
|
703
|
+
}
|
|
704
|
+
if (u0 < 65536) {
|
|
705
|
+
str3 += String.fromCharCode(u0);
|
|
706
|
+
} else {
|
|
707
|
+
var ch = u0 - 65536;
|
|
708
|
+
str3 += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
return str3;
|
|
713
|
+
}
|
|
714
|
+
function UTF8ToString(ptr, maxBytesToRead) {
|
|
715
|
+
return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : "";
|
|
716
|
+
}
|
|
717
|
+
function stringToUTF8Array(str3, heap, outIdx, maxBytesToWrite) {
|
|
718
|
+
if (!(maxBytesToWrite > 0))
|
|
719
|
+
return 0;
|
|
720
|
+
var startIdx = outIdx;
|
|
721
|
+
var endIdx = outIdx + maxBytesToWrite - 1;
|
|
722
|
+
for (var i = 0; i < str3.length; ++i) {
|
|
723
|
+
var u = str3.charCodeAt(i);
|
|
724
|
+
if (u >= 55296 && u <= 57343) {
|
|
725
|
+
var u1 = str3.charCodeAt(++i);
|
|
726
|
+
u = 65536 + ((u & 1023) << 10) | u1 & 1023;
|
|
727
|
+
}
|
|
728
|
+
if (u <= 127) {
|
|
729
|
+
if (outIdx >= endIdx) break;
|
|
730
|
+
heap[outIdx++] = u;
|
|
731
|
+
} else if (u <= 2047) {
|
|
732
|
+
if (outIdx + 1 >= endIdx) break;
|
|
733
|
+
heap[outIdx++] = 192 | u >> 6;
|
|
734
|
+
heap[outIdx++] = 128 | u & 63;
|
|
735
|
+
} else if (u <= 65535) {
|
|
736
|
+
if (outIdx + 2 >= endIdx) break;
|
|
737
|
+
heap[outIdx++] = 224 | u >> 12;
|
|
738
|
+
heap[outIdx++] = 128 | u >> 6 & 63;
|
|
739
|
+
heap[outIdx++] = 128 | u & 63;
|
|
740
|
+
} else {
|
|
741
|
+
if (outIdx + 3 >= endIdx) break;
|
|
742
|
+
if (u >= 2097152) warnOnce("Invalid Unicode code point 0x" + u.toString(16) + " encountered when serializing a JS string to an UTF-8 string on the asm.js/wasm heap! (Valid unicode code points should be in range 0-0x1FFFFF).");
|
|
743
|
+
heap[outIdx++] = 240 | u >> 18;
|
|
744
|
+
heap[outIdx++] = 128 | u >> 12 & 63;
|
|
745
|
+
heap[outIdx++] = 128 | u >> 6 & 63;
|
|
746
|
+
heap[outIdx++] = 128 | u & 63;
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
heap[outIdx] = 0;
|
|
750
|
+
return outIdx - startIdx;
|
|
751
|
+
}
|
|
752
|
+
function stringToUTF8(str3, outPtr, maxBytesToWrite) {
|
|
753
|
+
assert(typeof maxBytesToWrite == "number", "stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!");
|
|
754
|
+
return stringToUTF8Array(str3, HEAPU8, outPtr, maxBytesToWrite);
|
|
755
|
+
}
|
|
756
|
+
function lengthBytesUTF8(str3) {
|
|
757
|
+
var len = 0;
|
|
758
|
+
for (var i = 0; i < str3.length; ++i) {
|
|
759
|
+
var u = str3.charCodeAt(i);
|
|
760
|
+
if (u >= 55296 && u <= 57343) u = 65536 + ((u & 1023) << 10) | str3.charCodeAt(++i) & 1023;
|
|
761
|
+
if (u <= 127) ++len;
|
|
762
|
+
else if (u <= 2047) len += 2;
|
|
763
|
+
else if (u <= 65535) len += 3;
|
|
764
|
+
else len += 4;
|
|
765
|
+
}
|
|
766
|
+
return len;
|
|
767
|
+
}
|
|
768
|
+
var UTF16Decoder = typeof TextDecoder !== "undefined" ? new TextDecoder("utf-16le") : void 0;
|
|
769
|
+
function UTF16ToString(ptr, maxBytesToRead) {
|
|
770
|
+
assert(ptr % 2 == 0, "Pointer passed to UTF16ToString must be aligned to two bytes!");
|
|
771
|
+
var endPtr = ptr;
|
|
772
|
+
var idx = endPtr >> 1;
|
|
773
|
+
var maxIdx = idx + maxBytesToRead / 2;
|
|
774
|
+
while (!(idx >= maxIdx) && HEAPU16[idx]) ++idx;
|
|
775
|
+
endPtr = idx << 1;
|
|
776
|
+
if (endPtr - ptr > 32 && UTF16Decoder) {
|
|
777
|
+
return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr));
|
|
778
|
+
} else {
|
|
779
|
+
var str3 = "";
|
|
780
|
+
for (var i = 0; !(i >= maxBytesToRead / 2); ++i) {
|
|
781
|
+
var codeUnit = HEAP16[ptr + i * 2 >> 1];
|
|
782
|
+
if (codeUnit == 0) break;
|
|
783
|
+
str3 += String.fromCharCode(codeUnit);
|
|
784
|
+
}
|
|
785
|
+
return str3;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
function stringToUTF16(str3, outPtr, maxBytesToWrite) {
|
|
789
|
+
assert(outPtr % 2 == 0, "Pointer passed to stringToUTF16 must be aligned to two bytes!");
|
|
790
|
+
assert(typeof maxBytesToWrite == "number", "stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!");
|
|
791
|
+
if (maxBytesToWrite === void 0) {
|
|
792
|
+
maxBytesToWrite = 2147483647;
|
|
793
|
+
}
|
|
794
|
+
if (maxBytesToWrite < 2) return 0;
|
|
795
|
+
maxBytesToWrite -= 2;
|
|
796
|
+
var startPtr = outPtr;
|
|
797
|
+
var numCharsToWrite = maxBytesToWrite < str3.length * 2 ? maxBytesToWrite / 2 : str3.length;
|
|
798
|
+
for (var i = 0; i < numCharsToWrite; ++i) {
|
|
799
|
+
var codeUnit = str3.charCodeAt(i);
|
|
800
|
+
HEAP16[outPtr >> 1] = codeUnit;
|
|
801
|
+
outPtr += 2;
|
|
802
|
+
}
|
|
803
|
+
HEAP16[outPtr >> 1] = 0;
|
|
804
|
+
return outPtr - startPtr;
|
|
805
|
+
}
|
|
806
|
+
function lengthBytesUTF16(str3) {
|
|
807
|
+
return str3.length * 2;
|
|
808
|
+
}
|
|
809
|
+
function UTF32ToString(ptr, maxBytesToRead) {
|
|
810
|
+
assert(ptr % 4 == 0, "Pointer passed to UTF32ToString must be aligned to four bytes!");
|
|
811
|
+
var i = 0;
|
|
812
|
+
var str3 = "";
|
|
813
|
+
while (!(i >= maxBytesToRead / 4)) {
|
|
814
|
+
var utf32 = HEAP32[ptr + i * 4 >> 2];
|
|
815
|
+
if (utf32 == 0) break;
|
|
816
|
+
++i;
|
|
817
|
+
if (utf32 >= 65536) {
|
|
818
|
+
var ch = utf32 - 65536;
|
|
819
|
+
str3 += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023);
|
|
820
|
+
} else {
|
|
821
|
+
str3 += String.fromCharCode(utf32);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
return str3;
|
|
825
|
+
}
|
|
826
|
+
function stringToUTF32(str3, outPtr, maxBytesToWrite) {
|
|
827
|
+
assert(outPtr % 4 == 0, "Pointer passed to stringToUTF32 must be aligned to four bytes!");
|
|
828
|
+
assert(typeof maxBytesToWrite == "number", "stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!");
|
|
829
|
+
if (maxBytesToWrite === void 0) {
|
|
830
|
+
maxBytesToWrite = 2147483647;
|
|
831
|
+
}
|
|
832
|
+
if (maxBytesToWrite < 4) return 0;
|
|
833
|
+
var startPtr = outPtr;
|
|
834
|
+
var endPtr = startPtr + maxBytesToWrite - 4;
|
|
835
|
+
for (var i = 0; i < str3.length; ++i) {
|
|
836
|
+
var codeUnit = str3.charCodeAt(i);
|
|
837
|
+
if (codeUnit >= 55296 && codeUnit <= 57343) {
|
|
838
|
+
var trailSurrogate = str3.charCodeAt(++i);
|
|
839
|
+
codeUnit = 65536 + ((codeUnit & 1023) << 10) | trailSurrogate & 1023;
|
|
840
|
+
}
|
|
841
|
+
HEAP32[outPtr >> 2] = codeUnit;
|
|
842
|
+
outPtr += 4;
|
|
843
|
+
if (outPtr + 4 > endPtr) break;
|
|
844
|
+
}
|
|
845
|
+
HEAP32[outPtr >> 2] = 0;
|
|
846
|
+
return outPtr - startPtr;
|
|
847
|
+
}
|
|
848
|
+
function lengthBytesUTF32(str3) {
|
|
849
|
+
var len = 0;
|
|
850
|
+
for (var i = 0; i < str3.length; ++i) {
|
|
851
|
+
var codeUnit = str3.charCodeAt(i);
|
|
852
|
+
if (codeUnit >= 55296 && codeUnit <= 57343) ++i;
|
|
853
|
+
len += 4;
|
|
854
|
+
}
|
|
855
|
+
return len;
|
|
856
|
+
}
|
|
857
|
+
function writeArrayToMemory(array, buffer2) {
|
|
858
|
+
assert(array.length >= 0, "writeArrayToMemory array must have a length (should be an array or typed array)");
|
|
859
|
+
HEAP8.set(array, buffer2);
|
|
860
|
+
}
|
|
861
|
+
function writeAsciiToMemory(str3, buffer2, dontAddNull) {
|
|
862
|
+
for (var i = 0; i < str3.length; ++i) {
|
|
863
|
+
assert(str3.charCodeAt(i) === str3.charCodeAt(i) & 255);
|
|
864
|
+
HEAP8[buffer2++ >> 0] = str3.charCodeAt(i);
|
|
865
|
+
}
|
|
866
|
+
if (!dontAddNull) HEAP8[buffer2 >> 0] = 0;
|
|
867
|
+
}
|
|
868
|
+
var buffer;
|
|
869
|
+
var HEAP8;
|
|
870
|
+
var HEAPU8;
|
|
871
|
+
var HEAP16;
|
|
872
|
+
var HEAPU16;
|
|
873
|
+
var HEAP32;
|
|
874
|
+
var HEAPU32;
|
|
875
|
+
var HEAPF32;
|
|
876
|
+
var HEAPF64;
|
|
877
|
+
function updateGlobalBufferAndViews(buf) {
|
|
878
|
+
buffer = buf;
|
|
879
|
+
Module["HEAP8"] = HEAP8 = new Int8Array(buf);
|
|
880
|
+
Module["HEAP16"] = HEAP16 = new Int16Array(buf);
|
|
881
|
+
Module["HEAP32"] = HEAP32 = new Int32Array(buf);
|
|
882
|
+
Module["HEAPU8"] = HEAPU8 = new Uint8Array(buf);
|
|
883
|
+
Module["HEAPU16"] = HEAPU16 = new Uint16Array(buf);
|
|
884
|
+
Module["HEAPU32"] = HEAPU32 = new Uint32Array(buf);
|
|
885
|
+
Module["HEAPF32"] = HEAPF32 = new Float32Array(buf);
|
|
886
|
+
Module["HEAPF64"] = HEAPF64 = new Float64Array(buf);
|
|
887
|
+
}
|
|
888
|
+
var TOTAL_STACK = 5242880;
|
|
889
|
+
if (Module["TOTAL_STACK"]) assert(TOTAL_STACK === Module["TOTAL_STACK"], "the stack size can no longer be determined at runtime");
|
|
890
|
+
var INITIAL_MEMORY = Module["INITIAL_MEMORY"] || 16777216;
|
|
891
|
+
if (!Object.getOwnPropertyDescriptor(Module, "INITIAL_MEMORY")) Object.defineProperty(Module, "INITIAL_MEMORY", { configurable: true, get: function() {
|
|
892
|
+
abort("Module.INITIAL_MEMORY has been replaced with plain INITIAL_MEMORY (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)");
|
|
893
|
+
} });
|
|
894
|
+
assert(INITIAL_MEMORY >= TOTAL_STACK, "INITIAL_MEMORY should be larger than TOTAL_STACK, was " + INITIAL_MEMORY + "! (TOTAL_STACK=" + TOTAL_STACK + ")");
|
|
895
|
+
assert(
|
|
896
|
+
typeof Int32Array !== "undefined" && typeof Float64Array !== "undefined" && Int32Array.prototype.subarray !== void 0 && Int32Array.prototype.set !== void 0,
|
|
897
|
+
"JS engine does not provide full typed array support"
|
|
898
|
+
);
|
|
899
|
+
if (Module["wasmMemory"]) {
|
|
900
|
+
wasmMemory = Module["wasmMemory"];
|
|
901
|
+
} else {
|
|
902
|
+
wasmMemory = new WebAssembly.Memory({
|
|
903
|
+
"initial": INITIAL_MEMORY / 65536,
|
|
904
|
+
"maximum": INITIAL_MEMORY / 65536
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
if (wasmMemory) {
|
|
908
|
+
buffer = wasmMemory.buffer;
|
|
909
|
+
}
|
|
910
|
+
INITIAL_MEMORY = buffer.byteLength;
|
|
911
|
+
assert(INITIAL_MEMORY % 65536 === 0);
|
|
912
|
+
updateGlobalBufferAndViews(buffer);
|
|
913
|
+
var wasmTable;
|
|
914
|
+
function writeStackCookie() {
|
|
915
|
+
var max = _emscripten_stack_get_end();
|
|
511
916
|
assert((max & 3) == 0);
|
|
512
917
|
HEAPU32[(max >> 2) + 1] = 34821223;
|
|
513
918
|
HEAPU32[(max >> 2) + 2] = 2310721022;
|
|
@@ -3738,828 +4143,651 @@ var require_re22 = __commonJS({
|
|
|
3738
4143
|
i += 2;
|
|
3739
4144
|
break;
|
|
3740
4145
|
case "c":
|
|
3741
|
-
if (i + 2 < pattern.length) {
|
|
3742
|
-
const alphaIndex = ALPHA_UPPER.indexOf(pattern[i + 2]) + 1;
|
|
3743
|
-
if (alphaIndex >= 0) {
|
|
3744
|
-
result.push("\\x", HEX[Math.floor(alphaIndex / 16)], HEX[alphaIndex % 16]);
|
|
3745
|
-
i += 3;
|
|
3746
|
-
break;
|
|
3747
|
-
}
|
|
3748
|
-
}
|
|
3749
|
-
result.push("\\c");
|
|
3750
|
-
i += 2;
|
|
3751
|
-
break;
|
|
3752
|
-
case "u":
|
|
3753
|
-
if (i + 2 < pattern.length) {
|
|
3754
|
-
const ch2 = pattern[i + 2];
|
|
3755
|
-
if (isHexadecimal(ch2)) {
|
|
3756
|
-
result.push("\\x{");
|
|
3757
|
-
result.push(ch2);
|
|
3758
|
-
i += 3;
|
|
3759
|
-
for (let j = 0; j < 3 && i < pattern.length && isHexadecimal(pattern[i]); i++, j++) {
|
|
3760
|
-
result.push(pattern[i]);
|
|
3761
|
-
}
|
|
3762
|
-
result.push("}");
|
|
3763
|
-
break;
|
|
3764
|
-
} else if (ch2 === "{") {
|
|
3765
|
-
result.push("\\x");
|
|
3766
|
-
i += 2;
|
|
3767
|
-
break;
|
|
3768
|
-
}
|
|
3769
|
-
}
|
|
3770
|
-
result.push("\\u");
|
|
3771
|
-
i += 2;
|
|
3772
|
-
break;
|
|
3773
|
-
default:
|
|
3774
|
-
result.push("\\", pattern[i + 1]);
|
|
3775
|
-
i += 2;
|
|
3776
|
-
}
|
|
3777
|
-
continue;
|
|
3778
|
-
}
|
|
3779
|
-
} else if (pattern[i] === "/") {
|
|
3780
|
-
result.push("\\/");
|
|
3781
|
-
i += 1;
|
|
3782
|
-
continue;
|
|
3783
|
-
} else if (pattern.substring(i, i + 3) === "(?<") {
|
|
3784
|
-
if (pattern[i + 3] !== "=" && pattern[i + 3] !== "!") {
|
|
3785
|
-
result.push("(?P<");
|
|
3786
|
-
i += 3;
|
|
3787
|
-
continue;
|
|
3788
|
-
}
|
|
3789
|
-
}
|
|
3790
|
-
result.push(pattern[i]);
|
|
3791
|
-
i += 1;
|
|
3792
|
-
}
|
|
3793
|
-
return result.join("");
|
|
3794
|
-
}
|
|
3795
|
-
function escapeRegExp(pattern) {
|
|
3796
|
-
return pattern.replace(/(^|[^\\])((?:\\\\)*)\//g, "$1$2\\/");
|
|
3797
|
-
}
|
|
3798
|
-
var RE2 = class _RE2 {
|
|
3799
|
-
constructor(pattern, flags) {
|
|
3800
|
-
this._global = false;
|
|
3801
|
-
this._ignoreCase = false;
|
|
3802
|
-
this._multiline = false;
|
|
3803
|
-
this._dotAll = false;
|
|
3804
|
-
this._unicode = false;
|
|
3805
|
-
this._sticky = false;
|
|
3806
|
-
this.lastIndex = 0;
|
|
3807
|
-
this.pattern = "(?:)";
|
|
3808
|
-
this.groupNames = {};
|
|
3809
|
-
this.namedGroups = {};
|
|
3810
|
-
if (typeof pattern !== "string") {
|
|
3811
|
-
if (pattern instanceof RegExp || pattern instanceof _RE2) {
|
|
3812
|
-
flags = flags !== null && flags !== void 0 ? flags : pattern.flags;
|
|
3813
|
-
pattern = pattern.source;
|
|
3814
|
-
} else {
|
|
3815
|
-
if (pattern === void 0) {
|
|
3816
|
-
pattern = "(?:)";
|
|
3817
|
-
} else {
|
|
3818
|
-
pattern = pattern + "";
|
|
3819
|
-
}
|
|
3820
|
-
}
|
|
3821
|
-
}
|
|
3822
|
-
if (pattern === "") {
|
|
3823
|
-
pattern = "(?:)";
|
|
3824
|
-
}
|
|
3825
|
-
pattern = escapeRegExp(pattern);
|
|
3826
|
-
flags = flags !== null && flags !== void 0 ? flags : "";
|
|
3827
|
-
for (const flag of flags) {
|
|
3828
|
-
switch (flag) {
|
|
3829
|
-
case "g":
|
|
3830
|
-
this._global = true;
|
|
3831
|
-
break;
|
|
3832
|
-
case "i":
|
|
3833
|
-
this._ignoreCase = true;
|
|
3834
|
-
break;
|
|
3835
|
-
case "m":
|
|
3836
|
-
this._multiline = true;
|
|
3837
|
-
break;
|
|
3838
|
-
case "s":
|
|
3839
|
-
this._dotAll = true;
|
|
3840
|
-
break;
|
|
3841
|
-
case "u":
|
|
3842
|
-
this._unicode = true;
|
|
3843
|
-
break;
|
|
3844
|
-
case "y":
|
|
3845
|
-
this._sticky = true;
|
|
3846
|
-
break;
|
|
3847
|
-
}
|
|
3848
|
-
}
|
|
3849
|
-
if (!this._unicode) {
|
|
3850
|
-
throw new Error('RE2 only works in unicode mode. The "u" flag must be passed when constructing a RE2 instance');
|
|
3851
|
-
}
|
|
3852
|
-
this.pattern = pattern;
|
|
3853
|
-
this.wrapper = new re2_1.WrappedRE2(translateRegExp(pattern, this._multiline), this._ignoreCase, this._multiline, this._dotAll);
|
|
3854
|
-
if (!this.wrapper.ok()) {
|
|
3855
|
-
throw new SyntaxError(`Invalid regular expression: /${pattern}/${flags}: ${this.wrapper.error()}`);
|
|
3856
|
-
}
|
|
3857
|
-
const groupNames = this.wrapper.capturingGroupNames();
|
|
3858
|
-
const groupNumbers = groupNames.keys();
|
|
3859
|
-
for (let i = 0; i < groupNumbers.size(); i++) {
|
|
3860
|
-
const num2 = groupNumbers.get(i);
|
|
3861
|
-
const name = groupNames.get(num2);
|
|
3862
|
-
if (name in this.namedGroups) {
|
|
3863
|
-
throw new SyntaxError(`Invalid regular expression: /${pattern}/${flags}: Duplicate capture group name`);
|
|
3864
|
-
}
|
|
3865
|
-
this.groupNames[num2] = name;
|
|
3866
|
-
this.namedGroups[name] = num2;
|
|
3867
|
-
}
|
|
3868
|
-
}
|
|
3869
|
-
get source() {
|
|
3870
|
-
return this.pattern;
|
|
3871
|
-
}
|
|
3872
|
-
get internalSource() {
|
|
3873
|
-
return this.wrapper.pattern();
|
|
3874
|
-
}
|
|
3875
|
-
get flags() {
|
|
3876
|
-
return (this._global ? "g" : "") + (this._ignoreCase ? "i" : "") + (this._multiline ? "m" : "") + (this._dotAll ? "s" : "") + (this._unicode ? "u" : "") + (this._sticky ? "y" : "");
|
|
3877
|
-
}
|
|
3878
|
-
get global() {
|
|
3879
|
-
return this._global;
|
|
3880
|
-
}
|
|
3881
|
-
get ignoreCase() {
|
|
3882
|
-
return this._ignoreCase;
|
|
3883
|
-
}
|
|
3884
|
-
get multiline() {
|
|
3885
|
-
return this._multiline;
|
|
3886
|
-
}
|
|
3887
|
-
get dotAll() {
|
|
3888
|
-
return this._dotAll;
|
|
3889
|
-
}
|
|
3890
|
-
get unicode() {
|
|
3891
|
-
return this._unicode;
|
|
3892
|
-
}
|
|
3893
|
-
get sticky() {
|
|
3894
|
-
return this._sticky;
|
|
3895
|
-
}
|
|
3896
|
-
toString() {
|
|
3897
|
-
return `/${this.pattern}/${this.flags}`;
|
|
3898
|
-
}
|
|
3899
|
-
getMaybeStickyIndex() {
|
|
3900
|
-
if (this._global || this._sticky) {
|
|
3901
|
-
return this.lastIndex;
|
|
3902
|
-
} else {
|
|
3903
|
-
return 0;
|
|
3904
|
-
}
|
|
3905
|
-
}
|
|
3906
|
-
isMatchSuccessful(match, searchStart) {
|
|
3907
|
-
return match.index === searchStart || !this._sticky && match.index >= 0;
|
|
3908
|
-
}
|
|
3909
|
-
maybeUpdateLastIndex(match, start) {
|
|
3910
|
-
if (this._global || this._sticky) {
|
|
3911
|
-
if (this.isMatchSuccessful(match, start)) {
|
|
3912
|
-
this.lastIndex = match.index + match.match.length;
|
|
3913
|
-
} else {
|
|
3914
|
-
this.lastIndex = 0;
|
|
3915
|
-
}
|
|
3916
|
-
}
|
|
3917
|
-
}
|
|
3918
|
-
getNamedGroups(match) {
|
|
3919
|
-
const groups = {};
|
|
3920
|
-
for (const [groupName, groupNum] of Object.entries(this.namedGroups)) {
|
|
3921
|
-
if (match.groups[groupNum - 1] !== void 0) {
|
|
3922
|
-
groups[groupName] = match.groups[groupNum - 1];
|
|
3923
|
-
}
|
|
3924
|
-
}
|
|
3925
|
-
return groups;
|
|
3926
|
-
}
|
|
3927
|
-
exec(input) {
|
|
3928
|
-
if (typeof input !== "string") {
|
|
3929
|
-
input = input + "";
|
|
3930
|
-
}
|
|
3931
|
-
const startIndex = this.getMaybeStickyIndex();
|
|
3932
|
-
const match = this.wrapper.match(input, startIndex, true);
|
|
3933
|
-
this.maybeUpdateLastIndex(match, startIndex);
|
|
3934
|
-
if (!this.isMatchSuccessful(match, startIndex)) {
|
|
3935
|
-
return null;
|
|
3936
|
-
}
|
|
3937
|
-
const result = [match.match, ...match.groups];
|
|
3938
|
-
result.index = match.index;
|
|
3939
|
-
result.input = input;
|
|
3940
|
-
const groups = this.getNamedGroups(match);
|
|
3941
|
-
if (Object.keys(groups).length > 0) {
|
|
3942
|
-
result.groups = groups;
|
|
3943
|
-
}
|
|
3944
|
-
return result;
|
|
3945
|
-
}
|
|
3946
|
-
test(input) {
|
|
3947
|
-
if (typeof input !== "string") {
|
|
3948
|
-
input = input + "";
|
|
3949
|
-
}
|
|
3950
|
-
const startIndex = this.getMaybeStickyIndex();
|
|
3951
|
-
const match = this.wrapper.match(input, this.getMaybeStickyIndex(), false);
|
|
3952
|
-
this.maybeUpdateLastIndex(match, startIndex);
|
|
3953
|
-
return this.isMatchSuccessful(match, startIndex);
|
|
3954
|
-
}
|
|
3955
|
-
compile() {
|
|
3956
|
-
throw new Error("Deprecated RegExp method compile is not implemented in RE2.");
|
|
3957
|
-
}
|
|
3958
|
-
[Symbol.match](input) {
|
|
3959
|
-
if (typeof input !== "string") {
|
|
3960
|
-
input = input + "";
|
|
3961
|
-
}
|
|
3962
|
-
if (this._global) {
|
|
3963
|
-
const result = [];
|
|
3964
|
-
let nextIndex = 0;
|
|
3965
|
-
let success;
|
|
3966
|
-
do {
|
|
3967
|
-
const match = this.wrapper.match(input, nextIndex, false);
|
|
3968
|
-
success = match.index === nextIndex || !this._sticky && match.index >= 0;
|
|
3969
|
-
if (success) {
|
|
3970
|
-
result.push(match.match);
|
|
3971
|
-
nextIndex = match.index + match.match.length;
|
|
3972
|
-
}
|
|
3973
|
-
} while (success);
|
|
3974
|
-
if (result.length === 0) {
|
|
3975
|
-
return null;
|
|
3976
|
-
} else {
|
|
3977
|
-
return result;
|
|
3978
|
-
}
|
|
3979
|
-
} else {
|
|
3980
|
-
const startIndex = this.getMaybeStickyIndex();
|
|
3981
|
-
const match = this.wrapper.match(input, startIndex, true);
|
|
3982
|
-
this.maybeUpdateLastIndex(match, startIndex);
|
|
3983
|
-
if (!this.isMatchSuccessful(match, startIndex)) {
|
|
3984
|
-
return null;
|
|
3985
|
-
}
|
|
3986
|
-
const result = [match.match, ...match.groups];
|
|
3987
|
-
result.index = match.index;
|
|
3988
|
-
result.input = input;
|
|
3989
|
-
const groups = this.getNamedGroups(match);
|
|
3990
|
-
if (Object.keys(groups).length > 0) {
|
|
3991
|
-
result.groups = groups;
|
|
3992
|
-
}
|
|
3993
|
-
return result;
|
|
3994
|
-
}
|
|
3995
|
-
}
|
|
3996
|
-
match(input) {
|
|
3997
|
-
return this[Symbol.match](input);
|
|
3998
|
-
}
|
|
3999
|
-
/**
|
|
4000
|
-
* Outputs the replacement for the matched part of the string
|
|
4001
|
-
* @param input
|
|
4002
|
-
* @param match
|
|
4003
|
-
* @param replacer
|
|
4004
|
-
*/
|
|
4005
|
-
replaceMatch(input, match, replacer) {
|
|
4006
|
-
var _a, _b;
|
|
4007
|
-
if (typeof replacer === "string") {
|
|
4008
|
-
let result = "";
|
|
4009
|
-
for (let i = 0; i < replacer.length; i++) {
|
|
4010
|
-
if (replacer[i] === "$") {
|
|
4011
|
-
switch (replacer[i + 1]) {
|
|
4012
|
-
case "$":
|
|
4013
|
-
result += "$";
|
|
4014
|
-
i++;
|
|
4015
|
-
break;
|
|
4016
|
-
case "&":
|
|
4017
|
-
result += match.match;
|
|
4018
|
-
i++;
|
|
4019
|
-
break;
|
|
4020
|
-
case "`":
|
|
4021
|
-
result += input.substring(0, match.index);
|
|
4022
|
-
i++;
|
|
4023
|
-
break;
|
|
4024
|
-
case "'":
|
|
4025
|
-
result += input.substring(match.index + match.match.length);
|
|
4026
|
-
i++;
|
|
4027
|
-
break;
|
|
4028
|
-
case "<": {
|
|
4029
|
-
const endCaret = replacer.indexOf(">", i);
|
|
4030
|
-
if (endCaret < 0) {
|
|
4031
|
-
throw new Error("Invalid named group replacement");
|
|
4032
|
-
}
|
|
4033
|
-
const groupName = replacer.substring(i + 2, endCaret);
|
|
4034
|
-
if (groupName in this.namedGroups) {
|
|
4035
|
-
result += (_a = match.groups[this.namedGroups[groupName] - 1]) !== null && _a !== void 0 ? _a : "";
|
|
4036
|
-
}
|
|
4037
|
-
i = endCaret;
|
|
4038
|
-
break;
|
|
4039
|
-
}
|
|
4040
|
-
default: {
|
|
4041
|
-
let groupNum;
|
|
4042
|
-
if ("123456789".includes(replacer[i + 1])) {
|
|
4043
|
-
if ("0123456789".includes(replacer[i + 2])) {
|
|
4044
|
-
groupNum = Number.parseInt(replacer.substring(i + 1, i + 3)) - 1;
|
|
4045
|
-
i += 2;
|
|
4046
|
-
} else {
|
|
4047
|
-
groupNum = Number.parseInt(replacer[i + 1]) - 1;
|
|
4048
|
-
i++;
|
|
4049
|
-
}
|
|
4050
|
-
} else {
|
|
4051
|
-
throw new Error("Invalid replacement string");
|
|
4146
|
+
if (i + 2 < pattern.length) {
|
|
4147
|
+
const alphaIndex = ALPHA_UPPER.indexOf(pattern[i + 2]) + 1;
|
|
4148
|
+
if (alphaIndex >= 0) {
|
|
4149
|
+
result.push("\\x", HEX[Math.floor(alphaIndex / 16)], HEX[alphaIndex % 16]);
|
|
4150
|
+
i += 3;
|
|
4151
|
+
break;
|
|
4052
4152
|
}
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4153
|
+
}
|
|
4154
|
+
result.push("\\c");
|
|
4155
|
+
i += 2;
|
|
4156
|
+
break;
|
|
4157
|
+
case "u":
|
|
4158
|
+
if (i + 2 < pattern.length) {
|
|
4159
|
+
const ch2 = pattern[i + 2];
|
|
4160
|
+
if (isHexadecimal(ch2)) {
|
|
4161
|
+
result.push("\\x{");
|
|
4162
|
+
result.push(ch2);
|
|
4163
|
+
i += 3;
|
|
4164
|
+
for (let j = 0; j < 3 && i < pattern.length && isHexadecimal(pattern[i]); i++, j++) {
|
|
4165
|
+
result.push(pattern[i]);
|
|
4166
|
+
}
|
|
4167
|
+
result.push("}");
|
|
4168
|
+
break;
|
|
4169
|
+
} else if (ch2 === "{") {
|
|
4170
|
+
result.push("\\x");
|
|
4171
|
+
i += 2;
|
|
4172
|
+
break;
|
|
4057
4173
|
}
|
|
4058
4174
|
}
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4175
|
+
result.push("\\u");
|
|
4176
|
+
i += 2;
|
|
4177
|
+
break;
|
|
4178
|
+
default:
|
|
4179
|
+
result.push("\\", pattern[i + 1]);
|
|
4180
|
+
i += 2;
|
|
4062
4181
|
}
|
|
4182
|
+
continue;
|
|
4183
|
+
}
|
|
4184
|
+
} else if (pattern[i] === "/") {
|
|
4185
|
+
result.push("\\/");
|
|
4186
|
+
i += 1;
|
|
4187
|
+
continue;
|
|
4188
|
+
} else if (pattern.substring(i, i + 3) === "(?<") {
|
|
4189
|
+
if (pattern[i + 3] !== "=" && pattern[i + 3] !== "!") {
|
|
4190
|
+
result.push("(?P<");
|
|
4191
|
+
i += 3;
|
|
4192
|
+
continue;
|
|
4063
4193
|
}
|
|
4064
|
-
return result;
|
|
4065
|
-
} else {
|
|
4066
|
-
return replacer(match.match, ...match.groups, match.index, input, this.getNamedGroups(match));
|
|
4067
4194
|
}
|
|
4195
|
+
result.push(pattern[i]);
|
|
4196
|
+
i += 1;
|
|
4068
4197
|
}
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
return result;
|
|
4091
|
-
} else {
|
|
4092
|
-
const startIndex = this.getMaybeStickyIndex();
|
|
4093
|
-
const match = this.wrapper.match(input, startIndex, true);
|
|
4094
|
-
this.maybeUpdateLastIndex(match, startIndex);
|
|
4095
|
-
if (this.isMatchSuccessful(match, startIndex)) {
|
|
4096
|
-
return input.substring(0, match.index) + this.replaceMatch(input, match, replacer) + input.substring(match.index + match.match.length);
|
|
4198
|
+
return result.join("");
|
|
4199
|
+
}
|
|
4200
|
+
function escapeRegExp(pattern) {
|
|
4201
|
+
return pattern.replace(/(^|[^\\])((?:\\\\)*)\//g, "$1$2\\/");
|
|
4202
|
+
}
|
|
4203
|
+
var RE2 = class _RE2 {
|
|
4204
|
+
constructor(pattern, flags) {
|
|
4205
|
+
this._global = false;
|
|
4206
|
+
this._ignoreCase = false;
|
|
4207
|
+
this._multiline = false;
|
|
4208
|
+
this._dotAll = false;
|
|
4209
|
+
this._unicode = false;
|
|
4210
|
+
this._sticky = false;
|
|
4211
|
+
this.lastIndex = 0;
|
|
4212
|
+
this.pattern = "(?:)";
|
|
4213
|
+
this.groupNames = {};
|
|
4214
|
+
this.namedGroups = {};
|
|
4215
|
+
if (typeof pattern !== "string") {
|
|
4216
|
+
if (pattern instanceof RegExp || pattern instanceof _RE2) {
|
|
4217
|
+
flags = flags !== null && flags !== void 0 ? flags : pattern.flags;
|
|
4218
|
+
pattern = pattern.source;
|
|
4097
4219
|
} else {
|
|
4098
|
-
|
|
4220
|
+
if (pattern === void 0) {
|
|
4221
|
+
pattern = "(?:)";
|
|
4222
|
+
} else {
|
|
4223
|
+
pattern = pattern + "";
|
|
4224
|
+
}
|
|
4099
4225
|
}
|
|
4100
4226
|
}
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
return this[Symbol.replace](input, replacer);
|
|
4104
|
-
}
|
|
4105
|
-
[Symbol.search](input) {
|
|
4106
|
-
if (typeof input !== "string") {
|
|
4107
|
-
input = input + "";
|
|
4227
|
+
if (pattern === "") {
|
|
4228
|
+
pattern = "(?:)";
|
|
4108
4229
|
}
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4230
|
+
pattern = escapeRegExp(pattern);
|
|
4231
|
+
flags = flags !== null && flags !== void 0 ? flags : "";
|
|
4232
|
+
for (const flag of flags) {
|
|
4233
|
+
switch (flag) {
|
|
4234
|
+
case "g":
|
|
4235
|
+
this._global = true;
|
|
4236
|
+
break;
|
|
4237
|
+
case "i":
|
|
4238
|
+
this._ignoreCase = true;
|
|
4239
|
+
break;
|
|
4240
|
+
case "m":
|
|
4241
|
+
this._multiline = true;
|
|
4242
|
+
break;
|
|
4243
|
+
case "s":
|
|
4244
|
+
this._dotAll = true;
|
|
4245
|
+
break;
|
|
4246
|
+
case "u":
|
|
4247
|
+
this._unicode = true;
|
|
4248
|
+
break;
|
|
4249
|
+
case "y":
|
|
4250
|
+
this._sticky = true;
|
|
4251
|
+
break;
|
|
4252
|
+
}
|
|
4114
4253
|
}
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
return this[Symbol.search](input);
|
|
4118
|
-
}
|
|
4119
|
-
[Symbol.split](input, limit) {
|
|
4120
|
-
if (typeof input !== "string") {
|
|
4121
|
-
input = input + "";
|
|
4254
|
+
if (!this._unicode) {
|
|
4255
|
+
throw new Error('RE2 only works in unicode mode. The "u" flag must be passed when constructing a RE2 instance');
|
|
4122
4256
|
}
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
}
|
|
4136
|
-
for (const group of nextMatch.groups) {
|
|
4137
|
-
if (output.length >= limit) {
|
|
4138
|
-
break;
|
|
4139
|
-
}
|
|
4140
|
-
output.push(group);
|
|
4141
|
-
}
|
|
4142
|
-
} else {
|
|
4143
|
-
output.push(input.substring(nextIndex));
|
|
4144
|
-
break;
|
|
4257
|
+
this.pattern = pattern;
|
|
4258
|
+
this.wrapper = new re2_1.WrappedRE2(translateRegExp(pattern, this._multiline), this._ignoreCase, this._multiline, this._dotAll);
|
|
4259
|
+
if (!this.wrapper.ok()) {
|
|
4260
|
+
throw new SyntaxError(`Invalid regular expression: /${pattern}/${flags}: ${this.wrapper.error()}`);
|
|
4261
|
+
}
|
|
4262
|
+
const groupNames = this.wrapper.capturingGroupNames();
|
|
4263
|
+
const groupNumbers = groupNames.keys();
|
|
4264
|
+
for (let i = 0; i < groupNumbers.size(); i++) {
|
|
4265
|
+
const num2 = groupNumbers.get(i);
|
|
4266
|
+
const name = groupNames.get(num2);
|
|
4267
|
+
if (name in this.namedGroups) {
|
|
4268
|
+
throw new SyntaxError(`Invalid regular expression: /${pattern}/${flags}: Duplicate capture group name`);
|
|
4145
4269
|
}
|
|
4270
|
+
this.groupNames[num2] = name;
|
|
4271
|
+
this.namedGroups[name] = num2;
|
|
4146
4272
|
}
|
|
4147
|
-
return output;
|
|
4148
4273
|
}
|
|
4149
|
-
|
|
4150
|
-
return this
|
|
4274
|
+
get source() {
|
|
4275
|
+
return this.pattern;
|
|
4151
4276
|
}
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
module.exports = function quote(xs) {
|
|
4185
|
-
return xs.map(function(s) {
|
|
4186
|
-
if (s === "") {
|
|
4187
|
-
return (
|
|
4188
|
-
/** @type {const} */
|
|
4189
|
-
"''"
|
|
4190
|
-
);
|
|
4277
|
+
get internalSource() {
|
|
4278
|
+
return this.wrapper.pattern();
|
|
4279
|
+
}
|
|
4280
|
+
get flags() {
|
|
4281
|
+
return (this._global ? "g" : "") + (this._ignoreCase ? "i" : "") + (this._multiline ? "m" : "") + (this._dotAll ? "s" : "") + (this._unicode ? "u" : "") + (this._sticky ? "y" : "");
|
|
4282
|
+
}
|
|
4283
|
+
get global() {
|
|
4284
|
+
return this._global;
|
|
4285
|
+
}
|
|
4286
|
+
get ignoreCase() {
|
|
4287
|
+
return this._ignoreCase;
|
|
4288
|
+
}
|
|
4289
|
+
get multiline() {
|
|
4290
|
+
return this._multiline;
|
|
4291
|
+
}
|
|
4292
|
+
get dotAll() {
|
|
4293
|
+
return this._dotAll;
|
|
4294
|
+
}
|
|
4295
|
+
get unicode() {
|
|
4296
|
+
return this._unicode;
|
|
4297
|
+
}
|
|
4298
|
+
get sticky() {
|
|
4299
|
+
return this._sticky;
|
|
4300
|
+
}
|
|
4301
|
+
toString() {
|
|
4302
|
+
return `/${this.pattern}/${this.flags}`;
|
|
4303
|
+
}
|
|
4304
|
+
getMaybeStickyIndex() {
|
|
4305
|
+
if (this._global || this._sticky) {
|
|
4306
|
+
return this.lastIndex;
|
|
4307
|
+
} else {
|
|
4308
|
+
return 0;
|
|
4191
4309
|
}
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
if ("op" in s && typeof s.op === "string") {
|
|
4203
|
-
if (OPS.indexOf(s.op) < 0) {
|
|
4204
|
-
throw new TypeError("invalid `op` value: " + JSON.stringify(s.op));
|
|
4205
|
-
}
|
|
4206
|
-
return s.op.replace(/[\s\S]/g, "\\$&");
|
|
4310
|
+
}
|
|
4311
|
+
isMatchSuccessful(match, searchStart) {
|
|
4312
|
+
return match.index === searchStart || !this._sticky && match.index >= 0;
|
|
4313
|
+
}
|
|
4314
|
+
maybeUpdateLastIndex(match, start) {
|
|
4315
|
+
if (this._global || this._sticky) {
|
|
4316
|
+
if (this.isMatchSuccessful(match, start)) {
|
|
4317
|
+
this.lastIndex = match.index + match.match.length;
|
|
4318
|
+
} else {
|
|
4319
|
+
this.lastIndex = 0;
|
|
4207
4320
|
}
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4321
|
+
}
|
|
4322
|
+
}
|
|
4323
|
+
getNamedGroups(match) {
|
|
4324
|
+
const groups = {};
|
|
4325
|
+
for (const [groupName, groupNum] of Object.entries(this.namedGroups)) {
|
|
4326
|
+
if (match.groups[groupNum - 1] !== void 0) {
|
|
4327
|
+
groups[groupName] = match.groups[groupNum - 1];
|
|
4213
4328
|
}
|
|
4214
|
-
throw new TypeError("unrecognized object token shape");
|
|
4215
4329
|
}
|
|
4216
|
-
|
|
4217
|
-
|
|
4330
|
+
return groups;
|
|
4331
|
+
}
|
|
4332
|
+
exec(input) {
|
|
4333
|
+
if (typeof input !== "string") {
|
|
4334
|
+
input = input + "";
|
|
4218
4335
|
}
|
|
4219
|
-
|
|
4220
|
-
|
|
4336
|
+
const startIndex = this.getMaybeStickyIndex();
|
|
4337
|
+
const match = this.wrapper.match(input, startIndex, true);
|
|
4338
|
+
this.maybeUpdateLastIndex(match, startIndex);
|
|
4339
|
+
if (!this.isMatchSuccessful(match, startIndex)) {
|
|
4340
|
+
return null;
|
|
4221
4341
|
}
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
// node_modules/.pnpm/shell-quote@1.10.0/node_modules/shell-quote/parse.js
|
|
4229
|
-
var require_parse = __commonJS({
|
|
4230
|
-
"node_modules/.pnpm/shell-quote@1.10.0/node_modules/shell-quote/parse.js"(exports, module) {
|
|
4231
|
-
"use strict";
|
|
4232
|
-
var CONTROL = (
|
|
4233
|
-
/** @type {const} */
|
|
4234
|
-
"(?:" + /** @type {const} */
|
|
4235
|
-
[
|
|
4236
|
-
"\\|\\|",
|
|
4237
|
-
"\\&\\&",
|
|
4238
|
-
";;",
|
|
4239
|
-
"\\|\\&",
|
|
4240
|
-
"\\<\\(",
|
|
4241
|
-
"\\<\\<\\<",
|
|
4242
|
-
">>",
|
|
4243
|
-
">\\&",
|
|
4244
|
-
"<\\&",
|
|
4245
|
-
"[&;()|<>]"
|
|
4246
|
-
].join(
|
|
4247
|
-
/** @type {const} */
|
|
4248
|
-
"|"
|
|
4249
|
-
) + /** @type {const} */
|
|
4250
|
-
")"
|
|
4251
|
-
);
|
|
4252
|
-
var controlRE = new RegExp("^" + CONTROL + "$");
|
|
4253
|
-
var META = (
|
|
4254
|
-
/** @type {const} */
|
|
4255
|
-
"|&;()<> \\t"
|
|
4256
|
-
);
|
|
4257
|
-
var SINGLE_QUOTE = (
|
|
4258
|
-
/** @type {const} */
|
|
4259
|
-
"'([^']*?)'"
|
|
4260
|
-
);
|
|
4261
|
-
var DOUBLE_QUOTE = (
|
|
4262
|
-
/** @type {const} */
|
|
4263
|
-
'"((\\\\"|[^"])*?)"'
|
|
4264
|
-
);
|
|
4265
|
-
var hash = /^#$/;
|
|
4266
|
-
var SQ = (
|
|
4267
|
-
/** @type {const} */
|
|
4268
|
-
"'"
|
|
4269
|
-
);
|
|
4270
|
-
var DQ = (
|
|
4271
|
-
/** @type {const} */
|
|
4272
|
-
'"'
|
|
4273
|
-
);
|
|
4274
|
-
var DS = (
|
|
4275
|
-
/** @type {const} */
|
|
4276
|
-
"$"
|
|
4277
|
-
);
|
|
4278
|
-
var TOKEN = "";
|
|
4279
|
-
var mult = (
|
|
4280
|
-
/** @type {const} */
|
|
4281
|
-
4294967296
|
|
4282
|
-
);
|
|
4283
|
-
for (i = 0; i < 4; i++) {
|
|
4284
|
-
TOKEN += (mult * Math.random()).toString(16);
|
|
4285
|
-
}
|
|
4286
|
-
var i;
|
|
4287
|
-
var startsWithToken = new RegExp("^" + TOKEN);
|
|
4288
|
-
function matchAll(s, r) {
|
|
4289
|
-
var origIndex = r.lastIndex;
|
|
4290
|
-
var matches = [];
|
|
4291
|
-
var matchObj;
|
|
4292
|
-
while (matchObj = r.exec(s)) {
|
|
4293
|
-
matches[matches.length] = matchObj;
|
|
4294
|
-
if (r.lastIndex === matchObj.index) {
|
|
4295
|
-
r.lastIndex += 1;
|
|
4342
|
+
const result = [match.match, ...match.groups];
|
|
4343
|
+
result.index = match.index;
|
|
4344
|
+
result.input = input;
|
|
4345
|
+
const groups = this.getNamedGroups(match);
|
|
4346
|
+
if (Object.keys(groups).length > 0) {
|
|
4347
|
+
result.groups = groups;
|
|
4296
4348
|
}
|
|
4349
|
+
return result;
|
|
4297
4350
|
}
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
r = "$";
|
|
4307
|
-
}
|
|
4308
|
-
if (typeof r === "object") {
|
|
4309
|
-
return pre + TOKEN + JSON.stringify(r) + TOKEN;
|
|
4310
|
-
}
|
|
4311
|
-
return pre + r;
|
|
4312
|
-
}
|
|
4313
|
-
function parseInternal(string, env, opts) {
|
|
4314
|
-
if (!opts) {
|
|
4315
|
-
opts = {};
|
|
4316
|
-
}
|
|
4317
|
-
var BS = opts.escape || "\\";
|
|
4318
|
-
var ifs = opts.splitUnquoted === true ? " \n" : typeof opts.splitUnquoted === "string" ? opts.splitUnquoted : "";
|
|
4319
|
-
var BAREWORD = "(\\" + BS + `['"` + META + `]|[^\\s'"` + META + "])+";
|
|
4320
|
-
var chunker = new RegExp([
|
|
4321
|
-
"(" + CONTROL + ")",
|
|
4322
|
-
// control chars
|
|
4323
|
-
"(" + BAREWORD + "|" + DOUBLE_QUOTE + "|" + SINGLE_QUOTE + ")+"
|
|
4324
|
-
].join("|"), "g");
|
|
4325
|
-
var matches = matchAll(string, chunker);
|
|
4326
|
-
if (matches.length === 0) {
|
|
4327
|
-
return [];
|
|
4351
|
+
test(input) {
|
|
4352
|
+
if (typeof input !== "string") {
|
|
4353
|
+
input = input + "";
|
|
4354
|
+
}
|
|
4355
|
+
const startIndex = this.getMaybeStickyIndex();
|
|
4356
|
+
const match = this.wrapper.match(input, this.getMaybeStickyIndex(), false);
|
|
4357
|
+
this.maybeUpdateLastIndex(match, startIndex);
|
|
4358
|
+
return this.isMatchSuccessful(match, startIndex);
|
|
4328
4359
|
}
|
|
4329
|
-
|
|
4330
|
-
|
|
4360
|
+
compile() {
|
|
4361
|
+
throw new Error("Deprecated RegExp method compile is not implemented in RE2.");
|
|
4331
4362
|
}
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
if (!s || commented) {
|
|
4336
|
-
return void 0;
|
|
4337
|
-
}
|
|
4338
|
-
if (controlRE.test(s)) {
|
|
4339
|
-
return (
|
|
4340
|
-
/** @type {ControlOperator} */
|
|
4341
|
-
{ op: s }
|
|
4342
|
-
);
|
|
4363
|
+
[Symbol.match](input) {
|
|
4364
|
+
if (typeof input !== "string") {
|
|
4365
|
+
input = input + "";
|
|
4343
4366
|
}
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
var varend;
|
|
4355
|
-
var varname;
|
|
4356
|
-
var char = s.charAt(i2);
|
|
4357
|
-
if (char === "{") {
|
|
4358
|
-
i2 += 1;
|
|
4359
|
-
if (s.charAt(i2) === "}") {
|
|
4360
|
-
throw new Error("Bad substitution: " + s.slice(i2 - 2, i2 + 1));
|
|
4361
|
-
}
|
|
4362
|
-
var depth = 1;
|
|
4363
|
-
varend = i2;
|
|
4364
|
-
while (depth > 0 && varend < s.length) {
|
|
4365
|
-
if (s.charAt(varend) === "{" && s.charAt(varend - 1) === "$") {
|
|
4366
|
-
depth += 1;
|
|
4367
|
-
} else if (s.charAt(varend) === "}") {
|
|
4368
|
-
depth -= 1;
|
|
4369
|
-
}
|
|
4370
|
-
varend += 1;
|
|
4371
|
-
}
|
|
4372
|
-
if (depth !== 0) {
|
|
4373
|
-
throw new Error("Bad substitution: " + s.slice(i2));
|
|
4374
|
-
}
|
|
4375
|
-
varend -= 1;
|
|
4376
|
-
varname = s.slice(i2, varend);
|
|
4377
|
-
i2 = varend;
|
|
4378
|
-
} else if (/[*@#?$!_-]/.test(char)) {
|
|
4379
|
-
varname = char;
|
|
4380
|
-
i2 += 1;
|
|
4381
|
-
} else {
|
|
4382
|
-
var slicedFromI = s.slice(i2);
|
|
4383
|
-
varend = slicedFromI.match(/[^\w\d_]/);
|
|
4384
|
-
if (!varend) {
|
|
4385
|
-
varname = slicedFromI;
|
|
4386
|
-
i2 = s.length;
|
|
4387
|
-
} else {
|
|
4388
|
-
varname = slicedFromI.slice(0, varend.index);
|
|
4389
|
-
i2 += /** @type {number} */
|
|
4390
|
-
varend.index - 1;
|
|
4367
|
+
if (this._global) {
|
|
4368
|
+
const result = [];
|
|
4369
|
+
let nextIndex = 0;
|
|
4370
|
+
let success;
|
|
4371
|
+
do {
|
|
4372
|
+
const match = this.wrapper.match(input, nextIndex, false);
|
|
4373
|
+
success = match.index === nextIndex || !this._sticky && match.index >= 0;
|
|
4374
|
+
if (success) {
|
|
4375
|
+
result.push(match.match);
|
|
4376
|
+
nextIndex = match.index + match.match.length;
|
|
4391
4377
|
}
|
|
4378
|
+
} while (success);
|
|
4379
|
+
if (result.length === 0) {
|
|
4380
|
+
return null;
|
|
4381
|
+
} else {
|
|
4382
|
+
return result;
|
|
4392
4383
|
}
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
}
|
|
4400
|
-
function flushRun() {
|
|
4401
|
-
if (pendingNw === null) {
|
|
4402
|
-
return;
|
|
4384
|
+
} else {
|
|
4385
|
+
const startIndex = this.getMaybeStickyIndex();
|
|
4386
|
+
const match = this.wrapper.match(input, startIndex, true);
|
|
4387
|
+
this.maybeUpdateLastIndex(match, startIndex);
|
|
4388
|
+
if (!this.isMatchSuccessful(match, startIndex)) {
|
|
4389
|
+
return null;
|
|
4403
4390
|
}
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
words[words.length] = out;
|
|
4411
|
-
out = "";
|
|
4412
|
-
for (var fe = 1; fe < pendingNw; fe += 1) {
|
|
4413
|
-
words[words.length] = "";
|
|
4414
|
-
}
|
|
4391
|
+
const result = [match.match, ...match.groups];
|
|
4392
|
+
result.index = match.index;
|
|
4393
|
+
result.input = input;
|
|
4394
|
+
const groups = this.getNamedGroups(match);
|
|
4395
|
+
if (Object.keys(groups).length > 0) {
|
|
4396
|
+
result.groups = groups;
|
|
4415
4397
|
}
|
|
4416
|
-
|
|
4398
|
+
return result;
|
|
4417
4399
|
}
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4400
|
+
}
|
|
4401
|
+
match(input) {
|
|
4402
|
+
return this[Symbol.match](input);
|
|
4403
|
+
}
|
|
4404
|
+
/**
|
|
4405
|
+
* Outputs the replacement for the matched part of the string
|
|
4406
|
+
* @param input
|
|
4407
|
+
* @param match
|
|
4408
|
+
* @param replacer
|
|
4409
|
+
*/
|
|
4410
|
+
replaceMatch(input, match, replacer) {
|
|
4411
|
+
var _a, _b;
|
|
4412
|
+
if (typeof replacer === "string") {
|
|
4413
|
+
let result = "";
|
|
4414
|
+
for (let i = 0; i < replacer.length; i++) {
|
|
4415
|
+
if (replacer[i] === "$") {
|
|
4416
|
+
switch (replacer[i + 1]) {
|
|
4417
|
+
case "$":
|
|
4418
|
+
result += "$";
|
|
4419
|
+
i++;
|
|
4420
|
+
break;
|
|
4421
|
+
case "&":
|
|
4422
|
+
result += match.match;
|
|
4423
|
+
i++;
|
|
4424
|
+
break;
|
|
4425
|
+
case "`":
|
|
4426
|
+
result += input.substring(0, match.index);
|
|
4427
|
+
i++;
|
|
4428
|
+
break;
|
|
4429
|
+
case "'":
|
|
4430
|
+
result += input.substring(match.index + match.match.length);
|
|
4431
|
+
i++;
|
|
4432
|
+
break;
|
|
4433
|
+
case "<": {
|
|
4434
|
+
const endCaret = replacer.indexOf(">", i);
|
|
4435
|
+
if (endCaret < 0) {
|
|
4436
|
+
throw new Error("Invalid named group replacement");
|
|
4437
|
+
}
|
|
4438
|
+
const groupName = replacer.substring(i + 2, endCaret);
|
|
4439
|
+
if (groupName in this.namedGroups) {
|
|
4440
|
+
result += (_a = match.groups[this.namedGroups[groupName] - 1]) !== null && _a !== void 0 ? _a : "";
|
|
4441
|
+
}
|
|
4442
|
+
i = endCaret;
|
|
4443
|
+
break;
|
|
4440
4444
|
}
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
return (
|
|
4460
|
-
/** @type {const} */
|
|
4461
|
-
[out, commentObj]
|
|
4462
|
-
);
|
|
4463
|
-
}
|
|
4464
|
-
return (
|
|
4465
|
-
/** @type {const} */
|
|
4466
|
-
[commentObj]
|
|
4467
|
-
);
|
|
4468
|
-
} else if (c === BS) {
|
|
4469
|
-
esc = true;
|
|
4470
|
-
} else if (c === DS) {
|
|
4471
|
-
var value = parseEnvVar();
|
|
4472
|
-
if (!ifs) {
|
|
4473
|
-
out += value;
|
|
4474
|
-
} else {
|
|
4475
|
-
for (var vi = 0; vi < value.length; vi += 1) {
|
|
4476
|
-
var vc = value.charAt(vi);
|
|
4477
|
-
if (ifs.indexOf(vc) < 0) {
|
|
4478
|
-
flushRun();
|
|
4479
|
-
out += vc;
|
|
4480
|
-
} else if (pendingNw === null) {
|
|
4481
|
-
pendingNw = vc === " " || vc === " " || vc === "\n" ? 0 : 1;
|
|
4482
|
-
} else if (vc !== " " && vc !== " " && vc !== "\n") {
|
|
4483
|
-
pendingNw += 1;
|
|
4445
|
+
default: {
|
|
4446
|
+
let groupNum;
|
|
4447
|
+
if ("123456789".includes(replacer[i + 1])) {
|
|
4448
|
+
if ("0123456789".includes(replacer[i + 2])) {
|
|
4449
|
+
groupNum = Number.parseInt(replacer.substring(i + 1, i + 3)) - 1;
|
|
4450
|
+
i += 2;
|
|
4451
|
+
} else {
|
|
4452
|
+
groupNum = Number.parseInt(replacer[i + 1]) - 1;
|
|
4453
|
+
i++;
|
|
4454
|
+
}
|
|
4455
|
+
} else {
|
|
4456
|
+
throw new Error("Invalid replacement string");
|
|
4457
|
+
}
|
|
4458
|
+
if (groupNum < match.groups.length) {
|
|
4459
|
+
result += (_b = match.groups[groupNum]) !== null && _b !== void 0 ? _b : "";
|
|
4460
|
+
} else {
|
|
4461
|
+
result += "$" + groupNum;
|
|
4462
|
+
}
|
|
4484
4463
|
}
|
|
4485
4464
|
}
|
|
4465
|
+
} else {
|
|
4466
|
+
result += replacer[i];
|
|
4467
|
+
}
|
|
4468
|
+
}
|
|
4469
|
+
return result;
|
|
4470
|
+
} else {
|
|
4471
|
+
return replacer(match.match, ...match.groups, match.index, input, this.getNamedGroups(match));
|
|
4472
|
+
}
|
|
4473
|
+
}
|
|
4474
|
+
[Symbol.replace](input, replacer) {
|
|
4475
|
+
if (typeof input !== "string") {
|
|
4476
|
+
input = input + "";
|
|
4477
|
+
}
|
|
4478
|
+
if (typeof replacer !== "function") {
|
|
4479
|
+
replacer = replacer + "";
|
|
4480
|
+
}
|
|
4481
|
+
if (this._global) {
|
|
4482
|
+
let result = "";
|
|
4483
|
+
let nextIndex = 0;
|
|
4484
|
+
let success;
|
|
4485
|
+
do {
|
|
4486
|
+
const match = this.wrapper.match(input, nextIndex, true);
|
|
4487
|
+
success = match.index === nextIndex || !this._sticky && match.index >= 0;
|
|
4488
|
+
if (success) {
|
|
4489
|
+
result += input.substring(nextIndex, match.index) + this.replaceMatch(input, match, replacer);
|
|
4490
|
+
nextIndex = match.index + match.match.length;
|
|
4486
4491
|
}
|
|
4492
|
+
} while (success);
|
|
4493
|
+
result += input.substring(nextIndex);
|
|
4494
|
+
this.lastIndex = 0;
|
|
4495
|
+
return result;
|
|
4496
|
+
} else {
|
|
4497
|
+
const startIndex = this.getMaybeStickyIndex();
|
|
4498
|
+
const match = this.wrapper.match(input, startIndex, true);
|
|
4499
|
+
this.maybeUpdateLastIndex(match, startIndex);
|
|
4500
|
+
if (this.isMatchSuccessful(match, startIndex)) {
|
|
4501
|
+
return input.substring(0, match.index) + this.replaceMatch(input, match, replacer) + input.substring(match.index + match.match.length);
|
|
4487
4502
|
} else {
|
|
4488
|
-
|
|
4503
|
+
return input;
|
|
4489
4504
|
}
|
|
4490
4505
|
}
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4506
|
+
}
|
|
4507
|
+
replace(input, replacer) {
|
|
4508
|
+
return this[Symbol.replace](input, replacer);
|
|
4509
|
+
}
|
|
4510
|
+
[Symbol.search](input) {
|
|
4511
|
+
if (typeof input !== "string") {
|
|
4512
|
+
input = input + "";
|
|
4496
4513
|
}
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4514
|
+
const result = this.wrapper.match(input, 0, false).index;
|
|
4515
|
+
if (this._sticky && result !== 0) {
|
|
4516
|
+
return -1;
|
|
4517
|
+
} else {
|
|
4518
|
+
return result;
|
|
4519
|
+
}
|
|
4520
|
+
}
|
|
4521
|
+
search(input) {
|
|
4522
|
+
return this[Symbol.search](input);
|
|
4523
|
+
}
|
|
4524
|
+
[Symbol.split](input, limit) {
|
|
4525
|
+
if (typeof input !== "string") {
|
|
4526
|
+
input = input + "";
|
|
4527
|
+
}
|
|
4528
|
+
const output = [];
|
|
4529
|
+
let nextIndex = 0;
|
|
4530
|
+
limit = limit !== null && limit !== void 0 ? limit : Infinity;
|
|
4531
|
+
while (output.length < limit) {
|
|
4532
|
+
const nextMatch = this.wrapper.match(input, nextIndex, true);
|
|
4533
|
+
if (nextMatch.index >= 0) {
|
|
4534
|
+
if (nextMatch.match.length === 0) {
|
|
4535
|
+
output.push(input.substring(nextIndex, nextIndex + 1));
|
|
4536
|
+
nextIndex = nextIndex + 1;
|
|
4537
|
+
} else {
|
|
4538
|
+
output.push(input.substring(nextIndex, nextMatch.index));
|
|
4539
|
+
nextIndex = nextMatch.index + nextMatch.match.length;
|
|
4540
|
+
}
|
|
4541
|
+
for (const group of nextMatch.groups) {
|
|
4542
|
+
if (output.length >= limit) {
|
|
4543
|
+
break;
|
|
4544
|
+
}
|
|
4545
|
+
output.push(group);
|
|
4503
4546
|
}
|
|
4547
|
+
} else {
|
|
4548
|
+
output.push(input.substring(nextIndex));
|
|
4549
|
+
break;
|
|
4504
4550
|
}
|
|
4505
|
-
if (out !== "" || sawQuote && words.length === 0) {
|
|
4506
|
-
words[words.length] = out;
|
|
4507
|
-
}
|
|
4508
|
-
return words;
|
|
4509
4551
|
}
|
|
4510
|
-
return
|
|
4511
|
-
}
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
return prev;
|
|
4515
|
-
}
|
|
4516
|
-
[].concat(arg).forEach(function(entry) {
|
|
4517
|
-
prev[prev.length] = entry;
|
|
4518
|
-
});
|
|
4519
|
-
return prev;
|
|
4520
|
-
},
|
|
4521
|
-
/** @type {ParseEntry[]} */
|
|
4522
|
-
[]
|
|
4523
|
-
);
|
|
4524
|
-
}
|
|
4525
|
-
module.exports = function parse(s, env, opts) {
|
|
4526
|
-
var mapped = parseInternal(s, env, opts);
|
|
4527
|
-
if (typeof env !== "function") {
|
|
4528
|
-
return mapped;
|
|
4552
|
+
return output;
|
|
4553
|
+
}
|
|
4554
|
+
split(input, limit) {
|
|
4555
|
+
return this[Symbol.split](input, limit);
|
|
4529
4556
|
}
|
|
4530
|
-
return mapped.reduce(
|
|
4531
|
-
function(acc, s2) {
|
|
4532
|
-
if (typeof s2 === "object") {
|
|
4533
|
-
acc[acc.length] = s2;
|
|
4534
|
-
return acc;
|
|
4535
|
-
}
|
|
4536
|
-
var xs = s2.split(RegExp("(" + TOKEN + ".*?" + TOKEN + ")", "g"));
|
|
4537
|
-
if (xs.length === 1) {
|
|
4538
|
-
acc[acc.length] = xs[0];
|
|
4539
|
-
return acc;
|
|
4540
|
-
}
|
|
4541
|
-
xs.filter(Boolean).forEach(function(x) {
|
|
4542
|
-
acc[acc.length] = startsWithToken.test(x) ? JSON.parse(x.split(TOKEN)[1]) : x;
|
|
4543
|
-
});
|
|
4544
|
-
return acc;
|
|
4545
|
-
},
|
|
4546
|
-
/** @type {ParseEntry[]} */
|
|
4547
|
-
[]
|
|
4548
|
-
);
|
|
4549
4557
|
};
|
|
4558
|
+
exports.RE2 = RE2;
|
|
4550
4559
|
}
|
|
4551
4560
|
});
|
|
4552
4561
|
|
|
4553
|
-
//
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4562
|
+
// src/hooks/runtime/sniff.ts
|
|
4563
|
+
import { homedir } from "node:os";
|
|
4564
|
+
import { isAbsolute, resolve as resolvePath } from "node:path";
|
|
4565
|
+
|
|
4566
|
+
// src/hooks/runtime/shell-writes.ts
|
|
4567
|
+
var import_shell_quote = __toESM(require_shell_quote(), 1);
|
|
4568
|
+
var SEGMENT_OPS = /* @__PURE__ */ new Set([";", "&&", "||", "|", "|&", "&", "(", ")"]);
|
|
4569
|
+
var SHELL_INTERPRETERS = /* @__PURE__ */ new Set(["bash", "sh", "zsh", "dash", "ksh"]);
|
|
4570
|
+
var TRANSPARENT_PREFIXES = /* @__PURE__ */ new Set(["sudo", "doas", "nohup", "command", "time", "nice", "env"]);
|
|
4571
|
+
var HEREDOC_OPEN = /<<-?\s*(['"]?)([A-Za-z_][A-Za-z0-9_]*)\1/;
|
|
4572
|
+
function isOp(tok, op) {
|
|
4573
|
+
return typeof tok === "object" && "op" in tok && (op === void 0 || tok.op === op);
|
|
4574
|
+
}
|
|
4575
|
+
function tokenText(tok) {
|
|
4576
|
+
if (typeof tok === "string") return tok;
|
|
4577
|
+
if (typeof tok === "object" && "pattern" in tok) return tok.pattern;
|
|
4578
|
+
return null;
|
|
4579
|
+
}
|
|
4580
|
+
function stripHeredocBodies(command) {
|
|
4581
|
+
const lines = command.split("\n");
|
|
4582
|
+
const out = [];
|
|
4583
|
+
let i = 0;
|
|
4584
|
+
while (i < lines.length) {
|
|
4585
|
+
const line = lines[i];
|
|
4586
|
+
out.push(line);
|
|
4587
|
+
const m = HEREDOC_OPEN.exec(line);
|
|
4588
|
+
i++;
|
|
4589
|
+
if (!m) continue;
|
|
4590
|
+
const delimiter = m[2];
|
|
4591
|
+
while (i < lines.length) {
|
|
4592
|
+
const body = lines[i];
|
|
4593
|
+
i++;
|
|
4594
|
+
if (body.trim() === delimiter) break;
|
|
4595
|
+
}
|
|
4559
4596
|
}
|
|
4560
|
-
|
|
4597
|
+
return out.join("\n");
|
|
4598
|
+
}
|
|
4599
|
+
function isNoiseTarget(target) {
|
|
4600
|
+
if (target.length === 0) return true;
|
|
4601
|
+
if (target === "-") return true;
|
|
4602
|
+
if (target.startsWith("/dev/")) return true;
|
|
4603
|
+
if (/^&?\d+$/.test(target)) return true;
|
|
4604
|
+
return false;
|
|
4605
|
+
}
|
|
4606
|
+
function targetsFromArgv(argv, depth) {
|
|
4607
|
+
let i = 0;
|
|
4608
|
+
while (i < argv.length) {
|
|
4609
|
+
const tok = argv[i];
|
|
4610
|
+
if (/^[A-Za-z_][A-Za-z0-9_]*=/.test(tok)) {
|
|
4611
|
+
i++;
|
|
4612
|
+
continue;
|
|
4613
|
+
}
|
|
4614
|
+
if (TRANSPARENT_PREFIXES.has(tok)) {
|
|
4615
|
+
i++;
|
|
4616
|
+
if (tok === "env") {
|
|
4617
|
+
while (i < argv.length && (argv[i].startsWith("-") || /^[A-Za-z_][A-Za-z0-9_]*=/.test(argv[i]))) {
|
|
4618
|
+
if (argv[i] === "-u" || argv[i] === "--unset") i++;
|
|
4619
|
+
i++;
|
|
4620
|
+
}
|
|
4621
|
+
}
|
|
4622
|
+
continue;
|
|
4623
|
+
}
|
|
4624
|
+
break;
|
|
4625
|
+
}
|
|
4626
|
+
const cmd = argv[i] ?? "";
|
|
4627
|
+
const args = argv.slice(i + 1);
|
|
4628
|
+
const base = cmd.split("/").pop() ?? cmd;
|
|
4629
|
+
if (SHELL_INTERPRETERS.has(base)) {
|
|
4630
|
+
const c = args.indexOf("-c");
|
|
4631
|
+
if (c >= 0 && typeof args[c + 1] === "string" && depth < 1) {
|
|
4632
|
+
return extractShellWriteTargetsAt(args[c + 1], depth + 1);
|
|
4633
|
+
}
|
|
4634
|
+
return [];
|
|
4635
|
+
}
|
|
4636
|
+
if (base === "tee") {
|
|
4637
|
+
return args.filter((a) => !a.startsWith("-") && !isNoiseTarget(a));
|
|
4638
|
+
}
|
|
4639
|
+
if (base === "sed" || base === "gsed") {
|
|
4640
|
+
return sedTargets(args);
|
|
4641
|
+
}
|
|
4642
|
+
if (base === "perl") {
|
|
4643
|
+
return perlTargets(args);
|
|
4644
|
+
}
|
|
4645
|
+
if (base === "cp" || base === "mv" || base === "install") {
|
|
4646
|
+
const positional = args.filter((a) => !a.startsWith("-") || a === "-");
|
|
4647
|
+
if (positional.length >= 2) {
|
|
4648
|
+
const tFlag = args.findIndex((a) => a === "-t" || a === "--target-directory");
|
|
4649
|
+
if (tFlag >= 0 && args[tFlag + 1]) return [args[tFlag + 1]];
|
|
4650
|
+
return [positional[positional.length - 1]];
|
|
4651
|
+
}
|
|
4652
|
+
return [];
|
|
4653
|
+
}
|
|
4654
|
+
if (base === "dd") {
|
|
4655
|
+
return args.filter((a) => a.startsWith("of=")).map((a) => a.slice(3)).filter((a) => !isNoiseTarget(a));
|
|
4656
|
+
}
|
|
4657
|
+
return [];
|
|
4658
|
+
}
|
|
4659
|
+
function sedTargets(args) {
|
|
4660
|
+
let inPlace = false;
|
|
4661
|
+
let scriptGiven = false;
|
|
4662
|
+
const files = [];
|
|
4663
|
+
let i = 0;
|
|
4664
|
+
while (i < args.length) {
|
|
4665
|
+
const a = args[i];
|
|
4666
|
+
if (a === "--") {
|
|
4667
|
+
files.push(...args.slice(i + 1).filter((f) => f.length > 0));
|
|
4668
|
+
break;
|
|
4669
|
+
}
|
|
4670
|
+
if (a === "-i" || a === "--in-place") {
|
|
4671
|
+
inPlace = true;
|
|
4672
|
+
const next = args[i + 1];
|
|
4673
|
+
if (typeof next === "string" && (next === "" || /^\.[A-Za-z0-9_-]+$/.test(next))) i++;
|
|
4674
|
+
i++;
|
|
4675
|
+
continue;
|
|
4676
|
+
}
|
|
4677
|
+
if (/^-i/.test(a) || a.startsWith("--in-place=")) {
|
|
4678
|
+
inPlace = true;
|
|
4679
|
+
i++;
|
|
4680
|
+
continue;
|
|
4681
|
+
}
|
|
4682
|
+
if (a === "-e" || a === "--expression" || a === "-f" || a === "--file") {
|
|
4683
|
+
scriptGiven = true;
|
|
4684
|
+
i += 2;
|
|
4685
|
+
continue;
|
|
4686
|
+
}
|
|
4687
|
+
if (a.startsWith("--expression=") || a.startsWith("--file=")) {
|
|
4688
|
+
scriptGiven = true;
|
|
4689
|
+
i++;
|
|
4690
|
+
continue;
|
|
4691
|
+
}
|
|
4692
|
+
if (a.startsWith("-") && a.length > 1) {
|
|
4693
|
+
if (/^-[A-Za-z]*i/.test(a)) inPlace = true;
|
|
4694
|
+
i++;
|
|
4695
|
+
continue;
|
|
4696
|
+
}
|
|
4697
|
+
if (!scriptGiven) {
|
|
4698
|
+
scriptGiven = true;
|
|
4699
|
+
i++;
|
|
4700
|
+
continue;
|
|
4701
|
+
}
|
|
4702
|
+
if (a.length > 0) files.push(a);
|
|
4703
|
+
i++;
|
|
4704
|
+
}
|
|
4705
|
+
return inPlace ? files : [];
|
|
4706
|
+
}
|
|
4707
|
+
function perlTargets(args) {
|
|
4708
|
+
let inPlace = false;
|
|
4709
|
+
const files = [];
|
|
4710
|
+
let i = 0;
|
|
4711
|
+
while (i < args.length) {
|
|
4712
|
+
const a = args[i];
|
|
4713
|
+
if (a === "-e" || a === "-E") {
|
|
4714
|
+
i += 2;
|
|
4715
|
+
continue;
|
|
4716
|
+
}
|
|
4717
|
+
if (a.startsWith("-")) {
|
|
4718
|
+
if (/^-[A-Za-z0-9]*i/.test(a)) inPlace = true;
|
|
4719
|
+
if (/e$/.test(a) && !/^-i/.test(a)) i++;
|
|
4720
|
+
i++;
|
|
4721
|
+
continue;
|
|
4722
|
+
}
|
|
4723
|
+
files.push(a);
|
|
4724
|
+
i++;
|
|
4725
|
+
}
|
|
4726
|
+
return inPlace ? files : [];
|
|
4727
|
+
}
|
|
4728
|
+
function extractShellWriteTargetsAt(command, depth) {
|
|
4729
|
+
let tokens;
|
|
4730
|
+
try {
|
|
4731
|
+
tokens = (0, import_shell_quote.parse)(stripHeredocBodies(command), (key) => `$${key}`);
|
|
4732
|
+
} catch {
|
|
4733
|
+
return [];
|
|
4734
|
+
}
|
|
4735
|
+
const targets = [];
|
|
4736
|
+
let argv = [];
|
|
4737
|
+
const flush = () => {
|
|
4738
|
+
if (argv.length > 0) targets.push(...targetsFromArgv(argv, depth));
|
|
4739
|
+
argv = [];
|
|
4740
|
+
};
|
|
4741
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
4742
|
+
const tok = tokens[i];
|
|
4743
|
+
if (isOp(tok)) {
|
|
4744
|
+
if (tok.op === "&" && isOp(tokens[i + 1], ">")) continue;
|
|
4745
|
+
if (tok.op === ">" || tok.op === ">>") {
|
|
4746
|
+
const next = tokens[i + 1];
|
|
4747
|
+
const text2 = next === void 0 ? null : tokenText(next);
|
|
4748
|
+
if (text2 !== null) {
|
|
4749
|
+
if (!isNoiseTarget(text2)) targets.push(text2);
|
|
4750
|
+
i++;
|
|
4751
|
+
}
|
|
4752
|
+
if (/^\d+$/.test(argv[argv.length - 1] ?? "")) argv.pop();
|
|
4753
|
+
continue;
|
|
4754
|
+
}
|
|
4755
|
+
if (tok.op === ">&") {
|
|
4756
|
+
i++;
|
|
4757
|
+
if (/^\d+$/.test(argv[argv.length - 1] ?? "")) argv.pop();
|
|
4758
|
+
continue;
|
|
4759
|
+
}
|
|
4760
|
+
if (tok.op === "<") {
|
|
4761
|
+
const next = tokens[i + 1];
|
|
4762
|
+
if (!isOp(next, "<") && !isOp(tokens[i - 1], "<")) i++;
|
|
4763
|
+
else if (isOp(tokens[i - 1], "<")) i++;
|
|
4764
|
+
continue;
|
|
4765
|
+
}
|
|
4766
|
+
if (SEGMENT_OPS.has(tok.op)) {
|
|
4767
|
+
flush();
|
|
4768
|
+
continue;
|
|
4769
|
+
}
|
|
4770
|
+
continue;
|
|
4771
|
+
}
|
|
4772
|
+
const text = tokenText(tok);
|
|
4773
|
+
if (text !== null) argv.push(text);
|
|
4774
|
+
}
|
|
4775
|
+
flush();
|
|
4776
|
+
return Array.from(new Set(targets));
|
|
4777
|
+
}
|
|
4778
|
+
function extractShellWriteTargets(command) {
|
|
4779
|
+
if (typeof command !== "string" || command.trim().length === 0) return [];
|
|
4780
|
+
return extractShellWriteTargetsAt(command, 0);
|
|
4781
|
+
}
|
|
4561
4782
|
|
|
4562
4783
|
// src/hooks/runtime/sniff.ts
|
|
4784
|
+
function resolveWriteTarget(cwd, target) {
|
|
4785
|
+
if (target.includes("$")) return target;
|
|
4786
|
+
if (target === "~" || target.startsWith("~/")) {
|
|
4787
|
+
return resolvePath(homedir(), target.slice(2));
|
|
4788
|
+
}
|
|
4789
|
+
return isAbsolute(target) ? resolvePath(target) : resolvePath(cwd, target);
|
|
4790
|
+
}
|
|
4563
4791
|
function filePathFromPatch(patch) {
|
|
4564
4792
|
const lines = patch.split("\n");
|
|
4565
4793
|
for (const line of lines) {
|
|
@@ -4591,7 +4819,14 @@ function sniff(input) {
|
|
|
4591
4819
|
} else if (action === "pre_read_code" || action === "post_read_code") {
|
|
4592
4820
|
toolName = "Read";
|
|
4593
4821
|
}
|
|
4594
|
-
return {
|
|
4822
|
+
return {
|
|
4823
|
+
client: "windsurf",
|
|
4824
|
+
toolName,
|
|
4825
|
+
filePath,
|
|
4826
|
+
filePaths: filePath ? [filePath] : [],
|
|
4827
|
+
newContent,
|
|
4828
|
+
raw: input
|
|
4829
|
+
};
|
|
4595
4830
|
}
|
|
4596
4831
|
if ("hookEventName" in input) {
|
|
4597
4832
|
return extractToolInputShape(input, "vscode");
|
|
@@ -4603,7 +4838,7 @@ function sniff(input) {
|
|
|
4603
4838
|
client = "cursor";
|
|
4604
4839
|
} else {
|
|
4605
4840
|
const toolName = typeof input.tool_name === "string" ? input.tool_name : "";
|
|
4606
|
-
client = toolName === "apply_patch" ? "codex" : "claude-code";
|
|
4841
|
+
client = toolName === "apply_patch" || "turn_id" in input ? "codex" : "claude-code";
|
|
4607
4842
|
}
|
|
4608
4843
|
return extractToolInputShape(input, client);
|
|
4609
4844
|
}
|
|
@@ -4611,6 +4846,7 @@ function sniff(input) {
|
|
|
4611
4846
|
client: "unknown",
|
|
4612
4847
|
toolName: "",
|
|
4613
4848
|
filePath: "",
|
|
4849
|
+
filePaths: [],
|
|
4614
4850
|
newContent: "",
|
|
4615
4851
|
raw: input
|
|
4616
4852
|
};
|
|
@@ -4619,8 +4855,19 @@ function extractToolInputShape(input, client) {
|
|
|
4619
4855
|
const toolName = typeof input.tool_name === "string" ? input.tool_name : "";
|
|
4620
4856
|
const toolInput = input.tool_input ?? {};
|
|
4621
4857
|
let filePath = typeof toolInput.file_path === "string" ? toolInput.file_path : "";
|
|
4858
|
+
let filePaths = [];
|
|
4622
4859
|
let newContent = "";
|
|
4623
4860
|
switch (toolName) {
|
|
4861
|
+
case "Bash": {
|
|
4862
|
+
const command = typeof toolInput.command === "string" ? toolInput.command : "";
|
|
4863
|
+
newContent = command;
|
|
4864
|
+
const cwd = typeof input.cwd === "string" && input.cwd.length > 0 ? input.cwd : process.cwd();
|
|
4865
|
+
filePaths = extractShellWriteTargets(command).map(
|
|
4866
|
+
(t) => resolveWriteTarget(cwd, t)
|
|
4867
|
+
);
|
|
4868
|
+
filePath = filePaths[0] ?? "";
|
|
4869
|
+
break;
|
|
4870
|
+
}
|
|
4624
4871
|
case "Write":
|
|
4625
4872
|
newContent = typeof toolInput.content === "string" ? toolInput.content : "";
|
|
4626
4873
|
break;
|
|
@@ -4633,22 +4880,28 @@ function extractToolInputShape(input, client) {
|
|
|
4633
4880
|
);
|
|
4634
4881
|
break;
|
|
4635
4882
|
case "apply_patch": {
|
|
4636
|
-
const patch = typeof toolInput.patch === "string" ? toolInput.patch : "";
|
|
4883
|
+
const patch = typeof toolInput.patch === "string" ? toolInput.patch : typeof toolInput.command === "string" ? toolInput.command : "";
|
|
4637
4884
|
newContent = patch;
|
|
4638
4885
|
if (!filePath) filePath = filePathFromPatch(patch);
|
|
4639
4886
|
break;
|
|
4640
4887
|
}
|
|
4641
4888
|
}
|
|
4642
|
-
|
|
4889
|
+
if (typeof input.cwd === "string" && input.cwd.length > 0) {
|
|
4890
|
+
if (filePath) filePath = resolveWriteTarget(input.cwd, filePath);
|
|
4891
|
+
filePaths = filePaths.map((f) => resolveWriteTarget(input.cwd, f));
|
|
4892
|
+
}
|
|
4893
|
+
if (filePaths.length === 0 && filePath) filePaths = [filePath];
|
|
4894
|
+
return { client, toolName, filePath, filePaths, newContent, raw: input };
|
|
4643
4895
|
}
|
|
4644
4896
|
|
|
4645
4897
|
// src/hooks/runtime/resolve.ts
|
|
4646
4898
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
4899
|
+
import { createHash } from "node:crypto";
|
|
4647
4900
|
import { existsSync as existsSync6, readFileSync as readFileSync6 } from "node:fs";
|
|
4648
4901
|
|
|
4649
4902
|
// src/auth/auth-store.ts
|
|
4650
4903
|
import { execFileSync } from "node:child_process";
|
|
4651
|
-
import { homedir } from "node:os";
|
|
4904
|
+
import { homedir as homedir2 } from "node:os";
|
|
4652
4905
|
import { join } from "node:path";
|
|
4653
4906
|
import {
|
|
4654
4907
|
existsSync,
|
|
@@ -4764,10 +5017,10 @@ function readMacOSKeychain(mcpName) {
|
|
|
4764
5017
|
}
|
|
4765
5018
|
}
|
|
4766
5019
|
function fileFallbackPath() {
|
|
4767
|
-
return join(
|
|
5020
|
+
return join(homedir2(), ".cybedefend", "auth.json");
|
|
4768
5021
|
}
|
|
4769
5022
|
function storeFileFallback(blob) {
|
|
4770
|
-
const dir = join(
|
|
5023
|
+
const dir = join(homedir2(), ".cybedefend");
|
|
4771
5024
|
mkdirSync(dir, { recursive: true });
|
|
4772
5025
|
const p = fileFallbackPath();
|
|
4773
5026
|
writeFileSync(p, blob, { mode: 384 });
|
|
@@ -4995,7 +5248,7 @@ import { dirname as dirname2 } from "node:path";
|
|
|
4995
5248
|
// src/utils.ts
|
|
4996
5249
|
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
4997
5250
|
import { dirname, join as join2 } from "node:path";
|
|
4998
|
-
import { homedir as
|
|
5251
|
+
import { homedir as homedir3, platform } from "node:os";
|
|
4999
5252
|
|
|
5000
5253
|
// node_modules/.pnpm/kleur@4.1.5/node_modules/kleur/index.mjs
|
|
5001
5254
|
var FORCE_COLOR;
|
|
@@ -5098,7 +5351,7 @@ function init(open, close) {
|
|
|
5098
5351
|
|
|
5099
5352
|
// src/utils.ts
|
|
5100
5353
|
function home(...parts) {
|
|
5101
|
-
return join2(
|
|
5354
|
+
return join2(homedir3(), ...parts);
|
|
5102
5355
|
}
|
|
5103
5356
|
function ensureDirFor(filePath) {
|
|
5104
5357
|
const dir = dirname(filePath);
|
|
@@ -5173,10 +5426,10 @@ function writeCachedRepoLink(key, entry, deps = {}) {
|
|
|
5173
5426
|
|
|
5174
5427
|
// src/hooks/runtime/config.ts
|
|
5175
5428
|
import { existsSync as existsSync4, readFileSync as readFileSync4 } from "node:fs";
|
|
5176
|
-
import { homedir as
|
|
5429
|
+
import { homedir as homedir4 } from "node:os";
|
|
5177
5430
|
import { join as join3 } from "node:path";
|
|
5178
5431
|
function runtimeConfigPath() {
|
|
5179
|
-
return join3(
|
|
5432
|
+
return join3(homedir4(), ".cybedefend", "runtime-config.json");
|
|
5180
5433
|
}
|
|
5181
5434
|
function loadRuntimeConfig(path) {
|
|
5182
5435
|
const p = path ?? runtimeConfigPath();
|
|
@@ -5205,7 +5458,7 @@ async function readStdinJson() {
|
|
|
5205
5458
|
|
|
5206
5459
|
// src/hooks/runtime/trusted-api-base.ts
|
|
5207
5460
|
import { existsSync as existsSync5, readFileSync as readFileSync5 } from "node:fs";
|
|
5208
|
-
import { homedir as
|
|
5461
|
+
import { homedir as homedir5 } from "node:os";
|
|
5209
5462
|
import { join as join4 } from "node:path";
|
|
5210
5463
|
|
|
5211
5464
|
// src/config.ts
|
|
@@ -5234,7 +5487,7 @@ var REGIONS = [
|
|
|
5234
5487
|
|
|
5235
5488
|
// src/hooks/runtime/trusted-api-base.ts
|
|
5236
5489
|
function userRegionsPath() {
|
|
5237
|
-
return join4(
|
|
5490
|
+
return join4(homedir5(), ".cybedefend", "regions.json");
|
|
5238
5491
|
}
|
|
5239
5492
|
function normalizeOrigin(candidate) {
|
|
5240
5493
|
if (typeof candidate !== "string") return null;
|
|
@@ -5333,30 +5586,50 @@ function resolveProjectId(cwd = process.cwd(), deps = {}) {
|
|
|
5333
5586
|
}
|
|
5334
5587
|
return { projectId: null, apiBase: null };
|
|
5335
5588
|
}
|
|
5336
|
-
function resolveToken(mcpName) {
|
|
5589
|
+
function resolveToken(mcpName, opts = {}) {
|
|
5337
5590
|
const envToken = process.env.CYBEDEFEND_TOKEN;
|
|
5338
5591
|
if (envToken && envToken.length > 0) return envToken;
|
|
5339
|
-
|
|
5340
|
-
|
|
5592
|
+
const stored = (opts.loadStoredAuth ?? loadAuth)(mcpName);
|
|
5593
|
+
if (stored && (opts.now ?? Date.now)() < stored.expiresAt) {
|
|
5594
|
+
return stored.accessToken;
|
|
5595
|
+
}
|
|
5596
|
+
const platform2 = opts.platform ?? process.platform;
|
|
5597
|
+
const readKeychain = opts.readKeychain ?? readMacOSKeychain2;
|
|
5598
|
+
if (platform2 === "darwin") {
|
|
5599
|
+
return resolveTokenMacOS(mcpName, readKeychain) ?? resolveTokenCodexMacOS(mcpName, opts.mcpUrl, readKeychain);
|
|
5341
5600
|
}
|
|
5342
|
-
if (
|
|
5601
|
+
if (platform2 === "linux") return resolveTokenLinux(mcpName);
|
|
5343
5602
|
return null;
|
|
5344
5603
|
}
|
|
5345
|
-
function
|
|
5346
|
-
|
|
5604
|
+
function codexCredentialAccount(mcpName, mcpUrl) {
|
|
5605
|
+
const digest = createHash("sha256").update(JSON.stringify({ type: "http", url: mcpUrl, headers: {} })).digest("hex");
|
|
5606
|
+
return `${mcpName}|${digest.slice(0, 16)}`;
|
|
5607
|
+
}
|
|
5608
|
+
function readMacOSKeychain2(service, account) {
|
|
5347
5609
|
try {
|
|
5348
|
-
blob = execFileSync2(
|
|
5610
|
+
const blob = execFileSync2(
|
|
5349
5611
|
"security",
|
|
5350
|
-
[
|
|
5612
|
+
[
|
|
5613
|
+
"find-generic-password",
|
|
5614
|
+
"-s",
|
|
5615
|
+
service,
|
|
5616
|
+
...account === void 0 ? [] : ["-a", account],
|
|
5617
|
+
"-w"
|
|
5618
|
+
],
|
|
5351
5619
|
{
|
|
5352
5620
|
encoding: "utf8",
|
|
5353
5621
|
stdio: ["ignore", "pipe", "ignore"],
|
|
5354
5622
|
timeout: 2e3
|
|
5355
5623
|
}
|
|
5356
5624
|
).trim();
|
|
5625
|
+
return blob.length > 0 ? blob : null;
|
|
5357
5626
|
} catch {
|
|
5358
5627
|
return null;
|
|
5359
5628
|
}
|
|
5629
|
+
}
|
|
5630
|
+
function resolveTokenMacOS(mcpName, readKeychain) {
|
|
5631
|
+
const blob = readKeychain("Claude Code-credentials");
|
|
5632
|
+
if (!blob) return null;
|
|
5360
5633
|
try {
|
|
5361
5634
|
const data = JSON.parse(blob);
|
|
5362
5635
|
const oauth = data.mcpOAuth ?? {};
|
|
@@ -5370,37 +5643,20 @@ function resolveTokenMacOS(mcpName) {
|
|
|
5370
5643
|
}
|
|
5371
5644
|
return null;
|
|
5372
5645
|
}
|
|
5373
|
-
function resolveTokenCodexMacOS(mcpName) {
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
blob =
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
encoding: "utf8",
|
|
5381
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
5382
|
-
timeout: 2e3
|
|
5383
|
-
}
|
|
5384
|
-
).trim();
|
|
5385
|
-
} catch {
|
|
5386
|
-
try {
|
|
5387
|
-
blob = execFileSync2(
|
|
5388
|
-
"security",
|
|
5389
|
-
["find-generic-password", "-s", "Codex MCP Credentials", "-w"],
|
|
5390
|
-
{
|
|
5391
|
-
encoding: "utf8",
|
|
5392
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
5393
|
-
timeout: 2e3
|
|
5394
|
-
}
|
|
5395
|
-
).trim();
|
|
5396
|
-
} catch {
|
|
5397
|
-
return null;
|
|
5398
|
-
}
|
|
5646
|
+
function resolveTokenCodexMacOS(mcpName, mcpUrl, readKeychain) {
|
|
5647
|
+
const accounts = mcpUrl ? [codexCredentialAccount(mcpName, mcpUrl), mcpName] : [mcpName];
|
|
5648
|
+
for (const account of accounts) {
|
|
5649
|
+
const blob = readKeychain("Codex MCP Credentials", account);
|
|
5650
|
+
if (!blob) continue;
|
|
5651
|
+
const token = parseCodexCredential(blob);
|
|
5652
|
+
if (token) return token;
|
|
5399
5653
|
}
|
|
5400
|
-
|
|
5654
|
+
return null;
|
|
5655
|
+
}
|
|
5656
|
+
function parseCodexCredential(blob) {
|
|
5401
5657
|
try {
|
|
5402
5658
|
const data = JSON.parse(blob);
|
|
5403
|
-
return data.access_token ?? data.accessToken ?? data.token ?? null;
|
|
5659
|
+
return data.token_response?.access_token ?? data.access_token ?? data.accessToken ?? data.token ?? null;
|
|
5404
5660
|
} catch {
|
|
5405
5661
|
return blob || null;
|
|
5406
5662
|
}
|
|
@@ -5421,7 +5677,7 @@ function resolveTokenLinux(mcpName) {
|
|
|
5421
5677
|
return null;
|
|
5422
5678
|
}
|
|
5423
5679
|
}
|
|
5424
|
-
async function resolveTokenWithRefresh(mcpName, deps = {}) {
|
|
5680
|
+
async function resolveTokenWithRefresh(mcpName, deps = {}, opts = {}) {
|
|
5425
5681
|
const getValidAccessTokenFn = deps.getValidAccessToken ?? getValidAccessToken;
|
|
5426
5682
|
const resolveTokenFn = deps.resolveTokenFn ?? resolveToken;
|
|
5427
5683
|
const envToken = process.env.CYBEDEFEND_TOKEN;
|
|
@@ -5431,10 +5687,10 @@ async function resolveTokenWithRefresh(mcpName, deps = {}) {
|
|
|
5431
5687
|
if (token) return token;
|
|
5432
5688
|
} catch (e) {
|
|
5433
5689
|
if (e instanceof LoginRequiredError) {
|
|
5434
|
-
return resolveTokenFn(mcpName);
|
|
5690
|
+
return resolveTokenFn(mcpName, opts);
|
|
5435
5691
|
}
|
|
5436
5692
|
}
|
|
5437
|
-
return resolveTokenFn(mcpName);
|
|
5693
|
+
return resolveTokenFn(mcpName, opts);
|
|
5438
5694
|
}
|
|
5439
5695
|
var RESOLVE_API_TIMEOUT_MS = 4e3;
|
|
5440
5696
|
async function resolveProjectIdWithApi(cwd = process.cwd(), deps = {}) {
|
|
@@ -5584,6 +5840,10 @@ async function fetchProposalsCount(opts) {
|
|
|
5584
5840
|
}
|
|
5585
5841
|
|
|
5586
5842
|
// src/hooks/runtime/emit.ts
|
|
5843
|
+
var ENVELOPE_CLIENTS = {
|
|
5844
|
+
SessionStart: /* @__PURE__ */ new Set(["codex"]),
|
|
5845
|
+
PreToolUse: /* @__PURE__ */ new Set(["claude-code", "codex"])
|
|
5846
|
+
};
|
|
5587
5847
|
function emit(body, client) {
|
|
5588
5848
|
if (!body) return;
|
|
5589
5849
|
if (client === "cursor") {
|
|
@@ -5597,16 +5857,16 @@ function emit(body, client) {
|
|
|
5597
5857
|
process.stdout.write(body);
|
|
5598
5858
|
if (!body.endsWith("\n")) process.stdout.write("\n");
|
|
5599
5859
|
}
|
|
5600
|
-
function emitContext(body, client) {
|
|
5860
|
+
function emitContext(body, client, hookEventName) {
|
|
5601
5861
|
if (!body) return;
|
|
5602
|
-
if (client
|
|
5862
|
+
if (ENVELOPE_CLIENTS[hookEventName].has(client)) {
|
|
5603
5863
|
const payload = JSON.stringify({
|
|
5604
5864
|
hookSpecificOutput: {
|
|
5605
|
-
hookEventName
|
|
5865
|
+
hookEventName,
|
|
5606
5866
|
additionalContext: body
|
|
5607
5867
|
}
|
|
5608
5868
|
});
|
|
5609
|
-
process.stdout.write(payload);
|
|
5869
|
+
process.stdout.write(payload + "\n");
|
|
5610
5870
|
return;
|
|
5611
5871
|
}
|
|
5612
5872
|
emit(body, client);
|
|
@@ -5626,11 +5886,15 @@ function emitStop(body, client, reason) {
|
|
|
5626
5886
|
}
|
|
5627
5887
|
|
|
5628
5888
|
// src/hooks/runtime/fetch-rules.ts
|
|
5889
|
+
function emitPreToolUseContext(body, client) {
|
|
5890
|
+
emitContext(body, client, "PreToolUse");
|
|
5891
|
+
}
|
|
5629
5892
|
var INTERESTED_TOOLS = /* @__PURE__ */ new Set([
|
|
5630
5893
|
"Edit",
|
|
5631
5894
|
"Write",
|
|
5632
5895
|
"MultiEdit",
|
|
5633
|
-
"apply_patch"
|
|
5896
|
+
"apply_patch",
|
|
5897
|
+
"Bash"
|
|
5634
5898
|
]);
|
|
5635
5899
|
async function fetchRulesHook(deps = {}) {
|
|
5636
5900
|
const readStdin = deps.readStdin ?? readStdinJson;
|
|
@@ -5639,7 +5903,7 @@ async function fetchRulesHook(deps = {}) {
|
|
|
5639
5903
|
const resolveTok = deps.resolveTokenFn ?? resolveToken;
|
|
5640
5904
|
const fetchRules = deps.fetchRulesFn ?? fetchBusinessRules;
|
|
5641
5905
|
const fetchSecRules = deps.fetchSecurityRulesFn ?? fetchSecurityRules;
|
|
5642
|
-
const emitFn = deps.emitFn ??
|
|
5906
|
+
const emitFn = deps.emitFn ?? emitPreToolUseContext;
|
|
5643
5907
|
const stdin = await readStdin();
|
|
5644
5908
|
const event = sniff(stdin);
|
|
5645
5909
|
if (!INTERESTED_TOOLS.has(event.toolName)) return;
|
|
@@ -5649,14 +5913,18 @@ async function fetchRulesHook(deps = {}) {
|
|
|
5649
5913
|
const { projectId, apiBase: configApiBase } = await resolveProject();
|
|
5650
5914
|
if (!projectId) return;
|
|
5651
5915
|
const apiBase = process.env.CYBEDEFEND_API_BASE ?? configApiBase ?? config.region.apiBase;
|
|
5652
|
-
const token = resolveTok(config.region.mcpName
|
|
5916
|
+
const token = resolveTok(config.region.mcpName, {
|
|
5917
|
+
mcpUrl: config.region.mcpUrl
|
|
5918
|
+
});
|
|
5653
5919
|
if (!token) return;
|
|
5654
5920
|
const intent = buildIntent(event);
|
|
5921
|
+
const files = event.filePaths.length > 0 ? event.filePaths : [event.filePath];
|
|
5922
|
+
const fileLabel = files.join(", ");
|
|
5655
5923
|
const fetchOpts = {
|
|
5656
5924
|
apiBase,
|
|
5657
5925
|
projectId,
|
|
5658
5926
|
token,
|
|
5659
|
-
files
|
|
5927
|
+
files,
|
|
5660
5928
|
intent,
|
|
5661
5929
|
topK: 5
|
|
5662
5930
|
};
|
|
@@ -5664,24 +5932,25 @@ async function fetchRulesHook(deps = {}) {
|
|
|
5664
5932
|
fetchRules(fetchOpts),
|
|
5665
5933
|
fetchSecRules(fetchOpts)
|
|
5666
5934
|
]);
|
|
5935
|
+
const blocks = [];
|
|
5667
5936
|
if (businessResult) {
|
|
5668
5937
|
const body = composeBody(
|
|
5669
5938
|
businessResult.markdown,
|
|
5670
5939
|
businessResult.total,
|
|
5671
|
-
|
|
5940
|
+
fileLabel
|
|
5672
5941
|
);
|
|
5673
|
-
if (body)
|
|
5942
|
+
if (body) blocks.push(body);
|
|
5674
5943
|
}
|
|
5675
5944
|
if (securityResult && securityResult.total > 0 && securityResult.markdown && securityResult.markdown.length > 0) {
|
|
5676
|
-
|
|
5945
|
+
blocks.push(
|
|
5677
5946
|
composeSecurityBody(
|
|
5678
5947
|
securityResult.markdown,
|
|
5679
5948
|
securityResult.total,
|
|
5680
|
-
|
|
5681
|
-
)
|
|
5682
|
-
event.client
|
|
5949
|
+
fileLabel
|
|
5950
|
+
)
|
|
5683
5951
|
);
|
|
5684
5952
|
}
|
|
5953
|
+
if (blocks.length > 0) emitFn(blocks.join("\n"), event.client);
|
|
5685
5954
|
}
|
|
5686
5955
|
function buildIntent(event) {
|
|
5687
5956
|
const limit = parseInt(process.env.CYBEDEFEND_INTENT_BYTES ?? "800", 10);
|
|
@@ -5693,7 +5962,7 @@ function visibleCalloutTemplate(kind, total, filePath) {
|
|
|
5693
5962
|
return [
|
|
5694
5963
|
"---",
|
|
5695
5964
|
"",
|
|
5696
|
-
`**\u{1F6E1}\uFE0F REQUIRED USER-VISIBLE MARKER** \u2014 you MUST include this exact block as the FIRST paragraph of your next assistant reply, BEFORE the
|
|
5965
|
+
`**\u{1F6E1}\uFE0F REQUIRED USER-VISIBLE MARKER** \u2014 you MUST include this exact block as the FIRST paragraph of your next assistant reply, BEFORE the tool call that writes the file. Do not paraphrase, do not skip \u2014 without it, the user cannot see CybeDefend is influencing the change.`,
|
|
5697
5966
|
"",
|
|
5698
5967
|
`> \u{1F6E1}\uFE0F **CybeDefend ${kind} Rules** \u2014 ${total} rule${total === 1 ? "" : "s"} for \`${filePath}\``,
|
|
5699
5968
|
`> - **<rule-title>** [<severity> \xB7 <category>] \u2014 applies because <one-sentence reason>`,
|
|
@@ -5740,7 +6009,7 @@ function composeSecurityBody(markdown, total, filePath) {
|
|
|
5740
6009
|
// src/hooks/runtime/self-update-check.ts
|
|
5741
6010
|
import { spawn } from "node:child_process";
|
|
5742
6011
|
import { existsSync as existsSync8, readFileSync as readFileSync7, rmSync, writeFileSync as writeFileSync4 } from "node:fs";
|
|
5743
|
-
import { homedir as
|
|
6012
|
+
import { homedir as homedir6 } from "node:os";
|
|
5744
6013
|
import { join as join5 } from "node:path";
|
|
5745
6014
|
|
|
5746
6015
|
// src/hooks/runtime/semver.ts
|
|
@@ -5818,7 +6087,7 @@ function isValidRegistryVersion(value) {
|
|
|
5818
6087
|
}
|
|
5819
6088
|
async function selfUpdateCheck(deps) {
|
|
5820
6089
|
const now = deps.now ?? (() => Date.now());
|
|
5821
|
-
const dir = deps.cybeDir ?? join5(process.env.CYBEDEFEND_HOME ??
|
|
6090
|
+
const dir = deps.cybeDir ?? join5(process.env.CYBEDEFEND_HOME ?? homedir6(), ".cybedefend");
|
|
5822
6091
|
const throttlePath = join5(dir, "update-check.json");
|
|
5823
6092
|
const logPath = join5(dir, "last-update.log");
|
|
5824
6093
|
const installMode = deps.installMode ?? (deps.runnerSource ? detectInstallMode(deps.runnerSource) : detectInstallMode(resolveScriptPath()));
|
|
@@ -5946,19 +6215,66 @@ function pmCommand(mode, spec) {
|
|
|
5946
6215
|
}
|
|
5947
6216
|
}
|
|
5948
6217
|
|
|
6218
|
+
// src/hooks/runtime/hook-refresh-trigger.ts
|
|
6219
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
6220
|
+
import { existsSync as existsSync9, readFileSync as readFileSync8, writeFileSync as writeFileSync5 } from "node:fs";
|
|
6221
|
+
import { homedir as homedir7 } from "node:os";
|
|
6222
|
+
import { dirname as dirname3, join as join6 } from "node:path";
|
|
6223
|
+
function maybeRefreshStaleWiring(deps) {
|
|
6224
|
+
try {
|
|
6225
|
+
const { config, runnerVersion } = deps;
|
|
6226
|
+
if (!config.runnerSource || config.installedVersion === runnerVersion) {
|
|
6227
|
+
return false;
|
|
6228
|
+
}
|
|
6229
|
+
const cliEntry = join6(dirname3(dirname3(config.runnerSource)), "bin", "vibedefend.js");
|
|
6230
|
+
if (!(deps.exists ?? existsSync9)(cliEntry)) return false;
|
|
6231
|
+
const markerPath = deps.markerPath ?? join6(process.env.CYBEDEFEND_HOME ?? homedir7(), ".cybedefend", "hook-refresh.json");
|
|
6232
|
+
if (readMarkerVersion(markerPath) === runnerVersion) return false;
|
|
6233
|
+
(deps.spawnRefresh ?? defaultSpawnRefresh)(cliEntry);
|
|
6234
|
+
writeMarker(markerPath, runnerVersion);
|
|
6235
|
+
return true;
|
|
6236
|
+
} catch {
|
|
6237
|
+
return false;
|
|
6238
|
+
}
|
|
6239
|
+
}
|
|
6240
|
+
function readMarkerVersion(path) {
|
|
6241
|
+
try {
|
|
6242
|
+
if (!existsSync9(path)) return null;
|
|
6243
|
+
const data = JSON.parse(readFileSync8(path, "utf8"));
|
|
6244
|
+
return typeof data.version === "string" ? data.version : null;
|
|
6245
|
+
} catch {
|
|
6246
|
+
return null;
|
|
6247
|
+
}
|
|
6248
|
+
}
|
|
6249
|
+
function writeMarker(path, version) {
|
|
6250
|
+
try {
|
|
6251
|
+
ensureDirFor(path);
|
|
6252
|
+
writeFileSync5(path, JSON.stringify({ version, spawnedAt: Date.now() }) + "\n");
|
|
6253
|
+
} catch {
|
|
6254
|
+
}
|
|
6255
|
+
}
|
|
6256
|
+
function defaultSpawnRefresh(cliEntry) {
|
|
6257
|
+
const child = spawn2(process.execPath, [cliEntry, "update", "--refresh-hooks"], {
|
|
6258
|
+
detached: true,
|
|
6259
|
+
stdio: "ignore",
|
|
6260
|
+
windowsHide: true
|
|
6261
|
+
});
|
|
6262
|
+
child.unref();
|
|
6263
|
+
}
|
|
6264
|
+
|
|
5949
6265
|
// src/version.ts
|
|
5950
|
-
import { readFileSync as
|
|
6266
|
+
import { readFileSync as readFileSync9 } from "node:fs";
|
|
5951
6267
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
5952
|
-
import { dirname as
|
|
6268
|
+
import { dirname as dirname4, join as join7 } from "node:path";
|
|
5953
6269
|
var PKG_NAME = "@cybedefend/vibedefend";
|
|
5954
6270
|
function defaultPkgPath() {
|
|
5955
|
-
return
|
|
6271
|
+
return join7(dirname4(fileURLToPath2(import.meta.url)), "..", "package.json");
|
|
5956
6272
|
}
|
|
5957
6273
|
function readPackageMeta(opts = {}) {
|
|
5958
6274
|
if (typeof opts.bakedVersion === "string" && opts.bakedVersion.length > 0) {
|
|
5959
6275
|
return { name: PKG_NAME, version: opts.bakedVersion };
|
|
5960
6276
|
}
|
|
5961
|
-
const readFile = opts.readFile ?? ((p) =>
|
|
6277
|
+
const readFile = opts.readFile ?? ((p) => readFileSync9(p, "utf8"));
|
|
5962
6278
|
const pkgPath = opts.pkgPath ?? defaultPkgPath();
|
|
5963
6279
|
try {
|
|
5964
6280
|
return JSON.parse(readFile(pkgPath));
|
|
@@ -5967,10 +6283,13 @@ function readPackageMeta(opts = {}) {
|
|
|
5967
6283
|
}
|
|
5968
6284
|
}
|
|
5969
6285
|
var pkg = readPackageMeta({
|
|
5970
|
-
bakedVersion: true ? "1.4.
|
|
6286
|
+
bakedVersion: true ? "1.4.4" : void 0
|
|
5971
6287
|
});
|
|
5972
6288
|
|
|
5973
6289
|
// src/hooks/runtime/session-start.ts
|
|
6290
|
+
function emitSessionStartContext(body, client) {
|
|
6291
|
+
emitContext(body, client, "SessionStart");
|
|
6292
|
+
}
|
|
5974
6293
|
async function sessionStartHook(deps = {}) {
|
|
5975
6294
|
const readStdin = deps.readStdin ?? readStdinJson;
|
|
5976
6295
|
const loadConfig = deps.loadConfig ?? loadRuntimeConfig;
|
|
@@ -5978,11 +6297,15 @@ async function sessionStartHook(deps = {}) {
|
|
|
5978
6297
|
const resolveTok = deps.resolveTokenFn ?? resolveToken;
|
|
5979
6298
|
const fetchProposals = deps.fetchProposalsFn ?? fetchProposalsCount;
|
|
5980
6299
|
const selfUpdateCheckFn = deps.selfUpdateCheckFn ?? selfUpdateCheck;
|
|
5981
|
-
const emitFn = deps.emitFn ??
|
|
6300
|
+
const emitFn = deps.emitFn ?? emitSessionStartContext;
|
|
5982
6301
|
const stdin = await readStdin();
|
|
5983
6302
|
const event = sniff(stdin);
|
|
5984
6303
|
const config = loadConfig();
|
|
5985
6304
|
if (!config) return;
|
|
6305
|
+
(deps.refreshStaleWiringFn ?? maybeRefreshStaleWiring)({
|
|
6306
|
+
config,
|
|
6307
|
+
runnerVersion: pkg.version
|
|
6308
|
+
});
|
|
5986
6309
|
const { projectId, apiBase: configApiBase } = await resolveProject();
|
|
5987
6310
|
if (!projectId) return;
|
|
5988
6311
|
const apiBase = process.env.CYBEDEFEND_API_BASE ?? configApiBase ?? config.region.apiBase;
|
|
@@ -5995,7 +6318,9 @@ async function sessionStartHook(deps = {}) {
|
|
|
5995
6318
|
);
|
|
5996
6319
|
return;
|
|
5997
6320
|
}
|
|
5998
|
-
const token = resolveTok(config.region.mcpName
|
|
6321
|
+
const token = resolveTok(config.region.mcpName, {
|
|
6322
|
+
mcpUrl: config.region.mcpUrl
|
|
6323
|
+
});
|
|
5999
6324
|
let total = null;
|
|
6000
6325
|
if (token) {
|
|
6001
6326
|
const result = await fetchProposals({ apiBase, projectId, token });
|
|
@@ -6069,7 +6394,7 @@ async function sessionStartHook(deps = {}) {
|
|
|
6069
6394
|
}
|
|
6070
6395
|
|
|
6071
6396
|
// src/hooks/runtime/session-review.ts
|
|
6072
|
-
import { existsSync as
|
|
6397
|
+
import { existsSync as existsSync10, readFileSync as readFileSync10 } from "node:fs";
|
|
6073
6398
|
var COUNTED_TOOLS = /* @__PURE__ */ new Set([
|
|
6074
6399
|
"Edit",
|
|
6075
6400
|
"Write",
|
|
@@ -6147,9 +6472,9 @@ function loadTranscript(stdin, readFile) {
|
|
|
6147
6472
|
return out;
|
|
6148
6473
|
}
|
|
6149
6474
|
function defaultReadTranscript(path) {
|
|
6150
|
-
if (!
|
|
6475
|
+
if (!existsSync10(path)) return null;
|
|
6151
6476
|
try {
|
|
6152
|
-
return
|
|
6477
|
+
return readFileSync10(path, "utf8");
|
|
6153
6478
|
} catch {
|
|
6154
6479
|
return null;
|
|
6155
6480
|
}
|
|
@@ -6407,19 +6732,19 @@ async function preCompactHook(deps = {}) {
|
|
|
6407
6732
|
}
|
|
6408
6733
|
|
|
6409
6734
|
// src/hooks/runtime/user-prompt-submit.ts
|
|
6410
|
-
import { existsSync as
|
|
6411
|
-
import { homedir as
|
|
6412
|
-
import { join as
|
|
6735
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync4, readFileSync as readFileSync11, writeFileSync as writeFileSync6 } from "node:fs";
|
|
6736
|
+
import { homedir as homedir8 } from "node:os";
|
|
6737
|
+
import { join as join8 } from "node:path";
|
|
6413
6738
|
var SESSIONS_CAP = 100;
|
|
6414
6739
|
function defaultSessionsFile() {
|
|
6415
|
-
const dir = process.env.CYBEDEFEND_BASELINE_DIR ??
|
|
6416
|
-
return
|
|
6740
|
+
const dir = process.env.CYBEDEFEND_BASELINE_DIR ?? join8(homedir8(), ".cybedefend");
|
|
6741
|
+
return join8(dir, "user-prompt-seen-sessions.json");
|
|
6417
6742
|
}
|
|
6418
6743
|
function defaultSessionTracker(file = defaultSessionsFile()) {
|
|
6419
6744
|
function load() {
|
|
6420
|
-
if (!
|
|
6745
|
+
if (!existsSync11(file)) return [];
|
|
6421
6746
|
try {
|
|
6422
|
-
const raw =
|
|
6747
|
+
const raw = readFileSync11(file, "utf8");
|
|
6423
6748
|
const data = JSON.parse(raw);
|
|
6424
6749
|
if (!Array.isArray(data.sessions)) return [];
|
|
6425
6750
|
return data.sessions.filter((s) => typeof s === "string");
|
|
@@ -6436,8 +6761,8 @@ function defaultSessionTracker(file = defaultSessionsFile()) {
|
|
|
6436
6761
|
if (existing.includes(sessionId)) return;
|
|
6437
6762
|
const next = [...existing, sessionId].slice(-SESSIONS_CAP);
|
|
6438
6763
|
try {
|
|
6439
|
-
mkdirSync4(
|
|
6440
|
-
|
|
6764
|
+
mkdirSync4(join8(file, ".."), { recursive: true });
|
|
6765
|
+
writeFileSync6(file, JSON.stringify({ sessions: next }), "utf8");
|
|
6441
6766
|
} catch {
|
|
6442
6767
|
}
|
|
6443
6768
|
}
|
|
@@ -6462,7 +6787,9 @@ async function userPromptSubmitHook(deps = {}) {
|
|
|
6462
6787
|
const { projectId, apiBase: configApiBase } = await resolveProject();
|
|
6463
6788
|
if (!projectId) return;
|
|
6464
6789
|
const apiBase = process.env.CYBEDEFEND_API_BASE ?? configApiBase ?? config.region.apiBase;
|
|
6465
|
-
const token = resolveTok(config.region.mcpName
|
|
6790
|
+
const token = resolveTok(config.region.mcpName, {
|
|
6791
|
+
mcpUrl: config.region.mcpUrl
|
|
6792
|
+
});
|
|
6466
6793
|
let total = null;
|
|
6467
6794
|
if (token) {
|
|
6468
6795
|
const result = await fetchProposals({ apiBase, projectId, token });
|
|
@@ -6719,7 +7046,7 @@ function bucketRules(rules) {
|
|
|
6719
7046
|
}
|
|
6720
7047
|
|
|
6721
7048
|
// src/guards-evaluator/preprocess.ts
|
|
6722
|
-
var
|
|
7049
|
+
var import_shell_quote2 = __toESM(require_shell_quote(), 1);
|
|
6723
7050
|
var PLACEHOLDER = "<DATA>";
|
|
6724
7051
|
var DATA_BEARING_CONTEXTS = {
|
|
6725
7052
|
git: /* @__PURE__ */ new Set(["commit", "tag", "notes", "stash", "merge", "cherry-pick", "revert"]),
|
|
@@ -6738,7 +7065,7 @@ var DATA_FLAGS_VALUE = /* @__PURE__ */ new Set([
|
|
|
6738
7065
|
]);
|
|
6739
7066
|
var DATA_FLAGS_EQUAL = ["--message=", "--file=", "--body=", "--body-file="];
|
|
6740
7067
|
var SHELL_OPS = /* @__PURE__ */ new Set([";", "&&", "||", "|", "|&", "&", ">", ">>", "<", "(", ")"]);
|
|
6741
|
-
var
|
|
7068
|
+
var HEREDOC_OPEN2 = /^<<-?\s*(['"]?)([A-Za-z_][A-Za-z0-9_]*)\1/;
|
|
6742
7069
|
function isExecutableValue(tok) {
|
|
6743
7070
|
return tok.startsWith("$(") || tok.startsWith("<(") || tok.startsWith(">(") || tok.includes("`");
|
|
6744
7071
|
}
|
|
@@ -6751,7 +7078,7 @@ function stripDataArgs(command) {
|
|
|
6751
7078
|
tokens = command.slice();
|
|
6752
7079
|
} else {
|
|
6753
7080
|
try {
|
|
6754
|
-
tokens = (0,
|
|
7081
|
+
tokens = (0, import_shell_quote2.parse)(command, (key) => "$" + key);
|
|
6755
7082
|
} catch {
|
|
6756
7083
|
return command;
|
|
6757
7084
|
}
|
|
@@ -6792,7 +7119,7 @@ function stripDataArgs(command) {
|
|
|
6792
7119
|
const contextSubcommands = segmentTopCmd ? DATA_BEARING_CONTEXTS[segmentTopCmd] : void 0;
|
|
6793
7120
|
const inDataBearingContext = contextSubcommands === null || contextSubcommands !== void 0 && segmentSubCmd !== null && contextSubcommands.has(segmentSubCmd);
|
|
6794
7121
|
if (inDataBearingContext) {
|
|
6795
|
-
const heredoc =
|
|
7122
|
+
const heredoc = HEREDOC_OPEN2.exec(tok);
|
|
6796
7123
|
if (heredoc) {
|
|
6797
7124
|
const delim = heredoc[2];
|
|
6798
7125
|
const closes = (t) => t === delim || t.endsWith("\n" + delim);
|
|
@@ -7120,7 +7447,7 @@ function validateRule(rule) {
|
|
|
7120
7447
|
}
|
|
7121
7448
|
|
|
7122
7449
|
// src/guards-evaluator/redact.ts
|
|
7123
|
-
import { createHash } from "node:crypto";
|
|
7450
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
7124
7451
|
var REDACTED = "[REDACTED]";
|
|
7125
7452
|
var PATTERNS = [
|
|
7126
7453
|
// 1. JWT — three base64url segments separated by dots
|
|
@@ -7222,7 +7549,7 @@ function redactTarget(text, maxLen = 256) {
|
|
|
7222
7549
|
return result;
|
|
7223
7550
|
}
|
|
7224
7551
|
function hashTarget(text) {
|
|
7225
|
-
return
|
|
7552
|
+
return createHash2("sha256").update(text, "utf8").digest("hex");
|
|
7226
7553
|
}
|
|
7227
7554
|
|
|
7228
7555
|
// src/hooks/runtime/near-miss.ts
|
|
@@ -7500,10 +7827,10 @@ function nearMiss(req, rule) {
|
|
|
7500
7827
|
}
|
|
7501
7828
|
|
|
7502
7829
|
// src/hooks/runtime/guard-rules-cache.ts
|
|
7503
|
-
import { readFileSync as
|
|
7504
|
-
import { dirname as
|
|
7505
|
-
import { homedir as
|
|
7506
|
-
import { join as
|
|
7830
|
+
import { readFileSync as readFileSync12, writeFileSync as writeFileSync7, existsSync as existsSync12, mkdirSync as mkdirSync5 } from "node:fs";
|
|
7831
|
+
import { dirname as dirname5 } from "node:path";
|
|
7832
|
+
import { homedir as homedir9 } from "node:os";
|
|
7833
|
+
import { join as join9 } from "node:path";
|
|
7507
7834
|
|
|
7508
7835
|
// node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
|
|
7509
7836
|
var external_exports = {};
|
|
@@ -11615,8 +11942,8 @@ function parseRuleFields(raw) {
|
|
|
11615
11942
|
}
|
|
11616
11943
|
|
|
11617
11944
|
// src/hooks/runtime/guard-rules-cache.ts
|
|
11618
|
-
var DEFAULT_CACHE_FILE =
|
|
11619
|
-
|
|
11945
|
+
var DEFAULT_CACHE_FILE = join9(
|
|
11946
|
+
homedir9(),
|
|
11620
11947
|
".cybedefend",
|
|
11621
11948
|
"guards-cache.json"
|
|
11622
11949
|
);
|
|
@@ -11740,9 +12067,9 @@ function makeGuardRulesCache(opts) {
|
|
|
11740
12067
|
}
|
|
11741
12068
|
}
|
|
11742
12069
|
function readCache(projectId) {
|
|
11743
|
-
if (!
|
|
12070
|
+
if (!existsSync12(cacheFile)) return null;
|
|
11744
12071
|
try {
|
|
11745
|
-
const raw =
|
|
12072
|
+
const raw = readFileSync12(cacheFile, "utf8");
|
|
11746
12073
|
const data = JSON.parse(raw);
|
|
11747
12074
|
if (data.projectId !== projectId) return null;
|
|
11748
12075
|
return data;
|
|
@@ -11753,15 +12080,15 @@ function makeGuardRulesCache(opts) {
|
|
|
11753
12080
|
function writeCache(entry) {
|
|
11754
12081
|
try {
|
|
11755
12082
|
ensureDirFor2(cacheFile);
|
|
11756
|
-
|
|
12083
|
+
writeFileSync7(cacheFile, JSON.stringify(entry), "utf8");
|
|
11757
12084
|
} catch {
|
|
11758
12085
|
}
|
|
11759
12086
|
}
|
|
11760
12087
|
return { refreshIfStale };
|
|
11761
12088
|
}
|
|
11762
12089
|
function ensureDirFor2(filePath) {
|
|
11763
|
-
const dir =
|
|
11764
|
-
if (!
|
|
12090
|
+
const dir = dirname5(filePath);
|
|
12091
|
+
if (!existsSync12(dir)) {
|
|
11765
12092
|
mkdirSync5(dir, { recursive: true });
|
|
11766
12093
|
}
|
|
11767
12094
|
}
|
|
@@ -11883,11 +12210,11 @@ function detectPromptInjection(text) {
|
|
|
11883
12210
|
}
|
|
11884
12211
|
|
|
11885
12212
|
// src/hooks/runtime/judge-cache.ts
|
|
11886
|
-
import { readFileSync as
|
|
11887
|
-
import { dirname as
|
|
11888
|
-
import { homedir as
|
|
11889
|
-
var DEFAULT_JUDGE_CACHE_FILE =
|
|
11890
|
-
|
|
12213
|
+
import { readFileSync as readFileSync13, writeFileSync as writeFileSync8, existsSync as existsSync13, mkdirSync as mkdirSync6 } from "node:fs";
|
|
12214
|
+
import { dirname as dirname6, join as join10 } from "node:path";
|
|
12215
|
+
import { homedir as homedir10 } from "node:os";
|
|
12216
|
+
var DEFAULT_JUDGE_CACHE_FILE = join10(
|
|
12217
|
+
homedir10(),
|
|
11891
12218
|
".cybedefend",
|
|
11892
12219
|
"guards-judge-cache.json"
|
|
11893
12220
|
);
|
|
@@ -11897,9 +12224,9 @@ function makeJudgeCache(opts = {}) {
|
|
|
11897
12224
|
const ttlMs = opts.ttlMs ?? DEFAULT_JUDGE_TTL_MS;
|
|
11898
12225
|
const now = opts.now ?? (() => Date.now());
|
|
11899
12226
|
function readAll() {
|
|
11900
|
-
if (!
|
|
12227
|
+
if (!existsSync13(cacheFile)) return {};
|
|
11901
12228
|
try {
|
|
11902
|
-
return JSON.parse(
|
|
12229
|
+
return JSON.parse(readFileSync13(cacheFile, "utf8"));
|
|
11903
12230
|
} catch {
|
|
11904
12231
|
return {};
|
|
11905
12232
|
}
|
|
@@ -11919,36 +12246,36 @@ function makeJudgeCache(opts = {}) {
|
|
|
11919
12246
|
}
|
|
11920
12247
|
all[key] = { res, at: t };
|
|
11921
12248
|
ensureDirFor3(cacheFile);
|
|
11922
|
-
|
|
12249
|
+
writeFileSync8(cacheFile, JSON.stringify(all), "utf8");
|
|
11923
12250
|
} catch {
|
|
11924
12251
|
}
|
|
11925
12252
|
}
|
|
11926
12253
|
return { get, set };
|
|
11927
12254
|
}
|
|
11928
12255
|
function ensureDirFor3(filePath) {
|
|
11929
|
-
const dir =
|
|
11930
|
-
if (!
|
|
12256
|
+
const dir = dirname6(filePath);
|
|
12257
|
+
if (!existsSync13(dir)) {
|
|
11931
12258
|
mkdirSync6(dir, { recursive: true });
|
|
11932
12259
|
}
|
|
11933
12260
|
}
|
|
11934
12261
|
|
|
11935
12262
|
// src/hooks/runtime/guard-check.ts
|
|
11936
|
-
import { homedir as
|
|
11937
|
-
import { join as
|
|
12263
|
+
import { homedir as homedir12 } from "node:os";
|
|
12264
|
+
import { join as join12 } from "node:path";
|
|
11938
12265
|
|
|
11939
12266
|
// src/hooks/runtime/guard-violations-buffer.ts
|
|
11940
12267
|
import {
|
|
11941
12268
|
appendFileSync,
|
|
11942
|
-
existsSync as
|
|
11943
|
-
readFileSync as
|
|
11944
|
-
writeFileSync as
|
|
12269
|
+
existsSync as existsSync14,
|
|
12270
|
+
readFileSync as readFileSync14,
|
|
12271
|
+
writeFileSync as writeFileSync9,
|
|
11945
12272
|
mkdirSync as mkdirSync7
|
|
11946
12273
|
} from "node:fs";
|
|
11947
|
-
import { dirname as
|
|
11948
|
-
import { homedir as
|
|
11949
|
-
import { join as
|
|
11950
|
-
var DEFAULT_BUFFER_FILE =
|
|
11951
|
-
|
|
12274
|
+
import { dirname as dirname7 } from "node:path";
|
|
12275
|
+
import { homedir as homedir11 } from "node:os";
|
|
12276
|
+
import { join as join11 } from "node:path";
|
|
12277
|
+
var DEFAULT_BUFFER_FILE = join11(
|
|
12278
|
+
homedir11(),
|
|
11952
12279
|
".cybedefend",
|
|
11953
12280
|
"guards-violations-buffer.jsonl"
|
|
11954
12281
|
);
|
|
@@ -11967,10 +12294,10 @@ function makeViolationsBuffer(opts = {}) {
|
|
|
11967
12294
|
}
|
|
11968
12295
|
}
|
|
11969
12296
|
async function flushViolations2(ctx, postFn) {
|
|
11970
|
-
if (!
|
|
12297
|
+
if (!existsSync14(bufferFile)) return;
|
|
11971
12298
|
let content;
|
|
11972
12299
|
try {
|
|
11973
|
-
content =
|
|
12300
|
+
content = readFileSync14(bufferFile, "utf8").trim();
|
|
11974
12301
|
} catch {
|
|
11975
12302
|
return;
|
|
11976
12303
|
}
|
|
@@ -11989,7 +12316,7 @@ function makeViolationsBuffer(opts = {}) {
|
|
|
11989
12316
|
}
|
|
11990
12317
|
if (records.length === 0) {
|
|
11991
12318
|
try {
|
|
11992
|
-
|
|
12319
|
+
writeFileSync9(bufferFile, "", "utf8");
|
|
11993
12320
|
} catch {
|
|
11994
12321
|
}
|
|
11995
12322
|
return;
|
|
@@ -12019,10 +12346,10 @@ function makeViolationsBuffer(opts = {}) {
|
|
|
12019
12346
|
}
|
|
12020
12347
|
try {
|
|
12021
12348
|
if (failed.length === 0) {
|
|
12022
|
-
|
|
12349
|
+
writeFileSync9(bufferFile, "", "utf8");
|
|
12023
12350
|
} else {
|
|
12024
12351
|
const serialised = failed.map((r) => JSON.stringify(r)).join("\n") + "\n";
|
|
12025
|
-
|
|
12352
|
+
writeFileSync9(bufferFile, serialised, "utf8");
|
|
12026
12353
|
}
|
|
12027
12354
|
} catch {
|
|
12028
12355
|
}
|
|
@@ -12030,8 +12357,8 @@ function makeViolationsBuffer(opts = {}) {
|
|
|
12030
12357
|
return { bufferViolation: bufferViolation2, flushViolations: flushViolations2 };
|
|
12031
12358
|
}
|
|
12032
12359
|
function ensureDirFor4(filePath) {
|
|
12033
|
-
const dir =
|
|
12034
|
-
if (!
|
|
12360
|
+
const dir = dirname7(filePath);
|
|
12361
|
+
if (!existsSync14(dir)) {
|
|
12035
12362
|
mkdirSync7(dir, { recursive: true });
|
|
12036
12363
|
}
|
|
12037
12364
|
}
|
|
@@ -12059,10 +12386,10 @@ function appendDebugLog(entry) {
|
|
|
12059
12386
|
const homeDir = process.env.HOME ?? process.env.USERPROFILE ?? "";
|
|
12060
12387
|
if (!homeDir) return;
|
|
12061
12388
|
const { mkdirSync: mkdirSync8, appendFileSync: appendFileSync2 } = __require("node:fs");
|
|
12062
|
-
const { join:
|
|
12063
|
-
const dir =
|
|
12389
|
+
const { join: join13 } = __require("node:path");
|
|
12390
|
+
const dir = join13(homeDir, ".cybedefend");
|
|
12064
12391
|
mkdirSync8(dir, { recursive: true });
|
|
12065
|
-
appendFileSync2(
|
|
12392
|
+
appendFileSync2(join13(dir, "hook-debug.log"), entry + "\n", "utf8");
|
|
12066
12393
|
} catch {
|
|
12067
12394
|
}
|
|
12068
12395
|
}
|
|
@@ -12548,8 +12875,6 @@ function emitAgentMessage(verdict, message) {
|
|
|
12548
12875
|
// Claude Code legacy
|
|
12549
12876
|
decision: "block",
|
|
12550
12877
|
reason: fullMessage,
|
|
12551
|
-
continue: false,
|
|
12552
|
-
stopReason: fullMessage,
|
|
12553
12878
|
// Claude Code modern
|
|
12554
12879
|
hookSpecificOutput: {
|
|
12555
12880
|
hookEventName: "PreToolUse",
|
|
@@ -12578,9 +12903,9 @@ function emitAgentMessage(verdict, message) {
|
|
|
12578
12903
|
}
|
|
12579
12904
|
function makeProductionJudgeDeps() {
|
|
12580
12905
|
const cache = makeJudgeCache();
|
|
12581
|
-
const warnDir = process.env.CYBEDEFEND_BASELINE_DIR ??
|
|
12906
|
+
const warnDir = process.env.CYBEDEFEND_BASELINE_DIR ?? join12(homedir12(), ".cybedefend");
|
|
12582
12907
|
const warnTracker = defaultSessionTracker(
|
|
12583
|
-
|
|
12908
|
+
join12(warnDir, "guards-judge-warned-sessions.json")
|
|
12584
12909
|
);
|
|
12585
12910
|
return {
|
|
12586
12911
|
callJudge,
|
|
@@ -12605,7 +12930,11 @@ async function runPreToolUseGuard() {
|
|
|
12605
12930
|
const { projectId, apiBase: configApiBase } = await resolveProjectIdWithApi();
|
|
12606
12931
|
if (!projectId) return 0;
|
|
12607
12932
|
const apiBaseResolved = process.env.CYBEDEFEND_API_BASE ?? configApiBase ?? config.region.apiBase;
|
|
12608
|
-
const token = await resolveTokenWithRefresh(
|
|
12933
|
+
const token = await resolveTokenWithRefresh(
|
|
12934
|
+
config.region.mcpName,
|
|
12935
|
+
{},
|
|
12936
|
+
{ mcpUrl: config.region.mcpUrl }
|
|
12937
|
+
);
|
|
12609
12938
|
if (!token) {
|
|
12610
12939
|
emitUnverifiedBanner(
|
|
12611
12940
|
"Not authenticated \u2014 run `vibedefend login` to restore Action Guards."
|