@akasecurity/ai-tc-codex 0.9.10 → 0.9.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/scripts/intro.js CHANGED
@@ -50,7 +50,7 @@ var require_ignore = __commonJS({
50
50
  var REGEX_SPLITALL_CRLF = /\r?\n/g;
51
51
  var REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/;
52
52
  var REGEX_TEST_TRAILING_SLASH = /\/$/;
53
- var SLASH = "/";
53
+ var SLASH2 = "/";
54
54
  var TMP_KEY_IGNORE = "node-ignore";
55
55
  if (typeof Symbol !== "undefined") {
56
56
  TMP_KEY_IGNORE = /* @__PURE__ */ Symbol.for("node-ignore");
@@ -422,11 +422,11 @@ var require_ignore = __commonJS({
422
422
  if (!REGEX_TEST_TRAILING_SLASH.test(path)) {
423
423
  return this.test(path);
424
424
  }
425
- const slices = path.split(SLASH).filter(Boolean);
425
+ const slices = path.split(SLASH2).filter(Boolean);
426
426
  slices.pop();
427
427
  if (slices.length) {
428
428
  const parent = this._t(
429
- slices.join(SLASH) + SLASH,
429
+ slices.join(SLASH2) + SLASH2,
430
430
  this._testCache,
431
431
  true,
432
432
  slices
@@ -442,14 +442,14 @@ var require_ignore = __commonJS({
442
442
  return cache[path];
443
443
  }
444
444
  if (!slices) {
445
- slices = path.split(SLASH).filter(Boolean);
445
+ slices = path.split(SLASH2).filter(Boolean);
446
446
  }
447
447
  slices.pop();
448
448
  if (!slices.length) {
449
449
  return cache[path] = this._rules.test(path, checkUnignored, MODE_IGNORE);
450
450
  }
451
451
  const parent = this._t(
452
- slices.join(SLASH) + SLASH,
452
+ slices.join(SLASH2) + SLASH2,
453
453
  cache,
454
454
  checkUnignored,
455
455
  slices
@@ -492,7 +492,7 @@ var require_ignore = __commonJS({
492
492
  });
493
493
 
494
494
  // src/intro.ts
495
- import { readFileSync as readFileSync15 } from "fs";
495
+ import { readFileSync as readFileSync18 } from "fs";
496
496
 
497
497
  // src/present.ts
498
498
  var SHADE = {
@@ -548,8 +548,8 @@ function fenced(body) {
548
548
  }
549
549
 
550
550
  // ../../packages/plugin-sdk/src/config.ts
551
- import { existsSync as existsSync7 } from "fs";
552
- import { join as join13 } from "path";
551
+ import { existsSync as existsSync8 } from "fs";
552
+ import { join as join16 } from "path";
553
553
 
554
554
  // ../../packages/persistence/src/attached-derived.ts
555
555
  import { rmSync } from "fs";
@@ -559,6 +559,14 @@ import { join } from "path";
559
559
  import { chmodSync as chmodSync2, lstatSync as lstatSync2, readFileSync, rmSync as rmSync3, statSync } from "fs";
560
560
  import { join as join2 } from "path";
561
561
 
562
+ // ../../packages/schema/src/drizzle/deferred-migrations.ts
563
+ var DEFERRED_MIGRATION_TAGS = [
564
+ "0031_audit_capture_by_time_index",
565
+ "0032_audit_capture_by_id_index",
566
+ "0033_audit_capture_location_index",
567
+ "0034_findings_read_indexes"
568
+ ];
569
+
562
570
  // ../../packages/schema/src/exception-scope.ts
563
571
  var MINUTE_MS = 6e4;
564
572
  var HOUR_MS = 60 * MINUTE_MS;
@@ -20368,6 +20376,15 @@ var FindingCategory = external_exports.enum([
20368
20376
  ]).meta({ id: "FindingCategory" });
20369
20377
  var FindingOrigin = external_exports.enum(["in-flight", "at-rest"]).meta({ id: "FindingOrigin" });
20370
20378
  var FindingStatus = external_exports.enum(["open", "handled", "resolved", "dismissed"]).meta({ id: "FindingStatus" });
20379
+ var SyncFailureReason = external_exports.enum(["deployment_refused", "payload_invalid", "detached_undelivered"]).meta({ id: "SyncFailureReason" });
20380
+ var FindingDeliveryState = external_exports.enum(["sent", "queued", "not_sent", "never_offered", "local_scan"]).meta({ id: "FindingDeliveryState" });
20381
+ var FindingDelivery = external_exports.object({
20382
+ state: FindingDeliveryState,
20383
+ // The delivery time for `sent`; the failure time for `not_sent` when recorded.
20384
+ at: external_exports.iso.datetime().optional(),
20385
+ // Only on `not_sent`, and only when a known reason was recorded.
20386
+ reason: SyncFailureReason.optional()
20387
+ }).meta({ id: "FindingDelivery" });
20371
20388
  var ResolutionMethod = external_exports.enum([
20372
20389
  "enforced-in-flight",
20373
20390
  "fixed-at-source",
@@ -20424,7 +20441,10 @@ var FindingInstance = external_exports.object({
20424
20441
  // The session that event belongs to, when it has one — the seam a
20425
20442
  // per-instance "view session" link needs. Absent for events captured
20426
20443
  // outside a session.
20427
- sessionId: external_exports.string().optional()
20444
+ sessionId: external_exports.string().optional(),
20445
+ // The delivery state of the event above (see FindingDelivery). Optional so
20446
+ // readers that do not project it stay valid.
20447
+ delivery: FindingDelivery.optional()
20428
20448
  }).meta({ id: "FindingInstance" });
20429
20449
  var FindingGroup = external_exports.object({
20430
20450
  id: external_exports.string(),
@@ -20441,13 +20461,11 @@ var FindingGroup = external_exports.object({
20441
20461
  latestDetectedAt: external_exports.iso.datetime(),
20442
20462
  instances: external_exports.array(FindingInstance),
20443
20463
  // Derived from instances' statuses with open-dominates precedence (see
20444
- // buildFindingGroups). Undefined only when no instance carries a status.
20464
+ // foldGroupStatus). Undefined only when no instance carries a status.
20445
20465
  status: FindingStatus.optional(),
20446
- // The distinct people across the WHOLE group, not just the `instances`
20447
- // preview — from the store's whole-group aggregate when it supplies one,
20448
- // else folded from the rows (see buildFindingGroups). Undefined when no
20449
- // instance carries a user, or when the store supplied whole-group folds
20450
- // without one.
20466
+ // The distinct people across the WHOLE group, not just the instances
20467
+ // carried here. Undefined when no instance carries a user, or when the
20468
+ // store supplied whole-group folds without one.
20451
20469
  users: external_exports.array(FindingUser).optional()
20452
20470
  }).meta({ id: "FindingGroup" });
20453
20471
  var FindingStats = external_exports.object({
@@ -20476,20 +20494,33 @@ var FindingFacets = external_exports.object({
20476
20494
  // counted under no value.
20477
20495
  status: external_exports.array(FindingFacetItem),
20478
20496
  // Host tool (attributes.tool_name). Present only on the instance-level
20479
- // reads, which can filter by it; the grouped read omits the dimension
20497
+ // reads, which can filter by it; the type-level read omits the dimension
20480
20498
  // because a group spans tools.
20481
- tool: external_exports.array(FindingFacetItem).optional()
20499
+ tool: external_exports.array(FindingFacetItem).optional(),
20500
+ // Delivery states (FindingDeliveryState). Present only on the
20501
+ // instance-level reads, like `tool`.
20502
+ deployment: external_exports.array(FindingFacetItem).optional()
20482
20503
  }).meta({ id: "FindingFacets" });
20483
- var ListGroupedFindingsQuery = external_exports.object({
20504
+ var FindingTypeSummary = FindingGroup.omit({ instances: true, match: true }).meta({
20505
+ id: "FindingTypeSummary"
20506
+ });
20507
+ var MAX_FINDING_TYPES_LIMIT = 100;
20508
+ var ListFindingTypesQuery = external_exports.object({
20484
20509
  // NOTE: severity filters by Severity (critical/high/medium/low), not by
20485
- // FindingAction.
20510
+ // FindingAction. It narrows TYPES: a type's severity is the one its newest
20511
+ // firing version carries, and this list pages types.
20512
+ //
20513
+ // That is NOT a claim the findings of a type share it. A rule can hold several
20514
+ // definition versions at different severities, so a type kept by this filter
20515
+ // can hold findings that individually do not match — see totals.findings on
20516
+ // ListFindingTypesResponse, which counts them all.
20486
20517
  severity: external_exports.array(Severity).optional(),
20487
20518
  subtype: external_exports.array(external_exports.string()).optional(),
20488
20519
  provider: external_exports.array(FindingProvider).optional(),
20489
20520
  action: external_exports.array(FindingAction).optional(),
20490
- // Matches a group's DERIVED status (see FindingGroup.status), not its
20491
- // individual instances' — so a filtered group's Status column always reads
20492
- // one of the requested values.
20521
+ // Matches a type's DERIVED status (see FindingGroup.status), not its
20522
+ // individual findings' — so a filtered row's status always reads one of the
20523
+ // requested values.
20493
20524
  status: external_exports.array(FindingStatus).optional(),
20494
20525
  q: external_exports.string().optional(),
20495
20526
  // Scope to findings whose event carries this session id (the Activity page's
@@ -20499,23 +20530,37 @@ var ListGroupedFindingsQuery = external_exports.object({
20499
20530
  // from a time-scoped page (Activity's range) can carry that scope. Absent
20500
20531
  // means all time — this list has no default window.
20501
20532
  from: external_exports.iso.datetime().optional(),
20502
- // A group or instance id that must appear in the page even when the cursor
20503
- // has already advanced past its sort position. This is what keeps the
20504
- // Findings page's one-shot ?finding= deep link resolving once the list
20505
- // paginates: the target group is appended out of sort order rather than
20506
- // scanning forward for it. Never affects totals, facets or the cursor.
20533
+ // A RULE id that must appear in the page even when the cursor has already
20534
+ // advanced past its sort position. This is what keeps the selected type
20535
+ // visible in the list once it paginates: the target is appended out of sort
20536
+ // order rather than scanned forward for. Never affects totals, facets or the
20537
+ // cursor. Unlike the grouped read this replaces, it names a rule only — an
20538
+ // instance id is resolved by `findingInstance`, which is a primary-key seek
20539
+ // and so is not bounded by what any page happens to hold.
20507
20540
  includeId: external_exports.string().optional(),
20508
- groupBy: external_exports.literal("type").optional(),
20509
- limit: external_exports.coerce.number().int().min(1).max(100).optional(),
20541
+ limit: external_exports.coerce.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
20510
20542
  cursor: external_exports.string().optional()
20511
20543
  });
20512
- var ListGroupedFindingsResponse = external_exports.object({
20544
+ var ListFindingTypesResponse = external_exports.object({
20513
20545
  totals: external_exports.object({
20546
+ // Findings belonging to the matching TYPES — not findings that each match
20547
+ // the filters. The filters here select types, so a type that survives
20548
+ // contributes its whole instanceCount.
20549
+ //
20550
+ // `status` is the one exception, narrowed per finding via
20551
+ // countInstancesByStatus. `severity`, `provider` and `action` are not, so
20552
+ // this can exceed what the instance read reports for the same filters: a
20553
+ // rule whose severity moved between versions is kept on its newest and
20554
+ // still counts its older findings. Narrowing the other three needs
20555
+ // per-dimension counts the aggregate does not carry today.
20514
20556
  findings: external_exports.number().int().nonnegative(),
20515
- groups: external_exports.number().int().nonnegative()
20557
+ // Counts TYPES, which is the unit this read pages. The instance read's
20558
+ // own totals count findings; the two deliberately answer different
20559
+ // questions and are never summed.
20560
+ types: external_exports.number().int().nonnegative()
20516
20561
  }),
20517
20562
  facets: FindingFacets,
20518
- items: external_exports.array(FindingGroup),
20563
+ items: external_exports.array(FindingTypeSummary),
20519
20564
  nextCursor: external_exports.string().nullable(),
20520
20565
  // Present only on session-scoped queries (`sessionId` set): per ruleId, how
20521
20566
  // many times that rule fired in the session's persisted transcript. Findings
@@ -20523,7 +20568,7 @@ var ListGroupedFindingsResponse = external_exports.object({
20523
20568
  // every firing, so the two numbers legitimately differ — this map lets a
20524
20569
  // session-scoped view show both.
20525
20570
  sessionFirings: external_exports.record(external_exports.string(), external_exports.number().int().nonnegative()).optional()
20526
- }).meta({ id: "ListGroupedFindingsResponse" });
20571
+ }).meta({ id: "ListFindingTypesResponse" });
20527
20572
  var ApplyFindingActionRequest = external_exports.object({
20528
20573
  // 'quarantined' is system-assigned (see FindingAction) — clients may not set
20529
20574
  // it, so it is excluded from the request contract. The mapping helper
@@ -20552,16 +20597,19 @@ var FindingInstanceDetail = FindingInstance.extend({
20552
20597
  var MAX_FLAT_FINDINGS_LIMIT = 200;
20553
20598
  var ListFindingInstancesQuery = external_exports.object({
20554
20599
  severity: external_exports.array(Severity).optional(),
20555
- // Rule ids, the same vocabulary the grouped list's `subtype` carries.
20600
+ // Rule ids, the same vocabulary the types list's `subtype` carries. Pinning
20601
+ // ONE of them is how the master/detail view scopes its right-hand panel.
20556
20602
  subtype: external_exports.array(external_exports.string()).optional(),
20557
20603
  provider: external_exports.array(FindingProvider).optional(),
20558
20604
  action: external_exports.array(FindingAction).optional(),
20559
20605
  // Matches each instance's OWN derived status (deriveFindingStatus), unlike
20560
- // the grouped query's group-level fold.
20606
+ // the types query's type-level fold.
20561
20607
  status: external_exports.array(FindingStatus).optional(),
20562
20608
  // Exact host-tool names (attributes.tool_name, e.g. 'Bash'). A real filter,
20563
20609
  // where the free-text `q` can only match the rendered "via Bash" label.
20564
20610
  tool: external_exports.array(external_exports.string()).optional(),
20611
+ // The delivery state of each finding's event (see FindingDelivery).
20612
+ deployment: external_exports.array(FindingDeliveryState).optional(),
20565
20613
  // Exact repository / file-path matches, for the drill-down out of the
20566
20614
  // locations view. A row whose event carries no repo/file matches neither.
20567
20615
  repo: external_exports.string().optional(),
@@ -20574,37 +20622,50 @@ var ListFindingInstancesQuery = external_exports.object({
20574
20622
  });
20575
20623
  var ListFindingInstancesResponse = external_exports.object({
20576
20624
  // Instances matching the filters across the whole scope, not just this
20577
- // page — cursor-independent, like the grouped list's totals.
20625
+ // page — cursor-independent, like the types list's totals.
20578
20626
  totals: external_exports.object({ findings: external_exports.number().int().nonnegative() }),
20579
- // Counts in INSTANCES here, where the grouped response counts groups. Each
20627
+ // Counts in INSTANCES here, where the types response counts types. Each
20580
20628
  // dimension still excludes its own filter.
20581
20629
  facets: FindingFacets,
20582
20630
  items: external_exports.array(FindingInstanceDetail),
20583
20631
  nextCursor: external_exports.string().nullable()
20584
20632
  }).meta({ id: "ListFindingInstancesResponse" });
20585
- var FindingLocationFile = external_exports.object({
20586
- // Empty when the instances carried no file path (a prompt or a tool call
20587
- // with no file attribution).
20588
- file: external_exports.string(),
20589
- instanceCount: external_exports.number().int().nonnegative(),
20590
- maxSeverity: Severity,
20591
- latestDetectedAt: external_exports.iso.datetime(),
20592
- // Folded from the instances' derived statuses with the same
20593
- // open-dominates precedence a group uses.
20594
- status: FindingStatus.optional(),
20595
- // Distinct rules seen at this location, capped — the row shows them as
20596
- // chips, and the count is what conveys scale.
20597
- ruleIds: external_exports.array(external_exports.string())
20598
- }).meta({ id: "FindingLocationFile" });
20599
- var FindingLocationRepo = external_exports.object({
20633
+ var ListFindingInstancesPage = external_exports.object({
20634
+ items: external_exports.array(FindingInstanceDetail),
20635
+ nextCursor: external_exports.string().nullable()
20636
+ }).meta({ id: "ListFindingInstancesPage" });
20637
+ var FindingLocationSummary = external_exports.object({
20638
+ // Opaque, stable, minted from the pair by encodeLocationId. It exists
20639
+ // because a location's identity is two values and a URL param carries one:
20640
+ // `?loc=` names a location the way `?rule=` names a type. Only ever compared
20641
+ // for EQUALITY — the page's selection check, this read's `includeId`, the
20642
+ // client's page dedupe — never decoded, and never a sort key.
20643
+ id: external_exports.string(),
20600
20644
  /** Empty when the instances carried no repo attribute. */
20601
20645
  repo: external_exports.string(),
20646
+ // Empty when the instances carried no file path (a prompt, or a tool call
20647
+ // with no file attribution). Both halves empty is a real location — usually
20648
+ // the largest one in a store — and is selectable like any other.
20649
+ file: external_exports.string(),
20602
20650
  instanceCount: external_exports.number().int().nonnegative(),
20651
+ // The WORST severity present, not the first row's. It is this list's primary
20652
+ // sort key, so it is also what explains why a row is where it is, and it is
20653
+ // how a reader decides what to open without opening everything.
20603
20654
  maxSeverity: Severity,
20604
20655
  latestDetectedAt: external_exports.iso.datetime(),
20656
+ // Folded from the instances' derived statuses with the same open-dominates
20657
+ // precedence a group uses, so it answers "is anything left to do here" and
20658
+ // not much more: a location holding 1 open among 40 resolved reads like one
20659
+ // holding 40 open. That loss is accepted — the panel beside this list
20660
+ // carries each finding's own status, and instanceCount sits next to the
20661
+ // badge.
20605
20662
  status: FindingStatus.optional(),
20606
- files: external_exports.array(FindingLocationFile)
20607
- }).meta({ id: "FindingLocationRepo" });
20663
+ // Every distinct rule seen at this location, UNCAPPED — so the length is a
20664
+ // tally rather than a sample and a row can say how many there are. Bounded
20665
+ // by the ruleset, not by the store. The view bounds what it DISPLAYS.
20666
+ ruleIds: external_exports.array(external_exports.string())
20667
+ }).meta({ id: "FindingLocationSummary" });
20668
+ var MAX_FINDING_LOCATIONS_LIMIT = 100;
20608
20669
  var ListFindingLocationsQuery = external_exports.object({
20609
20670
  severity: external_exports.array(Severity).optional(),
20610
20671
  subtype: external_exports.array(external_exports.string()).optional(),
@@ -20614,21 +20675,47 @@ var ListFindingLocationsQuery = external_exports.object({
20614
20675
  // instances that match, and folds its status from those.
20615
20676
  status: external_exports.array(FindingStatus).optional(),
20616
20677
  tool: external_exports.array(external_exports.string()).optional(),
20678
+ // The delivery state of each finding's event (see FindingDelivery).
20679
+ deployment: external_exports.array(FindingDeliveryState).optional(),
20617
20680
  q: external_exports.string().optional(),
20618
20681
  sessionId: external_exports.string().optional(),
20619
20682
  from: external_exports.iso.datetime().optional(),
20620
- limit: external_exports.coerce.number().int().min(1).max(500).optional()
20683
+ // A LOCATION id (see FindingLocationSummary.id) that must appear in the page
20684
+ // even when the cursor has already advanced past its sort position — the
20685
+ // counterpart of ListFindingTypesQuery.includeId, and needed far more often
20686
+ // here. Selecting a row pushes the URL, which re-renders the server and resets
20687
+ // the client's page cache to page 0; with distinct (repo, file) pairs running
20688
+ // into the thousands, a selection sitting off page 0 is the ordinary case
20689
+ // rather than a deep-link corner. Never affects totals, facets or the cursor.
20690
+ includeId: external_exports.string().optional(),
20691
+ limit: external_exports.coerce.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
20692
+ cursor: external_exports.string().optional()
20621
20693
  });
20622
20694
  var ListFindingLocationsResponse = external_exports.object({
20623
20695
  totals: external_exports.object({
20696
+ // Findings matching the filters across the whole scope. Unlike the types
20697
+ // read's same-named field this needs no caveat: the filters here narrow
20698
+ // per finding, so this is the sum of every row's instanceCount.
20624
20699
  findings: external_exports.number().int().nonnegative(),
20625
- repos: external_exports.number().int().nonnegative(),
20626
- files: external_exports.number().int().nonnegative()
20700
+ // Counts LOCATIONS, the unit this read pages — the number the paginator
20701
+ // states. The facets beside it count FINDINGS (see below); a surface
20702
+ // showing both says which is which.
20703
+ locations: external_exports.number().int().nonnegative()
20627
20704
  }),
20628
- /** Sorted by max severity, then most recent. */
20629
- items: external_exports.array(FindingLocationRepo),
20630
- /** Whether `limit` truncated the repo list. */
20631
- hasMore: external_exports.boolean()
20705
+ // Counts in FINDINGS, where the types response counts types, each dimension
20706
+ // still excluding its own filter. Deliberately not locations: counting those
20707
+ // needs a set of location keys per dimension per value — memory tracking the
20708
+ // store times the vocabulary, in a read whose scan promises flat memory —
20709
+ // and the cheap per-location version is not an approximation but WRONG. A
20710
+ // location holding {claudecode, block} and {codex, warn} would survive
20711
+ // provider=claudecode AND action=warn, under which no single finding
20712
+ // matches, so the facet would contradict the instanceCount this whole view
20713
+ // rests on. Findings also keep the toolbar in the same unit as the page
20714
+ // tally and the panel it sits above.
20715
+ facets: FindingFacets,
20716
+ /** Sorted by max severity, then most recent, then (repo, file). */
20717
+ items: external_exports.array(FindingLocationSummary),
20718
+ nextCursor: external_exports.string().nullable()
20632
20719
  }).meta({ id: "ListFindingLocationsResponse" });
20633
20720
 
20634
20721
  // ../../packages/schema/src/zod/meta.ts
@@ -20792,6 +20879,10 @@ var CaptureAttributes = external_exports.object({
20792
20879
  // to 'allow' — the enforcement audit trail's link back to the grant that
20793
20880
  // authorized the bypass.
20794
20881
  exception_ids: external_exports.array(external_exports.guid()).optional(),
20882
+ // The persisted spellings of EventMetadata's messageId/conversationId — the
20883
+ // join back to the `llm_call` leaf for the same assistant turn.
20884
+ message_id: external_exports.string().optional(),
20885
+ conversation_id: external_exports.string().optional(),
20795
20886
  // Whole milliseconds this capture's inspection blocked its caller — the
20796
20887
  // plugin's own added latency (see EventMetadata.inspectionMs, whose value
20797
20888
  // this is). Promoted to the `inspection_ms` generated column so the facet is
@@ -20800,7 +20891,19 @@ var CaptureAttributes = external_exports.object({
20800
20891
  // inline json_extract and is not itself an optimization.
20801
20892
  // ABSENT on replayed captures (backfill / worktree scan) and on rows written
20802
20893
  // before the measurement shipped — never present as a placeholder 0.
20803
- inspection_ms: external_exports.number().int().nonnegative().optional()
20894
+ inspection_ms: external_exports.number().int().nonnegative().optional(),
20895
+ // What a `redact` this capture could not carry out became instead (see
20896
+ // EventMetadata.redactDegradedTo, whose value this is). Present only when a
20897
+ // degrade actually happened, so absence is the ordinary case rather than a
20898
+ // reader having to distinguish it from a zero.
20899
+ //
20900
+ // PER CAPTURE, while `inspection_findings.action_taken` is per finding —
20901
+ // so on a multi-finding row this does not say which finding degraded, and
20902
+ // its presence does not mean the fallback decided the capture's action. A
20903
+ // capture denied by another finding's own Block policy carries `block`
20904
+ // here too. The full statement is on EventMetadata.redactDegradedTo; it is
20905
+ // repeated rather than referenced because a store reader opens this file.
20906
+ redact_degraded_to: ActionTaken.optional()
20804
20907
  }).catchall(external_exports.unknown());
20805
20908
  var ToolCallInspection = external_exports.object({
20806
20909
  ruleId: external_exports.string().min(1),
@@ -20996,7 +21099,17 @@ var AuditEvent = external_exports.object({
20996
21099
  /** `share` to a first-party/internal destination. */
20997
21100
  internal: external_exports.boolean(),
20998
21101
  /** Event needs review (e.g. unverified egress). */
20999
- flagged: external_exports.boolean()
21102
+ flagged: external_exports.boolean(),
21103
+ /**
21104
+ * The body this event's `title` is drawn from was cleared by local body
21105
+ * expiry, so an EMPTY title here means "gone", not "never had one".
21106
+ *
21107
+ * A separate flag rather than a sentinel written into `title`: the title is
21108
+ * rendered text, and a store-layer module that invented display copy for it
21109
+ * would be choosing words the view is supposed to choose. Additive and
21110
+ * defaulted, so an older producer still validates.
21111
+ */
21112
+ bodyExpired: external_exports.boolean().default(false)
21000
21113
  }).meta({ id: "ActivityAuditEvent" });
21001
21114
  var ActivitySessionSummary = external_exports.object({
21002
21115
  id: external_exports.string(),
@@ -21793,6 +21906,14 @@ var ControlPlaneErrorBody = external_exports.object({
21793
21906
  message: external_exports.string().optional()
21794
21907
  }).optional()
21795
21908
  });
21909
+ var RemoteFailureKind = external_exports.enum([
21910
+ "unauthorized",
21911
+ "forbidden",
21912
+ "route-absent",
21913
+ "invalid-request",
21914
+ "rejected",
21915
+ "unreachable"
21916
+ ]);
21796
21917
  var AttachDeviceRequest = external_exports.object({
21797
21918
  // This machine's own continuity id, so re-attaching ROTATES the credential
21798
21919
  // on one machine record instead of producing a second one. Client-minted
@@ -22211,6 +22332,12 @@ var EventMetadata = external_exports.object({
22211
22332
  // to 'allow' — the enforcement audit trail's link back to the grant that
22212
22333
  // authorized the bypass. Absent on captures where no exception applied.
22213
22334
  exceptionIds: external_exports.array(external_exports.guid()).optional(),
22335
+ // The assistant message this capture belongs to, and the conversation it sits
22336
+ // in — set by the browser extension's network capture so a stored `response`
22337
+ // row can be joined to the `llm_call` leaf describing the same turn. Absent
22338
+ // on every other capture path, which has no such id.
22339
+ messageId: external_exports.string().optional(),
22340
+ conversationId: external_exports.string().optional(),
22214
22341
  // How long THIS capture's inspection blocked its caller, in whole
22215
22342
  // milliseconds — the plugin's own added latency, NOT the LLM call it sat in
22216
22343
  // front of. Measured inside `capture()` (@akasecurity/plugin-sdk) across
@@ -22223,7 +22350,37 @@ var EventMetadata = external_exports.object({
22223
22350
  // Absent is also what every pre-measurement client writes, and what a
22224
22351
  // clock failure degrades to — a reader must treat absence as "not measured"
22225
22352
  // and never as a zero, which would read as "inspection is free".
22226
- inspectionMs: external_exports.number().int().nonnegative().optional()
22353
+ inspectionMs: external_exports.number().int().nonnegative().optional(),
22354
+ // What a `redact` this capture COULD NOT CARRY OUT became instead — the
22355
+ // workspace's `redactFallback`, applied because the field could not be
22356
+ // masked in place (a shell command, a URL, or any argument on a host whose
22357
+ // hook contract offers no rewrite channel).
22358
+ //
22359
+ // It exists because the action alone cannot say why. A finding recorded as
22360
+ // `warn` reads identically whether its detection was ASSIGNED Warn or was
22361
+ // assigned Redact on a field that could not take one — and those are
22362
+ // different facts about the same row: the first is a policy the user chose,
22363
+ // the second is a masking the host could not perform. Absent means no
22364
+ // degrade happened, which is every ordinary capture.
22365
+ //
22366
+ // TWO LIMITS a reader of a stored row has to know, because the grain here
22367
+ // is the CAPTURE while `actionTaken` is per FINDING:
22368
+ //
22369
+ // - It does not say WHICH finding degraded. A capture carrying a degraded
22370
+ // `redact` alongside a finding ASSIGNED the same action stores both
22371
+ // identically and one reason for the pair; attributing it to both
22372
+ // describes the assigned one wrongly, and to neither loses the degrade.
22373
+ // - PRESENCE IS NOT CAUSATION. The value is the action the lost redact
22374
+ // became, not the reason the capture ended as it did — a capture denied
22375
+ // by some other finding's own Block policy still carries `block` here,
22376
+ // and clearing the workspace's fallback would not have let it through.
22377
+ // Gate on the value against what a fallback can produce; never read the
22378
+ // field's presence as "this was the fallback's doing".
22379
+ //
22380
+ // Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
22381
+ // Closing either means moving the reason onto the finding row, which
22382
+ // already carries its own action.
22383
+ redactDegradedTo: ActionTaken.optional()
22227
22384
  }).meta({ id: "EventMetadata" });
22228
22385
  var Event = external_exports.object({
22229
22386
  id: external_exports.guid(),
@@ -22333,6 +22490,15 @@ var RotateKeyInput = external_exports.object({
22333
22490
  confirmation: external_exports.string()
22334
22491
  });
22335
22492
 
22493
+ // ../../packages/schema/src/zod/finding-delivery.ts
22494
+ var KNOWN_REASONS = SyncFailureReason.options;
22495
+
22496
+ // ../../packages/schema/src/zod/findings-group-build.ts
22497
+ function rankByOrder(members2) {
22498
+ return Object.fromEntries(members2.map((member, index) => [member, index]));
22499
+ }
22500
+ var SEVERITY_RANK = rankByOrder(Severity.options);
22501
+
22336
22502
  // ../../packages/schema/src/zod/installed-pack.ts
22337
22503
  var InstalledPack = external_exports.object({
22338
22504
  id: external_exports.guid(),
@@ -22399,6 +22565,11 @@ var Policy = external_exports.object({
22399
22565
  // test `prohibitedModels` passes and `reversibleRuleIds` fails.
22400
22566
  provenance: PolicyProvenance.optional()
22401
22567
  }).meta({ id: "Policy" });
22568
+ var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
22569
+ var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
22570
+ var RedactFallback = BuiltinPolicyId.extract(["monitor", "warn", "block"]).meta({
22571
+ id: "RedactFallback"
22572
+ });
22402
22573
  var PolicyBundle = external_exports.object({
22403
22574
  version: external_exports.string(),
22404
22575
  policies: external_exports.array(Policy),
@@ -22446,6 +22617,16 @@ var PolicyBundle = external_exports.object({
22446
22617
  // control plane), so no name resolution stands between the decision and the
22447
22618
  // comparison.
22448
22619
  prohibitedModels: external_exports.array(external_exports.string()).optional(),
22620
+ // What a resolved `redact` becomes on a field the host cannot rewrite, as
22621
+ // the ORGANIZATION would have it. Merged raise-only against the device's own
22622
+ // `WorkspaceSettings.redactFallback` (see strongerRedactFallback below), so
22623
+ // a control plane can tighten a machine and never loosen one — the same
22624
+ // direction `mergeRaiseOnly` enforces for policies.
22625
+ //
22626
+ // Optional so an older backend, and an older on-disk cache, still parses;
22627
+ // absent leaves the device's own setting in force, which is the behaviour
22628
+ // that predates the field and the safe direction to default.
22629
+ redactFallback: RedactFallback.optional(),
22449
22630
  customKeywords: external_exports.array(external_exports.string()),
22450
22631
  fetchedAt: external_exports.iso.datetime()
22451
22632
  }).meta({ id: "PolicyBundle" });
@@ -22475,11 +22656,6 @@ function severityFloorPolicy(category) {
22475
22656
  const peak = CATEGORY_PEAK_SEVERITY[category];
22476
22657
  return peak === "critical" || peak === "high" ? "warn" : "monitor";
22477
22658
  }
22478
- var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
22479
- var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
22480
- var RedactFallback = BuiltinPolicyId.extract(["monitor", "warn", "block"]).meta({
22481
- id: "RedactFallback"
22482
- });
22483
22659
  var BUILTIN_POLICY_SPECS = {
22484
22660
  monitor: {
22485
22661
  name: "Monitor",
@@ -22741,7 +22917,7 @@ var VaultConsent = external_exports.object({
22741
22917
  });
22742
22918
 
22743
22919
  // ../../packages/schema/src/zod/local.ts
22744
- var WORKSPACE_SETTINGS_SPEC_VERSION = 7;
22920
+ var WORKSPACE_SETTINGS_SPEC_VERSION = 8;
22745
22921
  var RunMode = external_exports.enum(["standalone", "attached"]);
22746
22922
  var ControlPlaneConnection = external_exports.object({
22747
22923
  endpoint: external_exports.string().min(1),
@@ -22760,6 +22936,15 @@ var HistorySyncConsent = external_exports.object({
22760
22936
  payloadVersion: external_exports.number().int().positive(),
22761
22937
  endpoint: external_exports.string()
22762
22938
  });
22939
+ var BODY_RETENTION_DEFAULT_DAYS = 30;
22940
+ var BodyRetention = external_exports.object({
22941
+ enabled: external_exports.boolean().default(false),
22942
+ // Never 0, and the ceiling is a fat-finger guard rather than a policy
22943
+ // limit — `enabled` is the real gate. A low value cannot reach a row the
22944
+ // sync ledger still owes: the sweep's age filter only ever NARROWS a
22945
+ // candidate set that is already bounded by "delivered, or never owed".
22946
+ retainDays: external_exports.number().int().min(1).max(3650).default(BODY_RETENTION_DEFAULT_DAYS)
22947
+ }).meta({ id: "BodyRetention" });
22763
22948
  var WorkspaceSettings = external_exports.object({
22764
22949
  specVersion: external_exports.number().int().positive().default(WORKSPACE_SETTINGS_SPEC_VERSION),
22765
22950
  runMode: RunMode.default("standalone"),
@@ -22803,12 +22988,18 @@ var WorkspaceSettings = external_exports.object({
22803
22988
  // covers the current payload and must be re-granted.
22804
22989
  modelJudgeConsent: ModelJudgeConsent.optional(),
22805
22990
  // Records that the user consented to the DEFERRED send — the outbox — along
22806
- // with the payload shape and the endpoint they agreed to. Since payload v2
22807
- // that covers both the pre-attach backlog and undelivered captures (which
22808
- // carry prompt/reply text in `content`); the key name predates the widening.
22809
- // Absent until granted, and a grant for a different endpoint or an older
22810
- // payload no longer counts.
22811
- historySyncConsent: HistorySyncConsent.optional()
22991
+ // with the payload shape and the endpoint they agreed to. Since payload v3
22992
+ // that covers the pre-attach backlog AND undelivered captures alike, and both
22993
+ // carry prompt/reply/tool-output text in `content`; the key name predates
22994
+ // both widenings. Absent until granted, and a grant for a different endpoint
22995
+ // or an older payload no longer counts.
22996
+ historySyncConsent: HistorySyncConsent.optional(),
22997
+ // Local body expiry (see BodyRetention). Off until switched on; expiring a
22998
+ // body never removes the row or its findings.
22999
+ bodyRetention: BodyRetention.default({
23000
+ enabled: false,
23001
+ retainDays: BODY_RETENTION_DEFAULT_DAYS
23002
+ })
22812
23003
  });
22813
23004
 
22814
23005
  // ../../packages/schema/src/zod/managed.ts
@@ -22821,10 +23012,22 @@ var ManagedSettingKey = external_exports.enum([
22821
23012
  "vaultInlineReveal",
22822
23013
  "modelJudgeConsent",
22823
23014
  "dataSharesInPlace",
22824
- "redactFallback"
23015
+ "redactFallback",
23016
+ // Pins the toggle and the day count together — see BodyRetention on why the
23017
+ // two are one unit. An administrator mandating a window wants the count
23018
+ // enforced with it, not one a user can widen while the toggle stays on.
23019
+ "bodyRetention"
22825
23020
  ]).meta({ id: "ManagedSettingKey" });
23021
+ function isManagedSettingKey(value) {
23022
+ return ManagedSettingKey.safeParse(value).success;
23023
+ }
22826
23024
  var ManagedSettingsValues = external_exports.object({
22827
23025
  runMode: external_exports.enum(["standalone", "attached"]).optional(),
23026
+ // `controlPlane` and `bodyRetention` are the two nested values, and both are
23027
+ // plain, non-strict objects: a key under either that this build does not know
23028
+ // is stripped and nothing reports it. The unknown-value split in
23029
+ // ManagedSettings below classifies top-level names only, so it stops at
23030
+ // these boundaries.
22828
23031
  controlPlane: external_exports.object({
22829
23032
  endpoint: external_exports.string().min(1),
22830
23033
  label: external_exports.string().min(1).optional()
@@ -22835,7 +23038,8 @@ var ManagedSettingsValues = external_exports.object({
22835
23038
  vaultInlineReveal: external_exports.enum(["masked", "full", "off"]).optional(),
22836
23039
  modelJudgeConsent: external_exports.boolean().optional(),
22837
23040
  dataSharesInPlace: external_exports.boolean().optional(),
22838
- redactFallback: RedactFallback.optional()
23041
+ redactFallback: RedactFallback.optional(),
23042
+ bodyRetention: BodyRetention.optional()
22839
23043
  }).meta({ id: "ManagedSettingsValues" });
22840
23044
  var ManagedSettings = external_exports.object({
22841
23045
  specVersion: external_exports.number().int().positive().default(MANAGED_SETTINGS_SPEC_VERSION),
@@ -22843,11 +23047,59 @@ var ManagedSettings = external_exports.object({
22843
23047
  // decision from a bug. Absent renders as a generic "your organization".
22844
23048
  organization: external_exports.string().min(1).optional(),
22845
23049
  // What the administrator pinned.
22846
- values: ManagedSettingsValues.default({}),
23050
+ //
23051
+ // Parsed as a RECORD rather than as the nested schema, and split below for
23052
+ // the same reason `lockedFields` is parsed as names: a plain `z.object`
23053
+ // drops an unrecognised key and succeeds, so a pin this build does not know
23054
+ // vanished and nothing anywhere said so. A pin with no lock is a supported
23055
+ // shape — it is a DEFAULT the user may still change — so that silence hit
23056
+ // exactly the file an administrator is most likely to write while a fleet
23057
+ // is mid-upgrade.
23058
+ //
23059
+ // Splitting here rather than calling `.strict()`: strict would REFUSE the
23060
+ // file, which is the outcome the lock half already rejected — an older
23061
+ // build then runs entirely unmanaged, every pin and lock gone. A bad KNOWN
23062
+ // value still fails, because the nested schema is re-run over the known
23063
+ // subset and its issues are re-raised on this parse.
23064
+ values: external_exports.record(external_exports.string(), external_exports.unknown()).default({}),
22847
23065
  // Which of those the user may not change. A key here with no matching value
22848
23066
  // freezes whatever the user last chose; a value with no lock is a DEFAULT
22849
23067
  // the user may still override. The two are separable on purpose.
22850
- lockedFields: external_exports.array(ManagedSettingKey).default([])
23068
+ //
23069
+ // Parsed as NAMES rather than as the enum, and split below: a name this
23070
+ // build does not know is dropped from the locked set and reported, never a
23071
+ // reason to refuse the file. The same shape reaches an older build whenever
23072
+ // an administrator locks a key a newer build added, and refusing it there
23073
+ // ran that build entirely unmanaged — every pin and lock gone — on exactly
23074
+ // the fleets most likely to carry a version skew. A name outside the enum
23075
+ // is still never HONOURED: the lockable set stays explicit above.
23076
+ lockedFields: external_exports.array(external_exports.string()).default([])
23077
+ }).transform(({ lockedFields, values, ...rest }, ctx) => {
23078
+ const known = [];
23079
+ const unknown2 = [];
23080
+ for (const name of lockedFields) {
23081
+ if (isManagedSettingKey(name)) known.push(name);
23082
+ else unknown2.push(name);
23083
+ }
23084
+ const knownValues = /* @__PURE__ */ Object.create(null);
23085
+ const unknownValues = [];
23086
+ for (const [name, value] of Object.entries(values)) {
23087
+ if (Object.hasOwn(ManagedSettingsValues.shape, name)) knownValues[name] = value;
23088
+ else unknownValues.push(name);
23089
+ }
23090
+ const pinned = ManagedSettingsValues.safeParse(knownValues);
23091
+ if (!pinned.success) {
23092
+ for (const issue2 of pinned.error.issues)
23093
+ ctx.addIssue({ ...issue2, path: ["values", ...issue2.path] });
23094
+ return external_exports.NEVER;
23095
+ }
23096
+ return {
23097
+ ...rest,
23098
+ values: pinned.data,
23099
+ lockedFields: known,
23100
+ ...unknown2.length > 0 ? { unknownLockedFields: unknown2 } : {},
23101
+ ...unknownValues.length > 0 ? { unknownValueFields: unknownValues } : {}
23102
+ };
22851
23103
  }).meta({ id: "ManagedSettings" });
22852
23104
 
22853
23105
  // ../../packages/schema/src/zod/project-files.ts
@@ -22965,7 +23217,11 @@ var FindingsTimeseriesPoint = external_exports.object({
22965
23217
  timestamp: external_exports.iso.date(),
22966
23218
  critical: external_exports.number().int().nonnegative(),
22967
23219
  high: external_exports.number().int().nonnegative(),
22968
- medium: external_exports.number().int().nonnegative()
23220
+ medium: external_exports.number().int().nonnegative(),
23221
+ // Optional and additive, so a producer written against the earlier
23222
+ // three-series contract keeps validating. A consumer plotting it resolves the
23223
+ // absent case itself — the chart point requires a number.
23224
+ low: external_exports.number().int().nonnegative().optional()
22969
23225
  }).meta({ id: "FindingsTimeseriesPoint" });
22970
23226
  var FindingsTimeseriesResponse = external_exports.object({
22971
23227
  range: TimeRange,
@@ -22991,6 +23247,10 @@ var ResolvedFeedItem = external_exports.object({
22991
23247
  findingKey: external_exports.string(),
22992
23248
  ruleId: external_exports.string(),
22993
23249
  severity: Severity,
23250
+ // Repository slug, and the file path RELATIVE to it. The pair is what
23251
+ // identifies the file: a bare path matches the same name in every repo.
23252
+ // Optional and additive; empty when the event carried no repo.
23253
+ repo: external_exports.string().optional(),
22994
23254
  path: external_exports.string(),
22995
23255
  // ISO-8601 datetime (matches FindingInstance.detectedAt / the rest of the
22996
23256
  // findings domain). The reader `.toISOString()`s the DB epoch-ms values.
@@ -23096,7 +23356,23 @@ var SaveSettingsInput = external_exports.object({
23096
23356
  modelJudgeConsent: ModelJudgeConsentChoice,
23097
23357
  historySyncConsent: HistorySyncConsentChoice,
23098
23358
  vaultConsent: external_exports.string(),
23099
- vaultInlineReveal: external_exports.string()
23359
+ vaultInlineReveal: external_exports.string(),
23360
+ // Widened to `string` like its neighbours rather than typed as
23361
+ // `RedactFallback`, on this module's own layering rule: shape here, VALUE at
23362
+ // the call site, so the domain check receives the type it was written for.
23363
+ //
23364
+ // NOT because a narrower schema would reject differently. `parseActionInput`
23365
+ // is a `safeParse` wrapper and throws for no field schema, so either spelling
23366
+ // reaches a recoverable `{ ok: false }` and there is no rejected promise to
23367
+ // trade against. The real cost runs the other way and is the part worth
23368
+ // knowing: a value this schema admits and the domain enum then rejects lands
23369
+ // on the action's shared refusal, which names NO field, where a shape
23370
+ // rejection reaches `malformedInput` and names the schema key.
23371
+ redactFallback: external_exports.string(),
23372
+ // Shape only, the way the enum fields above are strings only: the RANGE is
23373
+ // `BodyRetention`'s and the action checks it there, so there is one place
23374
+ // that decides what a legal horizon is rather than two that can drift.
23375
+ bodyRetention: external_exports.object({ enabled: external_exports.boolean(), retainDays: external_exports.number() })
23100
23376
  });
23101
23377
  var AttachInput = external_exports.object({
23102
23378
  endpoint: external_exports.string(),
@@ -23222,6 +23498,52 @@ var SetupHandoffOffer = external_exports.object({
23222
23498
  path: ["liveKeys"]
23223
23499
  });
23224
23500
 
23501
+ // ../../packages/schema/src/zod/web-capture.ts
23502
+ var WebUsageSource = external_exports.enum(["site", "estimated", "none"]);
23503
+ var WebUsage = external_exports.object({
23504
+ inputTokens: external_exports.number().int().nonnegative().optional(),
23505
+ outputTokens: external_exports.number().int().nonnegative().optional(),
23506
+ cacheReadInputTokens: external_exports.number().int().nonnegative().optional(),
23507
+ cacheCreationInputTokens: external_exports.number().int().nonnegative().optional()
23508
+ });
23509
+ var WebToolCall = external_exports.object({
23510
+ toolUseId: external_exports.string().min(1),
23511
+ toolName: external_exports.string().min(1),
23512
+ target: external_exports.string().optional(),
23513
+ isError: external_exports.boolean().optional(),
23514
+ inputSize: external_exports.number().int().nonnegative().optional(),
23515
+ outputSize: external_exports.number().int().nonnegative().optional()
23516
+ });
23517
+ var WebExchange = external_exports.object({
23518
+ messageId: external_exports.string().min(1),
23519
+ startedAt: external_exports.iso.datetime(),
23520
+ model: external_exports.string().optional(),
23521
+ usage: WebUsage.optional(),
23522
+ usageSource: WebUsageSource,
23523
+ stopReason: external_exports.string().optional(),
23524
+ conversationId: external_exports.string().optional(),
23525
+ turnIndex: external_exports.number().int().nonnegative().optional(),
23526
+ toolCalls: external_exports.array(WebToolCall).default([]),
23527
+ // Absent when the adapter recovered no text. Capped by the caller at
23528
+ // RESPONSE_TEXT_MAX_BYTES; `truncated` records that the cap was reached, so a
23529
+ // short capture is never mistaken for a short reply.
23530
+ responseText: external_exports.string().optional(),
23531
+ truncated: external_exports.boolean().default(false)
23532
+ });
23533
+ var RESPONSE_TEXT_MAX_BYTES = 2 * 1024 * 1024;
23534
+ var WebCaptureStatus = external_exports.object({
23535
+ patched: external_exports.boolean(),
23536
+ live: external_exports.boolean(),
23537
+ blind: external_exports.boolean(),
23538
+ sendsSeenDom: external_exports.number().int().nonnegative(),
23539
+ exchangesSeenNet: external_exports.number().int().nonnegative(),
23540
+ parseFailures: external_exports.number().int().nonnegative(),
23541
+ unparsedBodies: external_exports.number().int().nonnegative(),
23542
+ // The adapter-declared JSON key paths that were absent from a real payload —
23543
+ // the earliest signal that a site's contract moved.
23544
+ shapeMisses: external_exports.array(external_exports.string()).default([])
23545
+ });
23546
+
23225
23547
  // ../../packages/persistence/src/paths.ts
23226
23548
  import {
23227
23549
  chmodSync,
@@ -23250,6 +23572,32 @@ var STALE_PARTIAL_MS = 5 * 6e4;
23250
23572
  var SNAPSHOT_STAGING_SUFFIX = ".partial";
23251
23573
  var STAGED_NAME_SUFFIX = `.bak${SNAPSHOT_STAGING_SUFFIX}`;
23252
23574
 
23575
+ // ../../packages/persistence/src/internal/sql-functions.ts
23576
+ var utf8 = new TextDecoder();
23577
+
23578
+ // ../../packages/persistence/src/internal/outbox-lane.ts
23579
+ var OUTBOX_CAPTURE_EVENT_TYPES = ["prompt", "response", "tool_use"];
23580
+ var OUTBOX_CAPTURE_TYPE_LIST = OUTBOX_CAPTURE_EVENT_TYPES.map((t) => `'${t}'`).join(", ");
23581
+
23582
+ // ../../packages/persistence/src/sync-failure.ts
23583
+ var SYNC_FAILURE_REASONS = SyncFailureReason.options;
23584
+
23585
+ // ../../packages/persistence/src/repositories/history-sync.ts
23586
+ var STRUCTURAL_EVENT_TYPES = ["session", "llm_call", "tool_call"];
23587
+ var TYPE_LIST = STRUCTURAL_EVENT_TYPES.map((t) => `'${t}'`).join(", ");
23588
+ var COUNTED_EVENT_TYPES = [
23589
+ ...STRUCTURAL_EVENT_TYPES,
23590
+ ...OUTBOX_CAPTURE_EVENT_TYPES
23591
+ ];
23592
+ var COUNTED_TYPE_LIST = COUNTED_EVENT_TYPES.map((t) => `'${t}'`).join(", ");
23593
+ var COUNTED_SCOPE = `
23594
+ WHERE event_type IN (${COUNTED_TYPE_LIST})
23595
+ AND (
23596
+ event_type IN (${TYPE_LIST})
23597
+ OR synced_at IS NOT NULL
23598
+ OR outbox_owed = 1
23599
+ )`;
23600
+
23253
23601
  // ../../packages/persistence/src/repositories/activity.ts
23254
23602
  var LIVE_ACTIVITY_WINDOW_MS = 30 * 6e4;
23255
23603
  var DB_EVENT_TYPE_TO_KIND = {
@@ -23279,11 +23627,34 @@ var ACTIVE_REVEAL_GRANT_PREDICATE = `capability = 'reveal_to_model'
23279
23627
  AND conditions IS NULL
23280
23628
  AND ${ACTIVE_PREDICATE}`;
23281
23629
 
23282
- // ../../packages/persistence/src/repositories/history-sync.ts
23283
- var STRUCTURAL_EVENT_TYPES = ["session", "llm_call", "tool_call"];
23284
- var TYPE_LIST = STRUCTURAL_EVENT_TYPES.map((t) => `'${t}'`).join(", ");
23285
- var OUTBOX_CAPTURE_EVENT_TYPES = ["prompt", "response", "tool_use"];
23286
- var CAPTURE_TYPE_LIST = OUTBOX_CAPTURE_EVENT_TYPES.map((t) => `'${t}'`).join(", ");
23630
+ // ../../packages/persistence/src/repositories/resolution-sql.ts
23631
+ function latestResolutionColumnSql(column, findingsAlias) {
23632
+ return `(
23633
+ SELECT fr.${column} FROM finding_resolution fr
23634
+ WHERE fr.finding_key = ${findingsAlias}.finding_key
23635
+ ORDER BY fr.created_at DESC, fr.rowid DESC
23636
+ LIMIT 1
23637
+ )`;
23638
+ }
23639
+ function latestResolutionStatusSql(findingsAlias) {
23640
+ return latestResolutionColumnSql("status", findingsAlias);
23641
+ }
23642
+
23643
+ // ../../packages/persistence/src/repositories/findings.ts
23644
+ var FINDING_ROW_COLUMNS_SQL = `f.id AS id, d.rule_id AS rule_id, d.category AS category,
23645
+ d.severity AS severity, f.masked_match AS masked_match,
23646
+ f.action_taken AS action_taken, f.confidence AS confidence,
23647
+ e.started_at AS occurred_at,
23648
+ e.source_tool AS source_tool,
23649
+ e.repo AS repo,
23650
+ e.file_path AS file,
23651
+ e.tool_name AS tool_name,
23652
+ f.audit_event_id AS event_id, e.root_session_id AS session_id,
23653
+ e.event_type AS kind, f.finding_key AS finding_key,
23654
+ ${latestResolutionStatusSql("f")} AS latest_status,
23655
+ e.synced_at AS synced_at, e.sync_claimed_at AS sync_claimed_at,
23656
+ e.sync_failed_at AS sync_failed_at, e.sync_failure AS sync_failure,
23657
+ e.outbox_owed AS outbox_owed`;
23287
23658
 
23288
23659
  // ../../packages/persistence/src/repositories/installed-packs.ts
23289
23660
  import { createHash as createHash2, randomUUID as randomUUID4 } from "crypto";
@@ -23367,9 +23738,14 @@ import { randomUUID as randomUUID10 } from "crypto";
23367
23738
 
23368
23739
  // ../../packages/persistence/src/database.ts
23369
23740
  var CAPTURE_GRAIN = new Set(EventKind.options);
23741
+ var DEFERRED_TAGS = new Set(DEFERRED_MIGRATION_TAGS);
23370
23742
 
23371
- // ../../packages/persistence/src/finding-key.ts
23743
+ // ../../packages/persistence/src/egress-wire.ts
23372
23744
  import { createHash as createHash3 } from "crypto";
23745
+ var SLASH = "/".charCodeAt(0);
23746
+
23747
+ // ../../packages/persistence/src/finding-key.ts
23748
+ import { createHash as createHash4 } from "crypto";
23373
23749
 
23374
23750
  // ../../packages/persistence/src/fingerprint.ts
23375
23751
  import { createHmac, randomBytes } from "crypto";
@@ -23377,14 +23753,26 @@ import { existsSync as existsSync3, readFileSync as readFileSync6 } from "fs";
23377
23753
  import { join as join8 } from "path";
23378
23754
  import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
23379
23755
 
23380
- // ../../packages/persistence/src/history-preview.ts
23381
- import { existsSync as existsSync4 } from "fs";
23756
+ // ../../packages/persistence/src/forward-health.ts
23757
+ import { readFileSync as readFileSync7 } from "fs";
23382
23758
  import { join as join9 } from "path";
23759
+
23760
+ // ../../packages/persistence/src/history-backfill.ts
23761
+ import { existsSync as existsSync4 } from "fs";
23762
+ import { join as join10 } from "path";
23763
+
23764
+ // ../../packages/persistence/src/history-preview.ts
23765
+ import { existsSync as existsSync5 } from "fs";
23766
+ import { join as join11 } from "path";
23383
23767
  import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
23384
23768
 
23769
+ // ../../packages/persistence/src/history-sync-state.ts
23770
+ import { readFileSync as readFileSync8 } from "fs";
23771
+ import { join as join12 } from "path";
23772
+
23385
23773
  // ../../packages/persistence/src/store-symlinks.ts
23386
- import { existsSync as existsSync5, lstatSync as lstatSync3, readlinkSync, realpathSync, statSync as statSync4 } from "fs";
23387
- import { dirname as dirname3, join as join10, resolve } from "path";
23774
+ import { existsSync as existsSync6, lstatSync as lstatSync3, readlinkSync, realpathSync, statSync as statSync4 } from "fs";
23775
+ import { dirname as dirname3, join as join13, resolve } from "path";
23388
23776
 
23389
23777
  // ../../packages/persistence/src/vault/crypto.ts
23390
23778
  import {
@@ -23398,15 +23786,15 @@ import {
23398
23786
  // ../../packages/persistence/src/vault/key-provider.ts
23399
23787
  import { execFileSync } from "child_process";
23400
23788
  import { randomBytes as randomBytes2 } from "crypto";
23401
- import { chmodSync as chmodSync3, readFileSync as readFileSync7, renameSync as renameSync4, rmSync as rmSync6, statSync as statSync5, writeFileSync as writeFileSync3 } from "fs";
23402
- import { join as join11 } from "path";
23789
+ import { chmodSync as chmodSync3, readFileSync as readFileSync9, renameSync as renameSync4, rmSync as rmSync6, statSync as statSync5, writeFileSync as writeFileSync3 } from "fs";
23790
+ import { join as join14 } from "path";
23403
23791
 
23404
23792
  // ../../packages/persistence/src/vault/vault.ts
23405
23793
  import { randomBytes as randomBytes3, randomUUID as randomUUID12 } from "crypto";
23406
23794
 
23407
23795
  // ../../packages/persistence/src/warn-era-cap.ts
23408
- import { existsSync as existsSync6, writeFileSync as writeFileSync4 } from "fs";
23409
- import { join as join12 } from "path";
23796
+ import { existsSync as existsSync7, writeFileSync as writeFileSync4 } from "fs";
23797
+ import { join as join15 } from "path";
23410
23798
 
23411
23799
  // ../../packages/plugin-sdk/src/provider-env.ts
23412
23800
  var booleanish = external_exports.string().optional().transform((v) => {
@@ -23427,9 +23815,9 @@ var providerEnvShape = {
23427
23815
  var ProviderEnvSchema = external_exports.object(providerEnvShape);
23428
23816
 
23429
23817
  // ../../packages/plugin-sdk/src/config-inventory.ts
23430
- import { readdirSync as readdirSync2, readFileSync as readFileSync9, realpathSync as realpathSync2, statSync as statSync7 } from "fs";
23818
+ import { readdirSync as readdirSync2, readFileSync as readFileSync11, realpathSync as realpathSync2, statSync as statSync7 } from "fs";
23431
23819
  import { homedir as homedir2 } from "os";
23432
- import { basename as basename3, join as join15 } from "path";
23820
+ import { basename as basename3, join as join18 } from "path";
23433
23821
 
23434
23822
  // ../../packages/detections/src/egress/registry.ts
23435
23823
  var EXTRACTOR_VERSION = "1";
@@ -24187,24 +24575,20 @@ var CPU_CORROBORATION_SHARE = 0.2;
24187
24575
  var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
24188
24576
 
24189
24577
  // ../../packages/plugin-sdk/src/repo.ts
24190
- import { existsSync as existsSync8, readFileSync as readFileSync8, statSync as statSync6 } from "fs";
24191
- import { basename as basename2, dirname as dirname4, isAbsolute, join as join14, sep as sep2 } from "path";
24578
+ import { existsSync as existsSync9, readFileSync as readFileSync10, statSync as statSync6 } from "fs";
24579
+ import { basename as basename2, dirname as dirname4, isAbsolute, join as join17, sep as sep2 } from "path";
24192
24580
 
24193
24581
  // ../../packages/plugin-sdk/src/events.ts
24194
- import { createHash as createHash4, randomUUID as randomUUID13 } from "crypto";
24582
+ import { createHash as createHash5, randomUUID as randomUUID13 } from "crypto";
24195
24583
 
24196
24584
  // ../../packages/plugin-sdk/src/isolated-scan.ts
24197
- import { existsSync as existsSync9 } from "fs";
24585
+ import { existsSync as existsSync10 } from "fs";
24198
24586
  import { fileURLToPath } from "url";
24199
24587
  import { Worker } from "worker_threads";
24200
24588
 
24201
- // ../../packages/plugin-sdk/src/ignore-layers.ts
24202
- var import_ignore = __toESM(require_ignore(), 1);
24203
- import { readFileSync as readFileSync10 } from "fs";
24204
- import { join as join16 } from "path";
24205
-
24206
- // ../../packages/plugin-sdk/src/inventory-resolver.ts
24207
- import { arch, hostname as hostname4, platform, release } from "os";
24589
+ // ../../packages/plugin-sdk/src/host-floor.ts
24590
+ import { readFileSync as readFileSync13 } from "fs";
24591
+ import { join as join20 } from "path";
24208
24592
 
24209
24593
  // ../../packages/plugin-sdk/src/model-governance.ts
24210
24594
  import {
@@ -24212,24 +24596,50 @@ import {
24212
24596
  fstatSync,
24213
24597
  mkdirSync as mkdirSync2,
24214
24598
  openSync as openSync2,
24215
- readFileSync as readFileSync11,
24599
+ readFileSync as readFileSync12,
24216
24600
  readSync,
24217
24601
  writeFileSync as writeFileSync5
24218
24602
  } from "fs";
24219
- import { join as join17 } from "path";
24603
+ import { join as join19 } from "path";
24220
24604
  var TAIL_BYTES = 256 * 1024;
24221
24605
 
24606
+ // ../../packages/plugin-sdk/src/host-floor.ts
24607
+ var HOST_FEATURE = {
24608
+ ModelSwitch: "model-switch",
24609
+ VaultPointerDisplay: "vault-pointer-display"
24610
+ };
24611
+ var HOST_FLOORS = {
24612
+ [HOST_FEATURE.ModelSwitch]: {
24613
+ label: "model-switch protection",
24614
+ hookEvents: ["PreModelSwitch", "PostModelSwitch"],
24615
+ since: "2.1.251"
24616
+ },
24617
+ [HOST_FEATURE.VaultPointerDisplay]: {
24618
+ label: "vault pointer display",
24619
+ hookEvents: ["MessageDisplay"],
24620
+ since: "2.1.152"
24621
+ }
24622
+ };
24623
+
24624
+ // ../../packages/plugin-sdk/src/ignore-layers.ts
24625
+ var import_ignore = __toESM(require_ignore(), 1);
24626
+ import { readFileSync as readFileSync14 } from "fs";
24627
+ import { join as join21 } from "path";
24628
+
24629
+ // ../../packages/plugin-sdk/src/inventory-resolver.ts
24630
+ import { arch, hostname as hostname4, platform, release } from "os";
24631
+
24222
24632
  // ../../packages/plugin-sdk/src/nudge.ts
24223
- import { mkdirSync as mkdirSync3, readFileSync as readFileSync12, writeFileSync as writeFileSync6 } from "fs";
24224
- import { join as join18 } from "path";
24633
+ import { mkdirSync as mkdirSync3, readFileSync as readFileSync15, writeFileSync as writeFileSync6 } from "fs";
24634
+ import { join as join22 } from "path";
24225
24635
 
24226
24636
  // ../../packages/plugin-sdk/src/paths.ts
24227
24637
  import { readdirSync as readdirSync3, realpathSync as realpathSync3 } from "fs";
24228
24638
  import { basename as basename4, dirname as dirname5, sep as sep3 } from "path";
24229
24639
 
24230
24640
  // ../../packages/plugin-sdk/src/project-files.ts
24231
- import { existsSync as existsSync10, readdirSync as readdirSync4 } from "fs";
24232
- import { basename as basename5, join as join19 } from "path";
24641
+ import { existsSync as existsSync11, readdirSync as readdirSync4 } from "fs";
24642
+ import { basename as basename5, join as join23 } from "path";
24233
24643
 
24234
24644
  // ../../packages/plugin-sdk/src/provider-env-antigravity.ts
24235
24645
  var optionalBaseUrl2 = external_exports.preprocess((v) => {
@@ -24265,11 +24675,11 @@ var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
24265
24675
 
24266
24676
  // ../../packages/plugin-sdk/src/throttle.ts
24267
24677
  import { mkdirSync as mkdirSync4, statSync as statSync8, writeFileSync as writeFileSync7 } from "fs";
24268
- import { join as join20 } from "path";
24678
+ import { join as join24 } from "path";
24269
24679
 
24270
24680
  // ../../packages/setup-wizard/src/remediation/rotation-checklist.ts
24271
24681
  import { writeFileSync as writeFileSync8 } from "fs";
24272
- import { join as join21 } from "path";
24682
+ import { join as join25 } from "path";
24273
24683
 
24274
24684
  // ../../packages/setup-wizard/src/triage/merge.ts
24275
24685
  var RANK = Object.fromEntries(
@@ -24277,9 +24687,9 @@ var RANK = Object.fromEntries(
24277
24687
  );
24278
24688
 
24279
24689
  // ../../packages/setup-wizard/src/triage/plan-file.ts
24280
- import { mkdtempSync, readFileSync as readFileSync13, rmdirSync, rmSync as rmSync7, writeFileSync as writeFileSync9 } from "fs";
24690
+ import { mkdtempSync, readFileSync as readFileSync16, rmdirSync, rmSync as rmSync7, writeFileSync as writeFileSync9 } from "fs";
24281
24691
  import { tmpdir } from "os";
24282
- import { basename as basename6, dirname as dirname6, join as join22 } from "path";
24692
+ import { basename as basename6, dirname as dirname6, join as join26 } from "path";
24283
24693
  var SuppressionEntrySchema = external_exports.object({
24284
24694
  ruleId: external_exports.string(),
24285
24695
  category: DetectionCategory,
@@ -24321,8 +24731,8 @@ var PersistedPlanSchema = external_exports.object({
24321
24731
  });
24322
24732
 
24323
24733
  // src/skills-registry.ts
24324
- import { readdirSync as readdirSync5, readFileSync as readFileSync14 } from "fs";
24325
- import { join as join23 } from "path";
24734
+ import { readdirSync as readdirSync5, readFileSync as readFileSync17 } from "fs";
24735
+ import { join as join27 } from "path";
24326
24736
  import { fileURLToPath as fileURLToPath2 } from "url";
24327
24737
  var SKILLS_DIR = fileURLToPath2(new URL("../skills", import.meta.url));
24328
24738
 
@@ -24362,7 +24772,7 @@ function authorName(author) {
24362
24772
  var manifestPath = process.argv[2];
24363
24773
  var manifest = {};
24364
24774
  try {
24365
- manifest = JSON.parse(readFileSync15(manifestPath ?? "", "utf8"));
24775
+ manifest = JSON.parse(readFileSync18(manifestPath ?? "", "utf8"));
24366
24776
  } catch {
24367
24777
  }
24368
24778
  process.stdout.write(