@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/backfill.js
CHANGED
|
@@ -20481,7 +20481,17 @@ var UNPRICEABLE_PROVIDERS = Object.freeze([
|
|
|
20481
20481
|
"gateway",
|
|
20482
20482
|
"unknown",
|
|
20483
20483
|
"cli",
|
|
20484
|
-
"api"
|
|
20484
|
+
"api",
|
|
20485
|
+
// The browser extension's native host records these as `llm_call.provider`
|
|
20486
|
+
// for a web-chat turn — the web tool id, deliberately never the vendor id
|
|
20487
|
+
// (`openai`/`anthropic`) the session root carries. Subscription traffic
|
|
20488
|
+
// burns rate-limit budget, not dollar credits, and listing them here is
|
|
20489
|
+
// what keeps that true structurally: a later maintainer who wants to price
|
|
20490
|
+
// web-chat traffic at API rates has to delete this entry first, and meet
|
|
20491
|
+
// the reason on the way, rather than quietly adding one to
|
|
20492
|
+
// PROVIDER_PLATFORM.
|
|
20493
|
+
"chatgpt",
|
|
20494
|
+
"claude-ai"
|
|
20485
20495
|
]);
|
|
20486
20496
|
function platformForProvider(provider) {
|
|
20487
20497
|
return PROVIDER_PLATFORM.get(provider.trim().toLowerCase()) ?? null;
|
|
@@ -20624,7 +20634,12 @@ var HARNESS = {
|
|
|
20624
20634
|
ClaudeDesktop: "claudedesktop",
|
|
20625
20635
|
ChatGpt: "chatgpt",
|
|
20626
20636
|
ClaudeAi: "claudeai",
|
|
20627
|
-
Api: "api"
|
|
20637
|
+
Api: "api",
|
|
20638
|
+
// Not a coding assistant a person drives — an in-process SDK embedded in an
|
|
20639
|
+
// application, so it has no IDE/CLI/desktop/web surface of its own. Carries
|
|
20640
|
+
// the same id as its SOURCE_TOOL counterpart, unlike every capture-side tool
|
|
20641
|
+
// whose wire spelling differs from its display spelling.
|
|
20642
|
+
AiTcSdk: "ai-tc-sdk"
|
|
20628
20643
|
};
|
|
20629
20644
|
var Harness = external_exports.enum(HARNESS).meta({ id: "Harness" });
|
|
20630
20645
|
var SOURCE_TOOL = {
|
|
@@ -20640,9 +20655,15 @@ var SOURCE_TOOL = {
|
|
|
20640
20655
|
// whose tool could not be identified both render through the read side's
|
|
20641
20656
|
// miss path rather than as a harness of their own.
|
|
20642
20657
|
Cli: "cli",
|
|
20643
|
-
Unknown: "unknown"
|
|
20658
|
+
Unknown: "unknown",
|
|
20659
|
+
// The wire id an in-process, request-path SDK stamps on its own structural
|
|
20660
|
+
// rows (`request_decision`) — never a capture of prompt/response/tool text,
|
|
20661
|
+
// since the SDK sits in front of a model call rather than inside a coding
|
|
20662
|
+
// assistant's own hook contract.
|
|
20663
|
+
AiTcSdk: "ai-tc-sdk"
|
|
20644
20664
|
};
|
|
20645
20665
|
var SourceTool = external_exports.enum(SOURCE_TOOL).meta({ id: "SourceTool" });
|
|
20666
|
+
var WebSourceTool = SourceTool.extract(["ChatGpt", "ClaudeAi"]);
|
|
20646
20667
|
var TOOL_TO_HARNESS = {
|
|
20647
20668
|
[SOURCE_TOOL.ClaudeCode]: HARNESS.ClaudeCode,
|
|
20648
20669
|
[SOURCE_TOOL.ClaudeDesktop]: HARNESS.ClaudeDesktop,
|
|
@@ -20651,7 +20672,12 @@ var TOOL_TO_HARNESS = {
|
|
|
20651
20672
|
[SOURCE_TOOL.ChatGpt]: HARNESS.ChatGpt,
|
|
20652
20673
|
[SOURCE_TOOL.Codex]: HARNESS.Codex,
|
|
20653
20674
|
[SOURCE_TOOL.Antigravity]: HARNESS.Antigravity,
|
|
20654
|
-
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi
|
|
20675
|
+
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi,
|
|
20676
|
+
// Wire and display id are the same string here, but the row still belongs:
|
|
20677
|
+
// both vocabularies carry the `AiTcSdk` member, and the join is exactly
|
|
20678
|
+
// their intersection — leaving a shared member out would read as an
|
|
20679
|
+
// uninstrumented tool on both surfaces, which this one is not.
|
|
20680
|
+
[SOURCE_TOOL.AiTcSdk]: HARNESS.AiTcSdk
|
|
20655
20681
|
};
|
|
20656
20682
|
function harnessFromTool(tool) {
|
|
20657
20683
|
return (Object.hasOwn(TOOL_TO_HARNESS, tool) ? TOOL_TO_HARNESS[tool] : void 0) ?? tool;
|
|
@@ -20688,7 +20714,8 @@ var FindingProvider = Harness.extract([
|
|
|
20688
20714
|
"ClaudeAi",
|
|
20689
20715
|
"Codex",
|
|
20690
20716
|
"Antigravity",
|
|
20691
|
-
"Api"
|
|
20717
|
+
"Api",
|
|
20718
|
+
"AiTcSdk"
|
|
20692
20719
|
]).meta({ id: "FindingProvider" });
|
|
20693
20720
|
var FindingCategory = external_exports.enum([
|
|
20694
20721
|
"secret",
|
|
@@ -21065,18 +21092,41 @@ var AuditEventType = external_exports.enum([
|
|
|
21065
21092
|
// 'tool_call' is the reconciler's structural row for every call, while
|
|
21066
21093
|
// 'tool_use' exists only where a hook enforced against the arguments.
|
|
21067
21094
|
"tool_use",
|
|
21068
|
-
// One row per model REFUSAL
|
|
21069
|
-
//
|
|
21070
|
-
//
|
|
21071
|
-
//
|
|
21072
|
-
//
|
|
21073
|
-
//
|
|
21095
|
+
// One row per model REFUSAL, across all four seams a prohibited model can be
|
|
21096
|
+
// stopped at: a switch onto it, a turn already running on it, a subagent
|
|
21097
|
+
// spawn asking for it, or a request-path refusal an embedded request-path
|
|
21098
|
+
// SDK makes in-process before the call leaves the application. Which seam
|
|
21099
|
+
// rides `attributes.refusal_seam`, never this member name. A structural row
|
|
21100
|
+
// like the ones above rather than a capture — it carries the model that was
|
|
21101
|
+
// refused and nothing the user typed, because what is worth recording about
|
|
21102
|
+
// a governance decision is the decision, and prompt text is the thing this
|
|
21103
|
+
// product exists to keep from travelling.
|
|
21074
21104
|
"model_refusal",
|
|
21105
|
+
// One row per request-path DECISION: a policy check an embedded request-path
|
|
21106
|
+
// SDK performs in-process before a model call leaves the application, or
|
|
21107
|
+
// against that call's non-streamed response. A structural row like
|
|
21108
|
+
// 'model_refusal' rather than a capture — content-free in the same way:
|
|
21109
|
+
// which side, which seam, what action and which field are decided rides
|
|
21110
|
+
// `attributes`, never this member name, and the matched text itself never
|
|
21111
|
+
// travels.
|
|
21112
|
+
//
|
|
21113
|
+
// A prohibited-model refusal on the request path is deliberately NOT this
|
|
21114
|
+
// member: it stays 'model_refusal' with `refusal_seam: 'request'`, so it
|
|
21115
|
+
// shares one bucket with the plugin's switch/turn/spawn refusals rather
|
|
21116
|
+
// than splitting one governance concept across two event types. This
|
|
21117
|
+
// member carries every OTHER request-path decision.
|
|
21118
|
+
"request_decision",
|
|
21075
21119
|
// One row per config-inventory scan, hung off the session root. It is the
|
|
21076
21120
|
// fact the posture inspection findings reference (findings require an
|
|
21077
21121
|
// audit_event_id), and its started_at is the "scanned Nm ago" the read
|
|
21078
21122
|
// surface renders.
|
|
21079
|
-
"config_scan"
|
|
21123
|
+
"config_scan",
|
|
21124
|
+
// One row per reported browser-extension capture status, hung off the web
|
|
21125
|
+
// session root. The durable home of what one tab's network interception
|
|
21126
|
+
// is doing — a write-through of the native host's in-memory tracker, so a
|
|
21127
|
+
// second process (aka extension status) and a restarted host both have
|
|
21128
|
+
// somewhere to read it back from.
|
|
21129
|
+
"capture_status"
|
|
21080
21130
|
]).meta({ id: "AuditEventType" });
|
|
21081
21131
|
var AttributeBag = external_exports.record(external_exports.string(), external_exports.unknown());
|
|
21082
21132
|
var HostAttributes = external_exports.object({
|
|
@@ -21236,6 +21286,20 @@ var CaptureAttributes = external_exports.object({
|
|
|
21236
21286
|
// repeated rather than referenced because a store reader opens this file.
|
|
21237
21287
|
redact_degraded_to: ActionTaken.optional()
|
|
21238
21288
|
}).catchall(external_exports.unknown());
|
|
21289
|
+
var CaptureStatusAttributes = external_exports.object({
|
|
21290
|
+
source_tool: external_exports.string().optional(),
|
|
21291
|
+
patched: external_exports.boolean().optional(),
|
|
21292
|
+
live: external_exports.boolean().optional(),
|
|
21293
|
+
blind: external_exports.boolean().optional(),
|
|
21294
|
+
sends_seen_dom: external_exports.number().int().nonnegative().optional(),
|
|
21295
|
+
exchanges_seen_net: external_exports.number().int().nonnegative().optional(),
|
|
21296
|
+
parse_failures: external_exports.number().int().nonnegative().optional(),
|
|
21297
|
+
unparsed_bodies: external_exports.number().int().nonnegative().optional(),
|
|
21298
|
+
shape_misses: external_exports.array(external_exports.string()).optional(),
|
|
21299
|
+
conversation_endpoints: external_exports.number().int().nonnegative().optional(),
|
|
21300
|
+
closed: external_exports.boolean().optional(),
|
|
21301
|
+
enforcement: external_exports.string().optional()
|
|
21302
|
+
}).catchall(external_exports.unknown());
|
|
21239
21303
|
var ToolCallInspection = external_exports.object({
|
|
21240
21304
|
ruleId: external_exports.string().min(1),
|
|
21241
21305
|
ruleName: external_exports.string(),
|
|
@@ -22095,6 +22159,30 @@ var AttachedCredential = external_exports.object({
|
|
|
22095
22159
|
keyPrefix: external_exports.string().min(1).max(16).optional(),
|
|
22096
22160
|
mintedAt: external_exports.iso.datetime().optional()
|
|
22097
22161
|
});
|
|
22162
|
+
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
22163
|
+
function unsafeEndpointReason(endpoint) {
|
|
22164
|
+
let parsed2;
|
|
22165
|
+
try {
|
|
22166
|
+
parsed2 = new URL(endpoint);
|
|
22167
|
+
} catch {
|
|
22168
|
+
return "unparseable";
|
|
22169
|
+
}
|
|
22170
|
+
if (parsed2.username !== "" || parsed2.password !== "") return "userinfo";
|
|
22171
|
+
if (parsed2.search !== "" || parsed2.hash !== "") return "query-or-fragment";
|
|
22172
|
+
if (parsed2.protocol === "https:") return null;
|
|
22173
|
+
return parsed2.protocol === "http:" && LOOPBACK_HOSTS.has(parsed2.hostname) ? null : "insecure";
|
|
22174
|
+
}
|
|
22175
|
+
function isSafeEndpoint(endpoint) {
|
|
22176
|
+
return unsafeEndpointReason(endpoint) === null;
|
|
22177
|
+
}
|
|
22178
|
+
function originOnly(endpoint) {
|
|
22179
|
+
try {
|
|
22180
|
+
const parsed2 = new URL(endpoint);
|
|
22181
|
+
return `${parsed2.protocol}//${parsed2.host}`;
|
|
22182
|
+
} catch {
|
|
22183
|
+
return "(unparseable endpoint)";
|
|
22184
|
+
}
|
|
22185
|
+
}
|
|
22098
22186
|
var MAX_DATE_MS = 253402300799999;
|
|
22099
22187
|
var MAX_INT4 = 2147483647;
|
|
22100
22188
|
var StorePosturePack = external_exports.object({
|
|
@@ -22249,6 +22337,11 @@ var RemoteFailureKind = external_exports.enum([
|
|
|
22249
22337
|
"rejected",
|
|
22250
22338
|
"unreachable"
|
|
22251
22339
|
]);
|
|
22340
|
+
var ControlPlaneFailure = RemoteFailureKind.extract([
|
|
22341
|
+
"unauthorized",
|
|
22342
|
+
"forbidden",
|
|
22343
|
+
"unreachable"
|
|
22344
|
+
]);
|
|
22252
22345
|
var AttachDeviceRequest = external_exports.object({
|
|
22253
22346
|
// This machine's own continuity id, so re-attaching ROTATES the credential
|
|
22254
22347
|
// on one machine record instead of producing a second one. Client-minted
|
|
@@ -22788,7 +22881,12 @@ var EventMetadata = external_exports.object({
|
|
|
22788
22881
|
// in — set by the browser extension's network capture so a stored `response`
|
|
22789
22882
|
// row can be joined to the `llm_call` leaf describing the same turn. Absent
|
|
22790
22883
|
// on every other capture path, which has no such id.
|
|
22791
|
-
|
|
22884
|
+
//
|
|
22885
|
+
// Non-empty for the reason WebExchange.messageId is: it is the join key, and
|
|
22886
|
+
// a blank one matches no `llm_call` leaf. That refusal reaches only the
|
|
22887
|
+
// places an event is PARSED; the local write path types the event and parses
|
|
22888
|
+
// nothing, which is why `toCaptureAttributes` omits a blank one separately.
|
|
22889
|
+
messageId: external_exports.string().min(1).optional(),
|
|
22792
22890
|
conversationId: external_exports.string().optional(),
|
|
22793
22891
|
// How long THIS capture's inspection blocked its caller, in whole
|
|
22794
22892
|
// milliseconds — the plugin's own added latency, NOT the LLM call it sat in
|
|
@@ -23635,6 +23733,85 @@ function policyIdIsReversible(policyId) {
|
|
|
23635
23733
|
var DEFAULT_ACTIONS = Object.fromEntries(
|
|
23636
23734
|
DetectionCategory.options.map((c) => [c, builtinPolicyToAction(severityFloorPolicy(c))])
|
|
23637
23735
|
);
|
|
23736
|
+
function ruleCategoryMap(wireRules, localRules, compiledRules) {
|
|
23737
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
23738
|
+
for (const rule of wireRules ?? []) map2.set(rule.id, rule.category);
|
|
23739
|
+
for (const rule of localRules ?? []) map2.set(rule.id, rule.category);
|
|
23740
|
+
for (const rule of compiledRules) map2.set(rule.id, rule.category);
|
|
23741
|
+
return map2;
|
|
23742
|
+
}
|
|
23743
|
+
function policyKey(policy) {
|
|
23744
|
+
return "ruleId" in policy.target ? `rule:${policy.target.ruleId}` : `category:${policy.target.category}`;
|
|
23745
|
+
}
|
|
23746
|
+
function floorFor(policy, categoryByRuleId) {
|
|
23747
|
+
const category = "category" in policy.target ? policy.target.category : categoryByRuleId.get(policy.target.ruleId);
|
|
23748
|
+
return category === void 0 ? null : DEFAULT_ACTIONS[category];
|
|
23749
|
+
}
|
|
23750
|
+
function strongerOf(a, b) {
|
|
23751
|
+
if (a === null) return b;
|
|
23752
|
+
if (b === null) return a;
|
|
23753
|
+
return strongerAction(a, b);
|
|
23754
|
+
}
|
|
23755
|
+
function mergeRaiseOnly(localPolicies, remotePolicies, categoryByRuleId) {
|
|
23756
|
+
const merged = /* @__PURE__ */ new Map();
|
|
23757
|
+
const disabled = [];
|
|
23758
|
+
const remoteCategoryAction = /* @__PURE__ */ new Map();
|
|
23759
|
+
for (const policy of remotePolicies) {
|
|
23760
|
+
if (!policy.enabled) continue;
|
|
23761
|
+
if (!("category" in policy.target)) continue;
|
|
23762
|
+
if (remoteCategoryAction.has(policy.target.category)) continue;
|
|
23763
|
+
const floor = floorFor(policy, categoryByRuleId);
|
|
23764
|
+
remoteCategoryAction.set(
|
|
23765
|
+
policy.target.category,
|
|
23766
|
+
floor !== null && !isActionAtLeast(policy.action, floor) ? floor : policy.action
|
|
23767
|
+
);
|
|
23768
|
+
}
|
|
23769
|
+
for (const policy of localPolicies) {
|
|
23770
|
+
if (!policy.enabled) {
|
|
23771
|
+
disabled.push(policy);
|
|
23772
|
+
continue;
|
|
23773
|
+
}
|
|
23774
|
+
const key = policyKey(policy);
|
|
23775
|
+
if (merged.has(key)) continue;
|
|
23776
|
+
let remoteFloor = null;
|
|
23777
|
+
if ("ruleId" in policy.target) {
|
|
23778
|
+
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
23779
|
+
if (category !== void 0) remoteFloor = remoteCategoryAction.get(category) ?? null;
|
|
23780
|
+
}
|
|
23781
|
+
merged.set(
|
|
23782
|
+
key,
|
|
23783
|
+
remoteFloor !== null && !isActionAtLeast(policy.action, remoteFloor) ? { ...policy, action: remoteFloor } : policy
|
|
23784
|
+
);
|
|
23785
|
+
}
|
|
23786
|
+
const localCategoryAction = /* @__PURE__ */ new Map();
|
|
23787
|
+
for (const policy of merged.values()) {
|
|
23788
|
+
if ("category" in policy.target) localCategoryAction.set(policy.target.category, policy.action);
|
|
23789
|
+
}
|
|
23790
|
+
for (const policy of remotePolicies) {
|
|
23791
|
+
if (!policy.enabled) {
|
|
23792
|
+
disabled.push(policy);
|
|
23793
|
+
continue;
|
|
23794
|
+
}
|
|
23795
|
+
const key = policyKey(policy);
|
|
23796
|
+
const floor = floorFor(policy, categoryByRuleId);
|
|
23797
|
+
let localFloor = null;
|
|
23798
|
+
if ("ruleId" in policy.target) {
|
|
23799
|
+
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
23800
|
+
if (category !== void 0) localFloor = localCategoryAction.get(category) ?? null;
|
|
23801
|
+
}
|
|
23802
|
+
const effectiveFloor = strongerOf(floor, localFloor);
|
|
23803
|
+
const clamped = effectiveFloor !== null && !isActionAtLeast(policy.action, effectiveFloor) ? { ...policy, action: effectiveFloor } : policy;
|
|
23804
|
+
const existing = merged.get(key);
|
|
23805
|
+
if (existing === void 0) {
|
|
23806
|
+
merged.set(key, clamped);
|
|
23807
|
+
continue;
|
|
23808
|
+
}
|
|
23809
|
+
if (actionRank(clamped.action) > actionRank(existing.action)) {
|
|
23810
|
+
merged.set(key, clamped);
|
|
23811
|
+
}
|
|
23812
|
+
}
|
|
23813
|
+
return [...merged.values(), ...disabled];
|
|
23814
|
+
}
|
|
23638
23815
|
var BUILTIN_POLICIES = Object.fromEntries(
|
|
23639
23816
|
KNOWN_BUILTIN_IDS.map((id) => [id, { id, ...BUILTIN_POLICY_SPECS[id] }])
|
|
23640
23817
|
);
|
|
@@ -23867,6 +24044,18 @@ var HistorySyncConsent = external_exports.object({
|
|
|
23867
24044
|
payloadVersion: external_exports.number().int().positive(),
|
|
23868
24045
|
endpoint: external_exports.string()
|
|
23869
24046
|
});
|
|
24047
|
+
var WebChatCaptureConsent = external_exports.object({
|
|
24048
|
+
acknowledgedAt: external_exports.iso.datetime(),
|
|
24049
|
+
version: external_exports.number().int().positive()
|
|
24050
|
+
});
|
|
24051
|
+
var WebChatResponseCapture = external_exports.enum(["with-findings", "always", "never"]);
|
|
24052
|
+
var WebChatCapture = external_exports.object({
|
|
24053
|
+
responses: WebChatResponseCapture.default("with-findings"),
|
|
24054
|
+
account: external_exports.boolean().default(false),
|
|
24055
|
+
// Absent until granted. Presence alone does not authorize anything — see
|
|
24056
|
+
// isWebChatCaptureConsentValid.
|
|
24057
|
+
consent: WebChatCaptureConsent.optional()
|
|
24058
|
+
});
|
|
23870
24059
|
var BODY_RETENTION_DEFAULT_DAYS = 30;
|
|
23871
24060
|
var BodyRetention = external_exports.object({
|
|
23872
24061
|
enabled: external_exports.boolean().default(false),
|
|
@@ -23925,6 +24114,16 @@ var WorkspaceSettings = external_exports.object({
|
|
|
23925
24114
|
// both widenings. Absent until granted, and a grant for a different endpoint
|
|
23926
24115
|
// or an older payload no longer counts.
|
|
23927
24116
|
historySyncConsent: HistorySyncConsent.optional(),
|
|
24117
|
+
// What the browser extension may record from a web chat, and the grant that
|
|
24118
|
+
// authorizes it. Absent until the user answers: recording something that was
|
|
24119
|
+
// never recorded before is never an assumed grant on upgrade, so the whole
|
|
24120
|
+
// block is optional rather than defaulted in. What an absent block means is
|
|
24121
|
+
// webChatCaptureOf's answer, in one place.
|
|
24122
|
+
//
|
|
24123
|
+
// Enforcement is NOT gated on this. A machine that has never answered still
|
|
24124
|
+
// blocks, redacts and warns on what a user sends; the grant covers what is
|
|
24125
|
+
// written down.
|
|
24126
|
+
webChatCapture: WebChatCapture.optional(),
|
|
23928
24127
|
// Local body expiry (see BodyRetention). Off until switched on; expiring a
|
|
23929
24128
|
// body never removes the row or its findings.
|
|
23930
24129
|
bodyRetention: BodyRetention.default({
|
|
@@ -24032,7 +24231,10 @@ function toCaptureAttributes(event) {
|
|
|
24032
24231
|
// `.catchall(z.unknown())` carries the long tail.
|
|
24033
24232
|
...metadata?.model !== void 0 ? { model: metadata.model } : {},
|
|
24034
24233
|
...metadata?.turnIndex !== void 0 ? { turn_index: metadata.turnIndex } : {},
|
|
24035
|
-
|
|
24234
|
+
// A blank id is omitted rather than stored: it is a join key and `''` joins
|
|
24235
|
+
// nothing. This runs on the local write path, which types the event but
|
|
24236
|
+
// never parses it, so EventMetadata's own `.min(1)` does not reach here.
|
|
24237
|
+
...metadata?.messageId !== void 0 && metadata.messageId !== "" ? { message_id: metadata.messageId } : {},
|
|
24036
24238
|
...metadata?.conversationId !== void 0 ? { conversation_id: metadata.conversationId } : {}
|
|
24037
24239
|
};
|
|
24038
24240
|
}
|
|
@@ -24406,12 +24608,14 @@ var RecommendedActionIdParam = external_exports.object({ id: external_exports.st
|
|
|
24406
24608
|
// ../../packages/schema/src/zod/settings-action.ts
|
|
24407
24609
|
var HistorySyncConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "HistorySyncConsentChoice" });
|
|
24408
24610
|
var ModelJudgeConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "ModelJudgeConsentChoice" });
|
|
24611
|
+
var WebChatCaptureConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "WebChatCaptureConsentChoice" });
|
|
24409
24612
|
var SaveSettingsInput = external_exports.object({
|
|
24410
24613
|
historicalAccess: external_exports.string(),
|
|
24411
24614
|
modelJudgeConsent: ModelJudgeConsentChoice,
|
|
24412
24615
|
historySyncConsent: HistorySyncConsentChoice,
|
|
24413
24616
|
vaultConsent: external_exports.string(),
|
|
24414
24617
|
vaultInlineReveal: external_exports.string(),
|
|
24618
|
+
webChatCaptureConsent: WebChatCaptureConsentChoice,
|
|
24415
24619
|
// Widened to `string` like its neighbours rather than typed as
|
|
24416
24620
|
// `RedactFallback`, on this module's own layering rule: shape here, VALUE at
|
|
24417
24621
|
// the call site, so the domain check receives the type it was written for.
|
|
@@ -24626,11 +24830,24 @@ var WebExchange = external_exports.object({
|
|
|
24626
24830
|
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
24627
24831
|
toolCalls: external_exports.array(WebToolCall).default([]),
|
|
24628
24832
|
// Absent when the adapter recovered no text. Capped by the caller at
|
|
24629
|
-
// RESPONSE_TEXT_MAX_BYTES
|
|
24630
|
-
//
|
|
24833
|
+
// RESPONSE_TEXT_MAX_BYTES, so a short capture is never mistaken for a short
|
|
24834
|
+
// reply.
|
|
24631
24835
|
responseText: external_exports.string().optional(),
|
|
24836
|
+
// The stored text is short of the reply. It does NOT say which of the two
|
|
24837
|
+
// ceilings on this path cut it: the caller applies its own cap on the raw
|
|
24838
|
+
// bytes it reads off the wire, which can be reached by a stream whose
|
|
24839
|
+
// recovered text stays well under RESPONSE_TEXT_MAX_BYTES, and applies that
|
|
24840
|
+
// one to the text. A reader cannot tell them apart, and nothing downstream
|
|
24841
|
+
// should branch as though it could.
|
|
24632
24842
|
truncated: external_exports.boolean().default(false)
|
|
24633
24843
|
});
|
|
24844
|
+
var WebEnforcementState = external_exports.enum([
|
|
24845
|
+
"watching",
|
|
24846
|
+
"composer-only",
|
|
24847
|
+
"button-only",
|
|
24848
|
+
"unattached",
|
|
24849
|
+
"unknown"
|
|
24850
|
+
]);
|
|
24634
24851
|
var RESPONSE_TEXT_MAX_BYTES = 2 * 1024 * 1024;
|
|
24635
24852
|
var WebCaptureStatus = external_exports.object({
|
|
24636
24853
|
patched: external_exports.boolean(),
|
|
@@ -24642,8 +24859,66 @@ var WebCaptureStatus = external_exports.object({
|
|
|
24642
24859
|
unparsedBodies: external_exports.number().int().nonnegative(),
|
|
24643
24860
|
// The adapter-declared JSON key paths that were absent from a real payload —
|
|
24644
24861
|
// the earliest signal that a site's contract moved.
|
|
24645
|
-
shapeMisses: external_exports.array(external_exports.string()).default([])
|
|
24646
|
-
|
|
24862
|
+
shapeMisses: external_exports.array(external_exports.string()).default([]),
|
|
24863
|
+
// How many `kind: 'conversation'` endpoints the reporting tab's adapter
|
|
24864
|
+
// compiled. Zero means this build declares none for the site, so observing
|
|
24865
|
+
// nothing is the design rather than a fault — the one fact that separates a
|
|
24866
|
+
// site nobody has surveyed yet from one whose contract moved. Defaulted so a
|
|
24867
|
+
// build predating the field is read as declaring nothing rather than refused.
|
|
24868
|
+
conversationEndpoints: external_exports.number().int().nonnegative().default(0),
|
|
24869
|
+
// The document that sent this report is going away. The bridge sets it on
|
|
24870
|
+
// its `pagehide` report and nowhere else.
|
|
24871
|
+
//
|
|
24872
|
+
// A property of the REPORT rather than of capture health, which is why
|
|
24873
|
+
// nothing in `deriveWebCaptureState` reads it and why it stays out of the
|
|
24874
|
+
// bridge's own report signature — a closing tab's last word must not be
|
|
24875
|
+
// suppressed for carrying the same health as the report before it. What
|
|
24876
|
+
// reads it is the per-site fold: a document that said it was unloading stops
|
|
24877
|
+
// voting on the site's state, so the reload the `blind` remediation asks for
|
|
24878
|
+
// can actually clear the verdict it was shown. A document that dies without
|
|
24879
|
+
// sending one is covered by CAPTURE_STATUS_DOCUMENT_QUIET_MS instead.
|
|
24880
|
+
//
|
|
24881
|
+
// Defaulted so a build predating the field reads as a document that never
|
|
24882
|
+
// said it was closing — which keeps it voting, the same as every report that
|
|
24883
|
+
// is not a final one.
|
|
24884
|
+
closed: external_exports.boolean().default(false),
|
|
24885
|
+
// What the DOM enforcement path is doing, which none of the counters above
|
|
24886
|
+
// can say: `sendsSeenDom` rises only once a send has COMPLETED, so a tab
|
|
24887
|
+
// whose watcher never bound reports zero exactly like a tab nobody typed in.
|
|
24888
|
+
// Defaulted to 'unknown' rather than 'watching' so a status from a build
|
|
24889
|
+
// predating the field is not read as reporting a healthy one.
|
|
24890
|
+
enforcement: WebEnforcementState.default("unknown")
|
|
24891
|
+
});
|
|
24892
|
+
function webCaptureStatusObservedTurnPath(status) {
|
|
24893
|
+
if (!status.patched) return true;
|
|
24894
|
+
if (status.conversationEndpoints === 0) return true;
|
|
24895
|
+
return status.blind || status.shapeMisses.length > 0 || status.parseFailures > 0 || status.unparsedBodies > 0 || status.exchangesSeenNet > 0;
|
|
24896
|
+
}
|
|
24897
|
+
function pickReportedCaptureStatus(candidates) {
|
|
24898
|
+
return candidates.find((c) => webCaptureStatusObservedTurnPath(c.status)) ?? candidates[0];
|
|
24899
|
+
}
|
|
24900
|
+
var CAPTURE_STATUS_RECENCY_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
24901
|
+
var CAPTURE_STATUS_RECENCY_DAYS = CAPTURE_STATUS_RECENCY_MS / (24 * 60 * 60 * 1e3);
|
|
24902
|
+
var CAPTURE_STATUS_DOCUMENT_QUIET_MS = 12 * 60 * 60 * 1e3;
|
|
24903
|
+
function fromCaptureStatusAttributes(bag) {
|
|
24904
|
+
const parsedBag = CaptureStatusAttributes.safeParse(bag);
|
|
24905
|
+
if (!parsedBag.success) return null;
|
|
24906
|
+
const b = parsedBag.data;
|
|
24907
|
+
const parsedStatus = WebCaptureStatus.safeParse({
|
|
24908
|
+
patched: b.patched,
|
|
24909
|
+
live: b.live,
|
|
24910
|
+
blind: b.blind,
|
|
24911
|
+
sendsSeenDom: b.sends_seen_dom,
|
|
24912
|
+
exchangesSeenNet: b.exchanges_seen_net,
|
|
24913
|
+
parseFailures: b.parse_failures,
|
|
24914
|
+
unparsedBodies: b.unparsed_bodies,
|
|
24915
|
+
shapeMisses: b.shape_misses,
|
|
24916
|
+
conversationEndpoints: b.conversation_endpoints,
|
|
24917
|
+
closed: b.closed,
|
|
24918
|
+
enforcement: b.enforcement
|
|
24919
|
+
});
|
|
24920
|
+
return parsedStatus.success ? parsedStatus.data : null;
|
|
24921
|
+
}
|
|
24647
24922
|
|
|
24648
24923
|
// ../../packages/persistence/src/paths.ts
|
|
24649
24924
|
import {
|
|
@@ -24774,17 +25049,6 @@ function publishByLink(tmp, file2, data) {
|
|
|
24774
25049
|
function controlPlaneCredentialPath(settingsDir2) {
|
|
24775
25050
|
return join2(settingsDir2, ATTACHED_CREDENTIAL_FILENAME);
|
|
24776
25051
|
}
|
|
24777
|
-
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
24778
|
-
function isSafeEndpoint(endpoint) {
|
|
24779
|
-
let parsed2;
|
|
24780
|
-
try {
|
|
24781
|
-
parsed2 = new URL(endpoint);
|
|
24782
|
-
} catch {
|
|
24783
|
-
return false;
|
|
24784
|
-
}
|
|
24785
|
-
if (parsed2.protocol === "https:") return true;
|
|
24786
|
-
return parsed2.protocol === "http:" && LOOPBACK_HOSTS.has(parsed2.hostname);
|
|
24787
|
-
}
|
|
24788
25052
|
function repairOrRefuseMode(file2) {
|
|
24789
25053
|
const link = lstatSync2(file2, { throwIfNoEntry: false });
|
|
24790
25054
|
if (link === void 0) return "absent";
|
|
@@ -26577,7 +26841,7 @@ var SESSION_ROOT = `event_type = 'session'`;
|
|
|
26577
26841
|
var HAS_ACTIVITY = `EXISTS (
|
|
26578
26842
|
SELECT 1 FROM audit_events c
|
|
26579
26843
|
WHERE c.root_session_id = audit_events.id
|
|
26580
|
-
AND c.event_type NOT IN ('hook', 'config_scan'))`;
|
|
26844
|
+
AND c.event_type NOT IN ('hook', 'config_scan', 'capture_status'))`;
|
|
26581
26845
|
var SqliteActivityRepository = class {
|
|
26582
26846
|
constructor(db, now = () => Date.now()) {
|
|
26583
26847
|
this.db = db;
|
|
@@ -26604,10 +26868,10 @@ var SqliteActivityRepository = class {
|
|
|
26604
26868
|
SELECT id FROM audit_events WHERE event_type = 'session' AND started_at >= ?
|
|
26605
26869
|
UNION
|
|
26606
26870
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_started_at
|
|
26607
|
-
WHERE started_at >= ?
|
|
26871
|
+
WHERE started_at >= ? AND event_type <> 'capture_status'
|
|
26608
26872
|
UNION
|
|
26609
26873
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_ended_at
|
|
26610
|
-
WHERE ended_at >= ?)`,
|
|
26874
|
+
WHERE ended_at >= ? AND event_type <> 'capture_status')`,
|
|
26611
26875
|
[liveThreshold, liveThreshold, liveThreshold]
|
|
26612
26876
|
);
|
|
26613
26877
|
const toolCallsToday = countScalar(
|
|
@@ -27014,7 +27278,10 @@ var SqliteAuditEventsRepository = class {
|
|
|
27014
27278
|
attributes = excluded.attributes,
|
|
27015
27279
|
ended_at = excluded.ended_at
|
|
27016
27280
|
WHERE COALESCE(json_extract(excluded.attributes, '$.output_tokens'), 0)
|
|
27017
|
-
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27281
|
+
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27282
|
+
OR (json_extract(excluded.attributes, '$.usage_source') IS NOT NULL
|
|
27283
|
+
AND json_extract(excluded.attributes, '$.output_tokens') IS NULL
|
|
27284
|
+
AND excluded.attributes <> audit_events.attributes)`
|
|
27018
27285
|
);
|
|
27019
27286
|
this.upsertSessionRootStmt = db.prepare(
|
|
27020
27287
|
`INSERT OR IGNORE INTO audit_events
|
|
@@ -27282,6 +27549,87 @@ var SqliteBodyRetentionRepository = class {
|
|
|
27282
27549
|
}
|
|
27283
27550
|
};
|
|
27284
27551
|
|
|
27552
|
+
// ../../packages/persistence/src/repositories/capture-status.ts
|
|
27553
|
+
var STATUS_LOOKBACK_ROWS = 128;
|
|
27554
|
+
var SqliteCaptureStatusRepository = class {
|
|
27555
|
+
constructor(db) {
|
|
27556
|
+
this.db = db;
|
|
27557
|
+
this.recentStmt = db.prepare(
|
|
27558
|
+
`SELECT a.started_at AS startedAt,
|
|
27559
|
+
a.attributes AS attributes,
|
|
27560
|
+
a.root_session_id AS rootSessionId
|
|
27561
|
+
FROM audit_events a
|
|
27562
|
+
WHERE a.event_type = 'capture_status'
|
|
27563
|
+
AND a.source_tool = ?
|
|
27564
|
+
AND a.started_at >= ?
|
|
27565
|
+
ORDER BY a.started_at DESC, a.id DESC
|
|
27566
|
+
LIMIT ?`
|
|
27567
|
+
);
|
|
27568
|
+
}
|
|
27569
|
+
db;
|
|
27570
|
+
recentStmt;
|
|
27571
|
+
/**
|
|
27572
|
+
* Every document that reported for a site, in registry order by site, from
|
|
27573
|
+
* the last `CAPTURE_STATUS_RECENCY_MS`.
|
|
27574
|
+
*
|
|
27575
|
+
* SEVERAL per site, not one: a browser is many documents and each reports
|
|
27576
|
+
* for itself, so one row per site is a choice about which of them a user
|
|
27577
|
+
* sees — and the newest is the wrong one, since a healthy tab writing a
|
|
27578
|
+
* fresh report would hide a drifting tab's verdict, which is the whole
|
|
27579
|
+
* reason these rows exist. The pick WITHIN a document is made here (the
|
|
27580
|
+
* unchanged `pickReportedCaptureStatus`, over that document's own rows);
|
|
27581
|
+
* choosing between documents belongs where the state semantics live, and
|
|
27582
|
+
* that is `reportedCaptureDocumentForSite` in `@akasecurity/detections` —
|
|
27583
|
+
* this package may not import it.
|
|
27584
|
+
*
|
|
27585
|
+
* `now` is a required argument rather than a `Date.now()` read, so a caller
|
|
27586
|
+
* that already holds a render instant passes THAT one and a test can drive
|
|
27587
|
+
* the window without moving the wall clock.
|
|
27588
|
+
*
|
|
27589
|
+
* A site whose reports have all aged out contributes nothing, so it derives
|
|
27590
|
+
* to `unreported`. That is the point: nothing but the browser extension ever
|
|
27591
|
+
* writes these rows, so an uninstalled extension's last verdict would
|
|
27592
|
+
* otherwise stand as a live claim for ever with no later report able to
|
|
27593
|
+
* clear it.
|
|
27594
|
+
*/
|
|
27595
|
+
latest(now) {
|
|
27596
|
+
const since = now - CAPTURE_STATUS_RECENCY_MS;
|
|
27597
|
+
const documents = [];
|
|
27598
|
+
for (const tool of WebSourceTool.options) {
|
|
27599
|
+
const rows = /* @__PURE__ */ new Map();
|
|
27600
|
+
const lastWord = /* @__PURE__ */ new Map();
|
|
27601
|
+
for (const row of allRows(this.recentStmt, [
|
|
27602
|
+
tool,
|
|
27603
|
+
since,
|
|
27604
|
+
STATUS_LOOKBACK_ROWS
|
|
27605
|
+
])) {
|
|
27606
|
+
const status = fromCaptureStatusAttributes(parseJsonObject(row.attributes));
|
|
27607
|
+
if (status === null) continue;
|
|
27608
|
+
const record2 = { tool, observedAt: epochMillisToIso(row.startedAt), status };
|
|
27609
|
+
const group = rows.get(row.rootSessionId);
|
|
27610
|
+
if (group === void 0) {
|
|
27611
|
+
rows.set(row.rootSessionId, [record2]);
|
|
27612
|
+
lastWord.set(row.rootSessionId, { at: record2.observedAt, closed: status.closed });
|
|
27613
|
+
} else {
|
|
27614
|
+
group.push(record2);
|
|
27615
|
+
}
|
|
27616
|
+
}
|
|
27617
|
+
for (const [root, candidates] of rows) {
|
|
27618
|
+
const picked = pickReportedCaptureStatus(candidates);
|
|
27619
|
+
const last = lastWord.get(root);
|
|
27620
|
+
if (picked === void 0 || last === void 0) continue;
|
|
27621
|
+
documents.push({
|
|
27622
|
+
...picked,
|
|
27623
|
+
...root === null ? {} : { rootSessionId: root },
|
|
27624
|
+
lastReportAt: last.at,
|
|
27625
|
+
closed: last.closed
|
|
27626
|
+
});
|
|
27627
|
+
}
|
|
27628
|
+
}
|
|
27629
|
+
return documents;
|
|
27630
|
+
}
|
|
27631
|
+
};
|
|
27632
|
+
|
|
27285
27633
|
// ../../packages/persistence/src/repositories/classified-data.ts
|
|
27286
27634
|
var SqliteClassifiedDataRepository = class {
|
|
27287
27635
|
constructor(db) {
|
|
@@ -32862,6 +33210,7 @@ function openAndInitialize(file2, base, skipTags) {
|
|
|
32862
33210
|
activity: new SqliteActivityRepository(db),
|
|
32863
33211
|
sourceProject: new SqliteSourceProjectRepository(db),
|
|
32864
33212
|
auditEvents: new SqliteAuditEventsRepository(db),
|
|
33213
|
+
captureStatus: new SqliteCaptureStatusRepository(db),
|
|
32865
33214
|
classifiedData: new SqliteClassifiedDataRepository(db),
|
|
32866
33215
|
inspectionDefinitions: new SqliteInspectionDefinitionsRepository(db),
|
|
32867
33216
|
inspectionFindings: new SqliteInspectionFindingsRepository(db),
|
|
@@ -32902,6 +33251,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
32902
33251
|
activity,
|
|
32903
33252
|
sourceProject,
|
|
32904
33253
|
auditEvents,
|
|
33254
|
+
captureStatus,
|
|
32905
33255
|
classifiedData,
|
|
32906
33256
|
inspectionDefinitions,
|
|
32907
33257
|
inspectionFindings,
|
|
@@ -33119,6 +33469,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
33119
33469
|
activity,
|
|
33120
33470
|
sourceProject,
|
|
33121
33471
|
auditEvents,
|
|
33472
|
+
captureStatus,
|
|
33122
33473
|
classifiedData,
|
|
33123
33474
|
inspectionDefinitions,
|
|
33124
33475
|
inspectionFindings,
|
|
@@ -33364,11 +33715,6 @@ function fingerprintValue(key, raw) {
|
|
|
33364
33715
|
// ../../packages/persistence/src/forward-health.ts
|
|
33365
33716
|
import { readFileSync as readFileSync7 } from "fs";
|
|
33366
33717
|
import { join as join9 } from "path";
|
|
33367
|
-
var FAILURES = /* @__PURE__ */ new Set([
|
|
33368
|
-
"unauthorized",
|
|
33369
|
-
"forbidden",
|
|
33370
|
-
"unreachable"
|
|
33371
|
-
]);
|
|
33372
33718
|
var BREAKER_COOLDOWN_MS = 3e4;
|
|
33373
33719
|
function parseForwardHealth(raw, nowMs) {
|
|
33374
33720
|
try {
|
|
@@ -33377,7 +33723,8 @@ function parseForwardHealth(raw, nowMs) {
|
|
|
33377
33723
|
const record2 = parsed2;
|
|
33378
33724
|
const failures = typeof record2.consecutiveFailures === "number" && record2.consecutiveFailures >= 0 ? record2.consecutiveFailures : 0;
|
|
33379
33725
|
const openedAtMs = typeof record2.openedAtMs === "number" && Number.isFinite(record2.openedAtMs) && record2.openedAtMs <= nowMs ? record2.openedAtMs : null;
|
|
33380
|
-
const
|
|
33726
|
+
const parsedFailure = ControlPlaneFailure.safeParse(record2.lastFailure);
|
|
33727
|
+
const lastFailure = parsedFailure.success ? parsedFailure.data : null;
|
|
33381
33728
|
return { consecutiveFailures: failures, openedAtMs, lastFailure };
|
|
33382
33729
|
} catch {
|
|
33383
33730
|
return null;
|
|
@@ -34381,6 +34728,12 @@ var RemoteRequestInvalid = class extends Error {
|
|
|
34381
34728
|
}
|
|
34382
34729
|
cause;
|
|
34383
34730
|
};
|
|
34731
|
+
var RemoteEndpointRefused = class extends Error {
|
|
34732
|
+
constructor(endpoint) {
|
|
34733
|
+
super(`refusing to talk to an unsafe control-plane endpoint: ${originOnly(endpoint)}`);
|
|
34734
|
+
this.name = "RemoteEndpointRefused";
|
|
34735
|
+
}
|
|
34736
|
+
};
|
|
34384
34737
|
var RemoteResponseInvalid = class extends Error {
|
|
34385
34738
|
constructor(route, detail) {
|
|
34386
34739
|
super(`control plane answered ${route} with ${detail}`);
|
|
@@ -34533,14 +34886,15 @@ function parsed(schema, body, route) {
|
|
|
34533
34886
|
}
|
|
34534
34887
|
return result.data;
|
|
34535
34888
|
}
|
|
34536
|
-
function
|
|
34889
|
+
function resolveBaseUrl(endpoint) {
|
|
34890
|
+
if (!isSafeEndpoint(endpoint)) throw new RemoteEndpointRefused(endpoint);
|
|
34537
34891
|
let end = endpoint.length;
|
|
34538
34892
|
while (end > 0 && endpoint.charCodeAt(end - 1) === SLASH2) end -= 1;
|
|
34539
34893
|
return endpoint.slice(0, end);
|
|
34540
34894
|
}
|
|
34541
34895
|
var SLASH2 = "/".charCodeAt(0);
|
|
34542
34896
|
function createRemoteClient(options) {
|
|
34543
|
-
const base =
|
|
34897
|
+
const base = resolveBaseUrl(options.endpoint);
|
|
34544
34898
|
const url2 = (route) => `${base}${route}`;
|
|
34545
34899
|
const common = { apiKey: options.apiKey, timeoutMs: options.timeoutMs };
|
|
34546
34900
|
const sendOne = async (event) => {
|
|
@@ -34670,6 +35024,7 @@ function classifyRemoteFailure(err) {
|
|
|
34670
35024
|
case "RemoteRouteAbsent":
|
|
34671
35025
|
return "route-absent";
|
|
34672
35026
|
case "RemoteRequestInvalid":
|
|
35027
|
+
case "RemoteEndpointRefused":
|
|
34673
35028
|
return "invalid-request";
|
|
34674
35029
|
case "RemoteResponseInvalid":
|
|
34675
35030
|
return "rejected";
|
|
@@ -35796,6 +36151,56 @@ var CONFIG_POSTURE_RULES = [
|
|
|
35796
36151
|
}
|
|
35797
36152
|
];
|
|
35798
36153
|
|
|
36154
|
+
// ../../packages/detections/src/posture/web-capture-posture.ts
|
|
36155
|
+
var RULE_VERSION2 = "1";
|
|
36156
|
+
var DRIFT_MIN_PARSE_FAILURES = 2;
|
|
36157
|
+
var WEB_CAPTURE_DRIFT_STATES = /* @__PURE__ */ new Set([
|
|
36158
|
+
"blind",
|
|
36159
|
+
"degraded"
|
|
36160
|
+
]);
|
|
36161
|
+
var WEB_CAPTURE_DRIFT_RULE = {
|
|
36162
|
+
ruleId: "web-capture-drift",
|
|
36163
|
+
version: RULE_VERSION2,
|
|
36164
|
+
name: "Web chat capture is not reading the site",
|
|
36165
|
+
category: "config",
|
|
36166
|
+
severity: "medium",
|
|
36167
|
+
definition: JSON.stringify({
|
|
36168
|
+
kind: "web-capture-drift",
|
|
36169
|
+
states: [...WEB_CAPTURE_DRIFT_STATES],
|
|
36170
|
+
minParseFailures: DRIFT_MIN_PARSE_FAILURES
|
|
36171
|
+
})
|
|
36172
|
+
};
|
|
36173
|
+
var STATIC_COPY = {
|
|
36174
|
+
active: { headline: "turns are being observed on this site" },
|
|
36175
|
+
unreported: {
|
|
36176
|
+
// Says "recently" rather than "yet": the store read is bounded to
|
|
36177
|
+
// CAPTURE_STATUS_RECENCY_MS, so this state covers a site nothing has ever
|
|
36178
|
+
// reported for AND one whose last report has aged out. The two are the
|
|
36179
|
+
// same fact to a reader — nobody has confirmed anything lately — and the
|
|
36180
|
+
// copy may not claim the stronger of them.
|
|
36181
|
+
headline: `no report in the last ${String(CAPTURE_STATUS_RECENCY_DAYS)} days \u2014 open the site in Chrome with the extension loaded`
|
|
36182
|
+
},
|
|
36183
|
+
standby: {
|
|
36184
|
+
headline: "this build declares no endpoints for the site, so nothing is observed yet"
|
|
36185
|
+
},
|
|
36186
|
+
unpatched: {
|
|
36187
|
+
// Says what the flags say and no more. `patched` is false both for a tap
|
|
36188
|
+
// that installed and hooked neither transport and for one that never ran
|
|
36189
|
+
// at all — a page reports the same status either way, so the copy may not
|
|
36190
|
+
// assert one of them.
|
|
36191
|
+
headline: "the page tap captured neither fetch nor XHR \u2014 it may not have installed; reload the extension at chrome://extensions"
|
|
36192
|
+
},
|
|
36193
|
+
idle: { headline: "watching; no turn has been observed yet" },
|
|
36194
|
+
blind: {
|
|
36195
|
+
headline: "messages were sent in the page that the network capture never saw",
|
|
36196
|
+
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."
|
|
36197
|
+
},
|
|
36198
|
+
degraded: {
|
|
36199
|
+
headline: "the site's payloads no longer carry the fields the extension reads",
|
|
36200
|
+
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."
|
|
36201
|
+
}
|
|
36202
|
+
};
|
|
36203
|
+
|
|
35799
36204
|
// ../../packages/detections/src/security/redos-probe.ts
|
|
35800
36205
|
var BUDGET_MS = 100;
|
|
35801
36206
|
var EXPONENTIAL_UNITS = [
|
|
@@ -39596,86 +40001,10 @@ function createForwardPolicy(deps) {
|
|
|
39596
40001
|
}
|
|
39597
40002
|
|
|
39598
40003
|
// ../../packages/plugin-runtime/src/attached/gateway.ts
|
|
39599
|
-
|
|
39600
|
-
|
|
39601
|
-
|
|
39602
|
-
return
|
|
39603
|
-
}
|
|
39604
|
-
function ruleCategoryMap(wireRules, localRules) {
|
|
39605
|
-
const map2 = /* @__PURE__ */ new Map();
|
|
39606
|
-
for (const rule of wireRules ?? []) map2.set(rule.id, rule.category);
|
|
39607
|
-
for (const rule of localRules ?? []) map2.set(rule.id, rule.category);
|
|
39608
|
-
for (const pack of bundledDetections()) {
|
|
39609
|
-
for (const rule of pack.rules) map2.set(rule.id, rule.category);
|
|
39610
|
-
}
|
|
39611
|
-
return map2;
|
|
39612
|
-
}
|
|
39613
|
-
function policyKey(policy) {
|
|
39614
|
-
return "ruleId" in policy.target ? `rule:${policy.target.ruleId}` : `category:${policy.target.category}`;
|
|
39615
|
-
}
|
|
39616
|
-
function floorFor(policy, categoryByRuleId) {
|
|
39617
|
-
const category = "category" in policy.target ? policy.target.category : categoryByRuleId.get(policy.target.ruleId);
|
|
39618
|
-
return category === void 0 ? null : DEFAULT_ACTIONS[category];
|
|
39619
|
-
}
|
|
39620
|
-
function mergeRaiseOnly(localPolicies, remotePolicies, categoryByRuleId) {
|
|
39621
|
-
const merged = /* @__PURE__ */ new Map();
|
|
39622
|
-
const disabled = [];
|
|
39623
|
-
const remoteCategoryAction = /* @__PURE__ */ new Map();
|
|
39624
|
-
for (const policy of remotePolicies) {
|
|
39625
|
-
if (!policy.enabled) continue;
|
|
39626
|
-
if (!("category" in policy.target)) continue;
|
|
39627
|
-
if (remoteCategoryAction.has(policy.target.category)) continue;
|
|
39628
|
-
const floor = floorFor(policy, categoryByRuleId);
|
|
39629
|
-
remoteCategoryAction.set(
|
|
39630
|
-
policy.target.category,
|
|
39631
|
-
floor !== null && !isActionAtLeast(policy.action, floor) ? floor : policy.action
|
|
39632
|
-
);
|
|
39633
|
-
}
|
|
39634
|
-
for (const policy of localPolicies) {
|
|
39635
|
-
if (!policy.enabled) {
|
|
39636
|
-
disabled.push(policy);
|
|
39637
|
-
continue;
|
|
39638
|
-
}
|
|
39639
|
-
const key = policyKey(policy);
|
|
39640
|
-
if (merged.has(key)) continue;
|
|
39641
|
-
let remoteFloor = null;
|
|
39642
|
-
if ("ruleId" in policy.target) {
|
|
39643
|
-
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
39644
|
-
if (category !== void 0) remoteFloor = remoteCategoryAction.get(category) ?? null;
|
|
39645
|
-
}
|
|
39646
|
-
merged.set(
|
|
39647
|
-
key,
|
|
39648
|
-
remoteFloor !== null && !isActionAtLeast(policy.action, remoteFloor) ? { ...policy, action: remoteFloor } : policy
|
|
39649
|
-
);
|
|
39650
|
-
}
|
|
39651
|
-
const localCategoryAction = /* @__PURE__ */ new Map();
|
|
39652
|
-
for (const policy of merged.values()) {
|
|
39653
|
-
if ("category" in policy.target) localCategoryAction.set(policy.target.category, policy.action);
|
|
39654
|
-
}
|
|
39655
|
-
for (const policy of remotePolicies) {
|
|
39656
|
-
if (!policy.enabled) {
|
|
39657
|
-
disabled.push(policy);
|
|
39658
|
-
continue;
|
|
39659
|
-
}
|
|
39660
|
-
const key = policyKey(policy);
|
|
39661
|
-
const floor = floorFor(policy, categoryByRuleId);
|
|
39662
|
-
let localFloor = null;
|
|
39663
|
-
if ("ruleId" in policy.target) {
|
|
39664
|
-
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
39665
|
-
if (category !== void 0) localFloor = localCategoryAction.get(category) ?? null;
|
|
39666
|
-
}
|
|
39667
|
-
const effectiveFloor = strongerOf(floor, localFloor);
|
|
39668
|
-
const clamped = effectiveFloor !== null && !isActionAtLeast(policy.action, effectiveFloor) ? { ...policy, action: effectiveFloor } : policy;
|
|
39669
|
-
const existing = merged.get(key);
|
|
39670
|
-
if (existing === void 0) {
|
|
39671
|
-
merged.set(key, clamped);
|
|
39672
|
-
continue;
|
|
39673
|
-
}
|
|
39674
|
-
if (actionRank(clamped.action) > actionRank(existing.action)) {
|
|
39675
|
-
merged.set(key, clamped);
|
|
39676
|
-
}
|
|
39677
|
-
}
|
|
39678
|
-
return [...merged.values(), ...disabled];
|
|
40004
|
+
var bundledRulesFlatCache;
|
|
40005
|
+
function bundledRulesFlat() {
|
|
40006
|
+
bundledRulesFlatCache ??= bundledDetections().flatMap((pack) => pack.rules);
|
|
40007
|
+
return bundledRulesFlatCache;
|
|
39679
40008
|
}
|
|
39680
40009
|
var AttachedDataGateway = class {
|
|
39681
40010
|
constructor(deps) {
|
|
@@ -39995,6 +40324,9 @@ var AttachedDataGateway = class {
|
|
|
39995
40324
|
async readSessionProvider(sessionId) {
|
|
39996
40325
|
return this.deps.local.readSessionProvider(sessionId);
|
|
39997
40326
|
}
|
|
40327
|
+
async readCaptureStatuses() {
|
|
40328
|
+
return this.deps.local.readCaptureStatuses();
|
|
40329
|
+
}
|
|
39998
40330
|
async facets() {
|
|
39999
40331
|
return this.deps.local.facets();
|
|
40000
40332
|
}
|
|
@@ -40077,7 +40409,7 @@ var AttachedDataGateway = class {
|
|
|
40077
40409
|
policies: mergeRaiseOnly(
|
|
40078
40410
|
local.policies,
|
|
40079
40411
|
cached2.policies,
|
|
40080
|
-
ruleCategoryMap(cached2.rules, local.rules)
|
|
40412
|
+
ruleCategoryMap(cached2.rules, local.rules, bundledRulesFlat())
|
|
40081
40413
|
),
|
|
40082
40414
|
customKeywords: [...local.customKeywords, ...cached2.customKeywords],
|
|
40083
40415
|
// TAKEN FROM THE CACHE, unlike the two fields below — and the asymmetry
|
|
@@ -40293,10 +40625,15 @@ import { join as join27 } from "path";
|
|
|
40293
40625
|
// ../../packages/plugin-runtime/src/attached/atomic-publish.ts
|
|
40294
40626
|
import { rename as rename2 } from "fs/promises";
|
|
40295
40627
|
var RETRYABLE = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
|
|
40296
|
-
var
|
|
40628
|
+
var IMMEDIATE_RETRIES = 8;
|
|
40629
|
+
var TIMED_RETRIES = 4;
|
|
40630
|
+
var ATTEMPTS = 1 + IMMEDIATE_RETRIES + TIMED_RETRIES;
|
|
40297
40631
|
var delay = (ms) => new Promise((resolve3) => {
|
|
40298
40632
|
setTimeout(resolve3, ms);
|
|
40299
40633
|
});
|
|
40634
|
+
var yieldToLoop = () => new Promise((resolve3) => {
|
|
40635
|
+
setImmediate(resolve3);
|
|
40636
|
+
});
|
|
40300
40637
|
async function publishByRename(tmp, file2, move = rename2) {
|
|
40301
40638
|
for (let attempt = 1; ; attempt += 1) {
|
|
40302
40639
|
try {
|
|
@@ -40305,7 +40642,7 @@ async function publishByRename(tmp, file2, move = rename2) {
|
|
|
40305
40642
|
} catch (err) {
|
|
40306
40643
|
const code = err.code;
|
|
40307
40644
|
if (attempt >= ATTEMPTS || code === void 0 || !RETRYABLE.has(code)) throw err;
|
|
40308
|
-
await delay(attempt * 10);
|
|
40645
|
+
await (attempt <= IMMEDIATE_RETRIES ? yieldToLoop() : delay((attempt - IMMEDIATE_RETRIES) * 10));
|
|
40309
40646
|
}
|
|
40310
40647
|
}
|
|
40311
40648
|
}
|
|
@@ -40769,6 +41106,9 @@ var StandaloneDataGateway = class {
|
|
|
40769
41106
|
readSessionProvider(sessionId) {
|
|
40770
41107
|
return Promise.resolve(this.db.auditEvents.sessionProvider(sessionId));
|
|
40771
41108
|
}
|
|
41109
|
+
readCaptureStatuses() {
|
|
41110
|
+
return Promise.resolve(this.db.captureStatus.latest(Date.now()));
|
|
41111
|
+
}
|
|
40772
41112
|
facets() {
|
|
40773
41113
|
return Promise.resolve(this.db.facets());
|
|
40774
41114
|
}
|