@akasecurity/ai-tc-codex 0.9.16 → 0.9.17
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/.codex-plugin/plugin.json +1 -1
- package/package.json +6 -6
- package/scripts/apply-suppressions.js +739 -1263
- package/scripts/backfill.js +1040 -1291
- package/scripts/content-retention.js +781 -2074
- package/scripts/filescan.js +1266 -497
- package/scripts/firstrun.js +1277 -1701
- package/scripts/history-sync.js +777 -2107
- package/scripts/intro.js +141 -2190
- package/scripts/onboard.js +2806 -1186
- package/scripts/post-tool-use.js +1512 -1728
- package/scripts/pre-tool-use.js +1094 -1319
- package/scripts/query.js +1277 -1701
- package/scripts/reconcile.js +897 -1288
- package/scripts/remediate.js +1081 -1341
- package/scripts/scan-worker.js +147 -14
- package/scripts/session-start.js +1895 -827
- package/scripts/start-light.js +176 -1360
- package/scripts/stop.js +322 -1113
- package/scripts/sync.js +1818 -1029
- package/scripts/user-prompt-submit.js +1295 -1489
package/scripts/stop.js
CHANGED
|
@@ -1,888 +1,12 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
-
try {
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
} catch (e) {
|
|
11
|
-
throw mod = 0, e;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
2
|
var __export = (target, all) => {
|
|
15
3
|
for (var name in all)
|
|
16
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
5
|
};
|
|
18
|
-
var __copyProps = (to, from, except, desc) => {
|
|
19
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
-
for (let key of __getOwnPropNames(from))
|
|
21
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
-
}
|
|
24
|
-
return to;
|
|
25
|
-
};
|
|
26
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
32
|
-
mod
|
|
33
|
-
));
|
|
34
|
-
|
|
35
|
-
// ../../node_modules/.pnpm/ignore@7.0.11/node_modules/ignore/index.js
|
|
36
|
-
var require_ignore = __commonJS({
|
|
37
|
-
"../../node_modules/.pnpm/ignore@7.0.11/node_modules/ignore/index.js"(exports, module) {
|
|
38
|
-
"use strict";
|
|
39
|
-
function makeArray(subject) {
|
|
40
|
-
return Array.isArray(subject) ? subject : [subject];
|
|
41
|
-
}
|
|
42
|
-
var UNDEFINED = void 0;
|
|
43
|
-
var EMPTY = "";
|
|
44
|
-
var SPACE = " ";
|
|
45
|
-
var ESCAPE = "\\";
|
|
46
|
-
var REGEX_LITERAL_SPECIAL = /[.*+?()[\]{}^$|\\/]/;
|
|
47
|
-
var REGEX_TEST_BLANK_LINE = /^\uFEFF? *$/;
|
|
48
|
-
var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
|
|
49
|
-
var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
|
50
|
-
var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
|
|
51
|
-
var REGEX_SPLITALL_CRLF = /\r?\n/g;
|
|
52
|
-
var DOUBLE_SLASH = "//";
|
|
53
|
-
var SLASH_CODE = 47;
|
|
54
|
-
var DOT_CODE = 46;
|
|
55
|
-
var SLASH3 = "/";
|
|
56
|
-
var TMP_KEY_IGNORE = "node-ignore";
|
|
57
|
-
if (typeof Symbol !== "undefined") {
|
|
58
|
-
TMP_KEY_IGNORE = /* @__PURE__ */ Symbol.for("node-ignore");
|
|
59
|
-
}
|
|
60
|
-
var KEY_IGNORE = TMP_KEY_IGNORE;
|
|
61
|
-
var define = (object2, key, value) => {
|
|
62
|
-
Object.defineProperty(object2, key, { value });
|
|
63
|
-
return value;
|
|
64
|
-
};
|
|
65
|
-
var RETURN_FALSE = () => false;
|
|
66
|
-
var cleanRangeBackSlash = (slashes) => {
|
|
67
|
-
const { length } = slashes;
|
|
68
|
-
return slashes.slice(0, length - length % 2);
|
|
69
|
-
};
|
|
70
|
-
var POSIX_CLASSES = {
|
|
71
|
-
alnum: "0-9A-Za-z",
|
|
72
|
-
alpha: "A-Za-z",
|
|
73
|
-
blank: " \\t",
|
|
74
|
-
cntrl: "\\x00-\\x1f\\x7f",
|
|
75
|
-
digit: "0-9",
|
|
76
|
-
graph: "!-.0-~",
|
|
77
|
-
lower: "a-z",
|
|
78
|
-
print: " -.0-~",
|
|
79
|
-
punct: "!-.:-@\\[-`{-~",
|
|
80
|
-
// git's `sane-ctype.h` classifies \v and \f as control, not space,
|
|
81
|
-
// unlike C's `isspace`
|
|
82
|
-
space: " \\t\\n\\r",
|
|
83
|
-
upper: "A-Z",
|
|
84
|
-
xdigit: "0-9A-Fa-f"
|
|
85
|
-
};
|
|
86
|
-
var CLASS_MEMBERS_TO_ESCAPE = "\\]^-[";
|
|
87
|
-
var escapeMember = (char) => CLASS_MEMBERS_TO_ESCAPE.indexOf(char) < 0 ? char : ESCAPE + char;
|
|
88
|
-
var NON_SLASH = "(?!\\/)";
|
|
89
|
-
var classSource = (negated, body) => {
|
|
90
|
-
if (negated) {
|
|
91
|
-
return `[^\\/${body}]`;
|
|
92
|
-
}
|
|
93
|
-
const source = `[${body}]`;
|
|
94
|
-
return new RegExp(source).test("/") ? NON_SLASH + source : source;
|
|
95
|
-
};
|
|
96
|
-
var scanBracket = (pattern, start) => {
|
|
97
|
-
const { length } = pattern;
|
|
98
|
-
let index = start + 1;
|
|
99
|
-
let negated = EMPTY;
|
|
100
|
-
const lead = pattern[index];
|
|
101
|
-
if (lead === "!" || lead === "^") {
|
|
102
|
-
negated = "^";
|
|
103
|
-
index++;
|
|
104
|
-
}
|
|
105
|
-
let body = EMPTY;
|
|
106
|
-
let prev = EMPTY;
|
|
107
|
-
for (; ; ) {
|
|
108
|
-
const char = pattern[index];
|
|
109
|
-
if (char === UNDEFINED) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
if (char === ESCAPE) {
|
|
113
|
-
const escaped = pattern[index + 1];
|
|
114
|
-
if (escaped === UNDEFINED) {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
body += escapeMember(escaped);
|
|
118
|
-
prev = escaped;
|
|
119
|
-
index++;
|
|
120
|
-
} else if (char === "-" && prev && index + 1 < length && pattern[index + 1] !== "]") {
|
|
121
|
-
index++;
|
|
122
|
-
let to = pattern[index];
|
|
123
|
-
if (to === ESCAPE) {
|
|
124
|
-
to = pattern[index += 1];
|
|
125
|
-
}
|
|
126
|
-
if (prev <= to) {
|
|
127
|
-
body += `-${escapeMember(to)}`;
|
|
128
|
-
}
|
|
129
|
-
prev = EMPTY;
|
|
130
|
-
} else if (char === "[" && pattern[index + 1] === ":") {
|
|
131
|
-
const nameStart = index + 2;
|
|
132
|
-
let end = nameStart;
|
|
133
|
-
while (end < length && pattern[end] !== "]") {
|
|
134
|
-
end++;
|
|
135
|
-
}
|
|
136
|
-
if (end === length) {
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
if (end > nameStart && pattern[end - 1] === ":") {
|
|
140
|
-
const expanded = POSIX_CLASSES[pattern.slice(nameStart, end - 1)];
|
|
141
|
-
if (expanded === UNDEFINED) {
|
|
142
|
-
return null;
|
|
143
|
-
}
|
|
144
|
-
body += expanded;
|
|
145
|
-
prev = EMPTY;
|
|
146
|
-
index = end;
|
|
147
|
-
} else {
|
|
148
|
-
body += escapeMember("[");
|
|
149
|
-
prev = "[";
|
|
150
|
-
index = nameStart - 2;
|
|
151
|
-
}
|
|
152
|
-
} else {
|
|
153
|
-
body += escapeMember(char);
|
|
154
|
-
prev = char;
|
|
155
|
-
}
|
|
156
|
-
index++;
|
|
157
|
-
if (pattern[index] === "]") {
|
|
158
|
-
return {
|
|
159
|
-
end: index,
|
|
160
|
-
source: classSource(negated, body)
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
var NEVER_MATCH = "[]";
|
|
166
|
-
var PLACEHOLDER = "\0";
|
|
167
|
-
var REGEX_RESTORE_PLACEHOLDER = new RegExp(
|
|
168
|
-
`${PLACEHOLDER}(\\d+)${PLACEHOLDER}`,
|
|
169
|
-
"g"
|
|
170
|
-
);
|
|
171
|
-
var TRAILING_WILDCARD = "\uE000";
|
|
172
|
-
var TRAILING_DOUBLESTAR = "\uE001";
|
|
173
|
-
var extractBrackets = (pattern) => {
|
|
174
|
-
const sources = [];
|
|
175
|
-
const hold = (source) => `${PLACEHOLDER}${sources.push(source) - 1}${PLACEHOLDER}`;
|
|
176
|
-
const { length } = pattern;
|
|
177
|
-
let out = EMPTY;
|
|
178
|
-
let index = 0;
|
|
179
|
-
while (index < length) {
|
|
180
|
-
const char = pattern[index];
|
|
181
|
-
if (char === ESCAPE) {
|
|
182
|
-
const escaped = pattern[index + 1];
|
|
183
|
-
if (escaped === "*" || escaped === "[" || escaped === SPACE || escaped === ESCAPE) {
|
|
184
|
-
out += pattern.slice(index, index + 2);
|
|
185
|
-
} else {
|
|
186
|
-
out += hold(
|
|
187
|
-
REGEX_LITERAL_SPECIAL.test(escaped) ? ESCAPE + escaped : escaped
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
index += 2;
|
|
191
|
-
} else if (char === PLACEHOLDER) {
|
|
192
|
-
out += hold(`[${PLACEHOLDER}]`);
|
|
193
|
-
index++;
|
|
194
|
-
} else if (char === "[") {
|
|
195
|
-
const scanned = scanBracket(pattern, index);
|
|
196
|
-
if (scanned === null) {
|
|
197
|
-
out += hold(NEVER_MATCH);
|
|
198
|
-
index = length;
|
|
199
|
-
} else {
|
|
200
|
-
out += hold(scanned.source);
|
|
201
|
-
index = scanned.end + 1;
|
|
202
|
-
}
|
|
203
|
-
} else {
|
|
204
|
-
out += char;
|
|
205
|
-
index++;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
return {
|
|
209
|
-
source: out,
|
|
210
|
-
sources
|
|
211
|
-
};
|
|
212
|
-
};
|
|
213
|
-
var DIRECT = null;
|
|
214
|
-
var REGEX_INNER_SLASH = /\/(?!$)/;
|
|
215
|
-
var REPLACERS = [
|
|
216
|
-
[
|
|
217
|
-
// Remove BOM
|
|
218
|
-
// TODO:
|
|
219
|
-
// Other similar zero-width characters?
|
|
220
|
-
/^\uFEFF/,
|
|
221
|
-
() => EMPTY,
|
|
222
|
-
"\uFEFF"
|
|
223
|
-
],
|
|
224
|
-
[
|
|
225
|
-
// A trailing line terminator, left on when a whole file's contents are
|
|
226
|
-
// added as one pattern rather than split into lines. git never sees one
|
|
227
|
-
// -- it reads a `.gitignore` line by line -- so it is not part of the
|
|
228
|
-
// pattern and is dropped here, apart from the trailing-space trimming,
|
|
229
|
-
// which follows git in touching spaces and nothing else.
|
|
230
|
-
/[\r\n]+$/,
|
|
231
|
-
() => EMPTY
|
|
232
|
-
],
|
|
233
|
-
// > Trailing spaces are ignored unless they are quoted with backslash ("\")
|
|
234
|
-
[
|
|
235
|
-
// Only spaces, never tabs or other whitespace: git trims a trailing run
|
|
236
|
-
// of `' '` and nothing else (dir.c, `trim_trailing_spaces`, a single
|
|
237
|
-
// `case ' '`), so a pattern ending in a tab keeps it as a literal.
|
|
238
|
-
// (a\ ) -> (a )
|
|
239
|
-
// (a ) -> (a)
|
|
240
|
-
// (a ) -> (a)
|
|
241
|
-
// (a \ ) -> (a )
|
|
242
|
-
/((?:\\\\)*?)(\\? +)$/,
|
|
243
|
-
(_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY)
|
|
244
|
-
],
|
|
245
|
-
// Replace (\ ) with ' '
|
|
246
|
-
// Only a space: an escaped tab or other whitespace is already a literal by
|
|
247
|
-
// the time it reaches here, and a bare tab must be left as one, not turned
|
|
248
|
-
// into a space.
|
|
249
|
-
// (\ ) -> ' '
|
|
250
|
-
// (\\ ) -> '\\ '
|
|
251
|
-
// (\\\ ) -> '\\ '
|
|
252
|
-
[
|
|
253
|
-
/(\\+?) /g,
|
|
254
|
-
(_, m1) => {
|
|
255
|
-
const { length } = m1;
|
|
256
|
-
return m1.slice(0, length - length % 2) + SPACE;
|
|
257
|
-
}
|
|
258
|
-
],
|
|
259
|
-
// Escape metacharacters
|
|
260
|
-
// which is written down by users but means special for regular expressions.
|
|
261
|
-
// > There are 12 characters with special meanings:
|
|
262
|
-
// > - the backslash \,
|
|
263
|
-
// > - the caret ^,
|
|
264
|
-
// > - the dollar sign $,
|
|
265
|
-
// > - the period or dot .,
|
|
266
|
-
// > - the vertical bar or pipe symbol |,
|
|
267
|
-
// > - the question mark ?,
|
|
268
|
-
// > - the asterisk or star *,
|
|
269
|
-
// > - the plus sign +,
|
|
270
|
-
// > - the opening parenthesis (,
|
|
271
|
-
// > - the closing parenthesis ),
|
|
272
|
-
// > - and the opening square bracket [,
|
|
273
|
-
// > - the opening curly brace {,
|
|
274
|
-
// > These special characters are often called "metacharacters".
|
|
275
|
-
[
|
|
276
|
-
/[\\$.|*+(){^]/g,
|
|
277
|
-
(match) => `\\${match}`
|
|
278
|
-
],
|
|
279
|
-
[
|
|
280
|
-
// > a question mark (?) matches a single character
|
|
281
|
-
/(?!\\)\?/g,
|
|
282
|
-
() => "[^/]",
|
|
283
|
-
"?"
|
|
284
|
-
],
|
|
285
|
-
// leading slash
|
|
286
|
-
[
|
|
287
|
-
// > A leading slash matches the beginning of the pathname.
|
|
288
|
-
// > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
|
|
289
|
-
// A leading slash matches the beginning of the pathname
|
|
290
|
-
/^\//,
|
|
291
|
-
() => "^",
|
|
292
|
-
SLASH3
|
|
293
|
-
],
|
|
294
|
-
// replace special metacharacter slash after the leading slash
|
|
295
|
-
[
|
|
296
|
-
/\//g,
|
|
297
|
-
() => "\\/",
|
|
298
|
-
SLASH3
|
|
299
|
-
],
|
|
300
|
-
[
|
|
301
|
-
// > A leading "**" followed by a slash means match in all directories.
|
|
302
|
-
// > For example, "**/foo" matches file or directory "foo" anywhere,
|
|
303
|
-
// > the same as pattern "foo".
|
|
304
|
-
// > "**/foo/bar" matches file or directory "bar" anywhere that is directly
|
|
305
|
-
// > under directory "foo".
|
|
306
|
-
// Notice that the '*'s have been replaced as '\\*'
|
|
307
|
-
/^\^*(?:\\\*\\\*\\\/)+/,
|
|
308
|
-
// '**/foo' <-> 'foo'
|
|
309
|
-
() => "^(?:.*\\/)?",
|
|
310
|
-
"*"
|
|
311
|
-
],
|
|
312
|
-
// starting
|
|
313
|
-
[
|
|
314
|
-
// there will be no leading '/'
|
|
315
|
-
// (which has been replaced by section "leading slash")
|
|
316
|
-
// If starts with '**', adding a '^' to the regular expression also works
|
|
317
|
-
DIRECT,
|
|
318
|
-
(source, pattern) => {
|
|
319
|
-
if (!source || source[0] === "^") {
|
|
320
|
-
return source;
|
|
321
|
-
}
|
|
322
|
-
const anchor2 = !REGEX_INNER_SLASH.test(pattern) ? "(?:^|\\/)" : "^";
|
|
323
|
-
return anchor2 + source;
|
|
324
|
-
}
|
|
325
|
-
],
|
|
326
|
-
// two globstars
|
|
327
|
-
[
|
|
328
|
-
// Use lookahead assertions so that we could match more than one `'/**'`
|
|
329
|
-
/\\\/\\\*\\\*(?=\\\/|$)/g,
|
|
330
|
-
// Zero, one or several directories
|
|
331
|
-
// should not use '*', or it will be replaced by the next replacer
|
|
332
|
-
// Check if it is not the last `'/**'`
|
|
333
|
-
(_, index, str) => index + 6 < str.length ? str.slice(index + 6) === "\\/" ? "(?:\\/[^\\/]+)+" : "(?:\\/[^\\/]+)*" : `\\/${TRAILING_DOUBLESTAR}`,
|
|
334
|
-
"*"
|
|
335
|
-
],
|
|
336
|
-
// normal intermediate wildcards
|
|
337
|
-
[
|
|
338
|
-
// Never replace escaped '*'
|
|
339
|
-
// ignore rule '\*' will match the path '*'
|
|
340
|
-
// 'abc.*/' -> go
|
|
341
|
-
// 'abc.*' -> skip this rule,
|
|
342
|
-
// coz trailing single wildcard will be handed by [trailing wildcard]
|
|
343
|
-
/(^|[^\\]+)(\\\*)+(?=.+)/g,
|
|
344
|
-
// '*.js' matches '.js'
|
|
345
|
-
// '*.js' doesn't match 'abc'
|
|
346
|
-
(_, p1, p2) => {
|
|
347
|
-
const unescaped = p2.replace(/\\\*/g, "[^\\/]*");
|
|
348
|
-
return p1 + unescaped;
|
|
349
|
-
},
|
|
350
|
-
"*"
|
|
351
|
-
],
|
|
352
|
-
// trailing wildcard, held apart from a literal star
|
|
353
|
-
[
|
|
354
|
-
// The step above leaves a trailing `*` alone, so a single `\*` is all that
|
|
355
|
-
// can be left at the end here. Whether it is a wildcard or a literal
|
|
356
|
-
// turns on the backslashes the user put in front of it: the escaper has
|
|
357
|
-
// since doubled every one, so what stands here is those `2N` doubled
|
|
358
|
-
// backslashes and then the star's own escape. An even number of the
|
|
359
|
-
// original `N` leaves the star unescaped -- a wildcard -- and an odd
|
|
360
|
-
// number escapes it -- a literal. This runs while the two are still
|
|
361
|
-
// distinct, before the unescape steps below collapse the literal onto
|
|
362
|
-
// the very `\*` a wildcard leaves behind.
|
|
363
|
-
/(^|[^\\])((?:\\\\)*)\\\*$/,
|
|
364
|
-
(match, p1, p2) => (
|
|
365
|
-
// `p2` holds the doubled user backslashes; half of them is `N`.
|
|
366
|
-
p2.length / 2 % 2 === 0 ? p1 + p2 + TRAILING_WILDCARD : match
|
|
367
|
-
),
|
|
368
|
-
"*"
|
|
369
|
-
],
|
|
370
|
-
[
|
|
371
|
-
// unescape, revert step 3 except for back slash
|
|
372
|
-
// For example, if a user escape a '\\*',
|
|
373
|
-
// after step 3, the result will be '\\\\\\*'
|
|
374
|
-
/\\\\\\(?=[$.|*+(){^])/g,
|
|
375
|
-
() => ESCAPE,
|
|
376
|
-
ESCAPE + ESCAPE
|
|
377
|
-
],
|
|
378
|
-
[
|
|
379
|
-
// '\\\\' -> '\\'
|
|
380
|
-
/\\\\/g,
|
|
381
|
-
() => ESCAPE,
|
|
382
|
-
ESCAPE + ESCAPE
|
|
383
|
-
],
|
|
384
|
-
[
|
|
385
|
-
// Every real bracket expression -- POSIX classes included -- has already
|
|
386
|
-
// been held aside by `extractBrackets`, so the only `[` left in the
|
|
387
|
-
// pattern is an escaped, literal one.
|
|
388
|
-
// `\` is escaped by step 3
|
|
389
|
-
/\\\[([^\]/]*?)(\\*)($|\])/g,
|
|
390
|
-
// '\\[bar]' -> '\\\\[bar\\]'
|
|
391
|
-
(match, range, endEscape, close) => `\\[${range}${cleanRangeBackSlash(endEscape)}${close}`,
|
|
392
|
-
"["
|
|
393
|
-
],
|
|
394
|
-
// ending
|
|
395
|
-
[
|
|
396
|
-
// 'js' will not match 'js.'
|
|
397
|
-
// 'ab' will not match 'abc'
|
|
398
|
-
DIRECT,
|
|
399
|
-
// WTF!
|
|
400
|
-
// https://git-scm.com/docs/gitignore
|
|
401
|
-
// changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
|
|
402
|
-
// which re-fixes #24, #38
|
|
403
|
-
// > If there is a separator at the end of the pattern then the pattern
|
|
404
|
-
// > will only match directories, otherwise the pattern can match both
|
|
405
|
-
// > files and directories.
|
|
406
|
-
// 'js*' will not match 'a.js'
|
|
407
|
-
// 'js/' will not match 'a.js'
|
|
408
|
-
// 'js' will match 'a.js' and 'a.js/'
|
|
409
|
-
(source) => {
|
|
410
|
-
const last = source[source.length - 1];
|
|
411
|
-
if (!last || last === TRAILING_WILDCARD || last === TRAILING_DOUBLESTAR) {
|
|
412
|
-
return source;
|
|
413
|
-
}
|
|
414
|
-
return last === SLASH3 ? `${source}$` : `${source}(?=$|\\/$)`;
|
|
415
|
-
}
|
|
416
|
-
]
|
|
417
|
-
];
|
|
418
|
-
var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\uE000$/;
|
|
419
|
-
var MODE_IGNORE = "regex";
|
|
420
|
-
var MODE_CHECK_IGNORE = "checkRegex";
|
|
421
|
-
var UNDERSCORE = "_";
|
|
422
|
-
var replaceTrailingWildcard = (_, p1) => {
|
|
423
|
-
const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
|
|
424
|
-
return `${prefix}(?=$|\\/$)`;
|
|
425
|
-
};
|
|
426
|
-
var REGEX_REPLACE_TRAILING_DOUBLESTAR = /\uE001$/;
|
|
427
|
-
var replaceTrailingDoublestar = () => ".+(?=$|\\/$)";
|
|
428
|
-
var WILDCARD = "[^\\/]*";
|
|
429
|
-
var separatorAfter = (run, at) => {
|
|
430
|
-
let separator = EMPTY;
|
|
431
|
-
for (let index = at + 1; index < run.length && !run[index].wildcard; index++) {
|
|
432
|
-
separator += run[index].single;
|
|
433
|
-
}
|
|
434
|
-
return separator;
|
|
435
|
-
};
|
|
436
|
-
var pinWildcards = (source) => {
|
|
437
|
-
if (source.indexOf(WILDCARD) < 0) {
|
|
438
|
-
return source;
|
|
439
|
-
}
|
|
440
|
-
const tokens = [];
|
|
441
|
-
const { length } = source;
|
|
442
|
-
let index = 0;
|
|
443
|
-
while (index < length) {
|
|
444
|
-
const char = source[index];
|
|
445
|
-
if (source.startsWith(WILDCARD, index)) {
|
|
446
|
-
tokens.push({ wildcard: true });
|
|
447
|
-
index += WILDCARD.length;
|
|
448
|
-
} else if (char === "[") {
|
|
449
|
-
let end = index + 1;
|
|
450
|
-
if (source[end] === "^") {
|
|
451
|
-
end++;
|
|
452
|
-
}
|
|
453
|
-
if (source[end] === "]") {
|
|
454
|
-
end++;
|
|
455
|
-
}
|
|
456
|
-
while (end < length && source[end] !== "]") {
|
|
457
|
-
end += source[end] === ESCAPE ? 2 : 1;
|
|
458
|
-
}
|
|
459
|
-
end++;
|
|
460
|
-
tokens.push({ single: source.slice(index, end) });
|
|
461
|
-
index = end;
|
|
462
|
-
} else if (char === ESCAPE) {
|
|
463
|
-
tokens.push({ single: source.slice(index, index + 2) });
|
|
464
|
-
index += 2;
|
|
465
|
-
} else if (char === "(") {
|
|
466
|
-
let depth = 0;
|
|
467
|
-
let end = index;
|
|
468
|
-
do {
|
|
469
|
-
if (source[end] === ESCAPE) {
|
|
470
|
-
end++;
|
|
471
|
-
} else if (source[end] === "(") {
|
|
472
|
-
depth++;
|
|
473
|
-
} else if (source[end] === ")") {
|
|
474
|
-
depth--;
|
|
475
|
-
}
|
|
476
|
-
end++;
|
|
477
|
-
} while (end < length && depth > 0);
|
|
478
|
-
if ("*+?".indexOf(source[end]) >= 0) {
|
|
479
|
-
end++;
|
|
480
|
-
}
|
|
481
|
-
tokens.push({ boundary: source.slice(index, end) });
|
|
482
|
-
index = end;
|
|
483
|
-
} else if (char === "^" || char === "$") {
|
|
484
|
-
tokens.push({ boundary: char });
|
|
485
|
-
index++;
|
|
486
|
-
} else {
|
|
487
|
-
tokens.push({ single: char });
|
|
488
|
-
index++;
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
let out = EMPTY;
|
|
492
|
-
let run = [];
|
|
493
|
-
const flush = () => {
|
|
494
|
-
let lastWildcard;
|
|
495
|
-
run.forEach((token, at) => {
|
|
496
|
-
if (token.wildcard) {
|
|
497
|
-
lastWildcard = at;
|
|
498
|
-
}
|
|
499
|
-
});
|
|
500
|
-
run.forEach((token, at) => {
|
|
501
|
-
if (!token.wildcard) {
|
|
502
|
-
out += token.single;
|
|
503
|
-
return;
|
|
504
|
-
}
|
|
505
|
-
out += at === lastWildcard ? WILDCARD : `(?:(?!${separatorAfter(run, at)})[^\\/])*`;
|
|
506
|
-
});
|
|
507
|
-
run = [];
|
|
508
|
-
};
|
|
509
|
-
tokens.forEach((token) => {
|
|
510
|
-
if (token.boundary === void 0) {
|
|
511
|
-
run.push(token);
|
|
512
|
-
return;
|
|
513
|
-
}
|
|
514
|
-
flush();
|
|
515
|
-
out += token.boundary;
|
|
516
|
-
});
|
|
517
|
-
flush();
|
|
518
|
-
return out;
|
|
519
|
-
};
|
|
520
|
-
var makeRegexPrefix = (pattern) => {
|
|
521
|
-
const { source, sources } = extractBrackets(pattern);
|
|
522
|
-
const replaced = REPLACERS.reduce(
|
|
523
|
-
// A pass whose matcher finds nothing hands back the very string it was
|
|
524
|
-
// given, so asking first costs a search and saves a rewrite. Ten of the
|
|
525
|
-
// fifteen passes never fire for a typical .gitignore line, and between
|
|
526
|
-
// them they were 45% of this chain.
|
|
527
|
-
(prev, [matcher, replacer, required2]) => {
|
|
528
|
-
if (matcher === DIRECT) {
|
|
529
|
-
return replacer(prev, pattern);
|
|
530
|
-
}
|
|
531
|
-
if (required2 !== UNDEFINED && prev.indexOf(required2) < 0) {
|
|
532
|
-
return prev;
|
|
533
|
-
}
|
|
534
|
-
return matcher.test(prev) ? prev.replace(matcher, replacer.bind(pattern)) : prev;
|
|
535
|
-
},
|
|
536
|
-
source
|
|
537
|
-
);
|
|
538
|
-
return sources.length ? replaced.replace(
|
|
539
|
-
REGEX_RESTORE_PLACEHOLDER,
|
|
540
|
-
(match, index) => sources[index]
|
|
541
|
-
) : replaced;
|
|
542
|
-
};
|
|
543
|
-
var checkSourceOf = (body, prefix) => {
|
|
544
|
-
if (body[body.length - 1] === SLASH3) {
|
|
545
|
-
prefix = makeRegexPrefix(body.slice(0, -1));
|
|
546
|
-
}
|
|
547
|
-
const head = prefix.slice(0, -1);
|
|
548
|
-
const last = prefix[prefix.length - 1];
|
|
549
|
-
return last === TRAILING_WILDCARD ? `${head}$` : last === TRAILING_DOUBLESTAR ? `${head}.*$` : NEVER_MATCH;
|
|
550
|
-
};
|
|
551
|
-
var matchesBasename = (body) => {
|
|
552
|
-
const index = body.indexOf(SLASH3);
|
|
553
|
-
return index < 0 || index === body.length - 1;
|
|
554
|
-
};
|
|
555
|
-
var basenameOf = (path) => {
|
|
556
|
-
const end = path.length - 1;
|
|
557
|
-
const index = path.lastIndexOf(
|
|
558
|
-
SLASH3,
|
|
559
|
-
path[end] === SLASH3 ? end - 1 : end
|
|
560
|
-
);
|
|
561
|
-
return index < 0 ? path : path.slice(index + 1);
|
|
562
|
-
};
|
|
563
|
-
var parentOf = (path) => {
|
|
564
|
-
if (path.charCodeAt(0) === SLASH_CODE || path.indexOf(DOUBLE_SLASH) >= 0) {
|
|
565
|
-
const slices = path.split(SLASH3).filter(Boolean);
|
|
566
|
-
slices.pop();
|
|
567
|
-
return slices.length ? slices.join(SLASH3) + SLASH3 : EMPTY;
|
|
568
|
-
}
|
|
569
|
-
const end = path.length - 1;
|
|
570
|
-
const cut = path.lastIndexOf(
|
|
571
|
-
SLASH3,
|
|
572
|
-
path.charCodeAt(end) === SLASH_CODE ? end - 1 : end
|
|
573
|
-
);
|
|
574
|
-
return cut < 0 ? EMPTY : path.slice(0, cut + 1);
|
|
575
|
-
};
|
|
576
|
-
var isString = (subject) => typeof subject === "string";
|
|
577
|
-
var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
|
|
578
|
-
var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
|
|
579
|
-
var IgnoreRule = class {
|
|
580
|
-
constructor(pattern, mark, body, ignoreCase, negative, prefix) {
|
|
581
|
-
this.pattern = pattern;
|
|
582
|
-
this.mark = mark;
|
|
583
|
-
this.negative = negative;
|
|
584
|
-
define(this, "body", body);
|
|
585
|
-
define(this, "ignoreCase", ignoreCase);
|
|
586
|
-
define(this, "regexPrefix", prefix);
|
|
587
|
-
}
|
|
588
|
-
// Worked out on first use and kept behind an own property, the way `regex`
|
|
589
|
-
// caches itself in `_regex`. Deciding it in the constructor instead would
|
|
590
|
-
// add a fourth `defineProperty` to every rule ever built, which cost 4% of
|
|
591
|
-
// every compile -- including the compiles of rules that are never matched
|
|
592
|
-
// against anything.
|
|
593
|
-
get _basenameOnly() {
|
|
594
|
-
return define(this, "_basenameOnly", matchesBasename(this.body));
|
|
595
|
-
}
|
|
596
|
-
get regex() {
|
|
597
|
-
const key = UNDERSCORE + MODE_IGNORE;
|
|
598
|
-
if (this[key]) {
|
|
599
|
-
return this[key];
|
|
600
|
-
}
|
|
601
|
-
return this._make(MODE_IGNORE, key);
|
|
602
|
-
}
|
|
603
|
-
get checkRegex() {
|
|
604
|
-
const key = UNDERSCORE + MODE_CHECK_IGNORE;
|
|
605
|
-
if (this[key]) {
|
|
606
|
-
return this[key];
|
|
607
|
-
}
|
|
608
|
-
return this._make(MODE_CHECK_IGNORE, key);
|
|
609
|
-
}
|
|
610
|
-
_make(mode, key) {
|
|
611
|
-
const str = pinWildcards(
|
|
612
|
-
mode === MODE_IGNORE ? this.regexPrefix.replace(REGEX_REPLACE_TRAILING_WILDCARD, replaceTrailingWildcard).replace(REGEX_REPLACE_TRAILING_DOUBLESTAR, replaceTrailingDoublestar) : checkSourceOf(this.body, this.regexPrefix)
|
|
613
|
-
);
|
|
614
|
-
const regex = this.ignoreCase ? new RegExp(str, "i") : new RegExp(str);
|
|
615
|
-
return define(this, key, regex);
|
|
616
|
-
}
|
|
617
|
-
};
|
|
618
|
-
var createRule = ({
|
|
619
|
-
pattern,
|
|
620
|
-
mark
|
|
621
|
-
}, ignoreCase) => {
|
|
622
|
-
let negative = false;
|
|
623
|
-
let body = pattern;
|
|
624
|
-
if (body.indexOf("!") === 0) {
|
|
625
|
-
negative = true;
|
|
626
|
-
body = body.substr(1);
|
|
627
|
-
}
|
|
628
|
-
body = body.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
|
|
629
|
-
const regexPrefix = makeRegexPrefix(body);
|
|
630
|
-
return new IgnoreRule(
|
|
631
|
-
pattern,
|
|
632
|
-
mark,
|
|
633
|
-
body,
|
|
634
|
-
ignoreCase,
|
|
635
|
-
negative,
|
|
636
|
-
regexPrefix
|
|
637
|
-
);
|
|
638
|
-
};
|
|
639
|
-
var RuleManager = class {
|
|
640
|
-
constructor(ignoreCase) {
|
|
641
|
-
this._ignoreCase = ignoreCase;
|
|
642
|
-
this._rules = [];
|
|
643
|
-
this._basenameCount = 0;
|
|
644
|
-
}
|
|
645
|
-
_add(pattern) {
|
|
646
|
-
if (pattern && pattern[KEY_IGNORE]) {
|
|
647
|
-
this._rules = this._rules.concat(pattern._rules._rules);
|
|
648
|
-
this._basenameCount += pattern._rules._basenameCount;
|
|
649
|
-
this._added = true;
|
|
650
|
-
return;
|
|
651
|
-
}
|
|
652
|
-
if (isString(pattern)) {
|
|
653
|
-
pattern = {
|
|
654
|
-
pattern
|
|
655
|
-
};
|
|
656
|
-
}
|
|
657
|
-
if (checkPattern(pattern.pattern)) {
|
|
658
|
-
const rule = createRule(pattern, this._ignoreCase);
|
|
659
|
-
this._added = true;
|
|
660
|
-
this._rules.push(rule);
|
|
661
|
-
if (matchesBasename(rule.body)) {
|
|
662
|
-
this._basenameCount++;
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
// @param {Array<string> | string | Ignore} pattern
|
|
667
|
-
add(pattern) {
|
|
668
|
-
this._added = false;
|
|
669
|
-
makeArray(
|
|
670
|
-
isString(pattern) ? splitPattern(pattern) : pattern
|
|
671
|
-
).forEach(this._add, this);
|
|
672
|
-
if (this._added) {
|
|
673
|
-
this._literalRules = UNDEFINED;
|
|
674
|
-
}
|
|
675
|
-
return this._added;
|
|
676
|
-
}
|
|
677
|
-
// Match the literal 'abc/' for `checkIgnore`, last rule wins. Only a rule
|
|
678
|
-
// ending in a wildcard can match it (see `checkSourceOf`), so the rest
|
|
679
|
-
// are left out once, rather than tested or compiled for every path.
|
|
680
|
-
testLiteral(path) {
|
|
681
|
-
const rules = this._literalRules || (this._literalRules = this._rules.filter(
|
|
682
|
-
({ body }) => body[body.length - (body[body.length - 1] === SLASH3 ? 2 : 1)] === "*"
|
|
683
|
-
));
|
|
684
|
-
let ignored = false;
|
|
685
|
-
let unignored = false;
|
|
686
|
-
let matchedRule;
|
|
687
|
-
for (let index = rules.length - 1; index >= 0; index--) {
|
|
688
|
-
const rule = rules[index];
|
|
689
|
-
if (rule.checkRegex.test(path)) {
|
|
690
|
-
ignored = !rule.negative;
|
|
691
|
-
unignored = rule.negative;
|
|
692
|
-
matchedRule = rule.negative ? UNDEFINED : rule;
|
|
693
|
-
break;
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
const ret = {
|
|
697
|
-
ignored,
|
|
698
|
-
unignored
|
|
699
|
-
};
|
|
700
|
-
if (matchedRule) {
|
|
701
|
-
ret.rule = matchedRule;
|
|
702
|
-
}
|
|
703
|
-
return ret;
|
|
704
|
-
}
|
|
705
|
-
// Test one single path without recursively checking parent directories
|
|
706
|
-
//
|
|
707
|
-
// - checkUnignored `boolean` whether should check if the path is unignored,
|
|
708
|
-
// setting `checkUnignored` to `false` could reduce additional
|
|
709
|
-
// path matching.
|
|
710
|
-
// - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
|
|
711
|
-
// @returns {TestResult} true if a file is ignored
|
|
712
|
-
test(path, checkUnignored, mode) {
|
|
713
|
-
let ignored = false;
|
|
714
|
-
let unignored = false;
|
|
715
|
-
let matchedRule;
|
|
716
|
-
const rules = this._rules;
|
|
717
|
-
const { length } = rules;
|
|
718
|
-
const shortcut = this._basenameCount * 2 >= length;
|
|
719
|
-
const basename7 = shortcut ? basenameOf(path) : path;
|
|
720
|
-
for (let index = 0; index < length; index++) {
|
|
721
|
-
const rule = rules[index];
|
|
722
|
-
const { negative } = rule;
|
|
723
|
-
const skip = unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored;
|
|
724
|
-
if (!skip && rule[mode].test(
|
|
725
|
-
shortcut && rule._basenameOnly ? basename7 : path
|
|
726
|
-
)) {
|
|
727
|
-
ignored = !negative;
|
|
728
|
-
unignored = negative;
|
|
729
|
-
matchedRule = negative ? UNDEFINED : rule;
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
const ret = {
|
|
733
|
-
ignored,
|
|
734
|
-
unignored
|
|
735
|
-
};
|
|
736
|
-
if (matchedRule) {
|
|
737
|
-
ret.rule = matchedRule;
|
|
738
|
-
}
|
|
739
|
-
return ret;
|
|
740
|
-
}
|
|
741
|
-
};
|
|
742
|
-
var throwError = (message, Ctor) => {
|
|
743
|
-
throw new Ctor(message);
|
|
744
|
-
};
|
|
745
|
-
var checkPath = (path, originalPath, doThrow) => {
|
|
746
|
-
if (!isString(path)) {
|
|
747
|
-
return doThrow(
|
|
748
|
-
`path must be a string, but got \`${originalPath}\``,
|
|
749
|
-
TypeError
|
|
750
|
-
);
|
|
751
|
-
}
|
|
752
|
-
if (!path) {
|
|
753
|
-
return doThrow(`path must not be empty`, TypeError);
|
|
754
|
-
}
|
|
755
|
-
if (checkPath.isNotRelative(path)) {
|
|
756
|
-
const r = "`path.relative()`d";
|
|
757
|
-
return doThrow(
|
|
758
|
-
`path should be a ${r} string, but got "${originalPath}"`,
|
|
759
|
-
RangeError
|
|
760
|
-
);
|
|
761
|
-
}
|
|
762
|
-
return true;
|
|
763
|
-
};
|
|
764
|
-
var isNotRelative = (path) => {
|
|
765
|
-
const first = path.charCodeAt(0);
|
|
766
|
-
if (first === SLASH_CODE) {
|
|
767
|
-
return true;
|
|
768
|
-
}
|
|
769
|
-
if (first !== DOT_CODE) {
|
|
770
|
-
return false;
|
|
771
|
-
}
|
|
772
|
-
if (path.length === 1) {
|
|
773
|
-
return true;
|
|
774
|
-
}
|
|
775
|
-
const second = path.charCodeAt(1);
|
|
776
|
-
if (second === SLASH_CODE) {
|
|
777
|
-
return true;
|
|
778
|
-
}
|
|
779
|
-
if (second !== DOT_CODE) {
|
|
780
|
-
return false;
|
|
781
|
-
}
|
|
782
|
-
return path.length === 2 || path.charCodeAt(2) === SLASH_CODE;
|
|
783
|
-
};
|
|
784
|
-
checkPath.isNotRelative = isNotRelative;
|
|
785
|
-
checkPath.convert = (p) => p;
|
|
786
|
-
var Ignore = class {
|
|
787
|
-
constructor({
|
|
788
|
-
ignorecase = true,
|
|
789
|
-
ignoreCase = ignorecase,
|
|
790
|
-
allowRelativePaths = false
|
|
791
|
-
} = {}) {
|
|
792
|
-
define(this, KEY_IGNORE, true);
|
|
793
|
-
this._rules = new RuleManager(ignoreCase);
|
|
794
|
-
this._strictPathCheck = !allowRelativePaths;
|
|
795
|
-
this._initCache();
|
|
796
|
-
}
|
|
797
|
-
_initCache() {
|
|
798
|
-
this._ignoreCache = /* @__PURE__ */ Object.create(null);
|
|
799
|
-
this._testCache = /* @__PURE__ */ Object.create(null);
|
|
800
|
-
}
|
|
801
|
-
add(pattern) {
|
|
802
|
-
if (this._rules.add(pattern)) {
|
|
803
|
-
this._initCache();
|
|
804
|
-
}
|
|
805
|
-
return this;
|
|
806
|
-
}
|
|
807
|
-
// legacy
|
|
808
|
-
addPattern(pattern) {
|
|
809
|
-
return this.add(pattern);
|
|
810
|
-
}
|
|
811
|
-
// @returns {TestResult}
|
|
812
|
-
_test(originalPath, cache, checkUnignored) {
|
|
813
|
-
const path = originalPath && checkPath.convert(originalPath);
|
|
814
|
-
checkPath(
|
|
815
|
-
path,
|
|
816
|
-
originalPath,
|
|
817
|
-
this._strictPathCheck ? throwError : RETURN_FALSE
|
|
818
|
-
);
|
|
819
|
-
return this._t(path, cache, checkUnignored);
|
|
820
|
-
}
|
|
821
|
-
checkIgnore(path) {
|
|
822
|
-
if (path.charCodeAt(path.length - 1) !== SLASH_CODE) {
|
|
823
|
-
return this.test(path);
|
|
824
|
-
}
|
|
825
|
-
const dir = this._t(path, this._testCache, true);
|
|
826
|
-
if (dir.ignored) {
|
|
827
|
-
return dir;
|
|
828
|
-
}
|
|
829
|
-
const literal2 = this._rules.testLiteral(path);
|
|
830
|
-
return literal2.ignored || literal2.unignored ? literal2 : dir;
|
|
831
|
-
}
|
|
832
|
-
_t(path, cache, checkUnignored) {
|
|
833
|
-
if (path in cache) {
|
|
834
|
-
return cache[path];
|
|
835
|
-
}
|
|
836
|
-
const parentPath = parentOf(path);
|
|
837
|
-
const parent = parentPath ? this._t(parentPath, cache, checkUnignored) : UNDEFINED;
|
|
838
|
-
return cache[path] = parent && parent.ignored ? parent : this._rules.test(path, checkUnignored, MODE_IGNORE);
|
|
839
|
-
}
|
|
840
|
-
ignores(path) {
|
|
841
|
-
return this._test(path, this._ignoreCache, false).ignored;
|
|
842
|
-
}
|
|
843
|
-
createFilter() {
|
|
844
|
-
return (path) => !this.ignores(path);
|
|
845
|
-
}
|
|
846
|
-
filter(paths) {
|
|
847
|
-
return makeArray(paths).filter(this.createFilter());
|
|
848
|
-
}
|
|
849
|
-
// @returns {TestResult}
|
|
850
|
-
test(path) {
|
|
851
|
-
return this._test(path, this._testCache, true);
|
|
852
|
-
}
|
|
853
|
-
};
|
|
854
|
-
var factory = (options) => new Ignore(options);
|
|
855
|
-
var isPathValid = (path) => checkPath(path && checkPath.convert(path), path, RETURN_FALSE);
|
|
856
|
-
var setupWindows = () => {
|
|
857
|
-
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
858
|
-
checkPath.convert = makePosix;
|
|
859
|
-
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
860
|
-
checkPath.isNotRelative = (path) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
|
|
861
|
-
};
|
|
862
|
-
if (
|
|
863
|
-
// Detect `process` so that it can run in browsers.
|
|
864
|
-
typeof process !== "undefined" && process.platform === "win32"
|
|
865
|
-
) {
|
|
866
|
-
setupWindows();
|
|
867
|
-
}
|
|
868
|
-
module.exports = factory;
|
|
869
|
-
factory.default = factory;
|
|
870
|
-
module.exports.isPathValid = isPathValid;
|
|
871
|
-
define(module.exports, /* @__PURE__ */ Symbol.for("setupWindows"), setupWindows);
|
|
872
|
-
}
|
|
873
|
-
});
|
|
874
6
|
|
|
875
7
|
// ../../packages/plugin-sdk/src/config.ts
|
|
876
8
|
import { existsSync as existsSync8 } from "fs";
|
|
877
|
-
import { join as
|
|
878
|
-
|
|
879
|
-
// ../../packages/persistence/src/attached-derived.ts
|
|
880
|
-
import { rmSync } from "fs";
|
|
881
|
-
import { join } from "path";
|
|
882
|
-
|
|
883
|
-
// ../../packages/persistence/src/control-plane-credential.ts
|
|
884
|
-
import { chmodSync as chmodSync2, lstatSync as lstatSync2, readFileSync, rmSync as rmSync3, statSync } from "fs";
|
|
885
|
-
import { join as join2 } from "path";
|
|
9
|
+
import { join as join17 } from "path";
|
|
886
10
|
|
|
887
11
|
// ../../packages/schema/src/drizzle/deferred-migrations.ts
|
|
888
12
|
var DEFERRED_MIGRATION_TAGS = [
|
|
@@ -3711,9 +2835,9 @@ var asciiTabOrNewline = /[\t\n\r]/g;
|
|
|
3711
2835
|
function stripTabAndNewline(value) {
|
|
3712
2836
|
return value.replace(asciiTabOrNewline, "");
|
|
3713
2837
|
}
|
|
3714
|
-
function urlHostnameOk(url2,
|
|
3715
|
-
|
|
3716
|
-
return
|
|
2838
|
+
function urlHostnameOk(url2, hostname6) {
|
|
2839
|
+
hostname6.lastIndex = 0;
|
|
2840
|
+
return hostname6.test(url2.hostname);
|
|
3717
2841
|
}
|
|
3718
2842
|
function urlProtocolOk(url2, protocol) {
|
|
3719
2843
|
protocol.lastIndex = 0;
|
|
@@ -20682,8 +19806,8 @@ var PLATFORM_HOSTING = /* @__PURE__ */ new Map([
|
|
|
20682
19806
|
["ollama", "local"],
|
|
20683
19807
|
["local", "local"]
|
|
20684
19808
|
]);
|
|
20685
|
-
function hostingFor(
|
|
20686
|
-
return PLATFORM_HOSTING.get(
|
|
19809
|
+
function hostingFor(platform) {
|
|
19810
|
+
return PLATFORM_HOSTING.get(platform) ?? "api";
|
|
20687
19811
|
}
|
|
20688
19812
|
var FIRST_PARTY = /* @__PURE__ */ new Map([
|
|
20689
19813
|
["anthropic", "anthropic"],
|
|
@@ -20697,8 +19821,8 @@ var FIRST_PARTY = /* @__PURE__ */ new Map([
|
|
|
20697
19821
|
function firstPartyPlatformFor(vendor2) {
|
|
20698
19822
|
return FIRST_PARTY.get(vendor2) ?? null;
|
|
20699
19823
|
}
|
|
20700
|
-
function isFirstParty(vendor2,
|
|
20701
|
-
return FIRST_PARTY.get(vendor2) ===
|
|
19824
|
+
function isFirstParty(vendor2, platform) {
|
|
19825
|
+
return FIRST_PARTY.get(vendor2) === platform;
|
|
20702
19826
|
}
|
|
20703
19827
|
var PLATFORM_NAMESPACES = Object.freeze([
|
|
20704
19828
|
"anthropic",
|
|
@@ -20759,14 +19883,14 @@ var ModelVendorBuilder = class {
|
|
|
20759
19883
|
);
|
|
20760
19884
|
}
|
|
20761
19885
|
for (const ref of spec.on ?? []) {
|
|
20762
|
-
const { platform
|
|
20763
|
-
const firstParty = isFirstParty(this.vendor,
|
|
20764
|
-
const hosting = hostingFor(
|
|
19886
|
+
const { platform, price, retention, region } = normalizeRef(ref);
|
|
19887
|
+
const firstParty = isFirstParty(this.vendor, platform);
|
|
19888
|
+
const hosting = hostingFor(platform);
|
|
20765
19889
|
const isSelfHosted = hosting === "local";
|
|
20766
19890
|
platforms.set(
|
|
20767
|
-
|
|
19891
|
+
platform,
|
|
20768
19892
|
Object.freeze({
|
|
20769
|
-
platform
|
|
19893
|
+
platform,
|
|
20770
19894
|
hosting,
|
|
20771
19895
|
firstParty,
|
|
20772
19896
|
price: price ?? (isSelfHosted ? ZERO_PRICE : firstParty ? spec.price ?? null : null),
|
|
@@ -20916,7 +20040,7 @@ anthropic.model("claude-haiku-4-5", {
|
|
|
20916
20040
|
name: "Claude Haiku 4.5",
|
|
20917
20041
|
ctx: 2e5,
|
|
20918
20042
|
maxOut: 64e3,
|
|
20919
|
-
// Reviewed: fast/cheap tier,
|
|
20043
|
+
// Reviewed: fast/cheap general-purpose tier, not a reasoning or code model.
|
|
20920
20044
|
capability: null,
|
|
20921
20045
|
price: anthropicPrice(1, 5, 0.1),
|
|
20922
20046
|
// The vendor documents `claude-haiku-4-5-20251001` as the versioned id and
|
|
@@ -21047,6 +20171,11 @@ openai.model("gpt-4o", {
|
|
|
21047
20171
|
price: tokenPrice(2.5, 10, { cacheRead: 1.25 }),
|
|
21048
20172
|
on: [...OPENAI_RESELLERS]
|
|
21049
20173
|
});
|
|
20174
|
+
openai.model("gpt-4o-2024-05-13", {
|
|
20175
|
+
name: "GPT-4o (2024-05-13)",
|
|
20176
|
+
price: tokenPrice(5, 15),
|
|
20177
|
+
on: [...OPENAI_RESELLERS]
|
|
20178
|
+
});
|
|
21050
20179
|
openai.model("gpt-4o-mini", {
|
|
21051
20180
|
name: "GPT-4o mini",
|
|
21052
20181
|
price: tokenPrice(0.15, 0.6, { cacheRead: 0.075 }),
|
|
@@ -21066,6 +20195,24 @@ openai.model("o3", {
|
|
|
21066
20195
|
price: tokenPrice(2, 8, { cacheRead: 0.5 }),
|
|
21067
20196
|
on: [...OPENAI_RESELLERS]
|
|
21068
20197
|
});
|
|
20198
|
+
openai.model("text-embedding-3-small", {
|
|
20199
|
+
name: "text-embedding-3-small",
|
|
20200
|
+
capability: "embedding",
|
|
20201
|
+
price: tokenPrice(0.02, 0),
|
|
20202
|
+
on: [...OPENAI_RESELLERS]
|
|
20203
|
+
});
|
|
20204
|
+
openai.model("text-embedding-3-large", {
|
|
20205
|
+
name: "text-embedding-3-large",
|
|
20206
|
+
capability: "embedding",
|
|
20207
|
+
price: tokenPrice(0.13, 0),
|
|
20208
|
+
on: [...OPENAI_RESELLERS]
|
|
20209
|
+
});
|
|
20210
|
+
openai.model("text-embedding-ada-002", {
|
|
20211
|
+
name: "text-embedding-ada-002",
|
|
20212
|
+
capability: "embedding",
|
|
20213
|
+
price: tokenPrice(0.1, 0),
|
|
20214
|
+
on: [...OPENAI_RESELLERS]
|
|
20215
|
+
});
|
|
21069
20216
|
openai.model("gpt-oss-120b", {
|
|
21070
20217
|
name: "GPT-OSS 120B",
|
|
21071
20218
|
openWeights: true,
|
|
@@ -21352,10 +20499,21 @@ var MODEL_ENTRIES = Object.freeze([
|
|
|
21352
20499
|
...alibaba.models(),
|
|
21353
20500
|
...amazon.models()
|
|
21354
20501
|
]);
|
|
20502
|
+
var LONG_CONTEXT_THRESHOLDS = Object.freeze(
|
|
20503
|
+
[
|
|
20504
|
+
...new Set(
|
|
20505
|
+
MODEL_ENTRIES.flatMap(
|
|
20506
|
+
(entry) => [...entry.platforms.values()].flatMap(
|
|
20507
|
+
(offering) => offering.price?.longContext ? [offering.price.longContext.thresholdInputTokens] : []
|
|
20508
|
+
)
|
|
20509
|
+
)
|
|
20510
|
+
)
|
|
20511
|
+
].sort((a, b) => a - b)
|
|
20512
|
+
);
|
|
21355
20513
|
var MODEL_INDEX = buildModelIndex(MODEL_ENTRIES);
|
|
21356
20514
|
|
|
21357
20515
|
// ../../packages/schema/src/model/governance.ts
|
|
21358
|
-
var ModelCapability = external_exports.enum(["reasoning", "code"]);
|
|
20516
|
+
var ModelCapability = external_exports.enum(["reasoning", "code", "embedding"]);
|
|
21359
20517
|
var DataRetention = external_exports.enum([
|
|
21360
20518
|
"zero_retention",
|
|
21361
20519
|
"no_storage",
|
|
@@ -22116,6 +21274,11 @@ var CaptureAttributes = external_exports.object({
|
|
|
22116
21274
|
// here too. The full statement is on EventMetadata.redactDegradedTo; it is
|
|
22117
21275
|
// repeated rather than referenced because a store reader opens this file.
|
|
22118
21276
|
redact_degraded_to: ActionTaken.optional(),
|
|
21277
|
+
// Why a capture has no content and no findings: its field was refused
|
|
21278
|
+
// because its bounded scan did not finish (see EventMetadata.scanIncomplete,
|
|
21279
|
+
// whose value this is). Absent on every capture that was scanned, so a
|
|
21280
|
+
// reader can tell a refused row from an empty clean one.
|
|
21281
|
+
scan_incomplete: external_exports.enum(["timeout", "unavailable"]).optional(),
|
|
22119
21282
|
// The scope key this capture was stamped with: the canonical repository
|
|
22120
21283
|
// (`host/owner/repo`) of the path the capture names (a relative path is read
|
|
22121
21284
|
// against its working directory), else of its own working directory, or a
|
|
@@ -22293,8 +21456,9 @@ var SessionTokenReport = external_exports.object({
|
|
|
22293
21456
|
totalTokens: external_exports.number().int().nonnegative(),
|
|
22294
21457
|
// Σ of the PRICED rollups only; null when no rollup had a known price.
|
|
22295
21458
|
estimatedCostUsd: external_exports.number().nullable(),
|
|
22296
|
-
// True whenever any
|
|
22297
|
-
//
|
|
21459
|
+
// True whenever any call priced to null (an unknown provider/model, or a call
|
|
21460
|
+
// over a long-context threshold whose rate is unpublished), so the total
|
|
21461
|
+
// understates real spend — the UI renders `≥ $X` instead of a falsely
|
|
22298
21462
|
// precise figure rather than silently dropping the unpriced calls.
|
|
22299
21463
|
costIsPartial: external_exports.boolean()
|
|
22300
21464
|
});
|
|
@@ -23140,7 +22304,15 @@ var StorePostureSnapshot = external_exports.object({
|
|
|
23140
22304
|
policyCounts: StorePosturePolicyCounts,
|
|
23141
22305
|
// OPTIONAL, not nullable: a reporter that predates this member keeps
|
|
23142
22306
|
// getting its 200 without a payload change.
|
|
23143
|
-
plugin: StorePosturePlugin.optional()
|
|
22307
|
+
plugin: StorePosturePlugin.optional(),
|
|
22308
|
+
// OPTIONAL, and sent only by a scoped attachment, always as `scoped`. A
|
|
22309
|
+
// machine attachment omits it, so its body is byte for byte the one it
|
|
22310
|
+
// sent before this member existed. Absent therefore means machine-wide OR
|
|
22311
|
+
// a reporter older than this member, never "scoped". Both values parse, so
|
|
22312
|
+
// a sender that one day spells `machine` breaks no receiver; any other
|
|
22313
|
+
// value fails the whole snapshot, which is why the reporter sends a
|
|
22314
|
+
// constant and never the raw mode.
|
|
22315
|
+
attachmentMode: AttachmentMode.optional()
|
|
23144
22316
|
}).meta({ id: "StorePostureSnapshot" });
|
|
23145
22317
|
var CAPTURE_VERSION_PREFIX = "capture/";
|
|
23146
22318
|
var RecordAuditEventRequest = AuditEventInput.extend({
|
|
@@ -23417,7 +22589,19 @@ var EventMetadata = external_exports.object({
|
|
|
23417
22589
|
// Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
|
|
23418
22590
|
// Closing either means moving the reason onto the finding row, which
|
|
23419
22591
|
// already carries its own action.
|
|
23420
|
-
redactDegradedTo: ActionTaken.optional()
|
|
22592
|
+
redactDegradedTo: ActionTaken.optional(),
|
|
22593
|
+
// Set when this capture's field was REFUSED rather than scanned: a hook
|
|
22594
|
+
// bounds the scan of a large field (see `LargeInputScanOptions` in
|
|
22595
|
+
// @akasecurity/plugin-sdk), and a scan that did not finish blocks the
|
|
22596
|
+
// field instead of letting it through unscanned.
|
|
22597
|
+
//
|
|
22598
|
+
// - 'timeout': the bounded scan ran out of time.
|
|
22599
|
+
// - 'unavailable': no worker could run it.
|
|
22600
|
+
//
|
|
22601
|
+
// A refused row stores '' as its content and has no findings, which is
|
|
22602
|
+
// exactly what a clean, empty capture looks like — this marker is the only
|
|
22603
|
+
// thing that tells the two apart. Absent on every capture that was scanned.
|
|
22604
|
+
scanIncomplete: external_exports.enum(["timeout", "unavailable"]).optional()
|
|
23421
22605
|
}).meta({ id: "EventMetadata" });
|
|
23422
22606
|
var Event = external_exports.object({
|
|
23423
22607
|
id: external_exports.guid(),
|
|
@@ -23587,7 +22771,7 @@ var Rule = external_exports.strictObject({
|
|
|
23587
22771
|
postValidators: external_exports.array(PostValidatorRef).optional(),
|
|
23588
22772
|
requiresNearby: RequiresNearby.optional(),
|
|
23589
22773
|
examples: external_exports.array(external_exports.string()).optional(),
|
|
23590
|
-
// Whether the matched text is itself sensitive
|
|
22774
|
+
// Whether the matched text is itself sensitive (see RuleEvidence).
|
|
23591
22775
|
evidence: RuleEvidence.optional()
|
|
23592
22776
|
}).meta({ id: "Rule" });
|
|
23593
22777
|
var Author = external_exports.object({
|
|
@@ -23679,7 +22863,13 @@ var DetectionRule = external_exports.object({
|
|
|
23679
22863
|
// Representative matching strings the rule author shipped with the rule. The
|
|
23680
22864
|
// cheapest honest answer to "show me what this rule catches" — every bundled
|
|
23681
22865
|
// rule has them, and they are already in the stored snapshot.
|
|
23682
|
-
examples: external_exports.array(external_exports.string()).optional()
|
|
22866
|
+
examples: external_exports.array(external_exports.string()).optional(),
|
|
22867
|
+
// The rule's DECLARED evidence, as stored. Absent defers to the engine's
|
|
22868
|
+
// classification (ruleEvidence in @akasecurity/detections): a bundled
|
|
22869
|
+
// code-flaw rule reads as 'code' and anything else as 'value', and a rule
|
|
22870
|
+
// in a value category (secret/pii/financial/phi) is always 'value',
|
|
22871
|
+
// whatever it declares.
|
|
22872
|
+
evidence: RuleEvidence.optional()
|
|
23683
22873
|
}).meta({ id: "DetectionRule" });
|
|
23684
22874
|
var DetectionUpdate = external_exports.object({
|
|
23685
22875
|
available: external_exports.boolean(),
|
|
@@ -23945,11 +23135,14 @@ var PolicyBundle = external_exports.object({
|
|
|
23945
23135
|
ruleVersions: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
23946
23136
|
// Model ids (the raw `model` string a harness reports, e.g.
|
|
23947
23137
|
// `claude-opus-4-1`) the tenant has PROHIBITED. The plugin refuses to switch
|
|
23948
|
-
// a session onto one (PreModelSwitch)
|
|
23949
|
-
//
|
|
23950
|
-
//
|
|
23951
|
-
//
|
|
23952
|
-
//
|
|
23138
|
+
// a session onto one (PreModelSwitch), refuses a turn that would run on one
|
|
23139
|
+
// (UserPromptSubmit) and refuses a subagent spawn onto one (PreToolUse),
|
|
23140
|
+
// wherever the organization governs the event: everywhere on a
|
|
23141
|
+
// machine-wide attachment, and only in enrolled repositories on a scoped
|
|
23142
|
+
// one (the plugin runtime's `governanceApplies`).
|
|
23143
|
+
// Optional so an older backend — and an older on-disk cache — still
|
|
23144
|
+
// parses; consumers read `?? []`, which is the unenforced behaviour that
|
|
23145
|
+
// predates this field and the safe direction to default.
|
|
23953
23146
|
//
|
|
23954
23147
|
// Ids, not display names: the governance decision is keyed on the exact
|
|
23955
23148
|
// string the harness reports (`model_status_override.versionId` in the
|
|
@@ -24291,6 +23484,8 @@ var AttachmentScopeEntry = external_exports.object({
|
|
|
24291
23484
|
});
|
|
24292
23485
|
var AttachmentScope = external_exports.object({
|
|
24293
23486
|
endpoint: external_exports.string().min(1),
|
|
23487
|
+
tenantName: PluginWhoami.shape.tenantName.optional(),
|
|
23488
|
+
userEmail: PluginWhoami.shape.userEmail.optional(),
|
|
24294
23489
|
entries: external_exports.array(AttachmentScopeEntry)
|
|
24295
23490
|
});
|
|
24296
23491
|
var AttachmentScopeEnvelope = AttachmentScope.extend({ entries: external_exports.array(external_exports.unknown()) });
|
|
@@ -24503,6 +23698,27 @@ var ManagedSettings = external_exports.object({
|
|
|
24503
23698
|
};
|
|
24504
23699
|
}).meta({ id: "ManagedSettings" });
|
|
24505
23700
|
|
|
23701
|
+
// ../../packages/schema/src/zod/mod-policy-snapshot.ts
|
|
23702
|
+
var MOD_POLICY_SNAPSHOT_VERSION = 1;
|
|
23703
|
+
var MOD_POLICY_SNAPSHOT_MAX_BYTES = 4 * 1024 * 1024;
|
|
23704
|
+
var ModPolicySnapshot = external_exports.object({
|
|
23705
|
+
version: external_exports.literal(MOD_POLICY_SNAPSHOT_VERSION),
|
|
23706
|
+
generatedAt: external_exports.iso.datetime(),
|
|
23707
|
+
// The complete effective ruleset, as the hook's runtime scans with it: the
|
|
23708
|
+
// user's enabled installed packs (user-modified and custom packs included).
|
|
23709
|
+
// Absent means the store holds no authoritative snapshot, and the reader
|
|
23710
|
+
// scans with the packs it ships — the hook's own fallback.
|
|
23711
|
+
rules: external_exports.array(Rule).optional(),
|
|
23712
|
+
// Rule-targeted actions (first enabled policy per rule wins).
|
|
23713
|
+
ruleActions: external_exports.record(external_exports.string(), ActionTaken),
|
|
23714
|
+
// The resolved action per detection category.
|
|
23715
|
+
categoryActions: external_exports.record(external_exports.string(), ActionTaken),
|
|
23716
|
+
// Rules with an active exception grant. Honouring a grant means matching a
|
|
23717
|
+
// keyed fingerprint of the value and consuming a use, which only the hook can
|
|
23718
|
+
// do, so the mod leaves a finding of one of these rules for the hook to decide.
|
|
23719
|
+
exceptionRuleIds: external_exports.array(external_exports.string())
|
|
23720
|
+
}).meta({ id: "ModPolicySnapshot" });
|
|
23721
|
+
|
|
24506
23722
|
// ../../packages/schema/src/zod/project-files.ts
|
|
24507
23723
|
var ProjectFileInput = external_exports.object({
|
|
24508
23724
|
path: external_exports.string().min(1),
|
|
@@ -24817,7 +24033,16 @@ var AttachInput = external_exports.object({
|
|
|
24817
24033
|
// 200 matches the tenantName bound beside it in control-plane.ts; nothing
|
|
24818
24034
|
// renders a longer one usefully.
|
|
24819
24035
|
label: printable(200).optional(),
|
|
24820
|
-
accessKey: external_exports.string()
|
|
24036
|
+
accessKey: external_exports.string(),
|
|
24037
|
+
// How much of this machine the attachment is for: everything, or only the
|
|
24038
|
+
// repositories its user enrolls. Optional, so an input without it still
|
|
24039
|
+
// parses; what an absent mode means is for whatever reads it to decide, not
|
|
24040
|
+
// this shape. This member validates the VALUE rather than leaving that to the
|
|
24041
|
+
// call site, a deliberate exception to this module's shape-only rule: a shape
|
|
24042
|
+
// rejection names the field, so a value that is not a mode is refused as a bad
|
|
24043
|
+
// `mode` rather than stripped or passed on. The dashboard's attach action reads
|
|
24044
|
+
// it as the mode to attach in.
|
|
24045
|
+
mode: AttachmentMode.optional()
|
|
24821
24046
|
});
|
|
24822
24047
|
|
|
24823
24048
|
// ../../packages/schema/src/zod/triage.ts
|
|
@@ -25030,6 +24255,14 @@ var CAPTURE_STATUS_RECENCY_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
|
25030
24255
|
var CAPTURE_STATUS_RECENCY_DAYS = CAPTURE_STATUS_RECENCY_MS / (24 * 60 * 60 * 1e3);
|
|
25031
24256
|
var CAPTURE_STATUS_DOCUMENT_QUIET_MS = 12 * 60 * 60 * 1e3;
|
|
25032
24257
|
|
|
24258
|
+
// ../../packages/persistence/src/attached-derived.ts
|
|
24259
|
+
import { rmSync } from "fs";
|
|
24260
|
+
import { join } from "path";
|
|
24261
|
+
|
|
24262
|
+
// ../../packages/persistence/src/control-plane-credential.ts
|
|
24263
|
+
import { chmodSync as chmodSync2, lstatSync as lstatSync2, readFileSync, rmSync as rmSync3, statSync } from "fs";
|
|
24264
|
+
import { join as join2 } from "path";
|
|
24265
|
+
|
|
25033
24266
|
// ../../packages/persistence/src/paths.ts
|
|
25034
24267
|
import {
|
|
25035
24268
|
chmodSync,
|
|
@@ -25093,11 +24326,12 @@ function writeOwnerOnlyFileSync(file2, data) {
|
|
|
25093
24326
|
|
|
25094
24327
|
// ../../packages/persistence/src/database.ts
|
|
25095
24328
|
import { randomUUID as randomUUID11 } from "crypto";
|
|
25096
|
-
import { dirname as dirname2, join as
|
|
24329
|
+
import { dirname as dirname2, join as join8, sep } from "path";
|
|
25097
24330
|
import { DatabaseSync } from "node:sqlite";
|
|
25098
24331
|
|
|
25099
24332
|
// ../../packages/persistence/src/ids.ts
|
|
25100
24333
|
import { createHash } from "crypto";
|
|
24334
|
+
var DOT = ".".charCodeAt(0);
|
|
25101
24335
|
|
|
25102
24336
|
// ../../packages/persistence/src/internal/snapshot.ts
|
|
25103
24337
|
import { randomUUID } from "crypto";
|
|
@@ -25120,6 +24354,7 @@ var SYNC_FAILURE_REASONS = SyncFailureReason.options;
|
|
|
25120
24354
|
// ../../packages/persistence/src/repositories/history-sync.ts
|
|
25121
24355
|
var STRUCTURAL_EVENT_TYPES = ["session", "llm_call", "tool_call"];
|
|
25122
24356
|
var TYPE_LIST = STRUCTURAL_EVENT_TYPES.map((t) => `'${t}'`).join(", ");
|
|
24357
|
+
var CAPTURE_TYPE_LIST = OUTBOX_CAPTURE_TYPE_LIST;
|
|
25123
24358
|
var COUNTED_EVENT_TYPES = [
|
|
25124
24359
|
...STRUCTURAL_EVENT_TYPES,
|
|
25125
24360
|
...OUTBOX_CAPTURE_EVENT_TYPES
|
|
@@ -25132,6 +24367,37 @@ var COUNTED_SCOPE = `
|
|
|
25132
24367
|
OR synced_at IS NOT NULL
|
|
25133
24368
|
OR outbox_owed = 1
|
|
25134
24369
|
)`;
|
|
24370
|
+
var SKIPPED = -1;
|
|
24371
|
+
function inScope(column) {
|
|
24372
|
+
return `${column} IN (SELECT value FROM json_each(:scopeKeys))`;
|
|
24373
|
+
}
|
|
24374
|
+
var ROOT_SCOPE_KEY = `(SELECT session_root.scope_key
|
|
24375
|
+
FROM audit_events AS session_root
|
|
24376
|
+
WHERE session_root.id = COALESCE(audit_events.root_session_id, audit_events.id))`;
|
|
24377
|
+
var COUNTED_IN_SCOPE = `
|
|
24378
|
+
AND ${inScope("scope_key")}
|
|
24379
|
+
AND (event_type IN (${CAPTURE_TYPE_LIST}) OR ${inScope(ROOT_SCOPE_KEY)})`;
|
|
24380
|
+
var DRAIN_TOTALS = `SELECT
|
|
24381
|
+
SUM(CASE WHEN synced_at IS NULL AND started_at < :before THEN 1 ELSE 0 END) AS pending,
|
|
24382
|
+
SUM(CASE WHEN synced_at > 0 THEN 1 ELSE 0 END) AS sent,
|
|
24383
|
+
SUM(CASE WHEN synced_at = ${String(SKIPPED)}
|
|
24384
|
+
AND (sync_failure IS NULL OR sync_failure = 'payload_invalid')
|
|
24385
|
+
THEN 1 ELSE 0 END) AS skipped,
|
|
24386
|
+
SUM(CASE WHEN synced_at = ${String(SKIPPED)}
|
|
24387
|
+
AND sync_failure = 'deployment_refused' THEN 1 ELSE 0 END) AS refused,
|
|
24388
|
+
SUM(CASE WHEN synced_at = ${String(SKIPPED)}
|
|
24389
|
+
AND sync_failure = 'detached_undelivered' THEN 1 ELSE 0 END) AS detached
|
|
24390
|
+
FROM audit_events
|
|
24391
|
+
WHERE event_type IN (${TYPE_LIST})`;
|
|
24392
|
+
var CAPTURE_SKIPS = `SELECT COUNT(*) AS skipped
|
|
24393
|
+
FROM audit_events
|
|
24394
|
+
WHERE synced_at = ${String(SKIPPED)}
|
|
24395
|
+
AND event_type IN (${CAPTURE_TYPE_LIST})`;
|
|
24396
|
+
|
|
24397
|
+
// ../../packages/persistence/src/mod-policy-snapshot.ts
|
|
24398
|
+
import { createHash as createHash2 } from "crypto";
|
|
24399
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
24400
|
+
import { join as join4 } from "path";
|
|
25135
24401
|
|
|
25136
24402
|
// ../../packages/persistence/src/internal/json.ts
|
|
25137
24403
|
function parseJsonObject(s) {
|
|
@@ -25161,6 +24427,25 @@ var DB_EVENT_TYPE_TO_KIND = {
|
|
|
25161
24427
|
};
|
|
25162
24428
|
var TIMELINE_EVENT_TYPES = Object.keys(DB_EVENT_TYPE_TO_KIND).map((kind) => `'${kind}'`).join(", ");
|
|
25163
24429
|
var DEFAULT_HARNESS = HARNESS.ClaudeCode;
|
|
24430
|
+
var CALL_PROMPT_TOKENS = `(coalesce(input_tokens, 0) + coalesce(cache_read_input_tokens, 0)
|
|
24431
|
+
+ coalesce(ephemeral_1h_input_tokens, 0) + coalesce(ephemeral_5m_input_tokens, 0))`;
|
|
24432
|
+
var CALL_BAND = LONG_CONTEXT_THRESHOLDS.length === 0 ? "0" : LONG_CONTEXT_THRESHOLDS.map((t) => `(${CALL_PROMPT_TOKENS} > ${String(Math.trunc(t))})`).join(
|
|
24433
|
+
" + "
|
|
24434
|
+
);
|
|
24435
|
+
var LLM_USAGE_SELECT = `
|
|
24436
|
+
SELECT root_session_id AS sessionId,
|
|
24437
|
+
provider,
|
|
24438
|
+
model,
|
|
24439
|
+
service_tier AS serviceTier,
|
|
24440
|
+
coalesce(sum(input_tokens), 0) AS inputTokens,
|
|
24441
|
+
coalesce(sum(output_tokens), 0) AS outputTokens,
|
|
24442
|
+
coalesce(sum(cache_creation_input_tokens), 0) AS cacheCreationTokens,
|
|
24443
|
+
coalesce(sum(cache_read_input_tokens), 0) AS cacheReadTokens,
|
|
24444
|
+
coalesce(sum(ephemeral_1h_input_tokens), 0) AS ephemeral1hTokens,
|
|
24445
|
+
coalesce(sum(ephemeral_5m_input_tokens), 0) AS ephemeral5mTokens,
|
|
24446
|
+
coalesce(sum(web_search_requests), 0) AS webSearchRequests,
|
|
24447
|
+
coalesce(max(${CALL_PROMPT_TOKENS}), 0) AS promptTokens`;
|
|
24448
|
+
var LLM_USAGE_GROUP = `GROUP BY root_session_id, provider, model, service_tier, ${CALL_BAND}`;
|
|
25164
24449
|
|
|
25165
24450
|
// ../../packages/persistence/src/repositories/exceptions.ts
|
|
25166
24451
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
@@ -25214,31 +24499,31 @@ var FINDING_ROW_COLUMNS_SQL = `f.id AS id, d.rule_id AS rule_id, d.category AS c
|
|
|
25214
24499
|
f.line AS line, f.col AS col`;
|
|
25215
24500
|
|
|
25216
24501
|
// ../../packages/persistence/src/repositories/installed-packs.ts
|
|
25217
|
-
import { createHash as
|
|
24502
|
+
import { createHash as createHash3, randomUUID as randomUUID4 } from "crypto";
|
|
25218
24503
|
|
|
25219
24504
|
// ../../packages/persistence/src/policy-floor.ts
|
|
25220
|
-
import { readFileSync as
|
|
25221
|
-
import { join as
|
|
24505
|
+
import { readFileSync as readFileSync6 } from "fs";
|
|
24506
|
+
import { join as join7 } from "path";
|
|
25222
24507
|
|
|
25223
24508
|
// ../../packages/persistence/src/local-layout.ts
|
|
25224
24509
|
import { renameSync as renameSync3 } from "fs";
|
|
25225
24510
|
import { mkdir } from "fs/promises";
|
|
25226
24511
|
import { homedir } from "os";
|
|
25227
|
-
import { join as
|
|
24512
|
+
import { join as join5 } from "path";
|
|
25228
24513
|
function defaultDataDir() {
|
|
25229
|
-
return
|
|
24514
|
+
return join5(homedir(), ".aka");
|
|
25230
24515
|
}
|
|
25231
24516
|
function settingsDir(base = defaultDataDir()) {
|
|
25232
|
-
return
|
|
24517
|
+
return join5(base, "settings");
|
|
25233
24518
|
}
|
|
25234
24519
|
function dataDir(base = defaultDataDir()) {
|
|
25235
|
-
return
|
|
24520
|
+
return join5(base, "data");
|
|
25236
24521
|
}
|
|
25237
24522
|
function dbPath(base = defaultDataDir()) {
|
|
25238
|
-
return
|
|
24523
|
+
return join5(dataDir(base), "aka.db");
|
|
25239
24524
|
}
|
|
25240
24525
|
function keysDir(base = defaultDataDir()) {
|
|
25241
|
-
return
|
|
24526
|
+
return join5(base, "keys");
|
|
25242
24527
|
}
|
|
25243
24528
|
function ensureLayoutDirSync(dir = defaultDataDir()) {
|
|
25244
24529
|
ensureDataDirSync(dir);
|
|
@@ -25251,8 +24536,8 @@ function migrateLegacyLayout(base = defaultDataDir()) {
|
|
|
25251
24536
|
for (const { name, dest } of moves) {
|
|
25252
24537
|
try {
|
|
25253
24538
|
ensureDataDirSync(dest);
|
|
25254
|
-
const moved =
|
|
25255
|
-
renameSync3(
|
|
24539
|
+
const moved = join5(dest, name);
|
|
24540
|
+
renameSync3(join5(base, name), moved);
|
|
25256
24541
|
tightenFile(moved);
|
|
25257
24542
|
} catch {
|
|
25258
24543
|
}
|
|
@@ -25260,8 +24545,8 @@ function migrateLegacyLayout(base = defaultDataDir()) {
|
|
|
25260
24545
|
}
|
|
25261
24546
|
|
|
25262
24547
|
// ../../packages/persistence/src/settings.ts
|
|
25263
|
-
import { readFileSync as
|
|
25264
|
-
import { join as
|
|
24548
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
24549
|
+
import { join as join6 } from "path";
|
|
25265
24550
|
|
|
25266
24551
|
// ../../packages/persistence/src/file-lock.ts
|
|
25267
24552
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
@@ -25269,7 +24554,7 @@ import {
|
|
|
25269
24554
|
closeSync,
|
|
25270
24555
|
existsSync as existsSync2,
|
|
25271
24556
|
openSync,
|
|
25272
|
-
readFileSync as
|
|
24557
|
+
readFileSync as readFileSync3,
|
|
25273
24558
|
rmSync as rmSync5,
|
|
25274
24559
|
statSync as statSync3,
|
|
25275
24560
|
writeFileSync as writeFileSync2
|
|
@@ -25278,16 +24563,16 @@ import { hostname as hostname3 } from "os";
|
|
|
25278
24563
|
var PARK = new Int32Array(new SharedArrayBuffer(4));
|
|
25279
24564
|
|
|
25280
24565
|
// ../../packages/persistence/src/managed-settings.ts
|
|
25281
|
-
import { readFileSync as
|
|
24566
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
25282
24567
|
import { posix, win32 } from "path";
|
|
25283
|
-
function managedSettingsPaths(
|
|
25284
|
-
if (
|
|
24568
|
+
function managedSettingsPaths(platform = process.platform) {
|
|
24569
|
+
if (platform === "darwin") {
|
|
25285
24570
|
return [
|
|
25286
24571
|
posix.join("/Library", "Application Support", "AKASecurity", MANAGED_SETTINGS_FILENAME),
|
|
25287
24572
|
posix.join("/Library", "Managed Preferences", MANAGED_SETTINGS_FILENAME)
|
|
25288
24573
|
];
|
|
25289
24574
|
}
|
|
25290
|
-
if (
|
|
24575
|
+
if (platform === "win32") {
|
|
25291
24576
|
return [win32.join("C:\\", "ProgramData", "AKASecurity", MANAGED_SETTINGS_FILENAME)];
|
|
25292
24577
|
}
|
|
25293
24578
|
return [posix.join("/etc", "aka", MANAGED_SETTINGS_FILENAME)];
|
|
@@ -25297,7 +24582,7 @@ function readManagedSettings(paths = testOnlyManagedPaths ?? managedSettingsPath
|
|
|
25297
24582
|
for (const path of paths) {
|
|
25298
24583
|
let text;
|
|
25299
24584
|
try {
|
|
25300
|
-
text =
|
|
24585
|
+
text = readFileSync4(path, "utf8");
|
|
25301
24586
|
} catch {
|
|
25302
24587
|
continue;
|
|
25303
24588
|
}
|
|
@@ -25351,7 +24636,7 @@ function readWorkspaceSettings(base = defaultDataDir()) {
|
|
|
25351
24636
|
return overlayManagedSettings(readUserSettings(base), readManagedSettings());
|
|
25352
24637
|
}
|
|
25353
24638
|
function readUserSettings(base) {
|
|
25354
|
-
const record2 = readJson(
|
|
24639
|
+
const record2 = readJson(join6(settingsDir(base), SETTINGS_FILENAME));
|
|
25355
24640
|
if (!record2) return defaultWorkspaceSettings();
|
|
25356
24641
|
try {
|
|
25357
24642
|
return WorkspaceSettings.parse(record2);
|
|
@@ -25362,7 +24647,7 @@ function readUserSettings(base) {
|
|
|
25362
24647
|
function readJson(file2) {
|
|
25363
24648
|
let text;
|
|
25364
24649
|
try {
|
|
25365
|
-
text =
|
|
24650
|
+
text = readFileSync5(file2, "utf8");
|
|
25366
24651
|
} catch {
|
|
25367
24652
|
return null;
|
|
25368
24653
|
}
|
|
@@ -25436,39 +24721,39 @@ var CAPTURE_GRAIN = new Set(EventKind.options);
|
|
|
25436
24721
|
var DEFERRED_TAGS = new Set(DEFERRED_MIGRATION_TAGS);
|
|
25437
24722
|
|
|
25438
24723
|
// ../../packages/persistence/src/egress-wire.ts
|
|
25439
|
-
import { createHash as
|
|
24724
|
+
import { createHash as createHash4 } from "crypto";
|
|
25440
24725
|
var SLASH = "/".charCodeAt(0);
|
|
25441
24726
|
var SCOPE_KEY = printable(ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH);
|
|
25442
24727
|
|
|
25443
24728
|
// ../../packages/persistence/src/finding-key.ts
|
|
25444
|
-
import { createHash as
|
|
24729
|
+
import { createHash as createHash5 } from "crypto";
|
|
25445
24730
|
|
|
25446
24731
|
// ../../packages/persistence/src/fingerprint.ts
|
|
25447
24732
|
import { createHmac, randomBytes } from "crypto";
|
|
25448
|
-
import { existsSync as existsSync3, readFileSync as
|
|
25449
|
-
import { join as
|
|
25450
|
-
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
24733
|
+
import { existsSync as existsSync3, readFileSync as readFileSync7 } from "fs";
|
|
24734
|
+
import { join as join9 } from "path";
|
|
25451
24735
|
|
|
25452
24736
|
// ../../packages/persistence/src/forward-health.ts
|
|
25453
|
-
import { readFileSync as
|
|
25454
|
-
import { join as
|
|
24737
|
+
import { readFileSync as readFileSync8 } from "fs";
|
|
24738
|
+
import { join as join10 } from "path";
|
|
25455
24739
|
|
|
25456
24740
|
// ../../packages/persistence/src/history-backfill.ts
|
|
25457
24741
|
import { existsSync as existsSync4 } from "fs";
|
|
25458
|
-
import { join as
|
|
24742
|
+
import { join as join11 } from "path";
|
|
25459
24743
|
|
|
25460
24744
|
// ../../packages/persistence/src/history-preview.ts
|
|
25461
24745
|
import { existsSync as existsSync5 } from "fs";
|
|
25462
|
-
import { join as
|
|
25463
|
-
import { DatabaseSync as
|
|
24746
|
+
import { join as join12 } from "path";
|
|
24747
|
+
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
25464
24748
|
|
|
25465
24749
|
// ../../packages/persistence/src/history-sync-state.ts
|
|
25466
|
-
import { readFileSync as
|
|
25467
|
-
import { join as
|
|
24750
|
+
import { readFileSync as readFileSync9 } from "fs";
|
|
24751
|
+
import { join as join13 } from "path";
|
|
24752
|
+
var COUNTS_SCOPES = new Set(AttachmentMode.options);
|
|
25468
24753
|
|
|
25469
24754
|
// ../../packages/persistence/src/store-symlinks.ts
|
|
25470
24755
|
import { existsSync as existsSync6, lstatSync as lstatSync3, readlinkSync, realpathSync, statSync as statSync4 } from "fs";
|
|
25471
|
-
import { dirname as dirname3, join as
|
|
24756
|
+
import { dirname as dirname3, join as join14, resolve } from "path";
|
|
25472
24757
|
var STORE_DB = "the store database (including the prompt corpus)";
|
|
25473
24758
|
var STORE_SETTINGS = "your settings file";
|
|
25474
24759
|
function storeContents(home) {
|
|
@@ -25477,11 +24762,11 @@ function storeContents(home) {
|
|
|
25477
24762
|
[settingsDir(home), STORE_SETTINGS],
|
|
25478
24763
|
[dataDir(home), STORE_DB],
|
|
25479
24764
|
[keysDir(home), "the vault key"],
|
|
25480
|
-
[
|
|
24765
|
+
[join14(settingsDir(home), "settings.json"), STORE_SETTINGS],
|
|
25481
24766
|
[dbPath(home), STORE_DB]
|
|
25482
24767
|
]);
|
|
25483
24768
|
}
|
|
25484
|
-
function symlinkedStorePaths(home,
|
|
24769
|
+
function symlinkedStorePaths(home, platform = process.platform) {
|
|
25485
24770
|
return [...storeContents(home)].flatMap(([path, holds]) => {
|
|
25486
24771
|
try {
|
|
25487
24772
|
if (!lstatSync3(path).isSymbolicLink()) return [];
|
|
@@ -25493,7 +24778,7 @@ function symlinkedStorePaths(home, platform2 = process.platform) {
|
|
|
25493
24778
|
// existsSync follows the link, so a target that is gone reads as
|
|
25494
24779
|
// absent here while lstat above still sees the link itself.
|
|
25495
24780
|
missing: !existsSync6(path),
|
|
25496
|
-
mode: targetMode(path,
|
|
24781
|
+
mode: targetMode(path, platform)
|
|
25497
24782
|
}
|
|
25498
24783
|
];
|
|
25499
24784
|
} catch {
|
|
@@ -25508,8 +24793,8 @@ function linkTarget(path) {
|
|
|
25508
24793
|
return resolve(dirname3(path), readlinkSync(path));
|
|
25509
24794
|
}
|
|
25510
24795
|
}
|
|
25511
|
-
function targetMode(path,
|
|
25512
|
-
if (
|
|
24796
|
+
function targetMode(path, platform) {
|
|
24797
|
+
if (platform === "win32") return void 0;
|
|
25513
24798
|
try {
|
|
25514
24799
|
return statSync4(path).mode & 511;
|
|
25515
24800
|
} catch {
|
|
@@ -25529,15 +24814,15 @@ import {
|
|
|
25529
24814
|
// ../../packages/persistence/src/vault/key-provider.ts
|
|
25530
24815
|
import { execFileSync } from "child_process";
|
|
25531
24816
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
25532
|
-
import { chmodSync as chmodSync3, readFileSync as
|
|
25533
|
-
import { join as
|
|
24817
|
+
import { chmodSync as chmodSync3, readFileSync as readFileSync10, renameSync as renameSync4, rmSync as rmSync6, statSync as statSync5, writeFileSync as writeFileSync3 } from "fs";
|
|
24818
|
+
import { join as join15 } from "path";
|
|
25534
24819
|
|
|
25535
24820
|
// ../../packages/persistence/src/vault/vault.ts
|
|
25536
24821
|
import { randomBytes as randomBytes3, randomUUID as randomUUID12 } from "crypto";
|
|
25537
24822
|
|
|
25538
24823
|
// ../../packages/persistence/src/warn-era-cap.ts
|
|
25539
24824
|
import { existsSync as existsSync7, writeFileSync as writeFileSync4 } from "fs";
|
|
25540
|
-
import { join as
|
|
24825
|
+
import { join as join16 } from "path";
|
|
25541
24826
|
|
|
25542
24827
|
// ../../packages/plugin-sdk/src/provider-env.ts
|
|
25543
24828
|
var DEFAULT_ANTHROPIC_HOST = "api.anthropic.com";
|
|
@@ -25591,7 +24876,7 @@ function resolveProvider() {
|
|
|
25591
24876
|
function loadConfig(base = defaultDataDir(), resolveProviderFn = resolveProvider) {
|
|
25592
24877
|
try {
|
|
25593
24878
|
ensureLayoutDirSync(base);
|
|
25594
|
-
const settingsFile =
|
|
24879
|
+
const settingsFile = join17(settingsDir(base), "settings.json");
|
|
25595
24880
|
if (existsSync8(settingsFile)) tightenFile(settingsFile);
|
|
25596
24881
|
} catch {
|
|
25597
24882
|
}
|
|
@@ -25614,11 +24899,6 @@ function resolveProviderSafe(resolveProviderFn) {
|
|
|
25614
24899
|
}
|
|
25615
24900
|
}
|
|
25616
24901
|
|
|
25617
|
-
// ../../packages/plugin-sdk/src/config-inventory.ts
|
|
25618
|
-
import { readdirSync as readdirSync2, readFileSync as readFileSync11, realpathSync as realpathSync2, statSync as statSync7 } from "fs";
|
|
25619
|
-
import { homedir as homedir2 } from "os";
|
|
25620
|
-
import { basename as basename3, join as join18 } from "path";
|
|
25621
|
-
|
|
25622
24902
|
// ../../packages/detections/src/egress/registry.ts
|
|
25623
24903
|
var EXTRACTOR_VERSION = "3";
|
|
25624
24904
|
var PROVIDER_REGISTRY = [
|
|
@@ -26293,12 +25573,12 @@ var RegexMatcher2 = class {
|
|
|
26293
25573
|
rule.matcher,
|
|
26294
25574
|
() => new RegExp(pattern, flags.includes("d") ? flags : `${flags}d`)
|
|
26295
25575
|
);
|
|
26296
|
-
const
|
|
25576
|
+
const scanText = text.length > MAX_REGEX_INPUT_LENGTH ? text.slice(0, MAX_REGEX_INPUT_LENGTH) : text;
|
|
26297
25577
|
const spans = [];
|
|
26298
25578
|
let m;
|
|
26299
|
-
const maxIterations =
|
|
25579
|
+
const maxIterations = scanText.length + 1;
|
|
26300
25580
|
let iterations = 0;
|
|
26301
|
-
while ((m = re.exec(
|
|
25581
|
+
while ((m = re.exec(scanText)) !== null) {
|
|
26302
25582
|
if (++iterations > maxIterations) break;
|
|
26303
25583
|
const group = captureGroup != null ? m[captureGroup] : m[0];
|
|
26304
25584
|
if (m[0].length === 0) re.lastIndex++;
|
|
@@ -26451,26 +25731,45 @@ var POLYNOMIAL_PROBES = ["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].m
|
|
|
26451
25731
|
);
|
|
26452
25732
|
var CPU_CORROBORATION_SHARE = 0.2;
|
|
26453
25733
|
var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
|
|
26454
|
-
|
|
26455
|
-
|
|
26456
|
-
|
|
26457
|
-
|
|
26458
|
-
|
|
26459
|
-
|
|
26460
|
-
|
|
26461
|
-
|
|
26462
|
-
|
|
26463
|
-
|
|
26464
|
-
|
|
26465
|
-
|
|
26466
|
-
|
|
25734
|
+
function repeatTo(unit, length) {
|
|
25735
|
+
return unit.repeat(Math.ceil(length / unit.length)).slice(0, length);
|
|
25736
|
+
}
|
|
25737
|
+
function joinTo(length, open3, close, item) {
|
|
25738
|
+
const parts = [];
|
|
25739
|
+
let size = open3.length;
|
|
25740
|
+
for (let i = 0; size < length; i++) {
|
|
25741
|
+
const next = (i === 0 ? "" : ",") + item(i);
|
|
25742
|
+
parts.push(next);
|
|
25743
|
+
size += next.length;
|
|
25744
|
+
}
|
|
25745
|
+
return (open3 + parts.join("") + close).slice(0, length);
|
|
25746
|
+
}
|
|
25747
|
+
var SQL_WORDS = ["select", "insert", "update", "delete", "drop", "where"];
|
|
25748
|
+
var GROWTH_CORPORA = [
|
|
25749
|
+
{
|
|
25750
|
+
name: "one-line JSON dictionary",
|
|
25751
|
+
build: (length) => joinTo(length, "{", "}", (i) => `"id-${String(i)}":"label ${String(i)}"`)
|
|
25752
|
+
},
|
|
25753
|
+
{
|
|
25754
|
+
name: "JSON array of quoted SQL keywords",
|
|
25755
|
+
build: (length) => joinTo(length, "[", "]", (i) => `"${SQL_WORDS[i % SQL_WORDS.length] ?? ""} ${String(i)}"`)
|
|
25756
|
+
},
|
|
25757
|
+
{ name: "single-quoted keyword run ('where)", build: (length) => repeatTo("'where", length) },
|
|
25758
|
+
{ name: "double-quote run", build: (length) => repeatTo('"', length) },
|
|
25759
|
+
{ name: "space run", build: (length) => repeatTo(" ", length) },
|
|
25760
|
+
{ name: "newline run", build: (length) => repeatTo("\n", length) },
|
|
25761
|
+
...["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].map((unit) => ({
|
|
25762
|
+
name: `unit run ${JSON.stringify(unit)}`,
|
|
25763
|
+
build: (length) => repeatTo(unit, length)
|
|
25764
|
+
}))
|
|
25765
|
+
];
|
|
26467
25766
|
|
|
26468
25767
|
// ../../packages/plugin-sdk/src/hook-fail-opens.ts
|
|
26469
|
-
import { readFileSync as
|
|
26470
|
-
import { join as
|
|
25768
|
+
import { readFileSync as readFileSync11 } from "fs";
|
|
25769
|
+
import { join as join18 } from "path";
|
|
26471
25770
|
var HOOK_FAIL_OPENS_FILENAME = "hook-fail-opens.json";
|
|
26472
25771
|
function hookFailOpensPath(dataDir2) {
|
|
26473
|
-
return
|
|
25772
|
+
return join18(dataDir2, HOOK_FAIL_OPENS_FILENAME);
|
|
26474
25773
|
}
|
|
26475
25774
|
function recordHookFailOpen(dataDir2, nowMs) {
|
|
26476
25775
|
try {
|
|
@@ -26489,7 +25788,7 @@ function recordHookFailOpen(dataDir2, nowMs) {
|
|
|
26489
25788
|
}
|
|
26490
25789
|
function readHookFailOpens(dataDir2) {
|
|
26491
25790
|
try {
|
|
26492
|
-
const parsed = JSON.parse(
|
|
25791
|
+
const parsed = JSON.parse(readFileSync11(hookFailOpensPath(dataDir2), "utf8"));
|
|
26493
25792
|
if (typeof parsed !== "object" || parsed === null) return null;
|
|
26494
25793
|
const record2 = parsed;
|
|
26495
25794
|
if (!isPositiveSafeInteger(record2.failOpens)) return null;
|
|
@@ -26503,28 +25802,24 @@ function isPositiveSafeInteger(value) {
|
|
|
26503
25802
|
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
26504
25803
|
}
|
|
26505
25804
|
|
|
26506
|
-
// ../../packages/plugin-sdk/src/host-floor.ts
|
|
26507
|
-
import { readFileSync as readFileSync14 } from "fs";
|
|
26508
|
-
import { join as join21 } from "path";
|
|
26509
|
-
|
|
26510
25805
|
// ../../packages/plugin-sdk/src/model-governance.ts
|
|
26511
25806
|
import {
|
|
26512
25807
|
closeSync as closeSync2,
|
|
26513
25808
|
fstatSync,
|
|
26514
25809
|
mkdirSync as mkdirSync2,
|
|
26515
25810
|
openSync as openSync2,
|
|
26516
|
-
readFileSync as
|
|
25811
|
+
readFileSync as readFileSync12,
|
|
26517
25812
|
readSync,
|
|
26518
25813
|
writeFileSync as writeFileSync5
|
|
26519
25814
|
} from "fs";
|
|
26520
|
-
import { join as
|
|
25815
|
+
import { join as join19 } from "path";
|
|
26521
25816
|
var SESSION_MODEL_MARKER = "session-model";
|
|
26522
25817
|
function recordSessionModel(dataDir2, sessionId, model) {
|
|
26523
25818
|
if (sessionId === void 0 || sessionId === "") return;
|
|
26524
25819
|
if (model === void 0 || model === "") return;
|
|
26525
25820
|
try {
|
|
26526
25821
|
mkdirSync2(dataDir2, { recursive: true, mode: DATA_DIR_MODE });
|
|
26527
|
-
writeFileSync5(
|
|
25822
|
+
writeFileSync5(join19(dataDir2, SESSION_MODEL_MARKER), JSON.stringify({ sessionId, model }), {
|
|
26528
25823
|
encoding: "utf8",
|
|
26529
25824
|
mode: DATA_FILE_MODE
|
|
26530
25825
|
});
|
|
@@ -26536,7 +25831,7 @@ function readTail(path) {
|
|
|
26536
25831
|
const fd = openSync2(path, "r");
|
|
26537
25832
|
try {
|
|
26538
25833
|
const { size } = fstatSync(fd);
|
|
26539
|
-
if (size <= TAIL_BYTES) return { text:
|
|
25834
|
+
if (size <= TAIL_BYTES) return { text: readFileSync12(fd, "utf8"), truncated: false };
|
|
26540
25835
|
const buffer = Buffer.allocUnsafe(TAIL_BYTES);
|
|
26541
25836
|
let filled = 0;
|
|
26542
25837
|
while (filled < TAIL_BYTES) {
|
|
@@ -26581,105 +25876,18 @@ var codexModelFromRecord = (record2) => {
|
|
|
26581
25876
|
return typeof model === "string" && model !== "" ? model : void 0;
|
|
26582
25877
|
};
|
|
26583
25878
|
|
|
26584
|
-
// ../../packages/plugin-sdk/src/host-floor.ts
|
|
26585
|
-
var HOST_FEATURE = {
|
|
26586
|
-
ModelSwitch: "model-switch",
|
|
26587
|
-
VaultPointerDisplay: "vault-pointer-display"
|
|
26588
|
-
};
|
|
26589
|
-
var HOST_FLOORS = {
|
|
26590
|
-
[HOST_FEATURE.ModelSwitch]: {
|
|
26591
|
-
label: "model-switch protection",
|
|
26592
|
-
hookEvents: ["PreModelSwitch", "PostModelSwitch"],
|
|
26593
|
-
since: "2.1.251"
|
|
26594
|
-
},
|
|
26595
|
-
[HOST_FEATURE.VaultPointerDisplay]: {
|
|
26596
|
-
label: "vault pointer display",
|
|
26597
|
-
hookEvents: ["MessageDisplay"],
|
|
26598
|
-
since: "2.1.152"
|
|
26599
|
-
}
|
|
26600
|
-
};
|
|
26601
|
-
var ANTIGRAVITY_HOST_FEATURE = {
|
|
26602
|
-
EndOfTurnCapture: "end-of-turn-capture"
|
|
26603
|
-
};
|
|
26604
|
-
var ANTIGRAVITY_HOST_FLOORS = {
|
|
26605
|
-
[ANTIGRAVITY_HOST_FEATURE.EndOfTurnCapture]: {
|
|
26606
|
-
label: "end-of-turn history capture",
|
|
26607
|
-
hookEvents: ["Stop"],
|
|
26608
|
-
since: "1.1.10"
|
|
26609
|
-
}
|
|
26610
|
-
};
|
|
26611
|
-
|
|
26612
|
-
// ../../packages/plugin-sdk/src/ignore-layers.ts
|
|
26613
|
-
var import_ignore = __toESM(require_ignore(), 1);
|
|
26614
|
-
import { readFileSync as readFileSync15 } from "fs";
|
|
26615
|
-
import { join as join22 } from "path";
|
|
26616
|
-
|
|
26617
|
-
// ../../packages/plugin-sdk/src/inventory-resolver.ts
|
|
26618
|
-
import { arch, hostname as hostname4, platform, release } from "os";
|
|
26619
|
-
|
|
26620
|
-
// ../../packages/plugin-sdk/src/nudge.ts
|
|
26621
|
-
import { mkdirSync as mkdirSync3, readFileSync as readFileSync16, writeFileSync as writeFileSync6 } from "fs";
|
|
26622
|
-
import { join as join23 } from "path";
|
|
26623
|
-
|
|
26624
|
-
// ../../packages/plugin-sdk/src/paths.ts
|
|
26625
|
-
import { readdirSync as readdirSync3, realpathSync as realpathSync3 } from "fs";
|
|
26626
|
-
import { basename as basename4, dirname as dirname5, sep as sep3 } from "path";
|
|
26627
|
-
|
|
26628
|
-
// ../../packages/plugin-sdk/src/policy-resolver.ts
|
|
26629
|
-
import { randomUUID as randomUUID14 } from "crypto";
|
|
26630
|
-
|
|
26631
|
-
// ../../packages/plugin-sdk/src/project-files.ts
|
|
26632
|
-
import { existsSync as existsSync11, readdirSync as readdirSync4 } from "fs";
|
|
26633
|
-
import { basename as basename5, join as join24 } from "path";
|
|
26634
|
-
|
|
26635
|
-
// ../../packages/plugin-sdk/src/provider-env-antigravity.ts
|
|
26636
|
-
var optionalBaseUrl2 = external_exports.preprocess((v) => {
|
|
26637
|
-
if (typeof v === "string" && v.trim() === "") return void 0;
|
|
26638
|
-
return v;
|
|
26639
|
-
}, external_exports.string().optional()).catch(void 0);
|
|
26640
|
-
var optionalFlag = external_exports.preprocess((v) => {
|
|
26641
|
-
if (typeof v !== "string") return false;
|
|
26642
|
-
const normalized = v.trim().toLowerCase();
|
|
26643
|
-
return normalized !== "" && normalized !== "0" && normalized !== "false";
|
|
26644
|
-
}, external_exports.boolean()).catch(false);
|
|
26645
|
-
var antigravityProviderEnvShape = {
|
|
26646
|
-
GOOGLE_GENAI_USE_VERTEXAI: optionalFlag,
|
|
26647
|
-
GOOGLE_GEMINI_BASE_URL: optionalBaseUrl2
|
|
26648
|
-
};
|
|
26649
|
-
var AntigravityProviderEnvSchema = external_exports.object(antigravityProviderEnvShape);
|
|
26650
|
-
|
|
26651
|
-
// ../../packages/plugin-sdk/src/provider-env-codex.ts
|
|
26652
|
-
var optionalBaseUrl3 = external_exports.preprocess((v) => {
|
|
26653
|
-
if (typeof v === "string" && v.trim() === "") return void 0;
|
|
26654
|
-
return v;
|
|
26655
|
-
}, external_exports.string().optional()).catch(void 0);
|
|
26656
|
-
var codexProviderEnvShape = {
|
|
26657
|
-
OPENAI_BASE_URL: optionalBaseUrl3
|
|
26658
|
-
};
|
|
26659
|
-
var CodexProviderEnvSchema = external_exports.object(codexProviderEnvShape);
|
|
26660
|
-
|
|
26661
|
-
// ../../packages/plugin-sdk/src/runtime.ts
|
|
26662
|
-
import { randomUUID as randomUUID15 } from "crypto";
|
|
26663
|
-
|
|
26664
|
-
// ../../packages/plugin-sdk/src/scope-key.ts
|
|
26665
|
-
import { existsSync as existsSync12 } from "fs";
|
|
26666
|
-
import { dirname as dirname6, isAbsolute as isAbsolute2, join as join25, normalize } from "path";
|
|
26667
|
-
|
|
26668
|
-
// ../../packages/plugin-sdk/src/suppressions.ts
|
|
26669
|
-
var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
26670
|
-
|
|
26671
25879
|
// ../../packages/plugin-sdk/src/throttle.ts
|
|
26672
|
-
import { mkdirSync as
|
|
26673
|
-
import { join as
|
|
25880
|
+
import { mkdirSync as mkdirSync3, statSync as statSync6, writeFileSync as writeFileSync6 } from "fs";
|
|
25881
|
+
import { join as join20 } from "path";
|
|
26674
25882
|
function throttled(dataDir2, markerName, windowMs) {
|
|
26675
|
-
const marker =
|
|
25883
|
+
const marker = join20(dataDir2, markerName);
|
|
26676
25884
|
try {
|
|
26677
|
-
if (Date.now() -
|
|
25885
|
+
if (Date.now() - statSync6(marker).mtimeMs < windowMs) return true;
|
|
26678
25886
|
} catch {
|
|
26679
25887
|
}
|
|
26680
25888
|
try {
|
|
26681
|
-
|
|
26682
|
-
|
|
25889
|
+
mkdirSync3(dataDir2, { recursive: true, mode: DATA_DIR_MODE });
|
|
25890
|
+
writeFileSync6(marker, String(Date.now()), { mode: DATA_FILE_MODE });
|
|
26683
25891
|
} catch {
|
|
26684
25892
|
}
|
|
26685
25893
|
return false;
|
|
@@ -26687,21 +25895,21 @@ function throttled(dataDir2, markerName, windowMs) {
|
|
|
26687
25895
|
|
|
26688
25896
|
// src/history/reconcile-trigger.ts
|
|
26689
25897
|
import { spawn } from "child_process";
|
|
26690
|
-
import { dirname as
|
|
26691
|
-
import { fileURLToPath
|
|
25898
|
+
import { dirname as dirname4, join as join22 } from "path";
|
|
25899
|
+
import { fileURLToPath } from "url";
|
|
26692
25900
|
|
|
26693
25901
|
// src/history/tail.ts
|
|
26694
25902
|
import { createHash as createHash6 } from "crypto";
|
|
26695
25903
|
import {
|
|
26696
25904
|
closeSync as closeSync3,
|
|
26697
25905
|
fstatSync as fstatSync2,
|
|
26698
|
-
mkdirSync as
|
|
25906
|
+
mkdirSync as mkdirSync4,
|
|
26699
25907
|
openSync as openSync3,
|
|
26700
|
-
readFileSync as
|
|
25908
|
+
readFileSync as readFileSync13,
|
|
26701
25909
|
readSync as readSync2,
|
|
26702
|
-
writeFileSync as
|
|
25910
|
+
writeFileSync as writeFileSync7
|
|
26703
25911
|
} from "fs";
|
|
26704
|
-
import { join as
|
|
25912
|
+
import { join as join21 } from "path";
|
|
26705
25913
|
var SAFE_SESSION_ID = /^[A-Za-z0-9._-]+$/;
|
|
26706
25914
|
function safeSessionId(sessionId) {
|
|
26707
25915
|
if (SAFE_SESSION_ID.test(sessionId) && sessionId !== "." && sessionId !== "..") {
|
|
@@ -26717,8 +25925,8 @@ function triggerReconcile(dataDir2, sessionId, transcriptPath) {
|
|
|
26717
25925
|
try {
|
|
26718
25926
|
const marker = `${RECONCILE_MARKER_PREFIX}-${safeSessionId(sessionId)}`;
|
|
26719
25927
|
if (throttled(dataDir2, marker, RECONCILE_THROTTLE_MS)) return;
|
|
26720
|
-
const here =
|
|
26721
|
-
const child = spawn(process.execPath, [
|
|
25928
|
+
const here = dirname4(fileURLToPath(import.meta.url));
|
|
25929
|
+
const child = spawn(process.execPath, [join22(here, "reconcile.js"), sessionId, transcriptPath], {
|
|
26722
25930
|
detached: true,
|
|
26723
25931
|
stdio: "ignore"
|
|
26724
25932
|
});
|
|
@@ -26728,7 +25936,7 @@ function triggerReconcile(dataDir2, sessionId, transcriptPath) {
|
|
|
26728
25936
|
}
|
|
26729
25937
|
|
|
26730
25938
|
// src/hooks/shared.ts
|
|
26731
|
-
import { isAbsolute
|
|
25939
|
+
import { isAbsolute, normalize, resolve as resolvePath } from "path";
|
|
26732
25940
|
async function readStdin() {
|
|
26733
25941
|
return new Promise((resolve3) => {
|
|
26734
25942
|
let data = "";
|
|
@@ -26780,8 +25988,8 @@ function parseStopPayload(input2) {
|
|
|
26780
25988
|
}
|
|
26781
25989
|
|
|
26782
25990
|
// src/hooks/store-health.ts
|
|
26783
|
-
import { mkdirSync as
|
|
26784
|
-
import { dirname as
|
|
25991
|
+
import { mkdirSync as mkdirSync5, readFileSync as readFileSync18, writeFileSync as writeFileSync8 } from "fs";
|
|
25992
|
+
import { dirname as dirname6, join as join30 } from "path";
|
|
26785
25993
|
|
|
26786
25994
|
// ../../packages/remote/src/http.ts
|
|
26787
25995
|
import { request as httpRequest } from "http";
|
|
@@ -26795,44 +26003,45 @@ var SLASH2 = "/".charCodeAt(0);
|
|
|
26795
26003
|
var REQUEST_TIMEOUT_MS = 2e3;
|
|
26796
26004
|
|
|
26797
26005
|
// ../../packages/plugin-runtime/src/attached/forward-drops.ts
|
|
26798
|
-
import { readFileSync as
|
|
26799
|
-
import { join as
|
|
26006
|
+
import { readFileSync as readFileSync14 } from "fs";
|
|
26007
|
+
import { join as join23 } from "path";
|
|
26800
26008
|
|
|
26801
26009
|
// ../../packages/plugin-runtime/src/attached/forward-policy.ts
|
|
26802
|
-
import { randomUUID as
|
|
26010
|
+
import { randomUUID as randomUUID13 } from "crypto";
|
|
26803
26011
|
import { readFile, rename, writeFile } from "fs/promises";
|
|
26804
|
-
import { join as
|
|
26012
|
+
import { join as join24 } from "path";
|
|
26805
26013
|
|
|
26806
26014
|
// ../../packages/plugin-runtime/src/attached/history-sync.ts
|
|
26807
26015
|
import { createHash as createHash7 } from "crypto";
|
|
26808
|
-
import { hostname as
|
|
26016
|
+
import { hostname as hostname4 } from "os";
|
|
26809
26017
|
|
|
26810
26018
|
// ../../packages/plugin-runtime/src/attached/capture-rebuild.ts
|
|
26811
26019
|
var CORRELATION_ID = EventMetadata.shape.correlationId;
|
|
26812
26020
|
var TRACE_ID = EventMetadata.shape.traceId;
|
|
26813
26021
|
var EXCEPTION_ID = EventMetadata.shape.exceptionIds.unwrap().element;
|
|
26814
26022
|
var REDACT_DEGRADED_TO = EventMetadata.shape.redactDegradedTo.unwrap();
|
|
26023
|
+
var SCAN_INCOMPLETE = EventMetadata.shape.scanIncomplete.unwrap();
|
|
26815
26024
|
|
|
26816
26025
|
// ../../packages/plugin-runtime/src/attached/history-sync.ts
|
|
26817
26026
|
var CAPTURE_BATCH_BYTES = 1024 * 1024;
|
|
26818
26027
|
|
|
26819
26028
|
// ../../packages/plugin-runtime/src/attached/history-sync-trigger.ts
|
|
26820
26029
|
import { spawn as spawn2 } from "child_process";
|
|
26821
|
-
import { fileURLToPath as
|
|
26030
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
26822
26031
|
var HISTORY_SYNC_THROTTLE_MS = 5 * 60 * 1e3;
|
|
26823
26032
|
|
|
26824
26033
|
// ../../packages/plugin-runtime/src/attached/install-record.ts
|
|
26825
26034
|
import { readFile as readFile2, stat } from "fs/promises";
|
|
26826
|
-
import { basename as
|
|
26035
|
+
import { basename as basename2, dirname as dirname5, join as join25, resolve as resolve2 } from "path";
|
|
26827
26036
|
|
|
26828
26037
|
// ../../packages/plugin-runtime/src/attached/plugin-block.ts
|
|
26829
|
-
import { readFileSync as
|
|
26038
|
+
import { readFileSync as readFileSync15 } from "fs";
|
|
26830
26039
|
var INSTALL_RECORD_READ_TIMEOUT_MS = REQUEST_TIMEOUT_MS / 2;
|
|
26831
26040
|
|
|
26832
26041
|
// ../../packages/plugin-runtime/src/attached/policy-store.ts
|
|
26833
|
-
import { randomUUID as
|
|
26042
|
+
import { randomUUID as randomUUID14 } from "crypto";
|
|
26834
26043
|
import { readFile as readFile3, rm, writeFile as writeFile2 } from "fs/promises";
|
|
26835
|
-
import { join as
|
|
26044
|
+
import { join as join26 } from "path";
|
|
26836
26045
|
|
|
26837
26046
|
// ../../packages/plugin-runtime/src/attached/atomic-publish.ts
|
|
26838
26047
|
import { rename as rename2 } from "fs/promises";
|
|
@@ -26841,8 +26050,8 @@ var TIMED_RETRIES = 4;
|
|
|
26841
26050
|
var ATTEMPTS = 1 + IMMEDIATE_RETRIES + TIMED_RETRIES;
|
|
26842
26051
|
|
|
26843
26052
|
// ../../packages/plugin-runtime/src/attached/posture-report-state.ts
|
|
26844
|
-
import { readFileSync as
|
|
26845
|
-
import { join as
|
|
26053
|
+
import { readFileSync as readFileSync16 } from "fs";
|
|
26054
|
+
import { join as join27 } from "path";
|
|
26846
26055
|
var OUTCOME_KEYS = {
|
|
26847
26056
|
ok: true,
|
|
26848
26057
|
unauthorized: true,
|
|
@@ -26859,17 +26068,17 @@ var OUTCOMES = new Set(Object.keys(OUTCOME_KEYS));
|
|
|
26859
26068
|
var POSTURE_REPORT_INTERVAL_MS = 60 * 60 * 1e3;
|
|
26860
26069
|
|
|
26861
26070
|
// ../../packages/plugin-runtime/src/attached/posture-snapshot.ts
|
|
26862
|
-
import { statSync as
|
|
26863
|
-
import { DatabaseSync as
|
|
26071
|
+
import { statSync as statSync7 } from "fs";
|
|
26072
|
+
import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
26864
26073
|
|
|
26865
26074
|
// ../../packages/plugin-runtime/src/attached/posture-store.ts
|
|
26866
|
-
import { randomUUID as
|
|
26075
|
+
import { randomUUID as randomUUID15 } from "crypto";
|
|
26867
26076
|
import { readFile as readFile4, rm as rm2, writeFile as writeFile3 } from "fs/promises";
|
|
26868
|
-
import { join as
|
|
26077
|
+
import { join as join28 } from "path";
|
|
26869
26078
|
|
|
26870
26079
|
// ../../packages/plugin-runtime/src/attached/sync-state.ts
|
|
26871
|
-
import { readFileSync as
|
|
26872
|
-
import { join as
|
|
26080
|
+
import { readFileSync as readFileSync17 } from "fs";
|
|
26081
|
+
import { join as join29 } from "path";
|
|
26873
26082
|
|
|
26874
26083
|
// ../../packages/plugin-runtime/src/attached/status.ts
|
|
26875
26084
|
var REFUSAL_LINES = {
|
|
@@ -26887,7 +26096,7 @@ var OUTCOME_LINES = {
|
|
|
26887
26096
|
|
|
26888
26097
|
// ../../packages/plugin-runtime/src/attached/sync-trigger.ts
|
|
26889
26098
|
import { spawn as spawn3 } from "child_process";
|
|
26890
|
-
import { fileURLToPath as
|
|
26099
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
26891
26100
|
var SYNC_THROTTLE_MS = 15 * 60 * 1e3;
|
|
26892
26101
|
|
|
26893
26102
|
// ../../packages/plugin-runtime/src/content-retention-pass.ts
|
|
@@ -26895,25 +26104,25 @@ var MAX_ROWS_PER_SWEEP = 50 * 1e3;
|
|
|
26895
26104
|
|
|
26896
26105
|
// ../../packages/plugin-runtime/src/content-retention-trigger.ts
|
|
26897
26106
|
import { spawn as spawn4 } from "child_process";
|
|
26898
|
-
import { fileURLToPath as
|
|
26107
|
+
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
26899
26108
|
var CONTENT_RETENTION_THROTTLE_MS = 60 * 60 * 1e3;
|
|
26900
26109
|
|
|
26901
26110
|
// ../../packages/plugin-runtime/src/attached/factory.ts
|
|
26902
|
-
import { hostname as
|
|
26111
|
+
import { hostname as hostname5 } from "os";
|
|
26903
26112
|
|
|
26904
26113
|
// ../../packages/plugin-runtime/src/handle-session-start.ts
|
|
26905
|
-
import { randomUUID as
|
|
26114
|
+
import { randomUUID as randomUUID16 } from "crypto";
|
|
26906
26115
|
var EXCEPTION_RETENTION_MS = 90 * 24 * 60 * 60 * 1e3;
|
|
26907
26116
|
|
|
26908
26117
|
// src/hooks/store-health.ts
|
|
26909
26118
|
var STORE_REDIRECT_MARKER = "store-redirect-last-session";
|
|
26910
26119
|
function markerDirs(dataDir2) {
|
|
26911
|
-
return [dataDir2,
|
|
26120
|
+
return [dataDir2, dirname6(dataDir2)];
|
|
26912
26121
|
}
|
|
26913
26122
|
function alreadyClaimed(dirs, marker, sessionId) {
|
|
26914
26123
|
return dirs.some((dir) => {
|
|
26915
26124
|
try {
|
|
26916
|
-
return
|
|
26125
|
+
return readFileSync18(join30(dir, marker), "utf8") === sessionId;
|
|
26917
26126
|
} catch {
|
|
26918
26127
|
return false;
|
|
26919
26128
|
}
|
|
@@ -26922,14 +26131,14 @@ function alreadyClaimed(dirs, marker, sessionId) {
|
|
|
26922
26131
|
function recordClaim(dirs, marker, sessionId) {
|
|
26923
26132
|
for (const dir of dirs) {
|
|
26924
26133
|
try {
|
|
26925
|
-
|
|
26926
|
-
|
|
26134
|
+
mkdirSync5(dir, { recursive: true, mode: DATA_DIR_MODE });
|
|
26135
|
+
writeFileSync8(join30(dir, marker), sessionId, { mode: DATA_FILE_MODE });
|
|
26927
26136
|
return;
|
|
26928
26137
|
} catch {
|
|
26929
26138
|
}
|
|
26930
26139
|
}
|
|
26931
26140
|
}
|
|
26932
|
-
function storeRedirectedMessage(paths,
|
|
26141
|
+
function storeRedirectedMessage(paths, platform = process.platform) {
|
|
26933
26142
|
const where = paths.map(({ path, target, holds, missing, mode }) => {
|
|
26934
26143
|
if (missing) return `${path} -> ${target} (which does not exist; ${holds} cannot land there)`;
|
|
26935
26144
|
const loose = mode !== void 0 && (mode & 63) !== 0 ? ", NOT owner-only" : "";
|
|
@@ -26939,7 +26148,7 @@ function storeRedirectedMessage(paths, platform2 = process.platform) {
|
|
|
26939
26148
|
const subject = paths.length === 1 ? "a store path is a symlink" : `${String(paths.length)} store paths are symlinks`;
|
|
26940
26149
|
const anyResolves = paths.some(({ missing }) => !missing);
|
|
26941
26150
|
const lead = anyResolves ? `${subject}, so AKA is writing into the target instead: ${where}. ` : `${subject} resolving nowhere, so AKA cannot write there: ${where}. `;
|
|
26942
|
-
const kept = anyResolves &&
|
|
26151
|
+
const kept = anyResolves && platform !== "win32" ? "Permissions are never changed through a symlink, so the store keeps whatever the target already had. " : "";
|
|
26943
26152
|
return `[aka] ${lead}${kept}If you did not create that link, treat it as untrusted and run \`aka init\` for the full report.
|
|
26944
26153
|
`;
|
|
26945
26154
|
}
|
|
@@ -26948,7 +26157,7 @@ function formatMode(mode) {
|
|
|
26948
26157
|
}
|
|
26949
26158
|
function warnIfStoreRedirected(config2, sessionId, write = (message) => void process.stderr.write(message)) {
|
|
26950
26159
|
try {
|
|
26951
|
-
const paths = symlinkedStorePaths(
|
|
26160
|
+
const paths = symlinkedStorePaths(dirname6(config2.dataDir));
|
|
26952
26161
|
if (paths.length === 0) return;
|
|
26953
26162
|
if (!sessionId) {
|
|
26954
26163
|
write(storeRedirectedMessage(paths));
|