@akasecurity/ai-tc-codex 0.9.16 → 0.9.17-beta.1
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 +5 -5
- package/scripts/apply-suppressions.js +678 -1252
- package/scripts/backfill.js +879 -1267
- package/scripts/content-retention.js +761 -2073
- package/scripts/filescan.js +1105 -473
- package/scripts/firstrun.js +1215 -1690
- package/scripts/history-sync.js +750 -2106
- package/scripts/intro.js +123 -2189
- package/scripts/onboard.js +2755 -1185
- package/scripts/post-tool-use.js +1302 -1696
- package/scripts/pre-tool-use.js +903 -1295
- package/scripts/query.js +1215 -1690
- package/scripts/reconcile.js +835 -1277
- package/scripts/remediate.js +920 -1317
- package/scripts/scan-worker.js +97 -13
- package/scripts/session-start.js +1819 -816
- package/scripts/start-light.js +127 -1360
- package/scripts/stop.js +271 -1112
- package/scripts/sync.js +1657 -1005
- package/scripts/user-prompt-submit.js +1042 -1404
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",
|
|
@@ -22293,8 +21451,9 @@ var SessionTokenReport = external_exports.object({
|
|
|
22293
21451
|
totalTokens: external_exports.number().int().nonnegative(),
|
|
22294
21452
|
// Σ of the PRICED rollups only; null when no rollup had a known price.
|
|
22295
21453
|
estimatedCostUsd: external_exports.number().nullable(),
|
|
22296
|
-
// True whenever any
|
|
22297
|
-
//
|
|
21454
|
+
// True whenever any call priced to null (an unknown provider/model, or a call
|
|
21455
|
+
// over a long-context threshold whose rate is unpublished), so the total
|
|
21456
|
+
// understates real spend — the UI renders `≥ $X` instead of a falsely
|
|
22298
21457
|
// precise figure rather than silently dropping the unpriced calls.
|
|
22299
21458
|
costIsPartial: external_exports.boolean()
|
|
22300
21459
|
});
|
|
@@ -23140,7 +22299,15 @@ var StorePostureSnapshot = external_exports.object({
|
|
|
23140
22299
|
policyCounts: StorePosturePolicyCounts,
|
|
23141
22300
|
// OPTIONAL, not nullable: a reporter that predates this member keeps
|
|
23142
22301
|
// getting its 200 without a payload change.
|
|
23143
|
-
plugin: StorePosturePlugin.optional()
|
|
22302
|
+
plugin: StorePosturePlugin.optional(),
|
|
22303
|
+
// OPTIONAL, and sent only by a scoped attachment, always as `scoped`. A
|
|
22304
|
+
// machine attachment omits it, so its body is byte for byte the one it
|
|
22305
|
+
// sent before this member existed. Absent therefore means machine-wide OR
|
|
22306
|
+
// a reporter older than this member, never "scoped". Both values parse, so
|
|
22307
|
+
// a sender that one day spells `machine` breaks no receiver; any other
|
|
22308
|
+
// value fails the whole snapshot, which is why the reporter sends a
|
|
22309
|
+
// constant and never the raw mode.
|
|
22310
|
+
attachmentMode: AttachmentMode.optional()
|
|
23144
22311
|
}).meta({ id: "StorePostureSnapshot" });
|
|
23145
22312
|
var CAPTURE_VERSION_PREFIX = "capture/";
|
|
23146
22313
|
var RecordAuditEventRequest = AuditEventInput.extend({
|
|
@@ -23587,7 +22754,7 @@ var Rule = external_exports.strictObject({
|
|
|
23587
22754
|
postValidators: external_exports.array(PostValidatorRef).optional(),
|
|
23588
22755
|
requiresNearby: RequiresNearby.optional(),
|
|
23589
22756
|
examples: external_exports.array(external_exports.string()).optional(),
|
|
23590
|
-
// Whether the matched text is itself sensitive
|
|
22757
|
+
// Whether the matched text is itself sensitive (see RuleEvidence).
|
|
23591
22758
|
evidence: RuleEvidence.optional()
|
|
23592
22759
|
}).meta({ id: "Rule" });
|
|
23593
22760
|
var Author = external_exports.object({
|
|
@@ -23679,7 +22846,13 @@ var DetectionRule = external_exports.object({
|
|
|
23679
22846
|
// Representative matching strings the rule author shipped with the rule. The
|
|
23680
22847
|
// cheapest honest answer to "show me what this rule catches" — every bundled
|
|
23681
22848
|
// rule has them, and they are already in the stored snapshot.
|
|
23682
|
-
examples: external_exports.array(external_exports.string()).optional()
|
|
22849
|
+
examples: external_exports.array(external_exports.string()).optional(),
|
|
22850
|
+
// The rule's DECLARED evidence, as stored. Absent defers to the engine's
|
|
22851
|
+
// classification (ruleEvidence in @akasecurity/detections): a bundled
|
|
22852
|
+
// code-flaw rule reads as 'code' and anything else as 'value', and a rule
|
|
22853
|
+
// in a value category (secret/pii/financial/phi) is always 'value',
|
|
22854
|
+
// whatever it declares.
|
|
22855
|
+
evidence: RuleEvidence.optional()
|
|
23683
22856
|
}).meta({ id: "DetectionRule" });
|
|
23684
22857
|
var DetectionUpdate = external_exports.object({
|
|
23685
22858
|
available: external_exports.boolean(),
|
|
@@ -23945,11 +23118,14 @@ var PolicyBundle = external_exports.object({
|
|
|
23945
23118
|
ruleVersions: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
23946
23119
|
// Model ids (the raw `model` string a harness reports, e.g.
|
|
23947
23120
|
// `claude-opus-4-1`) the tenant has PROHIBITED. The plugin refuses to switch
|
|
23948
|
-
// a session onto one (PreModelSwitch)
|
|
23949
|
-
//
|
|
23950
|
-
//
|
|
23951
|
-
//
|
|
23952
|
-
//
|
|
23121
|
+
// a session onto one (PreModelSwitch), refuses a turn that would run on one
|
|
23122
|
+
// (UserPromptSubmit) and refuses a subagent spawn onto one (PreToolUse),
|
|
23123
|
+
// wherever the organization governs the event: everywhere on a
|
|
23124
|
+
// machine-wide attachment, and only in enrolled repositories on a scoped
|
|
23125
|
+
// one (the plugin runtime's `governanceApplies`).
|
|
23126
|
+
// Optional so an older backend — and an older on-disk cache — still
|
|
23127
|
+
// parses; consumers read `?? []`, which is the unenforced behaviour that
|
|
23128
|
+
// predates this field and the safe direction to default.
|
|
23953
23129
|
//
|
|
23954
23130
|
// Ids, not display names: the governance decision is keyed on the exact
|
|
23955
23131
|
// string the harness reports (`model_status_override.versionId` in the
|
|
@@ -24291,6 +23467,8 @@ var AttachmentScopeEntry = external_exports.object({
|
|
|
24291
23467
|
});
|
|
24292
23468
|
var AttachmentScope = external_exports.object({
|
|
24293
23469
|
endpoint: external_exports.string().min(1),
|
|
23470
|
+
tenantName: PluginWhoami.shape.tenantName.optional(),
|
|
23471
|
+
userEmail: PluginWhoami.shape.userEmail.optional(),
|
|
24294
23472
|
entries: external_exports.array(AttachmentScopeEntry)
|
|
24295
23473
|
});
|
|
24296
23474
|
var AttachmentScopeEnvelope = AttachmentScope.extend({ entries: external_exports.array(external_exports.unknown()) });
|
|
@@ -24503,6 +23681,27 @@ var ManagedSettings = external_exports.object({
|
|
|
24503
23681
|
};
|
|
24504
23682
|
}).meta({ id: "ManagedSettings" });
|
|
24505
23683
|
|
|
23684
|
+
// ../../packages/schema/src/zod/mod-policy-snapshot.ts
|
|
23685
|
+
var MOD_POLICY_SNAPSHOT_VERSION = 1;
|
|
23686
|
+
var MOD_POLICY_SNAPSHOT_MAX_BYTES = 4 * 1024 * 1024;
|
|
23687
|
+
var ModPolicySnapshot = external_exports.object({
|
|
23688
|
+
version: external_exports.literal(MOD_POLICY_SNAPSHOT_VERSION),
|
|
23689
|
+
generatedAt: external_exports.iso.datetime(),
|
|
23690
|
+
// The complete effective ruleset, as the hook's runtime scans with it: the
|
|
23691
|
+
// user's enabled installed packs (user-modified and custom packs included).
|
|
23692
|
+
// Absent means the store holds no authoritative snapshot, and the reader
|
|
23693
|
+
// scans with the packs it ships — the hook's own fallback.
|
|
23694
|
+
rules: external_exports.array(Rule).optional(),
|
|
23695
|
+
// Rule-targeted actions (first enabled policy per rule wins).
|
|
23696
|
+
ruleActions: external_exports.record(external_exports.string(), ActionTaken),
|
|
23697
|
+
// The resolved action per detection category.
|
|
23698
|
+
categoryActions: external_exports.record(external_exports.string(), ActionTaken),
|
|
23699
|
+
// Rules with an active exception grant. Honouring a grant means matching a
|
|
23700
|
+
// keyed fingerprint of the value and consuming a use, which only the hook can
|
|
23701
|
+
// do, so the mod leaves a finding of one of these rules for the hook to decide.
|
|
23702
|
+
exceptionRuleIds: external_exports.array(external_exports.string())
|
|
23703
|
+
}).meta({ id: "ModPolicySnapshot" });
|
|
23704
|
+
|
|
24506
23705
|
// ../../packages/schema/src/zod/project-files.ts
|
|
24507
23706
|
var ProjectFileInput = external_exports.object({
|
|
24508
23707
|
path: external_exports.string().min(1),
|
|
@@ -24817,7 +24016,16 @@ var AttachInput = external_exports.object({
|
|
|
24817
24016
|
// 200 matches the tenantName bound beside it in control-plane.ts; nothing
|
|
24818
24017
|
// renders a longer one usefully.
|
|
24819
24018
|
label: printable(200).optional(),
|
|
24820
|
-
accessKey: external_exports.string()
|
|
24019
|
+
accessKey: external_exports.string(),
|
|
24020
|
+
// How much of this machine the attachment is for: everything, or only the
|
|
24021
|
+
// repositories its user enrolls. Optional, so an input without it still
|
|
24022
|
+
// parses; what an absent mode means is for whatever reads it to decide, not
|
|
24023
|
+
// this shape. This member validates the VALUE rather than leaving that to the
|
|
24024
|
+
// call site, a deliberate exception to this module's shape-only rule: a shape
|
|
24025
|
+
// rejection names the field, so a value that is not a mode is refused as a bad
|
|
24026
|
+
// `mode` rather than stripped or passed on. The dashboard's attach action reads
|
|
24027
|
+
// it as the mode to attach in.
|
|
24028
|
+
mode: AttachmentMode.optional()
|
|
24821
24029
|
});
|
|
24822
24030
|
|
|
24823
24031
|
// ../../packages/schema/src/zod/triage.ts
|
|
@@ -25030,6 +24238,14 @@ var CAPTURE_STATUS_RECENCY_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
|
25030
24238
|
var CAPTURE_STATUS_RECENCY_DAYS = CAPTURE_STATUS_RECENCY_MS / (24 * 60 * 60 * 1e3);
|
|
25031
24239
|
var CAPTURE_STATUS_DOCUMENT_QUIET_MS = 12 * 60 * 60 * 1e3;
|
|
25032
24240
|
|
|
24241
|
+
// ../../packages/persistence/src/attached-derived.ts
|
|
24242
|
+
import { rmSync } from "fs";
|
|
24243
|
+
import { join } from "path";
|
|
24244
|
+
|
|
24245
|
+
// ../../packages/persistence/src/control-plane-credential.ts
|
|
24246
|
+
import { chmodSync as chmodSync2, lstatSync as lstatSync2, readFileSync, rmSync as rmSync3, statSync } from "fs";
|
|
24247
|
+
import { join as join2 } from "path";
|
|
24248
|
+
|
|
25033
24249
|
// ../../packages/persistence/src/paths.ts
|
|
25034
24250
|
import {
|
|
25035
24251
|
chmodSync,
|
|
@@ -25093,11 +24309,12 @@ function writeOwnerOnlyFileSync(file2, data) {
|
|
|
25093
24309
|
|
|
25094
24310
|
// ../../packages/persistence/src/database.ts
|
|
25095
24311
|
import { randomUUID as randomUUID11 } from "crypto";
|
|
25096
|
-
import { dirname as dirname2, join as
|
|
24312
|
+
import { dirname as dirname2, join as join8, sep } from "path";
|
|
25097
24313
|
import { DatabaseSync } from "node:sqlite";
|
|
25098
24314
|
|
|
25099
24315
|
// ../../packages/persistence/src/ids.ts
|
|
25100
24316
|
import { createHash } from "crypto";
|
|
24317
|
+
var DOT = ".".charCodeAt(0);
|
|
25101
24318
|
|
|
25102
24319
|
// ../../packages/persistence/src/internal/snapshot.ts
|
|
25103
24320
|
import { randomUUID } from "crypto";
|
|
@@ -25120,6 +24337,7 @@ var SYNC_FAILURE_REASONS = SyncFailureReason.options;
|
|
|
25120
24337
|
// ../../packages/persistence/src/repositories/history-sync.ts
|
|
25121
24338
|
var STRUCTURAL_EVENT_TYPES = ["session", "llm_call", "tool_call"];
|
|
25122
24339
|
var TYPE_LIST = STRUCTURAL_EVENT_TYPES.map((t) => `'${t}'`).join(", ");
|
|
24340
|
+
var CAPTURE_TYPE_LIST = OUTBOX_CAPTURE_TYPE_LIST;
|
|
25123
24341
|
var COUNTED_EVENT_TYPES = [
|
|
25124
24342
|
...STRUCTURAL_EVENT_TYPES,
|
|
25125
24343
|
...OUTBOX_CAPTURE_EVENT_TYPES
|
|
@@ -25132,6 +24350,37 @@ var COUNTED_SCOPE = `
|
|
|
25132
24350
|
OR synced_at IS NOT NULL
|
|
25133
24351
|
OR outbox_owed = 1
|
|
25134
24352
|
)`;
|
|
24353
|
+
var SKIPPED = -1;
|
|
24354
|
+
function inScope(column) {
|
|
24355
|
+
return `${column} IN (SELECT value FROM json_each(:scopeKeys))`;
|
|
24356
|
+
}
|
|
24357
|
+
var ROOT_SCOPE_KEY = `(SELECT session_root.scope_key
|
|
24358
|
+
FROM audit_events AS session_root
|
|
24359
|
+
WHERE session_root.id = COALESCE(audit_events.root_session_id, audit_events.id))`;
|
|
24360
|
+
var COUNTED_IN_SCOPE = `
|
|
24361
|
+
AND ${inScope("scope_key")}
|
|
24362
|
+
AND (event_type IN (${CAPTURE_TYPE_LIST}) OR ${inScope(ROOT_SCOPE_KEY)})`;
|
|
24363
|
+
var DRAIN_TOTALS = `SELECT
|
|
24364
|
+
SUM(CASE WHEN synced_at IS NULL AND started_at < :before THEN 1 ELSE 0 END) AS pending,
|
|
24365
|
+
SUM(CASE WHEN synced_at > 0 THEN 1 ELSE 0 END) AS sent,
|
|
24366
|
+
SUM(CASE WHEN synced_at = ${String(SKIPPED)}
|
|
24367
|
+
AND (sync_failure IS NULL OR sync_failure = 'payload_invalid')
|
|
24368
|
+
THEN 1 ELSE 0 END) AS skipped,
|
|
24369
|
+
SUM(CASE WHEN synced_at = ${String(SKIPPED)}
|
|
24370
|
+
AND sync_failure = 'deployment_refused' THEN 1 ELSE 0 END) AS refused,
|
|
24371
|
+
SUM(CASE WHEN synced_at = ${String(SKIPPED)}
|
|
24372
|
+
AND sync_failure = 'detached_undelivered' THEN 1 ELSE 0 END) AS detached
|
|
24373
|
+
FROM audit_events
|
|
24374
|
+
WHERE event_type IN (${TYPE_LIST})`;
|
|
24375
|
+
var CAPTURE_SKIPS = `SELECT COUNT(*) AS skipped
|
|
24376
|
+
FROM audit_events
|
|
24377
|
+
WHERE synced_at = ${String(SKIPPED)}
|
|
24378
|
+
AND event_type IN (${CAPTURE_TYPE_LIST})`;
|
|
24379
|
+
|
|
24380
|
+
// ../../packages/persistence/src/mod-policy-snapshot.ts
|
|
24381
|
+
import { createHash as createHash2 } from "crypto";
|
|
24382
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
24383
|
+
import { join as join4 } from "path";
|
|
25135
24384
|
|
|
25136
24385
|
// ../../packages/persistence/src/internal/json.ts
|
|
25137
24386
|
function parseJsonObject(s) {
|
|
@@ -25161,6 +24410,25 @@ var DB_EVENT_TYPE_TO_KIND = {
|
|
|
25161
24410
|
};
|
|
25162
24411
|
var TIMELINE_EVENT_TYPES = Object.keys(DB_EVENT_TYPE_TO_KIND).map((kind) => `'${kind}'`).join(", ");
|
|
25163
24412
|
var DEFAULT_HARNESS = HARNESS.ClaudeCode;
|
|
24413
|
+
var CALL_PROMPT_TOKENS = `(coalesce(input_tokens, 0) + coalesce(cache_read_input_tokens, 0)
|
|
24414
|
+
+ coalesce(ephemeral_1h_input_tokens, 0) + coalesce(ephemeral_5m_input_tokens, 0))`;
|
|
24415
|
+
var CALL_BAND = LONG_CONTEXT_THRESHOLDS.length === 0 ? "0" : LONG_CONTEXT_THRESHOLDS.map((t) => `(${CALL_PROMPT_TOKENS} > ${String(Math.trunc(t))})`).join(
|
|
24416
|
+
" + "
|
|
24417
|
+
);
|
|
24418
|
+
var LLM_USAGE_SELECT = `
|
|
24419
|
+
SELECT root_session_id AS sessionId,
|
|
24420
|
+
provider,
|
|
24421
|
+
model,
|
|
24422
|
+
service_tier AS serviceTier,
|
|
24423
|
+
coalesce(sum(input_tokens), 0) AS inputTokens,
|
|
24424
|
+
coalesce(sum(output_tokens), 0) AS outputTokens,
|
|
24425
|
+
coalesce(sum(cache_creation_input_tokens), 0) AS cacheCreationTokens,
|
|
24426
|
+
coalesce(sum(cache_read_input_tokens), 0) AS cacheReadTokens,
|
|
24427
|
+
coalesce(sum(ephemeral_1h_input_tokens), 0) AS ephemeral1hTokens,
|
|
24428
|
+
coalesce(sum(ephemeral_5m_input_tokens), 0) AS ephemeral5mTokens,
|
|
24429
|
+
coalesce(sum(web_search_requests), 0) AS webSearchRequests,
|
|
24430
|
+
coalesce(max(${CALL_PROMPT_TOKENS}), 0) AS promptTokens`;
|
|
24431
|
+
var LLM_USAGE_GROUP = `GROUP BY root_session_id, provider, model, service_tier, ${CALL_BAND}`;
|
|
25164
24432
|
|
|
25165
24433
|
// ../../packages/persistence/src/repositories/exceptions.ts
|
|
25166
24434
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
@@ -25214,31 +24482,31 @@ var FINDING_ROW_COLUMNS_SQL = `f.id AS id, d.rule_id AS rule_id, d.category AS c
|
|
|
25214
24482
|
f.line AS line, f.col AS col`;
|
|
25215
24483
|
|
|
25216
24484
|
// ../../packages/persistence/src/repositories/installed-packs.ts
|
|
25217
|
-
import { createHash as
|
|
24485
|
+
import { createHash as createHash3, randomUUID as randomUUID4 } from "crypto";
|
|
25218
24486
|
|
|
25219
24487
|
// ../../packages/persistence/src/policy-floor.ts
|
|
25220
|
-
import { readFileSync as
|
|
25221
|
-
import { join as
|
|
24488
|
+
import { readFileSync as readFileSync6 } from "fs";
|
|
24489
|
+
import { join as join7 } from "path";
|
|
25222
24490
|
|
|
25223
24491
|
// ../../packages/persistence/src/local-layout.ts
|
|
25224
24492
|
import { renameSync as renameSync3 } from "fs";
|
|
25225
24493
|
import { mkdir } from "fs/promises";
|
|
25226
24494
|
import { homedir } from "os";
|
|
25227
|
-
import { join as
|
|
24495
|
+
import { join as join5 } from "path";
|
|
25228
24496
|
function defaultDataDir() {
|
|
25229
|
-
return
|
|
24497
|
+
return join5(homedir(), ".aka");
|
|
25230
24498
|
}
|
|
25231
24499
|
function settingsDir(base = defaultDataDir()) {
|
|
25232
|
-
return
|
|
24500
|
+
return join5(base, "settings");
|
|
25233
24501
|
}
|
|
25234
24502
|
function dataDir(base = defaultDataDir()) {
|
|
25235
|
-
return
|
|
24503
|
+
return join5(base, "data");
|
|
25236
24504
|
}
|
|
25237
24505
|
function dbPath(base = defaultDataDir()) {
|
|
25238
|
-
return
|
|
24506
|
+
return join5(dataDir(base), "aka.db");
|
|
25239
24507
|
}
|
|
25240
24508
|
function keysDir(base = defaultDataDir()) {
|
|
25241
|
-
return
|
|
24509
|
+
return join5(base, "keys");
|
|
25242
24510
|
}
|
|
25243
24511
|
function ensureLayoutDirSync(dir = defaultDataDir()) {
|
|
25244
24512
|
ensureDataDirSync(dir);
|
|
@@ -25251,8 +24519,8 @@ function migrateLegacyLayout(base = defaultDataDir()) {
|
|
|
25251
24519
|
for (const { name, dest } of moves) {
|
|
25252
24520
|
try {
|
|
25253
24521
|
ensureDataDirSync(dest);
|
|
25254
|
-
const moved =
|
|
25255
|
-
renameSync3(
|
|
24522
|
+
const moved = join5(dest, name);
|
|
24523
|
+
renameSync3(join5(base, name), moved);
|
|
25256
24524
|
tightenFile(moved);
|
|
25257
24525
|
} catch {
|
|
25258
24526
|
}
|
|
@@ -25260,8 +24528,8 @@ function migrateLegacyLayout(base = defaultDataDir()) {
|
|
|
25260
24528
|
}
|
|
25261
24529
|
|
|
25262
24530
|
// ../../packages/persistence/src/settings.ts
|
|
25263
|
-
import { readFileSync as
|
|
25264
|
-
import { join as
|
|
24531
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
24532
|
+
import { join as join6 } from "path";
|
|
25265
24533
|
|
|
25266
24534
|
// ../../packages/persistence/src/file-lock.ts
|
|
25267
24535
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
@@ -25269,7 +24537,7 @@ import {
|
|
|
25269
24537
|
closeSync,
|
|
25270
24538
|
existsSync as existsSync2,
|
|
25271
24539
|
openSync,
|
|
25272
|
-
readFileSync as
|
|
24540
|
+
readFileSync as readFileSync3,
|
|
25273
24541
|
rmSync as rmSync5,
|
|
25274
24542
|
statSync as statSync3,
|
|
25275
24543
|
writeFileSync as writeFileSync2
|
|
@@ -25278,16 +24546,16 @@ import { hostname as hostname3 } from "os";
|
|
|
25278
24546
|
var PARK = new Int32Array(new SharedArrayBuffer(4));
|
|
25279
24547
|
|
|
25280
24548
|
// ../../packages/persistence/src/managed-settings.ts
|
|
25281
|
-
import { readFileSync as
|
|
24549
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
25282
24550
|
import { posix, win32 } from "path";
|
|
25283
|
-
function managedSettingsPaths(
|
|
25284
|
-
if (
|
|
24551
|
+
function managedSettingsPaths(platform = process.platform) {
|
|
24552
|
+
if (platform === "darwin") {
|
|
25285
24553
|
return [
|
|
25286
24554
|
posix.join("/Library", "Application Support", "AKASecurity", MANAGED_SETTINGS_FILENAME),
|
|
25287
24555
|
posix.join("/Library", "Managed Preferences", MANAGED_SETTINGS_FILENAME)
|
|
25288
24556
|
];
|
|
25289
24557
|
}
|
|
25290
|
-
if (
|
|
24558
|
+
if (platform === "win32") {
|
|
25291
24559
|
return [win32.join("C:\\", "ProgramData", "AKASecurity", MANAGED_SETTINGS_FILENAME)];
|
|
25292
24560
|
}
|
|
25293
24561
|
return [posix.join("/etc", "aka", MANAGED_SETTINGS_FILENAME)];
|
|
@@ -25297,7 +24565,7 @@ function readManagedSettings(paths = testOnlyManagedPaths ?? managedSettingsPath
|
|
|
25297
24565
|
for (const path of paths) {
|
|
25298
24566
|
let text;
|
|
25299
24567
|
try {
|
|
25300
|
-
text =
|
|
24568
|
+
text = readFileSync4(path, "utf8");
|
|
25301
24569
|
} catch {
|
|
25302
24570
|
continue;
|
|
25303
24571
|
}
|
|
@@ -25351,7 +24619,7 @@ function readWorkspaceSettings(base = defaultDataDir()) {
|
|
|
25351
24619
|
return overlayManagedSettings(readUserSettings(base), readManagedSettings());
|
|
25352
24620
|
}
|
|
25353
24621
|
function readUserSettings(base) {
|
|
25354
|
-
const record2 = readJson(
|
|
24622
|
+
const record2 = readJson(join6(settingsDir(base), SETTINGS_FILENAME));
|
|
25355
24623
|
if (!record2) return defaultWorkspaceSettings();
|
|
25356
24624
|
try {
|
|
25357
24625
|
return WorkspaceSettings.parse(record2);
|
|
@@ -25362,7 +24630,7 @@ function readUserSettings(base) {
|
|
|
25362
24630
|
function readJson(file2) {
|
|
25363
24631
|
let text;
|
|
25364
24632
|
try {
|
|
25365
|
-
text =
|
|
24633
|
+
text = readFileSync5(file2, "utf8");
|
|
25366
24634
|
} catch {
|
|
25367
24635
|
return null;
|
|
25368
24636
|
}
|
|
@@ -25436,39 +24704,39 @@ var CAPTURE_GRAIN = new Set(EventKind.options);
|
|
|
25436
24704
|
var DEFERRED_TAGS = new Set(DEFERRED_MIGRATION_TAGS);
|
|
25437
24705
|
|
|
25438
24706
|
// ../../packages/persistence/src/egress-wire.ts
|
|
25439
|
-
import { createHash as
|
|
24707
|
+
import { createHash as createHash4 } from "crypto";
|
|
25440
24708
|
var SLASH = "/".charCodeAt(0);
|
|
25441
24709
|
var SCOPE_KEY = printable(ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH);
|
|
25442
24710
|
|
|
25443
24711
|
// ../../packages/persistence/src/finding-key.ts
|
|
25444
|
-
import { createHash as
|
|
24712
|
+
import { createHash as createHash5 } from "crypto";
|
|
25445
24713
|
|
|
25446
24714
|
// ../../packages/persistence/src/fingerprint.ts
|
|
25447
24715
|
import { createHmac, randomBytes } from "crypto";
|
|
25448
|
-
import { existsSync as existsSync3, readFileSync as
|
|
25449
|
-
import { join as
|
|
25450
|
-
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
24716
|
+
import { existsSync as existsSync3, readFileSync as readFileSync7 } from "fs";
|
|
24717
|
+
import { join as join9 } from "path";
|
|
25451
24718
|
|
|
25452
24719
|
// ../../packages/persistence/src/forward-health.ts
|
|
25453
|
-
import { readFileSync as
|
|
25454
|
-
import { join as
|
|
24720
|
+
import { readFileSync as readFileSync8 } from "fs";
|
|
24721
|
+
import { join as join10 } from "path";
|
|
25455
24722
|
|
|
25456
24723
|
// ../../packages/persistence/src/history-backfill.ts
|
|
25457
24724
|
import { existsSync as existsSync4 } from "fs";
|
|
25458
|
-
import { join as
|
|
24725
|
+
import { join as join11 } from "path";
|
|
25459
24726
|
|
|
25460
24727
|
// ../../packages/persistence/src/history-preview.ts
|
|
25461
24728
|
import { existsSync as existsSync5 } from "fs";
|
|
25462
|
-
import { join as
|
|
25463
|
-
import { DatabaseSync as
|
|
24729
|
+
import { join as join12 } from "path";
|
|
24730
|
+
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
25464
24731
|
|
|
25465
24732
|
// ../../packages/persistence/src/history-sync-state.ts
|
|
25466
|
-
import { readFileSync as
|
|
25467
|
-
import { join as
|
|
24733
|
+
import { readFileSync as readFileSync9 } from "fs";
|
|
24734
|
+
import { join as join13 } from "path";
|
|
24735
|
+
var COUNTS_SCOPES = new Set(AttachmentMode.options);
|
|
25468
24736
|
|
|
25469
24737
|
// ../../packages/persistence/src/store-symlinks.ts
|
|
25470
24738
|
import { existsSync as existsSync6, lstatSync as lstatSync3, readlinkSync, realpathSync, statSync as statSync4 } from "fs";
|
|
25471
|
-
import { dirname as dirname3, join as
|
|
24739
|
+
import { dirname as dirname3, join as join14, resolve } from "path";
|
|
25472
24740
|
var STORE_DB = "the store database (including the prompt corpus)";
|
|
25473
24741
|
var STORE_SETTINGS = "your settings file";
|
|
25474
24742
|
function storeContents(home) {
|
|
@@ -25477,11 +24745,11 @@ function storeContents(home) {
|
|
|
25477
24745
|
[settingsDir(home), STORE_SETTINGS],
|
|
25478
24746
|
[dataDir(home), STORE_DB],
|
|
25479
24747
|
[keysDir(home), "the vault key"],
|
|
25480
|
-
[
|
|
24748
|
+
[join14(settingsDir(home), "settings.json"), STORE_SETTINGS],
|
|
25481
24749
|
[dbPath(home), STORE_DB]
|
|
25482
24750
|
]);
|
|
25483
24751
|
}
|
|
25484
|
-
function symlinkedStorePaths(home,
|
|
24752
|
+
function symlinkedStorePaths(home, platform = process.platform) {
|
|
25485
24753
|
return [...storeContents(home)].flatMap(([path, holds]) => {
|
|
25486
24754
|
try {
|
|
25487
24755
|
if (!lstatSync3(path).isSymbolicLink()) return [];
|
|
@@ -25493,7 +24761,7 @@ function symlinkedStorePaths(home, platform2 = process.platform) {
|
|
|
25493
24761
|
// existsSync follows the link, so a target that is gone reads as
|
|
25494
24762
|
// absent here while lstat above still sees the link itself.
|
|
25495
24763
|
missing: !existsSync6(path),
|
|
25496
|
-
mode: targetMode(path,
|
|
24764
|
+
mode: targetMode(path, platform)
|
|
25497
24765
|
}
|
|
25498
24766
|
];
|
|
25499
24767
|
} catch {
|
|
@@ -25508,8 +24776,8 @@ function linkTarget(path) {
|
|
|
25508
24776
|
return resolve(dirname3(path), readlinkSync(path));
|
|
25509
24777
|
}
|
|
25510
24778
|
}
|
|
25511
|
-
function targetMode(path,
|
|
25512
|
-
if (
|
|
24779
|
+
function targetMode(path, platform) {
|
|
24780
|
+
if (platform === "win32") return void 0;
|
|
25513
24781
|
try {
|
|
25514
24782
|
return statSync4(path).mode & 511;
|
|
25515
24783
|
} catch {
|
|
@@ -25529,15 +24797,15 @@ import {
|
|
|
25529
24797
|
// ../../packages/persistence/src/vault/key-provider.ts
|
|
25530
24798
|
import { execFileSync } from "child_process";
|
|
25531
24799
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
25532
|
-
import { chmodSync as chmodSync3, readFileSync as
|
|
25533
|
-
import { join as
|
|
24800
|
+
import { chmodSync as chmodSync3, readFileSync as readFileSync10, renameSync as renameSync4, rmSync as rmSync6, statSync as statSync5, writeFileSync as writeFileSync3 } from "fs";
|
|
24801
|
+
import { join as join15 } from "path";
|
|
25534
24802
|
|
|
25535
24803
|
// ../../packages/persistence/src/vault/vault.ts
|
|
25536
24804
|
import { randomBytes as randomBytes3, randomUUID as randomUUID12 } from "crypto";
|
|
25537
24805
|
|
|
25538
24806
|
// ../../packages/persistence/src/warn-era-cap.ts
|
|
25539
24807
|
import { existsSync as existsSync7, writeFileSync as writeFileSync4 } from "fs";
|
|
25540
|
-
import { join as
|
|
24808
|
+
import { join as join16 } from "path";
|
|
25541
24809
|
|
|
25542
24810
|
// ../../packages/plugin-sdk/src/provider-env.ts
|
|
25543
24811
|
var DEFAULT_ANTHROPIC_HOST = "api.anthropic.com";
|
|
@@ -25591,7 +24859,7 @@ function resolveProvider() {
|
|
|
25591
24859
|
function loadConfig(base = defaultDataDir(), resolveProviderFn = resolveProvider) {
|
|
25592
24860
|
try {
|
|
25593
24861
|
ensureLayoutDirSync(base);
|
|
25594
|
-
const settingsFile =
|
|
24862
|
+
const settingsFile = join17(settingsDir(base), "settings.json");
|
|
25595
24863
|
if (existsSync8(settingsFile)) tightenFile(settingsFile);
|
|
25596
24864
|
} catch {
|
|
25597
24865
|
}
|
|
@@ -25614,11 +24882,6 @@ function resolveProviderSafe(resolveProviderFn) {
|
|
|
25614
24882
|
}
|
|
25615
24883
|
}
|
|
25616
24884
|
|
|
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
24885
|
// ../../packages/detections/src/egress/registry.ts
|
|
25623
24886
|
var EXTRACTOR_VERSION = "3";
|
|
25624
24887
|
var PROVIDER_REGISTRY = [
|
|
@@ -26293,12 +25556,12 @@ var RegexMatcher2 = class {
|
|
|
26293
25556
|
rule.matcher,
|
|
26294
25557
|
() => new RegExp(pattern, flags.includes("d") ? flags : `${flags}d`)
|
|
26295
25558
|
);
|
|
26296
|
-
const
|
|
25559
|
+
const scanText = text.length > MAX_REGEX_INPUT_LENGTH ? text.slice(0, MAX_REGEX_INPUT_LENGTH) : text;
|
|
26297
25560
|
const spans = [];
|
|
26298
25561
|
let m;
|
|
26299
|
-
const maxIterations =
|
|
25562
|
+
const maxIterations = scanText.length + 1;
|
|
26300
25563
|
let iterations = 0;
|
|
26301
|
-
while ((m = re.exec(
|
|
25564
|
+
while ((m = re.exec(scanText)) !== null) {
|
|
26302
25565
|
if (++iterations > maxIterations) break;
|
|
26303
25566
|
const group = captureGroup != null ? m[captureGroup] : m[0];
|
|
26304
25567
|
if (m[0].length === 0) re.lastIndex++;
|
|
@@ -26452,25 +25715,12 @@ var POLYNOMIAL_PROBES = ["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].m
|
|
|
26452
25715
|
var CPU_CORROBORATION_SHARE = 0.2;
|
|
26453
25716
|
var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
|
|
26454
25717
|
|
|
26455
|
-
// ../../packages/plugin-sdk/src/repo.ts
|
|
26456
|
-
import { existsSync as existsSync9, readFileSync as readFileSync10, statSync as statSync6 } from "fs";
|
|
26457
|
-
import { basename as basename2, dirname as dirname4, isAbsolute, join as join17, sep as sep2 } from "path";
|
|
26458
|
-
var NO_ATTRIBUTION = Object.freeze({});
|
|
26459
|
-
|
|
26460
|
-
// ../../packages/plugin-sdk/src/events.ts
|
|
26461
|
-
import { createHash as createHash5, randomUUID as randomUUID13 } from "crypto";
|
|
26462
|
-
|
|
26463
|
-
// ../../packages/plugin-sdk/src/isolated-scan.ts
|
|
26464
|
-
import { existsSync as existsSync10 } from "fs";
|
|
26465
|
-
import { fileURLToPath } from "url";
|
|
26466
|
-
import { Worker } from "worker_threads";
|
|
26467
|
-
|
|
26468
25718
|
// ../../packages/plugin-sdk/src/hook-fail-opens.ts
|
|
26469
|
-
import { readFileSync as
|
|
26470
|
-
import { join as
|
|
25719
|
+
import { readFileSync as readFileSync11 } from "fs";
|
|
25720
|
+
import { join as join18 } from "path";
|
|
26471
25721
|
var HOOK_FAIL_OPENS_FILENAME = "hook-fail-opens.json";
|
|
26472
25722
|
function hookFailOpensPath(dataDir2) {
|
|
26473
|
-
return
|
|
25723
|
+
return join18(dataDir2, HOOK_FAIL_OPENS_FILENAME);
|
|
26474
25724
|
}
|
|
26475
25725
|
function recordHookFailOpen(dataDir2, nowMs) {
|
|
26476
25726
|
try {
|
|
@@ -26489,7 +25739,7 @@ function recordHookFailOpen(dataDir2, nowMs) {
|
|
|
26489
25739
|
}
|
|
26490
25740
|
function readHookFailOpens(dataDir2) {
|
|
26491
25741
|
try {
|
|
26492
|
-
const parsed = JSON.parse(
|
|
25742
|
+
const parsed = JSON.parse(readFileSync11(hookFailOpensPath(dataDir2), "utf8"));
|
|
26493
25743
|
if (typeof parsed !== "object" || parsed === null) return null;
|
|
26494
25744
|
const record2 = parsed;
|
|
26495
25745
|
if (!isPositiveSafeInteger(record2.failOpens)) return null;
|
|
@@ -26503,28 +25753,24 @@ function isPositiveSafeInteger(value) {
|
|
|
26503
25753
|
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
26504
25754
|
}
|
|
26505
25755
|
|
|
26506
|
-
// ../../packages/plugin-sdk/src/host-floor.ts
|
|
26507
|
-
import { readFileSync as readFileSync14 } from "fs";
|
|
26508
|
-
import { join as join21 } from "path";
|
|
26509
|
-
|
|
26510
25756
|
// ../../packages/plugin-sdk/src/model-governance.ts
|
|
26511
25757
|
import {
|
|
26512
25758
|
closeSync as closeSync2,
|
|
26513
25759
|
fstatSync,
|
|
26514
25760
|
mkdirSync as mkdirSync2,
|
|
26515
25761
|
openSync as openSync2,
|
|
26516
|
-
readFileSync as
|
|
25762
|
+
readFileSync as readFileSync12,
|
|
26517
25763
|
readSync,
|
|
26518
25764
|
writeFileSync as writeFileSync5
|
|
26519
25765
|
} from "fs";
|
|
26520
|
-
import { join as
|
|
25766
|
+
import { join as join19 } from "path";
|
|
26521
25767
|
var SESSION_MODEL_MARKER = "session-model";
|
|
26522
25768
|
function recordSessionModel(dataDir2, sessionId, model) {
|
|
26523
25769
|
if (sessionId === void 0 || sessionId === "") return;
|
|
26524
25770
|
if (model === void 0 || model === "") return;
|
|
26525
25771
|
try {
|
|
26526
25772
|
mkdirSync2(dataDir2, { recursive: true, mode: DATA_DIR_MODE });
|
|
26527
|
-
writeFileSync5(
|
|
25773
|
+
writeFileSync5(join19(dataDir2, SESSION_MODEL_MARKER), JSON.stringify({ sessionId, model }), {
|
|
26528
25774
|
encoding: "utf8",
|
|
26529
25775
|
mode: DATA_FILE_MODE
|
|
26530
25776
|
});
|
|
@@ -26536,7 +25782,7 @@ function readTail(path) {
|
|
|
26536
25782
|
const fd = openSync2(path, "r");
|
|
26537
25783
|
try {
|
|
26538
25784
|
const { size } = fstatSync(fd);
|
|
26539
|
-
if (size <= TAIL_BYTES) return { text:
|
|
25785
|
+
if (size <= TAIL_BYTES) return { text: readFileSync12(fd, "utf8"), truncated: false };
|
|
26540
25786
|
const buffer = Buffer.allocUnsafe(TAIL_BYTES);
|
|
26541
25787
|
let filled = 0;
|
|
26542
25788
|
while (filled < TAIL_BYTES) {
|
|
@@ -26581,105 +25827,18 @@ var codexModelFromRecord = (record2) => {
|
|
|
26581
25827
|
return typeof model === "string" && model !== "" ? model : void 0;
|
|
26582
25828
|
};
|
|
26583
25829
|
|
|
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
25830
|
// ../../packages/plugin-sdk/src/throttle.ts
|
|
26672
|
-
import { mkdirSync as
|
|
26673
|
-
import { join as
|
|
25831
|
+
import { mkdirSync as mkdirSync3, statSync as statSync6, writeFileSync as writeFileSync6 } from "fs";
|
|
25832
|
+
import { join as join20 } from "path";
|
|
26674
25833
|
function throttled(dataDir2, markerName, windowMs) {
|
|
26675
|
-
const marker =
|
|
25834
|
+
const marker = join20(dataDir2, markerName);
|
|
26676
25835
|
try {
|
|
26677
|
-
if (Date.now() -
|
|
25836
|
+
if (Date.now() - statSync6(marker).mtimeMs < windowMs) return true;
|
|
26678
25837
|
} catch {
|
|
26679
25838
|
}
|
|
26680
25839
|
try {
|
|
26681
|
-
|
|
26682
|
-
|
|
25840
|
+
mkdirSync3(dataDir2, { recursive: true, mode: DATA_DIR_MODE });
|
|
25841
|
+
writeFileSync6(marker, String(Date.now()), { mode: DATA_FILE_MODE });
|
|
26683
25842
|
} catch {
|
|
26684
25843
|
}
|
|
26685
25844
|
return false;
|
|
@@ -26687,21 +25846,21 @@ function throttled(dataDir2, markerName, windowMs) {
|
|
|
26687
25846
|
|
|
26688
25847
|
// src/history/reconcile-trigger.ts
|
|
26689
25848
|
import { spawn } from "child_process";
|
|
26690
|
-
import { dirname as
|
|
26691
|
-
import { fileURLToPath
|
|
25849
|
+
import { dirname as dirname4, join as join22 } from "path";
|
|
25850
|
+
import { fileURLToPath } from "url";
|
|
26692
25851
|
|
|
26693
25852
|
// src/history/tail.ts
|
|
26694
25853
|
import { createHash as createHash6 } from "crypto";
|
|
26695
25854
|
import {
|
|
26696
25855
|
closeSync as closeSync3,
|
|
26697
25856
|
fstatSync as fstatSync2,
|
|
26698
|
-
mkdirSync as
|
|
25857
|
+
mkdirSync as mkdirSync4,
|
|
26699
25858
|
openSync as openSync3,
|
|
26700
|
-
readFileSync as
|
|
25859
|
+
readFileSync as readFileSync13,
|
|
26701
25860
|
readSync as readSync2,
|
|
26702
|
-
writeFileSync as
|
|
25861
|
+
writeFileSync as writeFileSync7
|
|
26703
25862
|
} from "fs";
|
|
26704
|
-
import { join as
|
|
25863
|
+
import { join as join21 } from "path";
|
|
26705
25864
|
var SAFE_SESSION_ID = /^[A-Za-z0-9._-]+$/;
|
|
26706
25865
|
function safeSessionId(sessionId) {
|
|
26707
25866
|
if (SAFE_SESSION_ID.test(sessionId) && sessionId !== "." && sessionId !== "..") {
|
|
@@ -26717,8 +25876,8 @@ function triggerReconcile(dataDir2, sessionId, transcriptPath) {
|
|
|
26717
25876
|
try {
|
|
26718
25877
|
const marker = `${RECONCILE_MARKER_PREFIX}-${safeSessionId(sessionId)}`;
|
|
26719
25878
|
if (throttled(dataDir2, marker, RECONCILE_THROTTLE_MS)) return;
|
|
26720
|
-
const here =
|
|
26721
|
-
const child = spawn(process.execPath, [
|
|
25879
|
+
const here = dirname4(fileURLToPath(import.meta.url));
|
|
25880
|
+
const child = spawn(process.execPath, [join22(here, "reconcile.js"), sessionId, transcriptPath], {
|
|
26722
25881
|
detached: true,
|
|
26723
25882
|
stdio: "ignore"
|
|
26724
25883
|
});
|
|
@@ -26728,7 +25887,7 @@ function triggerReconcile(dataDir2, sessionId, transcriptPath) {
|
|
|
26728
25887
|
}
|
|
26729
25888
|
|
|
26730
25889
|
// src/hooks/shared.ts
|
|
26731
|
-
import { isAbsolute
|
|
25890
|
+
import { isAbsolute, normalize, resolve as resolvePath } from "path";
|
|
26732
25891
|
async function readStdin() {
|
|
26733
25892
|
return new Promise((resolve3) => {
|
|
26734
25893
|
let data = "";
|
|
@@ -26780,8 +25939,8 @@ function parseStopPayload(input2) {
|
|
|
26780
25939
|
}
|
|
26781
25940
|
|
|
26782
25941
|
// src/hooks/store-health.ts
|
|
26783
|
-
import { mkdirSync as
|
|
26784
|
-
import { dirname as
|
|
25942
|
+
import { mkdirSync as mkdirSync5, readFileSync as readFileSync18, writeFileSync as writeFileSync8 } from "fs";
|
|
25943
|
+
import { dirname as dirname6, join as join30 } from "path";
|
|
26785
25944
|
|
|
26786
25945
|
// ../../packages/remote/src/http.ts
|
|
26787
25946
|
import { request as httpRequest } from "http";
|
|
@@ -26795,17 +25954,17 @@ var SLASH2 = "/".charCodeAt(0);
|
|
|
26795
25954
|
var REQUEST_TIMEOUT_MS = 2e3;
|
|
26796
25955
|
|
|
26797
25956
|
// ../../packages/plugin-runtime/src/attached/forward-drops.ts
|
|
26798
|
-
import { readFileSync as
|
|
26799
|
-
import { join as
|
|
25957
|
+
import { readFileSync as readFileSync14 } from "fs";
|
|
25958
|
+
import { join as join23 } from "path";
|
|
26800
25959
|
|
|
26801
25960
|
// ../../packages/plugin-runtime/src/attached/forward-policy.ts
|
|
26802
|
-
import { randomUUID as
|
|
25961
|
+
import { randomUUID as randomUUID13 } from "crypto";
|
|
26803
25962
|
import { readFile, rename, writeFile } from "fs/promises";
|
|
26804
|
-
import { join as
|
|
25963
|
+
import { join as join24 } from "path";
|
|
26805
25964
|
|
|
26806
25965
|
// ../../packages/plugin-runtime/src/attached/history-sync.ts
|
|
26807
25966
|
import { createHash as createHash7 } from "crypto";
|
|
26808
|
-
import { hostname as
|
|
25967
|
+
import { hostname as hostname4 } from "os";
|
|
26809
25968
|
|
|
26810
25969
|
// ../../packages/plugin-runtime/src/attached/capture-rebuild.ts
|
|
26811
25970
|
var CORRELATION_ID = EventMetadata.shape.correlationId;
|
|
@@ -26818,21 +25977,21 @@ var CAPTURE_BATCH_BYTES = 1024 * 1024;
|
|
|
26818
25977
|
|
|
26819
25978
|
// ../../packages/plugin-runtime/src/attached/history-sync-trigger.ts
|
|
26820
25979
|
import { spawn as spawn2 } from "child_process";
|
|
26821
|
-
import { fileURLToPath as
|
|
25980
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
26822
25981
|
var HISTORY_SYNC_THROTTLE_MS = 5 * 60 * 1e3;
|
|
26823
25982
|
|
|
26824
25983
|
// ../../packages/plugin-runtime/src/attached/install-record.ts
|
|
26825
25984
|
import { readFile as readFile2, stat } from "fs/promises";
|
|
26826
|
-
import { basename as
|
|
25985
|
+
import { basename as basename2, dirname as dirname5, join as join25, resolve as resolve2 } from "path";
|
|
26827
25986
|
|
|
26828
25987
|
// ../../packages/plugin-runtime/src/attached/plugin-block.ts
|
|
26829
|
-
import { readFileSync as
|
|
25988
|
+
import { readFileSync as readFileSync15 } from "fs";
|
|
26830
25989
|
var INSTALL_RECORD_READ_TIMEOUT_MS = REQUEST_TIMEOUT_MS / 2;
|
|
26831
25990
|
|
|
26832
25991
|
// ../../packages/plugin-runtime/src/attached/policy-store.ts
|
|
26833
|
-
import { randomUUID as
|
|
25992
|
+
import { randomUUID as randomUUID14 } from "crypto";
|
|
26834
25993
|
import { readFile as readFile3, rm, writeFile as writeFile2 } from "fs/promises";
|
|
26835
|
-
import { join as
|
|
25994
|
+
import { join as join26 } from "path";
|
|
26836
25995
|
|
|
26837
25996
|
// ../../packages/plugin-runtime/src/attached/atomic-publish.ts
|
|
26838
25997
|
import { rename as rename2 } from "fs/promises";
|
|
@@ -26841,8 +26000,8 @@ var TIMED_RETRIES = 4;
|
|
|
26841
26000
|
var ATTEMPTS = 1 + IMMEDIATE_RETRIES + TIMED_RETRIES;
|
|
26842
26001
|
|
|
26843
26002
|
// ../../packages/plugin-runtime/src/attached/posture-report-state.ts
|
|
26844
|
-
import { readFileSync as
|
|
26845
|
-
import { join as
|
|
26003
|
+
import { readFileSync as readFileSync16 } from "fs";
|
|
26004
|
+
import { join as join27 } from "path";
|
|
26846
26005
|
var OUTCOME_KEYS = {
|
|
26847
26006
|
ok: true,
|
|
26848
26007
|
unauthorized: true,
|
|
@@ -26859,17 +26018,17 @@ var OUTCOMES = new Set(Object.keys(OUTCOME_KEYS));
|
|
|
26859
26018
|
var POSTURE_REPORT_INTERVAL_MS = 60 * 60 * 1e3;
|
|
26860
26019
|
|
|
26861
26020
|
// ../../packages/plugin-runtime/src/attached/posture-snapshot.ts
|
|
26862
|
-
import { statSync as
|
|
26863
|
-
import { DatabaseSync as
|
|
26021
|
+
import { statSync as statSync7 } from "fs";
|
|
26022
|
+
import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
26864
26023
|
|
|
26865
26024
|
// ../../packages/plugin-runtime/src/attached/posture-store.ts
|
|
26866
|
-
import { randomUUID as
|
|
26025
|
+
import { randomUUID as randomUUID15 } from "crypto";
|
|
26867
26026
|
import { readFile as readFile4, rm as rm2, writeFile as writeFile3 } from "fs/promises";
|
|
26868
|
-
import { join as
|
|
26027
|
+
import { join as join28 } from "path";
|
|
26869
26028
|
|
|
26870
26029
|
// ../../packages/plugin-runtime/src/attached/sync-state.ts
|
|
26871
|
-
import { readFileSync as
|
|
26872
|
-
import { join as
|
|
26030
|
+
import { readFileSync as readFileSync17 } from "fs";
|
|
26031
|
+
import { join as join29 } from "path";
|
|
26873
26032
|
|
|
26874
26033
|
// ../../packages/plugin-runtime/src/attached/status.ts
|
|
26875
26034
|
var REFUSAL_LINES = {
|
|
@@ -26887,7 +26046,7 @@ var OUTCOME_LINES = {
|
|
|
26887
26046
|
|
|
26888
26047
|
// ../../packages/plugin-runtime/src/attached/sync-trigger.ts
|
|
26889
26048
|
import { spawn as spawn3 } from "child_process";
|
|
26890
|
-
import { fileURLToPath as
|
|
26049
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
26891
26050
|
var SYNC_THROTTLE_MS = 15 * 60 * 1e3;
|
|
26892
26051
|
|
|
26893
26052
|
// ../../packages/plugin-runtime/src/content-retention-pass.ts
|
|
@@ -26895,25 +26054,25 @@ var MAX_ROWS_PER_SWEEP = 50 * 1e3;
|
|
|
26895
26054
|
|
|
26896
26055
|
// ../../packages/plugin-runtime/src/content-retention-trigger.ts
|
|
26897
26056
|
import { spawn as spawn4 } from "child_process";
|
|
26898
|
-
import { fileURLToPath as
|
|
26057
|
+
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
26899
26058
|
var CONTENT_RETENTION_THROTTLE_MS = 60 * 60 * 1e3;
|
|
26900
26059
|
|
|
26901
26060
|
// ../../packages/plugin-runtime/src/attached/factory.ts
|
|
26902
|
-
import { hostname as
|
|
26061
|
+
import { hostname as hostname5 } from "os";
|
|
26903
26062
|
|
|
26904
26063
|
// ../../packages/plugin-runtime/src/handle-session-start.ts
|
|
26905
|
-
import { randomUUID as
|
|
26064
|
+
import { randomUUID as randomUUID16 } from "crypto";
|
|
26906
26065
|
var EXCEPTION_RETENTION_MS = 90 * 24 * 60 * 60 * 1e3;
|
|
26907
26066
|
|
|
26908
26067
|
// src/hooks/store-health.ts
|
|
26909
26068
|
var STORE_REDIRECT_MARKER = "store-redirect-last-session";
|
|
26910
26069
|
function markerDirs(dataDir2) {
|
|
26911
|
-
return [dataDir2,
|
|
26070
|
+
return [dataDir2, dirname6(dataDir2)];
|
|
26912
26071
|
}
|
|
26913
26072
|
function alreadyClaimed(dirs, marker, sessionId) {
|
|
26914
26073
|
return dirs.some((dir) => {
|
|
26915
26074
|
try {
|
|
26916
|
-
return
|
|
26075
|
+
return readFileSync18(join30(dir, marker), "utf8") === sessionId;
|
|
26917
26076
|
} catch {
|
|
26918
26077
|
return false;
|
|
26919
26078
|
}
|
|
@@ -26922,14 +26081,14 @@ function alreadyClaimed(dirs, marker, sessionId) {
|
|
|
26922
26081
|
function recordClaim(dirs, marker, sessionId) {
|
|
26923
26082
|
for (const dir of dirs) {
|
|
26924
26083
|
try {
|
|
26925
|
-
|
|
26926
|
-
|
|
26084
|
+
mkdirSync5(dir, { recursive: true, mode: DATA_DIR_MODE });
|
|
26085
|
+
writeFileSync8(join30(dir, marker), sessionId, { mode: DATA_FILE_MODE });
|
|
26927
26086
|
return;
|
|
26928
26087
|
} catch {
|
|
26929
26088
|
}
|
|
26930
26089
|
}
|
|
26931
26090
|
}
|
|
26932
|
-
function storeRedirectedMessage(paths,
|
|
26091
|
+
function storeRedirectedMessage(paths, platform = process.platform) {
|
|
26933
26092
|
const where = paths.map(({ path, target, holds, missing, mode }) => {
|
|
26934
26093
|
if (missing) return `${path} -> ${target} (which does not exist; ${holds} cannot land there)`;
|
|
26935
26094
|
const loose = mode !== void 0 && (mode & 63) !== 0 ? ", NOT owner-only" : "";
|
|
@@ -26939,7 +26098,7 @@ function storeRedirectedMessage(paths, platform2 = process.platform) {
|
|
|
26939
26098
|
const subject = paths.length === 1 ? "a store path is a symlink" : `${String(paths.length)} store paths are symlinks`;
|
|
26940
26099
|
const anyResolves = paths.some(({ missing }) => !missing);
|
|
26941
26100
|
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 &&
|
|
26101
|
+
const kept = anyResolves && platform !== "win32" ? "Permissions are never changed through a symlink, so the store keeps whatever the target already had. " : "";
|
|
26943
26102
|
return `[aka] ${lead}${kept}If you did not create that link, treat it as untrusted and run \`aka init\` for the full report.
|
|
26944
26103
|
`;
|
|
26945
26104
|
}
|
|
@@ -26948,7 +26107,7 @@ function formatMode(mode) {
|
|
|
26948
26107
|
}
|
|
26949
26108
|
function warnIfStoreRedirected(config2, sessionId, write = (message) => void process.stderr.write(message)) {
|
|
26950
26109
|
try {
|
|
26951
|
-
const paths = symlinkedStorePaths(
|
|
26110
|
+
const paths = symlinkedStorePaths(dirname6(config2.dataDir));
|
|
26952
26111
|
if (paths.length === 0) return;
|
|
26953
26112
|
if (!sessionId) {
|
|
26954
26113
|
write(storeRedirectedMessage(paths));
|