@akasecurity/ai-tc-claude-code 0.9.12 → 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.
@@ -20480,7 +20480,17 @@ var UNPRICEABLE_PROVIDERS = Object.freeze([
20480
20480
  "gateway",
20481
20481
  "unknown",
20482
20482
  "cli",
20483
- "api"
20483
+ "api",
20484
+ // The browser extension's native host records these as `llm_call.provider`
20485
+ // for a web-chat turn — the web tool id, deliberately never the vendor id
20486
+ // (`openai`/`anthropic`) the session root carries. Subscription traffic
20487
+ // burns rate-limit budget, not dollar credits, and listing them here is
20488
+ // what keeps that true structurally: a later maintainer who wants to price
20489
+ // web-chat traffic at API rates has to delete this entry first, and meet
20490
+ // the reason on the way, rather than quietly adding one to
20491
+ // PROVIDER_PLATFORM.
20492
+ "chatgpt",
20493
+ "claude-ai"
20484
20494
  ]);
20485
20495
  function platformForProvider(provider) {
20486
20496
  return PROVIDER_PLATFORM.get(provider.trim().toLowerCase()) ?? null;
@@ -20623,7 +20633,12 @@ var HARNESS = {
20623
20633
  ClaudeDesktop: "claudedesktop",
20624
20634
  ChatGpt: "chatgpt",
20625
20635
  ClaudeAi: "claudeai",
20626
- Api: "api"
20636
+ Api: "api",
20637
+ // Not a coding assistant a person drives — an in-process SDK embedded in an
20638
+ // application, so it has no IDE/CLI/desktop/web surface of its own. Carries
20639
+ // the same id as its SOURCE_TOOL counterpart, unlike every capture-side tool
20640
+ // whose wire spelling differs from its display spelling.
20641
+ AiTcSdk: "ai-tc-sdk"
20627
20642
  };
20628
20643
  var Harness = external_exports.enum(HARNESS).meta({ id: "Harness" });
20629
20644
  var SOURCE_TOOL = {
@@ -20639,9 +20654,15 @@ var SOURCE_TOOL = {
20639
20654
  // whose tool could not be identified both render through the read side's
20640
20655
  // miss path rather than as a harness of their own.
20641
20656
  Cli: "cli",
20642
- Unknown: "unknown"
20657
+ Unknown: "unknown",
20658
+ // The wire id an in-process, request-path SDK stamps on its own structural
20659
+ // rows (`request_decision`) — never a capture of prompt/response/tool text,
20660
+ // since the SDK sits in front of a model call rather than inside a coding
20661
+ // assistant's own hook contract.
20662
+ AiTcSdk: "ai-tc-sdk"
20643
20663
  };
20644
20664
  var SourceTool = external_exports.enum(SOURCE_TOOL).meta({ id: "SourceTool" });
20665
+ var WebSourceTool = SourceTool.extract(["ChatGpt", "ClaudeAi"]);
20645
20666
  var TOOL_TO_HARNESS = {
20646
20667
  [SOURCE_TOOL.ClaudeCode]: HARNESS.ClaudeCode,
20647
20668
  [SOURCE_TOOL.ClaudeDesktop]: HARNESS.ClaudeDesktop,
@@ -20650,7 +20671,12 @@ var TOOL_TO_HARNESS = {
20650
20671
  [SOURCE_TOOL.ChatGpt]: HARNESS.ChatGpt,
20651
20672
  [SOURCE_TOOL.Codex]: HARNESS.Codex,
20652
20673
  [SOURCE_TOOL.Antigravity]: HARNESS.Antigravity,
20653
- [SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi
20674
+ [SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi,
20675
+ // Wire and display id are the same string here, but the row still belongs:
20676
+ // both vocabularies carry the `AiTcSdk` member, and the join is exactly
20677
+ // their intersection — leaving a shared member out would read as an
20678
+ // uninstrumented tool on both surfaces, which this one is not.
20679
+ [SOURCE_TOOL.AiTcSdk]: HARNESS.AiTcSdk
20654
20680
  };
20655
20681
 
20656
20682
  // ../../packages/schema/src/zod/finding.ts
@@ -20684,7 +20710,8 @@ var FindingProvider = Harness.extract([
20684
20710
  "ClaudeAi",
20685
20711
  "Codex",
20686
20712
  "Antigravity",
20687
- "Api"
20713
+ "Api",
20714
+ "AiTcSdk"
20688
20715
  ]).meta({ id: "FindingProvider" });
20689
20716
  var FindingCategory = external_exports.enum([
20690
20717
  "secret",
@@ -21061,18 +21088,41 @@ var AuditEventType = external_exports.enum([
21061
21088
  // 'tool_call' is the reconciler's structural row for every call, while
21062
21089
  // 'tool_use' exists only where a hook enforced against the arguments.
21063
21090
  "tool_use",
21064
- // One row per model REFUSAL: a switch onto a prohibited model that was
21065
- // denied, or a turn refused because the session was already running on one.
21066
- // A structural row like the ones above rather than a capture — it carries
21067
- // the model that was refused and nothing the user typed, because what is
21068
- // worth recording about a governance decision is the decision, and prompt
21069
- // text is the thing this product exists to keep from travelling.
21091
+ // One row per model REFUSAL, across all four seams a prohibited model can be
21092
+ // stopped at: a switch onto it, a turn already running on it, a subagent
21093
+ // spawn asking for it, or a request-path refusal an embedded request-path
21094
+ // SDK makes in-process before the call leaves the application. Which seam
21095
+ // rides `attributes.refusal_seam`, never this member name. A structural row
21096
+ // like the ones above rather than a capture — it carries the model that was
21097
+ // refused and nothing the user typed, because what is worth recording about
21098
+ // a governance decision is the decision, and prompt text is the thing this
21099
+ // product exists to keep from travelling.
21070
21100
  "model_refusal",
21101
+ // One row per request-path DECISION: a policy check an embedded request-path
21102
+ // SDK performs in-process before a model call leaves the application, or
21103
+ // against that call's non-streamed response. A structural row like
21104
+ // 'model_refusal' rather than a capture — content-free in the same way:
21105
+ // which side, which seam, what action and which field are decided rides
21106
+ // `attributes`, never this member name, and the matched text itself never
21107
+ // travels.
21108
+ //
21109
+ // A prohibited-model refusal on the request path is deliberately NOT this
21110
+ // member: it stays 'model_refusal' with `refusal_seam: 'request'`, so it
21111
+ // shares one bucket with the plugin's switch/turn/spawn refusals rather
21112
+ // than splitting one governance concept across two event types. This
21113
+ // member carries every OTHER request-path decision.
21114
+ "request_decision",
21071
21115
  // One row per config-inventory scan, hung off the session root. It is the
21072
21116
  // fact the posture inspection findings reference (findings require an
21073
21117
  // audit_event_id), and its started_at is the "scanned Nm ago" the read
21074
21118
  // surface renders.
21075
- "config_scan"
21119
+ "config_scan",
21120
+ // One row per reported browser-extension capture status, hung off the web
21121
+ // session root. The durable home of what one tab's network interception
21122
+ // is doing — a write-through of the native host's in-memory tracker, so a
21123
+ // second process (aka extension status) and a restarted host both have
21124
+ // somewhere to read it back from.
21125
+ "capture_status"
21076
21126
  ]).meta({ id: "AuditEventType" });
21077
21127
  var AttributeBag = external_exports.record(external_exports.string(), external_exports.unknown());
21078
21128
  var HostAttributes = external_exports.object({
@@ -21232,6 +21282,20 @@ var CaptureAttributes = external_exports.object({
21232
21282
  // repeated rather than referenced because a store reader opens this file.
21233
21283
  redact_degraded_to: ActionTaken.optional()
21234
21284
  }).catchall(external_exports.unknown());
21285
+ var CaptureStatusAttributes = external_exports.object({
21286
+ source_tool: external_exports.string().optional(),
21287
+ patched: external_exports.boolean().optional(),
21288
+ live: external_exports.boolean().optional(),
21289
+ blind: external_exports.boolean().optional(),
21290
+ sends_seen_dom: external_exports.number().int().nonnegative().optional(),
21291
+ exchanges_seen_net: external_exports.number().int().nonnegative().optional(),
21292
+ parse_failures: external_exports.number().int().nonnegative().optional(),
21293
+ unparsed_bodies: external_exports.number().int().nonnegative().optional(),
21294
+ shape_misses: external_exports.array(external_exports.string()).optional(),
21295
+ conversation_endpoints: external_exports.number().int().nonnegative().optional(),
21296
+ closed: external_exports.boolean().optional(),
21297
+ enforcement: external_exports.string().optional()
21298
+ }).catchall(external_exports.unknown());
21235
21299
  var ToolCallInspection = external_exports.object({
21236
21300
  ruleId: external_exports.string().min(1),
21237
21301
  ruleName: external_exports.string(),
@@ -22244,6 +22308,11 @@ var RemoteFailureKind = external_exports.enum([
22244
22308
  "rejected",
22245
22309
  "unreachable"
22246
22310
  ]);
22311
+ var ControlPlaneFailure = RemoteFailureKind.extract([
22312
+ "unauthorized",
22313
+ "forbidden",
22314
+ "unreachable"
22315
+ ]);
22247
22316
  var AttachDeviceRequest = external_exports.object({
22248
22317
  // This machine's own continuity id, so re-attaching ROTATES the credential
22249
22318
  // on one machine record instead of producing a second one. Client-minted
@@ -22783,7 +22852,12 @@ var EventMetadata = external_exports.object({
22783
22852
  // in — set by the browser extension's network capture so a stored `response`
22784
22853
  // row can be joined to the `llm_call` leaf describing the same turn. Absent
22785
22854
  // on every other capture path, which has no such id.
22786
- messageId: external_exports.string().optional(),
22855
+ //
22856
+ // Non-empty for the reason WebExchange.messageId is: it is the join key, and
22857
+ // a blank one matches no `llm_call` leaf. That refusal reaches only the
22858
+ // places an event is PARSED; the local write path types the event and parses
22859
+ // nothing, which is why `toCaptureAttributes` omits a blank one separately.
22860
+ messageId: external_exports.string().min(1).optional(),
22787
22861
  conversationId: external_exports.string().optional(),
22788
22862
  // How long THIS capture's inspection blocked its caller, in whole
22789
22863
  // milliseconds — the plugin's own added latency, NOT the LLM call it sat in
@@ -23858,6 +23932,18 @@ var HistorySyncConsent = external_exports.object({
23858
23932
  payloadVersion: external_exports.number().int().positive(),
23859
23933
  endpoint: external_exports.string()
23860
23934
  });
23935
+ var WebChatCaptureConsent = external_exports.object({
23936
+ acknowledgedAt: external_exports.iso.datetime(),
23937
+ version: external_exports.number().int().positive()
23938
+ });
23939
+ var WebChatResponseCapture = external_exports.enum(["with-findings", "always", "never"]);
23940
+ var WebChatCapture = external_exports.object({
23941
+ responses: WebChatResponseCapture.default("with-findings"),
23942
+ account: external_exports.boolean().default(false),
23943
+ // Absent until granted. Presence alone does not authorize anything — see
23944
+ // isWebChatCaptureConsentValid.
23945
+ consent: WebChatCaptureConsent.optional()
23946
+ });
23861
23947
  var BODY_RETENTION_DEFAULT_DAYS = 30;
23862
23948
  var BodyRetention = external_exports.object({
23863
23949
  enabled: external_exports.boolean().default(false),
@@ -23916,6 +24002,16 @@ var WorkspaceSettings = external_exports.object({
23916
24002
  // both widenings. Absent until granted, and a grant for a different endpoint
23917
24003
  // or an older payload no longer counts.
23918
24004
  historySyncConsent: HistorySyncConsent.optional(),
24005
+ // What the browser extension may record from a web chat, and the grant that
24006
+ // authorizes it. Absent until the user answers: recording something that was
24007
+ // never recorded before is never an assumed grant on upgrade, so the whole
24008
+ // block is optional rather than defaulted in. What an absent block means is
24009
+ // webChatCaptureOf's answer, in one place.
24010
+ //
24011
+ // Enforcement is NOT gated on this. A machine that has never answered still
24012
+ // blocks, redacts and warns on what a user sends; the grant covers what is
24013
+ // written down.
24014
+ webChatCapture: WebChatCapture.optional(),
23919
24015
  // Local body expiry (see BodyRetention). Off until switched on; expiring a
23920
24016
  // body never removes the row or its findings.
23921
24017
  bodyRetention: BodyRetention.default({
@@ -24023,7 +24119,10 @@ function toCaptureAttributes(event) {
24023
24119
  // `.catchall(z.unknown())` carries the long tail.
24024
24120
  ...metadata?.model !== void 0 ? { model: metadata.model } : {},
24025
24121
  ...metadata?.turnIndex !== void 0 ? { turn_index: metadata.turnIndex } : {},
24026
- ...metadata?.messageId !== void 0 ? { message_id: metadata.messageId } : {},
24122
+ // A blank id is omitted rather than stored: it is a join key and `''` joins
24123
+ // nothing. This runs on the local write path, which types the event but
24124
+ // never parses it, so EventMetadata's own `.min(1)` does not reach here.
24125
+ ...metadata?.messageId !== void 0 && metadata.messageId !== "" ? { message_id: metadata.messageId } : {},
24027
24126
  ...metadata?.conversationId !== void 0 ? { conversation_id: metadata.conversationId } : {}
24028
24127
  };
24029
24128
  }
@@ -24397,12 +24496,14 @@ var RecommendedActionIdParam = external_exports.object({ id: external_exports.st
24397
24496
  // ../../packages/schema/src/zod/settings-action.ts
24398
24497
  var HistorySyncConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "HistorySyncConsentChoice" });
24399
24498
  var ModelJudgeConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "ModelJudgeConsentChoice" });
24499
+ var WebChatCaptureConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "WebChatCaptureConsentChoice" });
24400
24500
  var SaveSettingsInput = external_exports.object({
24401
24501
  historicalAccess: external_exports.string(),
24402
24502
  modelJudgeConsent: ModelJudgeConsentChoice,
24403
24503
  historySyncConsent: HistorySyncConsentChoice,
24404
24504
  vaultConsent: external_exports.string(),
24405
24505
  vaultInlineReveal: external_exports.string(),
24506
+ webChatCaptureConsent: WebChatCaptureConsentChoice,
24406
24507
  // Widened to `string` like its neighbours rather than typed as
24407
24508
  // `RedactFallback`, on this module's own layering rule: shape here, VALUE at
24408
24509
  // the call site, so the domain check receives the type it was written for.
@@ -24617,11 +24718,24 @@ var WebExchange = external_exports.object({
24617
24718
  turnIndex: external_exports.number().int().nonnegative().optional(),
24618
24719
  toolCalls: external_exports.array(WebToolCall).default([]),
24619
24720
  // Absent when the adapter recovered no text. Capped by the caller at
24620
- // RESPONSE_TEXT_MAX_BYTES; `truncated` records that the cap was reached, so a
24621
- // short capture is never mistaken for a short reply.
24721
+ // RESPONSE_TEXT_MAX_BYTES, so a short capture is never mistaken for a short
24722
+ // reply.
24622
24723
  responseText: external_exports.string().optional(),
24724
+ // The stored text is short of the reply. It does NOT say which of the two
24725
+ // ceilings on this path cut it: the caller applies its own cap on the raw
24726
+ // bytes it reads off the wire, which can be reached by a stream whose
24727
+ // recovered text stays well under RESPONSE_TEXT_MAX_BYTES, and applies that
24728
+ // one to the text. A reader cannot tell them apart, and nothing downstream
24729
+ // should branch as though it could.
24623
24730
  truncated: external_exports.boolean().default(false)
24624
24731
  });
24732
+ var WebEnforcementState = external_exports.enum([
24733
+ "watching",
24734
+ "composer-only",
24735
+ "button-only",
24736
+ "unattached",
24737
+ "unknown"
24738
+ ]);
24625
24739
  var RESPONSE_TEXT_MAX_BYTES = 2 * 1024 * 1024;
24626
24740
  var WebCaptureStatus = external_exports.object({
24627
24741
  patched: external_exports.boolean(),
@@ -24633,8 +24747,66 @@ var WebCaptureStatus = external_exports.object({
24633
24747
  unparsedBodies: external_exports.number().int().nonnegative(),
24634
24748
  // The adapter-declared JSON key paths that were absent from a real payload —
24635
24749
  // the earliest signal that a site's contract moved.
24636
- shapeMisses: external_exports.array(external_exports.string()).default([])
24637
- });
24750
+ shapeMisses: external_exports.array(external_exports.string()).default([]),
24751
+ // How many `kind: 'conversation'` endpoints the reporting tab's adapter
24752
+ // compiled. Zero means this build declares none for the site, so observing
24753
+ // nothing is the design rather than a fault — the one fact that separates a
24754
+ // site nobody has surveyed yet from one whose contract moved. Defaulted so a
24755
+ // build predating the field is read as declaring nothing rather than refused.
24756
+ conversationEndpoints: external_exports.number().int().nonnegative().default(0),
24757
+ // The document that sent this report is going away. The bridge sets it on
24758
+ // its `pagehide` report and nowhere else.
24759
+ //
24760
+ // A property of the REPORT rather than of capture health, which is why
24761
+ // nothing in `deriveWebCaptureState` reads it and why it stays out of the
24762
+ // bridge's own report signature — a closing tab's last word must not be
24763
+ // suppressed for carrying the same health as the report before it. What
24764
+ // reads it is the per-site fold: a document that said it was unloading stops
24765
+ // voting on the site's state, so the reload the `blind` remediation asks for
24766
+ // can actually clear the verdict it was shown. A document that dies without
24767
+ // sending one is covered by CAPTURE_STATUS_DOCUMENT_QUIET_MS instead.
24768
+ //
24769
+ // Defaulted so a build predating the field reads as a document that never
24770
+ // said it was closing — which keeps it voting, the same as every report that
24771
+ // is not a final one.
24772
+ closed: external_exports.boolean().default(false),
24773
+ // What the DOM enforcement path is doing, which none of the counters above
24774
+ // can say: `sendsSeenDom` rises only once a send has COMPLETED, so a tab
24775
+ // whose watcher never bound reports zero exactly like a tab nobody typed in.
24776
+ // Defaulted to 'unknown' rather than 'watching' so a status from a build
24777
+ // predating the field is not read as reporting a healthy one.
24778
+ enforcement: WebEnforcementState.default("unknown")
24779
+ });
24780
+ function webCaptureStatusObservedTurnPath(status) {
24781
+ if (!status.patched) return true;
24782
+ if (status.conversationEndpoints === 0) return true;
24783
+ return status.blind || status.shapeMisses.length > 0 || status.parseFailures > 0 || status.unparsedBodies > 0 || status.exchangesSeenNet > 0;
24784
+ }
24785
+ function pickReportedCaptureStatus(candidates) {
24786
+ return candidates.find((c) => webCaptureStatusObservedTurnPath(c.status)) ?? candidates[0];
24787
+ }
24788
+ var CAPTURE_STATUS_RECENCY_MS = 30 * 24 * 60 * 60 * 1e3;
24789
+ var CAPTURE_STATUS_RECENCY_DAYS = CAPTURE_STATUS_RECENCY_MS / (24 * 60 * 60 * 1e3);
24790
+ var CAPTURE_STATUS_DOCUMENT_QUIET_MS = 12 * 60 * 60 * 1e3;
24791
+ function fromCaptureStatusAttributes(bag) {
24792
+ const parsedBag = CaptureStatusAttributes.safeParse(bag);
24793
+ if (!parsedBag.success) return null;
24794
+ const b = parsedBag.data;
24795
+ const parsedStatus = WebCaptureStatus.safeParse({
24796
+ patched: b.patched,
24797
+ live: b.live,
24798
+ blind: b.blind,
24799
+ sendsSeenDom: b.sends_seen_dom,
24800
+ exchangesSeenNet: b.exchanges_seen_net,
24801
+ parseFailures: b.parse_failures,
24802
+ unparsedBodies: b.unparsed_bodies,
24803
+ shapeMisses: b.shape_misses,
24804
+ conversationEndpoints: b.conversation_endpoints,
24805
+ closed: b.closed,
24806
+ enforcement: b.enforcement
24807
+ });
24808
+ return parsedStatus.success ? parsedStatus.data : null;
24809
+ }
24638
24810
 
24639
24811
  // ../../packages/persistence/src/paths.ts
24640
24812
  import {
@@ -26477,7 +26649,7 @@ var SESSION_ROOT = `event_type = 'session'`;
26477
26649
  var HAS_ACTIVITY = `EXISTS (
26478
26650
  SELECT 1 FROM audit_events c
26479
26651
  WHERE c.root_session_id = audit_events.id
26480
- AND c.event_type NOT IN ('hook', 'config_scan'))`;
26652
+ AND c.event_type NOT IN ('hook', 'config_scan', 'capture_status'))`;
26481
26653
  var SqliteActivityRepository = class {
26482
26654
  constructor(db, now = () => Date.now()) {
26483
26655
  this.db = db;
@@ -26504,10 +26676,10 @@ var SqliteActivityRepository = class {
26504
26676
  SELECT id FROM audit_events WHERE event_type = 'session' AND started_at >= ?
26505
26677
  UNION
26506
26678
  SELECT root_session_id FROM audit_events INDEXED BY idx_audit_started_at
26507
- WHERE started_at >= ?
26679
+ WHERE started_at >= ? AND event_type <> 'capture_status'
26508
26680
  UNION
26509
26681
  SELECT root_session_id FROM audit_events INDEXED BY idx_audit_ended_at
26510
- WHERE ended_at >= ?)`,
26682
+ WHERE ended_at >= ? AND event_type <> 'capture_status')`,
26511
26683
  [liveThreshold, liveThreshold, liveThreshold]
26512
26684
  );
26513
26685
  const toolCallsToday = countScalar(
@@ -26914,7 +27086,10 @@ var SqliteAuditEventsRepository = class {
26914
27086
  attributes = excluded.attributes,
26915
27087
  ended_at = excluded.ended_at
26916
27088
  WHERE COALESCE(json_extract(excluded.attributes, '$.output_tokens'), 0)
26917
- > COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)`
27089
+ > COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
27090
+ OR (json_extract(excluded.attributes, '$.usage_source') IS NOT NULL
27091
+ AND json_extract(excluded.attributes, '$.output_tokens') IS NULL
27092
+ AND excluded.attributes <> audit_events.attributes)`
26918
27093
  );
26919
27094
  this.upsertSessionRootStmt = db.prepare(
26920
27095
  `INSERT OR IGNORE INTO audit_events
@@ -27182,6 +27357,87 @@ var SqliteBodyRetentionRepository = class {
27182
27357
  }
27183
27358
  };
27184
27359
 
27360
+ // ../../packages/persistence/src/repositories/capture-status.ts
27361
+ var STATUS_LOOKBACK_ROWS = 128;
27362
+ var SqliteCaptureStatusRepository = class {
27363
+ constructor(db) {
27364
+ this.db = db;
27365
+ this.recentStmt = db.prepare(
27366
+ `SELECT a.started_at AS startedAt,
27367
+ a.attributes AS attributes,
27368
+ a.root_session_id AS rootSessionId
27369
+ FROM audit_events a
27370
+ WHERE a.event_type = 'capture_status'
27371
+ AND a.source_tool = ?
27372
+ AND a.started_at >= ?
27373
+ ORDER BY a.started_at DESC, a.id DESC
27374
+ LIMIT ?`
27375
+ );
27376
+ }
27377
+ db;
27378
+ recentStmt;
27379
+ /**
27380
+ * Every document that reported for a site, in registry order by site, from
27381
+ * the last `CAPTURE_STATUS_RECENCY_MS`.
27382
+ *
27383
+ * SEVERAL per site, not one: a browser is many documents and each reports
27384
+ * for itself, so one row per site is a choice about which of them a user
27385
+ * sees — and the newest is the wrong one, since a healthy tab writing a
27386
+ * fresh report would hide a drifting tab's verdict, which is the whole
27387
+ * reason these rows exist. The pick WITHIN a document is made here (the
27388
+ * unchanged `pickReportedCaptureStatus`, over that document's own rows);
27389
+ * choosing between documents belongs where the state semantics live, and
27390
+ * that is `reportedCaptureDocumentForSite` in `@akasecurity/detections` —
27391
+ * this package may not import it.
27392
+ *
27393
+ * `now` is a required argument rather than a `Date.now()` read, so a caller
27394
+ * that already holds a render instant passes THAT one and a test can drive
27395
+ * the window without moving the wall clock.
27396
+ *
27397
+ * A site whose reports have all aged out contributes nothing, so it derives
27398
+ * to `unreported`. That is the point: nothing but the browser extension ever
27399
+ * writes these rows, so an uninstalled extension's last verdict would
27400
+ * otherwise stand as a live claim for ever with no later report able to
27401
+ * clear it.
27402
+ */
27403
+ latest(now) {
27404
+ const since = now - CAPTURE_STATUS_RECENCY_MS;
27405
+ const documents = [];
27406
+ for (const tool of WebSourceTool.options) {
27407
+ const rows = /* @__PURE__ */ new Map();
27408
+ const lastWord = /* @__PURE__ */ new Map();
27409
+ for (const row of allRows(this.recentStmt, [
27410
+ tool,
27411
+ since,
27412
+ STATUS_LOOKBACK_ROWS
27413
+ ])) {
27414
+ const status = fromCaptureStatusAttributes(parseJsonObject(row.attributes));
27415
+ if (status === null) continue;
27416
+ const record2 = { tool, observedAt: epochMillisToIso(row.startedAt), status };
27417
+ const group = rows.get(row.rootSessionId);
27418
+ if (group === void 0) {
27419
+ rows.set(row.rootSessionId, [record2]);
27420
+ lastWord.set(row.rootSessionId, { at: record2.observedAt, closed: status.closed });
27421
+ } else {
27422
+ group.push(record2);
27423
+ }
27424
+ }
27425
+ for (const [root, candidates] of rows) {
27426
+ const picked = pickReportedCaptureStatus(candidates);
27427
+ const last = lastWord.get(root);
27428
+ if (picked === void 0 || last === void 0) continue;
27429
+ documents.push({
27430
+ ...picked,
27431
+ ...root === null ? {} : { rootSessionId: root },
27432
+ lastReportAt: last.at,
27433
+ closed: last.closed
27434
+ });
27435
+ }
27436
+ }
27437
+ return documents;
27438
+ }
27439
+ };
27440
+
27185
27441
  // ../../packages/persistence/src/repositories/classified-data.ts
27186
27442
  var SqliteClassifiedDataRepository = class {
27187
27443
  constructor(db) {
@@ -32758,6 +33014,7 @@ function openAndInitialize(file2, base, skipTags) {
32758
33014
  activity: new SqliteActivityRepository(db),
32759
33015
  sourceProject: new SqliteSourceProjectRepository(db),
32760
33016
  auditEvents: new SqliteAuditEventsRepository(db),
33017
+ captureStatus: new SqliteCaptureStatusRepository(db),
32761
33018
  classifiedData: new SqliteClassifiedDataRepository(db),
32762
33019
  inspectionDefinitions: new SqliteInspectionDefinitionsRepository(db),
32763
33020
  inspectionFindings: new SqliteInspectionFindingsRepository(db),
@@ -32798,6 +33055,7 @@ function openLocalDatabase(dir, options = {}) {
32798
33055
  activity,
32799
33056
  sourceProject,
32800
33057
  auditEvents,
33058
+ captureStatus,
32801
33059
  classifiedData,
32802
33060
  inspectionDefinitions,
32803
33061
  inspectionFindings,
@@ -33015,6 +33273,7 @@ function openLocalDatabase(dir, options = {}) {
33015
33273
  activity,
33016
33274
  sourceProject,
33017
33275
  auditEvents,
33276
+ captureStatus,
33018
33277
  classifiedData,
33019
33278
  inspectionDefinitions,
33020
33279
  inspectionFindings,
@@ -35134,6 +35393,56 @@ var CONFIG_POSTURE_RULES = [
35134
35393
  }
35135
35394
  ];
35136
35395
 
35396
+ // ../../packages/detections/src/posture/web-capture-posture.ts
35397
+ var RULE_VERSION2 = "1";
35398
+ var DRIFT_MIN_PARSE_FAILURES = 2;
35399
+ var WEB_CAPTURE_DRIFT_STATES = /* @__PURE__ */ new Set([
35400
+ "blind",
35401
+ "degraded"
35402
+ ]);
35403
+ var WEB_CAPTURE_DRIFT_RULE = {
35404
+ ruleId: "web-capture-drift",
35405
+ version: RULE_VERSION2,
35406
+ name: "Web chat capture is not reading the site",
35407
+ category: "config",
35408
+ severity: "medium",
35409
+ definition: JSON.stringify({
35410
+ kind: "web-capture-drift",
35411
+ states: [...WEB_CAPTURE_DRIFT_STATES],
35412
+ minParseFailures: DRIFT_MIN_PARSE_FAILURES
35413
+ })
35414
+ };
35415
+ var STATIC_COPY = {
35416
+ active: { headline: "turns are being observed on this site" },
35417
+ unreported: {
35418
+ // Says "recently" rather than "yet": the store read is bounded to
35419
+ // CAPTURE_STATUS_RECENCY_MS, so this state covers a site nothing has ever
35420
+ // reported for AND one whose last report has aged out. The two are the
35421
+ // same fact to a reader — nobody has confirmed anything lately — and the
35422
+ // copy may not claim the stronger of them.
35423
+ headline: `no report in the last ${String(CAPTURE_STATUS_RECENCY_DAYS)} days \u2014 open the site in Chrome with the extension loaded`
35424
+ },
35425
+ standby: {
35426
+ headline: "this build declares no endpoints for the site, so nothing is observed yet"
35427
+ },
35428
+ unpatched: {
35429
+ // Says what the flags say and no more. `patched` is false both for a tap
35430
+ // that installed and hooked neither transport and for one that never ran
35431
+ // at all — a page reports the same status either way, so the copy may not
35432
+ // assert one of them.
35433
+ headline: "the page tap captured neither fetch nor XHR \u2014 it may not have installed; reload the extension at chrome://extensions"
35434
+ },
35435
+ idle: { headline: "watching; no turn has been observed yet" },
35436
+ blind: {
35437
+ headline: "messages were sent in the page that the network capture never saw",
35438
+ 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."
35439
+ },
35440
+ degraded: {
35441
+ headline: "the site's payloads no longer carry the fields the extension reads",
35442
+ 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."
35443
+ }
35444
+ };
35445
+
35137
35446
  // ../../packages/detections/src/security/redos-probe.ts
35138
35447
  var BUDGET_MS = 100;
35139
35448
  var EXPONENTIAL_UNITS = [