@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/post-tool-use.js
CHANGED
|
@@ -20478,7 +20478,17 @@ var UNPRICEABLE_PROVIDERS = Object.freeze([
|
|
|
20478
20478
|
"gateway",
|
|
20479
20479
|
"unknown",
|
|
20480
20480
|
"cli",
|
|
20481
|
-
"api"
|
|
20481
|
+
"api",
|
|
20482
|
+
// The browser extension's native host records these as `llm_call.provider`
|
|
20483
|
+
// for a web-chat turn — the web tool id, deliberately never the vendor id
|
|
20484
|
+
// (`openai`/`anthropic`) the session root carries. Subscription traffic
|
|
20485
|
+
// burns rate-limit budget, not dollar credits, and listing them here is
|
|
20486
|
+
// what keeps that true structurally: a later maintainer who wants to price
|
|
20487
|
+
// web-chat traffic at API rates has to delete this entry first, and meet
|
|
20488
|
+
// the reason on the way, rather than quietly adding one to
|
|
20489
|
+
// PROVIDER_PLATFORM.
|
|
20490
|
+
"chatgpt",
|
|
20491
|
+
"claude-ai"
|
|
20482
20492
|
]);
|
|
20483
20493
|
function platformForProvider(provider) {
|
|
20484
20494
|
return PROVIDER_PLATFORM.get(provider.trim().toLowerCase()) ?? null;
|
|
@@ -20621,7 +20631,12 @@ var HARNESS = {
|
|
|
20621
20631
|
ClaudeDesktop: "claudedesktop",
|
|
20622
20632
|
ChatGpt: "chatgpt",
|
|
20623
20633
|
ClaudeAi: "claudeai",
|
|
20624
|
-
Api: "api"
|
|
20634
|
+
Api: "api",
|
|
20635
|
+
// Not a coding assistant a person drives — an in-process SDK embedded in an
|
|
20636
|
+
// application, so it has no IDE/CLI/desktop/web surface of its own. Carries
|
|
20637
|
+
// the same id as its SOURCE_TOOL counterpart, unlike every capture-side tool
|
|
20638
|
+
// whose wire spelling differs from its display spelling.
|
|
20639
|
+
AiTcSdk: "ai-tc-sdk"
|
|
20625
20640
|
};
|
|
20626
20641
|
var Harness = external_exports.enum(HARNESS).meta({ id: "Harness" });
|
|
20627
20642
|
var SOURCE_TOOL = {
|
|
@@ -20637,9 +20652,15 @@ var SOURCE_TOOL = {
|
|
|
20637
20652
|
// whose tool could not be identified both render through the read side's
|
|
20638
20653
|
// miss path rather than as a harness of their own.
|
|
20639
20654
|
Cli: "cli",
|
|
20640
|
-
Unknown: "unknown"
|
|
20655
|
+
Unknown: "unknown",
|
|
20656
|
+
// The wire id an in-process, request-path SDK stamps on its own structural
|
|
20657
|
+
// rows (`request_decision`) — never a capture of prompt/response/tool text,
|
|
20658
|
+
// since the SDK sits in front of a model call rather than inside a coding
|
|
20659
|
+
// assistant's own hook contract.
|
|
20660
|
+
AiTcSdk: "ai-tc-sdk"
|
|
20641
20661
|
};
|
|
20642
20662
|
var SourceTool = external_exports.enum(SOURCE_TOOL).meta({ id: "SourceTool" });
|
|
20663
|
+
var WebSourceTool = SourceTool.extract(["ChatGpt", "ClaudeAi"]);
|
|
20643
20664
|
var TOOL_TO_HARNESS = {
|
|
20644
20665
|
[SOURCE_TOOL.ClaudeCode]: HARNESS.ClaudeCode,
|
|
20645
20666
|
[SOURCE_TOOL.ClaudeDesktop]: HARNESS.ClaudeDesktop,
|
|
@@ -20648,7 +20669,12 @@ var TOOL_TO_HARNESS = {
|
|
|
20648
20669
|
[SOURCE_TOOL.ChatGpt]: HARNESS.ChatGpt,
|
|
20649
20670
|
[SOURCE_TOOL.Codex]: HARNESS.Codex,
|
|
20650
20671
|
[SOURCE_TOOL.Antigravity]: HARNESS.Antigravity,
|
|
20651
|
-
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi
|
|
20672
|
+
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi,
|
|
20673
|
+
// Wire and display id are the same string here, but the row still belongs:
|
|
20674
|
+
// both vocabularies carry the `AiTcSdk` member, and the join is exactly
|
|
20675
|
+
// their intersection — leaving a shared member out would read as an
|
|
20676
|
+
// uninstrumented tool on both surfaces, which this one is not.
|
|
20677
|
+
[SOURCE_TOOL.AiTcSdk]: HARNESS.AiTcSdk
|
|
20652
20678
|
};
|
|
20653
20679
|
|
|
20654
20680
|
// ../../packages/schema/src/zod/finding.ts
|
|
@@ -20682,7 +20708,8 @@ var FindingProvider = Harness.extract([
|
|
|
20682
20708
|
"ClaudeAi",
|
|
20683
20709
|
"Codex",
|
|
20684
20710
|
"Antigravity",
|
|
20685
|
-
"Api"
|
|
20711
|
+
"Api",
|
|
20712
|
+
"AiTcSdk"
|
|
20686
20713
|
]).meta({ id: "FindingProvider" });
|
|
20687
20714
|
var FindingCategory = external_exports.enum([
|
|
20688
20715
|
"secret",
|
|
@@ -21059,18 +21086,41 @@ var AuditEventType = external_exports.enum([
|
|
|
21059
21086
|
// 'tool_call' is the reconciler's structural row for every call, while
|
|
21060
21087
|
// 'tool_use' exists only where a hook enforced against the arguments.
|
|
21061
21088
|
"tool_use",
|
|
21062
|
-
// One row per model REFUSAL
|
|
21063
|
-
//
|
|
21064
|
-
//
|
|
21065
|
-
//
|
|
21066
|
-
//
|
|
21067
|
-
//
|
|
21089
|
+
// One row per model REFUSAL, across all four seams a prohibited model can be
|
|
21090
|
+
// stopped at: a switch onto it, a turn already running on it, a subagent
|
|
21091
|
+
// spawn asking for it, or a request-path refusal an embedded request-path
|
|
21092
|
+
// SDK makes in-process before the call leaves the application. Which seam
|
|
21093
|
+
// rides `attributes.refusal_seam`, never this member name. A structural row
|
|
21094
|
+
// like the ones above rather than a capture — it carries the model that was
|
|
21095
|
+
// refused and nothing the user typed, because what is worth recording about
|
|
21096
|
+
// a governance decision is the decision, and prompt text is the thing this
|
|
21097
|
+
// product exists to keep from travelling.
|
|
21068
21098
|
"model_refusal",
|
|
21099
|
+
// One row per request-path DECISION: a policy check an embedded request-path
|
|
21100
|
+
// SDK performs in-process before a model call leaves the application, or
|
|
21101
|
+
// against that call's non-streamed response. A structural row like
|
|
21102
|
+
// 'model_refusal' rather than a capture — content-free in the same way:
|
|
21103
|
+
// which side, which seam, what action and which field are decided rides
|
|
21104
|
+
// `attributes`, never this member name, and the matched text itself never
|
|
21105
|
+
// travels.
|
|
21106
|
+
//
|
|
21107
|
+
// A prohibited-model refusal on the request path is deliberately NOT this
|
|
21108
|
+
// member: it stays 'model_refusal' with `refusal_seam: 'request'`, so it
|
|
21109
|
+
// shares one bucket with the plugin's switch/turn/spawn refusals rather
|
|
21110
|
+
// than splitting one governance concept across two event types. This
|
|
21111
|
+
// member carries every OTHER request-path decision.
|
|
21112
|
+
"request_decision",
|
|
21069
21113
|
// One row per config-inventory scan, hung off the session root. It is the
|
|
21070
21114
|
// fact the posture inspection findings reference (findings require an
|
|
21071
21115
|
// audit_event_id), and its started_at is the "scanned Nm ago" the read
|
|
21072
21116
|
// surface renders.
|
|
21073
|
-
"config_scan"
|
|
21117
|
+
"config_scan",
|
|
21118
|
+
// One row per reported browser-extension capture status, hung off the web
|
|
21119
|
+
// session root. The durable home of what one tab's network interception
|
|
21120
|
+
// is doing — a write-through of the native host's in-memory tracker, so a
|
|
21121
|
+
// second process (aka extension status) and a restarted host both have
|
|
21122
|
+
// somewhere to read it back from.
|
|
21123
|
+
"capture_status"
|
|
21074
21124
|
]).meta({ id: "AuditEventType" });
|
|
21075
21125
|
var AttributeBag = external_exports.record(external_exports.string(), external_exports.unknown());
|
|
21076
21126
|
var HostAttributes = external_exports.object({
|
|
@@ -21230,6 +21280,20 @@ var CaptureAttributes = external_exports.object({
|
|
|
21230
21280
|
// repeated rather than referenced because a store reader opens this file.
|
|
21231
21281
|
redact_degraded_to: ActionTaken.optional()
|
|
21232
21282
|
}).catchall(external_exports.unknown());
|
|
21283
|
+
var CaptureStatusAttributes = external_exports.object({
|
|
21284
|
+
source_tool: external_exports.string().optional(),
|
|
21285
|
+
patched: external_exports.boolean().optional(),
|
|
21286
|
+
live: external_exports.boolean().optional(),
|
|
21287
|
+
blind: external_exports.boolean().optional(),
|
|
21288
|
+
sends_seen_dom: external_exports.number().int().nonnegative().optional(),
|
|
21289
|
+
exchanges_seen_net: external_exports.number().int().nonnegative().optional(),
|
|
21290
|
+
parse_failures: external_exports.number().int().nonnegative().optional(),
|
|
21291
|
+
unparsed_bodies: external_exports.number().int().nonnegative().optional(),
|
|
21292
|
+
shape_misses: external_exports.array(external_exports.string()).optional(),
|
|
21293
|
+
conversation_endpoints: external_exports.number().int().nonnegative().optional(),
|
|
21294
|
+
closed: external_exports.boolean().optional(),
|
|
21295
|
+
enforcement: external_exports.string().optional()
|
|
21296
|
+
}).catchall(external_exports.unknown());
|
|
21233
21297
|
var ToolCallInspection = external_exports.object({
|
|
21234
21298
|
ruleId: external_exports.string().min(1),
|
|
21235
21299
|
ruleName: external_exports.string(),
|
|
@@ -22089,6 +22153,30 @@ var AttachedCredential = external_exports.object({
|
|
|
22089
22153
|
keyPrefix: external_exports.string().min(1).max(16).optional(),
|
|
22090
22154
|
mintedAt: external_exports.iso.datetime().optional()
|
|
22091
22155
|
});
|
|
22156
|
+
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
22157
|
+
function unsafeEndpointReason(endpoint) {
|
|
22158
|
+
let parsed2;
|
|
22159
|
+
try {
|
|
22160
|
+
parsed2 = new URL(endpoint);
|
|
22161
|
+
} catch {
|
|
22162
|
+
return "unparseable";
|
|
22163
|
+
}
|
|
22164
|
+
if (parsed2.username !== "" || parsed2.password !== "") return "userinfo";
|
|
22165
|
+
if (parsed2.search !== "" || parsed2.hash !== "") return "query-or-fragment";
|
|
22166
|
+
if (parsed2.protocol === "https:") return null;
|
|
22167
|
+
return parsed2.protocol === "http:" && LOOPBACK_HOSTS.has(parsed2.hostname) ? null : "insecure";
|
|
22168
|
+
}
|
|
22169
|
+
function isSafeEndpoint(endpoint) {
|
|
22170
|
+
return unsafeEndpointReason(endpoint) === null;
|
|
22171
|
+
}
|
|
22172
|
+
function originOnly(endpoint) {
|
|
22173
|
+
try {
|
|
22174
|
+
const parsed2 = new URL(endpoint);
|
|
22175
|
+
return `${parsed2.protocol}//${parsed2.host}`;
|
|
22176
|
+
} catch {
|
|
22177
|
+
return "(unparseable endpoint)";
|
|
22178
|
+
}
|
|
22179
|
+
}
|
|
22092
22180
|
var MAX_DATE_MS = 253402300799999;
|
|
22093
22181
|
var MAX_INT4 = 2147483647;
|
|
22094
22182
|
var StorePosturePack = external_exports.object({
|
|
@@ -22243,6 +22331,11 @@ var RemoteFailureKind = external_exports.enum([
|
|
|
22243
22331
|
"rejected",
|
|
22244
22332
|
"unreachable"
|
|
22245
22333
|
]);
|
|
22334
|
+
var ControlPlaneFailure = RemoteFailureKind.extract([
|
|
22335
|
+
"unauthorized",
|
|
22336
|
+
"forbidden",
|
|
22337
|
+
"unreachable"
|
|
22338
|
+
]);
|
|
22246
22339
|
var AttachDeviceRequest = external_exports.object({
|
|
22247
22340
|
// This machine's own continuity id, so re-attaching ROTATES the credential
|
|
22248
22341
|
// on one machine record instead of producing a second one. Client-minted
|
|
@@ -22782,7 +22875,12 @@ var EventMetadata = external_exports.object({
|
|
|
22782
22875
|
// in — set by the browser extension's network capture so a stored `response`
|
|
22783
22876
|
// row can be joined to the `llm_call` leaf describing the same turn. Absent
|
|
22784
22877
|
// on every other capture path, which has no such id.
|
|
22785
|
-
|
|
22878
|
+
//
|
|
22879
|
+
// Non-empty for the reason WebExchange.messageId is: it is the join key, and
|
|
22880
|
+
// a blank one matches no `llm_call` leaf. That refusal reaches only the
|
|
22881
|
+
// places an event is PARSED; the local write path types the event and parses
|
|
22882
|
+
// nothing, which is why `toCaptureAttributes` omits a blank one separately.
|
|
22883
|
+
messageId: external_exports.string().min(1).optional(),
|
|
22786
22884
|
conversationId: external_exports.string().optional(),
|
|
22787
22885
|
// How long THIS capture's inspection blocked its caller, in whole
|
|
22788
22886
|
// milliseconds — the plugin's own added latency, NOT the LLM call it sat in
|
|
@@ -23629,6 +23727,85 @@ function policyIdIsReversible(policyId) {
|
|
|
23629
23727
|
var DEFAULT_ACTIONS = Object.fromEntries(
|
|
23630
23728
|
DetectionCategory.options.map((c) => [c, builtinPolicyToAction(severityFloorPolicy(c))])
|
|
23631
23729
|
);
|
|
23730
|
+
function ruleCategoryMap(wireRules, localRules, compiledRules) {
|
|
23731
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
23732
|
+
for (const rule of wireRules ?? []) map2.set(rule.id, rule.category);
|
|
23733
|
+
for (const rule of localRules ?? []) map2.set(rule.id, rule.category);
|
|
23734
|
+
for (const rule of compiledRules) map2.set(rule.id, rule.category);
|
|
23735
|
+
return map2;
|
|
23736
|
+
}
|
|
23737
|
+
function policyKey(policy) {
|
|
23738
|
+
return "ruleId" in policy.target ? `rule:${policy.target.ruleId}` : `category:${policy.target.category}`;
|
|
23739
|
+
}
|
|
23740
|
+
function floorFor(policy, categoryByRuleId) {
|
|
23741
|
+
const category = "category" in policy.target ? policy.target.category : categoryByRuleId.get(policy.target.ruleId);
|
|
23742
|
+
return category === void 0 ? null : DEFAULT_ACTIONS[category];
|
|
23743
|
+
}
|
|
23744
|
+
function strongerOf(a, b) {
|
|
23745
|
+
if (a === null) return b;
|
|
23746
|
+
if (b === null) return a;
|
|
23747
|
+
return strongerAction(a, b);
|
|
23748
|
+
}
|
|
23749
|
+
function mergeRaiseOnly(localPolicies, remotePolicies, categoryByRuleId) {
|
|
23750
|
+
const merged = /* @__PURE__ */ new Map();
|
|
23751
|
+
const disabled = [];
|
|
23752
|
+
const remoteCategoryAction = /* @__PURE__ */ new Map();
|
|
23753
|
+
for (const policy of remotePolicies) {
|
|
23754
|
+
if (!policy.enabled) continue;
|
|
23755
|
+
if (!("category" in policy.target)) continue;
|
|
23756
|
+
if (remoteCategoryAction.has(policy.target.category)) continue;
|
|
23757
|
+
const floor = floorFor(policy, categoryByRuleId);
|
|
23758
|
+
remoteCategoryAction.set(
|
|
23759
|
+
policy.target.category,
|
|
23760
|
+
floor !== null && !isActionAtLeast(policy.action, floor) ? floor : policy.action
|
|
23761
|
+
);
|
|
23762
|
+
}
|
|
23763
|
+
for (const policy of localPolicies) {
|
|
23764
|
+
if (!policy.enabled) {
|
|
23765
|
+
disabled.push(policy);
|
|
23766
|
+
continue;
|
|
23767
|
+
}
|
|
23768
|
+
const key = policyKey(policy);
|
|
23769
|
+
if (merged.has(key)) continue;
|
|
23770
|
+
let remoteFloor = null;
|
|
23771
|
+
if ("ruleId" in policy.target) {
|
|
23772
|
+
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
23773
|
+
if (category !== void 0) remoteFloor = remoteCategoryAction.get(category) ?? null;
|
|
23774
|
+
}
|
|
23775
|
+
merged.set(
|
|
23776
|
+
key,
|
|
23777
|
+
remoteFloor !== null && !isActionAtLeast(policy.action, remoteFloor) ? { ...policy, action: remoteFloor } : policy
|
|
23778
|
+
);
|
|
23779
|
+
}
|
|
23780
|
+
const localCategoryAction = /* @__PURE__ */ new Map();
|
|
23781
|
+
for (const policy of merged.values()) {
|
|
23782
|
+
if ("category" in policy.target) localCategoryAction.set(policy.target.category, policy.action);
|
|
23783
|
+
}
|
|
23784
|
+
for (const policy of remotePolicies) {
|
|
23785
|
+
if (!policy.enabled) {
|
|
23786
|
+
disabled.push(policy);
|
|
23787
|
+
continue;
|
|
23788
|
+
}
|
|
23789
|
+
const key = policyKey(policy);
|
|
23790
|
+
const floor = floorFor(policy, categoryByRuleId);
|
|
23791
|
+
let localFloor = null;
|
|
23792
|
+
if ("ruleId" in policy.target) {
|
|
23793
|
+
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
23794
|
+
if (category !== void 0) localFloor = localCategoryAction.get(category) ?? null;
|
|
23795
|
+
}
|
|
23796
|
+
const effectiveFloor = strongerOf(floor, localFloor);
|
|
23797
|
+
const clamped = effectiveFloor !== null && !isActionAtLeast(policy.action, effectiveFloor) ? { ...policy, action: effectiveFloor } : policy;
|
|
23798
|
+
const existing = merged.get(key);
|
|
23799
|
+
if (existing === void 0) {
|
|
23800
|
+
merged.set(key, clamped);
|
|
23801
|
+
continue;
|
|
23802
|
+
}
|
|
23803
|
+
if (actionRank(clamped.action) > actionRank(existing.action)) {
|
|
23804
|
+
merged.set(key, clamped);
|
|
23805
|
+
}
|
|
23806
|
+
}
|
|
23807
|
+
return [...merged.values(), ...disabled];
|
|
23808
|
+
}
|
|
23632
23809
|
var BUILTIN_POLICIES = Object.fromEntries(
|
|
23633
23810
|
KNOWN_BUILTIN_IDS.map((id) => [id, { id, ...BUILTIN_POLICY_SPECS[id] }])
|
|
23634
23811
|
);
|
|
@@ -23862,6 +24039,18 @@ var HistorySyncConsent = external_exports.object({
|
|
|
23862
24039
|
payloadVersion: external_exports.number().int().positive(),
|
|
23863
24040
|
endpoint: external_exports.string()
|
|
23864
24041
|
});
|
|
24042
|
+
var WebChatCaptureConsent = external_exports.object({
|
|
24043
|
+
acknowledgedAt: external_exports.iso.datetime(),
|
|
24044
|
+
version: external_exports.number().int().positive()
|
|
24045
|
+
});
|
|
24046
|
+
var WebChatResponseCapture = external_exports.enum(["with-findings", "always", "never"]);
|
|
24047
|
+
var WebChatCapture = external_exports.object({
|
|
24048
|
+
responses: WebChatResponseCapture.default("with-findings"),
|
|
24049
|
+
account: external_exports.boolean().default(false),
|
|
24050
|
+
// Absent until granted. Presence alone does not authorize anything — see
|
|
24051
|
+
// isWebChatCaptureConsentValid.
|
|
24052
|
+
consent: WebChatCaptureConsent.optional()
|
|
24053
|
+
});
|
|
23865
24054
|
var BODY_RETENTION_DEFAULT_DAYS = 30;
|
|
23866
24055
|
var BodyRetention = external_exports.object({
|
|
23867
24056
|
enabled: external_exports.boolean().default(false),
|
|
@@ -23920,6 +24109,16 @@ var WorkspaceSettings = external_exports.object({
|
|
|
23920
24109
|
// both widenings. Absent until granted, and a grant for a different endpoint
|
|
23921
24110
|
// or an older payload no longer counts.
|
|
23922
24111
|
historySyncConsent: HistorySyncConsent.optional(),
|
|
24112
|
+
// What the browser extension may record from a web chat, and the grant that
|
|
24113
|
+
// authorizes it. Absent until the user answers: recording something that was
|
|
24114
|
+
// never recorded before is never an assumed grant on upgrade, so the whole
|
|
24115
|
+
// block is optional rather than defaulted in. What an absent block means is
|
|
24116
|
+
// webChatCaptureOf's answer, in one place.
|
|
24117
|
+
//
|
|
24118
|
+
// Enforcement is NOT gated on this. A machine that has never answered still
|
|
24119
|
+
// blocks, redacts and warns on what a user sends; the grant covers what is
|
|
24120
|
+
// written down.
|
|
24121
|
+
webChatCapture: WebChatCapture.optional(),
|
|
23923
24122
|
// Local body expiry (see BodyRetention). Off until switched on; expiring a
|
|
23924
24123
|
// body never removes the row or its findings.
|
|
23925
24124
|
bodyRetention: BodyRetention.default({
|
|
@@ -24027,7 +24226,10 @@ function toCaptureAttributes(event) {
|
|
|
24027
24226
|
// `.catchall(z.unknown())` carries the long tail.
|
|
24028
24227
|
...metadata?.model !== void 0 ? { model: metadata.model } : {},
|
|
24029
24228
|
...metadata?.turnIndex !== void 0 ? { turn_index: metadata.turnIndex } : {},
|
|
24030
|
-
|
|
24229
|
+
// A blank id is omitted rather than stored: it is a join key and `''` joins
|
|
24230
|
+
// nothing. This runs on the local write path, which types the event but
|
|
24231
|
+
// never parses it, so EventMetadata's own `.min(1)` does not reach here.
|
|
24232
|
+
...metadata?.messageId !== void 0 && metadata.messageId !== "" ? { message_id: metadata.messageId } : {},
|
|
24031
24233
|
...metadata?.conversationId !== void 0 ? { conversation_id: metadata.conversationId } : {}
|
|
24032
24234
|
};
|
|
24033
24235
|
}
|
|
@@ -24401,12 +24603,14 @@ var RecommendedActionIdParam = external_exports.object({ id: external_exports.st
|
|
|
24401
24603
|
// ../../packages/schema/src/zod/settings-action.ts
|
|
24402
24604
|
var HistorySyncConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "HistorySyncConsentChoice" });
|
|
24403
24605
|
var ModelJudgeConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "ModelJudgeConsentChoice" });
|
|
24606
|
+
var WebChatCaptureConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "WebChatCaptureConsentChoice" });
|
|
24404
24607
|
var SaveSettingsInput = external_exports.object({
|
|
24405
24608
|
historicalAccess: external_exports.string(),
|
|
24406
24609
|
modelJudgeConsent: ModelJudgeConsentChoice,
|
|
24407
24610
|
historySyncConsent: HistorySyncConsentChoice,
|
|
24408
24611
|
vaultConsent: external_exports.string(),
|
|
24409
24612
|
vaultInlineReveal: external_exports.string(),
|
|
24613
|
+
webChatCaptureConsent: WebChatCaptureConsentChoice,
|
|
24410
24614
|
// Widened to `string` like its neighbours rather than typed as
|
|
24411
24615
|
// `RedactFallback`, on this module's own layering rule: shape here, VALUE at
|
|
24412
24616
|
// the call site, so the domain check receives the type it was written for.
|
|
@@ -24621,11 +24825,24 @@ var WebExchange = external_exports.object({
|
|
|
24621
24825
|
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
24622
24826
|
toolCalls: external_exports.array(WebToolCall).default([]),
|
|
24623
24827
|
// Absent when the adapter recovered no text. Capped by the caller at
|
|
24624
|
-
// RESPONSE_TEXT_MAX_BYTES
|
|
24625
|
-
//
|
|
24828
|
+
// RESPONSE_TEXT_MAX_BYTES, so a short capture is never mistaken for a short
|
|
24829
|
+
// reply.
|
|
24626
24830
|
responseText: external_exports.string().optional(),
|
|
24831
|
+
// The stored text is short of the reply. It does NOT say which of the two
|
|
24832
|
+
// ceilings on this path cut it: the caller applies its own cap on the raw
|
|
24833
|
+
// bytes it reads off the wire, which can be reached by a stream whose
|
|
24834
|
+
// recovered text stays well under RESPONSE_TEXT_MAX_BYTES, and applies that
|
|
24835
|
+
// one to the text. A reader cannot tell them apart, and nothing downstream
|
|
24836
|
+
// should branch as though it could.
|
|
24627
24837
|
truncated: external_exports.boolean().default(false)
|
|
24628
24838
|
});
|
|
24839
|
+
var WebEnforcementState = external_exports.enum([
|
|
24840
|
+
"watching",
|
|
24841
|
+
"composer-only",
|
|
24842
|
+
"button-only",
|
|
24843
|
+
"unattached",
|
|
24844
|
+
"unknown"
|
|
24845
|
+
]);
|
|
24629
24846
|
var RESPONSE_TEXT_MAX_BYTES = 2 * 1024 * 1024;
|
|
24630
24847
|
var WebCaptureStatus = external_exports.object({
|
|
24631
24848
|
patched: external_exports.boolean(),
|
|
@@ -24637,8 +24854,66 @@ var WebCaptureStatus = external_exports.object({
|
|
|
24637
24854
|
unparsedBodies: external_exports.number().int().nonnegative(),
|
|
24638
24855
|
// The adapter-declared JSON key paths that were absent from a real payload —
|
|
24639
24856
|
// the earliest signal that a site's contract moved.
|
|
24640
|
-
shapeMisses: external_exports.array(external_exports.string()).default([])
|
|
24641
|
-
|
|
24857
|
+
shapeMisses: external_exports.array(external_exports.string()).default([]),
|
|
24858
|
+
// How many `kind: 'conversation'` endpoints the reporting tab's adapter
|
|
24859
|
+
// compiled. Zero means this build declares none for the site, so observing
|
|
24860
|
+
// nothing is the design rather than a fault — the one fact that separates a
|
|
24861
|
+
// site nobody has surveyed yet from one whose contract moved. Defaulted so a
|
|
24862
|
+
// build predating the field is read as declaring nothing rather than refused.
|
|
24863
|
+
conversationEndpoints: external_exports.number().int().nonnegative().default(0),
|
|
24864
|
+
// The document that sent this report is going away. The bridge sets it on
|
|
24865
|
+
// its `pagehide` report and nowhere else.
|
|
24866
|
+
//
|
|
24867
|
+
// A property of the REPORT rather than of capture health, which is why
|
|
24868
|
+
// nothing in `deriveWebCaptureState` reads it and why it stays out of the
|
|
24869
|
+
// bridge's own report signature — a closing tab's last word must not be
|
|
24870
|
+
// suppressed for carrying the same health as the report before it. What
|
|
24871
|
+
// reads it is the per-site fold: a document that said it was unloading stops
|
|
24872
|
+
// voting on the site's state, so the reload the `blind` remediation asks for
|
|
24873
|
+
// can actually clear the verdict it was shown. A document that dies without
|
|
24874
|
+
// sending one is covered by CAPTURE_STATUS_DOCUMENT_QUIET_MS instead.
|
|
24875
|
+
//
|
|
24876
|
+
// Defaulted so a build predating the field reads as a document that never
|
|
24877
|
+
// said it was closing — which keeps it voting, the same as every report that
|
|
24878
|
+
// is not a final one.
|
|
24879
|
+
closed: external_exports.boolean().default(false),
|
|
24880
|
+
// What the DOM enforcement path is doing, which none of the counters above
|
|
24881
|
+
// can say: `sendsSeenDom` rises only once a send has COMPLETED, so a tab
|
|
24882
|
+
// whose watcher never bound reports zero exactly like a tab nobody typed in.
|
|
24883
|
+
// Defaulted to 'unknown' rather than 'watching' so a status from a build
|
|
24884
|
+
// predating the field is not read as reporting a healthy one.
|
|
24885
|
+
enforcement: WebEnforcementState.default("unknown")
|
|
24886
|
+
});
|
|
24887
|
+
function webCaptureStatusObservedTurnPath(status) {
|
|
24888
|
+
if (!status.patched) return true;
|
|
24889
|
+
if (status.conversationEndpoints === 0) return true;
|
|
24890
|
+
return status.blind || status.shapeMisses.length > 0 || status.parseFailures > 0 || status.unparsedBodies > 0 || status.exchangesSeenNet > 0;
|
|
24891
|
+
}
|
|
24892
|
+
function pickReportedCaptureStatus(candidates) {
|
|
24893
|
+
return candidates.find((c) => webCaptureStatusObservedTurnPath(c.status)) ?? candidates[0];
|
|
24894
|
+
}
|
|
24895
|
+
var CAPTURE_STATUS_RECENCY_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
24896
|
+
var CAPTURE_STATUS_RECENCY_DAYS = CAPTURE_STATUS_RECENCY_MS / (24 * 60 * 60 * 1e3);
|
|
24897
|
+
var CAPTURE_STATUS_DOCUMENT_QUIET_MS = 12 * 60 * 60 * 1e3;
|
|
24898
|
+
function fromCaptureStatusAttributes(bag) {
|
|
24899
|
+
const parsedBag = CaptureStatusAttributes.safeParse(bag);
|
|
24900
|
+
if (!parsedBag.success) return null;
|
|
24901
|
+
const b = parsedBag.data;
|
|
24902
|
+
const parsedStatus = WebCaptureStatus.safeParse({
|
|
24903
|
+
patched: b.patched,
|
|
24904
|
+
live: b.live,
|
|
24905
|
+
blind: b.blind,
|
|
24906
|
+
sendsSeenDom: b.sends_seen_dom,
|
|
24907
|
+
exchangesSeenNet: b.exchanges_seen_net,
|
|
24908
|
+
parseFailures: b.parse_failures,
|
|
24909
|
+
unparsedBodies: b.unparsed_bodies,
|
|
24910
|
+
shapeMisses: b.shape_misses,
|
|
24911
|
+
conversationEndpoints: b.conversation_endpoints,
|
|
24912
|
+
closed: b.closed,
|
|
24913
|
+
enforcement: b.enforcement
|
|
24914
|
+
});
|
|
24915
|
+
return parsedStatus.success ? parsedStatus.data : null;
|
|
24916
|
+
}
|
|
24642
24917
|
|
|
24643
24918
|
// ../../packages/persistence/src/paths.ts
|
|
24644
24919
|
import {
|
|
@@ -24769,17 +25044,6 @@ function publishByLink(tmp, file2, data) {
|
|
|
24769
25044
|
function controlPlaneCredentialPath(settingsDir2) {
|
|
24770
25045
|
return join2(settingsDir2, ATTACHED_CREDENTIAL_FILENAME);
|
|
24771
25046
|
}
|
|
24772
|
-
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
24773
|
-
function isSafeEndpoint(endpoint) {
|
|
24774
|
-
let parsed2;
|
|
24775
|
-
try {
|
|
24776
|
-
parsed2 = new URL(endpoint);
|
|
24777
|
-
} catch {
|
|
24778
|
-
return false;
|
|
24779
|
-
}
|
|
24780
|
-
if (parsed2.protocol === "https:") return true;
|
|
24781
|
-
return parsed2.protocol === "http:" && LOOPBACK_HOSTS.has(parsed2.hostname);
|
|
24782
|
-
}
|
|
24783
25047
|
function repairOrRefuseMode(file2) {
|
|
24784
25048
|
const link = lstatSync2(file2, { throwIfNoEntry: false });
|
|
24785
25049
|
if (link === void 0) return "absent";
|
|
@@ -26572,7 +26836,7 @@ var SESSION_ROOT = `event_type = 'session'`;
|
|
|
26572
26836
|
var HAS_ACTIVITY = `EXISTS (
|
|
26573
26837
|
SELECT 1 FROM audit_events c
|
|
26574
26838
|
WHERE c.root_session_id = audit_events.id
|
|
26575
|
-
AND c.event_type NOT IN ('hook', 'config_scan'))`;
|
|
26839
|
+
AND c.event_type NOT IN ('hook', 'config_scan', 'capture_status'))`;
|
|
26576
26840
|
var SqliteActivityRepository = class {
|
|
26577
26841
|
constructor(db, now = () => Date.now()) {
|
|
26578
26842
|
this.db = db;
|
|
@@ -26599,10 +26863,10 @@ var SqliteActivityRepository = class {
|
|
|
26599
26863
|
SELECT id FROM audit_events WHERE event_type = 'session' AND started_at >= ?
|
|
26600
26864
|
UNION
|
|
26601
26865
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_started_at
|
|
26602
|
-
WHERE started_at >= ?
|
|
26866
|
+
WHERE started_at >= ? AND event_type <> 'capture_status'
|
|
26603
26867
|
UNION
|
|
26604
26868
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_ended_at
|
|
26605
|
-
WHERE ended_at >= ?)`,
|
|
26869
|
+
WHERE ended_at >= ? AND event_type <> 'capture_status')`,
|
|
26606
26870
|
[liveThreshold, liveThreshold, liveThreshold]
|
|
26607
26871
|
);
|
|
26608
26872
|
const toolCallsToday = countScalar(
|
|
@@ -27009,7 +27273,10 @@ var SqliteAuditEventsRepository = class {
|
|
|
27009
27273
|
attributes = excluded.attributes,
|
|
27010
27274
|
ended_at = excluded.ended_at
|
|
27011
27275
|
WHERE COALESCE(json_extract(excluded.attributes, '$.output_tokens'), 0)
|
|
27012
|
-
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27276
|
+
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27277
|
+
OR (json_extract(excluded.attributes, '$.usage_source') IS NOT NULL
|
|
27278
|
+
AND json_extract(excluded.attributes, '$.output_tokens') IS NULL
|
|
27279
|
+
AND excluded.attributes <> audit_events.attributes)`
|
|
27013
27280
|
);
|
|
27014
27281
|
this.upsertSessionRootStmt = db.prepare(
|
|
27015
27282
|
`INSERT OR IGNORE INTO audit_events
|
|
@@ -27277,6 +27544,87 @@ var SqliteBodyRetentionRepository = class {
|
|
|
27277
27544
|
}
|
|
27278
27545
|
};
|
|
27279
27546
|
|
|
27547
|
+
// ../../packages/persistence/src/repositories/capture-status.ts
|
|
27548
|
+
var STATUS_LOOKBACK_ROWS = 128;
|
|
27549
|
+
var SqliteCaptureStatusRepository = class {
|
|
27550
|
+
constructor(db) {
|
|
27551
|
+
this.db = db;
|
|
27552
|
+
this.recentStmt = db.prepare(
|
|
27553
|
+
`SELECT a.started_at AS startedAt,
|
|
27554
|
+
a.attributes AS attributes,
|
|
27555
|
+
a.root_session_id AS rootSessionId
|
|
27556
|
+
FROM audit_events a
|
|
27557
|
+
WHERE a.event_type = 'capture_status'
|
|
27558
|
+
AND a.source_tool = ?
|
|
27559
|
+
AND a.started_at >= ?
|
|
27560
|
+
ORDER BY a.started_at DESC, a.id DESC
|
|
27561
|
+
LIMIT ?`
|
|
27562
|
+
);
|
|
27563
|
+
}
|
|
27564
|
+
db;
|
|
27565
|
+
recentStmt;
|
|
27566
|
+
/**
|
|
27567
|
+
* Every document that reported for a site, in registry order by site, from
|
|
27568
|
+
* the last `CAPTURE_STATUS_RECENCY_MS`.
|
|
27569
|
+
*
|
|
27570
|
+
* SEVERAL per site, not one: a browser is many documents and each reports
|
|
27571
|
+
* for itself, so one row per site is a choice about which of them a user
|
|
27572
|
+
* sees — and the newest is the wrong one, since a healthy tab writing a
|
|
27573
|
+
* fresh report would hide a drifting tab's verdict, which is the whole
|
|
27574
|
+
* reason these rows exist. The pick WITHIN a document is made here (the
|
|
27575
|
+
* unchanged `pickReportedCaptureStatus`, over that document's own rows);
|
|
27576
|
+
* choosing between documents belongs where the state semantics live, and
|
|
27577
|
+
* that is `reportedCaptureDocumentForSite` in `@akasecurity/detections` —
|
|
27578
|
+
* this package may not import it.
|
|
27579
|
+
*
|
|
27580
|
+
* `now` is a required argument rather than a `Date.now()` read, so a caller
|
|
27581
|
+
* that already holds a render instant passes THAT one and a test can drive
|
|
27582
|
+
* the window without moving the wall clock.
|
|
27583
|
+
*
|
|
27584
|
+
* A site whose reports have all aged out contributes nothing, so it derives
|
|
27585
|
+
* to `unreported`. That is the point: nothing but the browser extension ever
|
|
27586
|
+
* writes these rows, so an uninstalled extension's last verdict would
|
|
27587
|
+
* otherwise stand as a live claim for ever with no later report able to
|
|
27588
|
+
* clear it.
|
|
27589
|
+
*/
|
|
27590
|
+
latest(now) {
|
|
27591
|
+
const since = now - CAPTURE_STATUS_RECENCY_MS;
|
|
27592
|
+
const documents = [];
|
|
27593
|
+
for (const tool of WebSourceTool.options) {
|
|
27594
|
+
const rows = /* @__PURE__ */ new Map();
|
|
27595
|
+
const lastWord = /* @__PURE__ */ new Map();
|
|
27596
|
+
for (const row of allRows(this.recentStmt, [
|
|
27597
|
+
tool,
|
|
27598
|
+
since,
|
|
27599
|
+
STATUS_LOOKBACK_ROWS
|
|
27600
|
+
])) {
|
|
27601
|
+
const status = fromCaptureStatusAttributes(parseJsonObject(row.attributes));
|
|
27602
|
+
if (status === null) continue;
|
|
27603
|
+
const record2 = { tool, observedAt: epochMillisToIso(row.startedAt), status };
|
|
27604
|
+
const group = rows.get(row.rootSessionId);
|
|
27605
|
+
if (group === void 0) {
|
|
27606
|
+
rows.set(row.rootSessionId, [record2]);
|
|
27607
|
+
lastWord.set(row.rootSessionId, { at: record2.observedAt, closed: status.closed });
|
|
27608
|
+
} else {
|
|
27609
|
+
group.push(record2);
|
|
27610
|
+
}
|
|
27611
|
+
}
|
|
27612
|
+
for (const [root, candidates] of rows) {
|
|
27613
|
+
const picked = pickReportedCaptureStatus(candidates);
|
|
27614
|
+
const last = lastWord.get(root);
|
|
27615
|
+
if (picked === void 0 || last === void 0) continue;
|
|
27616
|
+
documents.push({
|
|
27617
|
+
...picked,
|
|
27618
|
+
...root === null ? {} : { rootSessionId: root },
|
|
27619
|
+
lastReportAt: last.at,
|
|
27620
|
+
closed: last.closed
|
|
27621
|
+
});
|
|
27622
|
+
}
|
|
27623
|
+
}
|
|
27624
|
+
return documents;
|
|
27625
|
+
}
|
|
27626
|
+
};
|
|
27627
|
+
|
|
27280
27628
|
// ../../packages/persistence/src/repositories/classified-data.ts
|
|
27281
27629
|
var SqliteClassifiedDataRepository = class {
|
|
27282
27630
|
constructor(db) {
|
|
@@ -32857,6 +33205,7 @@ function openAndInitialize(file2, base, skipTags) {
|
|
|
32857
33205
|
activity: new SqliteActivityRepository(db),
|
|
32858
33206
|
sourceProject: new SqliteSourceProjectRepository(db),
|
|
32859
33207
|
auditEvents: new SqliteAuditEventsRepository(db),
|
|
33208
|
+
captureStatus: new SqliteCaptureStatusRepository(db),
|
|
32860
33209
|
classifiedData: new SqliteClassifiedDataRepository(db),
|
|
32861
33210
|
inspectionDefinitions: new SqliteInspectionDefinitionsRepository(db),
|
|
32862
33211
|
inspectionFindings: new SqliteInspectionFindingsRepository(db),
|
|
@@ -32897,6 +33246,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
32897
33246
|
activity,
|
|
32898
33247
|
sourceProject,
|
|
32899
33248
|
auditEvents,
|
|
33249
|
+
captureStatus,
|
|
32900
33250
|
classifiedData,
|
|
32901
33251
|
inspectionDefinitions,
|
|
32902
33252
|
inspectionFindings,
|
|
@@ -33114,6 +33464,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
33114
33464
|
activity,
|
|
33115
33465
|
sourceProject,
|
|
33116
33466
|
auditEvents,
|
|
33467
|
+
captureStatus,
|
|
33117
33468
|
classifiedData,
|
|
33118
33469
|
inspectionDefinitions,
|
|
33119
33470
|
inspectionFindings,
|
|
@@ -33359,11 +33710,6 @@ function fingerprintValue(key, raw) {
|
|
|
33359
33710
|
// ../../packages/persistence/src/forward-health.ts
|
|
33360
33711
|
import { readFileSync as readFileSync7 } from "fs";
|
|
33361
33712
|
import { join as join9 } from "path";
|
|
33362
|
-
var FAILURES = /* @__PURE__ */ new Set([
|
|
33363
|
-
"unauthorized",
|
|
33364
|
-
"forbidden",
|
|
33365
|
-
"unreachable"
|
|
33366
|
-
]);
|
|
33367
33713
|
var BREAKER_COOLDOWN_MS = 3e4;
|
|
33368
33714
|
function parseForwardHealth(raw, nowMs) {
|
|
33369
33715
|
try {
|
|
@@ -33372,7 +33718,8 @@ function parseForwardHealth(raw, nowMs) {
|
|
|
33372
33718
|
const record2 = parsed2;
|
|
33373
33719
|
const failures = typeof record2.consecutiveFailures === "number" && record2.consecutiveFailures >= 0 ? record2.consecutiveFailures : 0;
|
|
33374
33720
|
const openedAtMs = typeof record2.openedAtMs === "number" && Number.isFinite(record2.openedAtMs) && record2.openedAtMs <= nowMs ? record2.openedAtMs : null;
|
|
33375
|
-
const
|
|
33721
|
+
const parsedFailure = ControlPlaneFailure.safeParse(record2.lastFailure);
|
|
33722
|
+
const lastFailure = parsedFailure.success ? parsedFailure.data : null;
|
|
33376
33723
|
return { consecutiveFailures: failures, openedAtMs, lastFailure };
|
|
33377
33724
|
} catch {
|
|
33378
33725
|
return null;
|
|
@@ -34423,6 +34770,12 @@ var RemoteRequestInvalid = class extends Error {
|
|
|
34423
34770
|
}
|
|
34424
34771
|
cause;
|
|
34425
34772
|
};
|
|
34773
|
+
var RemoteEndpointRefused = class extends Error {
|
|
34774
|
+
constructor(endpoint) {
|
|
34775
|
+
super(`refusing to talk to an unsafe control-plane endpoint: ${originOnly(endpoint)}`);
|
|
34776
|
+
this.name = "RemoteEndpointRefused";
|
|
34777
|
+
}
|
|
34778
|
+
};
|
|
34426
34779
|
var RemoteResponseInvalid = class extends Error {
|
|
34427
34780
|
constructor(route, detail) {
|
|
34428
34781
|
super(`control plane answered ${route} with ${detail}`);
|
|
@@ -34575,14 +34928,15 @@ function parsed(schema, body, route) {
|
|
|
34575
34928
|
}
|
|
34576
34929
|
return result.data;
|
|
34577
34930
|
}
|
|
34578
|
-
function
|
|
34931
|
+
function resolveBaseUrl(endpoint) {
|
|
34932
|
+
if (!isSafeEndpoint(endpoint)) throw new RemoteEndpointRefused(endpoint);
|
|
34579
34933
|
let end = endpoint.length;
|
|
34580
34934
|
while (end > 0 && endpoint.charCodeAt(end - 1) === SLASH2) end -= 1;
|
|
34581
34935
|
return endpoint.slice(0, end);
|
|
34582
34936
|
}
|
|
34583
34937
|
var SLASH2 = "/".charCodeAt(0);
|
|
34584
34938
|
function createRemoteClient(options) {
|
|
34585
|
-
const base =
|
|
34939
|
+
const base = resolveBaseUrl(options.endpoint);
|
|
34586
34940
|
const url2 = (route) => `${base}${route}`;
|
|
34587
34941
|
const common = { apiKey: options.apiKey, timeoutMs: options.timeoutMs };
|
|
34588
34942
|
const sendOne = async (event) => {
|
|
@@ -34712,6 +35066,7 @@ function classifyRemoteFailure(err) {
|
|
|
34712
35066
|
case "RemoteRouteAbsent":
|
|
34713
35067
|
return "route-absent";
|
|
34714
35068
|
case "RemoteRequestInvalid":
|
|
35069
|
+
case "RemoteEndpointRefused":
|
|
34715
35070
|
return "invalid-request";
|
|
34716
35071
|
case "RemoteResponseInvalid":
|
|
34717
35072
|
return "rejected";
|
|
@@ -35828,6 +36183,56 @@ var CONFIG_POSTURE_RULES = [
|
|
|
35828
36183
|
}
|
|
35829
36184
|
];
|
|
35830
36185
|
|
|
36186
|
+
// ../../packages/detections/src/posture/web-capture-posture.ts
|
|
36187
|
+
var RULE_VERSION2 = "1";
|
|
36188
|
+
var DRIFT_MIN_PARSE_FAILURES = 2;
|
|
36189
|
+
var WEB_CAPTURE_DRIFT_STATES = /* @__PURE__ */ new Set([
|
|
36190
|
+
"blind",
|
|
36191
|
+
"degraded"
|
|
36192
|
+
]);
|
|
36193
|
+
var WEB_CAPTURE_DRIFT_RULE = {
|
|
36194
|
+
ruleId: "web-capture-drift",
|
|
36195
|
+
version: RULE_VERSION2,
|
|
36196
|
+
name: "Web chat capture is not reading the site",
|
|
36197
|
+
category: "config",
|
|
36198
|
+
severity: "medium",
|
|
36199
|
+
definition: JSON.stringify({
|
|
36200
|
+
kind: "web-capture-drift",
|
|
36201
|
+
states: [...WEB_CAPTURE_DRIFT_STATES],
|
|
36202
|
+
minParseFailures: DRIFT_MIN_PARSE_FAILURES
|
|
36203
|
+
})
|
|
36204
|
+
};
|
|
36205
|
+
var STATIC_COPY = {
|
|
36206
|
+
active: { headline: "turns are being observed on this site" },
|
|
36207
|
+
unreported: {
|
|
36208
|
+
// Says "recently" rather than "yet": the store read is bounded to
|
|
36209
|
+
// CAPTURE_STATUS_RECENCY_MS, so this state covers a site nothing has ever
|
|
36210
|
+
// reported for AND one whose last report has aged out. The two are the
|
|
36211
|
+
// same fact to a reader — nobody has confirmed anything lately — and the
|
|
36212
|
+
// copy may not claim the stronger of them.
|
|
36213
|
+
headline: `no report in the last ${String(CAPTURE_STATUS_RECENCY_DAYS)} days \u2014 open the site in Chrome with the extension loaded`
|
|
36214
|
+
},
|
|
36215
|
+
standby: {
|
|
36216
|
+
headline: "this build declares no endpoints for the site, so nothing is observed yet"
|
|
36217
|
+
},
|
|
36218
|
+
unpatched: {
|
|
36219
|
+
// Says what the flags say and no more. `patched` is false both for a tap
|
|
36220
|
+
// that installed and hooked neither transport and for one that never ran
|
|
36221
|
+
// at all — a page reports the same status either way, so the copy may not
|
|
36222
|
+
// assert one of them.
|
|
36223
|
+
headline: "the page tap captured neither fetch nor XHR \u2014 it may not have installed; reload the extension at chrome://extensions"
|
|
36224
|
+
},
|
|
36225
|
+
idle: { headline: "watching; no turn has been observed yet" },
|
|
36226
|
+
blind: {
|
|
36227
|
+
headline: "messages were sent in the page that the network capture never saw",
|
|
36228
|
+
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."
|
|
36229
|
+
},
|
|
36230
|
+
degraded: {
|
|
36231
|
+
headline: "the site's payloads no longer carry the fields the extension reads",
|
|
36232
|
+
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."
|
|
36233
|
+
}
|
|
36234
|
+
};
|
|
36235
|
+
|
|
35831
36236
|
// ../../packages/detections/src/security/redos-probe.ts
|
|
35832
36237
|
var BUDGET_MS = 100;
|
|
35833
36238
|
var EXPONENTIAL_UNITS = [
|
|
@@ -39588,86 +39993,10 @@ function createForwardPolicy(deps) {
|
|
|
39588
39993
|
}
|
|
39589
39994
|
|
|
39590
39995
|
// ../../packages/plugin-runtime/src/attached/gateway.ts
|
|
39591
|
-
|
|
39592
|
-
|
|
39593
|
-
|
|
39594
|
-
return
|
|
39595
|
-
}
|
|
39596
|
-
function ruleCategoryMap(wireRules, localRules) {
|
|
39597
|
-
const map2 = /* @__PURE__ */ new Map();
|
|
39598
|
-
for (const rule of wireRules ?? []) map2.set(rule.id, rule.category);
|
|
39599
|
-
for (const rule of localRules ?? []) map2.set(rule.id, rule.category);
|
|
39600
|
-
for (const pack of bundledDetections()) {
|
|
39601
|
-
for (const rule of pack.rules) map2.set(rule.id, rule.category);
|
|
39602
|
-
}
|
|
39603
|
-
return map2;
|
|
39604
|
-
}
|
|
39605
|
-
function policyKey(policy) {
|
|
39606
|
-
return "ruleId" in policy.target ? `rule:${policy.target.ruleId}` : `category:${policy.target.category}`;
|
|
39607
|
-
}
|
|
39608
|
-
function floorFor(policy, categoryByRuleId) {
|
|
39609
|
-
const category = "category" in policy.target ? policy.target.category : categoryByRuleId.get(policy.target.ruleId);
|
|
39610
|
-
return category === void 0 ? null : DEFAULT_ACTIONS[category];
|
|
39611
|
-
}
|
|
39612
|
-
function mergeRaiseOnly(localPolicies, remotePolicies, categoryByRuleId) {
|
|
39613
|
-
const merged = /* @__PURE__ */ new Map();
|
|
39614
|
-
const disabled = [];
|
|
39615
|
-
const remoteCategoryAction = /* @__PURE__ */ new Map();
|
|
39616
|
-
for (const policy of remotePolicies) {
|
|
39617
|
-
if (!policy.enabled) continue;
|
|
39618
|
-
if (!("category" in policy.target)) continue;
|
|
39619
|
-
if (remoteCategoryAction.has(policy.target.category)) continue;
|
|
39620
|
-
const floor = floorFor(policy, categoryByRuleId);
|
|
39621
|
-
remoteCategoryAction.set(
|
|
39622
|
-
policy.target.category,
|
|
39623
|
-
floor !== null && !isActionAtLeast(policy.action, floor) ? floor : policy.action
|
|
39624
|
-
);
|
|
39625
|
-
}
|
|
39626
|
-
for (const policy of localPolicies) {
|
|
39627
|
-
if (!policy.enabled) {
|
|
39628
|
-
disabled.push(policy);
|
|
39629
|
-
continue;
|
|
39630
|
-
}
|
|
39631
|
-
const key = policyKey(policy);
|
|
39632
|
-
if (merged.has(key)) continue;
|
|
39633
|
-
let remoteFloor = null;
|
|
39634
|
-
if ("ruleId" in policy.target) {
|
|
39635
|
-
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
39636
|
-
if (category !== void 0) remoteFloor = remoteCategoryAction.get(category) ?? null;
|
|
39637
|
-
}
|
|
39638
|
-
merged.set(
|
|
39639
|
-
key,
|
|
39640
|
-
remoteFloor !== null && !isActionAtLeast(policy.action, remoteFloor) ? { ...policy, action: remoteFloor } : policy
|
|
39641
|
-
);
|
|
39642
|
-
}
|
|
39643
|
-
const localCategoryAction = /* @__PURE__ */ new Map();
|
|
39644
|
-
for (const policy of merged.values()) {
|
|
39645
|
-
if ("category" in policy.target) localCategoryAction.set(policy.target.category, policy.action);
|
|
39646
|
-
}
|
|
39647
|
-
for (const policy of remotePolicies) {
|
|
39648
|
-
if (!policy.enabled) {
|
|
39649
|
-
disabled.push(policy);
|
|
39650
|
-
continue;
|
|
39651
|
-
}
|
|
39652
|
-
const key = policyKey(policy);
|
|
39653
|
-
const floor = floorFor(policy, categoryByRuleId);
|
|
39654
|
-
let localFloor = null;
|
|
39655
|
-
if ("ruleId" in policy.target) {
|
|
39656
|
-
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
39657
|
-
if (category !== void 0) localFloor = localCategoryAction.get(category) ?? null;
|
|
39658
|
-
}
|
|
39659
|
-
const effectiveFloor = strongerOf(floor, localFloor);
|
|
39660
|
-
const clamped = effectiveFloor !== null && !isActionAtLeast(policy.action, effectiveFloor) ? { ...policy, action: effectiveFloor } : policy;
|
|
39661
|
-
const existing = merged.get(key);
|
|
39662
|
-
if (existing === void 0) {
|
|
39663
|
-
merged.set(key, clamped);
|
|
39664
|
-
continue;
|
|
39665
|
-
}
|
|
39666
|
-
if (actionRank(clamped.action) > actionRank(existing.action)) {
|
|
39667
|
-
merged.set(key, clamped);
|
|
39668
|
-
}
|
|
39669
|
-
}
|
|
39670
|
-
return [...merged.values(), ...disabled];
|
|
39996
|
+
var bundledRulesFlatCache;
|
|
39997
|
+
function bundledRulesFlat() {
|
|
39998
|
+
bundledRulesFlatCache ??= bundledDetections().flatMap((pack) => pack.rules);
|
|
39999
|
+
return bundledRulesFlatCache;
|
|
39671
40000
|
}
|
|
39672
40001
|
var AttachedDataGateway = class {
|
|
39673
40002
|
constructor(deps) {
|
|
@@ -39987,6 +40316,9 @@ var AttachedDataGateway = class {
|
|
|
39987
40316
|
async readSessionProvider(sessionId) {
|
|
39988
40317
|
return this.deps.local.readSessionProvider(sessionId);
|
|
39989
40318
|
}
|
|
40319
|
+
async readCaptureStatuses() {
|
|
40320
|
+
return this.deps.local.readCaptureStatuses();
|
|
40321
|
+
}
|
|
39990
40322
|
async facets() {
|
|
39991
40323
|
return this.deps.local.facets();
|
|
39992
40324
|
}
|
|
@@ -40069,7 +40401,7 @@ var AttachedDataGateway = class {
|
|
|
40069
40401
|
policies: mergeRaiseOnly(
|
|
40070
40402
|
local.policies,
|
|
40071
40403
|
cached2.policies,
|
|
40072
|
-
ruleCategoryMap(cached2.rules, local.rules)
|
|
40404
|
+
ruleCategoryMap(cached2.rules, local.rules, bundledRulesFlat())
|
|
40073
40405
|
),
|
|
40074
40406
|
customKeywords: [...local.customKeywords, ...cached2.customKeywords],
|
|
40075
40407
|
// TAKEN FROM THE CACHE, unlike the two fields below — and the asymmetry
|
|
@@ -40270,10 +40602,15 @@ import { join as join27 } from "path";
|
|
|
40270
40602
|
// ../../packages/plugin-runtime/src/attached/atomic-publish.ts
|
|
40271
40603
|
import { rename as rename2 } from "fs/promises";
|
|
40272
40604
|
var RETRYABLE = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
|
|
40273
|
-
var
|
|
40605
|
+
var IMMEDIATE_RETRIES = 8;
|
|
40606
|
+
var TIMED_RETRIES = 4;
|
|
40607
|
+
var ATTEMPTS = 1 + IMMEDIATE_RETRIES + TIMED_RETRIES;
|
|
40274
40608
|
var delay = (ms) => new Promise((resolve2) => {
|
|
40275
40609
|
setTimeout(resolve2, ms);
|
|
40276
40610
|
});
|
|
40611
|
+
var yieldToLoop = () => new Promise((resolve2) => {
|
|
40612
|
+
setImmediate(resolve2);
|
|
40613
|
+
});
|
|
40277
40614
|
async function publishByRename(tmp, file2, move = rename2) {
|
|
40278
40615
|
for (let attempt = 1; ; attempt += 1) {
|
|
40279
40616
|
try {
|
|
@@ -40282,7 +40619,7 @@ async function publishByRename(tmp, file2, move = rename2) {
|
|
|
40282
40619
|
} catch (err) {
|
|
40283
40620
|
const code = err.code;
|
|
40284
40621
|
if (attempt >= ATTEMPTS || code === void 0 || !RETRYABLE.has(code)) throw err;
|
|
40285
|
-
await delay(attempt * 10);
|
|
40622
|
+
await (attempt <= IMMEDIATE_RETRIES ? yieldToLoop() : delay((attempt - IMMEDIATE_RETRIES) * 10));
|
|
40286
40623
|
}
|
|
40287
40624
|
}
|
|
40288
40625
|
}
|
|
@@ -40746,6 +41083,9 @@ var StandaloneDataGateway = class {
|
|
|
40746
41083
|
readSessionProvider(sessionId) {
|
|
40747
41084
|
return Promise.resolve(this.db.auditEvents.sessionProvider(sessionId));
|
|
40748
41085
|
}
|
|
41086
|
+
readCaptureStatuses() {
|
|
41087
|
+
return Promise.resolve(this.db.captureStatus.latest(Date.now()));
|
|
41088
|
+
}
|
|
40749
41089
|
facets() {
|
|
40750
41090
|
return Promise.resolve(this.db.facets());
|
|
40751
41091
|
}
|