@akasecurity/ai-tc-claude-code 0.9.6 → 0.9.8

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.
@@ -492,13 +492,12 @@ var require_ignore = __commonJS({
492
492
  });
493
493
 
494
494
  // ../../packages/plugin-sdk/src/config.ts
495
- import { existsSync as existsSync5 } from "fs";
496
- import { join as join8 } from "path";
495
+ import { existsSync as existsSync6 } from "fs";
496
+ import { join as join10 } from "path";
497
497
 
498
- // ../../packages/persistence/src/database.ts
499
- import { randomUUID as randomUUID10 } from "crypto";
500
- import { join as join2, sep } from "path";
501
- import { DatabaseSync } from "node:sqlite";
498
+ // ../../packages/persistence/src/control-plane-credential.ts
499
+ import { chmodSync as chmodSync2, lstatSync as lstatSync2, readFileSync, rmSync as rmSync2, statSync } from "fs";
500
+ import { join } from "path";
502
501
 
503
502
  // ../../packages/schema/src/exception-scope.ts
504
503
  var MINUTE_MS = 6e4;
@@ -15070,6 +15069,47 @@ function date4(params) {
15070
15069
  // ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
15071
15070
  config(en_default());
15072
15071
 
15072
+ // ../../packages/schema/src/zod/harness-map.ts
15073
+ var HARNESS = {
15074
+ ClaudeCode: "claudecode",
15075
+ Cursor: "cursor",
15076
+ Copilot: "copilot",
15077
+ Codex: "codex",
15078
+ Antigravity: "antigravity",
15079
+ Windsurf: "windsurf",
15080
+ ClaudeDesktop: "claudedesktop",
15081
+ ChatGpt: "chatgpt",
15082
+ ClaudeAi: "claudeai",
15083
+ Api: "api"
15084
+ };
15085
+ var Harness = external_exports.enum(HARNESS).meta({ id: "Harness" });
15086
+ var SOURCE_TOOL = {
15087
+ ClaudeCode: "claude-code",
15088
+ ClaudeDesktop: "claude-desktop",
15089
+ Cursor: "cursor",
15090
+ ChatGpt: "chatgpt",
15091
+ ClaudeAi: "claude-ai",
15092
+ Copilot: "github-copilot",
15093
+ Codex: "codex",
15094
+ Antigravity: "antigravity",
15095
+ // No harness counterpart, deliberately: the CLI's own captures and a capture
15096
+ // whose tool could not be identified both render through the read side's
15097
+ // miss path rather than as a harness of their own.
15098
+ Cli: "cli",
15099
+ Unknown: "unknown"
15100
+ };
15101
+ var SourceTool = external_exports.enum(SOURCE_TOOL).meta({ id: "SourceTool" });
15102
+ var TOOL_TO_HARNESS = {
15103
+ [SOURCE_TOOL.ClaudeCode]: HARNESS.ClaudeCode,
15104
+ [SOURCE_TOOL.ClaudeDesktop]: HARNESS.ClaudeDesktop,
15105
+ [SOURCE_TOOL.Copilot]: HARNESS.Copilot,
15106
+ [SOURCE_TOOL.Cursor]: HARNESS.Cursor,
15107
+ [SOURCE_TOOL.ChatGpt]: HARNESS.ChatGpt,
15108
+ [SOURCE_TOOL.Codex]: HARNESS.Codex,
15109
+ [SOURCE_TOOL.Antigravity]: HARNESS.Antigravity,
15110
+ [SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi
15111
+ };
15112
+
15073
15113
  // ../../packages/schema/src/zod/finding.ts
15074
15114
  var DetectionCategory = external_exports.enum(["pii", "financial", "secret", "phi", "code_context", "code_flaw", "custom", "config"]).meta({ id: "DetectionCategory" });
15075
15115
  var Severity = external_exports.enum(["critical", "high", "medium", "low"]).meta({ id: "Severity" });
@@ -15092,21 +15132,22 @@ var Finding = external_exports.object({
15092
15132
  }).meta({ id: "Finding" });
15093
15133
  var DetectedFinding = Finding.meta({ id: "DetectedFinding" });
15094
15134
  var FindingAction = external_exports.enum(["blocked", "redacted", "warned", "allowed", "quarantined", "monitored"]).meta({ id: "FindingAction" });
15095
- var FindingProvider = external_exports.enum([
15096
- "claudecode",
15097
- "claudedesktop",
15098
- "cursor",
15099
- "copilot",
15100
- "chatgpt",
15101
- "claudeai",
15102
- "codex",
15103
- "antigravity",
15104
- "api"
15135
+ var FindingProvider = Harness.extract([
15136
+ "ClaudeCode",
15137
+ "ClaudeDesktop",
15138
+ "Cursor",
15139
+ "Copilot",
15140
+ "ChatGpt",
15141
+ "ClaudeAi",
15142
+ "Codex",
15143
+ "Antigravity",
15144
+ "Api"
15105
15145
  ]).meta({ id: "FindingProvider" });
15106
15146
  var FindingCategory = external_exports.enum([
15107
15147
  "secret",
15108
15148
  "pii",
15109
15149
  "source_code",
15150
+ "code_flaw",
15110
15151
  "external_share",
15111
15152
  "mcp_server",
15112
15153
  "customer_data",
@@ -15284,6 +15325,7 @@ var FindingInstanceDetail = FindingInstance.extend({
15284
15325
  detection: FindingDetectionRef,
15285
15326
  policy: FindingPolicyRef
15286
15327
  }).meta({ id: "FindingInstanceDetail" });
15328
+ var MAX_FLAT_FINDINGS_LIMIT = 200;
15287
15329
  var ListFindingInstancesQuery = external_exports.object({
15288
15330
  severity: external_exports.array(Severity).optional(),
15289
15331
  // Rule ids, the same vocabulary the grouped list's `subtype` carries.
@@ -15303,7 +15345,7 @@ var ListFindingInstancesQuery = external_exports.object({
15303
15345
  q: external_exports.string().optional(),
15304
15346
  sessionId: external_exports.string().optional(),
15305
15347
  from: external_exports.iso.datetime().optional(),
15306
- limit: external_exports.coerce.number().int().min(1).max(200).optional(),
15348
+ limit: external_exports.coerce.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
15307
15349
  cursor: external_exports.string().optional()
15308
15350
  });
15309
15351
  var ListFindingInstancesResponse = external_exports.object({
@@ -15365,20 +15407,6 @@ var ListFindingLocationsResponse = external_exports.object({
15365
15407
  hasMore: external_exports.boolean()
15366
15408
  }).meta({ id: "ListFindingLocationsResponse" });
15367
15409
 
15368
- // ../../packages/schema/src/zod/harness-map.ts
15369
- var Harness = external_exports.enum([
15370
- "claudecode",
15371
- "cursor",
15372
- "copilot",
15373
- "codex",
15374
- "antigravity",
15375
- "windsurf",
15376
- "claudedesktop",
15377
- "chatgpt",
15378
- "claudeai",
15379
- "api"
15380
- ]).meta({ id: "Harness" });
15381
-
15382
15410
  // ../../packages/schema/src/zod/meta.ts
15383
15411
  var InventoryObjectType = external_exports.enum(["host", "harness", "user", "skill", "hook", "mcp_server", "config_file"]).meta({ id: "InventoryObjectType" });
15384
15412
  var AuditEventType = external_exports.enum([
@@ -15828,366 +15856,240 @@ var ActivityOverviewResponse = external_exports.object({
15828
15856
  sessions: ListActivitySessionsResponse
15829
15857
  }).meta({ id: "ActivityOverviewResponse" });
15830
15858
 
15831
- // ../../packages/schema/src/zod/event.ts
15832
- var EventKind = external_exports.enum(["prompt", "response", "code_change", "tool_use"]).meta({ id: "EventKind" });
15833
- var CAPTURE_EVENT_TYPES_SQL = EventKind.options.map((k) => `'${k}'`).join(",");
15834
- var SourceTool = external_exports.enum([
15835
- "claude-code",
15836
- "claude-desktop",
15837
- "cursor",
15838
- "chatgpt",
15839
- "claude-ai",
15840
- "github-copilot",
15841
- "codex",
15842
- "antigravity",
15843
- "cli",
15844
- "unknown"
15845
- ]).meta({ id: "SourceTool" });
15846
- var EventMetadata = external_exports.object({
15847
- sessionId: external_exports.string().optional(),
15848
- repo: external_exports.string().optional(),
15849
- filePath: external_exports.string().optional(),
15850
- // The host tool whose input/output was scanned (e.g. 'Bash', 'WebFetch'),
15851
- // set by the tool-scanning hooks. The tool NAME only — never the tool's
15852
- // arguments or output, which can carry the very value a finding masked
15853
- // (metadata is stored unredacted). Gives findings on non-file captures a
15854
- // display location ("via Bash") when no filePath exists.
15855
- toolName: external_exports.string().optional(),
15856
- // Set (true) by the worktree scanner when the file is excluded by the
15857
- // repo's .gitignore. Gitignored files ARE still scanned — local scratch and
15858
- // generated code can leak real secrets — but the provenance is recorded so
15859
- // policy/dashboards can treat those findings as informational rather than
15860
- // blocking. Omitted (not false) for tracked files and non-scan events.
15861
- gitignored: external_exports.boolean().optional(),
15862
- // Set (true) ONLY when the event's `content` is the COMPLETE file at
15863
- // capture time (a worktree scan reading from disk). Hook-captured edits
15864
- // (e.g. an Edit tool's new_string) are partial fragments and MUST NOT set
15865
- // this. The resolver-on-ingest keys its fixed-at-source dropout
15866
- // diff on this marker: only a whole-file snapshot can prove a previously
15867
- // open finding is gone; a fragment's absence proves nothing (the secret
15868
- // may live outside the hunk). Omitted (not false) for fragments and
15869
- // non-scan events, so pre-marker clients safely default to the
15870
- // non-authoritative path.
15871
- wholeFile: external_exports.boolean().optional(),
15872
- model: external_exports.string().optional(),
15873
- turnIndex: external_exports.number().int().nonnegative().optional(),
15874
- // Distributed-tracing correlation. `correlationId` ties a recorded event back
15875
- // to the request that captured/ingested it (a UUID, generated independently of
15876
- // the trace id); `traceId` is the W3C trace id (32 lowercase hex chars) of the
15877
- // originating span when telemetry is enabled. Both optional + backward
15878
- // compatible — populated by the plugin (see @akasecurity/plugin-sdk).
15879
- correlationId: external_exports.uuid().optional(),
15880
- traceId: external_exports.string().regex(/^[0-9a-f]{32}$/).optional(),
15881
- // Ids of the detection exceptions that downgraded findings in this capture
15882
- // to 'allow' — the enforcement audit trail's link back to the grant that
15883
- // authorized the bypass. Absent on captures where no exception applied.
15884
- exceptionIds: external_exports.array(external_exports.guid()).optional()
15885
- }).meta({ id: "EventMetadata" });
15886
- var Event = external_exports.object({
15887
- id: external_exports.guid(),
15888
- sourceTool: SourceTool,
15889
- kind: EventKind,
15890
- occurredAt: external_exports.iso.datetime(),
15891
- contentHash: external_exports.string(),
15892
- content: external_exports.string(),
15893
- metadata: EventMetadata.optional()
15894
- }).meta({ id: "Event" });
15895
- var IngestEvent = Event.meta({ id: "IngestEvent" });
15896
- var IngestBatch = external_exports.object({
15897
- events: external_exports.array(IngestEvent).min(1).max(100),
15898
- // Dedup policy for this batch. Id-dedup ALWAYS applies. 'content-hash'
15899
- // additionally rejects any event whose contentHash the store has already
15900
- // recorded — for re-runnable bulk ingest (worktree scan, transcript
15901
- // backfill), where a re-run mints fresh event ids for identical content and
15902
- // would otherwise accumulate duplicates. Live hook traffic must NOT set it:
15903
- // two genuinely separate prompts can be byte-identical and both belong on
15904
- // the timeline.
15905
- dedupe: external_exports.literal("content-hash").optional()
15906
- }).meta({ id: "IngestBatch" });
15907
-
15908
- // ../../packages/schema/src/zod/inventory.ts
15909
- var AssetType = external_exports.enum(["project", "skill", "mcp", "hook", "config"]).meta({ id: "AssetType" });
15910
- var AccessLevel = external_exports.enum(["open", "approved", "blocked"]).meta({ id: "AccessLevel" });
15911
- var Origin = external_exports.enum(["source", "public-dep", "vendored", "config", "data", "docs", "generated"]).meta({ id: "Origin" });
15912
- var TrustLevel = external_exports.enum(["known-good", "risky", "unapproved"]).meta({ id: "TrustLevel" });
15913
- var Flag = external_exports.enum(["update", "stale", "conflict", "unknown", "change", "untracked", "risk", "findings"]).meta({ id: "Flag" });
15914
- var Visibility = external_exports.enum(["public", "private"]).meta({ id: "Visibility" });
15915
- var HarnessEventKind = external_exports.enum(["block", "redact", "warn"]).meta({ id: "HarnessEventKind" });
15916
- var HarnessId = external_exports.enum(["claudecode", "cursor", "codex", "antigravity"]).meta({ id: "HarnessId" });
15917
- var AccessCounts = external_exports.object({
15918
- open: external_exports.number().int().nonnegative(),
15919
- approved: external_exports.number().int().nonnegative(),
15920
- blocked: external_exports.number().int().nonnegative(),
15921
- total: external_exports.number().int().nonnegative()
15922
- }).meta({ id: "AccessCounts" });
15923
- var AssetSummary = external_exports.object({
15924
- id: external_exports.string(),
15925
- type: AssetType,
15926
- name: external_exports.string(),
15927
- sub: external_exports.string(),
15928
- flags: external_exports.array(Flag),
15929
- /** MCP servers only — omitted for all other types. */
15930
- trust: TrustLevel.optional()
15931
- }).meta({ id: "AssetSummary" });
15932
- var ProjectSummary = external_exports.object({
15933
- id: external_exports.string(),
15934
- name: external_exports.string(),
15935
- repo: external_exports.string(),
15936
- visibility: Visibility,
15937
- language: external_exports.string(),
15938
- policyDefault: AccessLevel,
15939
- updatedAt: external_exports.iso.datetime(),
15940
- accessCounts: AccessCounts,
15941
- findingsCount: external_exports.number().int().nonnegative()
15942
- }).meta({ id: "ProjectSummary" });
15943
- var HarnessCategory = external_exports.object({
15944
- /** One of config/skill/mcp/hook — never project (enforced at service layer). */
15945
- type: AssetType,
15946
- assets: external_exports.array(AssetSummary)
15859
+ // ../../packages/schema/src/zod/config-inventory.ts
15860
+ var ConfigScope = external_exports.enum(["user", "project", "local", "plugin"]);
15861
+ var SkillScanEntry = external_exports.object({
15862
+ name: external_exports.string().min(1),
15863
+ // The identity source: a marketplace repo for plugin skills (e.g.
15864
+ // 'anthropics/skills'), 'local' for personal ~/.claude/skills, or
15865
+ // 'project:<repo-identity>' for checked-in project skills. The surrogate keeps
15866
+ // a personal skill named 'pdf' from colliding with the marketplace 'pdf'.
15867
+ source: external_exports.string().min(1),
15868
+ scope: ConfigScope,
15869
+ pluginName: external_exports.string().optional(),
15870
+ // Volatile — rides the attribute bag, never the identity hash.
15871
+ version: external_exports.string().optional(),
15872
+ description: external_exports.string().optional(),
15873
+ // Skill directory mtime (ISO) the "updated Nd ago" freshness signal.
15874
+ updatedAt: external_exports.iso.datetime().optional(),
15875
+ // Filesystem path — the promoted inventory `location` column.
15876
+ location: external_exports.string().optional()
15947
15877
  });
15948
- var HarnessSummary = external_exports.object({
15949
- id: HarnessId,
15950
- label: external_exports.string(),
15951
- kind: external_exports.string(),
15952
- version: external_exports.string(),
15953
- sessions: external_exports.number().int().nonnegative(),
15954
- assetCount: external_exports.number().int().nonnegative(),
15955
- flagCount: external_exports.number().int().nonnegative(),
15956
- projects: external_exports.array(ProjectSummary),
15957
- categories: external_exports.array(HarnessCategory)
15958
- }).meta({ id: "HarnessSummary" });
15959
- var ListHarnessesResponse = external_exports.object({ items: external_exports.array(HarnessSummary) }).meta({ id: "ListHarnessesResponse" });
15960
- var AssetGroup = external_exports.object({
15961
- /** Group key — never project (enforced at service layer). */
15962
- type: AssetType,
15963
- total: external_exports.number().int().nonnegative(),
15964
- /**
15965
- * MCP group only — omitted for all other types.
15966
- * Partial: only TrustLevel keys with non-zero counts are included.
15967
- * Strict: unknown keys are rejected only TrustLevel values are valid keys.
15968
- */
15969
- trustRollup: external_exports.object({
15970
- "known-good": external_exports.number().int().nonnegative(),
15971
- risky: external_exports.number().int().nonnegative(),
15972
- unapproved: external_exports.number().int().nonnegative()
15973
- }).partial().strict().optional(),
15878
+ var HookScanEntry = external_exports.object({
15879
+ // Hook event name (PreToolUse, PostToolUse, …). Open string, not an enum: the
15880
+ // set is harness-defined and grows without a schema change.
15881
+ event: external_exports.string().min(1),
15882
+ // The tool matcher ('Bash', 'Edit|Write', …). Absent = matches all tools.
15883
+ matcher: external_exports.string().optional(),
15884
+ command: external_exports.string().min(1),
15885
+ timeout: external_exports.number().optional(),
15886
+ scope: ConfigScope,
15887
+ pluginName: external_exports.string().optional(),
15888
+ // The settings file / hooks.json the entry came from.
15889
+ location: external_exports.string().optional()
15890
+ });
15891
+ var McpServerScanEntry = external_exports.object({
15892
+ // The server's config key ("github", "filesystem", …) — identity, with the
15893
+ // qualified scope (see mcpServerIdentityKey).
15894
+ name: external_exports.string().min(1),
15895
+ scope: ConfigScope,
15896
+ pluginName: external_exports.string().optional(),
15897
+ // The owning plugin's marketplacepart of PLUGIN-scope identity: two
15898
+ // marketplaces can each ship a plugin named `guard`, and without this their
15899
+ // same-named servers would collapse to one row (the second silently dropped,
15900
+ // inheriting the first's trust).
15901
+ marketplace: external_exports.string().optional(),
15902
+ // The repo identity (remote url, or the cwd for un-remoted repos) — part of
15903
+ // PROJECT/LOCAL-scope identity: a server named `github` in repo A and one in
15904
+ // repo B are different servers with different commands, and MUST NOT share a
15905
+ // row — a shared row would let a cloned repo's .mcp.json inherit the trust
15906
+ // the user granted elsewhere.
15907
+ project: external_exports.string().optional(),
15908
+ // 'stdio' when the entry carries a command; otherwise the config's `type`
15909
+ // ('http' / 'sse' / …). Open string — the transport set is harness-defined.
15910
+ transport: external_exports.string().min(1),
15911
+ // Volatile on purpose (unlike hook `command`): a changed command/url is drift
15912
+ // on a stable row — visible across config_scan snapshots and preserving the
15913
+ // user's trust decision — never a quiet new row. One of the two is present.
15914
+ // Secret-masked at collection time (the scanner runs the bundled detection
15915
+ // packs over both — tokens routinely ride command args and URLs).
15916
+ command: external_exports.string().optional(),
15917
+ url: external_exports.string().optional(),
15918
+ // Env var NAMES only, never values (the no-secrets rule).
15919
+ envKeys: external_exports.array(external_exports.string()).optional(),
15920
+ // The config file the entry came from.
15921
+ location: external_exports.string().optional()
15922
+ });
15923
+ var ConfigFileScanEntry = external_exports.object({
15924
+ // Basename (settings.json, CLAUDE.md) or dir name (commands/, agents/).
15925
+ name: external_exports.string().min(1),
15926
+ // The absolute path — identity (with scope) and the promoted `location`.
15927
+ path: external_exports.string().min(1),
15928
+ scope: ConfigScope,
15929
+ // Human label: "User settings", "Project memory", "Slash commands", …
15930
+ kind: external_exports.string().min(1),
15931
+ // Derived SHAPE summary — top-level key names, entry counts, line counts.
15932
+ // Never file content or values (memory files can carry sensitive detail).
15933
+ detail: external_exports.string().optional(),
15934
+ // Dir configs (commands/, agents/) and .mcp.json: how many entries.
15935
+ entryCount: external_exports.number().optional(),
15936
+ // File mtime (ISO) — the freshness signal.
15937
+ updatedAt: external_exports.iso.datetime().optional()
15938
+ });
15939
+ var ConfigScanResult = external_exports.object({
15940
+ scannedAt: external_exports.iso.datetime(),
15941
+ skills: external_exports.array(SkillScanEntry),
15942
+ hooks: external_exports.array(HookScanEntry),
15943
+ mcpServers: external_exports.array(McpServerScanEntry),
15944
+ configFiles: external_exports.array(ConfigFileScanEntry),
15945
+ errors: external_exports.array(external_exports.object({ source: external_exports.string(), reason: external_exports.string() }))
15946
+ });
15947
+ var ConfigPostureFindingInput = external_exports.object({
15948
+ ruleId: external_exports.string().min(1),
15949
+ version: external_exports.string().min(1),
15950
+ span: Span,
15951
+ // For posture rules this is the offending COMMAND (config the user already
15952
+ // holds locally, not captured secret content) — it is also the correlation
15953
+ // key the read surface matches back to a hook row.
15954
+ maskedMatch: external_exports.string(),
15955
+ actionTaken: ActionTaken,
15956
+ confidence: external_exports.number().min(0).max(1)
15957
+ });
15958
+ var ConfigScanRecord = external_exports.object({
15959
+ items: external_exports.array(InventoryInput),
15960
+ scanEvent: AuditEventInput,
15961
+ definitions: external_exports.array(InspectionDefinitionInput).optional(),
15962
+ findings: external_exports.array(ConfigPostureFindingInput).optional()
15963
+ });
15964
+
15965
+ // ../../packages/schema/src/zod/control-plane.ts
15966
+ var ATTACHED_CREDENTIAL_SPEC_VERSION = 1;
15967
+ var AttachedCredential = external_exports.object({
15968
+ specVersion: external_exports.literal(ATTACHED_CREDENTIAL_SPEC_VERSION),
15969
+ // The control-plane endpoint this credential was minted against.
15970
+ endpoint: external_exports.string().min(1),
15971
+ // The bearer credential itself. Never logged, never rendered — status
15972
+ // surfaces show `keyPrefix` and nothing else.
15973
+ apiKey: external_exports.string().min(1),
15974
+ // First few characters of the key, safe to display so a user can match the
15975
+ // credential against their organization's key list.
15976
+ keyPrefix: external_exports.string().min(1).max(16).optional(),
15977
+ mintedAt: external_exports.iso.datetime().optional()
15978
+ });
15979
+ var MAX_DATE_MS = 253402300799999;
15980
+ var MAX_INT4 = 2147483647;
15981
+ var StorePosturePack = external_exports.object({
15982
+ packId: external_exports.string().min(1),
15983
+ // 'namespace/packId'
15984
+ version: external_exports.string().min(1),
15985
+ enabled: external_exports.boolean(),
15986
+ // Stringified pass-through of the local store's `installed_packs.updated_at`
15987
+ // — the column format is store-version-dependent (epoch millis vs ISO), so
15988
+ // the wire shape assumes neither.
15989
+ updatedAt: external_exports.string().nullable()
15990
+ }).meta({ id: "StorePosturePack" });
15991
+ var StorePosturePolicyCounts = external_exports.object({
15992
+ total: external_exports.number().int().min(0),
15993
+ disabled: external_exports.number().int().min(0),
15994
+ // Exhaustive per-action map; the builder pre-fills every action with 0.
15995
+ //
15996
+ // Spelled out member-by-member rather than `z.record(ActionTaken, …)`. Zod
15997
+ // enforces exhaustiveness either way, but z.record emits `propertyNames` +
15998
+ // `additionalProperties` into a generated schema document, and a type
15999
+ // generator renders THAT with every key optional — a sender built against
16000
+ // the generated type would typecheck and still be rejected at runtime. An
16001
+ // explicit object emits `properties` + `required`, so generated types
16002
+ // demand all five.
16003
+ //
16004
+ // `satisfies Record<ActionTaken, …>` keeps the link to the enum: adding an
16005
+ // ActionTaken member is a COMPILE error here instead of silent drift.
16006
+ // `.strict()` is load-bearing — it rejects an unknown action key, which a
16007
+ // bare object would silently STRIP, accepting a miscounted map as valid.
16008
+ byAction: external_exports.object({
16009
+ warn: external_exports.number().int().min(0),
16010
+ redact: external_exports.number().int().min(0),
16011
+ block: external_exports.number().int().min(0),
16012
+ allow: external_exports.number().int().min(0),
16013
+ log: external_exports.number().int().min(0)
16014
+ }).strict()
16015
+ }).meta({ id: "StorePosturePolicyCounts" });
16016
+ var StorePosturePlugin = external_exports.object({
16017
+ /** Package name of the reporting plugin. */
16018
+ package: external_exports.string().min(1).max(200),
16019
+ version: external_exports.string().min(1).max(64),
16020
+ /** Version of the bundled core, when the build records one separately. */
16021
+ ossVersion: external_exports.string().max(64).nullable(),
15974
16022
  /**
15975
- * Partial: only Flag keys with non-zero counts are included.
15976
- * Strict: unknown keys are rejected only Flag values are valid keys.
16023
+ * `version` of the policy bundle this machine last fetched. Bounded at 200
16024
+ * rather than the 64 a bare sha256 hex digest needs today, so a later
16025
+ * format with an algorithm prefix does not start rejecting the channel.
15977
16026
  */
15978
- flagRollup: external_exports.object({
15979
- update: external_exports.number().int().nonnegative(),
15980
- stale: external_exports.number().int().nonnegative(),
15981
- conflict: external_exports.number().int().nonnegative(),
15982
- unknown: external_exports.number().int().nonnegative(),
15983
- change: external_exports.number().int().nonnegative(),
15984
- untracked: external_exports.number().int().nonnegative(),
15985
- risk: external_exports.number().int().nonnegative(),
15986
- findings: external_exports.number().int().nonnegative()
15987
- }).partial().strict(),
15988
- items: external_exports.array(AssetSummary)
15989
- }).meta({ id: "AssetGroup" });
15990
- var ListAssetsResponse = external_exports.object({ groups: external_exports.array(AssetGroup) }).meta({ id: "ListAssetsResponse" });
15991
- var McpTool = external_exports.object({
15992
- name: external_exports.string(),
15993
- signature: external_exports.string(),
15994
- description: external_exports.string(),
15995
- write: external_exports.boolean(),
15996
- /** Non-null string when tool is dangerous / blocked; null otherwise. */
15997
- risk: external_exports.string().nullable()
15998
- }).meta({ id: "McpTool" });
15999
- var AssetFindingRef = external_exports.object({
16000
- id: external_exports.string(),
16001
- title: external_exports.string(),
16002
- note: external_exports.string()
16003
- });
16004
- var AssetDetail = AssetSummary.extend({
16005
- /** string | null — null when no description is available. */
16006
- description: external_exports.string().nullable(),
16007
- /** trustLevel | null — null for non-MCP assets. */
16008
- trust: TrustLevel.nullable(),
16009
- /** Type-specific raw key/values — FE renders the grid. */
16010
- meta: external_exports.record(external_exports.string(), external_exports.unknown()),
16011
- /** always present object when there is an active finding, null when absent. */
16012
- finding: AssetFindingRef.nullable(),
16013
- /** MCP exposed-tools list — omitted for non-mcp. */
16014
- tools: external_exports.array(McpTool).optional()
16015
- }).meta({ id: "AssetDetail" });
16016
- var ListProjectsResponse = external_exports.object({ items: external_exports.array(ProjectSummary) }).meta({ id: "ListProjectsResponse" });
16017
- var InventoryStats = external_exports.object({
16018
- /** Total assets/projects with ≥1 flag or finding (drives the attention header chip). */
16019
- attention: external_exports.number().int().nonnegative(),
16020
- byType: external_exports.object({
16021
- project: external_exports.number().int().nonnegative(),
16022
- skill: external_exports.number().int().nonnegative(),
16023
- mcp: external_exports.number().int().nonnegative(),
16024
- hook: external_exports.number().int().nonnegative(),
16025
- config: external_exports.number().int().nonnegative()
16026
- }),
16027
- harnesses: external_exports.number().int().nonnegative(),
16028
- mcpTrust: external_exports.object({
16029
- "known-good": external_exports.number().int().nonnegative(),
16030
- risky: external_exports.number().int().nonnegative(),
16031
- unapproved: external_exports.number().int().nonnegative()
16032
- })
16033
- }).meta({ id: "InventoryStats" });
16034
- var FileSummary = external_exports.object({
16035
- path: external_exports.string(),
16036
- name: external_exports.string(),
16037
- origin: Origin,
16038
- /** Effective access (override applied). */
16039
- access: AccessLevel,
16040
- /** True when a file_access_override differs from the computed default. */
16041
- isCustom: external_exports.boolean(),
16042
- findings: external_exports.number().int().nonnegative(),
16043
- /** When the file was auto-blocked by a detection; null when not blocked. */
16044
- blockedAt: external_exports.iso.datetime().nullable().optional(),
16045
- /** Why the file was blocked; null when absent. */
16046
- note: external_exports.string().nullable().optional()
16047
- }).meta({ id: "FileSummary" });
16048
- var FolderSummary = external_exports.object({
16049
- name: external_exports.string(),
16050
- path: external_exports.string(),
16051
- /** Rollup of effective access across all descendants. */
16052
- accessCounts: AccessCounts
16053
- }).meta({ id: "FolderSummary" });
16054
- var ProjectTreeResponse = external_exports.object({
16055
- project: external_exports.object({
16056
- id: external_exports.string(),
16057
- repo: external_exports.string(),
16058
- visibility: Visibility
16059
- }),
16060
- path: external_exports.string(),
16061
- /** Browse mode: one-level folders at the current path. Omitted in search mode. */
16062
- folders: external_exports.array(FolderSummary).optional(),
16063
- files: external_exports.array(FileSummary)
16064
- }).meta({ id: "ProjectTreeResponse" });
16065
- var FileDetail = FileSummary.extend({
16066
- project: external_exports.object({
16067
- repo: external_exports.string(),
16068
- visibility: Visibility,
16069
- language: external_exports.string(),
16070
- policyDefault: AccessLevel,
16071
- updatedAt: external_exports.iso.datetime()
16072
- }),
16073
- findingsRefs: external_exports.array(external_exports.object({ id: external_exports.string(), title: external_exports.string() }))
16074
- }).meta({ id: "FileDetail" });
16075
- var SetFileAccessBody = external_exports.object({
16076
- path: external_exports.string(),
16077
- access: AccessLevel
16078
- }).meta({ id: "SetFileAccessBody" });
16079
- var SetFileAccessResponse = external_exports.object({
16080
- file: FileSummary,
16081
- accessCounts: AccessCounts
16082
- }).meta({ id: "SetFileAccessResponse" });
16083
- var SetMcpTrustBody = external_exports.object({ trust: TrustLevel }).meta({ id: "SetMcpTrustBody" });
16084
- var HarnessEventItem = external_exports.object({
16085
- kind: HarnessEventKind,
16086
- title: external_exports.string(),
16087
- detail: external_exports.string(),
16088
- occurredAt: external_exports.iso.datetime(),
16089
- findingId: external_exports.string().nullable().optional()
16090
- }).meta({ id: "HarnessEventItem" });
16091
- var HarnessEventsResponse = external_exports.object({
16092
- counts: external_exports.object({
16093
- block: external_exports.number().int().nonnegative(),
16094
- redact: external_exports.number().int().nonnegative(),
16095
- warn: external_exports.number().int().nonnegative()
16096
- }),
16097
- items: external_exports.array(HarnessEventItem)
16098
- }).meta({ id: "HarnessEventsResponse" });
16099
- var RescanResponse = external_exports.object({
16100
- jobId: external_exports.string(),
16101
- startedAt: external_exports.iso.datetime()
16102
- }).meta({ id: "RescanResponse" });
16103
- var ConnectProjectBody = external_exports.object({ repo: external_exports.string() }).meta({ id: "ConnectProjectBody" });
16104
- var ListAssetsQuery = external_exports.object({
16105
- /** Filter by one or more AssetType values; absent means all types. */
16106
- type: external_exports.array(AssetType).optional(),
16107
- /** Free-text search term. */
16108
- q: external_exports.string().optional()
16109
- });
16110
- var GetProjectTreeQuery = external_exports.object({
16111
- /** Subtree root path; defaults to repository root when absent. */
16112
- path: external_exports.string().optional(),
16113
- /** Free-text filter applied to file paths. */
16114
- q: external_exports.string().optional(),
16115
- /**
16116
- * Special listing mode. `blocked` returns every effectively-blocked, auto-blocked
16117
- * file across the whole repo (folders omitted, most-recent first), ignoring
16118
- * `path`/`q` — powers the project-wide "recently blocked" strip.
16119
- */
16120
- filter: external_exports.enum(["blocked"]).optional()
16027
+ policyBundleVersion: external_exports.string().max(200).nullable(),
16028
+ /** Epoch millis, on the CLIENT clock, of that fetch. */
16029
+ policyFetchedAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable()
16030
+ }).meta({ id: "StorePosturePlugin" });
16031
+ var StorePostureSnapshot = external_exports.object({
16032
+ deviceId: external_exports.guid(),
16033
+ hostname: external_exports.string().min(1).max(253),
16034
+ // Epoch millis on the CLIENT clock. Bounded by what a receiving store
16035
+ // accepts (see MAX_DATE_MS), not by what a JavaScript Date can hold.
16036
+ capturedAt: external_exports.number().int().min(0).max(MAX_DATE_MS),
16037
+ // False is a measurement, not an error state: "no local store exists on
16038
+ // this machine".
16039
+ storePresent: external_exports.boolean(),
16040
+ schemaVersion: external_exports.number().int().min(0).max(MAX_INT4).nullable(),
16041
+ // PRAGMA user_version
16042
+ findingsTotal: external_exports.number().int().min(0).max(MAX_INT4),
16043
+ // Epoch millis, bounded like `capturedAt` — see MAX_DATE_MS on what that
16044
+ // bound does and does not do. Worth stating for these two specifically:
16045
+ // they are read from the local store's own ROWS rather than from this
16046
+ // machine's clock, so a damaged or hand-edited store is enough to produce
16047
+ // an out-of-range value with no clock skew involved.
16048
+ findingsFirstAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable(),
16049
+ findingsLastAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable(),
16050
+ packs: external_exports.array(StorePosturePack).max(500),
16051
+ policyCounts: StorePosturePolicyCounts,
16052
+ // OPTIONAL, not nullable: a reporter that predates this member keeps
16053
+ // getting its 200 without a payload change.
16054
+ plugin: StorePosturePlugin.optional()
16055
+ }).meta({ id: "StorePostureSnapshot" });
16056
+ var CAPTURE_VERSION_PREFIX = "capture/";
16057
+ var RecordAuditEventRequest = AuditEventInput.extend({
16058
+ inspections: external_exports.array(ToolCallInspection).default([])
16059
+ }).refine((v) => v.inspections.every((i) => !i.ruleVersion.startsWith(CAPTURE_VERSION_PREFIX)), {
16060
+ message: `inspections[].ruleVersion must not start with \`${CAPTURE_VERSION_PREFIX}\` \u2014 that namespace is reserved for capture definitions the control plane mints itself`,
16061
+ path: ["inspections"]
16062
+ }).meta({ id: "RecordAuditEventRequest" });
16063
+ var IngestAck = external_exports.object({
16064
+ accepted: external_exports.number().int().nonnegative(),
16065
+ duplicates: external_exports.number().int().nonnegative()
16121
16066
  });
16122
- var GetProjectFileQuery = external_exports.object({
16123
- /** Repository-relative file path; absent or empty 400. */
16124
- path: external_exports.string()
16067
+ var PRINTABLE = /^[^\p{Cc}\p{Cf}]*$/u;
16068
+ var printable = (max) => external_exports.string().max(max).regex(PRINTABLE, "must not contain control characters");
16069
+ var PluginWhoami = external_exports.object({
16070
+ tenantName: printable(200),
16071
+ userEmail: printable(320),
16072
+ role: printable(64),
16073
+ keyKind: printable(64),
16074
+ serverTime: printable(64)
16125
16075
  });
16126
- var GetHarnessEventsQuery = external_exports.object({
16127
- /** Maximum number of events to return. Range: 1–50; default: 7. */
16128
- limit: external_exports.coerce.number().int().min(1).max(50).default(7)
16076
+ var ControlPlaneErrorBody = external_exports.object({
16077
+ error: external_exports.object({
16078
+ code: external_exports.string().optional(),
16079
+ message: external_exports.string().optional()
16080
+ }).optional()
16129
16081
  });
16130
16082
 
16131
- // ../../packages/schema/src/zod/exception.ts
16132
- var ExceptionScope = external_exports.enum(["once", "temporary", "permanent"]);
16133
- var ExceptionConditions = external_exports.object({
16134
- repo: external_exports.string().optional(),
16135
- sourceTool: external_exports.string().optional(),
16136
- provider: external_exports.string().optional()
16137
- }).strict();
16138
- var ExceptionCapability = external_exports.enum(["suppress", "reveal_to_model"]);
16139
- var DetectionException = external_exports.object({
16140
- id: external_exports.guid(),
16141
- ruleId: external_exports.string(),
16142
- // Denormalized from the rule, for reporting — never matched on.
16143
- category: DetectionCategory,
16144
- // HMAC-SHA256 hex of the raw match under a machine-local key: a KEYED
16145
- // fingerprint, never the raw value, and never reversible. Matching recomputes
16146
- // the fingerprint from a fresh capture; the value itself is never stored.
16147
- // Shape-constrained so a malformed — or accidentally raw — value is rejected
16148
- // at the boundary rather than persisted.
16149
- valueFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
16150
- // Version of the fingerprint key the grant was written under; a rotated key
16151
- // invalidates old grants rather than silently mismatching them.
16152
- keyVersion: external_exports.number().int().positive(),
16153
- // maskMatch() preview of the approved value — never the raw value.
16154
- maskedValue: external_exports.string(),
16155
- capability: ExceptionCapability.default("suppress"),
16156
- scope: ExceptionScope,
16157
- expiresAt: external_exports.iso.datetime().nullable(),
16158
- maxUses: external_exports.number().int().positive().nullable(),
16159
- useCount: external_exports.number().int().nonnegative(),
16160
- lastUsedAt: external_exports.iso.datetime().nullable(),
16161
- // Mandatory: every grant carries the human reason it exists.
16162
- justification: external_exports.string().min(1),
16163
- conditions: ExceptionConditions.nullable(),
16164
- createdBy: external_exports.string(),
16165
- createdVia: external_exports.enum(["cli-approve", "cli-add", "web-approve", "web-add", "api", "setup-triage"]),
16166
- createdAt: external_exports.iso.datetime(),
16167
- updatedAt: external_exports.iso.datetime(),
16168
- // Revocation is terminal and retained — consumed/expired/revoked rows are
16169
- // audit evidence; nothing in the exception lifecycle hard-deletes.
16170
- revokedAt: external_exports.iso.datetime().nullable(),
16171
- revokedBy: external_exports.string().nullable(),
16172
- revokeReason: external_exports.string().nullable()
16173
- });
16174
- var ExceptionBundleEntry = DetectionException.pick({
16175
- id: true,
16176
- ruleId: true,
16177
- valueFingerprint: true,
16178
- keyVersion: true,
16179
- capability: true,
16180
- expiresAt: true,
16181
- maxUses: true,
16182
- useCount: true,
16183
- conditions: true
16184
- });
16185
- var ExceptionDescriptor = DetectionException.omit({ valueFingerprint: true });
16083
+ // ../../packages/schema/src/zod/registry.ts
16084
+ var Namespace = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
16085
+ var PackId = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
16086
+ var SemVer = external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?$/);
16087
+ var PublisherKind = external_exports.enum(["labs", "user", "org"]);
16186
16088
 
16187
16089
  // ../../packages/schema/src/zod/rule.ts
16188
- var MatcherType = external_exports.enum(["keyword", "regex", "validator"]).meta({ id: "MatcherType" });
16090
+ var MatcherType = external_exports.enum(["keyword", "regex"]).meta({ id: "MatcherType" });
16189
16091
  var RuleProbeVerdict = external_exports.enum(["safe", "quarantined"]).meta({ id: "RuleProbeVerdict" });
16190
- var KeywordMatcher = external_exports.object({
16092
+ var KeywordMatcher = external_exports.strictObject({
16191
16093
  type: external_exports.literal("keyword"),
16192
16094
  // An empty keyword matches at every position, yielding one zero-length span
16193
16095
  // per character. Rejected here because a keyword that matches everything is
@@ -16203,16 +16105,31 @@ function isValidRegex(pattern, flags) {
16203
16105
  return false;
16204
16106
  }
16205
16107
  }
16108
+ function probeFlags(flags) {
16109
+ return flags.replace(/[gy]/g, "");
16110
+ }
16206
16111
  function matchesEmptyString(pattern, flags) {
16207
16112
  try {
16208
- const re = new RegExp(pattern, flags.replace(/[gy]/g, ""));
16113
+ const re = new RegExp(pattern, probeFlags(flags));
16209
16114
  return re.exec("")?.[0].length === 0;
16210
16115
  } catch {
16211
16116
  return false;
16212
16117
  }
16213
16118
  }
16119
+ function spansWholeMatch(captureGroup) {
16120
+ return captureGroup === void 0 || captureGroup === 0;
16121
+ }
16122
+ function captureGroupCount(pattern, flags) {
16123
+ try {
16124
+ const probe = new RegExp(`${pattern}|`, probeFlags(flags));
16125
+ const result = probe.exec("");
16126
+ return result ? result.length - 1 : void 0;
16127
+ } catch {
16128
+ return void 0;
16129
+ }
16130
+ }
16214
16131
  var MAX_PATTERN_LENGTH = 2e3;
16215
- var RegexMatcher = external_exports.object({
16132
+ var RegexMatcher = external_exports.strictObject({
16216
16133
  type: external_exports.literal("regex"),
16217
16134
  pattern: external_exports.string().min(1).max(MAX_PATTERN_LENGTH),
16218
16135
  flags: external_exports.string().default("gi"),
@@ -16220,28 +16137,47 @@ var RegexMatcher = external_exports.object({
16220
16137
  }).refine((v) => isValidRegex(v.pattern, v.flags), {
16221
16138
  message: "pattern/flags do not form a valid JavaScript regular expression",
16222
16139
  path: ["pattern"]
16223
- }).refine((v) => v.captureGroup !== void 0 || !matchesEmptyString(v.pattern, v.flags), {
16140
+ }).refine((v) => !spansWholeMatch(v.captureGroup) || !matchesEmptyString(v.pattern, v.flags), {
16224
16141
  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',
16225
16142
  path: ["pattern"]
16143
+ }).superRefine((v, ctx) => {
16144
+ if (v.captureGroup === void 0) return;
16145
+ const groups = captureGroupCount(v.pattern, v.flags);
16146
+ if (groups === void 0 || v.captureGroup <= groups) return;
16147
+ ctx.addIssue({
16148
+ code: "custom",
16149
+ path: ["captureGroup"],
16150
+ 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.`
16151
+ });
16226
16152
  });
16227
- var ValidatorMatcher = external_exports.object({
16228
- type: external_exports.literal("validator"),
16229
- name: external_exports.enum(["luhn", "entropy", "ssn-checksum"]),
16230
- config: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
16231
- });
16232
- var Matcher = external_exports.discriminatedUnion("type", [KeywordMatcher, RegexMatcher, ValidatorMatcher]).meta({ id: "Matcher" });
16233
- var AppliesTo = external_exports.object({
16153
+ var Matcher = external_exports.discriminatedUnion("type", [KeywordMatcher, RegexMatcher]).meta({ id: "Matcher" });
16154
+ var MATCHER_TYPES = MatcherType.options;
16155
+ var AppliesTo = external_exports.strictObject({
16234
16156
  // Dot-prefixed, e.g. ".py" — matches the scanner's SOURCE_EXTENSIONS shape.
16235
16157
  extensions: external_exports.array(external_exports.string().regex(/^\.[A-Za-z0-9]+$/)).min(1)
16236
16158
  }).meta({ id: "AppliesTo" });
16237
- var PostValidatorRef = external_exports.union([
16238
- external_exports.string(),
16239
- external_exports.object({
16240
- name: external_exports.string(),
16241
- config: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
16242
- })
16243
- ]).meta({ id: "PostValidatorRef" });
16244
- var RequiresNearby = external_exports.object({
16159
+ var PostValidatorName = external_exports.enum(["entropy", "luhn"]).meta({ id: "PostValidatorName" });
16160
+ var PostValidatorRef = external_exports.union(
16161
+ [
16162
+ PostValidatorName,
16163
+ external_exports.strictObject({
16164
+ name: PostValidatorName,
16165
+ config: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
16166
+ })
16167
+ ],
16168
+ {
16169
+ // A union reports one collapsed issue for every way its arms can fail, so
16170
+ // this has to describe the whole shape rather than just the name — it is
16171
+ // what an author sees for a misspelled name AND for a stray key in the
16172
+ // object form. The names come from the enum so the message cannot go
16173
+ // stale. Without it Zod says only "Invalid input", which is precisely the
16174
+ // no-feedback outcome this schema exists to remove.
16175
+ error: () => `not a valid post-validator: use a bare name (${PostValidatorName.options.map((name) => JSON.stringify(name)).join(
16176
+ " or "
16177
+ )}) or { "name": ..., "config": { ... } }. An unrecognized name would be a false-positive guard that never runs.`
16178
+ }
16179
+ ).meta({ id: "PostValidatorRef" });
16180
+ var RequiresNearby = external_exports.strictObject({
16245
16181
  // Each array, when present, must be non-empty and contain non-empty strings —
16246
16182
  // an empty/blank criterion would either never fire or (for labels) match
16247
16183
  // everything.
@@ -16256,16 +16192,23 @@ var RequiresNearby = external_exports.object({
16256
16192
  (v) => (v.categories?.length ?? 0) + (v.ruleIds?.length ?? 0) + (v.labels?.length ?? 0) > 0,
16257
16193
  { message: "requiresNearby needs at least one of categories, ruleIds, or labels" }
16258
16194
  ).meta({ id: "RequiresNearby" });
16259
- var RuleFixture = external_exports.object({
16195
+ var RuleFixture = external_exports.strictObject({
16260
16196
  label: external_exports.string(),
16261
16197
  text: external_exports.string().max(5e4),
16262
16198
  shouldMatch: external_exports.boolean(),
16263
16199
  // Simulated file context for the scan, so fixtures can assert `appliesTo`
16264
16200
  // gating (e.g. a Python-only pattern must NOT fire in a .ts file).
16265
16201
  filePath: external_exports.string().optional(),
16266
- expectedSpans: external_exports.array(external_exports.object({ start: external_exports.number(), end: external_exports.number() })).optional()
16202
+ expectedSpans: external_exports.array(external_exports.strictObject({ start: external_exports.number(), end: external_exports.number() })).optional()
16267
16203
  }).meta({ id: "RuleFixture" });
16268
- var Rule = external_exports.object({
16204
+ var Rule = external_exports.strictObject({
16205
+ // A pinned literal over a STRICT object, and the two together decide how this
16206
+ // format may grow. A rule carrying a key not listed below is refused with
16207
+ // `unrecognized_keys`; a rule declaring `specVersion: 2` is refused with
16208
+ // `invalid_value`. So the only additive path is adding an OPTIONAL field here
16209
+ // — that keeps every rule authored before it valid — and a rule author has no
16210
+ // way to introduce a field of their own or to opt into a later version.
16211
+ // Widening the format means changing this literal and every consumer of it.
16269
16212
  specVersion: external_exports.literal(1),
16270
16213
  // `packId/ruleName` (e.g. `secrets/aws-access-key`). NOTE the first segment is
16271
16214
  // the PACK id, NOT a namespace — this is a DIFFERENT slug space from a
@@ -16301,293 +16244,6 @@ var PackManifest = external_exports.object({
16301
16244
  sourceUrl: external_exports.url().optional()
16302
16245
  }).meta({ id: "PackManifest" });
16303
16246
 
16304
- // ../../packages/schema/src/zod/policy.ts
16305
- var PolicyScope = external_exports.enum(["global", "repo", "user"]).meta({ id: "PolicyScope" });
16306
- var PolicyTarget = external_exports.union([external_exports.object({ ruleId: external_exports.string() }), external_exports.object({ category: DetectionCategory })]).meta({ id: "PolicyTarget" });
16307
- var Policy = external_exports.object({
16308
- id: external_exports.guid(),
16309
- scope: PolicyScope,
16310
- target: PolicyTarget,
16311
- action: ActionTaken,
16312
- enabled: external_exports.boolean().default(true),
16313
- customKeywords: external_exports.array(external_exports.string()).optional(),
16314
- // Display name — optional so older policy rows without name still parse.
16315
- // Added for the findings API (policy.name column migration).
16316
- name: external_exports.string().optional()
16317
- }).meta({ id: "Policy" });
16318
- var PolicyBundle = external_exports.object({
16319
- version: external_exports.string(),
16320
- policies: external_exports.array(Policy),
16321
- // Rules from the installed marketplace packs (snapshotted by the
16322
- // control plane). The plugin registers these in addition to its bundled
16323
- // packs. Optional so older backends — and older on-disk caches — that omit
16324
- // the field still parse; consumers read `bundle.rules ?? []`.
16325
- rules: external_exports.array(Rule).optional(),
16326
- // When true, `rules` IS the complete effective ruleset and the runtime must
16327
- // NOT merge its compiled-in bundled packs — the standalone gateway sets this
16328
- // after reading the user's installed snapshot (installed_packs, enabled
16329
- // packs only), which is how detection updates stay manual: new bundled
16330
- // rules run only after the user applies the pack update. Absent/false keeps
16331
- // the historical composition (bundled packs + rules) — older caches.
16332
- rulesComplete: external_exports.boolean().optional(),
16333
- // Active detection exceptions, evaluation subset only (see
16334
- // ExceptionBundleEntry). Optional so older bundle producers — and older
16335
- // on-disk caches — that omit the field still parse; consumers read
16336
- // `bundle.exceptions ?? []`.
16337
- exceptions: external_exports.array(ExceptionBundleEntry).optional(),
16338
- // Installed pack version, keyed by ruleId, for rules in `rules` that came
16339
- // from a versioned installed pack. Optional so older backends — and older
16340
- // on-disk caches — that omit the field still parse; consumers fall back to
16341
- // the rule's own spec version. NOT the bundle version above — see
16342
- // installedRuleset's ruleVersions for the source of truth.
16343
- ruleVersions: external_exports.record(external_exports.string(), external_exports.string()).optional(),
16344
- customKeywords: external_exports.array(external_exports.string()),
16345
- fetchedAt: external_exports.iso.datetime()
16346
- }).meta({ id: "PolicyBundle" });
16347
- var OBSERVE_ONLY_CATEGORIES = ["config"];
16348
- var ENFORCEABLE_CATEGORIES = DetectionCategory.options.filter((c) => !OBSERVE_ONLY_CATEGORIES.includes(c));
16349
- var CATEGORY_PEAK_SEVERITY = {
16350
- secret: "critical",
16351
- financial: "critical",
16352
- // core-financial/credit-card
16353
- code_flaw: "critical",
16354
- pii: "high",
16355
- phi: "high",
16356
- custom: "high",
16357
- // user-defined; conservative
16358
- code_context: "low",
16359
- config: "low"
16360
- // observe-only; floors to monitor regardless
16361
- };
16362
- function severityFloorPolicy(category) {
16363
- if (OBSERVE_ONLY_CATEGORIES.includes(category)) return "monitor";
16364
- const peak = CATEGORY_PEAK_SEVERITY[category];
16365
- return peak === "critical" || peak === "high" ? "warn" : "monitor";
16366
- }
16367
- function severityFloorPosture() {
16368
- const out = {};
16369
- for (const c of DetectionCategory.options) out[c] = severityFloorPolicy(c);
16370
- return out;
16371
- }
16372
- var PolicyKind = external_exports.enum(["builtin", "custom"]).meta({ id: "PolicyKind" });
16373
- var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "block"];
16374
- var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
16375
- var BUILTIN_ORDER = KNOWN_BUILTIN_IDS;
16376
- var BUILTIN_POLICY_SPECS = {
16377
- monitor: {
16378
- name: "Monitor",
16379
- action: "log",
16380
- description: "Log every match for audit. The request is allowed through untouched."
16381
- },
16382
- warn: {
16383
- name: "Warn",
16384
- action: "warn",
16385
- description: "Allow the request, but warn the user inline before it is sent."
16386
- },
16387
- redact: {
16388
- name: "Redact",
16389
- action: "redact",
16390
- description: "Automatically strip the matched value from the request, then continue."
16391
- },
16392
- block: {
16393
- name: "Block",
16394
- action: "block",
16395
- description: "Refuse the request entirely whenever any rule in this detection matches."
16396
- }
16397
- };
16398
- function builtinPolicyToAction(id) {
16399
- return BUILTIN_POLICY_SPECS[id].action;
16400
- }
16401
- var DEFAULT_ACTIONS = Object.fromEntries(
16402
- DetectionCategory.options.map((c) => [c, builtinPolicyToAction(severityFloorPolicy(c))])
16403
- );
16404
- var BUILTIN_POLICIES = Object.fromEntries(
16405
- KNOWN_BUILTIN_IDS.map((id) => [id, { id, ...BUILTIN_POLICY_SPECS[id] }])
16406
- );
16407
- var UsedByItem = external_exports.object({
16408
- id: external_exports.string(),
16409
- name: external_exports.string(),
16410
- ruleCount: external_exports.number().int().nonnegative(),
16411
- enabled: external_exports.boolean()
16412
- }).meta({ id: "UsedByItem" });
16413
- var PolicyListItem = external_exports.object({
16414
- id: external_exports.string(),
16415
- kind: PolicyKind,
16416
- name: external_exports.string(),
16417
- enabled: external_exports.boolean(),
16418
- usedByCount: external_exports.number().int().nonnegative()
16419
- }).meta({ id: "PolicyListItem" });
16420
- var PolicyDetail = external_exports.object({
16421
- specVersion: external_exports.literal(1),
16422
- id: external_exports.string(),
16423
- kind: PolicyKind,
16424
- name: external_exports.string(),
16425
- enabled: external_exports.boolean(),
16426
- description: external_exports.string(),
16427
- usedBy: external_exports.array(UsedByItem)
16428
- }).meta({ id: "PolicyDetail" });
16429
- var PolicyStatsResponse = external_exports.object({
16430
- policies: external_exports.number().int().nonnegative(),
16431
- builtin: external_exports.number().int().nonnegative(),
16432
- custom: external_exports.number().int().nonnegative(),
16433
- detectionsGoverned: external_exports.number().int().nonnegative()
16434
- }).meta({ id: "PolicyStatsResponse" });
16435
-
16436
- // ../../packages/schema/src/zod/api.ts
16437
- var LIST_QUERY_MAX_LIMIT = 200;
16438
- var ListEventsQuery = external_exports.object({
16439
- cursor: external_exports.string().optional(),
16440
- limit: external_exports.coerce.number().int().min(1).max(LIST_QUERY_MAX_LIMIT).default(50),
16441
- sourceTool: external_exports.string().optional(),
16442
- kind: external_exports.string().optional(),
16443
- from: external_exports.iso.datetime().optional(),
16444
- to: external_exports.iso.datetime().optional()
16445
- });
16446
- var ListEventsResponse = external_exports.object({
16447
- items: external_exports.array(Event),
16448
- nextCursor: external_exports.string().nullable()
16449
- }).meta({ id: "ListEventsResponse" });
16450
- var IngestResponse = external_exports.object({
16451
- accepted: external_exports.number().int().nonnegative(),
16452
- duplicates: external_exports.number().int().nonnegative()
16453
- }).meta({ id: "IngestResponse" });
16454
- var ListFindingsQuery = external_exports.object({
16455
- cursor: external_exports.string().optional(),
16456
- limit: external_exports.coerce.number().int().min(1).max(LIST_QUERY_MAX_LIMIT).default(50),
16457
- severity: external_exports.string().optional(),
16458
- category: external_exports.string().optional(),
16459
- eventId: external_exports.guid().optional()
16460
- });
16461
- var ListFindingsResponse = external_exports.object({
16462
- items: external_exports.array(Finding),
16463
- nextCursor: external_exports.string().nullable()
16464
- }).meta({ id: "ListFindingsResponse" });
16465
- var ListPoliciesResponse = external_exports.object({ items: external_exports.array(PolicyListItem) }).meta({ id: "ListPoliciesResponse" });
16466
- var CreatePolicyRequest = Policy.omit({ id: true }).meta({
16467
- id: "CreatePolicyRequest"
16468
- });
16469
- var UpdatePolicyRequest = Policy.partial().required({ id: true }).meta({ id: "UpdatePolicyRequest" });
16470
- var RecordAuditEventResponse = external_exports.object({ accepted: external_exports.boolean() }).meta({ id: "RecordAuditEventResponse" });
16471
- var ErrorResponse = external_exports.object({
16472
- error: external_exports.object({
16473
- code: external_exports.string(),
16474
- message: external_exports.string(),
16475
- details: external_exports.unknown().optional()
16476
- })
16477
- }).meta({ id: "ErrorResponse" });
16478
-
16479
- // ../../packages/schema/src/zod/config-inventory.ts
16480
- var ConfigScope = external_exports.enum(["user", "project", "local", "plugin"]);
16481
- var SkillScanEntry = external_exports.object({
16482
- name: external_exports.string().min(1),
16483
- // The identity source: a marketplace repo for plugin skills (e.g.
16484
- // 'anthropics/skills'), 'local' for personal ~/.claude/skills, or
16485
- // 'project:<repo-identity>' for checked-in project skills. The surrogate keeps
16486
- // a personal skill named 'pdf' from colliding with the marketplace 'pdf'.
16487
- source: external_exports.string().min(1),
16488
- scope: ConfigScope,
16489
- pluginName: external_exports.string().optional(),
16490
- // Volatile — rides the attribute bag, never the identity hash.
16491
- version: external_exports.string().optional(),
16492
- description: external_exports.string().optional(),
16493
- // Skill directory mtime (ISO) — the "updated Nd ago" freshness signal.
16494
- updatedAt: external_exports.iso.datetime().optional(),
16495
- // Filesystem path — the promoted inventory `location` column.
16496
- location: external_exports.string().optional()
16497
- });
16498
- var HookScanEntry = external_exports.object({
16499
- // Hook event name (PreToolUse, PostToolUse, …). Open string, not an enum: the
16500
- // set is harness-defined and grows without a schema change.
16501
- event: external_exports.string().min(1),
16502
- // The tool matcher ('Bash', 'Edit|Write', …). Absent = matches all tools.
16503
- matcher: external_exports.string().optional(),
16504
- command: external_exports.string().min(1),
16505
- timeout: external_exports.number().optional(),
16506
- scope: ConfigScope,
16507
- pluginName: external_exports.string().optional(),
16508
- // The settings file / hooks.json the entry came from.
16509
- location: external_exports.string().optional()
16510
- });
16511
- var McpServerScanEntry = external_exports.object({
16512
- // The server's config key ("github", "filesystem", …) — identity, with the
16513
- // qualified scope (see mcpServerIdentityKey).
16514
- name: external_exports.string().min(1),
16515
- scope: ConfigScope,
16516
- pluginName: external_exports.string().optional(),
16517
- // The owning plugin's marketplace — part of PLUGIN-scope identity: two
16518
- // marketplaces can each ship a plugin named `guard`, and without this their
16519
- // same-named servers would collapse to one row (the second silently dropped,
16520
- // inheriting the first's trust).
16521
- marketplace: external_exports.string().optional(),
16522
- // The repo identity (remote url, or the cwd for un-remoted repos) — part of
16523
- // PROJECT/LOCAL-scope identity: a server named `github` in repo A and one in
16524
- // repo B are different servers with different commands, and MUST NOT share a
16525
- // row — a shared row would let a cloned repo's .mcp.json inherit the trust
16526
- // the user granted elsewhere.
16527
- project: external_exports.string().optional(),
16528
- // 'stdio' when the entry carries a command; otherwise the config's `type`
16529
- // ('http' / 'sse' / …). Open string — the transport set is harness-defined.
16530
- transport: external_exports.string().min(1),
16531
- // Volatile on purpose (unlike hook `command`): a changed command/url is drift
16532
- // on a stable row — visible across config_scan snapshots and preserving the
16533
- // user's trust decision — never a quiet new row. One of the two is present.
16534
- // Secret-masked at collection time (the scanner runs the bundled detection
16535
- // packs over both — tokens routinely ride command args and URLs).
16536
- command: external_exports.string().optional(),
16537
- url: external_exports.string().optional(),
16538
- // Env var NAMES only, never values (the no-secrets rule).
16539
- envKeys: external_exports.array(external_exports.string()).optional(),
16540
- // The config file the entry came from.
16541
- location: external_exports.string().optional()
16542
- });
16543
- var ConfigFileScanEntry = external_exports.object({
16544
- // Basename (settings.json, CLAUDE.md) or dir name (commands/, agents/).
16545
- name: external_exports.string().min(1),
16546
- // The absolute path — identity (with scope) and the promoted `location`.
16547
- path: external_exports.string().min(1),
16548
- scope: ConfigScope,
16549
- // Human label: "User settings", "Project memory", "Slash commands", …
16550
- kind: external_exports.string().min(1),
16551
- // Derived SHAPE summary — top-level key names, entry counts, line counts.
16552
- // Never file content or values (memory files can carry sensitive detail).
16553
- detail: external_exports.string().optional(),
16554
- // Dir configs (commands/, agents/) and .mcp.json: how many entries.
16555
- entryCount: external_exports.number().optional(),
16556
- // File mtime (ISO) — the freshness signal.
16557
- updatedAt: external_exports.iso.datetime().optional()
16558
- });
16559
- var ConfigScanResult = external_exports.object({
16560
- scannedAt: external_exports.iso.datetime(),
16561
- skills: external_exports.array(SkillScanEntry),
16562
- hooks: external_exports.array(HookScanEntry),
16563
- mcpServers: external_exports.array(McpServerScanEntry),
16564
- configFiles: external_exports.array(ConfigFileScanEntry),
16565
- errors: external_exports.array(external_exports.object({ source: external_exports.string(), reason: external_exports.string() }))
16566
- });
16567
- var ConfigPostureFindingInput = external_exports.object({
16568
- ruleId: external_exports.string().min(1),
16569
- version: external_exports.string().min(1),
16570
- span: Span,
16571
- // For posture rules this is the offending COMMAND (config the user already
16572
- // holds locally, not captured secret content) — it is also the correlation
16573
- // key the read surface matches back to a hook row.
16574
- maskedMatch: external_exports.string(),
16575
- actionTaken: ActionTaken,
16576
- confidence: external_exports.number().min(0).max(1)
16577
- });
16578
- var ConfigScanRecord = external_exports.object({
16579
- items: external_exports.array(InventoryInput),
16580
- scanEvent: AuditEventInput,
16581
- definitions: external_exports.array(InspectionDefinitionInput).optional(),
16582
- findings: external_exports.array(ConfigPostureFindingInput).optional()
16583
- });
16584
-
16585
- // ../../packages/schema/src/zod/registry.ts
16586
- var Namespace = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
16587
- var PackId = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
16588
- var SemVer = external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?$/);
16589
- var PublisherKind = external_exports.enum(["labs", "user", "org"]);
16590
-
16591
16247
  // ../../packages/schema/src/zod/detection.ts
16592
16248
  var OriginEnum = external_exports.enum(["library"]).meta({ id: "OriginEnum" });
16593
16249
  var DetectionFilterEnum = external_exports.enum(["all", "library", "custom", "customized", "updates"]);
@@ -16641,72 +16297,297 @@ var DetectionStats = external_exports.object({
16641
16297
  var DetectionRule = external_exports.object({
16642
16298
  id: external_exports.string(),
16643
16299
  name: external_exports.string(),
16644
- category: DetectionCategory,
16645
- severity: Severity,
16646
- matcher: Matcher
16647
- }).meta({ id: "DetectionRule" });
16648
- var DetectionUpdate = external_exports.object({
16649
- available: external_exports.boolean(),
16650
- latestVersion: SemVer,
16651
- // Rule count of the latest snapshot. Lets the update UI show a meaningful
16652
- // delta ("2 rules → 14 rules") when the version did NOT change but the rule
16653
- // content did — the OSS store compares content, not just version. Optional:
16654
- // registry-backed updates omit it.
16655
- latestRuleCount: external_exports.number().int().nonnegative().optional()
16656
- }).nullable().meta({ id: "DetectionUpdate" });
16657
- var DetectionDetail = external_exports.object({
16300
+ category: DetectionCategory,
16301
+ severity: Severity,
16302
+ matcher: Matcher
16303
+ }).meta({ id: "DetectionRule" });
16304
+ var DetectionUpdate = external_exports.object({
16305
+ available: external_exports.boolean(),
16306
+ latestVersion: SemVer,
16307
+ // Rule count of the latest snapshot. Lets the update UI show a meaningful
16308
+ // delta ("2 rules → 14 rules") when the version did NOT change but the rule
16309
+ // content did — the OSS store compares content, not just version. Optional:
16310
+ // registry-backed updates omit it.
16311
+ latestRuleCount: external_exports.number().int().nonnegative().optional()
16312
+ }).nullable().meta({ id: "DetectionUpdate" });
16313
+ var DetectionDetail = external_exports.object({
16314
+ id: external_exports.string(),
16315
+ name: external_exports.string(),
16316
+ version: SemVer,
16317
+ enabled: external_exports.boolean(),
16318
+ origin: OriginEnum,
16319
+ publisher: Namespace.optional(),
16320
+ publisherKind: PublisherKind.optional(),
16321
+ ruleCount: external_exports.number().int().nonnegative(),
16322
+ namespace: Namespace,
16323
+ packId: PackId,
16324
+ description: external_exports.string().optional(),
16325
+ editedAt: external_exports.iso.datetime(),
16326
+ findingsLast30d: external_exports.number().int().nonnegative(),
16327
+ latestVersion: SemVer.nullable().optional(),
16328
+ update: DetectionUpdate,
16329
+ rules: external_exports.array(DetectionRule),
16330
+ modified: external_exports.boolean(),
16331
+ // Per-pack enforcement-policy assignment. Holds a BuiltinPolicyId ARCHETYPE
16332
+ // (monitor|warn|redact|block) — NOT a policies-table Policy.id guid; a
16333
+ // detection is a PACK, and its policy is the archetype applied to all its
16334
+ // rules. Absent == unassigned, which resolves to Monitor everywhere
16335
+ // (DEFAULT_PACK_POLICY_ID). Every enforcement surface expands it into
16336
+ // per-rule policies (see policyIdToAction). Typed z.string() (not
16337
+ // the enum) to keep the OpenAPI response tolerant of a future custom id.
16338
+ policyId: external_exports.string().optional()
16339
+ }).meta({ id: "DetectionDetail" });
16340
+ var LibraryItem = external_exports.object({
16341
+ id: external_exports.string(),
16342
+ name: external_exports.string(),
16343
+ publisher: Namespace,
16344
+ publisherKind: PublisherKind.optional(),
16345
+ // LOSSY single-category view of a pack. A pack MAY span several categories;
16346
+ // this carries only the canonical-first one for display. Do NOT filter/facet
16347
+ // on it — the library filter matches a pack's full category set (see
16348
+ // ListLibraryResponse.categories).
16349
+ category: DetectionCategory.optional(),
16350
+ version: SemVer,
16351
+ ruleCount: external_exports.number().int().nonnegative(),
16352
+ description: external_exports.string().optional(),
16353
+ updatedAt: external_exports.iso.datetime(),
16354
+ state: LibraryStateEnum,
16355
+ importedAs: external_exports.string().nullable()
16356
+ }).meta({ id: "LibraryItem" });
16357
+ var ListLibraryResponse = external_exports.object({
16358
+ categories: external_exports.array(DetectionCategory),
16359
+ items: external_exports.array(LibraryItem)
16360
+ }).meta({ id: "ListLibraryResponse" });
16361
+ var ImportDetectionRequest = external_exports.object({
16362
+ libraryId: external_exports.string().refine((v) => /^[^/]+\/[^/]+$/.test(v), {
16363
+ message: "libraryId must be in namespace/packId format"
16364
+ })
16365
+ }).meta({ id: "ImportDetectionRequest" });
16366
+
16367
+ // ../../packages/schema/src/zod/inventory.ts
16368
+ var AssetType = external_exports.enum(["project", "skill", "mcp", "hook", "config"]).meta({ id: "AssetType" });
16369
+ var AccessLevel = external_exports.enum(["open", "approved", "blocked"]).meta({ id: "AccessLevel" });
16370
+ var Origin = external_exports.enum(["source", "public-dep", "vendored", "config", "data", "docs", "generated"]).meta({ id: "Origin" });
16371
+ var TrustLevel = external_exports.enum(["known-good", "risky", "unapproved"]).meta({ id: "TrustLevel" });
16372
+ var Flag = external_exports.enum(["update", "stale", "conflict", "unknown", "change", "untracked", "risk", "findings"]).meta({ id: "Flag" });
16373
+ var Visibility = external_exports.enum(["public", "private"]).meta({ id: "Visibility" });
16374
+ var HarnessEventKind = external_exports.enum(["block", "redact", "warn"]).meta({ id: "HarnessEventKind" });
16375
+ var HarnessId = Harness.extract(["ClaudeCode", "Cursor", "Codex", "Antigravity"]).meta({
16376
+ id: "HarnessId"
16377
+ });
16378
+ var AccessCounts = external_exports.object({
16379
+ open: external_exports.number().int().nonnegative(),
16380
+ approved: external_exports.number().int().nonnegative(),
16381
+ blocked: external_exports.number().int().nonnegative(),
16382
+ total: external_exports.number().int().nonnegative()
16383
+ }).meta({ id: "AccessCounts" });
16384
+ var AssetSummary = external_exports.object({
16385
+ id: external_exports.string(),
16386
+ type: AssetType,
16387
+ name: external_exports.string(),
16388
+ sub: external_exports.string(),
16389
+ flags: external_exports.array(Flag),
16390
+ /** MCP servers only — omitted for all other types. */
16391
+ trust: TrustLevel.optional()
16392
+ }).meta({ id: "AssetSummary" });
16393
+ var ProjectSummary = external_exports.object({
16394
+ id: external_exports.string(),
16395
+ name: external_exports.string(),
16396
+ repo: external_exports.string(),
16397
+ visibility: Visibility,
16398
+ language: external_exports.string(),
16399
+ policyDefault: AccessLevel,
16400
+ updatedAt: external_exports.iso.datetime(),
16401
+ accessCounts: AccessCounts,
16402
+ findingsCount: external_exports.number().int().nonnegative()
16403
+ }).meta({ id: "ProjectSummary" });
16404
+ var HarnessCategory = external_exports.object({
16405
+ /** One of config/skill/mcp/hook — never project (enforced at service layer). */
16406
+ type: AssetType,
16407
+ assets: external_exports.array(AssetSummary)
16408
+ });
16409
+ var HarnessSummary = external_exports.object({
16410
+ id: HarnessId,
16411
+ label: external_exports.string(),
16412
+ kind: external_exports.string(),
16413
+ version: external_exports.string(),
16414
+ sessions: external_exports.number().int().nonnegative(),
16415
+ assetCount: external_exports.number().int().nonnegative(),
16416
+ flagCount: external_exports.number().int().nonnegative(),
16417
+ projects: external_exports.array(ProjectSummary),
16418
+ categories: external_exports.array(HarnessCategory)
16419
+ }).meta({ id: "HarnessSummary" });
16420
+ var ListHarnessesResponse = external_exports.object({ items: external_exports.array(HarnessSummary) }).meta({ id: "ListHarnessesResponse" });
16421
+ var AssetGroup = external_exports.object({
16422
+ /** Group key — never project (enforced at service layer). */
16423
+ type: AssetType,
16424
+ total: external_exports.number().int().nonnegative(),
16425
+ /**
16426
+ * MCP group only — omitted for all other types.
16427
+ * Partial: only TrustLevel keys with non-zero counts are included.
16428
+ * Strict: unknown keys are rejected — only TrustLevel values are valid keys.
16429
+ */
16430
+ trustRollup: external_exports.object({
16431
+ "known-good": external_exports.number().int().nonnegative(),
16432
+ risky: external_exports.number().int().nonnegative(),
16433
+ unapproved: external_exports.number().int().nonnegative()
16434
+ }).partial().strict().optional(),
16435
+ /**
16436
+ * Partial: only Flag keys with non-zero counts are included.
16437
+ * Strict: unknown keys are rejected — only Flag values are valid keys.
16438
+ */
16439
+ flagRollup: external_exports.object({
16440
+ update: external_exports.number().int().nonnegative(),
16441
+ stale: external_exports.number().int().nonnegative(),
16442
+ conflict: external_exports.number().int().nonnegative(),
16443
+ unknown: external_exports.number().int().nonnegative(),
16444
+ change: external_exports.number().int().nonnegative(),
16445
+ untracked: external_exports.number().int().nonnegative(),
16446
+ risk: external_exports.number().int().nonnegative(),
16447
+ findings: external_exports.number().int().nonnegative()
16448
+ }).partial().strict(),
16449
+ items: external_exports.array(AssetSummary)
16450
+ }).meta({ id: "AssetGroup" });
16451
+ var ListAssetsResponse = external_exports.object({ groups: external_exports.array(AssetGroup) }).meta({ id: "ListAssetsResponse" });
16452
+ var McpTool = external_exports.object({
16453
+ name: external_exports.string(),
16454
+ signature: external_exports.string(),
16455
+ description: external_exports.string(),
16456
+ write: external_exports.boolean(),
16457
+ /** Non-null string when tool is dangerous / blocked; null otherwise. */
16458
+ risk: external_exports.string().nullable()
16459
+ }).meta({ id: "McpTool" });
16460
+ var AssetFindingRef = external_exports.object({
16658
16461
  id: external_exports.string(),
16462
+ title: external_exports.string(),
16463
+ note: external_exports.string()
16464
+ });
16465
+ var AssetDetail = AssetSummary.extend({
16466
+ /** string | null — null when no description is available. */
16467
+ description: external_exports.string().nullable(),
16468
+ /** trustLevel | null — null for non-MCP assets. */
16469
+ trust: TrustLevel.nullable(),
16470
+ /** Type-specific raw key/values — FE renders the grid. */
16471
+ meta: external_exports.record(external_exports.string(), external_exports.unknown()),
16472
+ /** always present — object when there is an active finding, null when absent. */
16473
+ finding: AssetFindingRef.nullable(),
16474
+ /** MCP exposed-tools list — omitted for non-mcp. */
16475
+ tools: external_exports.array(McpTool).optional()
16476
+ }).meta({ id: "AssetDetail" });
16477
+ var ListProjectsResponse = external_exports.object({ items: external_exports.array(ProjectSummary) }).meta({ id: "ListProjectsResponse" });
16478
+ var InventoryStats = external_exports.object({
16479
+ /** Total assets/projects with ≥1 flag or finding (drives the attention header chip). */
16480
+ attention: external_exports.number().int().nonnegative(),
16481
+ byType: external_exports.object({
16482
+ project: external_exports.number().int().nonnegative(),
16483
+ skill: external_exports.number().int().nonnegative(),
16484
+ mcp: external_exports.number().int().nonnegative(),
16485
+ hook: external_exports.number().int().nonnegative(),
16486
+ config: external_exports.number().int().nonnegative()
16487
+ }),
16488
+ harnesses: external_exports.number().int().nonnegative(),
16489
+ mcpTrust: external_exports.object({
16490
+ "known-good": external_exports.number().int().nonnegative(),
16491
+ risky: external_exports.number().int().nonnegative(),
16492
+ unapproved: external_exports.number().int().nonnegative()
16493
+ })
16494
+ }).meta({ id: "InventoryStats" });
16495
+ var FileSummary = external_exports.object({
16496
+ path: external_exports.string(),
16659
16497
  name: external_exports.string(),
16660
- version: SemVer,
16661
- enabled: external_exports.boolean(),
16662
- origin: OriginEnum,
16663
- publisher: Namespace.optional(),
16664
- publisherKind: PublisherKind.optional(),
16665
- ruleCount: external_exports.number().int().nonnegative(),
16666
- namespace: Namespace,
16667
- packId: PackId,
16668
- description: external_exports.string().optional(),
16669
- editedAt: external_exports.iso.datetime(),
16670
- findingsLast30d: external_exports.number().int().nonnegative(),
16671
- latestVersion: SemVer.nullable().optional(),
16672
- update: DetectionUpdate,
16673
- rules: external_exports.array(DetectionRule),
16674
- modified: external_exports.boolean(),
16675
- // Per-pack enforcement-policy assignment. Holds a BuiltinPolicyId ARCHETYPE
16676
- // (monitor|warn|redact|block) — NOT a policies-table Policy.id guid; a
16677
- // detection is a PACK, and its policy is the archetype applied to all its
16678
- // rules. Absent == unassigned, which resolves to Monitor everywhere
16679
- // (DEFAULT_PACK_POLICY_ID). Every enforcement surface expands it into
16680
- // per-rule policies (see policyIdToAction). Typed z.string() (not
16681
- // the enum) to keep the OpenAPI response tolerant of a future custom id.
16682
- policyId: external_exports.string().optional()
16683
- }).meta({ id: "DetectionDetail" });
16684
- var LibraryItem = external_exports.object({
16685
- id: external_exports.string(),
16498
+ origin: Origin,
16499
+ /** Effective access (override applied). */
16500
+ access: AccessLevel,
16501
+ /** True when a file_access_override differs from the computed default. */
16502
+ isCustom: external_exports.boolean(),
16503
+ findings: external_exports.number().int().nonnegative(),
16504
+ /** When the file was auto-blocked by a detection; null when not blocked. */
16505
+ blockedAt: external_exports.iso.datetime().nullable().optional(),
16506
+ /** Why the file was blocked; null when absent. */
16507
+ note: external_exports.string().nullable().optional()
16508
+ }).meta({ id: "FileSummary" });
16509
+ var FolderSummary = external_exports.object({
16686
16510
  name: external_exports.string(),
16687
- publisher: Namespace,
16688
- publisherKind: PublisherKind.optional(),
16689
- // LOSSY single-category view of a pack. A pack MAY span several categories;
16690
- // this carries only the canonical-first one for display. Do NOT filter/facet
16691
- // on it — the library filter matches a pack's full category set (see
16692
- // ListLibraryResponse.categories).
16693
- category: DetectionCategory.optional(),
16694
- version: SemVer,
16695
- ruleCount: external_exports.number().int().nonnegative(),
16696
- description: external_exports.string().optional(),
16697
- updatedAt: external_exports.iso.datetime(),
16698
- state: LibraryStateEnum,
16699
- importedAs: external_exports.string().nullable()
16700
- }).meta({ id: "LibraryItem" });
16701
- var ListLibraryResponse = external_exports.object({
16702
- categories: external_exports.array(DetectionCategory),
16703
- items: external_exports.array(LibraryItem)
16704
- }).meta({ id: "ListLibraryResponse" });
16705
- var ImportDetectionRequest = external_exports.object({
16706
- libraryId: external_exports.string().refine((v) => /^[^/]+\/[^/]+$/.test(v), {
16707
- message: "libraryId must be in namespace/packId format"
16708
- })
16709
- }).meta({ id: "ImportDetectionRequest" });
16511
+ path: external_exports.string(),
16512
+ /** Rollup of effective access across all descendants. */
16513
+ accessCounts: AccessCounts
16514
+ }).meta({ id: "FolderSummary" });
16515
+ var ProjectTreeResponse = external_exports.object({
16516
+ project: external_exports.object({
16517
+ id: external_exports.string(),
16518
+ repo: external_exports.string(),
16519
+ visibility: Visibility
16520
+ }),
16521
+ path: external_exports.string(),
16522
+ /** Browse mode: one-level folders at the current path. Omitted in search mode. */
16523
+ folders: external_exports.array(FolderSummary).optional(),
16524
+ files: external_exports.array(FileSummary)
16525
+ }).meta({ id: "ProjectTreeResponse" });
16526
+ var FileDetail = FileSummary.extend({
16527
+ project: external_exports.object({
16528
+ repo: external_exports.string(),
16529
+ visibility: Visibility,
16530
+ language: external_exports.string(),
16531
+ policyDefault: AccessLevel,
16532
+ updatedAt: external_exports.iso.datetime()
16533
+ }),
16534
+ findingsRefs: external_exports.array(external_exports.object({ id: external_exports.string(), title: external_exports.string() }))
16535
+ }).meta({ id: "FileDetail" });
16536
+ var SetFileAccessBody = external_exports.object({
16537
+ path: external_exports.string(),
16538
+ access: AccessLevel
16539
+ }).meta({ id: "SetFileAccessBody" });
16540
+ var SetFileAccessResponse = external_exports.object({
16541
+ file: FileSummary,
16542
+ accessCounts: AccessCounts
16543
+ }).meta({ id: "SetFileAccessResponse" });
16544
+ var SetMcpTrustBody = external_exports.object({ trust: TrustLevel }).meta({ id: "SetMcpTrustBody" });
16545
+ var HarnessEventItem = external_exports.object({
16546
+ kind: HarnessEventKind,
16547
+ title: external_exports.string(),
16548
+ detail: external_exports.string(),
16549
+ occurredAt: external_exports.iso.datetime(),
16550
+ findingId: external_exports.string().nullable().optional()
16551
+ }).meta({ id: "HarnessEventItem" });
16552
+ var HarnessEventsResponse = external_exports.object({
16553
+ counts: external_exports.object({
16554
+ block: external_exports.number().int().nonnegative(),
16555
+ redact: external_exports.number().int().nonnegative(),
16556
+ warn: external_exports.number().int().nonnegative()
16557
+ }),
16558
+ items: external_exports.array(HarnessEventItem)
16559
+ }).meta({ id: "HarnessEventsResponse" });
16560
+ var RescanResponse = external_exports.object({
16561
+ jobId: external_exports.string(),
16562
+ startedAt: external_exports.iso.datetime()
16563
+ }).meta({ id: "RescanResponse" });
16564
+ var ConnectProjectBody = external_exports.object({ repo: external_exports.string() }).meta({ id: "ConnectProjectBody" });
16565
+ var ListAssetsQuery = external_exports.object({
16566
+ /** Filter by one or more AssetType values; absent means all types. */
16567
+ type: external_exports.array(AssetType).optional(),
16568
+ /** Free-text search term. */
16569
+ q: external_exports.string().optional()
16570
+ });
16571
+ var GetProjectTreeQuery = external_exports.object({
16572
+ /** Subtree root path; defaults to repository root when absent. */
16573
+ path: external_exports.string().optional(),
16574
+ /** Free-text filter applied to file paths. */
16575
+ q: external_exports.string().optional(),
16576
+ /**
16577
+ * Special listing mode. `blocked` returns every effectively-blocked, auto-blocked
16578
+ * file across the whole repo (folders omitted, most-recent first), ignoring
16579
+ * `path`/`q` — powers the project-wide "recently blocked" strip.
16580
+ */
16581
+ filter: external_exports.enum(["blocked"]).optional()
16582
+ });
16583
+ var GetProjectFileQuery = external_exports.object({
16584
+ /** Repository-relative file path; absent or empty → 400. */
16585
+ path: external_exports.string()
16586
+ });
16587
+ var GetHarnessEventsQuery = external_exports.object({
16588
+ /** Maximum number of events to return. Range: 1–50; default: 7. */
16589
+ limit: external_exports.coerce.number().int().min(1).max(50).default(7)
16590
+ });
16710
16591
 
16711
16592
  // ../../packages/schema/src/zod/shares.ts
16712
16593
  var DestinationKind = external_exports.enum(["provider", "internal", "external", "ip"]).meta({ id: "DestinationKind" });
@@ -16914,6 +16795,127 @@ var EgressWriteSummary = external_exports.object({
16914
16795
  droppedFiles: external_exports.array(external_exports.string()).default([])
16915
16796
  }).meta({ id: "EgressWriteSummary" });
16916
16797
 
16798
+ // ../../packages/schema/src/zod/event.ts
16799
+ var EventKind = external_exports.enum(["prompt", "response", "code_change", "tool_use"]).meta({ id: "EventKind" });
16800
+ var CAPTURE_EVENT_TYPES_SQL = EventKind.options.map((k) => `'${k}'`).join(",");
16801
+ var EventMetadata = external_exports.object({
16802
+ sessionId: external_exports.string().optional(),
16803
+ repo: external_exports.string().optional(),
16804
+ filePath: external_exports.string().optional(),
16805
+ // The host tool whose input/output was scanned (e.g. 'Bash', 'WebFetch'),
16806
+ // set by the tool-scanning hooks. The tool NAME only — never the tool's
16807
+ // arguments or output, which can carry the very value a finding masked
16808
+ // (metadata is stored unredacted). Gives findings on non-file captures a
16809
+ // display location ("via Bash") when no filePath exists.
16810
+ toolName: external_exports.string().optional(),
16811
+ // Set (true) by the worktree scanner when the file is excluded by the
16812
+ // repo's .gitignore. Gitignored files ARE still scanned — local scratch and
16813
+ // generated code can leak real secrets — but the provenance is recorded so
16814
+ // policy/dashboards can treat those findings as informational rather than
16815
+ // blocking. Omitted (not false) for tracked files and non-scan events.
16816
+ gitignored: external_exports.boolean().optional(),
16817
+ // Set (true) ONLY when the event's `content` is the COMPLETE file at
16818
+ // capture time (a worktree scan reading from disk). Hook-captured edits
16819
+ // (e.g. an Edit tool's new_string) are partial fragments and MUST NOT set
16820
+ // this. The resolver-on-ingest keys its fixed-at-source dropout
16821
+ // diff on this marker: only a whole-file snapshot can prove a previously
16822
+ // open finding is gone; a fragment's absence proves nothing (the secret
16823
+ // may live outside the hunk). Omitted (not false) for fragments and
16824
+ // non-scan events, so pre-marker clients safely default to the
16825
+ // non-authoritative path.
16826
+ wholeFile: external_exports.boolean().optional(),
16827
+ model: external_exports.string().optional(),
16828
+ turnIndex: external_exports.number().int().nonnegative().optional(),
16829
+ // Distributed-tracing correlation. `correlationId` ties a recorded event back
16830
+ // to the request that captured/ingested it (a UUID, generated independently of
16831
+ // the trace id); `traceId` is the W3C trace id (32 lowercase hex chars) of the
16832
+ // originating span when telemetry is enabled. Both optional + backward
16833
+ // compatible — populated by the plugin (see @akasecurity/plugin-sdk).
16834
+ correlationId: external_exports.uuid().optional(),
16835
+ traceId: external_exports.string().regex(/^[0-9a-f]{32}$/).optional(),
16836
+ // Ids of the detection exceptions that downgraded findings in this capture
16837
+ // to 'allow' — the enforcement audit trail's link back to the grant that
16838
+ // authorized the bypass. Absent on captures where no exception applied.
16839
+ exceptionIds: external_exports.array(external_exports.guid()).optional()
16840
+ }).meta({ id: "EventMetadata" });
16841
+ var Event = external_exports.object({
16842
+ id: external_exports.guid(),
16843
+ sourceTool: SourceTool,
16844
+ kind: EventKind,
16845
+ occurredAt: external_exports.iso.datetime(),
16846
+ contentHash: external_exports.string(),
16847
+ content: external_exports.string(),
16848
+ metadata: EventMetadata.optional()
16849
+ }).meta({ id: "Event" });
16850
+ var IngestEvent = Event.meta({ id: "IngestEvent" });
16851
+ var IngestBatch = external_exports.object({
16852
+ events: external_exports.array(IngestEvent).min(1).max(100),
16853
+ // Dedup policy for this batch. Id-dedup ALWAYS applies. 'content-hash'
16854
+ // additionally rejects any event whose contentHash the store has already
16855
+ // recorded — for re-runnable bulk ingest (worktree scan, transcript
16856
+ // backfill), where a re-run mints fresh event ids for identical content and
16857
+ // would otherwise accumulate duplicates. Live hook traffic must NOT set it:
16858
+ // two genuinely separate prompts can be byte-identical and both belong on
16859
+ // the timeline.
16860
+ dedupe: external_exports.literal("content-hash").optional()
16861
+ }).meta({ id: "IngestBatch" });
16862
+
16863
+ // ../../packages/schema/src/zod/exception.ts
16864
+ var ExceptionScope = external_exports.enum(["once", "temporary", "permanent"]);
16865
+ var ExceptionConditions = external_exports.object({
16866
+ repo: external_exports.string().optional(),
16867
+ sourceTool: external_exports.string().optional(),
16868
+ provider: external_exports.string().optional()
16869
+ }).strict();
16870
+ var ExceptionCapability = external_exports.enum(["suppress", "reveal_to_model"]);
16871
+ var DetectionException = external_exports.object({
16872
+ id: external_exports.guid(),
16873
+ ruleId: external_exports.string(),
16874
+ // Denormalized from the rule, for reporting — never matched on.
16875
+ category: DetectionCategory,
16876
+ // HMAC-SHA256 hex of the raw match under a machine-local key: a KEYED
16877
+ // fingerprint, never the raw value, and never reversible. Matching recomputes
16878
+ // the fingerprint from a fresh capture; the value itself is never stored.
16879
+ // Shape-constrained so a malformed — or accidentally raw — value is rejected
16880
+ // at the boundary rather than persisted.
16881
+ valueFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
16882
+ // Version of the fingerprint key the grant was written under; a rotated key
16883
+ // invalidates old grants rather than silently mismatching them.
16884
+ keyVersion: external_exports.number().int().positive(),
16885
+ // maskMatch() preview of the approved value — never the raw value.
16886
+ maskedValue: external_exports.string(),
16887
+ capability: ExceptionCapability.default("suppress"),
16888
+ scope: ExceptionScope,
16889
+ expiresAt: external_exports.iso.datetime().nullable(),
16890
+ maxUses: external_exports.number().int().positive().nullable(),
16891
+ useCount: external_exports.number().int().nonnegative(),
16892
+ lastUsedAt: external_exports.iso.datetime().nullable(),
16893
+ // Mandatory: every grant carries the human reason it exists.
16894
+ justification: external_exports.string().min(1),
16895
+ conditions: ExceptionConditions.nullable(),
16896
+ createdBy: external_exports.string(),
16897
+ createdVia: external_exports.enum(["cli-approve", "cli-add", "web-approve", "web-add", "api", "setup-triage"]),
16898
+ createdAt: external_exports.iso.datetime(),
16899
+ updatedAt: external_exports.iso.datetime(),
16900
+ // Revocation is terminal and retained — consumed/expired/revoked rows are
16901
+ // audit evidence; nothing in the exception lifecycle hard-deletes.
16902
+ revokedAt: external_exports.iso.datetime().nullable(),
16903
+ revokedBy: external_exports.string().nullable(),
16904
+ revokeReason: external_exports.string().nullable()
16905
+ });
16906
+ var ExceptionBundleEntry = DetectionException.pick({
16907
+ id: true,
16908
+ ruleId: true,
16909
+ valueFingerprint: true,
16910
+ keyVersion: true,
16911
+ capability: true,
16912
+ expiresAt: true,
16913
+ maxUses: true,
16914
+ useCount: true,
16915
+ conditions: true
16916
+ });
16917
+ var ExceptionDescriptor = DetectionException.omit({ valueFingerprint: true });
16918
+
16917
16919
  // ../../packages/schema/src/zod/exception-action.ts
16918
16920
  var confirmation = external_exports.string().optional();
16919
16921
  var ApproveBlockedInput = external_exports.object({
@@ -17125,7 +17127,13 @@ var VaultConsent = external_exports.object({
17125
17127
 
17126
17128
  // ../../packages/schema/src/zod/local.ts
17127
17129
  var WORKSPACE_SETTINGS_SPEC_VERSION = 5;
17128
- var RunMode = external_exports.enum(["standalone"]);
17130
+ var RunMode = external_exports.enum(["standalone", "attached"]);
17131
+ var ControlPlaneConnection = external_exports.object({
17132
+ endpoint: external_exports.string().min(1),
17133
+ // Display name for the deployment, shown instead of the raw endpoint.
17134
+ label: external_exports.string().min(1).optional(),
17135
+ attachedAt: external_exports.iso.datetime()
17136
+ }).meta({ id: "ControlPlaneConnection" });
17129
17137
  var SimpleDetectionPolicy = external_exports.enum(["redact", "warn"]);
17130
17138
  var HistoricalAccess = external_exports.enum(["full", "session-only"]);
17131
17139
  var ModelJudgeConsent = external_exports.object({
@@ -17134,12 +17142,10 @@ var ModelJudgeConsent = external_exports.object({
17134
17142
  });
17135
17143
  var WorkspaceSettings = external_exports.object({
17136
17144
  specVersion: external_exports.number().int().positive().default(WORKSPACE_SETTINGS_SPEC_VERSION),
17137
- // Settings files written by earlier releases may carry the retired 'attached'
17138
- // value; it parses as 'standalone' so those files keep loading.
17139
- runMode: external_exports.preprocess(
17140
- (v) => v === "attached" ? "standalone" : v,
17141
- RunMode.default("standalone")
17142
- ),
17145
+ runMode: RunMode.default("standalone"),
17146
+ // Present only while attached; a detach clears it. Its presence is what makes
17147
+ // `runMode: 'attached'` mean anything — see isAttached.
17148
+ controlPlane: ControlPlaneConnection.optional(),
17143
17149
  policy: SimpleDetectionPolicy.default("redact"),
17144
17150
  // Consent for scanning pre-install surfaces; opt-in (see HistoricalAccess).
17145
17151
  historicalAccess: HistoricalAccess.default("session-only"),
@@ -17165,6 +17171,200 @@ var WorkspaceSettings = external_exports.object({
17165
17171
  modelJudgeConsent: ModelJudgeConsent.optional()
17166
17172
  });
17167
17173
 
17174
+ // ../../packages/schema/src/zod/managed.ts
17175
+ var MANAGED_SETTINGS_SPEC_VERSION = 1;
17176
+ var ManagedSettingKey = external_exports.enum([
17177
+ "runMode",
17178
+ "historicalAccess",
17179
+ "vaultConsent",
17180
+ "vaultKeyCustody",
17181
+ "vaultInlineReveal",
17182
+ "modelJudgeConsent",
17183
+ "dataSharesInPlace"
17184
+ ]).meta({ id: "ManagedSettingKey" });
17185
+ var ManagedSettingsValues = external_exports.object({
17186
+ runMode: external_exports.enum(["standalone", "attached"]).optional(),
17187
+ controlPlane: external_exports.object({
17188
+ endpoint: external_exports.string().min(1),
17189
+ label: external_exports.string().min(1).optional()
17190
+ }).optional(),
17191
+ historicalAccess: external_exports.enum(["full", "session-only"]).optional(),
17192
+ vaultConsent: external_exports.boolean().optional(),
17193
+ vaultKeyCustody: external_exports.enum(["file", "keychain"]).optional(),
17194
+ vaultInlineReveal: external_exports.enum(["masked", "full", "off"]).optional(),
17195
+ modelJudgeConsent: external_exports.boolean().optional(),
17196
+ dataSharesInPlace: external_exports.boolean().optional()
17197
+ }).meta({ id: "ManagedSettingsValues" });
17198
+ var ManagedSettings = external_exports.object({
17199
+ specVersion: external_exports.number().int().positive().default(MANAGED_SETTINGS_SPEC_VERSION),
17200
+ // Shown on every locked control, so the user can tell an administrative
17201
+ // decision from a bug. Absent renders as a generic "your organization".
17202
+ organization: external_exports.string().min(1).optional(),
17203
+ // What the administrator pinned.
17204
+ values: ManagedSettingsValues.default({}),
17205
+ // Which of those the user may not change. A key here with no matching value
17206
+ // freezes whatever the user last chose; a value with no lock is a DEFAULT
17207
+ // the user may still override. The two are separable on purpose.
17208
+ lockedFields: external_exports.array(ManagedSettingKey).default([])
17209
+ }).meta({ id: "ManagedSettings" });
17210
+
17211
+ // ../../packages/schema/src/zod/policy.ts
17212
+ var PolicyScope = external_exports.enum(["global", "repo", "user"]).meta({ id: "PolicyScope" });
17213
+ var PolicyTarget = external_exports.union([external_exports.object({ ruleId: external_exports.string() }), external_exports.object({ category: DetectionCategory })]).meta({ id: "PolicyTarget" });
17214
+ var Policy = external_exports.object({
17215
+ id: external_exports.guid(),
17216
+ scope: PolicyScope,
17217
+ target: PolicyTarget,
17218
+ action: ActionTaken,
17219
+ enabled: external_exports.boolean().default(true),
17220
+ customKeywords: external_exports.array(external_exports.string()).optional(),
17221
+ // Display name — optional so older policy rows without name still parse.
17222
+ // Added for the findings API (policy.name column migration).
17223
+ name: external_exports.string().optional()
17224
+ }).meta({ id: "Policy" });
17225
+ var PolicyBundle = external_exports.object({
17226
+ version: external_exports.string(),
17227
+ policies: external_exports.array(Policy),
17228
+ // Rules from the installed marketplace packs (snapshotted by the
17229
+ // control plane). The plugin registers these in addition to its bundled
17230
+ // packs. Optional so older backends — and older on-disk caches — that omit
17231
+ // the field still parse; consumers read `bundle.rules ?? []`.
17232
+ rules: external_exports.array(Rule).optional(),
17233
+ // When true, `rules` IS the complete effective ruleset and the runtime must
17234
+ // NOT merge its compiled-in bundled packs — the standalone gateway sets this
17235
+ // after reading the user's installed snapshot (installed_packs, enabled
17236
+ // packs only), which is how detection updates stay manual: new bundled
17237
+ // rules run only after the user applies the pack update. Absent/false keeps
17238
+ // the historical composition (bundled packs + rules) — older caches.
17239
+ rulesComplete: external_exports.boolean().optional(),
17240
+ // Active detection exceptions, evaluation subset only (see
17241
+ // ExceptionBundleEntry). Optional so older bundle producers — and older
17242
+ // on-disk caches — that omit the field still parse; consumers read
17243
+ // `bundle.exceptions ?? []`.
17244
+ exceptions: external_exports.array(ExceptionBundleEntry).optional(),
17245
+ // Rule ids whose pack is assigned a REVERSIBLE archetype (Redact & Vault).
17246
+ // A second axis over the same `redact` action, carried beside the policies
17247
+ // rather than on them: nothing writes ruleId-targeted policies to disk, so
17248
+ // widening Policy itself would change a persisted shape to express something
17249
+ // only the in-memory bundle needs. Optional so an older producer — or an
17250
+ // older on-disk cache — still parses; consumers read `?? []` and get the
17251
+ // pre-existing one-way behaviour, which is the safe direction to default.
17252
+ reversibleRuleIds: external_exports.array(external_exports.string()).optional(),
17253
+ // Installed pack version, keyed by ruleId, for rules in `rules` that came
17254
+ // from a versioned installed pack. Optional so older backends — and older
17255
+ // on-disk caches — that omit the field still parse; consumers fall back to
17256
+ // the rule's own spec version. NOT the bundle version above — see
17257
+ // installedRuleset's ruleVersions for the source of truth.
17258
+ ruleVersions: external_exports.record(external_exports.string(), external_exports.string()).optional(),
17259
+ customKeywords: external_exports.array(external_exports.string()),
17260
+ fetchedAt: external_exports.iso.datetime()
17261
+ }).meta({ id: "PolicyBundle" });
17262
+ var OBSERVE_ONLY_CATEGORIES = ["config"];
17263
+ var ENFORCEABLE_CATEGORIES = DetectionCategory.options.filter((c) => !OBSERVE_ONLY_CATEGORIES.includes(c));
17264
+ var CATEGORY_PEAK_SEVERITY = {
17265
+ secret: "critical",
17266
+ financial: "critical",
17267
+ // core-financial/credit-card
17268
+ code_flaw: "critical",
17269
+ pii: "high",
17270
+ phi: "high",
17271
+ custom: "high",
17272
+ // user-defined; conservative
17273
+ code_context: "low",
17274
+ config: "low"
17275
+ // observe-only; floors to monitor regardless
17276
+ };
17277
+ function severityFloorPolicy(category) {
17278
+ if (OBSERVE_ONLY_CATEGORIES.includes(category)) return "monitor";
17279
+ const peak = CATEGORY_PEAK_SEVERITY[category];
17280
+ return peak === "critical" || peak === "high" ? "warn" : "monitor";
17281
+ }
17282
+ function severityFloorPosture() {
17283
+ const out = {};
17284
+ for (const c of DetectionCategory.options) out[c] = severityFloorPolicy(c);
17285
+ return out;
17286
+ }
17287
+ var PolicyKind = external_exports.enum(["builtin", "custom"]).meta({ id: "PolicyKind" });
17288
+ var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
17289
+ var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
17290
+ var BUILTIN_POLICY_SPECS = {
17291
+ monitor: {
17292
+ name: "Monitor",
17293
+ action: "log",
17294
+ reversible: false,
17295
+ description: "Log every match for audit. The request is allowed through untouched."
17296
+ },
17297
+ warn: {
17298
+ name: "Warn",
17299
+ action: "warn",
17300
+ reversible: false,
17301
+ description: "Allow the request, but warn the user inline before it is sent."
17302
+ },
17303
+ redact: {
17304
+ name: "Redact",
17305
+ action: "redact",
17306
+ reversible: false,
17307
+ description: "Strip the matched value from the request and destroy it, then continue. What was removed cannot be recovered."
17308
+ },
17309
+ vault: {
17310
+ name: "Redact & Vault",
17311
+ action: "redact",
17312
+ reversible: true,
17313
+ 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."
17314
+ },
17315
+ block: {
17316
+ name: "Block",
17317
+ action: "block",
17318
+ reversible: false,
17319
+ description: "Refuse the request entirely whenever any rule in this detection matches."
17320
+ }
17321
+ };
17322
+ function builtinPolicyToAction(id) {
17323
+ return BUILTIN_POLICY_SPECS[id].action;
17324
+ }
17325
+ var CATEGORY_EXPRESSIBLE_IDS = KNOWN_BUILTIN_IDS.filter(
17326
+ (id) => !BUILTIN_POLICY_SPECS[id].reversible
17327
+ );
17328
+ var CATEGORY_INEXPRESSIBLE_IDS = KNOWN_BUILTIN_IDS.filter(
17329
+ (id) => BUILTIN_POLICY_SPECS[id].reversible
17330
+ );
17331
+ var CategoryPolicyId = external_exports.enum(CATEGORY_EXPRESSIBLE_IDS).meta({ id: "CategoryPolicyId" });
17332
+ var DEFAULT_ACTIONS = Object.fromEntries(
17333
+ DetectionCategory.options.map((c) => [c, builtinPolicyToAction(severityFloorPolicy(c))])
17334
+ );
17335
+ var BUILTIN_POLICIES = Object.fromEntries(
17336
+ KNOWN_BUILTIN_IDS.map((id) => [id, { id, ...BUILTIN_POLICY_SPECS[id] }])
17337
+ );
17338
+ var UsedByItem = external_exports.object({
17339
+ id: external_exports.string(),
17340
+ name: external_exports.string(),
17341
+ ruleCount: external_exports.number().int().nonnegative(),
17342
+ enabled: external_exports.boolean()
17343
+ }).meta({ id: "UsedByItem" });
17344
+ var PolicyListItem = external_exports.object({
17345
+ id: external_exports.string(),
17346
+ kind: PolicyKind,
17347
+ name: external_exports.string(),
17348
+ enabled: external_exports.boolean(),
17349
+ usedByCount: external_exports.number().int().nonnegative()
17350
+ }).meta({ id: "PolicyListItem" });
17351
+ var ListPoliciesResponse = external_exports.object({ items: external_exports.array(PolicyListItem) }).meta({ id: "ListPoliciesResponse" });
17352
+ var PolicyDetail = external_exports.object({
17353
+ specVersion: external_exports.literal(1),
17354
+ id: external_exports.string(),
17355
+ kind: PolicyKind,
17356
+ name: external_exports.string(),
17357
+ enabled: external_exports.boolean(),
17358
+ description: external_exports.string(),
17359
+ usedBy: external_exports.array(UsedByItem)
17360
+ }).meta({ id: "PolicyDetail" });
17361
+ var PolicyStatsResponse = external_exports.object({
17362
+ policies: external_exports.number().int().nonnegative(),
17363
+ builtin: external_exports.number().int().nonnegative(),
17364
+ custom: external_exports.number().int().nonnegative(),
17365
+ detectionsGoverned: external_exports.number().int().nonnegative()
17366
+ }).meta({ id: "PolicyStatsResponse" });
17367
+
17168
17368
  // ../../packages/schema/src/zod/project-files.ts
17169
17369
  var ProjectFileInput = external_exports.object({
17170
17370
  path: external_exports.string().min(1),
@@ -17237,44 +17437,6 @@ var BatchedRemediation = external_exports.discriminatedUnion("kind", [
17237
17437
  NoRemediationDecision
17238
17438
  ]);
17239
17439
 
17240
- // ../../packages/schema/src/zod/rule-test.ts
17241
- var TestRulesRequest = external_exports.object({
17242
- rules: external_exports.array(Rule).min(1).max(100),
17243
- text: external_exports.string().max(5e4).optional(),
17244
- fixtures: external_exports.array(RuleFixture).max(200).optional()
17245
- }).refine((v) => v.text !== void 0 || (v.fixtures?.length ?? 0) > 0, {
17246
- message: "Provide `text`, `fixtures`, or both \u2014 there must be something to test"
17247
- }).meta({ id: "TestRulesRequest" });
17248
- var RuleTestMatch = external_exports.object({
17249
- ruleId: external_exports.string(),
17250
- category: DetectionCategory,
17251
- severity: Severity,
17252
- span: Span,
17253
- confidence: external_exports.number().min(0).max(1),
17254
- match: external_exports.string()
17255
- }).meta({ id: "RuleTestMatch" });
17256
- var FixtureResult = external_exports.object({
17257
- label: external_exports.string(),
17258
- shouldMatch: external_exports.boolean(),
17259
- didMatch: external_exports.boolean(),
17260
- passed: external_exports.boolean(),
17261
- matches: external_exports.array(RuleTestMatch)
17262
- }).meta({ id: "FixtureResult" });
17263
- var TestRulesResponse = external_exports.object({
17264
- // Present only when the request supplied `text`.
17265
- adhoc: external_exports.object({ matches: external_exports.array(RuleTestMatch) }).optional(),
17266
- fixtures: external_exports.array(FixtureResult),
17267
- summary: external_exports.object({
17268
- total: external_exports.number().int().nonnegative(),
17269
- passed: external_exports.number().int().nonnegative(),
17270
- failed: external_exports.number().int().nonnegative()
17271
- }),
17272
- // Ids of rules whose matcher type the engine cannot evaluate today (e.g.
17273
- // `validator`), so they silently never match. Surfaced so an author is not
17274
- // misled by a green run that actually skipped a rule.
17275
- unsupportedRuleIds: external_exports.array(external_exports.string())
17276
- }).meta({ id: "TestRulesResponse" });
17277
-
17278
17440
  // ../../packages/schema/src/zod/security.ts
17279
17441
  var SeveritySummaryItem = external_exports.object({
17280
17442
  severity: Severity,
@@ -17372,10 +17534,22 @@ var TopSourcesQuery = external_exports.object({
17372
17534
  // Omit for both kinds.
17373
17535
  kind: external_exports.enum(SOURCE_KINDS).optional()
17374
17536
  });
17375
- var Provider = external_exports.enum(["claudecode", "cursor", "codex", "antigravity", "claudeai", "chatgpt", "copilot", "api"]).meta({ id: "Provider" });
17537
+ var Provider = Harness.extract([
17538
+ "ClaudeCode",
17539
+ "Cursor",
17540
+ "Codex",
17541
+ "Antigravity",
17542
+ "ClaudeAi",
17543
+ "ChatGpt",
17544
+ "Copilot",
17545
+ "Api"
17546
+ ]).meta({ id: "Provider" });
17376
17547
  var ScanCoverageProvider = external_exports.object({
17377
17548
  provider: Provider,
17378
- // Percent of that provider's traffic scanned in the window. 0 when unsupported.
17549
+ // Percent of that provider's traffic the shipped capture surface reaches.
17550
+ // A curated business fact, constant across every `range` — not a measured
17551
+ // per-window metric. 0 exactly when `supported` is false. See the comment
17552
+ // above the block for where these numbers are decided.
17379
17553
  coverage: external_exports.number().int().min(0).max(100),
17380
17554
  supported: external_exports.boolean()
17381
17555
  }).meta({ id: "ScanCoverageProvider" });
@@ -17429,6 +17603,18 @@ var ApplyRecommendedActionResponse = external_exports.object({
17429
17603
  var DismissRecommendedActionResponse = external_exports.object({ id: external_exports.string(), status: external_exports.literal("dismissed") }).meta({ id: "DismissRecommendedActionResponse" });
17430
17604
  var RecommendedActionIdParam = external_exports.object({ id: external_exports.string() });
17431
17605
 
17606
+ // ../../packages/schema/src/zod/settings-action.ts
17607
+ var SaveSettingsInput = external_exports.object({
17608
+ historicalAccess: external_exports.string(),
17609
+ modelJudgeConsent: external_exports.boolean(),
17610
+ vaultConsent: external_exports.string(),
17611
+ vaultInlineReveal: external_exports.string()
17612
+ });
17613
+ var AttachInput = external_exports.object({
17614
+ endpoint: external_exports.string(),
17615
+ label: external_exports.string().optional()
17616
+ });
17617
+
17432
17618
  // ../../packages/schema/src/zod/triage.ts
17433
17619
  var TriageHit = external_exports.object({
17434
17620
  ruleId: external_exports.string(),
@@ -17443,7 +17629,7 @@ var TriageHit = external_exports.object({
17443
17629
  valueFingerprint: external_exports.string().optional(),
17444
17630
  keyVersion: external_exports.number().int().nonnegative().optional()
17445
17631
  });
17446
- var TriagePolicy = BuiltinPolicyId;
17632
+ var TriagePolicy = CategoryPolicyId;
17447
17633
  var TriageCategoryRec = external_exports.object({
17448
17634
  category: DetectionCategory,
17449
17635
  action: TriagePolicy,
@@ -17537,14 +17723,6 @@ var SetupHandoffOffer = external_exports.object({
17537
17723
  path: ["liveKeys"]
17538
17724
  });
17539
17725
 
17540
- // ../../packages/persistence/src/ids.ts
17541
- import { createHash } from "crypto";
17542
-
17543
- // ../../packages/persistence/src/internal/snapshot.ts
17544
- import { randomUUID } from "crypto";
17545
- import { existsSync, readdirSync, renameSync as renameSync2, rmSync as rmSync2, statSync } from "fs";
17546
- import { basename, dirname, join } from "path";
17547
-
17548
17726
  // ../../packages/persistence/src/paths.ts
17549
17727
  import {
17550
17728
  chmodSync,
@@ -17557,11 +17735,25 @@ import {
17557
17735
  } from "fs";
17558
17736
  import { threadId } from "worker_threads";
17559
17737
 
17738
+ // ../../packages/persistence/src/database.ts
17739
+ import { randomUUID as randomUUID10 } from "crypto";
17740
+ import { join as join3, sep } from "path";
17741
+ import { DatabaseSync } from "node:sqlite";
17742
+
17743
+ // ../../packages/persistence/src/ids.ts
17744
+ import { createHash } from "crypto";
17745
+
17560
17746
  // ../../packages/persistence/src/internal/snapshot.ts
17747
+ import { randomUUID } from "crypto";
17748
+ import { existsSync, readdirSync, renameSync as renameSync2, rmSync as rmSync3, statSync as statSync2 } from "fs";
17749
+ import { basename, dirname, join as join2 } from "path";
17561
17750
  var STALE_PARTIAL_MS = 5 * 6e4;
17751
+ var SNAPSHOT_STAGING_SUFFIX = ".partial";
17752
+ var STAGED_NAME_SUFFIX = `.bak${SNAPSHOT_STAGING_SUFFIX}`;
17562
17753
 
17563
17754
  // ../../packages/persistence/src/repositories/activity.ts
17564
17755
  var LIVE_ACTIVITY_WINDOW_MS = 30 * 6e4;
17756
+ var DEFAULT_HARNESS = HARNESS.ClaudeCode;
17565
17757
 
17566
17758
  // ../../packages/persistence/src/repositories/exceptions.ts
17567
17759
  import { randomUUID as randomUUID2 } from "crypto";
@@ -17580,7 +17772,20 @@ import { createHash as createHash2, randomUUID as randomUUID3 } from "crypto";
17580
17772
  // ../../packages/persistence/src/repositories/inventory-assets.ts
17581
17773
  import { randomUUID as randomUUID4 } from "crypto";
17582
17774
  var VALID_HARNESS_IDS = new Set(HarnessId.options);
17775
+ var HARNESS_LABELS = {
17776
+ [HARNESS.ClaudeCode]: "Claude Code",
17777
+ [HARNESS.Cursor]: "Cursor",
17778
+ [HARNESS.Codex]: "Codex",
17779
+ [HARNESS.Antigravity]: "Antigravity"
17780
+ };
17583
17781
  var HARNESS_LIVENESS_WINDOW_MS = 30 * 24 * 60 * 60 * 1e3;
17782
+ var stripSeparators = (value) => value.toLowerCase().replace(/[\s-]/g, "");
17783
+ var TITLE_NEEDLES = {
17784
+ ClaudeCode: stripSeparators(SOURCE_TOOL.ClaudeCode),
17785
+ Cursor: stripSeparators(SOURCE_TOOL.Cursor),
17786
+ Codex: stripSeparators(SOURCE_TOOL.Codex),
17787
+ Antigravity: stripSeparators(SOURCE_TOOL.Antigravity)
17788
+ };
17584
17789
 
17585
17790
  // ../../packages/persistence/src/repositories/policies.ts
17586
17791
  import { randomUUID as randomUUID5 } from "crypto";
@@ -17594,6 +17799,18 @@ import { randomUUID as randomUUID7 } from "crypto";
17594
17799
  // ../../packages/persistence/src/repositories/secret-vault.ts
17595
17800
  import { randomUUID as randomUUID8 } from "crypto";
17596
17801
 
17802
+ // ../../packages/persistence/src/repositories/security.ts
17803
+ var SCAN_COVERAGE = {
17804
+ [HARNESS.Antigravity]: { coverage: 60, supported: true },
17805
+ [HARNESS.Api]: { coverage: 0, supported: false },
17806
+ [HARNESS.ChatGpt]: { coverage: 40, supported: true },
17807
+ [HARNESS.ClaudeAi]: { coverage: 40, supported: true },
17808
+ [HARNESS.ClaudeCode]: { coverage: 100, supported: true },
17809
+ [HARNESS.Codex]: { coverage: 80, supported: true },
17810
+ [HARNESS.Copilot]: { coverage: 0, supported: false },
17811
+ [HARNESS.Cursor]: { coverage: 0, supported: false }
17812
+ };
17813
+
17597
17814
  // ../../packages/persistence/src/repositories/shares.ts
17598
17815
  import { randomUUID as randomUUID9 } from "crypto";
17599
17816
 
@@ -17603,9 +17820,9 @@ import {
17603
17820
  closeSync,
17604
17821
  existsSync as existsSync2,
17605
17822
  openSync,
17606
- readFileSync,
17607
- rmSync as rmSync3,
17608
- statSync as statSync2,
17823
+ readFileSync as readFileSync2,
17824
+ rmSync as rmSync4,
17825
+ statSync as statSync3,
17609
17826
  writeFileSync as writeFileSync2
17610
17827
  } from "fs";
17611
17828
  import { hostname as hostname3 } from "os";
@@ -17616,19 +17833,27 @@ import { createHash as createHash3 } from "crypto";
17616
17833
 
17617
17834
  // ../../packages/persistence/src/fingerprint.ts
17618
17835
  import { createHmac, randomBytes } from "crypto";
17619
- import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
17620
- import { join as join3 } from "path";
17836
+ import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
17837
+ import { join as join4 } from "path";
17621
17838
  import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
17622
17839
 
17623
17840
  // ../../packages/persistence/src/local-layout.ts
17624
17841
  import { renameSync as renameSync3 } from "fs";
17625
17842
  import { mkdir } from "fs/promises";
17626
17843
  import { homedir } from "os";
17627
- import { join as join4 } from "path";
17844
+ import { join as join5 } from "path";
17845
+
17846
+ // ../../packages/persistence/src/managed-settings.ts
17847
+ import { readFileSync as readFileSync4 } from "fs";
17848
+ import { posix, win32 } from "path";
17628
17849
 
17629
17850
  // ../../packages/persistence/src/settings.ts
17630
- import { readFileSync as readFileSync3 } from "fs";
17631
- import { join as join5 } from "path";
17851
+ import { readFileSync as readFileSync5 } from "fs";
17852
+ import { join as join6 } from "path";
17853
+
17854
+ // ../../packages/persistence/src/store-symlinks.ts
17855
+ import { existsSync as existsSync4, lstatSync as lstatSync3, readlinkSync, realpathSync, statSync as statSync4 } from "fs";
17856
+ import { dirname as dirname2, join as join7, resolve } from "path";
17632
17857
 
17633
17858
  // ../../packages/persistence/src/vault/crypto.ts
17634
17859
  import {
@@ -17642,23 +17867,15 @@ import {
17642
17867
  // ../../packages/persistence/src/vault/key-provider.ts
17643
17868
  import { execFileSync } from "child_process";
17644
17869
  import { randomBytes as randomBytes2 } from "crypto";
17645
- import {
17646
- chmodSync as chmodSync2,
17647
- mkdirSync as mkdirSync2,
17648
- readFileSync as readFileSync4,
17649
- renameSync as renameSync4,
17650
- rmSync as rmSync4,
17651
- statSync as statSync3,
17652
- writeFileSync as writeFileSync3
17653
- } from "fs";
17654
- import { join as join6 } from "path";
17870
+ import { chmodSync as chmodSync3, readFileSync as readFileSync6, renameSync as renameSync4, rmSync as rmSync5, statSync as statSync5, writeFileSync as writeFileSync3 } from "fs";
17871
+ import { join as join8 } from "path";
17655
17872
 
17656
17873
  // ../../packages/persistence/src/vault/vault.ts
17657
17874
  import { randomBytes as randomBytes3, randomUUID as randomUUID12 } from "crypto";
17658
17875
 
17659
17876
  // ../../packages/persistence/src/warn-era-cap.ts
17660
- import { existsSync as existsSync4, writeFileSync as writeFileSync4 } from "fs";
17661
- import { join as join7 } from "path";
17877
+ import { existsSync as existsSync5, writeFileSync as writeFileSync4 } from "fs";
17878
+ import { join as join9 } from "path";
17662
17879
 
17663
17880
  // ../../packages/plugin-sdk/src/provider-env.ts
17664
17881
  var booleanish = external_exports.string().optional().transform((v) => {
@@ -17679,9 +17896,9 @@ var providerEnvShape = {
17679
17896
  var ProviderEnvSchema = external_exports.object(providerEnvShape);
17680
17897
 
17681
17898
  // ../../packages/plugin-sdk/src/config-inventory.ts
17682
- import { readdirSync as readdirSync2, readFileSync as readFileSync6, realpathSync, statSync as statSync5 } from "fs";
17899
+ import { readdirSync as readdirSync2, readFileSync as readFileSync8, realpathSync as realpathSync2, statSync as statSync7 } from "fs";
17683
17900
  import { homedir as homedir2 } from "os";
17684
- import { basename as basename3, join as join10 } from "path";
17901
+ import { basename as basename3, join as join12 } from "path";
17685
17902
 
17686
17903
  // ../../packages/detections/src/egress/registry.ts
17687
17904
  var EXTRACTOR_VERSION = "1";
@@ -18411,6 +18628,7 @@ var CONFIG_POSTURE_RULES = [
18411
18628
  ];
18412
18629
 
18413
18630
  // ../../packages/detections/src/security/redos-probe.ts
18631
+ var BUDGET_MS = 100;
18414
18632
  var EXPONENTIAL_UNITS = [
18415
18633
  "a",
18416
18634
  "0",
@@ -18434,34 +18652,40 @@ var EXPONENTIAL_PROBES = EXPONENTIAL_UNITS.flatMap(
18434
18652
  var POLYNOMIAL_PROBES = ["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].map(
18435
18653
  (unit) => unit.repeat(1e4).slice(0, 4e4) + "!"
18436
18654
  );
18655
+ var CPU_CORROBORATION_SHARE = 0.2;
18656
+ var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
18437
18657
 
18438
18658
  // ../../packages/plugin-sdk/src/repo.ts
18439
- import { existsSync as existsSync6, readFileSync as readFileSync5, statSync as statSync4 } from "fs";
18440
- import { basename as basename2, dirname as dirname2, isAbsolute, join as join9, sep as sep2 } from "path";
18659
+ import { existsSync as existsSync7, readFileSync as readFileSync7, statSync as statSync6 } from "fs";
18660
+ import { basename as basename2, dirname as dirname3, isAbsolute, join as join11, sep as sep2 } from "path";
18441
18661
 
18442
18662
  // ../../packages/plugin-sdk/src/events.ts
18443
18663
  import { createHash as createHash4, randomUUID as randomUUID13 } from "crypto";
18444
18664
 
18445
18665
  // ../../packages/plugin-sdk/src/isolated-scan.ts
18446
- import { existsSync as existsSync7 } from "fs";
18666
+ import { existsSync as existsSync8 } from "fs";
18447
18667
  import { fileURLToPath } from "url";
18448
18668
  import { Worker } from "worker_threads";
18449
18669
 
18670
+ // ../../packages/plugin-sdk/src/ignore-layers.ts
18671
+ var import_ignore = __toESM(require_ignore(), 1);
18672
+ import { readFileSync as readFileSync9 } from "fs";
18673
+ import { join as join13 } from "path";
18674
+
18450
18675
  // ../../packages/plugin-sdk/src/inventory-resolver.ts
18451
18676
  import { arch, hostname as hostname4, platform, release } from "os";
18452
18677
 
18453
18678
  // ../../packages/plugin-sdk/src/nudge.ts
18454
- import { mkdirSync as mkdirSync3, readFileSync as readFileSync7, writeFileSync as writeFileSync5 } from "fs";
18455
- import { join as join11 } from "path";
18679
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync10, writeFileSync as writeFileSync5 } from "fs";
18680
+ import { join as join14 } from "path";
18456
18681
 
18457
18682
  // ../../packages/plugin-sdk/src/paths.ts
18458
- import { readdirSync as readdirSync3, realpathSync as realpathSync2 } from "fs";
18459
- import { basename as basename4, dirname as dirname3, sep as sep3 } from "path";
18683
+ import { readdirSync as readdirSync3, realpathSync as realpathSync3 } from "fs";
18684
+ import { basename as basename4, dirname as dirname4, sep as sep3 } from "path";
18460
18685
 
18461
18686
  // ../../packages/plugin-sdk/src/project-files.ts
18462
- var import_ignore = __toESM(require_ignore(), 1);
18463
- import { existsSync as existsSync8, readdirSync as readdirSync4, readFileSync as readFileSync8 } from "fs";
18464
- import { basename as basename5, join as join12 } from "path";
18687
+ import { existsSync as existsSync9, readdirSync as readdirSync4 } from "fs";
18688
+ import { basename as basename5, join as join15 } from "path";
18465
18689
 
18466
18690
  // ../../packages/plugin-sdk/src/provider-env-antigravity.ts
18467
18691
  var optionalBaseUrl2 = external_exports.preprocess((v) => {
@@ -18496,8 +18720,8 @@ import { randomUUID as randomUUID14 } from "crypto";
18496
18720
  var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
18497
18721
 
18498
18722
  // ../../packages/plugin-sdk/src/throttle.ts
18499
- import { mkdirSync as mkdirSync4, statSync as statSync6, writeFileSync as writeFileSync6 } from "fs";
18500
- import { join as join13 } from "path";
18723
+ import { mkdirSync as mkdirSync3, statSync as statSync8, writeFileSync as writeFileSync6 } from "fs";
18724
+ import { join as join16 } from "path";
18501
18725
 
18502
18726
  // ../../packages/setup-wizard/src/onboard-posture.ts
18503
18727
  function parsePosture(json2) {
@@ -18507,10 +18731,10 @@ function parsePosture(json2) {
18507
18731
  for (const [key, value] of Object.entries(raw)) {
18508
18732
  const cat = DetectionCategory.safeParse(key);
18509
18733
  if (!cat.success) throw new Error(`unknown category "${key}"`);
18510
- const act = BuiltinPolicyId.safeParse(value);
18734
+ const act = CategoryPolicyId.safeParse(value);
18511
18735
  if (!act.success)
18512
18736
  throw new Error(
18513
- `invalid action "${String(value)}" for ${key} (expected monitor/warn/redact/block)`
18737
+ `invalid action "${String(value)}" for ${key} (expected ${CATEGORY_EXPRESSIBLE_IDS.join("/")})`
18514
18738
  );
18515
18739
  out[cat.data] = act.data;
18516
18740
  }
@@ -18536,7 +18760,7 @@ function parseCurrent(json2) {
18536
18760
 
18537
18761
  // ../../packages/setup-wizard/src/remediation/rotation-checklist.ts
18538
18762
  import { writeFileSync as writeFileSync7 } from "fs";
18539
- import { join as join14 } from "path";
18763
+ import { join as join17 } from "path";
18540
18764
 
18541
18765
  // ../../packages/setup-wizard/src/triage/gate-display.ts
18542
18766
  var ACTION_RANK = {
@@ -18557,10 +18781,15 @@ function downgradeWarning(downgrades) {
18557
18781
  Heads up \u2014 this would lower ${String(downgrades.length)} detection level${downgrades.length === 1 ? "" : "s"} (${downgrades.join(", ")}) below what you've already set. Confirm you mean to lower ${downgrades.length === 1 ? "it" : "them"} before I apply.`;
18558
18782
  }
18559
18783
 
18784
+ // ../../packages/setup-wizard/src/triage/merge.ts
18785
+ var RANK = Object.fromEntries(
18786
+ KNOWN_BUILTIN_IDS.map((id, i) => [id, i])
18787
+ );
18788
+
18560
18789
  // ../../packages/setup-wizard/src/triage/plan-file.ts
18561
- import { mkdtempSync, readFileSync as readFileSync9, rmdirSync, rmSync as rmSync5, writeFileSync as writeFileSync8 } from "fs";
18790
+ import { mkdtempSync, readFileSync as readFileSync11, rmdirSync, rmSync as rmSync6, writeFileSync as writeFileSync8 } from "fs";
18562
18791
  import { tmpdir } from "os";
18563
- import { basename as basename6, dirname as dirname4, join as join15 } from "path";
18792
+ import { basename as basename6, dirname as dirname5, join as join18 } from "path";
18564
18793
  var SuppressionEntrySchema = external_exports.object({
18565
18794
  ruleId: external_exports.string(),
18566
18795
  category: DetectionCategory,
@@ -18708,9 +18937,9 @@ function renderPostureGrid(posture) {
18708
18937
  );
18709
18938
  const rows = packs.map((category) => [
18710
18939
  category,
18711
- ...BUILTIN_ORDER.map((level) => posture[category] === level ? GRID_MARK : "")
18940
+ ...CATEGORY_EXPRESSIBLE_IDS.map((level) => posture[category] === level ? GRID_MARK : "")
18712
18941
  ]);
18713
- return indent(table(["Category", ...BUILTIN_ORDER], rows));
18942
+ return indent(table(["Category", ...CATEGORY_EXPRESSIBLE_IDS], rows));
18714
18943
  }
18715
18944
  var RE_TUNE_HINT = "Re-tune anytime with /aka:setup or the dashboard";
18716
18945
  var PACK_RATIONALE = {