@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
|
@@ -20482,7 +20482,17 @@ var UNPRICEABLE_PROVIDERS = Object.freeze([
|
|
|
20482
20482
|
"gateway",
|
|
20483
20483
|
"unknown",
|
|
20484
20484
|
"cli",
|
|
20485
|
-
"api"
|
|
20485
|
+
"api",
|
|
20486
|
+
// The browser extension's native host records these as `llm_call.provider`
|
|
20487
|
+
// for a web-chat turn — the web tool id, deliberately never the vendor id
|
|
20488
|
+
// (`openai`/`anthropic`) the session root carries. Subscription traffic
|
|
20489
|
+
// burns rate-limit budget, not dollar credits, and listing them here is
|
|
20490
|
+
// what keeps that true structurally: a later maintainer who wants to price
|
|
20491
|
+
// web-chat traffic at API rates has to delete this entry first, and meet
|
|
20492
|
+
// the reason on the way, rather than quietly adding one to
|
|
20493
|
+
// PROVIDER_PLATFORM.
|
|
20494
|
+
"chatgpt",
|
|
20495
|
+
"claude-ai"
|
|
20486
20496
|
]);
|
|
20487
20497
|
function platformForProvider(provider) {
|
|
20488
20498
|
return PROVIDER_PLATFORM.get(provider.trim().toLowerCase()) ?? null;
|
|
@@ -20625,7 +20635,12 @@ var HARNESS = {
|
|
|
20625
20635
|
ClaudeDesktop: "claudedesktop",
|
|
20626
20636
|
ChatGpt: "chatgpt",
|
|
20627
20637
|
ClaudeAi: "claudeai",
|
|
20628
|
-
Api: "api"
|
|
20638
|
+
Api: "api",
|
|
20639
|
+
// Not a coding assistant a person drives — an in-process SDK embedded in an
|
|
20640
|
+
// application, so it has no IDE/CLI/desktop/web surface of its own. Carries
|
|
20641
|
+
// the same id as its SOURCE_TOOL counterpart, unlike every capture-side tool
|
|
20642
|
+
// whose wire spelling differs from its display spelling.
|
|
20643
|
+
AiTcSdk: "ai-tc-sdk"
|
|
20629
20644
|
};
|
|
20630
20645
|
var Harness = external_exports.enum(HARNESS).meta({ id: "Harness" });
|
|
20631
20646
|
var SOURCE_TOOL = {
|
|
@@ -20641,9 +20656,15 @@ var SOURCE_TOOL = {
|
|
|
20641
20656
|
// whose tool could not be identified both render through the read side's
|
|
20642
20657
|
// miss path rather than as a harness of their own.
|
|
20643
20658
|
Cli: "cli",
|
|
20644
|
-
Unknown: "unknown"
|
|
20659
|
+
Unknown: "unknown",
|
|
20660
|
+
// The wire id an in-process, request-path SDK stamps on its own structural
|
|
20661
|
+
// rows (`request_decision`) — never a capture of prompt/response/tool text,
|
|
20662
|
+
// since the SDK sits in front of a model call rather than inside a coding
|
|
20663
|
+
// assistant's own hook contract.
|
|
20664
|
+
AiTcSdk: "ai-tc-sdk"
|
|
20645
20665
|
};
|
|
20646
20666
|
var SourceTool = external_exports.enum(SOURCE_TOOL).meta({ id: "SourceTool" });
|
|
20667
|
+
var WebSourceTool = SourceTool.extract(["ChatGpt", "ClaudeAi"]);
|
|
20647
20668
|
var TOOL_TO_HARNESS = {
|
|
20648
20669
|
[SOURCE_TOOL.ClaudeCode]: HARNESS.ClaudeCode,
|
|
20649
20670
|
[SOURCE_TOOL.ClaudeDesktop]: HARNESS.ClaudeDesktop,
|
|
@@ -20652,7 +20673,12 @@ var TOOL_TO_HARNESS = {
|
|
|
20652
20673
|
[SOURCE_TOOL.ChatGpt]: HARNESS.ChatGpt,
|
|
20653
20674
|
[SOURCE_TOOL.Codex]: HARNESS.Codex,
|
|
20654
20675
|
[SOURCE_TOOL.Antigravity]: HARNESS.Antigravity,
|
|
20655
|
-
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi
|
|
20676
|
+
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi,
|
|
20677
|
+
// Wire and display id are the same string here, but the row still belongs:
|
|
20678
|
+
// both vocabularies carry the `AiTcSdk` member, and the join is exactly
|
|
20679
|
+
// their intersection — leaving a shared member out would read as an
|
|
20680
|
+
// uninstrumented tool on both surfaces, which this one is not.
|
|
20681
|
+
[SOURCE_TOOL.AiTcSdk]: HARNESS.AiTcSdk
|
|
20656
20682
|
};
|
|
20657
20683
|
|
|
20658
20684
|
// ../../packages/schema/src/zod/finding.ts
|
|
@@ -20686,7 +20712,8 @@ var FindingProvider = Harness.extract([
|
|
|
20686
20712
|
"ClaudeAi",
|
|
20687
20713
|
"Codex",
|
|
20688
20714
|
"Antigravity",
|
|
20689
|
-
"Api"
|
|
20715
|
+
"Api",
|
|
20716
|
+
"AiTcSdk"
|
|
20690
20717
|
]).meta({ id: "FindingProvider" });
|
|
20691
20718
|
var FindingCategory = external_exports.enum([
|
|
20692
20719
|
"secret",
|
|
@@ -21063,18 +21090,41 @@ var AuditEventType = external_exports.enum([
|
|
|
21063
21090
|
// 'tool_call' is the reconciler's structural row for every call, while
|
|
21064
21091
|
// 'tool_use' exists only where a hook enforced against the arguments.
|
|
21065
21092
|
"tool_use",
|
|
21066
|
-
// One row per model REFUSAL
|
|
21067
|
-
//
|
|
21068
|
-
//
|
|
21069
|
-
//
|
|
21070
|
-
//
|
|
21071
|
-
//
|
|
21093
|
+
// One row per model REFUSAL, across all four seams a prohibited model can be
|
|
21094
|
+
// stopped at: a switch onto it, a turn already running on it, a subagent
|
|
21095
|
+
// spawn asking for it, or a request-path refusal an embedded request-path
|
|
21096
|
+
// SDK makes in-process before the call leaves the application. Which seam
|
|
21097
|
+
// rides `attributes.refusal_seam`, never this member name. A structural row
|
|
21098
|
+
// like the ones above rather than a capture — it carries the model that was
|
|
21099
|
+
// refused and nothing the user typed, because what is worth recording about
|
|
21100
|
+
// a governance decision is the decision, and prompt text is the thing this
|
|
21101
|
+
// product exists to keep from travelling.
|
|
21072
21102
|
"model_refusal",
|
|
21103
|
+
// One row per request-path DECISION: a policy check an embedded request-path
|
|
21104
|
+
// SDK performs in-process before a model call leaves the application, or
|
|
21105
|
+
// against that call's non-streamed response. A structural row like
|
|
21106
|
+
// 'model_refusal' rather than a capture — content-free in the same way:
|
|
21107
|
+
// which side, which seam, what action and which field are decided rides
|
|
21108
|
+
// `attributes`, never this member name, and the matched text itself never
|
|
21109
|
+
// travels.
|
|
21110
|
+
//
|
|
21111
|
+
// A prohibited-model refusal on the request path is deliberately NOT this
|
|
21112
|
+
// member: it stays 'model_refusal' with `refusal_seam: 'request'`, so it
|
|
21113
|
+
// shares one bucket with the plugin's switch/turn/spawn refusals rather
|
|
21114
|
+
// than splitting one governance concept across two event types. This
|
|
21115
|
+
// member carries every OTHER request-path decision.
|
|
21116
|
+
"request_decision",
|
|
21073
21117
|
// One row per config-inventory scan, hung off the session root. It is the
|
|
21074
21118
|
// fact the posture inspection findings reference (findings require an
|
|
21075
21119
|
// audit_event_id), and its started_at is the "scanned Nm ago" the read
|
|
21076
21120
|
// surface renders.
|
|
21077
|
-
"config_scan"
|
|
21121
|
+
"config_scan",
|
|
21122
|
+
// One row per reported browser-extension capture status, hung off the web
|
|
21123
|
+
// session root. The durable home of what one tab's network interception
|
|
21124
|
+
// is doing — a write-through of the native host's in-memory tracker, so a
|
|
21125
|
+
// second process (aka extension status) and a restarted host both have
|
|
21126
|
+
// somewhere to read it back from.
|
|
21127
|
+
"capture_status"
|
|
21078
21128
|
]).meta({ id: "AuditEventType" });
|
|
21079
21129
|
var AttributeBag = external_exports.record(external_exports.string(), external_exports.unknown());
|
|
21080
21130
|
var HostAttributes = external_exports.object({
|
|
@@ -21234,6 +21284,20 @@ var CaptureAttributes = external_exports.object({
|
|
|
21234
21284
|
// repeated rather than referenced because a store reader opens this file.
|
|
21235
21285
|
redact_degraded_to: ActionTaken.optional()
|
|
21236
21286
|
}).catchall(external_exports.unknown());
|
|
21287
|
+
var CaptureStatusAttributes = external_exports.object({
|
|
21288
|
+
source_tool: external_exports.string().optional(),
|
|
21289
|
+
patched: external_exports.boolean().optional(),
|
|
21290
|
+
live: external_exports.boolean().optional(),
|
|
21291
|
+
blind: external_exports.boolean().optional(),
|
|
21292
|
+
sends_seen_dom: external_exports.number().int().nonnegative().optional(),
|
|
21293
|
+
exchanges_seen_net: external_exports.number().int().nonnegative().optional(),
|
|
21294
|
+
parse_failures: external_exports.number().int().nonnegative().optional(),
|
|
21295
|
+
unparsed_bodies: external_exports.number().int().nonnegative().optional(),
|
|
21296
|
+
shape_misses: external_exports.array(external_exports.string()).optional(),
|
|
21297
|
+
conversation_endpoints: external_exports.number().int().nonnegative().optional(),
|
|
21298
|
+
closed: external_exports.boolean().optional(),
|
|
21299
|
+
enforcement: external_exports.string().optional()
|
|
21300
|
+
}).catchall(external_exports.unknown());
|
|
21237
21301
|
var ToolCallInspection = external_exports.object({
|
|
21238
21302
|
ruleId: external_exports.string().min(1),
|
|
21239
21303
|
ruleName: external_exports.string(),
|
|
@@ -22093,6 +22157,30 @@ var AttachedCredential = external_exports.object({
|
|
|
22093
22157
|
keyPrefix: external_exports.string().min(1).max(16).optional(),
|
|
22094
22158
|
mintedAt: external_exports.iso.datetime().optional()
|
|
22095
22159
|
});
|
|
22160
|
+
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
22161
|
+
function unsafeEndpointReason(endpoint) {
|
|
22162
|
+
let parsed2;
|
|
22163
|
+
try {
|
|
22164
|
+
parsed2 = new URL(endpoint);
|
|
22165
|
+
} catch {
|
|
22166
|
+
return "unparseable";
|
|
22167
|
+
}
|
|
22168
|
+
if (parsed2.username !== "" || parsed2.password !== "") return "userinfo";
|
|
22169
|
+
if (parsed2.search !== "" || parsed2.hash !== "") return "query-or-fragment";
|
|
22170
|
+
if (parsed2.protocol === "https:") return null;
|
|
22171
|
+
return parsed2.protocol === "http:" && LOOPBACK_HOSTS.has(parsed2.hostname) ? null : "insecure";
|
|
22172
|
+
}
|
|
22173
|
+
function isSafeEndpoint(endpoint) {
|
|
22174
|
+
return unsafeEndpointReason(endpoint) === null;
|
|
22175
|
+
}
|
|
22176
|
+
function originOnly(endpoint) {
|
|
22177
|
+
try {
|
|
22178
|
+
const parsed2 = new URL(endpoint);
|
|
22179
|
+
return `${parsed2.protocol}//${parsed2.host}`;
|
|
22180
|
+
} catch {
|
|
22181
|
+
return "(unparseable endpoint)";
|
|
22182
|
+
}
|
|
22183
|
+
}
|
|
22096
22184
|
var MAX_DATE_MS = 253402300799999;
|
|
22097
22185
|
var MAX_INT4 = 2147483647;
|
|
22098
22186
|
var StorePosturePack = external_exports.object({
|
|
@@ -22247,6 +22335,11 @@ var RemoteFailureKind = external_exports.enum([
|
|
|
22247
22335
|
"rejected",
|
|
22248
22336
|
"unreachable"
|
|
22249
22337
|
]);
|
|
22338
|
+
var ControlPlaneFailure = RemoteFailureKind.extract([
|
|
22339
|
+
"unauthorized",
|
|
22340
|
+
"forbidden",
|
|
22341
|
+
"unreachable"
|
|
22342
|
+
]);
|
|
22250
22343
|
var AttachDeviceRequest = external_exports.object({
|
|
22251
22344
|
// This machine's own continuity id, so re-attaching ROTATES the credential
|
|
22252
22345
|
// on one machine record instead of producing a second one. Client-minted
|
|
@@ -22786,7 +22879,12 @@ var EventMetadata = external_exports.object({
|
|
|
22786
22879
|
// in — set by the browser extension's network capture so a stored `response`
|
|
22787
22880
|
// row can be joined to the `llm_call` leaf describing the same turn. Absent
|
|
22788
22881
|
// on every other capture path, which has no such id.
|
|
22789
|
-
|
|
22882
|
+
//
|
|
22883
|
+
// Non-empty for the reason WebExchange.messageId is: it is the join key, and
|
|
22884
|
+
// a blank one matches no `llm_call` leaf. That refusal reaches only the
|
|
22885
|
+
// places an event is PARSED; the local write path types the event and parses
|
|
22886
|
+
// nothing, which is why `toCaptureAttributes` omits a blank one separately.
|
|
22887
|
+
messageId: external_exports.string().min(1).optional(),
|
|
22790
22888
|
conversationId: external_exports.string().optional(),
|
|
22791
22889
|
// How long THIS capture's inspection blocked its caller, in whole
|
|
22792
22890
|
// milliseconds — the plugin's own added latency, NOT the LLM call it sat in
|
|
@@ -23633,6 +23731,85 @@ function policyIdIsReversible(policyId) {
|
|
|
23633
23731
|
var DEFAULT_ACTIONS = Object.fromEntries(
|
|
23634
23732
|
DetectionCategory.options.map((c) => [c, builtinPolicyToAction(severityFloorPolicy(c))])
|
|
23635
23733
|
);
|
|
23734
|
+
function ruleCategoryMap(wireRules, localRules, compiledRules) {
|
|
23735
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
23736
|
+
for (const rule of wireRules ?? []) map2.set(rule.id, rule.category);
|
|
23737
|
+
for (const rule of localRules ?? []) map2.set(rule.id, rule.category);
|
|
23738
|
+
for (const rule of compiledRules) map2.set(rule.id, rule.category);
|
|
23739
|
+
return map2;
|
|
23740
|
+
}
|
|
23741
|
+
function policyKey(policy) {
|
|
23742
|
+
return "ruleId" in policy.target ? `rule:${policy.target.ruleId}` : `category:${policy.target.category}`;
|
|
23743
|
+
}
|
|
23744
|
+
function floorFor(policy, categoryByRuleId) {
|
|
23745
|
+
const category = "category" in policy.target ? policy.target.category : categoryByRuleId.get(policy.target.ruleId);
|
|
23746
|
+
return category === void 0 ? null : DEFAULT_ACTIONS[category];
|
|
23747
|
+
}
|
|
23748
|
+
function strongerOf(a, b) {
|
|
23749
|
+
if (a === null) return b;
|
|
23750
|
+
if (b === null) return a;
|
|
23751
|
+
return strongerAction(a, b);
|
|
23752
|
+
}
|
|
23753
|
+
function mergeRaiseOnly(localPolicies, remotePolicies, categoryByRuleId) {
|
|
23754
|
+
const merged = /* @__PURE__ */ new Map();
|
|
23755
|
+
const disabled = [];
|
|
23756
|
+
const remoteCategoryAction = /* @__PURE__ */ new Map();
|
|
23757
|
+
for (const policy of remotePolicies) {
|
|
23758
|
+
if (!policy.enabled) continue;
|
|
23759
|
+
if (!("category" in policy.target)) continue;
|
|
23760
|
+
if (remoteCategoryAction.has(policy.target.category)) continue;
|
|
23761
|
+
const floor = floorFor(policy, categoryByRuleId);
|
|
23762
|
+
remoteCategoryAction.set(
|
|
23763
|
+
policy.target.category,
|
|
23764
|
+
floor !== null && !isActionAtLeast(policy.action, floor) ? floor : policy.action
|
|
23765
|
+
);
|
|
23766
|
+
}
|
|
23767
|
+
for (const policy of localPolicies) {
|
|
23768
|
+
if (!policy.enabled) {
|
|
23769
|
+
disabled.push(policy);
|
|
23770
|
+
continue;
|
|
23771
|
+
}
|
|
23772
|
+
const key = policyKey(policy);
|
|
23773
|
+
if (merged.has(key)) continue;
|
|
23774
|
+
let remoteFloor = null;
|
|
23775
|
+
if ("ruleId" in policy.target) {
|
|
23776
|
+
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
23777
|
+
if (category !== void 0) remoteFloor = remoteCategoryAction.get(category) ?? null;
|
|
23778
|
+
}
|
|
23779
|
+
merged.set(
|
|
23780
|
+
key,
|
|
23781
|
+
remoteFloor !== null && !isActionAtLeast(policy.action, remoteFloor) ? { ...policy, action: remoteFloor } : policy
|
|
23782
|
+
);
|
|
23783
|
+
}
|
|
23784
|
+
const localCategoryAction = /* @__PURE__ */ new Map();
|
|
23785
|
+
for (const policy of merged.values()) {
|
|
23786
|
+
if ("category" in policy.target) localCategoryAction.set(policy.target.category, policy.action);
|
|
23787
|
+
}
|
|
23788
|
+
for (const policy of remotePolicies) {
|
|
23789
|
+
if (!policy.enabled) {
|
|
23790
|
+
disabled.push(policy);
|
|
23791
|
+
continue;
|
|
23792
|
+
}
|
|
23793
|
+
const key = policyKey(policy);
|
|
23794
|
+
const floor = floorFor(policy, categoryByRuleId);
|
|
23795
|
+
let localFloor = null;
|
|
23796
|
+
if ("ruleId" in policy.target) {
|
|
23797
|
+
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
23798
|
+
if (category !== void 0) localFloor = localCategoryAction.get(category) ?? null;
|
|
23799
|
+
}
|
|
23800
|
+
const effectiveFloor = strongerOf(floor, localFloor);
|
|
23801
|
+
const clamped = effectiveFloor !== null && !isActionAtLeast(policy.action, effectiveFloor) ? { ...policy, action: effectiveFloor } : policy;
|
|
23802
|
+
const existing = merged.get(key);
|
|
23803
|
+
if (existing === void 0) {
|
|
23804
|
+
merged.set(key, clamped);
|
|
23805
|
+
continue;
|
|
23806
|
+
}
|
|
23807
|
+
if (actionRank(clamped.action) > actionRank(existing.action)) {
|
|
23808
|
+
merged.set(key, clamped);
|
|
23809
|
+
}
|
|
23810
|
+
}
|
|
23811
|
+
return [...merged.values(), ...disabled];
|
|
23812
|
+
}
|
|
23636
23813
|
var BUILTIN_POLICIES = Object.fromEntries(
|
|
23637
23814
|
KNOWN_BUILTIN_IDS.map((id) => [id, { id, ...BUILTIN_POLICY_SPECS[id] }])
|
|
23638
23815
|
);
|
|
@@ -23865,6 +24042,18 @@ var HistorySyncConsent = external_exports.object({
|
|
|
23865
24042
|
payloadVersion: external_exports.number().int().positive(),
|
|
23866
24043
|
endpoint: external_exports.string()
|
|
23867
24044
|
});
|
|
24045
|
+
var WebChatCaptureConsent = external_exports.object({
|
|
24046
|
+
acknowledgedAt: external_exports.iso.datetime(),
|
|
24047
|
+
version: external_exports.number().int().positive()
|
|
24048
|
+
});
|
|
24049
|
+
var WebChatResponseCapture = external_exports.enum(["with-findings", "always", "never"]);
|
|
24050
|
+
var WebChatCapture = external_exports.object({
|
|
24051
|
+
responses: WebChatResponseCapture.default("with-findings"),
|
|
24052
|
+
account: external_exports.boolean().default(false),
|
|
24053
|
+
// Absent until granted. Presence alone does not authorize anything — see
|
|
24054
|
+
// isWebChatCaptureConsentValid.
|
|
24055
|
+
consent: WebChatCaptureConsent.optional()
|
|
24056
|
+
});
|
|
23868
24057
|
var BODY_RETENTION_DEFAULT_DAYS = 30;
|
|
23869
24058
|
var BodyRetention = external_exports.object({
|
|
23870
24059
|
enabled: external_exports.boolean().default(false),
|
|
@@ -23923,6 +24112,16 @@ var WorkspaceSettings = external_exports.object({
|
|
|
23923
24112
|
// both widenings. Absent until granted, and a grant for a different endpoint
|
|
23924
24113
|
// or an older payload no longer counts.
|
|
23925
24114
|
historySyncConsent: HistorySyncConsent.optional(),
|
|
24115
|
+
// What the browser extension may record from a web chat, and the grant that
|
|
24116
|
+
// authorizes it. Absent until the user answers: recording something that was
|
|
24117
|
+
// never recorded before is never an assumed grant on upgrade, so the whole
|
|
24118
|
+
// block is optional rather than defaulted in. What an absent block means is
|
|
24119
|
+
// webChatCaptureOf's answer, in one place.
|
|
24120
|
+
//
|
|
24121
|
+
// Enforcement is NOT gated on this. A machine that has never answered still
|
|
24122
|
+
// blocks, redacts and warns on what a user sends; the grant covers what is
|
|
24123
|
+
// written down.
|
|
24124
|
+
webChatCapture: WebChatCapture.optional(),
|
|
23926
24125
|
// Local body expiry (see BodyRetention). Off until switched on; expiring a
|
|
23927
24126
|
// body never removes the row or its findings.
|
|
23928
24127
|
bodyRetention: BodyRetention.default({
|
|
@@ -24030,7 +24229,10 @@ function toCaptureAttributes(event) {
|
|
|
24030
24229
|
// `.catchall(z.unknown())` carries the long tail.
|
|
24031
24230
|
...metadata?.model !== void 0 ? { model: metadata.model } : {},
|
|
24032
24231
|
...metadata?.turnIndex !== void 0 ? { turn_index: metadata.turnIndex } : {},
|
|
24033
|
-
|
|
24232
|
+
// A blank id is omitted rather than stored: it is a join key and `''` joins
|
|
24233
|
+
// nothing. This runs on the local write path, which types the event but
|
|
24234
|
+
// never parses it, so EventMetadata's own `.min(1)` does not reach here.
|
|
24235
|
+
...metadata?.messageId !== void 0 && metadata.messageId !== "" ? { message_id: metadata.messageId } : {},
|
|
24034
24236
|
...metadata?.conversationId !== void 0 ? { conversation_id: metadata.conversationId } : {}
|
|
24035
24237
|
};
|
|
24036
24238
|
}
|
|
@@ -24404,12 +24606,14 @@ var RecommendedActionIdParam = external_exports.object({ id: external_exports.st
|
|
|
24404
24606
|
// ../../packages/schema/src/zod/settings-action.ts
|
|
24405
24607
|
var HistorySyncConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "HistorySyncConsentChoice" });
|
|
24406
24608
|
var ModelJudgeConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "ModelJudgeConsentChoice" });
|
|
24609
|
+
var WebChatCaptureConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "WebChatCaptureConsentChoice" });
|
|
24407
24610
|
var SaveSettingsInput = external_exports.object({
|
|
24408
24611
|
historicalAccess: external_exports.string(),
|
|
24409
24612
|
modelJudgeConsent: ModelJudgeConsentChoice,
|
|
24410
24613
|
historySyncConsent: HistorySyncConsentChoice,
|
|
24411
24614
|
vaultConsent: external_exports.string(),
|
|
24412
24615
|
vaultInlineReveal: external_exports.string(),
|
|
24616
|
+
webChatCaptureConsent: WebChatCaptureConsentChoice,
|
|
24413
24617
|
// Widened to `string` like its neighbours rather than typed as
|
|
24414
24618
|
// `RedactFallback`, on this module's own layering rule: shape here, VALUE at
|
|
24415
24619
|
// the call site, so the domain check receives the type it was written for.
|
|
@@ -24624,11 +24828,24 @@ var WebExchange = external_exports.object({
|
|
|
24624
24828
|
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
24625
24829
|
toolCalls: external_exports.array(WebToolCall).default([]),
|
|
24626
24830
|
// Absent when the adapter recovered no text. Capped by the caller at
|
|
24627
|
-
// RESPONSE_TEXT_MAX_BYTES
|
|
24628
|
-
//
|
|
24831
|
+
// RESPONSE_TEXT_MAX_BYTES, so a short capture is never mistaken for a short
|
|
24832
|
+
// reply.
|
|
24629
24833
|
responseText: external_exports.string().optional(),
|
|
24834
|
+
// The stored text is short of the reply. It does NOT say which of the two
|
|
24835
|
+
// ceilings on this path cut it: the caller applies its own cap on the raw
|
|
24836
|
+
// bytes it reads off the wire, which can be reached by a stream whose
|
|
24837
|
+
// recovered text stays well under RESPONSE_TEXT_MAX_BYTES, and applies that
|
|
24838
|
+
// one to the text. A reader cannot tell them apart, and nothing downstream
|
|
24839
|
+
// should branch as though it could.
|
|
24630
24840
|
truncated: external_exports.boolean().default(false)
|
|
24631
24841
|
});
|
|
24842
|
+
var WebEnforcementState = external_exports.enum([
|
|
24843
|
+
"watching",
|
|
24844
|
+
"composer-only",
|
|
24845
|
+
"button-only",
|
|
24846
|
+
"unattached",
|
|
24847
|
+
"unknown"
|
|
24848
|
+
]);
|
|
24632
24849
|
var RESPONSE_TEXT_MAX_BYTES = 2 * 1024 * 1024;
|
|
24633
24850
|
var WebCaptureStatus = external_exports.object({
|
|
24634
24851
|
patched: external_exports.boolean(),
|
|
@@ -24640,8 +24857,66 @@ var WebCaptureStatus = external_exports.object({
|
|
|
24640
24857
|
unparsedBodies: external_exports.number().int().nonnegative(),
|
|
24641
24858
|
// The adapter-declared JSON key paths that were absent from a real payload —
|
|
24642
24859
|
// the earliest signal that a site's contract moved.
|
|
24643
|
-
shapeMisses: external_exports.array(external_exports.string()).default([])
|
|
24644
|
-
|
|
24860
|
+
shapeMisses: external_exports.array(external_exports.string()).default([]),
|
|
24861
|
+
// How many `kind: 'conversation'` endpoints the reporting tab's adapter
|
|
24862
|
+
// compiled. Zero means this build declares none for the site, so observing
|
|
24863
|
+
// nothing is the design rather than a fault — the one fact that separates a
|
|
24864
|
+
// site nobody has surveyed yet from one whose contract moved. Defaulted so a
|
|
24865
|
+
// build predating the field is read as declaring nothing rather than refused.
|
|
24866
|
+
conversationEndpoints: external_exports.number().int().nonnegative().default(0),
|
|
24867
|
+
// The document that sent this report is going away. The bridge sets it on
|
|
24868
|
+
// its `pagehide` report and nowhere else.
|
|
24869
|
+
//
|
|
24870
|
+
// A property of the REPORT rather than of capture health, which is why
|
|
24871
|
+
// nothing in `deriveWebCaptureState` reads it and why it stays out of the
|
|
24872
|
+
// bridge's own report signature — a closing tab's last word must not be
|
|
24873
|
+
// suppressed for carrying the same health as the report before it. What
|
|
24874
|
+
// reads it is the per-site fold: a document that said it was unloading stops
|
|
24875
|
+
// voting on the site's state, so the reload the `blind` remediation asks for
|
|
24876
|
+
// can actually clear the verdict it was shown. A document that dies without
|
|
24877
|
+
// sending one is covered by CAPTURE_STATUS_DOCUMENT_QUIET_MS instead.
|
|
24878
|
+
//
|
|
24879
|
+
// Defaulted so a build predating the field reads as a document that never
|
|
24880
|
+
// said it was closing — which keeps it voting, the same as every report that
|
|
24881
|
+
// is not a final one.
|
|
24882
|
+
closed: external_exports.boolean().default(false),
|
|
24883
|
+
// What the DOM enforcement path is doing, which none of the counters above
|
|
24884
|
+
// can say: `sendsSeenDom` rises only once a send has COMPLETED, so a tab
|
|
24885
|
+
// whose watcher never bound reports zero exactly like a tab nobody typed in.
|
|
24886
|
+
// Defaulted to 'unknown' rather than 'watching' so a status from a build
|
|
24887
|
+
// predating the field is not read as reporting a healthy one.
|
|
24888
|
+
enforcement: WebEnforcementState.default("unknown")
|
|
24889
|
+
});
|
|
24890
|
+
function webCaptureStatusObservedTurnPath(status) {
|
|
24891
|
+
if (!status.patched) return true;
|
|
24892
|
+
if (status.conversationEndpoints === 0) return true;
|
|
24893
|
+
return status.blind || status.shapeMisses.length > 0 || status.parseFailures > 0 || status.unparsedBodies > 0 || status.exchangesSeenNet > 0;
|
|
24894
|
+
}
|
|
24895
|
+
function pickReportedCaptureStatus(candidates) {
|
|
24896
|
+
return candidates.find((c) => webCaptureStatusObservedTurnPath(c.status)) ?? candidates[0];
|
|
24897
|
+
}
|
|
24898
|
+
var CAPTURE_STATUS_RECENCY_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
24899
|
+
var CAPTURE_STATUS_RECENCY_DAYS = CAPTURE_STATUS_RECENCY_MS / (24 * 60 * 60 * 1e3);
|
|
24900
|
+
var CAPTURE_STATUS_DOCUMENT_QUIET_MS = 12 * 60 * 60 * 1e3;
|
|
24901
|
+
function fromCaptureStatusAttributes(bag) {
|
|
24902
|
+
const parsedBag = CaptureStatusAttributes.safeParse(bag);
|
|
24903
|
+
if (!parsedBag.success) return null;
|
|
24904
|
+
const b = parsedBag.data;
|
|
24905
|
+
const parsedStatus = WebCaptureStatus.safeParse({
|
|
24906
|
+
patched: b.patched,
|
|
24907
|
+
live: b.live,
|
|
24908
|
+
blind: b.blind,
|
|
24909
|
+
sendsSeenDom: b.sends_seen_dom,
|
|
24910
|
+
exchangesSeenNet: b.exchanges_seen_net,
|
|
24911
|
+
parseFailures: b.parse_failures,
|
|
24912
|
+
unparsedBodies: b.unparsed_bodies,
|
|
24913
|
+
shapeMisses: b.shape_misses,
|
|
24914
|
+
conversationEndpoints: b.conversation_endpoints,
|
|
24915
|
+
closed: b.closed,
|
|
24916
|
+
enforcement: b.enforcement
|
|
24917
|
+
});
|
|
24918
|
+
return parsedStatus.success ? parsedStatus.data : null;
|
|
24919
|
+
}
|
|
24645
24920
|
|
|
24646
24921
|
// ../../packages/persistence/src/paths.ts
|
|
24647
24922
|
import {
|
|
@@ -24772,17 +25047,6 @@ function publishByLink(tmp, file2, data) {
|
|
|
24772
25047
|
function controlPlaneCredentialPath(settingsDir2) {
|
|
24773
25048
|
return join2(settingsDir2, ATTACHED_CREDENTIAL_FILENAME);
|
|
24774
25049
|
}
|
|
24775
|
-
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
24776
|
-
function isSafeEndpoint(endpoint) {
|
|
24777
|
-
let parsed2;
|
|
24778
|
-
try {
|
|
24779
|
-
parsed2 = new URL(endpoint);
|
|
24780
|
-
} catch {
|
|
24781
|
-
return false;
|
|
24782
|
-
}
|
|
24783
|
-
if (parsed2.protocol === "https:") return true;
|
|
24784
|
-
return parsed2.protocol === "http:" && LOOPBACK_HOSTS.has(parsed2.hostname);
|
|
24785
|
-
}
|
|
24786
25050
|
function repairOrRefuseMode(file2) {
|
|
24787
25051
|
const link = lstatSync2(file2, { throwIfNoEntry: false });
|
|
24788
25052
|
if (link === void 0) return "absent";
|
|
@@ -26575,7 +26839,7 @@ var SESSION_ROOT = `event_type = 'session'`;
|
|
|
26575
26839
|
var HAS_ACTIVITY = `EXISTS (
|
|
26576
26840
|
SELECT 1 FROM audit_events c
|
|
26577
26841
|
WHERE c.root_session_id = audit_events.id
|
|
26578
|
-
AND c.event_type NOT IN ('hook', 'config_scan'))`;
|
|
26842
|
+
AND c.event_type NOT IN ('hook', 'config_scan', 'capture_status'))`;
|
|
26579
26843
|
var SqliteActivityRepository = class {
|
|
26580
26844
|
constructor(db, now = () => Date.now()) {
|
|
26581
26845
|
this.db = db;
|
|
@@ -26602,10 +26866,10 @@ var SqliteActivityRepository = class {
|
|
|
26602
26866
|
SELECT id FROM audit_events WHERE event_type = 'session' AND started_at >= ?
|
|
26603
26867
|
UNION
|
|
26604
26868
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_started_at
|
|
26605
|
-
WHERE started_at >= ?
|
|
26869
|
+
WHERE started_at >= ? AND event_type <> 'capture_status'
|
|
26606
26870
|
UNION
|
|
26607
26871
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_ended_at
|
|
26608
|
-
WHERE ended_at >= ?)`,
|
|
26872
|
+
WHERE ended_at >= ? AND event_type <> 'capture_status')`,
|
|
26609
26873
|
[liveThreshold, liveThreshold, liveThreshold]
|
|
26610
26874
|
);
|
|
26611
26875
|
const toolCallsToday = countScalar(
|
|
@@ -27012,7 +27276,10 @@ var SqliteAuditEventsRepository = class {
|
|
|
27012
27276
|
attributes = excluded.attributes,
|
|
27013
27277
|
ended_at = excluded.ended_at
|
|
27014
27278
|
WHERE COALESCE(json_extract(excluded.attributes, '$.output_tokens'), 0)
|
|
27015
|
-
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27279
|
+
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27280
|
+
OR (json_extract(excluded.attributes, '$.usage_source') IS NOT NULL
|
|
27281
|
+
AND json_extract(excluded.attributes, '$.output_tokens') IS NULL
|
|
27282
|
+
AND excluded.attributes <> audit_events.attributes)`
|
|
27016
27283
|
);
|
|
27017
27284
|
this.upsertSessionRootStmt = db.prepare(
|
|
27018
27285
|
`INSERT OR IGNORE INTO audit_events
|
|
@@ -27280,6 +27547,87 @@ var SqliteBodyRetentionRepository = class {
|
|
|
27280
27547
|
}
|
|
27281
27548
|
};
|
|
27282
27549
|
|
|
27550
|
+
// ../../packages/persistence/src/repositories/capture-status.ts
|
|
27551
|
+
var STATUS_LOOKBACK_ROWS = 128;
|
|
27552
|
+
var SqliteCaptureStatusRepository = class {
|
|
27553
|
+
constructor(db) {
|
|
27554
|
+
this.db = db;
|
|
27555
|
+
this.recentStmt = db.prepare(
|
|
27556
|
+
`SELECT a.started_at AS startedAt,
|
|
27557
|
+
a.attributes AS attributes,
|
|
27558
|
+
a.root_session_id AS rootSessionId
|
|
27559
|
+
FROM audit_events a
|
|
27560
|
+
WHERE a.event_type = 'capture_status'
|
|
27561
|
+
AND a.source_tool = ?
|
|
27562
|
+
AND a.started_at >= ?
|
|
27563
|
+
ORDER BY a.started_at DESC, a.id DESC
|
|
27564
|
+
LIMIT ?`
|
|
27565
|
+
);
|
|
27566
|
+
}
|
|
27567
|
+
db;
|
|
27568
|
+
recentStmt;
|
|
27569
|
+
/**
|
|
27570
|
+
* Every document that reported for a site, in registry order by site, from
|
|
27571
|
+
* the last `CAPTURE_STATUS_RECENCY_MS`.
|
|
27572
|
+
*
|
|
27573
|
+
* SEVERAL per site, not one: a browser is many documents and each reports
|
|
27574
|
+
* for itself, so one row per site is a choice about which of them a user
|
|
27575
|
+
* sees — and the newest is the wrong one, since a healthy tab writing a
|
|
27576
|
+
* fresh report would hide a drifting tab's verdict, which is the whole
|
|
27577
|
+
* reason these rows exist. The pick WITHIN a document is made here (the
|
|
27578
|
+
* unchanged `pickReportedCaptureStatus`, over that document's own rows);
|
|
27579
|
+
* choosing between documents belongs where the state semantics live, and
|
|
27580
|
+
* that is `reportedCaptureDocumentForSite` in `@akasecurity/detections` —
|
|
27581
|
+
* this package may not import it.
|
|
27582
|
+
*
|
|
27583
|
+
* `now` is a required argument rather than a `Date.now()` read, so a caller
|
|
27584
|
+
* that already holds a render instant passes THAT one and a test can drive
|
|
27585
|
+
* the window without moving the wall clock.
|
|
27586
|
+
*
|
|
27587
|
+
* A site whose reports have all aged out contributes nothing, so it derives
|
|
27588
|
+
* to `unreported`. That is the point: nothing but the browser extension ever
|
|
27589
|
+
* writes these rows, so an uninstalled extension's last verdict would
|
|
27590
|
+
* otherwise stand as a live claim for ever with no later report able to
|
|
27591
|
+
* clear it.
|
|
27592
|
+
*/
|
|
27593
|
+
latest(now) {
|
|
27594
|
+
const since = now - CAPTURE_STATUS_RECENCY_MS;
|
|
27595
|
+
const documents = [];
|
|
27596
|
+
for (const tool of WebSourceTool.options) {
|
|
27597
|
+
const rows = /* @__PURE__ */ new Map();
|
|
27598
|
+
const lastWord = /* @__PURE__ */ new Map();
|
|
27599
|
+
for (const row of allRows(this.recentStmt, [
|
|
27600
|
+
tool,
|
|
27601
|
+
since,
|
|
27602
|
+
STATUS_LOOKBACK_ROWS
|
|
27603
|
+
])) {
|
|
27604
|
+
const status = fromCaptureStatusAttributes(parseJsonObject(row.attributes));
|
|
27605
|
+
if (status === null) continue;
|
|
27606
|
+
const record2 = { tool, observedAt: epochMillisToIso(row.startedAt), status };
|
|
27607
|
+
const group = rows.get(row.rootSessionId);
|
|
27608
|
+
if (group === void 0) {
|
|
27609
|
+
rows.set(row.rootSessionId, [record2]);
|
|
27610
|
+
lastWord.set(row.rootSessionId, { at: record2.observedAt, closed: status.closed });
|
|
27611
|
+
} else {
|
|
27612
|
+
group.push(record2);
|
|
27613
|
+
}
|
|
27614
|
+
}
|
|
27615
|
+
for (const [root, candidates] of rows) {
|
|
27616
|
+
const picked = pickReportedCaptureStatus(candidates);
|
|
27617
|
+
const last = lastWord.get(root);
|
|
27618
|
+
if (picked === void 0 || last === void 0) continue;
|
|
27619
|
+
documents.push({
|
|
27620
|
+
...picked,
|
|
27621
|
+
...root === null ? {} : { rootSessionId: root },
|
|
27622
|
+
lastReportAt: last.at,
|
|
27623
|
+
closed: last.closed
|
|
27624
|
+
});
|
|
27625
|
+
}
|
|
27626
|
+
}
|
|
27627
|
+
return documents;
|
|
27628
|
+
}
|
|
27629
|
+
};
|
|
27630
|
+
|
|
27283
27631
|
// ../../packages/persistence/src/repositories/classified-data.ts
|
|
27284
27632
|
var SqliteClassifiedDataRepository = class {
|
|
27285
27633
|
constructor(db) {
|
|
@@ -32860,6 +33208,7 @@ function openAndInitialize(file2, base, skipTags) {
|
|
|
32860
33208
|
activity: new SqliteActivityRepository(db),
|
|
32861
33209
|
sourceProject: new SqliteSourceProjectRepository(db),
|
|
32862
33210
|
auditEvents: new SqliteAuditEventsRepository(db),
|
|
33211
|
+
captureStatus: new SqliteCaptureStatusRepository(db),
|
|
32863
33212
|
classifiedData: new SqliteClassifiedDataRepository(db),
|
|
32864
33213
|
inspectionDefinitions: new SqliteInspectionDefinitionsRepository(db),
|
|
32865
33214
|
inspectionFindings: new SqliteInspectionFindingsRepository(db),
|
|
@@ -32900,6 +33249,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
32900
33249
|
activity,
|
|
32901
33250
|
sourceProject,
|
|
32902
33251
|
auditEvents,
|
|
33252
|
+
captureStatus,
|
|
32903
33253
|
classifiedData,
|
|
32904
33254
|
inspectionDefinitions,
|
|
32905
33255
|
inspectionFindings,
|
|
@@ -33117,6 +33467,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
33117
33467
|
activity,
|
|
33118
33468
|
sourceProject,
|
|
33119
33469
|
auditEvents,
|
|
33470
|
+
captureStatus,
|
|
33120
33471
|
classifiedData,
|
|
33121
33472
|
inspectionDefinitions,
|
|
33122
33473
|
inspectionFindings,
|
|
@@ -33362,11 +33713,6 @@ function fingerprintValue(key, raw) {
|
|
|
33362
33713
|
// ../../packages/persistence/src/forward-health.ts
|
|
33363
33714
|
import { readFileSync as readFileSync7 } from "fs";
|
|
33364
33715
|
import { join as join9 } from "path";
|
|
33365
|
-
var FAILURES = /* @__PURE__ */ new Set([
|
|
33366
|
-
"unauthorized",
|
|
33367
|
-
"forbidden",
|
|
33368
|
-
"unreachable"
|
|
33369
|
-
]);
|
|
33370
33716
|
var BREAKER_COOLDOWN_MS = 3e4;
|
|
33371
33717
|
function parseForwardHealth(raw, nowMs) {
|
|
33372
33718
|
try {
|
|
@@ -33375,7 +33721,8 @@ function parseForwardHealth(raw, nowMs) {
|
|
|
33375
33721
|
const record2 = parsed2;
|
|
33376
33722
|
const failures = typeof record2.consecutiveFailures === "number" && record2.consecutiveFailures >= 0 ? record2.consecutiveFailures : 0;
|
|
33377
33723
|
const openedAtMs = typeof record2.openedAtMs === "number" && Number.isFinite(record2.openedAtMs) && record2.openedAtMs <= nowMs ? record2.openedAtMs : null;
|
|
33378
|
-
const
|
|
33724
|
+
const parsedFailure = ControlPlaneFailure.safeParse(record2.lastFailure);
|
|
33725
|
+
const lastFailure = parsedFailure.success ? parsedFailure.data : null;
|
|
33379
33726
|
return { consecutiveFailures: failures, openedAtMs, lastFailure };
|
|
33380
33727
|
} catch {
|
|
33381
33728
|
return null;
|
|
@@ -35416,6 +35763,56 @@ var CONFIG_POSTURE_RULES = [
|
|
|
35416
35763
|
}
|
|
35417
35764
|
];
|
|
35418
35765
|
|
|
35766
|
+
// ../../packages/detections/src/posture/web-capture-posture.ts
|
|
35767
|
+
var RULE_VERSION2 = "1";
|
|
35768
|
+
var DRIFT_MIN_PARSE_FAILURES = 2;
|
|
35769
|
+
var WEB_CAPTURE_DRIFT_STATES = /* @__PURE__ */ new Set([
|
|
35770
|
+
"blind",
|
|
35771
|
+
"degraded"
|
|
35772
|
+
]);
|
|
35773
|
+
var WEB_CAPTURE_DRIFT_RULE = {
|
|
35774
|
+
ruleId: "web-capture-drift",
|
|
35775
|
+
version: RULE_VERSION2,
|
|
35776
|
+
name: "Web chat capture is not reading the site",
|
|
35777
|
+
category: "config",
|
|
35778
|
+
severity: "medium",
|
|
35779
|
+
definition: JSON.stringify({
|
|
35780
|
+
kind: "web-capture-drift",
|
|
35781
|
+
states: [...WEB_CAPTURE_DRIFT_STATES],
|
|
35782
|
+
minParseFailures: DRIFT_MIN_PARSE_FAILURES
|
|
35783
|
+
})
|
|
35784
|
+
};
|
|
35785
|
+
var STATIC_COPY = {
|
|
35786
|
+
active: { headline: "turns are being observed on this site" },
|
|
35787
|
+
unreported: {
|
|
35788
|
+
// Says "recently" rather than "yet": the store read is bounded to
|
|
35789
|
+
// CAPTURE_STATUS_RECENCY_MS, so this state covers a site nothing has ever
|
|
35790
|
+
// reported for AND one whose last report has aged out. The two are the
|
|
35791
|
+
// same fact to a reader — nobody has confirmed anything lately — and the
|
|
35792
|
+
// copy may not claim the stronger of them.
|
|
35793
|
+
headline: `no report in the last ${String(CAPTURE_STATUS_RECENCY_DAYS)} days \u2014 open the site in Chrome with the extension loaded`
|
|
35794
|
+
},
|
|
35795
|
+
standby: {
|
|
35796
|
+
headline: "this build declares no endpoints for the site, so nothing is observed yet"
|
|
35797
|
+
},
|
|
35798
|
+
unpatched: {
|
|
35799
|
+
// Says what the flags say and no more. `patched` is false both for a tap
|
|
35800
|
+
// that installed and hooked neither transport and for one that never ran
|
|
35801
|
+
// at all — a page reports the same status either way, so the copy may not
|
|
35802
|
+
// assert one of them.
|
|
35803
|
+
headline: "the page tap captured neither fetch nor XHR \u2014 it may not have installed; reload the extension at chrome://extensions"
|
|
35804
|
+
},
|
|
35805
|
+
idle: { headline: "watching; no turn has been observed yet" },
|
|
35806
|
+
blind: {
|
|
35807
|
+
headline: "messages were sent in the page that the network capture never saw",
|
|
35808
|
+
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."
|
|
35809
|
+
},
|
|
35810
|
+
degraded: {
|
|
35811
|
+
headline: "the site's payloads no longer carry the fields the extension reads",
|
|
35812
|
+
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."
|
|
35813
|
+
}
|
|
35814
|
+
};
|
|
35815
|
+
|
|
35419
35816
|
// ../../packages/detections/src/security/redos-probe.ts
|
|
35420
35817
|
var BUDGET_MS = 100;
|
|
35421
35818
|
var EXPONENTIAL_UNITS = [
|
|
@@ -38246,10 +38643,31 @@ var claudeCodeModelFromRecord = (record2) => {
|
|
|
38246
38643
|
function modelFromTranscript(transcriptPath) {
|
|
38247
38644
|
return modelFromTranscriptTail(transcriptPath, claudeCodeModelFromRecord);
|
|
38248
38645
|
}
|
|
38646
|
+
var SWITCH_MODEL_REMEDY = "Switch to an approved model with /model";
|
|
38647
|
+
var WORDING = {
|
|
38648
|
+
switch: {
|
|
38649
|
+
subject: (model) => `Cannot switch to ${model}`,
|
|
38650
|
+
remedy: SWITCH_MODEL_REMEDY
|
|
38651
|
+
},
|
|
38652
|
+
turn: {
|
|
38653
|
+
subject: (model) => `This session is running on ${model}, which cannot be used`,
|
|
38654
|
+
remedy: SWITCH_MODEL_REMEDY
|
|
38655
|
+
},
|
|
38656
|
+
spawn: {
|
|
38657
|
+
subject: (model) => `Cannot start a subagent on ${model}`,
|
|
38658
|
+
remedy: "Name an approved model on the subagent"
|
|
38659
|
+
},
|
|
38660
|
+
request: {
|
|
38661
|
+
subject: (model) => `Cannot use ${model} for this request`,
|
|
38662
|
+
remedy: "Change the model this application requests"
|
|
38663
|
+
}
|
|
38664
|
+
};
|
|
38665
|
+
function lookupWording(action) {
|
|
38666
|
+
return Object.hasOwn(WORDING, action) ? WORDING[action] : void 0;
|
|
38667
|
+
}
|
|
38249
38668
|
function prohibitedModelMessage(model, action) {
|
|
38250
|
-
const subject
|
|
38251
|
-
|
|
38252
|
-
return `${subject} \u2014 your organization has prohibited this model. ${remedy}, or ask an administrator to change its status in AKA under Govern \u2192 LLM Providers.`;
|
|
38669
|
+
const { subject, remedy } = lookupWording(action) ?? WORDING.turn;
|
|
38670
|
+
return `${subject(model)} \u2014 your organization has prohibited this model. ${remedy}, or ask an administrator to change its status in AKA under Govern \u2192 LLM Providers.`;
|
|
38253
38671
|
}
|
|
38254
38672
|
function decideProhibitedModelTurn(model, prohibitedModels) {
|
|
38255
38673
|
if (model === void 0 || model === "") return null;
|
|
@@ -39261,6 +39679,12 @@ var RemoteRequestInvalid = class extends Error {
|
|
|
39261
39679
|
}
|
|
39262
39680
|
cause;
|
|
39263
39681
|
};
|
|
39682
|
+
var RemoteEndpointRefused = class extends Error {
|
|
39683
|
+
constructor(endpoint) {
|
|
39684
|
+
super(`refusing to talk to an unsafe control-plane endpoint: ${originOnly(endpoint)}`);
|
|
39685
|
+
this.name = "RemoteEndpointRefused";
|
|
39686
|
+
}
|
|
39687
|
+
};
|
|
39264
39688
|
var RemoteResponseInvalid = class extends Error {
|
|
39265
39689
|
constructor(route, detail) {
|
|
39266
39690
|
super(`control plane answered ${route} with ${detail}`);
|
|
@@ -39413,14 +39837,15 @@ function parsed(schema, body, route) {
|
|
|
39413
39837
|
}
|
|
39414
39838
|
return result.data;
|
|
39415
39839
|
}
|
|
39416
|
-
function
|
|
39840
|
+
function resolveBaseUrl(endpoint) {
|
|
39841
|
+
if (!isSafeEndpoint(endpoint)) throw new RemoteEndpointRefused(endpoint);
|
|
39417
39842
|
let end = endpoint.length;
|
|
39418
39843
|
while (end > 0 && endpoint.charCodeAt(end - 1) === SLASH2) end -= 1;
|
|
39419
39844
|
return endpoint.slice(0, end);
|
|
39420
39845
|
}
|
|
39421
39846
|
var SLASH2 = "/".charCodeAt(0);
|
|
39422
39847
|
function createRemoteClient(options) {
|
|
39423
|
-
const base =
|
|
39848
|
+
const base = resolveBaseUrl(options.endpoint);
|
|
39424
39849
|
const url2 = (route) => `${base}${route}`;
|
|
39425
39850
|
const common = { apiKey: options.apiKey, timeoutMs: options.timeoutMs };
|
|
39426
39851
|
const sendOne = async (event) => {
|
|
@@ -39550,6 +39975,7 @@ function classifyRemoteFailure(err) {
|
|
|
39550
39975
|
case "RemoteRouteAbsent":
|
|
39551
39976
|
return "route-absent";
|
|
39552
39977
|
case "RemoteRequestInvalid":
|
|
39978
|
+
case "RemoteEndpointRefused":
|
|
39553
39979
|
return "invalid-request";
|
|
39554
39980
|
case "RemoteResponseInvalid":
|
|
39555
39981
|
return "rejected";
|
|
@@ -39753,86 +40179,10 @@ function createForwardPolicy(deps) {
|
|
|
39753
40179
|
}
|
|
39754
40180
|
|
|
39755
40181
|
// ../../packages/plugin-runtime/src/attached/gateway.ts
|
|
39756
|
-
|
|
39757
|
-
|
|
39758
|
-
|
|
39759
|
-
return
|
|
39760
|
-
}
|
|
39761
|
-
function ruleCategoryMap(wireRules, localRules) {
|
|
39762
|
-
const map2 = /* @__PURE__ */ new Map();
|
|
39763
|
-
for (const rule of wireRules ?? []) map2.set(rule.id, rule.category);
|
|
39764
|
-
for (const rule of localRules ?? []) map2.set(rule.id, rule.category);
|
|
39765
|
-
for (const pack of bundledDetections()) {
|
|
39766
|
-
for (const rule of pack.rules) map2.set(rule.id, rule.category);
|
|
39767
|
-
}
|
|
39768
|
-
return map2;
|
|
39769
|
-
}
|
|
39770
|
-
function policyKey(policy) {
|
|
39771
|
-
return "ruleId" in policy.target ? `rule:${policy.target.ruleId}` : `category:${policy.target.category}`;
|
|
39772
|
-
}
|
|
39773
|
-
function floorFor(policy, categoryByRuleId) {
|
|
39774
|
-
const category = "category" in policy.target ? policy.target.category : categoryByRuleId.get(policy.target.ruleId);
|
|
39775
|
-
return category === void 0 ? null : DEFAULT_ACTIONS[category];
|
|
39776
|
-
}
|
|
39777
|
-
function mergeRaiseOnly(localPolicies, remotePolicies, categoryByRuleId) {
|
|
39778
|
-
const merged = /* @__PURE__ */ new Map();
|
|
39779
|
-
const disabled = [];
|
|
39780
|
-
const remoteCategoryAction = /* @__PURE__ */ new Map();
|
|
39781
|
-
for (const policy of remotePolicies) {
|
|
39782
|
-
if (!policy.enabled) continue;
|
|
39783
|
-
if (!("category" in policy.target)) continue;
|
|
39784
|
-
if (remoteCategoryAction.has(policy.target.category)) continue;
|
|
39785
|
-
const floor = floorFor(policy, categoryByRuleId);
|
|
39786
|
-
remoteCategoryAction.set(
|
|
39787
|
-
policy.target.category,
|
|
39788
|
-
floor !== null && !isActionAtLeast(policy.action, floor) ? floor : policy.action
|
|
39789
|
-
);
|
|
39790
|
-
}
|
|
39791
|
-
for (const policy of localPolicies) {
|
|
39792
|
-
if (!policy.enabled) {
|
|
39793
|
-
disabled.push(policy);
|
|
39794
|
-
continue;
|
|
39795
|
-
}
|
|
39796
|
-
const key = policyKey(policy);
|
|
39797
|
-
if (merged.has(key)) continue;
|
|
39798
|
-
let remoteFloor = null;
|
|
39799
|
-
if ("ruleId" in policy.target) {
|
|
39800
|
-
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
39801
|
-
if (category !== void 0) remoteFloor = remoteCategoryAction.get(category) ?? null;
|
|
39802
|
-
}
|
|
39803
|
-
merged.set(
|
|
39804
|
-
key,
|
|
39805
|
-
remoteFloor !== null && !isActionAtLeast(policy.action, remoteFloor) ? { ...policy, action: remoteFloor } : policy
|
|
39806
|
-
);
|
|
39807
|
-
}
|
|
39808
|
-
const localCategoryAction = /* @__PURE__ */ new Map();
|
|
39809
|
-
for (const policy of merged.values()) {
|
|
39810
|
-
if ("category" in policy.target) localCategoryAction.set(policy.target.category, policy.action);
|
|
39811
|
-
}
|
|
39812
|
-
for (const policy of remotePolicies) {
|
|
39813
|
-
if (!policy.enabled) {
|
|
39814
|
-
disabled.push(policy);
|
|
39815
|
-
continue;
|
|
39816
|
-
}
|
|
39817
|
-
const key = policyKey(policy);
|
|
39818
|
-
const floor = floorFor(policy, categoryByRuleId);
|
|
39819
|
-
let localFloor = null;
|
|
39820
|
-
if ("ruleId" in policy.target) {
|
|
39821
|
-
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
39822
|
-
if (category !== void 0) localFloor = localCategoryAction.get(category) ?? null;
|
|
39823
|
-
}
|
|
39824
|
-
const effectiveFloor = strongerOf(floor, localFloor);
|
|
39825
|
-
const clamped = effectiveFloor !== null && !isActionAtLeast(policy.action, effectiveFloor) ? { ...policy, action: effectiveFloor } : policy;
|
|
39826
|
-
const existing = merged.get(key);
|
|
39827
|
-
if (existing === void 0) {
|
|
39828
|
-
merged.set(key, clamped);
|
|
39829
|
-
continue;
|
|
39830
|
-
}
|
|
39831
|
-
if (actionRank(clamped.action) > actionRank(existing.action)) {
|
|
39832
|
-
merged.set(key, clamped);
|
|
39833
|
-
}
|
|
39834
|
-
}
|
|
39835
|
-
return [...merged.values(), ...disabled];
|
|
40182
|
+
var bundledRulesFlatCache;
|
|
40183
|
+
function bundledRulesFlat() {
|
|
40184
|
+
bundledRulesFlatCache ??= bundledDetections().flatMap((pack) => pack.rules);
|
|
40185
|
+
return bundledRulesFlatCache;
|
|
39836
40186
|
}
|
|
39837
40187
|
var AttachedDataGateway = class {
|
|
39838
40188
|
constructor(deps) {
|
|
@@ -40152,6 +40502,9 @@ var AttachedDataGateway = class {
|
|
|
40152
40502
|
async readSessionProvider(sessionId) {
|
|
40153
40503
|
return this.deps.local.readSessionProvider(sessionId);
|
|
40154
40504
|
}
|
|
40505
|
+
async readCaptureStatuses() {
|
|
40506
|
+
return this.deps.local.readCaptureStatuses();
|
|
40507
|
+
}
|
|
40155
40508
|
async facets() {
|
|
40156
40509
|
return this.deps.local.facets();
|
|
40157
40510
|
}
|
|
@@ -40234,7 +40587,7 @@ var AttachedDataGateway = class {
|
|
|
40234
40587
|
policies: mergeRaiseOnly(
|
|
40235
40588
|
local.policies,
|
|
40236
40589
|
cached2.policies,
|
|
40237
|
-
ruleCategoryMap(cached2.rules, local.rules)
|
|
40590
|
+
ruleCategoryMap(cached2.rules, local.rules, bundledRulesFlat())
|
|
40238
40591
|
),
|
|
40239
40592
|
customKeywords: [...local.customKeywords, ...cached2.customKeywords],
|
|
40240
40593
|
// TAKEN FROM THE CACHE, unlike the two fields below — and the asymmetry
|
|
@@ -40435,10 +40788,15 @@ import { join as join28 } from "path";
|
|
|
40435
40788
|
// ../../packages/plugin-runtime/src/attached/atomic-publish.ts
|
|
40436
40789
|
import { rename as rename2 } from "fs/promises";
|
|
40437
40790
|
var RETRYABLE = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
|
|
40438
|
-
var
|
|
40791
|
+
var IMMEDIATE_RETRIES = 8;
|
|
40792
|
+
var TIMED_RETRIES = 4;
|
|
40793
|
+
var ATTEMPTS = 1 + IMMEDIATE_RETRIES + TIMED_RETRIES;
|
|
40439
40794
|
var delay = (ms) => new Promise((resolve2) => {
|
|
40440
40795
|
setTimeout(resolve2, ms);
|
|
40441
40796
|
});
|
|
40797
|
+
var yieldToLoop = () => new Promise((resolve2) => {
|
|
40798
|
+
setImmediate(resolve2);
|
|
40799
|
+
});
|
|
40442
40800
|
async function publishByRename(tmp, file2, move = rename2) {
|
|
40443
40801
|
for (let attempt = 1; ; attempt += 1) {
|
|
40444
40802
|
try {
|
|
@@ -40447,7 +40805,7 @@ async function publishByRename(tmp, file2, move = rename2) {
|
|
|
40447
40805
|
} catch (err) {
|
|
40448
40806
|
const code = err.code;
|
|
40449
40807
|
if (attempt >= ATTEMPTS || code === void 0 || !RETRYABLE.has(code)) throw err;
|
|
40450
|
-
await delay(attempt * 10);
|
|
40808
|
+
await (attempt <= IMMEDIATE_RETRIES ? yieldToLoop() : delay((attempt - IMMEDIATE_RETRIES) * 10));
|
|
40451
40809
|
}
|
|
40452
40810
|
}
|
|
40453
40811
|
}
|
|
@@ -40911,6 +41269,9 @@ var StandaloneDataGateway = class {
|
|
|
40911
41269
|
readSessionProvider(sessionId) {
|
|
40912
41270
|
return Promise.resolve(this.db.auditEvents.sessionProvider(sessionId));
|
|
40913
41271
|
}
|
|
41272
|
+
readCaptureStatuses() {
|
|
41273
|
+
return Promise.resolve(this.db.captureStatus.latest(Date.now()));
|
|
41274
|
+
}
|
|
40914
41275
|
facets() {
|
|
40915
41276
|
return Promise.resolve(this.db.facets());
|
|
40916
41277
|
}
|