@akasecurity/ai-tc-claude-code 0.9.7 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +2 -2
- package/package.json +4 -4
- package/scripts/apply-suppressions.js +283 -132
- package/scripts/backfill.js +1711 -250
- package/scripts/filescan.js +1713 -235
- package/scripts/firstrun.js +1724 -206
- package/scripts/intro.js +171 -47
- package/scripts/message-display.js +279 -128
- package/scripts/onboard.js +261 -110
- package/scripts/post-tool-use.js +1842 -272
- package/scripts/pre-tool-use.js +1841 -284
- package/scripts/query.js +1726 -208
- package/scripts/reconcile.js +1698 -237
- package/scripts/remediate.js +1704 -243
- package/scripts/scan-worker.js +118 -0
- package/scripts/session-start.js +1951 -299
- package/scripts/start-light.js +169 -45
- package/scripts/statusline.js +1726 -206
- package/scripts/stop.js +374 -67
- package/scripts/sync.js +19413 -0
- package/scripts/user-prompt-submit.js +1841 -284
package/scripts/onboard.js
CHANGED
|
@@ -491,10 +491,9 @@ var require_ignore = __commonJS({
|
|
|
491
491
|
}
|
|
492
492
|
});
|
|
493
493
|
|
|
494
|
-
// ../../packages/persistence/src/
|
|
495
|
-
import {
|
|
496
|
-
import { join
|
|
497
|
-
import { DatabaseSync } from "node:sqlite";
|
|
494
|
+
// ../../packages/persistence/src/control-plane-credential.ts
|
|
495
|
+
import { chmodSync as chmodSync2, lstatSync as lstatSync2, readFileSync, rmSync as rmSync2, statSync } from "fs";
|
|
496
|
+
import { join } from "path";
|
|
498
497
|
|
|
499
498
|
// ../../packages/schema/src/drizzle/sqlite-ddl.ts
|
|
500
499
|
var SQLITE_MIGRATIONS = [
|
|
@@ -16198,6 +16197,124 @@ var ConfigScanRecord = external_exports.object({
|
|
|
16198
16197
|
findings: external_exports.array(ConfigPostureFindingInput).optional()
|
|
16199
16198
|
});
|
|
16200
16199
|
|
|
16200
|
+
// ../../packages/schema/src/zod/control-plane.ts
|
|
16201
|
+
var ATTACHED_CREDENTIAL_SPEC_VERSION = 1;
|
|
16202
|
+
var AttachedCredential = external_exports.object({
|
|
16203
|
+
specVersion: external_exports.literal(ATTACHED_CREDENTIAL_SPEC_VERSION),
|
|
16204
|
+
// The control-plane endpoint this credential was minted against.
|
|
16205
|
+
endpoint: external_exports.string().min(1),
|
|
16206
|
+
// The bearer credential itself. Never logged, never rendered — status
|
|
16207
|
+
// surfaces show `keyPrefix` and nothing else.
|
|
16208
|
+
apiKey: external_exports.string().min(1),
|
|
16209
|
+
// First few characters of the key, safe to display so a user can match the
|
|
16210
|
+
// credential against their organization's key list.
|
|
16211
|
+
keyPrefix: external_exports.string().min(1).max(16).optional(),
|
|
16212
|
+
mintedAt: external_exports.iso.datetime().optional()
|
|
16213
|
+
});
|
|
16214
|
+
var MAX_DATE_MS = 253402300799999;
|
|
16215
|
+
var MAX_INT4 = 2147483647;
|
|
16216
|
+
var StorePosturePack = external_exports.object({
|
|
16217
|
+
packId: external_exports.string().min(1),
|
|
16218
|
+
// 'namespace/packId'
|
|
16219
|
+
version: external_exports.string().min(1),
|
|
16220
|
+
enabled: external_exports.boolean(),
|
|
16221
|
+
// Stringified pass-through of the local store's `installed_packs.updated_at`
|
|
16222
|
+
// — the column format is store-version-dependent (epoch millis vs ISO), so
|
|
16223
|
+
// the wire shape assumes neither.
|
|
16224
|
+
updatedAt: external_exports.string().nullable()
|
|
16225
|
+
}).meta({ id: "StorePosturePack" });
|
|
16226
|
+
var StorePosturePolicyCounts = external_exports.object({
|
|
16227
|
+
total: external_exports.number().int().min(0),
|
|
16228
|
+
disabled: external_exports.number().int().min(0),
|
|
16229
|
+
// Exhaustive per-action map; the builder pre-fills every action with 0.
|
|
16230
|
+
//
|
|
16231
|
+
// Spelled out member-by-member rather than `z.record(ActionTaken, …)`. Zod
|
|
16232
|
+
// enforces exhaustiveness either way, but z.record emits `propertyNames` +
|
|
16233
|
+
// `additionalProperties` into a generated schema document, and a type
|
|
16234
|
+
// generator renders THAT with every key optional — a sender built against
|
|
16235
|
+
// the generated type would typecheck and still be rejected at runtime. An
|
|
16236
|
+
// explicit object emits `properties` + `required`, so generated types
|
|
16237
|
+
// demand all five.
|
|
16238
|
+
//
|
|
16239
|
+
// `satisfies Record<ActionTaken, …>` keeps the link to the enum: adding an
|
|
16240
|
+
// ActionTaken member is a COMPILE error here instead of silent drift.
|
|
16241
|
+
// `.strict()` is load-bearing — it rejects an unknown action key, which a
|
|
16242
|
+
// bare object would silently STRIP, accepting a miscounted map as valid.
|
|
16243
|
+
byAction: external_exports.object({
|
|
16244
|
+
warn: external_exports.number().int().min(0),
|
|
16245
|
+
redact: external_exports.number().int().min(0),
|
|
16246
|
+
block: external_exports.number().int().min(0),
|
|
16247
|
+
allow: external_exports.number().int().min(0),
|
|
16248
|
+
log: external_exports.number().int().min(0)
|
|
16249
|
+
}).strict()
|
|
16250
|
+
}).meta({ id: "StorePosturePolicyCounts" });
|
|
16251
|
+
var StorePosturePlugin = external_exports.object({
|
|
16252
|
+
/** Package name of the reporting plugin. */
|
|
16253
|
+
package: external_exports.string().min(1).max(200),
|
|
16254
|
+
version: external_exports.string().min(1).max(64),
|
|
16255
|
+
/** Version of the bundled core, when the build records one separately. */
|
|
16256
|
+
ossVersion: external_exports.string().max(64).nullable(),
|
|
16257
|
+
/**
|
|
16258
|
+
* `version` of the policy bundle this machine last fetched. Bounded at 200
|
|
16259
|
+
* rather than the 64 a bare sha256 hex digest needs today, so a later
|
|
16260
|
+
* format with an algorithm prefix does not start rejecting the channel.
|
|
16261
|
+
*/
|
|
16262
|
+
policyBundleVersion: external_exports.string().max(200).nullable(),
|
|
16263
|
+
/** Epoch millis, on the CLIENT clock, of that fetch. */
|
|
16264
|
+
policyFetchedAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable()
|
|
16265
|
+
}).meta({ id: "StorePosturePlugin" });
|
|
16266
|
+
var StorePostureSnapshot = external_exports.object({
|
|
16267
|
+
deviceId: external_exports.guid(),
|
|
16268
|
+
hostname: external_exports.string().min(1).max(253),
|
|
16269
|
+
// Epoch millis on the CLIENT clock. Bounded by what a receiving store
|
|
16270
|
+
// accepts (see MAX_DATE_MS), not by what a JavaScript Date can hold.
|
|
16271
|
+
capturedAt: external_exports.number().int().min(0).max(MAX_DATE_MS),
|
|
16272
|
+
// False is a measurement, not an error state: "no local store exists on
|
|
16273
|
+
// this machine".
|
|
16274
|
+
storePresent: external_exports.boolean(),
|
|
16275
|
+
schemaVersion: external_exports.number().int().min(0).max(MAX_INT4).nullable(),
|
|
16276
|
+
// PRAGMA user_version
|
|
16277
|
+
findingsTotal: external_exports.number().int().min(0).max(MAX_INT4),
|
|
16278
|
+
// Epoch millis, bounded like `capturedAt` — see MAX_DATE_MS on what that
|
|
16279
|
+
// bound does and does not do. Worth stating for these two specifically:
|
|
16280
|
+
// they are read from the local store's own ROWS rather than from this
|
|
16281
|
+
// machine's clock, so a damaged or hand-edited store is enough to produce
|
|
16282
|
+
// an out-of-range value with no clock skew involved.
|
|
16283
|
+
findingsFirstAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable(),
|
|
16284
|
+
findingsLastAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable(),
|
|
16285
|
+
packs: external_exports.array(StorePosturePack).max(500),
|
|
16286
|
+
policyCounts: StorePosturePolicyCounts,
|
|
16287
|
+
// OPTIONAL, not nullable: a reporter that predates this member keeps
|
|
16288
|
+
// getting its 200 without a payload change.
|
|
16289
|
+
plugin: StorePosturePlugin.optional()
|
|
16290
|
+
}).meta({ id: "StorePostureSnapshot" });
|
|
16291
|
+
var CAPTURE_VERSION_PREFIX = "capture/";
|
|
16292
|
+
var RecordAuditEventRequest = AuditEventInput.extend({
|
|
16293
|
+
inspections: external_exports.array(ToolCallInspection).default([])
|
|
16294
|
+
}).refine((v) => v.inspections.every((i) => !i.ruleVersion.startsWith(CAPTURE_VERSION_PREFIX)), {
|
|
16295
|
+
message: `inspections[].ruleVersion must not start with \`${CAPTURE_VERSION_PREFIX}\` \u2014 that namespace is reserved for capture definitions the control plane mints itself`,
|
|
16296
|
+
path: ["inspections"]
|
|
16297
|
+
}).meta({ id: "RecordAuditEventRequest" });
|
|
16298
|
+
var IngestAck = external_exports.object({
|
|
16299
|
+
accepted: external_exports.number().int().nonnegative(),
|
|
16300
|
+
duplicates: external_exports.number().int().nonnegative()
|
|
16301
|
+
});
|
|
16302
|
+
var PRINTABLE = /^[^\p{Cc}\p{Cf}]*$/u;
|
|
16303
|
+
var printable = (max) => external_exports.string().max(max).regex(PRINTABLE, "must not contain control characters");
|
|
16304
|
+
var PluginWhoami = external_exports.object({
|
|
16305
|
+
tenantName: printable(200),
|
|
16306
|
+
userEmail: printable(320),
|
|
16307
|
+
role: printable(64),
|
|
16308
|
+
keyKind: printable(64),
|
|
16309
|
+
serverTime: printable(64)
|
|
16310
|
+
});
|
|
16311
|
+
var ControlPlaneErrorBody = external_exports.object({
|
|
16312
|
+
error: external_exports.object({
|
|
16313
|
+
code: external_exports.string().optional(),
|
|
16314
|
+
message: external_exports.string().optional()
|
|
16315
|
+
}).optional()
|
|
16316
|
+
});
|
|
16317
|
+
|
|
16201
16318
|
// ../../packages/schema/src/zod/registry.ts
|
|
16202
16319
|
var Namespace = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
16203
16320
|
var PackId = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
@@ -18517,42 +18634,6 @@ function reviewSeverityRank(reasons) {
|
|
|
18517
18634
|
return Math.min(...reasons.map((r) => REVIEW_SEVERITY_RANK[r]));
|
|
18518
18635
|
}
|
|
18519
18636
|
|
|
18520
|
-
// ../../packages/persistence/src/ids.ts
|
|
18521
|
-
import { createHash } from "crypto";
|
|
18522
|
-
function sha256Hex(input) {
|
|
18523
|
-
return createHash("sha256").update(input).digest("hex");
|
|
18524
|
-
}
|
|
18525
|
-
function inventoryId(objectType, identityKey) {
|
|
18526
|
-
return sha256Hex(canonicalIdentity(["inventory", objectType, identityKey]));
|
|
18527
|
-
}
|
|
18528
|
-
function sourceProjectId(url2) {
|
|
18529
|
-
return sha256Hex(canonicalIdentity(["source_project", url2]));
|
|
18530
|
-
}
|
|
18531
|
-
function classifiedDataId(cls) {
|
|
18532
|
-
return sha256Hex(canonicalIdentity(["classified_data", cls]));
|
|
18533
|
-
}
|
|
18534
|
-
function inspectionDefinitionId(ruleId, version2) {
|
|
18535
|
-
return sha256Hex(canonicalIdentity(["inspection_definition", ruleId, version2]));
|
|
18536
|
-
}
|
|
18537
|
-
function llmCallId(sessionId, messageId) {
|
|
18538
|
-
return sha256Hex(canonicalIdentity(["audit_event_llm_call", sessionId, messageId]));
|
|
18539
|
-
}
|
|
18540
|
-
function toolCallId(sessionId, toolUseId) {
|
|
18541
|
-
return sha256Hex(canonicalIdentity(["audit_event_tool_call", sessionId, toolUseId]));
|
|
18542
|
-
}
|
|
18543
|
-
var NO_SESSION = "no_session";
|
|
18544
|
-
var NO_PATH = "no_path";
|
|
18545
|
-
function captureId(sessionId, contentHash, filePath = null) {
|
|
18546
|
-
return sha256Hex(
|
|
18547
|
-
canonicalIdentity(["capture", sessionId ?? NO_SESSION, contentHash, filePath ?? NO_PATH])
|
|
18548
|
-
);
|
|
18549
|
-
}
|
|
18550
|
-
|
|
18551
|
-
// ../../packages/persistence/src/internal/snapshot.ts
|
|
18552
|
-
import { randomUUID } from "crypto";
|
|
18553
|
-
import { existsSync, readdirSync, renameSync as renameSync2, rmSync as rmSync2, statSync } from "fs";
|
|
18554
|
-
import { basename, dirname, join } from "path";
|
|
18555
|
-
|
|
18556
18637
|
// ../../packages/persistence/src/paths.ts
|
|
18557
18638
|
import {
|
|
18558
18639
|
chmodSync,
|
|
@@ -18621,7 +18702,46 @@ function writeOwnerOnlyFileSync(file2, data) {
|
|
|
18621
18702
|
tightenFile(file2);
|
|
18622
18703
|
}
|
|
18623
18704
|
|
|
18705
|
+
// ../../packages/persistence/src/database.ts
|
|
18706
|
+
import { randomUUID as randomUUID10 } from "crypto";
|
|
18707
|
+
import { join as join3, sep } from "path";
|
|
18708
|
+
import { DatabaseSync } from "node:sqlite";
|
|
18709
|
+
|
|
18710
|
+
// ../../packages/persistence/src/ids.ts
|
|
18711
|
+
import { createHash } from "crypto";
|
|
18712
|
+
function sha256Hex(input) {
|
|
18713
|
+
return createHash("sha256").update(input).digest("hex");
|
|
18714
|
+
}
|
|
18715
|
+
function inventoryId(objectType, identityKey) {
|
|
18716
|
+
return sha256Hex(canonicalIdentity(["inventory", objectType, identityKey]));
|
|
18717
|
+
}
|
|
18718
|
+
function sourceProjectId(url2) {
|
|
18719
|
+
return sha256Hex(canonicalIdentity(["source_project", url2]));
|
|
18720
|
+
}
|
|
18721
|
+
function classifiedDataId(cls) {
|
|
18722
|
+
return sha256Hex(canonicalIdentity(["classified_data", cls]));
|
|
18723
|
+
}
|
|
18724
|
+
function inspectionDefinitionId(ruleId, version2) {
|
|
18725
|
+
return sha256Hex(canonicalIdentity(["inspection_definition", ruleId, version2]));
|
|
18726
|
+
}
|
|
18727
|
+
function llmCallId(sessionId, messageId) {
|
|
18728
|
+
return sha256Hex(canonicalIdentity(["audit_event_llm_call", sessionId, messageId]));
|
|
18729
|
+
}
|
|
18730
|
+
function toolCallId(sessionId, toolUseId) {
|
|
18731
|
+
return sha256Hex(canonicalIdentity(["audit_event_tool_call", sessionId, toolUseId]));
|
|
18732
|
+
}
|
|
18733
|
+
var NO_SESSION = "no_session";
|
|
18734
|
+
var NO_PATH = "no_path";
|
|
18735
|
+
function captureId(sessionId, contentHash, filePath = null) {
|
|
18736
|
+
return sha256Hex(
|
|
18737
|
+
canonicalIdentity(["capture", sessionId ?? NO_SESSION, contentHash, filePath ?? NO_PATH])
|
|
18738
|
+
);
|
|
18739
|
+
}
|
|
18740
|
+
|
|
18624
18741
|
// ../../packages/persistence/src/internal/snapshot.ts
|
|
18742
|
+
import { randomUUID } from "crypto";
|
|
18743
|
+
import { existsSync, readdirSync, renameSync as renameSync2, rmSync as rmSync3, statSync as statSync2 } from "fs";
|
|
18744
|
+
import { basename, dirname, join as join2 } from "path";
|
|
18625
18745
|
function backupPath(file2, tag) {
|
|
18626
18746
|
return `${file2}.${tag}.${String(Date.now())}.${randomUUID().slice(0, 8)}.bak`;
|
|
18627
18747
|
}
|
|
@@ -18631,15 +18751,15 @@ var STAGED_NAME_SUFFIX = `.bak${SNAPSHOT_STAGING_SUFFIX}`;
|
|
|
18631
18751
|
var SNAPSHOT_STAGING_COPY = "copy";
|
|
18632
18752
|
function createSnapshotStaging(backup) {
|
|
18633
18753
|
const stage = `${backup}${SNAPSHOT_STAGING_SUFFIX}`;
|
|
18634
|
-
|
|
18754
|
+
rmSync3(stage, { recursive: true, force: true });
|
|
18635
18755
|
mkdirOwnerOnlySync(stage);
|
|
18636
18756
|
tightenDir(stage);
|
|
18637
|
-
return { stage, copy:
|
|
18757
|
+
return { stage, copy: join2(stage, SNAPSHOT_STAGING_COPY) };
|
|
18638
18758
|
}
|
|
18639
18759
|
function idleMs(entry) {
|
|
18640
|
-
for (const candidate of [
|
|
18760
|
+
for (const candidate of [join2(entry, SNAPSHOT_STAGING_COPY), entry]) {
|
|
18641
18761
|
try {
|
|
18642
|
-
return Date.now() -
|
|
18762
|
+
return Date.now() - statSync2(candidate).mtimeMs;
|
|
18643
18763
|
} catch {
|
|
18644
18764
|
}
|
|
18645
18765
|
}
|
|
@@ -18656,11 +18776,11 @@ function reapStalePartials(file2) {
|
|
|
18656
18776
|
}
|
|
18657
18777
|
for (const name of entries) {
|
|
18658
18778
|
if (!name.startsWith(prefix) || !name.endsWith(STAGED_NAME_SUFFIX)) continue;
|
|
18659
|
-
const staging =
|
|
18779
|
+
const staging = join2(dir, name);
|
|
18660
18780
|
try {
|
|
18661
18781
|
const idle = idleMs(staging);
|
|
18662
18782
|
if (idle !== null && idle > STALE_PARTIAL_MS) {
|
|
18663
|
-
|
|
18783
|
+
rmSync3(staging, { recursive: true, force: true });
|
|
18664
18784
|
}
|
|
18665
18785
|
} catch {
|
|
18666
18786
|
}
|
|
@@ -18674,13 +18794,13 @@ function snapshotStore(db, backup) {
|
|
|
18674
18794
|
renameSync2(copy, backup);
|
|
18675
18795
|
} catch (error51) {
|
|
18676
18796
|
try {
|
|
18677
|
-
|
|
18797
|
+
rmSync3(stage, { recursive: true, force: true });
|
|
18678
18798
|
} catch {
|
|
18679
18799
|
}
|
|
18680
18800
|
throw error51;
|
|
18681
18801
|
}
|
|
18682
18802
|
try {
|
|
18683
|
-
|
|
18803
|
+
rmSync3(stage, { recursive: true, force: true });
|
|
18684
18804
|
} catch {
|
|
18685
18805
|
}
|
|
18686
18806
|
}
|
|
@@ -18695,7 +18815,7 @@ function moveStoreAside(file2, backup) {
|
|
|
18695
18815
|
renameSync2(sidecar, moved);
|
|
18696
18816
|
undo.push([moved, sidecar]);
|
|
18697
18817
|
} catch {
|
|
18698
|
-
|
|
18818
|
+
rmSync3(sidecar, { force: true });
|
|
18699
18819
|
}
|
|
18700
18820
|
}
|
|
18701
18821
|
} catch (error51) {
|
|
@@ -18711,14 +18831,14 @@ function moveStoreAside(file2, backup) {
|
|
|
18711
18831
|
}
|
|
18712
18832
|
function discardStore(file2, backup) {
|
|
18713
18833
|
try {
|
|
18714
|
-
|
|
18834
|
+
rmSync3(file2, { force: true });
|
|
18715
18835
|
for (const sidecar of dbSidecars(file2)) {
|
|
18716
|
-
|
|
18836
|
+
rmSync3(sidecar, { force: true });
|
|
18717
18837
|
}
|
|
18718
18838
|
} catch (error51) {
|
|
18719
18839
|
if (existsSync(file2)) {
|
|
18720
18840
|
try {
|
|
18721
|
-
|
|
18841
|
+
rmSync3(backup, { force: true });
|
|
18722
18842
|
} catch {
|
|
18723
18843
|
}
|
|
18724
18844
|
}
|
|
@@ -18950,10 +19070,31 @@ function applyMigrations(db, file2) {
|
|
|
18950
19070
|
if (drained) applyLegacyDropMigration(db, file2);
|
|
18951
19071
|
}
|
|
18952
19072
|
}
|
|
19073
|
+
function readLegacyTables(db) {
|
|
19074
|
+
let holdsRows = false;
|
|
19075
|
+
const marks = [];
|
|
19076
|
+
for (const table2 of ["events", "findings"]) {
|
|
19077
|
+
try {
|
|
19078
|
+
const row = db.prepare(`SELECT count(*) AS n, ifnull(max(rowid), -1) AS hi FROM ${table2}`).get();
|
|
19079
|
+
if (row === void 0) {
|
|
19080
|
+
holdsRows = true;
|
|
19081
|
+
marks.push(`${table2}:unreadable`);
|
|
19082
|
+
continue;
|
|
19083
|
+
}
|
|
19084
|
+
if (row.n > 0) holdsRows = true;
|
|
19085
|
+
marks.push(`${table2}:${String(row.n)}:${String(row.hi)}`);
|
|
19086
|
+
} catch {
|
|
19087
|
+
holdsRows = true;
|
|
19088
|
+
marks.push(`${table2}:unreadable`);
|
|
19089
|
+
}
|
|
19090
|
+
}
|
|
19091
|
+
return { holdsRows, mark: marks.join("|") };
|
|
19092
|
+
}
|
|
18953
19093
|
function applyLegacyDropMigration(db, file2) {
|
|
18954
19094
|
const migration = SQLITE_MIGRATIONS.find((m) => m.tag === LEGACY_DROP_MIGRATION_TAG);
|
|
18955
19095
|
if (!migration) return;
|
|
18956
|
-
|
|
19096
|
+
const before = file2 === void 0 ? void 0 : readLegacyTables(db);
|
|
19097
|
+
if (file2 !== void 0 && before?.holdsRows === true) {
|
|
18957
19098
|
try {
|
|
18958
19099
|
backupBeforeLegacyDrop(db, file2);
|
|
18959
19100
|
} catch (error51) {
|
|
@@ -18967,6 +19108,12 @@ function applyLegacyDropMigration(db, file2) {
|
|
|
18967
19108
|
() => {
|
|
18968
19109
|
const alreadyDropped = db.prepare("SELECT 1 FROM migration_ledger WHERE tag = ?").get(migration.tag);
|
|
18969
19110
|
if (alreadyDropped) return;
|
|
19111
|
+
if (before !== void 0 && readLegacyTables(db).mark !== before.mark) {
|
|
19112
|
+
akaWarn(
|
|
19113
|
+
"legacy events/findings rows changed after the pre-drop snapshot decision; deferring the drop so the next open can copy them first."
|
|
19114
|
+
);
|
|
19115
|
+
return;
|
|
19116
|
+
}
|
|
18970
19117
|
for (const statement of splitStatements(migration.sql)) {
|
|
18971
19118
|
db.exec(statement);
|
|
18972
19119
|
}
|
|
@@ -25188,7 +25335,7 @@ function openAndInitialize(file2) {
|
|
|
25188
25335
|
}
|
|
25189
25336
|
function openLocalDatabase(dir) {
|
|
25190
25337
|
ensureDataDirSync(dir);
|
|
25191
|
-
const file2 =
|
|
25338
|
+
const file2 = join3(dir, DB_FILENAME);
|
|
25192
25339
|
reapStalePartials(file2);
|
|
25193
25340
|
const {
|
|
25194
25341
|
db,
|
|
@@ -25424,9 +25571,9 @@ import {
|
|
|
25424
25571
|
closeSync,
|
|
25425
25572
|
existsSync as existsSync2,
|
|
25426
25573
|
openSync,
|
|
25427
|
-
readFileSync,
|
|
25428
|
-
rmSync as
|
|
25429
|
-
statSync as
|
|
25574
|
+
readFileSync as readFileSync2,
|
|
25575
|
+
rmSync as rmSync4,
|
|
25576
|
+
statSync as statSync3,
|
|
25430
25577
|
writeFileSync as writeFileSync2
|
|
25431
25578
|
} from "fs";
|
|
25432
25579
|
import { hostname as hostname3 } from "os";
|
|
@@ -25460,7 +25607,7 @@ function lockPathFor(file2) {
|
|
|
25460
25607
|
function readLockBody(lock) {
|
|
25461
25608
|
let raw;
|
|
25462
25609
|
try {
|
|
25463
|
-
raw =
|
|
25610
|
+
raw = readFileSync2(lock, "utf8");
|
|
25464
25611
|
} catch {
|
|
25465
25612
|
return null;
|
|
25466
25613
|
}
|
|
@@ -25491,7 +25638,7 @@ function directoryAcceptsCreates(lock) {
|
|
|
25491
25638
|
return false;
|
|
25492
25639
|
} finally {
|
|
25493
25640
|
try {
|
|
25494
|
-
|
|
25641
|
+
rmSync4(probe, { force: true });
|
|
25495
25642
|
} catch {
|
|
25496
25643
|
}
|
|
25497
25644
|
}
|
|
@@ -25524,7 +25671,7 @@ function tryAcquire(lock, file2) {
|
|
|
25524
25671
|
closeSync(fd);
|
|
25525
25672
|
} catch {
|
|
25526
25673
|
}
|
|
25527
|
-
|
|
25674
|
+
rmSync4(lock, { force: true });
|
|
25528
25675
|
return null;
|
|
25529
25676
|
}
|
|
25530
25677
|
try {
|
|
@@ -25536,7 +25683,7 @@ function tryAcquire(lock, file2) {
|
|
|
25536
25683
|
function isAbandoned(body, lock, staleMs) {
|
|
25537
25684
|
if (!body) {
|
|
25538
25685
|
try {
|
|
25539
|
-
return Date.now() -
|
|
25686
|
+
return Date.now() - statSync3(lock).mtimeMs >= staleMs;
|
|
25540
25687
|
} catch {
|
|
25541
25688
|
return false;
|
|
25542
25689
|
}
|
|
@@ -25560,13 +25707,13 @@ function breakIfStale(lock, staleMs) {
|
|
|
25560
25707
|
}
|
|
25561
25708
|
try {
|
|
25562
25709
|
if (!existsSync2(lock) || !isAbandoned(readLockBody(lock), lock, staleMs)) return false;
|
|
25563
|
-
|
|
25710
|
+
rmSync4(lock, { force: true });
|
|
25564
25711
|
return true;
|
|
25565
25712
|
} catch {
|
|
25566
25713
|
return false;
|
|
25567
25714
|
} finally {
|
|
25568
25715
|
try {
|
|
25569
|
-
|
|
25716
|
+
rmSync4(breaker, { force: true });
|
|
25570
25717
|
} catch {
|
|
25571
25718
|
}
|
|
25572
25719
|
}
|
|
@@ -25574,8 +25721,8 @@ function breakIfStale(lock, staleMs) {
|
|
|
25574
25721
|
var BREAKER_ABANDONED_MS = 1e4;
|
|
25575
25722
|
function reapAbandonedBreaker(breaker) {
|
|
25576
25723
|
try {
|
|
25577
|
-
if (Date.now() -
|
|
25578
|
-
|
|
25724
|
+
if (Date.now() - statSync3(breaker).mtimeMs >= BREAKER_ABANDONED_MS) {
|
|
25725
|
+
rmSync4(breaker, { force: true });
|
|
25579
25726
|
}
|
|
25580
25727
|
} catch {
|
|
25581
25728
|
}
|
|
@@ -25586,7 +25733,7 @@ function abandonWindow(staleMs) {
|
|
|
25586
25733
|
function release(lock, token) {
|
|
25587
25734
|
try {
|
|
25588
25735
|
if (readLockBody(lock)?.token !== token) return;
|
|
25589
|
-
|
|
25736
|
+
rmSync4(lock, { force: true });
|
|
25590
25737
|
} catch {
|
|
25591
25738
|
}
|
|
25592
25739
|
}
|
|
@@ -25637,26 +25784,26 @@ import { createHash as createHash3 } from "crypto";
|
|
|
25637
25784
|
|
|
25638
25785
|
// ../../packages/persistence/src/fingerprint.ts
|
|
25639
25786
|
import { createHmac, randomBytes } from "crypto";
|
|
25640
|
-
import { existsSync as existsSync3, readFileSync as
|
|
25641
|
-
import { join as
|
|
25787
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
25788
|
+
import { join as join4 } from "path";
|
|
25642
25789
|
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
25643
25790
|
|
|
25644
25791
|
// ../../packages/persistence/src/local-layout.ts
|
|
25645
25792
|
import { renameSync as renameSync3 } from "fs";
|
|
25646
25793
|
import { mkdir } from "fs/promises";
|
|
25647
25794
|
import { homedir } from "os";
|
|
25648
|
-
import { join as
|
|
25795
|
+
import { join as join5 } from "path";
|
|
25649
25796
|
function defaultDataDir() {
|
|
25650
|
-
return
|
|
25797
|
+
return join5(homedir(), ".aka");
|
|
25651
25798
|
}
|
|
25652
25799
|
function settingsDir(base = defaultDataDir()) {
|
|
25653
|
-
return
|
|
25800
|
+
return join5(base, "settings");
|
|
25654
25801
|
}
|
|
25655
25802
|
function dataDir(base = defaultDataDir()) {
|
|
25656
|
-
return
|
|
25803
|
+
return join5(base, "data");
|
|
25657
25804
|
}
|
|
25658
25805
|
function dbPath(base = defaultDataDir()) {
|
|
25659
|
-
return
|
|
25806
|
+
return join5(dataDir(base), "aka.db");
|
|
25660
25807
|
}
|
|
25661
25808
|
function ensureLayoutDirSync(dir = defaultDataDir()) {
|
|
25662
25809
|
ensureDataDirSync(dir);
|
|
@@ -25669,8 +25816,8 @@ function migrateLegacyLayout(base = defaultDataDir()) {
|
|
|
25669
25816
|
for (const { name, dest } of moves) {
|
|
25670
25817
|
try {
|
|
25671
25818
|
ensureDataDirSync(dest);
|
|
25672
|
-
const moved =
|
|
25673
|
-
renameSync3(
|
|
25819
|
+
const moved = join5(dest, name);
|
|
25820
|
+
renameSync3(join5(base, name), moved);
|
|
25674
25821
|
tightenFile(moved);
|
|
25675
25822
|
} catch {
|
|
25676
25823
|
}
|
|
@@ -25678,7 +25825,7 @@ function migrateLegacyLayout(base = defaultDataDir()) {
|
|
|
25678
25825
|
}
|
|
25679
25826
|
|
|
25680
25827
|
// ../../packages/persistence/src/managed-settings.ts
|
|
25681
|
-
import { readFileSync as
|
|
25828
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
25682
25829
|
import { posix, win32 } from "path";
|
|
25683
25830
|
function managedSettingsPaths(platform2 = process.platform) {
|
|
25684
25831
|
if (platform2 === "darwin") {
|
|
@@ -25696,7 +25843,7 @@ function readManagedSettings(paths = managedSettingsPaths()) {
|
|
|
25696
25843
|
for (const path of paths) {
|
|
25697
25844
|
let text;
|
|
25698
25845
|
try {
|
|
25699
|
-
text =
|
|
25846
|
+
text = readFileSync4(path, "utf8");
|
|
25700
25847
|
} catch {
|
|
25701
25848
|
continue;
|
|
25702
25849
|
}
|
|
@@ -25755,14 +25902,14 @@ function lockedAmong(context, requested) {
|
|
|
25755
25902
|
}
|
|
25756
25903
|
|
|
25757
25904
|
// ../../packages/persistence/src/settings.ts
|
|
25758
|
-
import { readFileSync as
|
|
25759
|
-
import { join as
|
|
25905
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
25906
|
+
import { join as join6 } from "path";
|
|
25760
25907
|
var SETTINGS_FILENAME = "settings.json";
|
|
25761
25908
|
function readWorkspaceSettings(base = defaultDataDir()) {
|
|
25762
25909
|
return overlayManagedSettings(readUserSettings(base), readManagedSettings());
|
|
25763
25910
|
}
|
|
25764
25911
|
function readUserSettings(base) {
|
|
25765
|
-
const record2 = readJson(
|
|
25912
|
+
const record2 = readJson(join6(settingsDir(base), SETTINGS_FILENAME));
|
|
25766
25913
|
if (!record2) return defaultWorkspaceSettings();
|
|
25767
25914
|
try {
|
|
25768
25915
|
return WorkspaceSettings.parse(record2);
|
|
@@ -25827,7 +25974,7 @@ function withoutManagedKeys(applied, managed, pinned, touched) {
|
|
|
25827
25974
|
function applyOnboarding(answers2, base = defaultDataDir(), managedOverride) {
|
|
25828
25975
|
const dir = settingsDir(base);
|
|
25829
25976
|
ensureDataDirSync(dir);
|
|
25830
|
-
const file2 =
|
|
25977
|
+
const file2 = join6(dir, SETTINGS_FILENAME);
|
|
25831
25978
|
const managedSettings = managedOverride === void 0 ? readManagedSettings() : managedOverride;
|
|
25832
25979
|
const managed = managedContextOf(managedSettings);
|
|
25833
25980
|
return withFileLock(file2, () => {
|
|
@@ -25856,13 +26003,17 @@ function applyOnboarding(answers2, base = defaultDataDir(), managedOverride) {
|
|
|
25856
26003
|
function readJson(file2) {
|
|
25857
26004
|
let text;
|
|
25858
26005
|
try {
|
|
25859
|
-
text =
|
|
26006
|
+
text = readFileSync5(file2, "utf8");
|
|
25860
26007
|
} catch {
|
|
25861
26008
|
return null;
|
|
25862
26009
|
}
|
|
25863
26010
|
return parseJsonObject(text) ?? null;
|
|
25864
26011
|
}
|
|
25865
26012
|
|
|
26013
|
+
// ../../packages/persistence/src/store-symlinks.ts
|
|
26014
|
+
import { existsSync as existsSync4, lstatSync as lstatSync3, readlinkSync, realpathSync, statSync as statSync4 } from "fs";
|
|
26015
|
+
import { dirname as dirname2, join as join7, resolve } from "path";
|
|
26016
|
+
|
|
25866
26017
|
// ../../packages/persistence/src/vault/crypto.ts
|
|
25867
26018
|
import {
|
|
25868
26019
|
createCipheriv,
|
|
@@ -25875,20 +26026,20 @@ import {
|
|
|
25875
26026
|
// ../../packages/persistence/src/vault/key-provider.ts
|
|
25876
26027
|
import { execFileSync } from "child_process";
|
|
25877
26028
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
25878
|
-
import { chmodSync as
|
|
25879
|
-
import { join as
|
|
26029
|
+
import { chmodSync as chmodSync3, readFileSync as readFileSync6, renameSync as renameSync4, rmSync as rmSync5, statSync as statSync5, writeFileSync as writeFileSync3 } from "fs";
|
|
26030
|
+
import { join as join8 } from "path";
|
|
25880
26031
|
|
|
25881
26032
|
// ../../packages/persistence/src/vault/vault.ts
|
|
25882
26033
|
import { randomBytes as randomBytes3, randomUUID as randomUUID12 } from "crypto";
|
|
25883
26034
|
|
|
25884
26035
|
// ../../packages/persistence/src/warn-era-cap.ts
|
|
25885
|
-
import { existsSync as
|
|
25886
|
-
import { join as
|
|
26036
|
+
import { existsSync as existsSync5, writeFileSync as writeFileSync4 } from "fs";
|
|
26037
|
+
import { join as join9 } from "path";
|
|
25887
26038
|
var MARKER = "warn-era-capped";
|
|
25888
26039
|
function capWarnEraEnforcementOnce(db, policyMode, dataDir2) {
|
|
25889
26040
|
if (policyMode !== "warn") return { capped: 0, skipped: "not-warn" };
|
|
25890
|
-
const marker =
|
|
25891
|
-
if (
|
|
26041
|
+
const marker = join9(dataDir2, MARKER);
|
|
26042
|
+
if (existsSync5(marker)) return { capped: 0, skipped: "already-run" };
|
|
25892
26043
|
const capped = db.policies.capCategoryActions();
|
|
25893
26044
|
writeFileSync4(marker, `${new Date(Date.now()).toISOString()}
|
|
25894
26045
|
`, { mode: DATA_FILE_MODE });
|
|
@@ -25896,8 +26047,8 @@ function capWarnEraEnforcementOnce(db, policyMode, dataDir2) {
|
|
|
25896
26047
|
}
|
|
25897
26048
|
|
|
25898
26049
|
// ../../packages/plugin-sdk/src/config.ts
|
|
25899
|
-
import { existsSync as
|
|
25900
|
-
import { join as
|
|
26050
|
+
import { existsSync as existsSync6 } from "fs";
|
|
26051
|
+
import { join as join10 } from "path";
|
|
25901
26052
|
|
|
25902
26053
|
// ../../packages/plugin-sdk/src/provider-env.ts
|
|
25903
26054
|
var DEFAULT_ANTHROPIC_HOST = "api.anthropic.com";
|
|
@@ -25951,8 +26102,8 @@ function resolveProvider() {
|
|
|
25951
26102
|
function loadConfig(base = defaultDataDir(), resolveProviderFn = resolveProvider) {
|
|
25952
26103
|
try {
|
|
25953
26104
|
ensureLayoutDirSync(base);
|
|
25954
|
-
const settingsFile =
|
|
25955
|
-
if (
|
|
26105
|
+
const settingsFile = join10(settingsDir(base), "settings.json");
|
|
26106
|
+
if (existsSync6(settingsFile)) tightenFile(settingsFile);
|
|
25956
26107
|
} catch {
|
|
25957
26108
|
}
|
|
25958
26109
|
migrateLegacyLayout(base);
|
|
@@ -25975,9 +26126,9 @@ function resolveProviderSafe(resolveProviderFn) {
|
|
|
25975
26126
|
}
|
|
25976
26127
|
|
|
25977
26128
|
// ../../packages/plugin-sdk/src/config-inventory.ts
|
|
25978
|
-
import { readdirSync as readdirSync2, readFileSync as
|
|
26129
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync8, realpathSync as realpathSync2, statSync as statSync7 } from "fs";
|
|
25979
26130
|
import { homedir as homedir2 } from "os";
|
|
25980
|
-
import { basename as basename3, join as
|
|
26131
|
+
import { basename as basename3, join as join12 } from "path";
|
|
25981
26132
|
|
|
25982
26133
|
// ../../packages/detections/src/egress/registry.ts
|
|
25983
26134
|
var EXTRACTOR_VERSION = "1";
|
|
@@ -26735,32 +26886,32 @@ var CPU_CORROBORATION_SHARE = 0.2;
|
|
|
26735
26886
|
var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
|
|
26736
26887
|
|
|
26737
26888
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
26738
|
-
import { existsSync as
|
|
26739
|
-
import { basename as basename2, dirname as
|
|
26889
|
+
import { existsSync as existsSync7, readFileSync as readFileSync7, statSync as statSync6 } from "fs";
|
|
26890
|
+
import { basename as basename2, dirname as dirname3, isAbsolute, join as join11, sep as sep2 } from "path";
|
|
26740
26891
|
|
|
26741
26892
|
// ../../packages/plugin-sdk/src/events.ts
|
|
26742
26893
|
import { createHash as createHash4, randomUUID as randomUUID13 } from "crypto";
|
|
26743
26894
|
|
|
26744
26895
|
// ../../packages/plugin-sdk/src/isolated-scan.ts
|
|
26745
|
-
import { existsSync as
|
|
26896
|
+
import { existsSync as existsSync8 } from "fs";
|
|
26746
26897
|
import { fileURLToPath } from "url";
|
|
26747
26898
|
import { Worker } from "worker_threads";
|
|
26748
26899
|
|
|
26749
26900
|
// ../../packages/plugin-sdk/src/ignore-layers.ts
|
|
26750
26901
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
26751
|
-
import { readFileSync as
|
|
26752
|
-
import { join as
|
|
26902
|
+
import { readFileSync as readFileSync9 } from "fs";
|
|
26903
|
+
import { join as join13 } from "path";
|
|
26753
26904
|
|
|
26754
26905
|
// ../../packages/plugin-sdk/src/inventory-resolver.ts
|
|
26755
26906
|
import { arch, hostname as hostname4, platform, release as release2 } from "os";
|
|
26756
26907
|
|
|
26757
26908
|
// ../../packages/plugin-sdk/src/nudge.ts
|
|
26758
|
-
import { mkdirSync as mkdirSync2, readFileSync as
|
|
26759
|
-
import { join as
|
|
26909
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync10, writeFileSync as writeFileSync5 } from "fs";
|
|
26910
|
+
import { join as join14 } from "path";
|
|
26760
26911
|
|
|
26761
26912
|
// ../../packages/plugin-sdk/src/paths.ts
|
|
26762
|
-
import { readdirSync as readdirSync3, realpathSync as
|
|
26763
|
-
import { basename as basename4, dirname as
|
|
26913
|
+
import { readdirSync as readdirSync3, realpathSync as realpathSync3 } from "fs";
|
|
26914
|
+
import { basename as basename4, dirname as dirname4, sep as sep3 } from "path";
|
|
26764
26915
|
|
|
26765
26916
|
// ../../packages/plugin-sdk/src/posture.ts
|
|
26766
26917
|
function applyCategoryPosture(posture, repo, mode = "fill-gaps") {
|
|
@@ -26773,8 +26924,8 @@ function applyCategoryPosture(posture, repo, mode = "fill-gaps") {
|
|
|
26773
26924
|
}
|
|
26774
26925
|
|
|
26775
26926
|
// ../../packages/plugin-sdk/src/project-files.ts
|
|
26776
|
-
import { existsSync as
|
|
26777
|
-
import { basename as basename5, join as
|
|
26927
|
+
import { existsSync as existsSync9, readdirSync as readdirSync4 } from "fs";
|
|
26928
|
+
import { basename as basename5, join as join15 } from "path";
|
|
26778
26929
|
|
|
26779
26930
|
// ../../packages/plugin-sdk/src/provider-env-antigravity.ts
|
|
26780
26931
|
var optionalBaseUrl2 = external_exports.preprocess((v) => {
|
|
@@ -26809,8 +26960,8 @@ import { randomUUID as randomUUID14 } from "crypto";
|
|
|
26809
26960
|
var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
26810
26961
|
|
|
26811
26962
|
// ../../packages/plugin-sdk/src/throttle.ts
|
|
26812
|
-
import { mkdirSync as mkdirSync3, statSync as
|
|
26813
|
-
import { join as
|
|
26963
|
+
import { mkdirSync as mkdirSync3, statSync as statSync8, writeFileSync as writeFileSync6 } from "fs";
|
|
26964
|
+
import { join as join16 } from "path";
|
|
26814
26965
|
|
|
26815
26966
|
// ../../packages/setup-wizard/src/onboard-posture.ts
|
|
26816
26967
|
function parsePosture(json2) {
|
|
@@ -26833,7 +26984,7 @@ function parsePosture(json2) {
|
|
|
26833
26984
|
|
|
26834
26985
|
// ../../packages/setup-wizard/src/remediation/rotation-checklist.ts
|
|
26835
26986
|
import { writeFileSync as writeFileSync7 } from "fs";
|
|
26836
|
-
import { join as
|
|
26987
|
+
import { join as join17 } from "path";
|
|
26837
26988
|
|
|
26838
26989
|
// ../../packages/setup-wizard/src/triage/merge.ts
|
|
26839
26990
|
var RANK = Object.fromEntries(
|
|
@@ -26841,9 +26992,9 @@ var RANK = Object.fromEntries(
|
|
|
26841
26992
|
);
|
|
26842
26993
|
|
|
26843
26994
|
// ../../packages/setup-wizard/src/triage/plan-file.ts
|
|
26844
|
-
import { mkdtempSync, readFileSync as
|
|
26995
|
+
import { mkdtempSync, readFileSync as readFileSync11, rmdirSync, rmSync as rmSync6, writeFileSync as writeFileSync8 } from "fs";
|
|
26845
26996
|
import { tmpdir } from "os";
|
|
26846
|
-
import { basename as basename6, dirname as
|
|
26997
|
+
import { basename as basename6, dirname as dirname5, join as join18 } from "path";
|
|
26847
26998
|
var SuppressionEntrySchema = external_exports.object({
|
|
26848
26999
|
ruleId: external_exports.string(),
|
|
26849
27000
|
category: DetectionCategory,
|