@akasecurity/ai-tc-codex 0.9.15 → 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/scripts/stop.js CHANGED
@@ -1,856 +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.10/node_modules/ignore/index.js
36
- var require_ignore = __commonJS({
37
- "../../node_modules/.pnpm/ignore@7.0.10/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 extractBrackets = (pattern) => {
173
- const sources = [];
174
- const hold = (source) => `${PLACEHOLDER}${sources.push(source) - 1}${PLACEHOLDER}`;
175
- const { length } = pattern;
176
- let out = EMPTY;
177
- let index = 0;
178
- while (index < length) {
179
- const char = pattern[index];
180
- if (char === ESCAPE) {
181
- const escaped = pattern[index + 1];
182
- if (escaped === "*" || escaped === "[" || escaped === SPACE || escaped === ESCAPE) {
183
- out += pattern.slice(index, index + 2);
184
- } else {
185
- out += hold(
186
- REGEX_LITERAL_SPECIAL.test(escaped) ? ESCAPE + escaped : escaped
187
- );
188
- }
189
- index += 2;
190
- } else if (char === PLACEHOLDER) {
191
- out += hold(`[${PLACEHOLDER}]`);
192
- index++;
193
- } else if (char === "[") {
194
- const scanned = scanBracket(pattern, index);
195
- if (scanned === null) {
196
- out += hold(NEVER_MATCH);
197
- index = length;
198
- } else {
199
- out += hold(scanned.source);
200
- index = scanned.end + 1;
201
- }
202
- } else {
203
- out += char;
204
- index++;
205
- }
206
- }
207
- return {
208
- source: out,
209
- sources
210
- };
211
- };
212
- var DIRECT = null;
213
- var REGEX_INNER_SLASH = /\/(?!$)/;
214
- var REPLACERS = [
215
- [
216
- // Remove BOM
217
- // TODO:
218
- // Other similar zero-width characters?
219
- /^\uFEFF/,
220
- () => EMPTY,
221
- "\uFEFF"
222
- ],
223
- [
224
- // A trailing line terminator, left on when a whole file's contents are
225
- // added as one pattern rather than split into lines. git never sees one
226
- // -- it reads a `.gitignore` line by line -- so it is not part of the
227
- // pattern and is dropped here, apart from the trailing-space trimming,
228
- // which follows git in touching spaces and nothing else.
229
- /[\r\n]+$/,
230
- () => EMPTY
231
- ],
232
- // > Trailing spaces are ignored unless they are quoted with backslash ("\")
233
- [
234
- // Only spaces, never tabs or other whitespace: git trims a trailing run
235
- // of `' '` and nothing else (dir.c, `trim_trailing_spaces`, a single
236
- // `case ' '`), so a pattern ending in a tab keeps it as a literal.
237
- // (a\ ) -> (a )
238
- // (a ) -> (a)
239
- // (a ) -> (a)
240
- // (a \ ) -> (a )
241
- /((?:\\\\)*?)(\\? +)$/,
242
- (_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY)
243
- ],
244
- // Replace (\ ) with ' '
245
- // Only a space: an escaped tab or other whitespace is already a literal by
246
- // the time it reaches here, and a bare tab must be left as one, not turned
247
- // into a space.
248
- // (\ ) -> ' '
249
- // (\\ ) -> '\\ '
250
- // (\\\ ) -> '\\ '
251
- [
252
- /(\\+?) /g,
253
- (_, m1) => {
254
- const { length } = m1;
255
- return m1.slice(0, length - length % 2) + SPACE;
256
- }
257
- ],
258
- // Escape metacharacters
259
- // which is written down by users but means special for regular expressions.
260
- // > There are 12 characters with special meanings:
261
- // > - the backslash \,
262
- // > - the caret ^,
263
- // > - the dollar sign $,
264
- // > - the period or dot .,
265
- // > - the vertical bar or pipe symbol |,
266
- // > - the question mark ?,
267
- // > - the asterisk or star *,
268
- // > - the plus sign +,
269
- // > - the opening parenthesis (,
270
- // > - the closing parenthesis ),
271
- // > - and the opening square bracket [,
272
- // > - the opening curly brace {,
273
- // > These special characters are often called "metacharacters".
274
- [
275
- /[\\$.|*+(){^]/g,
276
- (match) => `\\${match}`
277
- ],
278
- [
279
- // > a question mark (?) matches a single character
280
- /(?!\\)\?/g,
281
- () => "[^/]",
282
- "?"
283
- ],
284
- // leading slash
285
- [
286
- // > A leading slash matches the beginning of the pathname.
287
- // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
288
- // A leading slash matches the beginning of the pathname
289
- /^\//,
290
- () => "^",
291
- SLASH3
292
- ],
293
- // replace special metacharacter slash after the leading slash
294
- [
295
- /\//g,
296
- () => "\\/",
297
- SLASH3
298
- ],
299
- [
300
- // > A leading "**" followed by a slash means match in all directories.
301
- // > For example, "**/foo" matches file or directory "foo" anywhere,
302
- // > the same as pattern "foo".
303
- // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
304
- // > under directory "foo".
305
- // Notice that the '*'s have been replaced as '\\*'
306
- /^\^*(?:\\\*\\\*\\\/)+/,
307
- // '**/foo' <-> 'foo'
308
- () => "^(?:.*\\/)?",
309
- "*"
310
- ],
311
- // starting
312
- [
313
- // there will be no leading '/'
314
- // (which has been replaced by section "leading slash")
315
- // If starts with '**', adding a '^' to the regular expression also works
316
- DIRECT,
317
- (source, pattern) => {
318
- if (!source || source[0] === "^") {
319
- return source;
320
- }
321
- const anchor2 = !REGEX_INNER_SLASH.test(pattern) ? "(?:^|\\/)" : "^";
322
- return anchor2 + source;
323
- }
324
- ],
325
- // two globstars
326
- [
327
- // Use lookahead assertions so that we could match more than one `'/**'`
328
- /\\\/\\\*\\\*(?=\\\/|$)/g,
329
- // Zero, one or several directories
330
- // should not use '*', or it will be replaced by the next replacer
331
- // Check if it is not the last `'/**'`
332
- (_, index, str) => index + 6 < str.length ? str.slice(index + 6) === "\\/" ? "(?:\\/[^\\/]+)+" : "(?:\\/[^\\/]+)*" : "\\/.+",
333
- "*"
334
- ],
335
- // normal intermediate wildcards
336
- [
337
- // Never replace escaped '*'
338
- // ignore rule '\*' will match the path '*'
339
- // 'abc.*/' -> go
340
- // 'abc.*' -> skip this rule,
341
- // coz trailing single wildcard will be handed by [trailing wildcard]
342
- /(^|[^\\]+)(\\\*)+(?=.+)/g,
343
- // '*.js' matches '.js'
344
- // '*.js' doesn't match 'abc'
345
- (_, p1, p2) => {
346
- const unescaped = p2.replace(/\\\*/g, "[^\\/]*");
347
- return p1 + unescaped;
348
- },
349
- "*"
350
- ],
351
- // trailing wildcard, held apart from a literal star
352
- [
353
- // The step above leaves a trailing `*` alone, so a single `\*` is all that
354
- // can be left at the end here. Whether it is a wildcard or a literal
355
- // turns on the backslashes the user put in front of it: the escaper has
356
- // since doubled every one, so what stands here is those `2N` doubled
357
- // backslashes and then the star's own escape. An even number of the
358
- // original `N` leaves the star unescaped -- a wildcard -- and an odd
359
- // number escapes it -- a literal. This runs while the two are still
360
- // distinct, before the unescape steps below collapse the literal onto
361
- // the very `\*` a wildcard leaves behind.
362
- /(^|[^\\])((?:\\\\)*)\\\*$/,
363
- (match, p1, p2) => (
364
- // `p2` holds the doubled user backslashes; half of them is `N`.
365
- p2.length / 2 % 2 === 0 ? p1 + p2 + TRAILING_WILDCARD : match
366
- ),
367
- "*"
368
- ],
369
- [
370
- // unescape, revert step 3 except for back slash
371
- // For example, if a user escape a '\\*',
372
- // after step 3, the result will be '\\\\\\*'
373
- /\\\\\\(?=[$.|*+(){^])/g,
374
- () => ESCAPE,
375
- ESCAPE + ESCAPE
376
- ],
377
- [
378
- // '\\\\' -> '\\'
379
- /\\\\/g,
380
- () => ESCAPE,
381
- ESCAPE + ESCAPE
382
- ],
383
- [
384
- // Every real bracket expression -- POSIX classes included -- has already
385
- // been held aside by `extractBrackets`, so the only `[` left in the
386
- // pattern is an escaped, literal one.
387
- // `\` is escaped by step 3
388
- /\\\[([^\]/]*?)(\\*)($|\])/g,
389
- // '\\[bar]' -> '\\\\[bar\\]'
390
- (match, range, endEscape, close) => `\\[${range}${cleanRangeBackSlash(endEscape)}${close}`,
391
- "["
392
- ],
393
- // ending
394
- [
395
- // 'js' will not match 'js.'
396
- // 'ab' will not match 'abc'
397
- DIRECT,
398
- // WTF!
399
- // https://git-scm.com/docs/gitignore
400
- // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
401
- // which re-fixes #24, #38
402
- // > If there is a separator at the end of the pattern then the pattern
403
- // > will only match directories, otherwise the pattern can match both
404
- // > files and directories.
405
- // 'js*' will not match 'a.js'
406
- // 'js/' will not match 'a.js'
407
- // 'js' will match 'a.js' and 'a.js/'
408
- (source) => {
409
- const last = source[source.length - 1];
410
- if (!last || last === TRAILING_WILDCARD) {
411
- return source;
412
- }
413
- return last === SLASH3 ? `${source}$` : `${source}(?=$|\\/$)`;
414
- }
415
- ]
416
- ];
417
- var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\uE000$/;
418
- var MODE_IGNORE = "regex";
419
- var MODE_CHECK_IGNORE = "checkRegex";
420
- var UNDERSCORE = "_";
421
- var TRAILING_WILD_CARD_REPLACERS = {
422
- [MODE_IGNORE](_, p1) {
423
- const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
424
- return `${prefix}(?=$|\\/$)`;
425
- },
426
- [MODE_CHECK_IGNORE](_, p1) {
427
- const prefix = p1 ? `${p1}[^/]*` : "[^/]*";
428
- return `${prefix}(?=$|\\/$)`;
429
- }
430
- };
431
- var WILDCARD = "[^\\/]*";
432
- var separatorAfter = (run, at) => {
433
- let separator = EMPTY;
434
- for (let index = at + 1; index < run.length && !run[index].wildcard; index++) {
435
- separator += run[index].single;
436
- }
437
- return separator;
438
- };
439
- var pinWildcards = (source) => {
440
- if (source.indexOf(WILDCARD) < 0) {
441
- return source;
442
- }
443
- const tokens = [];
444
- const { length } = source;
445
- let index = 0;
446
- while (index < length) {
447
- const char = source[index];
448
- if (source.startsWith(WILDCARD, index)) {
449
- tokens.push({ wildcard: true });
450
- index += WILDCARD.length;
451
- } else if (char === "[") {
452
- let end = index + 1;
453
- if (source[end] === "^") {
454
- end++;
455
- }
456
- if (source[end] === "]") {
457
- end++;
458
- }
459
- while (end < length && source[end] !== "]") {
460
- end += source[end] === ESCAPE ? 2 : 1;
461
- }
462
- end++;
463
- tokens.push({ single: source.slice(index, end) });
464
- index = end;
465
- } else if (char === ESCAPE) {
466
- tokens.push({ single: source.slice(index, index + 2) });
467
- index += 2;
468
- } else if (char === "(") {
469
- let depth = 0;
470
- let end = index;
471
- do {
472
- if (source[end] === ESCAPE) {
473
- end++;
474
- } else if (source[end] === "(") {
475
- depth++;
476
- } else if (source[end] === ")") {
477
- depth--;
478
- }
479
- end++;
480
- } while (end < length && depth > 0);
481
- if ("*+?".indexOf(source[end]) >= 0) {
482
- end++;
483
- }
484
- tokens.push({ boundary: source.slice(index, end) });
485
- index = end;
486
- } else if (char === "^" || char === "$") {
487
- tokens.push({ boundary: char });
488
- index++;
489
- } else {
490
- tokens.push({ single: char });
491
- index++;
492
- }
493
- }
494
- let out = EMPTY;
495
- let run = [];
496
- const flush = () => {
497
- let lastWildcard;
498
- run.forEach((token, at) => {
499
- if (token.wildcard) {
500
- lastWildcard = at;
501
- }
502
- });
503
- run.forEach((token, at) => {
504
- if (!token.wildcard) {
505
- out += token.single;
506
- return;
507
- }
508
- out += at === lastWildcard ? WILDCARD : `(?:(?!${separatorAfter(run, at)})[^\\/])*`;
509
- });
510
- run = [];
511
- };
512
- tokens.forEach((token) => {
513
- if (token.boundary === void 0) {
514
- run.push(token);
515
- return;
516
- }
517
- flush();
518
- out += token.boundary;
519
- });
520
- flush();
521
- return out;
522
- };
523
- var makeRegexPrefix = (pattern) => {
524
- const { source, sources } = extractBrackets(pattern);
525
- const replaced = REPLACERS.reduce(
526
- // A pass whose matcher finds nothing hands back the very string it was
527
- // given, so asking first costs a search and saves a rewrite. Ten of the
528
- // fifteen passes never fire for a typical .gitignore line, and between
529
- // them they were 45% of this chain.
530
- (prev, [matcher, replacer, required2]) => {
531
- if (matcher === DIRECT) {
532
- return replacer(prev, pattern);
533
- }
534
- if (required2 !== UNDEFINED && prev.indexOf(required2) < 0) {
535
- return prev;
536
- }
537
- return matcher.test(prev) ? prev.replace(matcher, replacer.bind(pattern)) : prev;
538
- },
539
- source
540
- );
541
- return sources.length ? replaced.replace(
542
- REGEX_RESTORE_PLACEHOLDER,
543
- (match, index) => sources[index]
544
- ) : replaced;
545
- };
546
- var matchesBasename = (body) => {
547
- const index = body.indexOf(SLASH3);
548
- return index < 0 || index === body.length - 1;
549
- };
550
- var basenameOf = (path) => {
551
- const end = path.length - 1;
552
- const index = path.lastIndexOf(
553
- SLASH3,
554
- path[end] === SLASH3 ? end - 1 : end
555
- );
556
- return index < 0 ? path : path.slice(index + 1);
557
- };
558
- var parentOf = (path) => {
559
- if (path.charCodeAt(0) === SLASH_CODE || path.indexOf(DOUBLE_SLASH) >= 0) {
560
- const slices = path.split(SLASH3).filter(Boolean);
561
- slices.pop();
562
- return slices.length ? slices.join(SLASH3) + SLASH3 : EMPTY;
563
- }
564
- const end = path.length - 1;
565
- const cut = path.lastIndexOf(
566
- SLASH3,
567
- path.charCodeAt(end) === SLASH_CODE ? end - 1 : end
568
- );
569
- return cut < 0 ? EMPTY : path.slice(0, cut + 1);
570
- };
571
- var isString = (subject) => typeof subject === "string";
572
- var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
573
- var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
574
- var IgnoreRule = class {
575
- constructor(pattern, mark, body, ignoreCase, negative, prefix) {
576
- this.pattern = pattern;
577
- this.mark = mark;
578
- this.negative = negative;
579
- define(this, "body", body);
580
- define(this, "ignoreCase", ignoreCase);
581
- define(this, "regexPrefix", prefix);
582
- }
583
- // Worked out on first use and kept behind an own property, the way `regex`
584
- // caches itself in `_regex`. Deciding it in the constructor instead would
585
- // add a fourth `defineProperty` to every rule ever built, which cost 4% of
586
- // every compile -- including the compiles of rules that are never matched
587
- // against anything.
588
- get _basenameOnly() {
589
- return define(this, "_basenameOnly", matchesBasename(this.body));
590
- }
591
- get regex() {
592
- const key = UNDERSCORE + MODE_IGNORE;
593
- if (this[key]) {
594
- return this[key];
595
- }
596
- return this._make(MODE_IGNORE, key);
597
- }
598
- get checkRegex() {
599
- const key = UNDERSCORE + MODE_CHECK_IGNORE;
600
- if (this[key]) {
601
- return this[key];
602
- }
603
- return this._make(MODE_CHECK_IGNORE, key);
604
- }
605
- _make(mode, key) {
606
- const str = pinWildcards(this.regexPrefix.replace(
607
- REGEX_REPLACE_TRAILING_WILDCARD,
608
- // It does not need to bind pattern
609
- TRAILING_WILD_CARD_REPLACERS[mode]
610
- ));
611
- const regex = this.ignoreCase ? new RegExp(str, "i") : new RegExp(str);
612
- return define(this, key, regex);
613
- }
614
- };
615
- var createRule = ({
616
- pattern,
617
- mark
618
- }, ignoreCase) => {
619
- let negative = false;
620
- let body = pattern;
621
- if (body.indexOf("!") === 0) {
622
- negative = true;
623
- body = body.substr(1);
624
- }
625
- body = body.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
626
- const regexPrefix = makeRegexPrefix(body);
627
- return new IgnoreRule(
628
- pattern,
629
- mark,
630
- body,
631
- ignoreCase,
632
- negative,
633
- regexPrefix
634
- );
635
- };
636
- var RuleManager = class {
637
- constructor(ignoreCase) {
638
- this._ignoreCase = ignoreCase;
639
- this._rules = [];
640
- this._basenameCount = 0;
641
- }
642
- _add(pattern) {
643
- if (pattern && pattern[KEY_IGNORE]) {
644
- this._rules = this._rules.concat(pattern._rules._rules);
645
- this._basenameCount += pattern._rules._basenameCount;
646
- this._added = true;
647
- return;
648
- }
649
- if (isString(pattern)) {
650
- pattern = {
651
- pattern
652
- };
653
- }
654
- if (checkPattern(pattern.pattern)) {
655
- const rule = createRule(pattern, this._ignoreCase);
656
- this._added = true;
657
- this._rules.push(rule);
658
- if (matchesBasename(rule.body)) {
659
- this._basenameCount++;
660
- }
661
- }
662
- }
663
- // @param {Array<string> | string | Ignore} pattern
664
- add(pattern) {
665
- this._added = false;
666
- makeArray(
667
- isString(pattern) ? splitPattern(pattern) : pattern
668
- ).forEach(this._add, this);
669
- return this._added;
670
- }
671
- // Test one single path without recursively checking parent directories
672
- //
673
- // - checkUnignored `boolean` whether should check if the path is unignored,
674
- // setting `checkUnignored` to `false` could reduce additional
675
- // path matching.
676
- // - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
677
- // @returns {TestResult} true if a file is ignored
678
- test(path, checkUnignored, mode) {
679
- let ignored = false;
680
- let unignored = false;
681
- let matchedRule;
682
- const rules = this._rules;
683
- const { length } = rules;
684
- const shortcut = this._basenameCount * 2 >= length;
685
- const basename7 = shortcut ? basenameOf(path) : path;
686
- for (let index = 0; index < length; index++) {
687
- const rule = rules[index];
688
- const { negative } = rule;
689
- const skip = unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored;
690
- if (!skip && rule[mode].test(
691
- shortcut && rule._basenameOnly ? basename7 : path
692
- )) {
693
- ignored = !negative;
694
- unignored = negative;
695
- matchedRule = negative ? UNDEFINED : rule;
696
- }
697
- }
698
- const ret = {
699
- ignored,
700
- unignored
701
- };
702
- if (matchedRule) {
703
- ret.rule = matchedRule;
704
- }
705
- return ret;
706
- }
707
- };
708
- var throwError = (message, Ctor) => {
709
- throw new Ctor(message);
710
- };
711
- var checkPath = (path, originalPath, doThrow) => {
712
- if (!isString(path)) {
713
- return doThrow(
714
- `path must be a string, but got \`${originalPath}\``,
715
- TypeError
716
- );
717
- }
718
- if (!path) {
719
- return doThrow(`path must not be empty`, TypeError);
720
- }
721
- if (checkPath.isNotRelative(path)) {
722
- const r = "`path.relative()`d";
723
- return doThrow(
724
- `path should be a ${r} string, but got "${originalPath}"`,
725
- RangeError
726
- );
727
- }
728
- return true;
729
- };
730
- var isNotRelative = (path) => {
731
- const first = path.charCodeAt(0);
732
- if (first === SLASH_CODE) {
733
- return true;
734
- }
735
- if (first !== DOT_CODE) {
736
- return false;
737
- }
738
- if (path.length === 1) {
739
- return true;
740
- }
741
- const second = path.charCodeAt(1);
742
- if (second === SLASH_CODE) {
743
- return true;
744
- }
745
- if (second !== DOT_CODE) {
746
- return false;
747
- }
748
- return path.length === 2 || path.charCodeAt(2) === SLASH_CODE;
749
- };
750
- checkPath.isNotRelative = isNotRelative;
751
- checkPath.convert = (p) => p;
752
- var Ignore = class {
753
- constructor({
754
- ignorecase = true,
755
- ignoreCase = ignorecase,
756
- allowRelativePaths = false
757
- } = {}) {
758
- define(this, KEY_IGNORE, true);
759
- this._rules = new RuleManager(ignoreCase);
760
- this._strictPathCheck = !allowRelativePaths;
761
- this._initCache();
762
- }
763
- _initCache() {
764
- this._ignoreCache = /* @__PURE__ */ Object.create(null);
765
- this._testCache = /* @__PURE__ */ Object.create(null);
766
- }
767
- add(pattern) {
768
- if (this._rules.add(pattern)) {
769
- this._initCache();
770
- }
771
- return this;
772
- }
773
- // legacy
774
- addPattern(pattern) {
775
- return this.add(pattern);
776
- }
777
- // @returns {TestResult}
778
- _test(originalPath, cache, checkUnignored) {
779
- const path = originalPath && checkPath.convert(originalPath);
780
- checkPath(
781
- path,
782
- originalPath,
783
- this._strictPathCheck ? throwError : RETURN_FALSE
784
- );
785
- return this._t(path, cache, checkUnignored);
786
- }
787
- checkIgnore(path) {
788
- if (path.charCodeAt(path.length - 1) !== SLASH_CODE) {
789
- return this.test(path);
790
- }
791
- const parentPath = parentOf(path);
792
- if (parentPath) {
793
- const parent = this._t(parentPath, this._testCache, true);
794
- if (parent.ignored) {
795
- return parent;
796
- }
797
- }
798
- return this._rules.test(path, false, MODE_CHECK_IGNORE);
799
- }
800
- _t(path, cache, checkUnignored) {
801
- if (path in cache) {
802
- return cache[path];
803
- }
804
- const parentPath = parentOf(path);
805
- const parent = parentPath ? this._t(parentPath, cache, checkUnignored) : UNDEFINED;
806
- return cache[path] = parent && parent.ignored ? parent : this._rules.test(path, checkUnignored, MODE_IGNORE);
807
- }
808
- ignores(path) {
809
- return this._test(path, this._ignoreCache, false).ignored;
810
- }
811
- createFilter() {
812
- return (path) => !this.ignores(path);
813
- }
814
- filter(paths) {
815
- return makeArray(paths).filter(this.createFilter());
816
- }
817
- // @returns {TestResult}
818
- test(path) {
819
- return this._test(path, this._testCache, true);
820
- }
821
- };
822
- var factory = (options) => new Ignore(options);
823
- var isPathValid = (path) => checkPath(path && checkPath.convert(path), path, RETURN_FALSE);
824
- var setupWindows = () => {
825
- const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
826
- checkPath.convert = makePosix;
827
- const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
828
- checkPath.isNotRelative = (path) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
829
- };
830
- if (
831
- // Detect `process` so that it can run in browsers.
832
- typeof process !== "undefined" && process.platform === "win32"
833
- ) {
834
- setupWindows();
835
- }
836
- module.exports = factory;
837
- factory.default = factory;
838
- module.exports.isPathValid = isPathValid;
839
- define(module.exports, /* @__PURE__ */ Symbol.for("setupWindows"), setupWindows);
840
- }
841
- });
842
6
 
