@akasecurity/ai-tc-claude-code 0.9.11 → 0.9.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -50,7 +50,7 @@ var require_ignore = __commonJS({
50
50
  var REGEX_SPLITALL_CRLF = /\r?\n/g;
51
51
  var REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/;
52
52
  var REGEX_TEST_TRAILING_SLASH = /\/$/;
53
- var SLASH2 = "/";
53
+ var SLASH3 = "/";
54
54
  var TMP_KEY_IGNORE = "node-ignore";
55
55
  if (typeof Symbol !== "undefined") {
56
56
  TMP_KEY_IGNORE = /* @__PURE__ */ Symbol.for("node-ignore");
@@ -422,11 +422,11 @@ var require_ignore = __commonJS({
422
422
  if (!REGEX_TEST_TRAILING_SLASH.test(path)) {
423
423
  return this.test(path);
424
424
  }
425
- const slices = path.split(SLASH2).filter(Boolean);
425
+ const slices = path.split(SLASH3).filter(Boolean);
426
426
  slices.pop();
427
427
  if (slices.length) {
428
428
  const parent = this._t(
429
- slices.join(SLASH2) + SLASH2,
429
+ slices.join(SLASH3) + SLASH3,
430
430
  this._testCache,
431
431
  true,
432
432
  slices
@@ -442,14 +442,14 @@ var require_ignore = __commonJS({
442
442
  return cache[path];
443
443
  }
444
444
  if (!slices) {
445
- slices = path.split(SLASH2).filter(Boolean);
445
+ slices = path.split(SLASH3).filter(Boolean);
446
446
  }
447
447
  slices.pop();
448
448
  if (!slices.length) {
449
449
  return cache[path] = this._rules.test(path, checkUnignored, MODE_IGNORE);
450
450
  }
451
451
  const parent = this._t(
452
- slices.join(SLASH2) + SLASH2,
452
+ slices.join(SLASH3) + SLASH3,
453
453
  cache,
454
454
  checkUnignored,
455
455
  slices
@@ -493,7 +493,7 @@ var require_ignore = __commonJS({
493
493
 
494
494
  // ../../packages/plugin-sdk/src/config.ts
495
495
  import { existsSync as existsSync8 } from "fs";
496
- import { join as join14 } from "path";
496
+ import { join as join16 } from "path";
497
497
 
498
498
  // ../../packages/persistence/src/attached-derived.ts
499
499
  import { rmSync } from "fs";
@@ -503,6 +503,14 @@ import { join } from "path";
503
503
  import { chmodSync as chmodSync2, lstatSync as lstatSync2, readFileSync, rmSync as rmSync3, statSync } from "fs";
504
504
  import { join as join2 } from "path";
505
505
 
506
+ // ../../packages/schema/src/drizzle/deferred-migrations.ts
507
+ var DEFERRED_MIGRATION_TAGS = [
508
+ "0031_audit_capture_by_time_index",
509
+ "0032_audit_capture_by_id_index",
510
+ "0033_audit_capture_location_index",
511
+ "0034_findings_read_indexes"
512
+ ];
513
+
506
514
  // ../../packages/schema/src/exception-scope.ts
507
515
  var MINUTE_MS = 6e4;
508
516
  var HOUR_MS = 60 * MINUTE_MS;
@@ -20215,7 +20223,17 @@ var UNPRICEABLE_PROVIDERS = Object.freeze([
20215
20223
  "gateway",
20216
20224
  "unknown",
20217
20225
  "cli",
20218
- "api"
20226
+ "api",
20227
+ // The browser extension's native host records these as `llm_call.provider`
20228
+ // for a web-chat turn — the web tool id, deliberately never the vendor id
20229
+ // (`openai`/`anthropic`) the session root carries. Subscription traffic
20230
+ // burns rate-limit budget, not dollar credits, and listing them here is
20231
+ // what keeps that true structurally: a later maintainer who wants to price
20232
+ // web-chat traffic at API rates has to delete this entry first, and meet
20233
+ // the reason on the way, rather than quietly adding one to
20234
+ // PROVIDER_PLATFORM.
20235
+ "chatgpt",
20236
+ "claude-ai"
20219
20237
  ]);
20220
20238
 
20221
20239
  // ../../packages/schema/src/token/format.ts
@@ -20235,7 +20253,12 @@ var HARNESS = {
20235
20253
  ClaudeDesktop: "claudedesktop",
20236
20254
  ChatGpt: "chatgpt",
20237
20255
  ClaudeAi: "claudeai",
20238
- Api: "api"
20256
+ Api: "api",
20257
+ // Not a coding assistant a person drives — an in-process SDK embedded in an
20258
+ // application, so it has no IDE/CLI/desktop/web surface of its own. Carries
20259
+ // the same id as its SOURCE_TOOL counterpart, unlike every capture-side tool
20260
+ // whose wire spelling differs from its display spelling.
20261
+ AiTcSdk: "ai-tc-sdk"
20239
20262
  };
20240
20263
  var Harness = external_exports.enum(HARNESS).meta({ id: "Harness" });
20241
20264
  var SOURCE_TOOL = {
@@ -20251,9 +20274,15 @@ var SOURCE_TOOL = {
20251
20274
  // whose tool could not be identified both render through the read side's
20252
20275
  // miss path rather than as a harness of their own.
20253
20276
  Cli: "cli",
20254
- Unknown: "unknown"
20277
+ Unknown: "unknown",
20278
+ // The wire id an in-process, request-path SDK stamps on its own structural
20279
+ // rows (`request_decision`) — never a capture of prompt/response/tool text,
20280
+ // since the SDK sits in front of a model call rather than inside a coding
20281
+ // assistant's own hook contract.
20282
+ AiTcSdk: "ai-tc-sdk"
20255
20283
  };
20256
20284
  var SourceTool = external_exports.enum(SOURCE_TOOL).meta({ id: "SourceTool" });
20285
+ var WebSourceTool = SourceTool.extract(["ChatGpt", "ClaudeAi"]);
20257
20286
  var TOOL_TO_HARNESS = {
20258
20287
  [SOURCE_TOOL.ClaudeCode]: HARNESS.ClaudeCode,
20259
20288
  [SOURCE_TOOL.ClaudeDesktop]: HARNESS.ClaudeDesktop,
@@ -20262,7 +20291,12 @@ var TOOL_TO_HARNESS = {
20262
20291
  [SOURCE_TOOL.ChatGpt]: HARNESS.ChatGpt,
20263
20292
  [SOURCE_TOOL.Codex]: HARNESS.Codex,
20264
20293
  [SOURCE_TOOL.Antigravity]: HARNESS.Antigravity,
20265
- [SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi
20294
+ [SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi,
20295
+ // Wire and display id are the same string here, but the row still belongs:
20296
+ // both vocabularies carry the `AiTcSdk` member, and the join is exactly
20297
+ // their intersection — leaving a shared member out would read as an
20298
+ // uninstrumented tool on both surfaces, which this one is not.
20299
+ [SOURCE_TOOL.AiTcSdk]: HARNESS.AiTcSdk
20266
20300
  };
20267
20301
 
20268
20302
  // ../../packages/schema/src/zod/finding.ts
@@ -20296,7 +20330,8 @@ var FindingProvider = Harness.extract([
20296
20330
  "ClaudeAi",
20297
20331
  "Codex",
20298
20332
  "Antigravity",
20299
- "Api"
20333
+ "Api",
20334
+ "AiTcSdk"
20300
20335
  ]).meta({ id: "FindingProvider" });
20301
20336
  var FindingCategory = external_exports.enum([
20302
20337
  "secret",
@@ -20312,6 +20347,15 @@ var FindingCategory = external_exports.enum([
20312
20347
  ]).meta({ id: "FindingCategory" });
20313
20348
  var FindingOrigin = external_exports.enum(["in-flight", "at-rest"]).meta({ id: "FindingOrigin" });
20314
20349
  var FindingStatus = external_exports.enum(["open", "handled", "resolved", "dismissed"]).meta({ id: "FindingStatus" });
20350
+ var SyncFailureReason = external_exports.enum(["deployment_refused", "payload_invalid", "detached_undelivered"]).meta({ id: "SyncFailureReason" });
20351
+ var FindingDeliveryState = external_exports.enum(["sent", "queued", "not_sent", "never_offered", "local_scan"]).meta({ id: "FindingDeliveryState" });
20352
+ var FindingDelivery = external_exports.object({
20353
+ state: FindingDeliveryState,
20354
+ // The delivery time for `sent`; the failure time for `not_sent` when recorded.
20355
+ at: external_exports.iso.datetime().optional(),
20356
+ // Only on `not_sent`, and only when a known reason was recorded.
20357
+ reason: SyncFailureReason.optional()
20358
+ }).meta({ id: "FindingDelivery" });
20315
20359
  var ResolutionMethod = external_exports.enum([
20316
20360
  "enforced-in-flight",
20317
20361
  "fixed-at-source",
@@ -20368,7 +20412,10 @@ var FindingInstance = external_exports.object({
20368
20412
  // The session that event belongs to, when it has one — the seam a
20369
20413
  // per-instance "view session" link needs. Absent for events captured
20370
20414
  // outside a session.
20371
- sessionId: external_exports.string().optional()
20415
+ sessionId: external_exports.string().optional(),
20416
+ // The delivery state of the event above (see FindingDelivery). Optional so
20417
+ // readers that do not project it stay valid.
20418
+ delivery: FindingDelivery.optional()
20372
20419
  }).meta({ id: "FindingInstance" });
20373
20420
  var FindingGroup = external_exports.object({
20374
20421
  id: external_exports.string(),
@@ -20420,7 +20467,10 @@ var FindingFacets = external_exports.object({
20420
20467
  // Host tool (attributes.tool_name). Present only on the instance-level
20421
20468
  // reads, which can filter by it; the type-level read omits the dimension
20422
20469
  // because a group spans tools.
20423
- tool: external_exports.array(FindingFacetItem).optional()
20470
+ tool: external_exports.array(FindingFacetItem).optional(),
20471
+ // Delivery states (FindingDeliveryState). Present only on the
20472
+ // instance-level reads, like `tool`.
20473
+ deployment: external_exports.array(FindingFacetItem).optional()
20424
20474
  }).meta({ id: "FindingFacets" });
20425
20475
  var FindingTypeSummary = FindingGroup.omit({ instances: true, match: true }).meta({
20426
20476
  id: "FindingTypeSummary"
@@ -20529,6 +20579,8 @@ var ListFindingInstancesQuery = external_exports.object({
20529
20579
  // Exact host-tool names (attributes.tool_name, e.g. 'Bash'). A real filter,
20530
20580
  // where the free-text `q` can only match the rendered "via Bash" label.
20531
20581
  tool: external_exports.array(external_exports.string()).optional(),
20582
+ // The delivery state of each finding's event (see FindingDelivery).
20583
+ deployment: external_exports.array(FindingDeliveryState).optional(),
20532
20584
  // Exact repository / file-path matches, for the drill-down out of the
20533
20585
  // locations view. A row whose event carries no repo/file matches neither.
20534
20586
  repo: external_exports.string().optional(),
@@ -20549,6 +20601,10 @@ var ListFindingInstancesResponse = external_exports.object({
20549
20601
  items: external_exports.array(FindingInstanceDetail),
20550
20602
  nextCursor: external_exports.string().nullable()
20551
20603
  }).meta({ id: "ListFindingInstancesResponse" });
20604
+ var ListFindingInstancesPage = external_exports.object({
20605
+ items: external_exports.array(FindingInstanceDetail),
20606
+ nextCursor: external_exports.string().nullable()
20607
+ }).meta({ id: "ListFindingInstancesPage" });
20552
20608
  var FindingLocationSummary = external_exports.object({
20553
20609
  // Opaque, stable, minted from the pair by encodeLocationId. It exists
20554
20610
  // because a location's identity is two values and a URL param carries one:
@@ -20590,6 +20646,8 @@ var ListFindingLocationsQuery = external_exports.object({
20590
20646
  // instances that match, and folds its status from those.
20591
20647
  status: external_exports.array(FindingStatus).optional(),
20592
20648
  tool: external_exports.array(external_exports.string()).optional(),
20649
+ // The delivery state of each finding's event (see FindingDelivery).
20650
+ deployment: external_exports.array(FindingDeliveryState).optional(),
20593
20651
  q: external_exports.string().optional(),
20594
20652
  sessionId: external_exports.string().optional(),
20595
20653
  from: external_exports.iso.datetime().optional(),
@@ -20647,18 +20705,41 @@ var AuditEventType = external_exports.enum([
20647
20705
  // 'tool_call' is the reconciler's structural row for every call, while
20648
20706
  // 'tool_use' exists only where a hook enforced against the arguments.
20649
20707
  "tool_use",
20650
- // One row per model REFUSAL: a switch onto a prohibited model that was
20651
- // denied, or a turn refused because the session was already running on one.
20652
- // A structural row like the ones above rather than a capture — it carries
20653
- // the model that was refused and nothing the user typed, because what is
20654
- // worth recording about a governance decision is the decision, and prompt
20655
- // text is the thing this product exists to keep from travelling.
20708
+ // One row per model REFUSAL, across all four seams a prohibited model can be
20709
+ // stopped at: a switch onto it, a turn already running on it, a subagent
20710
+ // spawn asking for it, or a request-path refusal an embedded request-path
20711
+ // SDK makes in-process before the call leaves the application. Which seam
20712
+ // rides `attributes.refusal_seam`, never this member name. A structural row
20713
+ // like the ones above rather than a capture — it carries the model that was
20714
+ // refused and nothing the user typed, because what is worth recording about
20715
+ // a governance decision is the decision, and prompt text is the thing this
20716
+ // product exists to keep from travelling.
20656
20717
  "model_refusal",
20718
+ // One row per request-path DECISION: a policy check an embedded request-path
20719
+ // SDK performs in-process before a model call leaves the application, or
20720
+ // against that call's non-streamed response. A structural row like
20721
+ // 'model_refusal' rather than a capture — content-free in the same way:
20722
+ // which side, which seam, what action and which field are decided rides
20723
+ // `attributes`, never this member name, and the matched text itself never
20724
+ // travels.
20725
+ //
20726
+ // A prohibited-model refusal on the request path is deliberately NOT this
20727
+ // member: it stays 'model_refusal' with `refusal_seam: 'request'`, so it
20728
+ // shares one bucket with the plugin's switch/turn/spawn refusals rather
20729
+ // than splitting one governance concept across two event types. This
20730
+ // member carries every OTHER request-path decision.
20731
+ "request_decision",
20657
20732
  // One row per config-inventory scan, hung off the session root. It is the
20658
20733
  // fact the posture inspection findings reference (findings require an
20659
20734
  // audit_event_id), and its started_at is the "scanned Nm ago" the read
20660
20735
  // surface renders.
20661
- "config_scan"
20736
+ "config_scan",
20737
+ // One row per reported browser-extension capture status, hung off the web
20738
+ // session root. The durable home of what one tab's network interception
20739
+ // is doing — a write-through of the native host's in-memory tracker, so a
20740
+ // second process (aka extension status) and a restarted host both have
20741
+ // somewhere to read it back from.
20742
+ "capture_status"
20662
20743
  ]).meta({ id: "AuditEventType" });
20663
20744
  var AttributeBag = external_exports.record(external_exports.string(), external_exports.unknown());
20664
20745
  var HostAttributes = external_exports.object({
@@ -20792,6 +20873,10 @@ var CaptureAttributes = external_exports.object({
20792
20873
  // to 'allow' — the enforcement audit trail's link back to the grant that
20793
20874
  // authorized the bypass.
20794
20875
  exception_ids: external_exports.array(external_exports.guid()).optional(),
20876
+ // The persisted spellings of EventMetadata's messageId/conversationId — the
20877
+ // join back to the `llm_call` leaf for the same assistant turn.
20878
+ message_id: external_exports.string().optional(),
20879
+ conversation_id: external_exports.string().optional(),
20795
20880
  // Whole milliseconds this capture's inspection blocked its caller — the
20796
20881
  // plugin's own added latency (see EventMetadata.inspectionMs, whose value
20797
20882
  // this is). Promoted to the `inspection_ms` generated column so the facet is
@@ -20800,7 +20885,33 @@ var CaptureAttributes = external_exports.object({
20800
20885
  // inline json_extract and is not itself an optimization.
20801
20886
  // ABSENT on replayed captures (backfill / worktree scan) and on rows written
20802
20887
  // before the measurement shipped — never present as a placeholder 0.
20803
- inspection_ms: external_exports.number().int().nonnegative().optional()
20888
+ inspection_ms: external_exports.number().int().nonnegative().optional(),
20889
+ // What a `redact` this capture could not carry out became instead (see
20890
+ // EventMetadata.redactDegradedTo, whose value this is). Present only when a
20891
+ // degrade actually happened, so absence is the ordinary case rather than a
20892
+ // reader having to distinguish it from a zero.
20893
+ //
20894
+ // PER CAPTURE, while `inspection_findings.action_taken` is per finding —
20895
+ // so on a multi-finding row this does not say which finding degraded, and
20896
+ // its presence does not mean the fallback decided the capture's action. A
20897
+ // capture denied by another finding's own Block policy carries `block`
20898
+ // here too. The full statement is on EventMetadata.redactDegradedTo; it is
20899
+ // repeated rather than referenced because a store reader opens this file.
20900
+ redact_degraded_to: ActionTaken.optional()
20901
+ }).catchall(external_exports.unknown());
20902
+ var CaptureStatusAttributes = external_exports.object({
20903
+ source_tool: external_exports.string().optional(),
20904
+ patched: external_exports.boolean().optional(),
20905
+ live: external_exports.boolean().optional(),
20906
+ blind: external_exports.boolean().optional(),
20907
+ sends_seen_dom: external_exports.number().int().nonnegative().optional(),
20908
+ exchanges_seen_net: external_exports.number().int().nonnegative().optional(),
20909
+ parse_failures: external_exports.number().int().nonnegative().optional(),
20910
+ unparsed_bodies: external_exports.number().int().nonnegative().optional(),
20911
+ shape_misses: external_exports.array(external_exports.string()).optional(),
20912
+ conversation_endpoints: external_exports.number().int().nonnegative().optional(),
20913
+ closed: external_exports.boolean().optional(),
20914
+ enforcement: external_exports.string().optional()
20804
20915
  }).catchall(external_exports.unknown());
20805
20916
  var ToolCallInspection = external_exports.object({
20806
20917
  ruleId: external_exports.string().min(1),
@@ -20996,7 +21107,17 @@ var AuditEvent = external_exports.object({
20996
21107
  /** `share` to a first-party/internal destination. */
20997
21108
  internal: external_exports.boolean(),
20998
21109
  /** Event needs review (e.g. unverified egress). */
20999
- flagged: external_exports.boolean()
21110
+ flagged: external_exports.boolean(),
21111
+ /**
21112
+ * The body this event's `title` is drawn from was cleared by local body
21113
+ * expiry, so an EMPTY title here means "gone", not "never had one".
21114
+ *
21115
+ * A separate flag rather than a sentinel written into `title`: the title is
21116
+ * rendered text, and a store-layer module that invented display copy for it
21117
+ * would be choosing words the view is supposed to choose. Additive and
21118
+ * defaulted, so an older producer still validates.
21119
+ */
21120
+ bodyExpired: external_exports.boolean().default(false)
21000
21121
  }).meta({ id: "ActivityAuditEvent" });
21001
21122
  var ActivitySessionSummary = external_exports.object({
21002
21123
  id: external_exports.string(),
@@ -21801,6 +21922,11 @@ var RemoteFailureKind = external_exports.enum([
21801
21922
  "rejected",
21802
21923
  "unreachable"
21803
21924
  ]);
21925
+ var ControlPlaneFailure = RemoteFailureKind.extract([
21926
+ "unauthorized",
21927
+ "forbidden",
21928
+ "unreachable"
21929
+ ]);
21804
21930
  var AttachDeviceRequest = external_exports.object({
21805
21931
  // This machine's own continuity id, so re-attaching ROTATES the credential
21806
21932
  // on one machine record instead of producing a second one. Client-minted
@@ -22219,6 +22345,17 @@ var EventMetadata = external_exports.object({
22219
22345
  // to 'allow' — the enforcement audit trail's link back to the grant that
22220
22346
  // authorized the bypass. Absent on captures where no exception applied.
22221
22347
  exceptionIds: external_exports.array(external_exports.guid()).optional(),
22348
+ // The assistant message this capture belongs to, and the conversation it sits
22349
+ // in — set by the browser extension's network capture so a stored `response`
22350
+ // row can be joined to the `llm_call` leaf describing the same turn. Absent
22351
+ // on every other capture path, which has no such id.
22352
+ //
22353
+ // Non-empty for the reason WebExchange.messageId is: it is the join key, and
22354
+ // a blank one matches no `llm_call` leaf. That refusal reaches only the
22355
+ // places an event is PARSED; the local write path types the event and parses
22356
+ // nothing, which is why `toCaptureAttributes` omits a blank one separately.
22357
+ messageId: external_exports.string().min(1).optional(),
22358
+ conversationId: external_exports.string().optional(),
22222
22359
  // How long THIS capture's inspection blocked its caller, in whole
22223
22360
  // milliseconds — the plugin's own added latency, NOT the LLM call it sat in
22224
22361
  // front of. Measured inside `capture()` (@akasecurity/plugin-sdk) across
@@ -22231,7 +22368,37 @@ var EventMetadata = external_exports.object({
22231
22368
  // Absent is also what every pre-measurement client writes, and what a
22232
22369
  // clock failure degrades to — a reader must treat absence as "not measured"
22233
22370
  // and never as a zero, which would read as "inspection is free".
22234
- inspectionMs: external_exports.number().int().nonnegative().optional()
22371
+ inspectionMs: external_exports.number().int().nonnegative().optional(),
22372
+ // What a `redact` this capture COULD NOT CARRY OUT became instead — the
22373
+ // workspace's `redactFallback`, applied because the field could not be
22374
+ // masked in place (a shell command, a URL, or any argument on a host whose
22375
+ // hook contract offers no rewrite channel).
22376
+ //
22377
+ // It exists because the action alone cannot say why. A finding recorded as
22378
+ // `warn` reads identically whether its detection was ASSIGNED Warn or was
22379
+ // assigned Redact on a field that could not take one — and those are
22380
+ // different facts about the same row: the first is a policy the user chose,
22381
+ // the second is a masking the host could not perform. Absent means no
22382
+ // degrade happened, which is every ordinary capture.
22383
+ //
22384
+ // TWO LIMITS a reader of a stored row has to know, because the grain here
22385
+ // is the CAPTURE while `actionTaken` is per FINDING:
22386
+ //
22387
+ // - It does not say WHICH finding degraded. A capture carrying a degraded
22388
+ // `redact` alongside a finding ASSIGNED the same action stores both
22389
+ // identically and one reason for the pair; attributing it to both
22390
+ // describes the assigned one wrongly, and to neither loses the degrade.
22391
+ // - PRESENCE IS NOT CAUSATION. The value is the action the lost redact
22392
+ // became, not the reason the capture ended as it did — a capture denied
22393
+ // by some other finding's own Block policy still carries `block` here,
22394
+ // and clearing the workspace's fallback would not have let it through.
22395
+ // Gate on the value against what a fallback can produce; never read the
22396
+ // field's presence as "this was the fallback's doing".
22397
+ //
22398
+ // Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
22399
+ // Closing either means moving the reason onto the finding row, which
22400
+ // already carries its own action.
22401
+ redactDegradedTo: ActionTaken.optional()
22235
22402
  }).meta({ id: "EventMetadata" });
22236
22403
  var Event = external_exports.object({
22237
22404
  id: external_exports.guid(),
@@ -22341,6 +22508,15 @@ var RotateKeyInput = external_exports.object({
22341
22508
  confirmation: external_exports.string()
22342
22509
  });
22343
22510
 
22511
+ // ../../packages/schema/src/zod/finding-delivery.ts
22512
+ var KNOWN_REASONS = SyncFailureReason.options;
22513
+
22514
+ // ../../packages/schema/src/zod/findings-group-build.ts
22515
+ function rankByOrder(members2) {
22516
+ return Object.fromEntries(members2.map((member, index) => [member, index]));
22517
+ }
22518
+ var SEVERITY_RANK = rankByOrder(Severity.options);
22519
+
22344
22520
  // ../../packages/schema/src/zod/installed-pack.ts
22345
22521
  var InstalledPack = external_exports.object({
22346
22522
  id: external_exports.guid(),
@@ -22407,6 +22583,11 @@ var Policy = external_exports.object({
22407
22583
  // test `prohibitedModels` passes and `reversibleRuleIds` fails.
22408
22584
  provenance: PolicyProvenance.optional()
22409
22585
  }).meta({ id: "Policy" });
22586
+ var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
22587
+ var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
22588
+ var RedactFallback = BuiltinPolicyId.extract(["monitor", "warn", "block"]).meta({
22589
+ id: "RedactFallback"
22590
+ });
22410
22591
  var PolicyBundle = external_exports.object({
22411
22592
  version: external_exports.string(),
22412
22593
  policies: external_exports.array(Policy),
@@ -22454,6 +22635,16 @@ var PolicyBundle = external_exports.object({
22454
22635
  // control plane), so no name resolution stands between the decision and the
22455
22636
  // comparison.
22456
22637
  prohibitedModels: external_exports.array(external_exports.string()).optional(),
22638
+ // What a resolved `redact` becomes on a field the host cannot rewrite, as
22639
+ // the ORGANIZATION would have it. Merged raise-only against the device's own
22640
+ // `WorkspaceSettings.redactFallback` (see strongerRedactFallback below), so
22641
+ // a control plane can tighten a machine and never loosen one — the same
22642
+ // direction `mergeRaiseOnly` enforces for policies.
22643
+ //
22644
+ // Optional so an older backend, and an older on-disk cache, still parses;
22645
+ // absent leaves the device's own setting in force, which is the behaviour
22646
+ // that predates the field and the safe direction to default.
22647
+ redactFallback: RedactFallback.optional(),
22457
22648
  customKeywords: external_exports.array(external_exports.string()),
22458
22649
  fetchedAt: external_exports.iso.datetime()
22459
22650
  }).meta({ id: "PolicyBundle" });
@@ -22483,11 +22674,6 @@ function severityFloorPolicy(category) {
22483
22674
  const peak = CATEGORY_PEAK_SEVERITY[category];
22484
22675
  return peak === "critical" || peak === "high" ? "warn" : "monitor";
22485
22676
  }
22486
- var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
22487
- var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
22488
- var RedactFallback = BuiltinPolicyId.extract(["monitor", "warn", "block"]).meta({
22489
- id: "RedactFallback"
22490
- });
22491
22677
  var BUILTIN_POLICY_SPECS = {
22492
22678
  monitor: {
22493
22679
  name: "Monitor",
@@ -22750,7 +22936,7 @@ var VaultConsent = external_exports.object({
22750
22936
  });
22751
22937
 
22752
22938
  // ../../packages/schema/src/zod/local.ts
22753
- var WORKSPACE_SETTINGS_SPEC_VERSION = 7;
22939
+ var WORKSPACE_SETTINGS_SPEC_VERSION = 8;
22754
22940
  var MODEL_JUDGE_PAYLOAD_VERSION = 1;
22755
22941
  var RunMode = external_exports.enum(["standalone", "attached"]);
22756
22942
  var ControlPlaneConnection = external_exports.object({
@@ -22770,6 +22956,27 @@ var HistorySyncConsent = external_exports.object({
22770
22956
  payloadVersion: external_exports.number().int().positive(),
22771
22957
  endpoint: external_exports.string()
22772
22958
  });
22959
+ var WebChatCaptureConsent = external_exports.object({
22960
+ acknowledgedAt: external_exports.iso.datetime(),
22961
+ version: external_exports.number().int().positive()
22962
+ });
22963
+ var WebChatResponseCapture = external_exports.enum(["with-findings", "always", "never"]);
22964
+ var WebChatCapture = external_exports.object({
22965
+ responses: WebChatResponseCapture.default("with-findings"),
22966
+ account: external_exports.boolean().default(false),
22967
+ // Absent until granted. Presence alone does not authorize anything — see
22968
+ // isWebChatCaptureConsentValid.
22969
+ consent: WebChatCaptureConsent.optional()
22970
+ });
22971
+ var BODY_RETENTION_DEFAULT_DAYS = 30;
22972
+ var BodyRetention = external_exports.object({
22973
+ enabled: external_exports.boolean().default(false),
22974
+ // Never 0, and the ceiling is a fat-finger guard rather than a policy
22975
+ // limit — `enabled` is the real gate. A low value cannot reach a row the
22976
+ // sync ledger still owes: the sweep's age filter only ever NARROWS a
22977
+ // candidate set that is already bounded by "delivered, or never owed".
22978
+ retainDays: external_exports.number().int().min(1).max(3650).default(BODY_RETENTION_DEFAULT_DAYS)
22979
+ }).meta({ id: "BodyRetention" });
22773
22980
  var WorkspaceSettings = external_exports.object({
22774
22981
  specVersion: external_exports.number().int().positive().default(WORKSPACE_SETTINGS_SPEC_VERSION),
22775
22982
  runMode: RunMode.default("standalone"),
@@ -22818,7 +23025,23 @@ var WorkspaceSettings = external_exports.object({
22818
23025
  // carry prompt/reply/tool-output text in `content`; the key name predates
22819
23026
  // both widenings. Absent until granted, and a grant for a different endpoint
22820
23027
  // or an older payload no longer counts.
22821
- historySyncConsent: HistorySyncConsent.optional()
23028
+ historySyncConsent: HistorySyncConsent.optional(),
23029
+ // What the browser extension may record from a web chat, and the grant that
23030
+ // authorizes it. Absent until the user answers: recording something that was
23031
+ // never recorded before is never an assumed grant on upgrade, so the whole
23032
+ // block is optional rather than defaulted in. What an absent block means is
23033
+ // webChatCaptureOf's answer, in one place.
23034
+ //
23035
+ // Enforcement is NOT gated on this. A machine that has never answered still
23036
+ // blocks, redacts and warns on what a user sends; the grant covers what is
23037
+ // written down.
23038
+ webChatCapture: WebChatCapture.optional(),
23039
+ // Local body expiry (see BodyRetention). Off until switched on; expiring a
23040
+ // body never removes the row or its findings.
23041
+ bodyRetention: BodyRetention.default({
23042
+ enabled: false,
23043
+ retainDays: BODY_RETENTION_DEFAULT_DAYS
23044
+ })
22822
23045
  });
22823
23046
  function defaultWorkspaceSettings() {
22824
23047
  return WorkspaceSettings.parse({});
@@ -22835,13 +23058,22 @@ var ManagedSettingKey = external_exports.enum([
22835
23058
  "vaultInlineReveal",
22836
23059
  "modelJudgeConsent",
22837
23060
  "dataSharesInPlace",
22838
- "redactFallback"
23061
+ "redactFallback",
23062
+ // Pins the toggle and the day count together — see BodyRetention on why the
23063
+ // two are one unit. An administrator mandating a window wants the count
23064
+ // enforced with it, not one a user can widen while the toggle stays on.
23065
+ "bodyRetention"
22839
23066
  ]).meta({ id: "ManagedSettingKey" });
22840
23067
  function isManagedSettingKey(value) {
22841
23068
  return ManagedSettingKey.safeParse(value).success;
22842
23069
  }
22843
23070
  var ManagedSettingsValues = external_exports.object({
22844
23071
  runMode: external_exports.enum(["standalone", "attached"]).optional(),
23072
+ // `controlPlane` and `bodyRetention` are the two nested values, and both are
23073
+ // plain, non-strict objects: a key under either that this build does not know
23074
+ // is stripped and nothing reports it. The unknown-value split in
23075
+ // ManagedSettings below classifies top-level names only, so it stops at
23076
+ // these boundaries.
22845
23077
  controlPlane: external_exports.object({
22846
23078
  endpoint: external_exports.string().min(1),
22847
23079
  label: external_exports.string().min(1).optional()
@@ -22852,7 +23084,8 @@ var ManagedSettingsValues = external_exports.object({
22852
23084
  vaultInlineReveal: external_exports.enum(["masked", "full", "off"]).optional(),
22853
23085
  modelJudgeConsent: external_exports.boolean().optional(),
22854
23086
  dataSharesInPlace: external_exports.boolean().optional(),
22855
- redactFallback: RedactFallback.optional()
23087
+ redactFallback: RedactFallback.optional(),
23088
+ bodyRetention: BodyRetention.optional()
22856
23089
  }).meta({ id: "ManagedSettingsValues" });
22857
23090
  var ManagedSettings = external_exports.object({
22858
23091
  specVersion: external_exports.number().int().positive().default(MANAGED_SETTINGS_SPEC_VERSION),
@@ -22860,7 +23093,21 @@ var ManagedSettings = external_exports.object({
22860
23093
  // decision from a bug. Absent renders as a generic "your organization".
22861
23094
  organization: external_exports.string().min(1).optional(),
22862
23095
  // What the administrator pinned.
22863
- values: ManagedSettingsValues.default({}),
23096
+ //
23097
+ // Parsed as a RECORD rather than as the nested schema, and split below for
23098
+ // the same reason `lockedFields` is parsed as names: a plain `z.object`
23099
+ // drops an unrecognised key and succeeds, so a pin this build does not know
23100
+ // vanished and nothing anywhere said so. A pin with no lock is a supported
23101
+ // shape — it is a DEFAULT the user may still change — so that silence hit
23102
+ // exactly the file an administrator is most likely to write while a fleet
23103
+ // is mid-upgrade.
23104
+ //
23105
+ // Splitting here rather than calling `.strict()`: strict would REFUSE the
23106
+ // file, which is the outcome the lock half already rejected — an older
23107
+ // build then runs entirely unmanaged, every pin and lock gone. A bad KNOWN
23108
+ // value still fails, because the nested schema is re-run over the known
23109
+ // subset and its issues are re-raised on this parse.
23110
+ values: external_exports.record(external_exports.string(), external_exports.unknown()).default({}),
22864
23111
  // Which of those the user may not change. A key here with no matching value
22865
23112
  // freezes whatever the user last chose; a value with no lock is a DEFAULT
22866
23113
  // the user may still override. The two are separable on purpose.
@@ -22873,17 +23120,31 @@ var ManagedSettings = external_exports.object({
22873
23120
  // the fleets most likely to carry a version skew. A name outside the enum
22874
23121
  // is still never HONOURED: the lockable set stays explicit above.
22875
23122
  lockedFields: external_exports.array(external_exports.string()).default([])
22876
- }).transform(({ lockedFields, ...rest }) => {
23123
+ }).transform(({ lockedFields, values, ...rest }, ctx) => {
22877
23124
  const known = [];
22878
23125
  const unknown2 = [];
22879
23126
  for (const name of lockedFields) {
22880
23127
  if (isManagedSettingKey(name)) known.push(name);
22881
23128
  else unknown2.push(name);
22882
23129
  }
23130
+ const knownValues = /* @__PURE__ */ Object.create(null);
23131
+ const unknownValues = [];
23132
+ for (const [name, value] of Object.entries(values)) {
23133
+ if (Object.hasOwn(ManagedSettingsValues.shape, name)) knownValues[name] = value;
23134
+ else unknownValues.push(name);
23135
+ }
23136
+ const pinned = ManagedSettingsValues.safeParse(knownValues);
23137
+ if (!pinned.success) {
23138
+ for (const issue2 of pinned.error.issues)
23139
+ ctx.addIssue({ ...issue2, path: ["values", ...issue2.path] });
23140
+ return external_exports.NEVER;
23141
+ }
22883
23142
  return {
22884
23143
  ...rest,
23144
+ values: pinned.data,
22885
23145
  lockedFields: known,
22886
- ...unknown2.length > 0 ? { unknownLockedFields: unknown2 } : {}
23146
+ ...unknown2.length > 0 ? { unknownLockedFields: unknown2 } : {},
23147
+ ...unknownValues.length > 0 ? { unknownValueFields: unknownValues } : {}
22887
23148
  };
22888
23149
  }).meta({ id: "ManagedSettings" });
22889
23150
 
@@ -23136,12 +23397,30 @@ var RecommendedActionIdParam = external_exports.object({ id: external_exports.st
23136
23397
  // ../../packages/schema/src/zod/settings-action.ts
23137
23398
  var HistorySyncConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "HistorySyncConsentChoice" });
23138
23399
  var ModelJudgeConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "ModelJudgeConsentChoice" });
23400
+ var WebChatCaptureConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "WebChatCaptureConsentChoice" });
23139
23401
  var SaveSettingsInput = external_exports.object({
23140
23402
  historicalAccess: external_exports.string(),
23141
23403
  modelJudgeConsent: ModelJudgeConsentChoice,
23142
23404
  historySyncConsent: HistorySyncConsentChoice,
23143
23405
  vaultConsent: external_exports.string(),
23144
- vaultInlineReveal: external_exports.string()
23406
+ vaultInlineReveal: external_exports.string(),
23407
+ webChatCaptureConsent: WebChatCaptureConsentChoice,
23408
+ // Widened to `string` like its neighbours rather than typed as
23409
+ // `RedactFallback`, on this module's own layering rule: shape here, VALUE at
23410
+ // the call site, so the domain check receives the type it was written for.
23411
+ //
23412
+ // NOT because a narrower schema would reject differently. `parseActionInput`
23413
+ // is a `safeParse` wrapper and throws for no field schema, so either spelling
23414
+ // reaches a recoverable `{ ok: false }` and there is no rejected promise to
23415
+ // trade against. The real cost runs the other way and is the part worth
23416
+ // knowing: a value this schema admits and the domain enum then rejects lands
23417
+ // on the action's shared refusal, which names NO field, where a shape
23418
+ // rejection reaches `malformedInput` and names the schema key.
23419
+ redactFallback: external_exports.string(),
23420
+ // Shape only, the way the enum fields above are strings only: the RANGE is
23421
+ // `BodyRetention`'s and the action checks it there, so there is one place
23422
+ // that decides what a legal horizon is rather than two that can drift.
23423
+ bodyRetention: external_exports.object({ enabled: external_exports.boolean(), retainDays: external_exports.number() })
23145
23424
  });
23146
23425
  var AttachInput = external_exports.object({
23147
23426
  endpoint: external_exports.string(),
@@ -23267,6 +23546,96 @@ var SetupHandoffOffer = external_exports.object({
23267
23546
  path: ["liveKeys"]
23268
23547
  });
23269
23548
 
23549
+ // ../../packages/schema/src/zod/web-capture.ts
23550
+ var WebUsageSource = external_exports.enum(["site", "estimated", "none"]);
23551
+ var WebUsage = external_exports.object({
23552
+ inputTokens: external_exports.number().int().nonnegative().optional(),
23553
+ outputTokens: external_exports.number().int().nonnegative().optional(),
23554
+ cacheReadInputTokens: external_exports.number().int().nonnegative().optional(),
23555
+ cacheCreationInputTokens: external_exports.number().int().nonnegative().optional()
23556
+ });
23557
+ var WebToolCall = external_exports.object({
23558
+ toolUseId: external_exports.string().min(1),
23559
+ toolName: external_exports.string().min(1),
23560
+ target: external_exports.string().optional(),
23561
+ isError: external_exports.boolean().optional(),
23562
+ inputSize: external_exports.number().int().nonnegative().optional(),
23563
+ outputSize: external_exports.number().int().nonnegative().optional()
23564
+ });
23565
+ var WebExchange = external_exports.object({
23566
+ messageId: external_exports.string().min(1),
23567
+ startedAt: external_exports.iso.datetime(),
23568
+ model: external_exports.string().optional(),
23569
+ usage: WebUsage.optional(),
23570
+ usageSource: WebUsageSource,
23571
+ stopReason: external_exports.string().optional(),
23572
+ conversationId: external_exports.string().optional(),
23573
+ turnIndex: external_exports.number().int().nonnegative().optional(),
23574
+ toolCalls: external_exports.array(WebToolCall).default([]),
23575
+ // Absent when the adapter recovered no text. Capped by the caller at
23576
+ // RESPONSE_TEXT_MAX_BYTES, so a short capture is never mistaken for a short
23577
+ // reply.
23578
+ responseText: external_exports.string().optional(),
23579
+ // The stored text is short of the reply. It does NOT say which of the two
23580
+ // ceilings on this path cut it: the caller applies its own cap on the raw
23581
+ // bytes it reads off the wire, which can be reached by a stream whose
23582
+ // recovered text stays well under RESPONSE_TEXT_MAX_BYTES, and applies that
23583
+ // one to the text. A reader cannot tell them apart, and nothing downstream
23584
+ // should branch as though it could.
23585
+ truncated: external_exports.boolean().default(false)
23586
+ });
23587
+ var WebEnforcementState = external_exports.enum([
23588
+ "watching",
23589
+ "composer-only",
23590
+ "button-only",
23591
+ "unattached",
23592
+ "unknown"
23593
+ ]);
23594
+ var RESPONSE_TEXT_MAX_BYTES = 2 * 1024 * 1024;
23595
+ var WebCaptureStatus = external_exports.object({
23596
+ patched: external_exports.boolean(),
23597
+ live: external_exports.boolean(),
23598
+ blind: external_exports.boolean(),
23599
+ sendsSeenDom: external_exports.number().int().nonnegative(),
23600
+ exchangesSeenNet: external_exports.number().int().nonnegative(),
23601
+ parseFailures: external_exports.number().int().nonnegative(),
23602
+ unparsedBodies: external_exports.number().int().nonnegative(),
23603
+ // The adapter-declared JSON key paths that were absent from a real payload —
23604
+ // the earliest signal that a site's contract moved.
23605
+ shapeMisses: external_exports.array(external_exports.string()).default([]),
23606
+ // How many `kind: 'conversation'` endpoints the reporting tab's adapter
23607
+ // compiled. Zero means this build declares none for the site, so observing
23608
+ // nothing is the design rather than a fault — the one fact that separates a
23609
+ // site nobody has surveyed yet from one whose contract moved. Defaulted so a
23610
+ // build predating the field is read as declaring nothing rather than refused.
23611
+ conversationEndpoints: external_exports.number().int().nonnegative().default(0),
23612
+ // The document that sent this report is going away. The bridge sets it on
23613
+ // its `pagehide` report and nowhere else.
23614
+ //
23615
+ // A property of the REPORT rather than of capture health, which is why
23616
+ // nothing in `deriveWebCaptureState` reads it and why it stays out of the
23617
+ // bridge's own report signature — a closing tab's last word must not be
23618
+ // suppressed for carrying the same health as the report before it. What
23619
+ // reads it is the per-site fold: a document that said it was unloading stops
23620
+ // voting on the site's state, so the reload the `blind` remediation asks for
23621
+ // can actually clear the verdict it was shown. A document that dies without
23622
+ // sending one is covered by CAPTURE_STATUS_DOCUMENT_QUIET_MS instead.
23623
+ //
23624
+ // Defaulted so a build predating the field reads as a document that never
23625
+ // said it was closing — which keeps it voting, the same as every report that
23626
+ // is not a final one.
23627
+ closed: external_exports.boolean().default(false),
23628
+ // What the DOM enforcement path is doing, which none of the counters above
23629
+ // can say: `sendsSeenDom` rises only once a send has COMPLETED, so a tab
23630
+ // whose watcher never bound reports zero exactly like a tab nobody typed in.
23631
+ // Defaulted to 'unknown' rather than 'watching' so a status from a build
23632
+ // predating the field is not read as reporting a healthy one.
23633
+ enforcement: WebEnforcementState.default("unknown")
23634
+ });
23635
+ var CAPTURE_STATUS_RECENCY_MS = 30 * 24 * 60 * 60 * 1e3;
23636
+ var CAPTURE_STATUS_RECENCY_DAYS = CAPTURE_STATUS_RECENCY_MS / (24 * 60 * 60 * 1e3);
23637
+ var CAPTURE_STATUS_DOCUMENT_QUIET_MS = 12 * 60 * 60 * 1e3;
23638
+
23270
23639
  // ../../packages/persistence/src/paths.ts
23271
23640
  import {
23272
23641
  chmodSync,
@@ -23324,6 +23693,32 @@ var STALE_PARTIAL_MS = 5 * 6e4;
23324
23693
  var SNAPSHOT_STAGING_SUFFIX = ".partial";
23325
23694
  var STAGED_NAME_SUFFIX = `.bak${SNAPSHOT_STAGING_SUFFIX}`;
23326
23695
 
23696
+ // ../../packages/persistence/src/internal/sql-functions.ts
23697
+ var utf8 = new TextDecoder();
23698
+
23699
+ // ../../packages/persistence/src/internal/outbox-lane.ts
23700
+ var OUTBOX_CAPTURE_EVENT_TYPES = ["prompt", "response", "tool_use"];
23701
+ var OUTBOX_CAPTURE_TYPE_LIST = OUTBOX_CAPTURE_EVENT_TYPES.map((t) => `'${t}'`).join(", ");
23702
+
23703
+ // ../../packages/persistence/src/sync-failure.ts
23704
+ var SYNC_FAILURE_REASONS = SyncFailureReason.options;
23705
+
23706
+ // ../../packages/persistence/src/repositories/history-sync.ts
23707
+ var STRUCTURAL_EVENT_TYPES = ["session", "llm_call", "tool_call"];
23708
+ var TYPE_LIST = STRUCTURAL_EVENT_TYPES.map((t) => `'${t}'`).join(", ");
23709
+ var COUNTED_EVENT_TYPES = [
23710
+ ...STRUCTURAL_EVENT_TYPES,
23711
+ ...OUTBOX_CAPTURE_EVENT_TYPES
23712
+ ];
23713
+ var COUNTED_TYPE_LIST = COUNTED_EVENT_TYPES.map((t) => `'${t}'`).join(", ");
23714
+ var COUNTED_SCOPE = `
23715
+ WHERE event_type IN (${COUNTED_TYPE_LIST})
23716
+ AND (
23717
+ event_type IN (${TYPE_LIST})
23718
+ OR synced_at IS NOT NULL
23719
+ OR outbox_owed = 1
23720
+ )`;
23721
+
23327
23722
  // ../../packages/persistence/src/internal/json.ts
23328
23723
  function parseJsonObject(s) {
23329
23724
  if (s == null) return void 0;
@@ -23388,13 +23783,10 @@ var FINDING_ROW_COLUMNS_SQL = `f.id AS id, d.rule_id AS rule_id, d.category AS c
23388
23783
  e.tool_name AS tool_name,
23389
23784
  f.audit_event_id AS event_id, e.root_session_id AS session_id,
23390
23785
  e.event_type AS kind, f.finding_key AS finding_key,
23391
- ${latestResolutionStatusSql("f")} AS latest_status`;
23392
-
23393
- // ../../packages/persistence/src/repositories/history-sync.ts
23394
- var STRUCTURAL_EVENT_TYPES = ["session", "llm_call", "tool_call"];
23395
- var TYPE_LIST = STRUCTURAL_EVENT_TYPES.map((t) => `'${t}'`).join(", ");
23396
- var OUTBOX_CAPTURE_EVENT_TYPES = ["prompt", "response", "tool_use"];
23397
- var CAPTURE_TYPE_LIST = OUTBOX_CAPTURE_EVENT_TYPES.map((t) => `'${t}'`).join(", ");
23786
+ ${latestResolutionStatusSql("f")} AS latest_status,
23787
+ e.synced_at AS synced_at, e.sync_claimed_at AS sync_claimed_at,
23788
+ e.sync_failed_at AS sync_failed_at, e.sync_failure AS sync_failure,
23789
+ e.outbox_owed AS outbox_owed`;
23398
23790
 
23399
23791
  // ../../packages/persistence/src/repositories/installed-packs.ts
23400
23792
  import { createHash as createHash2, randomUUID as randomUUID4 } from "crypto";
@@ -23511,6 +23903,7 @@ function overlayManagedSettings(settings, managed, now = () => /* @__PURE__ */ n
23511
23903
  if (values.vaultInlineReveal !== void 0) merged.vaultInlineReveal = values.vaultInlineReveal;
23512
23904
  if (values.dataSharesInPlace !== void 0) merged.dataSharesInPlace = values.dataSharesInPlace;
23513
23905
  if (values.redactFallback !== void 0) merged.redactFallback = values.redactFallback;
23906
+ if (values.bodyRetention !== void 0) merged.bodyRetention = values.bodyRetention;
23514
23907
  if (values.vaultConsent !== void 0) {
23515
23908
  merged.vaultConsent = values.vaultConsent ? (
23516
23909
  // Keep an existing valid grant so its acknowledgedAt survives; mint one
@@ -23598,9 +23991,11 @@ import { randomUUID as randomUUID10 } from "crypto";
23598
23991
 
23599
23992
  // ../../packages/persistence/src/database.ts
23600
23993
  var CAPTURE_GRAIN = new Set(EventKind.options);
23994
+ var DEFERRED_TAGS = new Set(DEFERRED_MIGRATION_TAGS);
23601
23995
 
23602
23996
  // ../../packages/persistence/src/egress-wire.ts
23603
23997
  import { createHash as createHash3 } from "crypto";
23998
+ var SLASH = "/".charCodeAt(0);
23604
23999
 
23605
24000
  // ../../packages/persistence/src/finding-key.ts
23606
24001
  import { createHash as createHash4 } from "crypto";
@@ -23611,18 +24006,26 @@ import { existsSync as existsSync3, readFileSync as readFileSync6 } from "fs";
23611
24006
  import { join as join8 } from "path";
23612
24007
  import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
23613
24008
 
24009
+ // ../../packages/persistence/src/forward-health.ts
24010
+ import { readFileSync as readFileSync7 } from "fs";
24011
+ import { join as join9 } from "path";
24012
+
23614
24013
  // ../../packages/persistence/src/history-backfill.ts
23615
24014
  import { existsSync as existsSync4 } from "fs";
23616
- import { join as join9 } from "path";
24015
+ import { join as join10 } from "path";
23617
24016
 
23618
24017
  // ../../packages/persistence/src/history-preview.ts
23619
24018
  import { existsSync as existsSync5 } from "fs";
23620
- import { join as join10 } from "path";
24019
+ import { join as join11 } from "path";
23621
24020
  import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
23622
24021
 
24022
+ // ../../packages/persistence/src/history-sync-state.ts
24023
+ import { readFileSync as readFileSync8 } from "fs";
24024
+ import { join as join12 } from "path";
24025
+
23623
24026
  // ../../packages/persistence/src/store-symlinks.ts
23624
24027
  import { existsSync as existsSync6, lstatSync as lstatSync3, readlinkSync, realpathSync, statSync as statSync4 } from "fs";
23625
- import { dirname as dirname3, join as join11, resolve } from "path";
24028
+ import { dirname as dirname3, join as join13, resolve } from "path";
23626
24029
  var STORE_DB = "the store database (including the prompt corpus)";
23627
24030
  var STORE_SETTINGS = "your settings file";
23628
24031
  function storeContents(home) {
@@ -23631,7 +24034,7 @@ function storeContents(home) {
23631
24034
  [settingsDir(home), STORE_SETTINGS],
23632
24035
  [dataDir(home), STORE_DB],
23633
24036
  [keysDir(home), "the vault key"],
23634
- [join11(settingsDir(home), "settings.json"), STORE_SETTINGS],
24037
+ [join13(settingsDir(home), "settings.json"), STORE_SETTINGS],
23635
24038
  [dbPath(home), STORE_DB]
23636
24039
  ]);
23637
24040
  }
@@ -23683,15 +24086,15 @@ import {
23683
24086
  // ../../packages/persistence/src/vault/key-provider.ts
23684
24087
  import { execFileSync } from "child_process";
23685
24088
  import { randomBytes as randomBytes2 } from "crypto";
23686
- import { chmodSync as chmodSync3, readFileSync as readFileSync7, renameSync as renameSync4, rmSync as rmSync6, statSync as statSync5, writeFileSync as writeFileSync3 } from "fs";
23687
- import { join as join12 } from "path";
24089
+ import { chmodSync as chmodSync3, readFileSync as readFileSync9, renameSync as renameSync4, rmSync as rmSync6, statSync as statSync5, writeFileSync as writeFileSync3 } from "fs";
24090
+ import { join as join14 } from "path";
23688
24091
 
23689
24092
  // ../../packages/persistence/src/vault/vault.ts
23690
24093
  import { randomBytes as randomBytes3, randomUUID as randomUUID12 } from "crypto";
23691
24094
 
23692
24095
  // ../../packages/persistence/src/warn-era-cap.ts
23693
24096
  import { existsSync as existsSync7, writeFileSync as writeFileSync4 } from "fs";
23694
- import { join as join13 } from "path";
24097
+ import { join as join15 } from "path";
23695
24098
 
23696
24099
  // ../../packages/plugin-sdk/src/provider-env.ts
23697
24100
  var DEFAULT_ANTHROPIC_HOST = "api.anthropic.com";
@@ -23745,7 +24148,7 @@ function resolveProvider() {
23745
24148
  function loadConfig(base = defaultDataDir(), resolveProviderFn = resolveProvider) {
23746
24149
  try {
23747
24150
  ensureLayoutDirSync(base);
23748
- const settingsFile = join14(settingsDir(base), "settings.json");
24151
+ const settingsFile = join16(settingsDir(base), "settings.json");
23749
24152
  if (existsSync8(settingsFile)) tightenFile(settingsFile);
23750
24153
  } catch {
23751
24154
  }
@@ -23769,9 +24172,9 @@ function resolveProviderSafe(resolveProviderFn) {
23769
24172
  }
23770
24173
 
23771
24174
  // ../../packages/plugin-sdk/src/config-inventory.ts
23772
- import { readdirSync as readdirSync2, readFileSync as readFileSync9, realpathSync as realpathSync2, statSync as statSync7 } from "fs";
24175
+ import { readdirSync as readdirSync2, readFileSync as readFileSync11, realpathSync as realpathSync2, statSync as statSync7 } from "fs";
23773
24176
  import { homedir as homedir2 } from "os";
23774
- import { basename as basename3, join as join16 } from "path";
24177
+ import { basename as basename3, join as join18 } from "path";
23775
24178
 
23776
24179
  // ../../packages/detections/src/egress/registry.ts
23777
24180
  var EXTRACTOR_VERSION = "1";
@@ -24500,6 +24903,56 @@ var CONFIG_POSTURE_RULES = [
24500
24903
  }
24501
24904
  ];
24502
24905
 
24906
+ // ../../packages/detections/src/posture/web-capture-posture.ts
24907
+ var RULE_VERSION2 = "1";
24908
+ var DRIFT_MIN_PARSE_FAILURES = 2;
24909
+ var WEB_CAPTURE_DRIFT_STATES = /* @__PURE__ */ new Set([
24910
+ "blind",
24911
+ "degraded"
24912
+ ]);
24913
+ var WEB_CAPTURE_DRIFT_RULE = {
24914
+ ruleId: "web-capture-drift",
24915
+ version: RULE_VERSION2,
24916
+ name: "Web chat capture is not reading the site",
24917
+ category: "config",
24918
+ severity: "medium",
24919
+ definition: JSON.stringify({
24920
+ kind: "web-capture-drift",
24921
+ states: [...WEB_CAPTURE_DRIFT_STATES],
24922
+ minParseFailures: DRIFT_MIN_PARSE_FAILURES
24923
+ })
24924
+ };
24925
+ var STATIC_COPY = {
24926
+ active: { headline: "turns are being observed on this site" },
24927
+ unreported: {
24928
+ // Says "recently" rather than "yet": the store read is bounded to
24929
+ // CAPTURE_STATUS_RECENCY_MS, so this state covers a site nothing has ever
24930
+ // reported for AND one whose last report has aged out. The two are the
24931
+ // same fact to a reader — nobody has confirmed anything lately — and the
24932
+ // copy may not claim the stronger of them.
24933
+ headline: `no report in the last ${String(CAPTURE_STATUS_RECENCY_DAYS)} days \u2014 open the site in Chrome with the extension loaded`
24934
+ },
24935
+ standby: {
24936
+ headline: "this build declares no endpoints for the site, so nothing is observed yet"
24937
+ },
24938
+ unpatched: {
24939
+ // Says what the flags say and no more. `patched` is false both for a tap
24940
+ // that installed and hooked neither transport and for one that never ran
24941
+ // at all — a page reports the same status either way, so the copy may not
24942
+ // assert one of them.
24943
+ headline: "the page tap captured neither fetch nor XHR \u2014 it may not have installed; reload the extension at chrome://extensions"
24944
+ },
24945
+ idle: { headline: "watching; no turn has been observed yet" },
24946
+ blind: {
24947
+ headline: "messages were sent in the page that the network capture never saw",
24948
+ 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."
24949
+ },
24950
+ degraded: {
24951
+ headline: "the site's payloads no longer carry the fields the extension reads",
24952
+ 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."
24953
+ }
24954
+ };
24955
+
24503
24956
  // ../../packages/detections/src/security/redos-probe.ts
24504
24957
  var BUDGET_MS = 100;
24505
24958
  var EXPONENTIAL_UNITS = [
@@ -24529,8 +24982,8 @@ var CPU_CORROBORATION_SHARE = 0.2;
24529
24982
  var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
24530
24983
 
24531
24984
  // ../../packages/plugin-sdk/src/repo.ts
24532
- import { existsSync as existsSync9, readFileSync as readFileSync8, statSync as statSync6 } from "fs";
24533
- import { basename as basename2, dirname as dirname4, isAbsolute, join as join15, sep as sep2 } from "path";
24985
+ import { existsSync as existsSync9, readFileSync as readFileSync10, statSync as statSync6 } from "fs";
24986
+ import { basename as basename2, dirname as dirname4, isAbsolute, join as join17, sep as sep2 } from "path";
24534
24987
 
24535
24988
  // ../../packages/plugin-sdk/src/events.ts
24536
24989
  import { createHash as createHash5, randomUUID as randomUUID13 } from "crypto";
@@ -24541,8 +24994,8 @@ import { fileURLToPath } from "url";
24541
24994
  import { Worker } from "worker_threads";
24542
24995
 
24543
24996
  // ../../packages/plugin-sdk/src/host-floor.ts
24544
- import { readFileSync as readFileSync11 } from "fs";
24545
- import { join as join18 } from "path";
24997
+ import { readFileSync as readFileSync13 } from "fs";
24998
+ import { join as join20 } from "path";
24546
24999
 
24547
25000
  // ../../packages/plugin-sdk/src/model-governance.ts
24548
25001
  import {
@@ -24550,18 +25003,18 @@ import {
24550
25003
  fstatSync,
24551
25004
  mkdirSync as mkdirSync2,
24552
25005
  openSync as openSync2,
24553
- readFileSync as readFileSync10,
25006
+ readFileSync as readFileSync12,
24554
25007
  readSync,
24555
25008
  writeFileSync as writeFileSync5
24556
25009
  } from "fs";
24557
- import { join as join17 } from "path";
25010
+ import { join as join19 } from "path";
24558
25011
  var SESSION_MODEL_MARKER = "session-model";
24559
25012
  function recordSessionModel(dataDir2, sessionId, model) {
24560
25013
  if (sessionId === void 0 || sessionId === "") return;
24561
25014
  if (model === void 0 || model === "") return;
24562
25015
  try {
24563
25016
  mkdirSync2(dataDir2, { recursive: true, mode: DATA_DIR_MODE });
24564
- writeFileSync5(join17(dataDir2, SESSION_MODEL_MARKER), JSON.stringify({ sessionId, model }), {
25017
+ writeFileSync5(join19(dataDir2, SESSION_MODEL_MARKER), JSON.stringify({ sessionId, model }), {
24565
25018
  encoding: "utf8",
24566
25019
  mode: DATA_FILE_MODE
24567
25020
  });
@@ -24590,15 +25043,15 @@ var HOST_FLOORS = {
24590
25043
 
24591
25044
  // ../../packages/plugin-sdk/src/ignore-layers.ts
24592
25045
  var import_ignore = __toESM(require_ignore(), 1);
24593
- import { readFileSync as readFileSync12 } from "fs";
24594
- import { join as join19 } from "path";
25046
+ import { readFileSync as readFileSync14 } from "fs";
25047
+ import { join as join21 } from "path";
24595
25048
 
24596
25049
  // ../../packages/plugin-sdk/src/inventory-resolver.ts
24597
25050
  import { arch, hostname as hostname4, platform, release } from "os";
24598
25051
 
24599
25052
  // ../../packages/plugin-sdk/src/nudge.ts
24600
- import { mkdirSync as mkdirSync3, readFileSync as readFileSync13, writeFileSync as writeFileSync6 } from "fs";
24601
- import { join as join20 } from "path";
25053
+ import { mkdirSync as mkdirSync3, readFileSync as readFileSync15, writeFileSync as writeFileSync6 } from "fs";
25054
+ import { join as join22 } from "path";
24602
25055
 
24603
25056
  // ../../packages/plugin-sdk/src/paths.ts
24604
25057
  import { readdirSync as readdirSync3, realpathSync as realpathSync3 } from "fs";
@@ -24606,7 +25059,7 @@ import { basename as basename4, dirname as dirname5, sep as sep3 } from "path";
24606
25059
 
24607
25060
  // ../../packages/plugin-sdk/src/project-files.ts
24608
25061
  import { existsSync as existsSync11, readdirSync as readdirSync4 } from "fs";
24609
- import { basename as basename5, join as join21 } from "path";
25062
+ import { basename as basename5, join as join23 } from "path";
24610
25063
 
24611
25064
  // ../../packages/plugin-sdk/src/provider-env-antigravity.ts
24612
25065
  var optionalBaseUrl2 = external_exports.preprocess((v) => {
@@ -24642,16 +25095,16 @@ var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
24642
25095
 
24643
25096
  // ../../packages/plugin-sdk/src/throttle.ts
24644
25097
  import { mkdirSync as mkdirSync4, statSync as statSync8, writeFileSync as writeFileSync7 } from "fs";
24645
- import { join as join22 } from "path";
25098
+ import { join as join24 } from "path";
24646
25099
 
24647
25100
  // src/hooks/model-switch-run.ts
24648
25101
  import { randomUUID as randomUUID16 } from "crypto";
24649
25102
 
24650
25103
  // src/hooks/model-guard.ts
24651
25104
  import { randomUUID as randomUUID15 } from "crypto";
24652
- import { readFileSync as readFileSync14, statSync as statSync9 } from "fs";
25105
+ import { readFileSync as readFileSync16, statSync as statSync9 } from "fs";
24653
25106
  import { homedir as homedir3 } from "os";
24654
- import { dirname as dirname6, join as join23 } from "path";
25107
+ import { dirname as dirname6, join as join25 } from "path";
24655
25108
 
24656
25109
  // src/hooks/model-switch-run.ts
24657
25110
  function runPostModelSwitch(sessionId, toModel, deps) {
@@ -24697,7 +25150,7 @@ function getString(record2, key) {
24697
25150
 
24698
25151
  // src/hooks/store-health.ts
24699
25152
  import { mkdirSync as mkdirSync5, readFileSync as readFileSync20, writeFileSync as writeFileSync8 } from "fs";
24700
- import { dirname as dirname7, join as join30 } from "path";
25153
+ import { dirname as dirname7, join as join31 } from "path";
24701
25154
 
24702
25155
  // ../../packages/remote/src/http.ts
24703
25156
  import { request as httpRequest } from "http";
@@ -24705,21 +25158,16 @@ import { request as httpsRequest } from "https";
24705
25158
  var MAX_RESPONSE_BYTES = 8 * 1024 * 1024;
24706
25159
 
24707
25160
  // ../../packages/remote/src/client.ts
24708
- var SLASH = "/".charCodeAt(0);
25161
+ var SLASH2 = "/".charCodeAt(0);
24709
25162
 
24710
25163
  // ../../packages/plugin-runtime/src/attached/forward-drops.ts
24711
- import { readFileSync as readFileSync15 } from "fs";
24712
- import { join as join24 } from "path";
25164
+ import { readFileSync as readFileSync17 } from "fs";
25165
+ import { join as join26 } from "path";
24713
25166
 
24714
25167
  // ../../packages/plugin-runtime/src/attached/forward-policy.ts
24715
25168
  import { randomUUID as randomUUID17 } from "crypto";
24716
- import { readFileSync as readFileSync16 } from "fs";
24717
25169
  import { readFile, rename, writeFile } from "fs/promises";
24718
- import { join as join25 } from "path";
24719
-
24720
- // ../../packages/plugin-runtime/src/attached/history-state.ts
24721
- import { readFileSync as readFileSync17 } from "fs";
24722
- import { join as join26 } from "path";
25170
+ import { join as join27 } from "path";
24723
25171
 
24724
25172
  // ../../packages/plugin-runtime/src/attached/history-sync.ts
24725
25173
  import { createHash as createHash6 } from "crypto";
@@ -24729,6 +25177,10 @@ import { hostname as hostname5 } from "os";
24729
25177
  var CORRELATION_ID = EventMetadata.shape.correlationId;
24730
25178
  var TRACE_ID = EventMetadata.shape.traceId;
24731
25179
  var EXCEPTION_ID = EventMetadata.shape.exceptionIds.unwrap().element;
25180
+ var REDACT_DEGRADED_TO = EventMetadata.shape.redactDegradedTo.unwrap();
25181
+
25182
+ // ../../packages/plugin-runtime/src/attached/history-sync.ts
25183
+ var CAPTURE_BATCH_BYTES = 1024 * 1024;
24732
25184
 
24733
25185
  // ../../packages/plugin-runtime/src/attached/history-sync-trigger.ts
24734
25186
  import { spawn } from "child_process";
@@ -24741,10 +25193,13 @@ import { readFileSync as readFileSync18 } from "fs";
24741
25193
  // ../../packages/plugin-runtime/src/attached/policy-store.ts
24742
25194
  import { randomUUID as randomUUID18 } from "crypto";
24743
25195
  import { readFile as readFile2, rm, writeFile as writeFile2 } from "fs/promises";
24744
- import { join as join27 } from "path";
25196
+ import { join as join28 } from "path";
24745
25197
 
24746
25198
  // ../../packages/plugin-runtime/src/attached/atomic-publish.ts
24747
25199
  import { rename as rename2 } from "fs/promises";
25200
+ var IMMEDIATE_RETRIES = 8;
25201
+ var TIMED_RETRIES = 4;
25202
+ var ATTEMPTS = 1 + IMMEDIATE_RETRIES + TIMED_RETRIES;
24748
25203
 
24749
25204
  // ../../packages/plugin-runtime/src/attached/posture-reporter.ts
24750
25205
  var POSTURE_REPORT_INTERVAL_MS = 60 * 60 * 1e3;
@@ -24756,11 +25211,11 @@ import { DatabaseSync as DatabaseSync4 } from "node:sqlite";
24756
25211
  // ../../packages/plugin-runtime/src/attached/posture-store.ts
24757
25212
  import { randomUUID as randomUUID19 } from "crypto";
24758
25213
  import { readFile as readFile3, rm as rm2, writeFile as writeFile3 } from "fs/promises";
24759
- import { join as join28 } from "path";
25214
+ import { join as join29 } from "path";
24760
25215
 
24761
25216
  // ../../packages/plugin-runtime/src/attached/sync-state.ts
24762
25217
  import { readFileSync as readFileSync19 } from "fs";
24763
- import { join as join29 } from "path";
25218
+ import { join as join30 } from "path";
24764
25219
 
24765
25220
  // ../../packages/plugin-runtime/src/attached/status.ts
24766
25221
  var REFUSAL_LINES = {
@@ -24781,6 +25236,14 @@ import { spawn as spawn2 } from "child_process";
24781
25236
  import { fileURLToPath as fileURLToPath3 } from "url";
24782
25237
  var SYNC_THROTTLE_MS = 15 * 60 * 1e3;
24783
25238
 
25239
+ // ../../packages/plugin-runtime/src/content-retention-pass.ts
25240
+ var MAX_ROWS_PER_SWEEP = 50 * 1e3;
25241
+
25242
+ // ../../packages/plugin-runtime/src/content-retention-trigger.ts
25243
+ import { spawn as spawn3 } from "child_process";
25244
+ import { fileURLToPath as fileURLToPath4 } from "url";
25245
+ var CONTENT_RETENTION_THROTTLE_MS = 60 * 60 * 1e3;
25246
+
24784
25247
  // ../../packages/plugin-runtime/src/attached/factory.ts
24785
25248
  import { hostname as hostname6 } from "os";
24786
25249
 
@@ -24799,7 +25262,7 @@ function markerDirs(dataDir2) {
24799
25262
  function alreadyClaimed(dirs, marker, sessionId) {
24800
25263
  return dirs.some((dir) => {
24801
25264
  try {
24802
- return readFileSync20(join30(dir, marker), "utf8") === sessionId;
25265
+ return readFileSync20(join31(dir, marker), "utf8") === sessionId;
24803
25266
  } catch {
24804
25267
  return false;
24805
25268
  }
@@ -24809,7 +25272,7 @@ function recordClaim(dirs, marker, sessionId) {
24809
25272
  for (const dir of dirs) {
24810
25273
  try {
24811
25274
  mkdirSync5(dir, { recursive: true, mode: DATA_DIR_MODE });
24812
- writeFileSync8(join30(dir, marker), sessionId, { mode: DATA_FILE_MODE });
25275
+ writeFileSync8(join31(dir, marker), sessionId, { mode: DATA_FILE_MODE });
24813
25276
  return;
24814
25277
  } catch {
24815
25278
  }