@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/firstrun.js
CHANGED
|
@@ -20565,7 +20565,17 @@ var UNPRICEABLE_PROVIDERS = Object.freeze([
|
|
|
20565
20565
|
"gateway",
|
|
20566
20566
|
"unknown",
|
|
20567
20567
|
"cli",
|
|
20568
|
-
"api"
|
|
20568
|
+
"api",
|
|
20569
|
+
// The browser extension's native host records these as `llm_call.provider`
|
|
20570
|
+
// for a web-chat turn — the web tool id, deliberately never the vendor id
|
|
20571
|
+
// (`openai`/`anthropic`) the session root carries. Subscription traffic
|
|
20572
|
+
// burns rate-limit budget, not dollar credits, and listing them here is
|
|
20573
|
+
// what keeps that true structurally: a later maintainer who wants to price
|
|
20574
|
+
// web-chat traffic at API rates has to delete this entry first, and meet
|
|
20575
|
+
// the reason on the way, rather than quietly adding one to
|
|
20576
|
+
// PROVIDER_PLATFORM.
|
|
20577
|
+
"chatgpt",
|
|
20578
|
+
"claude-ai"
|
|
20569
20579
|
]);
|
|
20570
20580
|
function platformForProvider(provider) {
|
|
20571
20581
|
return PROVIDER_PLATFORM.get(provider.trim().toLowerCase()) ?? null;
|
|
@@ -20708,7 +20718,12 @@ var HARNESS = {
|
|
|
20708
20718
|
ClaudeDesktop: "claudedesktop",
|
|
20709
20719
|
ChatGpt: "chatgpt",
|
|
20710
20720
|
ClaudeAi: "claudeai",
|
|
20711
|
-
Api: "api"
|
|
20721
|
+
Api: "api",
|
|
20722
|
+
// Not a coding assistant a person drives — an in-process SDK embedded in an
|
|
20723
|
+
// application, so it has no IDE/CLI/desktop/web surface of its own. Carries
|
|
20724
|
+
// the same id as its SOURCE_TOOL counterpart, unlike every capture-side tool
|
|
20725
|
+
// whose wire spelling differs from its display spelling.
|
|
20726
|
+
AiTcSdk: "ai-tc-sdk"
|
|
20712
20727
|
};
|
|
20713
20728
|
var Harness = external_exports.enum(HARNESS).meta({ id: "Harness" });
|
|
20714
20729
|
var SOURCE_TOOL = {
|
|
@@ -20724,9 +20739,15 @@ var SOURCE_TOOL = {
|
|
|
20724
20739
|
// whose tool could not be identified both render through the read side's
|
|
20725
20740
|
// miss path rather than as a harness of their own.
|
|
20726
20741
|
Cli: "cli",
|
|
20727
|
-
Unknown: "unknown"
|
|
20742
|
+
Unknown: "unknown",
|
|
20743
|
+
// The wire id an in-process, request-path SDK stamps on its own structural
|
|
20744
|
+
// rows (`request_decision`) — never a capture of prompt/response/tool text,
|
|
20745
|
+
// since the SDK sits in front of a model call rather than inside a coding
|
|
20746
|
+
// assistant's own hook contract.
|
|
20747
|
+
AiTcSdk: "ai-tc-sdk"
|
|
20728
20748
|
};
|
|
20729
20749
|
var SourceTool = external_exports.enum(SOURCE_TOOL).meta({ id: "SourceTool" });
|
|
20750
|
+
var WebSourceTool = SourceTool.extract(["ChatGpt", "ClaudeAi"]);
|
|
20730
20751
|
var TOOL_TO_HARNESS = {
|
|
20731
20752
|
[SOURCE_TOOL.ClaudeCode]: HARNESS.ClaudeCode,
|
|
20732
20753
|
[SOURCE_TOOL.ClaudeDesktop]: HARNESS.ClaudeDesktop,
|
|
@@ -20735,7 +20756,12 @@ var TOOL_TO_HARNESS = {
|
|
|
20735
20756
|
[SOURCE_TOOL.ChatGpt]: HARNESS.ChatGpt,
|
|
20736
20757
|
[SOURCE_TOOL.Codex]: HARNESS.Codex,
|
|
20737
20758
|
[SOURCE_TOOL.Antigravity]: HARNESS.Antigravity,
|
|
20738
|
-
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi
|
|
20759
|
+
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi,
|
|
20760
|
+
// Wire and display id are the same string here, but the row still belongs:
|
|
20761
|
+
// both vocabularies carry the `AiTcSdk` member, and the join is exactly
|
|
20762
|
+
// their intersection — leaving a shared member out would read as an
|
|
20763
|
+
// uninstrumented tool on both surfaces, which this one is not.
|
|
20764
|
+
[SOURCE_TOOL.AiTcSdk]: HARNESS.AiTcSdk
|
|
20739
20765
|
};
|
|
20740
20766
|
|
|
20741
20767
|
// ../../packages/schema/src/zod/finding.ts
|
|
@@ -20769,7 +20795,8 @@ var FindingProvider = Harness.extract([
|
|
|
20769
20795
|
"ClaudeAi",
|
|
20770
20796
|
"Codex",
|
|
20771
20797
|
"Antigravity",
|
|
20772
|
-
"Api"
|
|
20798
|
+
"Api",
|
|
20799
|
+
"AiTcSdk"
|
|
20773
20800
|
]).meta({ id: "FindingProvider" });
|
|
20774
20801
|
var FindingCategory = external_exports.enum([
|
|
20775
20802
|
"secret",
|
|
@@ -21146,18 +21173,41 @@ var AuditEventType = external_exports.enum([
|
|
|
21146
21173
|
// 'tool_call' is the reconciler's structural row for every call, while
|
|
21147
21174
|
// 'tool_use' exists only where a hook enforced against the arguments.
|
|
21148
21175
|
"tool_use",
|
|
21149
|
-
// One row per model REFUSAL
|
|
21150
|
-
//
|
|
21151
|
-
//
|
|
21152
|
-
//
|
|
21153
|
-
//
|
|
21154
|
-
//
|
|
21176
|
+
// One row per model REFUSAL, across all four seams a prohibited model can be
|
|
21177
|
+
// stopped at: a switch onto it, a turn already running on it, a subagent
|
|
21178
|
+
// spawn asking for it, or a request-path refusal an embedded request-path
|
|
21179
|
+
// SDK makes in-process before the call leaves the application. Which seam
|
|
21180
|
+
// rides `attributes.refusal_seam`, never this member name. A structural row
|
|
21181
|
+
// like the ones above rather than a capture — it carries the model that was
|
|
21182
|
+
// refused and nothing the user typed, because what is worth recording about
|
|
21183
|
+
// a governance decision is the decision, and prompt text is the thing this
|
|
21184
|
+
// product exists to keep from travelling.
|
|
21155
21185
|
"model_refusal",
|
|
21186
|
+
// One row per request-path DECISION: a policy check an embedded request-path
|
|
21187
|
+
// SDK performs in-process before a model call leaves the application, or
|
|
21188
|
+
// against that call's non-streamed response. A structural row like
|
|
21189
|
+
// 'model_refusal' rather than a capture — content-free in the same way:
|
|
21190
|
+
// which side, which seam, what action and which field are decided rides
|
|
21191
|
+
// `attributes`, never this member name, and the matched text itself never
|
|
21192
|
+
// travels.
|
|
21193
|
+
//
|
|
21194
|
+
// A prohibited-model refusal on the request path is deliberately NOT this
|
|
21195
|
+
// member: it stays 'model_refusal' with `refusal_seam: 'request'`, so it
|
|
21196
|
+
// shares one bucket with the plugin's switch/turn/spawn refusals rather
|
|
21197
|
+
// than splitting one governance concept across two event types. This
|
|
21198
|
+
// member carries every OTHER request-path decision.
|
|
21199
|
+
"request_decision",
|
|
21156
21200
|
// One row per config-inventory scan, hung off the session root. It is the
|
|
21157
21201
|
// fact the posture inspection findings reference (findings require an
|
|
21158
21202
|
// audit_event_id), and its started_at is the "scanned Nm ago" the read
|
|
21159
21203
|
// surface renders.
|
|
21160
|
-
"config_scan"
|
|
21204
|
+
"config_scan",
|
|
21205
|
+
// One row per reported browser-extension capture status, hung off the web
|
|
21206
|
+
// session root. The durable home of what one tab's network interception
|
|
21207
|
+
// is doing — a write-through of the native host's in-memory tracker, so a
|
|
21208
|
+
// second process (aka extension status) and a restarted host both have
|
|
21209
|
+
// somewhere to read it back from.
|
|
21210
|
+
"capture_status"
|
|
21161
21211
|
]).meta({ id: "AuditEventType" });
|
|
21162
21212
|
var AttributeBag = external_exports.record(external_exports.string(), external_exports.unknown());
|
|
21163
21213
|
var HostAttributes = external_exports.object({
|
|
@@ -21317,6 +21367,20 @@ var CaptureAttributes = external_exports.object({
|
|
|
21317
21367
|
// repeated rather than referenced because a store reader opens this file.
|
|
21318
21368
|
redact_degraded_to: ActionTaken.optional()
|
|
21319
21369
|
}).catchall(external_exports.unknown());
|
|
21370
|
+
var CaptureStatusAttributes = external_exports.object({
|
|
21371
|
+
source_tool: external_exports.string().optional(),
|
|
21372
|
+
patched: external_exports.boolean().optional(),
|
|
21373
|
+
live: external_exports.boolean().optional(),
|
|
21374
|
+
blind: external_exports.boolean().optional(),
|
|
21375
|
+
sends_seen_dom: external_exports.number().int().nonnegative().optional(),
|
|
21376
|
+
exchanges_seen_net: external_exports.number().int().nonnegative().optional(),
|
|
21377
|
+
parse_failures: external_exports.number().int().nonnegative().optional(),
|
|
21378
|
+
unparsed_bodies: external_exports.number().int().nonnegative().optional(),
|
|
21379
|
+
shape_misses: external_exports.array(external_exports.string()).optional(),
|
|
21380
|
+
conversation_endpoints: external_exports.number().int().nonnegative().optional(),
|
|
21381
|
+
closed: external_exports.boolean().optional(),
|
|
21382
|
+
enforcement: external_exports.string().optional()
|
|
21383
|
+
}).catchall(external_exports.unknown());
|
|
21320
21384
|
var ToolCallInspection = external_exports.object({
|
|
21321
21385
|
ruleId: external_exports.string().min(1),
|
|
21322
21386
|
ruleName: external_exports.string(),
|
|
@@ -22176,6 +22240,30 @@ var AttachedCredential = external_exports.object({
|
|
|
22176
22240
|
keyPrefix: external_exports.string().min(1).max(16).optional(),
|
|
22177
22241
|
mintedAt: external_exports.iso.datetime().optional()
|
|
22178
22242
|
});
|
|
22243
|
+
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
22244
|
+
function unsafeEndpointReason(endpoint) {
|
|
22245
|
+
let parsed2;
|
|
22246
|
+
try {
|
|
22247
|
+
parsed2 = new URL(endpoint);
|
|
22248
|
+
} catch {
|
|
22249
|
+
return "unparseable";
|
|
22250
|
+
}
|
|
22251
|
+
if (parsed2.username !== "" || parsed2.password !== "") return "userinfo";
|
|
22252
|
+
if (parsed2.search !== "" || parsed2.hash !== "") return "query-or-fragment";
|
|
22253
|
+
if (parsed2.protocol === "https:") return null;
|
|
22254
|
+
return parsed2.protocol === "http:" && LOOPBACK_HOSTS.has(parsed2.hostname) ? null : "insecure";
|
|
22255
|
+
}
|
|
22256
|
+
function isSafeEndpoint(endpoint) {
|
|
22257
|
+
return unsafeEndpointReason(endpoint) === null;
|
|
22258
|
+
}
|
|
22259
|
+
function originOnly(endpoint) {
|
|
22260
|
+
try {
|
|
22261
|
+
const parsed2 = new URL(endpoint);
|
|
22262
|
+
return `${parsed2.protocol}//${parsed2.host}`;
|
|
22263
|
+
} catch {
|
|
22264
|
+
return "(unparseable endpoint)";
|
|
22265
|
+
}
|
|
22266
|
+
}
|
|
22179
22267
|
var MAX_DATE_MS = 253402300799999;
|
|
22180
22268
|
var MAX_INT4 = 2147483647;
|
|
22181
22269
|
var StorePosturePack = external_exports.object({
|
|
@@ -22330,6 +22418,11 @@ var RemoteFailureKind = external_exports.enum([
|
|
|
22330
22418
|
"rejected",
|
|
22331
22419
|
"unreachable"
|
|
22332
22420
|
]);
|
|
22421
|
+
var ControlPlaneFailure = RemoteFailureKind.extract([
|
|
22422
|
+
"unauthorized",
|
|
22423
|
+
"forbidden",
|
|
22424
|
+
"unreachable"
|
|
22425
|
+
]);
|
|
22333
22426
|
var AttachDeviceRequest = external_exports.object({
|
|
22334
22427
|
// This machine's own continuity id, so re-attaching ROTATES the credential
|
|
22335
22428
|
// on one machine record instead of producing a second one. Client-minted
|
|
@@ -22869,7 +22962,12 @@ var EventMetadata = external_exports.object({
|
|
|
22869
22962
|
// in — set by the browser extension's network capture so a stored `response`
|
|
22870
22963
|
// row can be joined to the `llm_call` leaf describing the same turn. Absent
|
|
22871
22964
|
// on every other capture path, which has no such id.
|
|
22872
|
-
|
|
22965
|
+
//
|
|
22966
|
+
// Non-empty for the reason WebExchange.messageId is: it is the join key, and
|
|
22967
|
+
// a blank one matches no `llm_call` leaf. That refusal reaches only the
|
|
22968
|
+
// places an event is PARSED; the local write path types the event and parses
|
|
22969
|
+
// nothing, which is why `toCaptureAttributes` omits a blank one separately.
|
|
22970
|
+
messageId: external_exports.string().min(1).optional(),
|
|
22873
22971
|
conversationId: external_exports.string().optional(),
|
|
22874
22972
|
// How long THIS capture's inspection blocked its caller, in whole
|
|
22875
22973
|
// milliseconds — the plugin's own added latency, NOT the LLM call it sat in
|
|
@@ -23711,6 +23809,85 @@ function policyIdIsReversible(policyId) {
|
|
|
23711
23809
|
var DEFAULT_ACTIONS = Object.fromEntries(
|
|
23712
23810
|
DetectionCategory.options.map((c) => [c, builtinPolicyToAction(severityFloorPolicy(c))])
|
|
23713
23811
|
);
|
|
23812
|
+
function ruleCategoryMap(wireRules, localRules, compiledRules) {
|
|
23813
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
23814
|
+
for (const rule of wireRules ?? []) map2.set(rule.id, rule.category);
|
|
23815
|
+
for (const rule of localRules ?? []) map2.set(rule.id, rule.category);
|
|
23816
|
+
for (const rule of compiledRules) map2.set(rule.id, rule.category);
|
|
23817
|
+
return map2;
|
|
23818
|
+
}
|
|
23819
|
+
function policyKey(policy) {
|
|
23820
|
+
return "ruleId" in policy.target ? `rule:${policy.target.ruleId}` : `category:${policy.target.category}`;
|
|
23821
|
+
}
|
|
23822
|
+
function floorFor(policy, categoryByRuleId) {
|
|
23823
|
+
const category = "category" in policy.target ? policy.target.category : categoryByRuleId.get(policy.target.ruleId);
|
|
23824
|
+
return category === void 0 ? null : DEFAULT_ACTIONS[category];
|
|
23825
|
+
}
|
|
23826
|
+
function strongerOf(a, b) {
|
|
23827
|
+
if (a === null) return b;
|
|
23828
|
+
if (b === null) return a;
|
|
23829
|
+
return strongerAction(a, b);
|
|
23830
|
+
}
|
|
23831
|
+
function mergeRaiseOnly(localPolicies, remotePolicies, categoryByRuleId) {
|
|
23832
|
+
const merged = /* @__PURE__ */ new Map();
|
|
23833
|
+
const disabled = [];
|
|
23834
|
+
const remoteCategoryAction = /* @__PURE__ */ new Map();
|
|
23835
|
+
for (const policy of remotePolicies) {
|
|
23836
|
+
if (!policy.enabled) continue;
|
|
23837
|
+
if (!("category" in policy.target)) continue;
|
|
23838
|
+
if (remoteCategoryAction.has(policy.target.category)) continue;
|
|
23839
|
+
const floor = floorFor(policy, categoryByRuleId);
|
|
23840
|
+
remoteCategoryAction.set(
|
|
23841
|
+
policy.target.category,
|
|
23842
|
+
floor !== null && !isActionAtLeast(policy.action, floor) ? floor : policy.action
|
|
23843
|
+
);
|
|
23844
|
+
}
|
|
23845
|
+
for (const policy of localPolicies) {
|
|
23846
|
+
if (!policy.enabled) {
|
|
23847
|
+
disabled.push(policy);
|
|
23848
|
+
continue;
|
|
23849
|
+
}
|
|
23850
|
+
const key = policyKey(policy);
|
|
23851
|
+
if (merged.has(key)) continue;
|
|
23852
|
+
let remoteFloor = null;
|
|
23853
|
+
if ("ruleId" in policy.target) {
|
|
23854
|
+
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
23855
|
+
if (category !== void 0) remoteFloor = remoteCategoryAction.get(category) ?? null;
|
|
23856
|
+
}
|
|
23857
|
+
merged.set(
|
|
23858
|
+
key,
|
|
23859
|
+
remoteFloor !== null && !isActionAtLeast(policy.action, remoteFloor) ? { ...policy, action: remoteFloor } : policy
|
|
23860
|
+
);
|
|
23861
|
+
}
|
|
23862
|
+
const localCategoryAction = /* @__PURE__ */ new Map();
|
|
23863
|
+
for (const policy of merged.values()) {
|
|
23864
|
+
if ("category" in policy.target) localCategoryAction.set(policy.target.category, policy.action);
|
|
23865
|
+
}
|
|
23866
|
+
for (const policy of remotePolicies) {
|
|
23867
|
+
if (!policy.enabled) {
|
|
23868
|
+
disabled.push(policy);
|
|
23869
|
+
continue;
|
|
23870
|
+
}
|
|
23871
|
+
const key = policyKey(policy);
|
|
23872
|
+
const floor = floorFor(policy, categoryByRuleId);
|
|
23873
|
+
let localFloor = null;
|
|
23874
|
+
if ("ruleId" in policy.target) {
|
|
23875
|
+
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
23876
|
+
if (category !== void 0) localFloor = localCategoryAction.get(category) ?? null;
|
|
23877
|
+
}
|
|
23878
|
+
const effectiveFloor = strongerOf(floor, localFloor);
|
|
23879
|
+
const clamped = effectiveFloor !== null && !isActionAtLeast(policy.action, effectiveFloor) ? { ...policy, action: effectiveFloor } : policy;
|
|
23880
|
+
const existing = merged.get(key);
|
|
23881
|
+
if (existing === void 0) {
|
|
23882
|
+
merged.set(key, clamped);
|
|
23883
|
+
continue;
|
|
23884
|
+
}
|
|
23885
|
+
if (actionRank(clamped.action) > actionRank(existing.action)) {
|
|
23886
|
+
merged.set(key, clamped);
|
|
23887
|
+
}
|
|
23888
|
+
}
|
|
23889
|
+
return [...merged.values(), ...disabled];
|
|
23890
|
+
}
|
|
23714
23891
|
var BUILTIN_POLICIES = Object.fromEntries(
|
|
23715
23892
|
KNOWN_BUILTIN_IDS.map((id) => [id, { id, ...BUILTIN_POLICY_SPECS[id] }])
|
|
23716
23893
|
);
|
|
@@ -23933,6 +24110,18 @@ var HistorySyncConsent = external_exports.object({
|
|
|
23933
24110
|
payloadVersion: external_exports.number().int().positive(),
|
|
23934
24111
|
endpoint: external_exports.string()
|
|
23935
24112
|
});
|
|
24113
|
+
var WebChatCaptureConsent = external_exports.object({
|
|
24114
|
+
acknowledgedAt: external_exports.iso.datetime(),
|
|
24115
|
+
version: external_exports.number().int().positive()
|
|
24116
|
+
});
|
|
24117
|
+
var WebChatResponseCapture = external_exports.enum(["with-findings", "always", "never"]);
|
|
24118
|
+
var WebChatCapture = external_exports.object({
|
|
24119
|
+
responses: WebChatResponseCapture.default("with-findings"),
|
|
24120
|
+
account: external_exports.boolean().default(false),
|
|
24121
|
+
// Absent until granted. Presence alone does not authorize anything — see
|
|
24122
|
+
// isWebChatCaptureConsentValid.
|
|
24123
|
+
consent: WebChatCaptureConsent.optional()
|
|
24124
|
+
});
|
|
23936
24125
|
var BODY_RETENTION_DEFAULT_DAYS = 30;
|
|
23937
24126
|
var BodyRetention = external_exports.object({
|
|
23938
24127
|
enabled: external_exports.boolean().default(false),
|
|
@@ -23991,6 +24180,16 @@ var WorkspaceSettings = external_exports.object({
|
|
|
23991
24180
|
// both widenings. Absent until granted, and a grant for a different endpoint
|
|
23992
24181
|
// or an older payload no longer counts.
|
|
23993
24182
|
historySyncConsent: HistorySyncConsent.optional(),
|
|
24183
|
+
// What the browser extension may record from a web chat, and the grant that
|
|
24184
|
+
// authorizes it. Absent until the user answers: recording something that was
|
|
24185
|
+
// never recorded before is never an assumed grant on upgrade, so the whole
|
|
24186
|
+
// block is optional rather than defaulted in. What an absent block means is
|
|
24187
|
+
// webChatCaptureOf's answer, in one place.
|
|
24188
|
+
//
|
|
24189
|
+
// Enforcement is NOT gated on this. A machine that has never answered still
|
|
24190
|
+
// blocks, redacts and warns on what a user sends; the grant covers what is
|
|
24191
|
+
// written down.
|
|
24192
|
+
webChatCapture: WebChatCapture.optional(),
|
|
23994
24193
|
// Local body expiry (see BodyRetention). Off until switched on; expiring a
|
|
23995
24194
|
// body never removes the row or its findings.
|
|
23996
24195
|
bodyRetention: BodyRetention.default({
|
|
@@ -24098,7 +24297,10 @@ function toCaptureAttributes(event) {
|
|
|
24098
24297
|
// `.catchall(z.unknown())` carries the long tail.
|
|
24099
24298
|
...metadata?.model !== void 0 ? { model: metadata.model } : {},
|
|
24100
24299
|
...metadata?.turnIndex !== void 0 ? { turn_index: metadata.turnIndex } : {},
|
|
24101
|
-
|
|
24300
|
+
// A blank id is omitted rather than stored: it is a join key and `''` joins
|
|
24301
|
+
// nothing. This runs on the local write path, which types the event but
|
|
24302
|
+
// never parses it, so EventMetadata's own `.min(1)` does not reach here.
|
|
24303
|
+
...metadata?.messageId !== void 0 && metadata.messageId !== "" ? { message_id: metadata.messageId } : {},
|
|
24102
24304
|
...metadata?.conversationId !== void 0 ? { conversation_id: metadata.conversationId } : {}
|
|
24103
24305
|
};
|
|
24104
24306
|
}
|
|
@@ -24472,12 +24674,14 @@ var RecommendedActionIdParam = external_exports.object({ id: external_exports.st
|
|
|
24472
24674
|
// ../../packages/schema/src/zod/settings-action.ts
|
|
24473
24675
|
var HistorySyncConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "HistorySyncConsentChoice" });
|
|
24474
24676
|
var ModelJudgeConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "ModelJudgeConsentChoice" });
|
|
24677
|
+
var WebChatCaptureConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "WebChatCaptureConsentChoice" });
|
|
24475
24678
|
var SaveSettingsInput = external_exports.object({
|
|
24476
24679
|
historicalAccess: external_exports.string(),
|
|
24477
24680
|
modelJudgeConsent: ModelJudgeConsentChoice,
|
|
24478
24681
|
historySyncConsent: HistorySyncConsentChoice,
|
|
24479
24682
|
vaultConsent: external_exports.string(),
|
|
24480
24683
|
vaultInlineReveal: external_exports.string(),
|
|
24684
|
+
webChatCaptureConsent: WebChatCaptureConsentChoice,
|
|
24481
24685
|
// Widened to `string` like its neighbours rather than typed as
|
|
24482
24686
|
// `RedactFallback`, on this module's own layering rule: shape here, VALUE at
|
|
24483
24687
|
// the call site, so the domain check receives the type it was written for.
|
|
@@ -24692,11 +24896,24 @@ var WebExchange = external_exports.object({
|
|
|
24692
24896
|
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
24693
24897
|
toolCalls: external_exports.array(WebToolCall).default([]),
|
|
24694
24898
|
// Absent when the adapter recovered no text. Capped by the caller at
|
|
24695
|
-
// RESPONSE_TEXT_MAX_BYTES
|
|
24696
|
-
//
|
|
24899
|
+
// RESPONSE_TEXT_MAX_BYTES, so a short capture is never mistaken for a short
|
|
24900
|
+
// reply.
|
|
24697
24901
|
responseText: external_exports.string().optional(),
|
|
24902
|
+
// The stored text is short of the reply. It does NOT say which of the two
|
|
24903
|
+
// ceilings on this path cut it: the caller applies its own cap on the raw
|
|
24904
|
+
// bytes it reads off the wire, which can be reached by a stream whose
|
|
24905
|
+
// recovered text stays well under RESPONSE_TEXT_MAX_BYTES, and applies that
|
|
24906
|
+
// one to the text. A reader cannot tell them apart, and nothing downstream
|
|
24907
|
+
// should branch as though it could.
|
|
24698
24908
|
truncated: external_exports.boolean().default(false)
|
|
24699
24909
|
});
|
|
24910
|
+
var WebEnforcementState = external_exports.enum([
|
|
24911
|
+
"watching",
|
|
24912
|
+
"composer-only",
|
|
24913
|
+
"button-only",
|
|
24914
|
+
"unattached",
|
|
24915
|
+
"unknown"
|
|
24916
|
+
]);
|
|
24700
24917
|
var RESPONSE_TEXT_MAX_BYTES = 2 * 1024 * 1024;
|
|
24701
24918
|
var WebCaptureStatus = external_exports.object({
|
|
24702
24919
|
patched: external_exports.boolean(),
|
|
@@ -24708,8 +24925,66 @@ var WebCaptureStatus = external_exports.object({
|
|
|
24708
24925
|
unparsedBodies: external_exports.number().int().nonnegative(),
|
|
24709
24926
|
// The adapter-declared JSON key paths that were absent from a real payload —
|
|
24710
24927
|
// the earliest signal that a site's contract moved.
|
|
24711
|
-
shapeMisses: external_exports.array(external_exports.string()).default([])
|
|
24712
|
-
|
|
24928
|
+
shapeMisses: external_exports.array(external_exports.string()).default([]),
|
|
24929
|
+
// How many `kind: 'conversation'` endpoints the reporting tab's adapter
|
|
24930
|
+
// compiled. Zero means this build declares none for the site, so observing
|
|
24931
|
+
// nothing is the design rather than a fault — the one fact that separates a
|
|
24932
|
+
// site nobody has surveyed yet from one whose contract moved. Defaulted so a
|
|
24933
|
+
// build predating the field is read as declaring nothing rather than refused.
|
|
24934
|
+
conversationEndpoints: external_exports.number().int().nonnegative().default(0),
|
|
24935
|
+
// The document that sent this report is going away. The bridge sets it on
|
|
24936
|
+
// its `pagehide` report and nowhere else.
|
|
24937
|
+
//
|
|
24938
|
+
// A property of the REPORT rather than of capture health, which is why
|
|
24939
|
+
// nothing in `deriveWebCaptureState` reads it and why it stays out of the
|
|
24940
|
+
// bridge's own report signature — a closing tab's last word must not be
|
|
24941
|
+
// suppressed for carrying the same health as the report before it. What
|
|
24942
|
+
// reads it is the per-site fold: a document that said it was unloading stops
|
|
24943
|
+
// voting on the site's state, so the reload the `blind` remediation asks for
|
|
24944
|
+
// can actually clear the verdict it was shown. A document that dies without
|
|
24945
|
+
// sending one is covered by CAPTURE_STATUS_DOCUMENT_QUIET_MS instead.
|
|
24946
|
+
//
|
|
24947
|
+
// Defaulted so a build predating the field reads as a document that never
|
|
24948
|
+
// said it was closing — which keeps it voting, the same as every report that
|
|
24949
|
+
// is not a final one.
|
|
24950
|
+
closed: external_exports.boolean().default(false),
|
|
24951
|
+
// What the DOM enforcement path is doing, which none of the counters above
|
|
24952
|
+
// can say: `sendsSeenDom` rises only once a send has COMPLETED, so a tab
|
|
24953
|
+
// whose watcher never bound reports zero exactly like a tab nobody typed in.
|
|
24954
|
+
// Defaulted to 'unknown' rather than 'watching' so a status from a build
|
|
24955
|
+
// predating the field is not read as reporting a healthy one.
|
|
24956
|
+
enforcement: WebEnforcementState.default("unknown")
|
|
24957
|
+
});
|
|
24958
|
+
function webCaptureStatusObservedTurnPath(status) {
|
|
24959
|
+
if (!status.patched) return true;
|
|
24960
|
+
if (status.conversationEndpoints === 0) return true;
|
|
24961
|
+
return status.blind || status.shapeMisses.length > 0 || status.parseFailures > 0 || status.unparsedBodies > 0 || status.exchangesSeenNet > 0;
|
|
24962
|
+
}
|
|
24963
|
+
function pickReportedCaptureStatus(candidates) {
|
|
24964
|
+
return candidates.find((c) => webCaptureStatusObservedTurnPath(c.status)) ?? candidates[0];
|
|
24965
|
+
}
|
|
24966
|
+
var CAPTURE_STATUS_RECENCY_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
24967
|
+
var CAPTURE_STATUS_RECENCY_DAYS = CAPTURE_STATUS_RECENCY_MS / (24 * 60 * 60 * 1e3);
|
|
24968
|
+
var CAPTURE_STATUS_DOCUMENT_QUIET_MS = 12 * 60 * 60 * 1e3;
|
|
24969
|
+
function fromCaptureStatusAttributes(bag) {
|
|
24970
|
+
const parsedBag = CaptureStatusAttributes.safeParse(bag);
|
|
24971
|
+
if (!parsedBag.success) return null;
|
|
24972
|
+
const b = parsedBag.data;
|
|
24973
|
+
const parsedStatus = WebCaptureStatus.safeParse({
|
|
24974
|
+
patched: b.patched,
|
|
24975
|
+
live: b.live,
|
|
24976
|
+
blind: b.blind,
|
|
24977
|
+
sendsSeenDom: b.sends_seen_dom,
|
|
24978
|
+
exchangesSeenNet: b.exchanges_seen_net,
|
|
24979
|
+
parseFailures: b.parse_failures,
|
|
24980
|
+
unparsedBodies: b.unparsed_bodies,
|
|
24981
|
+
shapeMisses: b.shape_misses,
|
|
24982
|
+
conversationEndpoints: b.conversation_endpoints,
|
|
24983
|
+
closed: b.closed,
|
|
24984
|
+
enforcement: b.enforcement
|
|
24985
|
+
});
|
|
24986
|
+
return parsedStatus.success ? parsedStatus.data : null;
|
|
24987
|
+
}
|
|
24713
24988
|
|
|
24714
24989
|
// ../../packages/persistence/src/paths.ts
|
|
24715
24990
|
import {
|
|
@@ -24820,17 +25095,6 @@ function publishByLink(tmp, file2, data) {
|
|
|
24820
25095
|
function controlPlaneCredentialPath(settingsDir2) {
|
|
24821
25096
|
return join2(settingsDir2, ATTACHED_CREDENTIAL_FILENAME);
|
|
24822
25097
|
}
|
|
24823
|
-
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
24824
|
-
function isSafeEndpoint(endpoint) {
|
|
24825
|
-
let parsed2;
|
|
24826
|
-
try {
|
|
24827
|
-
parsed2 = new URL(endpoint);
|
|
24828
|
-
} catch {
|
|
24829
|
-
return false;
|
|
24830
|
-
}
|
|
24831
|
-
if (parsed2.protocol === "https:") return true;
|
|
24832
|
-
return parsed2.protocol === "http:" && LOOPBACK_HOSTS.has(parsed2.hostname);
|
|
24833
|
-
}
|
|
24834
25098
|
function repairOrRefuseMode(file2) {
|
|
24835
25099
|
const link = lstatSync2(file2, { throwIfNoEntry: false });
|
|
24836
25100
|
if (link === void 0) return "absent";
|
|
@@ -26613,7 +26877,7 @@ var SESSION_ROOT = `event_type = 'session'`;
|
|
|
26613
26877
|
var HAS_ACTIVITY = `EXISTS (
|
|
26614
26878
|
SELECT 1 FROM audit_events c
|
|
26615
26879
|
WHERE c.root_session_id = audit_events.id
|
|
26616
|
-
AND c.event_type NOT IN ('hook', 'config_scan'))`;
|
|
26880
|
+
AND c.event_type NOT IN ('hook', 'config_scan', 'capture_status'))`;
|
|
26617
26881
|
var SqliteActivityRepository = class {
|
|
26618
26882
|
constructor(db, now = () => Date.now()) {
|
|
26619
26883
|
this.db = db;
|
|
@@ -26640,10 +26904,10 @@ var SqliteActivityRepository = class {
|
|
|
26640
26904
|
SELECT id FROM audit_events WHERE event_type = 'session' AND started_at >= ?
|
|
26641
26905
|
UNION
|
|
26642
26906
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_started_at
|
|
26643
|
-
WHERE started_at >= ?
|
|
26907
|
+
WHERE started_at >= ? AND event_type <> 'capture_status'
|
|
26644
26908
|
UNION
|
|
26645
26909
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_ended_at
|
|
26646
|
-
WHERE ended_at >= ?)`,
|
|
26910
|
+
WHERE ended_at >= ? AND event_type <> 'capture_status')`,
|
|
26647
26911
|
[liveThreshold, liveThreshold, liveThreshold]
|
|
26648
26912
|
);
|
|
26649
26913
|
const toolCallsToday = countScalar(
|
|
@@ -27050,7 +27314,10 @@ var SqliteAuditEventsRepository = class {
|
|
|
27050
27314
|
attributes = excluded.attributes,
|
|
27051
27315
|
ended_at = excluded.ended_at
|
|
27052
27316
|
WHERE COALESCE(json_extract(excluded.attributes, '$.output_tokens'), 0)
|
|
27053
|
-
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27317
|
+
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27318
|
+
OR (json_extract(excluded.attributes, '$.usage_source') IS NOT NULL
|
|
27319
|
+
AND json_extract(excluded.attributes, '$.output_tokens') IS NULL
|
|
27320
|
+
AND excluded.attributes <> audit_events.attributes)`
|
|
27054
27321
|
);
|
|
27055
27322
|
this.upsertSessionRootStmt = db.prepare(
|
|
27056
27323
|
`INSERT OR IGNORE INTO audit_events
|
|
@@ -27318,6 +27585,87 @@ var SqliteBodyRetentionRepository = class {
|
|
|
27318
27585
|
}
|
|
27319
27586
|
};
|
|
27320
27587
|
|
|
27588
|
+
// ../../packages/persistence/src/repositories/capture-status.ts
|
|
27589
|
+
var STATUS_LOOKBACK_ROWS = 128;
|
|
27590
|
+
var SqliteCaptureStatusRepository = class {
|
|
27591
|
+
constructor(db) {
|
|
27592
|
+
this.db = db;
|
|
27593
|
+
this.recentStmt = db.prepare(
|
|
27594
|
+
`SELECT a.started_at AS startedAt,
|
|
27595
|
+
a.attributes AS attributes,
|
|
27596
|
+
a.root_session_id AS rootSessionId
|
|
27597
|
+
FROM audit_events a
|
|
27598
|
+
WHERE a.event_type = 'capture_status'
|
|
27599
|
+
AND a.source_tool = ?
|
|
27600
|
+
AND a.started_at >= ?
|
|
27601
|
+
ORDER BY a.started_at DESC, a.id DESC
|
|
27602
|
+
LIMIT ?`
|
|
27603
|
+
);
|
|
27604
|
+
}
|
|
27605
|
+
db;
|
|
27606
|
+
recentStmt;
|
|
27607
|
+
/**
|
|
27608
|
+
* Every document that reported for a site, in registry order by site, from
|
|
27609
|
+
* the last `CAPTURE_STATUS_RECENCY_MS`.
|
|
27610
|
+
*
|
|
27611
|
+
* SEVERAL per site, not one: a browser is many documents and each reports
|
|
27612
|
+
* for itself, so one row per site is a choice about which of them a user
|
|
27613
|
+
* sees — and the newest is the wrong one, since a healthy tab writing a
|
|
27614
|
+
* fresh report would hide a drifting tab's verdict, which is the whole
|
|
27615
|
+
* reason these rows exist. The pick WITHIN a document is made here (the
|
|
27616
|
+
* unchanged `pickReportedCaptureStatus`, over that document's own rows);
|
|
27617
|
+
* choosing between documents belongs where the state semantics live, and
|
|
27618
|
+
* that is `reportedCaptureDocumentForSite` in `@akasecurity/detections` —
|
|
27619
|
+
* this package may not import it.
|
|
27620
|
+
*
|
|
27621
|
+
* `now` is a required argument rather than a `Date.now()` read, so a caller
|
|
27622
|
+
* that already holds a render instant passes THAT one and a test can drive
|
|
27623
|
+
* the window without moving the wall clock.
|
|
27624
|
+
*
|
|
27625
|
+
* A site whose reports have all aged out contributes nothing, so it derives
|
|
27626
|
+
* to `unreported`. That is the point: nothing but the browser extension ever
|
|
27627
|
+
* writes these rows, so an uninstalled extension's last verdict would
|
|
27628
|
+
* otherwise stand as a live claim for ever with no later report able to
|
|
27629
|
+
* clear it.
|
|
27630
|
+
*/
|
|
27631
|
+
latest(now) {
|
|
27632
|
+
const since = now - CAPTURE_STATUS_RECENCY_MS;
|
|
27633
|
+
const documents = [];
|
|
27634
|
+
for (const tool of WebSourceTool.options) {
|
|
27635
|
+
const rows = /* @__PURE__ */ new Map();
|
|
27636
|
+
const lastWord = /* @__PURE__ */ new Map();
|
|
27637
|
+
for (const row of allRows(this.recentStmt, [
|
|
27638
|
+
tool,
|
|
27639
|
+
since,
|
|
27640
|
+
STATUS_LOOKBACK_ROWS
|
|
27641
|
+
])) {
|
|
27642
|
+
const status = fromCaptureStatusAttributes(parseJsonObject(row.attributes));
|
|
27643
|
+
if (status === null) continue;
|
|
27644
|
+
const record2 = { tool, observedAt: epochMillisToIso(row.startedAt), status };
|
|
27645
|
+
const group = rows.get(row.rootSessionId);
|
|
27646
|
+
if (group === void 0) {
|
|
27647
|
+
rows.set(row.rootSessionId, [record2]);
|
|
27648
|
+
lastWord.set(row.rootSessionId, { at: record2.observedAt, closed: status.closed });
|
|
27649
|
+
} else {
|
|
27650
|
+
group.push(record2);
|
|
27651
|
+
}
|
|
27652
|
+
}
|
|
27653
|
+
for (const [root, candidates] of rows) {
|
|
27654
|
+
const picked = pickReportedCaptureStatus(candidates);
|
|
27655
|
+
const last = lastWord.get(root);
|
|
27656
|
+
if (picked === void 0 || last === void 0) continue;
|
|
27657
|
+
documents.push({
|
|
27658
|
+
...picked,
|
|
27659
|
+
...root === null ? {} : { rootSessionId: root },
|
|
27660
|
+
lastReportAt: last.at,
|
|
27661
|
+
closed: last.closed
|
|
27662
|
+
});
|
|
27663
|
+
}
|
|
27664
|
+
}
|
|
27665
|
+
return documents;
|
|
27666
|
+
}
|
|
27667
|
+
};
|
|
27668
|
+
|
|
27321
27669
|
// ../../packages/persistence/src/repositories/classified-data.ts
|
|
27322
27670
|
var SqliteClassifiedDataRepository = class {
|
|
27323
27671
|
constructor(db) {
|
|
@@ -32895,6 +33243,7 @@ function openAndInitialize(file2, base, skipTags) {
|
|
|
32895
33243
|
activity: new SqliteActivityRepository(db),
|
|
32896
33244
|
sourceProject: new SqliteSourceProjectRepository(db),
|
|
32897
33245
|
auditEvents: new SqliteAuditEventsRepository(db),
|
|
33246
|
+
captureStatus: new SqliteCaptureStatusRepository(db),
|
|
32898
33247
|
classifiedData: new SqliteClassifiedDataRepository(db),
|
|
32899
33248
|
inspectionDefinitions: new SqliteInspectionDefinitionsRepository(db),
|
|
32900
33249
|
inspectionFindings: new SqliteInspectionFindingsRepository(db),
|
|
@@ -32935,6 +33284,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
32935
33284
|
activity,
|
|
32936
33285
|
sourceProject,
|
|
32937
33286
|
auditEvents,
|
|
33287
|
+
captureStatus,
|
|
32938
33288
|
classifiedData,
|
|
32939
33289
|
inspectionDefinitions,
|
|
32940
33290
|
inspectionFindings,
|
|
@@ -33152,6 +33502,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
33152
33502
|
activity,
|
|
33153
33503
|
sourceProject,
|
|
33154
33504
|
auditEvents,
|
|
33505
|
+
captureStatus,
|
|
33155
33506
|
classifiedData,
|
|
33156
33507
|
inspectionDefinitions,
|
|
33157
33508
|
inspectionFindings,
|
|
@@ -33286,11 +33637,6 @@ function readFingerprintKey(dataDir2) {
|
|
|
33286
33637
|
// ../../packages/persistence/src/forward-health.ts
|
|
33287
33638
|
import { readFileSync as readFileSync7 } from "fs";
|
|
33288
33639
|
import { join as join9 } from "path";
|
|
33289
|
-
var FAILURES = /* @__PURE__ */ new Set([
|
|
33290
|
-
"unauthorized",
|
|
33291
|
-
"forbidden",
|
|
33292
|
-
"unreachable"
|
|
33293
|
-
]);
|
|
33294
33640
|
var BREAKER_COOLDOWN_MS = 3e4;
|
|
33295
33641
|
function parseForwardHealth(raw, nowMs) {
|
|
33296
33642
|
try {
|
|
@@ -33299,7 +33645,8 @@ function parseForwardHealth(raw, nowMs) {
|
|
|
33299
33645
|
const record2 = parsed2;
|
|
33300
33646
|
const failures = typeof record2.consecutiveFailures === "number" && record2.consecutiveFailures >= 0 ? record2.consecutiveFailures : 0;
|
|
33301
33647
|
const openedAtMs = typeof record2.openedAtMs === "number" && Number.isFinite(record2.openedAtMs) && record2.openedAtMs <= nowMs ? record2.openedAtMs : null;
|
|
33302
|
-
const
|
|
33648
|
+
const parsedFailure = ControlPlaneFailure.safeParse(record2.lastFailure);
|
|
33649
|
+
const lastFailure = parsedFailure.success ? parsedFailure.data : null;
|
|
33303
33650
|
return { consecutiveFailures: failures, openedAtMs, lastFailure };
|
|
33304
33651
|
} catch {
|
|
33305
33652
|
return null;
|
|
@@ -33389,6 +33736,12 @@ var RemoteRequestInvalid = class extends Error {
|
|
|
33389
33736
|
}
|
|
33390
33737
|
cause;
|
|
33391
33738
|
};
|
|
33739
|
+
var RemoteEndpointRefused = class extends Error {
|
|
33740
|
+
constructor(endpoint) {
|
|
33741
|
+
super(`refusing to talk to an unsafe control-plane endpoint: ${originOnly(endpoint)}`);
|
|
33742
|
+
this.name = "RemoteEndpointRefused";
|
|
33743
|
+
}
|
|
33744
|
+
};
|
|
33392
33745
|
var RemoteResponseInvalid = class extends Error {
|
|
33393
33746
|
constructor(route, detail) {
|
|
33394
33747
|
super(`control plane answered ${route} with ${detail}`);
|
|
@@ -33541,14 +33894,15 @@ function parsed(schema, body, route) {
|
|
|
33541
33894
|
}
|
|
33542
33895
|
return result.data;
|
|
33543
33896
|
}
|
|
33544
|
-
function
|
|
33897
|
+
function resolveBaseUrl(endpoint) {
|
|
33898
|
+
if (!isSafeEndpoint(endpoint)) throw new RemoteEndpointRefused(endpoint);
|
|
33545
33899
|
let end = endpoint.length;
|
|
33546
33900
|
while (end > 0 && endpoint.charCodeAt(end - 1) === SLASH2) end -= 1;
|
|
33547
33901
|
return endpoint.slice(0, end);
|
|
33548
33902
|
}
|
|
33549
33903
|
var SLASH2 = "/".charCodeAt(0);
|
|
33550
33904
|
function createRemoteClient(options) {
|
|
33551
|
-
const base =
|
|
33905
|
+
const base = resolveBaseUrl(options.endpoint);
|
|
33552
33906
|
const url2 = (route) => `${base}${route}`;
|
|
33553
33907
|
const common = { apiKey: options.apiKey, timeoutMs: options.timeoutMs };
|
|
33554
33908
|
const sendOne = async (event) => {
|
|
@@ -33678,6 +34032,7 @@ function classifyRemoteFailure(err) {
|
|
|
33678
34032
|
case "RemoteRouteAbsent":
|
|
33679
34033
|
return "route-absent";
|
|
33680
34034
|
case "RemoteRequestInvalid":
|
|
34035
|
+
case "RemoteEndpointRefused":
|
|
33681
34036
|
return "invalid-request";
|
|
33682
34037
|
case "RemoteResponseInvalid":
|
|
33683
34038
|
return "rejected";
|
|
@@ -34582,6 +34937,56 @@ var CONFIG_POSTURE_RULES = [
|
|
|
34582
34937
|
}
|
|
34583
34938
|
];
|
|
34584
34939
|
|
|
34940
|
+
// ../../packages/detections/src/posture/web-capture-posture.ts
|
|
34941
|
+
var RULE_VERSION2 = "1";
|
|
34942
|
+
var DRIFT_MIN_PARSE_FAILURES = 2;
|
|
34943
|
+
var WEB_CAPTURE_DRIFT_STATES = /* @__PURE__ */ new Set([
|
|
34944
|
+
"blind",
|
|
34945
|
+
"degraded"
|
|
34946
|
+
]);
|
|
34947
|
+
var WEB_CAPTURE_DRIFT_RULE = {
|
|
34948
|
+
ruleId: "web-capture-drift",
|
|
34949
|
+
version: RULE_VERSION2,
|
|
34950
|
+
name: "Web chat capture is not reading the site",
|
|
34951
|
+
category: "config",
|
|
34952
|
+
severity: "medium",
|
|
34953
|
+
definition: JSON.stringify({
|
|
34954
|
+
kind: "web-capture-drift",
|
|
34955
|
+
states: [...WEB_CAPTURE_DRIFT_STATES],
|
|
34956
|
+
minParseFailures: DRIFT_MIN_PARSE_FAILURES
|
|
34957
|
+
})
|
|
34958
|
+
};
|
|
34959
|
+
var STATIC_COPY = {
|
|
34960
|
+
active: { headline: "turns are being observed on this site" },
|
|
34961
|
+
unreported: {
|
|
34962
|
+
// Says "recently" rather than "yet": the store read is bounded to
|
|
34963
|
+
// CAPTURE_STATUS_RECENCY_MS, so this state covers a site nothing has ever
|
|
34964
|
+
// reported for AND one whose last report has aged out. The two are the
|
|
34965
|
+
// same fact to a reader — nobody has confirmed anything lately — and the
|
|
34966
|
+
// copy may not claim the stronger of them.
|
|
34967
|
+
headline: `no report in the last ${String(CAPTURE_STATUS_RECENCY_DAYS)} days \u2014 open the site in Chrome with the extension loaded`
|
|
34968
|
+
},
|
|
34969
|
+
standby: {
|
|
34970
|
+
headline: "this build declares no endpoints for the site, so nothing is observed yet"
|
|
34971
|
+
},
|
|
34972
|
+
unpatched: {
|
|
34973
|
+
// Says what the flags say and no more. `patched` is false both for a tap
|
|
34974
|
+
// that installed and hooked neither transport and for one that never ran
|
|
34975
|
+
// at all — a page reports the same status either way, so the copy may not
|
|
34976
|
+
// assert one of them.
|
|
34977
|
+
headline: "the page tap captured neither fetch nor XHR \u2014 it may not have installed; reload the extension at chrome://extensions"
|
|
34978
|
+
},
|
|
34979
|
+
idle: { headline: "watching; no turn has been observed yet" },
|
|
34980
|
+
blind: {
|
|
34981
|
+
headline: "messages were sent in the page that the network capture never saw",
|
|
34982
|
+
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."
|
|
34983
|
+
},
|
|
34984
|
+
degraded: {
|
|
34985
|
+
headline: "the site's payloads no longer carry the fields the extension reads",
|
|
34986
|
+
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."
|
|
34987
|
+
}
|
|
34988
|
+
};
|
|
34989
|
+
|
|
34585
34990
|
// ../../packages/detections/src/security/redos-probe.ts
|
|
34586
34991
|
var BUDGET_MS = 100;
|
|
34587
34992
|
var EXPONENTIAL_UNITS = [
|
|
@@ -36850,86 +37255,10 @@ function createForwardPolicy(deps) {
|
|
|
36850
37255
|
}
|
|
36851
37256
|
|
|
36852
37257
|
// ../../packages/plugin-runtime/src/attached/gateway.ts
|
|
36853
|
-
|
|
36854
|
-
|
|
36855
|
-
|
|
36856
|
-
return
|
|
36857
|
-
}
|
|
36858
|
-
function ruleCategoryMap(wireRules, localRules) {
|
|
36859
|
-
const map2 = /* @__PURE__ */ new Map();
|
|
36860
|
-
for (const rule of wireRules ?? []) map2.set(rule.id, rule.category);
|
|
36861
|
-
for (const rule of localRules ?? []) map2.set(rule.id, rule.category);
|
|
36862
|
-
for (const pack of bundledDetections()) {
|
|
36863
|
-
for (const rule of pack.rules) map2.set(rule.id, rule.category);
|
|
36864
|
-
}
|
|
36865
|
-
return map2;
|
|
36866
|
-
}
|
|
36867
|
-
function policyKey(policy) {
|
|
36868
|
-
return "ruleId" in policy.target ? `rule:${policy.target.ruleId}` : `category:${policy.target.category}`;
|
|
36869
|
-
}
|
|
36870
|
-
function floorFor(policy, categoryByRuleId) {
|
|
36871
|
-
const category = "category" in policy.target ? policy.target.category : categoryByRuleId.get(policy.target.ruleId);
|
|
36872
|
-
return category === void 0 ? null : DEFAULT_ACTIONS[category];
|
|
36873
|
-
}
|
|
36874
|
-
function mergeRaiseOnly(localPolicies, remotePolicies, categoryByRuleId) {
|
|
36875
|
-
const merged = /* @__PURE__ */ new Map();
|
|
36876
|
-
const disabled = [];
|
|
36877
|
-
const remoteCategoryAction = /* @__PURE__ */ new Map();
|
|
36878
|
-
for (const policy of remotePolicies) {
|
|
36879
|
-
if (!policy.enabled) continue;
|
|
36880
|
-
if (!("category" in policy.target)) continue;
|
|
36881
|
-
if (remoteCategoryAction.has(policy.target.category)) continue;
|
|
36882
|
-
const floor = floorFor(policy, categoryByRuleId);
|
|
36883
|
-
remoteCategoryAction.set(
|
|
36884
|
-
policy.target.category,
|
|
36885
|
-
floor !== null && !isActionAtLeast(policy.action, floor) ? floor : policy.action
|
|
36886
|
-
);
|
|
36887
|
-
}
|
|
36888
|
-
for (const policy of localPolicies) {
|
|
36889
|
-
if (!policy.enabled) {
|
|
36890
|
-
disabled.push(policy);
|
|
36891
|
-
continue;
|
|
36892
|
-
}
|
|
36893
|
-
const key = policyKey(policy);
|
|
36894
|
-
if (merged.has(key)) continue;
|
|
36895
|
-
let remoteFloor = null;
|
|
36896
|
-
if ("ruleId" in policy.target) {
|
|
36897
|
-
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
36898
|
-
if (category !== void 0) remoteFloor = remoteCategoryAction.get(category) ?? null;
|
|
36899
|
-
}
|
|
36900
|
-
merged.set(
|
|
36901
|
-
key,
|
|
36902
|
-
remoteFloor !== null && !isActionAtLeast(policy.action, remoteFloor) ? { ...policy, action: remoteFloor } : policy
|
|
36903
|
-
);
|
|
36904
|
-
}
|
|
36905
|
-
const localCategoryAction = /* @__PURE__ */ new Map();
|
|
36906
|
-
for (const policy of merged.values()) {
|
|
36907
|
-
if ("category" in policy.target) localCategoryAction.set(policy.target.category, policy.action);
|
|
36908
|
-
}
|
|
36909
|
-
for (const policy of remotePolicies) {
|
|
36910
|
-
if (!policy.enabled) {
|
|
36911
|
-
disabled.push(policy);
|
|
36912
|
-
continue;
|
|
36913
|
-
}
|
|
36914
|
-
const key = policyKey(policy);
|
|
36915
|
-
const floor = floorFor(policy, categoryByRuleId);
|
|
36916
|
-
let localFloor = null;
|
|
36917
|
-
if ("ruleId" in policy.target) {
|
|
36918
|
-
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
36919
|
-
if (category !== void 0) localFloor = localCategoryAction.get(category) ?? null;
|
|
36920
|
-
}
|
|
36921
|
-
const effectiveFloor = strongerOf(floor, localFloor);
|
|
36922
|
-
const clamped = effectiveFloor !== null && !isActionAtLeast(policy.action, effectiveFloor) ? { ...policy, action: effectiveFloor } : policy;
|
|
36923
|
-
const existing = merged.get(key);
|
|
36924
|
-
if (existing === void 0) {
|
|
36925
|
-
merged.set(key, clamped);
|
|
36926
|
-
continue;
|
|
36927
|
-
}
|
|
36928
|
-
if (actionRank(clamped.action) > actionRank(existing.action)) {
|
|
36929
|
-
merged.set(key, clamped);
|
|
36930
|
-
}
|
|
36931
|
-
}
|
|
36932
|
-
return [...merged.values(), ...disabled];
|
|
37258
|
+
var bundledRulesFlatCache;
|
|
37259
|
+
function bundledRulesFlat() {
|
|
37260
|
+
bundledRulesFlatCache ??= bundledDetections().flatMap((pack) => pack.rules);
|
|
37261
|
+
return bundledRulesFlatCache;
|
|
36933
37262
|
}
|
|
36934
37263
|
var AttachedDataGateway = class {
|
|
36935
37264
|
constructor(deps) {
|
|
@@ -37249,6 +37578,9 @@ var AttachedDataGateway = class {
|
|
|
37249
37578
|
async readSessionProvider(sessionId) {
|
|
37250
37579
|
return this.deps.local.readSessionProvider(sessionId);
|
|
37251
37580
|
}
|
|
37581
|
+
async readCaptureStatuses() {
|
|
37582
|
+
return this.deps.local.readCaptureStatuses();
|
|
37583
|
+
}
|
|
37252
37584
|
async facets() {
|
|
37253
37585
|
return this.deps.local.facets();
|
|
37254
37586
|
}
|
|
@@ -37331,7 +37663,7 @@ var AttachedDataGateway = class {
|
|
|
37331
37663
|
policies: mergeRaiseOnly(
|
|
37332
37664
|
local.policies,
|
|
37333
37665
|
cached2.policies,
|
|
37334
|
-
ruleCategoryMap(cached2.rules, local.rules)
|
|
37666
|
+
ruleCategoryMap(cached2.rules, local.rules, bundledRulesFlat())
|
|
37335
37667
|
),
|
|
37336
37668
|
customKeywords: [...local.customKeywords, ...cached2.customKeywords],
|
|
37337
37669
|
// TAKEN FROM THE CACHE, unlike the two fields below — and the asymmetry
|
|
@@ -37532,10 +37864,15 @@ import { join as join27 } from "path";
|
|
|
37532
37864
|
// ../../packages/plugin-runtime/src/attached/atomic-publish.ts
|
|
37533
37865
|
import { rename as rename2 } from "fs/promises";
|
|
37534
37866
|
var RETRYABLE = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
|
|
37535
|
-
var
|
|
37867
|
+
var IMMEDIATE_RETRIES = 8;
|
|
37868
|
+
var TIMED_RETRIES = 4;
|
|
37869
|
+
var ATTEMPTS = 1 + IMMEDIATE_RETRIES + TIMED_RETRIES;
|
|
37536
37870
|
var delay = (ms) => new Promise((resolve2) => {
|
|
37537
37871
|
setTimeout(resolve2, ms);
|
|
37538
37872
|
});
|
|
37873
|
+
var yieldToLoop = () => new Promise((resolve2) => {
|
|
37874
|
+
setImmediate(resolve2);
|
|
37875
|
+
});
|
|
37539
37876
|
async function publishByRename(tmp, file2, move = rename2) {
|
|
37540
37877
|
for (let attempt = 1; ; attempt += 1) {
|
|
37541
37878
|
try {
|
|
@@ -37544,7 +37881,7 @@ async function publishByRename(tmp, file2, move = rename2) {
|
|
|
37544
37881
|
} catch (err) {
|
|
37545
37882
|
const code = err.code;
|
|
37546
37883
|
if (attempt >= ATTEMPTS || code === void 0 || !RETRYABLE.has(code)) throw err;
|
|
37547
|
-
await delay(attempt * 10);
|
|
37884
|
+
await (attempt <= IMMEDIATE_RETRIES ? yieldToLoop() : delay((attempt - IMMEDIATE_RETRIES) * 10));
|
|
37548
37885
|
}
|
|
37549
37886
|
}
|
|
37550
37887
|
}
|
|
@@ -38008,6 +38345,9 @@ var StandaloneDataGateway = class {
|
|
|
38008
38345
|
readSessionProvider(sessionId) {
|
|
38009
38346
|
return Promise.resolve(this.db.auditEvents.sessionProvider(sessionId));
|
|
38010
38347
|
}
|
|
38348
|
+
readCaptureStatuses() {
|
|
38349
|
+
return Promise.resolve(this.db.captureStatus.latest(Date.now()));
|
|
38350
|
+
}
|
|
38011
38351
|
facets() {
|
|
38012
38352
|
return Promise.resolve(this.db.facets());
|
|
38013
38353
|
}
|