@akasecurity/ai-tc-claude-code 0.9.12 → 0.9.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/package.json +2 -2
- package/scripts/apply-suppressions.js +331 -22
- package/scripts/backfill.js +464 -124
- package/scripts/content-retention.js +334 -22
- package/scripts/filescan.js +464 -124
- package/scripts/firstrun.js +464 -124
- package/scripts/history-sync.js +379 -42
- package/scripts/intro.js +209 -17
- package/scripts/message-display.js +331 -22
- package/scripts/onboard.js +331 -22
- package/scripts/post-model-switch.js +212 -17
- package/scripts/post-tool-use.js +464 -124
- package/scripts/pre-model-switch.js +488 -127
- package/scripts/pre-tool-use.js +488 -127
- package/scripts/query.js +575 -125
- package/scripts/reconcile.js +464 -124
- package/scripts/remediate.js +464 -124
- package/scripts/scan-worker.js +209 -17
- package/scripts/session-start.js +464 -124
- package/scripts/start-light.js +209 -17
- package/scripts/statusline.js +464 -124
- package/scripts/stop.js +212 -17
- package/scripts/sync.js +464 -124
- package/scripts/user-prompt-submit.js +488 -127
package/scripts/onboard.js
CHANGED
|
@@ -20476,7 +20476,17 @@ var UNPRICEABLE_PROVIDERS = Object.freeze([
|
|
|
20476
20476
|
"gateway",
|
|
20477
20477
|
"unknown",
|
|
20478
20478
|
"cli",
|
|
20479
|
-
"api"
|
|
20479
|
+
"api",
|
|
20480
|
+
// The browser extension's native host records these as `llm_call.provider`
|
|
20481
|
+
// for a web-chat turn — the web tool id, deliberately never the vendor id
|
|
20482
|
+
// (`openai`/`anthropic`) the session root carries. Subscription traffic
|
|
20483
|
+
// burns rate-limit budget, not dollar credits, and listing them here is
|
|
20484
|
+
// what keeps that true structurally: a later maintainer who wants to price
|
|
20485
|
+
// web-chat traffic at API rates has to delete this entry first, and meet
|
|
20486
|
+
// the reason on the way, rather than quietly adding one to
|
|
20487
|
+
// PROVIDER_PLATFORM.
|
|
20488
|
+
"chatgpt",
|
|
20489
|
+
"claude-ai"
|
|
20480
20490
|
]);
|
|
20481
20491
|
function platformForProvider(provider) {
|
|
20482
20492
|
return PROVIDER_PLATFORM.get(provider.trim().toLowerCase()) ?? null;
|
|
@@ -20619,7 +20629,12 @@ var HARNESS = {
|
|
|
20619
20629
|
ClaudeDesktop: "claudedesktop",
|
|
20620
20630
|
ChatGpt: "chatgpt",
|
|
20621
20631
|
ClaudeAi: "claudeai",
|
|
20622
|
-
Api: "api"
|
|
20632
|
+
Api: "api",
|
|
20633
|
+
// Not a coding assistant a person drives — an in-process SDK embedded in an
|
|
20634
|
+
// application, so it has no IDE/CLI/desktop/web surface of its own. Carries
|
|
20635
|
+
// the same id as its SOURCE_TOOL counterpart, unlike every capture-side tool
|
|
20636
|
+
// whose wire spelling differs from its display spelling.
|
|
20637
|
+
AiTcSdk: "ai-tc-sdk"
|
|
20623
20638
|
};
|
|
20624
20639
|
var Harness = external_exports.enum(HARNESS).meta({ id: "Harness" });
|
|
20625
20640
|
var SOURCE_TOOL = {
|
|
@@ -20635,9 +20650,15 @@ var SOURCE_TOOL = {
|
|
|
20635
20650
|
// whose tool could not be identified both render through the read side's
|
|
20636
20651
|
// miss path rather than as a harness of their own.
|
|
20637
20652
|
Cli: "cli",
|
|
20638
|
-
Unknown: "unknown"
|
|
20653
|
+
Unknown: "unknown",
|
|
20654
|
+
// The wire id an in-process, request-path SDK stamps on its own structural
|
|
20655
|
+
// rows (`request_decision`) — never a capture of prompt/response/tool text,
|
|
20656
|
+
// since the SDK sits in front of a model call rather than inside a coding
|
|
20657
|
+
// assistant's own hook contract.
|
|
20658
|
+
AiTcSdk: "ai-tc-sdk"
|
|
20639
20659
|
};
|
|
20640
20660
|
var SourceTool = external_exports.enum(SOURCE_TOOL).meta({ id: "SourceTool" });
|
|
20661
|
+
var WebSourceTool = SourceTool.extract(["ChatGpt", "ClaudeAi"]);
|
|
20641
20662
|
var TOOL_TO_HARNESS = {
|
|
20642
20663
|
[SOURCE_TOOL.ClaudeCode]: HARNESS.ClaudeCode,
|
|
20643
20664
|
[SOURCE_TOOL.ClaudeDesktop]: HARNESS.ClaudeDesktop,
|
|
@@ -20646,7 +20667,12 @@ var TOOL_TO_HARNESS = {
|
|
|
20646
20667
|
[SOURCE_TOOL.ChatGpt]: HARNESS.ChatGpt,
|
|
20647
20668
|
[SOURCE_TOOL.Codex]: HARNESS.Codex,
|
|
20648
20669
|
[SOURCE_TOOL.Antigravity]: HARNESS.Antigravity,
|
|
20649
|
-
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi
|
|
20670
|
+
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi,
|
|
20671
|
+
// Wire and display id are the same string here, but the row still belongs:
|
|
20672
|
+
// both vocabularies carry the `AiTcSdk` member, and the join is exactly
|
|
20673
|
+
// their intersection — leaving a shared member out would read as an
|
|
20674
|
+
// uninstrumented tool on both surfaces, which this one is not.
|
|
20675
|
+
[SOURCE_TOOL.AiTcSdk]: HARNESS.AiTcSdk
|
|
20650
20676
|
};
|
|
20651
20677
|
|
|
20652
20678
|
// ../../packages/schema/src/zod/finding.ts
|
|
@@ -20680,7 +20706,8 @@ var FindingProvider = Harness.extract([
|
|
|
20680
20706
|
"ClaudeAi",
|
|
20681
20707
|
"Codex",
|
|
20682
20708
|
"Antigravity",
|
|
20683
|
-
"Api"
|
|
20709
|
+
"Api",
|
|
20710
|
+
"AiTcSdk"
|
|
20684
20711
|
]).meta({ id: "FindingProvider" });
|
|
20685
20712
|
var FindingCategory = external_exports.enum([
|
|
20686
20713
|
"secret",
|
|
@@ -21057,18 +21084,41 @@ var AuditEventType = external_exports.enum([
|
|
|
21057
21084
|
// 'tool_call' is the reconciler's structural row for every call, while
|
|
21058
21085
|
// 'tool_use' exists only where a hook enforced against the arguments.
|
|
21059
21086
|
"tool_use",
|
|
21060
|
-
// One row per model REFUSAL
|
|
21061
|
-
//
|
|
21062
|
-
//
|
|
21063
|
-
//
|
|
21064
|
-
//
|
|
21065
|
-
//
|
|
21087
|
+
// One row per model REFUSAL, across all four seams a prohibited model can be
|
|
21088
|
+
// stopped at: a switch onto it, a turn already running on it, a subagent
|
|
21089
|
+
// spawn asking for it, or a request-path refusal an embedded request-path
|
|
21090
|
+
// SDK makes in-process before the call leaves the application. Which seam
|
|
21091
|
+
// rides `attributes.refusal_seam`, never this member name. A structural row
|
|
21092
|
+
// like the ones above rather than a capture — it carries the model that was
|
|
21093
|
+
// refused and nothing the user typed, because what is worth recording about
|
|
21094
|
+
// a governance decision is the decision, and prompt text is the thing this
|
|
21095
|
+
// product exists to keep from travelling.
|
|
21066
21096
|
"model_refusal",
|
|
21097
|
+
// One row per request-path DECISION: a policy check an embedded request-path
|
|
21098
|
+
// SDK performs in-process before a model call leaves the application, or
|
|
21099
|
+
// against that call's non-streamed response. A structural row like
|
|
21100
|
+
// 'model_refusal' rather than a capture — content-free in the same way:
|
|
21101
|
+
// which side, which seam, what action and which field are decided rides
|
|
21102
|
+
// `attributes`, never this member name, and the matched text itself never
|
|
21103
|
+
// travels.
|
|
21104
|
+
//
|
|
21105
|
+
// A prohibited-model refusal on the request path is deliberately NOT this
|
|
21106
|
+
// member: it stays 'model_refusal' with `refusal_seam: 'request'`, so it
|
|
21107
|
+
// shares one bucket with the plugin's switch/turn/spawn refusals rather
|
|
21108
|
+
// than splitting one governance concept across two event types. This
|
|
21109
|
+
// member carries every OTHER request-path decision.
|
|
21110
|
+
"request_decision",
|
|
21067
21111
|
// One row per config-inventory scan, hung off the session root. It is the
|
|
21068
21112
|
// fact the posture inspection findings reference (findings require an
|
|
21069
21113
|
// audit_event_id), and its started_at is the "scanned Nm ago" the read
|
|
21070
21114
|
// surface renders.
|
|
21071
|
-
"config_scan"
|
|
21115
|
+
"config_scan",
|
|
21116
|
+
// One row per reported browser-extension capture status, hung off the web
|
|
21117
|
+
// session root. The durable home of what one tab's network interception
|
|
21118
|
+
// is doing — a write-through of the native host's in-memory tracker, so a
|
|
21119
|
+
// second process (aka extension status) and a restarted host both have
|
|
21120
|
+
// somewhere to read it back from.
|
|
21121
|
+
"capture_status"
|
|
21072
21122
|
]).meta({ id: "AuditEventType" });
|
|
21073
21123
|
var AttributeBag = external_exports.record(external_exports.string(), external_exports.unknown());
|
|
21074
21124
|
var HostAttributes = external_exports.object({
|
|
@@ -21228,6 +21278,20 @@ var CaptureAttributes = external_exports.object({
|
|
|
21228
21278
|
// repeated rather than referenced because a store reader opens this file.
|
|
21229
21279
|
redact_degraded_to: ActionTaken.optional()
|
|
21230
21280
|
}).catchall(external_exports.unknown());
|
|
21281
|
+
var CaptureStatusAttributes = external_exports.object({
|
|
21282
|
+
source_tool: external_exports.string().optional(),
|
|
21283
|
+
patched: external_exports.boolean().optional(),
|
|
21284
|
+
live: external_exports.boolean().optional(),
|
|
21285
|
+
blind: external_exports.boolean().optional(),
|
|
21286
|
+
sends_seen_dom: external_exports.number().int().nonnegative().optional(),
|
|
21287
|
+
exchanges_seen_net: external_exports.number().int().nonnegative().optional(),
|
|
21288
|
+
parse_failures: external_exports.number().int().nonnegative().optional(),
|
|
21289
|
+
unparsed_bodies: external_exports.number().int().nonnegative().optional(),
|
|
21290
|
+
shape_misses: external_exports.array(external_exports.string()).optional(),
|
|
21291
|
+
conversation_endpoints: external_exports.number().int().nonnegative().optional(),
|
|
21292
|
+
closed: external_exports.boolean().optional(),
|
|
21293
|
+
enforcement: external_exports.string().optional()
|
|
21294
|
+
}).catchall(external_exports.unknown());
|
|
21231
21295
|
var ToolCallInspection = external_exports.object({
|
|
21232
21296
|
ruleId: external_exports.string().min(1),
|
|
21233
21297
|
ruleName: external_exports.string(),
|
|
@@ -22240,6 +22304,11 @@ var RemoteFailureKind = external_exports.enum([
|
|
|
22240
22304
|
"rejected",
|
|
22241
22305
|
"unreachable"
|
|
22242
22306
|
]);
|
|
22307
|
+
var ControlPlaneFailure = RemoteFailureKind.extract([
|
|
22308
|
+
"unauthorized",
|
|
22309
|
+
"forbidden",
|
|
22310
|
+
"unreachable"
|
|
22311
|
+
]);
|
|
22243
22312
|
var AttachDeviceRequest = external_exports.object({
|
|
22244
22313
|
// This machine's own continuity id, so re-attaching ROTATES the credential
|
|
22245
22314
|
// on one machine record instead of producing a second one. Client-minted
|
|
@@ -22779,7 +22848,12 @@ var EventMetadata = external_exports.object({
|
|
|
22779
22848
|
// in — set by the browser extension's network capture so a stored `response`
|
|
22780
22849
|
// row can be joined to the `llm_call` leaf describing the same turn. Absent
|
|
22781
22850
|
// on every other capture path, which has no such id.
|
|
22782
|
-
|
|
22851
|
+
//
|
|
22852
|
+
// Non-empty for the reason WebExchange.messageId is: it is the join key, and
|
|
22853
|
+
// a blank one matches no `llm_call` leaf. That refusal reaches only the
|
|
22854
|
+
// places an event is PARSED; the local write path types the event and parses
|
|
22855
|
+
// nothing, which is why `toCaptureAttributes` omits a blank one separately.
|
|
22856
|
+
messageId: external_exports.string().min(1).optional(),
|
|
22783
22857
|
conversationId: external_exports.string().optional(),
|
|
22784
22858
|
// How long THIS capture's inspection blocked its caller, in whole
|
|
22785
22859
|
// milliseconds — the plugin's own added latency, NOT the LLM call it sat in
|
|
@@ -23854,6 +23928,18 @@ var HistorySyncConsent = external_exports.object({
|
|
|
23854
23928
|
payloadVersion: external_exports.number().int().positive(),
|
|
23855
23929
|
endpoint: external_exports.string()
|
|
23856
23930
|
});
|
|
23931
|
+
var WebChatCaptureConsent = external_exports.object({
|
|
23932
|
+
acknowledgedAt: external_exports.iso.datetime(),
|
|
23933
|
+
version: external_exports.number().int().positive()
|
|
23934
|
+
});
|
|
23935
|
+
var WebChatResponseCapture = external_exports.enum(["with-findings", "always", "never"]);
|
|
23936
|
+
var WebChatCapture = external_exports.object({
|
|
23937
|
+
responses: WebChatResponseCapture.default("with-findings"),
|
|
23938
|
+
account: external_exports.boolean().default(false),
|
|
23939
|
+
// Absent until granted. Presence alone does not authorize anything — see
|
|
23940
|
+
// isWebChatCaptureConsentValid.
|
|
23941
|
+
consent: WebChatCaptureConsent.optional()
|
|
23942
|
+
});
|
|
23857
23943
|
var BODY_RETENTION_DEFAULT_DAYS = 30;
|
|
23858
23944
|
var BodyRetention = external_exports.object({
|
|
23859
23945
|
enabled: external_exports.boolean().default(false),
|
|
@@ -23912,6 +23998,16 @@ var WorkspaceSettings = external_exports.object({
|
|
|
23912
23998
|
// both widenings. Absent until granted, and a grant for a different endpoint
|
|
23913
23999
|
// or an older payload no longer counts.
|
|
23914
24000
|
historySyncConsent: HistorySyncConsent.optional(),
|
|
24001
|
+
// What the browser extension may record from a web chat, and the grant that
|
|
24002
|
+
// authorizes it. Absent until the user answers: recording something that was
|
|
24003
|
+
// never recorded before is never an assumed grant on upgrade, so the whole
|
|
24004
|
+
// block is optional rather than defaulted in. What an absent block means is
|
|
24005
|
+
// webChatCaptureOf's answer, in one place.
|
|
24006
|
+
//
|
|
24007
|
+
// Enforcement is NOT gated on this. A machine that has never answered still
|
|
24008
|
+
// blocks, redacts and warns on what a user sends; the grant covers what is
|
|
24009
|
+
// written down.
|
|
24010
|
+
webChatCapture: WebChatCapture.optional(),
|
|
23915
24011
|
// Local body expiry (see BodyRetention). Off until switched on; expiring a
|
|
23916
24012
|
// body never removes the row or its findings.
|
|
23917
24013
|
bodyRetention: BodyRetention.default({
|
|
@@ -24019,7 +24115,10 @@ function toCaptureAttributes(event) {
|
|
|
24019
24115
|
// `.catchall(z.unknown())` carries the long tail.
|
|
24020
24116
|
...metadata?.model !== void 0 ? { model: metadata.model } : {},
|
|
24021
24117
|
...metadata?.turnIndex !== void 0 ? { turn_index: metadata.turnIndex } : {},
|
|
24022
|
-
|
|
24118
|
+
// A blank id is omitted rather than stored: it is a join key and `''` joins
|
|
24119
|
+
// nothing. This runs on the local write path, which types the event but
|
|
24120
|
+
// never parses it, so EventMetadata's own `.min(1)` does not reach here.
|
|
24121
|
+
...metadata?.messageId !== void 0 && metadata.messageId !== "" ? { message_id: metadata.messageId } : {},
|
|
24023
24122
|
...metadata?.conversationId !== void 0 ? { conversation_id: metadata.conversationId } : {}
|
|
24024
24123
|
};
|
|
24025
24124
|
}
|
|
@@ -24394,12 +24493,14 @@ var RecommendedActionIdParam = external_exports.object({ id: external_exports.st
|
|
|
24394
24493
|
// ../../packages/schema/src/zod/settings-action.ts
|
|
24395
24494
|
var HistorySyncConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "HistorySyncConsentChoice" });
|
|
24396
24495
|
var ModelJudgeConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "ModelJudgeConsentChoice" });
|
|
24496
|
+
var WebChatCaptureConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "WebChatCaptureConsentChoice" });
|
|
24397
24497
|
var SaveSettingsInput = external_exports.object({
|
|
24398
24498
|
historicalAccess: external_exports.string(),
|
|
24399
24499
|
modelJudgeConsent: ModelJudgeConsentChoice,
|
|
24400
24500
|
historySyncConsent: HistorySyncConsentChoice,
|
|
24401
24501
|
vaultConsent: external_exports.string(),
|
|
24402
24502
|
vaultInlineReveal: external_exports.string(),
|
|
24503
|
+
webChatCaptureConsent: WebChatCaptureConsentChoice,
|
|
24403
24504
|
// Widened to `string` like its neighbours rather than typed as
|
|
24404
24505
|
// `RedactFallback`, on this module's own layering rule: shape here, VALUE at
|
|
24405
24506
|
// the call site, so the domain check receives the type it was written for.
|
|
@@ -24614,11 +24715,24 @@ var WebExchange = external_exports.object({
|
|
|
24614
24715
|
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
24615
24716
|
toolCalls: external_exports.array(WebToolCall).default([]),
|
|
24616
24717
|
// Absent when the adapter recovered no text. Capped by the caller at
|
|
24617
|
-
// RESPONSE_TEXT_MAX_BYTES
|
|
24618
|
-
//
|
|
24718
|
+
// RESPONSE_TEXT_MAX_BYTES, so a short capture is never mistaken for a short
|
|
24719
|
+
// reply.
|
|
24619
24720
|
responseText: external_exports.string().optional(),
|
|
24721
|
+
// The stored text is short of the reply. It does NOT say which of the two
|
|
24722
|
+
// ceilings on this path cut it: the caller applies its own cap on the raw
|
|
24723
|
+
// bytes it reads off the wire, which can be reached by a stream whose
|
|
24724
|
+
// recovered text stays well under RESPONSE_TEXT_MAX_BYTES, and applies that
|
|
24725
|
+
// one to the text. A reader cannot tell them apart, and nothing downstream
|
|
24726
|
+
// should branch as though it could.
|
|
24620
24727
|
truncated: external_exports.boolean().default(false)
|
|
24621
24728
|
});
|
|
24729
|
+
var WebEnforcementState = external_exports.enum([
|
|
24730
|
+
"watching",
|
|
24731
|
+
"composer-only",
|
|
24732
|
+
"button-only",
|
|
24733
|
+
"unattached",
|
|
24734
|
+
"unknown"
|
|
24735
|
+
]);
|
|
24622
24736
|
var RESPONSE_TEXT_MAX_BYTES = 2 * 1024 * 1024;
|
|
24623
24737
|
var WebCaptureStatus = external_exports.object({
|
|
24624
24738
|
patched: external_exports.boolean(),
|
|
@@ -24630,8 +24744,66 @@ var WebCaptureStatus = external_exports.object({
|
|
|
24630
24744
|
unparsedBodies: external_exports.number().int().nonnegative(),
|
|
24631
24745
|
// The adapter-declared JSON key paths that were absent from a real payload —
|
|
24632
24746
|
// the earliest signal that a site's contract moved.
|
|
24633
|
-
shapeMisses: external_exports.array(external_exports.string()).default([])
|
|
24634
|
-
|
|
24747
|
+
shapeMisses: external_exports.array(external_exports.string()).default([]),
|
|
24748
|
+
// How many `kind: 'conversation'` endpoints the reporting tab's adapter
|
|
24749
|
+
// compiled. Zero means this build declares none for the site, so observing
|
|
24750
|
+
// nothing is the design rather than a fault — the one fact that separates a
|
|
24751
|
+
// site nobody has surveyed yet from one whose contract moved. Defaulted so a
|
|
24752
|
+
// build predating the field is read as declaring nothing rather than refused.
|
|
24753
|
+
conversationEndpoints: external_exports.number().int().nonnegative().default(0),
|
|
24754
|
+
// The document that sent this report is going away. The bridge sets it on
|
|
24755
|
+
// its `pagehide` report and nowhere else.
|
|
24756
|
+
//
|
|
24757
|
+
// A property of the REPORT rather than of capture health, which is why
|
|
24758
|
+
// nothing in `deriveWebCaptureState` reads it and why it stays out of the
|
|
24759
|
+
// bridge's own report signature — a closing tab's last word must not be
|
|
24760
|
+
// suppressed for carrying the same health as the report before it. What
|
|
24761
|
+
// reads it is the per-site fold: a document that said it was unloading stops
|
|
24762
|
+
// voting on the site's state, so the reload the `blind` remediation asks for
|
|
24763
|
+
// can actually clear the verdict it was shown. A document that dies without
|
|
24764
|
+
// sending one is covered by CAPTURE_STATUS_DOCUMENT_QUIET_MS instead.
|
|
24765
|
+
//
|
|
24766
|
+
// Defaulted so a build predating the field reads as a document that never
|
|
24767
|
+
// said it was closing — which keeps it voting, the same as every report that
|
|
24768
|
+
// is not a final one.
|
|
24769
|
+
closed: external_exports.boolean().default(false),
|
|
24770
|
+
// What the DOM enforcement path is doing, which none of the counters above
|
|
24771
|
+
// can say: `sendsSeenDom` rises only once a send has COMPLETED, so a tab
|
|
24772
|
+
// whose watcher never bound reports zero exactly like a tab nobody typed in.
|
|
24773
|
+
// Defaulted to 'unknown' rather than 'watching' so a status from a build
|
|
24774
|
+
// predating the field is not read as reporting a healthy one.
|
|
24775
|
+
enforcement: WebEnforcementState.default("unknown")
|
|
24776
|
+
});
|
|
24777
|
+
function webCaptureStatusObservedTurnPath(status) {
|
|
24778
|
+
if (!status.patched) return true;
|
|
24779
|
+
if (status.conversationEndpoints === 0) return true;
|
|
24780
|
+
return status.blind || status.shapeMisses.length > 0 || status.parseFailures > 0 || status.unparsedBodies > 0 || status.exchangesSeenNet > 0;
|
|
24781
|
+
}
|
|
24782
|
+
function pickReportedCaptureStatus(candidates) {
|
|
24783
|
+
return candidates.find((c) => webCaptureStatusObservedTurnPath(c.status)) ?? candidates[0];
|
|
24784
|
+
}
|
|
24785
|
+
var CAPTURE_STATUS_RECENCY_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
24786
|
+
var CAPTURE_STATUS_RECENCY_DAYS = CAPTURE_STATUS_RECENCY_MS / (24 * 60 * 60 * 1e3);
|
|
24787
|
+
var CAPTURE_STATUS_DOCUMENT_QUIET_MS = 12 * 60 * 60 * 1e3;
|
|
24788
|
+
function fromCaptureStatusAttributes(bag) {
|
|
24789
|
+
const parsedBag = CaptureStatusAttributes.safeParse(bag);
|
|
24790
|
+
if (!parsedBag.success) return null;
|
|
24791
|
+
const b = parsedBag.data;
|
|
24792
|
+
const parsedStatus = WebCaptureStatus.safeParse({
|
|
24793
|
+
patched: b.patched,
|
|
24794
|
+
live: b.live,
|
|
24795
|
+
blind: b.blind,
|
|
24796
|
+
sendsSeenDom: b.sends_seen_dom,
|
|
24797
|
+
exchangesSeenNet: b.exchanges_seen_net,
|
|
24798
|
+
parseFailures: b.parse_failures,
|
|
24799
|
+
unparsedBodies: b.unparsed_bodies,
|
|
24800
|
+
shapeMisses: b.shape_misses,
|
|
24801
|
+
conversationEndpoints: b.conversation_endpoints,
|
|
24802
|
+
closed: b.closed,
|
|
24803
|
+
enforcement: b.enforcement
|
|
24804
|
+
});
|
|
24805
|
+
return parsedStatus.success ? parsedStatus.data : null;
|
|
24806
|
+
}
|
|
24635
24807
|
|
|
24636
24808
|
// ../../packages/persistence/src/paths.ts
|
|
24637
24809
|
import {
|
|
@@ -26417,7 +26589,7 @@ var SESSION_ROOT = `event_type = 'session'`;
|
|
|
26417
26589
|
var HAS_ACTIVITY = `EXISTS (
|
|
26418
26590
|
SELECT 1 FROM audit_events c
|
|
26419
26591
|
WHERE c.root_session_id = audit_events.id
|
|
26420
|
-
AND c.event_type NOT IN ('hook', 'config_scan'))`;
|
|
26592
|
+
AND c.event_type NOT IN ('hook', 'config_scan', 'capture_status'))`;
|
|
26421
26593
|
var SqliteActivityRepository = class {
|
|
26422
26594
|
constructor(db, now = () => Date.now()) {
|
|
26423
26595
|
this.db = db;
|
|
@@ -26444,10 +26616,10 @@ var SqliteActivityRepository = class {
|
|
|
26444
26616
|
SELECT id FROM audit_events WHERE event_type = 'session' AND started_at >= ?
|
|
26445
26617
|
UNION
|
|
26446
26618
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_started_at
|
|
26447
|
-
WHERE started_at >= ?
|
|
26619
|
+
WHERE started_at >= ? AND event_type <> 'capture_status'
|
|
26448
26620
|
UNION
|
|
26449
26621
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_ended_at
|
|
26450
|
-
WHERE ended_at >= ?)`,
|
|
26622
|
+
WHERE ended_at >= ? AND event_type <> 'capture_status')`,
|
|
26451
26623
|
[liveThreshold, liveThreshold, liveThreshold]
|
|
26452
26624
|
);
|
|
26453
26625
|
const toolCallsToday = countScalar(
|
|
@@ -26854,7 +27026,10 @@ var SqliteAuditEventsRepository = class {
|
|
|
26854
27026
|
attributes = excluded.attributes,
|
|
26855
27027
|
ended_at = excluded.ended_at
|
|
26856
27028
|
WHERE COALESCE(json_extract(excluded.attributes, '$.output_tokens'), 0)
|
|
26857
|
-
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27029
|
+
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27030
|
+
OR (json_extract(excluded.attributes, '$.usage_source') IS NOT NULL
|
|
27031
|
+
AND json_extract(excluded.attributes, '$.output_tokens') IS NULL
|
|
27032
|
+
AND excluded.attributes <> audit_events.attributes)`
|
|
26858
27033
|
);
|
|
26859
27034
|
this.upsertSessionRootStmt = db.prepare(
|
|
26860
27035
|
`INSERT OR IGNORE INTO audit_events
|
|
@@ -27122,6 +27297,87 @@ var SqliteBodyRetentionRepository = class {
|
|
|
27122
27297
|
}
|
|
27123
27298
|
};
|
|
27124
27299
|
|
|
27300
|
+
// ../../packages/persistence/src/repositories/capture-status.ts
|
|
27301
|
+
var STATUS_LOOKBACK_ROWS = 128;
|
|
27302
|
+
var SqliteCaptureStatusRepository = class {
|
|
27303
|
+
constructor(db) {
|
|
27304
|
+
this.db = db;
|
|
27305
|
+
this.recentStmt = db.prepare(
|
|
27306
|
+
`SELECT a.started_at AS startedAt,
|
|
27307
|
+
a.attributes AS attributes,
|
|
27308
|
+
a.root_session_id AS rootSessionId
|
|
27309
|
+
FROM audit_events a
|
|
27310
|
+
WHERE a.event_type = 'capture_status'
|
|
27311
|
+
AND a.source_tool = ?
|
|
27312
|
+
AND a.started_at >= ?
|
|
27313
|
+
ORDER BY a.started_at DESC, a.id DESC
|
|
27314
|
+
LIMIT ?`
|
|
27315
|
+
);
|
|
27316
|
+
}
|
|
27317
|
+
db;
|
|
27318
|
+
recentStmt;
|
|
27319
|
+
/**
|
|
27320
|
+
* Every document that reported for a site, in registry order by site, from
|
|
27321
|
+
* the last `CAPTURE_STATUS_RECENCY_MS`.
|
|
27322
|
+
*
|
|
27323
|
+
* SEVERAL per site, not one: a browser is many documents and each reports
|
|
27324
|
+
* for itself, so one row per site is a choice about which of them a user
|
|
27325
|
+
* sees — and the newest is the wrong one, since a healthy tab writing a
|
|
27326
|
+
* fresh report would hide a drifting tab's verdict, which is the whole
|
|
27327
|
+
* reason these rows exist. The pick WITHIN a document is made here (the
|
|
27328
|
+
* unchanged `pickReportedCaptureStatus`, over that document's own rows);
|
|
27329
|
+
* choosing between documents belongs where the state semantics live, and
|
|
27330
|
+
* that is `reportedCaptureDocumentForSite` in `@akasecurity/detections` —
|
|
27331
|
+
* this package may not import it.
|
|
27332
|
+
*
|
|
27333
|
+
* `now` is a required argument rather than a `Date.now()` read, so a caller
|
|
27334
|
+
* that already holds a render instant passes THAT one and a test can drive
|
|
27335
|
+
* the window without moving the wall clock.
|
|
27336
|
+
*
|
|
27337
|
+
* A site whose reports have all aged out contributes nothing, so it derives
|
|
27338
|
+
* to `unreported`. That is the point: nothing but the browser extension ever
|
|
27339
|
+
* writes these rows, so an uninstalled extension's last verdict would
|
|
27340
|
+
* otherwise stand as a live claim for ever with no later report able to
|
|
27341
|
+
* clear it.
|
|
27342
|
+
*/
|
|
27343
|
+
latest(now) {
|
|
27344
|
+
const since = now - CAPTURE_STATUS_RECENCY_MS;
|
|
27345
|
+
const documents = [];
|
|
27346
|
+
for (const tool of WebSourceTool.options) {
|
|
27347
|
+
const rows = /* @__PURE__ */ new Map();
|
|
27348
|
+
const lastWord = /* @__PURE__ */ new Map();
|
|
27349
|
+
for (const row of allRows(this.recentStmt, [
|
|
27350
|
+
tool,
|
|
27351
|
+
since,
|
|
27352
|
+
STATUS_LOOKBACK_ROWS
|
|
27353
|
+
])) {
|
|
27354
|
+
const status = fromCaptureStatusAttributes(parseJsonObject(row.attributes));
|
|
27355
|
+
if (status === null) continue;
|
|
27356
|
+
const record2 = { tool, observedAt: epochMillisToIso(row.startedAt), status };
|
|
27357
|
+
const group = rows.get(row.rootSessionId);
|
|
27358
|
+
if (group === void 0) {
|
|
27359
|
+
rows.set(row.rootSessionId, [record2]);
|
|
27360
|
+
lastWord.set(row.rootSessionId, { at: record2.observedAt, closed: status.closed });
|
|
27361
|
+
} else {
|
|
27362
|
+
group.push(record2);
|
|
27363
|
+
}
|
|
27364
|
+
}
|
|
27365
|
+
for (const [root, candidates] of rows) {
|
|
27366
|
+
const picked = pickReportedCaptureStatus(candidates);
|
|
27367
|
+
const last = lastWord.get(root);
|
|
27368
|
+
if (picked === void 0 || last === void 0) continue;
|
|
27369
|
+
documents.push({
|
|
27370
|
+
...picked,
|
|
27371
|
+
...root === null ? {} : { rootSessionId: root },
|
|
27372
|
+
lastReportAt: last.at,
|
|
27373
|
+
closed: last.closed
|
|
27374
|
+
});
|
|
27375
|
+
}
|
|
27376
|
+
}
|
|
27377
|
+
return documents;
|
|
27378
|
+
}
|
|
27379
|
+
};
|
|
27380
|
+
|
|
27125
27381
|
// ../../packages/persistence/src/repositories/classified-data.ts
|
|
27126
27382
|
var SqliteClassifiedDataRepository = class {
|
|
27127
27383
|
constructor(db) {
|
|
@@ -33002,6 +33258,7 @@ function openAndInitialize(file2, base, skipTags) {
|
|
|
33002
33258
|
activity: new SqliteActivityRepository(db),
|
|
33003
33259
|
sourceProject: new SqliteSourceProjectRepository(db),
|
|
33004
33260
|
auditEvents: new SqliteAuditEventsRepository(db),
|
|
33261
|
+
captureStatus: new SqliteCaptureStatusRepository(db),
|
|
33005
33262
|
classifiedData: new SqliteClassifiedDataRepository(db),
|
|
33006
33263
|
inspectionDefinitions: new SqliteInspectionDefinitionsRepository(db),
|
|
33007
33264
|
inspectionFindings: new SqliteInspectionFindingsRepository(db),
|
|
@@ -33042,6 +33299,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
33042
33299
|
activity,
|
|
33043
33300
|
sourceProject,
|
|
33044
33301
|
auditEvents,
|
|
33302
|
+
captureStatus,
|
|
33045
33303
|
classifiedData,
|
|
33046
33304
|
inspectionDefinitions,
|
|
33047
33305
|
inspectionFindings,
|
|
@@ -33259,6 +33517,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
33259
33517
|
activity,
|
|
33260
33518
|
sourceProject,
|
|
33261
33519
|
auditEvents,
|
|
33520
|
+
captureStatus,
|
|
33262
33521
|
classifiedData,
|
|
33263
33522
|
inspectionDefinitions,
|
|
33264
33523
|
inspectionFindings,
|
|
@@ -34161,6 +34420,56 @@ var CONFIG_POSTURE_RULES = [
|
|
|
34161
34420
|
}
|
|
34162
34421
|
];
|
|
34163
34422
|
|
|
34423
|
+
// ../../packages/detections/src/posture/web-capture-posture.ts
|
|
34424
|
+
var RULE_VERSION2 = "1";
|
|
34425
|
+
var DRIFT_MIN_PARSE_FAILURES = 2;
|
|
34426
|
+
var WEB_CAPTURE_DRIFT_STATES = /* @__PURE__ */ new Set([
|
|
34427
|
+
"blind",
|
|
34428
|
+
"degraded"
|
|
34429
|
+
]);
|
|
34430
|
+
var WEB_CAPTURE_DRIFT_RULE = {
|
|
34431
|
+
ruleId: "web-capture-drift",
|
|
34432
|
+
version: RULE_VERSION2,
|
|
34433
|
+
name: "Web chat capture is not reading the site",
|
|
34434
|
+
category: "config",
|
|
34435
|
+
severity: "medium",
|
|
34436
|
+
definition: JSON.stringify({
|
|
34437
|
+
kind: "web-capture-drift",
|
|
34438
|
+
states: [...WEB_CAPTURE_DRIFT_STATES],
|
|
34439
|
+
minParseFailures: DRIFT_MIN_PARSE_FAILURES
|
|
34440
|
+
})
|
|
34441
|
+
};
|
|
34442
|
+
var STATIC_COPY = {
|
|
34443
|
+
active: { headline: "turns are being observed on this site" },
|
|
34444
|
+
unreported: {
|
|
34445
|
+
// Says "recently" rather than "yet": the store read is bounded to
|
|
34446
|
+
// CAPTURE_STATUS_RECENCY_MS, so this state covers a site nothing has ever
|
|
34447
|
+
// reported for AND one whose last report has aged out. The two are the
|
|
34448
|
+
// same fact to a reader — nobody has confirmed anything lately — and the
|
|
34449
|
+
// copy may not claim the stronger of them.
|
|
34450
|
+
headline: `no report in the last ${String(CAPTURE_STATUS_RECENCY_DAYS)} days \u2014 open the site in Chrome with the extension loaded`
|
|
34451
|
+
},
|
|
34452
|
+
standby: {
|
|
34453
|
+
headline: "this build declares no endpoints for the site, so nothing is observed yet"
|
|
34454
|
+
},
|
|
34455
|
+
unpatched: {
|
|
34456
|
+
// Says what the flags say and no more. `patched` is false both for a tap
|
|
34457
|
+
// that installed and hooked neither transport and for one that never ran
|
|
34458
|
+
// at all — a page reports the same status either way, so the copy may not
|
|
34459
|
+
// assert one of them.
|
|
34460
|
+
headline: "the page tap captured neither fetch nor XHR \u2014 it may not have installed; reload the extension at chrome://extensions"
|
|
34461
|
+
},
|
|
34462
|
+
idle: { headline: "watching; no turn has been observed yet" },
|
|
34463
|
+
blind: {
|
|
34464
|
+
headline: "messages were sent in the page that the network capture never saw",
|
|
34465
|
+
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."
|
|
34466
|
+
},
|
|
34467
|
+
degraded: {
|
|
34468
|
+
headline: "the site's payloads no longer carry the fields the extension reads",
|
|
34469
|
+
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."
|
|
34470
|
+
}
|
|
34471
|
+
};
|
|
34472
|
+
|
|
34164
34473
|
// ../../packages/detections/src/security/redos-probe.ts
|
|
34165
34474
|
var BUDGET_MS = 100;
|
|
34166
34475
|
var EXPONENTIAL_UNITS = [
|