@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/sync.js
CHANGED
|
@@ -20479,7 +20479,17 @@ var UNPRICEABLE_PROVIDERS = Object.freeze([
|
|
|
20479
20479
|
"gateway",
|
|
20480
20480
|
"unknown",
|
|
20481
20481
|
"cli",
|
|
20482
|
-
"api"
|
|
20482
|
+
"api",
|
|
20483
|
+
// The browser extension's native host records these as `llm_call.provider`
|
|
20484
|
+
// for a web-chat turn — the web tool id, deliberately never the vendor id
|
|
20485
|
+
// (`openai`/`anthropic`) the session root carries. Subscription traffic
|
|
20486
|
+
// burns rate-limit budget, not dollar credits, and listing them here is
|
|
20487
|
+
// what keeps that true structurally: a later maintainer who wants to price
|
|
20488
|
+
// web-chat traffic at API rates has to delete this entry first, and meet
|
|
20489
|
+
// the reason on the way, rather than quietly adding one to
|
|
20490
|
+
// PROVIDER_PLATFORM.
|
|
20491
|
+
"chatgpt",
|
|
20492
|
+
"claude-ai"
|
|
20483
20493
|
]);
|
|
20484
20494
|
function platformForProvider(provider) {
|
|
20485
20495
|
return PROVIDER_PLATFORM.get(provider.trim().toLowerCase()) ?? null;
|
|
@@ -20622,7 +20632,12 @@ var HARNESS = {
|
|
|
20622
20632
|
ClaudeDesktop: "claudedesktop",
|
|
20623
20633
|
ChatGpt: "chatgpt",
|
|
20624
20634
|
ClaudeAi: "claudeai",
|
|
20625
|
-
Api: "api"
|
|
20635
|
+
Api: "api",
|
|
20636
|
+
// Not a coding assistant a person drives — an in-process SDK embedded in an
|
|
20637
|
+
// application, so it has no IDE/CLI/desktop/web surface of its own. Carries
|
|
20638
|
+
// the same id as its SOURCE_TOOL counterpart, unlike every capture-side tool
|
|
20639
|
+
// whose wire spelling differs from its display spelling.
|
|
20640
|
+
AiTcSdk: "ai-tc-sdk"
|
|
20626
20641
|
};
|
|
20627
20642
|
var Harness = external_exports.enum(HARNESS).meta({ id: "Harness" });
|
|
20628
20643
|
var SOURCE_TOOL = {
|
|
@@ -20638,9 +20653,15 @@ var SOURCE_TOOL = {
|
|
|
20638
20653
|
// whose tool could not be identified both render through the read side's
|
|
20639
20654
|
// miss path rather than as a harness of their own.
|
|
20640
20655
|
Cli: "cli",
|
|
20641
|
-
Unknown: "unknown"
|
|
20656
|
+
Unknown: "unknown",
|
|
20657
|
+
// The wire id an in-process, request-path SDK stamps on its own structural
|
|
20658
|
+
// rows (`request_decision`) — never a capture of prompt/response/tool text,
|
|
20659
|
+
// since the SDK sits in front of a model call rather than inside a coding
|
|
20660
|
+
// assistant's own hook contract.
|
|
20661
|
+
AiTcSdk: "ai-tc-sdk"
|
|
20642
20662
|
};
|
|
20643
20663
|
var SourceTool = external_exports.enum(SOURCE_TOOL).meta({ id: "SourceTool" });
|
|
20664
|
+
var WebSourceTool = SourceTool.extract(["ChatGpt", "ClaudeAi"]);
|
|
20644
20665
|
var TOOL_TO_HARNESS = {
|
|
20645
20666
|
[SOURCE_TOOL.ClaudeCode]: HARNESS.ClaudeCode,
|
|
20646
20667
|
[SOURCE_TOOL.ClaudeDesktop]: HARNESS.ClaudeDesktop,
|
|
@@ -20649,7 +20670,12 @@ var TOOL_TO_HARNESS = {
|
|
|
20649
20670
|
[SOURCE_TOOL.ChatGpt]: HARNESS.ChatGpt,
|
|
20650
20671
|
[SOURCE_TOOL.Codex]: HARNESS.Codex,
|
|
20651
20672
|
[SOURCE_TOOL.Antigravity]: HARNESS.Antigravity,
|
|
20652
|
-
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi
|
|
20673
|
+
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi,
|
|
20674
|
+
// Wire and display id are the same string here, but the row still belongs:
|
|
20675
|
+
// both vocabularies carry the `AiTcSdk` member, and the join is exactly
|
|
20676
|
+
// their intersection — leaving a shared member out would read as an
|
|
20677
|
+
// uninstrumented tool on both surfaces, which this one is not.
|
|
20678
|
+
[SOURCE_TOOL.AiTcSdk]: HARNESS.AiTcSdk
|
|
20653
20679
|
};
|
|
20654
20680
|
|
|
20655
20681
|
// ../../packages/schema/src/zod/finding.ts
|
|
@@ -20683,7 +20709,8 @@ var FindingProvider = Harness.extract([
|
|
|
20683
20709
|
"ClaudeAi",
|
|
20684
20710
|
"Codex",
|
|
20685
20711
|
"Antigravity",
|
|
20686
|
-
"Api"
|
|
20712
|
+
"Api",
|
|
20713
|
+
"AiTcSdk"
|
|
20687
20714
|
]).meta({ id: "FindingProvider" });
|
|
20688
20715
|
var FindingCategory = external_exports.enum([
|
|
20689
20716
|
"secret",
|
|
@@ -21060,18 +21087,41 @@ var AuditEventType = external_exports.enum([
|
|
|
21060
21087
|
// 'tool_call' is the reconciler's structural row for every call, while
|
|
21061
21088
|
// 'tool_use' exists only where a hook enforced against the arguments.
|
|
21062
21089
|
"tool_use",
|
|
21063
|
-
// One row per model REFUSAL
|
|
21064
|
-
//
|
|
21065
|
-
//
|
|
21066
|
-
//
|
|
21067
|
-
//
|
|
21068
|
-
//
|
|
21090
|
+
// One row per model REFUSAL, across all four seams a prohibited model can be
|
|
21091
|
+
// stopped at: a switch onto it, a turn already running on it, a subagent
|
|
21092
|
+
// spawn asking for it, or a request-path refusal an embedded request-path
|
|
21093
|
+
// SDK makes in-process before the call leaves the application. Which seam
|
|
21094
|
+
// rides `attributes.refusal_seam`, never this member name. A structural row
|
|
21095
|
+
// like the ones above rather than a capture — it carries the model that was
|
|
21096
|
+
// refused and nothing the user typed, because what is worth recording about
|
|
21097
|
+
// a governance decision is the decision, and prompt text is the thing this
|
|
21098
|
+
// product exists to keep from travelling.
|
|
21069
21099
|
"model_refusal",
|
|
21100
|
+
// One row per request-path DECISION: a policy check an embedded request-path
|
|
21101
|
+
// SDK performs in-process before a model call leaves the application, or
|
|
21102
|
+
// against that call's non-streamed response. A structural row like
|
|
21103
|
+
// 'model_refusal' rather than a capture — content-free in the same way:
|
|
21104
|
+
// which side, which seam, what action and which field are decided rides
|
|
21105
|
+
// `attributes`, never this member name, and the matched text itself never
|
|
21106
|
+
// travels.
|
|
21107
|
+
//
|
|
21108
|
+
// A prohibited-model refusal on the request path is deliberately NOT this
|
|
21109
|
+
// member: it stays 'model_refusal' with `refusal_seam: 'request'`, so it
|
|
21110
|
+
// shares one bucket with the plugin's switch/turn/spawn refusals rather
|
|
21111
|
+
// than splitting one governance concept across two event types. This
|
|
21112
|
+
// member carries every OTHER request-path decision.
|
|
21113
|
+
"request_decision",
|
|
21070
21114
|
// One row per config-inventory scan, hung off the session root. It is the
|
|
21071
21115
|
// fact the posture inspection findings reference (findings require an
|
|
21072
21116
|
// audit_event_id), and its started_at is the "scanned Nm ago" the read
|
|
21073
21117
|
// surface renders.
|
|
21074
|
-
"config_scan"
|
|
21118
|
+
"config_scan",
|
|
21119
|
+
// One row per reported browser-extension capture status, hung off the web
|
|
21120
|
+
// session root. The durable home of what one tab's network interception
|
|
21121
|
+
// is doing — a write-through of the native host's in-memory tracker, so a
|
|
21122
|
+
// second process (aka extension status) and a restarted host both have
|
|
21123
|
+
// somewhere to read it back from.
|
|
21124
|
+
"capture_status"
|
|
21075
21125
|
]).meta({ id: "AuditEventType" });
|
|
21076
21126
|
var AttributeBag = external_exports.record(external_exports.string(), external_exports.unknown());
|
|
21077
21127
|
var HostAttributes = external_exports.object({
|
|
@@ -21231,6 +21281,20 @@ var CaptureAttributes = external_exports.object({
|
|
|
21231
21281
|
// repeated rather than referenced because a store reader opens this file.
|
|
21232
21282
|
redact_degraded_to: ActionTaken.optional()
|
|
21233
21283
|
}).catchall(external_exports.unknown());
|
|
21284
|
+
var CaptureStatusAttributes = external_exports.object({
|
|
21285
|
+
source_tool: external_exports.string().optional(),
|
|
21286
|
+
patched: external_exports.boolean().optional(),
|
|
21287
|
+
live: external_exports.boolean().optional(),
|
|
21288
|
+
blind: external_exports.boolean().optional(),
|
|
21289
|
+
sends_seen_dom: external_exports.number().int().nonnegative().optional(),
|
|
21290
|
+
exchanges_seen_net: external_exports.number().int().nonnegative().optional(),
|
|
21291
|
+
parse_failures: external_exports.number().int().nonnegative().optional(),
|
|
21292
|
+
unparsed_bodies: external_exports.number().int().nonnegative().optional(),
|
|
21293
|
+
shape_misses: external_exports.array(external_exports.string()).optional(),
|
|
21294
|
+
conversation_endpoints: external_exports.number().int().nonnegative().optional(),
|
|
21295
|
+
closed: external_exports.boolean().optional(),
|
|
21296
|
+
enforcement: external_exports.string().optional()
|
|
21297
|
+
}).catchall(external_exports.unknown());
|
|
21234
21298
|
var ToolCallInspection = external_exports.object({
|
|
21235
21299
|
ruleId: external_exports.string().min(1),
|
|
21236
21300
|
ruleName: external_exports.string(),
|
|
@@ -22090,6 +22154,30 @@ var AttachedCredential = external_exports.object({
|
|
|
22090
22154
|
keyPrefix: external_exports.string().min(1).max(16).optional(),
|
|
22091
22155
|
mintedAt: external_exports.iso.datetime().optional()
|
|
22092
22156
|
});
|
|
22157
|
+
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
22158
|
+
function unsafeEndpointReason(endpoint) {
|
|
22159
|
+
let parsed2;
|
|
22160
|
+
try {
|
|
22161
|
+
parsed2 = new URL(endpoint);
|
|
22162
|
+
} catch {
|
|
22163
|
+
return "unparseable";
|
|
22164
|
+
}
|
|
22165
|
+
if (parsed2.username !== "" || parsed2.password !== "") return "userinfo";
|
|
22166
|
+
if (parsed2.search !== "" || parsed2.hash !== "") return "query-or-fragment";
|
|
22167
|
+
if (parsed2.protocol === "https:") return null;
|
|
22168
|
+
return parsed2.protocol === "http:" && LOOPBACK_HOSTS.has(parsed2.hostname) ? null : "insecure";
|
|
22169
|
+
}
|
|
22170
|
+
function isSafeEndpoint(endpoint) {
|
|
22171
|
+
return unsafeEndpointReason(endpoint) === null;
|
|
22172
|
+
}
|
|
22173
|
+
function originOnly(endpoint) {
|
|
22174
|
+
try {
|
|
22175
|
+
const parsed2 = new URL(endpoint);
|
|
22176
|
+
return `${parsed2.protocol}//${parsed2.host}`;
|
|
22177
|
+
} catch {
|
|
22178
|
+
return "(unparseable endpoint)";
|
|
22179
|
+
}
|
|
22180
|
+
}
|
|
22093
22181
|
var MAX_DATE_MS = 253402300799999;
|
|
22094
22182
|
var MAX_INT4 = 2147483647;
|
|
22095
22183
|
var StorePosturePack = external_exports.object({
|
|
@@ -22244,6 +22332,11 @@ var RemoteFailureKind = external_exports.enum([
|
|
|
22244
22332
|
"rejected",
|
|
22245
22333
|
"unreachable"
|
|
22246
22334
|
]);
|
|
22335
|
+
var ControlPlaneFailure = RemoteFailureKind.extract([
|
|
22336
|
+
"unauthorized",
|
|
22337
|
+
"forbidden",
|
|
22338
|
+
"unreachable"
|
|
22339
|
+
]);
|
|
22247
22340
|
var AttachDeviceRequest = external_exports.object({
|
|
22248
22341
|
// This machine's own continuity id, so re-attaching ROTATES the credential
|
|
22249
22342
|
// on one machine record instead of producing a second one. Client-minted
|
|
@@ -22783,7 +22876,12 @@ var EventMetadata = external_exports.object({
|
|
|
22783
22876
|
// in — set by the browser extension's network capture so a stored `response`
|
|
22784
22877
|
// row can be joined to the `llm_call` leaf describing the same turn. Absent
|
|
22785
22878
|
// on every other capture path, which has no such id.
|
|
22786
|
-
|
|
22879
|
+
//
|
|
22880
|
+
// Non-empty for the reason WebExchange.messageId is: it is the join key, and
|
|
22881
|
+
// a blank one matches no `llm_call` leaf. That refusal reaches only the
|
|
22882
|
+
// places an event is PARSED; the local write path types the event and parses
|
|
22883
|
+
// nothing, which is why `toCaptureAttributes` omits a blank one separately.
|
|
22884
|
+
messageId: external_exports.string().min(1).optional(),
|
|
22787
22885
|
conversationId: external_exports.string().optional(),
|
|
22788
22886
|
// How long THIS capture's inspection blocked its caller, in whole
|
|
22789
22887
|
// milliseconds — the plugin's own added latency, NOT the LLM call it sat in
|
|
@@ -23630,6 +23728,85 @@ function policyIdIsReversible(policyId) {
|
|
|
23630
23728
|
var DEFAULT_ACTIONS = Object.fromEntries(
|
|
23631
23729
|
DetectionCategory.options.map((c) => [c, builtinPolicyToAction(severityFloorPolicy(c))])
|
|
23632
23730
|
);
|
|
23731
|
+
function ruleCategoryMap(wireRules, localRules, compiledRules) {
|
|
23732
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
23733
|
+
for (const rule of wireRules ?? []) map2.set(rule.id, rule.category);
|
|
23734
|
+
for (const rule of localRules ?? []) map2.set(rule.id, rule.category);
|
|
23735
|
+
for (const rule of compiledRules) map2.set(rule.id, rule.category);
|
|
23736
|
+
return map2;
|
|
23737
|
+
}
|
|
23738
|
+
function policyKey(policy) {
|
|
23739
|
+
return "ruleId" in policy.target ? `rule:${policy.target.ruleId}` : `category:${policy.target.category}`;
|
|
23740
|
+
}
|
|
23741
|
+
function floorFor(policy, categoryByRuleId) {
|
|
23742
|
+
const category = "category" in policy.target ? policy.target.category : categoryByRuleId.get(policy.target.ruleId);
|
|
23743
|
+
return category === void 0 ? null : DEFAULT_ACTIONS[category];
|
|
23744
|
+
}
|
|
23745
|
+
function strongerOf(a, b) {
|
|
23746
|
+
if (a === null) return b;
|
|
23747
|
+
if (b === null) return a;
|
|
23748
|
+
return strongerAction(a, b);
|
|
23749
|
+
}
|
|
23750
|
+
function mergeRaiseOnly(localPolicies, remotePolicies, categoryByRuleId) {
|
|
23751
|
+
const merged = /* @__PURE__ */ new Map();
|
|
23752
|
+
const disabled = [];
|
|
23753
|
+
const remoteCategoryAction = /* @__PURE__ */ new Map();
|
|
23754
|
+
for (const policy of remotePolicies) {
|
|
23755
|
+
if (!policy.enabled) continue;
|
|
23756
|
+
if (!("category" in policy.target)) continue;
|
|
23757
|
+
if (remoteCategoryAction.has(policy.target.category)) continue;
|
|
23758
|
+
const floor = floorFor(policy, categoryByRuleId);
|
|
23759
|
+
remoteCategoryAction.set(
|
|
23760
|
+
policy.target.category,
|
|
23761
|
+
floor !== null && !isActionAtLeast(policy.action, floor) ? floor : policy.action
|
|
23762
|
+
);
|
|
23763
|
+
}
|
|
23764
|
+
for (const policy of localPolicies) {
|
|
23765
|
+
if (!policy.enabled) {
|
|
23766
|
+
disabled.push(policy);
|
|
23767
|
+
continue;
|
|
23768
|
+
}
|
|
23769
|
+
const key = policyKey(policy);
|
|
23770
|
+
if (merged.has(key)) continue;
|
|
23771
|
+
let remoteFloor = null;
|
|
23772
|
+
if ("ruleId" in policy.target) {
|
|
23773
|
+
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
23774
|
+
if (category !== void 0) remoteFloor = remoteCategoryAction.get(category) ?? null;
|
|
23775
|
+
}
|
|
23776
|
+
merged.set(
|
|
23777
|
+
key,
|
|
23778
|
+
remoteFloor !== null && !isActionAtLeast(policy.action, remoteFloor) ? { ...policy, action: remoteFloor } : policy
|
|
23779
|
+
);
|
|
23780
|
+
}
|
|
23781
|
+
const localCategoryAction = /* @__PURE__ */ new Map();
|
|
23782
|
+
for (const policy of merged.values()) {
|
|
23783
|
+
if ("category" in policy.target) localCategoryAction.set(policy.target.category, policy.action);
|
|
23784
|
+
}
|
|
23785
|
+
for (const policy of remotePolicies) {
|
|
23786
|
+
if (!policy.enabled) {
|
|
23787
|
+
disabled.push(policy);
|
|
23788
|
+
continue;
|
|
23789
|
+
}
|
|
23790
|
+
const key = policyKey(policy);
|
|
23791
|
+
const floor = floorFor(policy, categoryByRuleId);
|
|
23792
|
+
let localFloor = null;
|
|
23793
|
+
if ("ruleId" in policy.target) {
|
|
23794
|
+
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
23795
|
+
if (category !== void 0) localFloor = localCategoryAction.get(category) ?? null;
|
|
23796
|
+
}
|
|
23797
|
+
const effectiveFloor = strongerOf(floor, localFloor);
|
|
23798
|
+
const clamped = effectiveFloor !== null && !isActionAtLeast(policy.action, effectiveFloor) ? { ...policy, action: effectiveFloor } : policy;
|
|
23799
|
+
const existing = merged.get(key);
|
|
23800
|
+
if (existing === void 0) {
|
|
23801
|
+
merged.set(key, clamped);
|
|
23802
|
+
continue;
|
|
23803
|
+
}
|
|
23804
|
+
if (actionRank(clamped.action) > actionRank(existing.action)) {
|
|
23805
|
+
merged.set(key, clamped);
|
|
23806
|
+
}
|
|
23807
|
+
}
|
|
23808
|
+
return [...merged.values(), ...disabled];
|
|
23809
|
+
}
|
|
23633
23810
|
var BUILTIN_POLICIES = Object.fromEntries(
|
|
23634
23811
|
KNOWN_BUILTIN_IDS.map((id) => [id, { id, ...BUILTIN_POLICY_SPECS[id] }])
|
|
23635
23812
|
);
|
|
@@ -23855,6 +24032,18 @@ var HistorySyncConsent = external_exports.object({
|
|
|
23855
24032
|
payloadVersion: external_exports.number().int().positive(),
|
|
23856
24033
|
endpoint: external_exports.string()
|
|
23857
24034
|
});
|
|
24035
|
+
var WebChatCaptureConsent = external_exports.object({
|
|
24036
|
+
acknowledgedAt: external_exports.iso.datetime(),
|
|
24037
|
+
version: external_exports.number().int().positive()
|
|
24038
|
+
});
|
|
24039
|
+
var WebChatResponseCapture = external_exports.enum(["with-findings", "always", "never"]);
|
|
24040
|
+
var WebChatCapture = external_exports.object({
|
|
24041
|
+
responses: WebChatResponseCapture.default("with-findings"),
|
|
24042
|
+
account: external_exports.boolean().default(false),
|
|
24043
|
+
// Absent until granted. Presence alone does not authorize anything — see
|
|
24044
|
+
// isWebChatCaptureConsentValid.
|
|
24045
|
+
consent: WebChatCaptureConsent.optional()
|
|
24046
|
+
});
|
|
23858
24047
|
var BODY_RETENTION_DEFAULT_DAYS = 30;
|
|
23859
24048
|
var BodyRetention = external_exports.object({
|
|
23860
24049
|
enabled: external_exports.boolean().default(false),
|
|
@@ -23913,6 +24102,16 @@ var WorkspaceSettings = external_exports.object({
|
|
|
23913
24102
|
// both widenings. Absent until granted, and a grant for a different endpoint
|
|
23914
24103
|
// or an older payload no longer counts.
|
|
23915
24104
|
historySyncConsent: HistorySyncConsent.optional(),
|
|
24105
|
+
// What the browser extension may record from a web chat, and the grant that
|
|
24106
|
+
// authorizes it. Absent until the user answers: recording something that was
|
|
24107
|
+
// never recorded before is never an assumed grant on upgrade, so the whole
|
|
24108
|
+
// block is optional rather than defaulted in. What an absent block means is
|
|
24109
|
+
// webChatCaptureOf's answer, in one place.
|
|
24110
|
+
//
|
|
24111
|
+
// Enforcement is NOT gated on this. A machine that has never answered still
|
|
24112
|
+
// blocks, redacts and warns on what a user sends; the grant covers what is
|
|
24113
|
+
// written down.
|
|
24114
|
+
webChatCapture: WebChatCapture.optional(),
|
|
23916
24115
|
// Local body expiry (see BodyRetention). Off until switched on; expiring a
|
|
23917
24116
|
// body never removes the row or its findings.
|
|
23918
24117
|
bodyRetention: BodyRetention.default({
|
|
@@ -24020,7 +24219,10 @@ function toCaptureAttributes(event) {
|
|
|
24020
24219
|
// `.catchall(z.unknown())` carries the long tail.
|
|
24021
24220
|
...metadata?.model !== void 0 ? { model: metadata.model } : {},
|
|
24022
24221
|
...metadata?.turnIndex !== void 0 ? { turn_index: metadata.turnIndex } : {},
|
|
24023
|
-
|
|
24222
|
+
// A blank id is omitted rather than stored: it is a join key and `''` joins
|
|
24223
|
+
// nothing. This runs on the local write path, which types the event but
|
|
24224
|
+
// never parses it, so EventMetadata's own `.min(1)` does not reach here.
|
|
24225
|
+
...metadata?.messageId !== void 0 && metadata.messageId !== "" ? { message_id: metadata.messageId } : {},
|
|
24024
24226
|
...metadata?.conversationId !== void 0 ? { conversation_id: metadata.conversationId } : {}
|
|
24025
24227
|
};
|
|
24026
24228
|
}
|
|
@@ -24394,12 +24596,14 @@ var RecommendedActionIdParam = external_exports.object({ id: external_exports.st
|
|
|
24394
24596
|
// ../../packages/schema/src/zod/settings-action.ts
|
|
24395
24597
|
var HistorySyncConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "HistorySyncConsentChoice" });
|
|
24396
24598
|
var ModelJudgeConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "ModelJudgeConsentChoice" });
|
|
24599
|
+
var WebChatCaptureConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "WebChatCaptureConsentChoice" });
|
|
24397
24600
|
var SaveSettingsInput = external_exports.object({
|
|
24398
24601
|
historicalAccess: external_exports.string(),
|
|
24399
24602
|
modelJudgeConsent: ModelJudgeConsentChoice,
|
|
24400
24603
|
historySyncConsent: HistorySyncConsentChoice,
|
|
24401
24604
|
vaultConsent: external_exports.string(),
|
|
24402
24605
|
vaultInlineReveal: external_exports.string(),
|
|
24606
|
+
webChatCaptureConsent: WebChatCaptureConsentChoice,
|
|
24403
24607
|
// Widened to `string` like its neighbours rather than typed as
|
|
24404
24608
|
// `RedactFallback`, on this module's own layering rule: shape here, VALUE at
|
|
24405
24609
|
// the call site, so the domain check receives the type it was written for.
|
|
@@ -24614,11 +24818,24 @@ var WebExchange = external_exports.object({
|
|
|
24614
24818
|
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
24615
24819
|
toolCalls: external_exports.array(WebToolCall).default([]),
|
|
24616
24820
|
// Absent when the adapter recovered no text. Capped by the caller at
|
|
24617
|
-
// RESPONSE_TEXT_MAX_BYTES
|
|
24618
|
-
//
|
|
24821
|
+
// RESPONSE_TEXT_MAX_BYTES, so a short capture is never mistaken for a short
|
|
24822
|
+
// reply.
|
|
24619
24823
|
responseText: external_exports.string().optional(),
|
|
24824
|
+
// The stored text is short of the reply. It does NOT say which of the two
|
|
24825
|
+
// ceilings on this path cut it: the caller applies its own cap on the raw
|
|
24826
|
+
// bytes it reads off the wire, which can be reached by a stream whose
|
|
24827
|
+
// recovered text stays well under RESPONSE_TEXT_MAX_BYTES, and applies that
|
|
24828
|
+
// one to the text. A reader cannot tell them apart, and nothing downstream
|
|
24829
|
+
// should branch as though it could.
|
|
24620
24830
|
truncated: external_exports.boolean().default(false)
|
|
24621
24831
|
});
|
|
24832
|
+
var WebEnforcementState = external_exports.enum([
|
|
24833
|
+
"watching",
|
|
24834
|
+
"composer-only",
|
|
24835
|
+
"button-only",
|
|
24836
|
+
"unattached",
|
|
24837
|
+
"unknown"
|
|
24838
|
+
]);
|
|
24622
24839
|
var RESPONSE_TEXT_MAX_BYTES = 2 * 1024 * 1024;
|
|
24623
24840
|
var WebCaptureStatus = external_exports.object({
|
|
24624
24841
|
patched: external_exports.boolean(),
|
|
@@ -24630,8 +24847,66 @@ var WebCaptureStatus = external_exports.object({
|
|
|
24630
24847
|
unparsedBodies: external_exports.number().int().nonnegative(),
|
|
24631
24848
|
// The adapter-declared JSON key paths that were absent from a real payload —
|
|
24632
24849
|
// the earliest signal that a site's contract moved.
|
|
24633
|
-
shapeMisses: external_exports.array(external_exports.string()).default([])
|
|
24634
|
-
|
|
24850
|
+
shapeMisses: external_exports.array(external_exports.string()).default([]),
|
|
24851
|
+
// How many `kind: 'conversation'` endpoints the reporting tab's adapter
|
|
24852
|
+
// compiled. Zero means this build declares none for the site, so observing
|
|
24853
|
+
// nothing is the design rather than a fault — the one fact that separates a
|
|
24854
|
+
// site nobody has surveyed yet from one whose contract moved. Defaulted so a
|
|
24855
|
+
// build predating the field is read as declaring nothing rather than refused.
|
|
24856
|
+
conversationEndpoints: external_exports.number().int().nonnegative().default(0),
|
|
24857
|
+
// The document that sent this report is going away. The bridge sets it on
|
|
24858
|
+
// its `pagehide` report and nowhere else.
|
|
24859
|
+
//
|
|
24860
|
+
// A property of the REPORT rather than of capture health, which is why
|
|
24861
|
+
// nothing in `deriveWebCaptureState` reads it and why it stays out of the
|
|
24862
|
+
// bridge's own report signature — a closing tab's last word must not be
|
|
24863
|
+
// suppressed for carrying the same health as the report before it. What
|
|
24864
|
+
// reads it is the per-site fold: a document that said it was unloading stops
|
|
24865
|
+
// voting on the site's state, so the reload the `blind` remediation asks for
|
|
24866
|
+
// can actually clear the verdict it was shown. A document that dies without
|
|
24867
|
+
// sending one is covered by CAPTURE_STATUS_DOCUMENT_QUIET_MS instead.
|
|
24868
|
+
//
|
|
24869
|
+
// Defaulted so a build predating the field reads as a document that never
|
|
24870
|
+
// said it was closing — which keeps it voting, the same as every report that
|
|
24871
|
+
// is not a final one.
|
|
24872
|
+
closed: external_exports.boolean().default(false),
|
|
24873
|
+
// What the DOM enforcement path is doing, which none of the counters above
|
|
24874
|
+
// can say: `sendsSeenDom` rises only once a send has COMPLETED, so a tab
|
|
24875
|
+
// whose watcher never bound reports zero exactly like a tab nobody typed in.
|
|
24876
|
+
// Defaulted to 'unknown' rather than 'watching' so a status from a build
|
|
24877
|
+
// predating the field is not read as reporting a healthy one.
|
|
24878
|
+
enforcement: WebEnforcementState.default("unknown")
|
|
24879
|
+
});
|
|
24880
|
+
function webCaptureStatusObservedTurnPath(status) {
|
|
24881
|
+
if (!status.patched) return true;
|
|
24882
|
+
if (status.conversationEndpoints === 0) return true;
|
|
24883
|
+
return status.blind || status.shapeMisses.length > 0 || status.parseFailures > 0 || status.unparsedBodies > 0 || status.exchangesSeenNet > 0;
|
|
24884
|
+
}
|
|
24885
|
+
function pickReportedCaptureStatus(candidates) {
|
|
24886
|
+
return candidates.find((c) => webCaptureStatusObservedTurnPath(c.status)) ?? candidates[0];
|
|
24887
|
+
}
|
|
24888
|
+
var CAPTURE_STATUS_RECENCY_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
24889
|
+
var CAPTURE_STATUS_RECENCY_DAYS = CAPTURE_STATUS_RECENCY_MS / (24 * 60 * 60 * 1e3);
|
|
24890
|
+
var CAPTURE_STATUS_DOCUMENT_QUIET_MS = 12 * 60 * 60 * 1e3;
|
|
24891
|
+
function fromCaptureStatusAttributes(bag) {
|
|
24892
|
+
const parsedBag = CaptureStatusAttributes.safeParse(bag);
|
|
24893
|
+
if (!parsedBag.success) return null;
|
|
24894
|
+
const b = parsedBag.data;
|
|
24895
|
+
const parsedStatus = WebCaptureStatus.safeParse({
|
|
24896
|
+
patched: b.patched,
|
|
24897
|
+
live: b.live,
|
|
24898
|
+
blind: b.blind,
|
|
24899
|
+
sendsSeenDom: b.sends_seen_dom,
|
|
24900
|
+
exchangesSeenNet: b.exchanges_seen_net,
|
|
24901
|
+
parseFailures: b.parse_failures,
|
|
24902
|
+
unparsedBodies: b.unparsed_bodies,
|
|
24903
|
+
shapeMisses: b.shape_misses,
|
|
24904
|
+
conversationEndpoints: b.conversation_endpoints,
|
|
24905
|
+
closed: b.closed,
|
|
24906
|
+
enforcement: b.enforcement
|
|
24907
|
+
});
|
|
24908
|
+
return parsedStatus.success ? parsedStatus.data : null;
|
|
24909
|
+
}
|
|
24635
24910
|
|
|
24636
24911
|
// ../../packages/persistence/src/paths.ts
|
|
24637
24912
|
import {
|
|
@@ -24762,17 +25037,6 @@ function publishByLink(tmp, file2, data) {
|
|
|
24762
25037
|
function controlPlaneCredentialPath(settingsDir2) {
|
|
24763
25038
|
return join2(settingsDir2, ATTACHED_CREDENTIAL_FILENAME);
|
|
24764
25039
|
}
|
|
24765
|
-
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
24766
|
-
function isSafeEndpoint(endpoint) {
|
|
24767
|
-
let parsed2;
|
|
24768
|
-
try {
|
|
24769
|
-
parsed2 = new URL(endpoint);
|
|
24770
|
-
} catch {
|
|
24771
|
-
return false;
|
|
24772
|
-
}
|
|
24773
|
-
if (parsed2.protocol === "https:") return true;
|
|
24774
|
-
return parsed2.protocol === "http:" && LOOPBACK_HOSTS.has(parsed2.hostname);
|
|
24775
|
-
}
|
|
24776
25040
|
function repairOrRefuseMode(file2) {
|
|
24777
25041
|
const link = lstatSync2(file2, { throwIfNoEntry: false });
|
|
24778
25042
|
if (link === void 0) return "absent";
|
|
@@ -26565,7 +26829,7 @@ var SESSION_ROOT = `event_type = 'session'`;
|
|
|
26565
26829
|
var HAS_ACTIVITY = `EXISTS (
|
|
26566
26830
|
SELECT 1 FROM audit_events c
|
|
26567
26831
|
WHERE c.root_session_id = audit_events.id
|
|
26568
|
-
AND c.event_type NOT IN ('hook', 'config_scan'))`;
|
|
26832
|
+
AND c.event_type NOT IN ('hook', 'config_scan', 'capture_status'))`;
|
|
26569
26833
|
var SqliteActivityRepository = class {
|
|
26570
26834
|
constructor(db, now = () => Date.now()) {
|
|
26571
26835
|
this.db = db;
|
|
@@ -26592,10 +26856,10 @@ var SqliteActivityRepository = class {
|
|
|
26592
26856
|
SELECT id FROM audit_events WHERE event_type = 'session' AND started_at >= ?
|
|
26593
26857
|
UNION
|
|
26594
26858
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_started_at
|
|
26595
|
-
WHERE started_at >= ?
|
|
26859
|
+
WHERE started_at >= ? AND event_type <> 'capture_status'
|
|
26596
26860
|
UNION
|
|
26597
26861
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_ended_at
|
|
26598
|
-
WHERE ended_at >= ?)`,
|
|
26862
|
+
WHERE ended_at >= ? AND event_type <> 'capture_status')`,
|
|
26599
26863
|
[liveThreshold, liveThreshold, liveThreshold]
|
|
26600
26864
|
);
|
|
26601
26865
|
const toolCallsToday = countScalar(
|
|
@@ -27002,7 +27266,10 @@ var SqliteAuditEventsRepository = class {
|
|
|
27002
27266
|
attributes = excluded.attributes,
|
|
27003
27267
|
ended_at = excluded.ended_at
|
|
27004
27268
|
WHERE COALESCE(json_extract(excluded.attributes, '$.output_tokens'), 0)
|
|
27005
|
-
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27269
|
+
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27270
|
+
OR (json_extract(excluded.attributes, '$.usage_source') IS NOT NULL
|
|
27271
|
+
AND json_extract(excluded.attributes, '$.output_tokens') IS NULL
|
|
27272
|
+
AND excluded.attributes <> audit_events.attributes)`
|
|
27006
27273
|
);
|
|
27007
27274
|
this.upsertSessionRootStmt = db.prepare(
|
|
27008
27275
|
`INSERT OR IGNORE INTO audit_events
|
|
@@ -27270,6 +27537,87 @@ var SqliteBodyRetentionRepository = class {
|
|
|
27270
27537
|
}
|
|
27271
27538
|
};
|
|
27272
27539
|
|
|
27540
|
+
// ../../packages/persistence/src/repositories/capture-status.ts
|
|
27541
|
+
var STATUS_LOOKBACK_ROWS = 128;
|
|
27542
|
+
var SqliteCaptureStatusRepository = class {
|
|
27543
|
+
constructor(db) {
|
|
27544
|
+
this.db = db;
|
|
27545
|
+
this.recentStmt = db.prepare(
|
|
27546
|
+
`SELECT a.started_at AS startedAt,
|
|
27547
|
+
a.attributes AS attributes,
|
|
27548
|
+
a.root_session_id AS rootSessionId
|
|
27549
|
+
FROM audit_events a
|
|
27550
|
+
WHERE a.event_type = 'capture_status'
|
|
27551
|
+
AND a.source_tool = ?
|
|
27552
|
+
AND a.started_at >= ?
|
|
27553
|
+
ORDER BY a.started_at DESC, a.id DESC
|
|
27554
|
+
LIMIT ?`
|
|
27555
|
+
);
|
|
27556
|
+
}
|
|
27557
|
+
db;
|
|
27558
|
+
recentStmt;
|
|
27559
|
+
/**
|
|
27560
|
+
* Every document that reported for a site, in registry order by site, from
|
|
27561
|
+
* the last `CAPTURE_STATUS_RECENCY_MS`.
|
|
27562
|
+
*
|
|
27563
|
+
* SEVERAL per site, not one: a browser is many documents and each reports
|
|
27564
|
+
* for itself, so one row per site is a choice about which of them a user
|
|
27565
|
+
* sees — and the newest is the wrong one, since a healthy tab writing a
|
|
27566
|
+
* fresh report would hide a drifting tab's verdict, which is the whole
|
|
27567
|
+
* reason these rows exist. The pick WITHIN a document is made here (the
|
|
27568
|
+
* unchanged `pickReportedCaptureStatus`, over that document's own rows);
|
|
27569
|
+
* choosing between documents belongs where the state semantics live, and
|
|
27570
|
+
* that is `reportedCaptureDocumentForSite` in `@akasecurity/detections` —
|
|
27571
|
+
* this package may not import it.
|
|
27572
|
+
*
|
|
27573
|
+
* `now` is a required argument rather than a `Date.now()` read, so a caller
|
|
27574
|
+
* that already holds a render instant passes THAT one and a test can drive
|
|
27575
|
+
* the window without moving the wall clock.
|
|
27576
|
+
*
|
|
27577
|
+
* A site whose reports have all aged out contributes nothing, so it derives
|
|
27578
|
+
* to `unreported`. That is the point: nothing but the browser extension ever
|
|
27579
|
+
* writes these rows, so an uninstalled extension's last verdict would
|
|
27580
|
+
* otherwise stand as a live claim for ever with no later report able to
|
|
27581
|
+
* clear it.
|
|
27582
|
+
*/
|
|
27583
|
+
latest(now) {
|
|
27584
|
+
const since = now - CAPTURE_STATUS_RECENCY_MS;
|
|
27585
|
+
const documents = [];
|
|
27586
|
+
for (const tool of WebSourceTool.options) {
|
|
27587
|
+
const rows = /* @__PURE__ */ new Map();
|
|
27588
|
+
const lastWord = /* @__PURE__ */ new Map();
|
|
27589
|
+
for (const row of allRows(this.recentStmt, [
|
|
27590
|
+
tool,
|
|
27591
|
+
since,
|
|
27592
|
+
STATUS_LOOKBACK_ROWS
|
|
27593
|
+
])) {
|
|
27594
|
+
const status = fromCaptureStatusAttributes(parseJsonObject(row.attributes));
|
|
27595
|
+
if (status === null) continue;
|
|
27596
|
+
const record2 = { tool, observedAt: epochMillisToIso(row.startedAt), status };
|
|
27597
|
+
const group = rows.get(row.rootSessionId);
|
|
27598
|
+
if (group === void 0) {
|
|
27599
|
+
rows.set(row.rootSessionId, [record2]);
|
|
27600
|
+
lastWord.set(row.rootSessionId, { at: record2.observedAt, closed: status.closed });
|
|
27601
|
+
} else {
|
|
27602
|
+
group.push(record2);
|
|
27603
|
+
}
|
|
27604
|
+
}
|
|
27605
|
+
for (const [root, candidates] of rows) {
|
|
27606
|
+
const picked = pickReportedCaptureStatus(candidates);
|
|
27607
|
+
const last = lastWord.get(root);
|
|
27608
|
+
if (picked === void 0 || last === void 0) continue;
|
|
27609
|
+
documents.push({
|
|
27610
|
+
...picked,
|
|
27611
|
+
...root === null ? {} : { rootSessionId: root },
|
|
27612
|
+
lastReportAt: last.at,
|
|
27613
|
+
closed: last.closed
|
|
27614
|
+
});
|
|
27615
|
+
}
|
|
27616
|
+
}
|
|
27617
|
+
return documents;
|
|
27618
|
+
}
|
|
27619
|
+
};
|
|
27620
|
+
|
|
27273
27621
|
// ../../packages/persistence/src/repositories/classified-data.ts
|
|
27274
27622
|
var SqliteClassifiedDataRepository = class {
|
|
27275
27623
|
constructor(db) {
|
|
@@ -32847,6 +33195,7 @@ function openAndInitialize(file2, base, skipTags) {
|
|
|
32847
33195
|
activity: new SqliteActivityRepository(db),
|
|
32848
33196
|
sourceProject: new SqliteSourceProjectRepository(db),
|
|
32849
33197
|
auditEvents: new SqliteAuditEventsRepository(db),
|
|
33198
|
+
captureStatus: new SqliteCaptureStatusRepository(db),
|
|
32850
33199
|
classifiedData: new SqliteClassifiedDataRepository(db),
|
|
32851
33200
|
inspectionDefinitions: new SqliteInspectionDefinitionsRepository(db),
|
|
32852
33201
|
inspectionFindings: new SqliteInspectionFindingsRepository(db),
|
|
@@ -32887,6 +33236,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
32887
33236
|
activity,
|
|
32888
33237
|
sourceProject,
|
|
32889
33238
|
auditEvents,
|
|
33239
|
+
captureStatus,
|
|
32890
33240
|
classifiedData,
|
|
32891
33241
|
inspectionDefinitions,
|
|
32892
33242
|
inspectionFindings,
|
|
@@ -33104,6 +33454,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
33104
33454
|
activity,
|
|
33105
33455
|
sourceProject,
|
|
33106
33456
|
auditEvents,
|
|
33457
|
+
captureStatus,
|
|
33107
33458
|
classifiedData,
|
|
33108
33459
|
inspectionDefinitions,
|
|
33109
33460
|
inspectionFindings,
|
|
@@ -33329,11 +33680,6 @@ function fingerprintValue(key, raw) {
|
|
|
33329
33680
|
// ../../packages/persistence/src/forward-health.ts
|
|
33330
33681
|
import { readFileSync as readFileSync7 } from "fs";
|
|
33331
33682
|
import { join as join9 } from "path";
|
|
33332
|
-
var FAILURES = /* @__PURE__ */ new Set([
|
|
33333
|
-
"unauthorized",
|
|
33334
|
-
"forbidden",
|
|
33335
|
-
"unreachable"
|
|
33336
|
-
]);
|
|
33337
33683
|
var BREAKER_COOLDOWN_MS = 3e4;
|
|
33338
33684
|
function parseForwardHealth(raw, nowMs) {
|
|
33339
33685
|
try {
|
|
@@ -33342,7 +33688,8 @@ function parseForwardHealth(raw, nowMs) {
|
|
|
33342
33688
|
const record2 = parsed2;
|
|
33343
33689
|
const failures = typeof record2.consecutiveFailures === "number" && record2.consecutiveFailures >= 0 ? record2.consecutiveFailures : 0;
|
|
33344
33690
|
const openedAtMs = typeof record2.openedAtMs === "number" && Number.isFinite(record2.openedAtMs) && record2.openedAtMs <= nowMs ? record2.openedAtMs : null;
|
|
33345
|
-
const
|
|
33691
|
+
const parsedFailure = ControlPlaneFailure.safeParse(record2.lastFailure);
|
|
33692
|
+
const lastFailure = parsedFailure.success ? parsedFailure.data : null;
|
|
33346
33693
|
return { consecutiveFailures: failures, openedAtMs, lastFailure };
|
|
33347
33694
|
} catch {
|
|
33348
33695
|
return null;
|
|
@@ -33432,6 +33779,12 @@ var RemoteRequestInvalid = class extends Error {
|
|
|
33432
33779
|
}
|
|
33433
33780
|
cause;
|
|
33434
33781
|
};
|
|
33782
|
+
var RemoteEndpointRefused = class extends Error {
|
|
33783
|
+
constructor(endpoint) {
|
|
33784
|
+
super(`refusing to talk to an unsafe control-plane endpoint: ${originOnly(endpoint)}`);
|
|
33785
|
+
this.name = "RemoteEndpointRefused";
|
|
33786
|
+
}
|
|
33787
|
+
};
|
|
33435
33788
|
var RemoteResponseInvalid = class extends Error {
|
|
33436
33789
|
constructor(route, detail) {
|
|
33437
33790
|
super(`control plane answered ${route} with ${detail}`);
|
|
@@ -33584,14 +33937,15 @@ function parsed(schema, body, route) {
|
|
|
33584
33937
|
}
|
|
33585
33938
|
return result.data;
|
|
33586
33939
|
}
|
|
33587
|
-
function
|
|
33940
|
+
function resolveBaseUrl(endpoint) {
|
|
33941
|
+
if (!isSafeEndpoint(endpoint)) throw new RemoteEndpointRefused(endpoint);
|
|
33588
33942
|
let end = endpoint.length;
|
|
33589
33943
|
while (end > 0 && endpoint.charCodeAt(end - 1) === SLASH2) end -= 1;
|
|
33590
33944
|
return endpoint.slice(0, end);
|
|
33591
33945
|
}
|
|
33592
33946
|
var SLASH2 = "/".charCodeAt(0);
|
|
33593
33947
|
function createRemoteClient(options) {
|
|
33594
|
-
const base =
|
|
33948
|
+
const base = resolveBaseUrl(options.endpoint);
|
|
33595
33949
|
const url2 = (route) => `${base}${route}`;
|
|
33596
33950
|
const common = { apiKey: options.apiKey, timeoutMs: options.timeoutMs };
|
|
33597
33951
|
const sendOne = async (event) => {
|
|
@@ -33721,6 +34075,7 @@ function classifyRemoteFailure(err) {
|
|
|
33721
34075
|
case "RemoteRouteAbsent":
|
|
33722
34076
|
return "route-absent";
|
|
33723
34077
|
case "RemoteRequestInvalid":
|
|
34078
|
+
case "RemoteEndpointRefused":
|
|
33724
34079
|
return "invalid-request";
|
|
33725
34080
|
case "RemoteResponseInvalid":
|
|
33726
34081
|
return "rejected";
|
|
@@ -35873,6 +36228,56 @@ var CONFIG_POSTURE_RULES = [
|
|
|
35873
36228
|
}
|
|
35874
36229
|
];
|
|
35875
36230
|
|
|
36231
|
+
// ../../packages/detections/src/posture/web-capture-posture.ts
|
|
36232
|
+
var RULE_VERSION2 = "1";
|
|
36233
|
+
var DRIFT_MIN_PARSE_FAILURES = 2;
|
|
36234
|
+
var WEB_CAPTURE_DRIFT_STATES = /* @__PURE__ */ new Set([
|
|
36235
|
+
"blind",
|
|
36236
|
+
"degraded"
|
|
36237
|
+
]);
|
|
36238
|
+
var WEB_CAPTURE_DRIFT_RULE = {
|
|
36239
|
+
ruleId: "web-capture-drift",
|
|
36240
|
+
version: RULE_VERSION2,
|
|
36241
|
+
name: "Web chat capture is not reading the site",
|
|
36242
|
+
category: "config",
|
|
36243
|
+
severity: "medium",
|
|
36244
|
+
definition: JSON.stringify({
|
|
36245
|
+
kind: "web-capture-drift",
|
|
36246
|
+
states: [...WEB_CAPTURE_DRIFT_STATES],
|
|
36247
|
+
minParseFailures: DRIFT_MIN_PARSE_FAILURES
|
|
36248
|
+
})
|
|
36249
|
+
};
|
|
36250
|
+
var STATIC_COPY = {
|
|
36251
|
+
active: { headline: "turns are being observed on this site" },
|
|
36252
|
+
unreported: {
|
|
36253
|
+
// Says "recently" rather than "yet": the store read is bounded to
|
|
36254
|
+
// CAPTURE_STATUS_RECENCY_MS, so this state covers a site nothing has ever
|
|
36255
|
+
// reported for AND one whose last report has aged out. The two are the
|
|
36256
|
+
// same fact to a reader — nobody has confirmed anything lately — and the
|
|
36257
|
+
// copy may not claim the stronger of them.
|
|
36258
|
+
headline: `no report in the last ${String(CAPTURE_STATUS_RECENCY_DAYS)} days \u2014 open the site in Chrome with the extension loaded`
|
|
36259
|
+
},
|
|
36260
|
+
standby: {
|
|
36261
|
+
headline: "this build declares no endpoints for the site, so nothing is observed yet"
|
|
36262
|
+
},
|
|
36263
|
+
unpatched: {
|
|
36264
|
+
// Says what the flags say and no more. `patched` is false both for a tap
|
|
36265
|
+
// that installed and hooked neither transport and for one that never ran
|
|
36266
|
+
// at all — a page reports the same status either way, so the copy may not
|
|
36267
|
+
// assert one of them.
|
|
36268
|
+
headline: "the page tap captured neither fetch nor XHR \u2014 it may not have installed; reload the extension at chrome://extensions"
|
|
36269
|
+
},
|
|
36270
|
+
idle: { headline: "watching; no turn has been observed yet" },
|
|
36271
|
+
blind: {
|
|
36272
|
+
headline: "messages were sent in the page that the network capture never saw",
|
|
36273
|
+
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."
|
|
36274
|
+
},
|
|
36275
|
+
degraded: {
|
|
36276
|
+
headline: "the site's payloads no longer carry the fields the extension reads",
|
|
36277
|
+
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."
|
|
36278
|
+
}
|
|
36279
|
+
};
|
|
36280
|
+
|
|
35876
36281
|
// ../../packages/detections/src/security/redos-probe.ts
|
|
35877
36282
|
var BUDGET_MS = 100;
|
|
35878
36283
|
var EXPONENTIAL_UNITS = [
|
|
@@ -39293,86 +39698,10 @@ function createForwardPolicy(deps) {
|
|
|
39293
39698
|
}
|
|
39294
39699
|
|
|
39295
39700
|
// ../../packages/plugin-runtime/src/attached/gateway.ts
|
|
39296
|
-
|
|
39297
|
-
|
|
39298
|
-
|
|
39299
|
-
return
|
|
39300
|
-
}
|
|
39301
|
-
function ruleCategoryMap(wireRules, localRules) {
|
|
39302
|
-
const map2 = /* @__PURE__ */ new Map();
|
|
39303
|
-
for (const rule of wireRules ?? []) map2.set(rule.id, rule.category);
|
|
39304
|
-
for (const rule of localRules ?? []) map2.set(rule.id, rule.category);
|
|
39305
|
-
for (const pack of bundledDetections()) {
|
|
39306
|
-
for (const rule of pack.rules) map2.set(rule.id, rule.category);
|
|
39307
|
-
}
|
|
39308
|
-
return map2;
|
|
39309
|
-
}
|
|
39310
|
-
function policyKey(policy) {
|
|
39311
|
-
return "ruleId" in policy.target ? `rule:${policy.target.ruleId}` : `category:${policy.target.category}`;
|
|
39312
|
-
}
|
|
39313
|
-
function floorFor(policy, categoryByRuleId) {
|
|
39314
|
-
const category = "category" in policy.target ? policy.target.category : categoryByRuleId.get(policy.target.ruleId);
|
|
39315
|
-
return category === void 0 ? null : DEFAULT_ACTIONS[category];
|
|
39316
|
-
}
|
|
39317
|
-
function mergeRaiseOnly(localPolicies, remotePolicies, categoryByRuleId) {
|
|
39318
|
-
const merged = /* @__PURE__ */ new Map();
|
|
39319
|
-
const disabled = [];
|
|
39320
|
-
const remoteCategoryAction = /* @__PURE__ */ new Map();
|
|
39321
|
-
for (const policy of remotePolicies) {
|
|
39322
|
-
if (!policy.enabled) continue;
|
|
39323
|
-
if (!("category" in policy.target)) continue;
|
|
39324
|
-
if (remoteCategoryAction.has(policy.target.category)) continue;
|
|
39325
|
-
const floor = floorFor(policy, categoryByRuleId);
|
|
39326
|
-
remoteCategoryAction.set(
|
|
39327
|
-
policy.target.category,
|
|
39328
|
-
floor !== null && !isActionAtLeast(policy.action, floor) ? floor : policy.action
|
|
39329
|
-
);
|
|
39330
|
-
}
|
|
39331
|
-
for (const policy of localPolicies) {
|
|
39332
|
-
if (!policy.enabled) {
|
|
39333
|
-
disabled.push(policy);
|
|
39334
|
-
continue;
|
|
39335
|
-
}
|
|
39336
|
-
const key = policyKey(policy);
|
|
39337
|
-
if (merged.has(key)) continue;
|
|
39338
|
-
let remoteFloor = null;
|
|
39339
|
-
if ("ruleId" in policy.target) {
|
|
39340
|
-
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
39341
|
-
if (category !== void 0) remoteFloor = remoteCategoryAction.get(category) ?? null;
|
|
39342
|
-
}
|
|
39343
|
-
merged.set(
|
|
39344
|
-
key,
|
|
39345
|
-
remoteFloor !== null && !isActionAtLeast(policy.action, remoteFloor) ? { ...policy, action: remoteFloor } : policy
|
|
39346
|
-
);
|
|
39347
|
-
}
|
|
39348
|
-
const localCategoryAction = /* @__PURE__ */ new Map();
|
|
39349
|
-
for (const policy of merged.values()) {
|
|
39350
|
-
if ("category" in policy.target) localCategoryAction.set(policy.target.category, policy.action);
|
|
39351
|
-
}
|
|
39352
|
-
for (const policy of remotePolicies) {
|
|
39353
|
-
if (!policy.enabled) {
|
|
39354
|
-
disabled.push(policy);
|
|
39355
|
-
continue;
|
|
39356
|
-
}
|
|
39357
|
-
const key = policyKey(policy);
|
|
39358
|
-
const floor = floorFor(policy, categoryByRuleId);
|
|
39359
|
-
let localFloor = null;
|
|
39360
|
-
if ("ruleId" in policy.target) {
|
|
39361
|
-
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
39362
|
-
if (category !== void 0) localFloor = localCategoryAction.get(category) ?? null;
|
|
39363
|
-
}
|
|
39364
|
-
const effectiveFloor = strongerOf(floor, localFloor);
|
|
39365
|
-
const clamped = effectiveFloor !== null && !isActionAtLeast(policy.action, effectiveFloor) ? { ...policy, action: effectiveFloor } : policy;
|
|
39366
|
-
const existing = merged.get(key);
|
|
39367
|
-
if (existing === void 0) {
|
|
39368
|
-
merged.set(key, clamped);
|
|
39369
|
-
continue;
|
|
39370
|
-
}
|
|
39371
|
-
if (actionRank(clamped.action) > actionRank(existing.action)) {
|
|
39372
|
-
merged.set(key, clamped);
|
|
39373
|
-
}
|
|
39374
|
-
}
|
|
39375
|
-
return [...merged.values(), ...disabled];
|
|
39701
|
+
var bundledRulesFlatCache;
|
|
39702
|
+
function bundledRulesFlat() {
|
|
39703
|
+
bundledRulesFlatCache ??= bundledDetections().flatMap((pack) => pack.rules);
|
|
39704
|
+
return bundledRulesFlatCache;
|
|
39376
39705
|
}
|
|
39377
39706
|
var AttachedDataGateway = class {
|
|
39378
39707
|
constructor(deps) {
|
|
@@ -39692,6 +40021,9 @@ var AttachedDataGateway = class {
|
|
|
39692
40021
|
async readSessionProvider(sessionId) {
|
|
39693
40022
|
return this.deps.local.readSessionProvider(sessionId);
|
|
39694
40023
|
}
|
|
40024
|
+
async readCaptureStatuses() {
|
|
40025
|
+
return this.deps.local.readCaptureStatuses();
|
|
40026
|
+
}
|
|
39695
40027
|
async facets() {
|
|
39696
40028
|
return this.deps.local.facets();
|
|
39697
40029
|
}
|
|
@@ -39774,7 +40106,7 @@ var AttachedDataGateway = class {
|
|
|
39774
40106
|
policies: mergeRaiseOnly(
|
|
39775
40107
|
local.policies,
|
|
39776
40108
|
cached2.policies,
|
|
39777
|
-
ruleCategoryMap(cached2.rules, local.rules)
|
|
40109
|
+
ruleCategoryMap(cached2.rules, local.rules, bundledRulesFlat())
|
|
39778
40110
|
),
|
|
39779
40111
|
customKeywords: [...local.customKeywords, ...cached2.customKeywords],
|
|
39780
40112
|
// TAKEN FROM THE CACHE, unlike the two fields below — and the asymmetry
|
|
@@ -39975,10 +40307,15 @@ import { join as join27 } from "path";
|
|
|
39975
40307
|
// ../../packages/plugin-runtime/src/attached/atomic-publish.ts
|
|
39976
40308
|
import { rename as rename2 } from "fs/promises";
|
|
39977
40309
|
var RETRYABLE = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
|
|
39978
|
-
var
|
|
40310
|
+
var IMMEDIATE_RETRIES = 8;
|
|
40311
|
+
var TIMED_RETRIES = 4;
|
|
40312
|
+
var ATTEMPTS = 1 + IMMEDIATE_RETRIES + TIMED_RETRIES;
|
|
39979
40313
|
var delay = (ms) => new Promise((resolve2) => {
|
|
39980
40314
|
setTimeout(resolve2, ms);
|
|
39981
40315
|
});
|
|
40316
|
+
var yieldToLoop = () => new Promise((resolve2) => {
|
|
40317
|
+
setImmediate(resolve2);
|
|
40318
|
+
});
|
|
39982
40319
|
async function publishByRename(tmp, file2, move = rename2) {
|
|
39983
40320
|
for (let attempt = 1; ; attempt += 1) {
|
|
39984
40321
|
try {
|
|
@@ -39987,7 +40324,7 @@ async function publishByRename(tmp, file2, move = rename2) {
|
|
|
39987
40324
|
} catch (err) {
|
|
39988
40325
|
const code = err.code;
|
|
39989
40326
|
if (attempt >= ATTEMPTS || code === void 0 || !RETRYABLE.has(code)) throw err;
|
|
39990
|
-
await delay(attempt * 10);
|
|
40327
|
+
await (attempt <= IMMEDIATE_RETRIES ? yieldToLoop() : delay((attempt - IMMEDIATE_RETRIES) * 10));
|
|
39991
40328
|
}
|
|
39992
40329
|
}
|
|
39993
40330
|
}
|
|
@@ -40535,6 +40872,9 @@ var StandaloneDataGateway = class {
|
|
|
40535
40872
|
readSessionProvider(sessionId) {
|
|
40536
40873
|
return Promise.resolve(this.db.auditEvents.sessionProvider(sessionId));
|
|
40537
40874
|
}
|
|
40875
|
+
readCaptureStatuses() {
|
|
40876
|
+
return Promise.resolve(this.db.captureStatus.latest(Date.now()));
|
|
40877
|
+
}
|
|
40538
40878
|
facets() {
|
|
40539
40879
|
return Promise.resolve(this.db.facets());
|
|
40540
40880
|
}
|