@akasecurity/ai-tc-claude-code 0.9.5 → 0.9.7

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.
@@ -579,6 +579,40 @@ function escapeRegExp2(value) {
579
579
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
580
580
  }
581
581
 
582
+ // ../../packages/detections/src/regex-cache.ts
583
+ var singles = /* @__PURE__ */ new WeakMap();
584
+ var keywordLists = /* @__PURE__ */ new WeakMap();
585
+ var labelLists = /* @__PURE__ */ new WeakMap();
586
+ function listCache(kind) {
587
+ return kind === "keyword" ? keywordLists : labelLists;
588
+ }
589
+ function memoizedRegExp(owner, build) {
590
+ const cached2 = singles.get(owner);
591
+ if (cached2 !== void 0) {
592
+ cached2.lastIndex = 0;
593
+ return cached2;
594
+ }
595
+ const compiled = build();
596
+ singles.set(owner, compiled);
597
+ return compiled;
598
+ }
599
+ function memoizedRegExpList(kind, owner, build) {
600
+ const cache = listCache(kind);
601
+ const cached2 = cache.get(owner);
602
+ if (cached2 !== void 0) {
603
+ if (cached2.stateful) {
604
+ for (const re of cached2.entries) if (re !== void 0) re.lastIndex = 0;
605
+ }
606
+ return cached2.entries;
607
+ }
608
+ const entries = build();
609
+ cache.set(owner, {
610
+ entries,
611
+ stateful: entries.some((re) => re !== void 0 && (re.global || re.sticky))
612
+ });
613
+ return entries;
614
+ }
615
+
582
616
  // ../../packages/detections/src/matchers/limits.ts
583
617
  var MAX_MATCHES_PER_RULE = 1e4;
584
618
  var MAX_REGEX_INPUT_LENGTH = 2e5;
