@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.
- package/.claude-plugin/plugin.json +1 -1
- package/package.json +2 -2
- package/scripts/apply-suppressions.js +331 -22
- package/scripts/backfill.js +464 -124
- package/scripts/content-retention.js +334 -22
- package/scripts/filescan.js +464 -124
- package/scripts/firstrun.js +464 -124
- package/scripts/history-sync.js +379 -42
- package/scripts/intro.js +209 -17
- package/scripts/message-display.js +331 -22
- package/scripts/onboard.js +331 -22
- package/scripts/post-model-switch.js +212 -17
- package/scripts/post-tool-use.js +464 -124
- package/scripts/pre-model-switch.js +488 -127
- package/scripts/pre-tool-use.js +488 -127
- package/scripts/query.js +575 -125
- package/scripts/reconcile.js +464 -124
- package/scripts/remediate.js +464 -124
- package/scripts/scan-worker.js +209 -17
- package/scripts/session-start.js +464 -124
- package/scripts/start-light.js +209 -17
- package/scripts/statusline.js +464 -124
- package/scripts/stop.js +212 -17
- package/scripts/sync.js +464 -124
- package/scripts/user-prompt-submit.js +488 -127
package/scripts/statusline.js
CHANGED
|
@@ -20492,7 +20492,17 @@ var UNPRICEABLE_PROVIDERS = Object.freeze([
|
|
|
20492
20492
|
"gateway",
|
|
20493
20493
|
"unknown",
|
|
20494
20494
|
"cli",
|
|
20495
|
-
"api"
|
|
20495
|
+
"api",
|
|
20496
|
+
// The browser extension's native host records these as `llm_call.provider`
|
|
20497
|
+
// for a web-chat turn — the web tool id, deliberately never the vendor id
|
|
20498
|
+
// (`openai`/`anthropic`) the session root carries. Subscription traffic
|
|
20499
|
+
// burns rate-limit budget, not dollar credits, and listing them here is
|
|
20500
|
+
// what keeps that true structurally: a later maintainer who wants to price
|
|
20501
|
+
// web-chat traffic at API rates has to delete this entry first, and meet
|
|
20502
|
+
// the reason on the way, rather than quietly adding one to
|
|
20503
|
+
// PROVIDER_PLATFORM.
|
|
20504
|
+
"chatgpt",
|
|
20505
|
+
"claude-ai"
|
|
20496
20506
|
]);
|
|
20497
20507
|
function platformForProvider(provider) {
|
|
20498
20508
|
return PROVIDER_PLATFORM.get(provider.trim().toLowerCase()) ?? null;
|
|
@@ -20635,7 +20645,12 @@ var HARNESS = {
|
|
|
20635
20645
|
ClaudeDesktop: "claudedesktop",
|
|
20636
20646
|
ChatGpt: "chatgpt",
|
|
20637
20647
|
ClaudeAi: "claudeai",
|
|
20638
|
-
Api: "api"
|
|
20648
|
+
Api: "api",
|
|
20649
|
+
// Not a coding assistant a person drives — an in-process SDK embedded in an
|
|
20650
|
+
// application, so it has no IDE/CLI/desktop/web surface of its own. Carries
|
|
20651
|
+
// the same id as its SOURCE_TOOL counterpart, unlike every capture-side tool
|
|
20652
|
+
// whose wire spelling differs from its display spelling.
|
|
20653
|
+
AiTcSdk: "ai-tc-sdk"
|
|
20639
20654
|
};
|
|
20640
20655
|
var Harness = external_exports.enum(HARNESS).meta({ id: "Harness" });
|
|
20641
20656
|
var SOURCE_TOOL = {
|
|
@@ -20651,9 +20666,15 @@ var SOURCE_TOOL = {
|
|
|
20651
20666
|
// whose tool could not be identified both render through the read side's
|
|
20652
20667
|
// miss path rather than as a harness of their own.
|
|
20653
20668
|
Cli: "cli",
|
|
20654
|
-
Unknown: "unknown"
|
|
20669
|
+
Unknown: "unknown",
|
|
20670
|
+
// The wire id an in-process, request-path SDK stamps on its own structural
|
|
20671
|
+
// rows (`request_decision`) — never a capture of prompt/response/tool text,
|
|
20672
|
+
// since the SDK sits in front of a model call rather than inside a coding
|
|
20673
|
+
// assistant's own hook contract.
|
|
20674
|
+
AiTcSdk: "ai-tc-sdk"
|
|
20655
20675
|
};
|
|
20656
20676
|
var SourceTool = external_exports.enum(SOURCE_TOOL).meta({ id: "SourceTool" });
|
|
20677
|
+
var WebSourceTool = SourceTool.extract(["ChatGpt", "ClaudeAi"]);
|
|
20657
20678
|
var TOOL_TO_HARNESS = {
|
|
20658
20679
|
[SOURCE_TOOL.ClaudeCode]: HARNESS.ClaudeCode,
|
|
20659
20680
|
[SOURCE_TOOL.ClaudeDesktop]: HARNESS.ClaudeDesktop,
|
|
@@ -20662,7 +20683,12 @@ var TOOL_TO_HARNESS = {
|
|
|
20662
20683
|
[SOURCE_TOOL.ChatGpt]: HARNESS.ChatGpt,
|
|
20663
20684
|
[SOURCE_TOOL.Codex]: HARNESS.Codex,
|
|
20664
20685
|
[SOURCE_TOOL.Antigravity]: HARNESS.Antigravity,
|
|
20665
|
-
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi
|
|
20686
|
+
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi,
|
|
20687
|
+
// Wire and display id are the same string here, but the row still belongs:
|
|
20688
|
+
// both vocabularies carry the `AiTcSdk` member, and the join is exactly
|
|
20689
|
+
// their intersection — leaving a shared member out would read as an
|
|
20690
|
+
// uninstrumented tool on both surfaces, which this one is not.
|
|
20691
|
+
[SOURCE_TOOL.AiTcSdk]: HARNESS.AiTcSdk
|
|
20666
20692
|
};
|
|
20667
20693
|
|
|
20668
20694
|
// ../../packages/schema/src/zod/finding.ts
|
|
@@ -20696,7 +20722,8 @@ var FindingProvider = Harness.extract([
|
|
|
20696
20722
|
"ClaudeAi",
|
|
20697
20723
|
"Codex",
|
|
20698
20724
|
"Antigravity",
|
|
20699
|
-
"Api"
|
|
20725
|
+
"Api",
|
|
20726
|
+
"AiTcSdk"
|
|
20700
20727
|
]).meta({ id: "FindingProvider" });
|
|
20701
20728
|
var FindingCategory = external_exports.enum([
|
|
20702
20729
|
"secret",
|
|
@@ -21073,18 +21100,41 @@ var AuditEventType = external_exports.enum([
|
|
|
21073
21100
|
// 'tool_call' is the reconciler's structural row for every call, while
|
|
21074
21101
|
// 'tool_use' exists only where a hook enforced against the arguments.
|
|
21075
21102
|
"tool_use",
|
|
21076
|
-
// One row per model REFUSAL
|
|
21077
|
-
//
|
|
21078
|
-
//
|
|
21079
|
-
//
|
|
21080
|
-
//
|
|
21081
|
-
//
|
|
21103
|
+
// One row per model REFUSAL, across all four seams a prohibited model can be
|
|
21104
|
+
// stopped at: a switch onto it, a turn already running on it, a subagent
|
|
21105
|
+
// spawn asking for it, or a request-path refusal an embedded request-path
|
|
21106
|
+
// SDK makes in-process before the call leaves the application. Which seam
|
|
21107
|
+
// rides `attributes.refusal_seam`, never this member name. A structural row
|
|
21108
|
+
// like the ones above rather than a capture — it carries the model that was
|
|
21109
|
+
// refused and nothing the user typed, because what is worth recording about
|
|
21110
|
+
// a governance decision is the decision, and prompt text is the thing this
|
|
21111
|
+
// product exists to keep from travelling.
|
|
21082
21112
|
"model_refusal",
|
|
21113
|
+
// One row per request-path DECISION: a policy check an embedded request-path
|
|
21114
|
+
// SDK performs in-process before a model call leaves the application, or
|
|
21115
|
+
// against that call's non-streamed response. A structural row like
|
|
21116
|
+
// 'model_refusal' rather than a capture — content-free in the same way:
|
|
21117
|
+
// which side, which seam, what action and which field are decided rides
|
|
21118
|
+
// `attributes`, never this member name, and the matched text itself never
|
|
21119
|
+
// travels.
|
|
21120
|
+
//
|
|
21121
|
+
// A prohibited-model refusal on the request path is deliberately NOT this
|
|
21122
|
+
// member: it stays 'model_refusal' with `refusal_seam: 'request'`, so it
|
|
21123
|
+
// shares one bucket with the plugin's switch/turn/spawn refusals rather
|
|
21124
|
+
// than splitting one governance concept across two event types. This
|
|
21125
|
+
// member carries every OTHER request-path decision.
|
|
21126
|
+
"request_decision",
|
|
21083
21127
|
// One row per config-inventory scan, hung off the session root. It is the
|
|
21084
21128
|
// fact the posture inspection findings reference (findings require an
|
|
21085
21129
|
// audit_event_id), and its started_at is the "scanned Nm ago" the read
|
|
21086
21130
|
// surface renders.
|
|
21087
|
-
"config_scan"
|
|
21131
|
+
"config_scan",
|
|
21132
|
+
// One row per reported browser-extension capture status, hung off the web
|
|
21133
|
+
// session root. The durable home of what one tab's network interception
|
|
21134
|
+
// is doing — a write-through of the native host's in-memory tracker, so a
|
|
21135
|
+
// second process (aka extension status) and a restarted host both have
|
|
21136
|
+
// somewhere to read it back from.
|
|
21137
|
+
"capture_status"
|
|
21088
21138
|
]).meta({ id: "AuditEventType" });
|
|
21089
21139
|
var AttributeBag = external_exports.record(external_exports.string(), external_exports.unknown());
|
|
21090
21140
|
var HostAttributes = external_exports.object({
|
|
@@ -21244,6 +21294,20 @@ var CaptureAttributes = external_exports.object({
|
|
|
21244
21294
|
// repeated rather than referenced because a store reader opens this file.
|
|
21245
21295
|
redact_degraded_to: ActionTaken.optional()
|
|
21246
21296
|
}).catchall(external_exports.unknown());
|
|
21297
|
+
var CaptureStatusAttributes = external_exports.object({
|
|
21298
|
+
source_tool: external_exports.string().optional(),
|
|
21299
|
+
patched: external_exports.boolean().optional(),
|
|
21300
|
+
live: external_exports.boolean().optional(),
|
|
21301
|
+
blind: external_exports.boolean().optional(),
|
|
21302
|
+
sends_seen_dom: external_exports.number().int().nonnegative().optional(),
|
|
21303
|
+
exchanges_seen_net: external_exports.number().int().nonnegative().optional(),
|
|
21304
|
+
parse_failures: external_exports.number().int().nonnegative().optional(),
|
|
21305
|
+
unparsed_bodies: external_exports.number().int().nonnegative().optional(),
|
|
21306
|
+
shape_misses: external_exports.array(external_exports.string()).optional(),
|
|
21307
|
+
conversation_endpoints: external_exports.number().int().nonnegative().optional(),
|
|
21308
|
+
closed: external_exports.boolean().optional(),
|
|
21309
|
+
enforcement: external_exports.string().optional()
|
|
21310
|
+
}).catchall(external_exports.unknown());
|
|
21247
21311
|
var ToolCallInspection = external_exports.object({
|
|
21248
21312
|
ruleId: external_exports.string().min(1),
|
|
21249
21313
|
ruleName: external_exports.string(),
|
|
@@ -22103,6 +22167,30 @@ var AttachedCredential = external_exports.object({
|
|
|
22103
22167
|
keyPrefix: external_exports.string().min(1).max(16).optional(),
|
|
22104
22168
|
mintedAt: external_exports.iso.datetime().optional()
|
|
22105
22169
|
});
|
|
22170
|
+
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
22171
|
+
function unsafeEndpointReason(endpoint) {
|
|
22172
|
+
let parsed2;
|
|
22173
|
+
try {
|
|
22174
|
+
parsed2 = new URL(endpoint);
|
|
22175
|
+
} catch {
|
|
22176
|
+
return "unparseable";
|
|
22177
|
+
}
|
|
22178
|
+
if (parsed2.username !== "" || parsed2.password !== "") return "userinfo";
|
|
22179
|
+
if (parsed2.search !== "" || parsed2.hash !== "") return "query-or-fragment";
|
|
22180
|
+
if (parsed2.protocol === "https:") return null;
|
|
22181
|
+
return parsed2.protocol === "http:" && LOOPBACK_HOSTS.has(parsed2.hostname) ? null : "insecure";
|
|
22182
|
+
}
|
|
22183
|
+
function isSafeEndpoint(endpoint) {
|
|
22184
|
+
return unsafeEndpointReason(endpoint) === null;
|
|
22185
|
+
}
|
|
22186
|
+
function originOnly(endpoint) {
|
|
22187
|
+
try {
|
|
22188
|
+
const parsed2 = new URL(endpoint);
|
|
22189
|
+
return `${parsed2.protocol}//${parsed2.host}`;
|
|
22190
|
+
} catch {
|
|
22191
|
+
return "(unparseable endpoint)";
|
|
22192
|
+
}
|
|
22193
|
+
}
|
|
22106
22194
|
var MAX_DATE_MS = 253402300799999;
|
|
22107
22195
|
var MAX_INT4 = 2147483647;
|
|
22108
22196
|
var StorePosturePack = external_exports.object({
|
|
@@ -22257,6 +22345,11 @@ var RemoteFailureKind = external_exports.enum([
|
|
|
22257
22345
|
"rejected",
|
|
22258
22346
|
"unreachable"
|
|
22259
22347
|
]);
|
|
22348
|
+
var ControlPlaneFailure = RemoteFailureKind.extract([
|
|
22349
|
+
"unauthorized",
|
|
22350
|
+
"forbidden",
|
|
22351
|
+
"unreachable"
|
|
22352
|
+
]);
|
|
22260
22353
|
var AttachDeviceRequest = external_exports.object({
|
|
22261
22354
|
// This machine's own continuity id, so re-attaching ROTATES the credential
|
|
22262
22355
|
// on one machine record instead of producing a second one. Client-minted
|
|
@@ -22796,7 +22889,12 @@ var EventMetadata = external_exports.object({
|
|
|
22796
22889
|
// in — set by the browser extension's network capture so a stored `response`
|
|
22797
22890
|
// row can be joined to the `llm_call` leaf describing the same turn. Absent
|
|
22798
22891
|
// on every other capture path, which has no such id.
|
|
22799
|
-
|
|
22892
|
+
//
|
|
22893
|
+
// Non-empty for the reason WebExchange.messageId is: it is the join key, and
|
|
22894
|
+
// a blank one matches no `llm_call` leaf. That refusal reaches only the
|
|
22895
|
+
// places an event is PARSED; the local write path types the event and parses
|
|
22896
|
+
// nothing, which is why `toCaptureAttributes` omits a blank one separately.
|
|
22897
|
+
messageId: external_exports.string().min(1).optional(),
|
|
22800
22898
|
conversationId: external_exports.string().optional(),
|
|
22801
22899
|
// How long THIS capture's inspection blocked its caller, in whole
|
|
22802
22900
|
// milliseconds — the plugin's own added latency, NOT the LLM call it sat in
|
|
@@ -23638,6 +23736,85 @@ function policyIdIsReversible(policyId) {
|
|
|
23638
23736
|
var DEFAULT_ACTIONS = Object.fromEntries(
|
|
23639
23737
|
DetectionCategory.options.map((c) => [c, builtinPolicyToAction(severityFloorPolicy(c))])
|
|
23640
23738
|
);
|
|
23739
|
+
function ruleCategoryMap(wireRules, localRules, compiledRules) {
|
|
23740
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
23741
|
+
for (const rule of wireRules ?? []) map2.set(rule.id, rule.category);
|
|
23742
|
+
for (const rule of localRules ?? []) map2.set(rule.id, rule.category);
|
|
23743
|
+
for (const rule of compiledRules) map2.set(rule.id, rule.category);
|
|
23744
|
+
return map2;
|
|
23745
|
+
}
|
|
23746
|
+
function policyKey(policy) {
|
|
23747
|
+
return "ruleId" in policy.target ? `rule:${policy.target.ruleId}` : `category:${policy.target.category}`;
|
|
23748
|
+
}
|
|
23749
|
+
function floorFor(policy, categoryByRuleId) {
|
|
23750
|
+
const category = "category" in policy.target ? policy.target.category : categoryByRuleId.get(policy.target.ruleId);
|
|
23751
|
+
return category === void 0 ? null : DEFAULT_ACTIONS[category];
|
|
23752
|
+
}
|
|
23753
|
+
function strongerOf(a, b) {
|
|
23754
|
+
if (a === null) return b;
|
|
23755
|
+
if (b === null) return a;
|
|
23756
|
+
return strongerAction(a, b);
|
|
23757
|
+
}
|
|
23758
|
+
function mergeRaiseOnly(localPolicies, remotePolicies, categoryByRuleId) {
|
|
23759
|
+
const merged = /* @__PURE__ */ new Map();
|
|
23760
|
+
const disabled = [];
|
|
23761
|
+
const remoteCategoryAction = /* @__PURE__ */ new Map();
|
|
23762
|
+
for (const policy of remotePolicies) {
|
|
23763
|
+
if (!policy.enabled) continue;
|
|
23764
|
+
if (!("category" in policy.target)) continue;
|
|
23765
|
+
if (remoteCategoryAction.has(policy.target.category)) continue;
|
|
23766
|
+
const floor = floorFor(policy, categoryByRuleId);
|
|
23767
|
+
remoteCategoryAction.set(
|
|
23768
|
+
policy.target.category,
|
|
23769
|
+
floor !== null && !isActionAtLeast(policy.action, floor) ? floor : policy.action
|
|
23770
|
+
);
|
|
23771
|
+
}
|
|
23772
|
+
for (const policy of localPolicies) {
|
|
23773
|
+
if (!policy.enabled) {
|
|
23774
|
+
disabled.push(policy);
|
|
23775
|
+
continue;
|
|
23776
|
+
}
|
|
23777
|
+
const key = policyKey(policy);
|
|
23778
|
+
if (merged.has(key)) continue;
|
|
23779
|
+
let remoteFloor = null;
|
|
23780
|
+
if ("ruleId" in policy.target) {
|
|
23781
|
+
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
23782
|
+
if (category !== void 0) remoteFloor = remoteCategoryAction.get(category) ?? null;
|
|
23783
|
+
}
|
|
23784
|
+
merged.set(
|
|
23785
|
+
key,
|
|
23786
|
+
remoteFloor !== null && !isActionAtLeast(policy.action, remoteFloor) ? { ...policy, action: remoteFloor } : policy
|
|
23787
|
+
);
|
|
23788
|
+
}
|
|
23789
|
+
const localCategoryAction = /* @__PURE__ */ new Map();
|
|
23790
|
+
for (const policy of merged.values()) {
|
|
23791
|
+
if ("category" in policy.target) localCategoryAction.set(policy.target.category, policy.action);
|
|
23792
|
+
}
|
|
23793
|
+
for (const policy of remotePolicies) {
|
|
23794
|
+
if (!policy.enabled) {
|
|
23795
|
+
disabled.push(policy);
|
|
23796
|
+
continue;
|
|
23797
|
+
}
|
|
23798
|
+
const key = policyKey(policy);
|
|
23799
|
+
const floor = floorFor(policy, categoryByRuleId);
|
|
23800
|
+
let localFloor = null;
|
|
23801
|
+
if ("ruleId" in policy.target) {
|
|
23802
|
+
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
23803
|
+
if (category !== void 0) localFloor = localCategoryAction.get(category) ?? null;
|
|
23804
|
+
}
|
|
23805
|
+
const effectiveFloor = strongerOf(floor, localFloor);
|
|
23806
|
+
const clamped = effectiveFloor !== null && !isActionAtLeast(policy.action, effectiveFloor) ? { ...policy, action: effectiveFloor } : policy;
|
|
23807
|
+
const existing = merged.get(key);
|
|
23808
|
+
if (existing === void 0) {
|
|
23809
|
+
merged.set(key, clamped);
|
|
23810
|
+
continue;
|
|
23811
|
+
}
|
|
23812
|
+
if (actionRank(clamped.action) > actionRank(existing.action)) {
|
|
23813
|
+
merged.set(key, clamped);
|
|
23814
|
+
}
|
|
23815
|
+
}
|
|
23816
|
+
return [...merged.values(), ...disabled];
|
|
23817
|
+
}
|
|
23641
23818
|
var BUILTIN_POLICIES = Object.fromEntries(
|
|
23642
23819
|
KNOWN_BUILTIN_IDS.map((id) => [id, { id, ...BUILTIN_POLICY_SPECS[id] }])
|
|
23643
23820
|
);
|
|
@@ -23860,6 +24037,18 @@ var HistorySyncConsent = external_exports.object({
|
|
|
23860
24037
|
payloadVersion: external_exports.number().int().positive(),
|
|
23861
24038
|
endpoint: external_exports.string()
|
|
23862
24039
|
});
|
|
24040
|
+
var WebChatCaptureConsent = external_exports.object({
|
|
24041
|
+
acknowledgedAt: external_exports.iso.datetime(),
|
|
24042
|
+
version: external_exports.number().int().positive()
|
|
24043
|
+
});
|
|
24044
|
+
var WebChatResponseCapture = external_exports.enum(["with-findings", "always", "never"]);
|
|
24045
|
+
var WebChatCapture = external_exports.object({
|
|
24046
|
+
responses: WebChatResponseCapture.default("with-findings"),
|
|
24047
|
+
account: external_exports.boolean().default(false),
|
|
24048
|
+
// Absent until granted. Presence alone does not authorize anything — see
|
|
24049
|
+
// isWebChatCaptureConsentValid.
|
|
24050
|
+
consent: WebChatCaptureConsent.optional()
|
|
24051
|
+
});
|
|
23863
24052
|
var BODY_RETENTION_DEFAULT_DAYS = 30;
|
|
23864
24053
|
var BodyRetention = external_exports.object({
|
|
23865
24054
|
enabled: external_exports.boolean().default(false),
|
|
@@ -23918,6 +24107,16 @@ var WorkspaceSettings = external_exports.object({
|
|
|
23918
24107
|
// both widenings. Absent until granted, and a grant for a different endpoint
|
|
23919
24108
|
// or an older payload no longer counts.
|
|
23920
24109
|
historySyncConsent: HistorySyncConsent.optional(),
|
|
24110
|
+
// What the browser extension may record from a web chat, and the grant that
|
|
24111
|
+
// authorizes it. Absent until the user answers: recording something that was
|
|
24112
|
+
// never recorded before is never an assumed grant on upgrade, so the whole
|
|
24113
|
+
// block is optional rather than defaulted in. What an absent block means is
|
|
24114
|
+
// webChatCaptureOf's answer, in one place.
|
|
24115
|
+
//
|
|
24116
|
+
// Enforcement is NOT gated on this. A machine that has never answered still
|
|
24117
|
+
// blocks, redacts and warns on what a user sends; the grant covers what is
|
|
24118
|
+
// written down.
|
|
24119
|
+
webChatCapture: WebChatCapture.optional(),
|
|
23921
24120
|
// Local body expiry (see BodyRetention). Off until switched on; expiring a
|
|
23922
24121
|
// body never removes the row or its findings.
|
|
23923
24122
|
bodyRetention: BodyRetention.default({
|
|
@@ -24025,7 +24224,10 @@ function toCaptureAttributes(event) {
|
|
|
24025
24224
|
// `.catchall(z.unknown())` carries the long tail.
|
|
24026
24225
|
...metadata?.model !== void 0 ? { model: metadata.model } : {},
|
|
24027
24226
|
...metadata?.turnIndex !== void 0 ? { turn_index: metadata.turnIndex } : {},
|
|
24028
|
-
|
|
24227
|
+
// A blank id is omitted rather than stored: it is a join key and `''` joins
|
|
24228
|
+
// nothing. This runs on the local write path, which types the event but
|
|
24229
|
+
// never parses it, so EventMetadata's own `.min(1)` does not reach here.
|
|
24230
|
+
...metadata?.messageId !== void 0 && metadata.messageId !== "" ? { message_id: metadata.messageId } : {},
|
|
24029
24231
|
...metadata?.conversationId !== void 0 ? { conversation_id: metadata.conversationId } : {}
|
|
24030
24232
|
};
|
|
24031
24233
|
}
|
|
@@ -24399,12 +24601,14 @@ var RecommendedActionIdParam = external_exports.object({ id: external_exports.st
|
|
|
24399
24601
|
// ../../packages/schema/src/zod/settings-action.ts
|
|
24400
24602
|
var HistorySyncConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "HistorySyncConsentChoice" });
|
|
24401
24603
|
var ModelJudgeConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "ModelJudgeConsentChoice" });
|
|
24604
|
+
var WebChatCaptureConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "WebChatCaptureConsentChoice" });
|
|
24402
24605
|
var SaveSettingsInput = external_exports.object({
|
|
24403
24606
|
historicalAccess: external_exports.string(),
|
|
24404
24607
|
modelJudgeConsent: ModelJudgeConsentChoice,
|
|
24405
24608
|
historySyncConsent: HistorySyncConsentChoice,
|
|
24406
24609
|
vaultConsent: external_exports.string(),
|
|
24407
24610
|
vaultInlineReveal: external_exports.string(),
|
|
24611
|
+
webChatCaptureConsent: WebChatCaptureConsentChoice,
|
|
24408
24612
|
// Widened to `string` like its neighbours rather than typed as
|
|
24409
24613
|
// `RedactFallback`, on this module's own layering rule: shape here, VALUE at
|
|
24410
24614
|
// the call site, so the domain check receives the type it was written for.
|
|
@@ -24619,11 +24823,24 @@ var WebExchange = external_exports.object({
|
|
|
24619
24823
|
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
24620
24824
|
toolCalls: external_exports.array(WebToolCall).default([]),
|
|
24621
24825
|
// Absent when the adapter recovered no text. Capped by the caller at
|
|
24622
|
-
// RESPONSE_TEXT_MAX_BYTES
|
|
24623
|
-
//
|
|
24826
|
+
// RESPONSE_TEXT_MAX_BYTES, so a short capture is never mistaken for a short
|
|
24827
|
+
// reply.
|
|
24624
24828
|
responseText: external_exports.string().optional(),
|
|
24829
|
+
// The stored text is short of the reply. It does NOT say which of the two
|
|
24830
|
+
// ceilings on this path cut it: the caller applies its own cap on the raw
|
|
24831
|
+
// bytes it reads off the wire, which can be reached by a stream whose
|
|
24832
|
+
// recovered text stays well under RESPONSE_TEXT_MAX_BYTES, and applies that
|
|
24833
|
+
// one to the text. A reader cannot tell them apart, and nothing downstream
|
|
24834
|
+
// should branch as though it could.
|
|
24625
24835
|
truncated: external_exports.boolean().default(false)
|
|
24626
24836
|
});
|
|
24837
|
+
var WebEnforcementState = external_exports.enum([
|
|
24838
|
+
"watching",
|
|
24839
|
+
"composer-only",
|
|
24840
|
+
"button-only",
|
|
24841
|
+
"unattached",
|
|
24842
|
+
"unknown"
|
|
24843
|
+
]);
|
|
24627
24844
|
var RESPONSE_TEXT_MAX_BYTES = 2 * 1024 * 1024;
|
|
24628
24845
|
var WebCaptureStatus = external_exports.object({
|
|
24629
24846
|
patched: external_exports.boolean(),
|
|
@@ -24635,8 +24852,66 @@ var WebCaptureStatus = external_exports.object({
|
|
|
24635
24852
|
unparsedBodies: external_exports.number().int().nonnegative(),
|
|
24636
24853
|
// The adapter-declared JSON key paths that were absent from a real payload —
|
|
24637
24854
|
// the earliest signal that a site's contract moved.
|
|
24638
|
-
shapeMisses: external_exports.array(external_exports.string()).default([])
|
|
24639
|
-
|
|
24855
|
+
shapeMisses: external_exports.array(external_exports.string()).default([]),
|
|
24856
|
+
// How many `kind: 'conversation'` endpoints the reporting tab's adapter
|
|
24857
|
+
// compiled. Zero means this build declares none for the site, so observing
|
|
24858
|
+
// nothing is the design rather than a fault — the one fact that separates a
|
|
24859
|
+
// site nobody has surveyed yet from one whose contract moved. Defaulted so a
|
|
24860
|
+
// build predating the field is read as declaring nothing rather than refused.
|
|
24861
|
+
conversationEndpoints: external_exports.number().int().nonnegative().default(0),
|
|
24862
|
+
// The document that sent this report is going away. The bridge sets it on
|
|
24863
|
+
// its `pagehide` report and nowhere else.
|
|
24864
|
+
//
|
|
24865
|
+
// A property of the REPORT rather than of capture health, which is why
|
|
24866
|
+
// nothing in `deriveWebCaptureState` reads it and why it stays out of the
|
|
24867
|
+
// bridge's own report signature — a closing tab's last word must not be
|
|
24868
|
+
// suppressed for carrying the same health as the report before it. What
|
|
24869
|
+
// reads it is the per-site fold: a document that said it was unloading stops
|
|
24870
|
+
// voting on the site's state, so the reload the `blind` remediation asks for
|
|
24871
|
+
// can actually clear the verdict it was shown. A document that dies without
|
|
24872
|
+
// sending one is covered by CAPTURE_STATUS_DOCUMENT_QUIET_MS instead.
|
|
24873
|
+
//
|
|
24874
|
+
// Defaulted so a build predating the field reads as a document that never
|
|
24875
|
+
// said it was closing — which keeps it voting, the same as every report that
|
|
24876
|
+
// is not a final one.
|
|
24877
|
+
closed: external_exports.boolean().default(false),
|
|
24878
|
+
// What the DOM enforcement path is doing, which none of the counters above
|
|
24879
|
+
// can say: `sendsSeenDom` rises only once a send has COMPLETED, so a tab
|
|
24880
|
+
// whose watcher never bound reports zero exactly like a tab nobody typed in.
|
|
24881
|
+
// Defaulted to 'unknown' rather than 'watching' so a status from a build
|
|
24882
|
+
// predating the field is not read as reporting a healthy one.
|
|
24883
|
+
enforcement: WebEnforcementState.default("unknown")
|
|
24884
|
+
});
|
|
24885
|
+
function webCaptureStatusObservedTurnPath(status) {
|
|
24886
|
+
if (!status.patched) return true;
|
|
24887
|
+
if (status.conversationEndpoints === 0) return true;
|
|
24888
|
+
return status.blind || status.shapeMisses.length > 0 || status.parseFailures > 0 || status.unparsedBodies > 0 || status.exchangesSeenNet > 0;
|
|
24889
|
+
}
|
|
24890
|
+
function pickReportedCaptureStatus(candidates) {
|
|
24891
|
+
return candidates.find((c) => webCaptureStatusObservedTurnPath(c.status)) ?? candidates[0];
|
|
24892
|
+
}
|
|
24893
|
+
var CAPTURE_STATUS_RECENCY_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
24894
|
+
var CAPTURE_STATUS_RECENCY_DAYS = CAPTURE_STATUS_RECENCY_MS / (24 * 60 * 60 * 1e3);
|
|
24895
|
+
var CAPTURE_STATUS_DOCUMENT_QUIET_MS = 12 * 60 * 60 * 1e3;
|
|
24896
|
+
function fromCaptureStatusAttributes(bag) {
|
|
24897
|
+
const parsedBag = CaptureStatusAttributes.safeParse(bag);
|
|
24898
|
+
if (!parsedBag.success) return null;
|
|
24899
|
+
const b = parsedBag.data;
|
|
24900
|
+
const parsedStatus = WebCaptureStatus.safeParse({
|
|
24901
|
+
patched: b.patched,
|
|
24902
|
+
live: b.live,
|
|
24903
|
+
blind: b.blind,
|
|
24904
|
+
sendsSeenDom: b.sends_seen_dom,
|
|
24905
|
+
exchangesSeenNet: b.exchanges_seen_net,
|
|
24906
|
+
parseFailures: b.parse_failures,
|
|
24907
|
+
unparsedBodies: b.unparsed_bodies,
|
|
24908
|
+
shapeMisses: b.shape_misses,
|
|
24909
|
+
conversationEndpoints: b.conversation_endpoints,
|
|
24910
|
+
closed: b.closed,
|
|
24911
|
+
enforcement: b.enforcement
|
|
24912
|
+
});
|
|
24913
|
+
return parsedStatus.success ? parsedStatus.data : null;
|
|
24914
|
+
}
|
|
24640
24915
|
|
|
24641
24916
|
// ../../packages/persistence/src/paths.ts
|
|
24642
24917
|
import {
|
|
@@ -24747,17 +25022,6 @@ function publishByLink(tmp, file2, data) {
|
|
|
24747
25022
|
function controlPlaneCredentialPath(settingsDir2) {
|
|
24748
25023
|
return join2(settingsDir2, ATTACHED_CREDENTIAL_FILENAME);
|
|
24749
25024
|
}
|
|
24750
|
-
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
24751
|
-
function isSafeEndpoint(endpoint) {
|
|
24752
|
-
let parsed2;
|
|
24753
|
-
try {
|
|
24754
|
-
parsed2 = new URL(endpoint);
|
|
24755
|
-
} catch {
|
|
24756
|
-
return false;
|
|
24757
|
-
}
|
|
24758
|
-
if (parsed2.protocol === "https:") return true;
|
|
24759
|
-
return parsed2.protocol === "http:" && LOOPBACK_HOSTS.has(parsed2.hostname);
|
|
24760
|
-
}
|
|
24761
25025
|
function repairOrRefuseMode(file2) {
|
|
24762
25026
|
const link = lstatSync2(file2, { throwIfNoEntry: false });
|
|
24763
25027
|
if (link === void 0) return "absent";
|
|
@@ -26540,7 +26804,7 @@ var SESSION_ROOT = `event_type = 'session'`;
|
|
|
26540
26804
|
var HAS_ACTIVITY = `EXISTS (
|
|
26541
26805
|
SELECT 1 FROM audit_events c
|
|
26542
26806
|
WHERE c.root_session_id = audit_events.id
|
|
26543
|
-
AND c.event_type NOT IN ('hook', 'config_scan'))`;
|
|
26807
|
+
AND c.event_type NOT IN ('hook', 'config_scan', 'capture_status'))`;
|
|
26544
26808
|
var SqliteActivityRepository = class {
|
|
26545
26809
|
constructor(db, now = () => Date.now()) {
|
|
26546
26810
|
this.db = db;
|
|
@@ -26567,10 +26831,10 @@ var SqliteActivityRepository = class {
|
|
|
26567
26831
|
SELECT id FROM audit_events WHERE event_type = 'session' AND started_at >= ?
|
|
26568
26832
|
UNION
|
|
26569
26833
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_started_at
|
|
26570
|
-
WHERE started_at >= ?
|
|
26834
|
+
WHERE started_at >= ? AND event_type <> 'capture_status'
|
|
26571
26835
|
UNION
|
|
26572
26836
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_ended_at
|
|
26573
|
-
WHERE ended_at >= ?)`,
|
|
26837
|
+
WHERE ended_at >= ? AND event_type <> 'capture_status')`,
|
|
26574
26838
|
[liveThreshold, liveThreshold, liveThreshold]
|
|
26575
26839
|
);
|
|
26576
26840
|
const toolCallsToday = countScalar(
|
|
@@ -26977,7 +27241,10 @@ var SqliteAuditEventsRepository = class {
|
|
|
26977
27241
|
attributes = excluded.attributes,
|
|
26978
27242
|
ended_at = excluded.ended_at
|
|
26979
27243
|
WHERE COALESCE(json_extract(excluded.attributes, '$.output_tokens'), 0)
|
|
26980
|
-
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27244
|
+
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27245
|
+
OR (json_extract(excluded.attributes, '$.usage_source') IS NOT NULL
|
|
27246
|
+
AND json_extract(excluded.attributes, '$.output_tokens') IS NULL
|
|
27247
|
+
AND excluded.attributes <> audit_events.attributes)`
|
|
26981
27248
|
);
|
|
26982
27249
|
this.upsertSessionRootStmt = db.prepare(
|
|
26983
27250
|
`INSERT OR IGNORE INTO audit_events
|
|
@@ -27245,6 +27512,87 @@ var SqliteBodyRetentionRepository = class {
|
|
|
27245
27512
|
}
|
|
27246
27513
|
};
|
|
27247
27514
|
|
|
27515
|
+
// ../../packages/persistence/src/repositories/capture-status.ts
|
|
27516
|
+
var STATUS_LOOKBACK_ROWS = 128;
|
|
27517
|
+
var SqliteCaptureStatusRepository = class {
|
|
27518
|
+
constructor(db) {
|
|
27519
|
+
this.db = db;
|
|
27520
|
+
this.recentStmt = db.prepare(
|
|
27521
|
+
`SELECT a.started_at AS startedAt,
|
|
27522
|
+
a.attributes AS attributes,
|
|
27523
|
+
a.root_session_id AS rootSessionId
|
|
27524
|
+
FROM audit_events a
|
|
27525
|
+
WHERE a.event_type = 'capture_status'
|
|
27526
|
+
AND a.source_tool = ?
|
|
27527
|
+
AND a.started_at >= ?
|
|
27528
|
+
ORDER BY a.started_at DESC, a.id DESC
|
|
27529
|
+
LIMIT ?`
|
|
27530
|
+
);
|
|
27531
|
+
}
|
|
27532
|
+
db;
|
|
27533
|
+
recentStmt;
|
|
27534
|
+
/**
|
|
27535
|
+
* Every document that reported for a site, in registry order by site, from
|
|
27536
|
+
* the last `CAPTURE_STATUS_RECENCY_MS`.
|
|
27537
|
+
*
|
|
27538
|
+
* SEVERAL per site, not one: a browser is many documents and each reports
|
|
27539
|
+
* for itself, so one row per site is a choice about which of them a user
|
|
27540
|
+
* sees — and the newest is the wrong one, since a healthy tab writing a
|
|
27541
|
+
* fresh report would hide a drifting tab's verdict, which is the whole
|
|
27542
|
+
* reason these rows exist. The pick WITHIN a document is made here (the
|
|
27543
|
+
* unchanged `pickReportedCaptureStatus`, over that document's own rows);
|
|
27544
|
+
* choosing between documents belongs where the state semantics live, and
|
|
27545
|
+
* that is `reportedCaptureDocumentForSite` in `@akasecurity/detections` —
|
|
27546
|
+
* this package may not import it.
|
|
27547
|
+
*
|
|
27548
|
+
* `now` is a required argument rather than a `Date.now()` read, so a caller
|
|
27549
|
+
* that already holds a render instant passes THAT one and a test can drive
|
|
27550
|
+
* the window without moving the wall clock.
|
|
27551
|
+
*
|
|
27552
|
+
* A site whose reports have all aged out contributes nothing, so it derives
|
|
27553
|
+
* to `unreported`. That is the point: nothing but the browser extension ever
|
|
27554
|
+
* writes these rows, so an uninstalled extension's last verdict would
|
|
27555
|
+
* otherwise stand as a live claim for ever with no later report able to
|
|
27556
|
+
* clear it.
|
|
27557
|
+
*/
|
|
27558
|
+
latest(now) {
|
|
27559
|
+
const since = now - CAPTURE_STATUS_RECENCY_MS;
|
|
27560
|
+
const documents = [];
|
|
27561
|
+
for (const tool of WebSourceTool.options) {
|
|
27562
|
+
const rows = /* @__PURE__ */ new Map();
|
|
27563
|
+
const lastWord = /* @__PURE__ */ new Map();
|
|
27564
|
+
for (const row of allRows(this.recentStmt, [
|
|
27565
|
+
tool,
|
|
27566
|
+
since,
|
|
27567
|
+
STATUS_LOOKBACK_ROWS
|
|
27568
|
+
])) {
|
|
27569
|
+
const status = fromCaptureStatusAttributes(parseJsonObject(row.attributes));
|
|
27570
|
+
if (status === null) continue;
|
|
27571
|
+
const record2 = { tool, observedAt: epochMillisToIso(row.startedAt), status };
|
|
27572
|
+
const group = rows.get(row.rootSessionId);
|
|
27573
|
+
if (group === void 0) {
|
|
27574
|
+
rows.set(row.rootSessionId, [record2]);
|
|
27575
|
+
lastWord.set(row.rootSessionId, { at: record2.observedAt, closed: status.closed });
|
|
27576
|
+
} else {
|
|
27577
|
+
group.push(record2);
|
|
27578
|
+
}
|
|
27579
|
+
}
|
|
27580
|
+
for (const [root, candidates] of rows) {
|
|
27581
|
+
const picked = pickReportedCaptureStatus(candidates);
|
|
27582
|
+
const last = lastWord.get(root);
|
|
27583
|
+
if (picked === void 0 || last === void 0) continue;
|
|
27584
|
+
documents.push({
|
|
27585
|
+
...picked,
|
|
27586
|
+
...root === null ? {} : { rootSessionId: root },
|
|
27587
|
+
lastReportAt: last.at,
|
|
27588
|
+
closed: last.closed
|
|
27589
|
+
});
|
|
27590
|
+
}
|
|
27591
|
+
}
|
|
27592
|
+
return documents;
|
|
27593
|
+
}
|
|
27594
|
+
};
|
|
27595
|
+
|
|
27248
27596
|
// ../../packages/persistence/src/repositories/classified-data.ts
|
|
27249
27597
|
var SqliteClassifiedDataRepository = class {
|
|
27250
27598
|
constructor(db) {
|
|
@@ -32822,6 +33170,7 @@ function openAndInitialize(file2, base, skipTags) {
|
|
|
32822
33170
|
activity: new SqliteActivityRepository(db),
|
|
32823
33171
|
sourceProject: new SqliteSourceProjectRepository(db),
|
|
32824
33172
|
auditEvents: new SqliteAuditEventsRepository(db),
|
|
33173
|
+
captureStatus: new SqliteCaptureStatusRepository(db),
|
|
32825
33174
|
classifiedData: new SqliteClassifiedDataRepository(db),
|
|
32826
33175
|
inspectionDefinitions: new SqliteInspectionDefinitionsRepository(db),
|
|
32827
33176
|
inspectionFindings: new SqliteInspectionFindingsRepository(db),
|
|
@@ -32862,6 +33211,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
32862
33211
|
activity,
|
|
32863
33212
|
sourceProject,
|
|
32864
33213
|
auditEvents,
|
|
33214
|
+
captureStatus,
|
|
32865
33215
|
classifiedData,
|
|
32866
33216
|
inspectionDefinitions,
|
|
32867
33217
|
inspectionFindings,
|
|
@@ -33079,6 +33429,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
33079
33429
|
activity,
|
|
33080
33430
|
sourceProject,
|
|
33081
33431
|
auditEvents,
|
|
33432
|
+
captureStatus,
|
|
33082
33433
|
classifiedData,
|
|
33083
33434
|
inspectionDefinitions,
|
|
33084
33435
|
inspectionFindings,
|
|
@@ -33213,11 +33564,6 @@ function readFingerprintKey(dataDir2) {
|
|
|
33213
33564
|
// ../../packages/persistence/src/forward-health.ts
|
|
33214
33565
|
import { readFileSync as readFileSync7 } from "fs";
|
|
33215
33566
|
import { join as join9 } from "path";
|
|
33216
|
-
var FAILURES = /* @__PURE__ */ new Set([
|
|
33217
|
-
"unauthorized",
|
|
33218
|
-
"forbidden",
|
|
33219
|
-
"unreachable"
|
|
33220
|
-
]);
|
|
33221
33567
|
var BREAKER_COOLDOWN_MS = 3e4;
|
|
33222
33568
|
function parseForwardHealth(raw, nowMs) {
|
|
33223
33569
|
try {
|
|
@@ -33226,7 +33572,8 @@ function parseForwardHealth(raw, nowMs) {
|
|
|
33226
33572
|
const record2 = parsed2;
|
|
33227
33573
|
const failures = typeof record2.consecutiveFailures === "number" && record2.consecutiveFailures >= 0 ? record2.consecutiveFailures : 0;
|
|
33228
33574
|
const openedAtMs = typeof record2.openedAtMs === "number" && Number.isFinite(record2.openedAtMs) && record2.openedAtMs <= nowMs ? record2.openedAtMs : null;
|
|
33229
|
-
const
|
|
33575
|
+
const parsedFailure = ControlPlaneFailure.safeParse(record2.lastFailure);
|
|
33576
|
+
const lastFailure = parsedFailure.success ? parsedFailure.data : null;
|
|
33230
33577
|
return { consecutiveFailures: failures, openedAtMs, lastFailure };
|
|
33231
33578
|
} catch {
|
|
33232
33579
|
return null;
|
|
@@ -33316,6 +33663,12 @@ var RemoteRequestInvalid = class extends Error {
|
|
|
33316
33663
|
}
|
|
33317
33664
|
cause;
|
|
33318
33665
|
};
|
|
33666
|
+
var RemoteEndpointRefused = class extends Error {
|
|
33667
|
+
constructor(endpoint) {
|
|
33668
|
+
super(`refusing to talk to an unsafe control-plane endpoint: ${originOnly(endpoint)}`);
|
|
33669
|
+
this.name = "RemoteEndpointRefused";
|
|
33670
|
+
}
|
|
33671
|
+
};
|
|
33319
33672
|
var RemoteResponseInvalid = class extends Error {
|
|
33320
33673
|
constructor(route, detail) {
|
|
33321
33674
|
super(`control plane answered ${route} with ${detail}`);
|
|
@@ -33468,14 +33821,15 @@ function parsed(schema, body, route) {
|
|
|
33468
33821
|
}
|
|
33469
33822
|
return result.data;
|
|
33470
33823
|
}
|
|
33471
|
-
function
|
|
33824
|
+
function resolveBaseUrl(endpoint) {
|
|
33825
|
+
if (!isSafeEndpoint(endpoint)) throw new RemoteEndpointRefused(endpoint);
|
|
33472
33826
|
let end = endpoint.length;
|
|
33473
33827
|
while (end > 0 && endpoint.charCodeAt(end - 1) === SLASH2) end -= 1;
|
|
33474
33828
|
return endpoint.slice(0, end);
|
|
33475
33829
|
}
|
|
33476
33830
|
var SLASH2 = "/".charCodeAt(0);
|
|
33477
33831
|
function createRemoteClient(options) {
|
|
33478
|
-
const base =
|
|
33832
|
+
const base = resolveBaseUrl(options.endpoint);
|
|
33479
33833
|
const url2 = (route) => `${base}${route}`;
|
|
33480
33834
|
const common = { apiKey: options.apiKey, timeoutMs: options.timeoutMs };
|
|
33481
33835
|
const sendOne = async (event) => {
|
|
@@ -33605,6 +33959,7 @@ function classifyRemoteFailure(err) {
|
|
|
33605
33959
|
case "RemoteRouteAbsent":
|
|
33606
33960
|
return "route-absent";
|
|
33607
33961
|
case "RemoteRequestInvalid":
|
|
33962
|
+
case "RemoteEndpointRefused":
|
|
33608
33963
|
return "invalid-request";
|
|
33609
33964
|
case "RemoteResponseInvalid":
|
|
33610
33965
|
return "rejected";
|
|
@@ -34509,6 +34864,56 @@ var CONFIG_POSTURE_RULES = [
|
|
|
34509
34864
|
}
|
|
34510
34865
|
];
|
|
34511
34866
|
|
|
34867
|
+
// ../../packages/detections/src/posture/web-capture-posture.ts
|
|
34868
|
+
var RULE_VERSION2 = "1";
|
|
34869
|
+
var DRIFT_MIN_PARSE_FAILURES = 2;
|
|
34870
|
+
var WEB_CAPTURE_DRIFT_STATES = /* @__PURE__ */ new Set([
|
|
34871
|
+
"blind",
|
|
34872
|
+
"degraded"
|
|
34873
|
+
]);
|
|
34874
|
+
var WEB_CAPTURE_DRIFT_RULE = {
|
|
34875
|
+
ruleId: "web-capture-drift",
|
|
34876
|
+
version: RULE_VERSION2,
|
|
34877
|
+
name: "Web chat capture is not reading the site",
|
|
34878
|
+
category: "config",
|
|
34879
|
+
severity: "medium",
|
|
34880
|
+
definition: JSON.stringify({
|
|
34881
|
+
kind: "web-capture-drift",
|
|
34882
|
+
states: [...WEB_CAPTURE_DRIFT_STATES],
|
|
34883
|
+
minParseFailures: DRIFT_MIN_PARSE_FAILURES
|
|
34884
|
+
})
|
|
34885
|
+
};
|
|
34886
|
+
var STATIC_COPY = {
|
|
34887
|
+
active: { headline: "turns are being observed on this site" },
|
|
34888
|
+
unreported: {
|
|
34889
|
+
// Says "recently" rather than "yet": the store read is bounded to
|
|
34890
|
+
// CAPTURE_STATUS_RECENCY_MS, so this state covers a site nothing has ever
|
|
34891
|
+
// reported for AND one whose last report has aged out. The two are the
|
|
34892
|
+
// same fact to a reader — nobody has confirmed anything lately — and the
|
|
34893
|
+
// copy may not claim the stronger of them.
|
|
34894
|
+
headline: `no report in the last ${String(CAPTURE_STATUS_RECENCY_DAYS)} days \u2014 open the site in Chrome with the extension loaded`
|
|
34895
|
+
},
|
|
34896
|
+
standby: {
|
|
34897
|
+
headline: "this build declares no endpoints for the site, so nothing is observed yet"
|
|
34898
|
+
},
|
|
34899
|
+
unpatched: {
|
|
34900
|
+
// Says what the flags say and no more. `patched` is false both for a tap
|
|
34901
|
+
// that installed and hooked neither transport and for one that never ran
|
|
34902
|
+
// at all — a page reports the same status either way, so the copy may not
|
|
34903
|
+
// assert one of them.
|
|
34904
|
+
headline: "the page tap captured neither fetch nor XHR \u2014 it may not have installed; reload the extension at chrome://extensions"
|
|
34905
|
+
},
|
|
34906
|
+
idle: { headline: "watching; no turn has been observed yet" },
|
|
34907
|
+
blind: {
|
|
34908
|
+
headline: "messages were sent in the page that the network capture never saw",
|
|
34909
|
+
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."
|
|
34910
|
+
},
|
|
34911
|
+
degraded: {
|
|
34912
|
+
headline: "the site's payloads no longer carry the fields the extension reads",
|
|
34913
|
+
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."
|
|
34914
|
+
}
|
|
34915
|
+
};
|
|
34916
|
+
|
|
34512
34917
|
// ../../packages/detections/src/security/redos-probe.ts
|
|
34513
34918
|
var BUDGET_MS = 100;
|
|
34514
34919
|
var EXPONENTIAL_UNITS = [
|
|
@@ -36777,86 +37182,10 @@ function createForwardPolicy(deps) {
|
|
|
36777
37182
|
}
|
|
36778
37183
|
|
|
36779
37184
|
// ../../packages/plugin-runtime/src/attached/gateway.ts
|
|
36780
|
-
|
|
36781
|
-
|
|
36782
|
-
|
|
36783
|
-
return
|
|
36784
|
-
}
|
|
36785
|
-
function ruleCategoryMap(wireRules, localRules) {
|
|
36786
|
-
const map2 = /* @__PURE__ */ new Map();
|
|
36787
|
-
for (const rule of wireRules ?? []) map2.set(rule.id, rule.category);
|
|
36788
|
-
for (const rule of localRules ?? []) map2.set(rule.id, rule.category);
|
|
36789
|
-
for (const pack of bundledDetections()) {
|
|
36790
|
-
for (const rule of pack.rules) map2.set(rule.id, rule.category);
|
|
36791
|
-
}
|
|
36792
|
-
return map2;
|
|
36793
|
-
}
|
|
36794
|
-
function policyKey(policy) {
|
|
36795
|
-
return "ruleId" in policy.target ? `rule:${policy.target.ruleId}` : `category:${policy.target.category}`;
|
|
36796
|
-
}
|
|
36797
|
-
function floorFor(policy, categoryByRuleId) {
|
|
36798
|
-
const category = "category" in policy.target ? policy.target.category : categoryByRuleId.get(policy.target.ruleId);
|
|
36799
|
-
return category === void 0 ? null : DEFAULT_ACTIONS[category];
|
|
36800
|
-
}
|
|
36801
|
-
function mergeRaiseOnly(localPolicies, remotePolicies, categoryByRuleId) {
|
|
36802
|
-
const merged = /* @__PURE__ */ new Map();
|
|
36803
|
-
const disabled = [];
|
|
36804
|
-
const remoteCategoryAction = /* @__PURE__ */ new Map();
|
|
36805
|
-
for (const policy of remotePolicies) {
|
|
36806
|
-
if (!policy.enabled) continue;
|
|
36807
|
-
if (!("category" in policy.target)) continue;
|
|
36808
|
-
if (remoteCategoryAction.has(policy.target.category)) continue;
|
|
36809
|
-
const floor = floorFor(policy, categoryByRuleId);
|
|
36810
|
-
remoteCategoryAction.set(
|
|
36811
|
-
policy.target.category,
|
|
36812
|
-
floor !== null && !isActionAtLeast(policy.action, floor) ? floor : policy.action
|
|
36813
|
-
);
|
|
36814
|
-
}
|
|
36815
|
-
for (const policy of localPolicies) {
|
|
36816
|
-
if (!policy.enabled) {
|
|
36817
|
-
disabled.push(policy);
|
|
36818
|
-
continue;
|
|
36819
|
-
}
|
|
36820
|
-
const key = policyKey(policy);
|
|
36821
|
-
if (merged.has(key)) continue;
|
|
36822
|
-
let remoteFloor = null;
|
|
36823
|
-
if ("ruleId" in policy.target) {
|
|
36824
|
-
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
36825
|
-
if (category !== void 0) remoteFloor = remoteCategoryAction.get(category) ?? null;
|
|
36826
|
-
}
|
|
36827
|
-
merged.set(
|
|
36828
|
-
key,
|
|
36829
|
-
remoteFloor !== null && !isActionAtLeast(policy.action, remoteFloor) ? { ...policy, action: remoteFloor } : policy
|
|
36830
|
-
);
|
|
36831
|
-
}
|
|
36832
|
-
const localCategoryAction = /* @__PURE__ */ new Map();
|
|
36833
|
-
for (const policy of merged.values()) {
|
|
36834
|
-
if ("category" in policy.target) localCategoryAction.set(policy.target.category, policy.action);
|
|
36835
|
-
}
|
|
36836
|
-
for (const policy of remotePolicies) {
|
|
36837
|
-
if (!policy.enabled) {
|
|
36838
|
-
disabled.push(policy);
|
|
36839
|
-
continue;
|
|
36840
|
-
}
|
|
36841
|
-
const key = policyKey(policy);
|
|
36842
|
-
const floor = floorFor(policy, categoryByRuleId);
|
|
36843
|
-
let localFloor = null;
|
|
36844
|
-
if ("ruleId" in policy.target) {
|
|
36845
|
-
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
36846
|
-
if (category !== void 0) localFloor = localCategoryAction.get(category) ?? null;
|
|
36847
|
-
}
|
|
36848
|
-
const effectiveFloor = strongerOf(floor, localFloor);
|
|
36849
|
-
const clamped = effectiveFloor !== null && !isActionAtLeast(policy.action, effectiveFloor) ? { ...policy, action: effectiveFloor } : policy;
|
|
36850
|
-
const existing = merged.get(key);
|
|
36851
|
-
if (existing === void 0) {
|
|
36852
|
-
merged.set(key, clamped);
|
|
36853
|
-
continue;
|
|
36854
|
-
}
|
|
36855
|
-
if (actionRank(clamped.action) > actionRank(existing.action)) {
|
|
36856
|
-
merged.set(key, clamped);
|
|
36857
|
-
}
|
|
36858
|
-
}
|
|
36859
|
-
return [...merged.values(), ...disabled];
|
|
37185
|
+
var bundledRulesFlatCache;
|
|
37186
|
+
function bundledRulesFlat() {
|
|
37187
|
+
bundledRulesFlatCache ??= bundledDetections().flatMap((pack) => pack.rules);
|
|
37188
|
+
return bundledRulesFlatCache;
|
|
36860
37189
|
}
|
|
36861
37190
|
var AttachedDataGateway = class {
|
|
36862
37191
|
constructor(deps) {
|
|
@@ -37176,6 +37505,9 @@ var AttachedDataGateway = class {
|
|
|
37176
37505
|
async readSessionProvider(sessionId) {
|
|
37177
37506
|
return this.deps.local.readSessionProvider(sessionId);
|
|
37178
37507
|
}
|
|
37508
|
+
async readCaptureStatuses() {
|
|
37509
|
+
return this.deps.local.readCaptureStatuses();
|
|
37510
|
+
}
|
|
37179
37511
|
async facets() {
|
|
37180
37512
|
return this.deps.local.facets();
|
|
37181
37513
|
}
|
|
@@ -37258,7 +37590,7 @@ var AttachedDataGateway = class {
|
|
|
37258
37590
|
policies: mergeRaiseOnly(
|
|
37259
37591
|
local.policies,
|
|
37260
37592
|
cached2.policies,
|
|
37261
|
-
ruleCategoryMap(cached2.rules, local.rules)
|
|
37593
|
+
ruleCategoryMap(cached2.rules, local.rules, bundledRulesFlat())
|
|
37262
37594
|
),
|
|
37263
37595
|
customKeywords: [...local.customKeywords, ...cached2.customKeywords],
|
|
37264
37596
|
// TAKEN FROM THE CACHE, unlike the two fields below — and the asymmetry
|
|
@@ -37459,10 +37791,15 @@ import { join as join27 } from "path";
|
|
|
37459
37791
|
// ../../packages/plugin-runtime/src/attached/atomic-publish.ts
|
|
37460
37792
|
import { rename as rename2 } from "fs/promises";
|
|
37461
37793
|
var RETRYABLE = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
|
|
37462
|
-
var
|
|
37794
|
+
var IMMEDIATE_RETRIES = 8;
|
|
37795
|
+
var TIMED_RETRIES = 4;
|
|
37796
|
+
var ATTEMPTS = 1 + IMMEDIATE_RETRIES + TIMED_RETRIES;
|
|
37463
37797
|
var delay = (ms) => new Promise((resolve2) => {
|
|
37464
37798
|
setTimeout(resolve2, ms);
|
|
37465
37799
|
});
|
|
37800
|
+
var yieldToLoop = () => new Promise((resolve2) => {
|
|
37801
|
+
setImmediate(resolve2);
|
|
37802
|
+
});
|
|
37466
37803
|
async function publishByRename(tmp, file2, move = rename2) {
|
|
37467
37804
|
for (let attempt = 1; ; attempt += 1) {
|
|
37468
37805
|
try {
|
|
@@ -37471,7 +37808,7 @@ async function publishByRename(tmp, file2, move = rename2) {
|
|
|
37471
37808
|
} catch (err) {
|
|
37472
37809
|
const code = err.code;
|
|
37473
37810
|
if (attempt >= ATTEMPTS || code === void 0 || !RETRYABLE.has(code)) throw err;
|
|
37474
|
-
await delay(attempt * 10);
|
|
37811
|
+
await (attempt <= IMMEDIATE_RETRIES ? yieldToLoop() : delay((attempt - IMMEDIATE_RETRIES) * 10));
|
|
37475
37812
|
}
|
|
37476
37813
|
}
|
|
37477
37814
|
}
|
|
@@ -37935,6 +38272,9 @@ var StandaloneDataGateway = class {
|
|
|
37935
38272
|
readSessionProvider(sessionId) {
|
|
37936
38273
|
return Promise.resolve(this.db.auditEvents.sessionProvider(sessionId));
|
|
37937
38274
|
}
|
|
38275
|
+
readCaptureStatuses() {
|
|
38276
|
+
return Promise.resolve(this.db.captureStatus.latest(Date.now()));
|
|
38277
|
+
}
|
|
37938
38278
|
facets() {
|
|
37939
38279
|
return Promise.resolve(this.db.facets());
|
|
37940
38280
|
}
|