@akasecurity/ai-tc-codex 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/.codex-plugin/plugin.json +1 -1
- package/package.json +3 -3
- 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/onboard.js +331 -22
- package/scripts/post-tool-use.js +464 -124
- package/scripts/pre-tool-use.js +464 -124
- package/scripts/query.js +580 -126
- 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/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
|
);
|
|
@@ -23858,6 +24035,18 @@ var HistorySyncConsent = external_exports.object({
|
|
|
23858
24035
|
payloadVersion: external_exports.number().int().positive(),
|
|
23859
24036
|
endpoint: external_exports.string()
|
|
23860
24037
|
});
|
|
24038
|
+
var WebChatCaptureConsent = external_exports.object({
|
|
24039
|
+
acknowledgedAt: external_exports.iso.datetime(),
|
|
24040
|
+
version: external_exports.number().int().positive()
|
|
24041
|
+
});
|
|
24042
|
+
var WebChatResponseCapture = external_exports.enum(["with-findings", "always", "never"]);
|
|
24043
|
+
var WebChatCapture = external_exports.object({
|
|
24044
|
+
responses: WebChatResponseCapture.default("with-findings"),
|
|
24045
|
+
account: external_exports.boolean().default(false),
|
|
24046
|
+
// Absent until granted. Presence alone does not authorize anything — see
|
|
24047
|
+
// isWebChatCaptureConsentValid.
|
|
24048
|
+
consent: WebChatCaptureConsent.optional()
|
|
24049
|
+
});
|
|
23861
24050
|
var BODY_RETENTION_DEFAULT_DAYS = 30;
|
|
23862
24051
|
var BodyRetention = external_exports.object({
|
|
23863
24052
|
enabled: external_exports.boolean().default(false),
|
|
@@ -23916,6 +24105,16 @@ var WorkspaceSettings = external_exports.object({
|
|
|
23916
24105
|
// both widenings. Absent until granted, and a grant for a different endpoint
|
|
23917
24106
|
// or an older payload no longer counts.
|
|
23918
24107
|
historySyncConsent: HistorySyncConsent.optional(),
|
|
24108
|
+
// What the browser extension may record from a web chat, and the grant that
|
|
24109
|
+
// authorizes it. Absent until the user answers: recording something that was
|
|
24110
|
+
// never recorded before is never an assumed grant on upgrade, so the whole
|
|
24111
|
+
// block is optional rather than defaulted in. What an absent block means is
|
|
24112
|
+
// webChatCaptureOf's answer, in one place.
|
|
24113
|
+
//
|
|
24114
|
+
// Enforcement is NOT gated on this. A machine that has never answered still
|
|
24115
|
+
// blocks, redacts and warns on what a user sends; the grant covers what is
|
|
24116
|
+
// written down.
|
|
24117
|
+
webChatCapture: WebChatCapture.optional(),
|
|
23919
24118
|
// Local body expiry (see BodyRetention). Off until switched on; expiring a
|
|
23920
24119
|
// body never removes the row or its findings.
|
|
23921
24120
|
bodyRetention: BodyRetention.default({
|
|
@@ -24023,7 +24222,10 @@ function toCaptureAttributes(event) {
|
|
|
24023
24222
|
// `.catchall(z.unknown())` carries the long tail.
|
|
24024
24223
|
...metadata?.model !== void 0 ? { model: metadata.model } : {},
|
|
24025
24224
|
...metadata?.turnIndex !== void 0 ? { turn_index: metadata.turnIndex } : {},
|
|
24026
|
-
|
|
24225
|
+
// A blank id is omitted rather than stored: it is a join key and `''` joins
|
|
24226
|
+
// nothing. This runs on the local write path, which types the event but
|
|
24227
|
+
// never parses it, so EventMetadata's own `.min(1)` does not reach here.
|
|
24228
|
+
...metadata?.messageId !== void 0 && metadata.messageId !== "" ? { message_id: metadata.messageId } : {},
|
|
24027
24229
|
...metadata?.conversationId !== void 0 ? { conversation_id: metadata.conversationId } : {}
|
|
24028
24230
|
};
|
|
24029
24231
|
}
|
|
@@ -24397,12 +24599,14 @@ var RecommendedActionIdParam = external_exports.object({ id: external_exports.st
|
|
|
24397
24599
|
// ../../packages/schema/src/zod/settings-action.ts
|
|
24398
24600
|
var HistorySyncConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "HistorySyncConsentChoice" });
|
|
24399
24601
|
var ModelJudgeConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "ModelJudgeConsentChoice" });
|
|
24602
|
+
var WebChatCaptureConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "WebChatCaptureConsentChoice" });
|
|
24400
24603
|
var SaveSettingsInput = external_exports.object({
|
|
24401
24604
|
historicalAccess: external_exports.string(),
|
|
24402
24605
|
modelJudgeConsent: ModelJudgeConsentChoice,
|
|
24403
24606
|
historySyncConsent: HistorySyncConsentChoice,
|
|
24404
24607
|
vaultConsent: external_exports.string(),
|
|
24405
24608
|
vaultInlineReveal: external_exports.string(),
|
|
24609
|
+
webChatCaptureConsent: WebChatCaptureConsentChoice,
|
|
24406
24610
|
// Widened to `string` like its neighbours rather than typed as
|
|
24407
24611
|
// `RedactFallback`, on this module's own layering rule: shape here, VALUE at
|
|
24408
24612
|
// the call site, so the domain check receives the type it was written for.
|
|
@@ -24617,11 +24821,24 @@ var WebExchange = external_exports.object({
|
|
|
24617
24821
|
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
24618
24822
|
toolCalls: external_exports.array(WebToolCall).default([]),
|
|
24619
24823
|
// Absent when the adapter recovered no text. Capped by the caller at
|
|
24620
|
-
// RESPONSE_TEXT_MAX_BYTES
|
|
24621
|
-
//
|
|
24824
|
+
// RESPONSE_TEXT_MAX_BYTES, so a short capture is never mistaken for a short
|
|
24825
|
+
// reply.
|
|
24622
24826
|
responseText: external_exports.string().optional(),
|
|
24827
|
+
// The stored text is short of the reply. It does NOT say which of the two
|
|
24828
|
+
// ceilings on this path cut it: the caller applies its own cap on the raw
|
|
24829
|
+
// bytes it reads off the wire, which can be reached by a stream whose
|
|
24830
|
+
// recovered text stays well under RESPONSE_TEXT_MAX_BYTES, and applies that
|
|
24831
|
+
// one to the text. A reader cannot tell them apart, and nothing downstream
|
|
24832
|
+
// should branch as though it could.
|
|
24623
24833
|
truncated: external_exports.boolean().default(false)
|
|
24624
24834
|
});
|
|
24835
|
+
var WebEnforcementState = external_exports.enum([
|
|
24836
|
+
"watching",
|
|
24837
|
+
"composer-only",
|
|
24838
|
+
"button-only",
|
|
24839
|
+
"unattached",
|
|
24840
|
+
"unknown"
|
|
24841
|
+
]);
|
|
24625
24842
|
var RESPONSE_TEXT_MAX_BYTES = 2 * 1024 * 1024;
|
|
24626
24843
|
var WebCaptureStatus = external_exports.object({
|
|
24627
24844
|
patched: external_exports.boolean(),
|
|
@@ -24633,8 +24850,66 @@ var WebCaptureStatus = external_exports.object({
|
|
|
24633
24850
|
unparsedBodies: external_exports.number().int().nonnegative(),
|
|
24634
24851
|
// The adapter-declared JSON key paths that were absent from a real payload —
|
|
24635
24852
|
// the earliest signal that a site's contract moved.
|
|
24636
|
-
shapeMisses: external_exports.array(external_exports.string()).default([])
|
|
24637
|
-
|
|
24853
|
+
shapeMisses: external_exports.array(external_exports.string()).default([]),
|
|
24854
|
+
// How many `kind: 'conversation'` endpoints the reporting tab's adapter
|
|
24855
|
+
// compiled. Zero means this build declares none for the site, so observing
|
|
24856
|
+
// nothing is the design rather than a fault — the one fact that separates a
|
|
24857
|
+
// site nobody has surveyed yet from one whose contract moved. Defaulted so a
|
|
24858
|
+
// build predating the field is read as declaring nothing rather than refused.
|
|
24859
|
+
conversationEndpoints: external_exports.number().int().nonnegative().default(0),
|
|
24860
|
+
// The document that sent this report is going away. The bridge sets it on
|
|
24861
|
+
// its `pagehide` report and nowhere else.
|
|
24862
|
+
//
|
|
24863
|
+
// A property of the REPORT rather than of capture health, which is why
|
|
24864
|
+
// nothing in `deriveWebCaptureState` reads it and why it stays out of the
|
|
24865
|
+
// bridge's own report signature — a closing tab's last word must not be
|
|
24866
|
+
// suppressed for carrying the same health as the report before it. What
|
|
24867
|
+
// reads it is the per-site fold: a document that said it was unloading stops
|
|
24868
|
+
// voting on the site's state, so the reload the `blind` remediation asks for
|
|
24869
|
+
// can actually clear the verdict it was shown. A document that dies without
|
|
24870
|
+
// sending one is covered by CAPTURE_STATUS_DOCUMENT_QUIET_MS instead.
|
|
24871
|
+
//
|
|
24872
|
+
// Defaulted so a build predating the field reads as a document that never
|
|
24873
|
+
// said it was closing — which keeps it voting, the same as every report that
|
|
24874
|
+
// is not a final one.
|
|
24875
|
+
closed: external_exports.boolean().default(false),
|
|
24876
|
+
// What the DOM enforcement path is doing, which none of the counters above
|
|
24877
|
+
// can say: `sendsSeenDom` rises only once a send has COMPLETED, so a tab
|
|
24878
|
+
// whose watcher never bound reports zero exactly like a tab nobody typed in.
|
|
24879
|
+
// Defaulted to 'unknown' rather than 'watching' so a status from a build
|
|
24880
|
+
// predating the field is not read as reporting a healthy one.
|
|
24881
|
+
enforcement: WebEnforcementState.default("unknown")
|
|
24882
|
+
});
|
|
24883
|
+
function webCaptureStatusObservedTurnPath(status) {
|
|
24884
|
+
if (!status.patched) return true;
|
|
24885
|
+
if (status.conversationEndpoints === 0) return true;
|
|
24886
|
+
return status.blind || status.shapeMisses.length > 0 || status.parseFailures > 0 || status.unparsedBodies > 0 || status.exchangesSeenNet > 0;
|
|
24887
|
+
}
|
|
24888
|
+
function pickReportedCaptureStatus(candidates) {
|
|
24889
|
+
return candidates.find((c) => webCaptureStatusObservedTurnPath(c.status)) ?? candidates[0];
|
|
24890
|
+
}
|
|
24891
|
+
var CAPTURE_STATUS_RECENCY_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
24892
|
+
var CAPTURE_STATUS_RECENCY_DAYS = CAPTURE_STATUS_RECENCY_MS / (24 * 60 * 60 * 1e3);
|
|
24893
|
+
var CAPTURE_STATUS_DOCUMENT_QUIET_MS = 12 * 60 * 60 * 1e3;
|
|
24894
|
+
function fromCaptureStatusAttributes(bag) {
|
|
24895
|
+
const parsedBag = CaptureStatusAttributes.safeParse(bag);
|
|
24896
|
+
if (!parsedBag.success) return null;
|
|
24897
|
+
const b = parsedBag.data;
|
|
24898
|
+
const parsedStatus = WebCaptureStatus.safeParse({
|
|
24899
|
+
patched: b.patched,
|
|
24900
|
+
live: b.live,
|
|
24901
|
+
blind: b.blind,
|
|
24902
|
+
sendsSeenDom: b.sends_seen_dom,
|
|
24903
|
+
exchangesSeenNet: b.exchanges_seen_net,
|
|
24904
|
+
parseFailures: b.parse_failures,
|
|
24905
|
+
unparsedBodies: b.unparsed_bodies,
|
|
24906
|
+
shapeMisses: b.shape_misses,
|
|
24907
|
+
conversationEndpoints: b.conversation_endpoints,
|
|
24908
|
+
closed: b.closed,
|
|
24909
|
+
enforcement: b.enforcement
|
|
24910
|
+
});
|
|
24911
|
+
return parsedStatus.success ? parsedStatus.data : null;
|
|
24912
|
+
}
|
|
24638
24913
|
|
|
24639
24914
|
// ../../packages/persistence/src/paths.ts
|
|
24640
24915
|
import {
|
|
@@ -24765,17 +25040,6 @@ function publishByLink(tmp, file2, data) {
|
|
|
24765
25040
|
function controlPlaneCredentialPath(settingsDir2) {
|
|
24766
25041
|
return join2(settingsDir2, ATTACHED_CREDENTIAL_FILENAME);
|
|
24767
25042
|
}
|
|
24768
|
-
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
24769
|
-
function isSafeEndpoint(endpoint) {
|
|
24770
|
-
let parsed2;
|
|
24771
|
-
try {
|
|
24772
|
-
parsed2 = new URL(endpoint);
|
|
24773
|
-
} catch {
|
|
24774
|
-
return false;
|
|
24775
|
-
}
|
|
24776
|
-
if (parsed2.protocol === "https:") return true;
|
|
24777
|
-
return parsed2.protocol === "http:" && LOOPBACK_HOSTS.has(parsed2.hostname);
|
|
24778
|
-
}
|
|
24779
25043
|
function repairOrRefuseMode(file2) {
|
|
24780
25044
|
const link = lstatSync2(file2, { throwIfNoEntry: false });
|
|
24781
25045
|
if (link === void 0) return "absent";
|
|
@@ -26568,7 +26832,7 @@ var SESSION_ROOT = `event_type = 'session'`;
|
|
|
26568
26832
|
var HAS_ACTIVITY = `EXISTS (
|
|
26569
26833
|
SELECT 1 FROM audit_events c
|
|
26570
26834
|
WHERE c.root_session_id = audit_events.id
|
|
26571
|
-
AND c.event_type NOT IN ('hook', 'config_scan'))`;
|
|
26835
|
+
AND c.event_type NOT IN ('hook', 'config_scan', 'capture_status'))`;
|
|
26572
26836
|
var SqliteActivityRepository = class {
|
|
26573
26837
|
constructor(db, now = () => Date.now()) {
|
|
26574
26838
|
this.db = db;
|
|
@@ -26595,10 +26859,10 @@ var SqliteActivityRepository = class {
|
|
|
26595
26859
|
SELECT id FROM audit_events WHERE event_type = 'session' AND started_at >= ?
|
|
26596
26860
|
UNION
|
|
26597
26861
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_started_at
|
|
26598
|
-
WHERE started_at >= ?
|
|
26862
|
+
WHERE started_at >= ? AND event_type <> 'capture_status'
|
|
26599
26863
|
UNION
|
|
26600
26864
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_ended_at
|
|
26601
|
-
WHERE ended_at >= ?)`,
|
|
26865
|
+
WHERE ended_at >= ? AND event_type <> 'capture_status')`,
|
|
26602
26866
|
[liveThreshold, liveThreshold, liveThreshold]
|
|
26603
26867
|
);
|
|
26604
26868
|
const toolCallsToday = countScalar(
|
|
@@ -27005,7 +27269,10 @@ var SqliteAuditEventsRepository = class {
|
|
|
27005
27269
|
attributes = excluded.attributes,
|
|
27006
27270
|
ended_at = excluded.ended_at
|
|
27007
27271
|
WHERE COALESCE(json_extract(excluded.attributes, '$.output_tokens'), 0)
|
|
27008
|
-
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27272
|
+
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27273
|
+
OR (json_extract(excluded.attributes, '$.usage_source') IS NOT NULL
|
|
27274
|
+
AND json_extract(excluded.attributes, '$.output_tokens') IS NULL
|
|
27275
|
+
AND excluded.attributes <> audit_events.attributes)`
|
|
27009
27276
|
);
|
|
27010
27277
|
this.upsertSessionRootStmt = db.prepare(
|
|
27011
27278
|
`INSERT OR IGNORE INTO audit_events
|
|
@@ -27273,6 +27540,87 @@ var SqliteBodyRetentionRepository = class {
|
|
|
27273
27540
|
}
|
|
27274
27541
|
};
|
|
27275
27542
|
|
|
27543
|
+
// ../../packages/persistence/src/repositories/capture-status.ts
|
|
27544
|
+
var STATUS_LOOKBACK_ROWS = 128;
|
|
27545
|
+
var SqliteCaptureStatusRepository = class {
|
|
27546
|
+
constructor(db) {
|
|
27547
|
+
this.db = db;
|
|
27548
|
+
this.recentStmt = db.prepare(
|
|
27549
|
+
`SELECT a.started_at AS startedAt,
|
|
27550
|
+
a.attributes AS attributes,
|
|
27551
|
+
a.root_session_id AS rootSessionId
|
|
27552
|
+
FROM audit_events a
|
|
27553
|
+
WHERE a.event_type = 'capture_status'
|
|
27554
|
+
AND a.source_tool = ?
|
|
27555
|
+
AND a.started_at >= ?
|
|
27556
|
+
ORDER BY a.started_at DESC, a.id DESC
|
|
27557
|
+
LIMIT ?`
|
|
27558
|
+
);
|
|
27559
|
+
}
|
|
27560
|
+
db;
|
|
27561
|
+
recentStmt;
|
|
27562
|
+
/**
|
|
27563
|
+
* Every document that reported for a site, in registry order by site, from
|
|
27564
|
+
* the last `CAPTURE_STATUS_RECENCY_MS`.
|
|
27565
|
+
*
|
|
27566
|
+
* SEVERAL per site, not one: a browser is many documents and each reports
|
|
27567
|
+
* for itself, so one row per site is a choice about which of them a user
|
|
27568
|
+
* sees — and the newest is the wrong one, since a healthy tab writing a
|
|
27569
|
+
* fresh report would hide a drifting tab's verdict, which is the whole
|
|
27570
|
+
* reason these rows exist. The pick WITHIN a document is made here (the
|
|
27571
|
+
* unchanged `pickReportedCaptureStatus`, over that document's own rows);
|
|
27572
|
+
* choosing between documents belongs where the state semantics live, and
|
|
27573
|
+
* that is `reportedCaptureDocumentForSite` in `@akasecurity/detections` —
|
|
27574
|
+
* this package may not import it.
|
|
27575
|
+
*
|
|
27576
|
+
* `now` is a required argument rather than a `Date.now()` read, so a caller
|
|
27577
|
+
* that already holds a render instant passes THAT one and a test can drive
|
|
27578
|
+
* the window without moving the wall clock.
|
|
27579
|
+
*
|
|
27580
|
+
* A site whose reports have all aged out contributes nothing, so it derives
|
|
27581
|
+
* to `unreported`. That is the point: nothing but the browser extension ever
|
|
27582
|
+
* writes these rows, so an uninstalled extension's last verdict would
|
|
27583
|
+
* otherwise stand as a live claim for ever with no later report able to
|
|
27584
|
+
* clear it.
|
|
27585
|
+
*/
|
|
27586
|
+
latest(now) {
|
|
27587
|
+
const since = now - CAPTURE_STATUS_RECENCY_MS;
|
|
27588
|
+
const documents = [];
|
|
27589
|
+
for (const tool of WebSourceTool.options) {
|
|
27590
|
+
const rows = /* @__PURE__ */ new Map();
|
|
27591
|
+
const lastWord = /* @__PURE__ */ new Map();
|
|
27592
|
+
for (const row of allRows(this.recentStmt, [
|
|
27593
|
+
tool,
|
|
27594
|
+
since,
|
|
27595
|
+
STATUS_LOOKBACK_ROWS
|
|
27596
|
+
])) {
|
|
27597
|
+
const status = fromCaptureStatusAttributes(parseJsonObject(row.attributes));
|
|
27598
|
+
if (status === null) continue;
|
|
27599
|
+
const record2 = { tool, observedAt: epochMillisToIso(row.startedAt), status };
|
|
27600
|
+
const group = rows.get(row.rootSessionId);
|
|
27601
|
+
if (group === void 0) {
|
|
27602
|
+
rows.set(row.rootSessionId, [record2]);
|
|
27603
|
+
lastWord.set(row.rootSessionId, { at: record2.observedAt, closed: status.closed });
|
|
27604
|
+
} else {
|
|
27605
|
+
group.push(record2);
|
|
27606
|
+
}
|
|
27607
|
+
}
|
|
27608
|
+
for (const [root, candidates] of rows) {
|
|
27609
|
+
const picked = pickReportedCaptureStatus(candidates);
|
|
27610
|
+
const last = lastWord.get(root);
|
|
27611
|
+
if (picked === void 0 || last === void 0) continue;
|
|
27612
|
+
documents.push({
|
|
27613
|
+
...picked,
|
|
27614
|
+
...root === null ? {} : { rootSessionId: root },
|
|
27615
|
+
lastReportAt: last.at,
|
|
27616
|
+
closed: last.closed
|
|
27617
|
+
});
|
|
27618
|
+
}
|
|
27619
|
+
}
|
|
27620
|
+
return documents;
|
|
27621
|
+
}
|
|
27622
|
+
};
|
|
27623
|
+
|
|
27276
27624
|
// ../../packages/persistence/src/repositories/classified-data.ts
|
|
27277
27625
|
var SqliteClassifiedDataRepository = class {
|
|
27278
27626
|
constructor(db) {
|
|
@@ -32853,6 +33201,7 @@ function openAndInitialize(file2, base, skipTags) {
|
|
|
32853
33201
|
activity: new SqliteActivityRepository(db),
|
|
32854
33202
|
sourceProject: new SqliteSourceProjectRepository(db),
|
|
32855
33203
|
auditEvents: new SqliteAuditEventsRepository(db),
|
|
33204
|
+
captureStatus: new SqliteCaptureStatusRepository(db),
|
|
32856
33205
|
classifiedData: new SqliteClassifiedDataRepository(db),
|
|
32857
33206
|
inspectionDefinitions: new SqliteInspectionDefinitionsRepository(db),
|
|
32858
33207
|
inspectionFindings: new SqliteInspectionFindingsRepository(db),
|
|
@@ -32893,6 +33242,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
32893
33242
|
activity,
|
|
32894
33243
|
sourceProject,
|
|
32895
33244
|
auditEvents,
|
|
33245
|
+
captureStatus,
|
|
32896
33246
|
classifiedData,
|
|
32897
33247
|
inspectionDefinitions,
|
|
32898
33248
|
inspectionFindings,
|
|
@@ -33110,6 +33460,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
33110
33460
|
activity,
|
|
33111
33461
|
sourceProject,
|
|
33112
33462
|
auditEvents,
|
|
33463
|
+
captureStatus,
|
|
33113
33464
|
classifiedData,
|
|
33114
33465
|
inspectionDefinitions,
|
|
33115
33466
|
inspectionFindings,
|
|
@@ -33335,11 +33686,6 @@ function fingerprintValue(key, raw) {
|
|
|
33335
33686
|
// ../../packages/persistence/src/forward-health.ts
|
|
33336
33687
|
import { readFileSync as readFileSync7 } from "fs";
|
|
33337
33688
|
import { join as join9 } from "path";
|
|
33338
|
-
var FAILURES = /* @__PURE__ */ new Set([
|
|
33339
|
-
"unauthorized",
|
|
33340
|
-
"forbidden",
|
|
33341
|
-
"unreachable"
|
|
33342
|
-
]);
|
|
33343
33689
|
var BREAKER_COOLDOWN_MS = 3e4;
|
|
33344
33690
|
function parseForwardHealth(raw, nowMs) {
|
|
33345
33691
|
try {
|
|
@@ -33348,7 +33694,8 @@ function parseForwardHealth(raw, nowMs) {
|
|
|
33348
33694
|
const record2 = parsed2;
|
|
33349
33695
|
const failures = typeof record2.consecutiveFailures === "number" && record2.consecutiveFailures >= 0 ? record2.consecutiveFailures : 0;
|
|
33350
33696
|
const openedAtMs = typeof record2.openedAtMs === "number" && Number.isFinite(record2.openedAtMs) && record2.openedAtMs <= nowMs ? record2.openedAtMs : null;
|
|
33351
|
-
const
|
|
33697
|
+
const parsedFailure = ControlPlaneFailure.safeParse(record2.lastFailure);
|
|
33698
|
+
const lastFailure = parsedFailure.success ? parsedFailure.data : null;
|
|
33352
33699
|
return { consecutiveFailures: failures, openedAtMs, lastFailure };
|
|
33353
33700
|
} catch {
|
|
33354
33701
|
return null;
|
|
@@ -34475,6 +34822,56 @@ var CONFIG_POSTURE_RULES = [
|
|
|
34475
34822
|
}
|
|
34476
34823
|
];
|
|
34477
34824
|
|
|
34825
|
+
// ../../packages/detections/src/posture/web-capture-posture.ts
|
|
34826
|
+
var RULE_VERSION2 = "1";
|
|
34827
|
+
var DRIFT_MIN_PARSE_FAILURES = 2;
|
|
34828
|
+
var WEB_CAPTURE_DRIFT_STATES = /* @__PURE__ */ new Set([
|
|
34829
|
+
"blind",
|
|
34830
|
+
"degraded"
|
|
34831
|
+
]);
|
|
34832
|
+
var WEB_CAPTURE_DRIFT_RULE = {
|
|
34833
|
+
ruleId: "web-capture-drift",
|
|
34834
|
+
version: RULE_VERSION2,
|
|
34835
|
+
name: "Web chat capture is not reading the site",
|
|
34836
|
+
category: "config",
|
|
34837
|
+
severity: "medium",
|
|
34838
|
+
definition: JSON.stringify({
|
|
34839
|
+
kind: "web-capture-drift",
|
|
34840
|
+
states: [...WEB_CAPTURE_DRIFT_STATES],
|
|
34841
|
+
minParseFailures: DRIFT_MIN_PARSE_FAILURES
|
|
34842
|
+
})
|
|
34843
|
+
};
|
|
34844
|
+
var STATIC_COPY = {
|
|
34845
|
+
active: { headline: "turns are being observed on this site" },
|
|
34846
|
+
unreported: {
|
|
34847
|
+
// Says "recently" rather than "yet": the store read is bounded to
|
|
34848
|
+
// CAPTURE_STATUS_RECENCY_MS, so this state covers a site nothing has ever
|
|
34849
|
+
// reported for AND one whose last report has aged out. The two are the
|
|
34850
|
+
// same fact to a reader — nobody has confirmed anything lately — and the
|
|
34851
|
+
// copy may not claim the stronger of them.
|
|
34852
|
+
headline: `no report in the last ${String(CAPTURE_STATUS_RECENCY_DAYS)} days \u2014 open the site in Chrome with the extension loaded`
|
|
34853
|
+
},
|
|
34854
|
+
standby: {
|
|
34855
|
+
headline: "this build declares no endpoints for the site, so nothing is observed yet"
|
|
34856
|
+
},
|
|
34857
|
+
unpatched: {
|
|
34858
|
+
// Says what the flags say and no more. `patched` is false both for a tap
|
|
34859
|
+
// that installed and hooked neither transport and for one that never ran
|
|
34860
|
+
// at all — a page reports the same status either way, so the copy may not
|
|
34861
|
+
// assert one of them.
|
|
34862
|
+
headline: "the page tap captured neither fetch nor XHR \u2014 it may not have installed; reload the extension at chrome://extensions"
|
|
34863
|
+
},
|
|
34864
|
+
idle: { headline: "watching; no turn has been observed yet" },
|
|
34865
|
+
blind: {
|
|
34866
|
+
headline: "messages were sent in the page that the network capture never saw",
|
|
34867
|
+
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."
|
|
34868
|
+
},
|
|
34869
|
+
degraded: {
|
|
34870
|
+
headline: "the site's payloads no longer carry the fields the extension reads",
|
|
34871
|
+
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."
|
|
34872
|
+
}
|
|
34873
|
+
};
|
|
34874
|
+
|
|
34478
34875
|
// ../../packages/detections/src/security/redos-probe.ts
|
|
34479
34876
|
var BUDGET_MS = 100;
|
|
34480
34877
|
var EXPONENTIAL_UNITS = [
|
|
@@ -37302,10 +37699,31 @@ var codexModelFromRecord = (record2) => {
|
|
|
37302
37699
|
const model = payload.model;
|
|
37303
37700
|
return typeof model === "string" && model !== "" ? model : void 0;
|
|
37304
37701
|
};
|
|
37702
|
+
var SWITCH_MODEL_REMEDY = "Switch to an approved model with /model";
|
|
37703
|
+
var WORDING = {
|
|
37704
|
+
switch: {
|
|
37705
|
+
subject: (model) => `Cannot switch to ${model}`,
|
|
37706
|
+
remedy: SWITCH_MODEL_REMEDY
|
|
37707
|
+
},
|
|
37708
|
+
turn: {
|
|
37709
|
+
subject: (model) => `This session is running on ${model}, which cannot be used`,
|
|
37710
|
+
remedy: SWITCH_MODEL_REMEDY
|
|
37711
|
+
},
|
|
37712
|
+
spawn: {
|
|
37713
|
+
subject: (model) => `Cannot start a subagent on ${model}`,
|
|
37714
|
+
remedy: "Name an approved model on the subagent"
|
|
37715
|
+
},
|
|
37716
|
+
request: {
|
|
37717
|
+
subject: (model) => `Cannot use ${model} for this request`,
|
|
37718
|
+
remedy: "Change the model this application requests"
|
|
37719
|
+
}
|
|
37720
|
+
};
|
|
37721
|
+
function lookupWording(action) {
|
|
37722
|
+
return Object.hasOwn(WORDING, action) ? WORDING[action] : void 0;
|
|
37723
|
+
}
|
|
37305
37724
|
function prohibitedModelMessage(model, action) {
|
|
37306
|
-
const subject
|
|
37307
|
-
|
|
37308
|
-
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.`;
|
|
37725
|
+
const { subject, remedy } = lookupWording(action) ?? WORDING.turn;
|
|
37726
|
+
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.`;
|
|
37309
37727
|
}
|
|
37310
37728
|
function decideProhibitedModelTurn(model, prohibitedModels) {
|
|
37311
37729
|
if (model === void 0 || model === "") return null;
|
|
@@ -38007,6 +38425,12 @@ var RemoteRequestInvalid = class extends Error {
|
|
|
38007
38425
|
}
|
|
38008
38426
|
cause;
|
|
38009
38427
|
};
|
|
38428
|
+
var RemoteEndpointRefused = class extends Error {
|
|
38429
|
+
constructor(endpoint) {
|
|
38430
|
+
super(`refusing to talk to an unsafe control-plane endpoint: ${originOnly(endpoint)}`);
|
|
38431
|
+
this.name = "RemoteEndpointRefused";
|
|
38432
|
+
}
|
|
38433
|
+
};
|
|
38010
38434
|
var RemoteResponseInvalid = class extends Error {
|
|
38011
38435
|
constructor(route, detail) {
|
|
38012
38436
|
super(`control plane answered ${route} with ${detail}`);
|
|
@@ -38159,14 +38583,15 @@ function parsed(schema, body, route) {
|
|
|
38159
38583
|
}
|
|
38160
38584
|
return result.data;
|
|
38161
38585
|
}
|
|
38162
|
-
function
|
|
38586
|
+
function resolveBaseUrl(endpoint) {
|
|
38587
|
+
if (!isSafeEndpoint(endpoint)) throw new RemoteEndpointRefused(endpoint);
|
|
38163
38588
|
let end = endpoint.length;
|
|
38164
38589
|
while (end > 0 && endpoint.charCodeAt(end - 1) === SLASH2) end -= 1;
|
|
38165
38590
|
return endpoint.slice(0, end);
|
|
38166
38591
|
}
|
|
38167
38592
|
var SLASH2 = "/".charCodeAt(0);
|
|
38168
38593
|
function createRemoteClient(options) {
|
|
38169
|
-
const base =
|
|
38594
|
+
const base = resolveBaseUrl(options.endpoint);
|
|
38170
38595
|
const url2 = (route) => `${base}${route}`;
|
|
38171
38596
|
const common = { apiKey: options.apiKey, timeoutMs: options.timeoutMs };
|
|
38172
38597
|
const sendOne = async (event) => {
|
|
@@ -38296,6 +38721,7 @@ function classifyRemoteFailure(err) {
|
|
|
38296
38721
|
case "RemoteRouteAbsent":
|
|
38297
38722
|
return "route-absent";
|
|
38298
38723
|
case "RemoteRequestInvalid":
|
|
38724
|
+
case "RemoteEndpointRefused":
|
|
38299
38725
|
return "invalid-request";
|
|
38300
38726
|
case "RemoteResponseInvalid":
|
|
38301
38727
|
return "rejected";
|
|
@@ -38499,86 +38925,10 @@ function createForwardPolicy(deps) {
|
|
|
38499
38925
|
}
|
|
38500
38926
|
|
|
38501
38927
|
// ../../packages/plugin-runtime/src/attached/gateway.ts
|
|
38502
|
-
|
|
38503
|
-
|
|
38504
|
-
|
|
38505
|
-
return
|
|
38506
|
-
}
|
|
38507
|
-
function ruleCategoryMap(wireRules, localRules) {
|
|
38508
|
-
const map2 = /* @__PURE__ */ new Map();
|
|
38509
|
-
for (const rule of wireRules ?? []) map2.set(rule.id, rule.category);
|
|
38510
|
-
for (const rule of localRules ?? []) map2.set(rule.id, rule.category);
|
|
38511
|
-
for (const pack of bundledDetections()) {
|
|
38512
|
-
for (const rule of pack.rules) map2.set(rule.id, rule.category);
|
|
38513
|
-
}
|
|
38514
|
-
return map2;
|
|
38515
|
-
}
|
|
38516
|
-
function policyKey(policy) {
|
|
38517
|
-
return "ruleId" in policy.target ? `rule:${policy.target.ruleId}` : `category:${policy.target.category}`;
|
|
38518
|
-
}
|
|
38519
|
-
function floorFor(policy, categoryByRuleId) {
|
|
38520
|
-
const category = "category" in policy.target ? policy.target.category : categoryByRuleId.get(policy.target.ruleId);
|
|
38521
|
-
return category === void 0 ? null : DEFAULT_ACTIONS[category];
|
|
38522
|
-
}
|
|
38523
|
-
function mergeRaiseOnly(localPolicies, remotePolicies, categoryByRuleId) {
|
|
38524
|
-
const merged = /* @__PURE__ */ new Map();
|
|
38525
|
-
const disabled = [];
|
|
38526
|
-
const remoteCategoryAction = /* @__PURE__ */ new Map();
|
|
38527
|
-
for (const policy of remotePolicies) {
|
|
38528
|
-
if (!policy.enabled) continue;
|
|
38529
|
-
if (!("category" in policy.target)) continue;
|
|
38530
|
-
if (remoteCategoryAction.has(policy.target.category)) continue;
|
|
38531
|
-
const floor = floorFor(policy, categoryByRuleId);
|
|
38532
|
-
remoteCategoryAction.set(
|
|
38533
|
-
policy.target.category,
|
|
38534
|
-
floor !== null && !isActionAtLeast(policy.action, floor) ? floor : policy.action
|
|
38535
|
-
);
|
|
38536
|
-
}
|
|
38537
|
-
for (const policy of localPolicies) {
|
|
38538
|
-
if (!policy.enabled) {
|
|
38539
|
-
disabled.push(policy);
|
|
38540
|
-
continue;
|
|
38541
|
-
}
|
|
38542
|
-
const key = policyKey(policy);
|
|
38543
|
-
if (merged.has(key)) continue;
|
|
38544
|
-
let remoteFloor = null;
|
|
38545
|
-
if ("ruleId" in policy.target) {
|
|
38546
|
-
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
38547
|
-
if (category !== void 0) remoteFloor = remoteCategoryAction.get(category) ?? null;
|
|
38548
|
-
}
|
|
38549
|
-
merged.set(
|
|
38550
|
-
key,
|
|
38551
|
-
remoteFloor !== null && !isActionAtLeast(policy.action, remoteFloor) ? { ...policy, action: remoteFloor } : policy
|
|
38552
|
-
);
|
|
38553
|
-
}
|
|
38554
|
-
const localCategoryAction = /* @__PURE__ */ new Map();
|
|
38555
|
-
for (const policy of merged.values()) {
|
|
38556
|
-
if ("category" in policy.target) localCategoryAction.set(policy.target.category, policy.action);
|
|
38557
|
-
}
|
|
38558
|
-
for (const policy of remotePolicies) {
|
|
38559
|
-
if (!policy.enabled) {
|
|
38560
|
-
disabled.push(policy);
|
|
38561
|
-
continue;
|
|
38562
|
-
}
|
|
38563
|
-
const key = policyKey(policy);
|
|
38564
|
-
const floor = floorFor(policy, categoryByRuleId);
|
|
38565
|
-
let localFloor = null;
|
|
38566
|
-
if ("ruleId" in policy.target) {
|
|
38567
|
-
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
38568
|
-
if (category !== void 0) localFloor = localCategoryAction.get(category) ?? null;
|
|
38569
|
-
}
|
|
38570
|
-
const effectiveFloor = strongerOf(floor, localFloor);
|
|
38571
|
-
const clamped = effectiveFloor !== null && !isActionAtLeast(policy.action, effectiveFloor) ? { ...policy, action: effectiveFloor } : policy;
|
|
38572
|
-
const existing = merged.get(key);
|
|
38573
|
-
if (existing === void 0) {
|
|
38574
|
-
merged.set(key, clamped);
|
|
38575
|
-
continue;
|
|
38576
|
-
}
|
|
38577
|
-
if (actionRank(clamped.action) > actionRank(existing.action)) {
|
|
38578
|
-
merged.set(key, clamped);
|
|
38579
|
-
}
|
|
38580
|
-
}
|
|
38581
|
-
return [...merged.values(), ...disabled];
|
|
38928
|
+
var bundledRulesFlatCache;
|
|
38929
|
+
function bundledRulesFlat() {
|
|
38930
|
+
bundledRulesFlatCache ??= bundledDetections().flatMap((pack) => pack.rules);
|
|
38931
|
+
return bundledRulesFlatCache;
|
|
38582
38932
|
}
|
|
38583
38933
|
var AttachedDataGateway = class {
|
|
38584
38934
|
constructor(deps) {
|
|
@@ -38898,6 +39248,9 @@ var AttachedDataGateway = class {
|
|
|
38898
39248
|
async readSessionProvider(sessionId) {
|
|
38899
39249
|
return this.deps.local.readSessionProvider(sessionId);
|
|
38900
39250
|
}
|
|
39251
|
+
async readCaptureStatuses() {
|
|
39252
|
+
return this.deps.local.readCaptureStatuses();
|
|
39253
|
+
}
|
|
38901
39254
|
async facets() {
|
|
38902
39255
|
return this.deps.local.facets();
|
|
38903
39256
|
}
|
|
@@ -38980,7 +39333,7 @@ var AttachedDataGateway = class {
|
|
|
38980
39333
|
policies: mergeRaiseOnly(
|
|
38981
39334
|
local.policies,
|
|
38982
39335
|
cached2.policies,
|
|
38983
|
-
ruleCategoryMap(cached2.rules, local.rules)
|
|
39336
|
+
ruleCategoryMap(cached2.rules, local.rules, bundledRulesFlat())
|
|
38984
39337
|
),
|
|
38985
39338
|
customKeywords: [...local.customKeywords, ...cached2.customKeywords],
|
|
38986
39339
|
// TAKEN FROM THE CACHE, unlike the two fields below — and the asymmetry
|
|
@@ -39181,10 +39534,15 @@ import { join as join27 } from "path";
|
|
|
39181
39534
|
// ../../packages/plugin-runtime/src/attached/atomic-publish.ts
|
|
39182
39535
|
import { rename as rename2 } from "fs/promises";
|
|
39183
39536
|
var RETRYABLE = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
|
|
39184
|
-
var
|
|
39537
|
+
var IMMEDIATE_RETRIES = 8;
|
|
39538
|
+
var TIMED_RETRIES = 4;
|
|
39539
|
+
var ATTEMPTS = 1 + IMMEDIATE_RETRIES + TIMED_RETRIES;
|
|
39185
39540
|
var delay = (ms) => new Promise((resolve2) => {
|
|
39186
39541
|
setTimeout(resolve2, ms);
|
|
39187
39542
|
});
|
|
39543
|
+
var yieldToLoop = () => new Promise((resolve2) => {
|
|
39544
|
+
setImmediate(resolve2);
|
|
39545
|
+
});
|
|
39188
39546
|
async function publishByRename(tmp, file2, move = rename2) {
|
|
39189
39547
|
for (let attempt = 1; ; attempt += 1) {
|
|
39190
39548
|
try {
|
|
@@ -39193,7 +39551,7 @@ async function publishByRename(tmp, file2, move = rename2) {
|
|
|
39193
39551
|
} catch (err) {
|
|
39194
39552
|
const code = err.code;
|
|
39195
39553
|
if (attempt >= ATTEMPTS || code === void 0 || !RETRYABLE.has(code)) throw err;
|
|
39196
|
-
await delay(attempt * 10);
|
|
39554
|
+
await (attempt <= IMMEDIATE_RETRIES ? yieldToLoop() : delay((attempt - IMMEDIATE_RETRIES) * 10));
|
|
39197
39555
|
}
|
|
39198
39556
|
}
|
|
39199
39557
|
}
|
|
@@ -39657,6 +40015,9 @@ var StandaloneDataGateway = class {
|
|
|
39657
40015
|
readSessionProvider(sessionId) {
|
|
39658
40016
|
return Promise.resolve(this.db.auditEvents.sessionProvider(sessionId));
|
|
39659
40017
|
}
|
|
40018
|
+
readCaptureStatuses() {
|
|
40019
|
+
return Promise.resolve(this.db.captureStatus.latest(Date.now()));
|
|
40020
|
+
}
|
|
39660
40021
|
facets() {
|
|
39661
40022
|
return Promise.resolve(this.db.facets());
|
|
39662
40023
|
}
|