843
7
  // ../../packages/plugin-sdk/src/config.ts
844
8
  import { existsSync as existsSync8 } from "fs";
845
- import { join as join16 } from "path";
846
-
847
- // ../../packages/persistence/src/attached-derived.ts
848
- import { rmSync } from "fs";
849
- import { join } from "path";
850
-
851
- // ../../packages/persistence/src/control-plane-credential.ts
852
- import { chmodSync as chmodSync2, lstatSync as lstatSync2, readFileSync, rmSync as rmSync3, statSync } from "fs";
853
- import { join as join2 } from "path";
9
+ import { join as join17 } from "path";
854
10
 
855
11
  // ../../packages/schema/src/drizzle/deferred-migrations.ts
856
12
  var DEFERRED_MIGRATION_TAGS = [
@@ -3679,9 +2835,9 @@ var asciiTabOrNewline = /[\t\n\r]/g;
3679
2835
  function stripTabAndNewline(value) {
3680
2836
  return value.replace(asciiTabOrNewline, "");
3681
2837
  }
3682
- function urlHostnameOk(url2, hostname7) {
3683
- hostname7.lastIndex = 0;
3684
- return hostname7.test(url2.hostname);
2838
+ function urlHostnameOk(url2, hostname6) {
2839
+ hostname6.lastIndex = 0;
2840
+ return hostname6.test(url2.hostname);
3685
2841
  }
3686
2842
  function urlProtocolOk(url2, protocol) {
3687
2843
  protocol.lastIndex = 0;
@@ -20650,8 +19806,8 @@ var PLATFORM_HOSTING = /* @__PURE__ */ new Map([
20650
19806
  ["ollama", "local"],
20651
19807
  ["local", "local"]
20652
19808
  ]);
20653
- function hostingFor(platform2) {
20654
- return PLATFORM_HOSTING.get(platform2) ?? "api";
19809
+ function hostingFor(platform) {
19810
+ return PLATFORM_HOSTING.get(platform) ?? "api";
20655
19811
  }
20656
19812
  var FIRST_PARTY = /* @__PURE__ */ new Map([
20657
19813
  ["anthropic", "anthropic"],
@@ -20665,8 +19821,8 @@ var FIRST_PARTY = /* @__PURE__ */ new Map([
20665
19821
  function firstPartyPlatformFor(vendor2) {
20666
19822
  return FIRST_PARTY.get(vendor2) ?? null;
20667
19823
  }
20668
- function isFirstParty(vendor2, platform2) {
20669
- return FIRST_PARTY.get(vendor2) === platform2;
19824
+ function isFirstParty(vendor2, platform) {
19825
+ return FIRST_PARTY.get(vendor2) === platform;
20670
19826
  }
20671
19827
  var PLATFORM_NAMESPACES = Object.freeze([
20672
19828
  "anthropic",
@@ -20727,14 +19883,14 @@ var ModelVendorBuilder = class {
20727
19883
  );
20728
19884
  }
20729
19885
  for (const ref of spec.on ?? []) {
20730
- const { platform: platform2, price, retention, region } = normalizeRef(ref);
20731
- const firstParty = isFirstParty(this.vendor, platform2);
20732
- const hosting = hostingFor(platform2);
19886
+ const { platform, price, retention, region } = normalizeRef(ref);
19887
+ const firstParty = isFirstParty(this.vendor, platform);
19888
+ const hosting = hostingFor(platform);
20733
19889
  const isSelfHosted = hosting === "local";
20734
19890
  platforms.set(
20735
- platform2,
19891
+ platform,
20736
19892
  Object.freeze({
20737
- platform: platform2,
19893
+ platform,
20738
19894
  hosting,
20739
19895
  firstParty,
20740
19896
  price: price ?? (isSelfHosted ? ZERO_PRICE : firstParty ? spec.price ?? null : null),
@@ -20884,7 +20040,7 @@ anthropic.model("claude-haiku-4-5", {
20884
20040
  name: "Claude Haiku 4.5",
20885
20041
  ctx: 2e5,
20886
20042
  maxOut: 64e3,
20887
- // Reviewed: fast/cheap tier, no flagged reasoning or code specialisation.
20043
+ // Reviewed: fast/cheap general-purpose tier, not a reasoning or code model.
20888
20044
  capability: null,
20889
20045
  price: anthropicPrice(1, 5, 0.1),
20890
20046
  // The vendor documents `claude-haiku-4-5-20251001` as the versioned id and
@@ -21015,6 +20171,11 @@ openai.model("gpt-4o", {
21015
20171
  price: tokenPrice(2.5, 10, { cacheRead: 1.25 }),
21016
20172
  on: [...OPENAI_RESELLERS]
21017
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
+ });
21018
20179
  openai.model("gpt-4o-mini", {
21019
20180
  name: "GPT-4o mini",
21020
20181
  price: tokenPrice(0.15, 0.6, { cacheRead: 0.075 }),
@@ -21034,6 +20195,24 @@ openai.model("o3", {
21034
20195
  price: tokenPrice(2, 8, { cacheRead: 0.5 }),
21035
20196
  on: [...OPENAI_RESELLERS]
21036
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
+ });
21037
20216
  openai.model("gpt-oss-120b", {
21038
20217
  name: "GPT-OSS 120B",
21039
20218
  openWeights: true,
@@ -21320,10 +20499,21 @@ var MODEL_ENTRIES = Object.freeze([
21320
20499
  ...alibaba.models(),
21321
20500
  ...amazon.models()
21322
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
+ );
21323
20513
  var MODEL_INDEX = buildModelIndex(MODEL_ENTRIES);
21324
20514
 
21325
20515
  // ../../packages/schema/src/model/governance.ts
21326
- var ModelCapability = external_exports.enum(["reasoning", "code"]);
20516
+ var ModelCapability = external_exports.enum(["reasoning", "code", "embedding"]);
21327
20517
  var DataRetention = external_exports.enum([
21328
20518
  "zero_retention",
21329
20519
  "no_storage",
@@ -21515,11 +20705,33 @@ var ResolutionMethod = external_exports.enum([
21515
20705
  "false-positive",
21516
20706
  "redetected"
21517
20707
  ]).meta({ id: "ResolutionMethod" });
20708
+ var FindingContextBasis = external_exports.enum(["file", "excerpt"]).meta({ id: "FindingContextBasis" });
20709
+ var FindingContext = external_exports.object({
20710
+ basis: FindingContextBasis,
20711
+ // 1-based line number of `lines[0]`.
20712
+ firstLine: external_exports.number().int().positive(),
20713
+ lines: external_exports.array(external_exports.string()).min(1).max(5),
20714
+ match: external_exports.object({
20715
+ // 1-based line number, within [firstLine, firstLine + lines.length).
20716
+ line: external_exports.number().int().positive(),
20717
+ // Offsets into that entry of `lines`, end exclusive.
20718
+ start: external_exports.number().int().nonnegative(),
20719
+ end: external_exports.number().int().nonnegative()
20720
+ }).nullable()
20721
+ }).meta({ id: "FindingContext" });
20722
+ var FindingLocation = external_exports.object({
20723
+ line: external_exports.number().int().positive(),
20724
+ col: external_exports.number().int().positive(),
20725
+ context: FindingContext.nullable()
20726
+ });
21518
20727
  var FindingMatch = external_exports.object({
21519
20728
  // Masked preview of the matched value. Never raw content.
21520
20729
  maskedValue: external_exports.string(),
21521
- // Redacted source-line prefix. Currently empty (pending privacy review).
21522
- contextPrefix: external_exports.string()
20730
+ // Deprecated: always empty. Superseded by `context`.
20731
+ contextPrefix: external_exports.string(),
20732
+ // The masked lines around the match. Absent when the finding predates
20733
+ // context capture or none could be built safely.
20734
+ context: FindingContext.optional()
21523
20735
  }).meta({ id: "FindingMatch" });
21524
20736
  var FindingDetectionRef = external_exports.object({
21525
20737
  id: external_exports.string(),
@@ -21539,6 +20751,11 @@ var FindingInstance = external_exports.object({
21539
20751
  provider: FindingProvider,
21540
20752
  repo: external_exports.string(),
21541
20753
  file: external_exports.string(),
20754
+ // 1-based line and column of the match start in the scanned text (the
20755
+ // column in UTF-16 code units). Absent for findings that predate location
20756
+ // capture or have no source text.
20757
+ line: external_exports.number().int().positive().optional(),
20758
+ col: external_exports.number().int().positive().optional(),
21542
20759
  // Who the capturing event is attributed to. Optional: a single-user store
21543
20760
  // has no one to attribute a finding to and never sets it.
21544
20761
  user: FindingUser.optional(),
@@ -21600,6 +20817,13 @@ var FindingStats = external_exports.object({
21600
20817
  low: external_exports.number().int().nonnegative()
21601
20818
  })
21602
20819
  }).meta({ id: "FindingStats" });
20820
+ var FindingsOverview = external_exports.object({
20821
+ findings: external_exports.number().int().nonnegative(),
20822
+ open: external_exports.number().int().nonnegative(),
20823
+ handled: external_exports.number().int().nonnegative(),
20824
+ resolved: external_exports.number().int().nonnegative(),
20825
+ dismissed: external_exports.number().int().nonnegative()
20826
+ }).meta({ id: "FindingsOverview" });
21603
20827
  var FindingFacetItem = external_exports.object({
21604
20828
  value: external_exports.string(),
21605
20829
  count: external_exports.number().int().nonnegative()
@@ -21717,6 +20941,7 @@ var FindingInstanceDetail = FindingInstance.extend({
21717
20941
  policy: FindingPolicyRef
21718
20942
  }).meta({ id: "FindingInstanceDetail" });
21719
20943
  var MAX_FLAT_FINDINGS_LIMIT = 200;
20944
+ var FindingContextQuery = external_exports.object({ id: external_exports.string().min(1).max(256) });
21720
20945
  var ListFindingInstancesQuery = external_exports.object({
21721
20946
  severity: external_exports.array(Severity).optional(),
21722
20947
  // Rule ids, the same vocabulary the types list's `subtype` carries. Pinning
@@ -22048,7 +21273,23 @@ var CaptureAttributes = external_exports.object({
22048
21273
  // capture denied by another finding's own Block policy carries `block`
22049
21274
  // here too. The full statement is on EventMetadata.redactDegradedTo; it is
22050
21275
  // repeated rather than referenced because a store reader opens this file.
22051
- redact_degraded_to: ActionTaken.optional()
21276
+ redact_degraded_to: ActionTaken.optional(),
21277
+ // The scope key this capture was stamped with: the canonical repository
21278
+ // (`host/owner/repo`) of the path the capture names (a relative path is read
21279
+ // against its working directory), else of its own working directory, or a
21280
+ // chat account's identity. The store's local `scope_key` column reads it, so
21281
+ // a scoped attachment has a per-row key to work from. Absent when no key
21282
+ // could be derived.
21283
+ //
21284
+ // LOCAL ONLY. That is the contract for every path that sends a row. Producers
21285
+ // stamp it in every attachment mode, and the two structural choke points strip
21286
+ // it: the attached gateway's `reKeyForForward` on the live path, and the
21287
+ // history drain's `rebuildAuditEvent`, which drops it through `withoutScopeKey`.
21288
+ // A capture row's bag reaches the wire through `rebuildCapture`, which builds
21289
+ // the metadata from named keys and never names this one; `toCaptureAttributes`,
21290
+ // which builds the bag from a wire event, never emits it. What a scoped
21291
+ // attachment does with the key is not part of this shape's contract.
21292
+ scope_key: external_exports.string().optional()
22052
21293
  }).catchall(external_exports.unknown());
22053
21294
  var CaptureStatusAttributes = external_exports.object({
22054
21295
  source_tool: external_exports.string().optional(),
@@ -22078,6 +21319,12 @@ var ToolCallInspection = external_exports.object({
22078
21319
  actionTaken: ActionTaken,
22079
21320
  confidence: external_exports.number().min(0).max(1)
22080
21321
  });
21322
+ var findingLocationFields = {
21323
+ line: external_exports.number().int().positive().optional(),
21324
+ col: external_exports.number().int().positive().optional(),
21325
+ context: FindingContext.nullable().optional()
21326
+ };
21327
+ var ToolCallInspectionInput = ToolCallInspection.extend(findingLocationFields);
22081
21328
  var ToolCallInput = external_exports.object({
22082
21329
  sessionId: external_exports.string().min(1),
22083
21330
  toolUseId: external_exports.string().min(1),
@@ -22087,7 +21334,7 @@ var ToolCallInput = external_exports.object({
22087
21334
  attributes: ToolCallAttributes,
22088
21335
  // Secrets detected in the tool's (masked) target — written as linked
22089
21336
  // `inspection_findings`. Empty for a clean tool call.
22090
- inspections: external_exports.array(ToolCallInspection).default([])
21337
+ inspections: external_exports.array(ToolCallInspectionInput).default([])
22091
21338
  });
22092
21339
  var InventoryInput = external_exports.object({
22093
21340
  objectType: InventoryObjectType,
@@ -22161,7 +21408,8 @@ var InspectionFindingInput = external_exports.object({
22161
21408
  // same findingKey — mirrors the legacy `findings.first_detected_at`.
22162
21409
  // Optional: when omitted, the writer derives it from the referenced audit
22163
21410
  // event's startedAt on first insert (see SqliteInspectionFindingsRepository).
22164
- firstDetectedAt: external_exports.iso.datetime().optional()
21411
+ firstDetectedAt: external_exports.iso.datetime().optional(),
21412
+ ...findingLocationFields
22165
21413
  });
22166
21414
  var InventoryContext = external_exports.object({
22167
21415
  host: InventoryInput.optional(),
@@ -22203,8 +21451,9 @@ var SessionTokenReport = external_exports.object({
22203
21451
  totalTokens: external_exports.number().int().nonnegative(),
22204
21452
  // Σ of the PRICED rollups only; null when no rollup had a known price.
22205
21453
  estimatedCostUsd: external_exports.number().nullable(),
22206
- // True whenever any rollup has a null cost (unknown provider/model), so the
22207
- // total understates real spend — the UI renders `≥ $X` instead of a falsely
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
22208
21457
  // precise figure rather than silently dropping the unpriced calls.
22209
21458
  costIsPartial: external_exports.boolean()
22210
21459
  });
@@ -22936,6 +22185,17 @@ var AttachedCredential = external_exports.object({
22936
22185
  keyPrefix: external_exports.string().min(1).max(16).optional(),
22937
22186
  mintedAt: external_exports.iso.datetime().optional()
22938
22187
  });
22188
+ var AttachmentMode = external_exports.enum(["machine", "scoped"]);
22189
+ var ATTACHED_CREDENTIAL_SCOPED_SPEC_VERSION = 2;
22190
+ var AttachedCredentialV1 = AttachedCredential;
22191
+ var AttachedCredentialV2 = AttachedCredential.extend({
22192
+ specVersion: external_exports.literal(ATTACHED_CREDENTIAL_SCOPED_SPEC_VERSION),
22193
+ mode: external_exports.literal("scoped")
22194
+ });
22195
+ var AttachedCredentialAny = external_exports.discriminatedUnion("specVersion", [
22196
+ AttachedCredentialV1,
22197
+ AttachedCredentialV2
22198
+ ]);
22939
22199
  var MAX_DATE_MS = 253402300799999;
22940
22200
  var MAX_INT4 = 2147483647;
22941
22201
  var StorePosturePack = external_exports.object({
@@ -23039,7 +22299,15 @@ var StorePostureSnapshot = external_exports.object({
23039
22299
  policyCounts: StorePosturePolicyCounts,
23040
22300
  // OPTIONAL, not nullable: a reporter that predates this member keeps
23041
22301
  // getting its 200 without a payload change.
23042
- 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()
23043
22311
  }).meta({ id: "StorePostureSnapshot" });
23044
22312
  var CAPTURE_VERSION_PREFIX = "capture/";
23045
22313
  var RecordAuditEventRequest = AuditEventInput.extend({
@@ -23217,105 +22485,233 @@ var PackId = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
23217
22485
  var SemVer = external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?$/);
23218
22486
  var PublisherKind = external_exports.enum(["labs", "user", "org"]);
23219
22487
 
23220
- // ../../packages/schema/src/zod/rule.ts
23221
- var MatcherType = external_exports.enum(["keyword", "regex"]).meta({ id: "MatcherType" });
23222
- var RuleProbeVerdict = external_exports.enum(["safe", "quarantined"]).meta({ id: "RuleProbeVerdict" });
23223
- var KeywordMatcher = external_exports.strictObject({
23224
- type: external_exports.literal("keyword"),
23225
- // An empty keyword matches at every position, yielding one zero-length span
23226
- // per character. Rejected here because a keyword that matches everything is
23227
- // never intentional.
23228
- keywords: external_exports.array(external_exports.string().min(1)).min(1),
23229
- caseSensitive: external_exports.boolean().default(false)
23230
- });
23231
- function isValidRegex(pattern, flags) {
23232
- try {
23233
- new RegExp(pattern, flags);
23234
- return true;
23235
- } catch {
23236
- return false;
23237
- }
23238
- }
23239
- function probeFlags(flags) {
23240
- return flags.replace(/[gy]/g, "");
23241
- }
23242
- function matchesEmptyString(pattern, flags) {
23243
- try {
23244
- const re = new RegExp(pattern, probeFlags(flags));
23245
- return re.exec("")?.[0].length === 0;
23246
- } catch {
23247
- return false;
23248
- }
23249
- }
23250
- function spansWholeMatch(captureGroup) {
23251
- return captureGroup === void 0 || captureGroup === 0;
23252
- }
23253
- function captureGroupCount(pattern, flags) {
23254
- try {
23255
- const probe = new RegExp(`${pattern}|`, probeFlags(flags));
23256
- const result = probe.exec("");
23257
- return result ? result.length - 1 : void 0;
23258
- } catch {
23259
- return void 0;
23260
- }
23261
- }
23262
- var MAX_PATTERN_LENGTH = 2e3;
23263
- var RegexMatcher = external_exports.strictObject({
23264
- type: external_exports.literal("regex"),
23265
- pattern: external_exports.string().min(1).max(MAX_PATTERN_LENGTH),
23266
- flags: external_exports.string().default("gi"),
23267
- captureGroup: external_exports.number().int().nonnegative().optional()
23268
- }).refine((v) => isValidRegex(v.pattern, v.flags), {
23269
- message: "pattern/flags do not form a valid JavaScript regular expression",
23270
- path: ["pattern"]
23271
- }).refine((v) => !spansWholeMatch(v.captureGroup) || !matchesEmptyString(v.pattern, v.flags), {
23272
- message: 'a whole-match regex that can match the empty string (e.g. "\\d*", "a?", "(?:)") can hang the matcher \u2014 scope the quantifier to a captureGroup, or require at least one character',
23273
- path: ["pattern"]
23274
- }).superRefine((v, ctx) => {
23275
- if (v.captureGroup === void 0) return;
23276
- const groups = captureGroupCount(v.pattern, v.flags);
23277
- if (groups === void 0 || v.captureGroup <= groups) return;
23278
- ctx.addIssue({
23279
- code: "custom",
23280
- path: ["captureGroup"],
23281
- message: `captureGroup ${String(v.captureGroup)} is out of range \u2014 the pattern declares ${String(groups)} capture group(s), so valid values are 0-${String(groups)}. An out-of-range group never matches, which would make the rule silently never fire.`
23282
- });
23283
- });
23284
- var Matcher = external_exports.discriminatedUnion("type", [KeywordMatcher, RegexMatcher]).meta({ id: "Matcher" });
23285
- var MATCHER_TYPES = MatcherType.options;
23286
- var AppliesTo = external_exports.strictObject({
23287
- // Dot-prefixed, e.g. ".py" — matches the scanner's SOURCE_EXTENSIONS shape.
23288
- extensions: external_exports.array(external_exports.string().regex(/^\.[A-Za-z0-9]+$/)).min(1)
23289
- }).meta({ id: "AppliesTo" });
23290
- var PostValidatorName = external_exports.enum(["entropy", "luhn"]).meta({ id: "PostValidatorName" });
23291
- var PostValidatorRef = external_exports.union(
23292
- [
23293
- PostValidatorName,
23294
- external_exports.strictObject({
23295
- name: PostValidatorName,
23296
- config: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
23297
- })
23298
- ],
23299
- {
23300
- // A union reports one collapsed issue for every way its arms can fail, so
23301
- // this has to describe the whole shape rather than just the name — it is
23302
- // what an author sees for a misspelled name AND for a stray key in the
23303
- // object form. The names come from the enum so the message cannot go
23304
- // stale. Without it Zod says only "Invalid input", which is precisely the
23305
- // no-feedback outcome this schema exists to remove.
23306
- error: () => `not a valid post-validator: use a bare name (${PostValidatorName.options.map((name) => JSON.stringify(name)).join(
23307
- " or "
23308
- )}) or { "name": ..., "config": { ... } }. An unrecognized name would be a false-positive guard that never runs.`
23309
- }
23310
- ).meta({ id: "PostValidatorRef" });
23311
- var RequiresNearby = external_exports.strictObject({
23312
- // Each array, when present, must be non-empty and contain non-empty strings —
23313
- // an empty/blank criterion would either never fire or (for labels) match
23314
- // everything.
23315
- categories: external_exports.array(DetectionCategory).min(1).optional(),
23316
- ruleIds: external_exports.array(external_exports.string().min(1)).min(1).optional(),
23317
- labels: external_exports.array(external_exports.string().min(1)).min(1).optional(),
23318
- windowChars: external_exports.number().int().positive().default(160),
22488
+ // ../../packages/schema/src/zod/builtin-policy-id.ts
22489
+ var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
22490
+ var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
22491
+
22492
+ // ../../packages/schema/src/zod/event.ts
22493
+ var EventKind = external_exports.enum(["prompt", "response", "code_change", "tool_use"]).meta({ id: "EventKind" });
22494
+ var CAPTURE_EVENT_TYPES_SQL = EventKind.options.map((k) => `'${k}'`).join(",");
22495
+ var EventMetadata = external_exports.object({
22496
+ sessionId: external_exports.string().optional(),
22497
+ repo: external_exports.string().optional(),
22498
+ filePath: external_exports.string().optional(),
22499
+ // The host tool whose input/output was scanned (e.g. 'Bash', 'WebFetch'),
22500
+ // set by the tool-scanning hooks. The tool NAME only — never the tool's
22501
+ // arguments or output, which can carry the very value a finding masked
22502
+ // (metadata is stored unredacted). Gives findings on non-file captures a
22503
+ // display location ("via Bash") when no filePath exists.
22504
+ toolName: external_exports.string().optional(),
22505
+ // Set (true) by the worktree scanner when the file is excluded by the
22506
+ // repo's .gitignore. Gitignored files ARE still scanned — local scratch and
22507
+ // generated code can leak real secrets — but the provenance is recorded so
22508
+ // policy/dashboards can treat those findings as informational rather than
22509
+ // blocking. Omitted (not false) for tracked files and non-scan events.
22510
+ gitignored: external_exports.boolean().optional(),
22511
+ // Set (true) ONLY when the event's `content` is the COMPLETE file at
22512
+ // capture time (a worktree scan reading from disk). Hook-captured edits
22513
+ // (e.g. an Edit tool's new_string) are partial fragments and MUST NOT set
22514
+ // this. The resolver-on-ingest keys its fixed-at-source dropout
22515
+ // diff on this marker: only a whole-file snapshot can prove a previously
22516
+ // open finding is gone; a fragment's absence proves nothing (the secret
22517
+ // may live outside the hunk). Omitted (not false) for fragments and
22518
+ // non-scan events, so pre-marker clients safely default to the
22519
+ // non-authoritative path.
22520
+ wholeFile: external_exports.boolean().optional(),
22521
+ model: external_exports.string().optional(),
22522
+ turnIndex: external_exports.number().int().nonnegative().optional(),
22523
+ // Distributed-tracing correlation. `correlationId` ties a recorded event back
22524
+ // to the request that captured/ingested it (a UUID, generated independently of
22525
+ // the trace id); `traceId` is the W3C trace id (32 lowercase hex chars) of the
22526
+ // originating span when telemetry is enabled. Both optional + backward
22527
+ // compatible — populated by the plugin (see @akasecurity/plugin-sdk).
22528
+ correlationId: external_exports.uuid().optional(),
22529
+ traceId: external_exports.string().regex(/^[0-9a-f]{32}$/).optional(),
22530
+ // Ids of the detection exceptions that downgraded findings in this capture
22531
+ // to 'allow' — the enforcement audit trail's link back to the grant that
22532
+ // authorized the bypass. Absent on captures where no exception applied.
22533
+ exceptionIds: external_exports.array(external_exports.guid()).optional(),
22534
+ // The assistant message this capture belongs to, and the conversation it sits
22535
+ // in — set by the browser extension's network capture so a stored `response`
22536
+ // row can be joined to the `llm_call` leaf describing the same turn. Absent
22537
+ // on every other capture path, which has no such id.
22538
+ //
22539
+ // Non-empty for the reason WebExchange.messageId is: it is the join key, and
22540
+ // a blank one matches no `llm_call` leaf. That refusal reaches only the
22541
+ // places an event is PARSED; the local write path types the event and parses
22542
+ // nothing, which is why `toCaptureAttributes` omits a blank one separately.
22543
+ messageId: external_exports.string().min(1).optional(),
22544
+ conversationId: external_exports.string().optional(),
22545
+ // How long THIS capture's inspection blocked its caller, in whole
22546
+ // milliseconds — the plugin's own added latency, NOT the LLM call it sat in
22547
+ // front of. Measured inside `capture()` (@akasecurity/plugin-sdk) across
22548
+ // detection + redaction, the work the host session actually waits on.
22549
+ //
22550
+ // Stamped ONLY on live in-flight captures. A capture that carries its own
22551
+ // `occurredAt` is replaying past work (the transcript backfill, the worktree
22552
+ // scan), and its scan duration is not latency any host session experienced,
22553
+ // so those rows leave this ABSENT rather than reporting a misleading number.
22554
+ // Absent is also what every pre-measurement client writes, and what a
22555
+ // clock failure degrades to — a reader must treat absence as "not measured"
22556
+ // and never as a zero, which would read as "inspection is free".
22557
+ inspectionMs: external_exports.number().int().nonnegative().optional(),
22558
+ // What a `redact` this capture COULD NOT CARRY OUT became instead — the
22559
+ // workspace's `redactFallback`, applied because the field could not be
22560
+ // masked in place (a shell command, a URL, or any argument on a host whose
22561
+ // hook contract offers no rewrite channel).
22562
+ //
22563
+ // It exists because the action alone cannot say why. A finding recorded as
22564
+ // `warn` reads identically whether its detection was ASSIGNED Warn or was
22565
+ // assigned Redact on a field that could not take one — and those are
22566
+ // different facts about the same row: the first is a policy the user chose,
22567
+ // the second is a masking the host could not perform. Absent means no
22568
+ // degrade happened, which is every ordinary capture.
22569
+ //
22570
+ // TWO LIMITS a reader of a stored row has to know, because the grain here
22571
+ // is the CAPTURE while `actionTaken` is per FINDING:
22572
+ //
22573
+ // - It does not say WHICH finding degraded. A capture carrying a degraded
22574
+ // `redact` alongside a finding ASSIGNED the same action stores both
22575
+ // identically and one reason for the pair; attributing it to both
22576
+ // describes the assigned one wrongly, and to neither loses the degrade.
22577
+ // - PRESENCE IS NOT CAUSATION. The value is the action the lost redact
22578
+ // became, not the reason the capture ended as it did — a capture denied
22579
+ // by some other finding's own Block policy still carries `block` here,
22580
+ // and clearing the workspace's fallback would not have let it through.
22581
+ // Gate on the value against what a fallback can produce; never read the
22582
+ // field's presence as "this was the fallback's doing".
22583
+ //
22584
+ // Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
22585
+ // Closing either means moving the reason onto the finding row, which
22586
+ // already carries its own action.
22587
+ redactDegradedTo: ActionTaken.optional()
22588
+ }).meta({ id: "EventMetadata" });
22589
+ var Event = external_exports.object({
22590
+ id: external_exports.guid(),
22591
+ sourceTool: SourceTool,
22592
+ kind: EventKind,
22593
+ occurredAt: external_exports.iso.datetime(),
22594
+ contentHash: external_exports.string(),
22595
+ content: external_exports.string(),
22596
+ metadata: EventMetadata.optional()
22597
+ }).meta({ id: "Event" });
22598
+ var IngestEvent = Event.meta({ id: "IngestEvent" });
22599
+ var INGEST_BATCH_MAX = 100;
22600
+ var IngestBatch = external_exports.object({
22601
+ events: external_exports.array(IngestEvent).min(1).max(INGEST_BATCH_MAX),
22602
+ // Dedup policy for this batch. Id-dedup ALWAYS applies. 'content-hash'
22603
+ // additionally rejects any event whose contentHash the store has already
22604
+ // recorded — for re-runnable bulk ingest (worktree scan, transcript
22605
+ // backfill), where a re-run mints fresh event ids for identical content and
22606
+ // would otherwise accumulate duplicates. Live hook traffic must NOT set it:
22607
+ // two genuinely separate prompts can be byte-identical and both belong on
22608
+ // the timeline.
22609
+ dedupe: external_exports.literal("content-hash").optional()
22610
+ }).meta({ id: "IngestBatch" });
22611
+
22612
+ // ../../packages/schema/src/zod/rule.ts
22613
+ var MatcherType = external_exports.enum(["keyword", "regex"]).meta({ id: "MatcherType" });
22614
+ var RuleProbeVerdict = external_exports.enum(["safe", "quarantined"]).meta({ id: "RuleProbeVerdict" });
22615
+ var KeywordMatcher = external_exports.strictObject({
22616
+ type: external_exports.literal("keyword"),
22617
+ // An empty keyword matches at every position, yielding one zero-length span
22618
+ // per character. Rejected here because a keyword that matches everything is
22619
+ // never intentional.
22620
+ keywords: external_exports.array(external_exports.string().min(1)).min(1),
22621
+ caseSensitive: external_exports.boolean().default(false)
22622
+ });
22623
+ function isValidRegex(pattern, flags) {
22624
+ try {
22625
+ new RegExp(pattern, flags);
22626
+ return true;
22627
+ } catch {
22628
+ return false;
22629
+ }
22630
+ }
22631
+ function probeFlags(flags) {
22632
+ return flags.replace(/[gy]/g, "");
22633
+ }
22634
+ function matchesEmptyString(pattern, flags) {
22635
+ try {
22636
+ const re = new RegExp(pattern, probeFlags(flags));
22637
+ return re.exec("")?.[0].length === 0;
22638
+ } catch {
22639
+ return false;
22640
+ }
22641
+ }
22642
+ function spansWholeMatch(captureGroup) {
22643
+ return captureGroup === void 0 || captureGroup === 0;
22644
+ }
22645
+ function captureGroupCount(pattern, flags) {
22646
+ try {
22647
+ const probe = new RegExp(`${pattern}|`, probeFlags(flags));
22648
+ const result = probe.exec("");
22649
+ return result ? result.length - 1 : void 0;
22650
+ } catch {
22651
+ return void 0;
22652
+ }
22653
+ }
22654
+ var MAX_PATTERN_LENGTH = 2e3;
22655
+ var RegexMatcher = external_exports.strictObject({
22656
+ type: external_exports.literal("regex"),
22657
+ pattern: external_exports.string().min(1).max(MAX_PATTERN_LENGTH),
22658
+ flags: external_exports.string().default("gi"),
22659
+ captureGroup: external_exports.number().int().nonnegative().optional()
22660
+ }).refine((v) => isValidRegex(v.pattern, v.flags), {
22661
+ message: "pattern/flags do not form a valid JavaScript regular expression",
22662
+ path: ["pattern"]
22663
+ }).refine((v) => !spansWholeMatch(v.captureGroup) || !matchesEmptyString(v.pattern, v.flags), {
22664
+ message: 'a whole-match regex that can match the empty string (e.g. "\\d*", "a?", "(?:)") can hang the matcher \u2014 scope the quantifier to a captureGroup, or require at least one character',
22665
+ path: ["pattern"]
22666
+ }).superRefine((v, ctx) => {
22667
+ if (v.captureGroup === void 0) return;
22668
+ const groups = captureGroupCount(v.pattern, v.flags);
22669
+ if (groups === void 0 || v.captureGroup <= groups) return;
22670
+ ctx.addIssue({
22671
+ code: "custom",
22672
+ path: ["captureGroup"],
22673
+ message: `captureGroup ${String(v.captureGroup)} is out of range \u2014 the pattern declares ${String(groups)} capture group(s), so valid values are 0-${String(groups)}. An out-of-range group never matches, which would make the rule silently never fire.`
22674
+ });
22675
+ });
22676
+ var Matcher = external_exports.discriminatedUnion("type", [KeywordMatcher, RegexMatcher]).meta({ id: "Matcher" });
22677
+ var MATCHER_TYPES = MatcherType.options;
22678
+ var AppliesTo = external_exports.strictObject({
22679
+ // Dot-prefixed, e.g. ".py" — matches the scanner's SOURCE_EXTENSIONS shape.
22680
+ extensions: external_exports.array(external_exports.string().regex(/^\.[A-Za-z0-9]+$/)).min(1).optional(),
22681
+ eventKinds: external_exports.array(EventKind).min(1).optional()
22682
+ }).refine((v) => v.extensions !== void 0 || v.eventKinds !== void 0, {
22683
+ message: "appliesTo needs extensions, eventKinds, or both"
22684
+ }).meta({ id: "AppliesTo" });
22685
+ var PostValidatorName = external_exports.enum(["entropy", "luhn"]).meta({ id: "PostValidatorName" });
22686
+ var PostValidatorRef = external_exports.union(
22687
+ [
22688
+ PostValidatorName,
22689
+ external_exports.strictObject({
22690
+ name: PostValidatorName,
22691
+ config: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
22692
+ })
22693
+ ],
22694
+ {
22695
+ // A union reports one collapsed issue for every way its arms can fail, so
22696
+ // this has to describe the whole shape rather than just the name — it is
22697
+ // what an author sees for a misspelled name AND for a stray key in the
22698
+ // object form. The names come from the enum so the message cannot go
22699
+ // stale. Without it Zod says only "Invalid input", which is precisely the
22700
+ // no-feedback outcome this schema exists to remove.
22701
+ error: () => `not a valid post-validator: use a bare name (${PostValidatorName.options.map((name) => JSON.stringify(name)).join(
22702
+ " or "
22703
+ )}) or { "name": ..., "config": { ... } }. An unrecognized name would be a false-positive guard that never runs.`
22704
+ }
22705
+ ).meta({ id: "PostValidatorRef" });
22706
+ var RuleEvidence = external_exports.enum(["code", "value"]).meta({ id: "RuleEvidence" });
22707
+ var RequiresNearby = external_exports.strictObject({
22708
+ // Each array, when present, must be non-empty and contain non-empty strings —
22709
+ // an empty/blank criterion would either never fire or (for labels) match
22710
+ // everything.
22711
+ categories: external_exports.array(DetectionCategory).min(1).optional(),
22712
+ ruleIds: external_exports.array(external_exports.string().min(1)).min(1).optional(),
22713
+ labels: external_exports.array(external_exports.string().min(1)).min(1).optional(),
22714
+ windowChars: external_exports.number().int().positive().default(160),
23319
22715
  // Optional confidence bump applied when a gated match is corroborated. Capped
23320
22716
  // small: it nudges confidence, it does not assert certainty.
23321
22717
  confidenceBoost: external_exports.number().min(0).max(0.3).optional()
@@ -23330,6 +22726,8 @@ var RuleFixture = external_exports.strictObject({
23330
22726
  // Simulated file context for the scan, so fixtures can assert `appliesTo`
23331
22727
  // gating (e.g. a Python-only pattern must NOT fire in a .ts file).
23332
22728
  filePath: external_exports.string().optional(),
22729
+ // Simulated capture kind, so fixtures can assert `appliesTo.eventKinds`.
22730
+ eventKind: EventKind.optional(),
23333
22731
  expectedSpans: external_exports.array(external_exports.strictObject({ start: external_exports.number(), end: external_exports.number() })).optional()
23334
22732
  }).meta({ id: "RuleFixture" });
23335
22733
  var Rule = external_exports.strictObject({
@@ -23355,7 +22753,9 @@ var Rule = external_exports.strictObject({
23355
22753
  appliesTo: AppliesTo.optional(),
23356
22754
  postValidators: external_exports.array(PostValidatorRef).optional(),
23357
22755
  requiresNearby: RequiresNearby.optional(),
23358
- examples: external_exports.array(external_exports.string()).optional()
22756
+ examples: external_exports.array(external_exports.string()).optional(),
22757
+ // Whether the matched text is itself sensitive (see RuleEvidence).
22758
+ evidence: RuleEvidence.optional()
23359
22759
  }).meta({ id: "Rule" });
23360
22760
  var Author = external_exports.object({
23361
22761
  name: external_exports.string(),
@@ -23372,7 +22772,11 @@ var PackManifest = external_exports.object({
23372
22772
  description: external_exports.string().optional(),
23373
22773
  author: Author.optional(),
23374
22774
  license: external_exports.string().optional(),
23375
- sourceUrl: external_exports.url().optional()
22775
+ sourceUrl: external_exports.url().optional(),
22776
+ // The built-in policy a FIRST install of this pack assigns
22777
+ // (installed_packs.policy_id). Absent leaves the pack unassigned, so its
22778
+ // rules follow the category policies. An existing install never takes it.
22779
+ defaultPolicy: BuiltinPolicyId.optional()
23376
22780
  }).meta({ id: "PackManifest" });
23377
22781
 
23378
22782
  // ../../packages/schema/src/zod/detection.ts
@@ -23400,10 +22804,12 @@ var DetectionListItem = external_exports.object({
23400
22804
  // Per-pack enforcement-policy assignment. Holds a BuiltinPolicyId ARCHETYPE
23401
22805
  // (monitor|warn|redact|block) — NOT a policies-table Policy.id guid; a
23402
22806
  // detection is a PACK, and its policy is the archetype applied to all its
23403
- // rules. Absent == unassigned, which resolves to Monitor everywhere
23404
- // (DEFAULT_PACK_POLICY_ID). Every enforcement surface expands it into
23405
- // per-rule policies (see policyIdToAction). Typed z.string() (not
23406
- // the enum) to keep the OpenAPI response tolerant of a future custom id.
22807
+ // rules. Absent == unassigned, which resolves to Monitor by default
22808
+ // (DEFAULT_PACK_POLICY_ID); a host may resolve it to a policy of its own
22809
+ // (see the dashboard's `unassignedPolicy`). Every enforcement surface
22810
+ // expands it into per-rule policies (see policyIdToAction). Typed
22811
+ // z.string() (not the enum) to keep the OpenAPI response tolerant of a
22812
+ // future custom id.
23407
22813
  policyId: external_exports.string().optional(),
23408
22814
  // Set ONLY when a newer snapshot is available for this pack (OSS: the
23409
22815
  // bundled inventory recorded in available_packs differs from the installed
@@ -23440,7 +22846,13 @@ var DetectionRule = external_exports.object({
23440
22846
  // Representative matching strings the rule author shipped with the rule. The
23441
22847
  // cheapest honest answer to "show me what this rule catches" — every bundled
23442
22848
  // rule has them, and they are already in the stored snapshot.
23443
- 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()
23444
22856
  }).meta({ id: "DetectionRule" });
23445
22857
  var DetectionUpdate = external_exports.object({
23446
22858
  available: external_exports.boolean(),
@@ -23472,10 +22884,12 @@ var DetectionDetail = external_exports.object({
23472
22884
  // Per-pack enforcement-policy assignment. Holds a BuiltinPolicyId ARCHETYPE
23473
22885
  // (monitor|warn|redact|block) — NOT a policies-table Policy.id guid; a
23474
22886
  // detection is a PACK, and its policy is the archetype applied to all its
23475
- // rules. Absent == unassigned, which resolves to Monitor everywhere
23476
- // (DEFAULT_PACK_POLICY_ID). Every enforcement surface expands it into
23477
- // per-rule policies (see policyIdToAction). Typed z.string() (not
23478
- // the enum) to keep the OpenAPI response tolerant of a future custom id.
22887
+ // rules. Absent == unassigned, which resolves to Monitor by default
22888
+ // (DEFAULT_PACK_POLICY_ID); a host may resolve it to a policy of its own
22889
+ // (see the dashboard's `unassignedPolicy`). Every enforcement surface
22890
+ // expands it into per-rule policies (see policyIdToAction). Typed
22891
+ // z.string() (not the enum) to keep the OpenAPI response tolerant of a
22892
+ // future custom id.
23479
22893
  policyId: external_exports.string().optional()
23480
22894
  }).meta({ id: "DetectionDetail" });
23481
22895
  var LibraryItem = external_exports.object({
@@ -23505,126 +22919,6 @@ var ImportDetectionRequest = external_exports.object({
23505
22919
  })
23506
22920
  }).meta({ id: "ImportDetectionRequest" });
23507
22921
 
23508
- // ../../packages/schema/src/zod/event.ts
23509
- var EventKind = external_exports.enum(["prompt", "response", "code_change", "tool_use"]).meta({ id: "EventKind" });
23510
- var CAPTURE_EVENT_TYPES_SQL = EventKind.options.map((k) => `'${k}'`).join(",");
23511
- var EventMetadata = external_exports.object({
23512
- sessionId: external_exports.string().optional(),
23513
- repo: external_exports.string().optional(),
23514
- filePath: external_exports.string().optional(),
23515
- // The host tool whose input/output was scanned (e.g. 'Bash', 'WebFetch'),
23516
- // set by the tool-scanning hooks. The tool NAME only — never the tool's
23517
- // arguments or output, which can carry the very value a finding masked
23518
- // (metadata is stored unredacted). Gives findings on non-file captures a
23519
- // display location ("via Bash") when no filePath exists.
23520
- toolName: external_exports.string().optional(),
23521
- // Set (true) by the worktree scanner when the file is excluded by the
23522
- // repo's .gitignore. Gitignored files ARE still scanned — local scratch and
23523
- // generated code can leak real secrets — but the provenance is recorded so
23524
- // policy/dashboards can treat those findings as informational rather than
23525
- // blocking. Omitted (not false) for tracked files and non-scan events.
23526
- gitignored: external_exports.boolean().optional(),
23527
- // Set (true) ONLY when the event's `content` is the COMPLETE file at
23528
- // capture time (a worktree scan reading from disk). Hook-captured edits
23529
- // (e.g. an Edit tool's new_string) are partial fragments and MUST NOT set
23530
- // this. The resolver-on-ingest keys its fixed-at-source dropout
23531
- // diff on this marker: only a whole-file snapshot can prove a previously
23532
- // open finding is gone; a fragment's absence proves nothing (the secret
23533
- // may live outside the hunk). Omitted (not false) for fragments and
23534
- // non-scan events, so pre-marker clients safely default to the
23535
- // non-authoritative path.
23536
- wholeFile: external_exports.boolean().optional(),
23537
- model: external_exports.string().optional(),
23538
- turnIndex: external_exports.number().int().nonnegative().optional(),
23539
- // Distributed-tracing correlation. `correlationId` ties a recorded event back
23540
- // to the request that captured/ingested it (a UUID, generated independently of
23541
- // the trace id); `traceId` is the W3C trace id (32 lowercase hex chars) of the
23542
- // originating span when telemetry is enabled. Both optional + backward
23543
- // compatible — populated by the plugin (see @akasecurity/plugin-sdk).
23544
- correlationId: external_exports.uuid().optional(),
23545
- traceId: external_exports.string().regex(/^[0-9a-f]{32}$/).optional(),
23546
- // Ids of the detection exceptions that downgraded findings in this capture
23547
- // to 'allow' — the enforcement audit trail's link back to the grant that
23548
- // authorized the bypass. Absent on captures where no exception applied.
23549
- exceptionIds: external_exports.array(external_exports.guid()).optional(),
23550
- // The assistant message this capture belongs to, and the conversation it sits
23551
- // in — set by the browser extension's network capture so a stored `response`
23552
- // row can be joined to the `llm_call` leaf describing the same turn. Absent
23553
- // on every other capture path, which has no such id.
23554
- //
23555
- // Non-empty for the reason WebExchange.messageId is: it is the join key, and
23556
- // a blank one matches no `llm_call` leaf. That refusal reaches only the
23557
- // places an event is PARSED; the local write path types the event and parses
23558
- // nothing, which is why `toCaptureAttributes` omits a blank one separately.
23559
- messageId: external_exports.string().min(1).optional(),
23560
- conversationId: external_exports.string().optional(),
23561
- // How long THIS capture's inspection blocked its caller, in whole
23562
- // milliseconds — the plugin's own added latency, NOT the LLM call it sat in
23563
- // front of. Measured inside `capture()` (@akasecurity/plugin-sdk) across
23564
- // detection + redaction, the work the host session actually waits on.
23565
- //
23566
- // Stamped ONLY on live in-flight captures. A capture that carries its own
23567
- // `occurredAt` is replaying past work (the transcript backfill, the worktree
23568
- // scan), and its scan duration is not latency any host session experienced,
23569
- // so those rows leave this ABSENT rather than reporting a misleading number.
23570
- // Absent is also what every pre-measurement client writes, and what a
23571
- // clock failure degrades to — a reader must treat absence as "not measured"
23572
- // and never as a zero, which would read as "inspection is free".
23573
- inspectionMs: external_exports.number().int().nonnegative().optional(),
23574
- // What a `redact` this capture COULD NOT CARRY OUT became instead — the
23575
- // workspace's `redactFallback`, applied because the field could not be
23576
- // masked in place (a shell command, a URL, or any argument on a host whose
23577
- // hook contract offers no rewrite channel).
23578
- //
23579
- // It exists because the action alone cannot say why. A finding recorded as
23580
- // `warn` reads identically whether its detection was ASSIGNED Warn or was
23581
- // assigned Redact on a field that could not take one — and those are
23582
- // different facts about the same row: the first is a policy the user chose,
23583
- // the second is a masking the host could not perform. Absent means no
23584
- // degrade happened, which is every ordinary capture.
23585
- //
23586
- // TWO LIMITS a reader of a stored row has to know, because the grain here
23587
- // is the CAPTURE while `actionTaken` is per FINDING:
23588
- //
23589
- // - It does not say WHICH finding degraded. A capture carrying a degraded
23590
- // `redact` alongside a finding ASSIGNED the same action stores both
23591
- // identically and one reason for the pair; attributing it to both
23592
- // describes the assigned one wrongly, and to neither loses the degrade.
23593
- // - PRESENCE IS NOT CAUSATION. The value is the action the lost redact
23594
- // became, not the reason the capture ended as it did — a capture denied
23595
- // by some other finding's own Block policy still carries `block` here,
23596
- // and clearing the workspace's fallback would not have let it through.
23597
- // Gate on the value against what a fallback can produce; never read the
23598
- // field's presence as "this was the fallback's doing".
23599
- //
23600
- // Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
23601
- // Closing either means moving the reason onto the finding row, which
23602
- // already carries its own action.
23603
- redactDegradedTo: ActionTaken.optional()
23604
- }).meta({ id: "EventMetadata" });
23605
- var Event = external_exports.object({
23606
- id: external_exports.guid(),
23607
- sourceTool: SourceTool,
23608
- kind: EventKind,
23609
- occurredAt: external_exports.iso.datetime(),
23610
- contentHash: external_exports.string(),
23611
- content: external_exports.string(),
23612
- metadata: EventMetadata.optional()
23613
- }).meta({ id: "Event" });
23614
- var IngestEvent = Event.meta({ id: "IngestEvent" });
23615
- var INGEST_BATCH_MAX = 100;
23616
- var IngestBatch = external_exports.object({
23617
- events: external_exports.array(IngestEvent).min(1).max(INGEST_BATCH_MAX),
23618
- // Dedup policy for this batch. Id-dedup ALWAYS applies. 'content-hash'
23619
- // additionally rejects any event whose contentHash the store has already
23620
- // recorded — for re-runnable bulk ingest (worktree scan, transcript
23621
- // backfill), where a re-run mints fresh event ids for identical content and
23622
- // would otherwise accumulate duplicates. Live hook traffic must NOT set it:
23623
- // two genuinely separate prompts can be byte-identical and both belong on
23624
- // the timeline.
23625
- dedupe: external_exports.literal("content-hash").optional()
23626
- }).meta({ id: "IngestBatch" });
23627
-
23628
22922
  // ../../packages/schema/src/zod/exception.ts
23629
22923
  var ExceptionScope = external_exports.enum(["once", "temporary", "permanent"]);
23630
22924
  var ExceptionConditions = external_exports.object({
@@ -23785,8 +23079,6 @@ var Policy = external_exports.object({
23785
23079
  // test `prohibitedModels` passes and `reversibleRuleIds` fails.
23786
23080
  provenance: PolicyProvenance.optional()
23787
23081
  }).meta({ id: "Policy" });
23788
- var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
23789
- var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
23790
23082
  var RedactFallback = BuiltinPolicyId.extract(["monitor", "warn", "block"]).meta({
23791
23083
  id: "RedactFallback"
23792
23084
  });
@@ -23826,11 +23118,14 @@ var PolicyBundle = external_exports.object({
23826
23118
  ruleVersions: external_exports.record(external_exports.string(), external_exports.string()).optional(),
23827
23119
  // Model ids (the raw `model` string a harness reports, e.g.
23828
23120
  // `claude-opus-4-1`) the tenant has PROHIBITED. The plugin refuses to switch
23829
- // a session onto one (PreModelSwitch) and refuses a turn that would run on
23830
- // one (UserPromptSubmit). Optional so an older backend — and an older
23831
- // on-disk cache — still parses; consumers read `?? []`, which is the
23832
- // unenforced behaviour that predates this field and the safe direction to
23833
- // default.
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.
23834
23129
  //
23835
23130
  // Ids, not display names: the governance decision is keyed on the exact
23836
23131
  // string the harness reports (`model_status_override.versionId` in the
@@ -24143,7 +23438,7 @@ var VaultConsent = external_exports.object({
24143
23438
  });
24144
23439
 
24145
23440
  // ../../packages/schema/src/zod/local.ts
24146
- var WORKSPACE_SETTINGS_SPEC_VERSION = 8;
23441
+ var WORKSPACE_SETTINGS_SPEC_VERSION = 9;
24147
23442
  var MODEL_JUDGE_PAYLOAD_VERSION = 1;
24148
23443
  var RunMode = external_exports.enum(["standalone", "attached"]);
24149
23444
  var ControlPlaneConnection = external_exports.object({
@@ -24163,6 +23458,20 @@ var HistorySyncConsent = external_exports.object({
24163
23458
  payloadVersion: external_exports.number().int().positive(),
24164
23459
  endpoint: external_exports.string()
24165
23460
  });
23461
+ var ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH = 512;
23462
+ var AttachmentScopeEntry = external_exports.object({
23463
+ kind: external_exports.enum(["repo", "account"]),
23464
+ identity: printable(ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH).min(1),
23465
+ label: printable(80).optional(),
23466
+ enrolledAt: external_exports.iso.datetime()
23467
+ });
23468
+ var AttachmentScope = external_exports.object({
23469
+ endpoint: external_exports.string().min(1),
23470
+ tenantName: PluginWhoami.shape.tenantName.optional(),
23471
+ userEmail: PluginWhoami.shape.userEmail.optional(),
23472
+ entries: external_exports.array(AttachmentScopeEntry)
23473
+ });
23474
+ var AttachmentScopeEnvelope = AttachmentScope.extend({ entries: external_exports.array(external_exports.unknown()) });
24166
23475
  var WebChatCaptureConsent = external_exports.object({
24167
23476
  acknowledgedAt: external_exports.iso.datetime(),
24168
23477
  version: external_exports.number().int().positive()
@@ -24233,6 +23542,23 @@ var WorkspaceSettings = external_exports.object({
24233
23542
  // both widenings. Absent until granted, and a grant for a different endpoint
24234
23543
  // or an older payload no longer counts.
24235
23544
  historySyncConsent: HistorySyncConsent.optional(),
23545
+ // The identities a SCOPED attachment forwards and the deployment they were
23546
+ // enrolled for (see AttachmentScope). Absent until something is enrolled.
23547
+ //
23548
+ // `z.unknown()`, NOT `AttachmentScope`, and the difference is this field's
23549
+ // whole failure mode. A settings.json that fails this schema reads as the
23550
+ // unonboarded defaults (readUserSettings in @akasecurity/persistence), and the
23551
+ // next save writes those defaults back over it. Typed, one entry with an
23552
+ // unknown `kind`, a control character or a bad timestamp would cost the
23553
+ // attachment, every consent and onboardedAt, permanently. Untyped, the value
23554
+ // is kept exactly as found and validated where it is used: parseAttachmentScope
23555
+ // drops a bad entry by itself, and on a scoped attachment resolveScope reads a
23556
+ // bad envelope as no entries, which keeps every event local.
23557
+ //
23558
+ // No default: absent must stay absent, so defaultWorkspaceSettings() and a
23559
+ // fresh settings.json do not change. No `.meta({ id })`, like every field
23560
+ // here. Not a ManagedSettingKey.
23561
+ attachmentScope: external_exports.unknown().optional(),
24236
23562
  // What the browser extension may record from a web chat, and the grant that
24237
23563
  // authorizes it. Absent until the user answers: recording something that was
24238
23564
  // never recorded before is never an assumed grant on upgrade, so the whole
@@ -24355,6 +23681,27 @@ var ManagedSettings = external_exports.object({
24355
23681
  };
24356
23682
  }).meta({ id: "ManagedSettings" });
24357
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
+
24358
23705
  // ../../packages/schema/src/zod/project-files.ts
24359
23706
  var ProjectFileInput = external_exports.object({
24360
23707
  path: external_exports.string().min(1),
@@ -24669,7 +24016,16 @@ var AttachInput = external_exports.object({
24669
24016
  // 200 matches the tenantName bound beside it in control-plane.ts; nothing
24670
24017
  // renders a longer one usefully.
24671
24018
  label: printable(200).optional(),
24672
- 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()
24673
24029
  });
24674
24030
 
24675
24031
  // ../../packages/schema/src/zod/triage.ts
@@ -24882,6 +24238,14 @@ var CAPTURE_STATUS_RECENCY_MS = 30 * 24 * 60 * 60 * 1e3;
24882
24238
  var CAPTURE_STATUS_RECENCY_DAYS = CAPTURE_STATUS_RECENCY_MS / (24 * 60 * 60 * 1e3);
24883
24239
  var CAPTURE_STATUS_DOCUMENT_QUIET_MS = 12 * 60 * 60 * 1e3;
24884
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
+
24885
24249
  // ../../packages/persistence/src/paths.ts
24886
24250
  import {
24887
24251
  chmodSync,
@@ -24945,11 +24309,12 @@ function writeOwnerOnlyFileSync(file2, data) {
24945
24309
 
24946
24310
  // ../../packages/persistence/src/database.ts
24947
24311
  import { randomUUID as randomUUID11 } from "crypto";
24948
- import { dirname as dirname2, join as join7, sep } from "path";
24312
+ import { dirname as dirname2, join as join8, sep } from "path";
24949
24313
  import { DatabaseSync } from "node:sqlite";
24950
24314
 
24951
24315
  // ../../packages/persistence/src/ids.ts
24952
24316
  import { createHash } from "crypto";
24317
+ var DOT = ".".charCodeAt(0);
24953
24318
 
24954
24319
  // ../../packages/persistence/src/internal/snapshot.ts
24955
24320
  import { randomUUID } from "crypto";
@@ -24972,6 +24337,7 @@ var SYNC_FAILURE_REASONS = SyncFailureReason.options;
24972
24337
  // ../../packages/persistence/src/repositories/history-sync.ts
24973
24338
  var STRUCTURAL_EVENT_TYPES = ["session", "llm_call", "tool_call"];
24974
24339
  var TYPE_LIST = STRUCTURAL_EVENT_TYPES.map((t) => `'${t}'`).join(", ");
24340
+ var CAPTURE_TYPE_LIST = OUTBOX_CAPTURE_TYPE_LIST;
24975
24341
  var COUNTED_EVENT_TYPES = [
24976
24342
  ...STRUCTURAL_EVENT_TYPES,
24977
24343
  ...OUTBOX_CAPTURE_EVENT_TYPES
@@ -24984,6 +24350,37 @@ var COUNTED_SCOPE = `
24984
24350
  OR synced_at IS NOT NULL
24985
24351
  OR outbox_owed = 1
24986
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";
24987
24384
 
24988
24385
  // ../../packages/persistence/src/internal/json.ts
24989
24386
  function parseJsonObject(s) {
@@ -25013,6 +24410,25 @@ var DB_EVENT_TYPE_TO_KIND = {
25013
24410
  };
25014
24411
  var TIMELINE_EVENT_TYPES = Object.keys(DB_EVENT_TYPE_TO_KIND).map((kind) => `'${kind}'`).join(", ");
25015
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}`;
25016
24432
 
25017
24433
  // ../../packages/persistence/src/repositories/exceptions.ts
25018
24434
  import { randomUUID as randomUUID2 } from "crypto";
@@ -25062,34 +24478,35 @@ var FINDING_ROW_COLUMNS_SQL = `f.id AS id, d.rule_id AS rule_id, d.category AS c
25062
24478
  ${latestResolutionStatusSql("f")} AS latest_status,
25063
24479
  e.synced_at AS synced_at, e.sync_claimed_at AS sync_claimed_at,
25064
24480
  e.sync_failed_at AS sync_failed_at, e.sync_failure AS sync_failure,
25065
- e.outbox_owed AS outbox_owed`;
24481
+ e.outbox_owed AS outbox_owed,
24482
+ f.line AS line, f.col AS col`;
25066
24483
 
25067
24484
  // ../../packages/persistence/src/repositories/installed-packs.ts
25068
- import { createHash as createHash2, randomUUID as randomUUID4 } from "crypto";
24485
+ import { createHash as createHash3, randomUUID as randomUUID4 } from "crypto";
25069
24486
 
25070
24487
  // ../../packages/persistence/src/policy-floor.ts
25071
- import { readFileSync as readFileSync5 } from "fs";
25072
- import { join as join6 } from "path";
24488
+ import { readFileSync as readFileSync6 } from "fs";
24489
+ import { join as join7 } from "path";
25073
24490
 
25074
24491
  // ../../packages/persistence/src/local-layout.ts
25075
24492
  import { renameSync as renameSync3 } from "fs";
25076
24493
  import { mkdir } from "fs/promises";
25077
24494
  import { homedir } from "os";
25078
- import { join as join4 } from "path";
24495
+ import { join as join5 } from "path";
25079
24496
  function defaultDataDir() {
25080
- return join4(homedir(), ".aka");
24497
+ return join5(homedir(), ".aka");
25081
24498
  }
25082
24499
  function settingsDir(base = defaultDataDir()) {
25083
- return join4(base, "settings");
24500
+ return join5(base, "settings");
25084
24501
  }
25085
24502
  function dataDir(base = defaultDataDir()) {
25086
- return join4(base, "data");
24503
+ return join5(base, "data");
25087
24504
  }
25088
24505
  function dbPath(base = defaultDataDir()) {
25089
- return join4(dataDir(base), "aka.db");
24506
+ return join5(dataDir(base), "aka.db");
25090
24507
  }
25091
24508
  function keysDir(base = defaultDataDir()) {
25092
- return join4(base, "keys");
24509
+ return join5(base, "keys");
25093
24510
  }
25094
24511
  function ensureLayoutDirSync(dir = defaultDataDir()) {
25095
24512
  ensureDataDirSync(dir);
@@ -25102,8 +24519,8 @@ function migrateLegacyLayout(base = defaultDataDir()) {
25102
24519
  for (const { name, dest } of moves) {
25103
24520
  try {
25104
24521
  ensureDataDirSync(dest);
25105
- const moved = join4(dest, name);
25106
- renameSync3(join4(base, name), moved);
24522
+ const moved = join5(dest, name);
24523
+ renameSync3(join5(base, name), moved);
25107
24524
  tightenFile(moved);
25108
24525
  } catch {
25109
24526
  }
@@ -25111,8 +24528,8 @@ function migrateLegacyLayout(base = defaultDataDir()) {
25111
24528
  }
25112
24529
 
25113
24530
  // ../../packages/persistence/src/settings.ts
25114
- import { readFileSync as readFileSync4 } from "fs";
25115
- import { join as join5 } from "path";
24531
+ import { readFileSync as readFileSync5 } from "fs";
24532
+ import { join as join6 } from "path";
25116
24533
 
25117
24534
  // ../../packages/persistence/src/file-lock.ts
25118
24535
  import { randomUUID as randomUUID3 } from "crypto";
@@ -25120,7 +24537,7 @@ import {
25120
24537
  closeSync,
25121
24538
  existsSync as existsSync2,
25122
24539
  openSync,
25123
- readFileSync as readFileSync2,
24540
+ readFileSync as readFileSync3,
25124
24541
  rmSync as rmSync5,
25125
24542
  statSync as statSync3,
25126
24543
  writeFileSync as writeFileSync2
@@ -25129,16 +24546,16 @@ import { hostname as hostname3 } from "os";
25129
24546
  var PARK = new Int32Array(new SharedArrayBuffer(4));
25130
24547
 
25131
24548
  // ../../packages/persistence/src/managed-settings.ts
25132
- import { readFileSync as readFileSync3 } from "fs";
24549
+ import { readFileSync as readFileSync4 } from "fs";
25133
24550
  import { posix, win32 } from "path";
25134
- function managedSettingsPaths(platform2 = process.platform) {
25135
- if (platform2 === "darwin") {
24551
+ function managedSettingsPaths(platform = process.platform) {
24552
+ if (platform === "darwin") {
25136
24553
  return [
25137
24554
  posix.join("/Library", "Application Support", "AKASecurity", MANAGED_SETTINGS_FILENAME),
25138
24555
  posix.join("/Library", "Managed Preferences", MANAGED_SETTINGS_FILENAME)
25139
24556
  ];
25140
24557
  }
25141
- if (platform2 === "win32") {
24558
+ if (platform === "win32") {
25142
24559
  return [win32.join("C:\\", "ProgramData", "AKASecurity", MANAGED_SETTINGS_FILENAME)];
25143
24560
  }
25144
24561
  return [posix.join("/etc", "aka", MANAGED_SETTINGS_FILENAME)];
@@ -25148,7 +24565,7 @@ function readManagedSettings(paths = testOnlyManagedPaths ?? managedSettingsPath
25148
24565
  for (const path of paths) {
25149
24566
  let text;
25150
24567
  try {
25151
- text = readFileSync3(path, "utf8");
24568
+ text = readFileSync4(path, "utf8");
25152
24569
  } catch {
25153
24570
  continue;
25154
24571
  }
@@ -25202,7 +24619,7 @@ function readWorkspaceSettings(base = defaultDataDir()) {
25202
24619
  return overlayManagedSettings(readUserSettings(base), readManagedSettings());
25203
24620
  }
25204
24621
  function readUserSettings(base) {
25205
- const record2 = readJson(join5(settingsDir(base), SETTINGS_FILENAME));
24622
+ const record2 = readJson(join6(settingsDir(base), SETTINGS_FILENAME));
25206
24623
  if (!record2) return defaultWorkspaceSettings();
25207
24624
  try {
25208
24625
  return WorkspaceSettings.parse(record2);
@@ -25213,7 +24630,7 @@ function readUserSettings(base) {
25213
24630
  function readJson(file2) {
25214
24631
  let text;
25215
24632
  try {
25216
- text = readFileSync4(file2, "utf8");
24633
+ text = readFileSync5(file2, "utf8");
25217
24634
  } catch {
25218
24635
  return null;
25219
24636
  }
@@ -25287,38 +24704,39 @@ var CAPTURE_GRAIN = new Set(EventKind.options);
25287
24704
  var DEFERRED_TAGS = new Set(DEFERRED_MIGRATION_TAGS);
25288
24705
 
25289
24706
  // ../../packages/persistence/src/egress-wire.ts
25290
- import { createHash as createHash3 } from "crypto";
24707
+ import { createHash as createHash4 } from "crypto";
25291
24708
  var SLASH = "/".charCodeAt(0);
24709
+ var SCOPE_KEY = printable(ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH);
25292
24710
 
25293
24711
  // ../../packages/persistence/src/finding-key.ts
25294
- import { createHash as createHash4 } from "crypto";
24712
+ import { createHash as createHash5 } from "crypto";
25295
24713
 
25296
24714
  // ../../packages/persistence/src/fingerprint.ts
25297
24715
  import { createHmac, randomBytes } from "crypto";
25298
- import { existsSync as existsSync3, readFileSync as readFileSync6 } from "fs";
25299
- import { join as join8 } from "path";
25300
- import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
24716
+ import { existsSync as existsSync3, readFileSync as readFileSync7 } from "fs";
24717
+ import { join as join9 } from "path";
25301
24718
 
25302
24719
  // ../../packages/persistence/src/forward-health.ts
25303
- import { readFileSync as readFileSync7 } from "fs";
25304
- import { join as join9 } from "path";
24720
+ import { readFileSync as readFileSync8 } from "fs";
24721
+ import { join as join10 } from "path";
25305
24722
 
25306
24723
  // ../../packages/persistence/src/history-backfill.ts
25307
24724
  import { existsSync as existsSync4 } from "fs";
25308
- import { join as join10 } from "path";
24725
+ import { join as join11 } from "path";
25309
24726
 
25310
24727
  // ../../packages/persistence/src/history-preview.ts
25311
24728
  import { existsSync as existsSync5 } from "fs";
25312
- import { join as join11 } from "path";
25313
- import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
24729
+ import { join as join12 } from "path";
24730
+ import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
25314
24731
 
25315
24732
  // ../../packages/persistence/src/history-sync-state.ts
25316
- import { readFileSync as readFileSync8 } from "fs";
25317
- import { join as join12 } from "path";
24733
+ import { readFileSync as readFileSync9 } from "fs";
24734
+ import { join as join13 } from "path";
24735
+ var COUNTS_SCOPES = new Set(AttachmentMode.options);
25318
24736
 
25319
24737
  // ../../packages/persistence/src/store-symlinks.ts
25320
24738
  import { existsSync as existsSync6, lstatSync as lstatSync3, readlinkSync, realpathSync, statSync as statSync4 } from "fs";
25321
- import { dirname as dirname3, join as join13, resolve } from "path";
24739
+ import { dirname as dirname3, join as join14, resolve } from "path";
25322
24740
  var STORE_DB = "the store database (including the prompt corpus)";
25323
24741
  var STORE_SETTINGS = "your settings file";
25324
24742
  function storeContents(home) {
@@ -25327,11 +24745,11 @@ function storeContents(home) {
25327
24745
  [settingsDir(home), STORE_SETTINGS],
25328
24746
  [dataDir(home), STORE_DB],
25329
24747
  [keysDir(home), "the vault key"],
25330
- [join13(settingsDir(home), "settings.json"), STORE_SETTINGS],
24748
+ [join14(settingsDir(home), "settings.json"), STORE_SETTINGS],
25331
24749
  [dbPath(home), STORE_DB]
25332
24750
  ]);
25333
24751
  }
25334
- function symlinkedStorePaths(home, platform2 = process.platform) {
24752
+ function symlinkedStorePaths(home, platform = process.platform) {
25335
24753
  return [...storeContents(home)].flatMap(([path, holds]) => {
25336
24754
  try {
25337
24755
  if (!lstatSync3(path).isSymbolicLink()) return [];
@@ -25343,7 +24761,7 @@ function symlinkedStorePaths(home, platform2 = process.platform) {
25343
24761
  // existsSync follows the link, so a target that is gone reads as
25344
24762
  // absent here while lstat above still sees the link itself.
25345
24763
  missing: !existsSync6(path),
25346
- mode: targetMode(path, platform2)
24764
+ mode: targetMode(path, platform)
25347
24765
  }
25348
24766
  ];
25349
24767
  } catch {
@@ -25358,8 +24776,8 @@ function linkTarget(path) {
25358
24776
  return resolve(dirname3(path), readlinkSync(path));
25359
24777
  }
25360
24778
  }
25361
- function targetMode(path, platform2) {
25362
- if (platform2 === "win32") return void 0;
24779
+ function targetMode(path, platform) {
24780
+ if (platform === "win32") return void 0;
25363
24781
  try {
25364
24782
  return statSync4(path).mode & 511;
25365
24783
  } catch {
@@ -25379,15 +24797,15 @@ import {
25379
24797
  // ../../packages/persistence/src/vault/key-provider.ts
25380
24798
  import { execFileSync } from "child_process";
25381
24799
  import { randomBytes as randomBytes2 } from "crypto";
25382
- import { chmodSync as chmodSync3, readFileSync as readFileSync9, renameSync as renameSync4, rmSync as rmSync6, statSync as statSync5, writeFileSync as writeFileSync3 } from "fs";
25383
- import { join as join14 } from "path";
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";
25384
24802
 
25385
24803
  // ../../packages/persistence/src/vault/vault.ts
25386
24804
  import { randomBytes as randomBytes3, randomUUID as randomUUID12 } from "crypto";
25387
24805
 
25388
24806
  // ../../packages/persistence/src/warn-era-cap.ts
25389
24807
  import { existsSync as existsSync7, writeFileSync as writeFileSync4 } from "fs";
25390
- import { join as join15 } from "path";
24808
+ import { join as join16 } from "path";
25391
24809
 
25392
24810
  // ../../packages/plugin-sdk/src/provider-env.ts
25393
24811
  var DEFAULT_ANTHROPIC_HOST = "api.anthropic.com";
@@ -25441,7 +24859,7 @@ function resolveProvider() {
25441
24859
  function loadConfig(base = defaultDataDir(), resolveProviderFn = resolveProvider) {
25442
24860
  try {
25443
24861
  ensureLayoutDirSync(base);
25444
- const settingsFile = join16(settingsDir(base), "settings.json");
24862
+ const settingsFile = join17(settingsDir(base), "settings.json");
25445
24863
  if (existsSync8(settingsFile)) tightenFile(settingsFile);
25446
24864
  } catch {
25447
24865
  }
@@ -25464,11 +24882,6 @@ function resolveProviderSafe(resolveProviderFn) {
25464
24882
  }
25465
24883
  }
25466
24884
 
25467
- // ../../packages/plugin-sdk/src/config-inventory.ts
25468
- import { readdirSync as readdirSync2, readFileSync as readFileSync11, realpathSync as realpathSync2, statSync as statSync7 } from "fs";
25469
- import { homedir as homedir2 } from "os";
25470
- import { basename as basename3, join as join18 } from "path";
25471
-
25472
24885
  // ../../packages/detections/src/egress/registry.ts
25473
24886
  var EXTRACTOR_VERSION = "3";
25474
24887
  var PROVIDER_REGISTRY = [
@@ -26143,12 +25556,12 @@ var RegexMatcher2 = class {
26143
25556
  rule.matcher,
26144
25557
  () => new RegExp(pattern, flags.includes("d") ? flags : `${flags}d`)
26145
25558
  );
26146
- const scanText2 = text.length > MAX_REGEX_INPUT_LENGTH ? text.slice(0, MAX_REGEX_INPUT_LENGTH) : text;
25559
+ const scanText = text.length > MAX_REGEX_INPUT_LENGTH ? text.slice(0, MAX_REGEX_INPUT_LENGTH) : text;
26147
25560
  const spans = [];
26148
25561
  let m;
26149
- const maxIterations = scanText2.length + 1;
25562
+ const maxIterations = scanText.length + 1;
26150
25563
  let iterations = 0;
26151
- while ((m = re.exec(scanText2)) !== null) {
25564
+ while ((m = re.exec(scanText)) !== null) {
26152
25565
  if (++iterations > maxIterations) break;
26153
25566
  const group = captureGroup != null ? m[captureGroup] : m[0];
26154
25567
  if (m[0].length === 0) re.lastIndex++;
@@ -26302,24 +25715,12 @@ var POLYNOMIAL_PROBES = ["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].m
26302
25715
  var CPU_CORROBORATION_SHARE = 0.2;
26303
25716
  var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
26304
25717
 
26305
- // ../../packages/plugin-sdk/src/repo.ts
26306
- import { existsSync as existsSync9, readFileSync as readFileSync10, statSync as statSync6 } from "fs";
26307
- import { basename as basename2, dirname as dirname4, isAbsolute, join as join17, sep as sep2 } from "path";
26308
-
26309
- // ../../packages/plugin-sdk/src/events.ts
26310
- import { createHash as createHash5, randomUUID as randomUUID13 } from "crypto";
26311
-
26312
- // ../../packages/plugin-sdk/src/isolated-scan.ts
26313
- import { existsSync as existsSync10 } from "fs";
26314
- import { fileURLToPath } from "url";
26315
- import { Worker } from "worker_threads";
26316
-
26317
25718
  // ../../packages/plugin-sdk/src/hook-fail-opens.ts
26318
- import { readFileSync as readFileSync12 } from "fs";
26319
- import { join as join19 } from "path";
25719
+ import { readFileSync as readFileSync11 } from "fs";
25720
+ import { join as join18 } from "path";
26320
25721
  var HOOK_FAIL_OPENS_FILENAME = "hook-fail-opens.json";
26321
25722
  function hookFailOpensPath(dataDir2) {
26322
- return join19(dataDir2, HOOK_FAIL_OPENS_FILENAME);
25723
+ return join18(dataDir2, HOOK_FAIL_OPENS_FILENAME);
26323
25724
  }
26324
25725
  function recordHookFailOpen(dataDir2, nowMs) {
26325
25726
  try {
@@ -26338,7 +25739,7 @@ function recordHookFailOpen(dataDir2, nowMs) {
26338
25739
  }
26339
25740
  function readHookFailOpens(dataDir2) {
26340
25741
  try {
26341
- const parsed = JSON.parse(readFileSync12(hookFailOpensPath(dataDir2), "utf8"));
25742
+ const parsed = JSON.parse(readFileSync11(hookFailOpensPath(dataDir2), "utf8"));
26342
25743
  if (typeof parsed !== "object" || parsed === null) return null;
26343
25744
  const record2 = parsed;
26344
25745
  if (!isPositiveSafeInteger(record2.failOpens)) return null;
@@ -26352,28 +25753,24 @@ function isPositiveSafeInteger(value) {
26352
25753
  return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
26353
25754
  }
26354
25755
 
26355
- // ../../packages/plugin-sdk/src/host-floor.ts
26356
- import { readFileSync as readFileSync14 } from "fs";
26357
- import { join as join21 } from "path";
26358
-
26359
25756
  // ../../packages/plugin-sdk/src/model-governance.ts
26360
25757
  import {
26361
25758
  closeSync as closeSync2,
26362
25759
  fstatSync,
26363
25760
  mkdirSync as mkdirSync2,
26364
25761
  openSync as openSync2,
26365
- readFileSync as readFileSync13,
25762
+ readFileSync as readFileSync12,
26366
25763
  readSync,
26367
25764
  writeFileSync as writeFileSync5
26368
25765
  } from "fs";
26369
- import { join as join20 } from "path";
25766
+ import { join as join19 } from "path";
26370
25767
  var SESSION_MODEL_MARKER = "session-model";
26371
25768
  function recordSessionModel(dataDir2, sessionId, model) {
26372
25769
  if (sessionId === void 0 || sessionId === "") return;
26373
25770
  if (model === void 0 || model === "") return;
26374
25771
  try {
26375
25772
  mkdirSync2(dataDir2, { recursive: true, mode: DATA_DIR_MODE });
26376
- writeFileSync5(join20(dataDir2, SESSION_MODEL_MARKER), JSON.stringify({ sessionId, model }), {
25773
+ writeFileSync5(join19(dataDir2, SESSION_MODEL_MARKER), JSON.stringify({ sessionId, model }), {
26377
25774
  encoding: "utf8",
26378
25775
  mode: DATA_FILE_MODE
26379
25776
  });
@@ -26385,7 +25782,7 @@ function readTail(path) {
26385
25782
  const fd = openSync2(path, "r");
26386
25783
  try {
26387
25784
  const { size } = fstatSync(fd);
26388
- if (size <= TAIL_BYTES) return { text: readFileSync13(fd, "utf8"), truncated: false };
25785
+ if (size <= TAIL_BYTES) return { text: readFileSync12(fd, "utf8"), truncated: false };
26389
25786
  const buffer = Buffer.allocUnsafe(TAIL_BYTES);
26390
25787
  let filled = 0;
26391
25788
  while (filled < TAIL_BYTES) {
@@ -26430,98 +25827,18 @@ var codexModelFromRecord = (record2) => {
26430
25827
  return typeof model === "string" && model !== "" ? model : void 0;
26431
25828
  };
26432
25829
 
26433
- // ../../packages/plugin-sdk/src/host-floor.ts
26434
- var HOST_FEATURE = {
26435
- ModelSwitch: "model-switch",
26436
- VaultPointerDisplay: "vault-pointer-display"
26437
- };
26438
- var HOST_FLOORS = {
26439
- [HOST_FEATURE.ModelSwitch]: {
26440
- label: "model-switch protection",
26441
- hookEvents: ["PreModelSwitch", "PostModelSwitch"],
26442
- since: "2.1.251"
26443
- },
26444
- [HOST_FEATURE.VaultPointerDisplay]: {
26445
- label: "vault pointer display",
26446
- hookEvents: ["MessageDisplay"],
26447
- since: "2.1.152"
26448
- }
26449
- };
26450
- var ANTIGRAVITY_HOST_FEATURE = {
26451
- EndOfTurnCapture: "end-of-turn-capture"
26452
- };
26453
- var ANTIGRAVITY_HOST_FLOORS = {
26454
- [ANTIGRAVITY_HOST_FEATURE.EndOfTurnCapture]: {
26455
- label: "end-of-turn history capture",
26456
- hookEvents: ["Stop"],
26457
- since: "1.1.10"
26458
- }
26459
- };
26460
-
26461
- // ../../packages/plugin-sdk/src/ignore-layers.ts
26462
- var import_ignore = __toESM(require_ignore(), 1);
26463
- import { readFileSync as readFileSync15 } from "fs";
26464
- import { join as join22 } from "path";
26465
-
26466
- // ../../packages/plugin-sdk/src/inventory-resolver.ts
26467
- import { arch, hostname as hostname4, platform, release } from "os";
26468
-
26469
- // ../../packages/plugin-sdk/src/nudge.ts
26470
- import { mkdirSync as mkdirSync3, readFileSync as readFileSync16, writeFileSync as writeFileSync6 } from "fs";
26471
- import { join as join23 } from "path";
26472
-
26473
- // ../../packages/plugin-sdk/src/paths.ts
26474
- import { readdirSync as readdirSync3, realpathSync as realpathSync3 } from "fs";
26475
- import { basename as basename4, dirname as dirname5, sep as sep3 } from "path";
26476
-
26477
- // ../../packages/plugin-sdk/src/project-files.ts
26478
- import { existsSync as existsSync11, readdirSync as readdirSync4 } from "fs";
26479
- import { basename as basename5, join as join24 } from "path";
26480
-
26481
- // ../../packages/plugin-sdk/src/provider-env-antigravity.ts
26482
- var optionalBaseUrl2 = external_exports.preprocess((v) => {
26483
- if (typeof v === "string" && v.trim() === "") return void 0;
26484
- return v;
26485
- }, external_exports.string().optional()).catch(void 0);
26486
- var optionalFlag = external_exports.preprocess((v) => {
26487
- if (typeof v !== "string") return false;
26488
- const normalized = v.trim().toLowerCase();
26489
- return normalized !== "" && normalized !== "0" && normalized !== "false";
26490
- }, external_exports.boolean()).catch(false);
26491
- var antigravityProviderEnvShape = {
26492
- GOOGLE_GENAI_USE_VERTEXAI: optionalFlag,
26493
- GOOGLE_GEMINI_BASE_URL: optionalBaseUrl2
26494
- };
26495
- var AntigravityProviderEnvSchema = external_exports.object(antigravityProviderEnvShape);
26496
-
26497
- // ../../packages/plugin-sdk/src/provider-env-codex.ts
26498
- var optionalBaseUrl3 = external_exports.preprocess((v) => {
26499
- if (typeof v === "string" && v.trim() === "") return void 0;
26500
- return v;
26501
- }, external_exports.string().optional()).catch(void 0);
26502
- var codexProviderEnvShape = {
26503
- OPENAI_BASE_URL: optionalBaseUrl3
26504
- };
26505
- var CodexProviderEnvSchema = external_exports.object(codexProviderEnvShape);
26506
-
26507
- // ../../packages/plugin-sdk/src/runtime.ts
26508
- import { randomUUID as randomUUID14 } from "crypto";
26509
-
26510
- // ../../packages/plugin-sdk/src/suppressions.ts
26511
- var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
26512
-
26513
25830
  // ../../packages/plugin-sdk/src/throttle.ts
26514
- import { mkdirSync as mkdirSync4, statSync as statSync8, writeFileSync as writeFileSync7 } from "fs";
26515
- import { join as join25 } from "path";
25831
+ import { mkdirSync as mkdirSync3, statSync as statSync6, writeFileSync as writeFileSync6 } from "fs";
25832
+ import { join as join20 } from "path";
26516
25833
  function throttled(dataDir2, markerName, windowMs) {
26517
- const marker = join25(dataDir2, markerName);
25834
+ const marker = join20(dataDir2, markerName);
26518
25835
  try {
26519
- if (Date.now() - statSync8(marker).mtimeMs < windowMs) return true;
25836
+ if (Date.now() - statSync6(marker).mtimeMs < windowMs) return true;
26520
25837
  } catch {
26521
25838
  }
26522
25839
  try {
26523
- mkdirSync4(dataDir2, { recursive: true, mode: DATA_DIR_MODE });
26524
- writeFileSync7(marker, String(Date.now()), { mode: DATA_FILE_MODE });
25840
+ mkdirSync3(dataDir2, { recursive: true, mode: DATA_DIR_MODE });
25841
+ writeFileSync6(marker, String(Date.now()), { mode: DATA_FILE_MODE });
26525
25842
  } catch {
26526
25843
  }
26527
25844
  return false;
@@ -26529,21 +25846,21 @@ function throttled(dataDir2, markerName, windowMs) {
26529
25846
 
26530
25847
  // src/history/reconcile-trigger.ts
26531
25848
  import { spawn } from "child_process";
26532
- import { dirname as dirname6, join as join27 } from "path";
26533
- import { fileURLToPath as fileURLToPath2 } from "url";
25849
+ import { dirname as dirname4, join as join22 } from "path";
25850
+ import { fileURLToPath } from "url";
26534
25851
 
26535
25852
  // src/history/tail.ts
26536
25853
  import { createHash as createHash6 } from "crypto";
26537
25854
  import {
26538
25855
  closeSync as closeSync3,
26539
25856
  fstatSync as fstatSync2,
26540
- mkdirSync as mkdirSync5,
25857
+ mkdirSync as mkdirSync4,
26541
25858
  openSync as openSync3,
26542
- readFileSync as readFileSync17,
25859
+ readFileSync as readFileSync13,
26543
25860
  readSync as readSync2,
26544
- writeFileSync as writeFileSync8
25861
+ writeFileSync as writeFileSync7
26545
25862
  } from "fs";
26546
- import { join as join26 } from "path";
25863
+ import { join as join21 } from "path";
26547
25864
  var SAFE_SESSION_ID = /^[A-Za-z0-9._-]+$/;
26548
25865
  function safeSessionId(sessionId) {
26549
25866
  if (SAFE_SESSION_ID.test(sessionId) && sessionId !== "." && sessionId !== "..") {
@@ -26559,8 +25876,8 @@ function triggerReconcile(dataDir2, sessionId, transcriptPath) {
26559
25876
  try {
26560
25877
  const marker = `${RECONCILE_MARKER_PREFIX}-${safeSessionId(sessionId)}`;
26561
25878
  if (throttled(dataDir2, marker, RECONCILE_THROTTLE_MS)) return;
26562
- const here = dirname6(fileURLToPath2(import.meta.url));
26563
- const child = spawn(process.execPath, [join27(here, "reconcile.js"), sessionId, transcriptPath], {
25879
+ const here = dirname4(fileURLToPath(import.meta.url));
25880
+ const child = spawn(process.execPath, [join22(here, "reconcile.js"), sessionId, transcriptPath], {
26564
25881
  detached: true,
26565
25882
  stdio: "ignore"
26566
25883
  });
@@ -26570,6 +25887,7 @@ function triggerReconcile(dataDir2, sessionId, transcriptPath) {
26570
25887
  }
26571
25888
 
26572
25889
  // src/hooks/shared.ts
25890
+ import { isAbsolute, normalize, resolve as resolvePath } from "path";
26573
25891
  async function readStdin() {
26574
25892
  return new Promise((resolve3) => {
26575
25893
  let data = "";
@@ -26621,8 +25939,8 @@ function parseStopPayload(input2) {
26621
25939
  }
26622
25940
 
26623
25941
  // src/hooks/store-health.ts
26624
- import { mkdirSync as mkdirSync6, readFileSync as readFileSync22, writeFileSync as writeFileSync9 } from "fs";
26625
- import { dirname as dirname8, join as join35 } from "path";
25942
+ import { mkdirSync as mkdirSync5, readFileSync as readFileSync18, writeFileSync as writeFileSync8 } from "fs";
25943
+ import { dirname as dirname6, join as join30 } from "path";
26626
25944
 
26627
25945
  // ../../packages/remote/src/http.ts
26628
25946
  import { request as httpRequest } from "http";
@@ -26636,17 +25954,17 @@ var SLASH2 = "/".charCodeAt(0);
26636
25954
  var REQUEST_TIMEOUT_MS = 2e3;
26637
25955
 
26638
25956
  // ../../packages/plugin-runtime/src/attached/forward-drops.ts
26639
- import { readFileSync as readFileSync18 } from "fs";
26640
- import { join as join28 } from "path";
25957
+ import { readFileSync as readFileSync14 } from "fs";
25958
+ import { join as join23 } from "path";
26641
25959
 
26642
25960
  // ../../packages/plugin-runtime/src/attached/forward-policy.ts
26643
- import { randomUUID as randomUUID15 } from "crypto";
25961
+ import { randomUUID as randomUUID13 } from "crypto";
26644
25962
  import { readFile, rename, writeFile } from "fs/promises";
26645
- import { join as join29 } from "path";
25963
+ import { join as join24 } from "path";
26646
25964
 
26647
25965
  // ../../packages/plugin-runtime/src/attached/history-sync.ts
26648
25966
  import { createHash as createHash7 } from "crypto";
26649
- import { hostname as hostname5 } from "os";
25967
+ import { hostname as hostname4 } from "os";
26650
25968
 
26651
25969
  // ../../packages/plugin-runtime/src/attached/capture-rebuild.ts
26652
25970
  var CORRELATION_ID = EventMetadata.shape.correlationId;
@@ -26659,21 +25977,21 @@ var CAPTURE_BATCH_BYTES = 1024 * 1024;
26659
25977
 
26660
25978
  // ../../packages/plugin-runtime/src/attached/history-sync-trigger.ts
26661
25979
  import { spawn as spawn2 } from "child_process";
26662
- import { fileURLToPath as fileURLToPath3 } from "url";
25980
+ import { fileURLToPath as fileURLToPath2 } from "url";
26663
25981
  var HISTORY_SYNC_THROTTLE_MS = 5 * 60 * 1e3;
26664
25982
 
26665
25983
  // ../../packages/plugin-runtime/src/attached/install-record.ts
26666
25984
  import { readFile as readFile2, stat } from "fs/promises";
26667
- import { basename as basename6, dirname as dirname7, join as join30, resolve as resolve2 } from "path";
25985
+ import { basename as basename2, dirname as dirname5, join as join25, resolve as resolve2 } from "path";
26668
25986
 
26669
25987
  // ../../packages/plugin-runtime/src/attached/plugin-block.ts
26670
- import { readFileSync as readFileSync19 } from "fs";
25988
+ import { readFileSync as readFileSync15 } from "fs";
26671
25989
  var INSTALL_RECORD_READ_TIMEOUT_MS = REQUEST_TIMEOUT_MS / 2;
26672
25990
 
26673
25991
  // ../../packages/plugin-runtime/src/attached/policy-store.ts
26674
- import { randomUUID as randomUUID16 } from "crypto";
25992
+ import { randomUUID as randomUUID14 } from "crypto";
26675
25993
  import { readFile as readFile3, rm, writeFile as writeFile2 } from "fs/promises";
26676
- import { join as join31 } from "path";
25994
+ import { join as join26 } from "path";
26677
25995
 
26678
25996
  // ../../packages/plugin-runtime/src/attached/atomic-publish.ts
26679
25997
  import { rename as rename2 } from "fs/promises";
@@ -26682,8 +26000,8 @@ var TIMED_RETRIES = 4;
26682
26000
  var ATTEMPTS = 1 + IMMEDIATE_RETRIES + TIMED_RETRIES;
26683
26001
 
26684
26002
  // ../../packages/plugin-runtime/src/attached/posture-report-state.ts
26685
- import { readFileSync as readFileSync20 } from "fs";
26686
- import { join as join32 } from "path";
26003
+ import { readFileSync as readFileSync16 } from "fs";
26004
+ import { join as join27 } from "path";
26687
26005
  var OUTCOME_KEYS = {
26688
26006
  ok: true,
26689
26007
  unauthorized: true,
@@ -26700,17 +26018,17 @@ var OUTCOMES = new Set(Object.keys(OUTCOME_KEYS));
26700
26018
  var POSTURE_REPORT_INTERVAL_MS = 60 * 60 * 1e3;
26701
26019
 
26702
26020
  // ../../packages/plugin-runtime/src/attached/posture-snapshot.ts
26703
- import { statSync as statSync9 } from "fs";
26704
- import { DatabaseSync as DatabaseSync4 } from "node:sqlite";
26021
+ import { statSync as statSync7 } from "fs";
26022
+ import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
26705
26023
 
26706
26024
  // ../../packages/plugin-runtime/src/attached/posture-store.ts
26707
- import { randomUUID as randomUUID17 } from "crypto";
26025
+ import { randomUUID as randomUUID15 } from "crypto";
26708
26026
  import { readFile as readFile4, rm as rm2, writeFile as writeFile3 } from "fs/promises";
26709
- import { join as join33 } from "path";
26027
+ import { join as join28 } from "path";
26710
26028
 
26711
26029
  // ../../packages/plugin-runtime/src/attached/sync-state.ts
26712
- import { readFileSync as readFileSync21 } from "fs";
26713
- import { join as join34 } from "path";
26030
+ import { readFileSync as readFileSync17 } from "fs";
26031
+ import { join as join29 } from "path";
26714
26032
 
26715
26033
  // ../../packages/plugin-runtime/src/attached/status.ts
26716
26034
  var REFUSAL_LINES = {
@@ -26728,7 +26046,7 @@ var OUTCOME_LINES = {
26728
26046
 
26729
26047
  // ../../packages/plugin-runtime/src/attached/sync-trigger.ts
26730
26048
  import { spawn as spawn3 } from "child_process";
26731
- import { fileURLToPath as fileURLToPath4 } from "url";
26049
+ import { fileURLToPath as fileURLToPath3 } from "url";
26732
26050
  var SYNC_THROTTLE_MS = 15 * 60 * 1e3;
26733
26051
 
26734
26052
  // ../../packages/plugin-runtime/src/content-retention-pass.ts
@@ -26736,28 +26054,25 @@ var MAX_ROWS_PER_SWEEP = 50 * 1e3;
26736
26054
 
26737
26055
  // ../../packages/plugin-runtime/src/content-retention-trigger.ts
26738
26056
  import { spawn as spawn4 } from "child_process";
26739
- import { fileURLToPath as fileURLToPath5 } from "url";
26057
+ import { fileURLToPath as fileURLToPath4 } from "url";
26740
26058
  var CONTENT_RETENTION_THROTTLE_MS = 60 * 60 * 1e3;
26741
26059
 
26742
26060
  // ../../packages/plugin-runtime/src/attached/factory.ts
26743
- import { hostname as hostname6 } from "os";
26744
-
26745
- // ../../packages/plugin-runtime/src/standalone-gateway.ts
26746
- import { randomUUID as randomUUID18 } from "crypto";
26061
+ import { hostname as hostname5 } from "os";
26747
26062
 
26748
26063
  // ../../packages/plugin-runtime/src/handle-session-start.ts
26749
- import { randomUUID as randomUUID19 } from "crypto";
26064
+ import { randomUUID as randomUUID16 } from "crypto";
26750
26065
  var EXCEPTION_RETENTION_MS = 90 * 24 * 60 * 60 * 1e3;
26751
26066
 
26752
26067
  // src/hooks/store-health.ts
26753
26068
  var STORE_REDIRECT_MARKER = "store-redirect-last-session";
26754
26069
  function markerDirs(dataDir2) {
26755
- return [dataDir2, dirname8(dataDir2)];
26070
+ return [dataDir2, dirname6(dataDir2)];
26756
26071
  }
26757
26072
  function alreadyClaimed(dirs, marker, sessionId) {
26758
26073
  return dirs.some((dir) => {
26759
26074
  try {
26760
- return readFileSync22(join35(dir, marker), "utf8") === sessionId;
26075
+ return readFileSync18(join30(dir, marker), "utf8") === sessionId;
26761
26076
  } catch {
26762
26077
  return false;
26763
26078
  }
@@ -26766,14 +26081,14 @@ function alreadyClaimed(dirs, marker, sessionId) {
26766
26081
  function recordClaim(dirs, marker, sessionId) {
26767
26082
  for (const dir of dirs) {
26768
26083
  try {
26769
- mkdirSync6(dir, { recursive: true, mode: DATA_DIR_MODE });
26770
- writeFileSync9(join35(dir, marker), sessionId, { mode: DATA_FILE_MODE });
26084
+ mkdirSync5(dir, { recursive: true, mode: DATA_DIR_MODE });
26085
+ writeFileSync8(join30(dir, marker), sessionId, { mode: DATA_FILE_MODE });
26771
26086
  return;
26772
26087
  } catch {
26773
26088
  }
26774
26089
  }
26775
26090
  }
26776
- function storeRedirectedMessage(paths, platform2 = process.platform) {
26091
+ function storeRedirectedMessage(paths, platform = process.platform) {
26777
26092
  const where = paths.map(({ path, target, holds, missing, mode }) => {
26778
26093
  if (missing) return `${path} -> ${target} (which does not exist; ${holds} cannot land there)`;
26779
26094
  const loose = mode !== void 0 && (mode & 63) !== 0 ? ", NOT owner-only" : "";
@@ -26783,7 +26098,7 @@ function storeRedirectedMessage(paths, platform2 = process.platform) {
26783
26098
  const subject = paths.length === 1 ? "a store path is a symlink" : `${String(paths.length)} store paths are symlinks`;
26784
26099
  const anyResolves = paths.some(({ missing }) => !missing);
26785
26100
  const lead = anyResolves ? `${subject}, so AKA is writing into the target instead: ${where}. ` : `${subject} resolving nowhere, so AKA cannot write there: ${where}. `;
26786
- const kept = anyResolves && platform2 !== "win32" ? "Permissions are never changed through a symlink, so the store keeps whatever the target already had. " : "";
26101
+ const kept = anyResolves && platform !== "win32" ? "Permissions are never changed through a symlink, so the store keeps whatever the target already had. " : "";
26787
26102
  return `[aka] ${lead}${kept}If you did not create that link, treat it as untrusted and run \`aka init\` for the full report.
26788
26103
  `;
26789
26104
  }
@@ -26792,7 +26107,7 @@ function formatMode(mode) {
26792
26107
  }
26793
26108
  function warnIfStoreRedirected(config2, sessionId, write = (message) => void process.stderr.write(message)) {
26794
26109
  try {
26795
- const paths = symlinkedStorePaths(dirname8(config2.dataDir));
26110
+ const paths = symlinkedStorePaths(dirname6(config2.dataDir));
26796
26111
  if (paths.length === 0) return;
26797
26112
  if (!sessionId) {
26798
26113
  write(storeRedirectedMessage(paths));