@akasecurity/ai-tc-codex 0.9.14 → 0.9.16

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
@@ -32,9 +32,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
32
32
  mod
33
33
  ));
34
34
 
35
- // ../../node_modules/.pnpm/ignore@7.0.9/node_modules/ignore/index.js
35
+ // ../../node_modules/.pnpm/ignore@7.0.11/node_modules/ignore/index.js
36
36
  var require_ignore = __commonJS({
37
- "../../node_modules/.pnpm/ignore@7.0.9/node_modules/ignore/index.js"(exports, module) {
37
+ "../../node_modules/.pnpm/ignore@7.0.11/node_modules/ignore/index.js"(exports, module) {
38
38
  "use strict";
39
39
  function makeArray(subject) {
40
40
  return Array.isArray(subject) ? subject : [subject];
@@ -169,6 +169,7 @@ var require_ignore = __commonJS({
169
169
  "g"
170
170
  );
171
171
  var TRAILING_WILDCARD = "\uE000";
172
+ var TRAILING_DOUBLESTAR = "\uE001";
172
173
  var extractBrackets = (pattern) => {
173
174
  const sources = [];
174
175
  const hold = (source) => `${PLACEHOLDER}${sources.push(source) - 1}${PLACEHOLDER}`;
@@ -329,7 +330,7 @@ var require_ignore = __commonJS({
329
330
  // Zero, one or several directories
330
331
  // should not use '*', or it will be replaced by the next replacer
331
332
  // Check if it is not the last `'/**'`
332
- (_, index, str) => index + 6 < str.length ? str.slice(index + 6) === "\\/" ? "(?:\\/[^\\/]+)+" : "(?:\\/[^\\/]+)*" : "\\/.+",
333
+ (_, index, str) => index + 6 < str.length ? str.slice(index + 6) === "\\/" ? "(?:\\/[^\\/]+)+" : "(?:\\/[^\\/]+)*" : `\\/${TRAILING_DOUBLESTAR}`,
333
334
  "*"
334
335
  ],
335
336
  // normal intermediate wildcards
@@ -407,7 +408,7 @@ var require_ignore = __commonJS({
407
408
  // 'js' will match 'a.js' and 'a.js/'
408
409
  (source) => {
409
410
  const last = source[source.length - 1];
410
- if (!last || last === TRAILING_WILDCARD) {
411
+ if (!last || last === TRAILING_WILDCARD || last === TRAILING_DOUBLESTAR) {
411
412
  return source;
412
413
  }
413
414
  return last === SLASH3 ? `${source}$` : `${source}(?=$|\\/$)`;
@@ -418,17 +419,20 @@ var require_ignore = __commonJS({
418
419
  var MODE_IGNORE = "regex";
419
420
  var MODE_CHECK_IGNORE = "checkRegex";
420
421
  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
- }
422
+ var replaceTrailingWildcard = (_, p1) => {
423
+ const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
424
+ return `${prefix}(?=$|\\/$)`;
430
425
  };
426
+ var REGEX_REPLACE_TRAILING_DOUBLESTAR = /\uE001$/;
427
+ var replaceTrailingDoublestar = () => ".+(?=$|\\/$)";
431
428
  var WILDCARD = "[^\\/]*";
429
+ var separatorAfter = (run, at) => {
430
+ let separator = EMPTY;
431
+ for (let index = at + 1; index < run.length && !run[index].wildcard; index++) {
432
+ separator += run[index].single;
433
+ }
434
+ return separator;
435
+ };
432
436
  var pinWildcards = (source) => {
433
437
  if (source.indexOf(WILDCARD) < 0) {
434
438
  return source;
@@ -498,7 +502,7 @@ var require_ignore = __commonJS({
498
502
  out += token.single;
499
503
  return;
500
504
  }
501
- out += at === lastWildcard ? WILDCARD : `(?:(?!${run[at + 1].single})[^\\/])*`;
505
+ out += at === lastWildcard ? WILDCARD : `(?:(?!${separatorAfter(run, at)})[^\\/])*`;
502
506
  });
503
507
  run = [];
504
508
  };
@@ -536,6 +540,14 @@ var require_ignore = __commonJS({
536
540
  (match, index) => sources[index]
537
541
  ) : replaced;
538
542
  };
543
+ var checkSourceOf = (body, prefix) => {
544
+ if (body[body.length - 1] === SLASH3) {
545
+ prefix = makeRegexPrefix(body.slice(0, -1));
546
+ }
547
+ const head = prefix.slice(0, -1);
548
+ const last = prefix[prefix.length - 1];
549
+ return last === TRAILING_WILDCARD ? `${head}$` : last === TRAILING_DOUBLESTAR ? `${head}.*$` : NEVER_MATCH;
550
+ };
539
551
  var matchesBasename = (body) => {
540
552
  const index = body.indexOf(SLASH3);
541
553
  return index < 0 || index === body.length - 1;
@@ -596,11 +608,9 @@ var require_ignore = __commonJS({
596
608
  return this._make(MODE_CHECK_IGNORE, key);
597
609
  }
598
610
  _make(mode, key) {
599
- const str = pinWildcards(this.regexPrefix.replace(
600
- REGEX_REPLACE_TRAILING_WILDCARD,
601
- // It does not need to bind pattern
602
- TRAILING_WILD_CARD_REPLACERS[mode]
603
- ));
611
+ const str = pinWildcards(
612
+ mode === MODE_IGNORE ? this.regexPrefix.replace(REGEX_REPLACE_TRAILING_WILDCARD, replaceTrailingWildcard).replace(REGEX_REPLACE_TRAILING_DOUBLESTAR, replaceTrailingDoublestar) : checkSourceOf(this.body, this.regexPrefix)
613
+ );
604
614
  const regex = this.ignoreCase ? new RegExp(str, "i") : new RegExp(str);
605
615
  return define(this, key, regex);
606
616
  }
@@ -659,8 +669,39 @@ var require_ignore = __commonJS({
659
669
  makeArray(
660
670
  isString(pattern) ? splitPattern(pattern) : pattern
661
671
  ).forEach(this._add, this);
672
+ if (this._added) {
673
+ this._literalRules = UNDEFINED;
674
+ }
662
675
  return this._added;
663
676
  }
677
+ // Match the literal 'abc/' for `checkIgnore`, last rule wins. Only a rule
678
+ // ending in a wildcard can match it (see `checkSourceOf`), so the rest
679
+ // are left out once, rather than tested or compiled for every path.
680
+ testLiteral(path) {
681
+ const rules = this._literalRules || (this._literalRules = this._rules.filter(
682
+ ({ body }) => body[body.length - (body[body.length - 1] === SLASH3 ? 2 : 1)] === "*"
683
+ ));
684
+ let ignored = false;
685
+ let unignored = false;
686
+ let matchedRule;
687
+ for (let index = rules.length - 1; index >= 0; index--) {
688
+ const rule = rules[index];
689
+ if (rule.checkRegex.test(path)) {
690
+ ignored = !rule.negative;
691
+ unignored = rule.negative;
692
+ matchedRule = rule.negative ? UNDEFINED : rule;
693
+ break;
694
+ }
695
+ }
696
+ const ret = {
697
+ ignored,
698
+ unignored
699
+ };
700
+ if (matchedRule) {
701
+ ret.rule = matchedRule;
702
+ }
703
+ return ret;
704
+ }
664
705
  // Test one single path without recursively checking parent directories
665
706
  //
666
707
  // - checkUnignored `boolean` whether should check if the path is unignored,
@@ -675,13 +716,13 @@ var require_ignore = __commonJS({
675
716
  const rules = this._rules;
676
717
  const { length } = rules;
677
718
  const shortcut = this._basenameCount * 2 >= length;
678
- const basename6 = shortcut ? basenameOf(path) : path;
719
+ const basename7 = shortcut ? basenameOf(path) : path;
679
720
  for (let index = 0; index < length; index++) {
680
721
  const rule = rules[index];
681
722
  const { negative } = rule;
682
723
  const skip = unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored;
683
724
  if (!skip && rule[mode].test(
684
- shortcut && rule._basenameOnly ? basename6 : path
725
+ shortcut && rule._basenameOnly ? basename7 : path
685
726
  )) {
686
727
  ignored = !negative;
687
728
  unignored = negative;
@@ -781,14 +822,12 @@ var require_ignore = __commonJS({
781
822
  if (path.charCodeAt(path.length - 1) !== SLASH_CODE) {
782
823
  return this.test(path);
783
824
  }
784
- const parentPath = parentOf(path);
785
- if (parentPath) {
786
- const parent = this._t(parentPath, this._testCache, true);
787
- if (parent.ignored) {
788
- return parent;
789
- }
825
+ const dir = this._t(path, this._testCache, true);
826
+ if (dir.ignored) {
827
+ return dir;
790
828
  }
791
- return this._rules.test(path, false, MODE_CHECK_IGNORE);
829
+ const literal2 = this._rules.testLiteral(path);
830
+ return literal2.ignored || literal2.unignored ? literal2 : dir;
792
831
  }
793
832
  _t(path, cache, checkUnignored) {
794
833
  if (path in cache) {
@@ -5885,7 +5924,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
5885
5924
  var NONE = 0;
5886
5925
  var ASSUMED = 1;
5887
5926
  var PROVEN = 2;
5888
- function isRecursive(inst, stack, resolve2) {
5927
+ function isRecursive(inst, stack, resolve3) {
5889
5928
  const cached2 = recursive.get(inst);
5890
5929
  if (cached2 !== void 0)
5891
5930
  return cached2 ? PROVEN : NONE;
@@ -5895,7 +5934,7 @@ function isRecursive(inst, stack, resolve2) {
5895
5934
  let result = NONE;
5896
5935
  const check2 = (child) => {
5897
5936
  if (result !== PROVEN && child?._zod) {
5898
- const answer = isRecursive(child, stack, resolve2);
5937
+ const answer = isRecursive(child, stack, resolve3);
5899
5938
  if (answer > result)
5900
5939
  result = answer;
5901
5940
  }
@@ -5906,7 +5945,7 @@ function isRecursive(inst, stack, resolve2) {
5906
5945
  const desc = Object.getOwnPropertyDescriptor(sh, key);
5907
5946
  if (spread && !desc.enumerable)
5908
5947
  continue;
5909
- const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve2) : NONE;
5948
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve3) : NONE;
5910
5949
  if (child > answer)
5911
5950
  answer = child;
5912
5951
  }
@@ -5970,7 +6009,7 @@ function isRecursive(inst, stack, resolve2) {
5970
6009
  break;
5971
6010
  // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
5972
6011
  case "lazy": {
5973
- const inner = def._cachedInner ?? (resolve2 ? inst._zod.innerType : void 0);
6012
+ const inner = def._cachedInner ?? (resolve3 ? inst._zod.innerType : void 0);
5974
6013
  merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
5975
6014
  break;
5976
6015
  }
@@ -21508,11 +21547,33 @@ var ResolutionMethod = external_exports.enum([
21508
21547
  "false-positive",
21509
21548
  "redetected"
21510
21549
  ]).meta({ id: "ResolutionMethod" });
21550
+ var FindingContextBasis = external_exports.enum(["file", "excerpt"]).meta({ id: "FindingContextBasis" });
21551
+ var FindingContext = external_exports.object({
21552
+ basis: FindingContextBasis,
21553
+ // 1-based line number of `lines[0]`.
21554
+ firstLine: external_exports.number().int().positive(),
21555
+ lines: external_exports.array(external_exports.string()).min(1).max(5),
21556
+ match: external_exports.object({
21557
+ // 1-based line number, within [firstLine, firstLine + lines.length).
21558
+ line: external_exports.number().int().positive(),
21559
+ // Offsets into that entry of `lines`, end exclusive.
21560
+ start: external_exports.number().int().nonnegative(),
21561
+ end: external_exports.number().int().nonnegative()
21562
+ }).nullable()
21563
+ }).meta({ id: "FindingContext" });
21564
+ var FindingLocation = external_exports.object({
21565
+ line: external_exports.number().int().positive(),
21566
+ col: external_exports.number().int().positive(),
21567
+ context: FindingContext.nullable()
21568
+ });
21511
21569
  var FindingMatch = external_exports.object({
21512
21570
  // Masked preview of the matched value. Never raw content.
21513
21571
  maskedValue: external_exports.string(),
21514
- // Redacted source-line prefix. Currently empty (pending privacy review).
21515
- contextPrefix: external_exports.string()
21572
+ // Deprecated: always empty. Superseded by `context`.
21573
+ contextPrefix: external_exports.string(),
21574
+ // The masked lines around the match. Absent when the finding predates
21575
+ // context capture or none could be built safely.
21576
+ context: FindingContext.optional()
21516
21577
  }).meta({ id: "FindingMatch" });
21517
21578
  var FindingDetectionRef = external_exports.object({
21518
21579
  id: external_exports.string(),
@@ -21532,6 +21593,11 @@ var FindingInstance = external_exports.object({
21532
21593
  provider: FindingProvider,
21533
21594
  repo: external_exports.string(),
21534
21595
  file: external_exports.string(),
21596
+ // 1-based line and column of the match start in the scanned text (the
21597
+ // column in UTF-16 code units). Absent for findings that predate location
21598
+ // capture or have no source text.
21599
+ line: external_exports.number().int().positive().optional(),
21600
+ col: external_exports.number().int().positive().optional(),
21535
21601
  // Who the capturing event is attributed to. Optional: a single-user store
21536
21602
  // has no one to attribute a finding to and never sets it.
21537
21603
  user: FindingUser.optional(),
@@ -21593,6 +21659,13 @@ var FindingStats = external_exports.object({
21593
21659
  low: external_exports.number().int().nonnegative()
21594
21660
  })
21595
21661
  }).meta({ id: "FindingStats" });
21662
+ var FindingsOverview = external_exports.object({
21663
+ findings: external_exports.number().int().nonnegative(),
21664
+ open: external_exports.number().int().nonnegative(),
21665
+ handled: external_exports.number().int().nonnegative(),
21666
+ resolved: external_exports.number().int().nonnegative(),
21667
+ dismissed: external_exports.number().int().nonnegative()
21668
+ }).meta({ id: "FindingsOverview" });
21596
21669
  var FindingFacetItem = external_exports.object({
21597
21670
  value: external_exports.string(),
21598
21671
  count: external_exports.number().int().nonnegative()
@@ -21710,6 +21783,7 @@ var FindingInstanceDetail = FindingInstance.extend({
21710
21783
  policy: FindingPolicyRef
21711
21784
  }).meta({ id: "FindingInstanceDetail" });
21712
21785
  var MAX_FLAT_FINDINGS_LIMIT = 200;
21786
+ var FindingContextQuery = external_exports.object({ id: external_exports.string().min(1).max(256) });
21713
21787
  var ListFindingInstancesQuery = external_exports.object({
21714
21788
  severity: external_exports.array(Severity).optional(),
21715
21789
  // Rule ids, the same vocabulary the types list's `subtype` carries. Pinning
@@ -22041,7 +22115,23 @@ var CaptureAttributes = external_exports.object({
22041
22115
  // capture denied by another finding's own Block policy carries `block`
22042
22116
  // here too. The full statement is on EventMetadata.redactDegradedTo; it is
22043
22117
  // repeated rather than referenced because a store reader opens this file.
22044
- redact_degraded_to: ActionTaken.optional()
22118
+ redact_degraded_to: ActionTaken.optional(),
22119
+ // The scope key this capture was stamped with: the canonical repository
22120
+ // (`host/owner/repo`) of the path the capture names (a relative path is read
22121
+ // against its working directory), else of its own working directory, or a
22122
+ // chat account's identity. The store's local `scope_key` column reads it, so
22123
+ // a scoped attachment has a per-row key to work from. Absent when no key
22124
+ // could be derived.
22125
+ //
22126
+ // LOCAL ONLY. That is the contract for every path that sends a row. Producers
22127
+ // stamp it in every attachment mode, and the two structural choke points strip
22128
+ // it: the attached gateway's `reKeyForForward` on the live path, and the
22129
+ // history drain's `rebuildAuditEvent`, which drops it through `withoutScopeKey`.
22130
+ // A capture row's bag reaches the wire through `rebuildCapture`, which builds
22131
+ // the metadata from named keys and never names this one; `toCaptureAttributes`,
22132
+ // which builds the bag from a wire event, never emits it. What a scoped
22133
+ // attachment does with the key is not part of this shape's contract.
22134
+ scope_key: external_exports.string().optional()
22045
22135
  }).catchall(external_exports.unknown());
22046
22136
  var CaptureStatusAttributes = external_exports.object({
22047
22137
  source_tool: external_exports.string().optional(),
@@ -22071,6 +22161,12 @@ var ToolCallInspection = external_exports.object({
22071
22161
  actionTaken: ActionTaken,
22072
22162
  confidence: external_exports.number().min(0).max(1)
22073
22163
  });
22164
+ var findingLocationFields = {
22165
+ line: external_exports.number().int().positive().optional(),
22166
+ col: external_exports.number().int().positive().optional(),
22167
+ context: FindingContext.nullable().optional()
22168
+ };
22169
+ var ToolCallInspectionInput = ToolCallInspection.extend(findingLocationFields);
22074
22170
  var ToolCallInput = external_exports.object({
22075
22171
  sessionId: external_exports.string().min(1),
22076
22172
  toolUseId: external_exports.string().min(1),
@@ -22080,7 +22176,7 @@ var ToolCallInput = external_exports.object({
22080
22176
  attributes: ToolCallAttributes,
22081
22177
  // Secrets detected in the tool's (masked) target — written as linked
22082
22178
  // `inspection_findings`. Empty for a clean tool call.
22083
- inspections: external_exports.array(ToolCallInspection).default([])
22179
+ inspections: external_exports.array(ToolCallInspectionInput).default([])
22084
22180
  });
22085
22181
  var InventoryInput = external_exports.object({
22086
22182
  objectType: InventoryObjectType,
@@ -22154,7 +22250,8 @@ var InspectionFindingInput = external_exports.object({
22154
22250
  // same findingKey — mirrors the legacy `findings.first_detected_at`.
22155
22251
  // Optional: when omitted, the writer derives it from the referenced audit
22156
22252
  // event's startedAt on first insert (see SqliteInspectionFindingsRepository).
22157
- firstDetectedAt: external_exports.iso.datetime().optional()
22253
+ firstDetectedAt: external_exports.iso.datetime().optional(),
22254
+ ...findingLocationFields
22158
22255
  });
22159
22256
  var InventoryContext = external_exports.object({
22160
22257
  host: InventoryInput.optional(),
@@ -22929,6 +23026,17 @@ var AttachedCredential = external_exports.object({
22929
23026
  keyPrefix: external_exports.string().min(1).max(16).optional(),
22930
23027
  mintedAt: external_exports.iso.datetime().optional()
22931
23028
  });
23029
+ var AttachmentMode = external_exports.enum(["machine", "scoped"]);
23030
+ var ATTACHED_CREDENTIAL_SCOPED_SPEC_VERSION = 2;
23031
+ var AttachedCredentialV1 = AttachedCredential;
23032
+ var AttachedCredentialV2 = AttachedCredential.extend({
23033
+ specVersion: external_exports.literal(ATTACHED_CREDENTIAL_SCOPED_SPEC_VERSION),
23034
+ mode: external_exports.literal("scoped")
23035
+ });
23036
+ var AttachedCredentialAny = external_exports.discriminatedUnion("specVersion", [
23037
+ AttachedCredentialV1,
23038
+ AttachedCredentialV2
23039
+ ]);
22932
23040
  var MAX_DATE_MS = 253402300799999;
22933
23041
  var MAX_INT4 = 2147483647;
22934
23042
  var StorePosturePack = external_exports.object({
@@ -22985,7 +23093,29 @@ var StorePosturePlugin = external_exports.object({
22985
23093
  */
22986
23094
  policyBundleVersion: external_exports.string().max(200).nullable(),
22987
23095
  /** Epoch millis, on the CLIENT clock, of that fetch. */
22988
- policyFetchedAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable()
23096
+ policyFetchedAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable(),
23097
+ /**
23098
+ * The newest version the host's own install record holds for this plugin —
23099
+ * what is on disk. After an update it leads `version` (the running copy) by
23100
+ * one launch. Null when no usable version can be read: no install record
23101
+ * (a plugin run from a checkout), no entry with a valid version, or every
23102
+ * such entry names an `installPath` that no longer exists; OPTIONAL, not
23103
+ * required, so a build that predates the member keeps getting its 200.
23104
+ * Bounded like `version`.
23105
+ */
23106
+ installedVersion: external_exports.string().max(64).nullable().optional(),
23107
+ /**
23108
+ * The local-store schema version this running build migrates a store to:
23109
+ * the number of store migrations it carries, the count it stamps into
23110
+ * `PRAGMA user_version`. A snapshot whose `schemaVersion` is above it
23111
+ * usually describes a store a newer build migrated. It is a hint, not a
23112
+ * verdict: the stamp is write-only, so a store whose count ran past this
23113
+ * build's while this build knows every migration in its ledger reads above
23114
+ * it too, which is why describeStoreSkew decides skew on ledger tags and
23115
+ * never on the count. OPTIONAL for the same reason as `installedVersion`;
23116
+ * bounded like `schemaVersion`.
23117
+ */
23118
+ buildSchemaVersion: external_exports.number().int().min(0).max(MAX_INT4).optional()
22989
23119
  }).meta({ id: "StorePosturePlugin" });
22990
23120
  var StorePostureSnapshot = external_exports.object({
22991
23121
  deviceId: external_exports.guid(),
@@ -23188,6 +23318,130 @@ var PackId = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
23188
23318
  var SemVer = external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?$/);
23189
23319
  var PublisherKind = external_exports.enum(["labs", "user", "org"]);
23190
23320
 
23321
+ // ../../packages/schema/src/zod/builtin-policy-id.ts
23322
+ var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
23323
+ var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
23324
+
23325
+ // ../../packages/schema/src/zod/event.ts
23326
+ var EventKind = external_exports.enum(["prompt", "response", "code_change", "tool_use"]).meta({ id: "EventKind" });
23327
+ var CAPTURE_EVENT_TYPES_SQL = EventKind.options.map((k) => `'${k}'`).join(",");
23328
+ var EventMetadata = external_exports.object({
23329
+ sessionId: external_exports.string().optional(),
23330
+ repo: external_exports.string().optional(),
23331
+ filePath: external_exports.string().optional(),
23332
+ // The host tool whose input/output was scanned (e.g. 'Bash', 'WebFetch'),
23333
+ // set by the tool-scanning hooks. The tool NAME only — never the tool's
23334
+ // arguments or output, which can carry the very value a finding masked
23335
+ // (metadata is stored unredacted). Gives findings on non-file captures a
23336
+ // display location ("via Bash") when no filePath exists.
23337
+ toolName: external_exports.string().optional(),
23338
+ // Set (true) by the worktree scanner when the file is excluded by the
23339
+ // repo's .gitignore. Gitignored files ARE still scanned — local scratch and
23340
+ // generated code can leak real secrets — but the provenance is recorded so
23341
+ // policy/dashboards can treat those findings as informational rather than
23342
+ // blocking. Omitted (not false) for tracked files and non-scan events.
23343
+ gitignored: external_exports.boolean().optional(),
23344
+ // Set (true) ONLY when the event's `content` is the COMPLETE file at
23345
+ // capture time (a worktree scan reading from disk). Hook-captured edits
23346
+ // (e.g. an Edit tool's new_string) are partial fragments and MUST NOT set
23347
+ // this. The resolver-on-ingest keys its fixed-at-source dropout
23348
+ // diff on this marker: only a whole-file snapshot can prove a previously
23349
+ // open finding is gone; a fragment's absence proves nothing (the secret
23350
+ // may live outside the hunk). Omitted (not false) for fragments and
23351
+ // non-scan events, so pre-marker clients safely default to the
23352
+ // non-authoritative path.
23353
+ wholeFile: external_exports.boolean().optional(),
23354
+ model: external_exports.string().optional(),
23355
+ turnIndex: external_exports.number().int().nonnegative().optional(),
23356
+ // Distributed-tracing correlation. `correlationId` ties a recorded event back
23357
+ // to the request that captured/ingested it (a UUID, generated independently of
23358
+ // the trace id); `traceId` is the W3C trace id (32 lowercase hex chars) of the
23359
+ // originating span when telemetry is enabled. Both optional + backward
23360
+ // compatible — populated by the plugin (see @akasecurity/plugin-sdk).
23361
+ correlationId: external_exports.uuid().optional(),
23362
+ traceId: external_exports.string().regex(/^[0-9a-f]{32}$/).optional(),
23363
+ // Ids of the detection exceptions that downgraded findings in this capture
23364
+ // to 'allow' — the enforcement audit trail's link back to the grant that
23365
+ // authorized the bypass. Absent on captures where no exception applied.
23366
+ exceptionIds: external_exports.array(external_exports.guid()).optional(),
23367
+ // The assistant message this capture belongs to, and the conversation it sits
23368
+ // in — set by the browser extension's network capture so a stored `response`
23369
+ // row can be joined to the `llm_call` leaf describing the same turn. Absent
23370
+ // on every other capture path, which has no such id.
23371
+ //
23372
+ // Non-empty for the reason WebExchange.messageId is: it is the join key, and
23373
+ // a blank one matches no `llm_call` leaf. That refusal reaches only the
23374
+ // places an event is PARSED; the local write path types the event and parses
23375
+ // nothing, which is why `toCaptureAttributes` omits a blank one separately.
23376
+ messageId: external_exports.string().min(1).optional(),
23377
+ conversationId: external_exports.string().optional(),
23378
+ // How long THIS capture's inspection blocked its caller, in whole
23379
+ // milliseconds — the plugin's own added latency, NOT the LLM call it sat in
23380
+ // front of. Measured inside `capture()` (@akasecurity/plugin-sdk) across
23381
+ // detection + redaction, the work the host session actually waits on.
23382
+ //
23383
+ // Stamped ONLY on live in-flight captures. A capture that carries its own
23384
+ // `occurredAt` is replaying past work (the transcript backfill, the worktree
23385
+ // scan), and its scan duration is not latency any host session experienced,
23386
+ // so those rows leave this ABSENT rather than reporting a misleading number.
23387
+ // Absent is also what every pre-measurement client writes, and what a
23388
+ // clock failure degrades to — a reader must treat absence as "not measured"
23389
+ // and never as a zero, which would read as "inspection is free".
23390
+ inspectionMs: external_exports.number().int().nonnegative().optional(),
23391
+ // What a `redact` this capture COULD NOT CARRY OUT became instead — the
23392
+ // workspace's `redactFallback`, applied because the field could not be
23393
+ // masked in place (a shell command, a URL, or any argument on a host whose
23394
+ // hook contract offers no rewrite channel).
23395
+ //
23396
+ // It exists because the action alone cannot say why. A finding recorded as
23397
+ // `warn` reads identically whether its detection was ASSIGNED Warn or was
23398
+ // assigned Redact on a field that could not take one — and those are
23399
+ // different facts about the same row: the first is a policy the user chose,
23400
+ // the second is a masking the host could not perform. Absent means no
23401
+ // degrade happened, which is every ordinary capture.
23402
+ //
23403
+ // TWO LIMITS a reader of a stored row has to know, because the grain here
23404
+ // is the CAPTURE while `actionTaken` is per FINDING:
23405
+ //
23406
+ // - It does not say WHICH finding degraded. A capture carrying a degraded
23407
+ // `redact` alongside a finding ASSIGNED the same action stores both
23408
+ // identically and one reason for the pair; attributing it to both
23409
+ // describes the assigned one wrongly, and to neither loses the degrade.
23410
+ // - PRESENCE IS NOT CAUSATION. The value is the action the lost redact
23411
+ // became, not the reason the capture ended as it did — a capture denied
23412
+ // by some other finding's own Block policy still carries `block` here,
23413
+ // and clearing the workspace's fallback would not have let it through.
23414
+ // Gate on the value against what a fallback can produce; never read the
23415
+ // field's presence as "this was the fallback's doing".
23416
+ //
23417
+ // Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
23418
+ // Closing either means moving the reason onto the finding row, which
23419
+ // already carries its own action.
23420
+ redactDegradedTo: ActionTaken.optional()
23421
+ }).meta({ id: "EventMetadata" });
23422
+ var Event = external_exports.object({
23423
+ id: external_exports.guid(),
23424
+ sourceTool: SourceTool,
23425
+ kind: EventKind,
23426
+ occurredAt: external_exports.iso.datetime(),
23427
+ contentHash: external_exports.string(),
23428
+ content: external_exports.string(),
23429
+ metadata: EventMetadata.optional()
23430
+ }).meta({ id: "Event" });
23431
+ var IngestEvent = Event.meta({ id: "IngestEvent" });
23432
+ var INGEST_BATCH_MAX = 100;
23433
+ var IngestBatch = external_exports.object({
23434
+ events: external_exports.array(IngestEvent).min(1).max(INGEST_BATCH_MAX),
23435
+ // Dedup policy for this batch. Id-dedup ALWAYS applies. 'content-hash'
23436
+ // additionally rejects any event whose contentHash the store has already
23437
+ // recorded — for re-runnable bulk ingest (worktree scan, transcript
23438
+ // backfill), where a re-run mints fresh event ids for identical content and
23439
+ // would otherwise accumulate duplicates. Live hook traffic must NOT set it:
23440
+ // two genuinely separate prompts can be byte-identical and both belong on
23441
+ // the timeline.
23442
+ dedupe: external_exports.literal("content-hash").optional()
23443
+ }).meta({ id: "IngestBatch" });
23444
+
23191
23445
  // ../../packages/schema/src/zod/rule.ts
23192
23446
  var MatcherType = external_exports.enum(["keyword", "regex"]).meta({ id: "MatcherType" });
23193
23447
  var RuleProbeVerdict = external_exports.enum(["safe", "quarantined"]).meta({ id: "RuleProbeVerdict" });
@@ -23256,7 +23510,10 @@ var Matcher = external_exports.discriminatedUnion("type", [KeywordMatcher, Regex
23256
23510
  var MATCHER_TYPES = MatcherType.options;
23257
23511
  var AppliesTo = external_exports.strictObject({
23258
23512
  // Dot-prefixed, e.g. ".py" — matches the scanner's SOURCE_EXTENSIONS shape.
23259
- extensions: external_exports.array(external_exports.string().regex(/^\.[A-Za-z0-9]+$/)).min(1)
23513
+ extensions: external_exports.array(external_exports.string().regex(/^\.[A-Za-z0-9]+$/)).min(1).optional(),
23514
+ eventKinds: external_exports.array(EventKind).min(1).optional()
23515
+ }).refine((v) => v.extensions !== void 0 || v.eventKinds !== void 0, {
23516
+ message: "appliesTo needs extensions, eventKinds, or both"
23260
23517
  }).meta({ id: "AppliesTo" });
23261
23518
  var PostValidatorName = external_exports.enum(["entropy", "luhn"]).meta({ id: "PostValidatorName" });
23262
23519
  var PostValidatorRef = external_exports.union(
@@ -23279,6 +23536,7 @@ var PostValidatorRef = external_exports.union(
23279
23536
  )}) or { "name": ..., "config": { ... } }. An unrecognized name would be a false-positive guard that never runs.`
23280
23537
  }
23281
23538
  ).meta({ id: "PostValidatorRef" });
23539
+ var RuleEvidence = external_exports.enum(["code", "value"]).meta({ id: "RuleEvidence" });
23282
23540
  var RequiresNearby = external_exports.strictObject({
23283
23541
  // Each array, when present, must be non-empty and contain non-empty strings —
23284
23542
  // an empty/blank criterion would either never fire or (for labels) match
@@ -23301,6 +23559,8 @@ var RuleFixture = external_exports.strictObject({
23301
23559
  // Simulated file context for the scan, so fixtures can assert `appliesTo`
23302
23560
  // gating (e.g. a Python-only pattern must NOT fire in a .ts file).
23303
23561
  filePath: external_exports.string().optional(),
23562
+ // Simulated capture kind, so fixtures can assert `appliesTo.eventKinds`.
23563
+ eventKind: EventKind.optional(),
23304
23564
  expectedSpans: external_exports.array(external_exports.strictObject({ start: external_exports.number(), end: external_exports.number() })).optional()
23305
23565
  }).meta({ id: "RuleFixture" });
23306
23566
  var Rule = external_exports.strictObject({
@@ -23326,7 +23586,9 @@ var Rule = external_exports.strictObject({
23326
23586
  appliesTo: AppliesTo.optional(),
23327
23587
  postValidators: external_exports.array(PostValidatorRef).optional(),
23328
23588
  requiresNearby: RequiresNearby.optional(),
23329
- examples: external_exports.array(external_exports.string()).optional()
23589
+ examples: external_exports.array(external_exports.string()).optional(),
23590
+ // Whether the matched text is itself sensitive. Absent means 'value'.
23591
+ evidence: RuleEvidence.optional()
23330
23592
  }).meta({ id: "Rule" });
23331
23593
  var Author = external_exports.object({
23332
23594
  name: external_exports.string(),
@@ -23343,7 +23605,11 @@ var PackManifest = external_exports.object({
23343
23605
  description: external_exports.string().optional(),
23344
23606
  author: Author.optional(),
23345
23607
  license: external_exports.string().optional(),
23346
- sourceUrl: external_exports.url().optional()
23608
+ sourceUrl: external_exports.url().optional(),
23609
+ // The built-in policy a FIRST install of this pack assigns
23610
+ // (installed_packs.policy_id). Absent leaves the pack unassigned, so its
23611
+ // rules follow the category policies. An existing install never takes it.
23612
+ defaultPolicy: BuiltinPolicyId.optional()
23347
23613
  }).meta({ id: "PackManifest" });
23348
23614
 
23349
23615
  // ../../packages/schema/src/zod/detection.ts
@@ -23371,10 +23637,12 @@ var DetectionListItem = external_exports.object({
23371
23637
  // Per-pack enforcement-policy assignment. Holds a BuiltinPolicyId ARCHETYPE
23372
23638
  // (monitor|warn|redact|block) — NOT a policies-table Policy.id guid; a
23373
23639
  // detection is a PACK, and its policy is the archetype applied to all its
23374
- // rules. Absent == unassigned, which resolves to Monitor everywhere
23375
- // (DEFAULT_PACK_POLICY_ID). Every enforcement surface expands it into
23376
- // per-rule policies (see policyIdToAction). Typed z.string() (not
23377
- // the enum) to keep the OpenAPI response tolerant of a future custom id.
23640
+ // rules. Absent == unassigned, which resolves to Monitor by default
23641
+ // (DEFAULT_PACK_POLICY_ID); a host may resolve it to a policy of its own
23642
+ // (see the dashboard's `unassignedPolicy`). Every enforcement surface
23643
+ // expands it into per-rule policies (see policyIdToAction). Typed
23644
+ // z.string() (not the enum) to keep the OpenAPI response tolerant of a
23645
+ // future custom id.
23378
23646
  policyId: external_exports.string().optional(),
23379
23647
  // Set ONLY when a newer snapshot is available for this pack (OSS: the
23380
23648
  // bundled inventory recorded in available_packs differs from the installed
@@ -23443,10 +23711,12 @@ var DetectionDetail = external_exports.object({
23443
23711
  // Per-pack enforcement-policy assignment. Holds a BuiltinPolicyId ARCHETYPE
23444
23712
  // (monitor|warn|redact|block) — NOT a policies-table Policy.id guid; a
23445
23713
  // detection is a PACK, and its policy is the archetype applied to all its
23446
- // rules. Absent == unassigned, which resolves to Monitor everywhere
23447
- // (DEFAULT_PACK_POLICY_ID). Every enforcement surface expands it into
23448
- // per-rule policies (see policyIdToAction). Typed z.string() (not
23449
- // the enum) to keep the OpenAPI response tolerant of a future custom id.
23714
+ // rules. Absent == unassigned, which resolves to Monitor by default
23715
+ // (DEFAULT_PACK_POLICY_ID); a host may resolve it to a policy of its own
23716
+ // (see the dashboard's `unassignedPolicy`). Every enforcement surface
23717
+ // expands it into per-rule policies (see policyIdToAction). Typed
23718
+ // z.string() (not the enum) to keep the OpenAPI response tolerant of a
23719
+ // future custom id.
23450
23720
  policyId: external_exports.string().optional()
23451
23721
  }).meta({ id: "DetectionDetail" });
23452
23722
  var LibraryItem = external_exports.object({
@@ -23476,126 +23746,6 @@ var ImportDetectionRequest = external_exports.object({
23476
23746
  })
23477
23747
  }).meta({ id: "ImportDetectionRequest" });
23478
23748
 
23479
- // ../../packages/schema/src/zod/event.ts
23480
- var EventKind = external_exports.enum(["prompt", "response", "code_change", "tool_use"]).meta({ id: "EventKind" });
23481
- var CAPTURE_EVENT_TYPES_SQL = EventKind.options.map((k) => `'${k}'`).join(",");
23482
- var EventMetadata = external_exports.object({
23483
- sessionId: external_exports.string().optional(),
23484
- repo: external_exports.string().optional(),
23485
- filePath: external_exports.string().optional(),
23486
- // The host tool whose input/output was scanned (e.g. 'Bash', 'WebFetch'),
23487
- // set by the tool-scanning hooks. The tool NAME only — never the tool's
23488
- // arguments or output, which can carry the very value a finding masked
23489
- // (metadata is stored unredacted). Gives findings on non-file captures a
23490
- // display location ("via Bash") when no filePath exists.
23491
- toolName: external_exports.string().optional(),
23492
- // Set (true) by the worktree scanner when the file is excluded by the
23493
- // repo's .gitignore. Gitignored files ARE still scanned — local scratch and
23494
- // generated code can leak real secrets — but the provenance is recorded so
23495
- // policy/dashboards can treat those findings as informational rather than
23496
- // blocking. Omitted (not false) for tracked files and non-scan events.
23497
- gitignored: external_exports.boolean().optional(),
23498
- // Set (true) ONLY when the event's `content` is the COMPLETE file at
23499
- // capture time (a worktree scan reading from disk). Hook-captured edits
23500
- // (e.g. an Edit tool's new_string) are partial fragments and MUST NOT set
23501
- // this. The resolver-on-ingest keys its fixed-at-source dropout
23502
- // diff on this marker: only a whole-file snapshot can prove a previously
23503
- // open finding is gone; a fragment's absence proves nothing (the secret
23504
- // may live outside the hunk). Omitted (not false) for fragments and
23505
- // non-scan events, so pre-marker clients safely default to the
23506
- // non-authoritative path.
23507
- wholeFile: external_exports.boolean().optional(),
23508
- model: external_exports.string().optional(),
23509
- turnIndex: external_exports.number().int().nonnegative().optional(),
23510
- // Distributed-tracing correlation. `correlationId` ties a recorded event back
23511
- // to the request that captured/ingested it (a UUID, generated independently of
23512
- // the trace id); `traceId` is the W3C trace id (32 lowercase hex chars) of the
23513
- // originating span when telemetry is enabled. Both optional + backward
23514
- // compatible — populated by the plugin (see @akasecurity/plugin-sdk).
23515
- correlationId: external_exports.uuid().optional(),
23516
- traceId: external_exports.string().regex(/^[0-9a-f]{32}$/).optional(),
23517
- // Ids of the detection exceptions that downgraded findings in this capture
23518
- // to 'allow' — the enforcement audit trail's link back to the grant that
23519
- // authorized the bypass. Absent on captures where no exception applied.
23520
- exceptionIds: external_exports.array(external_exports.guid()).optional(),
23521
- // The assistant message this capture belongs to, and the conversation it sits
23522
- // in — set by the browser extension's network capture so a stored `response`
23523
- // row can be joined to the `llm_call` leaf describing the same turn. Absent
23524
- // on every other capture path, which has no such id.
23525
- //
23526
- // Non-empty for the reason WebExchange.messageId is: it is the join key, and
23527
- // a blank one matches no `llm_call` leaf. That refusal reaches only the
23528
- // places an event is PARSED; the local write path types the event and parses
23529
- // nothing, which is why `toCaptureAttributes` omits a blank one separately.
23530
- messageId: external_exports.string().min(1).optional(),
23531
- conversationId: external_exports.string().optional(),
23532
- // How long THIS capture's inspection blocked its caller, in whole
23533
- // milliseconds — the plugin's own added latency, NOT the LLM call it sat in
23534
- // front of. Measured inside `capture()` (@akasecurity/plugin-sdk) across
23535
- // detection + redaction, the work the host session actually waits on.
23536
- //
23537
- // Stamped ONLY on live in-flight captures. A capture that carries its own
23538
- // `occurredAt` is replaying past work (the transcript backfill, the worktree
23539
- // scan), and its scan duration is not latency any host session experienced,
23540
- // so those rows leave this ABSENT rather than reporting a misleading number.
23541
- // Absent is also what every pre-measurement client writes, and what a
23542
- // clock failure degrades to — a reader must treat absence as "not measured"
23543
- // and never as a zero, which would read as "inspection is free".
23544
- inspectionMs: external_exports.number().int().nonnegative().optional(),
23545
- // What a `redact` this capture COULD NOT CARRY OUT became instead — the
23546
- // workspace's `redactFallback`, applied because the field could not be
23547
- // masked in place (a shell command, a URL, or any argument on a host whose
23548
- // hook contract offers no rewrite channel).
23549
- //
23550
- // It exists because the action alone cannot say why. A finding recorded as
23551
- // `warn` reads identically whether its detection was ASSIGNED Warn or was
23552
- // assigned Redact on a field that could not take one — and those are
23553
- // different facts about the same row: the first is a policy the user chose,
23554
- // the second is a masking the host could not perform. Absent means no
23555
- // degrade happened, which is every ordinary capture.
23556
- //
23557
- // TWO LIMITS a reader of a stored row has to know, because the grain here
23558
- // is the CAPTURE while `actionTaken` is per FINDING:
23559
- //
23560
- // - It does not say WHICH finding degraded. A capture carrying a degraded
23561
- // `redact` alongside a finding ASSIGNED the same action stores both
23562
- // identically and one reason for the pair; attributing it to both
23563
- // describes the assigned one wrongly, and to neither loses the degrade.
23564
- // - PRESENCE IS NOT CAUSATION. The value is the action the lost redact
23565
- // became, not the reason the capture ended as it did — a capture denied
23566
- // by some other finding's own Block policy still carries `block` here,
23567
- // and clearing the workspace's fallback would not have let it through.
23568
- // Gate on the value against what a fallback can produce; never read the
23569
- // field's presence as "this was the fallback's doing".
23570
- //
23571
- // Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
23572
- // Closing either means moving the reason onto the finding row, which
23573
- // already carries its own action.
23574
- redactDegradedTo: ActionTaken.optional()
23575
- }).meta({ id: "EventMetadata" });
23576
- var Event = external_exports.object({
23577
- id: external_exports.guid(),
23578
- sourceTool: SourceTool,
23579
- kind: EventKind,
23580
- occurredAt: external_exports.iso.datetime(),
23581
- contentHash: external_exports.string(),
23582
- content: external_exports.string(),
23583
- metadata: EventMetadata.optional()
23584
- }).meta({ id: "Event" });
23585
- var IngestEvent = Event.meta({ id: "IngestEvent" });
23586
- var INGEST_BATCH_MAX = 100;
23587
- var IngestBatch = external_exports.object({
23588
- events: external_exports.array(IngestEvent).min(1).max(INGEST_BATCH_MAX),
23589
- // Dedup policy for this batch. Id-dedup ALWAYS applies. 'content-hash'
23590
- // additionally rejects any event whose contentHash the store has already
23591
- // recorded — for re-runnable bulk ingest (worktree scan, transcript
23592
- // backfill), where a re-run mints fresh event ids for identical content and
23593
- // would otherwise accumulate duplicates. Live hook traffic must NOT set it:
23594
- // two genuinely separate prompts can be byte-identical and both belong on
23595
- // the timeline.
23596
- dedupe: external_exports.literal("content-hash").optional()
23597
- }).meta({ id: "IngestBatch" });
23598
-
23599
23749
  // ../../packages/schema/src/zod/exception.ts
23600
23750
  var ExceptionScope = external_exports.enum(["once", "temporary", "permanent"]);
23601
23751
  var ExceptionConditions = external_exports.object({
@@ -23756,8 +23906,6 @@ var Policy = external_exports.object({
23756
23906
  // test `prohibitedModels` passes and `reversibleRuleIds` fails.
23757
23907
  provenance: PolicyProvenance.optional()
23758
23908
  }).meta({ id: "Policy" });
23759
- var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
23760
- var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
23761
23909
  var RedactFallback = BuiltinPolicyId.extract(["monitor", "warn", "block"]).meta({
23762
23910
  id: "RedactFallback"
23763
23911
  });
@@ -23964,10 +24112,15 @@ var ParsedPointer = external_exports.object({
23964
24112
  });
23965
24113
  var VaultEntry = external_exports.object({
23966
24114
  pointerId: external_exports.string(),
23967
- // The keyed HMAC of the raw value under `exception.key`, and the epoch it was
23968
- // derived under. This is what a reveal-to-model grant matches on, and it rotates
23969
- // independently of the vault encryption key below.
24115
+ // The keyed HMAC of the EXACT raw bytes under `exception.key`, and the epoch it
24116
+ // was derived under. The vault's own dedupe key: a value and its invisibly
24117
+ // padded twin are two rows. It rotates independently of the vault encryption
24118
+ // key below. Never matched against an exception or grant.
23970
24119
  valueFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
24120
+ // The same HMAC over the raw with invisible padding removed: the identity a
24121
+ // reveal-to-model grant and every exception match on. Shared by a value and
24122
+ // its padded twin.
24123
+ valueIdentityFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
23971
24124
  fingerprintKeyVersion: external_exports.number().int().positive(),
23972
24125
  // The vault-key epoch this row's ciphertext was sealed under.
23973
24126
  keyVersion: external_exports.number().int().positive(),
@@ -24109,7 +24262,7 @@ var VaultConsent = external_exports.object({
24109
24262
  });
24110
24263
 
24111
24264
  // ../../packages/schema/src/zod/local.ts
24112
- var WORKSPACE_SETTINGS_SPEC_VERSION = 8;
24265
+ var WORKSPACE_SETTINGS_SPEC_VERSION = 9;
24113
24266
  var MODEL_JUDGE_PAYLOAD_VERSION = 1;
24114
24267
  var RunMode = external_exports.enum(["standalone", "attached"]);
24115
24268
  var ControlPlaneConnection = external_exports.object({
@@ -24129,6 +24282,18 @@ var HistorySyncConsent = external_exports.object({
24129
24282
  payloadVersion: external_exports.number().int().positive(),
24130
24283
  endpoint: external_exports.string()
24131
24284
  });
24285
+ var ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH = 512;
24286
+ var AttachmentScopeEntry = external_exports.object({
24287
+ kind: external_exports.enum(["repo", "account"]),
24288
+ identity: printable(ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH).min(1),
24289
+ label: printable(80).optional(),
24290
+ enrolledAt: external_exports.iso.datetime()
24291
+ });
24292
+ var AttachmentScope = external_exports.object({
24293
+ endpoint: external_exports.string().min(1),
24294
+ entries: external_exports.array(AttachmentScopeEntry)
24295
+ });
24296
+ var AttachmentScopeEnvelope = AttachmentScope.extend({ entries: external_exports.array(external_exports.unknown()) });
24132
24297
  var WebChatCaptureConsent = external_exports.object({
24133
24298
  acknowledgedAt: external_exports.iso.datetime(),
24134
24299
  version: external_exports.number().int().positive()
@@ -24199,6 +24364,23 @@ var WorkspaceSettings = external_exports.object({
24199
24364
  // both widenings. Absent until granted, and a grant for a different endpoint
24200
24365
  // or an older payload no longer counts.
24201
24366
  historySyncConsent: HistorySyncConsent.optional(),
24367
+ // The identities a SCOPED attachment forwards and the deployment they were
24368
+ // enrolled for (see AttachmentScope). Absent until something is enrolled.
24369
+ //
24370
+ // `z.unknown()`, NOT `AttachmentScope`, and the difference is this field's
24371
+ // whole failure mode. A settings.json that fails this schema reads as the
24372
+ // unonboarded defaults (readUserSettings in @akasecurity/persistence), and the
24373
+ // next save writes those defaults back over it. Typed, one entry with an
24374
+ // unknown `kind`, a control character or a bad timestamp would cost the
24375
+ // attachment, every consent and onboardedAt, permanently. Untyped, the value
24376
+ // is kept exactly as found and validated where it is used: parseAttachmentScope
24377
+ // drops a bad entry by itself, and on a scoped attachment resolveScope reads a
24378
+ // bad envelope as no entries, which keeps every event local.
24379
+ //
24380
+ // No default: absent must stay absent, so defaultWorkspaceSettings() and a
24381
+ // fresh settings.json do not change. No `.meta({ id })`, like every field
24382
+ // here. Not a ManagedSettingKey.
24383
+ attachmentScope: external_exports.unknown().optional(),
24202
24384
  // What the browser extension may record from a web chat, and the grant that
24203
24385
  // authorizes it. Absent until the user answers: recording something that was
24204
24386
  // never recorded before is never an assumed grant on upgrade, so the whole
@@ -24415,10 +24597,18 @@ var SeveritySummaryItem = external_exports.object({
24415
24597
  count: external_exports.number().int().nonnegative(),
24416
24598
  // Resolution-aware breakdown (optional, additive). Populated once findings
24417
24599
  // carry lifecycle state: `caught` = handled in-flight (enforced); `openAtRest`
24418
- // = still open with no in-flight enforcement (needs remediation). Absent on the
24419
- // legacy count-only response until the resolution feature lands.
24600
+ // = still open with no in-flight enforcement (needs remediation); `dismissed`
24601
+ // = closed by a human judgement rather than a fix — visible, but not counted as
24602
+ // needing remediation. The three are disjoint. Absent on the legacy count-only
24603
+ // response until the resolution feature lands.
24420
24604
  caught: external_exports.number().int().nonnegative().optional(),
24421
- openAtRest: external_exports.number().int().nonnegative().optional()
24605
+ openAtRest: external_exports.number().int().nonnegative().optional(),
24606
+ dismissed: external_exports.number().int().nonnegative().optional(),
24607
+ // The two halves of `caught`, for a reader that wants them apart: `handled` =
24608
+ // in-flight findings an enforcement action already contained; `resolved` =
24609
+ // at-rest findings closed out by fixing them. `handled + resolved === caught`.
24610
+ handled: external_exports.number().int().nonnegative().optional(),
24611
+ resolved: external_exports.number().int().nonnegative().optional()
24422
24612
  }).meta({ id: "SeveritySummaryItem" });
24423
24613
  var SeveritySummaryResponse = external_exports.object({
24424
24614
  // Sum of bySeverity[].count.
@@ -24426,6 +24616,9 @@ var SeveritySummaryResponse = external_exports.object({
24426
24616
  // Findings still open at rest (sum of bySeverity[].openAtRest). Optional and
24427
24617
  // additive — absent on the legacy response until the resolution feature lands.
24428
24618
  needsRemediation: external_exports.number().int().nonnegative().optional(),
24619
+ // Findings a user dismissed (sum of bySeverity[].dismissed). Excluded from
24620
+ // needsRemediation, and kept visible here so an accepted risk is not erased.
24621
+ dismissed: external_exports.number().int().nonnegative().optional(),
24429
24622
  // All four severity levels are always present (count may be 0).
24430
24623
  bySeverity: external_exports.array(SeveritySummaryItem)
24431
24624
  }).meta({ id: "SeveritySummaryResponse" });
@@ -24877,6 +25070,26 @@ function ensureDataDirSync(dir) {
24877
25070
  function tightenFile(file2) {
24878
25071
  chmodBestEffort(file2, DATA_FILE_MODE);
24879
25072
  }
25073
+ function writeExclusiveOwnerOnlySync(file2, data) {
25074
+ writeFileSync(file2, data, { mode: DATA_FILE_MODE, flag: "wx" });
25075
+ }
25076
+ function writeOwnerOnlyFileSync(file2, data) {
25077
+ const tmp = `${file2}.${String(process.pid)}.tmp`;
25078
+ try {
25079
+ rmSync2(tmp, { force: true });
25080
+ } catch {
25081
+ }
25082
+ try {
25083
+ writeExclusiveOwnerOnlySync(tmp, data);
25084
+ renameSync(tmp, file2);
25085
+ } finally {
25086
+ try {
25087
+ rmSync2(tmp, { force: true });
25088
+ } catch {
25089
+ }
25090
+ }
25091
+ tightenFile(file2);
25092
+ }
24880
25093
 
24881
25094
  // ../../packages/persistence/src/database.ts
24882
25095
  import { randomUUID as randomUUID11 } from "crypto";
@@ -24997,7 +25210,8 @@ var FINDING_ROW_COLUMNS_SQL = `f.id AS id, d.rule_id AS rule_id, d.category AS c
24997
25210
  ${latestResolutionStatusSql("f")} AS latest_status,
24998
25211
  e.synced_at AS synced_at, e.sync_claimed_at AS sync_claimed_at,
24999
25212
  e.sync_failed_at AS sync_failed_at, e.sync_failure AS sync_failure,
25000
- e.outbox_owed AS outbox_owed`;
25213
+ e.outbox_owed AS outbox_owed,
25214
+ f.line AS line, f.col AS col`;
25001
25215
 
25002
25216
  // ../../packages/persistence/src/repositories/installed-packs.ts
25003
25217
  import { createHash as createHash2, randomUUID as randomUUID4 } from "crypto";
@@ -25224,6 +25438,7 @@ var DEFERRED_TAGS = new Set(DEFERRED_MIGRATION_TAGS);
25224
25438
  // ../../packages/persistence/src/egress-wire.ts
25225
25439
  import { createHash as createHash3 } from "crypto";
25226
25440
  var SLASH = "/".charCodeAt(0);
25441
+ var SCOPE_KEY = printable(ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH);
25227
25442
 
25228
25443
  // ../../packages/persistence/src/finding-key.ts
25229
25444
  import { createHash as createHash4 } from "crypto";
@@ -26000,6 +26215,10 @@ function escapeRegExp2(value) {
26000
26215
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
26001
26216
  }
26002
26217
 
26218
+ // ../../packages/detections/src/format-chars.ts
26219
+ var HAS_FORMAT_CHAR = new RegExp("\\p{Cf}", "u");
26220
+ var FORMAT_CHAR_GLOBAL = new RegExp("\\p{Cf}", "gu");
26221
+
26003
26222
  // ../../packages/detections/src/regex-cache.ts
26004
26223
  var singles = /* @__PURE__ */ new WeakMap();
26005
26224
  var keywordLists = /* @__PURE__ */ new WeakMap();
@@ -26236,6 +26455,7 @@ var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
26236
26455
  // ../../packages/plugin-sdk/src/repo.ts
26237
26456
  import { existsSync as existsSync9, readFileSync as readFileSync10, statSync as statSync6 } from "fs";
26238
26457
  import { basename as basename2, dirname as dirname4, isAbsolute, join as join17, sep as sep2 } from "path";
26458
+ var NO_ATTRIBUTION = Object.freeze({});
26239
26459
 
26240
26460
  // ../../packages/plugin-sdk/src/events.ts
26241
26461
  import { createHash as createHash5, randomUUID as randomUUID13 } from "crypto";
@@ -26248,6 +26468,40 @@ import { Worker } from "worker_threads";
26248
26468
  // ../../packages/plugin-sdk/src/hook-fail-opens.ts
26249
26469
  import { readFileSync as readFileSync12 } from "fs";
26250
26470
  import { join as join19 } from "path";
26471
+ var HOOK_FAIL_OPENS_FILENAME = "hook-fail-opens.json";
26472
+ function hookFailOpensPath(dataDir2) {
26473
+ return join19(dataDir2, HOOK_FAIL_OPENS_FILENAME);
26474
+ }
26475
+ function recordHookFailOpen(dataDir2, nowMs) {
26476
+ try {
26477
+ ensureDataDirSync(dataDir2);
26478
+ const previous = readHookFailOpens(dataDir2);
26479
+ const next = {
26480
+ // Saturates at the largest count the reader accepts: one past it would
26481
+ // read back as nothing recorded and restart the tally from one.
26482
+ failOpens: Math.min((previous?.failOpens ?? 0) + 1, Number.MAX_SAFE_INTEGER),
26483
+ lastAtMs: nowMs
26484
+ };
26485
+ writeOwnerOnlyFileSync(hookFailOpensPath(dataDir2), `${JSON.stringify(next)}
26486
+ `);
26487
+ } catch {
26488
+ }
26489
+ }
26490
+ function readHookFailOpens(dataDir2) {
26491
+ try {
26492
+ const parsed = JSON.parse(readFileSync12(hookFailOpensPath(dataDir2), "utf8"));
26493
+ if (typeof parsed !== "object" || parsed === null) return null;
26494
+ const record2 = parsed;
26495
+ if (!isPositiveSafeInteger(record2.failOpens)) return null;
26496
+ if (!isPositiveSafeInteger(record2.lastAtMs)) return null;
26497
+ return { failOpens: record2.failOpens, lastAtMs: record2.lastAtMs };
26498
+ } catch {
26499
+ return null;
26500
+ }
26501
+ }
26502
+ function isPositiveSafeInteger(value) {
26503
+ return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
26504
+ }
26251
26505
 
26252
26506
  // ../../packages/plugin-sdk/src/host-floor.ts
26253
26507
  import { readFileSync as readFileSync14 } from "fs";
@@ -26371,6 +26625,9 @@ import { join as join23 } from "path";
26371
26625
  import { readdirSync as readdirSync3, realpathSync as realpathSync3 } from "fs";
26372
26626
  import { basename as basename4, dirname as dirname5, sep as sep3 } from "path";
26373
26627
 
26628
+ // ../../packages/plugin-sdk/src/policy-resolver.ts
26629
+ import { randomUUID as randomUUID14 } from "crypto";
26630
+
26374
26631
  // ../../packages/plugin-sdk/src/project-files.ts
26375
26632
  import { existsSync as existsSync11, readdirSync as readdirSync4 } from "fs";
26376
26633
  import { basename as basename5, join as join24 } from "path";
@@ -26402,16 +26659,20 @@ var codexProviderEnvShape = {
26402
26659
  var CodexProviderEnvSchema = external_exports.object(codexProviderEnvShape);
26403
26660
 
26404
26661
  // ../../packages/plugin-sdk/src/runtime.ts
26405
- import { randomUUID as randomUUID14 } from "crypto";
26662
+ import { randomUUID as randomUUID15 } from "crypto";
26663
+
26664
+ // ../../packages/plugin-sdk/src/scope-key.ts
26665
+ import { existsSync as existsSync12 } from "fs";
26666
+ import { dirname as dirname6, isAbsolute as isAbsolute2, join as join25, normalize } from "path";
26406
26667
 
26407
26668
  // ../../packages/plugin-sdk/src/suppressions.ts
26408
26669
  var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
26409
26670
 
26410
26671
  // ../../packages/plugin-sdk/src/throttle.ts
26411
26672
  import { mkdirSync as mkdirSync4, statSync as statSync8, writeFileSync as writeFileSync7 } from "fs";
26412
- import { join as join25 } from "path";
26673
+ import { join as join26 } from "path";
26413
26674
  function throttled(dataDir2, markerName, windowMs) {
26414
- const marker = join25(dataDir2, markerName);
26675
+ const marker = join26(dataDir2, markerName);
26415
26676
  try {
26416
26677
  if (Date.now() - statSync8(marker).mtimeMs < windowMs) return true;
26417
26678
  } catch {
@@ -26426,7 +26687,7 @@ function throttled(dataDir2, markerName, windowMs) {
26426
26687
 
26427
26688
  // src/history/reconcile-trigger.ts
26428
26689
  import { spawn } from "child_process";
26429
- import { dirname as dirname6, join as join27 } from "path";
26690
+ import { dirname as dirname7, join as join28 } from "path";
26430
26691
  import { fileURLToPath as fileURLToPath2 } from "url";
26431
26692
 
26432
26693
  // src/history/tail.ts
@@ -26440,7 +26701,7 @@ import {
26440
26701
  readSync as readSync2,
26441
26702
  writeFileSync as writeFileSync8
26442
26703
  } from "fs";
26443
- import { join as join26 } from "path";
26704
+ import { join as join27 } from "path";
26444
26705
  var SAFE_SESSION_ID = /^[A-Za-z0-9._-]+$/;
26445
26706
  function safeSessionId(sessionId) {
26446
26707
  if (SAFE_SESSION_ID.test(sessionId) && sessionId !== "." && sessionId !== "..") {
@@ -26456,8 +26717,8 @@ function triggerReconcile(dataDir2, sessionId, transcriptPath) {
26456
26717
  try {
26457
26718
  const marker = `${RECONCILE_MARKER_PREFIX}-${safeSessionId(sessionId)}`;
26458
26719
  if (throttled(dataDir2, marker, RECONCILE_THROTTLE_MS)) return;
26459
- const here = dirname6(fileURLToPath2(import.meta.url));
26460
- const child = spawn(process.execPath, [join27(here, "reconcile.js"), sessionId, transcriptPath], {
26720
+ const here = dirname7(fileURLToPath2(import.meta.url));
26721
+ const child = spawn(process.execPath, [join28(here, "reconcile.js"), sessionId, transcriptPath], {
26461
26722
  detached: true,
26462
26723
  stdio: "ignore"
26463
26724
  });
@@ -26467,8 +26728,9 @@ function triggerReconcile(dataDir2, sessionId, transcriptPath) {
26467
26728
  }
26468
26729
 
26469
26730
  // src/hooks/shared.ts
26731
+ import { isAbsolute as isAbsolute3, normalize as normalize2, resolve as resolvePath } from "path";
26470
26732
  async function readStdin() {
26471
- return new Promise((resolve2) => {
26733
+ return new Promise((resolve3) => {
26472
26734
  let data = "";
26473
26735
  let settled = false;
26474
26736
  const finish = () => {
@@ -26477,7 +26739,7 @@ async function readStdin() {
26477
26739
  clearTimeout(timer);
26478
26740
  process.stdin.removeListener("data", onData);
26479
26741
  process.stdin.removeListener("end", finish);
26480
- resolve2(data);
26742
+ resolve3(data);
26481
26743
  };
26482
26744
  const onData = (chunk) => {
26483
26745
  data += chunk;
@@ -26501,6 +26763,12 @@ function getString(record2, key) {
26501
26763
  const value = record2[key];
26502
26764
  return typeof value === "string" ? value : void 0;
26503
26765
  }
26766
+ function countFailOpen(base) {
26767
+ try {
26768
+ recordHookFailOpen(dataDir(base), Date.now());
26769
+ } catch {
26770
+ }
26771
+ }
26504
26772
 
26505
26773
  // src/hooks/stop-payload.ts
26506
26774
  function parseStopPayload(input2) {
@@ -26513,7 +26781,7 @@ function parseStopPayload(input2) {
26513
26781
 
26514
26782
  // src/hooks/store-health.ts
26515
26783
  import { mkdirSync as mkdirSync6, readFileSync as readFileSync22, writeFileSync as writeFileSync9 } from "fs";
26516
- import { dirname as dirname7, join as join34 } from "path";
26784
+ import { dirname as dirname9, join as join36 } from "path";
26517
26785
 
26518
26786
  // ../../packages/remote/src/http.ts
26519
26787
  import { request as httpRequest } from "http";
@@ -26523,14 +26791,17 @@ var MAX_RESPONSE_BYTES = 8 * 1024 * 1024;
26523
26791
  // ../../packages/remote/src/client.ts
26524
26792
  var SLASH2 = "/".charCodeAt(0);
26525
26793
 
26794
+ // ../../packages/plugin-runtime/src/attached/with-timeout.ts
26795
+ var REQUEST_TIMEOUT_MS = 2e3;
26796
+
26526
26797
  // ../../packages/plugin-runtime/src/attached/forward-drops.ts
26527
26798
  import { readFileSync as readFileSync18 } from "fs";
26528
- import { join as join28 } from "path";
26799
+ import { join as join29 } from "path";
26529
26800
 
26530
26801
  // ../../packages/plugin-runtime/src/attached/forward-policy.ts
26531
- import { randomUUID as randomUUID15 } from "crypto";
26802
+ import { randomUUID as randomUUID16 } from "crypto";
26532
26803
  import { readFile, rename, writeFile } from "fs/promises";
26533
- import { join as join29 } from "path";
26804
+ import { join as join30 } from "path";
26534
26805
 
26535
26806
  // ../../packages/plugin-runtime/src/attached/history-sync.ts
26536
26807
  import { createHash as createHash7 } from "crypto";
@@ -26550,13 +26821,18 @@ import { spawn as spawn2 } from "child_process";
26550
26821
  import { fileURLToPath as fileURLToPath3 } from "url";
26551
26822
  var HISTORY_SYNC_THROTTLE_MS = 5 * 60 * 1e3;
26552
26823
 
26824
+ // ../../packages/plugin-runtime/src/attached/install-record.ts
26825
+ import { readFile as readFile2, stat } from "fs/promises";
26826
+ import { basename as basename6, dirname as dirname8, join as join31, resolve as resolve2 } from "path";
26827
+
26553
26828
  // ../../packages/plugin-runtime/src/attached/plugin-block.ts
26554
26829
  import { readFileSync as readFileSync19 } from "fs";
26830
+ var INSTALL_RECORD_READ_TIMEOUT_MS = REQUEST_TIMEOUT_MS / 2;
26555
26831
 
26556
26832
  // ../../packages/plugin-runtime/src/attached/policy-store.ts
26557
- import { randomUUID as randomUUID16 } from "crypto";
26558
- import { readFile as readFile2, rm, writeFile as writeFile2 } from "fs/promises";
26559
- import { join as join30 } from "path";
26833
+ import { randomUUID as randomUUID17 } from "crypto";
26834
+ import { readFile as readFile3, rm, writeFile as writeFile2 } from "fs/promises";
26835
+ import { join as join32 } from "path";
26560
26836
 
26561
26837
  // ../../packages/plugin-runtime/src/attached/atomic-publish.ts
26562
26838
  import { rename as rename2 } from "fs/promises";
@@ -26566,7 +26842,7 @@ var ATTEMPTS = 1 + IMMEDIATE_RETRIES + TIMED_RETRIES;
26566
26842
 
26567
26843
  // ../../packages/plugin-runtime/src/attached/posture-report-state.ts
26568
26844
  import { readFileSync as readFileSync20 } from "fs";
26569
- import { join as join31 } from "path";
26845
+ import { join as join33 } from "path";
26570
26846
  var OUTCOME_KEYS = {
26571
26847
  ok: true,
26572
26848
  unauthorized: true,
@@ -26587,13 +26863,13 @@ import { statSync as statSync9 } from "fs";
26587
26863
  import { DatabaseSync as DatabaseSync4 } from "node:sqlite";
26588
26864
 
26589
26865
  // ../../packages/plugin-runtime/src/attached/posture-store.ts
26590
- import { randomUUID as randomUUID17 } from "crypto";
26591
- import { readFile as readFile3, rm as rm2, writeFile as writeFile3 } from "fs/promises";
26592
- import { join as join32 } from "path";
26866
+ import { randomUUID as randomUUID18 } from "crypto";
26867
+ import { readFile as readFile4, rm as rm2, writeFile as writeFile3 } from "fs/promises";
26868
+ import { join as join34 } from "path";
26593
26869
 
26594
26870
  // ../../packages/plugin-runtime/src/attached/sync-state.ts
26595
26871
  import { readFileSync as readFileSync21 } from "fs";
26596
- import { join as join33 } from "path";
26872
+ import { join as join35 } from "path";
26597
26873
 
26598
26874
  // ../../packages/plugin-runtime/src/attached/status.ts
26599
26875
  var REFUSAL_LINES = {
@@ -26625,9 +26901,6 @@ var CONTENT_RETENTION_THROTTLE_MS = 60 * 60 * 1e3;
26625
26901
  // ../../packages/plugin-runtime/src/attached/factory.ts
26626
26902
  import { hostname as hostname6 } from "os";
26627
26903
 
26628
- // ../../packages/plugin-runtime/src/standalone-gateway.ts
26629
- import { randomUUID as randomUUID18 } from "crypto";
26630
-
26631
26904
  // ../../packages/plugin-runtime/src/handle-session-start.ts
26632
26905
  import { randomUUID as randomUUID19 } from "crypto";
26633
26906
  var EXCEPTION_RETENTION_MS = 90 * 24 * 60 * 60 * 1e3;
@@ -26635,12 +26908,12 @@ var EXCEPTION_RETENTION_MS = 90 * 24 * 60 * 60 * 1e3;
26635
26908
  // src/hooks/store-health.ts
26636
26909
  var STORE_REDIRECT_MARKER = "store-redirect-last-session";
26637
26910
  function markerDirs(dataDir2) {
26638
- return [dataDir2, dirname7(dataDir2)];
26911
+ return [dataDir2, dirname9(dataDir2)];
26639
26912
  }
26640
26913
  function alreadyClaimed(dirs, marker, sessionId) {
26641
26914
  return dirs.some((dir) => {
26642
26915
  try {
26643
- return readFileSync22(join34(dir, marker), "utf8") === sessionId;
26916
+ return readFileSync22(join36(dir, marker), "utf8") === sessionId;
26644
26917
  } catch {
26645
26918
  return false;
26646
26919
  }
@@ -26650,7 +26923,7 @@ function recordClaim(dirs, marker, sessionId) {
26650
26923
  for (const dir of dirs) {
26651
26924
  try {
26652
26925
  mkdirSync6(dir, { recursive: true, mode: DATA_DIR_MODE });
26653
- writeFileSync9(join34(dir, marker), sessionId, { mode: DATA_FILE_MODE });
26926
+ writeFileSync9(join36(dir, marker), sessionId, { mode: DATA_FILE_MODE });
26654
26927
  return;
26655
26928
  } catch {
26656
26929
  }
@@ -26675,7 +26948,7 @@ function formatMode(mode) {
26675
26948
  }
26676
26949
  function warnIfStoreRedirected(config2, sessionId, write = (message) => void process.stderr.write(message)) {
26677
26950
  try {
26678
- const paths = symlinkedStorePaths(dirname7(config2.dataDir));
26951
+ const paths = symlinkedStorePaths(dirname9(config2.dataDir));
26679
26952
  if (paths.length === 0) return;
26680
26953
  if (!sessionId) {
26681
26954
  write(storeRedirectedMessage(paths));
@@ -26705,5 +26978,6 @@ async function main() {
26705
26978
  try {
26706
26979
  await main();
26707
26980
  } catch {
26981
+ countFailOpen();
26708
26982
  }
26709
26983
  process.exit(0);