@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.
@@ -20476,7 +20476,17 @@ var UNPRICEABLE_PROVIDERS = Object.freeze([
20476
20476
  "gateway",
20477
20477
  "unknown",
20478
20478
  "cli",
20479
- "api"
20479
+ "api",
20480
+ // The browser extension's native host records these as `llm_call.provider`
20481
+ // for a web-chat turn — the web tool id, deliberately never the vendor id
20482
+ // (`openai`/`anthropic`) the session root carries. Subscription traffic
20483
+ // burns rate-limit budget, not dollar credits, and listing them here is
20484
+ // what keeps that true structurally: a later maintainer who wants to price
20485
+ // web-chat traffic at API rates has to delete this entry first, and meet
20486
+ // the reason on the way, rather than quietly adding one to
20487
+ // PROVIDER_PLATFORM.
20488
+ "chatgpt",
20489
+ "claude-ai"
20480
20490
  ]);
20481
20491
  function platformForProvider(provider) {
20482
20492
  return PROVIDER_PLATFORM.get(provider.trim().toLowerCase()) ?? null;
@@ -20619,7 +20629,12 @@ var HARNESS = {
20619
20629
  ClaudeDesktop: "claudedesktop",
20620
20630
  ChatGpt: "chatgpt",
20621
20631
  ClaudeAi: "claudeai",
20622
- Api: "api"
20632
+ Api: "api",
20633
+ // Not a coding assistant a person drives — an in-process SDK embedded in an
20634
+ // application, so it has no IDE/CLI/desktop/web surface of its own. Carries
20635
+ // the same id as its SOURCE_TOOL counterpart, unlike every capture-side tool
20636
+ // whose wire spelling differs from its display spelling.
20637
+ AiTcSdk: "ai-tc-sdk"
20623
20638
  };
20624
20639
  var Harness = external_exports.enum(HARNESS).meta({ id: "Harness" });
20625
20640
  var SOURCE_TOOL = {
@@ -20635,9 +20650,15 @@ var SOURCE_TOOL = {
20635
20650
  // whose tool could not be identified both render through the read side's
20636
20651
  // miss path rather than as a harness of their own.
20637
20652
  Cli: "cli",
20638
- Unknown: "unknown"
20653
+ Unknown: "unknown",
20654
+ // The wire id an in-process, request-path SDK stamps on its own structural
20655
+ // rows (`request_decision`) — never a capture of prompt/response/tool text,
20656
+ // since the SDK sits in front of a model call rather than inside a coding
20657
+ // assistant's own hook contract.
20658
+ AiTcSdk: "ai-tc-sdk"
20639
20659
  };
20640
20660
  var SourceTool = external_exports.enum(SOURCE_TOOL).meta({ id: "SourceTool" });
20661
+ var WebSourceTool = SourceTool.extract(["ChatGpt", "ClaudeAi"]);
20641
20662
  var TOOL_TO_HARNESS = {
20642
20663
  [SOURCE_TOOL.ClaudeCode]: HARNESS.ClaudeCode,
20643
20664
  [SOURCE_TOOL.ClaudeDesktop]: HARNESS.ClaudeDesktop,
@@ -20646,7 +20667,12 @@ var TOOL_TO_HARNESS = {
20646
20667
  [SOURCE_TOOL.ChatGpt]: HARNESS.ChatGpt,
20647
20668
  [SOURCE_TOOL.Codex]: HARNESS.Codex,
20648
20669
  [SOURCE_TOOL.Antigravity]: HARNESS.Antigravity,
20649
- [SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi
20670
+ [SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi,
20671
+ // Wire and display id are the same string here, but the row still belongs:
20672
+ // both vocabularies carry the `AiTcSdk` member, and the join is exactly
20673
+ // their intersection — leaving a shared member out would read as an
20674
+ // uninstrumented tool on both surfaces, which this one is not.
20675
+ [SOURCE_TOOL.AiTcSdk]: HARNESS.AiTcSdk
20650
20676
  };
20651
20677
 
20652
20678
  // ../../packages/schema/src/zod/finding.ts
@@ -20680,7 +20706,8 @@ var FindingProvider = Harness.extract([
20680
20706
  "ClaudeAi",
20681
20707
  "Codex",
20682
20708
  "Antigravity",
20683
- "Api"
20709
+ "Api",
20710
+ "AiTcSdk"
20684
20711
  ]).meta({ id: "FindingProvider" });
20685
20712
  var FindingCategory = external_exports.enum([
20686
20713
  "secret",
@@ -21057,18 +21084,41 @@ var AuditEventType = external_exports.enum([
21057
21084
  // 'tool_call' is the reconciler's structural row for every call, while
21058
21085
  // 'tool_use' exists only where a hook enforced against the arguments.
21059
21086
  "tool_use",
21060
- // One row per model REFUSAL: a switch onto a prohibited model that was
21061
- // denied, or a turn refused because the session was already running on one.
21062
- // A structural row like the ones above rather than a capture — it carries
21063
- // the model that was refused and nothing the user typed, because what is
21064
- // worth recording about a governance decision is the decision, and prompt
21065
- // text is the thing this product exists to keep from travelling.
21087
+ // One row per model REFUSAL, across all four seams a prohibited model can be
21088
+ // stopped at: a switch onto it, a turn already running on it, a subagent
21089
+ // spawn asking for it, or a request-path refusal an embedded request-path
21090
+ // SDK makes in-process before the call leaves the application. Which seam
21091
+ // rides `attributes.refusal_seam`, never this member name. A structural row
21092
+ // like the ones above rather than a capture — it carries the model that was
21093
+ // refused and nothing the user typed, because what is worth recording about
21094
+ // a governance decision is the decision, and prompt text is the thing this
21095
+ // product exists to keep from travelling.
21066
21096
  "model_refusal",
21097
+ // One row per request-path DECISION: a policy check an embedded request-path
21098
+ // SDK performs in-process before a model call leaves the application, or
21099
+ // against that call's non-streamed response. A structural row like
21100
+ // 'model_refusal' rather than a capture — content-free in the same way:
21101
+ // which side, which seam, what action and which field are decided rides
21102
+ // `attributes`, never this member name, and the matched text itself never
21103
+ // travels.
21104
+ //
21105
+ // A prohibited-model refusal on the request path is deliberately NOT this
21106
+ // member: it stays 'model_refusal' with `refusal_seam: 'request'`, so it
21107
+ // shares one bucket with the plugin's switch/turn/spawn refusals rather
21108
+ // than splitting one governance concept across two event types. This
21109
+ // member carries every OTHER request-path decision.
21110
+ "request_decision",
21067
21111
  // One row per config-inventory scan, hung off the session root. It is the
21068
21112
  // fact the posture inspection findings reference (findings require an
21069
21113
  // audit_event_id), and its started_at is the "scanned Nm ago" the read
21070
21114
  // surface renders.
21071
- "config_scan"
21115
+ "config_scan",
21116
+ // One row per reported browser-extension capture status, hung off the web
21117
+ // session root. The durable home of what one tab's network interception
21118
+ // is doing — a write-through of the native host's in-memory tracker, so a
21119
+ // second process (aka extension status) and a restarted host both have
21120
+ // somewhere to read it back from.
21121
+ "capture_status"
21072
21122
  ]).meta({ id: "AuditEventType" });
21073
21123
  var AttributeBag = external_exports.record(external_exports.string(), external_exports.unknown());
21074
21124
  var HostAttributes = external_exports.object({
@@ -21228,6 +21278,20 @@ var CaptureAttributes = external_exports.object({
21228
21278
  // repeated rather than referenced because a store reader opens this file.
21229
21279
  redact_degraded_to: ActionTaken.optional()
21230
21280
  }).catchall(external_exports.unknown());
21281
+ var CaptureStatusAttributes = external_exports.object({
21282
+ source_tool: external_exports.string().optional(),
21283
+ patched: external_exports.boolean().optional(),
21284
+ live: external_exports.boolean().optional(),
21285
+ blind: external_exports.boolean().optional(),
21286
+ sends_seen_dom: external_exports.number().int().nonnegative().optional(),
21287
+ exchanges_seen_net: external_exports.number().int().nonnegative().optional(),
21288
+ parse_failures: external_exports.number().int().nonnegative().optional(),
21289
+ unparsed_bodies: external_exports.number().int().nonnegative().optional(),
21290
+ shape_misses: external_exports.array(external_exports.string()).optional(),
21291
+ conversation_endpoints: external_exports.number().int().nonnegative().optional(),
21292
+ closed: external_exports.boolean().optional(),
21293
+ enforcement: external_exports.string().optional()
21294
+ }).catchall(external_exports.unknown());
21231
21295
  var ToolCallInspection = external_exports.object({
21232
21296
  ruleId: external_exports.string().min(1),
21233
21297
  ruleName: external_exports.string(),
@@ -22240,6 +22304,11 @@ var RemoteFailureKind = external_exports.enum([
22240
22304
  "rejected",
22241
22305
  "unreachable"
22242
22306
  ]);
22307
+ var ControlPlaneFailure = RemoteFailureKind.extract([
22308
+ "unauthorized",
22309
+ "forbidden",
22310
+ "unreachable"
22311
+ ]);
22243
22312
  var AttachDeviceRequest = external_exports.object({
22244
22313
  // This machine's own continuity id, so re-attaching ROTATES the credential
22245
22314
  // on one machine record instead of producing a second one. Client-minted
@@ -22779,7 +22848,12 @@ var EventMetadata = external_exports.object({
22779
22848
  // in — set by the browser extension's network capture so a stored `response`
22780
22849
  // row can be joined to the `llm_call` leaf describing the same turn. Absent
22781
22850
  // on every other capture path, which has no such id.
22782
- messageId: external_exports.string().optional(),
22851
+ //
22852
+ // Non-empty for the reason WebExchange.messageId is: it is the join key, and
22853
+ // a blank one matches no `llm_call` leaf. That refusal reaches only the
22854
+ // places an event is PARSED; the local write path types the event and parses
22855
+ // nothing, which is why `toCaptureAttributes` omits a blank one separately.
22856
+ messageId: external_exports.string().min(1).optional(),
22783
22857
  conversationId: external_exports.string().optional(),
22784
22858
  // How long THIS capture's inspection blocked its caller, in whole
22785
22859
  // milliseconds — the plugin's own added latency, NOT the LLM call it sat in
@@ -23843,6 +23917,18 @@ var HistorySyncConsent = external_exports.object({
23843
23917
  payloadVersion: external_exports.number().int().positive(),
23844
23918
  endpoint: external_exports.string()
23845
23919
  });
23920
+ var WebChatCaptureConsent = external_exports.object({
23921
+ acknowledgedAt: external_exports.iso.datetime(),
23922
+ version: external_exports.number().int().positive()
23923
+ });
23924
+ var WebChatResponseCapture = external_exports.enum(["with-findings", "always", "never"]);
23925
+ var WebChatCapture = external_exports.object({
23926
+ responses: WebChatResponseCapture.default("with-findings"),
23927
+ account: external_exports.boolean().default(false),
23928
+ // Absent until granted. Presence alone does not authorize anything — see
23929
+ // isWebChatCaptureConsentValid.
23930
+ consent: WebChatCaptureConsent.optional()
23931
+ });
23846
23932
  var BODY_RETENTION_DEFAULT_DAYS = 30;
23847
23933
  var BodyRetention = external_exports.object({
23848
23934
  enabled: external_exports.boolean().default(false),
@@ -23901,6 +23987,16 @@ var WorkspaceSettings = external_exports.object({
23901
23987
  // both widenings. Absent until granted, and a grant for a different endpoint
23902
23988
  // or an older payload no longer counts.
23903
23989
  historySyncConsent: HistorySyncConsent.optional(),
23990
+ // What the browser extension may record from a web chat, and the grant that
23991
+ // authorizes it. Absent until the user answers: recording something that was
23992
+ // never recorded before is never an assumed grant on upgrade, so the whole
23993
+ // block is optional rather than defaulted in. What an absent block means is
23994
+ // webChatCaptureOf's answer, in one place.
23995
+ //
23996
+ // Enforcement is NOT gated on this. A machine that has never answered still
23997
+ // blocks, redacts and warns on what a user sends; the grant covers what is
23998
+ // written down.
23999
+ webChatCapture: WebChatCapture.optional(),
23904
24000
  // Local body expiry (see BodyRetention). Off until switched on; expiring a
23905
24001
  // body never removes the row or its findings.
23906
24002
  bodyRetention: BodyRetention.default({
@@ -24011,7 +24107,10 @@ function toCaptureAttributes(event) {
24011
24107
  // `.catchall(z.unknown())` carries the long tail.
24012
24108
  ...metadata?.model !== void 0 ? { model: metadata.model } : {},
24013
24109
  ...metadata?.turnIndex !== void 0 ? { turn_index: metadata.turnIndex } : {},
24014
- ...metadata?.messageId !== void 0 ? { message_id: metadata.messageId } : {},
24110
+ // A blank id is omitted rather than stored: it is a join key and `''` joins
24111
+ // nothing. This runs on the local write path, which types the event but
24112
+ // never parses it, so EventMetadata's own `.min(1)` does not reach here.
24113
+ ...metadata?.messageId !== void 0 && metadata.messageId !== "" ? { message_id: metadata.messageId } : {},
24015
24114
  ...metadata?.conversationId !== void 0 ? { conversation_id: metadata.conversationId } : {}
24016
24115
  };
24017
24116
  }
@@ -24385,12 +24484,14 @@ var RecommendedActionIdParam = external_exports.object({ id: external_exports.st
24385
24484
  // ../../packages/schema/src/zod/settings-action.ts
24386
24485
  var HistorySyncConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "HistorySyncConsentChoice" });
24387
24486
  var ModelJudgeConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "ModelJudgeConsentChoice" });
24487
+ var WebChatCaptureConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "WebChatCaptureConsentChoice" });
24388
24488
  var SaveSettingsInput = external_exports.object({
24389
24489
  historicalAccess: external_exports.string(),
24390
24490
  modelJudgeConsent: ModelJudgeConsentChoice,
24391
24491
  historySyncConsent: HistorySyncConsentChoice,
24392
24492
  vaultConsent: external_exports.string(),
24393
24493
  vaultInlineReveal: external_exports.string(),
24494
+ webChatCaptureConsent: WebChatCaptureConsentChoice,
24394
24495
  // Widened to `string` like its neighbours rather than typed as
24395
24496
  // `RedactFallback`, on this module's own layering rule: shape here, VALUE at
24396
24497
  // the call site, so the domain check receives the type it was written for.
@@ -24605,11 +24706,24 @@ var WebExchange = external_exports.object({
24605
24706
  turnIndex: external_exports.number().int().nonnegative().optional(),
24606
24707
  toolCalls: external_exports.array(WebToolCall).default([]),
24607
24708
  // Absent when the adapter recovered no text. Capped by the caller at
24608
- // RESPONSE_TEXT_MAX_BYTES; `truncated` records that the cap was reached, so a
24609
- // short capture is never mistaken for a short reply.
24709
+ // RESPONSE_TEXT_MAX_BYTES, so a short capture is never mistaken for a short
24710
+ // reply.
24610
24711
  responseText: external_exports.string().optional(),
24712
+ // The stored text is short of the reply. It does NOT say which of the two
24713
+ // ceilings on this path cut it: the caller applies its own cap on the raw
24714
+ // bytes it reads off the wire, which can be reached by a stream whose
24715
+ // recovered text stays well under RESPONSE_TEXT_MAX_BYTES, and applies that
24716
+ // one to the text. A reader cannot tell them apart, and nothing downstream
24717
+ // should branch as though it could.
24611
24718
  truncated: external_exports.boolean().default(false)
24612
24719
  });
24720
+ var WebEnforcementState = external_exports.enum([
24721
+ "watching",
24722
+ "composer-only",
24723
+ "button-only",
24724
+ "unattached",
24725
+ "unknown"
24726
+ ]);
24613
24727
  var RESPONSE_TEXT_MAX_BYTES = 2 * 1024 * 1024;
24614
24728
  var WebCaptureStatus = external_exports.object({
24615
24729
  patched: external_exports.boolean(),
@@ -24621,8 +24735,66 @@ var WebCaptureStatus = external_exports.object({
24621
24735
  unparsedBodies: external_exports.number().int().nonnegative(),
24622
24736
  // The adapter-declared JSON key paths that were absent from a real payload —
24623
24737
  // the earliest signal that a site's contract moved.
24624
- shapeMisses: external_exports.array(external_exports.string()).default([])
24625
- });
24738
+ shapeMisses: external_exports.array(external_exports.string()).default([]),
24739
+ // How many `kind: 'conversation'` endpoints the reporting tab's adapter
24740
+ // compiled. Zero means this build declares none for the site, so observing
24741
+ // nothing is the design rather than a fault — the one fact that separates a
24742
+ // site nobody has surveyed yet from one whose contract moved. Defaulted so a
24743
+ // build predating the field is read as declaring nothing rather than refused.
24744
+ conversationEndpoints: external_exports.number().int().nonnegative().default(0),
24745
+ // The document that sent this report is going away. The bridge sets it on
24746
+ // its `pagehide` report and nowhere else.
24747
+ //
24748
+ // A property of the REPORT rather than of capture health, which is why
24749
+ // nothing in `deriveWebCaptureState` reads it and why it stays out of the
24750
+ // bridge's own report signature — a closing tab's last word must not be
24751
+ // suppressed for carrying the same health as the report before it. What
24752
+ // reads it is the per-site fold: a document that said it was unloading stops
24753
+ // voting on the site's state, so the reload the `blind` remediation asks for
24754
+ // can actually clear the verdict it was shown. A document that dies without
24755
+ // sending one is covered by CAPTURE_STATUS_DOCUMENT_QUIET_MS instead.
24756
+ //
24757
+ // Defaulted so a build predating the field reads as a document that never
24758
+ // said it was closing — which keeps it voting, the same as every report that
24759
+ // is not a final one.
24760
+ closed: external_exports.boolean().default(false),
24761
+ // What the DOM enforcement path is doing, which none of the counters above
24762
+ // can say: `sendsSeenDom` rises only once a send has COMPLETED, so a tab
24763
+ // whose watcher never bound reports zero exactly like a tab nobody typed in.
24764
+ // Defaulted to 'unknown' rather than 'watching' so a status from a build
24765
+ // predating the field is not read as reporting a healthy one.
24766
+ enforcement: WebEnforcementState.default("unknown")
24767
+ });
24768
+ function webCaptureStatusObservedTurnPath(status) {
24769
+ if (!status.patched) return true;
24770
+ if (status.conversationEndpoints === 0) return true;
24771
+ return status.blind || status.shapeMisses.length > 0 || status.parseFailures > 0 || status.unparsedBodies > 0 || status.exchangesSeenNet > 0;
24772
+ }
24773
+ function pickReportedCaptureStatus(candidates) {
24774
+ return candidates.find((c) => webCaptureStatusObservedTurnPath(c.status)) ?? candidates[0];
24775
+ }
24776
+ var CAPTURE_STATUS_RECENCY_MS = 30 * 24 * 60 * 60 * 1e3;
24777
+ var CAPTURE_STATUS_RECENCY_DAYS = CAPTURE_STATUS_RECENCY_MS / (24 * 60 * 60 * 1e3);
24778
+ var CAPTURE_STATUS_DOCUMENT_QUIET_MS = 12 * 60 * 60 * 1e3;
24779
+ function fromCaptureStatusAttributes(bag) {
24780
+ const parsedBag = CaptureStatusAttributes.safeParse(bag);
24781
+ if (!parsedBag.success) return null;
24782
+ const b = parsedBag.data;
24783
+ const parsedStatus = WebCaptureStatus.safeParse({
24784
+ patched: b.patched,
24785
+ live: b.live,
24786
+ blind: b.blind,
24787
+ sendsSeenDom: b.sends_seen_dom,
24788
+ exchangesSeenNet: b.exchanges_seen_net,
24789
+ parseFailures: b.parse_failures,
24790
+ unparsedBodies: b.unparsed_bodies,
24791
+ shapeMisses: b.shape_misses,
24792
+ conversationEndpoints: b.conversation_endpoints,
24793
+ closed: b.closed,
24794
+ enforcement: b.enforcement
24795
+ });
24796
+ return parsedStatus.success ? parsedStatus.data : null;
24797
+ }
24626
24798
 
24627
24799
  // ../../packages/persistence/src/paths.ts
24628
24800
  import {
@@ -26388,7 +26560,7 @@ var SESSION_ROOT = `event_type = 'session'`;
26388
26560
  var HAS_ACTIVITY = `EXISTS (
26389
26561
  SELECT 1 FROM audit_events c
26390
26562
  WHERE c.root_session_id = audit_events.id
26391
- AND c.event_type NOT IN ('hook', 'config_scan'))`;
26563
+ AND c.event_type NOT IN ('hook', 'config_scan', 'capture_status'))`;
26392
26564
  var SqliteActivityRepository = class {
26393
26565
  constructor(db, now = () => Date.now()) {
26394
26566
  this.db = db;
@@ -26415,10 +26587,10 @@ var SqliteActivityRepository = class {
26415
26587
  SELECT id FROM audit_events WHERE event_type = 'session' AND started_at >= ?
26416
26588
  UNION
26417
26589
  SELECT root_session_id FROM audit_events INDEXED BY idx_audit_started_at
26418
- WHERE started_at >= ?
26590
+ WHERE started_at >= ? AND event_type <> 'capture_status'
26419
26591
  UNION
26420
26592
  SELECT root_session_id FROM audit_events INDEXED BY idx_audit_ended_at
26421
- WHERE ended_at >= ?)`,
26593
+ WHERE ended_at >= ? AND event_type <> 'capture_status')`,
26422
26594
  [liveThreshold, liveThreshold, liveThreshold]
26423
26595
  );
26424
26596
  const toolCallsToday = countScalar(
@@ -26825,7 +26997,10 @@ var SqliteAuditEventsRepository = class {
26825
26997
  attributes = excluded.attributes,
26826
26998
  ended_at = excluded.ended_at
26827
26999
  WHERE COALESCE(json_extract(excluded.attributes, '$.output_tokens'), 0)
26828
- > COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)`
27000
+ > COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
27001
+ OR (json_extract(excluded.attributes, '$.usage_source') IS NOT NULL
27002
+ AND json_extract(excluded.attributes, '$.output_tokens') IS NULL
27003
+ AND excluded.attributes <> audit_events.attributes)`
26829
27004
  );
26830
27005
  this.upsertSessionRootStmt = db.prepare(
26831
27006
  `INSERT OR IGNORE INTO audit_events
@@ -27093,6 +27268,87 @@ var SqliteBodyRetentionRepository = class {
27093
27268
  }
27094
27269
  };
27095
27270
 
27271
+ // ../../packages/persistence/src/repositories/capture-status.ts
27272
+ var STATUS_LOOKBACK_ROWS = 128;
27273
+ var SqliteCaptureStatusRepository = class {
27274
+ constructor(db) {
27275
+ this.db = db;
27276
+ this.recentStmt = db.prepare(
27277
+ `SELECT a.started_at AS startedAt,
27278
+ a.attributes AS attributes,
27279
+ a.root_session_id AS rootSessionId
27280
+ FROM audit_events a
27281
+ WHERE a.event_type = 'capture_status'
27282
+ AND a.source_tool = ?
27283
+ AND a.started_at >= ?
27284
+ ORDER BY a.started_at DESC, a.id DESC
27285
+ LIMIT ?`
27286
+ );
27287
+ }
27288
+ db;
27289
+ recentStmt;
27290
+ /**
27291
+ * Every document that reported for a site, in registry order by site, from
27292
+ * the last `CAPTURE_STATUS_RECENCY_MS`.
27293
+ *
27294
+ * SEVERAL per site, not one: a browser is many documents and each reports
27295
+ * for itself, so one row per site is a choice about which of them a user
27296
+ * sees — and the newest is the wrong one, since a healthy tab writing a
27297
+ * fresh report would hide a drifting tab's verdict, which is the whole
27298
+ * reason these rows exist. The pick WITHIN a document is made here (the
27299
+ * unchanged `pickReportedCaptureStatus`, over that document's own rows);
27300
+ * choosing between documents belongs where the state semantics live, and
27301
+ * that is `reportedCaptureDocumentForSite` in `@akasecurity/detections` —
27302
+ * this package may not import it.
27303
+ *
27304
+ * `now` is a required argument rather than a `Date.now()` read, so a caller
27305
+ * that already holds a render instant passes THAT one and a test can drive
27306
+ * the window without moving the wall clock.
27307
+ *
27308
+ * A site whose reports have all aged out contributes nothing, so it derives
27309
+ * to `unreported`. That is the point: nothing but the browser extension ever
27310
+ * writes these rows, so an uninstalled extension's last verdict would
27311
+ * otherwise stand as a live claim for ever with no later report able to
27312
+ * clear it.
27313
+ */
27314
+ latest(now) {
27315
+ const since = now - CAPTURE_STATUS_RECENCY_MS;
27316
+ const documents = [];
27317
+ for (const tool of WebSourceTool.options) {
27318
+ const rows = /* @__PURE__ */ new Map();
27319
+ const lastWord = /* @__PURE__ */ new Map();
27320
+ for (const row of allRows(this.recentStmt, [
27321
+ tool,
27322
+ since,
27323
+ STATUS_LOOKBACK_ROWS
27324
+ ])) {
27325
+ const status = fromCaptureStatusAttributes(parseJsonObject(row.attributes));
27326
+ if (status === null) continue;
27327
+ const record2 = { tool, observedAt: epochMillisToIso(row.startedAt), status };
27328
+ const group = rows.get(row.rootSessionId);
27329
+ if (group === void 0) {
27330
+ rows.set(row.rootSessionId, [record2]);
27331
+ lastWord.set(row.rootSessionId, { at: record2.observedAt, closed: status.closed });
27332
+ } else {
27333
+ group.push(record2);
27334
+ }
27335
+ }
27336
+ for (const [root, candidates] of rows) {
27337
+ const picked = pickReportedCaptureStatus(candidates);
27338
+ const last = lastWord.get(root);
27339
+ if (picked === void 0 || last === void 0) continue;
27340
+ documents.push({
27341
+ ...picked,
27342
+ ...root === null ? {} : { rootSessionId: root },
27343
+ lastReportAt: last.at,
27344
+ closed: last.closed
27345
+ });
27346
+ }
27347
+ }
27348
+ return documents;
27349
+ }
27350
+ };
27351
+
27096
27352
  // ../../packages/persistence/src/repositories/classified-data.ts
27097
27353
  var SqliteClassifiedDataRepository = class {
27098
27354
  constructor(db) {
@@ -32645,6 +32901,7 @@ function openAndInitialize(file2, base, skipTags) {
32645
32901
  activity: new SqliteActivityRepository(db),
32646
32902
  sourceProject: new SqliteSourceProjectRepository(db),
32647
32903
  auditEvents: new SqliteAuditEventsRepository(db),
32904
+ captureStatus: new SqliteCaptureStatusRepository(db),
32648
32905
  classifiedData: new SqliteClassifiedDataRepository(db),
32649
32906
  inspectionDefinitions: new SqliteInspectionDefinitionsRepository(db),
32650
32907
  inspectionFindings: new SqliteInspectionFindingsRepository(db),
@@ -32685,6 +32942,7 @@ function openLocalDatabase(dir, options = {}) {
32685
32942
  activity,
32686
32943
  sourceProject,
32687
32944
  auditEvents,
32945
+ captureStatus,
32688
32946
  classifiedData,
32689
32947
  inspectionDefinitions,
32690
32948
  inspectionFindings,
@@ -32902,6 +33160,7 @@ function openLocalDatabase(dir, options = {}) {
32902
33160
  activity,
32903
33161
  sourceProject,
32904
33162
  auditEvents,
33163
+ captureStatus,
32905
33164
  classifiedData,
32906
33165
  inspectionDefinitions,
32907
33166
  inspectionFindings,
@@ -33754,6 +34013,56 @@ var CONFIG_POSTURE_RULES = [
33754
34013
  }
33755
34014
  ];
33756
34015
 
34016
+ // ../../packages/detections/src/posture/web-capture-posture.ts
34017
+ var RULE_VERSION2 = "1";
34018
+ var DRIFT_MIN_PARSE_FAILURES = 2;
34019
+ var WEB_CAPTURE_DRIFT_STATES = /* @__PURE__ */ new Set([
34020
+ "blind",
34021
+ "degraded"
34022
+ ]);
34023
+ var WEB_CAPTURE_DRIFT_RULE = {
34024
+ ruleId: "web-capture-drift",
34025
+ version: RULE_VERSION2,
34026
+ name: "Web chat capture is not reading the site",
34027
+ category: "config",
34028
+ severity: "medium",
34029
+ definition: JSON.stringify({
34030
+ kind: "web-capture-drift",
34031
+ states: [...WEB_CAPTURE_DRIFT_STATES],
34032
+ minParseFailures: DRIFT_MIN_PARSE_FAILURES
34033
+ })
34034
+ };
34035
+ var STATIC_COPY = {
34036
+ active: { headline: "turns are being observed on this site" },
34037
+ unreported: {
34038
+ // Says "recently" rather than "yet": the store read is bounded to
34039
+ // CAPTURE_STATUS_RECENCY_MS, so this state covers a site nothing has ever
34040
+ // reported for AND one whose last report has aged out. The two are the
34041
+ // same fact to a reader — nobody has confirmed anything lately — and the
34042
+ // copy may not claim the stronger of them.
34043
+ headline: `no report in the last ${String(CAPTURE_STATUS_RECENCY_DAYS)} days \u2014 open the site in Chrome with the extension loaded`
34044
+ },
34045
+ standby: {
34046
+ headline: "this build declares no endpoints for the site, so nothing is observed yet"
34047
+ },
34048
+ unpatched: {
34049
+ // Says what the flags say and no more. `patched` is false both for a tap
34050
+ // that installed and hooked neither transport and for one that never ran
34051
+ // at all — a page reports the same status either way, so the copy may not
34052
+ // assert one of them.
34053
+ headline: "the page tap captured neither fetch nor XHR \u2014 it may not have installed; reload the extension at chrome://extensions"
34054
+ },
34055
+ idle: { headline: "watching; no turn has been observed yet" },
34056
+ blind: {
34057
+ headline: "messages were sent in the page that the network capture never saw",
34058
+ 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."
34059
+ },
34060
+ degraded: {
34061
+ headline: "the site's payloads no longer carry the fields the extension reads",
34062
+ 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."
34063
+ }
34064
+ };
34065
+
33757
34066
  // ../../packages/detections/src/security/redos-probe.ts
33758
34067
  var BUDGET_MS = 100;
33759
34068
  var EXPONENTIAL_UNITS = [
@@ -33913,6 +34222,9 @@ import { join as join27 } from "path";
33913
34222
 
33914
34223
  // ../../packages/plugin-runtime/src/attached/atomic-publish.ts
33915
34224
  import { rename as rename2 } from "fs/promises";
34225
+ var IMMEDIATE_RETRIES = 8;
34226
+ var TIMED_RETRIES = 4;
34227
+ var ATTEMPTS = 1 + IMMEDIATE_RETRIES + TIMED_RETRIES;
33916
34228
 
33917
34229
  // ../../packages/plugin-runtime/src/attached/posture-reporter.ts
33918
34230
  var POSTURE_REPORT_INTERVAL_MS = 60 * 60 * 1e3;