@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.
@@ -20482,7 +20482,17 @@ var UNPRICEABLE_PROVIDERS = Object.freeze([
20482
20482
  "gateway",
20483
20483
  "unknown",
20484
20484
  "cli",
20485
- "api"
20485
+ "api",
20486
+ // The browser extension's native host records these as `llm_call.provider`
20487
+ // for a web-chat turn — the web tool id, deliberately never the vendor id
20488
+ // (`openai`/`anthropic`) the session root carries. Subscription traffic
20489
+ // burns rate-limit budget, not dollar credits, and listing them here is
20490
+ // what keeps that true structurally: a later maintainer who wants to price
20491
+ // web-chat traffic at API rates has to delete this entry first, and meet
20492
+ // the reason on the way, rather than quietly adding one to
20493
+ // PROVIDER_PLATFORM.
20494
+ "chatgpt",
20495
+ "claude-ai"
20486
20496
  ]);
20487
20497
  function platformForProvider(provider) {
20488
20498
  return PROVIDER_PLATFORM.get(provider.trim().toLowerCase()) ?? null;
@@ -20625,7 +20635,12 @@ var HARNESS = {
20625
20635
  ClaudeDesktop: "claudedesktop",
20626
20636
  ChatGpt: "chatgpt",
20627
20637
  ClaudeAi: "claudeai",
20628
- Api: "api"
20638
+ Api: "api",
20639
+ // Not a coding assistant a person drives — an in-process SDK embedded in an
20640
+ // application, so it has no IDE/CLI/desktop/web surface of its own. Carries
20641
+ // the same id as its SOURCE_TOOL counterpart, unlike every capture-side tool
20642
+ // whose wire spelling differs from its display spelling.
20643
+ AiTcSdk: "ai-tc-sdk"
20629
20644
  };
20630
20645
  var Harness = external_exports.enum(HARNESS).meta({ id: "Harness" });
20631
20646
  var SOURCE_TOOL = {
@@ -20641,9 +20656,15 @@ var SOURCE_TOOL = {
20641
20656
  // whose tool could not be identified both render through the read side's
20642
20657
  // miss path rather than as a harness of their own.
20643
20658
  Cli: "cli",
20644
- Unknown: "unknown"
20659
+ Unknown: "unknown",
20660
+ // The wire id an in-process, request-path SDK stamps on its own structural
20661
+ // rows (`request_decision`) — never a capture of prompt/response/tool text,
20662
+ // since the SDK sits in front of a model call rather than inside a coding
20663
+ // assistant's own hook contract.
20664
+ AiTcSdk: "ai-tc-sdk"
20645
20665
  };
20646
20666
  var SourceTool = external_exports.enum(SOURCE_TOOL).meta({ id: "SourceTool" });
20667
+ var WebSourceTool = SourceTool.extract(["ChatGpt", "ClaudeAi"]);
20647
20668
  var TOOL_TO_HARNESS = {
20648
20669
  [SOURCE_TOOL.ClaudeCode]: HARNESS.ClaudeCode,
20649
20670
  [SOURCE_TOOL.ClaudeDesktop]: HARNESS.ClaudeDesktop,
@@ -20652,7 +20673,12 @@ var TOOL_TO_HARNESS = {
20652
20673
  [SOURCE_TOOL.ChatGpt]: HARNESS.ChatGpt,
20653
20674
  [SOURCE_TOOL.Codex]: HARNESS.Codex,
20654
20675
  [SOURCE_TOOL.Antigravity]: HARNESS.Antigravity,
20655
- [SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi
20676
+ [SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi,
20677
+ // Wire and display id are the same string here, but the row still belongs:
20678
+ // both vocabularies carry the `AiTcSdk` member, and the join is exactly
20679
+ // their intersection — leaving a shared member out would read as an
20680
+ // uninstrumented tool on both surfaces, which this one is not.
20681
+ [SOURCE_TOOL.AiTcSdk]: HARNESS.AiTcSdk
20656
20682
  };
20657
20683
 
20658
20684
  // ../../packages/schema/src/zod/finding.ts
@@ -20686,7 +20712,8 @@ var FindingProvider = Harness.extract([
20686
20712
  "ClaudeAi",
20687
20713
  "Codex",
20688
20714
  "Antigravity",
20689
- "Api"
20715
+ "Api",
20716
+ "AiTcSdk"
20690
20717
  ]).meta({ id: "FindingProvider" });
20691
20718
  var FindingCategory = external_exports.enum([
20692
20719
  "secret",
@@ -21063,18 +21090,41 @@ var AuditEventType = external_exports.enum([
21063
21090
  // 'tool_call' is the reconciler's structural row for every call, while
21064
21091
  // 'tool_use' exists only where a hook enforced against the arguments.
21065
21092
  "tool_use",
21066
- // One row per model REFUSAL: a switch onto a prohibited model that was
21067
- // denied, or a turn refused because the session was already running on one.
21068
- // A structural row like the ones above rather than a capture — it carries
21069
- // the model that was refused and nothing the user typed, because what is
21070
- // worth recording about a governance decision is the decision, and prompt
21071
- // text is the thing this product exists to keep from travelling.
21093
+ // One row per model REFUSAL, across all four seams a prohibited model can be
21094
+ // stopped at: a switch onto it, a turn already running on it, a subagent
21095
+ // spawn asking for it, or a request-path refusal an embedded request-path
21096
+ // SDK makes in-process before the call leaves the application. Which seam
21097
+ // rides `attributes.refusal_seam`, never this member name. A structural row
21098
+ // like the ones above rather than a capture — it carries the model that was
21099
+ // refused and nothing the user typed, because what is worth recording about
21100
+ // a governance decision is the decision, and prompt text is the thing this
21101
+ // product exists to keep from travelling.
21072
21102
  "model_refusal",
21103
+ // One row per request-path DECISION: a policy check an embedded request-path
21104
+ // SDK performs in-process before a model call leaves the application, or
21105
+ // against that call's non-streamed response. A structural row like
21106
+ // 'model_refusal' rather than a capture — content-free in the same way:
21107
+ // which side, which seam, what action and which field are decided rides
21108
+ // `attributes`, never this member name, and the matched text itself never
21109
+ // travels.
21110
+ //
21111
+ // A prohibited-model refusal on the request path is deliberately NOT this
21112
+ // member: it stays 'model_refusal' with `refusal_seam: 'request'`, so it
21113
+ // shares one bucket with the plugin's switch/turn/spawn refusals rather
21114
+ // than splitting one governance concept across two event types. This
21115
+ // member carries every OTHER request-path decision.
21116
+ "request_decision",
21073
21117
  // One row per config-inventory scan, hung off the session root. It is the
21074
21118
  // fact the posture inspection findings reference (findings require an
21075
21119
  // audit_event_id), and its started_at is the "scanned Nm ago" the read
21076
21120
  // surface renders.
21077
- "config_scan"
21121
+ "config_scan",
21122
+ // One row per reported browser-extension capture status, hung off the web
21123
+ // session root. The durable home of what one tab's network interception
21124
+ // is doing — a write-through of the native host's in-memory tracker, so a
21125
+ // second process (aka extension status) and a restarted host both have
21126
+ // somewhere to read it back from.
21127
+ "capture_status"
21078
21128
  ]).meta({ id: "AuditEventType" });
21079
21129
  var AttributeBag = external_exports.record(external_exports.string(), external_exports.unknown());
21080
21130
  var HostAttributes = external_exports.object({
@@ -21234,6 +21284,20 @@ var CaptureAttributes = external_exports.object({
21234
21284
  // repeated rather than referenced because a store reader opens this file.
21235
21285
  redact_degraded_to: ActionTaken.optional()
21236
21286
  }).catchall(external_exports.unknown());
21287
+ var CaptureStatusAttributes = external_exports.object({
21288
+ source_tool: external_exports.string().optional(),
21289
+ patched: external_exports.boolean().optional(),
21290
+ live: external_exports.boolean().optional(),
21291
+ blind: external_exports.boolean().optional(),
21292
+ sends_seen_dom: external_exports.number().int().nonnegative().optional(),
21293
+ exchanges_seen_net: external_exports.number().int().nonnegative().optional(),
21294
+ parse_failures: external_exports.number().int().nonnegative().optional(),
21295
+ unparsed_bodies: external_exports.number().int().nonnegative().optional(),
21296
+ shape_misses: external_exports.array(external_exports.string()).optional(),
21297
+ conversation_endpoints: external_exports.number().int().nonnegative().optional(),
21298
+ closed: external_exports.boolean().optional(),
21299
+ enforcement: external_exports.string().optional()
21300
+ }).catchall(external_exports.unknown());
21237
21301
  var ToolCallInspection = external_exports.object({
21238
21302
  ruleId: external_exports.string().min(1),
21239
21303
  ruleName: external_exports.string(),
@@ -22093,6 +22157,30 @@ var AttachedCredential = external_exports.object({
22093
22157
  keyPrefix: external_exports.string().min(1).max(16).optional(),
22094
22158
  mintedAt: external_exports.iso.datetime().optional()
22095
22159
  });
22160
+ var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
22161
+ function unsafeEndpointReason(endpoint) {
22162
+ let parsed2;
22163
+ try {
22164
+ parsed2 = new URL(endpoint);
22165
+ } catch {
22166
+ return "unparseable";
22167
+ }
22168
+ if (parsed2.username !== "" || parsed2.password !== "") return "userinfo";
22169
+ if (parsed2.search !== "" || parsed2.hash !== "") return "query-or-fragment";
22170
+ if (parsed2.protocol === "https:") return null;
22171
+ return parsed2.protocol === "http:" && LOOPBACK_HOSTS.has(parsed2.hostname) ? null : "insecure";
22172
+ }
22173
+ function isSafeEndpoint(endpoint) {
22174
+ return unsafeEndpointReason(endpoint) === null;
22175
+ }
22176
+ function originOnly(endpoint) {
22177
+ try {
22178
+ const parsed2 = new URL(endpoint);
22179
+ return `${parsed2.protocol}//${parsed2.host}`;
22180
+ } catch {
22181
+ return "(unparseable endpoint)";
22182
+ }
22183
+ }
22096
22184
  var MAX_DATE_MS = 253402300799999;
22097
22185
  var MAX_INT4 = 2147483647;
22098
22186
  var StorePosturePack = external_exports.object({
@@ -22247,6 +22335,11 @@ var RemoteFailureKind = external_exports.enum([
22247
22335
  "rejected",
22248
22336
  "unreachable"
22249
22337
  ]);
22338
+ var ControlPlaneFailure = RemoteFailureKind.extract([
22339
+ "unauthorized",
22340
+ "forbidden",
22341
+ "unreachable"
22342
+ ]);
22250
22343
  var AttachDeviceRequest = external_exports.object({
22251
22344
  // This machine's own continuity id, so re-attaching ROTATES the credential
22252
22345
  // on one machine record instead of producing a second one. Client-minted
@@ -22786,7 +22879,12 @@ var EventMetadata = external_exports.object({
22786
22879
  // in — set by the browser extension's network capture so a stored `response`
22787
22880
  // row can be joined to the `llm_call` leaf describing the same turn. Absent
22788
22881
  // on every other capture path, which has no such id.
22789
- messageId: external_exports.string().optional(),
22882
+ //
22883
+ // Non-empty for the reason WebExchange.messageId is: it is the join key, and
22884
+ // a blank one matches no `llm_call` leaf. That refusal reaches only the
22885
+ // places an event is PARSED; the local write path types the event and parses
22886
+ // nothing, which is why `toCaptureAttributes` omits a blank one separately.
22887
+ messageId: external_exports.string().min(1).optional(),
22790
22888
  conversationId: external_exports.string().optional(),
22791
22889
  // How long THIS capture's inspection blocked its caller, in whole
22792
22890
  // milliseconds — the plugin's own added latency, NOT the LLM call it sat in
@@ -23628,6 +23726,85 @@ function policyIdIsReversible(policyId) {
23628
23726
  var DEFAULT_ACTIONS = Object.fromEntries(
23629
23727
  DetectionCategory.options.map((c) => [c, builtinPolicyToAction(severityFloorPolicy(c))])
23630
23728
  );
23729
+ function ruleCategoryMap(wireRules, localRules, compiledRules) {
23730
+ const map2 = /* @__PURE__ */ new Map();
23731
+ for (const rule of wireRules ?? []) map2.set(rule.id, rule.category);
23732
+ for (const rule of localRules ?? []) map2.set(rule.id, rule.category);
23733
+ for (const rule of compiledRules) map2.set(rule.id, rule.category);
23734
+ return map2;
23735
+ }
23736
+ function policyKey(policy) {
23737
+ return "ruleId" in policy.target ? `rule:${policy.target.ruleId}` : `category:${policy.target.category}`;
23738
+ }
23739
+ function floorFor(policy, categoryByRuleId) {
23740
+ const category = "category" in policy.target ? policy.target.category : categoryByRuleId.get(policy.target.ruleId);
23741
+ return category === void 0 ? null : DEFAULT_ACTIONS[category];
23742
+ }
23743
+ function strongerOf(a, b) {
23744
+ if (a === null) return b;
23745
+ if (b === null) return a;
23746
+ return strongerAction(a, b);
23747
+ }
23748
+ function mergeRaiseOnly(localPolicies, remotePolicies, categoryByRuleId) {
23749
+ const merged = /* @__PURE__ */ new Map();
23750
+ const disabled = [];
23751
+ const remoteCategoryAction = /* @__PURE__ */ new Map();
23752
+ for (const policy of remotePolicies) {
23753
+ if (!policy.enabled) continue;
23754
+ if (!("category" in policy.target)) continue;
23755
+ if (remoteCategoryAction.has(policy.target.category)) continue;
23756
+ const floor = floorFor(policy, categoryByRuleId);
23757
+ remoteCategoryAction.set(
23758
+ policy.target.category,
23759
+ floor !== null && !isActionAtLeast(policy.action, floor) ? floor : policy.action
23760
+ );
23761
+ }
23762
+ for (const policy of localPolicies) {
23763
+ if (!policy.enabled) {
23764
+ disabled.push(policy);
23765
+ continue;
23766
+ }
23767
+ const key = policyKey(policy);
23768
+ if (merged.has(key)) continue;
23769
+ let remoteFloor = null;
23770
+ if ("ruleId" in policy.target) {
23771
+ const category = categoryByRuleId.get(policy.target.ruleId);
23772
+ if (category !== void 0) remoteFloor = remoteCategoryAction.get(category) ?? null;
23773
+ }
23774
+ merged.set(
23775
+ key,
23776
+ remoteFloor !== null && !isActionAtLeast(policy.action, remoteFloor) ? { ...policy, action: remoteFloor } : policy
23777
+ );
23778
+ }
23779
+ const localCategoryAction = /* @__PURE__ */ new Map();
23780
+ for (const policy of merged.values()) {
23781
+ if ("category" in policy.target) localCategoryAction.set(policy.target.category, policy.action);
23782
+ }
23783
+ for (const policy of remotePolicies) {
23784
+ if (!policy.enabled) {
23785
+ disabled.push(policy);
23786
+ continue;
23787
+ }
23788
+ const key = policyKey(policy);
23789
+ const floor = floorFor(policy, categoryByRuleId);
23790
+ let localFloor = null;
23791
+ if ("ruleId" in policy.target) {
23792
+ const category = categoryByRuleId.get(policy.target.ruleId);
23793
+ if (category !== void 0) localFloor = localCategoryAction.get(category) ?? null;
23794
+ }
23795
+ const effectiveFloor = strongerOf(floor, localFloor);
23796
+ const clamped = effectiveFloor !== null && !isActionAtLeast(policy.action, effectiveFloor) ? { ...policy, action: effectiveFloor } : policy;
23797
+ const existing = merged.get(key);
23798
+ if (existing === void 0) {
23799
+ merged.set(key, clamped);
23800
+ continue;
23801
+ }
23802
+ if (actionRank(clamped.action) > actionRank(existing.action)) {
23803
+ merged.set(key, clamped);
23804
+ }
23805
+ }
23806
+ return [...merged.values(), ...disabled];
23807
+ }
23631
23808
  var BUILTIN_POLICIES = Object.fromEntries(
23632
23809
  KNOWN_BUILTIN_IDS.map((id) => [id, { id, ...BUILTIN_POLICY_SPECS[id] }])
23633
23810
  );
@@ -23850,6 +24027,18 @@ var HistorySyncConsent = external_exports.object({
23850
24027
  payloadVersion: external_exports.number().int().positive(),
23851
24028
  endpoint: external_exports.string()
23852
24029
  });
24030
+ var WebChatCaptureConsent = external_exports.object({
24031
+ acknowledgedAt: external_exports.iso.datetime(),
24032
+ version: external_exports.number().int().positive()
24033
+ });
24034
+ var WebChatResponseCapture = external_exports.enum(["with-findings", "always", "never"]);
24035
+ var WebChatCapture = external_exports.object({
24036
+ responses: WebChatResponseCapture.default("with-findings"),
24037
+ account: external_exports.boolean().default(false),
24038
+ // Absent until granted. Presence alone does not authorize anything — see
24039
+ // isWebChatCaptureConsentValid.
24040
+ consent: WebChatCaptureConsent.optional()
24041
+ });
23853
24042
  var BODY_RETENTION_DEFAULT_DAYS = 30;
23854
24043
  var BodyRetention = external_exports.object({
23855
24044
  enabled: external_exports.boolean().default(false),
@@ -23908,6 +24097,16 @@ var WorkspaceSettings = external_exports.object({
23908
24097
  // both widenings. Absent until granted, and a grant for a different endpoint
23909
24098
  // or an older payload no longer counts.
23910
24099
  historySyncConsent: HistorySyncConsent.optional(),
24100
+ // What the browser extension may record from a web chat, and the grant that
24101
+ // authorizes it. Absent until the user answers: recording something that was
24102
+ // never recorded before is never an assumed grant on upgrade, so the whole
24103
+ // block is optional rather than defaulted in. What an absent block means is
24104
+ // webChatCaptureOf's answer, in one place.
24105
+ //
24106
+ // Enforcement is NOT gated on this. A machine that has never answered still
24107
+ // blocks, redacts and warns on what a user sends; the grant covers what is
24108
+ // written down.
24109
+ webChatCapture: WebChatCapture.optional(),
23911
24110
  // Local body expiry (see BodyRetention). Off until switched on; expiring a
23912
24111
  // body never removes the row or its findings.
23913
24112
  bodyRetention: BodyRetention.default({
@@ -24015,7 +24214,10 @@ function toCaptureAttributes(event) {
24015
24214
  // `.catchall(z.unknown())` carries the long tail.
24016
24215
  ...metadata?.model !== void 0 ? { model: metadata.model } : {},
24017
24216
  ...metadata?.turnIndex !== void 0 ? { turn_index: metadata.turnIndex } : {},
24018
- ...metadata?.messageId !== void 0 ? { message_id: metadata.messageId } : {},
24217
+ // A blank id is omitted rather than stored: it is a join key and `''` joins
24218
+ // nothing. This runs on the local write path, which types the event but
24219
+ // never parses it, so EventMetadata's own `.min(1)` does not reach here.
24220
+ ...metadata?.messageId !== void 0 && metadata.messageId !== "" ? { message_id: metadata.messageId } : {},
24019
24221
  ...metadata?.conversationId !== void 0 ? { conversation_id: metadata.conversationId } : {}
24020
24222
  };
24021
24223
  }
@@ -24389,12 +24591,14 @@ var RecommendedActionIdParam = external_exports.object({ id: external_exports.st
24389
24591
  // ../../packages/schema/src/zod/settings-action.ts
24390
24592
  var HistorySyncConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "HistorySyncConsentChoice" });
24391
24593
  var ModelJudgeConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "ModelJudgeConsentChoice" });
24594
+ var WebChatCaptureConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "WebChatCaptureConsentChoice" });
24392
24595
  var SaveSettingsInput = external_exports.object({
24393
24596
  historicalAccess: external_exports.string(),
24394
24597
  modelJudgeConsent: ModelJudgeConsentChoice,
24395
24598
  historySyncConsent: HistorySyncConsentChoice,
24396
24599
  vaultConsent: external_exports.string(),
24397
24600
  vaultInlineReveal: external_exports.string(),
24601
+ webChatCaptureConsent: WebChatCaptureConsentChoice,
24398
24602
  // Widened to `string` like its neighbours rather than typed as
24399
24603
  // `RedactFallback`, on this module's own layering rule: shape here, VALUE at
24400
24604
  // the call site, so the domain check receives the type it was written for.
@@ -24609,11 +24813,24 @@ var WebExchange = external_exports.object({
24609
24813
  turnIndex: external_exports.number().int().nonnegative().optional(),
24610
24814
  toolCalls: external_exports.array(WebToolCall).default([]),
24611
24815
  // Absent when the adapter recovered no text. Capped by the caller at
24612
- // RESPONSE_TEXT_MAX_BYTES; `truncated` records that the cap was reached, so a
24613
- // short capture is never mistaken for a short reply.
24816
+ // RESPONSE_TEXT_MAX_BYTES, so a short capture is never mistaken for a short
24817
+ // reply.
24614
24818
  responseText: external_exports.string().optional(),
24819
+ // The stored text is short of the reply. It does NOT say which of the two
24820
+ // ceilings on this path cut it: the caller applies its own cap on the raw
24821
+ // bytes it reads off the wire, which can be reached by a stream whose
24822
+ // recovered text stays well under RESPONSE_TEXT_MAX_BYTES, and applies that
24823
+ // one to the text. A reader cannot tell them apart, and nothing downstream
24824
+ // should branch as though it could.
24615
24825
  truncated: external_exports.boolean().default(false)
24616
24826
  });
24827
+ var WebEnforcementState = external_exports.enum([
24828
+ "watching",
24829
+ "composer-only",
24830
+ "button-only",
24831
+ "unattached",
24832
+ "unknown"
24833
+ ]);
24617
24834
  var RESPONSE_TEXT_MAX_BYTES = 2 * 1024 * 1024;
24618
24835
  var WebCaptureStatus = external_exports.object({
24619
24836
  patched: external_exports.boolean(),
@@ -24625,8 +24842,66 @@ var WebCaptureStatus = external_exports.object({
24625
24842
  unparsedBodies: external_exports.number().int().nonnegative(),
24626
24843
  // The adapter-declared JSON key paths that were absent from a real payload —
24627
24844
  // the earliest signal that a site's contract moved.
24628
- shapeMisses: external_exports.array(external_exports.string()).default([])
24629
- });
24845
+ shapeMisses: external_exports.array(external_exports.string()).default([]),
24846
+ // How many `kind: 'conversation'` endpoints the reporting tab's adapter
24847
+ // compiled. Zero means this build declares none for the site, so observing
24848
+ // nothing is the design rather than a fault — the one fact that separates a
24849
+ // site nobody has surveyed yet from one whose contract moved. Defaulted so a
24850
+ // build predating the field is read as declaring nothing rather than refused.
24851
+ conversationEndpoints: external_exports.number().int().nonnegative().default(0),
24852
+ // The document that sent this report is going away. The bridge sets it on
24853
+ // its `pagehide` report and nowhere else.
24854
+ //
24855
+ // A property of the REPORT rather than of capture health, which is why
24856
+ // nothing in `deriveWebCaptureState` reads it and why it stays out of the
24857
+ // bridge's own report signature — a closing tab's last word must not be
24858
+ // suppressed for carrying the same health as the report before it. What
24859
+ // reads it is the per-site fold: a document that said it was unloading stops
24860
+ // voting on the site's state, so the reload the `blind` remediation asks for
24861
+ // can actually clear the verdict it was shown. A document that dies without
24862
+ // sending one is covered by CAPTURE_STATUS_DOCUMENT_QUIET_MS instead.
24863
+ //
24864
+ // Defaulted so a build predating the field reads as a document that never
24865
+ // said it was closing — which keeps it voting, the same as every report that
24866
+ // is not a final one.
24867
+ closed: external_exports.boolean().default(false),
24868
+ // What the DOM enforcement path is doing, which none of the counters above
24869
+ // can say: `sendsSeenDom` rises only once a send has COMPLETED, so a tab
24870
+ // whose watcher never bound reports zero exactly like a tab nobody typed in.
24871
+ // Defaulted to 'unknown' rather than 'watching' so a status from a build
24872
+ // predating the field is not read as reporting a healthy one.
24873
+ enforcement: WebEnforcementState.default("unknown")
24874
+ });
24875
+ function webCaptureStatusObservedTurnPath(status) {
24876
+ if (!status.patched) return true;
24877
+ if (status.conversationEndpoints === 0) return true;
24878
+ return status.blind || status.shapeMisses.length > 0 || status.parseFailures > 0 || status.unparsedBodies > 0 || status.exchangesSeenNet > 0;
24879
+ }
24880
+ function pickReportedCaptureStatus(candidates) {
24881
+ return candidates.find((c) => webCaptureStatusObservedTurnPath(c.status)) ?? candidates[0];
24882
+ }
24883
+ var CAPTURE_STATUS_RECENCY_MS = 30 * 24 * 60 * 60 * 1e3;
24884
+ var CAPTURE_STATUS_RECENCY_DAYS = CAPTURE_STATUS_RECENCY_MS / (24 * 60 * 60 * 1e3);
24885
+ var CAPTURE_STATUS_DOCUMENT_QUIET_MS = 12 * 60 * 60 * 1e3;
24886
+ function fromCaptureStatusAttributes(bag) {
24887
+ const parsedBag = CaptureStatusAttributes.safeParse(bag);
24888
+ if (!parsedBag.success) return null;
24889
+ const b = parsedBag.data;
24890
+ const parsedStatus = WebCaptureStatus.safeParse({
24891
+ patched: b.patched,
24892
+ live: b.live,
24893
+ blind: b.blind,
24894
+ sendsSeenDom: b.sends_seen_dom,
24895
+ exchangesSeenNet: b.exchanges_seen_net,
24896
+ parseFailures: b.parse_failures,
24897
+ unparsedBodies: b.unparsed_bodies,
24898
+ shapeMisses: b.shape_misses,
24899
+ conversationEndpoints: b.conversation_endpoints,
24900
+ closed: b.closed,
24901
+ enforcement: b.enforcement
24902
+ });
24903
+ return parsedStatus.success ? parsedStatus.data : null;
24904
+ }
24630
24905
 
24631
24906
  // ../../packages/persistence/src/paths.ts
24632
24907
  import {
@@ -24737,17 +25012,6 @@ function publishByLink(tmp, file2, data) {
24737
25012
  function controlPlaneCredentialPath(settingsDir2) {
24738
25013
  return join2(settingsDir2, ATTACHED_CREDENTIAL_FILENAME);
24739
25014
  }
24740
- var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
24741
- function isSafeEndpoint(endpoint) {
24742
- let parsed2;
24743
- try {
24744
- parsed2 = new URL(endpoint);
24745
- } catch {
24746
- return false;
24747
- }
24748
- if (parsed2.protocol === "https:") return true;
24749
- return parsed2.protocol === "http:" && LOOPBACK_HOSTS.has(parsed2.hostname);
24750
- }
24751
25015
  function repairOrRefuseMode(file2) {
24752
25016
  const link = lstatSync2(file2, { throwIfNoEntry: false });
24753
25017
  if (link === void 0) return "absent";
@@ -26530,7 +26794,7 @@ var SESSION_ROOT = `event_type = 'session'`;
26530
26794
  var HAS_ACTIVITY = `EXISTS (
26531
26795
  SELECT 1 FROM audit_events c
26532
26796
  WHERE c.root_session_id = audit_events.id
26533
- AND c.event_type NOT IN ('hook', 'config_scan'))`;
26797
+ AND c.event_type NOT IN ('hook', 'config_scan', 'capture_status'))`;
26534
26798
  var SqliteActivityRepository = class {
26535
26799
  constructor(db, now = () => Date.now()) {
26536
26800
  this.db = db;
@@ -26557,10 +26821,10 @@ var SqliteActivityRepository = class {
26557
26821
  SELECT id FROM audit_events WHERE event_type = 'session' AND started_at >= ?
26558
26822
  UNION
26559
26823
  SELECT root_session_id FROM audit_events INDEXED BY idx_audit_started_at
26560
- WHERE started_at >= ?
26824
+ WHERE started_at >= ? AND event_type <> 'capture_status'
26561
26825
  UNION
26562
26826
  SELECT root_session_id FROM audit_events INDEXED BY idx_audit_ended_at
26563
- WHERE ended_at >= ?)`,
26827
+ WHERE ended_at >= ? AND event_type <> 'capture_status')`,
26564
26828
  [liveThreshold, liveThreshold, liveThreshold]
26565
26829
  );
26566
26830
  const toolCallsToday = countScalar(
@@ -26967,7 +27231,10 @@ var SqliteAuditEventsRepository = class {
26967
27231
  attributes = excluded.attributes,
26968
27232
  ended_at = excluded.ended_at
26969
27233
  WHERE COALESCE(json_extract(excluded.attributes, '$.output_tokens'), 0)
26970
- > COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)`
27234
+ > COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
27235
+ OR (json_extract(excluded.attributes, '$.usage_source') IS NOT NULL
27236
+ AND json_extract(excluded.attributes, '$.output_tokens') IS NULL
27237
+ AND excluded.attributes <> audit_events.attributes)`
26971
27238
  );
26972
27239
  this.upsertSessionRootStmt = db.prepare(
26973
27240
  `INSERT OR IGNORE INTO audit_events
@@ -27235,6 +27502,87 @@ var SqliteBodyRetentionRepository = class {
27235
27502
  }
27236
27503
  };
27237
27504
 
27505
+ // ../../packages/persistence/src/repositories/capture-status.ts
27506
+ var STATUS_LOOKBACK_ROWS = 128;
27507
+ var SqliteCaptureStatusRepository = class {
27508
+ constructor(db) {
27509
+ this.db = db;
27510
+ this.recentStmt = db.prepare(
27511
+ `SELECT a.started_at AS startedAt,
27512
+ a.attributes AS attributes,
27513
+ a.root_session_id AS rootSessionId
27514
+ FROM audit_events a
27515
+ WHERE a.event_type = 'capture_status'
27516
+ AND a.source_tool = ?
27517
+ AND a.started_at >= ?
27518
+ ORDER BY a.started_at DESC, a.id DESC
27519
+ LIMIT ?`
27520
+ );
27521
+ }
27522
+ db;
27523
+ recentStmt;
27524
+ /**
27525
+ * Every document that reported for a site, in registry order by site, from
27526
+ * the last `CAPTURE_STATUS_RECENCY_MS`.
27527
+ *
27528
+ * SEVERAL per site, not one: a browser is many documents and each reports
27529
+ * for itself, so one row per site is a choice about which of them a user
27530
+ * sees — and the newest is the wrong one, since a healthy tab writing a
27531
+ * fresh report would hide a drifting tab's verdict, which is the whole
27532
+ * reason these rows exist. The pick WITHIN a document is made here (the
27533
+ * unchanged `pickReportedCaptureStatus`, over that document's own rows);
27534
+ * choosing between documents belongs where the state semantics live, and
27535
+ * that is `reportedCaptureDocumentForSite` in `@akasecurity/detections` —
27536
+ * this package may not import it.
27537
+ *
27538
+ * `now` is a required argument rather than a `Date.now()` read, so a caller
27539
+ * that already holds a render instant passes THAT one and a test can drive
27540
+ * the window without moving the wall clock.
27541
+ *
27542
+ * A site whose reports have all aged out contributes nothing, so it derives
27543
+ * to `unreported`. That is the point: nothing but the browser extension ever
27544
+ * writes these rows, so an uninstalled extension's last verdict would
27545
+ * otherwise stand as a live claim for ever with no later report able to
27546
+ * clear it.
27547
+ */
27548
+ latest(now) {
27549
+ const since = now - CAPTURE_STATUS_RECENCY_MS;
27550
+ const documents = [];
27551
+ for (const tool of WebSourceTool.options) {
27552
+ const rows = /* @__PURE__ */ new Map();
27553
+ const lastWord = /* @__PURE__ */ new Map();
27554
+ for (const row of allRows(this.recentStmt, [
27555
+ tool,
27556
+ since,
27557
+ STATUS_LOOKBACK_ROWS
27558
+ ])) {
27559
+ const status = fromCaptureStatusAttributes(parseJsonObject(row.attributes));
27560
+ if (status === null) continue;
27561
+ const record2 = { tool, observedAt: epochMillisToIso(row.startedAt), status };
27562
+ const group = rows.get(row.rootSessionId);
27563
+ if (group === void 0) {
27564
+ rows.set(row.rootSessionId, [record2]);
27565
+ lastWord.set(row.rootSessionId, { at: record2.observedAt, closed: status.closed });
27566
+ } else {
27567
+ group.push(record2);
27568
+ }
27569
+ }
27570
+ for (const [root, candidates] of rows) {
27571
+ const picked = pickReportedCaptureStatus(candidates);
27572
+ const last = lastWord.get(root);
27573
+ if (picked === void 0 || last === void 0) continue;
27574
+ documents.push({
27575
+ ...picked,
27576
+ ...root === null ? {} : { rootSessionId: root },
27577
+ lastReportAt: last.at,
27578
+ closed: last.closed
27579
+ });
27580
+ }
27581
+ }
27582
+ return documents;
27583
+ }
27584
+ };
27585
+
27238
27586
  // ../../packages/persistence/src/repositories/classified-data.ts
27239
27587
  var SqliteClassifiedDataRepository = class {
27240
27588
  constructor(db) {
@@ -32815,6 +33163,7 @@ function openAndInitialize(file2, base, skipTags) {
32815
33163
  activity: new SqliteActivityRepository(db),
32816
33164
  sourceProject: new SqliteSourceProjectRepository(db),
32817
33165
  auditEvents: new SqliteAuditEventsRepository(db),
33166
+ captureStatus: new SqliteCaptureStatusRepository(db),
32818
33167
  classifiedData: new SqliteClassifiedDataRepository(db),
32819
33168
  inspectionDefinitions: new SqliteInspectionDefinitionsRepository(db),
32820
33169
  inspectionFindings: new SqliteInspectionFindingsRepository(db),
@@ -32855,6 +33204,7 @@ function openLocalDatabase(dir, options = {}) {
32855
33204
  activity,
32856
33205
  sourceProject,
32857
33206
  auditEvents,
33207
+ captureStatus,
32858
33208
  classifiedData,
32859
33209
  inspectionDefinitions,
32860
33210
  inspectionFindings,
@@ -33072,6 +33422,7 @@ function openLocalDatabase(dir, options = {}) {
33072
33422
  activity,
33073
33423
  sourceProject,
33074
33424
  auditEvents,
33425
+ captureStatus,
33075
33426
  classifiedData,
33076
33427
  inspectionDefinitions,
33077
33428
  inspectionFindings,
@@ -33206,11 +33557,6 @@ function readFingerprintKey(dataDir2) {
33206
33557
  // ../../packages/persistence/src/forward-health.ts
33207
33558
  import { readFileSync as readFileSync7 } from "fs";
33208
33559
  import { join as join9 } from "path";
33209
- var FAILURES = /* @__PURE__ */ new Set([
33210
- "unauthorized",
33211
- "forbidden",
33212
- "unreachable"
33213
- ]);
33214
33560
  var BREAKER_COOLDOWN_MS = 3e4;
33215
33561
  function parseForwardHealth(raw, nowMs) {
33216
33562
  try {
@@ -33219,7 +33565,8 @@ function parseForwardHealth(raw, nowMs) {
33219
33565
  const record2 = parsed2;
33220
33566
  const failures = typeof record2.consecutiveFailures === "number" && record2.consecutiveFailures >= 0 ? record2.consecutiveFailures : 0;
33221
33567
  const openedAtMs = typeof record2.openedAtMs === "number" && Number.isFinite(record2.openedAtMs) && record2.openedAtMs <= nowMs ? record2.openedAtMs : null;
33222
- const lastFailure = typeof record2.lastFailure === "string" && FAILURES.has(record2.lastFailure) ? record2.lastFailure : null;
33568
+ const parsedFailure = ControlPlaneFailure.safeParse(record2.lastFailure);
33569
+ const lastFailure = parsedFailure.success ? parsedFailure.data : null;
33223
33570
  return { consecutiveFailures: failures, openedAtMs, lastFailure };
33224
33571
  } catch {
33225
33572
  return null;
@@ -34134,6 +34481,56 @@ var CONFIG_POSTURE_RULES = [
34134
34481
  }
34135
34482
  ];
34136
34483
 
34484
+ // ../../packages/detections/src/posture/web-capture-posture.ts
34485
+ var RULE_VERSION2 = "1";
34486
+ var DRIFT_MIN_PARSE_FAILURES = 2;
34487
+ var WEB_CAPTURE_DRIFT_STATES = /* @__PURE__ */ new Set([
34488
+ "blind",
34489
+ "degraded"
34490
+ ]);
34491
+ var WEB_CAPTURE_DRIFT_RULE = {
34492
+ ruleId: "web-capture-drift",
34493
+ version: RULE_VERSION2,
34494
+ name: "Web chat capture is not reading the site",
34495
+ category: "config",
34496
+ severity: "medium",
34497
+ definition: JSON.stringify({
34498
+ kind: "web-capture-drift",
34499
+ states: [...WEB_CAPTURE_DRIFT_STATES],
34500
+ minParseFailures: DRIFT_MIN_PARSE_FAILURES
34501
+ })
34502
+ };
34503
+ var STATIC_COPY = {
34504
+ active: { headline: "turns are being observed on this site" },
34505
+ unreported: {
34506
+ // Says "recently" rather than "yet": the store read is bounded to
34507
+ // CAPTURE_STATUS_RECENCY_MS, so this state covers a site nothing has ever
34508
+ // reported for AND one whose last report has aged out. The two are the
34509
+ // same fact to a reader — nobody has confirmed anything lately — and the
34510
+ // copy may not claim the stronger of them.
34511
+ headline: `no report in the last ${String(CAPTURE_STATUS_RECENCY_DAYS)} days \u2014 open the site in Chrome with the extension loaded`
34512
+ },
34513
+ standby: {
34514
+ headline: "this build declares no endpoints for the site, so nothing is observed yet"
34515
+ },
34516
+ unpatched: {
34517
+ // Says what the flags say and no more. `patched` is false both for a tap
34518
+ // that installed and hooked neither transport and for one that never ran
34519
+ // at all — a page reports the same status either way, so the copy may not
34520
+ // assert one of them.
34521
+ headline: "the page tap captured neither fetch nor XHR \u2014 it may not have installed; reload the extension at chrome://extensions"
34522
+ },
34523
+ idle: { headline: "watching; no turn has been observed yet" },
34524
+ blind: {
34525
+ headline: "messages were sent in the page that the network capture never saw",
34526
+ 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."
34527
+ },
34528
+ degraded: {
34529
+ headline: "the site's payloads no longer carry the fields the extension reads",
34530
+ 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."
34531
+ }
34532
+ };
34533
+
34137
34534
  // ../../packages/detections/src/security/redos-probe.ts
34138
34535
  var BUDGET_MS = 100;
34139
34536
  var EXPONENTIAL_UNITS = [
@@ -36239,10 +36636,31 @@ function recordSessionModel(dataDir2, sessionId, model) {
36239
36636
  }
36240
36637
  }
36241
36638
  var TAIL_BYTES = 256 * 1024;
36639
+ var SWITCH_MODEL_REMEDY = "Switch to an approved model with /model";
36640
+ var WORDING = {
36641
+ switch: {
36642
+ subject: (model) => `Cannot switch to ${model}`,
36643
+ remedy: SWITCH_MODEL_REMEDY
36644
+ },
36645
+ turn: {
36646
+ subject: (model) => `This session is running on ${model}, which cannot be used`,
36647
+ remedy: SWITCH_MODEL_REMEDY
36648
+ },
36649
+ spawn: {
36650
+ subject: (model) => `Cannot start a subagent on ${model}`,
36651
+ remedy: "Name an approved model on the subagent"
36652
+ },
36653
+ request: {
36654
+ subject: (model) => `Cannot use ${model} for this request`,
36655
+ remedy: "Change the model this application requests"
36656
+ }
36657
+ };
36658
+ function lookupWording(action) {
36659
+ return Object.hasOwn(WORDING, action) ? WORDING[action] : void 0;
36660
+ }
36242
36661
  function prohibitedModelMessage(model, action) {
36243
- const subject = action === "switch" ? `Cannot switch to ${model}` : action === "spawn" ? `Cannot start a subagent on ${model}` : `This session is running on ${model}, which cannot be used`;
36244
- const remedy = action === "spawn" ? "Name an approved model on the subagent" : "Switch to an approved model with /model";
36245
- return `${subject} \u2014 your organization has prohibited this model. ${remedy}, or ask an administrator to change its status in AKA under Govern \u2192 LLM Providers.`;
36662
+ const { subject, remedy } = lookupWording(action) ?? WORDING.turn;
36663
+ return `${subject(model)} \u2014 your organization has prohibited this model. ${remedy}, or ask an administrator to change its status in AKA under Govern \u2192 LLM Providers.`;
36246
36664
  }
36247
36665
  function buildModelRefusalEvent(input2) {
36248
36666
  return {
@@ -36478,6 +36896,12 @@ var RemoteRequestInvalid = class extends Error {
36478
36896
  }
36479
36897
  cause;
36480
36898
  };
36899
+ var RemoteEndpointRefused = class extends Error {
36900
+ constructor(endpoint) {
36901
+ super(`refusing to talk to an unsafe control-plane endpoint: ${originOnly(endpoint)}`);
36902
+ this.name = "RemoteEndpointRefused";
36903
+ }
36904
+ };
36481
36905
  var RemoteResponseInvalid = class extends Error {
36482
36906
  constructor(route, detail) {
36483
36907
  super(`control plane answered ${route} with ${detail}`);
@@ -36630,14 +37054,15 @@ function parsed(schema, body, route) {
36630
37054
  }
36631
37055
  return result.data;
36632
37056
  }
36633
- function withoutTrailingSlashes(endpoint) {
37057
+ function resolveBaseUrl(endpoint) {
37058
+ if (!isSafeEndpoint(endpoint)) throw new RemoteEndpointRefused(endpoint);
36634
37059
  let end = endpoint.length;
36635
37060
  while (end > 0 && endpoint.charCodeAt(end - 1) === SLASH2) end -= 1;
36636
37061
  return endpoint.slice(0, end);
36637
37062
  }
36638
37063
  var SLASH2 = "/".charCodeAt(0);
36639
37064
  function createRemoteClient(options) {
36640
- const base = withoutTrailingSlashes(options.endpoint);
37065
+ const base = resolveBaseUrl(options.endpoint);
36641
37066
  const url2 = (route) => `${base}${route}`;
36642
37067
  const common = { apiKey: options.apiKey, timeoutMs: options.timeoutMs };
36643
37068
  const sendOne = async (event) => {
@@ -36767,6 +37192,7 @@ function classifyRemoteFailure(err) {
36767
37192
  case "RemoteRouteAbsent":
36768
37193
  return "route-absent";
36769
37194
  case "RemoteRequestInvalid":
37195
+ case "RemoteEndpointRefused":
36770
37196
  return "invalid-request";
36771
37197
  case "RemoteResponseInvalid":
36772
37198
  return "rejected";
@@ -36970,86 +37396,10 @@ function createForwardPolicy(deps) {
36970
37396
  }
36971
37397
 
36972
37398
  // ../../packages/plugin-runtime/src/attached/gateway.ts
36973
- function strongerOf(a, b) {
36974
- if (a === null) return b;
36975
- if (b === null) return a;
36976
- return strongerAction(a, b);
36977
- }
36978
- function ruleCategoryMap(wireRules, localRules) {
36979
- const map2 = /* @__PURE__ */ new Map();
36980
- for (const rule of wireRules ?? []) map2.set(rule.id, rule.category);
36981
- for (const rule of localRules ?? []) map2.set(rule.id, rule.category);
36982
- for (const pack of bundledDetections()) {
36983
- for (const rule of pack.rules) map2.set(rule.id, rule.category);
36984
- }
36985
- return map2;
36986
- }
36987
- function policyKey(policy) {
36988
- return "ruleId" in policy.target ? `rule:${policy.target.ruleId}` : `category:${policy.target.category}`;
36989
- }
36990
- function floorFor(policy, categoryByRuleId) {
36991
- const category = "category" in policy.target ? policy.target.category : categoryByRuleId.get(policy.target.ruleId);
36992
- return category === void 0 ? null : DEFAULT_ACTIONS[category];
36993
- }
36994
- function mergeRaiseOnly(localPolicies, remotePolicies, categoryByRuleId) {
36995
- const merged = /* @__PURE__ */ new Map();
36996
- const disabled = [];
36997
- const remoteCategoryAction = /* @__PURE__ */ new Map();
36998
- for (const policy of remotePolicies) {
36999
- if (!policy.enabled) continue;
37000
- if (!("category" in policy.target)) continue;
37001
- if (remoteCategoryAction.has(policy.target.category)) continue;
37002
- const floor = floorFor(policy, categoryByRuleId);
37003
- remoteCategoryAction.set(
37004
- policy.target.category,
37005
- floor !== null && !isActionAtLeast(policy.action, floor) ? floor : policy.action
37006
- );
37007
- }
37008
- for (const policy of localPolicies) {
37009
- if (!policy.enabled) {
37010
- disabled.push(policy);
37011
- continue;
37012
- }
37013
- const key = policyKey(policy);
37014
- if (merged.has(key)) continue;
37015
- let remoteFloor = null;
37016
- if ("ruleId" in policy.target) {
37017
- const category = categoryByRuleId.get(policy.target.ruleId);
37018
- if (category !== void 0) remoteFloor = remoteCategoryAction.get(category) ?? null;
37019
- }
37020
- merged.set(
37021
- key,
37022
- remoteFloor !== null && !isActionAtLeast(policy.action, remoteFloor) ? { ...policy, action: remoteFloor } : policy
37023
- );
37024
- }
37025
- const localCategoryAction = /* @__PURE__ */ new Map();
37026
- for (const policy of merged.values()) {
37027
- if ("category" in policy.target) localCategoryAction.set(policy.target.category, policy.action);
37028
- }
37029
- for (const policy of remotePolicies) {
37030
- if (!policy.enabled) {
37031
- disabled.push(policy);
37032
- continue;
37033
- }
37034
- const key = policyKey(policy);
37035
- const floor = floorFor(policy, categoryByRuleId);
37036
- let localFloor = null;
37037
- if ("ruleId" in policy.target) {
37038
- const category = categoryByRuleId.get(policy.target.ruleId);
37039
- if (category !== void 0) localFloor = localCategoryAction.get(category) ?? null;
37040
- }
37041
- const effectiveFloor = strongerOf(floor, localFloor);
37042
- const clamped = effectiveFloor !== null && !isActionAtLeast(policy.action, effectiveFloor) ? { ...policy, action: effectiveFloor } : policy;
37043
- const existing = merged.get(key);
37044
- if (existing === void 0) {
37045
- merged.set(key, clamped);
37046
- continue;
37047
- }
37048
- if (actionRank(clamped.action) > actionRank(existing.action)) {
37049
- merged.set(key, clamped);
37050
- }
37051
- }
37052
- return [...merged.values(), ...disabled];
37399
+ var bundledRulesFlatCache;
37400
+ function bundledRulesFlat() {
37401
+ bundledRulesFlatCache ??= bundledDetections().flatMap((pack) => pack.rules);
37402
+ return bundledRulesFlatCache;
37053
37403
  }
37054
37404
  var AttachedDataGateway = class {
37055
37405
  constructor(deps) {
@@ -37369,6 +37719,9 @@ var AttachedDataGateway = class {
37369
37719
  async readSessionProvider(sessionId) {
37370
37720
  return this.deps.local.readSessionProvider(sessionId);
37371
37721
  }
37722
+ async readCaptureStatuses() {
37723
+ return this.deps.local.readCaptureStatuses();
37724
+ }
37372
37725
  async facets() {
37373
37726
  return this.deps.local.facets();
37374
37727
  }
@@ -37451,7 +37804,7 @@ var AttachedDataGateway = class {
37451
37804
  policies: mergeRaiseOnly(
37452
37805
  local.policies,
37453
37806
  cached2.policies,
37454
- ruleCategoryMap(cached2.rules, local.rules)
37807
+ ruleCategoryMap(cached2.rules, local.rules, bundledRulesFlat())
37455
37808
  ),
37456
37809
  customKeywords: [...local.customKeywords, ...cached2.customKeywords],
37457
37810
  // TAKEN FROM THE CACHE, unlike the two fields below — and the asymmetry
@@ -37652,10 +38005,15 @@ import { join as join28 } from "path";
37652
38005
  // ../../packages/plugin-runtime/src/attached/atomic-publish.ts
37653
38006
  import { rename as rename2 } from "fs/promises";
37654
38007
  var RETRYABLE = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
37655
- var ATTEMPTS = 5;
38008
+ var IMMEDIATE_RETRIES = 8;
38009
+ var TIMED_RETRIES = 4;
38010
+ var ATTEMPTS = 1 + IMMEDIATE_RETRIES + TIMED_RETRIES;
37656
38011
  var delay = (ms) => new Promise((resolve2) => {
37657
38012
  setTimeout(resolve2, ms);
37658
38013
  });
38014
+ var yieldToLoop = () => new Promise((resolve2) => {
38015
+ setImmediate(resolve2);
38016
+ });
37659
38017
  async function publishByRename(tmp, file2, move = rename2) {
37660
38018
  for (let attempt = 1; ; attempt += 1) {
37661
38019
  try {
@@ -37664,7 +38022,7 @@ async function publishByRename(tmp, file2, move = rename2) {
37664
38022
  } catch (err) {
37665
38023
  const code = err.code;
37666
38024
  if (attempt >= ATTEMPTS || code === void 0 || !RETRYABLE.has(code)) throw err;
37667
- await delay(attempt * 10);
38025
+ await (attempt <= IMMEDIATE_RETRIES ? yieldToLoop() : delay((attempt - IMMEDIATE_RETRIES) * 10));
37668
38026
  }
37669
38027
  }
37670
38028
  }
@@ -38128,6 +38486,9 @@ var StandaloneDataGateway = class {
38128
38486
  readSessionProvider(sessionId) {
38129
38487
  return Promise.resolve(this.db.auditEvents.sessionProvider(sessionId));
38130
38488
  }
38489
+ readCaptureStatuses() {
38490
+ return Promise.resolve(this.db.captureStatus.latest(Date.now()));
38491
+ }
38131
38492
  facets() {
38132
38493
  return Promise.resolve(this.db.facets());
38133
38494
  }