@akasecurity/ai-tc-codex 0.9.15 → 0.9.16
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/hooks/hooks.json +1 -1
- package/package.json +5 -5
- package/scripts/apply-suppressions.js +1472 -393
- package/scripts/backfill.js +1963 -424
- package/scripts/content-retention.js +825 -227
- package/scripts/filescan.js +1900 -361
- package/scripts/firstrun.js +1406 -301
- package/scripts/history-sync.js +841 -228
- package/scripts/intro.js +328 -170
- package/scripts/onboard.js +823 -219
- package/scripts/post-tool-use.js +1960 -343
- package/scripts/pre-tool-use.js +1864 -338
- package/scripts/query.js +1405 -300
- package/scripts/reconcile.js +1873 -329
- package/scripts/remediate.js +1838 -350
- package/scripts/scan-worker.js +281 -149
- package/scripts/session-start.js +1821 -331
- package/scripts/start-light.js +328 -170
- package/scripts/stop.js +346 -190
- package/scripts/sync.js +1898 -359
- package/scripts/user-prompt-submit.js +1906 -373
- package/skills/setup/SKILL.md +27 -12
package/scripts/history-sync.js
CHANGED
|
@@ -32,9 +32,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
32
32
|
mod
|
|
33
33
|
));
|
|
34
34
|
|
|
35
|
-
// ../../node_modules/.pnpm/ignore@7.0.
|
|
35
|
+
// ../../node_modules/.pnpm/ignore@7.0.11/node_modules/ignore/index.js
|
|
36
36
|
var require_ignore = __commonJS({
|
|
37
|
-
"../../node_modules/.pnpm/ignore@7.0.
|
|
37
|
+
"../../node_modules/.pnpm/ignore@7.0.11/node_modules/ignore/index.js"(exports, module) {
|
|
38
38
|
"use strict";
|
|
39
39
|
function makeArray(subject) {
|
|
40
40
|
return Array.isArray(subject) ? subject : [subject];
|
|
@@ -169,6 +169,7 @@ var require_ignore = __commonJS({
|
|
|
169
169
|
"g"
|
|
170
170
|
);
|
|
171
171
|
var TRAILING_WILDCARD = "\uE000";
|
|
172
|
+
var TRAILING_DOUBLESTAR = "\uE001";
|
|
172
173
|
var extractBrackets = (pattern) => {
|
|
173
174
|
const sources = [];
|
|
174
175
|
const hold = (source) => `${PLACEHOLDER}${sources.push(source) - 1}${PLACEHOLDER}`;
|
|
@@ -329,7 +330,7 @@ var require_ignore = __commonJS({
|
|
|
329
330
|
// Zero, one or several directories
|
|
330
331
|
// should not use '*', or it will be replaced by the next replacer
|
|
331
332
|
// Check if it is not the last `'/**'`
|
|
332
|
-
(_, index, str2) => index + 6 < str2.length ? str2.slice(index + 6) === "\\/" ? "(?:\\/[^\\/]+)+" : "(?:\\/[^\\/]+)*" :
|
|
333
|
+
(_, index, str2) => index + 6 < str2.length ? str2.slice(index + 6) === "\\/" ? "(?:\\/[^\\/]+)+" : "(?:\\/[^\\/]+)*" : `\\/${TRAILING_DOUBLESTAR}`,
|
|
333
334
|
"*"
|
|
334
335
|
],
|
|
335
336
|
// normal intermediate wildcards
|
|
@@ -407,7 +408,7 @@ var require_ignore = __commonJS({
|
|
|
407
408
|
// 'js' will match 'a.js' and 'a.js/'
|
|
408
409
|
(source) => {
|
|
409
410
|
const last = source[source.length - 1];
|
|
410
|
-
if (!last || last === TRAILING_WILDCARD) {
|
|
411
|
+
if (!last || last === TRAILING_WILDCARD || last === TRAILING_DOUBLESTAR) {
|
|
411
412
|
return source;
|
|
412
413
|
}
|
|
413
414
|
return last === SLASH3 ? `${source}$` : `${source}(?=$|\\/$)`;
|
|
@@ -418,16 +419,12 @@ var require_ignore = __commonJS({
|
|
|
418
419
|
var MODE_IGNORE = "regex";
|
|
419
420
|
var MODE_CHECK_IGNORE = "checkRegex";
|
|
420
421
|
var UNDERSCORE = "_";
|
|
421
|
-
var
|
|
422
|
-
[
|
|
423
|
-
|
|
424
|
-
return `${prefix}(?=$|\\/$)`;
|
|
425
|
-
},
|
|
426
|
-
[MODE_CHECK_IGNORE](_, p1) {
|
|
427
|
-
const prefix = p1 ? `${p1}[^/]*` : "[^/]*";
|
|
428
|
-
return `${prefix}(?=$|\\/$)`;
|
|
429
|
-
}
|
|
422
|
+
var replaceTrailingWildcard = (_, p1) => {
|
|
423
|
+
const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
|
|
424
|
+
return `${prefix}(?=$|\\/$)`;
|
|
430
425
|
};
|
|
426
|
+
var REGEX_REPLACE_TRAILING_DOUBLESTAR = /\uE001$/;
|
|
427
|
+
var replaceTrailingDoublestar = () => ".+(?=$|\\/$)";
|
|
431
428
|
var WILDCARD = "[^\\/]*";
|
|
432
429
|
var separatorAfter = (run, at) => {
|
|
433
430
|
let separator = EMPTY;
|
|
@@ -543,6 +540,14 @@ var require_ignore = __commonJS({
|
|
|
543
540
|
(match, index) => sources[index]
|
|
544
541
|
) : replaced;
|
|
545
542
|
};
|
|
543
|
+
var checkSourceOf = (body, prefix) => {
|
|
544
|
+
if (body[body.length - 1] === SLASH3) {
|
|
545
|
+
prefix = makeRegexPrefix(body.slice(0, -1));
|
|
546
|
+
}
|
|
547
|
+
const head = prefix.slice(0, -1);
|
|
548
|
+
const last = prefix[prefix.length - 1];
|
|
549
|
+
return last === TRAILING_WILDCARD ? `${head}$` : last === TRAILING_DOUBLESTAR ? `${head}.*$` : NEVER_MATCH;
|
|
550
|
+
};
|
|
546
551
|
var matchesBasename = (body) => {
|
|
547
552
|
const index = body.indexOf(SLASH3);
|
|
548
553
|
return index < 0 || index === body.length - 1;
|
|
@@ -603,11 +608,9 @@ var require_ignore = __commonJS({
|
|
|
603
608
|
return this._make(MODE_CHECK_IGNORE, key);
|
|
604
609
|
}
|
|
605
610
|
_make(mode, key) {
|
|
606
|
-
const str2 = pinWildcards(
|
|
607
|
-
REGEX_REPLACE_TRAILING_WILDCARD,
|
|
608
|
-
|
|
609
|
-
TRAILING_WILD_CARD_REPLACERS[mode]
|
|
610
|
-
));
|
|
611
|
+
const str2 = pinWildcards(
|
|
612
|
+
mode === MODE_IGNORE ? this.regexPrefix.replace(REGEX_REPLACE_TRAILING_WILDCARD, replaceTrailingWildcard).replace(REGEX_REPLACE_TRAILING_DOUBLESTAR, replaceTrailingDoublestar) : checkSourceOf(this.body, this.regexPrefix)
|
|
613
|
+
);
|
|
611
614
|
const regex = this.ignoreCase ? new RegExp(str2, "i") : new RegExp(str2);
|
|
612
615
|
return define(this, key, regex);
|
|
613
616
|
}
|
|
@@ -666,8 +669,39 @@ var require_ignore = __commonJS({
|
|
|
666
669
|
makeArray(
|
|
667
670
|
isString(pattern) ? splitPattern(pattern) : pattern
|
|
668
671
|
).forEach(this._add, this);
|
|
672
|
+
if (this._added) {
|
|
673
|
+
this._literalRules = UNDEFINED;
|
|
674
|
+
}
|
|
669
675
|
return this._added;
|
|
670
676
|
}
|
|
677
|
+
// Match the literal 'abc/' for `checkIgnore`, last rule wins. Only a rule
|
|
678
|
+
// ending in a wildcard can match it (see `checkSourceOf`), so the rest
|
|
679
|
+
// are left out once, rather than tested or compiled for every path.
|
|
680
|
+
testLiteral(path) {
|
|
681
|
+
const rules = this._literalRules || (this._literalRules = this._rules.filter(
|
|
682
|
+
({ body }) => body[body.length - (body[body.length - 1] === SLASH3 ? 2 : 1)] === "*"
|
|
683
|
+
));
|
|
684
|
+
let ignored = false;
|
|
685
|
+
let unignored = false;
|
|
686
|
+
let matchedRule;
|
|
687
|
+
for (let index = rules.length - 1; index >= 0; index--) {
|
|
688
|
+
const rule = rules[index];
|
|
689
|
+
if (rule.checkRegex.test(path)) {
|
|
690
|
+
ignored = !rule.negative;
|
|
691
|
+
unignored = rule.negative;
|
|
692
|
+
matchedRule = rule.negative ? UNDEFINED : rule;
|
|
693
|
+
break;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
const ret = {
|
|
697
|
+
ignored,
|
|
698
|
+
unignored
|
|
699
|
+
};
|
|
700
|
+
if (matchedRule) {
|
|
701
|
+
ret.rule = matchedRule;
|
|
702
|
+
}
|
|
703
|
+
return ret;
|
|
704
|
+
}
|
|
671
705
|
// Test one single path without recursively checking parent directories
|
|
672
706
|
//
|
|
673
707
|
// - checkUnignored `boolean` whether should check if the path is unignored,
|
|
@@ -788,14 +822,12 @@ var require_ignore = __commonJS({
|
|
|
788
822
|
if (path.charCodeAt(path.length - 1) !== SLASH_CODE) {
|
|
789
823
|
return this.test(path);
|
|
790
824
|
}
|
|
791
|
-
const
|
|
792
|
-
if (
|
|
793
|
-
|
|
794
|
-
if (parent.ignored) {
|
|
795
|
-
return parent;
|
|
796
|
-
}
|
|
825
|
+
const dir = this._t(path, this._testCache, true);
|
|
826
|
+
if (dir.ignored) {
|
|
827
|
+
return dir;
|
|
797
828
|
}
|
|
798
|
-
|
|
829
|
+
const literal2 = this._rules.testLiteral(path);
|
|
830
|
+
return literal2.ignored || literal2.unignored ? literal2 : dir;
|
|
799
831
|
}
|
|
800
832
|
_t(path, cache, checkUnignored) {
|
|
801
833
|
if (path in cache) {
|
|
@@ -1008,6 +1040,10 @@ var SQLITE_MIGRATIONS = [
|
|
|
1008
1040
|
{
|
|
1009
1041
|
tag: "0036_secret_vault_identity_fingerprint",
|
|
1010
1042
|
sql: "ALTER TABLE `secret_vault` ADD `value_identity_fingerprint` text DEFAULT '' NOT NULL;--> statement-breakpoint\nUPDATE `secret_vault` SET `value_identity_fingerprint` = `value_fingerprint`;\n"
|
|
1043
|
+
},
|
|
1044
|
+
{
|
|
1045
|
+
tag: "0037_finding_location",
|
|
1046
|
+
sql: "ALTER TABLE `inspection_findings` ADD `line` integer;--> statement-breakpoint\nALTER TABLE `inspection_findings` ADD `col` integer;--> statement-breakpoint\nALTER TABLE `inspection_findings` ADD `context` text;--> statement-breakpoint\nCREATE INDEX `idx_inspection_findings_context` ON `inspection_findings` (`first_detected_at`) WHERE context IS NOT NULL;"
|
|
1011
1047
|
}
|
|
1012
1048
|
];
|
|
1013
1049
|
|
|
@@ -21901,11 +21937,33 @@ var ResolutionMethod = external_exports.enum([
|
|
|
21901
21937
|
"false-positive",
|
|
21902
21938
|
"redetected"
|
|
21903
21939
|
]).meta({ id: "ResolutionMethod" });
|
|
21940
|
+
var FindingContextBasis = external_exports.enum(["file", "excerpt"]).meta({ id: "FindingContextBasis" });
|
|
21941
|
+
var FindingContext = external_exports.object({
|
|
21942
|
+
basis: FindingContextBasis,
|
|
21943
|
+
// 1-based line number of `lines[0]`.
|
|
21944
|
+
firstLine: external_exports.number().int().positive(),
|
|
21945
|
+
lines: external_exports.array(external_exports.string()).min(1).max(5),
|
|
21946
|
+
match: external_exports.object({
|
|
21947
|
+
// 1-based line number, within [firstLine, firstLine + lines.length).
|
|
21948
|
+
line: external_exports.number().int().positive(),
|
|
21949
|
+
// Offsets into that entry of `lines`, end exclusive.
|
|
21950
|
+
start: external_exports.number().int().nonnegative(),
|
|
21951
|
+
end: external_exports.number().int().nonnegative()
|
|
21952
|
+
}).nullable()
|
|
21953
|
+
}).meta({ id: "FindingContext" });
|
|
21954
|
+
var FindingLocation = external_exports.object({
|
|
21955
|
+
line: external_exports.number().int().positive(),
|
|
21956
|
+
col: external_exports.number().int().positive(),
|
|
21957
|
+
context: FindingContext.nullable()
|
|
21958
|
+
});
|
|
21904
21959
|
var FindingMatch = external_exports.object({
|
|
21905
21960
|
// Masked preview of the matched value. Never raw content.
|
|
21906
21961
|
maskedValue: external_exports.string(),
|
|
21907
|
-
//
|
|
21908
|
-
contextPrefix: external_exports.string()
|
|
21962
|
+
// Deprecated: always empty. Superseded by `context`.
|
|
21963
|
+
contextPrefix: external_exports.string(),
|
|
21964
|
+
// The masked lines around the match. Absent when the finding predates
|
|
21965
|
+
// context capture or none could be built safely.
|
|
21966
|
+
context: FindingContext.optional()
|
|
21909
21967
|
}).meta({ id: "FindingMatch" });
|
|
21910
21968
|
var FindingDetectionRef = external_exports.object({
|
|
21911
21969
|
id: external_exports.string(),
|
|
@@ -21925,6 +21983,11 @@ var FindingInstance = external_exports.object({
|
|
|
21925
21983
|
provider: FindingProvider,
|
|
21926
21984
|
repo: external_exports.string(),
|
|
21927
21985
|
file: external_exports.string(),
|
|
21986
|
+
// 1-based line and column of the match start in the scanned text (the
|
|
21987
|
+
// column in UTF-16 code units). Absent for findings that predate location
|
|
21988
|
+
// capture or have no source text.
|
|
21989
|
+
line: external_exports.number().int().positive().optional(),
|
|
21990
|
+
col: external_exports.number().int().positive().optional(),
|
|
21928
21991
|
// Who the capturing event is attributed to. Optional: a single-user store
|
|
21929
21992
|
// has no one to attribute a finding to and never sets it.
|
|
21930
21993
|
user: FindingUser.optional(),
|
|
@@ -21986,6 +22049,13 @@ var FindingStats = external_exports.object({
|
|
|
21986
22049
|
low: external_exports.number().int().nonnegative()
|
|
21987
22050
|
})
|
|
21988
22051
|
}).meta({ id: "FindingStats" });
|
|
22052
|
+
var FindingsOverview = external_exports.object({
|
|
22053
|
+
findings: external_exports.number().int().nonnegative(),
|
|
22054
|
+
open: external_exports.number().int().nonnegative(),
|
|
22055
|
+
handled: external_exports.number().int().nonnegative(),
|
|
22056
|
+
resolved: external_exports.number().int().nonnegative(),
|
|
22057
|
+
dismissed: external_exports.number().int().nonnegative()
|
|
22058
|
+
}).meta({ id: "FindingsOverview" });
|
|
21989
22059
|
var FindingFacetItem = external_exports.object({
|
|
21990
22060
|
value: external_exports.string(),
|
|
21991
22061
|
count: external_exports.number().int().nonnegative()
|
|
@@ -22105,6 +22175,7 @@ var FindingInstanceDetail = FindingInstance.extend({
|
|
|
22105
22175
|
}).meta({ id: "FindingInstanceDetail" });
|
|
22106
22176
|
var DEFAULT_FLAT_FINDINGS_LIMIT = 50;
|
|
22107
22177
|
var MAX_FLAT_FINDINGS_LIMIT = 200;
|
|
22178
|
+
var FindingContextQuery = external_exports.object({ id: external_exports.string().min(1).max(256) });
|
|
22108
22179
|
var ListFindingInstancesQuery = external_exports.object({
|
|
22109
22180
|
severity: external_exports.array(Severity).optional(),
|
|
22110
22181
|
// Rule ids, the same vocabulary the types list's `subtype` carries. Pinning
|
|
@@ -22437,7 +22508,23 @@ var CaptureAttributes = external_exports.object({
|
|
|
22437
22508
|
// capture denied by another finding's own Block policy carries `block`
|
|
22438
22509
|
// here too. The full statement is on EventMetadata.redactDegradedTo; it is
|
|
22439
22510
|
// repeated rather than referenced because a store reader opens this file.
|
|
22440
|
-
redact_degraded_to: ActionTaken.optional()
|
|
22511
|
+
redact_degraded_to: ActionTaken.optional(),
|
|
22512
|
+
// The scope key this capture was stamped with: the canonical repository
|
|
22513
|
+
// (`host/owner/repo`) of the path the capture names (a relative path is read
|
|
22514
|
+
// against its working directory), else of its own working directory, or a
|
|
22515
|
+
// chat account's identity. The store's local `scope_key` column reads it, so
|
|
22516
|
+
// a scoped attachment has a per-row key to work from. Absent when no key
|
|
22517
|
+
// could be derived.
|
|
22518
|
+
//
|
|
22519
|
+
// LOCAL ONLY. That is the contract for every path that sends a row. Producers
|
|
22520
|
+
// stamp it in every attachment mode, and the two structural choke points strip
|
|
22521
|
+
// it: the attached gateway's `reKeyForForward` on the live path, and the
|
|
22522
|
+
// history drain's `rebuildAuditEvent`, which drops it through `withoutScopeKey`.
|
|
22523
|
+
// A capture row's bag reaches the wire through `rebuildCapture`, which builds
|
|
22524
|
+
// the metadata from named keys and never names this one; `toCaptureAttributes`,
|
|
22525
|
+
// which builds the bag from a wire event, never emits it. What a scoped
|
|
22526
|
+
// attachment does with the key is not part of this shape's contract.
|
|
22527
|
+
scope_key: external_exports.string().optional()
|
|
22441
22528
|
}).catchall(external_exports.unknown());
|
|
22442
22529
|
var CaptureStatusAttributes = external_exports.object({
|
|
22443
22530
|
source_tool: external_exports.string().optional(),
|
|
@@ -22467,6 +22554,12 @@ var ToolCallInspection = external_exports.object({
|
|
|
22467
22554
|
actionTaken: ActionTaken,
|
|
22468
22555
|
confidence: external_exports.number().min(0).max(1)
|
|
22469
22556
|
});
|
|
22557
|
+
var findingLocationFields = {
|
|
22558
|
+
line: external_exports.number().int().positive().optional(),
|
|
22559
|
+
col: external_exports.number().int().positive().optional(),
|
|
22560
|
+
context: FindingContext.nullable().optional()
|
|
22561
|
+
};
|
|
22562
|
+
var ToolCallInspectionInput = ToolCallInspection.extend(findingLocationFields);
|
|
22470
22563
|
var ToolCallInput = external_exports.object({
|
|
22471
22564
|
sessionId: external_exports.string().min(1),
|
|
22472
22565
|
toolUseId: external_exports.string().min(1),
|
|
@@ -22476,7 +22569,7 @@ var ToolCallInput = external_exports.object({
|
|
|
22476
22569
|
attributes: ToolCallAttributes,
|
|
22477
22570
|
// Secrets detected in the tool's (masked) target — written as linked
|
|
22478
22571
|
// `inspection_findings`. Empty for a clean tool call.
|
|
22479
|
-
inspections: external_exports.array(
|
|
22572
|
+
inspections: external_exports.array(ToolCallInspectionInput).default([])
|
|
22480
22573
|
});
|
|
22481
22574
|
var InventoryInput = external_exports.object({
|
|
22482
22575
|
objectType: InventoryObjectType,
|
|
@@ -22550,7 +22643,8 @@ var InspectionFindingInput = external_exports.object({
|
|
|
22550
22643
|
// same findingKey — mirrors the legacy `findings.first_detected_at`.
|
|
22551
22644
|
// Optional: when omitted, the writer derives it from the referenced audit
|
|
22552
22645
|
// event's startedAt on first insert (see SqliteInspectionFindingsRepository).
|
|
22553
|
-
firstDetectedAt: external_exports.iso.datetime().optional()
|
|
22646
|
+
firstDetectedAt: external_exports.iso.datetime().optional(),
|
|
22647
|
+
...findingLocationFields
|
|
22554
22648
|
});
|
|
22555
22649
|
var InventoryContext = external_exports.object({
|
|
22556
22650
|
host: InventoryInput.optional(),
|
|
@@ -23329,6 +23423,17 @@ var AttachedCredential = external_exports.object({
|
|
|
23329
23423
|
keyPrefix: external_exports.string().min(1).max(16).optional(),
|
|
23330
23424
|
mintedAt: external_exports.iso.datetime().optional()
|
|
23331
23425
|
});
|
|
23426
|
+
var AttachmentMode = external_exports.enum(["machine", "scoped"]);
|
|
23427
|
+
var ATTACHED_CREDENTIAL_SCOPED_SPEC_VERSION = 2;
|
|
23428
|
+
var AttachedCredentialV1 = AttachedCredential;
|
|
23429
|
+
var AttachedCredentialV2 = AttachedCredential.extend({
|
|
23430
|
+
specVersion: external_exports.literal(ATTACHED_CREDENTIAL_SCOPED_SPEC_VERSION),
|
|
23431
|
+
mode: external_exports.literal("scoped")
|
|
23432
|
+
});
|
|
23433
|
+
var AttachedCredentialAny = external_exports.discriminatedUnion("specVersion", [
|
|
23434
|
+
AttachedCredentialV1,
|
|
23435
|
+
AttachedCredentialV2
|
|
23436
|
+
]);
|
|
23332
23437
|
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
23333
23438
|
function unsafeEndpointReason(endpoint) {
|
|
23334
23439
|
let parsed2;
|
|
@@ -23634,6 +23739,130 @@ var PackId = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
|
23634
23739
|
var SemVer = external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?$/);
|
|
23635
23740
|
var PublisherKind = external_exports.enum(["labs", "user", "org"]);
|
|
23636
23741
|
|
|
23742
|
+
// ../../packages/schema/src/zod/builtin-policy-id.ts
|
|
23743
|
+
var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
|
|
23744
|
+
var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
|
|
23745
|
+
|
|
23746
|
+
// ../../packages/schema/src/zod/event.ts
|
|
23747
|
+
var EventKind = external_exports.enum(["prompt", "response", "code_change", "tool_use"]).meta({ id: "EventKind" });
|
|
23748
|
+
var CAPTURE_EVENT_TYPES_SQL = EventKind.options.map((k) => `'${k}'`).join(",");
|
|
23749
|
+
var EventMetadata = external_exports.object({
|
|
23750
|
+
sessionId: external_exports.string().optional(),
|
|
23751
|
+
repo: external_exports.string().optional(),
|
|
23752
|
+
filePath: external_exports.string().optional(),
|
|
23753
|
+
// The host tool whose input/output was scanned (e.g. 'Bash', 'WebFetch'),
|
|
23754
|
+
// set by the tool-scanning hooks. The tool NAME only — never the tool's
|
|
23755
|
+
// arguments or output, which can carry the very value a finding masked
|
|
23756
|
+
// (metadata is stored unredacted). Gives findings on non-file captures a
|
|
23757
|
+
// display location ("via Bash") when no filePath exists.
|
|
23758
|
+
toolName: external_exports.string().optional(),
|
|
23759
|
+
// Set (true) by the worktree scanner when the file is excluded by the
|
|
23760
|
+
// repo's .gitignore. Gitignored files ARE still scanned — local scratch and
|
|
23761
|
+
// generated code can leak real secrets — but the provenance is recorded so
|
|
23762
|
+
// policy/dashboards can treat those findings as informational rather than
|
|
23763
|
+
// blocking. Omitted (not false) for tracked files and non-scan events.
|
|
23764
|
+
gitignored: external_exports.boolean().optional(),
|
|
23765
|
+
// Set (true) ONLY when the event's `content` is the COMPLETE file at
|
|
23766
|
+
// capture time (a worktree scan reading from disk). Hook-captured edits
|
|
23767
|
+
// (e.g. an Edit tool's new_string) are partial fragments and MUST NOT set
|
|
23768
|
+
// this. The resolver-on-ingest keys its fixed-at-source dropout
|
|
23769
|
+
// diff on this marker: only a whole-file snapshot can prove a previously
|
|
23770
|
+
// open finding is gone; a fragment's absence proves nothing (the secret
|
|
23771
|
+
// may live outside the hunk). Omitted (not false) for fragments and
|
|
23772
|
+
// non-scan events, so pre-marker clients safely default to the
|
|
23773
|
+
// non-authoritative path.
|
|
23774
|
+
wholeFile: external_exports.boolean().optional(),
|
|
23775
|
+
model: external_exports.string().optional(),
|
|
23776
|
+
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
23777
|
+
// Distributed-tracing correlation. `correlationId` ties a recorded event back
|
|
23778
|
+
// to the request that captured/ingested it (a UUID, generated independently of
|
|
23779
|
+
// the trace id); `traceId` is the W3C trace id (32 lowercase hex chars) of the
|
|
23780
|
+
// originating span when telemetry is enabled. Both optional + backward
|
|
23781
|
+
// compatible — populated by the plugin (see @akasecurity/plugin-sdk).
|
|
23782
|
+
correlationId: external_exports.uuid().optional(),
|
|
23783
|
+
traceId: external_exports.string().regex(/^[0-9a-f]{32}$/).optional(),
|
|
23784
|
+
// Ids of the detection exceptions that downgraded findings in this capture
|
|
23785
|
+
// to 'allow' — the enforcement audit trail's link back to the grant that
|
|
23786
|
+
// authorized the bypass. Absent on captures where no exception applied.
|
|
23787
|
+
exceptionIds: external_exports.array(external_exports.guid()).optional(),
|
|
23788
|
+
// The assistant message this capture belongs to, and the conversation it sits
|
|
23789
|
+
// in — set by the browser extension's network capture so a stored `response`
|
|
23790
|
+
// row can be joined to the `llm_call` leaf describing the same turn. Absent
|
|
23791
|
+
// on every other capture path, which has no such id.
|
|
23792
|
+
//
|
|
23793
|
+
// Non-empty for the reason WebExchange.messageId is: it is the join key, and
|
|
23794
|
+
// a blank one matches no `llm_call` leaf. That refusal reaches only the
|
|
23795
|
+
// places an event is PARSED; the local write path types the event and parses
|
|
23796
|
+
// nothing, which is why `toCaptureAttributes` omits a blank one separately.
|
|
23797
|
+
messageId: external_exports.string().min(1).optional(),
|
|
23798
|
+
conversationId: external_exports.string().optional(),
|
|
23799
|
+
// How long THIS capture's inspection blocked its caller, in whole
|
|
23800
|
+
// milliseconds — the plugin's own added latency, NOT the LLM call it sat in
|
|
23801
|
+
// front of. Measured inside `capture()` (@akasecurity/plugin-sdk) across
|
|
23802
|
+
// detection + redaction, the work the host session actually waits on.
|
|
23803
|
+
//
|
|
23804
|
+
// Stamped ONLY on live in-flight captures. A capture that carries its own
|
|
23805
|
+
// `occurredAt` is replaying past work (the transcript backfill, the worktree
|
|
23806
|
+
// scan), and its scan duration is not latency any host session experienced,
|
|
23807
|
+
// so those rows leave this ABSENT rather than reporting a misleading number.
|
|
23808
|
+
// Absent is also what every pre-measurement client writes, and what a
|
|
23809
|
+
// clock failure degrades to — a reader must treat absence as "not measured"
|
|
23810
|
+
// and never as a zero, which would read as "inspection is free".
|
|
23811
|
+
inspectionMs: external_exports.number().int().nonnegative().optional(),
|
|
23812
|
+
// What a `redact` this capture COULD NOT CARRY OUT became instead — the
|
|
23813
|
+
// workspace's `redactFallback`, applied because the field could not be
|
|
23814
|
+
// masked in place (a shell command, a URL, or any argument on a host whose
|
|
23815
|
+
// hook contract offers no rewrite channel).
|
|
23816
|
+
//
|
|
23817
|
+
// It exists because the action alone cannot say why. A finding recorded as
|
|
23818
|
+
// `warn` reads identically whether its detection was ASSIGNED Warn or was
|
|
23819
|
+
// assigned Redact on a field that could not take one — and those are
|
|
23820
|
+
// different facts about the same row: the first is a policy the user chose,
|
|
23821
|
+
// the second is a masking the host could not perform. Absent means no
|
|
23822
|
+
// degrade happened, which is every ordinary capture.
|
|
23823
|
+
//
|
|
23824
|
+
// TWO LIMITS a reader of a stored row has to know, because the grain here
|
|
23825
|
+
// is the CAPTURE while `actionTaken` is per FINDING:
|
|
23826
|
+
//
|
|
23827
|
+
// - It does not say WHICH finding degraded. A capture carrying a degraded
|
|
23828
|
+
// `redact` alongside a finding ASSIGNED the same action stores both
|
|
23829
|
+
// identically and one reason for the pair; attributing it to both
|
|
23830
|
+
// describes the assigned one wrongly, and to neither loses the degrade.
|
|
23831
|
+
// - PRESENCE IS NOT CAUSATION. The value is the action the lost redact
|
|
23832
|
+
// became, not the reason the capture ended as it did — a capture denied
|
|
23833
|
+
// by some other finding's own Block policy still carries `block` here,
|
|
23834
|
+
// and clearing the workspace's fallback would not have let it through.
|
|
23835
|
+
// Gate on the value against what a fallback can produce; never read the
|
|
23836
|
+
// field's presence as "this was the fallback's doing".
|
|
23837
|
+
//
|
|
23838
|
+
// Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
|
|
23839
|
+
// Closing either means moving the reason onto the finding row, which
|
|
23840
|
+
// already carries its own action.
|
|
23841
|
+
redactDegradedTo: ActionTaken.optional()
|
|
23842
|
+
}).meta({ id: "EventMetadata" });
|
|
23843
|
+
var Event = external_exports.object({
|
|
23844
|
+
id: external_exports.guid(),
|
|
23845
|
+
sourceTool: SourceTool,
|
|
23846
|
+
kind: EventKind,
|
|
23847
|
+
occurredAt: external_exports.iso.datetime(),
|
|
23848
|
+
contentHash: external_exports.string(),
|
|
23849
|
+
content: external_exports.string(),
|
|
23850
|
+
metadata: EventMetadata.optional()
|
|
23851
|
+
}).meta({ id: "Event" });
|
|
23852
|
+
var IngestEvent = Event.meta({ id: "IngestEvent" });
|
|
23853
|
+
var INGEST_BATCH_MAX = 100;
|
|
23854
|
+
var IngestBatch = external_exports.object({
|
|
23855
|
+
events: external_exports.array(IngestEvent).min(1).max(INGEST_BATCH_MAX),
|
|
23856
|
+
// Dedup policy for this batch. Id-dedup ALWAYS applies. 'content-hash'
|
|
23857
|
+
// additionally rejects any event whose contentHash the store has already
|
|
23858
|
+
// recorded — for re-runnable bulk ingest (worktree scan, transcript
|
|
23859
|
+
// backfill), where a re-run mints fresh event ids for identical content and
|
|
23860
|
+
// would otherwise accumulate duplicates. Live hook traffic must NOT set it:
|
|
23861
|
+
// two genuinely separate prompts can be byte-identical and both belong on
|
|
23862
|
+
// the timeline.
|
|
23863
|
+
dedupe: external_exports.literal("content-hash").optional()
|
|
23864
|
+
}).meta({ id: "IngestBatch" });
|
|
23865
|
+
|
|
23637
23866
|
// ../../packages/schema/src/zod/rule.ts
|
|
23638
23867
|
var MatcherType = external_exports.enum(["keyword", "regex"]).meta({ id: "MatcherType" });
|
|
23639
23868
|
var RuleProbeVerdict = external_exports.enum(["safe", "quarantined"]).meta({ id: "RuleProbeVerdict" });
|
|
@@ -23702,7 +23931,10 @@ var Matcher = external_exports.discriminatedUnion("type", [KeywordMatcher, Regex
|
|
|
23702
23931
|
var MATCHER_TYPES = MatcherType.options;
|
|
23703
23932
|
var AppliesTo = external_exports.strictObject({
|
|
23704
23933
|
// Dot-prefixed, e.g. ".py" — matches the scanner's SOURCE_EXTENSIONS shape.
|
|
23705
|
-
extensions: external_exports.array(external_exports.string().regex(/^\.[A-Za-z0-9]+$/)).min(1)
|
|
23934
|
+
extensions: external_exports.array(external_exports.string().regex(/^\.[A-Za-z0-9]+$/)).min(1).optional(),
|
|
23935
|
+
eventKinds: external_exports.array(EventKind).min(1).optional()
|
|
23936
|
+
}).refine((v) => v.extensions !== void 0 || v.eventKinds !== void 0, {
|
|
23937
|
+
message: "appliesTo needs extensions, eventKinds, or both"
|
|
23706
23938
|
}).meta({ id: "AppliesTo" });
|
|
23707
23939
|
var PostValidatorName = external_exports.enum(["entropy", "luhn"]).meta({ id: "PostValidatorName" });
|
|
23708
23940
|
var PostValidatorRef = external_exports.union(
|
|
@@ -23725,6 +23957,7 @@ var PostValidatorRef = external_exports.union(
|
|
|
23725
23957
|
)}) or { "name": ..., "config": { ... } }. An unrecognized name would be a false-positive guard that never runs.`
|
|
23726
23958
|
}
|
|
23727
23959
|
).meta({ id: "PostValidatorRef" });
|
|
23960
|
+
var RuleEvidence = external_exports.enum(["code", "value"]).meta({ id: "RuleEvidence" });
|
|
23728
23961
|
var RequiresNearby = external_exports.strictObject({
|
|
23729
23962
|
// Each array, when present, must be non-empty and contain non-empty strings —
|
|
23730
23963
|
// an empty/blank criterion would either never fire or (for labels) match
|
|
@@ -23747,6 +23980,8 @@ var RuleFixture = external_exports.strictObject({
|
|
|
23747
23980
|
// Simulated file context for the scan, so fixtures can assert `appliesTo`
|
|
23748
23981
|
// gating (e.g. a Python-only pattern must NOT fire in a .ts file).
|
|
23749
23982
|
filePath: external_exports.string().optional(),
|
|
23983
|
+
// Simulated capture kind, so fixtures can assert `appliesTo.eventKinds`.
|
|
23984
|
+
eventKind: EventKind.optional(),
|
|
23750
23985
|
expectedSpans: external_exports.array(external_exports.strictObject({ start: external_exports.number(), end: external_exports.number() })).optional()
|
|
23751
23986
|
}).meta({ id: "RuleFixture" });
|
|
23752
23987
|
var Rule = external_exports.strictObject({
|
|
@@ -23772,7 +24007,9 @@ var Rule = external_exports.strictObject({
|
|
|
23772
24007
|
appliesTo: AppliesTo.optional(),
|
|
23773
24008
|
postValidators: external_exports.array(PostValidatorRef).optional(),
|
|
23774
24009
|
requiresNearby: RequiresNearby.optional(),
|
|
23775
|
-
examples: external_exports.array(external_exports.string()).optional()
|
|
24010
|
+
examples: external_exports.array(external_exports.string()).optional(),
|
|
24011
|
+
// Whether the matched text is itself sensitive. Absent means 'value'.
|
|
24012
|
+
evidence: RuleEvidence.optional()
|
|
23776
24013
|
}).meta({ id: "Rule" });
|
|
23777
24014
|
var Author = external_exports.object({
|
|
23778
24015
|
name: external_exports.string(),
|
|
@@ -23789,7 +24026,11 @@ var PackManifest = external_exports.object({
|
|
|
23789
24026
|
description: external_exports.string().optional(),
|
|
23790
24027
|
author: Author.optional(),
|
|
23791
24028
|
license: external_exports.string().optional(),
|
|
23792
|
-
sourceUrl: external_exports.url().optional()
|
|
24029
|
+
sourceUrl: external_exports.url().optional(),
|
|
24030
|
+
// The built-in policy a FIRST install of this pack assigns
|
|
24031
|
+
// (installed_packs.policy_id). Absent leaves the pack unassigned, so its
|
|
24032
|
+
// rules follow the category policies. An existing install never takes it.
|
|
24033
|
+
defaultPolicy: BuiltinPolicyId.optional()
|
|
23793
24034
|
}).meta({ id: "PackManifest" });
|
|
23794
24035
|
|
|
23795
24036
|
// ../../packages/schema/src/zod/detection.ts
|
|
@@ -23817,10 +24058,12 @@ var DetectionListItem = external_exports.object({
|
|
|
23817
24058
|
// Per-pack enforcement-policy assignment. Holds a BuiltinPolicyId ARCHETYPE
|
|
23818
24059
|
// (monitor|warn|redact|block) — NOT a policies-table Policy.id guid; a
|
|
23819
24060
|
// detection is a PACK, and its policy is the archetype applied to all its
|
|
23820
|
-
// rules. Absent == unassigned, which resolves to Monitor
|
|
23821
|
-
// (DEFAULT_PACK_POLICY_ID)
|
|
23822
|
-
//
|
|
23823
|
-
//
|
|
24061
|
+
// rules. Absent == unassigned, which resolves to Monitor by default
|
|
24062
|
+
// (DEFAULT_PACK_POLICY_ID); a host may resolve it to a policy of its own
|
|
24063
|
+
// (see the dashboard's `unassignedPolicy`). Every enforcement surface
|
|
24064
|
+
// expands it into per-rule policies (see policyIdToAction). Typed
|
|
24065
|
+
// z.string() (not the enum) to keep the OpenAPI response tolerant of a
|
|
24066
|
+
// future custom id.
|
|
23824
24067
|
policyId: external_exports.string().optional(),
|
|
23825
24068
|
// Set ONLY when a newer snapshot is available for this pack (OSS: the
|
|
23826
24069
|
// bundled inventory recorded in available_packs differs from the installed
|
|
@@ -23889,10 +24132,12 @@ var DetectionDetail = external_exports.object({
|
|
|
23889
24132
|
// Per-pack enforcement-policy assignment. Holds a BuiltinPolicyId ARCHETYPE
|
|
23890
24133
|
// (monitor|warn|redact|block) — NOT a policies-table Policy.id guid; a
|
|
23891
24134
|
// detection is a PACK, and its policy is the archetype applied to all its
|
|
23892
|
-
// rules. Absent == unassigned, which resolves to Monitor
|
|
23893
|
-
// (DEFAULT_PACK_POLICY_ID)
|
|
23894
|
-
//
|
|
23895
|
-
//
|
|
24135
|
+
// rules. Absent == unassigned, which resolves to Monitor by default
|
|
24136
|
+
// (DEFAULT_PACK_POLICY_ID); a host may resolve it to a policy of its own
|
|
24137
|
+
// (see the dashboard's `unassignedPolicy`). Every enforcement surface
|
|
24138
|
+
// expands it into per-rule policies (see policyIdToAction). Typed
|
|
24139
|
+
// z.string() (not the enum) to keep the OpenAPI response tolerant of a
|
|
24140
|
+
// future custom id.
|
|
23896
24141
|
policyId: external_exports.string().optional()
|
|
23897
24142
|
}).meta({ id: "DetectionDetail" });
|
|
23898
24143
|
var LibraryItem = external_exports.object({
|
|
@@ -24039,126 +24284,6 @@ function buildDetectionsList(summaries, query) {
|
|
|
24039
24284
|
return { counts, items: filtered.map(summaryToDetectionListItem) };
|
|
24040
24285
|
}
|
|
24041
24286
|
|
|
24042
|
-
// ../../packages/schema/src/zod/event.ts
|
|
24043
|
-
var EventKind = external_exports.enum(["prompt", "response", "code_change", "tool_use"]).meta({ id: "EventKind" });
|
|
24044
|
-
var CAPTURE_EVENT_TYPES_SQL = EventKind.options.map((k) => `'${k}'`).join(",");
|
|
24045
|
-
var EventMetadata = external_exports.object({
|
|
24046
|
-
sessionId: external_exports.string().optional(),
|
|
24047
|
-
repo: external_exports.string().optional(),
|
|
24048
|
-
filePath: external_exports.string().optional(),
|
|
24049
|
-
// The host tool whose input/output was scanned (e.g. 'Bash', 'WebFetch'),
|
|
24050
|
-
// set by the tool-scanning hooks. The tool NAME only — never the tool's
|
|
24051
|
-
// arguments or output, which can carry the very value a finding masked
|
|
24052
|
-
// (metadata is stored unredacted). Gives findings on non-file captures a
|
|
24053
|
-
// display location ("via Bash") when no filePath exists.
|
|
24054
|
-
toolName: external_exports.string().optional(),
|
|
24055
|
-
// Set (true) by the worktree scanner when the file is excluded by the
|
|
24056
|
-
// repo's .gitignore. Gitignored files ARE still scanned — local scratch and
|
|
24057
|
-
// generated code can leak real secrets — but the provenance is recorded so
|
|
24058
|
-
// policy/dashboards can treat those findings as informational rather than
|
|
24059
|
-
// blocking. Omitted (not false) for tracked files and non-scan events.
|
|
24060
|
-
gitignored: external_exports.boolean().optional(),
|
|
24061
|
-
// Set (true) ONLY when the event's `content` is the COMPLETE file at
|
|
24062
|
-
// capture time (a worktree scan reading from disk). Hook-captured edits
|
|
24063
|
-
// (e.g. an Edit tool's new_string) are partial fragments and MUST NOT set
|
|
24064
|
-
// this. The resolver-on-ingest keys its fixed-at-source dropout
|
|
24065
|
-
// diff on this marker: only a whole-file snapshot can prove a previously
|
|
24066
|
-
// open finding is gone; a fragment's absence proves nothing (the secret
|
|
24067
|
-
// may live outside the hunk). Omitted (not false) for fragments and
|
|
24068
|
-
// non-scan events, so pre-marker clients safely default to the
|
|
24069
|
-
// non-authoritative path.
|
|
24070
|
-
wholeFile: external_exports.boolean().optional(),
|
|
24071
|
-
model: external_exports.string().optional(),
|
|
24072
|
-
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
24073
|
-
// Distributed-tracing correlation. `correlationId` ties a recorded event back
|
|
24074
|
-
// to the request that captured/ingested it (a UUID, generated independently of
|
|
24075
|
-
// the trace id); `traceId` is the W3C trace id (32 lowercase hex chars) of the
|
|
24076
|
-
// originating span when telemetry is enabled. Both optional + backward
|
|
24077
|
-
// compatible — populated by the plugin (see @akasecurity/plugin-sdk).
|
|
24078
|
-
correlationId: external_exports.uuid().optional(),
|
|
24079
|
-
traceId: external_exports.string().regex(/^[0-9a-f]{32}$/).optional(),
|
|
24080
|
-
// Ids of the detection exceptions that downgraded findings in this capture
|
|
24081
|
-
// to 'allow' — the enforcement audit trail's link back to the grant that
|
|
24082
|
-
// authorized the bypass. Absent on captures where no exception applied.
|
|
24083
|
-
exceptionIds: external_exports.array(external_exports.guid()).optional(),
|
|
24084
|
-
// The assistant message this capture belongs to, and the conversation it sits
|
|
24085
|
-
// in — set by the browser extension's network capture so a stored `response`
|
|
24086
|
-
// row can be joined to the `llm_call` leaf describing the same turn. Absent
|
|
24087
|
-
// on every other capture path, which has no such id.
|
|
24088
|
-
//
|
|
24089
|
-
// Non-empty for the reason WebExchange.messageId is: it is the join key, and
|
|
24090
|
-
// a blank one matches no `llm_call` leaf. That refusal reaches only the
|
|
24091
|
-
// places an event is PARSED; the local write path types the event and parses
|
|
24092
|
-
// nothing, which is why `toCaptureAttributes` omits a blank one separately.
|
|
24093
|
-
messageId: external_exports.string().min(1).optional(),
|
|
24094
|
-
conversationId: external_exports.string().optional(),
|
|
24095
|
-
// How long THIS capture's inspection blocked its caller, in whole
|
|
24096
|
-
// milliseconds — the plugin's own added latency, NOT the LLM call it sat in
|
|
24097
|
-
// front of. Measured inside `capture()` (@akasecurity/plugin-sdk) across
|
|
24098
|
-
// detection + redaction, the work the host session actually waits on.
|
|
24099
|
-
//
|
|
24100
|
-
// Stamped ONLY on live in-flight captures. A capture that carries its own
|
|
24101
|
-
// `occurredAt` is replaying past work (the transcript backfill, the worktree
|
|
24102
|
-
// scan), and its scan duration is not latency any host session experienced,
|
|
24103
|
-
// so those rows leave this ABSENT rather than reporting a misleading number.
|
|
24104
|
-
// Absent is also what every pre-measurement client writes, and what a
|
|
24105
|
-
// clock failure degrades to — a reader must treat absence as "not measured"
|
|
24106
|
-
// and never as a zero, which would read as "inspection is free".
|
|
24107
|
-
inspectionMs: external_exports.number().int().nonnegative().optional(),
|
|
24108
|
-
// What a `redact` this capture COULD NOT CARRY OUT became instead — the
|
|
24109
|
-
// workspace's `redactFallback`, applied because the field could not be
|
|
24110
|
-
// masked in place (a shell command, a URL, or any argument on a host whose
|
|
24111
|
-
// hook contract offers no rewrite channel).
|
|
24112
|
-
//
|
|
24113
|
-
// It exists because the action alone cannot say why. A finding recorded as
|
|
24114
|
-
// `warn` reads identically whether its detection was ASSIGNED Warn or was
|
|
24115
|
-
// assigned Redact on a field that could not take one — and those are
|
|
24116
|
-
// different facts about the same row: the first is a policy the user chose,
|
|
24117
|
-
// the second is a masking the host could not perform. Absent means no
|
|
24118
|
-
// degrade happened, which is every ordinary capture.
|
|
24119
|
-
//
|
|
24120
|
-
// TWO LIMITS a reader of a stored row has to know, because the grain here
|
|
24121
|
-
// is the CAPTURE while `actionTaken` is per FINDING:
|
|
24122
|
-
//
|
|
24123
|
-
// - It does not say WHICH finding degraded. A capture carrying a degraded
|
|
24124
|
-
// `redact` alongside a finding ASSIGNED the same action stores both
|
|
24125
|
-
// identically and one reason for the pair; attributing it to both
|
|
24126
|
-
// describes the assigned one wrongly, and to neither loses the degrade.
|
|
24127
|
-
// - PRESENCE IS NOT CAUSATION. The value is the action the lost redact
|
|
24128
|
-
// became, not the reason the capture ended as it did — a capture denied
|
|
24129
|
-
// by some other finding's own Block policy still carries `block` here,
|
|
24130
|
-
// and clearing the workspace's fallback would not have let it through.
|
|
24131
|
-
// Gate on the value against what a fallback can produce; never read the
|
|
24132
|
-
// field's presence as "this was the fallback's doing".
|
|
24133
|
-
//
|
|
24134
|
-
// Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
|
|
24135
|
-
// Closing either means moving the reason onto the finding row, which
|
|
24136
|
-
// already carries its own action.
|
|
24137
|
-
redactDegradedTo: ActionTaken.optional()
|
|
24138
|
-
}).meta({ id: "EventMetadata" });
|
|
24139
|
-
var Event = external_exports.object({
|
|
24140
|
-
id: external_exports.guid(),
|
|
24141
|
-
sourceTool: SourceTool,
|
|
24142
|
-
kind: EventKind,
|
|
24143
|
-
occurredAt: external_exports.iso.datetime(),
|
|
24144
|
-
contentHash: external_exports.string(),
|
|
24145
|
-
content: external_exports.string(),
|
|
24146
|
-
metadata: EventMetadata.optional()
|
|
24147
|
-
}).meta({ id: "Event" });
|
|
24148
|
-
var IngestEvent = Event.meta({ id: "IngestEvent" });
|
|
24149
|
-
var INGEST_BATCH_MAX = 100;
|
|
24150
|
-
var IngestBatch = external_exports.object({
|
|
24151
|
-
events: external_exports.array(IngestEvent).min(1).max(INGEST_BATCH_MAX),
|
|
24152
|
-
// Dedup policy for this batch. Id-dedup ALWAYS applies. 'content-hash'
|
|
24153
|
-
// additionally rejects any event whose contentHash the store has already
|
|
24154
|
-
// recorded — for re-runnable bulk ingest (worktree scan, transcript
|
|
24155
|
-
// backfill), where a re-run mints fresh event ids for identical content and
|
|
24156
|
-
// would otherwise accumulate duplicates. Live hook traffic must NOT set it:
|
|
24157
|
-
// two genuinely separate prompts can be byte-identical and both belong on
|
|
24158
|
-
// the timeline.
|
|
24159
|
-
dedupe: external_exports.literal("content-hash").optional()
|
|
24160
|
-
}).meta({ id: "IngestBatch" });
|
|
24161
|
-
|
|
24162
24287
|
// ../../packages/schema/src/zod/exception.ts
|
|
24163
24288
|
var ExceptionScope = external_exports.enum(["once", "temporary", "permanent"]);
|
|
24164
24289
|
var ExceptionConditions = external_exports.object({
|
|
@@ -24626,6 +24751,8 @@ function toInstanceDetail(row) {
|
|
|
24626
24751
|
provider: toApiProvider(row.sourceTool),
|
|
24627
24752
|
repo: row.repo,
|
|
24628
24753
|
file: row.file,
|
|
24754
|
+
...row.line === void 0 ? {} : { line: row.line },
|
|
24755
|
+
...row.col === void 0 ? {} : { col: row.col },
|
|
24629
24756
|
...row.toolName === void 0 ? {} : { toolName: row.toolName },
|
|
24630
24757
|
eventId: row.eventId,
|
|
24631
24758
|
...row.sessionId === void 0 ? {} : { sessionId: row.sessionId },
|
|
@@ -24639,7 +24766,11 @@ function toInstanceDetail(row) {
|
|
|
24639
24766
|
category,
|
|
24640
24767
|
subtype: row.ruleId,
|
|
24641
24768
|
severity: row.severity,
|
|
24642
|
-
match: {
|
|
24769
|
+
match: {
|
|
24770
|
+
maskedValue: row.maskedMatch,
|
|
24771
|
+
contextPrefix: "",
|
|
24772
|
+
...row.context === void 0 ? {} : { context: row.context }
|
|
24773
|
+
},
|
|
24643
24774
|
detection: { id: row.ruleId, name: null },
|
|
24644
24775
|
policy: { id: `category:${category}`, name: category }
|
|
24645
24776
|
};
|
|
@@ -24751,8 +24882,6 @@ var Policy = external_exports.object({
|
|
|
24751
24882
|
// test `prohibitedModels` passes and `reversibleRuleIds` fails.
|
|
24752
24883
|
provenance: PolicyProvenance.optional()
|
|
24753
24884
|
}).meta({ id: "Policy" });
|
|
24754
|
-
var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
|
|
24755
|
-
var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
|
|
24756
24885
|
var RedactFallback = BuiltinPolicyId.extract(["monitor", "warn", "block"]).meta({
|
|
24757
24886
|
id: "RedactFallback"
|
|
24758
24887
|
});
|
|
@@ -25139,7 +25268,7 @@ var VaultConsent = external_exports.object({
|
|
|
25139
25268
|
});
|
|
25140
25269
|
|
|
25141
25270
|
// ../../packages/schema/src/zod/local.ts
|
|
25142
|
-
var WORKSPACE_SETTINGS_SPEC_VERSION =
|
|
25271
|
+
var WORKSPACE_SETTINGS_SPEC_VERSION = 9;
|
|
25143
25272
|
var MODEL_JUDGE_PAYLOAD_VERSION = 1;
|
|
25144
25273
|
var HISTORY_SYNC_PAYLOAD_VERSION = 3;
|
|
25145
25274
|
var RunMode = external_exports.enum(["standalone", "attached"]);
|
|
@@ -25164,6 +25293,18 @@ function isHistorySyncConsentValid(consent, endpoint) {
|
|
|
25164
25293
|
if (consent === void 0 || endpoint === void 0) return false;
|
|
25165
25294
|
return consent.payloadVersion === HISTORY_SYNC_PAYLOAD_VERSION && consent.endpoint === endpoint;
|
|
25166
25295
|
}
|
|
25296
|
+
var ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH = 512;
|
|
25297
|
+
var AttachmentScopeEntry = external_exports.object({
|
|
25298
|
+
kind: external_exports.enum(["repo", "account"]),
|
|
25299
|
+
identity: printable(ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH).min(1),
|
|
25300
|
+
label: printable(80).optional(),
|
|
25301
|
+
enrolledAt: external_exports.iso.datetime()
|
|
25302
|
+
});
|
|
25303
|
+
var AttachmentScope = external_exports.object({
|
|
25304
|
+
endpoint: external_exports.string().min(1),
|
|
25305
|
+
entries: external_exports.array(AttachmentScopeEntry)
|
|
25306
|
+
});
|
|
25307
|
+
var AttachmentScopeEnvelope = AttachmentScope.extend({ entries: external_exports.array(external_exports.unknown()) });
|
|
25167
25308
|
var WebChatCaptureConsent = external_exports.object({
|
|
25168
25309
|
acknowledgedAt: external_exports.iso.datetime(),
|
|
25169
25310
|
version: external_exports.number().int().positive()
|
|
@@ -25234,6 +25375,23 @@ var WorkspaceSettings = external_exports.object({
|
|
|
25234
25375
|
// both widenings. Absent until granted, and a grant for a different endpoint
|
|
25235
25376
|
// or an older payload no longer counts.
|
|
25236
25377
|
historySyncConsent: HistorySyncConsent.optional(),
|
|
25378
|
+
// The identities a SCOPED attachment forwards and the deployment they were
|
|
25379
|
+
// enrolled for (see AttachmentScope). Absent until something is enrolled.
|
|
25380
|
+
//
|
|
25381
|
+
// `z.unknown()`, NOT `AttachmentScope`, and the difference is this field's
|
|
25382
|
+
// whole failure mode. A settings.json that fails this schema reads as the
|
|
25383
|
+
// unonboarded defaults (readUserSettings in @akasecurity/persistence), and the
|
|
25384
|
+
// next save writes those defaults back over it. Typed, one entry with an
|
|
25385
|
+
// unknown `kind`, a control character or a bad timestamp would cost the
|
|
25386
|
+
// attachment, every consent and onboardedAt, permanently. Untyped, the value
|
|
25387
|
+
// is kept exactly as found and validated where it is used: parseAttachmentScope
|
|
25388
|
+
// drops a bad entry by itself, and on a scoped attachment resolveScope reads a
|
|
25389
|
+
// bad envelope as no entries, which keeps every event local.
|
|
25390
|
+
//
|
|
25391
|
+
// No default: absent must stay absent, so defaultWorkspaceSettings() and a
|
|
25392
|
+
// fresh settings.json do not change. No `.meta({ id })`, like every field
|
|
25393
|
+
// here. Not a ManagedSettingKey.
|
|
25394
|
+
attachmentScope: external_exports.unknown().optional(),
|
|
25237
25395
|
// What the browser extension may record from a web chat, and the grant that
|
|
25238
25396
|
// authorizes it. Absent until the user answers: recording something that was
|
|
25239
25397
|
// never recorded before is never an assumed grant on upgrade, so the whole
|
|
@@ -25328,7 +25486,10 @@ function toInspectionFindingRow(input2) {
|
|
|
25328
25486
|
actionTaken: input2.actionTaken,
|
|
25329
25487
|
confidence: input2.confidence,
|
|
25330
25488
|
findingKey: input2.findingKey ?? null,
|
|
25331
|
-
firstDetectedAt: input2.firstDetectedAt ? isoToEpochMillis(input2.firstDetectedAt) : null
|
|
25489
|
+
firstDetectedAt: input2.firstDetectedAt ? isoToEpochMillis(input2.firstDetectedAt) : null,
|
|
25490
|
+
line: input2.line ?? null,
|
|
25491
|
+
col: input2.col ?? null,
|
|
25492
|
+
context: input2.context ? JSON.stringify(input2.context) : null
|
|
25332
25493
|
};
|
|
25333
25494
|
}
|
|
25334
25495
|
function toCaptureAttributes(event) {
|
|
@@ -26565,6 +26726,15 @@ var COUNTED_SCOPE = `
|
|
|
26565
26726
|
OR outbox_owed = 1
|
|
26566
26727
|
)`;
|
|
26567
26728
|
var SKIPPED = -1;
|
|
26729
|
+
function inScope(column) {
|
|
26730
|
+
return `${column} IN (SELECT value FROM json_each(:scopeKeys))`;
|
|
26731
|
+
}
|
|
26732
|
+
function scopeKeysParam(scopeKeys) {
|
|
26733
|
+
return JSON.stringify(scopeKeys);
|
|
26734
|
+
}
|
|
26735
|
+
var ROOT_SCOPE_KEY = `(SELECT session_root.scope_key
|
|
26736
|
+
FROM audit_events AS session_root
|
|
26737
|
+
WHERE session_root.id = COALESCE(audit_events.root_session_id, audit_events.id))`;
|
|
26568
26738
|
var HISTORY_SYNC_LEASE_STALE_MS = 6e4;
|
|
26569
26739
|
var ROW_COLUMNS = `id,
|
|
26570
26740
|
parent_id AS parentId,
|
|
@@ -26594,6 +26764,18 @@ var SqliteHistorySyncRepository = class {
|
|
|
26594
26764
|
ORDER BY earliest
|
|
26595
26765
|
LIMIT :limit`
|
|
26596
26766
|
);
|
|
26767
|
+
this.scopedSessionsStmt = db.prepare(
|
|
26768
|
+
`SELECT COALESCE(root_session_id, id) AS sessionId, MIN(started_at) AS earliest
|
|
26769
|
+
FROM audit_events
|
|
26770
|
+
WHERE synced_at IS NULL
|
|
26771
|
+
AND event_type IN (${TYPE_LIST})
|
|
26772
|
+
AND started_at < :before
|
|
26773
|
+
AND ${inScope("scope_key")}
|
|
26774
|
+
AND ${inScope(ROOT_SCOPE_KEY)}
|
|
26775
|
+
GROUP BY sessionId
|
|
26776
|
+
ORDER BY earliest
|
|
26777
|
+
LIMIT :limit`
|
|
26778
|
+
);
|
|
26597
26779
|
this.rowsStmt = db.prepare(
|
|
26598
26780
|
`SELECT ${ROW_COLUMNS}
|
|
26599
26781
|
FROM audit_events
|
|
@@ -26604,6 +26786,18 @@ var SqliteHistorySyncRepository = class {
|
|
|
26604
26786
|
ORDER BY (event_type = 'session') DESC, started_at
|
|
26605
26787
|
LIMIT :limit`
|
|
26606
26788
|
);
|
|
26789
|
+
this.scopedRowsStmt = db.prepare(
|
|
26790
|
+
`SELECT ${ROW_COLUMNS}
|
|
26791
|
+
FROM audit_events
|
|
26792
|
+
WHERE synced_at IS NULL
|
|
26793
|
+
AND event_type IN (${TYPE_LIST})
|
|
26794
|
+
AND started_at < :before
|
|
26795
|
+
AND COALESCE(root_session_id, id) = :sessionId
|
|
26796
|
+
AND ${inScope("scope_key")}
|
|
26797
|
+
AND ${inScope(ROOT_SCOPE_KEY)}
|
|
26798
|
+
ORDER BY (event_type = 'session') DESC, started_at
|
|
26799
|
+
LIMIT :limit`
|
|
26800
|
+
);
|
|
26607
26801
|
this.captureRowsStmt = db.prepare(
|
|
26608
26802
|
`SELECT ${ROW_COLUMNS}
|
|
26609
26803
|
FROM audit_events
|
|
@@ -26615,6 +26809,18 @@ var SqliteHistorySyncRepository = class {
|
|
|
26615
26809
|
ORDER BY started_at
|
|
26616
26810
|
LIMIT :limit`
|
|
26617
26811
|
);
|
|
26812
|
+
this.scopedCaptureRowsStmt = db.prepare(
|
|
26813
|
+
`SELECT ${ROW_COLUMNS}
|
|
26814
|
+
FROM audit_events
|
|
26815
|
+
WHERE synced_at IS NULL
|
|
26816
|
+
AND sync_claimed_at IS NULL
|
|
26817
|
+
AND outbox_owed = 1
|
|
26818
|
+
AND event_type IN (${CAPTURE_TYPE_LIST})
|
|
26819
|
+
AND started_at < :before
|
|
26820
|
+
AND ${inScope("scope_key")}
|
|
26821
|
+
ORDER BY started_at
|
|
26822
|
+
LIMIT :limit`
|
|
26823
|
+
);
|
|
26618
26824
|
this.markOwedStmt = db.prepare(
|
|
26619
26825
|
`UPDATE audit_events SET outbox_owed = 1 WHERE id = :id AND synced_at IS NULL`
|
|
26620
26826
|
);
|
|
@@ -26624,6 +26830,20 @@ var SqliteHistorySyncRepository = class {
|
|
|
26624
26830
|
AND event_type IN (${CAPTURE_TYPE_LIST})
|
|
26625
26831
|
AND started_at < :before`
|
|
26626
26832
|
);
|
|
26833
|
+
this.scopedCaptureBacklogOwedStmt = db.prepare(
|
|
26834
|
+
`UPDATE audit_events SET outbox_owed = 1
|
|
26835
|
+
WHERE synced_at IS NULL
|
|
26836
|
+
AND event_type IN (${CAPTURE_TYPE_LIST})
|
|
26837
|
+
AND started_at < :before
|
|
26838
|
+
AND ${inScope("scope_key")}`
|
|
26839
|
+
);
|
|
26840
|
+
this.markScopeCapturesOwedStmt = db.prepare(
|
|
26841
|
+
`UPDATE audit_events SET outbox_owed = 1
|
|
26842
|
+
WHERE synced_at IS NULL
|
|
26843
|
+
AND outbox_owed IS NULL
|
|
26844
|
+
AND event_type IN (${CAPTURE_TYPE_LIST})
|
|
26845
|
+
AND ${inScope("scope_key")}`
|
|
26846
|
+
);
|
|
26627
26847
|
this.stampStmt = db.prepare(
|
|
26628
26848
|
`UPDATE audit_events
|
|
26629
26849
|
SET synced_at = :at,
|
|
@@ -26782,6 +27002,15 @@ var SqliteHistorySyncRepository = class {
|
|
|
26782
27002
|
claimRowStmt;
|
|
26783
27003
|
releaseRowStmt;
|
|
26784
27004
|
releaseStaleClaimsStmt;
|
|
27005
|
+
// The SCOPED twins, for a scoped attachment: the same reads and seeds with the
|
|
27006
|
+
// scope clause added, prepared once here beside the machine statements, so a
|
|
27007
|
+
// machine attachment's statements are untouched and neither form is compiled
|
|
27008
|
+
// per call.
|
|
27009
|
+
scopedSessionsStmt;
|
|
27010
|
+
scopedRowsStmt;
|
|
27011
|
+
scopedCaptureRowsStmt;
|
|
27012
|
+
scopedCaptureBacklogOwedStmt;
|
|
27013
|
+
markScopeCapturesOwedStmt;
|
|
26785
27014
|
/**
|
|
26786
27015
|
* The masked detections recorded against one tool call.
|
|
26787
27016
|
*
|
|
@@ -26801,15 +27030,33 @@ var SqliteHistorySyncRepository = class {
|
|
|
26801
27030
|
* path's to deliver; this drain exists for what was recorded before it, and a
|
|
26802
27031
|
* row both paths send is at best a duplicate request and at worst — for a
|
|
26803
27032
|
* session root — an overwrite of the inventory ids the live path resolved.
|
|
27033
|
+
*
|
|
27034
|
+
* `scopeKeys` is a scoped attachment's filter: a session is offered only while
|
|
27035
|
+
* its root's key is one of them AND at least one of its unsent rows' keys is
|
|
27036
|
+
* (see scopedSessionsStmt). Omitted, this runs the machine statement,
|
|
27037
|
+
* unchanged; an empty list offers nothing.
|
|
26804
27038
|
*/
|
|
26805
|
-
pendingSessions(limit, before) {
|
|
26806
|
-
|
|
26807
|
-
|
|
26808
|
-
|
|
27039
|
+
pendingSessions(limit, before, scopeKeys) {
|
|
27040
|
+
const rows = scopeKeys === void 0 ? allRows(this.sessionsStmt, { limit, before }) : allRows(this.scopedSessionsStmt, {
|
|
27041
|
+
limit,
|
|
27042
|
+
before,
|
|
27043
|
+
scopeKeys: scopeKeysParam(scopeKeys)
|
|
27044
|
+
});
|
|
27045
|
+
return rows.map((r) => r.sessionId);
|
|
26809
27046
|
}
|
|
26810
|
-
/**
|
|
26811
|
-
|
|
26812
|
-
|
|
27047
|
+
/**
|
|
27048
|
+
* One session's undelivered structural rows within the backlog, root first.
|
|
27049
|
+
*
|
|
27050
|
+
* With `scopeKeys`, only the rows whose own key AND whose session root's key
|
|
27051
|
+
* are among them, whichever session id is passed.
|
|
27052
|
+
*/
|
|
27053
|
+
pendingRows(sessionId, limit, before, scopeKeys) {
|
|
27054
|
+
return scopeKeys === void 0 ? allRows(this.rowsStmt, { sessionId, limit, before }) : allRows(this.scopedRowsStmt, {
|
|
27055
|
+
sessionId,
|
|
27056
|
+
limit,
|
|
27057
|
+
before,
|
|
27058
|
+
scopeKeys: scopeKeysParam(scopeKeys)
|
|
27059
|
+
});
|
|
26813
27060
|
}
|
|
26814
27061
|
/**
|
|
26815
27062
|
* Captures this machine still owes the deployment, oldest first.
|
|
@@ -26818,9 +27065,17 @@ var SqliteHistorySyncRepository = class {
|
|
|
26818
27065
|
* by a time window — see captureRowsStmt for why a window could not express
|
|
26819
27066
|
* this. `before` is the grace window that leaves a just-recorded capture to
|
|
26820
27067
|
* the live path.
|
|
27068
|
+
*
|
|
27069
|
+
* With `scopeKeys`, only captures stamped with one of them, decided per
|
|
27070
|
+
* capture: /v1/events stubs a missing root, so a capture never waits on its
|
|
27071
|
+
* session's scope. An empty list reads nothing.
|
|
26821
27072
|
*/
|
|
26822
|
-
pendingCaptureRows(limit, before) {
|
|
26823
|
-
return allRows(this.captureRowsStmt, { limit, before })
|
|
27073
|
+
pendingCaptureRows(limit, before, scopeKeys) {
|
|
27074
|
+
return scopeKeys === void 0 ? allRows(this.captureRowsStmt, { limit, before }) : allRows(this.scopedCaptureRowsStmt, {
|
|
27075
|
+
limit,
|
|
27076
|
+
before,
|
|
27077
|
+
scopeKeys: scopeKeysParam(scopeKeys)
|
|
27078
|
+
});
|
|
26824
27079
|
}
|
|
26825
27080
|
/**
|
|
26826
27081
|
* Record that a capture is OWED to the deployment.
|
|
@@ -26852,9 +27107,37 @@ var SqliteHistorySyncRepository = class {
|
|
|
26852
27107
|
* Returns how many rows matched, for the caller to log or test against. Not a
|
|
26853
27108
|
* count of NEWLY marked rows — a row still unsynced from an earlier call
|
|
26854
27109
|
* matches again and is counted again, the same as `UPDATE`'s own `changes`.
|
|
27110
|
+
*
|
|
27111
|
+
* `scopeKeys` scopes it for a scoped attachment: only captures stamped with one
|
|
27112
|
+
* of the keys are marked, and an empty list marks none. The scoped capture read
|
|
27113
|
+
* is what keeps a personal capture out of a batch; this keeps the marker to
|
|
27114
|
+
* what the grant covers. Omitted, it runs the machine statement, unchanged.
|
|
27115
|
+
*/
|
|
27116
|
+
markCaptureBacklogOwed(before, scopeKeys) {
|
|
27117
|
+
const result = scopeKeys === void 0 ? this.markCaptureBacklogOwedStmt.run({ before }) : this.scopedCaptureBacklogOwedStmt.run({ before, scopeKeys: scopeKeysParam(scopeKeys) });
|
|
27118
|
+
return Number(result.changes);
|
|
27119
|
+
}
|
|
27120
|
+
/**
|
|
27121
|
+
* Mark owed every unsent capture stamped with one of `scopeKeys`: the re-seed
|
|
27122
|
+
* an enrollment runs.
|
|
27123
|
+
*
|
|
27124
|
+
* This ASSUMES the contract a scoped caller keeps, and cannot check it: nothing
|
|
27125
|
+
* else marks an out-of-scope capture owed (the live forward must refuse it
|
|
27126
|
+
* before its owed branch, and the consent-time seed must be handed the key
|
|
27127
|
+
* list). Under that contract, an enrolled repository's unsent captures are
|
|
27128
|
+
* reachable only if this runs when the repository is enrolled. Like the
|
|
27129
|
+
* consent seed it is one explicit human action, never something a pass infers,
|
|
27130
|
+
* and its caller must know the history grant is in force: this method cannot
|
|
27131
|
+
* check consent and must not be called without it.
|
|
27132
|
+
*
|
|
27133
|
+
* No time bound. Delivered and skipped rows are never re-opened, and a row
|
|
27134
|
+
* already owed is not counted, so the return value is how many rows this call
|
|
27135
|
+
* newly marked. An empty list marks nothing.
|
|
26855
27136
|
*/
|
|
26856
|
-
|
|
26857
|
-
return Number(
|
|
27137
|
+
markScopeCapturesOwed(scopeKeys) {
|
|
27138
|
+
return Number(
|
|
27139
|
+
this.markScopeCapturesOwedStmt.run({ scopeKeys: scopeKeysParam(scopeKeys) }).changes
|
|
27140
|
+
);
|
|
26858
27141
|
}
|
|
26859
27142
|
/**
|
|
26860
27143
|
* Record delivery. Called only AFTER the far side has accepted the rows.
|
|
@@ -27059,8 +27342,12 @@ var SqliteHistorySyncRepository = class {
|
|
|
27059
27342
|
* disown from eating THIS SAME CALL's own re-mark is the order, not the
|
|
27060
27343
|
* bound — disown runs first, re-mark second, both inside the one
|
|
27061
27344
|
* transaction above.
|
|
27345
|
+
*
|
|
27346
|
+
* `scopeKeys` scopes the re-mark exactly as `markCaptureBacklogOwed` is scoped.
|
|
27347
|
+
* The disown before it is not scoped, and must not be: it clears the previous
|
|
27348
|
+
* deployment's markers whatever their scope.
|
|
27062
27349
|
*/
|
|
27063
|
-
rearmFor(fingerprint, backlogBefore, backfillCapturesBefore) {
|
|
27350
|
+
rearmFor(fingerprint, backlogBefore, backfillCapturesBefore, scopeKeys) {
|
|
27064
27351
|
this.ensureRowStmt.run();
|
|
27065
27352
|
withTransaction(
|
|
27066
27353
|
this.db,
|
|
@@ -27071,7 +27358,7 @@ var SqliteHistorySyncRepository = class {
|
|
|
27071
27358
|
this.disownCapturesStmt.run({ attachedAt: backlogBefore });
|
|
27072
27359
|
}
|
|
27073
27360
|
if (backfillCapturesBefore !== void 0) {
|
|
27074
|
-
this.
|
|
27361
|
+
this.markCaptureBacklogOwed(backfillCapturesBefore, scopeKeys);
|
|
27075
27362
|
}
|
|
27076
27363
|
this.setFingerprintStmt.run({ fingerprint, backlogBefore });
|
|
27077
27364
|
},
|
|
@@ -27237,6 +27524,7 @@ function applyMigrations(db, file2, options = {}) {
|
|
|
27237
27524
|
db.exec(`PRAGMA user_version = ${String(SQLITE_MIGRATIONS.length)}`);
|
|
27238
27525
|
}
|
|
27239
27526
|
ensureSyncedAtColumn(db, "audit_events");
|
|
27527
|
+
ensureScopeKeyColumn(db);
|
|
27240
27528
|
ensureScanLedgerTable(db);
|
|
27241
27529
|
ensureHistorySyncTable(db);
|
|
27242
27530
|
ensureBlockedDetectionsTable(db);
|
|
@@ -27662,6 +27950,21 @@ function ensureSyncedAtColumn(db, table) {
|
|
|
27662
27950
|
ON audit_events (sync_claimed_at) WHERE sync_claimed_at IS NOT NULL`
|
|
27663
27951
|
);
|
|
27664
27952
|
}
|
|
27953
|
+
var SCOPE_KEY_COLUMN_DDL = "ALTER TABLE audit_events ADD COLUMN scope_key text GENERATED ALWAYS AS (CASE WHEN json_valid(attributes) THEN json_extract(attributes, '$.scope_key') END) VIRTUAL";
|
|
27954
|
+
function ensureScopeKeyColumn(db) {
|
|
27955
|
+
if (!schemaObjectExists(db, "table", "audit_events")) return;
|
|
27956
|
+
if (hasScopeKeyColumn(db)) return;
|
|
27957
|
+
withTransaction(
|
|
27958
|
+
db,
|
|
27959
|
+
() => {
|
|
27960
|
+
if (!hasScopeKeyColumn(db)) db.exec(SCOPE_KEY_COLUMN_DDL);
|
|
27961
|
+
},
|
|
27962
|
+
"IMMEDIATE"
|
|
27963
|
+
);
|
|
27964
|
+
}
|
|
27965
|
+
function hasScopeKeyColumn(db) {
|
|
27966
|
+
return columnNames(db, "audit_events", { includeGenerated: true }).includes("scope_key");
|
|
27967
|
+
}
|
|
27665
27968
|
function ensureScanLedgerTable(db) {
|
|
27666
27969
|
db.exec(`CREATE TABLE IF NOT EXISTS scan_ledger (
|
|
27667
27970
|
path TEXT PRIMARY KEY,
|
|
@@ -28539,6 +28842,19 @@ var SqliteAuditEventsRepository = class {
|
|
|
28539
28842
|
if (typeof provider === "string") return provider;
|
|
28540
28843
|
return void 0;
|
|
28541
28844
|
}
|
|
28845
|
+
// The `scope_key` stored on a session root's attributes: the key the history
|
|
28846
|
+
// drain decides that root by. It is NOT necessarily the key of the root event a
|
|
28847
|
+
// caller just wrote, because roots are first-write-wins (see the session-root
|
|
28848
|
+
// upsert above) and the root event that arrives second leaves the stored row as
|
|
28849
|
+
// it was. Returns undefined when the id is not a session root, when the root is
|
|
28850
|
+
// a stub or carries no key, and when the stored value is not a string, which is
|
|
28851
|
+
// what the drain's scoped reads would not match either.
|
|
28852
|
+
sessionScopeKey(sessionId) {
|
|
28853
|
+
const row = this.findById(sessionId);
|
|
28854
|
+
if (row?.event_type !== "session" || !row.attributes) return void 0;
|
|
28855
|
+
const key = parseJsonObject(row.attributes)?.scope_key;
|
|
28856
|
+
return typeof key === "string" ? key : void 0;
|
|
28857
|
+
}
|
|
28542
28858
|
// Every `llm_call` leaf's session id + raw attribute bag, for the read-time token
|
|
28543
28859
|
// rollups. The caller parses each bag and prices it via the
|
|
28544
28860
|
// cost model — we stay a thin reader here (no business logic, no cost). `root_session_id`
|
|
@@ -28559,6 +28875,8 @@ var SqliteAuditEventsRepository = class {
|
|
|
28559
28875
|
var DEFAULT_BATCH_SIZE = 500;
|
|
28560
28876
|
var DEFAULT_MAX_ROWS = 5e4;
|
|
28561
28877
|
var SYNC_LANE_TYPES_SQL = OUTBOX_CAPTURE_TYPE_LIST;
|
|
28878
|
+
var SWEEP = { kind: "sweep" };
|
|
28879
|
+
var HOLD_ALL = { kind: "hold-all" };
|
|
28562
28880
|
var SqliteBodyRetentionRepository = class {
|
|
28563
28881
|
constructor(db) {
|
|
28564
28882
|
this.db = db;
|
|
@@ -28575,6 +28893,14 @@ var SqliteBodyRetentionRepository = class {
|
|
|
28575
28893
|
this.candidatesSyncSafeStmt = this.db.prepare(
|
|
28576
28894
|
select(`AND (event_type NOT IN (${SYNC_LANE_TYPES_SQL}) OR synced_at IS NOT NULL)`)
|
|
28577
28895
|
);
|
|
28896
|
+
this.candidatesScopedStmt = this.db.prepare(
|
|
28897
|
+
select(
|
|
28898
|
+
`AND (event_type NOT IN (${SYNC_LANE_TYPES_SQL}) OR synced_at IS NOT NULL
|
|
28899
|
+
OR (outbox_owed IS NOT 1
|
|
28900
|
+
AND (scope_key IS NULL
|
|
28901
|
+
OR scope_key NOT IN (SELECT value FROM json_each(:scopeKeys)))))`
|
|
28902
|
+
)
|
|
28903
|
+
);
|
|
28578
28904
|
this.heldBySyncStmt = this.db.prepare(`
|
|
28579
28905
|
SELECT COUNT(*) AS n
|
|
28580
28906
|
FROM audit_events
|
|
@@ -28582,37 +28908,63 @@ var SqliteBodyRetentionRepository = class {
|
|
|
28582
28908
|
AND started_at < :cutoff
|
|
28583
28909
|
AND event_type IN (${SYNC_LANE_TYPES_SQL})
|
|
28584
28910
|
AND synced_at IS NULL`);
|
|
28911
|
+
this.heldByScopeStmt = this.db.prepare(`
|
|
28912
|
+
SELECT COUNT(*) AS n
|
|
28913
|
+
FROM audit_events
|
|
28914
|
+
WHERE content IS NOT NULL
|
|
28915
|
+
AND started_at < :cutoff
|
|
28916
|
+
AND event_type IN (${SYNC_LANE_TYPES_SQL})
|
|
28917
|
+
AND synced_at IS NULL
|
|
28918
|
+
AND (outbox_owed = 1
|
|
28919
|
+
OR scope_key IN (SELECT value FROM json_each(:scopeKeys)))`);
|
|
28585
28920
|
this.expireStmt = this.db.prepare(
|
|
28586
28921
|
`UPDATE audit_events SET content = NULL, content_expired_at = :now WHERE id = :id`
|
|
28587
28922
|
);
|
|
28923
|
+
this.expireContextsStmt = this.db.prepare(
|
|
28924
|
+
`UPDATE inspection_findings SET context = NULL
|
|
28925
|
+
WHERE id IN (
|
|
28926
|
+
SELECT f.id
|
|
28927
|
+
FROM inspection_findings f INDEXED BY idx_inspection_findings_context
|
|
28928
|
+
JOIN audit_events e ON e.id = f.audit_event_id
|
|
28929
|
+
WHERE f.context IS NOT NULL
|
|
28930
|
+
AND f.first_detected_at < :cutoff
|
|
28931
|
+
AND e.content IS NULL
|
|
28932
|
+
AND e.started_at < :cutoff
|
|
28933
|
+
LIMIT :limit)`
|
|
28934
|
+
);
|
|
28588
28935
|
}
|
|
28589
28936
|
db;
|
|
28590
28937
|
candidatesStmt;
|
|
28591
28938
|
candidatesSyncSafeStmt;
|
|
28939
|
+
candidatesScopedStmt;
|
|
28592
28940
|
heldBySyncStmt;
|
|
28941
|
+
heldByScopeStmt;
|
|
28593
28942
|
expireStmt;
|
|
28594
|
-
|
|
28943
|
+
expireContextsStmt;
|
|
28944
|
+
/**
|
|
28945
|
+
* How many body bytes a pass with these options would free, changing
|
|
28946
|
+
* nothing. Finding excerpts are not counted (see `bytesFreed`).
|
|
28947
|
+
*/
|
|
28595
28948
|
preview(opts) {
|
|
28596
|
-
const
|
|
28597
|
-
const
|
|
28598
|
-
const rows = stmt.all({ cutoff: opts.cutoff, limit });
|
|
28949
|
+
const lane = laneOf(opts.sweepSyncLane);
|
|
28950
|
+
const rows = this.candidates(lane, opts.cutoff, opts.maxRows ?? DEFAULT_MAX_ROWS);
|
|
28599
28951
|
return {
|
|
28600
28952
|
rowsExpired: rows.length,
|
|
28601
28953
|
bytesFreed: rows.reduce((sum, r) => sum + r.bytes, 0),
|
|
28602
|
-
rowsHeldBySync: this.countHeldBySync(opts)
|
|
28954
|
+
rowsHeldBySync: this.countHeldBySync(lane, opts.cutoff)
|
|
28603
28955
|
};
|
|
28604
28956
|
}
|
|
28605
28957
|
/** Clear eligible bodies, in bounded batches. */
|
|
28606
28958
|
expire(opts) {
|
|
28607
28959
|
const batchSize = opts.batchSize ?? DEFAULT_BATCH_SIZE;
|
|
28608
28960
|
const maxRows = opts.maxRows ?? DEFAULT_MAX_ROWS;
|
|
28609
|
-
const
|
|
28961
|
+
const lane = laneOf(opts.sweepSyncLane);
|
|
28610
28962
|
let rowsExpired = 0;
|
|
28611
28963
|
let bytesFreed = 0;
|
|
28612
28964
|
let done = true;
|
|
28613
28965
|
while (rowsExpired < maxRows) {
|
|
28614
28966
|
const remaining = Math.min(batchSize, maxRows - rowsExpired);
|
|
28615
|
-
const batch =
|
|
28967
|
+
const batch = this.candidates(lane, opts.cutoff, remaining);
|
|
28616
28968
|
if (batch.length === 0) break;
|
|
28617
28969
|
withTransaction(
|
|
28618
28970
|
this.db,
|
|
@@ -28625,17 +28977,60 @@ var SqliteBodyRetentionRepository = class {
|
|
|
28625
28977
|
bytesFreed += batch.reduce((sum, r) => sum + r.bytes, 0);
|
|
28626
28978
|
if (batch.length < remaining) break;
|
|
28627
28979
|
if (rowsExpired >= maxRows) {
|
|
28628
|
-
done =
|
|
28980
|
+
done = this.candidates(lane, opts.cutoff, 1).length === 0;
|
|
28629
28981
|
}
|
|
28630
28982
|
}
|
|
28631
|
-
|
|
28983
|
+
this.expireContexts(opts.cutoff, batchSize, maxRows);
|
|
28984
|
+
return {
|
|
28985
|
+
rowsExpired,
|
|
28986
|
+
bytesFreed,
|
|
28987
|
+
rowsHeldBySync: this.countHeldBySync(lane, opts.cutoff),
|
|
28988
|
+
done
|
|
28989
|
+
};
|
|
28990
|
+
}
|
|
28991
|
+
// Clear the excerpts that outlived their body, one bounded transaction per
|
|
28992
|
+
// batch for the same reason the body sweep batches, and at most `maxRows` of
|
|
28993
|
+
// them per pass under the same cap: the next pass picks up the rest.
|
|
28994
|
+
expireContexts(cutoff, batchSize, maxRows) {
|
|
28995
|
+
let total = 0;
|
|
28996
|
+
while (total < maxRows) {
|
|
28997
|
+
const limit = Math.min(batchSize, maxRows - total);
|
|
28998
|
+
let cleared = 0;
|
|
28999
|
+
withTransaction(
|
|
29000
|
+
this.db,
|
|
29001
|
+
() => {
|
|
29002
|
+
cleared = Number(this.expireContextsStmt.run({ cutoff, limit }).changes);
|
|
29003
|
+
},
|
|
29004
|
+
"IMMEDIATE"
|
|
29005
|
+
);
|
|
29006
|
+
total += cleared;
|
|
29007
|
+
if (cleared < limit) return;
|
|
29008
|
+
}
|
|
29009
|
+
}
|
|
29010
|
+
/**
|
|
29011
|
+
* One batch of candidates under `lane`, bound with exactly the parameters its
|
|
29012
|
+
* statement names — node:sqlite refuses a named parameter a statement does not
|
|
29013
|
+
* declare, so the key list goes to the scoped statements only.
|
|
29014
|
+
*
|
|
29015
|
+
* Anything that is not `sweep` or `hold-keys` takes the hold-all statement.
|
|
29016
|
+
* The type admits no fourth kind, but this decides what is destroyed, and the
|
|
29017
|
+
* direction an unforeseen value falls has to be holding.
|
|
29018
|
+
*/
|
|
29019
|
+
candidates(lane, cutoff, limit) {
|
|
29020
|
+
const rows = lane.kind === "sweep" ? this.candidatesStmt.all({ cutoff, limit }) : lane.kind === "hold-keys" ? this.candidatesScopedStmt.all({ cutoff, limit, scopeKeys: JSON.stringify(lane.keys) }) : this.candidatesSyncSafeStmt.all({ cutoff, limit });
|
|
29021
|
+
return rows;
|
|
28632
29022
|
}
|
|
28633
|
-
countHeldBySync(
|
|
28634
|
-
if (
|
|
28635
|
-
const row = this.
|
|
29023
|
+
countHeldBySync(lane, cutoff) {
|
|
29024
|
+
if (lane.kind === "sweep") return 0;
|
|
29025
|
+
const row = lane.kind === "hold-keys" ? this.heldByScopeStmt.get({ cutoff, scopeKeys: JSON.stringify(lane.keys) }) : this.heldBySyncStmt.get({ cutoff });
|
|
28636
29026
|
return row.n;
|
|
28637
29027
|
}
|
|
28638
29028
|
};
|
|
29029
|
+
function laneOf(gate) {
|
|
29030
|
+
if (gate === true) return SWEEP;
|
|
29031
|
+
if (gate === false) return HOLD_ALL;
|
|
29032
|
+
return gate;
|
|
29033
|
+
}
|
|
28639
29034
|
|
|
28640
29035
|
// ../../packages/persistence/src/repositories/capture-status.ts
|
|
28641
29036
|
var STATUS_LOOKBACK_ROWS = 128;
|
|
@@ -29544,6 +29939,8 @@ function toFlatFindingRow(r) {
|
|
|
29544
29939
|
repo: r.repo ?? "",
|
|
29545
29940
|
file: r.file ?? "",
|
|
29546
29941
|
...r.tool_name === null ? {} : { toolName: r.tool_name },
|
|
29942
|
+
...r.line === null ? {} : { line: r.line },
|
|
29943
|
+
...r.col === null ? {} : { col: r.col },
|
|
29547
29944
|
eventId: r.event_id,
|
|
29548
29945
|
...r.session_id === null ? {} : { sessionId: r.session_id },
|
|
29549
29946
|
status: deriveInstanceStatus(r),
|
|
@@ -29621,7 +30018,8 @@ var FINDING_ROW_COLUMNS_SQL = `f.id AS id, d.rule_id AS rule_id, d.category AS c
|
|
|
29621
30018
|
${latestResolutionStatusSql("f")} AS latest_status,
|
|
29622
30019
|
e.synced_at AS synced_at, e.sync_claimed_at AS sync_claimed_at,
|
|
29623
30020
|
e.sync_failed_at AS sync_failed_at, e.sync_failure AS sync_failure,
|
|
29624
|
-
e.outbox_owed AS outbox_owed
|
|
30021
|
+
e.outbox_owed AS outbox_owed,
|
|
30022
|
+
f.line AS line, f.col AS col`;
|
|
29625
30023
|
var DAY_MS3 = 864e5;
|
|
29626
30024
|
var SqliteFindingsRepository = class {
|
|
29627
30025
|
constructor(db) {
|
|
@@ -30044,6 +30442,27 @@ var SqliteFindingsRepository = class {
|
|
|
30044
30442
|
).get(id);
|
|
30045
30443
|
return Promise.resolve(row === void 0 ? null : toInstanceDetail(toFlatFindingRow(row)));
|
|
30046
30444
|
}
|
|
30445
|
+
/**
|
|
30446
|
+
* One finding's excerpt source (see FindingContextSource). A primary-key
|
|
30447
|
+
* seek, like `findingInstance`, and the only findings read that touches the
|
|
30448
|
+
* event's text — which is why the list never projects the excerpt and the
|
|
30449
|
+
* drawer asks for it here, one finding at a time.
|
|
30450
|
+
*/
|
|
30451
|
+
findingContextSource(id) {
|
|
30452
|
+
const row = this.db.prepare(
|
|
30453
|
+
`SELECT f.context AS context, e.content AS content,
|
|
30454
|
+
f.span_start AS spanStart, f.span_end AS spanEnd,
|
|
30455
|
+
d.rule_id AS ruleId, d.category AS category,
|
|
30456
|
+
json_extract(e.attributes, '$.whole_file') AS wholeFile,
|
|
30457
|
+
e.tool_name AS toolName, e.event_type AS eventType
|
|
30458
|
+
FROM inspection_findings f
|
|
30459
|
+
JOIN audit_events e ON e.id = f.audit_event_id
|
|
30460
|
+
JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
30461
|
+
WHERE f.id = ?`
|
|
30462
|
+
).get(id);
|
|
30463
|
+
if (row === void 0) return null;
|
|
30464
|
+
return { ...row, wholeFile: row.wholeFile === 1 };
|
|
30465
|
+
}
|
|
30047
30466
|
/**
|
|
30048
30467
|
* The one statement both instance-level scans run: every finding in scope,
|
|
30049
30468
|
* joined to its event and definition, newest first.
|
|
@@ -30180,6 +30599,61 @@ var SqliteFindingsRepository = class {
|
|
|
30180
30599
|
])
|
|
30181
30600
|
);
|
|
30182
30601
|
}
|
|
30602
|
+
/**
|
|
30603
|
+
* The Findings page's summary strip: whole-store counts over exactly the rows
|
|
30604
|
+
* the instance reads list (the four capture kinds), each equal to what
|
|
30605
|
+
* listFindingInstances totals for the same filters — see FindingsOverview.
|
|
30606
|
+
*
|
|
30607
|
+
* ONE grouped aggregate whose keys are the raw classifier inputs, not the
|
|
30608
|
+
* answers: the statement groups by the three inputs deriveFindingStatus
|
|
30609
|
+
* reads, and each group is then classified here by that same function. So
|
|
30610
|
+
* SQL never restates the status rule, and the strip cannot disagree with the
|
|
30611
|
+
* list about which status a finding has. The group count is bounded by a
|
|
30612
|
+
* handful of status inputs, not by the store, so only the scan grows with it
|
|
30613
|
+
* — the same linear cost every other unscoped read on the page already pays.
|
|
30614
|
+
*
|
|
30615
|
+
* The definitions join selects nothing. It is there because the list's scan
|
|
30616
|
+
* joins it too, so a finding whose definition row is missing is left out of
|
|
30617
|
+
* both rather than counted here and absent there.
|
|
30618
|
+
*
|
|
30619
|
+
* The latest-resolution join is the derived-table form, which
|
|
30620
|
+
* resolution-sql.ts recommends for an aggregate over many findings.
|
|
30621
|
+
*/
|
|
30622
|
+
findingsOverview() {
|
|
30623
|
+
const rows = allRows(
|
|
30624
|
+
this.db.prepare(
|
|
30625
|
+
`SELECT e.event_type AS kind, (f.finding_key IS NOT NULL) AS keyed,
|
|
30626
|
+
latest.status AS latest_status, count(*) AS c
|
|
30627
|
+
FROM inspection_findings f
|
|
30628
|
+
JOIN audit_events e ON e.id = f.audit_event_id
|
|
30629
|
+
JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
30630
|
+
LEFT JOIN ${LATEST_RESOLUTION_BY_KEY_SQL} latest
|
|
30631
|
+
ON latest.finding_key = f.finding_key
|
|
30632
|
+
WHERE e.event_type IN (${CAPTURE_EVENT_TYPES_SQL})
|
|
30633
|
+
GROUP BY e.event_type, keyed, latest.status`
|
|
30634
|
+
)
|
|
30635
|
+
);
|
|
30636
|
+
const byStatus = {
|
|
30637
|
+
open: 0,
|
|
30638
|
+
handled: 0,
|
|
30639
|
+
resolved: 0,
|
|
30640
|
+
dismissed: 0
|
|
30641
|
+
};
|
|
30642
|
+
let findings = 0;
|
|
30643
|
+
for (const row of rows) {
|
|
30644
|
+
const status = deriveFindingStatus({
|
|
30645
|
+
kind: row.kind,
|
|
30646
|
+
// The classifier only asks whether a key exists, never what it is. The
|
|
30647
|
+
// stand-in is non-empty so a truthiness test of the key reads it as
|
|
30648
|
+
// present, exactly as it would a real one.
|
|
30649
|
+
findingKey: row.keyed ? "keyed" : null,
|
|
30650
|
+
latestResolutionStatus: row.latest_status
|
|
30651
|
+
});
|
|
30652
|
+
findings += row.c;
|
|
30653
|
+
byStatus[status] += row.c;
|
|
30654
|
+
}
|
|
30655
|
+
return Promise.resolve({ findings, ...byStatus });
|
|
30656
|
+
}
|
|
30183
30657
|
healthSummary() {
|
|
30184
30658
|
const total = countScalar(
|
|
30185
30659
|
this.db,
|
|
@@ -30307,12 +30781,13 @@ var SqliteInspectionFindingsRepository = class {
|
|
|
30307
30781
|
`INSERT INTO inspection_findings
|
|
30308
30782
|
(id, audit_event_id, inspection_definition_id, classified_data_id,
|
|
30309
30783
|
span_start, span_end, masked_match, action_taken, confidence,
|
|
30310
|
-
finding_key, first_detected_at)
|
|
30784
|
+
finding_key, first_detected_at, line, col, context)
|
|
30311
30785
|
VALUES
|
|
30312
30786
|
(:id, :auditEventId, :inspectionDefinitionId, :classifiedDataId,
|
|
30313
30787
|
:spanStart, :spanEnd, :maskedMatch, :actionTaken, :confidence,
|
|
30314
30788
|
:findingKey,
|
|
30315
|
-
COALESCE(:firstDetectedAt, (SELECT started_at FROM audit_events WHERE id = :auditEventId))
|
|
30789
|
+
COALESCE(:firstDetectedAt, (SELECT started_at FROM audit_events WHERE id = :auditEventId)),
|
|
30790
|
+
:line, :col, :context)
|
|
30316
30791
|
ON CONFLICT(id) DO UPDATE SET
|
|
30317
30792
|
inspection_definition_id = excluded.inspection_definition_id
|
|
30318
30793
|
ON CONFLICT (finding_key) DO UPDATE SET
|
|
@@ -30323,7 +30798,10 @@ var SqliteInspectionFindingsRepository = class {
|
|
|
30323
30798
|
span_end = excluded.span_end,
|
|
30324
30799
|
masked_match = excluded.masked_match,
|
|
30325
30800
|
action_taken = excluded.action_taken,
|
|
30326
|
-
confidence = excluded.confidence
|
|
30801
|
+
confidence = excluded.confidence,
|
|
30802
|
+
line = excluded.line,
|
|
30803
|
+
col = excluded.col,
|
|
30804
|
+
context = excluded.context`
|
|
30327
30805
|
);
|
|
30328
30806
|
this.sessionDupStmt = db.prepare(
|
|
30329
30807
|
`SELECT 1 FROM inspection_findings f
|
|
@@ -30373,7 +30851,10 @@ var SqliteInspectionFindingsRepository = class {
|
|
|
30373
30851
|
actionTaken: row.actionTaken,
|
|
30374
30852
|
confidence: row.confidence,
|
|
30375
30853
|
findingKey: row.findingKey,
|
|
30376
|
-
firstDetectedAt: row.firstDetectedAt
|
|
30854
|
+
firstDetectedAt: row.firstDetectedAt,
|
|
30855
|
+
line: row.line,
|
|
30856
|
+
col: row.col,
|
|
30857
|
+
context: row.context
|
|
30377
30858
|
})
|
|
30378
30859
|
);
|
|
30379
30860
|
}
|
|
@@ -30714,8 +31195,8 @@ var SqliteInstalledPacksRepository = class {
|
|
|
30714
31195
|
this.db = db;
|
|
30715
31196
|
this.baseDir = baseDir;
|
|
30716
31197
|
this.insertMissingStmt = db.prepare(
|
|
30717
|
-
`INSERT INTO installed_packs (id, namespace, pack_id, version, name, rules_json, enabled, created_at, updated_at)
|
|
30718
|
-
VALUES (:id, :namespace, :packId, :version, :name, :rulesJson, 1, :now, :now)
|
|
31198
|
+
`INSERT INTO installed_packs (id, namespace, pack_id, version, name, rules_json, enabled, policy_id, created_at, updated_at)
|
|
31199
|
+
VALUES (:id, :namespace, :packId, :version, :name, :rulesJson, 1, :policyId, :now, :now)
|
|
30719
31200
|
ON CONFLICT (namespace, pack_id) DO NOTHING`
|
|
30720
31201
|
);
|
|
30721
31202
|
this.upsertAvailableStmt = db.prepare(
|
|
@@ -30775,7 +31256,10 @@ var SqliteInstalledPacksRepository = class {
|
|
|
30775
31256
|
version: pack.version,
|
|
30776
31257
|
name: pack.name,
|
|
30777
31258
|
rulesJson: JSON.stringify(pack.rules),
|
|
30778
|
-
ruleIds: new Set(pack.rules.map((r) => r.id))
|
|
31259
|
+
ruleIds: new Set(pack.rules.map((r) => r.id)),
|
|
31260
|
+
// Only a first install takes it: an existing row is never modified here,
|
|
31261
|
+
// so a policy the user chose (or cleared) is never overwritten.
|
|
31262
|
+
defaultPolicyId: pack.defaultPolicyId ?? null
|
|
30779
31263
|
}));
|
|
30780
31264
|
if (this.storedSignature() === inventorySignature(rows)) return;
|
|
30781
31265
|
const now = Date.now();
|
|
@@ -30804,7 +31288,7 @@ var SqliteInstalledPacksRepository = class {
|
|
|
30804
31288
|
} else {
|
|
30805
31289
|
behind = true;
|
|
30806
31290
|
}
|
|
30807
|
-
this.insertMissingStmt.run(params);
|
|
31291
|
+
this.insertMissingStmt.run({ ...params, policyId: row.defaultPolicyId });
|
|
30808
31292
|
}
|
|
30809
31293
|
if (!behind) this.pruneAvailable(rows.map((r) => `${r.namespace}/${r.packId}`));
|
|
30810
31294
|
},
|
|
@@ -30922,7 +31406,8 @@ var SqliteInstalledPacksRepository = class {
|
|
|
30922
31406
|
rejectedRules: [],
|
|
30923
31407
|
ruleActions: /* @__PURE__ */ new Map(),
|
|
30924
31408
|
ruleVersions: /* @__PURE__ */ new Map(),
|
|
30925
|
-
reversibleRules: /* @__PURE__ */ new Set()
|
|
31409
|
+
reversibleRules: /* @__PURE__ */ new Set(),
|
|
31410
|
+
assignedRules: /* @__PURE__ */ new Set()
|
|
30926
31411
|
};
|
|
30927
31412
|
const reject = (pack, ruleId, reason) => {
|
|
30928
31413
|
if (out.rejectedRules.length >= REJECTED_RULE_DETAIL_CAP) return;
|
|
@@ -30955,6 +31440,8 @@ var SqliteInstalledPacksRepository = class {
|
|
|
30955
31440
|
out.ruleVersions.set(parsed2.data.id, row.version);
|
|
30956
31441
|
if (reversible) out.reversibleRules.add(parsed2.data.id);
|
|
30957
31442
|
else out.reversibleRules.delete(parsed2.data.id);
|
|
31443
|
+
if (row.policyId !== null) out.assignedRules.add(parsed2.data.id);
|
|
31444
|
+
else out.assignedRules.delete(parsed2.data.id);
|
|
30958
31445
|
} else {
|
|
30959
31446
|
out.invalidRules += 1;
|
|
30960
31447
|
reject(pack, printableRuleId(entry), firstIssueReason(parsed2.error));
|
|
@@ -32041,6 +32528,7 @@ var SqliteInventoryAssetsRepository = class {
|
|
|
32041
32528
|
|
|
32042
32529
|
// ../../packages/persistence/src/repositories/policies.ts
|
|
32043
32530
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
32531
|
+
var SEED_BATCH_WINDOW_MS = 6e4;
|
|
32044
32532
|
var SqlitePoliciesRepository = class {
|
|
32045
32533
|
constructor(db) {
|
|
32046
32534
|
this.db = db;
|
|
@@ -32062,39 +32550,123 @@ var SqlitePoliciesRepository = class {
|
|
|
32062
32550
|
});
|
|
32063
32551
|
return Promise.resolve(policies);
|
|
32064
32552
|
}
|
|
32065
|
-
// Seed one policy per bundled category
|
|
32066
|
-
//
|
|
32067
|
-
//
|
|
32553
|
+
// Seed one policy per bundled category at Monitor so the detection-type config
|
|
32554
|
+
// exists from first run. An unassigned pack's rules follow these rows, so
|
|
32555
|
+
// Monitor here is the posture of every pack that ships no defaultPolicy; a pack
|
|
32556
|
+
// that ships one carries its own assignment instead. Only when the
|
|
32557
|
+
// table is empty, so a user's edits are never clobbered.
|
|
32068
32558
|
seedDefaults() {
|
|
32069
32559
|
const count = countScalar(this.db, "SELECT count(*) AS n FROM policies");
|
|
32070
|
-
if (count > 0)
|
|
32560
|
+
if (count > 0) {
|
|
32561
|
+
this.markEarlierChoices();
|
|
32562
|
+
this.monitorUntouchedSeeds();
|
|
32563
|
+
return;
|
|
32564
|
+
}
|
|
32071
32565
|
const stmt = this.db.prepare(
|
|
32072
32566
|
`INSERT INTO policies (id, scope, target, action, enabled, created_at, updated_at)
|
|
32073
32567
|
VALUES (:id, 'global', :target, :action, 1, :now, :now)`
|
|
32074
32568
|
);
|
|
32075
32569
|
failOpenTransaction(this.db, () => {
|
|
32076
|
-
for (const
|
|
32570
|
+
for (const category of Object.keys(DEFAULT_ACTIONS)) {
|
|
32077
32571
|
stmt.run({
|
|
32078
32572
|
id: randomUUID6(),
|
|
32079
32573
|
target: JSON.stringify({ category }),
|
|
32080
|
-
action,
|
|
32574
|
+
action: "log",
|
|
32081
32575
|
now: Date.now()
|
|
32082
32576
|
});
|
|
32083
32577
|
}
|
|
32084
32578
|
});
|
|
32085
32579
|
}
|
|
32580
|
+
// Before this build, upsertCategoryAction INSERTed a new row with updated_at
|
|
32581
|
+
// equal to created_at, so a choice made for a category that had no row yet
|
|
32582
|
+
// (one added in a release after the store was seeded) looks exactly like a
|
|
32583
|
+
// seed. Left alone, fill-gaps would overwrite it and monitorUntouchedSeeds
|
|
32584
|
+
// could reset it. This pass marks such rows as chosen (updated_at =
|
|
32585
|
+
// created_at + 1) before either can read them. A row is an earlier build's
|
|
32586
|
+
// choice, not its seed, when either:
|
|
32587
|
+
// - its action is neither the old seed value (DEFAULT_ACTIONS) nor Monitor,
|
|
32588
|
+
// which no seed of any build ever wrote; or
|
|
32589
|
+
// - it was created well after the seed batch. Every build seeds all of its
|
|
32590
|
+
// categories in one transaction, and only into an empty table, so a row
|
|
32591
|
+
// created later came from upsertCategoryAction.
|
|
32592
|
+
// It needs no marker of its own: every row this build writes has updated_at >
|
|
32593
|
+
// created_at, and the seeds it leaves equal (fresh 'log' seeds, and seeds
|
|
32594
|
+
// moved to Monitor below, which keep their created_at) match neither test, so
|
|
32595
|
+
// after one pass it finds nothing and stays a read. What it cannot tell apart
|
|
32596
|
+
// is an earlier build's choice that equals the seed value AND was made within
|
|
32597
|
+
// the seed batch window; that row is read as a seed.
|
|
32598
|
+
markEarlierChoices() {
|
|
32599
|
+
const rows = allRows(
|
|
32600
|
+
this.db.prepare(
|
|
32601
|
+
`SELECT id, json_extract(target, '$.category') AS category, action,
|
|
32602
|
+
created_at AS c, updated_at AS u
|
|
32603
|
+
FROM policies
|
|
32604
|
+
WHERE scope = 'global' AND json_extract(target, '$.category') IS NOT NULL`
|
|
32605
|
+
)
|
|
32606
|
+
);
|
|
32607
|
+
if (rows.length === 0) return;
|
|
32608
|
+
const seedBatchStart = Math.min(...rows.map((row) => row.c));
|
|
32609
|
+
const seeded = DEFAULT_ACTIONS;
|
|
32610
|
+
const choices = rows.filter(
|
|
32611
|
+
(row) => row.u === row.c && (row.action !== "log" && row.action !== seeded[row.category] || row.c > seedBatchStart + SEED_BATCH_WINDOW_MS)
|
|
32612
|
+
);
|
|
32613
|
+
if (choices.length === 0) return;
|
|
32614
|
+
const stmt = this.db.prepare(
|
|
32615
|
+
`UPDATE policies SET updated_at = created_at + 1 WHERE id = :id AND updated_at = created_at`
|
|
32616
|
+
);
|
|
32617
|
+
failOpenTransaction(this.db, () => {
|
|
32618
|
+
for (const row of choices) stmt.run({ id: row.id });
|
|
32619
|
+
});
|
|
32620
|
+
}
|
|
32621
|
+
// Stores seeded by an earlier build hold DEFAULT_ACTIONS in their category
|
|
32622
|
+
// rows. Those rows used to be shadowed by the Monitor every unassigned pack
|
|
32623
|
+
// emitted; now that unassigned packs defer to them, an untouched one would
|
|
32624
|
+
// turn Monitor into Warn on upgrade with nobody having asked. So a row still
|
|
32625
|
+
// exactly as seeded — the seeded action, never updated since it was created —
|
|
32626
|
+
// is moved to Monitor. A row the user, the setup wizard or the warn-era cap
|
|
32627
|
+
// ever wrote has a later updated_at and is left alone. updated_at is NOT
|
|
32628
|
+
// advanced, so a moved row still reads as an untouched seed (see
|
|
32629
|
+
// isCategoryChosen); it never matches again because it is no longer off 'log'.
|
|
32630
|
+
// One knock-on: when the installed snapshot is unusable (corrupt rules_json)
|
|
32631
|
+
// the gateway falls back to the bundled packs with no per-rule policies, so
|
|
32632
|
+
// every rule follows these rows. On an upgraded store that fallback now
|
|
32633
|
+
// monitors where the earlier build warned.
|
|
32634
|
+
monitorUntouchedSeeds() {
|
|
32635
|
+
const untouched = allRows(
|
|
32636
|
+
this.db.prepare(
|
|
32637
|
+
`SELECT json_extract(target, '$.category') AS category, action FROM policies
|
|
32638
|
+
WHERE scope = 'global' AND json_extract(target, '$.category') IS NOT NULL
|
|
32639
|
+
AND action <> 'log' AND updated_at = created_at`
|
|
32640
|
+
)
|
|
32641
|
+
).filter(
|
|
32642
|
+
(row) => DEFAULT_ACTIONS[row.category] === row.action
|
|
32643
|
+
);
|
|
32644
|
+
if (untouched.length === 0) return;
|
|
32645
|
+
const stmt = this.db.prepare(
|
|
32646
|
+
`UPDATE policies SET action = 'log'
|
|
32647
|
+
WHERE scope = 'global' AND json_extract(target, '$.category') = :category
|
|
32648
|
+
AND action = :seeded AND action <> 'log' AND updated_at = created_at`
|
|
32649
|
+
);
|
|
32650
|
+
failOpenTransaction(this.db, () => {
|
|
32651
|
+
for (const row of untouched) {
|
|
32652
|
+
stmt.run({ category: row.category, seeded: row.action });
|
|
32653
|
+
}
|
|
32654
|
+
});
|
|
32655
|
+
}
|
|
32086
32656
|
// Insert-or-update the single global per-category policy row, keyed on the
|
|
32087
32657
|
// existing uq_policies_scope_target unique index (scope, target). `action`
|
|
32088
32658
|
// uses the SAME vocabulary seedDefaults writes (DEFAULT_ACTIONS' ActionTaken
|
|
32089
32659
|
// values), so the runtime's resolveAction reads rows written by either path
|
|
32090
32660
|
// identically. On conflict, `action`, `enabled`, and `updated_at` are updated;
|
|
32091
|
-
// `id` and `created_at` are left exactly as they were.
|
|
32661
|
+
// `id` and `created_at` are left exactly as they were. Either way updated_at
|
|
32662
|
+
// ends up later than created_at, which is what marks the row as chosen.
|
|
32092
32663
|
upsertCategoryAction(category, action) {
|
|
32093
32664
|
const now = Date.now();
|
|
32094
32665
|
this.db.prepare(
|
|
32095
32666
|
`INSERT INTO policies (id, scope, target, action, enabled, created_at, updated_at)
|
|
32096
|
-
VALUES (:id, 'global', :target, :action, 1, :now, :now)
|
|
32097
|
-
ON CONFLICT(scope, target) DO UPDATE SET action = excluded.action, enabled = 1,
|
|
32667
|
+
VALUES (:id, 'global', :target, :action, 1, :now, :now + 1)
|
|
32668
|
+
ON CONFLICT(scope, target) DO UPDATE SET action = excluded.action, enabled = 1,
|
|
32669
|
+
updated_at = MAX(excluded.updated_at, policies.created_at + 1)`
|
|
32098
32670
|
).run({ id: randomUUID6(), target: JSON.stringify({ category }), action, now });
|
|
32099
32671
|
}
|
|
32100
32672
|
// Caps every global per-category policy currently set to block/redact down
|
|
@@ -32108,6 +32680,16 @@ var SqlitePoliciesRepository = class {
|
|
|
32108
32680
|
).run({ now: Date.now() });
|
|
32109
32681
|
return Number(info.changes);
|
|
32110
32682
|
}
|
|
32683
|
+
// Whether the category's row was ever written after it was created — by the
|
|
32684
|
+
// user, the setup wizard or a cap. A row still as seeded (updated_at equal to
|
|
32685
|
+
// created_at) is not a choice, so a posture filling gaps may replace it.
|
|
32686
|
+
isCategoryChosen(category) {
|
|
32687
|
+
const row = this.db.prepare(
|
|
32688
|
+
`SELECT created_at AS c, updated_at AS u FROM policies
|
|
32689
|
+
WHERE scope='global' AND json_extract(target,'$.category') = :category`
|
|
32690
|
+
).get({ category });
|
|
32691
|
+
return row !== void 0 && row.u !== row.c;
|
|
32692
|
+
}
|
|
32111
32693
|
// Read the current action for a single global per-category policy row, mirroring
|
|
32112
32694
|
// upsertCategoryAction's category-lookup predicate. Returns undefined when no
|
|
32113
32695
|
// row exists yet, so callers can distinguish an unset category from a set one.
|
|
@@ -34353,6 +34935,11 @@ var UNSAFE_TEST_ONLY_RAW_HANDLE = /* @__PURE__ */ Symbol(
|
|
|
34353
34935
|
function linkHost(input2, hostId) {
|
|
34354
34936
|
return hostId ? { ...input2, hostId } : input2;
|
|
34355
34937
|
}
|
|
34938
|
+
function captureAttributesOf(event, scopeKey) {
|
|
34939
|
+
const attributes = toCaptureAttributes(event);
|
|
34940
|
+
if (scopeKey === void 0 || scopeKey === "") return attributes;
|
|
34941
|
+
return { ...attributes, scope_key: scopeKey };
|
|
34942
|
+
}
|
|
34356
34943
|
function closeQuietly(db) {
|
|
34357
34944
|
try {
|
|
34358
34945
|
db.close();
|
|
@@ -34538,7 +35125,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
34538
35125
|
);
|
|
34539
35126
|
return dismissed;
|
|
34540
35127
|
}
|
|
34541
|
-
function recordCapture(event, detected) {
|
|
35128
|
+
function recordCapture(event, detected, scopeKey) {
|
|
34542
35129
|
failOpenTransaction(db, () => {
|
|
34543
35130
|
const sessionId = event.metadata?.sessionId;
|
|
34544
35131
|
if (sessionId) {
|
|
@@ -34553,7 +35140,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
34553
35140
|
rootSessionId: sessionId,
|
|
34554
35141
|
content: event.content,
|
|
34555
35142
|
contentHash: event.contentHash,
|
|
34556
|
-
attributes:
|
|
35143
|
+
attributes: captureAttributesOf(event, scopeKey)
|
|
34557
35144
|
});
|
|
34558
35145
|
const definitionIds = /* @__PURE__ */ new Map();
|
|
34559
35146
|
for (const finding of detected) {
|
|
@@ -34583,7 +35170,12 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
34583
35170
|
maskedMatch: finding.maskedMatch,
|
|
34584
35171
|
actionTaken: finding.actionTaken,
|
|
34585
35172
|
confidence: finding.confidence,
|
|
34586
|
-
findingKey: finding.findingKey ?? void 0
|
|
35173
|
+
findingKey: finding.findingKey ?? void 0,
|
|
35174
|
+
...finding.location === void 0 ? {} : {
|
|
35175
|
+
line: finding.location.line,
|
|
35176
|
+
col: finding.location.col,
|
|
35177
|
+
context: finding.location.context
|
|
35178
|
+
}
|
|
34587
35179
|
});
|
|
34588
35180
|
}
|
|
34589
35181
|
});
|
|
@@ -34746,6 +35338,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
34746
35338
|
// ../../packages/persistence/src/egress-wire.ts
|
|
34747
35339
|
import { createHash as createHash3 } from "crypto";
|
|
34748
35340
|
var SLASH = "/".charCodeAt(0);
|
|
35341
|
+
var SCOPE_KEY = printable(ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH);
|
|
34749
35342
|
|
|
34750
35343
|
// ../../packages/persistence/src/finding-key.ts
|
|
34751
35344
|
import { createHash as createHash4 } from "crypto";
|
|
@@ -35199,9 +35792,9 @@ import { readFileSync as readFileSync10 } from "fs";
|
|
|
35199
35792
|
import { join as join16 } from "path";
|
|
35200
35793
|
|
|
35201
35794
|
// ../../packages/plugin-runtime/src/attached/forward-policy.ts
|
|
35202
|
-
import { randomUUID as
|
|
35795
|
+
import { randomUUID as randomUUID16 } from "crypto";
|
|
35203
35796
|
import { readFile, rename, writeFile } from "fs/promises";
|
|
35204
|
-
import { join as
|
|
35797
|
+
import { join as join28 } from "path";
|
|
35205
35798
|
|
|
35206
35799
|
// ../../packages/plugin-sdk/src/config.ts
|
|
35207
35800
|
import { existsSync as existsSync8 } from "fs";
|
|
@@ -36066,6 +36659,7 @@ var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
|
|
|
36066
36659
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
36067
36660
|
import { existsSync as existsSync9, readFileSync as readFileSync11, statSync as statSync6 } from "fs";
|
|
36068
36661
|
import { basename as basename2, dirname as dirname4, isAbsolute, join as join18, sep as sep2 } from "path";
|
|
36662
|
+
var NO_ATTRIBUTION = Object.freeze({});
|
|
36069
36663
|
|
|
36070
36664
|
// ../../packages/plugin-sdk/src/events.ts
|
|
36071
36665
|
import { createHash as createHash5, randomUUID as randomUUID13 } from "crypto";
|
|
@@ -36140,6 +36734,9 @@ import { join as join24 } from "path";
|
|
|
36140
36734
|
import { readdirSync as readdirSync3, realpathSync as realpathSync3 } from "fs";
|
|
36141
36735
|
import { basename as basename4, dirname as dirname5, sep as sep3 } from "path";
|
|
36142
36736
|
|
|
36737
|
+
// ../../packages/plugin-sdk/src/policy-resolver.ts
|
|
36738
|
+
import { randomUUID as randomUUID14 } from "crypto";
|
|
36739
|
+
|
|
36143
36740
|
// ../../packages/plugin-sdk/src/project-files.ts
|
|
36144
36741
|
import { existsSync as existsSync11, readdirSync as readdirSync4 } from "fs";
|
|
36145
36742
|
import { basename as basename5, join as join25 } from "path";
|
|
@@ -36171,14 +36768,30 @@ var codexProviderEnvShape = {
|
|
|
36171
36768
|
var CodexProviderEnvSchema = external_exports.object(codexProviderEnvShape);
|
|
36172
36769
|
|
|
36173
36770
|
// ../../packages/plugin-sdk/src/runtime.ts
|
|
36174
|
-
import { randomUUID as
|
|
36771
|
+
import { randomUUID as randomUUID15 } from "crypto";
|
|
36772
|
+
|
|
36773
|
+
// ../../packages/plugin-sdk/src/scope-key.ts
|
|
36774
|
+
import { existsSync as existsSync12 } from "fs";
|
|
36775
|
+
import { dirname as dirname6, isAbsolute as isAbsolute2, join as join26, normalize } from "path";
|
|
36175
36776
|
|
|
36176
36777
|
// ../../packages/plugin-sdk/src/suppressions.ts
|
|
36177
36778
|
var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
36178
36779
|
|
|
36179
36780
|
// ../../packages/plugin-sdk/src/throttle.ts
|
|
36180
36781
|
import { mkdirSync as mkdirSync4, statSync as statSync8, writeFileSync as writeFileSync7 } from "fs";
|
|
36181
|
-
import { join as
|
|
36782
|
+
import { join as join27 } from "path";
|
|
36783
|
+
|
|
36784
|
+
// ../../packages/plugin-runtime/src/attached/scope-strip.ts
|
|
36785
|
+
function withoutScopeKey(event) {
|
|
36786
|
+
const attributes = event.attributes;
|
|
36787
|
+
if (attributes == null || !Object.hasOwn(attributes, "scope_key")) return event;
|
|
36788
|
+
const rest = { ...attributes };
|
|
36789
|
+
delete rest.scope_key;
|
|
36790
|
+
if (Object.keys(rest).length > 0) return { ...event, attributes: rest };
|
|
36791
|
+
const bare = { ...event };
|
|
36792
|
+
delete bare.attributes;
|
|
36793
|
+
return bare;
|
|
36794
|
+
}
|
|
36182
36795
|
|
|
36183
36796
|
// ../../packages/plugin-runtime/src/attached/history-sync.ts
|
|
36184
36797
|
import { createHash as createHash6 } from "crypto";
|
|
@@ -36347,7 +36960,10 @@ function attributesOf(raw) {
|
|
|
36347
36960
|
try {
|
|
36348
36961
|
const parsed2 = JSON.parse(raw);
|
|
36349
36962
|
if (typeof parsed2 !== "object" || parsed2 === null || Array.isArray(parsed2)) return {};
|
|
36350
|
-
|
|
36963
|
+
const bag = {
|
|
36964
|
+
attributes: parsed2
|
|
36965
|
+
};
|
|
36966
|
+
return withoutScopeKey(bag);
|
|
36351
36967
|
} catch {
|
|
36352
36968
|
return {};
|
|
36353
36969
|
}
|
|
@@ -36852,16 +37468,16 @@ var HISTORY_SYNC_THROTTLE_MS = 5 * 60 * 1e3;
|
|
|
36852
37468
|
|
|
36853
37469
|
// ../../packages/plugin-runtime/src/attached/install-record.ts
|
|
36854
37470
|
import { readFile as readFile2, stat } from "fs/promises";
|
|
36855
|
-
import { basename as basename6, dirname as
|
|
37471
|
+
import { basename as basename6, dirname as dirname7, join as join29, resolve as resolve2 } from "path";
|
|
36856
37472
|
|
|
36857
37473
|
// ../../packages/plugin-runtime/src/attached/plugin-block.ts
|
|
36858
37474
|
import { readFileSync as readFileSync18 } from "fs";
|
|
36859
37475
|
var INSTALL_RECORD_READ_TIMEOUT_MS = REQUEST_TIMEOUT_MS / 2;
|
|
36860
37476
|
|
|
36861
37477
|
// ../../packages/plugin-runtime/src/attached/policy-store.ts
|
|
36862
|
-
import { randomUUID as
|
|
37478
|
+
import { randomUUID as randomUUID17 } from "crypto";
|
|
36863
37479
|
import { readFile as readFile3, rm, writeFile as writeFile2 } from "fs/promises";
|
|
36864
|
-
import { join as
|
|
37480
|
+
import { join as join30 } from "path";
|
|
36865
37481
|
|
|
36866
37482
|
// ../../packages/plugin-runtime/src/attached/atomic-publish.ts
|
|
36867
37483
|
import { rename as rename2 } from "fs/promises";
|
|
@@ -36871,7 +37487,7 @@ var ATTEMPTS = 1 + IMMEDIATE_RETRIES + TIMED_RETRIES;
|
|
|
36871
37487
|
|
|
36872
37488
|
// ../../packages/plugin-runtime/src/attached/posture-report-state.ts
|
|
36873
37489
|
import { readFileSync as readFileSync19 } from "fs";
|
|
36874
|
-
import { join as
|
|
37490
|
+
import { join as join31 } from "path";
|
|
36875
37491
|
var OUTCOME_KEYS = {
|
|
36876
37492
|
ok: true,
|
|
36877
37493
|
unauthorized: true,
|
|
@@ -36892,13 +37508,13 @@ import { statSync as statSync9 } from "fs";
|
|
|
36892
37508
|
import { DatabaseSync as DatabaseSync4 } from "node:sqlite";
|
|
36893
37509
|
|
|
36894
37510
|
// ../../packages/plugin-runtime/src/attached/posture-store.ts
|
|
36895
|
-
import { randomUUID as
|
|
37511
|
+
import { randomUUID as randomUUID18 } from "crypto";
|
|
36896
37512
|
import { readFile as readFile4, rm as rm2, writeFile as writeFile3 } from "fs/promises";
|
|
36897
|
-
import { join as
|
|
37513
|
+
import { join as join32 } from "path";
|
|
36898
37514
|
|
|
36899
37515
|
// ../../packages/plugin-runtime/src/attached/sync-state.ts
|
|
36900
37516
|
import { readFileSync as readFileSync20 } from "fs";
|
|
36901
|
-
import { join as
|
|
37517
|
+
import { join as join33 } from "path";
|
|
36902
37518
|
|
|
36903
37519
|
// ../../packages/plugin-runtime/src/attached/status.ts
|
|
36904
37520
|
var REFUSAL_LINES = {
|
|
@@ -36930,9 +37546,6 @@ var CONTENT_RETENTION_THROTTLE_MS = 60 * 60 * 1e3;
|
|
|
36930
37546
|
// ../../packages/plugin-runtime/src/attached/factory.ts
|
|
36931
37547
|
import { hostname as hostname6 } from "os";
|
|
36932
37548
|
|
|
36933
|
-
// ../../packages/plugin-runtime/src/standalone-gateway.ts
|
|
36934
|
-
import { randomUUID as randomUUID18 } from "crypto";
|
|
36935
|
-
|
|
36936
37549
|
// ../../packages/plugin-runtime/src/handle-session-start.ts
|
|
36937
37550
|
import { randomUUID as randomUUID19 } from "crypto";
|
|
36938
37551
|
var EXCEPTION_RETENTION_MS = 90 * 24 * 60 * 60 * 1e3;
|