@akasecurity/ai-tc-codex 0.9.11 → 0.9.13

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 readFileSync16 } from "fs";
495
+ import { readFileSync as readFileSync18 } from "fs";
496
496
 
497
497
  // src/present.ts
498
498
  var SHADE = {
@@ -549,7 +549,7 @@ function fenced(body) {
549
549
 
550
550
  // ../../packages/plugin-sdk/src/config.ts
551
551
  import { existsSync as existsSync8 } from "fs";
552
- import { join as join14 } from "path";
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;
@@ -20271,7 +20279,17 @@ var UNPRICEABLE_PROVIDERS = Object.freeze([
20271
20279
  "gateway",
20272
20280
  "unknown",
20273
20281
  "cli",
20274
- "api"
20282
+ "api",
20283
+ // The browser extension's native host records these as `llm_call.provider`
20284
+ // for a web-chat turn — the web tool id, deliberately never the vendor id
20285
+ // (`openai`/`anthropic`) the session root carries. Subscription traffic
20286
+ // burns rate-limit budget, not dollar credits, and listing them here is
20287
+ // what keeps that true structurally: a later maintainer who wants to price
20288
+ // web-chat traffic at API rates has to delete this entry first, and meet
20289
+ // the reason on the way, rather than quietly adding one to
20290
+ // PROVIDER_PLATFORM.
20291
+ "chatgpt",
20292
+ "claude-ai"
20275
20293
  ]);
20276
20294
 
20277
20295
  // ../../packages/schema/src/token/format.ts
@@ -20291,7 +20309,12 @@ var HARNESS = {
20291
20309
  ClaudeDesktop: "claudedesktop",
20292
20310
  ChatGpt: "chatgpt",
20293
20311
  ClaudeAi: "claudeai",
20294
- Api: "api"
20312
+ Api: "api",
20313
+ // Not a coding assistant a person drives — an in-process SDK embedded in an
20314
+ // application, so it has no IDE/CLI/desktop/web surface of its own. Carries
20315
+ // the same id as its SOURCE_TOOL counterpart, unlike every capture-side tool
20316
+ // whose wire spelling differs from its display spelling.
20317
+ AiTcSdk: "ai-tc-sdk"
20295
20318
  };
20296
20319
  var Harness = external_exports.enum(HARNESS).meta({ id: "Harness" });
20297
20320
  var SOURCE_TOOL = {
@@ -20307,9 +20330,15 @@ var SOURCE_TOOL = {
20307
20330
  // whose tool could not be identified both render through the read side's
20308
20331
  // miss path rather than as a harness of their own.
20309
20332
  Cli: "cli",
20310
- Unknown: "unknown"
20333
+ Unknown: "unknown",
20334
+ // The wire id an in-process, request-path SDK stamps on its own structural
20335
+ // rows (`request_decision`) — never a capture of prompt/response/tool text,
20336
+ // since the SDK sits in front of a model call rather than inside a coding
20337
+ // assistant's own hook contract.
20338
+ AiTcSdk: "ai-tc-sdk"
20311
20339
  };
20312
20340
  var SourceTool = external_exports.enum(SOURCE_TOOL).meta({ id: "SourceTool" });
20341
+ var WebSourceTool = SourceTool.extract(["ChatGpt", "ClaudeAi"]);
20313
20342
  var TOOL_TO_HARNESS = {
20314
20343
  [SOURCE_TOOL.ClaudeCode]: HARNESS.ClaudeCode,
20315
20344
  [SOURCE_TOOL.ClaudeDesktop]: HARNESS.ClaudeDesktop,
@@ -20318,7 +20347,12 @@ var TOOL_TO_HARNESS = {
20318
20347
  [SOURCE_TOOL.ChatGpt]: HARNESS.ChatGpt,
20319
20348
  [SOURCE_TOOL.Codex]: HARNESS.Codex,
20320
20349
  [SOURCE_TOOL.Antigravity]: HARNESS.Antigravity,
20321
- [SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi
20350
+ [SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi,
20351
+ // Wire and display id are the same string here, but the row still belongs:
20352
+ // both vocabularies carry the `AiTcSdk` member, and the join is exactly
20353
+ // their intersection — leaving a shared member out would read as an
20354
+ // uninstrumented tool on both surfaces, which this one is not.
20355
+ [SOURCE_TOOL.AiTcSdk]: HARNESS.AiTcSdk
20322
20356
  };
20323
20357
 
20324
20358
  // ../../packages/schema/src/zod/finding.ts
@@ -20352,7 +20386,8 @@ var FindingProvider = Harness.extract([
20352
20386
  "ClaudeAi",
20353
20387
  "Codex",
20354
20388
  "Antigravity",
20355
- "Api"
20389
+ "Api",
20390
+ "AiTcSdk"
20356
20391
  ]).meta({ id: "FindingProvider" });
20357
20392
  var FindingCategory = external_exports.enum([
20358
20393
  "secret",
@@ -20368,6 +20403,15 @@ var FindingCategory = external_exports.enum([
20368
20403
  ]).meta({ id: "FindingCategory" });
20369
20404
  var FindingOrigin = external_exports.enum(["in-flight", "at-rest"]).meta({ id: "FindingOrigin" });
20370
20405
  var FindingStatus = external_exports.enum(["open", "handled", "resolved", "dismissed"]).meta({ id: "FindingStatus" });
20406
+ var SyncFailureReason = external_exports.enum(["deployment_refused", "payload_invalid", "detached_undelivered"]).meta({ id: "SyncFailureReason" });
20407
+ var FindingDeliveryState = external_exports.enum(["sent", "queued", "not_sent", "never_offered", "local_scan"]).meta({ id: "FindingDeliveryState" });
20408
+ var FindingDelivery = external_exports.object({
20409
+ state: FindingDeliveryState,
20410
+ // The delivery time for `sent`; the failure time for `not_sent` when recorded.
20411
+ at: external_exports.iso.datetime().optional(),
20412
+ // Only on `not_sent`, and only when a known reason was recorded.
20413
+ reason: SyncFailureReason.optional()
20414
+ }).meta({ id: "FindingDelivery" });
20371
20415
  var ResolutionMethod = external_exports.enum([
20372
20416
  "enforced-in-flight",
20373
20417
  "fixed-at-source",
@@ -20424,7 +20468,10 @@ var FindingInstance = external_exports.object({
20424
20468
  // The session that event belongs to, when it has one — the seam a
20425
20469
  // per-instance "view session" link needs. Absent for events captured
20426
20470
  // outside a session.
20427
- sessionId: external_exports.string().optional()
20471
+ sessionId: external_exports.string().optional(),
20472
+ // The delivery state of the event above (see FindingDelivery). Optional so
20473
+ // readers that do not project it stay valid.
20474
+ delivery: FindingDelivery.optional()
20428
20475
  }).meta({ id: "FindingInstance" });
20429
20476
  var FindingGroup = external_exports.object({
20430
20477
  id: external_exports.string(),
@@ -20476,7 +20523,10 @@ var FindingFacets = external_exports.object({
20476
20523
  // Host tool (attributes.tool_name). Present only on the instance-level
20477
20524
  // reads, which can filter by it; the type-level read omits the dimension
20478
20525
  // because a group spans tools.
20479
- tool: external_exports.array(FindingFacetItem).optional()
20526
+ tool: external_exports.array(FindingFacetItem).optional(),
20527
+ // Delivery states (FindingDeliveryState). Present only on the
20528
+ // instance-level reads, like `tool`.
20529
+ deployment: external_exports.array(FindingFacetItem).optional()
20480
20530
  }).meta({ id: "FindingFacets" });
20481
20531
  var FindingTypeSummary = FindingGroup.omit({ instances: true, match: true }).meta({
20482
20532
  id: "FindingTypeSummary"
@@ -20585,6 +20635,8 @@ var ListFindingInstancesQuery = external_exports.object({
20585
20635
  // Exact host-tool names (attributes.tool_name, e.g. 'Bash'). A real filter,
20586
20636
  // where the free-text `q` can only match the rendered "via Bash" label.
20587
20637
  tool: external_exports.array(external_exports.string()).optional(),
20638
+ // The delivery state of each finding's event (see FindingDelivery).
20639
+ deployment: external_exports.array(FindingDeliveryState).optional(),
20588
20640
  // Exact repository / file-path matches, for the drill-down out of the
20589
20641
  // locations view. A row whose event carries no repo/file matches neither.
20590
20642
  repo: external_exports.string().optional(),
@@ -20605,6 +20657,10 @@ var ListFindingInstancesResponse = external_exports.object({
20605
20657
  items: external_exports.array(FindingInstanceDetail),
20606
20658
  nextCursor: external_exports.string().nullable()
20607
20659
  }).meta({ id: "ListFindingInstancesResponse" });
20660
+ var ListFindingInstancesPage = external_exports.object({
20661
+ items: external_exports.array(FindingInstanceDetail),
20662
+ nextCursor: external_exports.string().nullable()
20663
+ }).meta({ id: "ListFindingInstancesPage" });
20608
20664
  var FindingLocationSummary = external_exports.object({
20609
20665
  // Opaque, stable, minted from the pair by encodeLocationId. It exists
20610
20666
  // because a location's identity is two values and a URL param carries one:
@@ -20646,6 +20702,8 @@ var ListFindingLocationsQuery = external_exports.object({
20646
20702
  // instances that match, and folds its status from those.
20647
20703
  status: external_exports.array(FindingStatus).optional(),
20648
20704
  tool: external_exports.array(external_exports.string()).optional(),
20705
+ // The delivery state of each finding's event (see FindingDelivery).
20706
+ deployment: external_exports.array(FindingDeliveryState).optional(),
20649
20707
  q: external_exports.string().optional(),
20650
20708
  sessionId: external_exports.string().optional(),
20651
20709
  from: external_exports.iso.datetime().optional(),
@@ -20703,18 +20761,41 @@ var AuditEventType = external_exports.enum([
20703
20761
  // 'tool_call' is the reconciler's structural row for every call, while
20704
20762
  // 'tool_use' exists only where a hook enforced against the arguments.
20705
20763
  "tool_use",
20706
- // One row per model REFUSAL: a switch onto a prohibited model that was
20707
- // denied, or a turn refused because the session was already running on one.
20708
- // A structural row like the ones above rather than a capture — it carries
20709
- // the model that was refused and nothing the user typed, because what is
20710
- // worth recording about a governance decision is the decision, and prompt
20711
- // text is the thing this product exists to keep from travelling.
20764
+ // One row per model REFUSAL, across all four seams a prohibited model can be
20765
+ // stopped at: a switch onto it, a turn already running on it, a subagent
20766
+ // spawn asking for it, or a request-path refusal an embedded request-path
20767
+ // SDK makes in-process before the call leaves the application. Which seam
20768
+ // rides `attributes.refusal_seam`, never this member name. A structural row
20769
+ // like the ones above rather than a capture — it carries the model that was
20770
+ // refused and nothing the user typed, because what is worth recording about
20771
+ // a governance decision is the decision, and prompt text is the thing this
20772
+ // product exists to keep from travelling.
20712
20773
  "model_refusal",
20774
+ // One row per request-path DECISION: a policy check an embedded request-path
20775
+ // SDK performs in-process before a model call leaves the application, or
20776
+ // against that call's non-streamed response. A structural row like
20777
+ // 'model_refusal' rather than a capture — content-free in the same way:
20778
+ // which side, which seam, what action and which field are decided rides
20779
+ // `attributes`, never this member name, and the matched text itself never
20780
+ // travels.
20781
+ //
20782
+ // A prohibited-model refusal on the request path is deliberately NOT this
20783
+ // member: it stays 'model_refusal' with `refusal_seam: 'request'`, so it
20784
+ // shares one bucket with the plugin's switch/turn/spawn refusals rather
20785
+ // than splitting one governance concept across two event types. This
20786
+ // member carries every OTHER request-path decision.
20787
+ "request_decision",
20713
20788
  // One row per config-inventory scan, hung off the session root. It is the
20714
20789
  // fact the posture inspection findings reference (findings require an
20715
20790
  // audit_event_id), and its started_at is the "scanned Nm ago" the read
20716
20791
  // surface renders.
20717
- "config_scan"
20792
+ "config_scan",
20793
+ // One row per reported browser-extension capture status, hung off the web
20794
+ // session root. The durable home of what one tab's network interception
20795
+ // is doing — a write-through of the native host's in-memory tracker, so a
20796
+ // second process (aka extension status) and a restarted host both have
20797
+ // somewhere to read it back from.
20798
+ "capture_status"
20718
20799
  ]).meta({ id: "AuditEventType" });
20719
20800
  var AttributeBag = external_exports.record(external_exports.string(), external_exports.unknown());
20720
20801
  var HostAttributes = external_exports.object({
@@ -20848,6 +20929,10 @@ var CaptureAttributes = external_exports.object({
20848
20929
  // to 'allow' — the enforcement audit trail's link back to the grant that
20849
20930
  // authorized the bypass.
20850
20931
  exception_ids: external_exports.array(external_exports.guid()).optional(),
20932
+ // The persisted spellings of EventMetadata's messageId/conversationId — the
20933
+ // join back to the `llm_call` leaf for the same assistant turn.
20934
+ message_id: external_exports.string().optional(),
20935
+ conversation_id: external_exports.string().optional(),
20851
20936
  // Whole milliseconds this capture's inspection blocked its caller — the
20852
20937
  // plugin's own added latency (see EventMetadata.inspectionMs, whose value
20853
20938
  // this is). Promoted to the `inspection_ms` generated column so the facet is
@@ -20856,7 +20941,33 @@ var CaptureAttributes = external_exports.object({
20856
20941
  // inline json_extract and is not itself an optimization.
20857
20942
  // ABSENT on replayed captures (backfill / worktree scan) and on rows written
20858
20943
  // before the measurement shipped — never present as a placeholder 0.
20859
- inspection_ms: external_exports.number().int().nonnegative().optional()
20944
+ inspection_ms: external_exports.number().int().nonnegative().optional(),
20945
+ // What a `redact` this capture could not carry out became instead (see
20946
+ // EventMetadata.redactDegradedTo, whose value this is). Present only when a
20947
+ // degrade actually happened, so absence is the ordinary case rather than a
20948
+ // reader having to distinguish it from a zero.
20949
+ //
20950
+ // PER CAPTURE, while `inspection_findings.action_taken` is per finding —
20951
+ // so on a multi-finding row this does not say which finding degraded, and
20952
+ // its presence does not mean the fallback decided the capture's action. A
20953
+ // capture denied by another finding's own Block policy carries `block`
20954
+ // here too. The full statement is on EventMetadata.redactDegradedTo; it is
20955
+ // repeated rather than referenced because a store reader opens this file.
20956
+ redact_degraded_to: ActionTaken.optional()
20957
+ }).catchall(external_exports.unknown());
20958
+ var CaptureStatusAttributes = external_exports.object({
20959
+ source_tool: external_exports.string().optional(),
20960
+ patched: external_exports.boolean().optional(),
20961
+ live: external_exports.boolean().optional(),
20962
+ blind: external_exports.boolean().optional(),
20963
+ sends_seen_dom: external_exports.number().int().nonnegative().optional(),
20964
+ exchanges_seen_net: external_exports.number().int().nonnegative().optional(),
20965
+ parse_failures: external_exports.number().int().nonnegative().optional(),
20966
+ unparsed_bodies: external_exports.number().int().nonnegative().optional(),
20967
+ shape_misses: external_exports.array(external_exports.string()).optional(),
20968
+ conversation_endpoints: external_exports.number().int().nonnegative().optional(),
20969
+ closed: external_exports.boolean().optional(),
20970
+ enforcement: external_exports.string().optional()
20860
20971
  }).catchall(external_exports.unknown());
20861
20972
  var ToolCallInspection = external_exports.object({
20862
20973
  ruleId: external_exports.string().min(1),
@@ -21052,7 +21163,17 @@ var AuditEvent = external_exports.object({
21052
21163
  /** `share` to a first-party/internal destination. */
21053
21164
  internal: external_exports.boolean(),
21054
21165
  /** Event needs review (e.g. unverified egress). */
21055
- flagged: external_exports.boolean()
21166
+ flagged: external_exports.boolean(),
21167
+ /**
21168
+ * The body this event's `title` is drawn from was cleared by local body
21169
+ * expiry, so an EMPTY title here means "gone", not "never had one".
21170
+ *
21171
+ * A separate flag rather than a sentinel written into `title`: the title is
21172
+ * rendered text, and a store-layer module that invented display copy for it
21173
+ * would be choosing words the view is supposed to choose. Additive and
21174
+ * defaulted, so an older producer still validates.
21175
+ */
21176
+ bodyExpired: external_exports.boolean().default(false)
21056
21177
  }).meta({ id: "ActivityAuditEvent" });
21057
21178
  var ActivitySessionSummary = external_exports.object({
21058
21179
  id: external_exports.string(),
@@ -21857,6 +21978,11 @@ var RemoteFailureKind = external_exports.enum([
21857
21978
  "rejected",
21858
21979
  "unreachable"
21859
21980
  ]);
21981
+ var ControlPlaneFailure = RemoteFailureKind.extract([
21982
+ "unauthorized",
21983
+ "forbidden",
21984
+ "unreachable"
21985
+ ]);
21860
21986
  var AttachDeviceRequest = external_exports.object({
21861
21987
  // This machine's own continuity id, so re-attaching ROTATES the credential
21862
21988
  // on one machine record instead of producing a second one. Client-minted
@@ -22275,6 +22401,17 @@ var EventMetadata = external_exports.object({
22275
22401
  // to 'allow' — the enforcement audit trail's link back to the grant that
22276
22402
  // authorized the bypass. Absent on captures where no exception applied.
22277
22403
  exceptionIds: external_exports.array(external_exports.guid()).optional(),
22404
+ // The assistant message this capture belongs to, and the conversation it sits
22405
+ // in — set by the browser extension's network capture so a stored `response`
22406
+ // row can be joined to the `llm_call` leaf describing the same turn. Absent
22407
+ // on every other capture path, which has no such id.
22408
+ //
22409
+ // Non-empty for the reason WebExchange.messageId is: it is the join key, and
22410
+ // a blank one matches no `llm_call` leaf. That refusal reaches only the
22411
+ // places an event is PARSED; the local write path types the event and parses
22412
+ // nothing, which is why `toCaptureAttributes` omits a blank one separately.
22413
+ messageId: external_exports.string().min(1).optional(),
22414
+ conversationId: external_exports.string().optional(),
22278
22415
  // How long THIS capture's inspection blocked its caller, in whole
22279
22416
  // milliseconds — the plugin's own added latency, NOT the LLM call it sat in
22280
22417
  // front of. Measured inside `capture()` (@akasecurity/plugin-sdk) across
@@ -22287,7 +22424,37 @@ var EventMetadata = external_exports.object({
22287
22424
  // Absent is also what every pre-measurement client writes, and what a
22288
22425
  // clock failure degrades to — a reader must treat absence as "not measured"
22289
22426
  // and never as a zero, which would read as "inspection is free".
22290
- inspectionMs: external_exports.number().int().nonnegative().optional()
22427
+ inspectionMs: external_exports.number().int().nonnegative().optional(),
22428
+ // What a `redact` this capture COULD NOT CARRY OUT became instead — the
22429
+ // workspace's `redactFallback`, applied because the field could not be
22430
+ // masked in place (a shell command, a URL, or any argument on a host whose
22431
+ // hook contract offers no rewrite channel).
22432
+ //
22433
+ // It exists because the action alone cannot say why. A finding recorded as
22434
+ // `warn` reads identically whether its detection was ASSIGNED Warn or was
22435
+ // assigned Redact on a field that could not take one — and those are
22436
+ // different facts about the same row: the first is a policy the user chose,
22437
+ // the second is a masking the host could not perform. Absent means no
22438
+ // degrade happened, which is every ordinary capture.
22439
+ //
22440
+ // TWO LIMITS a reader of a stored row has to know, because the grain here
22441
+ // is the CAPTURE while `actionTaken` is per FINDING:
22442
+ //
22443
+ // - It does not say WHICH finding degraded. A capture carrying a degraded
22444
+ // `redact` alongside a finding ASSIGNED the same action stores both
22445
+ // identically and one reason for the pair; attributing it to both
22446
+ // describes the assigned one wrongly, and to neither loses the degrade.
22447
+ // - PRESENCE IS NOT CAUSATION. The value is the action the lost redact
22448
+ // became, not the reason the capture ended as it did — a capture denied
22449
+ // by some other finding's own Block policy still carries `block` here,
22450
+ // and clearing the workspace's fallback would not have let it through.
22451
+ // Gate on the value against what a fallback can produce; never read the
22452
+ // field's presence as "this was the fallback's doing".
22453
+ //
22454
+ // Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
22455
+ // Closing either means moving the reason onto the finding row, which
22456
+ // already carries its own action.
22457
+ redactDegradedTo: ActionTaken.optional()
22291
22458
  }).meta({ id: "EventMetadata" });
22292
22459
  var Event = external_exports.object({
22293
22460
  id: external_exports.guid(),
@@ -22397,6 +22564,15 @@ var RotateKeyInput = external_exports.object({
22397
22564
  confirmation: external_exports.string()
22398
22565
  });
22399
22566
 
22567
+ // ../../packages/schema/src/zod/finding-delivery.ts
22568
+ var KNOWN_REASONS = SyncFailureReason.options;
22569
+
22570
+ // ../../packages/schema/src/zod/findings-group-build.ts
22571
+ function rankByOrder(members2) {
22572
+ return Object.fromEntries(members2.map((member, index) => [member, index]));
22573
+ }
22574
+ var SEVERITY_RANK = rankByOrder(Severity.options);
22575
+
22400
22576
  // ../../packages/schema/src/zod/installed-pack.ts
22401
22577
  var InstalledPack = external_exports.object({
22402
22578
  id: external_exports.guid(),
@@ -22463,6 +22639,11 @@ var Policy = external_exports.object({
22463
22639
  // test `prohibitedModels` passes and `reversibleRuleIds` fails.
22464
22640
  provenance: PolicyProvenance.optional()
22465
22641
  }).meta({ id: "Policy" });
22642
+ var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
22643
+ var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
22644
+ var RedactFallback = BuiltinPolicyId.extract(["monitor", "warn", "block"]).meta({
22645
+ id: "RedactFallback"
22646
+ });
22466
22647
  var PolicyBundle = external_exports.object({
22467
22648
  version: external_exports.string(),
22468
22649
  policies: external_exports.array(Policy),
@@ -22510,6 +22691,16 @@ var PolicyBundle = external_exports.object({
22510
22691
  // control plane), so no name resolution stands between the decision and the
22511
22692
  // comparison.
22512
22693
  prohibitedModels: external_exports.array(external_exports.string()).optional(),
22694
+ // What a resolved `redact` becomes on a field the host cannot rewrite, as
22695
+ // the ORGANIZATION would have it. Merged raise-only against the device's own
22696
+ // `WorkspaceSettings.redactFallback` (see strongerRedactFallback below), so
22697
+ // a control plane can tighten a machine and never loosen one — the same
22698
+ // direction `mergeRaiseOnly` enforces for policies.
22699
+ //
22700
+ // Optional so an older backend, and an older on-disk cache, still parses;
22701
+ // absent leaves the device's own setting in force, which is the behaviour
22702
+ // that predates the field and the safe direction to default.
22703
+ redactFallback: RedactFallback.optional(),
22513
22704
  customKeywords: external_exports.array(external_exports.string()),
22514
22705
  fetchedAt: external_exports.iso.datetime()
22515
22706
  }).meta({ id: "PolicyBundle" });
@@ -22539,11 +22730,6 @@ function severityFloorPolicy(category) {
22539
22730
  const peak = CATEGORY_PEAK_SEVERITY[category];
22540
22731
  return peak === "critical" || peak === "high" ? "warn" : "monitor";
22541
22732
  }
22542
- var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
22543
- var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
22544
- var RedactFallback = BuiltinPolicyId.extract(["monitor", "warn", "block"]).meta({
22545
- id: "RedactFallback"
22546
- });
22547
22733
  var BUILTIN_POLICY_SPECS = {
22548
22734
  monitor: {
22549
22735
  name: "Monitor",
@@ -22805,7 +22991,7 @@ var VaultConsent = external_exports.object({
22805
22991
  });
22806
22992
 
22807
22993
  // ../../packages/schema/src/zod/local.ts
22808
- var WORKSPACE_SETTINGS_SPEC_VERSION = 7;
22994
+ var WORKSPACE_SETTINGS_SPEC_VERSION = 8;
22809
22995
  var RunMode = external_exports.enum(["standalone", "attached"]);
22810
22996
  var ControlPlaneConnection = external_exports.object({
22811
22997
  endpoint: external_exports.string().min(1),
@@ -22824,6 +23010,27 @@ var HistorySyncConsent = external_exports.object({
22824
23010
  payloadVersion: external_exports.number().int().positive(),
22825
23011
  endpoint: external_exports.string()
22826
23012
  });
23013
+ var WebChatCaptureConsent = external_exports.object({
23014
+ acknowledgedAt: external_exports.iso.datetime(),
23015
+ version: external_exports.number().int().positive()
23016
+ });
23017
+ var WebChatResponseCapture = external_exports.enum(["with-findings", "always", "never"]);
23018
+ var WebChatCapture = external_exports.object({
23019
+ responses: WebChatResponseCapture.default("with-findings"),
23020
+ account: external_exports.boolean().default(false),
23021
+ // Absent until granted. Presence alone does not authorize anything — see
23022
+ // isWebChatCaptureConsentValid.
23023
+ consent: WebChatCaptureConsent.optional()
23024
+ });
23025
+ var BODY_RETENTION_DEFAULT_DAYS = 30;
23026
+ var BodyRetention = external_exports.object({
23027
+ enabled: external_exports.boolean().default(false),
23028
+ // Never 0, and the ceiling is a fat-finger guard rather than a policy
23029
+ // limit — `enabled` is the real gate. A low value cannot reach a row the
23030
+ // sync ledger still owes: the sweep's age filter only ever NARROWS a
23031
+ // candidate set that is already bounded by "delivered, or never owed".
23032
+ retainDays: external_exports.number().int().min(1).max(3650).default(BODY_RETENTION_DEFAULT_DAYS)
23033
+ }).meta({ id: "BodyRetention" });
22827
23034
  var WorkspaceSettings = external_exports.object({
22828
23035
  specVersion: external_exports.number().int().positive().default(WORKSPACE_SETTINGS_SPEC_VERSION),
22829
23036
  runMode: RunMode.default("standalone"),
@@ -22872,7 +23079,23 @@ var WorkspaceSettings = external_exports.object({
22872
23079
  // carry prompt/reply/tool-output text in `content`; the key name predates
22873
23080
  // both widenings. Absent until granted, and a grant for a different endpoint
22874
23081
  // or an older payload no longer counts.
22875
- historySyncConsent: HistorySyncConsent.optional()
23082
+ historySyncConsent: HistorySyncConsent.optional(),
23083
+ // What the browser extension may record from a web chat, and the grant that
23084
+ // authorizes it. Absent until the user answers: recording something that was
23085
+ // never recorded before is never an assumed grant on upgrade, so the whole
23086
+ // block is optional rather than defaulted in. What an absent block means is
23087
+ // webChatCaptureOf's answer, in one place.
23088
+ //
23089
+ // Enforcement is NOT gated on this. A machine that has never answered still
23090
+ // blocks, redacts and warns on what a user sends; the grant covers what is
23091
+ // written down.
23092
+ webChatCapture: WebChatCapture.optional(),
23093
+ // Local body expiry (see BodyRetention). Off until switched on; expiring a
23094
+ // body never removes the row or its findings.
23095
+ bodyRetention: BodyRetention.default({
23096
+ enabled: false,
23097
+ retainDays: BODY_RETENTION_DEFAULT_DAYS
23098
+ })
22876
23099
  });
22877
23100
 
22878
23101
  // ../../packages/schema/src/zod/managed.ts
@@ -22885,13 +23108,22 @@ var ManagedSettingKey = external_exports.enum([
22885
23108
  "vaultInlineReveal",
22886
23109
  "modelJudgeConsent",
22887
23110
  "dataSharesInPlace",
22888
- "redactFallback"
23111
+ "redactFallback",
23112
+ // Pins the toggle and the day count together — see BodyRetention on why the
23113
+ // two are one unit. An administrator mandating a window wants the count
23114
+ // enforced with it, not one a user can widen while the toggle stays on.
23115
+ "bodyRetention"
22889
23116
  ]).meta({ id: "ManagedSettingKey" });
22890
23117
  function isManagedSettingKey(value) {
22891
23118
  return ManagedSettingKey.safeParse(value).success;
22892
23119
  }
22893
23120
  var ManagedSettingsValues = external_exports.object({
22894
23121
  runMode: external_exports.enum(["standalone", "attached"]).optional(),
23122
+ // `controlPlane` and `bodyRetention` are the two nested values, and both are
23123
+ // plain, non-strict objects: a key under either that this build does not know
23124
+ // is stripped and nothing reports it. The unknown-value split in
23125
+ // ManagedSettings below classifies top-level names only, so it stops at
23126
+ // these boundaries.
22895
23127
  controlPlane: external_exports.object({
22896
23128
  endpoint: external_exports.string().min(1),
22897
23129
  label: external_exports.string().min(1).optional()
@@ -22902,7 +23134,8 @@ var ManagedSettingsValues = external_exports.object({
22902
23134
  vaultInlineReveal: external_exports.enum(["masked", "full", "off"]).optional(),
22903
23135
  modelJudgeConsent: external_exports.boolean().optional(),
22904
23136
  dataSharesInPlace: external_exports.boolean().optional(),
22905
- redactFallback: RedactFallback.optional()
23137
+ redactFallback: RedactFallback.optional(),
23138
+ bodyRetention: BodyRetention.optional()
22906
23139
  }).meta({ id: "ManagedSettingsValues" });
22907
23140
  var ManagedSettings = external_exports.object({
22908
23141
  specVersion: external_exports.number().int().positive().default(MANAGED_SETTINGS_SPEC_VERSION),
@@ -22910,7 +23143,21 @@ var ManagedSettings = external_exports.object({
22910
23143
  // decision from a bug. Absent renders as a generic "your organization".
22911
23144
  organization: external_exports.string().min(1).optional(),
22912
23145
  // What the administrator pinned.
22913
- values: ManagedSettingsValues.default({}),
23146
+ //
23147
+ // Parsed as a RECORD rather than as the nested schema, and split below for
23148
+ // the same reason `lockedFields` is parsed as names: a plain `z.object`
23149
+ // drops an unrecognised key and succeeds, so a pin this build does not know
23150
+ // vanished and nothing anywhere said so. A pin with no lock is a supported
23151
+ // shape — it is a DEFAULT the user may still change — so that silence hit
23152
+ // exactly the file an administrator is most likely to write while a fleet
23153
+ // is mid-upgrade.
23154
+ //
23155
+ // Splitting here rather than calling `.strict()`: strict would REFUSE the
23156
+ // file, which is the outcome the lock half already rejected — an older
23157
+ // build then runs entirely unmanaged, every pin and lock gone. A bad KNOWN
23158
+ // value still fails, because the nested schema is re-run over the known
23159
+ // subset and its issues are re-raised on this parse.
23160
+ values: external_exports.record(external_exports.string(), external_exports.unknown()).default({}),
22914
23161
  // Which of those the user may not change. A key here with no matching value
22915
23162
  // freezes whatever the user last chose; a value with no lock is a DEFAULT
22916
23163
  // the user may still override. The two are separable on purpose.
@@ -22923,17 +23170,31 @@ var ManagedSettings = external_exports.object({
22923
23170
  // the fleets most likely to carry a version skew. A name outside the enum
22924
23171
  // is still never HONOURED: the lockable set stays explicit above.
22925
23172
  lockedFields: external_exports.array(external_exports.string()).default([])
22926
- }).transform(({ lockedFields, ...rest }) => {
23173
+ }).transform(({ lockedFields, values, ...rest }, ctx) => {
22927
23174
  const known = [];
22928
23175
  const unknown2 = [];
22929
23176
  for (const name of lockedFields) {
22930
23177
  if (isManagedSettingKey(name)) known.push(name);
22931
23178
  else unknown2.push(name);
22932
23179
  }
23180
+ const knownValues = /* @__PURE__ */ Object.create(null);
23181
+ const unknownValues = [];
23182
+ for (const [name, value] of Object.entries(values)) {
23183
+ if (Object.hasOwn(ManagedSettingsValues.shape, name)) knownValues[name] = value;
23184
+ else unknownValues.push(name);
23185
+ }
23186
+ const pinned = ManagedSettingsValues.safeParse(knownValues);
23187
+ if (!pinned.success) {
23188
+ for (const issue2 of pinned.error.issues)
23189
+ ctx.addIssue({ ...issue2, path: ["values", ...issue2.path] });
23190
+ return external_exports.NEVER;
23191
+ }
22933
23192
  return {
22934
23193
  ...rest,
23194
+ values: pinned.data,
22935
23195
  lockedFields: known,
22936
- ...unknown2.length > 0 ? { unknownLockedFields: unknown2 } : {}
23196
+ ...unknown2.length > 0 ? { unknownLockedFields: unknown2 } : {},
23197
+ ...unknownValues.length > 0 ? { unknownValueFields: unknownValues } : {}
22937
23198
  };
22938
23199
  }).meta({ id: "ManagedSettings" });
22939
23200
 
@@ -23186,12 +23447,30 @@ var RecommendedActionIdParam = external_exports.object({ id: external_exports.st
23186
23447
  // ../../packages/schema/src/zod/settings-action.ts
23187
23448
  var HistorySyncConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "HistorySyncConsentChoice" });
23188
23449
  var ModelJudgeConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "ModelJudgeConsentChoice" });
23450
+ var WebChatCaptureConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "WebChatCaptureConsentChoice" });
23189
23451
  var SaveSettingsInput = external_exports.object({
23190
23452
  historicalAccess: external_exports.string(),
23191
23453
  modelJudgeConsent: ModelJudgeConsentChoice,
23192
23454
  historySyncConsent: HistorySyncConsentChoice,
23193
23455
  vaultConsent: external_exports.string(),
23194
- vaultInlineReveal: external_exports.string()
23456
+ vaultInlineReveal: external_exports.string(),
23457
+ webChatCaptureConsent: WebChatCaptureConsentChoice,
23458
+ // Widened to `string` like its neighbours rather than typed as
23459
+ // `RedactFallback`, on this module's own layering rule: shape here, VALUE at
23460
+ // the call site, so the domain check receives the type it was written for.
23461
+ //
23462
+ // NOT because a narrower schema would reject differently. `parseActionInput`
23463
+ // is a `safeParse` wrapper and throws for no field schema, so either spelling
23464
+ // reaches a recoverable `{ ok: false }` and there is no rejected promise to
23465
+ // trade against. The real cost runs the other way and is the part worth
23466
+ // knowing: a value this schema admits and the domain enum then rejects lands
23467
+ // on the action's shared refusal, which names NO field, where a shape
23468
+ // rejection reaches `malformedInput` and names the schema key.
23469
+ redactFallback: external_exports.string(),
23470
+ // Shape only, the way the enum fields above are strings only: the RANGE is
23471
+ // `BodyRetention`'s and the action checks it there, so there is one place
23472
+ // that decides what a legal horizon is rather than two that can drift.
23473
+ bodyRetention: external_exports.object({ enabled: external_exports.boolean(), retainDays: external_exports.number() })
23195
23474
  });
23196
23475
  var AttachInput = external_exports.object({
23197
23476
  endpoint: external_exports.string(),
@@ -23317,6 +23596,96 @@ var SetupHandoffOffer = external_exports.object({
23317
23596
  path: ["liveKeys"]
23318
23597
  });
23319
23598
 
23599
+ // ../../packages/schema/src/zod/web-capture.ts
23600
+ var WebUsageSource = external_exports.enum(["site", "estimated", "none"]);
23601
+ var WebUsage = external_exports.object({
23602
+ inputTokens: external_exports.number().int().nonnegative().optional(),
23603
+ outputTokens: external_exports.number().int().nonnegative().optional(),
23604
+ cacheReadInputTokens: external_exports.number().int().nonnegative().optional(),
23605
+ cacheCreationInputTokens: external_exports.number().int().nonnegative().optional()
23606
+ });
23607
+ var WebToolCall = external_exports.object({
23608
+ toolUseId: external_exports.string().min(1),
23609
+ toolName: external_exports.string().min(1),
23610
+ target: external_exports.string().optional(),
23611
+ isError: external_exports.boolean().optional(),
23612
+ inputSize: external_exports.number().int().nonnegative().optional(),
23613
+ outputSize: external_exports.number().int().nonnegative().optional()
23614
+ });
23615
+ var WebExchange = external_exports.object({
23616
+ messageId: external_exports.string().min(1),
23617
+ startedAt: external_exports.iso.datetime(),
23618
+ model: external_exports.string().optional(),
23619
+ usage: WebUsage.optional(),
23620
+ usageSource: WebUsageSource,
23621
+ stopReason: external_exports.string().optional(),
23622
+ conversationId: external_exports.string().optional(),
23623
+ turnIndex: external_exports.number().int().nonnegative().optional(),
23624
+ toolCalls: external_exports.array(WebToolCall).default([]),
23625
+ // Absent when the adapter recovered no text. Capped by the caller at
23626
+ // RESPONSE_TEXT_MAX_BYTES, so a short capture is never mistaken for a short
23627
+ // reply.
23628
+ responseText: external_exports.string().optional(),
23629
+ // The stored text is short of the reply. It does NOT say which of the two
23630
+ // ceilings on this path cut it: the caller applies its own cap on the raw
23631
+ // bytes it reads off the wire, which can be reached by a stream whose
23632
+ // recovered text stays well under RESPONSE_TEXT_MAX_BYTES, and applies that
23633
+ // one to the text. A reader cannot tell them apart, and nothing downstream
23634
+ // should branch as though it could.
23635
+ truncated: external_exports.boolean().default(false)
23636
+ });
23637
+ var WebEnforcementState = external_exports.enum([
23638
+ "watching",
23639
+ "composer-only",
23640
+ "button-only",
23641
+ "unattached",
23642
+ "unknown"
23643
+ ]);
23644
+ var RESPONSE_TEXT_MAX_BYTES = 2 * 1024 * 1024;
23645
+ var WebCaptureStatus = external_exports.object({
23646
+ patched: external_exports.boolean(),
23647
+ live: external_exports.boolean(),
23648
+ blind: external_exports.boolean(),
23649
+ sendsSeenDom: external_exports.number().int().nonnegative(),
23650
+ exchangesSeenNet: external_exports.number().int().nonnegative(),
23651
+ parseFailures: external_exports.number().int().nonnegative(),
23652
+ unparsedBodies: external_exports.number().int().nonnegative(),
23653
+ // The adapter-declared JSON key paths that were absent from a real payload —
23654
+ // the earliest signal that a site's contract moved.
23655
+ shapeMisses: external_exports.array(external_exports.string()).default([]),
23656
+ // How many `kind: 'conversation'` endpoints the reporting tab's adapter
23657
+ // compiled. Zero means this build declares none for the site, so observing
23658
+ // nothing is the design rather than a fault — the one fact that separates a
23659
+ // site nobody has surveyed yet from one whose contract moved. Defaulted so a
23660
+ // build predating the field is read as declaring nothing rather than refused.
23661
+ conversationEndpoints: external_exports.number().int().nonnegative().default(0),
23662
+ // The document that sent this report is going away. The bridge sets it on
23663
+ // its `pagehide` report and nowhere else.
23664
+ //
23665
+ // A property of the REPORT rather than of capture health, which is why
23666
+ // nothing in `deriveWebCaptureState` reads it and why it stays out of the
23667
+ // bridge's own report signature — a closing tab's last word must not be
23668
+ // suppressed for carrying the same health as the report before it. What
23669
+ // reads it is the per-site fold: a document that said it was unloading stops
23670
+ // voting on the site's state, so the reload the `blind` remediation asks for
23671
+ // can actually clear the verdict it was shown. A document that dies without
23672
+ // sending one is covered by CAPTURE_STATUS_DOCUMENT_QUIET_MS instead.
23673
+ //
23674
+ // Defaulted so a build predating the field reads as a document that never
23675
+ // said it was closing — which keeps it voting, the same as every report that
23676
+ // is not a final one.
23677
+ closed: external_exports.boolean().default(false),
23678
+ // What the DOM enforcement path is doing, which none of the counters above
23679
+ // can say: `sendsSeenDom` rises only once a send has COMPLETED, so a tab
23680
+ // whose watcher never bound reports zero exactly like a tab nobody typed in.
23681
+ // Defaulted to 'unknown' rather than 'watching' so a status from a build
23682
+ // predating the field is not read as reporting a healthy one.
23683
+ enforcement: WebEnforcementState.default("unknown")
23684
+ });
23685
+ var CAPTURE_STATUS_RECENCY_MS = 30 * 24 * 60 * 60 * 1e3;
23686
+ var CAPTURE_STATUS_RECENCY_DAYS = CAPTURE_STATUS_RECENCY_MS / (24 * 60 * 60 * 1e3);
23687
+ var CAPTURE_STATUS_DOCUMENT_QUIET_MS = 12 * 60 * 60 * 1e3;
23688
+
23320
23689
  // ../../packages/persistence/src/paths.ts
23321
23690
  import {
23322
23691
  chmodSync,
@@ -23345,6 +23714,32 @@ var STALE_PARTIAL_MS = 5 * 6e4;
23345
23714
  var SNAPSHOT_STAGING_SUFFIX = ".partial";
23346
23715
  var STAGED_NAME_SUFFIX = `.bak${SNAPSHOT_STAGING_SUFFIX}`;
23347
23716
 
23717
+ // ../../packages/persistence/src/internal/sql-functions.ts
23718
+ var utf8 = new TextDecoder();
23719
+
23720
+ // ../../packages/persistence/src/internal/outbox-lane.ts
23721
+ var OUTBOX_CAPTURE_EVENT_TYPES = ["prompt", "response", "tool_use"];
23722
+ var OUTBOX_CAPTURE_TYPE_LIST = OUTBOX_CAPTURE_EVENT_TYPES.map((t) => `'${t}'`).join(", ");
23723
+
23724
+ // ../../packages/persistence/src/sync-failure.ts
23725
+ var SYNC_FAILURE_REASONS = SyncFailureReason.options;
23726
+
23727
+ // ../../packages/persistence/src/repositories/history-sync.ts
23728
+ var STRUCTURAL_EVENT_TYPES = ["session", "llm_call", "tool_call"];
23729
+ var TYPE_LIST = STRUCTURAL_EVENT_TYPES.map((t) => `'${t}'`).join(", ");
23730
+ var COUNTED_EVENT_TYPES = [
23731
+ ...STRUCTURAL_EVENT_TYPES,
23732
+ ...OUTBOX_CAPTURE_EVENT_TYPES
23733
+ ];
23734
+ var COUNTED_TYPE_LIST = COUNTED_EVENT_TYPES.map((t) => `'${t}'`).join(", ");
23735
+ var COUNTED_SCOPE = `
23736
+ WHERE event_type IN (${COUNTED_TYPE_LIST})
23737
+ AND (
23738
+ event_type IN (${TYPE_LIST})
23739
+ OR synced_at IS NOT NULL
23740
+ OR outbox_owed = 1
23741
+ )`;
23742
+
23348
23743
  // ../../packages/persistence/src/repositories/activity.ts
23349
23744
  var LIVE_ACTIVITY_WINDOW_MS = 30 * 6e4;
23350
23745
  var DB_EVENT_TYPE_TO_KIND = {
@@ -23398,13 +23793,10 @@ var FINDING_ROW_COLUMNS_SQL = `f.id AS id, d.rule_id AS rule_id, d.category AS c
23398
23793
  e.tool_name AS tool_name,
23399
23794
  f.audit_event_id AS event_id, e.root_session_id AS session_id,
23400
23795
  e.event_type AS kind, f.finding_key AS finding_key,
23401
- ${latestResolutionStatusSql("f")} AS latest_status`;
23402
-
23403
- // ../../packages/persistence/src/repositories/history-sync.ts
23404
- var STRUCTURAL_EVENT_TYPES = ["session", "llm_call", "tool_call"];
23405
- var TYPE_LIST = STRUCTURAL_EVENT_TYPES.map((t) => `'${t}'`).join(", ");
23406
- var OUTBOX_CAPTURE_EVENT_TYPES = ["prompt", "response", "tool_use"];
23407
- var CAPTURE_TYPE_LIST = OUTBOX_CAPTURE_EVENT_TYPES.map((t) => `'${t}'`).join(", ");
23796
+ ${latestResolutionStatusSql("f")} AS latest_status,
23797
+ e.synced_at AS synced_at, e.sync_claimed_at AS sync_claimed_at,
23798
+ e.sync_failed_at AS sync_failed_at, e.sync_failure AS sync_failure,
23799
+ e.outbox_owed AS outbox_owed`;
23408
23800
 
23409
23801
  // ../../packages/persistence/src/repositories/installed-packs.ts
23410
23802
  import { createHash as createHash2, randomUUID as randomUUID4 } from "crypto";
@@ -23488,9 +23880,11 @@ import { randomUUID as randomUUID10 } from "crypto";
23488
23880
 
23489
23881
  // ../../packages/persistence/src/database.ts
23490
23882
  var CAPTURE_GRAIN = new Set(EventKind.options);
23883
+ var DEFERRED_TAGS = new Set(DEFERRED_MIGRATION_TAGS);
23491
23884
 
23492
23885
  // ../../packages/persistence/src/egress-wire.ts
23493
23886
  import { createHash as createHash3 } from "crypto";
23887
+ var SLASH = "/".charCodeAt(0);
23494
23888
 
23495
23889
  // ../../packages/persistence/src/finding-key.ts
23496
23890
  import { createHash as createHash4 } from "crypto";
@@ -23501,18 +23895,26 @@ import { existsSync as existsSync3, readFileSync as readFileSync6 } from "fs";
23501
23895
  import { join as join8 } from "path";
23502
23896
  import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
23503
23897
 
23898
+ // ../../packages/persistence/src/forward-health.ts
23899
+ import { readFileSync as readFileSync7 } from "fs";
23900
+ import { join as join9 } from "path";
23901
+
23504
23902
  // ../../packages/persistence/src/history-backfill.ts
23505
23903
  import { existsSync as existsSync4 } from "fs";
23506
- import { join as join9 } from "path";
23904
+ import { join as join10 } from "path";
23507
23905
 
23508
23906
  // ../../packages/persistence/src/history-preview.ts
23509
23907
  import { existsSync as existsSync5 } from "fs";
23510
- import { join as join10 } from "path";
23908
+ import { join as join11 } from "path";
23511
23909
  import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
23512
23910
 
23911
+ // ../../packages/persistence/src/history-sync-state.ts
23912
+ import { readFileSync as readFileSync8 } from "fs";
23913
+ import { join as join12 } from "path";
23914
+
23513
23915
  // ../../packages/persistence/src/store-symlinks.ts
23514
23916
  import { existsSync as existsSync6, lstatSync as lstatSync3, readlinkSync, realpathSync, statSync as statSync4 } from "fs";
23515
- import { dirname as dirname3, join as join11, resolve } from "path";
23917
+ import { dirname as dirname3, join as join13, resolve } from "path";
23516
23918
 
23517
23919
  // ../../packages/persistence/src/vault/crypto.ts
23518
23920
  import {
@@ -23526,15 +23928,15 @@ import {
23526
23928
  // ../../packages/persistence/src/vault/key-provider.ts
23527
23929
  import { execFileSync } from "child_process";
23528
23930
  import { randomBytes as randomBytes2 } from "crypto";
23529
- import { chmodSync as chmodSync3, readFileSync as readFileSync7, renameSync as renameSync4, rmSync as rmSync6, statSync as statSync5, writeFileSync as writeFileSync3 } from "fs";
23530
- import { join as join12 } from "path";
23931
+ import { chmodSync as chmodSync3, readFileSync as readFileSync9, renameSync as renameSync4, rmSync as rmSync6, statSync as statSync5, writeFileSync as writeFileSync3 } from "fs";
23932
+ import { join as join14 } from "path";
23531
23933
 
23532
23934
  // ../../packages/persistence/src/vault/vault.ts
23533
23935
  import { randomBytes as randomBytes3, randomUUID as randomUUID12 } from "crypto";
23534
23936
 
23535
23937
  // ../../packages/persistence/src/warn-era-cap.ts
23536
23938
  import { existsSync as existsSync7, writeFileSync as writeFileSync4 } from "fs";
23537
- import { join as join13 } from "path";
23939
+ import { join as join15 } from "path";
23538
23940
 
23539
23941
  // ../../packages/plugin-sdk/src/provider-env.ts
23540
23942
  var booleanish = external_exports.string().optional().transform((v) => {
@@ -23555,9 +23957,9 @@ var providerEnvShape = {
23555
23957
  var ProviderEnvSchema = external_exports.object(providerEnvShape);
23556
23958
 
23557
23959
  // ../../packages/plugin-sdk/src/config-inventory.ts
23558
- import { readdirSync as readdirSync2, readFileSync as readFileSync9, realpathSync as realpathSync2, statSync as statSync7 } from "fs";
23960
+ import { readdirSync as readdirSync2, readFileSync as readFileSync11, realpathSync as realpathSync2, statSync as statSync7 } from "fs";
23559
23961
  import { homedir as homedir2 } from "os";
23560
- import { basename as basename3, join as join16 } from "path";
23962
+ import { basename as basename3, join as join18 } from "path";
23561
23963
 
23562
23964
  // ../../packages/detections/src/egress/registry.ts
23563
23965
  var EXTRACTOR_VERSION = "1";
@@ -24286,6 +24688,56 @@ var CONFIG_POSTURE_RULES = [
24286
24688
  }
24287
24689
  ];
24288
24690
 
24691
+ // ../../packages/detections/src/posture/web-capture-posture.ts
24692
+ var RULE_VERSION2 = "1";
24693
+ var DRIFT_MIN_PARSE_FAILURES = 2;
24694
+ var WEB_CAPTURE_DRIFT_STATES = /* @__PURE__ */ new Set([
24695
+ "blind",
24696
+ "degraded"
24697
+ ]);
24698
+ var WEB_CAPTURE_DRIFT_RULE = {
24699
+ ruleId: "web-capture-drift",
24700
+ version: RULE_VERSION2,
24701
+ name: "Web chat capture is not reading the site",
24702
+ category: "config",
24703
+ severity: "medium",
24704
+ definition: JSON.stringify({
24705
+ kind: "web-capture-drift",
24706
+ states: [...WEB_CAPTURE_DRIFT_STATES],
24707
+ minParseFailures: DRIFT_MIN_PARSE_FAILURES
24708
+ })
24709
+ };
24710
+ var STATIC_COPY = {
24711
+ active: { headline: "turns are being observed on this site" },
24712
+ unreported: {
24713
+ // Says "recently" rather than "yet": the store read is bounded to
24714
+ // CAPTURE_STATUS_RECENCY_MS, so this state covers a site nothing has ever
24715
+ // reported for AND one whose last report has aged out. The two are the
24716
+ // same fact to a reader — nobody has confirmed anything lately — and the
24717
+ // copy may not claim the stronger of them.
24718
+ headline: `no report in the last ${String(CAPTURE_STATUS_RECENCY_DAYS)} days \u2014 open the site in Chrome with the extension loaded`
24719
+ },
24720
+ standby: {
24721
+ headline: "this build declares no endpoints for the site, so nothing is observed yet"
24722
+ },
24723
+ unpatched: {
24724
+ // Says what the flags say and no more. `patched` is false both for a tap
24725
+ // that installed and hooked neither transport and for one that never ran
24726
+ // at all — a page reports the same status either way, so the copy may not
24727
+ // assert one of them.
24728
+ headline: "the page tap captured neither fetch nor XHR \u2014 it may not have installed; reload the extension at chrome://extensions"
24729
+ },
24730
+ idle: { headline: "watching; no turn has been observed yet" },
24731
+ blind: {
24732
+ headline: "messages were sent in the page that the network capture never saw",
24733
+ remediation: "reload the tab. If it persists after `aka update` and reloading the extension at chrome://extensions, the site's send path has changed and needs a new extension build."
24734
+ },
24735
+ degraded: {
24736
+ headline: "the site's payloads no longer carry the fields the extension reads",
24737
+ remediation: "run `aka update`, then reload the extension at chrome://extensions. If it stays degraded after an update, the site's contract has changed and needs a new extension build."
24738
+ }
24739
+ };
24740
+
24289
24741
  // ../../packages/detections/src/security/redos-probe.ts
24290
24742
  var BUDGET_MS = 100;
24291
24743
  var EXPONENTIAL_UNITS = [
@@ -24315,8 +24767,8 @@ var CPU_CORROBORATION_SHARE = 0.2;
24315
24767
  var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
24316
24768
 
24317
24769
  // ../../packages/plugin-sdk/src/repo.ts
24318
- import { existsSync as existsSync9, readFileSync as readFileSync8, statSync as statSync6 } from "fs";
24319
- import { basename as basename2, dirname as dirname4, isAbsolute, join as join15, sep as sep2 } from "path";
24770
+ import { existsSync as existsSync9, readFileSync as readFileSync10, statSync as statSync6 } from "fs";
24771
+ import { basename as basename2, dirname as dirname4, isAbsolute, join as join17, sep as sep2 } from "path";
24320
24772
 
24321
24773
  // ../../packages/plugin-sdk/src/events.ts
24322
24774
  import { createHash as createHash5, randomUUID as randomUUID13 } from "crypto";
@@ -24327,8 +24779,8 @@ import { fileURLToPath } from "url";
24327
24779
  import { Worker } from "worker_threads";
24328
24780
 
24329
24781
  // ../../packages/plugin-sdk/src/host-floor.ts
24330
- import { readFileSync as readFileSync11 } from "fs";
24331
- import { join as join18 } from "path";
24782
+ import { readFileSync as readFileSync13 } from "fs";
24783
+ import { join as join20 } from "path";
24332
24784
 
24333
24785
  // ../../packages/plugin-sdk/src/model-governance.ts
24334
24786
  import {
@@ -24336,11 +24788,11 @@ import {
24336
24788
  fstatSync,
24337
24789
  mkdirSync as mkdirSync2,
24338
24790
  openSync as openSync2,
24339
- readFileSync as readFileSync10,
24791
+ readFileSync as readFileSync12,
24340
24792
  readSync,
24341
24793
  writeFileSync as writeFileSync5
24342
24794
  } from "fs";
24343
- import { join as join17 } from "path";
24795
+ import { join as join19 } from "path";
24344
24796
  var TAIL_BYTES = 256 * 1024;
24345
24797
 
24346
24798
  // ../../packages/plugin-sdk/src/host-floor.ts
@@ -24363,15 +24815,15 @@ var HOST_FLOORS = {
24363
24815
 
24364
24816
  // ../../packages/plugin-sdk/src/ignore-layers.ts
24365
24817
  var import_ignore = __toESM(require_ignore(), 1);
24366
- import { readFileSync as readFileSync12 } from "fs";
24367
- import { join as join19 } from "path";
24818
+ import { readFileSync as readFileSync14 } from "fs";
24819
+ import { join as join21 } from "path";
24368
24820
 
24369
24821
  // ../../packages/plugin-sdk/src/inventory-resolver.ts
24370
24822
  import { arch, hostname as hostname4, platform, release } from "os";
24371
24823
 
24372
24824
  // ../../packages/plugin-sdk/src/nudge.ts
24373
- import { mkdirSync as mkdirSync3, readFileSync as readFileSync13, writeFileSync as writeFileSync6 } from "fs";
24374
- import { join as join20 } from "path";
24825
+ import { mkdirSync as mkdirSync3, readFileSync as readFileSync15, writeFileSync as writeFileSync6 } from "fs";
24826
+ import { join as join22 } from "path";
24375
24827
 
24376
24828
  // ../../packages/plugin-sdk/src/paths.ts
24377
24829
  import { readdirSync as readdirSync3, realpathSync as realpathSync3 } from "fs";
@@ -24379,7 +24831,7 @@ import { basename as basename4, dirname as dirname5, sep as sep3 } from "path";
24379
24831
 
24380
24832
  // ../../packages/plugin-sdk/src/project-files.ts
24381
24833
  import { existsSync as existsSync11, readdirSync as readdirSync4 } from "fs";
24382
- import { basename as basename5, join as join21 } from "path";
24834
+ import { basename as basename5, join as join23 } from "path";
24383
24835
 
24384
24836
  // ../../packages/plugin-sdk/src/provider-env-antigravity.ts
24385
24837
  var optionalBaseUrl2 = external_exports.preprocess((v) => {
@@ -24415,11 +24867,11 @@ var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
24415
24867
 
24416
24868
  // ../../packages/plugin-sdk/src/throttle.ts
24417
24869
  import { mkdirSync as mkdirSync4, statSync as statSync8, writeFileSync as writeFileSync7 } from "fs";
24418
- import { join as join22 } from "path";
24870
+ import { join as join24 } from "path";
24419
24871
 
24420
24872
  // ../../packages/setup-wizard/src/remediation/rotation-checklist.ts
24421
24873
  import { writeFileSync as writeFileSync8 } from "fs";
24422
- import { join as join23 } from "path";
24874
+ import { join as join25 } from "path";
24423
24875
 
24424
24876
  // ../../packages/setup-wizard/src/triage/merge.ts
24425
24877
  var RANK = Object.fromEntries(
@@ -24427,9 +24879,9 @@ var RANK = Object.fromEntries(
24427
24879
  );
24428
24880
 
24429
24881
  // ../../packages/setup-wizard/src/triage/plan-file.ts
24430
- import { mkdtempSync, readFileSync as readFileSync14, rmdirSync, rmSync as rmSync7, writeFileSync as writeFileSync9 } from "fs";
24882
+ import { mkdtempSync, readFileSync as readFileSync16, rmdirSync, rmSync as rmSync7, writeFileSync as writeFileSync9 } from "fs";
24431
24883
  import { tmpdir } from "os";
24432
- import { basename as basename6, dirname as dirname6, join as join24 } from "path";
24884
+ import { basename as basename6, dirname as dirname6, join as join26 } from "path";
24433
24885
  var SuppressionEntrySchema = external_exports.object({
24434
24886
  ruleId: external_exports.string(),
24435
24887
  category: DetectionCategory,
@@ -24471,8 +24923,8 @@ var PersistedPlanSchema = external_exports.object({
24471
24923
  });
24472
24924
 
24473
24925
  // src/skills-registry.ts
24474
- import { readdirSync as readdirSync5, readFileSync as readFileSync15 } from "fs";
24475
- import { join as join25 } from "path";
24926
+ import { readdirSync as readdirSync5, readFileSync as readFileSync17 } from "fs";
24927
+ import { join as join27 } from "path";
24476
24928
  import { fileURLToPath as fileURLToPath2 } from "url";
24477
24929
  var SKILLS_DIR = fileURLToPath2(new URL("../skills", import.meta.url));
24478
24930
 
@@ -24512,7 +24964,7 @@ function authorName(author) {
24512
24964
  var manifestPath = process.argv[2];
24513
24965
  var manifest = {};
24514
24966
  try {
24515
- manifest = JSON.parse(readFileSync16(manifestPath ?? "", "utf8"));
24967
+ manifest = JSON.parse(readFileSync18(manifestPath ?? "", "utf8"));
24516
24968
  } catch {
24517
24969
  }
24518
24970
  process.stdout.write(