@@ -589,10 +623,17 @@ var KeywordMatcher = class {
589
623
  if (rule.matcher.type !== "keyword") return [];
590
624
  const { keywords, caseSensitive } = rule.matcher;
591
625
  const spans = [];
592
- for (const kw of keywords) {
593
- if (kw.length === 0) continue;
626
+ const compiled = memoizedRegExpList(
627
+ "keyword",
628
+ rule.matcher,
629
+ () => keywords.map((kw) => {
630
+ if (kw.length === 0) return void 0;
631
+ return new RegExp(escapeRegExp2(kw), caseSensitive ? "gu" : "giu");
632
+ })
633
+ );
634
+ for (const re of compiled) {
635
+ if (re === void 0) continue;
594
636
  if (spans.length >= MAX_MATCHES_PER_RULE) break;
595
- const re = new RegExp(escapeRegExp2(kw), caseSensitive ? "gu" : "giu");
596
637
  let m;
597
638
  while ((m = re.exec(text)) !== null) {
598
639
  spans.push({ start: m.index, end: m.index + m[0].length });
@@ -608,7 +649,10 @@ var RegexMatcher = class {
608
649
  match(text, rule) {
609
650
  if (rule.matcher.type !== "regex") return [];
610
651
  const { pattern, flags, captureGroup } = rule.matcher;
611
- const re = new RegExp(pattern, flags.includes("d") ? flags : `${flags}d`);
652
+ const re = memoizedRegExp(
653
+ rule.matcher,
654
+ () => new RegExp(pattern, flags.includes("d") ? flags : `${flags}d`)
655
+ );
612
656
  const scanText = text.length > MAX_REGEX_INPUT_LENGTH ? text.slice(0, MAX_REGEX_INPUT_LENGTH) : text;
613
657
  const spans = [];
614
658
  let m;
@@ -667,6 +711,10 @@ function luhnCheck(digits) {
667
711
  // ../../packages/detections/src/engine.ts
668
712
  var keywordMatcher = new KeywordMatcher();
669
713
  var regexMatcher = new RegexMatcher();
714
+ var MATCHERS = {
715
+ keyword: (text, rule) => keywordMatcher.match(text, rule),
716
+ regex: (text, rule) => regexMatcher.match(text, rule)
717
+ };
670
718
  var packs = /* @__PURE__ */ new Map();
671
719
  var POST_VALIDATORS = {
672
720
  entropy: (value, config2) => isHighEntropy(value, numberOption(config2, "threshold"), numberOption(config2, "minLength")),
@@ -682,8 +730,7 @@ function passesPostValidators(rule, value) {
682
730
  for (const ref of validators) {
683
731
  const name = typeof ref === "string" ? ref : ref.name;
684
732
  const config2 = typeof ref === "string" ? void 0 : ref.config;
685
- const validate = POST_VALIDATORS[name];
686
- if (validate && !validate(value, config2)) return false;
733
+ if (!POST_VALIDATORS[name](value, config2)) return false;
687
734
  }
688
735
  return true;
689
736
  }
@@ -713,11 +760,15 @@ function isCorroborated(candidate, candidates, text) {
713
760
  const labels = req.labels;
714
761
  if (labels && labels.length > 0) {
715
762
  const haystack = text.slice(Math.max(0, winStart), winEnd);
716
- for (const label of labels) {
717
- const trimmed = label.trim();
718
- if (trimmed.length === 0) continue;
719
- const re = new RegExp(`(?<![A-Za-z0-9])${escapeRegExp2(trimmed)}(?![A-Za-z0-9])`, "i");
720
- if (re.test(haystack)) return true;
763
+ for (const re of memoizedRegExpList(
764
+ "label",
765
+ req,
766
+ () => labels.map((label) => {
767
+ const trimmed = label.trim();
768
+ return trimmed.length === 0 ? void 0 : new RegExp(`(?<![A-Za-z0-9])${escapeRegExp2(trimmed)}(?![A-Za-z0-9])`, "i");
769
+ })
770
+ )) {
771
+ if (re?.test(haystack)) return true;
721
772
  }
722
773
  }
723
774
  return false;
@@ -737,14 +788,7 @@ function scan(text, rules, context) {
737
788
  const candidates = [];
738
789
  for (const rule of ruleset2) {
739
790
  if (!ruleApplies(rule, extension)) continue;
740
- let spans;
741
- if (rule.matcher.type === "keyword") {
742
- spans = keywordMatcher.match(text, rule);
743
- } else if (rule.matcher.type === "regex") {
744
- spans = regexMatcher.match(text, rule);
745
- } else {
746
- continue;
747
- }
791
+ const spans = MATCHERS[rule.matcher.type](text, rule);
748
792
  for (const span of spans) {
749
793
  const rawMatch = text.slice(span.start, span.end);
750
794
  if (!passesPostValidators(rule, rawMatch)) continue;
@@ -1339,7 +1383,7 @@ __export(core_exports2, {
1339
1383
  parse: () => parse,
1340
1384
  parseAsync: () => parseAsync,
1341
1385
  prettifyError: () => prettifyError,
1342
- process: () => process,
1386
+ process: () => process2,
1343
1387
  regexes: () => regexes_exports,
1344
1388
  registry: () => registry,
1345
1389
  safeDecode: () => safeDecode,
@@ -12264,7 +12308,7 @@ function initializeContext(params) {
12264
12308
  external: params?.external ?? void 0
12265
12309
  };
12266
12310
  }
12267
- function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
12311
+ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
12268
12312
  var _a3;
12269
12313
  const def = schema._zod.def;
12270
12314
  const seen = ctx.seen.get(schema);
@@ -12301,7 +12345,7 @@ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
12301
12345
  if (parent) {
12302
12346
  if (!result.ref)
12303
12347
  result.ref = parent;
12304
- process(parent, ctx, params);
12348
+ process2(parent, ctx, params);
12305
12349
  ctx.seen.get(parent).isParent = true;
12306
12350
  }
12307
12351
  }
@@ -12589,14 +12633,14 @@ function isTransforming(_schema, _ctx) {
12589
12633
  }
12590
12634
  var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
12591
12635
  const ctx = initializeContext({ ...params, processors });
12592
- process(schema, ctx);
12636
+ process2(schema, ctx);
12593
12637
  extractDefs(ctx, schema);
12594
12638
  return finalize(ctx, schema);
12595
12639
  };
12596
12640
  var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
12597
12641
  const { libraryOptions, target } = params ?? {};
12598
12642
  const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
12599
- process(schema, ctx);
12643
+ process2(schema, ctx);
12600
12644
  extractDefs(ctx, schema);
12601
12645
  return finalize(ctx, schema);
12602
12646
  };
@@ -12842,7 +12886,7 @@ var arrayProcessor = (schema, ctx, _json, params) => {
12842
12886
  if (typeof maximum === "number")
12843
12887
  json2.maxItems = maximum;
12844
12888
  json2.type = "array";
12845
- json2.items = process(def.element, ctx, {
12889
+ json2.items = process2(def.element, ctx, {
12846
12890
  ...params,
12847
12891
  path: [...params.path, "items"]
12848
12892
  });
@@ -12854,7 +12898,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
12854
12898
  json2.properties = {};
12855
12899
  const shape = def.shape;
12856
12900
  for (const key in shape) {
12857
- json2.properties[key] = process(shape[key], ctx, {
12901
+ json2.properties[key] = process2(shape[key], ctx, {
12858
12902
  ...params,
12859
12903
  path: [...params.path, "properties", key]
12860
12904
  });
@@ -12877,7 +12921,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
12877
12921
  if (ctx.io === "output")
12878
12922
  json2.additionalProperties = false;
12879
12923
  } else if (def.catchall) {
12880
- json2.additionalProperties = process(def.catchall, ctx, {
12924
+ json2.additionalProperties = process2(def.catchall, ctx, {
12881
12925
  ...params,
12882
12926
  path: [...params.path, "additionalProperties"]
12883
12927
  });
@@ -12886,7 +12930,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
12886
12930
  var unionProcessor = (schema, ctx, json2, params) => {
12887
12931
  const def = schema._zod.def;
12888
12932
  const isExclusive = def.inclusive === false;
12889
- const options = def.options.map((x, i) => process(x, ctx, {
12933
+ const options = def.options.map((x, i) => process2(x, ctx, {
12890
12934
  ...params,
12891
12935
  path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
12892
12936
  }));
@@ -12898,11 +12942,11 @@ var unionProcessor = (schema, ctx, json2, params) => {
12898
12942
  };
12899
12943
  var intersectionProcessor = (schema, ctx, json2, params) => {
12900
12944
  const def = schema._zod.def;
12901
- const a = process(def.left, ctx, {
12945
+ const a = process2(def.left, ctx, {
12902
12946
  ...params,
12903
12947
  path: [...params.path, "allOf", 0]
12904
12948
  });
12905
- const b = process(def.right, ctx, {
12949
+ const b = process2(def.right, ctx, {
12906
12950
  ...params,
12907
12951
  path: [...params.path, "allOf", 1]
12908
12952
  });
@@ -12919,11 +12963,11 @@ var tupleProcessor = (schema, ctx, _json, params) => {
12919
12963
  json2.type = "array";
12920
12964
  const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
12921
12965
  const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
12922
- const prefixItems = def.items.map((x, i) => process(x, ctx, {
12966
+ const prefixItems = def.items.map((x, i) => process2(x, ctx, {
12923
12967
  ...params,
12924
12968
  path: [...params.path, prefixPath, i]
12925
12969
  }));
12926
- const rest = def.rest ? process(def.rest, ctx, {
12970
+ const rest = def.rest ? process2(def.rest, ctx, {
12927
12971
  ...params,
12928
12972
  path: [...params.path, restPath, ...ctx.target === "openapi-3.0" ? [def.items.length] : []]
12929
12973
  }) : null;
@@ -12963,7 +13007,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
12963
13007
  const keyBag = keyType._zod.bag;
12964
13008
  const patterns = keyBag?.patterns;
12965
13009
  if (def.mode === "loose" && patterns && patterns.size > 0) {
12966
- const valueSchema = process(def.valueType, ctx, {
13010
+ const valueSchema = process2(def.valueType, ctx, {
12967
13011
  ...params,
12968
13012
  path: [...params.path, "patternProperties", "*"]
12969
13013
  });
@@ -12973,12 +13017,12 @@ var recordProcessor = (schema, ctx, _json, params) => {
12973
13017
  }
12974
13018
  } else {
12975
13019
  if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
12976
- json2.propertyNames = process(def.keyType, ctx, {
13020
+ json2.propertyNames = process2(def.keyType, ctx, {
12977
13021
  ...params,
12978
13022
  path: [...params.path, "propertyNames"]
12979
13023
  });
12980
13024
  }
12981
- json2.additionalProperties = process(def.valueType, ctx, {
13025
+ json2.additionalProperties = process2(def.valueType, ctx, {
12982
13026
  ...params,
12983
13027
  path: [...params.path, "additionalProperties"]
12984
13028
  });
@@ -12993,7 +13037,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
12993
13037
  };
12994
13038
  var nullableProcessor = (schema, ctx, json2, params) => {
12995
13039
  const def = schema._zod.def;
12996
- const inner = process(def.innerType, ctx, params);
13040
+ const inner = process2(def.innerType, ctx, params);
12997
13041
  const seen = ctx.seen.get(schema);
12998
13042
  if (ctx.target === "openapi-3.0") {
12999
13043
  seen.ref = def.innerType;
@@ -13004,20 +13048,20 @@ var nullableProcessor = (schema, ctx, json2, params) => {
13004
13048
  };
13005
13049
  var nonoptionalProcessor = (schema, ctx, _json, params) => {
13006
13050
  const def = schema._zod.def;
13007
- process(def.innerType, ctx, params);
13051
+ process2(def.innerType, ctx, params);
13008
13052
  const seen = ctx.seen.get(schema);
13009
13053
  seen.ref = def.innerType;
13010
13054
  };
13011
13055
  var defaultProcessor = (schema, ctx, json2, params) => {
13012
13056
  const def = schema._zod.def;
13013
- process(def.innerType, ctx, params);
13057
+ process2(def.innerType, ctx, params);
13014
13058
  const seen = ctx.seen.get(schema);
13015
13059
  seen.ref = def.innerType;
13016
13060
  json2.default = JSON.parse(JSON.stringify(def.defaultValue));
13017
13061
  };
13018
13062
  var prefaultProcessor = (schema, ctx, json2, params) => {
13019
13063
  const def = schema._zod.def;
13020
- process(def.innerType, ctx, params);
13064
+ process2(def.innerType, ctx, params);
13021
13065
  const seen = ctx.seen.get(schema);
13022
13066
  seen.ref = def.innerType;
13023
13067
  if (ctx.io === "input")
@@ -13025,7 +13069,7 @@ var prefaultProcessor = (schema, ctx, json2, params) => {
13025
13069
  };
13026
13070
  var catchProcessor = (schema, ctx, json2, params) => {
13027
13071
  const def = schema._zod.def;
13028
- process(def.innerType, ctx, params);
13072
+ process2(def.innerType, ctx, params);
13029
13073
  const seen = ctx.seen.get(schema);
13030
13074
  seen.ref = def.innerType;
13031
13075
  let catchValue;
@@ -13040,32 +13084,32 @@ var pipeProcessor = (schema, ctx, _json, params) => {
13040
13084
  const def = schema._zod.def;
13041
13085
  const inIsTransform = def.in._zod.traits.has("$ZodTransform");
13042
13086
  const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
13043
- process(innerType, ctx, params);
13087
+ process2(innerType, ctx, params);
13044
13088
  const seen = ctx.seen.get(schema);
13045
13089
  seen.ref = innerType;
13046
13090
  };
13047
13091
  var readonlyProcessor = (schema, ctx, json2, params) => {
13048
13092
  const def = schema._zod.def;
13049
- process(def.innerType, ctx, params);
13093
+ process2(def.innerType, ctx, params);
13050
13094
  const seen = ctx.seen.get(schema);
13051
13095
  seen.ref = def.innerType;
13052
13096
  json2.readOnly = true;
13053
13097
  };
13054
13098
  var promiseProcessor = (schema, ctx, _json, params) => {
13055
13099
  const def = schema._zod.def;
13056
- process(def.innerType, ctx, params);
13100
+ process2(def.innerType, ctx, params);
13057
13101
  const seen = ctx.seen.get(schema);
13058
13102
  seen.ref = def.innerType;
13059
13103
  };
13060
13104
  var optionalProcessor = (schema, ctx, _json, params) => {
13061
13105
  const def = schema._zod.def;
13062
- process(def.innerType, ctx, params);
13106
+ process2(def.innerType, ctx, params);
13063
13107
  const seen = ctx.seen.get(schema);
13064
13108
  seen.ref = def.innerType;
13065
13109
  };
13066
13110
  var lazyProcessor = (schema, ctx, _json, params) => {
13067
13111
  const innerType = schema._zod.innerType;
13068
- process(innerType, ctx, params);
13112
+ process2(innerType, ctx, params);
13069
13113
  const seen = ctx.seen.get(schema);
13070
13114
  seen.ref = innerType;
13071
13115
  };
@@ -13117,7 +13161,7 @@ function toJSONSchema(input, params) {
13117
13161
  const defs = {};
13118
13162
  for (const entry of registry2._idmap.entries()) {
13119
13163
  const [_, schema] = entry;
13120
- process(schema, ctx2);
13164
+ process2(schema, ctx2);
13121
13165
  }
13122
13166
  const schemas = {};
13123
13167
  const external = {
@@ -13140,7 +13184,7 @@ function toJSONSchema(input, params) {
13140
13184
  return { schemas };
13141
13185
  }
13142
13186
  const ctx = initializeContext({ ...params, processors: allProcessors });
13143
- process(input, ctx);
13187
+ process2(input, ctx);
13144
13188
  extractDefs(ctx, input);
13145
13189
  return finalize(ctx, input);
13146
13190
  }
@@ -13198,7 +13242,7 @@ var JSONSchemaGenerator = class {
13198
13242
  * This must be called before emit().
13199
13243
  */
13200
13244
  process(schema, _params = { path: [], schemaPath: [] }) {
13201
- return process(schema, this.ctx, _params);
13245
+ return process2(schema, this.ctx, _params);
13202
13246
  }
13203
13247
  /**
13204
13248
  * Emit the final JSON Schema after processing.
@@ -15347,6 +15391,47 @@ function date4(params) {
15347
15391
  // ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
15348
15392
  config(en_default());
15349
15393
 
15394
+ // ../../packages/schema/src/zod/harness-map.ts
15395
+ var HARNESS = {
15396
+ ClaudeCode: "claudecode",
15397
+ Cursor: "cursor",
15398
+ Copilot: "copilot",
15399
+ Codex: "codex",
15400
+ Antigravity: "antigravity",
15401
+ Windsurf: "windsurf",
15402
+ ClaudeDesktop: "claudedesktop",
15403
+ ChatGpt: "chatgpt",
15404
+ ClaudeAi: "claudeai",
15405
+ Api: "api"
15406
+ };
15407
+ var Harness = external_exports.enum(HARNESS).meta({ id: "Harness" });
15408
+ var SOURCE_TOOL = {
15409
+ ClaudeCode: "claude-code",
15410
+ ClaudeDesktop: "claude-desktop",
15411
+ Cursor: "cursor",
15412
+ ChatGpt: "chatgpt",
15413
+ ClaudeAi: "claude-ai",
15414
+ Copilot: "github-copilot",
15415
+ Codex: "codex",
15416
+ Antigravity: "antigravity",
15417
+ // No harness counterpart, deliberately: the CLI's own captures and a capture
15418
+ // whose tool could not be identified both render through the read side's
15419
+ // miss path rather than as a harness of their own.
15420
+ Cli: "cli",
15421
+ Unknown: "unknown"
15422
+ };
15423
+ var SourceTool = external_exports.enum(SOURCE_TOOL).meta({ id: "SourceTool" });
15424
+ var TOOL_TO_HARNESS = {
15425
+ [SOURCE_TOOL.ClaudeCode]: HARNESS.ClaudeCode,
15426
+ [SOURCE_TOOL.ClaudeDesktop]: HARNESS.ClaudeDesktop,
15427
+ [SOURCE_TOOL.Copilot]: HARNESS.Copilot,
15428
+ [SOURCE_TOOL.Cursor]: HARNESS.Cursor,
15429
+ [SOURCE_TOOL.ChatGpt]: HARNESS.ChatGpt,
15430
+ [SOURCE_TOOL.Codex]: HARNESS.Codex,
15431
+ [SOURCE_TOOL.Antigravity]: HARNESS.Antigravity,
15432
+ [SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi
15433
+ };
15434
+
15350
15435
  // ../../packages/schema/src/zod/finding.ts
15351
15436
  var DetectionCategory = external_exports.enum(["pii", "financial", "secret", "phi", "code_context", "code_flaw", "custom", "config"]).meta({ id: "DetectionCategory" });
15352
15437
  var Severity = external_exports.enum(["critical", "high", "medium", "low"]).meta({ id: "Severity" });
@@ -15369,21 +15454,22 @@ var Finding = external_exports.object({
15369
15454
  }).meta({ id: "Finding" });
15370
15455
  var DetectedFinding = Finding.meta({ id: "DetectedFinding" });
15371
15456
  var FindingAction = external_exports.enum(["blocked", "redacted", "warned", "allowed", "quarantined", "monitored"]).meta({ id: "FindingAction" });
15372
- var FindingProvider = external_exports.enum([
15373
- "claudecode",
15374
- "claudedesktop",
15375
- "cursor",
15376
- "copilot",
15377
- "chatgpt",
15378
- "claudeai",
15379
- "codex",
15380
- "antigravity",
15381
- "api"
15457
+ var FindingProvider = Harness.extract([
15458
+ "ClaudeCode",
15459
+ "ClaudeDesktop",
15460
+ "Cursor",
15461
+ "Copilot",
15462
+ "ChatGpt",
15463
+ "ClaudeAi",
15464
+ "Codex",
15465
+ "Antigravity",
15466
+ "Api"
15382
15467
  ]).meta({ id: "FindingProvider" });
15383
15468
  var FindingCategory = external_exports.enum([
15384
15469
  "secret",
15385
15470
  "pii",
15386
15471
  "source_code",
15472
+ "code_flaw",
15387
15473
  "external_share",
15388
15474
  "mcp_server",
15389
15475
  "customer_data",
@@ -15561,6 +15647,7 @@ var FindingInstanceDetail = FindingInstance.extend({
15561
15647
  detection: FindingDetectionRef,
15562
15648
  policy: FindingPolicyRef
15563
15649
  }).meta({ id: "FindingInstanceDetail" });
15650
+ var MAX_FLAT_FINDINGS_LIMIT = 200;
15564
15651
  var ListFindingInstancesQuery = external_exports.object({
15565
15652
  severity: external_exports.array(Severity).optional(),
15566
15653
  // Rule ids, the same vocabulary the grouped list's `subtype` carries.
@@ -15580,7 +15667,7 @@ var ListFindingInstancesQuery = external_exports.object({
15580
15667
  q: external_exports.string().optional(),
15581
15668
  sessionId: external_exports.string().optional(),
15582
15669
  from: external_exports.iso.datetime().optional(),
15583
- limit: external_exports.coerce.number().int().min(1).max(200).optional(),
15670
+ limit: external_exports.coerce.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
15584
15671
  cursor: external_exports.string().optional()
15585
15672
  });
15586
15673
  var ListFindingInstancesResponse = external_exports.object({
@@ -15642,20 +15729,6 @@ var ListFindingLocationsResponse = external_exports.object({
15642
15729
  hasMore: external_exports.boolean()
15643
15730
  }).meta({ id: "ListFindingLocationsResponse" });
15644
15731
 
15645
- // ../../packages/schema/src/zod/harness-map.ts
15646
- var Harness = external_exports.enum([
15647
- "claudecode",
15648
- "cursor",
15649
- "copilot",
15650
- "codex",
15651
- "antigravity",
15652
- "windsurf",
15653
- "claudedesktop",
15654
- "chatgpt",
15655
- "claudeai",
15656
- "api"
15657
- ]).meta({ id: "Harness" });
15658
-
15659
15732
  // ../../packages/schema/src/zod/meta.ts
15660
15733
  var InventoryObjectType = external_exports.enum(["host", "harness", "user", "skill", "hook", "mcp_server", "config_file"]).meta({ id: "InventoryObjectType" });
15661
15734
  var AuditEventType = external_exports.enum([
@@ -16105,366 +16178,122 @@ var ActivityOverviewResponse = external_exports.object({
16105
16178
  sessions: ListActivitySessionsResponse
16106
16179
  }).meta({ id: "ActivityOverviewResponse" });
16107
16180
 
16108
- // ../../packages/schema/src/zod/event.ts
16109
- var EventKind = external_exports.enum(["prompt", "response", "code_change", "tool_use"]).meta({ id: "EventKind" });
16110
- var CAPTURE_EVENT_TYPES_SQL = EventKind.options.map((k) => `'${k}'`).join(",");
16111
- var SourceTool = external_exports.enum([
16112
- "claude-code",
16113
- "claude-desktop",
16114
- "cursor",
16115
- "chatgpt",
16116
- "claude-ai",
16117
- "github-copilot",
16118
- "codex",
16119
- "antigravity",
16120
- "cli",
16121
- "unknown"
16122
- ]).meta({ id: "SourceTool" });
16123
- var EventMetadata = external_exports.object({
16124
- sessionId: external_exports.string().optional(),
16125
- repo: external_exports.string().optional(),
16126
- filePath: external_exports.string().optional(),
16127
- // The host tool whose input/output was scanned (e.g. 'Bash', 'WebFetch'),
16128
- // set by the tool-scanning hooks. The tool NAME only — never the tool's
16129
- // arguments or output, which can carry the very value a finding masked
16130
- // (metadata is stored unredacted). Gives findings on non-file captures a
16131
- // display location ("via Bash") when no filePath exists.
16132
- toolName: external_exports.string().optional(),
16133
- // Set (true) by the worktree scanner when the file is excluded by the
16134
- // repo's .gitignore. Gitignored files ARE still scanned — local scratch and
16135
- // generated code can leak real secrets — but the provenance is recorded so
16136
- // policy/dashboards can treat those findings as informational rather than
16137
- // blocking. Omitted (not false) for tracked files and non-scan events.
16138
- gitignored: external_exports.boolean().optional(),
16139
- // Set (true) ONLY when the event's `content` is the COMPLETE file at
16140
- // capture time (a worktree scan reading from disk). Hook-captured edits
16141
- // (e.g. an Edit tool's new_string) are partial fragments and MUST NOT set
16142
- // this. The resolver-on-ingest keys its fixed-at-source dropout
16143
- // diff on this marker: only a whole-file snapshot can prove a previously
16144
- // open finding is gone; a fragment's absence proves nothing (the secret
16145
- // may live outside the hunk). Omitted (not false) for fragments and
16146
- // non-scan events, so pre-marker clients safely default to the
16147
- // non-authoritative path.
16148
- wholeFile: external_exports.boolean().optional(),
16149
- model: external_exports.string().optional(),
16150
- turnIndex: external_exports.number().int().nonnegative().optional(),
16151
- // Distributed-tracing correlation. `correlationId` ties a recorded event back
16152
- // to the request that captured/ingested it (a UUID, generated independently of
16153
- // the trace id); `traceId` is the W3C trace id (32 lowercase hex chars) of the
16154
- // originating span when telemetry is enabled. Both optional + backward
16155
- // compatible — populated by the plugin (see @akasecurity/plugin-sdk).
16156
- correlationId: external_exports.uuid().optional(),
16157
- traceId: external_exports.string().regex(/^[0-9a-f]{32}$/).optional(),
16158
- // Ids of the detection exceptions that downgraded findings in this capture
16159
- // to 'allow' — the enforcement audit trail's link back to the grant that
16160
- // authorized the bypass. Absent on captures where no exception applied.
16161
- exceptionIds: external_exports.array(external_exports.guid()).optional()
16162
- }).meta({ id: "EventMetadata" });
16163
- var Event = external_exports.object({
16164
- id: external_exports.guid(),
16165
- sourceTool: SourceTool,
16166
- kind: EventKind,
16167
- occurredAt: external_exports.iso.datetime(),
16168
- contentHash: external_exports.string(),
16169
- content: external_exports.string(),
16170
- metadata: EventMetadata.optional()
16171
- }).meta({ id: "Event" });
16172
- var IngestEvent = Event.meta({ id: "IngestEvent" });
16173
- var IngestBatch = external_exports.object({
16174
- events: external_exports.array(IngestEvent).min(1).max(100),
16175
- // Dedup policy for this batch. Id-dedup ALWAYS applies. 'content-hash'
16176
- // additionally rejects any event whose contentHash the store has already
16177
- // recorded — for re-runnable bulk ingest (worktree scan, transcript
16178
- // backfill), where a re-run mints fresh event ids for identical content and
16179
- // would otherwise accumulate duplicates. Live hook traffic must NOT set it:
16180
- // two genuinely separate prompts can be byte-identical and both belong on
16181
- // the timeline.
16182
- dedupe: external_exports.literal("content-hash").optional()
16183
- }).meta({ id: "IngestBatch" });
16184
-
16185
- // ../../packages/schema/src/zod/inventory.ts
16186
- var AssetType = external_exports.enum(["project", "skill", "mcp", "hook", "config"]).meta({ id: "AssetType" });
16187
- var AccessLevel = external_exports.enum(["open", "approved", "blocked"]).meta({ id: "AccessLevel" });
16188
- var Origin = external_exports.enum(["source", "public-dep", "vendored", "config", "data", "docs", "generated"]).meta({ id: "Origin" });
16189
- var TrustLevel = external_exports.enum(["known-good", "risky", "unapproved"]).meta({ id: "TrustLevel" });
16190
- var Flag = external_exports.enum(["update", "stale", "conflict", "unknown", "change", "untracked", "risk", "findings"]).meta({ id: "Flag" });
16191
- var Visibility = external_exports.enum(["public", "private"]).meta({ id: "Visibility" });
16192
- var HarnessEventKind = external_exports.enum(["block", "redact", "warn"]).meta({ id: "HarnessEventKind" });
16193
- var HarnessId = external_exports.enum(["claudecode", "cursor", "codex", "antigravity"]).meta({ id: "HarnessId" });
16194
- var AccessCounts = external_exports.object({
16195
- open: external_exports.number().int().nonnegative(),
16196
- approved: external_exports.number().int().nonnegative(),
16197
- blocked: external_exports.number().int().nonnegative(),
16198
- total: external_exports.number().int().nonnegative()
16199
- }).meta({ id: "AccessCounts" });
16200
- var AssetSummary = external_exports.object({
16201
- id: external_exports.string(),
16202
- type: AssetType,
16203
- name: external_exports.string(),
16204
- sub: external_exports.string(),
16205
- flags: external_exports.array(Flag),
16206
- /** MCP servers only — omitted for all other types. */
16207
- trust: TrustLevel.optional()
16208
- }).meta({ id: "AssetSummary" });
16209
- var ProjectSummary = external_exports.object({
16210
- id: external_exports.string(),
16211
- name: external_exports.string(),
16212
- repo: external_exports.string(),
16213
- visibility: Visibility,
16214
- language: external_exports.string(),
16215
- policyDefault: AccessLevel,
16216
- updatedAt: external_exports.iso.datetime(),
16217
- accessCounts: AccessCounts,
16218
- findingsCount: external_exports.number().int().nonnegative()
16219
- }).meta({ id: "ProjectSummary" });
16220
- var HarnessCategory = external_exports.object({
16221
- /** One of config/skill/mcp/hook — never project (enforced at service layer). */
16222
- type: AssetType,
16223
- assets: external_exports.array(AssetSummary)
16181
+ // ../../packages/schema/src/zod/config-inventory.ts
16182
+ var ConfigScope = external_exports.enum(["user", "project", "local", "plugin"]);
16183
+ var SkillScanEntry = external_exports.object({
16184
+ name: external_exports.string().min(1),
16185
+ // The identity source: a marketplace repo for plugin skills (e.g.
16186
+ // 'anthropics/skills'), 'local' for personal ~/.claude/skills, or
16187
+ // 'project:<repo-identity>' for checked-in project skills. The surrogate keeps
16188
+ // a personal skill named 'pdf' from colliding with the marketplace 'pdf'.
16189
+ source: external_exports.string().min(1),
16190
+ scope: ConfigScope,
16191
+ pluginName: external_exports.string().optional(),
16192
+ // Volatile — rides the attribute bag, never the identity hash.
16193
+ version: external_exports.string().optional(),
16194
+ description: external_exports.string().optional(),
16195
+ // Skill directory mtime (ISO) the "updated Nd ago" freshness signal.
16196
+ updatedAt: external_exports.iso.datetime().optional(),
16197
+ // Filesystem path — the promoted inventory `location` column.
16198
+ location: external_exports.string().optional()
16224
16199
  });
16225
- var HarnessSummary = external_exports.object({
16226
- id: HarnessId,
16227
- label: external_exports.string(),
16228
- kind: external_exports.string(),
16229
- version: external_exports.string(),
16230
- sessions: external_exports.number().int().nonnegative(),
16231
- assetCount: external_exports.number().int().nonnegative(),
16232
- flagCount: external_exports.number().int().nonnegative(),
16233
- projects: external_exports.array(ProjectSummary),
16234
- categories: external_exports.array(HarnessCategory)
16235
- }).meta({ id: "HarnessSummary" });
16236
- var ListHarnessesResponse = external_exports.object({ items: external_exports.array(HarnessSummary) }).meta({ id: "ListHarnessesResponse" });
16237
- var AssetGroup = external_exports.object({
16238
- /** Group key — never project (enforced at service layer). */
16239
- type: AssetType,
16240
- total: external_exports.number().int().nonnegative(),
16241
- /**
16242
- * MCP group only — omitted for all other types.
16243
- * Partial: only TrustLevel keys with non-zero counts are included.
16244
- * Strict: unknown keys are rejected — only TrustLevel values are valid keys.
16245
- */
16246
- trustRollup: external_exports.object({
16247
- "known-good": external_exports.number().int().nonnegative(),
16248
- risky: external_exports.number().int().nonnegative(),
16249
- unapproved: external_exports.number().int().nonnegative()
16250
- }).partial().strict().optional(),
16251
- /**
16252
- * Partial: only Flag keys with non-zero counts are included.
16253
- * Strict: unknown keys are rejected — only Flag values are valid keys.
16254
- */
16255
- flagRollup: external_exports.object({
16256
- update: external_exports.number().int().nonnegative(),
16257
- stale: external_exports.number().int().nonnegative(),
16258
- conflict: external_exports.number().int().nonnegative(),
16259
- unknown: external_exports.number().int().nonnegative(),
16260
- change: external_exports.number().int().nonnegative(),
16261
- untracked: external_exports.number().int().nonnegative(),
16262
- risk: external_exports.number().int().nonnegative(),
16263
- findings: external_exports.number().int().nonnegative()
16264
- }).partial().strict(),
16265
- items: external_exports.array(AssetSummary)
16266
- }).meta({ id: "AssetGroup" });
16267
- var ListAssetsResponse = external_exports.object({ groups: external_exports.array(AssetGroup) }).meta({ id: "ListAssetsResponse" });
16268
- var McpTool = external_exports.object({
16269
- name: external_exports.string(),
16270
- signature: external_exports.string(),
16271
- description: external_exports.string(),
16272
- write: external_exports.boolean(),
16273
- /** Non-null string when tool is dangerous / blocked; null otherwise. */
16274
- risk: external_exports.string().nullable()
16275
- }).meta({ id: "McpTool" });
16276
- var AssetFindingRef = external_exports.object({
16277
- id: external_exports.string(),
16278
- title: external_exports.string(),
16279
- note: external_exports.string()
16200
+ var HookScanEntry = external_exports.object({
16201
+ // Hook event name (PreToolUse, PostToolUse, …). Open string, not an enum: the
16202
+ // set is harness-defined and grows without a schema change.
16203
+ event: external_exports.string().min(1),
16204
+ // The tool matcher ('Bash', 'Edit|Write', …). Absent = matches all tools.
16205
+ matcher: external_exports.string().optional(),
16206
+ command: external_exports.string().min(1),
16207
+ timeout: external_exports.number().optional(),
16208
+ scope: ConfigScope,
16209
+ pluginName: external_exports.string().optional(),
16210
+ // The settings file / hooks.json the entry came from.
16211
+ location: external_exports.string().optional()
16280
16212
  });
16281
- var AssetDetail = AssetSummary.extend({
16282
- /** string | null null when no description is available. */
16283
- description: external_exports.string().nullable(),
16284
- /** trustLevel | null — null for non-MCP assets. */
16285
- trust: TrustLevel.nullable(),
16286
- /** Type-specific raw key/values — FE renders the grid. */
16287
- meta: external_exports.record(external_exports.string(), external_exports.unknown()),
16288
- /** always present object when there is an active finding, null when absent. */
16289
- finding: AssetFindingRef.nullable(),
16290
- /** MCP exposed-tools list — omitted for non-mcp. */
16291
- tools: external_exports.array(McpTool).optional()
16292
- }).meta({ id: "AssetDetail" });
16293
- var ListProjectsResponse = external_exports.object({ items: external_exports.array(ProjectSummary) }).meta({ id: "ListProjectsResponse" });
16294
- var InventoryStats = external_exports.object({
16295
- /** Total assets/projects with ≥1 flag or finding (drives the attention header chip). */
16296
- attention: external_exports.number().int().nonnegative(),
16297
- byType: external_exports.object({
16298
- project: external_exports.number().int().nonnegative(),
16299
- skill: external_exports.number().int().nonnegative(),
16300
- mcp: external_exports.number().int().nonnegative(),
16301
- hook: external_exports.number().int().nonnegative(),
16302
- config: external_exports.number().int().nonnegative()
16303
- }),
16304
- harnesses: external_exports.number().int().nonnegative(),
16305
- mcpTrust: external_exports.object({
16306
- "known-good": external_exports.number().int().nonnegative(),
16307
- risky: external_exports.number().int().nonnegative(),
16308
- unapproved: external_exports.number().int().nonnegative()
16309
- })
16310
- }).meta({ id: "InventoryStats" });
16311
- var FileSummary = external_exports.object({
16312
- path: external_exports.string(),
16313
- name: external_exports.string(),
16314
- origin: Origin,
16315
- /** Effective access (override applied). */
16316
- access: AccessLevel,
16317
- /** True when a file_access_override differs from the computed default. */
16318
- isCustom: external_exports.boolean(),
16319
- findings: external_exports.number().int().nonnegative(),
16320
- /** When the file was auto-blocked by a detection; null when not blocked. */
16321
- blockedAt: external_exports.iso.datetime().nullable().optional(),
16322
- /** Why the file was blocked; null when absent. */
16323
- note: external_exports.string().nullable().optional()
16324
- }).meta({ id: "FileSummary" });
16325
- var FolderSummary = external_exports.object({
16326
- name: external_exports.string(),
16327
- path: external_exports.string(),
16328
- /** Rollup of effective access across all descendants. */
16329
- accessCounts: AccessCounts
16330
- }).meta({ id: "FolderSummary" });
16331
- var ProjectTreeResponse = external_exports.object({
16332
- project: external_exports.object({
16333
- id: external_exports.string(),
16334
- repo: external_exports.string(),
16335
- visibility: Visibility
16336
- }),
16337
- path: external_exports.string(),
16338
- /** Browse mode: one-level folders at the current path. Omitted in search mode. */
16339
- folders: external_exports.array(FolderSummary).optional(),
16340
- files: external_exports.array(FileSummary)
16341
- }).meta({ id: "ProjectTreeResponse" });
16342
- var FileDetail = FileSummary.extend({
16343
- project: external_exports.object({
16344
- repo: external_exports.string(),
16345
- visibility: Visibility,
16346
- language: external_exports.string(),
16347
- policyDefault: AccessLevel,
16348
- updatedAt: external_exports.iso.datetime()
16349
- }),
16350
- findingsRefs: external_exports.array(external_exports.object({ id: external_exports.string(), title: external_exports.string() }))
16351
- }).meta({ id: "FileDetail" });
16352
- var SetFileAccessBody = external_exports.object({
16353
- path: external_exports.string(),
16354
- access: AccessLevel
16355
- }).meta({ id: "SetFileAccessBody" });
16356
- var SetFileAccessResponse = external_exports.object({
16357
- file: FileSummary,
16358
- accessCounts: AccessCounts
16359
- }).meta({ id: "SetFileAccessResponse" });
16360
- var SetMcpTrustBody = external_exports.object({ trust: TrustLevel }).meta({ id: "SetMcpTrustBody" });
16361
- var HarnessEventItem = external_exports.object({
16362
- kind: HarnessEventKind,
16363
- title: external_exports.string(),
16364
- detail: external_exports.string(),
16365
- occurredAt: external_exports.iso.datetime(),
16366
- findingId: external_exports.string().nullable().optional()
16367
- }).meta({ id: "HarnessEventItem" });
16368
- var HarnessEventsResponse = external_exports.object({
16369
- counts: external_exports.object({
16370
- block: external_exports.number().int().nonnegative(),
16371
- redact: external_exports.number().int().nonnegative(),
16372
- warn: external_exports.number().int().nonnegative()
16373
- }),
16374
- items: external_exports.array(HarnessEventItem)
16375
- }).meta({ id: "HarnessEventsResponse" });
16376
- var RescanResponse = external_exports.object({
16377
- jobId: external_exports.string(),
16378
- startedAt: external_exports.iso.datetime()
16379
- }).meta({ id: "RescanResponse" });
16380
- var ConnectProjectBody = external_exports.object({ repo: external_exports.string() }).meta({ id: "ConnectProjectBody" });
16381
- var ListAssetsQuery = external_exports.object({
16382
- /** Filter by one or more AssetType values; absent means all types. */
16383
- type: external_exports.array(AssetType).optional(),
16384
- /** Free-text search term. */
16385
- q: external_exports.string().optional()
16386
- });
16387
- var GetProjectTreeQuery = external_exports.object({
16388
- /** Subtree root path; defaults to repository root when absent. */
16389
- path: external_exports.string().optional(),
16390
- /** Free-text filter applied to file paths. */
16391
- q: external_exports.string().optional(),
16392
- /**
16393
- * Special listing mode. `blocked` returns every effectively-blocked, auto-blocked
16394
- * file across the whole repo (folders omitted, most-recent first), ignoring
16395
- * `path`/`q` — powers the project-wide "recently blocked" strip.
16396
- */
16397
- filter: external_exports.enum(["blocked"]).optional()
16213
+ var McpServerScanEntry = external_exports.object({
16214
+ // The server's config key ("github", "filesystem", …) identity, with the
16215
+ // qualified scope (see mcpServerIdentityKey).
16216
+ name: external_exports.string().min(1),
16217
+ scope: ConfigScope,
16218
+ pluginName: external_exports.string().optional(),
16219
+ // The owning plugin's marketplace — part of PLUGIN-scope identity: two
16220
+ // marketplaces can each ship a plugin named `guard`, and without this their
16221
+ // same-named servers would collapse to one row (the second silently dropped,
16222
+ // inheriting the first's trust).
16223
+ marketplace: external_exports.string().optional(),
16224
+ // The repo identity (remote url, or the cwd for un-remoted repos) — part of
16225
+ // PROJECT/LOCAL-scope identity: a server named `github` in repo A and one in
16226
+ // repo B are different servers with different commands, and MUST NOT share a
16227
+ // row a shared row would let a cloned repo's .mcp.json inherit the trust
16228
+ // the user granted elsewhere.
16229
+ project: external_exports.string().optional(),
16230
+ // 'stdio' when the entry carries a command; otherwise the config's `type`
16231
+ // ('http' / 'sse' / …). Open string — the transport set is harness-defined.
16232
+ transport: external_exports.string().min(1),
16233
+ // Volatile on purpose (unlike hook `command`): a changed command/url is drift
16234
+ // on a stable row — visible across config_scan snapshots and preserving the
16235
+ // user's trust decision — never a quiet new row. One of the two is present.
16236
+ // Secret-masked at collection time (the scanner runs the bundled detection
16237
+ // packs over both — tokens routinely ride command args and URLs).
16238
+ command: external_exports.string().optional(),
16239
+ url: external_exports.string().optional(),
16240
+ // Env var NAMES only, never values (the no-secrets rule).
16241
+ envKeys: external_exports.array(external_exports.string()).optional(),
16242
+ // The config file the entry came from.
16243
+ location: external_exports.string().optional()
16398
16244
  });
16399
- var GetProjectFileQuery = external_exports.object({
16400
- /** Repository-relative file path; absent or empty 400. */
16401
- path: external_exports.string()
16245
+ var ConfigFileScanEntry = external_exports.object({
16246
+ // Basename (settings.json, CLAUDE.md) or dir name (commands/, agents/).
16247
+ name: external_exports.string().min(1),
16248
+ // The absolute path — identity (with scope) and the promoted `location`.
16249
+ path: external_exports.string().min(1),
16250
+ scope: ConfigScope,
16251
+ // Human label: "User settings", "Project memory", "Slash commands", …
16252
+ kind: external_exports.string().min(1),
16253
+ // Derived SHAPE summary — top-level key names, entry counts, line counts.
16254
+ // Never file content or values (memory files can carry sensitive detail).
16255
+ detail: external_exports.string().optional(),
16256
+ // Dir configs (commands/, agents/) and .mcp.json: how many entries.
16257
+ entryCount: external_exports.number().optional(),
16258
+ // File mtime (ISO) — the freshness signal.
16259
+ updatedAt: external_exports.iso.datetime().optional()
16402
16260
  });
16403
- var GetHarnessEventsQuery = external_exports.object({
16404
- /** Maximum number of events to return. Range: 1–50; default: 7. */
16405
- limit: external_exports.coerce.number().int().min(1).max(50).default(7)
16261
+ var ConfigScanResult = external_exports.object({
16262
+ scannedAt: external_exports.iso.datetime(),
16263
+ skills: external_exports.array(SkillScanEntry),
16264
+ hooks: external_exports.array(HookScanEntry),
16265
+ mcpServers: external_exports.array(McpServerScanEntry),
16266
+ configFiles: external_exports.array(ConfigFileScanEntry),
16267
+ errors: external_exports.array(external_exports.object({ source: external_exports.string(), reason: external_exports.string() }))
16406
16268
  });
16407
-
16408
- // ../../packages/schema/src/zod/exception.ts
16409
- var ExceptionScope = external_exports.enum(["once", "temporary", "permanent"]);
16410
- var ExceptionConditions = external_exports.object({
16411
- repo: external_exports.string().optional(),
16412
- sourceTool: external_exports.string().optional(),
16413
- provider: external_exports.string().optional()
16414
- }).strict();
16415
- var ExceptionCapability = external_exports.enum(["suppress", "reveal_to_model"]);
16416
- var DetectionException = external_exports.object({
16417
- id: external_exports.guid(),
16418
- ruleId: external_exports.string(),
16419
- // Denormalized from the rule, for reporting — never matched on.
16420
- category: DetectionCategory,
16421
- // HMAC-SHA256 hex of the raw match under a machine-local key: a KEYED
16422
- // fingerprint, never the raw value, and never reversible. Matching recomputes
16423
- // the fingerprint from a fresh capture; the value itself is never stored.
16424
- // Shape-constrained so a malformed — or accidentally raw — value is rejected
16425
- // at the boundary rather than persisted.
16426
- valueFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
16427
- // Version of the fingerprint key the grant was written under; a rotated key
16428
- // invalidates old grants rather than silently mismatching them.
16429
- keyVersion: external_exports.number().int().positive(),
16430
- // maskMatch() preview of the approved value — never the raw value.
16431
- maskedValue: external_exports.string(),
16432
- capability: ExceptionCapability.default("suppress"),
16433
- scope: ExceptionScope,
16434
- expiresAt: external_exports.iso.datetime().nullable(),
16435
- maxUses: external_exports.number().int().positive().nullable(),
16436
- useCount: external_exports.number().int().nonnegative(),
16437
- lastUsedAt: external_exports.iso.datetime().nullable(),
16438
- // Mandatory: every grant carries the human reason it exists.
16439
- justification: external_exports.string().min(1),
16440
- conditions: ExceptionConditions.nullable(),
16441
- createdBy: external_exports.string(),
16442
- createdVia: external_exports.enum(["cli-approve", "cli-add", "web-approve", "web-add", "api", "setup-triage"]),
16443
- createdAt: external_exports.iso.datetime(),
16444
- updatedAt: external_exports.iso.datetime(),
16445
- // Revocation is terminal and retained — consumed/expired/revoked rows are
16446
- // audit evidence; nothing in the exception lifecycle hard-deletes.
16447
- revokedAt: external_exports.iso.datetime().nullable(),
16448
- revokedBy: external_exports.string().nullable(),
16449
- revokeReason: external_exports.string().nullable()
16269
+ var ConfigPostureFindingInput = external_exports.object({
16270
+ ruleId: external_exports.string().min(1),
16271
+ version: external_exports.string().min(1),
16272
+ span: Span,
16273
+ // For posture rules this is the offending COMMAND (config the user already
16274
+ // holds locally, not captured secret content) — it is also the correlation
16275
+ // key the read surface matches back to a hook row.
16276
+ maskedMatch: external_exports.string(),
16277
+ actionTaken: ActionTaken,
16278
+ confidence: external_exports.number().min(0).max(1)
16450
16279
  });
16451
- var ExceptionBundleEntry = DetectionException.pick({
16452
- id: true,
16453
- ruleId: true,
16454
- valueFingerprint: true,
16455
- keyVersion: true,
16456
- capability: true,
16457
- expiresAt: true,
16458
- maxUses: true,
16459
- useCount: true,
16460
- conditions: true
16280
+ var ConfigScanRecord = external_exports.object({
16281
+ items: external_exports.array(InventoryInput),
16282
+ scanEvent: AuditEventInput,
16283
+ definitions: external_exports.array(InspectionDefinitionInput).optional(),
16284
+ findings: external_exports.array(ConfigPostureFindingInput).optional()
16461
16285
  });
16462
- var ExceptionDescriptor = DetectionException.omit({ valueFingerprint: true });
16286
+
16287
+ // ../../packages/schema/src/zod/registry.ts
16288
+ var Namespace = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
16289
+ var PackId = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
16290
+ var SemVer = external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?$/);
16291
+ var PublisherKind = external_exports.enum(["labs", "user", "org"]);
16463
16292
 
16464
16293
  // ../../packages/schema/src/zod/rule.ts
16465
- var MatcherType = external_exports.enum(["keyword", "regex", "validator"]).meta({ id: "MatcherType" });
16294
+ var MatcherType = external_exports.enum(["keyword", "regex"]).meta({ id: "MatcherType" });
16466
16295
  var RuleProbeVerdict = external_exports.enum(["safe", "quarantined"]).meta({ id: "RuleProbeVerdict" });
16467
- var KeywordMatcher2 = external_exports.object({
16296
+ var KeywordMatcher2 = external_exports.strictObject({
16468
16297
  type: external_exports.literal("keyword"),
16469
16298
  // An empty keyword matches at every position, yielding one zero-length span
16470
16299
  // per character. Rejected here because a keyword that matches everything is
@@ -16480,16 +16309,31 @@ function isValidRegex(pattern, flags) {
16480
16309
  return false;
16481
16310
  }
16482
16311
  }
16312
+ function probeFlags(flags) {
16313
+ return flags.replace(/[gy]/g, "");
16314
+ }
16483
16315
  function matchesEmptyString(pattern, flags) {
16484
16316
  try {
16485
- const re = new RegExp(pattern, flags.replace(/[gy]/g, ""));
16317
+ const re = new RegExp(pattern, probeFlags(flags));
16486
16318
  return re.exec("")?.[0].length === 0;
16487
16319
  } catch {
16488
16320
  return false;
16489
16321
  }
16490
16322
  }
16323
+ function spansWholeMatch(captureGroup) {
16324
+ return captureGroup === void 0 || captureGroup === 0;
16325
+ }
16326
+ function captureGroupCount(pattern, flags) {
16327
+ try {
16328
+ const probe = new RegExp(`${pattern}|`, probeFlags(flags));
16329
+ const result = probe.exec("");
16330
+ return result ? result.length - 1 : void 0;
16331
+ } catch {
16332
+ return void 0;
16333
+ }
16334
+ }
16491
16335
  var MAX_PATTERN_LENGTH = 2e3;
16492
- var RegexMatcher2 = external_exports.object({
16336
+ var RegexMatcher2 = external_exports.strictObject({
16493
16337
  type: external_exports.literal("regex"),
16494
16338
  pattern: external_exports.string().min(1).max(MAX_PATTERN_LENGTH),
16495
16339
  flags: external_exports.string().default("gi"),
@@ -16497,28 +16341,47 @@ var RegexMatcher2 = external_exports.object({
16497
16341
  }).refine((v) => isValidRegex(v.pattern, v.flags), {
16498
16342
  message: "pattern/flags do not form a valid JavaScript regular expression",
16499
16343
  path: ["pattern"]
16500
- }).refine((v) => v.captureGroup !== void 0 || !matchesEmptyString(v.pattern, v.flags), {
16344
+ }).refine((v) => !spansWholeMatch(v.captureGroup) || !matchesEmptyString(v.pattern, v.flags), {
16501
16345
  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',
16502
16346
  path: ["pattern"]
16347
+ }).superRefine((v, ctx) => {
16348
+ if (v.captureGroup === void 0) return;
16349
+ const groups = captureGroupCount(v.pattern, v.flags);
16350
+ if (groups === void 0 || v.captureGroup <= groups) return;
16351
+ ctx.addIssue({
16352
+ code: "custom",
16353
+ path: ["captureGroup"],
16354
+ 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.`
16355
+ });
16503
16356
  });
16504
- var ValidatorMatcher = external_exports.object({
16505
- type: external_exports.literal("validator"),
16506
- name: external_exports.enum(["luhn", "entropy", "ssn-checksum"]),
16507
- config: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
16508
- });
16509
- var Matcher = external_exports.discriminatedUnion("type", [KeywordMatcher2, RegexMatcher2, ValidatorMatcher]).meta({ id: "Matcher" });
16510
- var AppliesTo = external_exports.object({
16357
+ var Matcher = external_exports.discriminatedUnion("type", [KeywordMatcher2, RegexMatcher2]).meta({ id: "Matcher" });
16358
+ var MATCHER_TYPES = MatcherType.options;
16359
+ var AppliesTo = external_exports.strictObject({
16511
16360
  // Dot-prefixed, e.g. ".py" — matches the scanner's SOURCE_EXTENSIONS shape.
16512
16361
  extensions: external_exports.array(external_exports.string().regex(/^\.[A-Za-z0-9]+$/)).min(1)
16513
16362
  }).meta({ id: "AppliesTo" });
16514
- var PostValidatorRef = external_exports.union([
16515
- external_exports.string(),
16516
- external_exports.object({
16517
- name: external_exports.string(),
16518
- config: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
16519
- })
16520
- ]).meta({ id: "PostValidatorRef" });
16521
- var RequiresNearby = external_exports.object({
16363
+ var PostValidatorName = external_exports.enum(["entropy", "luhn"]).meta({ id: "PostValidatorName" });
16364
+ var PostValidatorRef = external_exports.union(
16365
+ [
16366
+ PostValidatorName,
16367
+ external_exports.strictObject({
16368
+ name: PostValidatorName,
16369
+ config: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
16370
+ })
16371
+ ],
16372
+ {
16373
+ // A union reports one collapsed issue for every way its arms can fail, so
16374
+ // this has to describe the whole shape rather than just the name — it is
16375
+ // what an author sees for a misspelled name AND for a stray key in the
16376
+ // object form. The names come from the enum so the message cannot go
16377
+ // stale. Without it Zod says only "Invalid input", which is precisely the
16378
+ // no-feedback outcome this schema exists to remove.
16379
+ error: () => `not a valid post-validator: use a bare name (${PostValidatorName.options.map((name) => JSON.stringify(name)).join(
16380
+ " or "
16381
+ )}) or { "name": ..., "config": { ... } }. An unrecognized name would be a false-positive guard that never runs.`
16382
+ }
16383
+ ).meta({ id: "PostValidatorRef" });
16384
+ var RequiresNearby = external_exports.strictObject({
16522
16385
  // Each array, when present, must be non-empty and contain non-empty strings —
16523
16386
  // an empty/blank criterion would either never fire or (for labels) match
16524
16387
  // everything.
@@ -16533,16 +16396,23 @@ var RequiresNearby = external_exports.object({
16533
16396
  (v) => (v.categories?.length ?? 0) + (v.ruleIds?.length ?? 0) + (v.labels?.length ?? 0) > 0,
16534
16397
  { message: "requiresNearby needs at least one of categories, ruleIds, or labels" }
16535
16398
  ).meta({ id: "RequiresNearby" });
16536
- var RuleFixture = external_exports.object({
16399
+ var RuleFixture = external_exports.strictObject({
16537
16400
  label: external_exports.string(),
16538
16401
  text: external_exports.string().max(5e4),
16539
16402
  shouldMatch: external_exports.boolean(),
16540
16403
  // Simulated file context for the scan, so fixtures can assert `appliesTo`
16541
16404
  // gating (e.g. a Python-only pattern must NOT fire in a .ts file).
16542
16405
  filePath: external_exports.string().optional(),
16543
- expectedSpans: external_exports.array(external_exports.object({ start: external_exports.number(), end: external_exports.number() })).optional()
16406
+ expectedSpans: external_exports.array(external_exports.strictObject({ start: external_exports.number(), end: external_exports.number() })).optional()
16544
16407
  }).meta({ id: "RuleFixture" });
16545
- var Rule = external_exports.object({
16408
+ var Rule = external_exports.strictObject({
16409
+ // A pinned literal over a STRICT object, and the two together decide how this
16410
+ // format may grow. A rule carrying a key not listed below is refused with
16411
+ // `unrecognized_keys`; a rule declaring `specVersion: 2` is refused with
16412
+ // `invalid_value`. So the only additive path is adding an OPTIONAL field here
16413
+ // — that keeps every rule authored before it valid — and a rule author has no
16414
+ // way to introduce a field of their own or to opt into a later version.
16415
+ // Widening the format means changing this literal and every consumer of it.
16546
16416
  specVersion: external_exports.literal(1),
16547
16417
  // `packId/ruleName` (e.g. `secrets/aws-access-key`). NOTE the first segment is
16548
16418
  // the PACK id, NOT a namespace — this is a DIFFERENT slug space from a
@@ -16578,287 +16448,6 @@ var PackManifest = external_exports.object({
16578
16448
  sourceUrl: external_exports.url().optional()
16579
16449
  }).meta({ id: "PackManifest" });
16580
16450
 
16581
- // ../../packages/schema/src/zod/policy.ts
16582
- var PolicyScope = external_exports.enum(["global", "repo", "user"]).meta({ id: "PolicyScope" });
16583
- var PolicyTarget = external_exports.union([external_exports.object({ ruleId: external_exports.string() }), external_exports.object({ category: DetectionCategory })]).meta({ id: "PolicyTarget" });
16584
- var Policy = external_exports.object({
16585
- id: external_exports.guid(),
16586
- scope: PolicyScope,
16587
- target: PolicyTarget,
16588
- action: ActionTaken,
16589
- enabled: external_exports.boolean().default(true),
16590
- customKeywords: external_exports.array(external_exports.string()).optional(),
16591
- // Display name — optional so older policy rows without name still parse.
16592
- // Added for the findings API (policy.name column migration).
16593
- name: external_exports.string().optional()
16594
- }).meta({ id: "Policy" });
16595
- var PolicyBundle = external_exports.object({
16596
- version: external_exports.string(),
16597
- policies: external_exports.array(Policy),
16598
- // Rules from the installed marketplace packs (snapshotted by the
16599
- // control plane). The plugin registers these in addition to its bundled
16600
- // packs. Optional so older backends — and older on-disk caches — that omit
16601
- // the field still parse; consumers read `bundle.rules ?? []`.
16602
- rules: external_exports.array(Rule).optional(),
16603
- // When true, `rules` IS the complete effective ruleset and the runtime must
16604
- // NOT merge its compiled-in bundled packs — the standalone gateway sets this
16605
- // after reading the user's installed snapshot (installed_packs, enabled
16606
- // packs only), which is how detection updates stay manual: new bundled
16607
- // rules run only after the user applies the pack update. Absent/false keeps
16608
- // the historical composition (bundled packs + rules) — older caches.
16609
- rulesComplete: external_exports.boolean().optional(),
16610
- // Active detection exceptions, evaluation subset only (see
16611
- // ExceptionBundleEntry). Optional so older bundle producers — and older
16612
- // on-disk caches — that omit the field still parse; consumers read
16613
- // `bundle.exceptions ?? []`.
16614
- exceptions: external_exports.array(ExceptionBundleEntry).optional(),
16615
- // Installed pack version, keyed by ruleId, for rules in `rules` that came
16616
- // from a versioned installed pack. Optional so older backends — and older
16617
- // on-disk caches — that omit the field still parse; consumers fall back to
16618
- // the rule's own spec version. NOT the bundle version above — see
16619
- // installedRuleset's ruleVersions for the source of truth.
16620
- ruleVersions: external_exports.record(external_exports.string(), external_exports.string()).optional(),
16621
- customKeywords: external_exports.array(external_exports.string()),
16622
- fetchedAt: external_exports.iso.datetime()
16623
- }).meta({ id: "PolicyBundle" });
16624
- var OBSERVE_ONLY_CATEGORIES = ["config"];
16625
- var ENFORCEABLE_CATEGORIES = DetectionCategory.options.filter((c) => !OBSERVE_ONLY_CATEGORIES.includes(c));
16626
- var CATEGORY_PEAK_SEVERITY = {
16627
- secret: "critical",
16628
- financial: "critical",
16629
- // core-financial/credit-card
16630
- code_flaw: "critical",
16631
- pii: "high",
16632
- phi: "high",
16633
- custom: "high",
16634
- // user-defined; conservative
16635
- code_context: "low",
16636
- config: "low"
16637
- // observe-only; floors to monitor regardless
16638
- };
16639
- function severityFloorPolicy(category) {
16640
- if (OBSERVE_ONLY_CATEGORIES.includes(category)) return "monitor";
16641
- const peak = CATEGORY_PEAK_SEVERITY[category];
16642
- return peak === "critical" || peak === "high" ? "warn" : "monitor";
16643
- }
16644
- var PolicyKind = external_exports.enum(["builtin", "custom"]).meta({ id: "PolicyKind" });
16645
- var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "block"];
16646
- var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
16647
- var BUILTIN_POLICY_SPECS = {
16648
- monitor: {
16649
- name: "Monitor",
16650
- action: "log",
16651
- description: "Log every match for audit. The request is allowed through untouched."
16652
- },
16653
- warn: {
16654
- name: "Warn",
16655
- action: "warn",
16656
- description: "Allow the request, but warn the user inline before it is sent."
16657
- },
16658
- redact: {
16659
- name: "Redact",
16660
- action: "redact",
16661
- description: "Automatically strip the matched value from the request, then continue."
16662
- },
16663
- block: {
16664
- name: "Block",
16665
- action: "block",
16666
- description: "Refuse the request entirely whenever any rule in this detection matches."
16667
- }
16668
- };
16669
- function builtinPolicyToAction(id) {
16670
- return BUILTIN_POLICY_SPECS[id].action;
16671
- }
16672
- var DEFAULT_ACTIONS = Object.fromEntries(
16673
- DetectionCategory.options.map((c) => [c, builtinPolicyToAction(severityFloorPolicy(c))])
16674
- );
16675
- var BUILTIN_POLICIES = Object.fromEntries(
16676
- KNOWN_BUILTIN_IDS.map((id) => [id, { id, ...BUILTIN_POLICY_SPECS[id] }])
16677
- );
16678
- var UsedByItem = external_exports.object({
16679
- id: external_exports.string(),
16680
- name: external_exports.string(),
16681
- ruleCount: external_exports.number().int().nonnegative(),
16682
- enabled: external_exports.boolean()
16683
- }).meta({ id: "UsedByItem" });
16684
- var PolicyListItem = external_exports.object({
16685
- id: external_exports.string(),
16686
- kind: PolicyKind,
16687
- name: external_exports.string(),
16688
- enabled: external_exports.boolean(),
16689
- usedByCount: external_exports.number().int().nonnegative()
16690
- }).meta({ id: "PolicyListItem" });
16691
- var PolicyDetail = external_exports.object({
16692
- specVersion: external_exports.literal(1),
16693
- id: external_exports.string(),
16694
- kind: PolicyKind,
16695
- name: external_exports.string(),
16696
- enabled: external_exports.boolean(),
16697
- description: external_exports.string(),
16698
- usedBy: external_exports.array(UsedByItem)
16699
- }).meta({ id: "PolicyDetail" });
16700
- var PolicyStatsResponse = external_exports.object({
16701
- policies: external_exports.number().int().nonnegative(),
16702
- builtin: external_exports.number().int().nonnegative(),
16703
- custom: external_exports.number().int().nonnegative(),
16704
- detectionsGoverned: external_exports.number().int().nonnegative()
16705
- }).meta({ id: "PolicyStatsResponse" });
16706
-
16707
- // ../../packages/schema/src/zod/api.ts
16708
- var LIST_QUERY_MAX_LIMIT = 200;
16709
- var ListEventsQuery = external_exports.object({
16710
- cursor: external_exports.string().optional(),
16711
- limit: external_exports.coerce.number().int().min(1).max(LIST_QUERY_MAX_LIMIT).default(50),
16712
- sourceTool: external_exports.string().optional(),
16713
- kind: external_exports.string().optional(),
16714
- from: external_exports.iso.datetime().optional(),
16715
- to: external_exports.iso.datetime().optional()
16716
- });
16717
- var ListEventsResponse = external_exports.object({
16718
- items: external_exports.array(Event),
16719
- nextCursor: external_exports.string().nullable()
16720
- }).meta({ id: "ListEventsResponse" });
16721
- var IngestResponse = external_exports.object({
16722
- accepted: external_exports.number().int().nonnegative(),
16723
- duplicates: external_exports.number().int().nonnegative()
16724
- }).meta({ id: "IngestResponse" });
16725
- var ListFindingsQuery = external_exports.object({
16726
- cursor: external_exports.string().optional(),
16727
- limit: external_exports.coerce.number().int().min(1).max(LIST_QUERY_MAX_LIMIT).default(50),
16728
- severity: external_exports.string().optional(),
16729
- category: external_exports.string().optional(),
16730
- eventId: external_exports.guid().optional()
16731
- });
16732
- var ListFindingsResponse = external_exports.object({
16733
- items: external_exports.array(Finding),
16734
- nextCursor: external_exports.string().nullable()
16735
- }).meta({ id: "ListFindingsResponse" });
16736
- var ListPoliciesResponse = external_exports.object({ items: external_exports.array(PolicyListItem) }).meta({ id: "ListPoliciesResponse" });
16737
- var CreatePolicyRequest = Policy.omit({ id: true }).meta({
16738
- id: "CreatePolicyRequest"
16739
- });
16740
- var UpdatePolicyRequest = Policy.partial().required({ id: true }).meta({ id: "UpdatePolicyRequest" });
16741
- var RecordAuditEventResponse = external_exports.object({ accepted: external_exports.boolean() }).meta({ id: "RecordAuditEventResponse" });
16742
- var ErrorResponse = external_exports.object({
16743
- error: external_exports.object({
16744
- code: external_exports.string(),
16745
- message: external_exports.string(),
16746
- details: external_exports.unknown().optional()
16747
- })
16748
- }).meta({ id: "ErrorResponse" });
16749
-
16750
- // ../../packages/schema/src/zod/config-inventory.ts
16751
- var ConfigScope = external_exports.enum(["user", "project", "local", "plugin"]);
16752
- var SkillScanEntry = external_exports.object({
16753
- name: external_exports.string().min(1),
16754
- // The identity source: a marketplace repo for plugin skills (e.g.
16755
- // 'anthropics/skills'), 'local' for personal ~/.claude/skills, or
16756
- // 'project:<repo-identity>' for checked-in project skills. The surrogate keeps
16757
- // a personal skill named 'pdf' from colliding with the marketplace 'pdf'.
16758
- source: external_exports.string().min(1),
16759
- scope: ConfigScope,
16760
- pluginName: external_exports.string().optional(),
16761
- // Volatile — rides the attribute bag, never the identity hash.
16762
- version: external_exports.string().optional(),
16763
- description: external_exports.string().optional(),
16764
- // Skill directory mtime (ISO) — the "updated Nd ago" freshness signal.
16765
- updatedAt: external_exports.iso.datetime().optional(),
16766
- // Filesystem path — the promoted inventory `location` column.
16767
- location: external_exports.string().optional()
16768
- });
16769
- var HookScanEntry = external_exports.object({
16770
- // Hook event name (PreToolUse, PostToolUse, …). Open string, not an enum: the
16771
- // set is harness-defined and grows without a schema change.
16772
- event: external_exports.string().min(1),
16773
- // The tool matcher ('Bash', 'Edit|Write', …). Absent = matches all tools.
16774
- matcher: external_exports.string().optional(),
16775
- command: external_exports.string().min(1),
16776
- timeout: external_exports.number().optional(),
16777
- scope: ConfigScope,
16778
- pluginName: external_exports.string().optional(),
16779
- // The settings file / hooks.json the entry came from.
16780
- location: external_exports.string().optional()
16781
- });
16782
- var McpServerScanEntry = external_exports.object({
16783
- // The server's config key ("github", "filesystem", …) — identity, with the
16784
- // qualified scope (see mcpServerIdentityKey).
16785
- name: external_exports.string().min(1),
16786
- scope: ConfigScope,
16787
- pluginName: external_exports.string().optional(),
16788
- // The owning plugin's marketplace — part of PLUGIN-scope identity: two
16789
- // marketplaces can each ship a plugin named `guard`, and without this their
16790
- // same-named servers would collapse to one row (the second silently dropped,
16791
- // inheriting the first's trust).
16792
- marketplace: external_exports.string().optional(),
16793
- // The repo identity (remote url, or the cwd for un-remoted repos) — part of
16794
- // PROJECT/LOCAL-scope identity: a server named `github` in repo A and one in
16795
- // repo B are different servers with different commands, and MUST NOT share a
16796
- // row — a shared row would let a cloned repo's .mcp.json inherit the trust
16797
- // the user granted elsewhere.
16798
- project: external_exports.string().optional(),
16799
- // 'stdio' when the entry carries a command; otherwise the config's `type`
16800
- // ('http' / 'sse' / …). Open string — the transport set is harness-defined.
16801
- transport: external_exports.string().min(1),
16802
- // Volatile on purpose (unlike hook `command`): a changed command/url is drift
16803
- // on a stable row — visible across config_scan snapshots and preserving the
16804
- // user's trust decision — never a quiet new row. One of the two is present.
16805
- // Secret-masked at collection time (the scanner runs the bundled detection
16806
- // packs over both — tokens routinely ride command args and URLs).
16807
- command: external_exports.string().optional(),
16808
- url: external_exports.string().optional(),
16809
- // Env var NAMES only, never values (the no-secrets rule).
16810
- envKeys: external_exports.array(external_exports.string()).optional(),
16811
- // The config file the entry came from.
16812
- location: external_exports.string().optional()
16813
- });
16814
- var ConfigFileScanEntry = external_exports.object({
16815
- // Basename (settings.json, CLAUDE.md) or dir name (commands/, agents/).
16816
- name: external_exports.string().min(1),
16817
- // The absolute path — identity (with scope) and the promoted `location`.
16818
- path: external_exports.string().min(1),
16819
- scope: ConfigScope,
16820
- // Human label: "User settings", "Project memory", "Slash commands", …
16821
- kind: external_exports.string().min(1),
16822
- // Derived SHAPE summary — top-level key names, entry counts, line counts.
16823
- // Never file content or values (memory files can carry sensitive detail).
16824
- detail: external_exports.string().optional(),
16825
- // Dir configs (commands/, agents/) and .mcp.json: how many entries.
16826
- entryCount: external_exports.number().optional(),
16827
- // File mtime (ISO) — the freshness signal.
16828
- updatedAt: external_exports.iso.datetime().optional()
16829
- });
16830
- var ConfigScanResult = external_exports.object({
16831
- scannedAt: external_exports.iso.datetime(),
16832
- skills: external_exports.array(SkillScanEntry),
16833
- hooks: external_exports.array(HookScanEntry),
16834
- mcpServers: external_exports.array(McpServerScanEntry),
16835
- configFiles: external_exports.array(ConfigFileScanEntry),
16836
- errors: external_exports.array(external_exports.object({ source: external_exports.string(), reason: external_exports.string() }))
16837
- });
16838
- var ConfigPostureFindingInput = external_exports.object({
16839
- ruleId: external_exports.string().min(1),
16840
- version: external_exports.string().min(1),
16841
- span: Span,
16842
- // For posture rules this is the offending COMMAND (config the user already
16843
- // holds locally, not captured secret content) — it is also the correlation
16844
- // key the read surface matches back to a hook row.
16845
- maskedMatch: external_exports.string(),
16846
- actionTaken: ActionTaken,
16847
- confidence: external_exports.number().min(0).max(1)
16848
- });
16849
- var ConfigScanRecord = external_exports.object({
16850
- items: external_exports.array(InventoryInput),
16851
- scanEvent: AuditEventInput,
16852
- definitions: external_exports.array(InspectionDefinitionInput).optional(),
16853
- findings: external_exports.array(ConfigPostureFindingInput).optional()
16854
- });
16855
-
16856
- // ../../packages/schema/src/zod/registry.ts
16857
- var Namespace = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
16858
- var PackId = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
16859
- var SemVer = external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?$/);
16860
- var PublisherKind = external_exports.enum(["labs", "user", "org"]);
16861
-
16862
16451
  // ../../packages/schema/src/zod/detection.ts
16863
16452
  var OriginEnum = external_exports.enum(["library"]).meta({ id: "OriginEnum" });
16864
16453
  var DetectionFilterEnum = external_exports.enum(["all", "library", "custom", "customized", "updates"]);
@@ -16903,81 +16492,306 @@ var ListDetectionsQuery = external_exports.object({
16903
16492
  filter: DetectionFilterEnum.optional().default("all"),
16904
16493
  q: external_exports.string().optional()
16905
16494
  });
16906
- var DetectionStats = external_exports.object({
16907
- detections: external_exports.number().int().nonnegative(),
16908
- rules: external_exports.number().int().nonnegative(),
16909
- active: external_exports.number().int().nonnegative(),
16910
- findingsLast30d: external_exports.number().int().nonnegative()
16911
- }).meta({ id: "DetectionStats" });
16912
- var DetectionRule = external_exports.object({
16913
- id: external_exports.string(),
16914
- name: external_exports.string(),
16915
- category: DetectionCategory,
16916
- severity: Severity,
16917
- matcher: Matcher
16918
- }).meta({ id: "DetectionRule" });
16919
- var DetectionUpdate = external_exports.object({
16920
- available: external_exports.boolean(),
16921
- latestVersion: SemVer,
16922
- // Rule count of the latest snapshot. Lets the update UI show a meaningful
16923
- // delta ("2 rules → 14 rules") when the version did NOT change but the rule
16924
- // content did — the OSS store compares content, not just version. Optional:
16925
- // registry-backed updates omit it.
16926
- latestRuleCount: external_exports.number().int().nonnegative().optional()
16927
- }).nullable().meta({ id: "DetectionUpdate" });
16928
- var DetectionDetail = external_exports.object({
16929
- id: external_exports.string(),
16930
- name: external_exports.string(),
16931
- version: SemVer,
16932
- enabled: external_exports.boolean(),
16933
- origin: OriginEnum,
16934
- publisher: Namespace.optional(),
16935
- publisherKind: PublisherKind.optional(),
16936
- ruleCount: external_exports.number().int().nonnegative(),
16937
- namespace: Namespace,
16938
- packId: PackId,
16939
- description: external_exports.string().optional(),
16940
- editedAt: external_exports.iso.datetime(),
16941
- findingsLast30d: external_exports.number().int().nonnegative(),
16942
- latestVersion: SemVer.nullable().optional(),
16943
- update: DetectionUpdate,
16944
- rules: external_exports.array(DetectionRule),
16945
- modified: external_exports.boolean(),
16946
- // Per-pack enforcement-policy assignment. Holds a BuiltinPolicyId ARCHETYPE
16947
- // (monitor|warn|redact|block) — NOT a policies-table Policy.id guid; a
16948
- // detection is a PACK, and its policy is the archetype applied to all its
16949
- // rules. Absent == unassigned, which resolves to Monitor everywhere
16950
- // (DEFAULT_PACK_POLICY_ID). Every enforcement surface expands it into
16951
- // per-rule policies (see policyIdToAction). Typed z.string() (not
16952
- // the enum) to keep the OpenAPI response tolerant of a future custom id.
16953
- policyId: external_exports.string().optional()
16954
- }).meta({ id: "DetectionDetail" });
16955
- var LibraryItem = external_exports.object({
16956
- id: external_exports.string(),
16957
- name: external_exports.string(),
16958
- publisher: Namespace,
16959
- publisherKind: PublisherKind.optional(),
16960
- // LOSSY single-category view of a pack. A pack MAY span several categories;
16961
- // this carries only the canonical-first one for display. Do NOT filter/facet
16962
- // on it — the library filter matches a pack's full category set (see
16963
- // ListLibraryResponse.categories).
16964
- category: DetectionCategory.optional(),
16965
- version: SemVer,
16966
- ruleCount: external_exports.number().int().nonnegative(),
16967
- description: external_exports.string().optional(),
16968
- updatedAt: external_exports.iso.datetime(),
16969
- state: LibraryStateEnum,
16970
- importedAs: external_exports.string().nullable()
16971
- }).meta({ id: "LibraryItem" });
16972
- var ListLibraryResponse = external_exports.object({
16973
- categories: external_exports.array(DetectionCategory),
16974
- items: external_exports.array(LibraryItem)
16975
- }).meta({ id: "ListLibraryResponse" });
16976
- var ImportDetectionRequest = external_exports.object({
16977
- libraryId: external_exports.string().refine((v) => /^[^/]+\/[^/]+$/.test(v), {
16978
- message: "libraryId must be in namespace/packId format"
16979
- })
16980
- }).meta({ id: "ImportDetectionRequest" });
16495
+ var DetectionStats = external_exports.object({
16496
+ detections: external_exports.number().int().nonnegative(),
16497
+ rules: external_exports.number().int().nonnegative(),
16498
+ active: external_exports.number().int().nonnegative(),
16499
+ findingsLast30d: external_exports.number().int().nonnegative()
16500
+ }).meta({ id: "DetectionStats" });
16501
+ var DetectionRule = external_exports.object({
16502
+ id: external_exports.string(),
16503
+ name: external_exports.string(),
16504
+ category: DetectionCategory,
16505
+ severity: Severity,
16506
+ matcher: Matcher
16507
+ }).meta({ id: "DetectionRule" });
16508
+ var DetectionUpdate = external_exports.object({
16509
+ available: external_exports.boolean(),
16510
+ latestVersion: SemVer,
16511
+ // Rule count of the latest snapshot. Lets the update UI show a meaningful
16512
+ // delta ("2 rules → 14 rules") when the version did NOT change but the rule
16513
+ // content did — the OSS store compares content, not just version. Optional:
16514
+ // registry-backed updates omit it.
16515
+ latestRuleCount: external_exports.number().int().nonnegative().optional()
16516
+ }).nullable().meta({ id: "DetectionUpdate" });
16517
+ var DetectionDetail = external_exports.object({
16518
+ id: external_exports.string(),
16519
+ name: external_exports.string(),
16520
+ version: SemVer,
16521
+ enabled: external_exports.boolean(),
16522
+ origin: OriginEnum,
16523
+ publisher: Namespace.optional(),
16524
+ publisherKind: PublisherKind.optional(),
16525
+ ruleCount: external_exports.number().int().nonnegative(),
16526
+ namespace: Namespace,
16527
+ packId: PackId,
16528
+ description: external_exports.string().optional(),
16529
+ editedAt: external_exports.iso.datetime(),
16530
+ findingsLast30d: external_exports.number().int().nonnegative(),
16531
+ latestVersion: SemVer.nullable().optional(),
16532
+ update: DetectionUpdate,
16533
+ rules: external_exports.array(DetectionRule),
16534
+ modified: external_exports.boolean(),
16535
+ // Per-pack enforcement-policy assignment. Holds a BuiltinPolicyId ARCHETYPE
16536
+ // (monitor|warn|redact|block) — NOT a policies-table Policy.id guid; a
16537
+ // detection is a PACK, and its policy is the archetype applied to all its
16538
+ // rules. Absent == unassigned, which resolves to Monitor everywhere
16539
+ // (DEFAULT_PACK_POLICY_ID). Every enforcement surface expands it into
16540
+ // per-rule policies (see policyIdToAction). Typed z.string() (not
16541
+ // the enum) to keep the OpenAPI response tolerant of a future custom id.
16542
+ policyId: external_exports.string().optional()
16543
+ }).meta({ id: "DetectionDetail" });
16544
+ var LibraryItem = external_exports.object({
16545
+ id: external_exports.string(),
16546
+ name: external_exports.string(),
16547
+ publisher: Namespace,
16548
+ publisherKind: PublisherKind.optional(),
16549
+ // LOSSY single-category view of a pack. A pack MAY span several categories;
16550
+ // this carries only the canonical-first one for display. Do NOT filter/facet
16551
+ // on it — the library filter matches a pack's full category set (see
16552
+ // ListLibraryResponse.categories).
16553
+ category: DetectionCategory.optional(),
16554
+ version: SemVer,
16555
+ ruleCount: external_exports.number().int().nonnegative(),
16556
+ description: external_exports.string().optional(),
16557
+ updatedAt: external_exports.iso.datetime(),
16558
+ state: LibraryStateEnum,
16559
+ importedAs: external_exports.string().nullable()
16560
+ }).meta({ id: "LibraryItem" });
16561
+ var ListLibraryResponse = external_exports.object({
16562
+ categories: external_exports.array(DetectionCategory),
16563
+ items: external_exports.array(LibraryItem)
16564
+ }).meta({ id: "ListLibraryResponse" });
16565
+ var ImportDetectionRequest = external_exports.object({
16566
+ libraryId: external_exports.string().refine((v) => /^[^/]+\/[^/]+$/.test(v), {
16567
+ message: "libraryId must be in namespace/packId format"
16568
+ })
16569
+ }).meta({ id: "ImportDetectionRequest" });
16570
+
16571
+ // ../../packages/schema/src/zod/inventory.ts
16572
+ var AssetType = external_exports.enum(["project", "skill", "mcp", "hook", "config"]).meta({ id: "AssetType" });
16573
+ var AccessLevel = external_exports.enum(["open", "approved", "blocked"]).meta({ id: "AccessLevel" });
16574
+ var Origin = external_exports.enum(["source", "public-dep", "vendored", "config", "data", "docs", "generated"]).meta({ id: "Origin" });
16575
+ var TrustLevel = external_exports.enum(["known-good", "risky", "unapproved"]).meta({ id: "TrustLevel" });
16576
+ var Flag = external_exports.enum(["update", "stale", "conflict", "unknown", "change", "untracked", "risk", "findings"]).meta({ id: "Flag" });
16577
+ var Visibility = external_exports.enum(["public", "private"]).meta({ id: "Visibility" });
16578
+ var HarnessEventKind = external_exports.enum(["block", "redact", "warn"]).meta({ id: "HarnessEventKind" });
16579
+ var HarnessId = Harness.extract(["ClaudeCode", "Cursor", "Codex", "Antigravity"]).meta({
16580
+ id: "HarnessId"
16581
+ });
16582
+ var AccessCounts = external_exports.object({
16583
+ open: external_exports.number().int().nonnegative(),
16584
+ approved: external_exports.number().int().nonnegative(),
16585
+ blocked: external_exports.number().int().nonnegative(),
16586
+ total: external_exports.number().int().nonnegative()
16587
+ }).meta({ id: "AccessCounts" });
16588
+ var AssetSummary = external_exports.object({
16589
+ id: external_exports.string(),
16590
+ type: AssetType,
16591
+ name: external_exports.string(),
16592
+ sub: external_exports.string(),
16593
+ flags: external_exports.array(Flag),
16594
+ /** MCP servers only — omitted for all other types. */
16595
+ trust: TrustLevel.optional()
16596
+ }).meta({ id: "AssetSummary" });
16597
+ var ProjectSummary = external_exports.object({
16598
+ id: external_exports.string(),
16599
+ name: external_exports.string(),
16600
+ repo: external_exports.string(),
16601
+ visibility: Visibility,
16602
+ language: external_exports.string(),
16603
+ policyDefault: AccessLevel,
16604
+ updatedAt: external_exports.iso.datetime(),
16605
+ accessCounts: AccessCounts,
16606
+ findingsCount: external_exports.number().int().nonnegative()
16607
+ }).meta({ id: "ProjectSummary" });
16608
+ var HarnessCategory = external_exports.object({
16609
+ /** One of config/skill/mcp/hook — never project (enforced at service layer). */
16610
+ type: AssetType,
16611
+ assets: external_exports.array(AssetSummary)
16612
+ });
16613
+ var HarnessSummary = external_exports.object({
16614
+ id: HarnessId,
16615
+ label: external_exports.string(),
16616
+ kind: external_exports.string(),
16617
+ version: external_exports.string(),
16618
+ sessions: external_exports.number().int().nonnegative(),
16619
+ assetCount: external_exports.number().int().nonnegative(),
16620
+ flagCount: external_exports.number().int().nonnegative(),
16621
+ projects: external_exports.array(ProjectSummary),
16622
+ categories: external_exports.array(HarnessCategory)
16623
+ }).meta({ id: "HarnessSummary" });
16624
+ var ListHarnessesResponse = external_exports.object({ items: external_exports.array(HarnessSummary) }).meta({ id: "ListHarnessesResponse" });
16625
+ var AssetGroup = external_exports.object({
16626
+ /** Group key — never project (enforced at service layer). */
16627
+ type: AssetType,
16628
+ total: external_exports.number().int().nonnegative(),
16629
+ /**
16630
+ * MCP group only — omitted for all other types.
16631
+ * Partial: only TrustLevel keys with non-zero counts are included.
16632
+ * Strict: unknown keys are rejected — only TrustLevel values are valid keys.
16633
+ */
16634
+ trustRollup: external_exports.object({
16635
+ "known-good": external_exports.number().int().nonnegative(),
16636
+ risky: external_exports.number().int().nonnegative(),
16637
+ unapproved: external_exports.number().int().nonnegative()
16638
+ }).partial().strict().optional(),
16639
+ /**
16640
+ * Partial: only Flag keys with non-zero counts are included.
16641
+ * Strict: unknown keys are rejected — only Flag values are valid keys.
16642
+ */
16643
+ flagRollup: external_exports.object({
16644
+ update: external_exports.number().int().nonnegative(),
16645
+ stale: external_exports.number().int().nonnegative(),
16646
+ conflict: external_exports.number().int().nonnegative(),
16647
+ unknown: external_exports.number().int().nonnegative(),
16648
+ change: external_exports.number().int().nonnegative(),
16649
+ untracked: external_exports.number().int().nonnegative(),
16650
+ risk: external_exports.number().int().nonnegative(),
16651
+ findings: external_exports.number().int().nonnegative()
16652
+ }).partial().strict(),
16653
+ items: external_exports.array(AssetSummary)
16654
+ }).meta({ id: "AssetGroup" });
16655
+ var ListAssetsResponse = external_exports.object({ groups: external_exports.array(AssetGroup) }).meta({ id: "ListAssetsResponse" });
16656
+ var McpTool = external_exports.object({
16657
+ name: external_exports.string(),
16658
+ signature: external_exports.string(),
16659
+ description: external_exports.string(),
16660
+ write: external_exports.boolean(),
16661
+ /** Non-null string when tool is dangerous / blocked; null otherwise. */
16662
+ risk: external_exports.string().nullable()
16663
+ }).meta({ id: "McpTool" });
16664
+ var AssetFindingRef = external_exports.object({
16665
+ id: external_exports.string(),
16666
+ title: external_exports.string(),
16667
+ note: external_exports.string()
16668
+ });
16669
+ var AssetDetail = AssetSummary.extend({
16670
+ /** string | null — null when no description is available. */
16671
+ description: external_exports.string().nullable(),
16672
+ /** trustLevel | null — null for non-MCP assets. */
16673
+ trust: TrustLevel.nullable(),
16674
+ /** Type-specific raw key/values — FE renders the grid. */
16675
+ meta: external_exports.record(external_exports.string(), external_exports.unknown()),
16676
+ /** always present — object when there is an active finding, null when absent. */
16677
+ finding: AssetFindingRef.nullable(),
16678
+ /** MCP exposed-tools list — omitted for non-mcp. */
16679
+ tools: external_exports.array(McpTool).optional()
16680
+ }).meta({ id: "AssetDetail" });
16681
+ var ListProjectsResponse = external_exports.object({ items: external_exports.array(ProjectSummary) }).meta({ id: "ListProjectsResponse" });
16682
+ var InventoryStats = external_exports.object({
16683
+ /** Total assets/projects with ≥1 flag or finding (drives the attention header chip). */
16684
+ attention: external_exports.number().int().nonnegative(),
16685
+ byType: external_exports.object({
16686
+ project: external_exports.number().int().nonnegative(),
16687
+ skill: external_exports.number().int().nonnegative(),
16688
+ mcp: external_exports.number().int().nonnegative(),
16689
+ hook: external_exports.number().int().nonnegative(),
16690
+ config: external_exports.number().int().nonnegative()
16691
+ }),
16692
+ harnesses: external_exports.number().int().nonnegative(),
16693
+ mcpTrust: external_exports.object({
16694
+ "known-good": external_exports.number().int().nonnegative(),
16695
+ risky: external_exports.number().int().nonnegative(),
16696
+ unapproved: external_exports.number().int().nonnegative()
16697
+ })
16698
+ }).meta({ id: "InventoryStats" });
16699
+ var FileSummary = external_exports.object({
16700
+ path: external_exports.string(),
16701
+ name: external_exports.string(),
16702
+ origin: Origin,
16703
+ /** Effective access (override applied). */
16704
+ access: AccessLevel,
16705
+ /** True when a file_access_override differs from the computed default. */
16706
+ isCustom: external_exports.boolean(),
16707
+ findings: external_exports.number().int().nonnegative(),
16708
+ /** When the file was auto-blocked by a detection; null when not blocked. */
16709
+ blockedAt: external_exports.iso.datetime().nullable().optional(),
16710
+ /** Why the file was blocked; null when absent. */
16711
+ note: external_exports.string().nullable().optional()
16712
+ }).meta({ id: "FileSummary" });
16713
+ var FolderSummary = external_exports.object({
16714
+ name: external_exports.string(),
16715
+ path: external_exports.string(),
16716
+ /** Rollup of effective access across all descendants. */
16717
+ accessCounts: AccessCounts
16718
+ }).meta({ id: "FolderSummary" });
16719
+ var ProjectTreeResponse = external_exports.object({
16720
+ project: external_exports.object({
16721
+ id: external_exports.string(),
16722
+ repo: external_exports.string(),
16723
+ visibility: Visibility
16724
+ }),
16725
+ path: external_exports.string(),
16726
+ /** Browse mode: one-level folders at the current path. Omitted in search mode. */
16727
+ folders: external_exports.array(FolderSummary).optional(),
16728
+ files: external_exports.array(FileSummary)
16729
+ }).meta({ id: "ProjectTreeResponse" });
16730
+ var FileDetail = FileSummary.extend({
16731
+ project: external_exports.object({
16732
+ repo: external_exports.string(),
16733
+ visibility: Visibility,
16734
+ language: external_exports.string(),
16735
+ policyDefault: AccessLevel,
16736
+ updatedAt: external_exports.iso.datetime()
16737
+ }),
16738
+ findingsRefs: external_exports.array(external_exports.object({ id: external_exports.string(), title: external_exports.string() }))
16739
+ }).meta({ id: "FileDetail" });
16740
+ var SetFileAccessBody = external_exports.object({
16741
+ path: external_exports.string(),
16742
+ access: AccessLevel
16743
+ }).meta({ id: "SetFileAccessBody" });
16744
+ var SetFileAccessResponse = external_exports.object({
16745
+ file: FileSummary,
16746
+ accessCounts: AccessCounts
16747
+ }).meta({ id: "SetFileAccessResponse" });
16748
+ var SetMcpTrustBody = external_exports.object({ trust: TrustLevel }).meta({ id: "SetMcpTrustBody" });
16749
+ var HarnessEventItem = external_exports.object({
16750
+ kind: HarnessEventKind,
16751
+ title: external_exports.string(),
16752
+ detail: external_exports.string(),
16753
+ occurredAt: external_exports.iso.datetime(),
16754
+ findingId: external_exports.string().nullable().optional()
16755
+ }).meta({ id: "HarnessEventItem" });
16756
+ var HarnessEventsResponse = external_exports.object({
16757
+ counts: external_exports.object({
16758
+ block: external_exports.number().int().nonnegative(),
16759
+ redact: external_exports.number().int().nonnegative(),
16760
+ warn: external_exports.number().int().nonnegative()
16761
+ }),
16762
+ items: external_exports.array(HarnessEventItem)
16763
+ }).meta({ id: "HarnessEventsResponse" });
16764
+ var RescanResponse = external_exports.object({
16765
+ jobId: external_exports.string(),
16766
+ startedAt: external_exports.iso.datetime()
16767
+ }).meta({ id: "RescanResponse" });
16768
+ var ConnectProjectBody = external_exports.object({ repo: external_exports.string() }).meta({ id: "ConnectProjectBody" });
16769
+ var ListAssetsQuery = external_exports.object({
16770
+ /** Filter by one or more AssetType values; absent means all types. */
16771
+ type: external_exports.array(AssetType).optional(),
16772
+ /** Free-text search term. */
16773
+ q: external_exports.string().optional()
16774
+ });
16775
+ var GetProjectTreeQuery = external_exports.object({
16776
+ /** Subtree root path; defaults to repository root when absent. */
16777
+ path: external_exports.string().optional(),
16778
+ /** Free-text filter applied to file paths. */
16779
+ q: external_exports.string().optional(),
16780
+ /**
16781
+ * Special listing mode. `blocked` returns every effectively-blocked, auto-blocked
16782
+ * file across the whole repo (folders omitted, most-recent first), ignoring
16783
+ * `path`/`q` — powers the project-wide "recently blocked" strip.
16784
+ */
16785
+ filter: external_exports.enum(["blocked"]).optional()
16786
+ });
16787
+ var GetProjectFileQuery = external_exports.object({
16788
+ /** Repository-relative file path; absent or empty → 400. */
16789
+ path: external_exports.string()
16790
+ });
16791
+ var GetHarnessEventsQuery = external_exports.object({
16792
+ /** Maximum number of events to return. Range: 1–50; default: 7. */
16793
+ limit: external_exports.coerce.number().int().min(1).max(50).default(7)
16794
+ });
16981
16795
 
16982
16796
  // ../../packages/schema/src/zod/shares.ts
16983
16797
  var DestinationKind = external_exports.enum(["provider", "internal", "external", "ip"]).meta({ id: "DestinationKind" });
@@ -17113,77 +16927,198 @@ var ListShareDestinationsQuery = external_exports.object({
17113
16927
  */
17114
16928
  review: external_exports.stringbool().default(false)
17115
16929
  });
17116
- var ExportSharesQuery = external_exports.object({
17117
- format: external_exports.enum(["csv", "json"]).default("csv"),
17118
- q: external_exports.string().optional(),
17119
- kind: external_exports.array(DestinationKind).optional()
16930
+ var ExportSharesQuery = external_exports.object({
16931
+ format: external_exports.enum(["csv", "json"]).default("csv"),
16932
+ q: external_exports.string().optional(),
16933
+ kind: external_exports.array(DestinationKind).optional()
16934
+ });
16935
+
16936
+ // ../../packages/schema/src/zod/egress-extraction.ts
16937
+ var EgressEcosystem = external_exports.enum(["npm", "pypi", "go", "maven", "rubygems", "cargo", "composer", "nuget"]).meta({ id: "EgressEcosystem" });
16938
+ var ProviderRegistryEntry = external_exports.object({
16939
+ id: external_exports.string(),
16940
+ name: external_exports.string(),
16941
+ category: external_exports.string(),
16942
+ /** Suffix-matched: 'stripe.com' matches api.stripe.com, never evilstripe.com. */
16943
+ hostSuffixes: external_exports.array(external_exports.string()).min(1),
16944
+ /** Canonical API base URL recorded for manifest-derived (method 'SDK') endpoints. */
16945
+ apiBase: external_exports.string(),
16946
+ /** Most-sensitive first; index 0 becomes the endpoint dataClass. */
16947
+ defaultDataClasses: external_exports.array(DataClass).min(1),
16948
+ /** SDK identifiers per ecosystem ('go' prefix-matched by path, 'maven' by group-id prefix). */
16949
+ sdks: external_exports.partialRecord(EgressEcosystem, external_exports.array(external_exports.string()))
16950
+ }).meta({ id: "ProviderRegistryEntry" });
16951
+ var EgressCallSiteHit = external_exports.object({
16952
+ file: external_exports.string(),
16953
+ line: external_exports.number().int().positive(),
16954
+ snippet: external_exports.string(),
16955
+ dynamic: external_exports.boolean(),
16956
+ vendored: external_exports.boolean()
16957
+ }).meta({ id: "EgressCallSiteHit" });
16958
+ var ResolvedEgressHit = external_exports.object({
16959
+ host: external_exports.string(),
16960
+ kind: DestinationKind,
16961
+ name: external_exports.string(),
16962
+ category: external_exports.string(),
16963
+ trust: ShareTrustLevel,
16964
+ network: DestinationNetwork.nullable(),
16965
+ method: HttpMethod,
16966
+ transport: Transport,
16967
+ url: external_exports.string(),
16968
+ template: external_exports.boolean(),
16969
+ dataClass: DataClass,
16970
+ site: EgressCallSiteHit
16971
+ }).meta({ id: "ResolvedEgressHit" });
16972
+ var EgressReconcile = external_exports.discriminatedUnion("mode", [
16973
+ external_exports.object({ mode: external_exports.literal("walk"), walkedPrefix: external_exports.string() }),
16974
+ external_exports.object({
16975
+ mode: external_exports.literal("ledger"),
16976
+ scannedFiles: external_exports.array(external_exports.string()),
16977
+ deletedFiles: external_exports.array(external_exports.string())
16978
+ })
16979
+ ]).meta({ id: "EgressReconcile" });
16980
+ var RecordProjectEgressInput = external_exports.object({
16981
+ /** Stable reconcile key: 'git:<repo identity>' or 'path:<abs root>' (non-git). */
16982
+ projectKey: external_exports.string().min(1),
16983
+ /** Display name only — never keys reconciliation. */
16984
+ project: external_exports.string(),
16985
+ projectId: external_exports.string().nullable(),
16986
+ reconcile: EgressReconcile,
16987
+ hits: external_exports.array(ResolvedEgressHit)
16988
+ }).meta({ id: "RecordProjectEgressInput" });
16989
+ var EgressWriteSummary = external_exports.object({
16990
+ destinations: external_exports.number().int().nonnegative(),
16991
+ endpoints: external_exports.number().int().nonnegative(),
16992
+ callSites: external_exports.number().int().nonnegative(),
16993
+ truncated: external_exports.boolean(),
16994
+ /**
16995
+ * Files the cap dropped whole. Their stored rows were left untouched, so a
16996
+ * ledger-keeping caller must withhold their ledger entries and read them
16997
+ * again next scan.
16998
+ */
16999
+ droppedFiles: external_exports.array(external_exports.string()).default([])
17000
+ }).meta({ id: "EgressWriteSummary" });
17001
+
17002
+ // ../../packages/schema/src/zod/event.ts
17003
+ var EventKind = external_exports.enum(["prompt", "response", "code_change", "tool_use"]).meta({ id: "EventKind" });
17004
+ var CAPTURE_EVENT_TYPES_SQL = EventKind.options.map((k) => `'${k}'`).join(",");
17005
+ var EventMetadata = external_exports.object({
17006
+ sessionId: external_exports.string().optional(),
17007
+ repo: external_exports.string().optional(),
17008
+ filePath: external_exports.string().optional(),
17009
+ // The host tool whose input/output was scanned (e.g. 'Bash', 'WebFetch'),
17010
+ // set by the tool-scanning hooks. The tool NAME only — never the tool's
17011
+ // arguments or output, which can carry the very value a finding masked
17012
+ // (metadata is stored unredacted). Gives findings on non-file captures a
17013
+ // display location ("via Bash") when no filePath exists.
17014
+ toolName: external_exports.string().optional(),
17015
+ // Set (true) by the worktree scanner when the file is excluded by the
17016
+ // repo's .gitignore. Gitignored files ARE still scanned — local scratch and
17017
+ // generated code can leak real secrets — but the provenance is recorded so
17018
+ // policy/dashboards can treat those findings as informational rather than
17019
+ // blocking. Omitted (not false) for tracked files and non-scan events.
17020
+ gitignored: external_exports.boolean().optional(),
17021
+ // Set (true) ONLY when the event's `content` is the COMPLETE file at
17022
+ // capture time (a worktree scan reading from disk). Hook-captured edits
17023
+ // (e.g. an Edit tool's new_string) are partial fragments and MUST NOT set
17024
+ // this. The resolver-on-ingest keys its fixed-at-source dropout
17025
+ // diff on this marker: only a whole-file snapshot can prove a previously
17026
+ // open finding is gone; a fragment's absence proves nothing (the secret
17027
+ // may live outside the hunk). Omitted (not false) for fragments and
17028
+ // non-scan events, so pre-marker clients safely default to the
17029
+ // non-authoritative path.
17030
+ wholeFile: external_exports.boolean().optional(),
17031
+ model: external_exports.string().optional(),
17032
+ turnIndex: external_exports.number().int().nonnegative().optional(),
17033
+ // Distributed-tracing correlation. `correlationId` ties a recorded event back
17034
+ // to the request that captured/ingested it (a UUID, generated independently of
17035
+ // the trace id); `traceId` is the W3C trace id (32 lowercase hex chars) of the
17036
+ // originating span when telemetry is enabled. Both optional + backward
17037
+ // compatible — populated by the plugin (see @akasecurity/plugin-sdk).
17038
+ correlationId: external_exports.uuid().optional(),
17039
+ traceId: external_exports.string().regex(/^[0-9a-f]{32}$/).optional(),
17040
+ // Ids of the detection exceptions that downgraded findings in this capture
17041
+ // to 'allow' — the enforcement audit trail's link back to the grant that
17042
+ // authorized the bypass. Absent on captures where no exception applied.
17043
+ exceptionIds: external_exports.array(external_exports.guid()).optional()
17044
+ }).meta({ id: "EventMetadata" });
17045
+ var Event = external_exports.object({
17046
+ id: external_exports.guid(),
17047
+ sourceTool: SourceTool,
17048
+ kind: EventKind,
17049
+ occurredAt: external_exports.iso.datetime(),
17050
+ contentHash: external_exports.string(),
17051
+ content: external_exports.string(),
17052
+ metadata: EventMetadata.optional()
17053
+ }).meta({ id: "Event" });
17054
+ var IngestEvent = Event.meta({ id: "IngestEvent" });
17055
+ var IngestBatch = external_exports.object({
17056
+ events: external_exports.array(IngestEvent).min(1).max(100),
17057
+ // Dedup policy for this batch. Id-dedup ALWAYS applies. 'content-hash'
17058
+ // additionally rejects any event whose contentHash the store has already
17059
+ // recorded — for re-runnable bulk ingest (worktree scan, transcript
17060
+ // backfill), where a re-run mints fresh event ids for identical content and
17061
+ // would otherwise accumulate duplicates. Live hook traffic must NOT set it:
17062
+ // two genuinely separate prompts can be byte-identical and both belong on
17063
+ // the timeline.
17064
+ dedupe: external_exports.literal("content-hash").optional()
17065
+ }).meta({ id: "IngestBatch" });
17066
+
17067
+ // ../../packages/schema/src/zod/exception.ts
17068
+ var ExceptionScope = external_exports.enum(["once", "temporary", "permanent"]);
17069
+ var ExceptionConditions = external_exports.object({
17070
+ repo: external_exports.string().optional(),
17071
+ sourceTool: external_exports.string().optional(),
17072
+ provider: external_exports.string().optional()
17073
+ }).strict();
17074
+ var ExceptionCapability = external_exports.enum(["suppress", "reveal_to_model"]);
17075
+ var DetectionException = external_exports.object({
17076
+ id: external_exports.guid(),
17077
+ ruleId: external_exports.string(),
17078
+ // Denormalized from the rule, for reporting — never matched on.
17079
+ category: DetectionCategory,
17080
+ // HMAC-SHA256 hex of the raw match under a machine-local key: a KEYED
17081
+ // fingerprint, never the raw value, and never reversible. Matching recomputes
17082
+ // the fingerprint from a fresh capture; the value itself is never stored.
17083
+ // Shape-constrained so a malformed — or accidentally raw — value is rejected
17084
+ // at the boundary rather than persisted.
17085
+ valueFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
17086
+ // Version of the fingerprint key the grant was written under; a rotated key
17087
+ // invalidates old grants rather than silently mismatching them.
17088
+ keyVersion: external_exports.number().int().positive(),
17089
+ // maskMatch() preview of the approved value — never the raw value.
17090
+ maskedValue: external_exports.string(),
17091
+ capability: ExceptionCapability.default("suppress"),
17092
+ scope: ExceptionScope,
17093
+ expiresAt: external_exports.iso.datetime().nullable(),
17094
+ maxUses: external_exports.number().int().positive().nullable(),
17095
+ useCount: external_exports.number().int().nonnegative(),
17096
+ lastUsedAt: external_exports.iso.datetime().nullable(),
17097
+ // Mandatory: every grant carries the human reason it exists.
17098
+ justification: external_exports.string().min(1),
17099
+ conditions: ExceptionConditions.nullable(),
17100
+ createdBy: external_exports.string(),
17101
+ createdVia: external_exports.enum(["cli-approve", "cli-add", "web-approve", "web-add", "api", "setup-triage"]),
17102
+ createdAt: external_exports.iso.datetime(),
17103
+ updatedAt: external_exports.iso.datetime(),
17104
+ // Revocation is terminal and retained — consumed/expired/revoked rows are
17105
+ // audit evidence; nothing in the exception lifecycle hard-deletes.
17106
+ revokedAt: external_exports.iso.datetime().nullable(),
17107
+ revokedBy: external_exports.string().nullable(),
17108
+ revokeReason: external_exports.string().nullable()
17109
+ });
17110
+ var ExceptionBundleEntry = DetectionException.pick({
17111
+ id: true,
17112
+ ruleId: true,
17113
+ valueFingerprint: true,
17114
+ keyVersion: true,
17115
+ capability: true,
17116
+ expiresAt: true,
17117
+ maxUses: true,
17118
+ useCount: true,
17119
+ conditions: true
17120
17120
  });
17121
-
17122
- // ../../packages/schema/src/zod/egress-extraction.ts
17123
- var EgressEcosystem = external_exports.enum(["npm", "pypi", "go", "maven", "rubygems", "cargo", "composer", "nuget"]).meta({ id: "EgressEcosystem" });
17124
- var ProviderRegistryEntry = external_exports.object({
17125
- id: external_exports.string(),
17126
- name: external_exports.string(),
17127
- category: external_exports.string(),
17128
- /** Suffix-matched: 'stripe.com' matches api.stripe.com, never evilstripe.com. */
17129
- hostSuffixes: external_exports.array(external_exports.string()).min(1),
17130
- /** Canonical API base URL recorded for manifest-derived (method 'SDK') endpoints. */
17131
- apiBase: external_exports.string(),
17132
- /** Most-sensitive first; index 0 becomes the endpoint dataClass. */
17133
- defaultDataClasses: external_exports.array(DataClass).min(1),
17134
- /** SDK identifiers per ecosystem ('go' prefix-matched by path, 'maven' by group-id prefix). */
17135
- sdks: external_exports.partialRecord(EgressEcosystem, external_exports.array(external_exports.string()))
17136
- }).meta({ id: "ProviderRegistryEntry" });
17137
- var EgressCallSiteHit = external_exports.object({
17138
- file: external_exports.string(),
17139
- line: external_exports.number().int().positive(),
17140
- snippet: external_exports.string(),
17141
- dynamic: external_exports.boolean(),
17142
- vendored: external_exports.boolean()
17143
- }).meta({ id: "EgressCallSiteHit" });
17144
- var ResolvedEgressHit = external_exports.object({
17145
- host: external_exports.string(),
17146
- kind: DestinationKind,
17147
- name: external_exports.string(),
17148
- category: external_exports.string(),
17149
- trust: ShareTrustLevel,
17150
- network: DestinationNetwork.nullable(),
17151
- method: HttpMethod,
17152
- transport: Transport,
17153
- url: external_exports.string(),
17154
- template: external_exports.boolean(),
17155
- dataClass: DataClass,
17156
- site: EgressCallSiteHit
17157
- }).meta({ id: "ResolvedEgressHit" });
17158
- var EgressReconcile = external_exports.discriminatedUnion("mode", [
17159
- external_exports.object({ mode: external_exports.literal("walk"), walkedPrefix: external_exports.string() }),
17160
- external_exports.object({
17161
- mode: external_exports.literal("ledger"),
17162
- scannedFiles: external_exports.array(external_exports.string()),
17163
- deletedFiles: external_exports.array(external_exports.string())
17164
- })
17165
- ]).meta({ id: "EgressReconcile" });
17166
- var RecordProjectEgressInput = external_exports.object({
17167
- /** Stable reconcile key: 'git:<repo identity>' or 'path:<abs root>' (non-git). */
17168
- projectKey: external_exports.string().min(1),
17169
- /** Display name only — never keys reconciliation. */
17170
- project: external_exports.string(),
17171
- projectId: external_exports.string().nullable(),
17172
- reconcile: EgressReconcile,
17173
- hits: external_exports.array(ResolvedEgressHit)
17174
- }).meta({ id: "RecordProjectEgressInput" });
17175
- var EgressWriteSummary = external_exports.object({
17176
- destinations: external_exports.number().int().nonnegative(),
17177
- endpoints: external_exports.number().int().nonnegative(),
17178
- callSites: external_exports.number().int().nonnegative(),
17179
- truncated: external_exports.boolean(),
17180
- /**
17181
- * Files the cap dropped whole. Their stored rows were left untouched, so a
17182
- * ledger-keeping caller must withhold their ledger entries and read them
17183
- * again next scan.
17184
- */
17185
- droppedFiles: external_exports.array(external_exports.string()).default([])
17186
- }).meta({ id: "EgressWriteSummary" });
17121
+ var ExceptionDescriptor = DetectionException.omit({ valueFingerprint: true });
17187
17122
 
17188
17123
  // ../../packages/schema/src/zod/exception-action.ts
17189
17124
  var confirmation = external_exports.string().optional();
@@ -17396,7 +17331,13 @@ var VaultConsent = external_exports.object({
17396
17331
 
17397
17332
  // ../../packages/schema/src/zod/local.ts
17398
17333
  var WORKSPACE_SETTINGS_SPEC_VERSION = 5;
17399
- var RunMode = external_exports.enum(["standalone"]);
17334
+ var RunMode = external_exports.enum(["standalone", "attached"]);
17335
+ var ControlPlaneConnection = external_exports.object({
17336
+ endpoint: external_exports.string().min(1),
17337
+ // Display name for the deployment, shown instead of the raw endpoint.
17338
+ label: external_exports.string().min(1).optional(),
17339
+ attachedAt: external_exports.iso.datetime()
17340
+ }).meta({ id: "ControlPlaneConnection" });
17400
17341
  var SimpleDetectionPolicy = external_exports.enum(["redact", "warn"]);
17401
17342
  var HistoricalAccess = external_exports.enum(["full", "session-only"]);
17402
17343
  var ModelJudgeConsent = external_exports.object({
@@ -17405,12 +17346,10 @@ var ModelJudgeConsent = external_exports.object({
17405
17346
  });
17406
17347
  var WorkspaceSettings = external_exports.object({
17407
17348
  specVersion: external_exports.number().int().positive().default(WORKSPACE_SETTINGS_SPEC_VERSION),
17408
- // Settings files written by earlier releases may carry the retired 'attached'
17409
- // value; it parses as 'standalone' so those files keep loading.
17410
- runMode: external_exports.preprocess(
17411
- (v) => v === "attached" ? "standalone" : v,
17412
- RunMode.default("standalone")
17413
- ),
17349
+ runMode: RunMode.default("standalone"),
17350
+ // Present only while attached; a detach clears it. Its presence is what makes
17351
+ // `runMode: 'attached'` mean anything — see isAttached.
17352
+ controlPlane: ControlPlaneConnection.optional(),
17414
17353
  policy: SimpleDetectionPolicy.default("redact"),
17415
17354
  // Consent for scanning pre-install surfaces; opt-in (see HistoricalAccess).
17416
17355
  historicalAccess: HistoricalAccess.default("session-only"),
@@ -17436,6 +17375,195 @@ var WorkspaceSettings = external_exports.object({
17436
17375
  modelJudgeConsent: ModelJudgeConsent.optional()
17437
17376
  });
17438
17377
 
17378
+ // ../../packages/schema/src/zod/managed.ts
17379
+ var MANAGED_SETTINGS_SPEC_VERSION = 1;
17380
+ var ManagedSettingKey = external_exports.enum([
17381
+ "runMode",
17382
+ "historicalAccess",
17383
+ "vaultConsent",
17384
+ "vaultKeyCustody",
17385
+ "vaultInlineReveal",
17386
+ "modelJudgeConsent",
17387
+ "dataSharesInPlace"
17388
+ ]).meta({ id: "ManagedSettingKey" });
17389
+ var ManagedSettingsValues = external_exports.object({
17390
+ runMode: external_exports.enum(["standalone", "attached"]).optional(),
17391
+ controlPlane: external_exports.object({
17392
+ endpoint: external_exports.string().min(1),
17393
+ label: external_exports.string().min(1).optional()
17394
+ }).optional(),
17395
+ historicalAccess: external_exports.enum(["full", "session-only"]).optional(),
17396
+ vaultConsent: external_exports.boolean().optional(),
17397
+ vaultKeyCustody: external_exports.enum(["file", "keychain"]).optional(),
17398
+ vaultInlineReveal: external_exports.enum(["masked", "full", "off"]).optional(),
17399
+ modelJudgeConsent: external_exports.boolean().optional(),
17400
+ dataSharesInPlace: external_exports.boolean().optional()
17401
+ }).meta({ id: "ManagedSettingsValues" });
17402
+ var ManagedSettings = external_exports.object({
17403
+ specVersion: external_exports.number().int().positive().default(MANAGED_SETTINGS_SPEC_VERSION),
17404
+ // Shown on every locked control, so the user can tell an administrative
17405
+ // decision from a bug. Absent renders as a generic "your organization".
17406
+ organization: external_exports.string().min(1).optional(),
17407
+ // What the administrator pinned.
17408
+ values: ManagedSettingsValues.default({}),
17409
+ // Which of those the user may not change. A key here with no matching value
17410
+ // freezes whatever the user last chose; a value with no lock is a DEFAULT
17411
+ // the user may still override. The two are separable on purpose.
17412
+ lockedFields: external_exports.array(ManagedSettingKey).default([])
17413
+ }).meta({ id: "ManagedSettings" });
17414
+
17415
+ // ../../packages/schema/src/zod/policy.ts
17416
+ var PolicyScope = external_exports.enum(["global", "repo", "user"]).meta({ id: "PolicyScope" });
17417
+ var PolicyTarget = external_exports.union([external_exports.object({ ruleId: external_exports.string() }), external_exports.object({ category: DetectionCategory })]).meta({ id: "PolicyTarget" });
17418
+ var Policy = external_exports.object({
17419
+ id: external_exports.guid(),
17420
+ scope: PolicyScope,
17421
+ target: PolicyTarget,
17422
+ action: ActionTaken,
17423
+ enabled: external_exports.boolean().default(true),
17424
+ customKeywords: external_exports.array(external_exports.string()).optional(),
17425
+ // Display name — optional so older policy rows without name still parse.
17426
+ // Added for the findings API (policy.name column migration).
17427
+ name: external_exports.string().optional()
17428
+ }).meta({ id: "Policy" });
17429
+ var PolicyBundle = external_exports.object({
17430
+ version: external_exports.string(),
17431
+ policies: external_exports.array(Policy),
17432
+ // Rules from the installed marketplace packs (snapshotted by the
17433
+ // control plane). The plugin registers these in addition to its bundled
17434
+ // packs. Optional so older backends — and older on-disk caches — that omit
17435
+ // the field still parse; consumers read `bundle.rules ?? []`.
17436
+ rules: external_exports.array(Rule).optional(),
17437
+ // When true, `rules` IS the complete effective ruleset and the runtime must
17438
+ // NOT merge its compiled-in bundled packs — the standalone gateway sets this
17439
+ // after reading the user's installed snapshot (installed_packs, enabled
17440
+ // packs only), which is how detection updates stay manual: new bundled
17441
+ // rules run only after the user applies the pack update. Absent/false keeps
17442
+ // the historical composition (bundled packs + rules) — older caches.
17443
+ rulesComplete: external_exports.boolean().optional(),
17444
+ // Active detection exceptions, evaluation subset only (see
17445
+ // ExceptionBundleEntry). Optional so older bundle producers — and older
17446
+ // on-disk caches — that omit the field still parse; consumers read
17447
+ // `bundle.exceptions ?? []`.
17448
+ exceptions: external_exports.array(ExceptionBundleEntry).optional(),
17449
+ // Rule ids whose pack is assigned a REVERSIBLE archetype (Redact & Vault).
17450
+ // A second axis over the same `redact` action, carried beside the policies
17451
+ // rather than on them: nothing writes ruleId-targeted policies to disk, so
17452
+ // widening Policy itself would change a persisted shape to express something
17453
+ // only the in-memory bundle needs. Optional so an older producer — or an
17454
+ // older on-disk cache — still parses; consumers read `?? []` and get the
17455
+ // pre-existing one-way behaviour, which is the safe direction to default.
17456
+ reversibleRuleIds: external_exports.array(external_exports.string()).optional(),
17457
+ // Installed pack version, keyed by ruleId, for rules in `rules` that came
17458
+ // from a versioned installed pack. Optional so older backends — and older
17459
+ // on-disk caches — that omit the field still parse; consumers fall back to
17460
+ // the rule's own spec version. NOT the bundle version above — see
17461
+ // installedRuleset's ruleVersions for the source of truth.
17462
+ ruleVersions: external_exports.record(external_exports.string(), external_exports.string()).optional(),
17463
+ customKeywords: external_exports.array(external_exports.string()),
17464
+ fetchedAt: external_exports.iso.datetime()
17465
+ }).meta({ id: "PolicyBundle" });
17466
+ var OBSERVE_ONLY_CATEGORIES = ["config"];
17467
+ var ENFORCEABLE_CATEGORIES = DetectionCategory.options.filter((c) => !OBSERVE_ONLY_CATEGORIES.includes(c));
17468
+ var CATEGORY_PEAK_SEVERITY = {
17469
+ secret: "critical",
17470
+ financial: "critical",
17471
+ // core-financial/credit-card
17472
+ code_flaw: "critical",
17473
+ pii: "high",
17474
+ phi: "high",
17475
+ custom: "high",
17476
+ // user-defined; conservative
17477
+ code_context: "low",
17478
+ config: "low"
17479
+ // observe-only; floors to monitor regardless
17480
+ };
17481
+ function severityFloorPolicy(category) {
17482
+ if (OBSERVE_ONLY_CATEGORIES.includes(category)) return "monitor";
17483
+ const peak = CATEGORY_PEAK_SEVERITY[category];
17484
+ return peak === "critical" || peak === "high" ? "warn" : "monitor";
17485
+ }
17486
+ var PolicyKind = external_exports.enum(["builtin", "custom"]).meta({ id: "PolicyKind" });
17487
+ var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
17488
+ var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
17489
+ var BUILTIN_POLICY_SPECS = {
17490
+ monitor: {
17491
+ name: "Monitor",
17492
+ action: "log",
17493
+ reversible: false,
17494
+ description: "Log every match for audit. The request is allowed through untouched."
17495
+ },
17496
+ warn: {
17497
+ name: "Warn",
17498
+ action: "warn",
17499
+ reversible: false,
17500
+ description: "Allow the request, but warn the user inline before it is sent."
17501
+ },
17502
+ redact: {
17503
+ name: "Redact",
17504
+ action: "redact",
17505
+ reversible: false,
17506
+ description: "Strip the matched value from the request and destroy it, then continue. What was removed cannot be recovered."
17507
+ },
17508
+ vault: {
17509
+ name: "Redact & Vault",
17510
+ action: "redact",
17511
+ reversible: true,
17512
+ description: "Strip the matched value from the request and keep an encrypted, recoverable copy in the local vault, leaving a pointer in its place. Needs the vault consent granted under Settings; without it this behaves as Redact."
17513
+ },
17514
+ block: {
17515
+ name: "Block",
17516
+ action: "block",
17517
+ reversible: false,
17518
+ description: "Refuse the request entirely whenever any rule in this detection matches."
17519
+ }
17520
+ };
17521
+ function builtinPolicyToAction(id) {
17522
+ return BUILTIN_POLICY_SPECS[id].action;
17523
+ }
17524
+ var CATEGORY_EXPRESSIBLE_IDS = KNOWN_BUILTIN_IDS.filter(
17525
+ (id) => !BUILTIN_POLICY_SPECS[id].reversible
17526
+ );
17527
+ var CATEGORY_INEXPRESSIBLE_IDS = KNOWN_BUILTIN_IDS.filter(
17528
+ (id) => BUILTIN_POLICY_SPECS[id].reversible
17529
+ );
17530
+ var CategoryPolicyId = external_exports.enum(CATEGORY_EXPRESSIBLE_IDS).meta({ id: "CategoryPolicyId" });
17531
+ var DEFAULT_ACTIONS = Object.fromEntries(
17532
+ DetectionCategory.options.map((c) => [c, builtinPolicyToAction(severityFloorPolicy(c))])
17533
+ );
17534
+ var BUILTIN_POLICIES = Object.fromEntries(
17535
+ KNOWN_BUILTIN_IDS.map((id) => [id, { id, ...BUILTIN_POLICY_SPECS[id] }])
17536
+ );
17537
+ var UsedByItem = external_exports.object({
17538
+ id: external_exports.string(),
17539
+ name: external_exports.string(),
17540
+ ruleCount: external_exports.number().int().nonnegative(),
17541
+ enabled: external_exports.boolean()
17542
+ }).meta({ id: "UsedByItem" });
17543
+ var PolicyListItem = external_exports.object({
17544
+ id: external_exports.string(),
17545
+ kind: PolicyKind,
17546
+ name: external_exports.string(),
17547
+ enabled: external_exports.boolean(),
17548
+ usedByCount: external_exports.number().int().nonnegative()
17549
+ }).meta({ id: "PolicyListItem" });
17550
+ var ListPoliciesResponse = external_exports.object({ items: external_exports.array(PolicyListItem) }).meta({ id: "ListPoliciesResponse" });
17551
+ var PolicyDetail = external_exports.object({
17552
+ specVersion: external_exports.literal(1),
17553
+ id: external_exports.string(),
17554
+ kind: PolicyKind,
17555
+ name: external_exports.string(),
17556
+ enabled: external_exports.boolean(),
17557
+ description: external_exports.string(),
17558
+ usedBy: external_exports.array(UsedByItem)
17559
+ }).meta({ id: "PolicyDetail" });
17560
+ var PolicyStatsResponse = external_exports.object({
17561
+ policies: external_exports.number().int().nonnegative(),
17562
+ builtin: external_exports.number().int().nonnegative(),
17563
+ custom: external_exports.number().int().nonnegative(),
17564
+ detectionsGoverned: external_exports.number().int().nonnegative()
17565
+ }).meta({ id: "PolicyStatsResponse" });
17566
+
17439
17567
  // ../../packages/schema/src/zod/project-files.ts
17440
17568
  var ProjectFileInput = external_exports.object({
17441
17569
  path: external_exports.string().min(1),
@@ -17508,44 +17636,6 @@ var BatchedRemediation = external_exports.discriminatedUnion("kind", [
17508
17636
  NoRemediationDecision
17509
17637
  ]);
17510
17638
 
17511
- // ../../packages/schema/src/zod/rule-test.ts
17512
- var TestRulesRequest = external_exports.object({
17513
- rules: external_exports.array(Rule).min(1).max(100),
17514
- text: external_exports.string().max(5e4).optional(),
17515
- fixtures: external_exports.array(RuleFixture).max(200).optional()
17516
- }).refine((v) => v.text !== void 0 || (v.fixtures?.length ?? 0) > 0, {
17517
- message: "Provide `text`, `fixtures`, or both \u2014 there must be something to test"
17518
- }).meta({ id: "TestRulesRequest" });
17519
- var RuleTestMatch = external_exports.object({
17520
- ruleId: external_exports.string(),
17521
- category: DetectionCategory,
17522
- severity: Severity,
17523
- span: Span,
17524
- confidence: external_exports.number().min(0).max(1),
17525
- match: external_exports.string()
17526
- }).meta({ id: "RuleTestMatch" });
17527
- var FixtureResult = external_exports.object({
17528
- label: external_exports.string(),
17529
- shouldMatch: external_exports.boolean(),
17530
- didMatch: external_exports.boolean(),
17531
- passed: external_exports.boolean(),
17532
- matches: external_exports.array(RuleTestMatch)
17533
- }).meta({ id: "FixtureResult" });
17534
- var TestRulesResponse = external_exports.object({
17535
- // Present only when the request supplied `text`.
17536
- adhoc: external_exports.object({ matches: external_exports.array(RuleTestMatch) }).optional(),
17537
- fixtures: external_exports.array(FixtureResult),
17538
- summary: external_exports.object({
17539
- total: external_exports.number().int().nonnegative(),
17540
- passed: external_exports.number().int().nonnegative(),
17541
- failed: external_exports.number().int().nonnegative()
17542
- }),
17543
- // Ids of rules whose matcher type the engine cannot evaluate today (e.g.
17544
- // `validator`), so they silently never match. Surfaced so an author is not
17545
- // misled by a green run that actually skipped a rule.
17546
- unsupportedRuleIds: external_exports.array(external_exports.string())
17547
- }).meta({ id: "TestRulesResponse" });
17548
-
17549
17639
  // ../../packages/schema/src/zod/security.ts
17550
17640
  var SeveritySummaryItem = external_exports.object({
17551
17641
  severity: Severity,
@@ -17643,10 +17733,22 @@ var TopSourcesQuery = external_exports.object({
17643
17733
  // Omit for both kinds.
17644
17734
  kind: external_exports.enum(SOURCE_KINDS).optional()
17645
17735
  });
17646
- var Provider = external_exports.enum(["claudecode", "cursor", "codex", "antigravity", "claudeai", "chatgpt", "copilot", "api"]).meta({ id: "Provider" });
17736
+ var Provider = Harness.extract([
17737
+ "ClaudeCode",
17738
+ "Cursor",
17739
+ "Codex",
17740
+ "Antigravity",
17741
+ "ClaudeAi",
17742
+ "ChatGpt",
17743
+ "Copilot",
17744
+ "Api"
17745
+ ]).meta({ id: "Provider" });
17647
17746
  var ScanCoverageProvider = external_exports.object({
17648
17747
  provider: Provider,
17649
- // Percent of that provider's traffic scanned in the window. 0 when unsupported.
17748
+ // Percent of that provider's traffic the shipped capture surface reaches.
17749
+ // A curated business fact, constant across every `range` — not a measured
17750
+ // per-window metric. 0 exactly when `supported` is false. See the comment
17751
+ // above the block for where these numbers are decided.
17650
17752
  coverage: external_exports.number().int().min(0).max(100),
17651
17753
  supported: external_exports.boolean()
17652
17754
  }).meta({ id: "ScanCoverageProvider" });
@@ -17700,6 +17802,18 @@ var ApplyRecommendedActionResponse = external_exports.object({
17700
17802
  var DismissRecommendedActionResponse = external_exports.object({ id: external_exports.string(), status: external_exports.literal("dismissed") }).meta({ id: "DismissRecommendedActionResponse" });
17701
17803
  var RecommendedActionIdParam = external_exports.object({ id: external_exports.string() });
17702
17804
 
17805
+ // ../../packages/schema/src/zod/settings-action.ts
17806
+ var SaveSettingsInput = external_exports.object({
17807
+ historicalAccess: external_exports.string(),
17808
+ modelJudgeConsent: external_exports.boolean(),
17809
+ vaultConsent: external_exports.string(),
17810
+ vaultInlineReveal: external_exports.string()
17811
+ });
17812
+ var AttachInput = external_exports.object({
17813
+ endpoint: external_exports.string(),
17814
+ label: external_exports.string().optional()
17815
+ });
17816
+
17703
17817
  // ../../packages/schema/src/zod/triage.ts
17704
17818
  var TriageHit = external_exports.object({
17705
17819
  ruleId: external_exports.string(),
@@ -17714,7 +17828,7 @@ var TriageHit = external_exports.object({
17714
17828
  valueFingerprint: external_exports.string().optional(),
17715
17829
  keyVersion: external_exports.number().int().nonnegative().optional()
17716
17830
  });
17717
- var TriagePolicy = BuiltinPolicyId;
17831
+ var TriagePolicy = CategoryPolicyId;
17718
17832
  var TriageCategoryRec = external_exports.object({
17719
17833
  category: DetectionCategory,
17720
17834
  action: TriagePolicy,
@@ -17951,24 +18065,39 @@ function probesFor(rule) {
17951
18065
  const derived = rule.matcher.type === "regex" ? derivedProbes(rule.matcher.pattern) : [];
17952
18066
  return [...derived, ...EXPONENTIAL_PROBES, ...POLYNOMIAL_PROBES];
17953
18067
  }
17954
- function worstProbeMs(rule) {
18068
+ var wallClock = () => performance.now();
18069
+ function worstProbeMs(rule, now = wallClock, corroborate) {
17955
18070
  let ms = 0;
17956
18071
  let probe = "";
18072
+ let corroboratedMs;
17957
18073
  for (const text of probesFor(rule)) {
17958
- const start = performance.now();
18074
+ const start = now();
18075
+ const corroborateStart = corroborate?.();
17959
18076
  scan(text, [rule]);
17960
- const elapsed = performance.now() - start;
18077
+ const elapsed = now() - start;
18078
+ const corroborateEnd = corroborate?.();
17961
18079
  if (elapsed > ms) {
17962
18080
  ms = elapsed;
17963
18081
  probe = text;
18082
+ corroboratedMs = corroborateStart === void 0 || corroborateEnd === void 0 ? void 0 : corroborateEnd - corroborateStart;
17964
18083
  }
17965
18084
  if (ms >= BUDGET_MS) break;
17966
18085
  }
17967
- return { ms, probe };
18086
+ return { ms, probe, corroboratedMs };
17968
18087
  }
17969
- function checkRuleTiming(rule) {
17970
- const { ms, probe } = worstProbeMs(rule);
17971
- return { safe: ms < BUDGET_MS, worstMs: ms, probe };
18088
+ var CPU_CORROBORATION_SHARE = 0.2;
18089
+ var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
18090
+ function checkRuleTiming(rule, corroborate) {
18091
+ const { ms, probe, corroboratedMs } = worstProbeMs(rule, wallClock, corroborate);
18092
+ const work = corroboratedMs ?? 0;
18093
+ const verdict = ms < BUDGET_MS ? "safe" : work >= CORROBORATION_FLOOR_MS ? "over-budget" : "uncorroborated";
18094
+ return { verdict, worstMs: ms, corroboratedMs: work, probe };
18095
+ }
18096
+
18097
+ // ../../packages/plugin-sdk/src/work-clock.ts
18098
+ function workClockMs() {
18099
+ const usage = typeof process.threadCpuUsage === "function" ? process.threadCpuUsage() : process.cpuUsage();
18100
+ return (usage.user + usage.system) / 1e3;
17972
18101
  }
17973
18102
 
17974
18103
  // ../../packages/plugin-sdk/src/scan-worker.ts
@@ -17982,8 +18111,8 @@ function post(message) {
17982
18111
  port.on("message", (job) => {
17983
18112
  try {
17984
18113
  if (job.kind === "probe") {
17985
- const { safe, worstMs } = checkRuleTiming(job.rule);
17986
- post({ kind: "probed", id: job.id, safe, worstMs });
18114
+ const { verdict, worstMs, corroboratedMs } = checkRuleTiming(job.rule, workClockMs);
18115
+ post({ kind: "probed", id: job.id, verdict, worstMs, corroboratedMs });
17987
18116
  return;
17988
18117
  }
17989
18118
  const context = job.filePath === void 0 ? void 0 : { filePath: job.filePath };