@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
|
@@ -492,13 +492,12 @@ var require_ignore = __commonJS({
|
|
|
492
492
|
});
|
|
493
493
|
|
|
494
494
|
// ../../packages/plugin-sdk/src/config.ts
|
|
495
|
-
import { existsSync as
|
|
496
|
-
import { join as
|
|
495
|
+
import { existsSync as existsSync6 } from "fs";
|
|
496
|
+
import { join as join10 } from "path";
|
|
497
497
|
|
|
498
|
-
// ../../packages/persistence/src/
|
|
499
|
-
import {
|
|
500
|
-
import { join
|
|
501
|
-
import { DatabaseSync } from "node:sqlite";
|
|
498
|
+
// ../../packages/persistence/src/control-plane-credential.ts
|
|
499
|
+
import { chmodSync as chmodSync2, lstatSync as lstatSync2, readFileSync, rmSync as rmSync2, statSync } from "fs";
|
|
500
|
+
import { join } from "path";
|
|
502
501
|
|
|
503
502
|
// ../../packages/schema/src/drizzle/sqlite-ddl.ts
|
|
504
503
|
var SQLITE_MIGRATIONS = [
|
|
@@ -16202,6 +16201,124 @@ var ConfigScanRecord = external_exports.object({
|
|
|
16202
16201
|
findings: external_exports.array(ConfigPostureFindingInput).optional()
|
|
16203
16202
|
});
|
|
16204
16203
|
|
|
16204
|
+
// ../../packages/schema/src/zod/control-plane.ts
|
|
16205
|
+
var ATTACHED_CREDENTIAL_SPEC_VERSION = 1;
|
|
16206
|
+
var AttachedCredential = external_exports.object({
|
|
16207
|
+
specVersion: external_exports.literal(ATTACHED_CREDENTIAL_SPEC_VERSION),
|
|
16208
|
+
// The control-plane endpoint this credential was minted against.
|
|
16209
|
+
endpoint: external_exports.string().min(1),
|
|
16210
|
+
// The bearer credential itself. Never logged, never rendered — status
|
|
16211
|
+
// surfaces show `keyPrefix` and nothing else.
|
|
16212
|
+
apiKey: external_exports.string().min(1),
|
|
16213
|
+
// First few characters of the key, safe to display so a user can match the
|
|
16214
|
+
// credential against their organization's key list.
|
|
16215
|
+
keyPrefix: external_exports.string().min(1).max(16).optional(),
|
|
16216
|
+
mintedAt: external_exports.iso.datetime().optional()
|
|
16217
|
+
});
|
|
16218
|
+
var MAX_DATE_MS = 253402300799999;
|
|
16219
|
+
var MAX_INT4 = 2147483647;
|
|
16220
|
+
var StorePosturePack = external_exports.object({
|
|
16221
|
+
packId: external_exports.string().min(1),
|
|
16222
|
+
// 'namespace/packId'
|
|
16223
|
+
version: external_exports.string().min(1),
|
|
16224
|
+
enabled: external_exports.boolean(),
|
|
16225
|
+
// Stringified pass-through of the local store's `installed_packs.updated_at`
|
|
16226
|
+
// — the column format is store-version-dependent (epoch millis vs ISO), so
|
|
16227
|
+
// the wire shape assumes neither.
|
|
16228
|
+
updatedAt: external_exports.string().nullable()
|
|
16229
|
+
}).meta({ id: "StorePosturePack" });
|
|
16230
|
+
var StorePosturePolicyCounts = external_exports.object({
|
|
16231
|
+
total: external_exports.number().int().min(0),
|
|
16232
|
+
disabled: external_exports.number().int().min(0),
|
|
16233
|
+
// Exhaustive per-action map; the builder pre-fills every action with 0.
|
|
16234
|
+
//
|
|
16235
|
+
// Spelled out member-by-member rather than `z.record(ActionTaken, …)`. Zod
|
|
16236
|
+
// enforces exhaustiveness either way, but z.record emits `propertyNames` +
|
|
16237
|
+
// `additionalProperties` into a generated schema document, and a type
|
|
16238
|
+
// generator renders THAT with every key optional — a sender built against
|
|
16239
|
+
// the generated type would typecheck and still be rejected at runtime. An
|
|
16240
|
+
// explicit object emits `properties` + `required`, so generated types
|
|
16241
|
+
// demand all five.
|
|
16242
|
+
//
|
|
16243
|
+
// `satisfies Record<ActionTaken, …>` keeps the link to the enum: adding an
|
|
16244
|
+
// ActionTaken member is a COMPILE error here instead of silent drift.
|
|
16245
|
+
// `.strict()` is load-bearing — it rejects an unknown action key, which a
|
|
16246
|
+
// bare object would silently STRIP, accepting a miscounted map as valid.
|
|
16247
|
+
byAction: external_exports.object({
|
|
16248
|
+
warn: external_exports.number().int().min(0),
|
|
16249
|
+
redact: external_exports.number().int().min(0),
|
|
16250
|
+
block: external_exports.number().int().min(0),
|
|
16251
|
+
allow: external_exports.number().int().min(0),
|
|
16252
|
+
log: external_exports.number().int().min(0)
|
|
16253
|
+
}).strict()
|
|
16254
|
+
}).meta({ id: "StorePosturePolicyCounts" });
|
|
16255
|
+
var StorePosturePlugin = external_exports.object({
|
|
16256
|
+
/** Package name of the reporting plugin. */
|
|
16257
|
+
package: external_exports.string().min(1).max(200),
|
|
16258
|
+
version: external_exports.string().min(1).max(64),
|
|
16259
|
+
/** Version of the bundled core, when the build records one separately. */
|
|
16260
|
+
ossVersion: external_exports.string().max(64).nullable(),
|
|
16261
|
+
/**
|
|
16262
|
+
* `version` of the policy bundle this machine last fetched. Bounded at 200
|
|
16263
|
+
* rather than the 64 a bare sha256 hex digest needs today, so a later
|
|
16264
|
+
* format with an algorithm prefix does not start rejecting the channel.
|
|
16265
|
+
*/
|
|
16266
|
+
policyBundleVersion: external_exports.string().max(200).nullable(),
|
|
16267
|
+
/** Epoch millis, on the CLIENT clock, of that fetch. */
|
|
16268
|
+
policyFetchedAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable()
|
|
16269
|
+
}).meta({ id: "StorePosturePlugin" });
|
|
16270
|
+
var StorePostureSnapshot = external_exports.object({
|
|
16271
|
+
deviceId: external_exports.guid(),
|
|
16272
|
+
hostname: external_exports.string().min(1).max(253),
|
|
16273
|
+
// Epoch millis on the CLIENT clock. Bounded by what a receiving store
|
|
16274
|
+
// accepts (see MAX_DATE_MS), not by what a JavaScript Date can hold.
|
|
16275
|
+
capturedAt: external_exports.number().int().min(0).max(MAX_DATE_MS),
|
|
16276
|
+
// False is a measurement, not an error state: "no local store exists on
|
|
16277
|
+
// this machine".
|
|
16278
|
+
storePresent: external_exports.boolean(),
|
|
16279
|
+
schemaVersion: external_exports.number().int().min(0).max(MAX_INT4).nullable(),
|
|
16280
|
+
// PRAGMA user_version
|
|
16281
|
+
findingsTotal: external_exports.number().int().min(0).max(MAX_INT4),
|
|
16282
|
+
// Epoch millis, bounded like `capturedAt` — see MAX_DATE_MS on what that
|
|
16283
|
+
// bound does and does not do. Worth stating for these two specifically:
|
|
16284
|
+
// they are read from the local store's own ROWS rather than from this
|
|
16285
|
+
// machine's clock, so a damaged or hand-edited store is enough to produce
|
|
16286
|
+
// an out-of-range value with no clock skew involved.
|
|
16287
|
+
findingsFirstAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable(),
|
|
16288
|
+
findingsLastAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable(),
|
|
16289
|
+
packs: external_exports.array(StorePosturePack).max(500),
|
|
16290
|
+
policyCounts: StorePosturePolicyCounts,
|
|
16291
|
+
// OPTIONAL, not nullable: a reporter that predates this member keeps
|
|
16292
|
+
// getting its 200 without a payload change.
|
|
16293
|
+
plugin: StorePosturePlugin.optional()
|
|
16294
|
+
}).meta({ id: "StorePostureSnapshot" });
|
|
16295
|
+
var CAPTURE_VERSION_PREFIX = "capture/";
|
|
16296
|
+
var RecordAuditEventRequest = AuditEventInput.extend({
|
|
16297
|
+
inspections: external_exports.array(ToolCallInspection).default([])
|
|
16298
|
+
}).refine((v) => v.inspections.every((i) => !i.ruleVersion.startsWith(CAPTURE_VERSION_PREFIX)), {
|
|
16299
|
+
message: `inspections[].ruleVersion must not start with \`${CAPTURE_VERSION_PREFIX}\` \u2014 that namespace is reserved for capture definitions the control plane mints itself`,
|
|
16300
|
+
path: ["inspections"]
|
|
16301
|
+
}).meta({ id: "RecordAuditEventRequest" });
|
|
16302
|
+
var IngestAck = external_exports.object({
|
|
16303
|
+
accepted: external_exports.number().int().nonnegative(),
|
|
16304
|
+
duplicates: external_exports.number().int().nonnegative()
|
|
16305
|
+
});
|
|
16306
|
+
var PRINTABLE = /^[^\p{Cc}\p{Cf}]*$/u;
|
|
16307
|
+
var printable = (max) => external_exports.string().max(max).regex(PRINTABLE, "must not contain control characters");
|
|
16308
|
+
var PluginWhoami = external_exports.object({
|
|
16309
|
+
tenantName: printable(200),
|
|
16310
|
+
userEmail: printable(320),
|
|
16311
|
+
role: printable(64),
|
|
16312
|
+
keyKind: printable(64),
|
|
16313
|
+
serverTime: printable(64)
|
|
16314
|
+
});
|
|
16315
|
+
var ControlPlaneErrorBody = external_exports.object({
|
|
16316
|
+
error: external_exports.object({
|
|
16317
|
+
code: external_exports.string().optional(),
|
|
16318
|
+
message: external_exports.string().optional()
|
|
16319
|
+
}).optional()
|
|
16320
|
+
});
|
|
16321
|
+
|
|
16205
16322
|
// ../../packages/schema/src/zod/registry.ts
|
|
16206
16323
|
var Namespace = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
16207
16324
|
var PackId = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
@@ -18520,42 +18637,6 @@ function reviewSeverityRank(reasons) {
|
|
|
18520
18637
|
return Math.min(...reasons.map((r) => REVIEW_SEVERITY_RANK[r]));
|
|
18521
18638
|
}
|
|
18522
18639
|
|
|
18523
|
-
// ../../packages/persistence/src/ids.ts
|
|
18524
|
-
import { createHash } from "crypto";
|
|
18525
|
-
function sha256Hex(input) {
|
|
18526
|
-
return createHash("sha256").update(input).digest("hex");
|
|
18527
|
-
}
|
|
18528
|
-
function inventoryId(objectType, identityKey) {
|
|
18529
|
-
return sha256Hex(canonicalIdentity(["inventory", objectType, identityKey]));
|
|
18530
|
-
}
|
|
18531
|
-
function sourceProjectId(url2) {
|
|
18532
|
-
return sha256Hex(canonicalIdentity(["source_project", url2]));
|
|
18533
|
-
}
|
|
18534
|
-
function classifiedDataId(cls) {
|
|
18535
|
-
return sha256Hex(canonicalIdentity(["classified_data", cls]));
|
|
18536
|
-
}
|
|
18537
|
-
function inspectionDefinitionId(ruleId, version2) {
|
|
18538
|
-
return sha256Hex(canonicalIdentity(["inspection_definition", ruleId, version2]));
|
|
18539
|
-
}
|
|
18540
|
-
function llmCallId(sessionId, messageId) {
|
|
18541
|
-
return sha256Hex(canonicalIdentity(["audit_event_llm_call", sessionId, messageId]));
|
|
18542
|
-
}
|
|
18543
|
-
function toolCallId(sessionId, toolUseId) {
|
|
18544
|
-
return sha256Hex(canonicalIdentity(["audit_event_tool_call", sessionId, toolUseId]));
|
|
18545
|
-
}
|
|
18546
|
-
var NO_SESSION = "no_session";
|
|
18547
|
-
var NO_PATH = "no_path";
|
|
18548
|
-
function captureId(sessionId, contentHash, filePath = null) {
|
|
18549
|
-
return sha256Hex(
|
|
18550
|
-
canonicalIdentity(["capture", sessionId ?? NO_SESSION, contentHash, filePath ?? NO_PATH])
|
|
18551
|
-
);
|
|
18552
|
-
}
|
|
18553
|
-
|
|
18554
|
-
// ../../packages/persistence/src/internal/snapshot.ts
|
|
18555
|
-
import { randomUUID } from "crypto";
|
|
18556
|
-
import { existsSync, readdirSync, renameSync as renameSync2, rmSync as rmSync2, statSync } from "fs";
|
|
18557
|
-
import { basename, dirname, join } from "path";
|
|
18558
|
-
|
|
18559
18640
|
// ../../packages/persistence/src/paths.ts
|
|
18560
18641
|
import {
|
|
18561
18642
|
chmodSync,
|
|
@@ -18681,7 +18762,46 @@ function publishByLink(tmp, file2, data) {
|
|
|
18681
18762
|
}
|
|
18682
18763
|
}
|
|
18683
18764
|
|
|
18765
|
+
// ../../packages/persistence/src/database.ts
|
|
18766
|
+
import { randomUUID as randomUUID10 } from "crypto";
|
|
18767
|
+
import { join as join3, sep } from "path";
|
|
18768
|
+
import { DatabaseSync } from "node:sqlite";
|
|
18769
|
+
|
|
18770
|
+
// ../../packages/persistence/src/ids.ts
|
|
18771
|
+
import { createHash } from "crypto";
|
|
18772
|
+
function sha256Hex(input) {
|
|
18773
|
+
return createHash("sha256").update(input).digest("hex");
|
|
18774
|
+
}
|
|
18775
|
+
function inventoryId(objectType, identityKey) {
|
|
18776
|
+
return sha256Hex(canonicalIdentity(["inventory", objectType, identityKey]));
|
|
18777
|
+
}
|
|
18778
|
+
function sourceProjectId(url2) {
|
|
18779
|
+
return sha256Hex(canonicalIdentity(["source_project", url2]));
|
|
18780
|
+
}
|
|
18781
|
+
function classifiedDataId(cls) {
|
|
18782
|
+
return sha256Hex(canonicalIdentity(["classified_data", cls]));
|
|
18783
|
+
}
|
|
18784
|
+
function inspectionDefinitionId(ruleId, version2) {
|
|
18785
|
+
return sha256Hex(canonicalIdentity(["inspection_definition", ruleId, version2]));
|
|
18786
|
+
}
|
|
18787
|
+
function llmCallId(sessionId, messageId) {
|
|
18788
|
+
return sha256Hex(canonicalIdentity(["audit_event_llm_call", sessionId, messageId]));
|
|
18789
|
+
}
|
|
18790
|
+
function toolCallId(sessionId, toolUseId) {
|
|
18791
|
+
return sha256Hex(canonicalIdentity(["audit_event_tool_call", sessionId, toolUseId]));
|
|
18792
|
+
}
|
|
18793
|
+
var NO_SESSION = "no_session";
|
|
18794
|
+
var NO_PATH = "no_path";
|
|
18795
|
+
function captureId(sessionId, contentHash, filePath = null) {
|
|
18796
|
+
return sha256Hex(
|
|
18797
|
+
canonicalIdentity(["capture", sessionId ?? NO_SESSION, contentHash, filePath ?? NO_PATH])
|
|
18798
|
+
);
|
|
18799
|
+
}
|
|
18800
|
+
|
|
18684
18801
|
// ../../packages/persistence/src/internal/snapshot.ts
|
|
18802
|
+
import { randomUUID } from "crypto";
|
|
18803
|
+
import { existsSync, readdirSync, renameSync as renameSync2, rmSync as rmSync3, statSync as statSync2 } from "fs";
|
|
18804
|
+
import { basename, dirname, join as join2 } from "path";
|
|
18685
18805
|
function backupPath(file2, tag) {
|
|
18686
18806
|
return `${file2}.${tag}.${String(Date.now())}.${randomUUID().slice(0, 8)}.bak`;
|
|
18687
18807
|
}
|
|
@@ -18691,15 +18811,15 @@ var STAGED_NAME_SUFFIX = `.bak${SNAPSHOT_STAGING_SUFFIX}`;
|
|
|
18691
18811
|
var SNAPSHOT_STAGING_COPY = "copy";
|
|
18692
18812
|
function createSnapshotStaging(backup) {
|
|
18693
18813
|
const stage = `${backup}${SNAPSHOT_STAGING_SUFFIX}`;
|
|
18694
|
-
|
|
18814
|
+
rmSync3(stage, { recursive: true, force: true });
|
|
18695
18815
|
mkdirOwnerOnlySync(stage);
|
|
18696
18816
|
tightenDir(stage);
|
|
18697
|
-
return { stage, copy:
|
|
18817
|
+
return { stage, copy: join2(stage, SNAPSHOT_STAGING_COPY) };
|
|
18698
18818
|
}
|
|
18699
18819
|
function idleMs(entry) {
|
|
18700
|
-
for (const candidate of [
|
|
18820
|
+
for (const candidate of [join2(entry, SNAPSHOT_STAGING_COPY), entry]) {
|
|
18701
18821
|
try {
|
|
18702
|
-
return Date.now() -
|
|
18822
|
+
return Date.now() - statSync2(candidate).mtimeMs;
|
|
18703
18823
|
} catch {
|
|
18704
18824
|
}
|
|
18705
18825
|
}
|
|
@@ -18716,11 +18836,11 @@ function reapStalePartials(file2) {
|
|
|
18716
18836
|
}
|
|
18717
18837
|
for (const name of entries) {
|
|
18718
18838
|
if (!name.startsWith(prefix) || !name.endsWith(STAGED_NAME_SUFFIX)) continue;
|
|
18719
|
-
const staging =
|
|
18839
|
+
const staging = join2(dir, name);
|
|
18720
18840
|
try {
|
|
18721
18841
|
const idle = idleMs(staging);
|
|
18722
18842
|
if (idle !== null && idle > STALE_PARTIAL_MS) {
|
|
18723
|
-
|
|
18843
|
+
rmSync3(staging, { recursive: true, force: true });
|
|
18724
18844
|
}
|
|
18725
18845
|
} catch {
|
|
18726
18846
|
}
|
|
@@ -18734,13 +18854,13 @@ function snapshotStore(db, backup) {
|
|
|
18734
18854
|
renameSync2(copy, backup);
|
|
18735
18855
|
} catch (error51) {
|
|
18736
18856
|
try {
|
|
18737
|
-
|
|
18857
|
+
rmSync3(stage, { recursive: true, force: true });
|
|
18738
18858
|
} catch {
|
|
18739
18859
|
}
|
|
18740
18860
|
throw error51;
|
|
18741
18861
|
}
|
|
18742
18862
|
try {
|
|
18743
|
-
|
|
18863
|
+
rmSync3(stage, { recursive: true, force: true });
|
|
18744
18864
|
} catch {
|
|
18745
18865
|
}
|
|
18746
18866
|
}
|
|
@@ -18755,7 +18875,7 @@ function moveStoreAside(file2, backup) {
|
|
|
18755
18875
|
renameSync2(sidecar, moved);
|
|
18756
18876
|
undo.push([moved, sidecar]);
|
|
18757
18877
|
} catch {
|
|
18758
|
-
|
|
18878
|
+
rmSync3(sidecar, { force: true });
|
|
18759
18879
|
}
|
|
18760
18880
|
}
|
|
18761
18881
|
} catch (error51) {
|
|
@@ -18771,14 +18891,14 @@ function moveStoreAside(file2, backup) {
|
|
|
18771
18891
|
}
|
|
18772
18892
|
function discardStore(file2, backup) {
|
|
18773
18893
|
try {
|
|
18774
|
-
|
|
18894
|
+
rmSync3(file2, { force: true });
|
|
18775
18895
|
for (const sidecar of dbSidecars(file2)) {
|
|
18776
|
-
|
|
18896
|
+
rmSync3(sidecar, { force: true });
|
|
18777
18897
|
}
|
|
18778
18898
|
} catch (error51) {
|
|
18779
18899
|
if (existsSync(file2)) {
|
|
18780
18900
|
try {
|
|
18781
|
-
|
|
18901
|
+
rmSync3(backup, { force: true });
|
|
18782
18902
|
} catch {
|
|
18783
18903
|
}
|
|
18784
18904
|
}
|
|
@@ -19010,10 +19130,31 @@ function applyMigrations(db, file2) {
|
|
|
19010
19130
|
if (drained) applyLegacyDropMigration(db, file2);
|
|
19011
19131
|
}
|
|
19012
19132
|
}
|
|
19133
|
+
function readLegacyTables(db) {
|
|
19134
|
+
let holdsRows = false;
|
|
19135
|
+
const marks = [];
|
|
19136
|
+
for (const table of ["events", "findings"]) {
|
|
19137
|
+
try {
|
|
19138
|
+
const row = db.prepare(`SELECT count(*) AS n, ifnull(max(rowid), -1) AS hi FROM ${table}`).get();
|
|
19139
|
+
if (row === void 0) {
|
|
19140
|
+
holdsRows = true;
|
|
19141
|
+
marks.push(`${table}:unreadable`);
|
|
19142
|
+
continue;
|
|
19143
|
+
}
|
|
19144
|
+
if (row.n > 0) holdsRows = true;
|
|
19145
|
+
marks.push(`${table}:${String(row.n)}:${String(row.hi)}`);
|
|
19146
|
+
} catch {
|
|
19147
|
+
holdsRows = true;
|
|
19148
|
+
marks.push(`${table}:unreadable`);
|
|
19149
|
+
}
|
|
19150
|
+
}
|
|
19151
|
+
return { holdsRows, mark: marks.join("|") };
|
|
19152
|
+
}
|
|
19013
19153
|
function applyLegacyDropMigration(db, file2) {
|
|
19014
19154
|
const migration = SQLITE_MIGRATIONS.find((m) => m.tag === LEGACY_DROP_MIGRATION_TAG);
|
|
19015
19155
|
if (!migration) return;
|
|
19016
|
-
|
|
19156
|
+
const before = file2 === void 0 ? void 0 : readLegacyTables(db);
|
|
19157
|
+
if (file2 !== void 0 && before?.holdsRows === true) {
|
|
19017
19158
|
try {
|
|
19018
19159
|
backupBeforeLegacyDrop(db, file2);
|
|
19019
19160
|
} catch (error51) {
|
|
@@ -19027,6 +19168,12 @@ function applyLegacyDropMigration(db, file2) {
|
|
|
19027
19168
|
() => {
|
|
19028
19169
|
const alreadyDropped = db.prepare("SELECT 1 FROM migration_ledger WHERE tag = ?").get(migration.tag);
|
|
19029
19170
|
if (alreadyDropped) return;
|
|
19171
|
+
if (before !== void 0 && readLegacyTables(db).mark !== before.mark) {
|
|
19172
|
+
akaWarn(
|
|
19173
|
+
"legacy events/findings rows changed after the pre-drop snapshot decision; deferring the drop so the next open can copy them first."
|
|
19174
|
+
);
|
|
19175
|
+
return;
|
|
19176
|
+
}
|
|
19030
19177
|
for (const statement of splitStatements(migration.sql)) {
|
|
19031
19178
|
db.exec(statement);
|
|
19032
19179
|
}
|
|
@@ -25248,7 +25395,7 @@ function openAndInitialize(file2) {
|
|
|
25248
25395
|
}
|
|
25249
25396
|
function openLocalDatabase(dir) {
|
|
25250
25397
|
ensureDataDirSync(dir);
|
|
25251
|
-
const file2 =
|
|
25398
|
+
const file2 = join3(dir, DB_FILENAME);
|
|
25252
25399
|
reapStalePartials(file2);
|
|
25253
25400
|
const {
|
|
25254
25401
|
db,
|
|
@@ -25504,9 +25651,9 @@ import {
|
|
|
25504
25651
|
closeSync,
|
|
25505
25652
|
existsSync as existsSync2,
|
|
25506
25653
|
openSync,
|
|
25507
|
-
readFileSync,
|
|
25508
|
-
rmSync as
|
|
25509
|
-
statSync as
|
|
25654
|
+
readFileSync as readFileSync2,
|
|
25655
|
+
rmSync as rmSync4,
|
|
25656
|
+
statSync as statSync3,
|
|
25510
25657
|
writeFileSync as writeFileSync2
|
|
25511
25658
|
} from "fs";
|
|
25512
25659
|
import { hostname as hostname3 } from "os";
|
|
@@ -25517,13 +25664,13 @@ import { createHash as createHash3 } from "crypto";
|
|
|
25517
25664
|
|
|
25518
25665
|
// ../../packages/persistence/src/fingerprint.ts
|
|
25519
25666
|
import { createHmac, randomBytes } from "crypto";
|
|
25520
|
-
import { existsSync as existsSync3, readFileSync as
|
|
25521
|
-
import { join as
|
|
25667
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
25668
|
+
import { join as join4 } from "path";
|
|
25522
25669
|
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
25523
25670
|
var EXCEPTION_KEY_FILENAME = "exception.key";
|
|
25524
25671
|
var KEY_MATERIAL_BYTES = 32;
|
|
25525
25672
|
function keyFilePath(dataDir2) {
|
|
25526
|
-
return
|
|
25673
|
+
return join4(dataDir2, EXCEPTION_KEY_FILENAME);
|
|
25527
25674
|
}
|
|
25528
25675
|
function parseKeyFile(raw) {
|
|
25529
25676
|
const parsed = JSON.parse(raw);
|
|
@@ -25561,7 +25708,7 @@ var FloorUnreadableError = class extends Error {
|
|
|
25561
25708
|
}
|
|
25562
25709
|
};
|
|
25563
25710
|
function storedKeyVersionFloor(dataDir2) {
|
|
25564
|
-
const file2 =
|
|
25711
|
+
const file2 = join4(dataDir2, DB_FILENAME);
|
|
25565
25712
|
if (!existsSync3(file2)) return 0;
|
|
25566
25713
|
let db;
|
|
25567
25714
|
try {
|
|
@@ -25616,7 +25763,7 @@ function occupantMessage(file2, kind) {
|
|
|
25616
25763
|
function readFingerprintKey(dataDir2) {
|
|
25617
25764
|
let raw;
|
|
25618
25765
|
try {
|
|
25619
|
-
raw =
|
|
25766
|
+
raw = readFileSync3(keyFilePath(dataDir2), "utf8");
|
|
25620
25767
|
} catch (err) {
|
|
25621
25768
|
if (err.code === "ENOENT") return null;
|
|
25622
25769
|
throw err instanceof Error ? err : new Error(String(err));
|
|
@@ -25642,21 +25789,21 @@ function fingerprintValue(key, raw) {
|
|
|
25642
25789
|
import { renameSync as renameSync3 } from "fs";
|
|
25643
25790
|
import { mkdir } from "fs/promises";
|
|
25644
25791
|
import { homedir } from "os";
|
|
25645
|
-
import { join as
|
|
25792
|
+
import { join as join5 } from "path";
|
|
25646
25793
|
function defaultDataDir() {
|
|
25647
|
-
return
|
|
25794
|
+
return join5(homedir(), ".aka");
|
|
25648
25795
|
}
|
|
25649
25796
|
function settingsDir(base = defaultDataDir()) {
|
|
25650
|
-
return
|
|
25797
|
+
return join5(base, "settings");
|
|
25651
25798
|
}
|
|
25652
25799
|
function dataDir(base = defaultDataDir()) {
|
|
25653
|
-
return
|
|
25800
|
+
return join5(base, "data");
|
|
25654
25801
|
}
|
|
25655
25802
|
function dbPath(base = defaultDataDir()) {
|
|
25656
|
-
return
|
|
25803
|
+
return join5(dataDir(base), "aka.db");
|
|
25657
25804
|
}
|
|
25658
25805
|
function keysDir(base = defaultDataDir()) {
|
|
25659
|
-
return
|
|
25806
|
+
return join5(base, "keys");
|
|
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
|
}
|
|
@@ -25743,14 +25890,14 @@ function overlayManagedSettings(settings, managed, now = () => /* @__PURE__ */ n
|
|
|
25743
25890
|
}
|
|
25744
25891
|
|
|
25745
25892
|
// ../../packages/persistence/src/settings.ts
|
|
25746
|
-
import { readFileSync as
|
|
25747
|
-
import { join as
|
|
25893
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
25894
|
+
import { join as join6 } from "path";
|
|
25748
25895
|
var SETTINGS_FILENAME = "settings.json";
|
|
25749
25896
|
function readWorkspaceSettings(base = defaultDataDir()) {
|
|
25750
25897
|
return overlayManagedSettings(readUserSettings(base), readManagedSettings());
|
|
25751
25898
|
}
|
|
25752
25899
|
function readUserSettings(base) {
|
|
25753
|
-
const record2 = readJson(
|
|
25900
|
+
const record2 = readJson(join6(settingsDir(base), SETTINGS_FILENAME));
|
|
25754
25901
|
if (!record2) return defaultWorkspaceSettings();
|
|
25755
25902
|
try {
|
|
25756
25903
|
return WorkspaceSettings.parse(record2);
|
|
@@ -25761,13 +25908,17 @@ function readUserSettings(base) {
|
|
|
25761
25908
|
function readJson(file2) {
|
|
25762
25909
|
let text;
|
|
25763
25910
|
try {
|
|
25764
|
-
text =
|
|
25911
|
+
text = readFileSync5(file2, "utf8");
|
|
25765
25912
|
} catch {
|
|
25766
25913
|
return null;
|
|
25767
25914
|
}
|
|
25768
25915
|
return parseJsonObject(text) ?? null;
|
|
25769
25916
|
}
|
|
25770
25917
|
|
|
25918
|
+
// ../../packages/persistence/src/store-symlinks.ts
|
|
25919
|
+
import { existsSync as existsSync4, lstatSync as lstatSync3, readlinkSync, realpathSync, statSync as statSync4 } from "fs";
|
|
25920
|
+
import { dirname as dirname2, join as join7, resolve } from "path";
|
|
25921
|
+
|
|
25771
25922
|
// ../../packages/persistence/src/vault/crypto.ts
|
|
25772
25923
|
import {
|
|
25773
25924
|
createCipheriv,
|
|
@@ -25879,8 +26030,8 @@ function formatPointer(category, keyVersion, pointerId, tag) {
|
|
|
25879
26030
|
// ../../packages/persistence/src/vault/key-provider.ts
|
|
25880
26031
|
import { execFileSync } from "child_process";
|
|
25881
26032
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
25882
|
-
import { chmodSync as
|
|
25883
|
-
import { join as
|
|
26033
|
+
import { chmodSync as chmodSync3, readFileSync as readFileSync6, renameSync as renameSync4, rmSync as rmSync5, statSync as statSync5, writeFileSync as writeFileSync3 } from "fs";
|
|
26034
|
+
import { join as join8 } from "path";
|
|
25884
26035
|
var VAULT_OCCUPANT_REASON = {
|
|
25885
26036
|
symlink: "the path is a symlink; remove it so a keyring can be created",
|
|
25886
26037
|
gone: "the path was occupied but holds no keyring (removed while it was being created)",
|
|
@@ -25979,28 +26130,28 @@ function claimRotationLock(lock, owner) {
|
|
|
25979
26130
|
throw asError(err);
|
|
25980
26131
|
}
|
|
25981
26132
|
try {
|
|
25982
|
-
writeFileSync3(
|
|
26133
|
+
writeFileSync3(join8(lock, LOCK_OWNER_FILE), `${owner}
|
|
25983
26134
|
`, { mode: DATA_FILE_MODE });
|
|
25984
26135
|
return true;
|
|
25985
26136
|
} catch (err) {
|
|
25986
|
-
|
|
26137
|
+
rmSync5(lock, { recursive: true, force: true });
|
|
25987
26138
|
throw asError(err);
|
|
25988
26139
|
}
|
|
25989
26140
|
}
|
|
25990
26141
|
function acquireRotationLock(keysDir2) {
|
|
25991
|
-
const lock =
|
|
26142
|
+
const lock = join8(keysDir2, `${VAULT_KEY_FILENAME}.lock`);
|
|
25992
26143
|
const owner = randomBytes2(16).toString("hex");
|
|
25993
26144
|
if (claimRotationLock(lock, owner)) return { lock, owner };
|
|
25994
26145
|
let held;
|
|
25995
26146
|
try {
|
|
25996
|
-
held =
|
|
26147
|
+
held = statSync5(lock);
|
|
25997
26148
|
} catch {
|
|
25998
26149
|
throw new Error(ROTATION_IN_PROGRESS);
|
|
25999
26150
|
}
|
|
26000
26151
|
if (Date.now() - held.mtimeMs < ROTATION_LOCK_STALE_MS) throw new Error(ROTATION_IN_PROGRESS);
|
|
26001
26152
|
const aside = `${lock}.stale.${owner}`;
|
|
26002
26153
|
try {
|
|
26003
|
-
const now =
|
|
26154
|
+
const now = statSync5(lock);
|
|
26004
26155
|
if (now.ino !== held.ino || now.mtimeMs !== held.mtimeMs) {
|
|
26005
26156
|
throw new Error(ROTATION_IN_PROGRESS);
|
|
26006
26157
|
}
|
|
@@ -26009,17 +26160,17 @@ function acquireRotationLock(keysDir2) {
|
|
|
26009
26160
|
if (err instanceof Error && err.message === ROTATION_IN_PROGRESS) throw err;
|
|
26010
26161
|
throw new Error(ROTATION_IN_PROGRESS, { cause: err });
|
|
26011
26162
|
}
|
|
26012
|
-
|
|
26163
|
+
rmSync5(aside, { recursive: true, force: true });
|
|
26013
26164
|
if (!claimRotationLock(lock, owner)) throw new Error(ROTATION_IN_PROGRESS);
|
|
26014
26165
|
return { lock, owner };
|
|
26015
26166
|
}
|
|
26016
26167
|
function releaseRotationLock(lease) {
|
|
26017
26168
|
try {
|
|
26018
|
-
if (
|
|
26169
|
+
if (readFileSync6(join8(lease.lock, LOCK_OWNER_FILE), "utf8").trim() !== lease.owner) return;
|
|
26019
26170
|
} catch {
|
|
26020
26171
|
return;
|
|
26021
26172
|
}
|
|
26022
|
-
|
|
26173
|
+
rmSync5(lease.lock, { recursive: true, force: true });
|
|
26023
26174
|
}
|
|
26024
26175
|
function withRotationLock(keysDir2, work) {
|
|
26025
26176
|
ensureDataDirSync(keysDir2);
|
|
@@ -26036,7 +26187,7 @@ var FileKeyProvider = class {
|
|
|
26036
26187
|
this.#keysDir = keysDir2;
|
|
26037
26188
|
}
|
|
26038
26189
|
get filePath() {
|
|
26039
|
-
return
|
|
26190
|
+
return join8(this.#keysDir, VAULT_KEY_FILENAME);
|
|
26040
26191
|
}
|
|
26041
26192
|
loadOrCreate() {
|
|
26042
26193
|
return asAsync(() => {
|
|
@@ -26066,7 +26217,7 @@ var FileKeyProvider = class {
|
|
|
26066
26217
|
#read() {
|
|
26067
26218
|
let raw;
|
|
26068
26219
|
try {
|
|
26069
|
-
raw =
|
|
26220
|
+
raw = readFileSync6(this.filePath, "utf8");
|
|
26070
26221
|
} catch (err) {
|
|
26071
26222
|
if (err.code === "ENOENT") return null;
|
|
26072
26223
|
throw err instanceof Error ? err : new Error(String(err));
|
|
@@ -26123,7 +26274,7 @@ var FileKeyProvider = class {
|
|
|
26123
26274
|
};
|
|
26124
26275
|
function tightenFileMode(file2) {
|
|
26125
26276
|
try {
|
|
26126
|
-
|
|
26277
|
+
chmodSync3(file2, DATA_FILE_MODE);
|
|
26127
26278
|
} catch {
|
|
26128
26279
|
}
|
|
26129
26280
|
}
|
|
@@ -26693,8 +26844,8 @@ var SecretVault = class {
|
|
|
26693
26844
|
};
|
|
26694
26845
|
|
|
26695
26846
|
// ../../packages/persistence/src/warn-era-cap.ts
|
|
26696
|
-
import { existsSync as
|
|
26697
|
-
import { join as
|
|
26847
|
+
import { existsSync as existsSync5, writeFileSync as writeFileSync4 } from "fs";
|
|
26848
|
+
import { join as join9 } from "path";
|
|
26698
26849
|
|
|
26699
26850
|
// ../../packages/plugin-sdk/src/provider-env.ts
|
|
26700
26851
|
var DEFAULT_ANTHROPIC_HOST = "api.anthropic.com";
|
|
@@ -26748,8 +26899,8 @@ function resolveProvider() {
|
|
|
26748
26899
|
function loadConfig(base = defaultDataDir(), resolveProviderFn = resolveProvider) {
|
|
26749
26900
|
try {
|
|
26750
26901
|
ensureLayoutDirSync(base);
|
|
26751
|
-
const settingsFile =
|
|
26752
|
-
if (
|
|
26902
|
+
const settingsFile = join10(settingsDir(base), "settings.json");
|
|
26903
|
+
if (existsSync6(settingsFile)) tightenFile(settingsFile);
|
|
26753
26904
|
} catch {
|
|
26754
26905
|
}
|
|
26755
26906
|
migrateLegacyLayout(base);
|
|
@@ -26772,9 +26923,9 @@ function resolveProviderSafe(resolveProviderFn) {
|
|
|
26772
26923
|
}
|
|
26773
26924
|
|
|
26774
26925
|
// ../../packages/plugin-sdk/src/config-inventory.ts
|
|
26775
|
-
import { readdirSync as readdirSync2, readFileSync as
|
|
26926
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync8, realpathSync as realpathSync2, statSync as statSync7 } from "fs";
|
|
26776
26927
|
import { homedir as homedir2 } from "os";
|
|
26777
|
-
import { basename as basename3, join as
|
|
26928
|
+
import { basename as basename3, join as join12 } from "path";
|
|
26778
26929
|
|
|
26779
26930
|
// ../../packages/detections/src/egress/registry.ts
|
|
26780
26931
|
var EXTRACTOR_VERSION = "1";
|
|
@@ -28432,10 +28583,10 @@ var localhost_ref_default = {
|
|
|
28432
28583
|
severity: "low",
|
|
28433
28584
|
matcher: {
|
|
28434
28585
|
type: "regex",
|
|
28435
|
-
pattern: "
|
|
28586
|
+
pattern: "(?<![A-Za-z0-9_])(?:localhost|127\\.0\\.0\\.1|0\\.0\\.0\\.0|(?<![A-Za-z0-9_]\\[)::1(?!:|\\.[0-9]))(?![A-Za-z0-9_])",
|
|
28436
28587
|
flags: "g"
|
|
28437
28588
|
},
|
|
28438
|
-
examples: ["localhost", "127.0.0.1"]
|
|
28589
|
+
examples: ["localhost", "127.0.0.1", "0.0.0.0", "::1"]
|
|
28439
28590
|
};
|
|
28440
28591
|
|
|
28441
28592
|
// ../../rules/core-code-context/stack-trace.json
|
|
@@ -29732,36 +29883,36 @@ function registerBundledPacks() {
|
|
|
29732
29883
|
}
|
|
29733
29884
|
|
|
29734
29885
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
29735
|
-
import { existsSync as
|
|
29736
|
-
import { basename as basename2, dirname as
|
|
29886
|
+
import { existsSync as existsSync7, readFileSync as readFileSync7, statSync as statSync6 } from "fs";
|
|
29887
|
+
import { basename as basename2, dirname as dirname3, isAbsolute, join as join11, sep as sep2 } from "path";
|
|
29737
29888
|
|
|
29738
29889
|
// ../../packages/plugin-sdk/src/events.ts
|
|
29739
29890
|
import { createHash as createHash4, randomUUID as randomUUID13 } from "crypto";
|
|
29740
29891
|
|
|
29741
29892
|
// ../../packages/plugin-sdk/src/isolated-scan.ts
|
|
29742
|
-
import { existsSync as
|
|
29893
|
+
import { existsSync as existsSync8 } from "fs";
|
|
29743
29894
|
import { fileURLToPath } from "url";
|
|
29744
29895
|
import { Worker } from "worker_threads";
|
|
29745
29896
|
|
|
29746
29897
|
// ../../packages/plugin-sdk/src/ignore-layers.ts
|
|
29747
29898
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
29748
|
-
import { readFileSync as
|
|
29749
|
-
import { join as
|
|
29899
|
+
import { readFileSync as readFileSync9 } from "fs";
|
|
29900
|
+
import { join as join13 } from "path";
|
|
29750
29901
|
|
|
29751
29902
|
// ../../packages/plugin-sdk/src/inventory-resolver.ts
|
|
29752
29903
|
import { arch, hostname as hostname4, platform, release } from "os";
|
|
29753
29904
|
|
|
29754
29905
|
// ../../packages/plugin-sdk/src/nudge.ts
|
|
29755
|
-
import { mkdirSync as mkdirSync2, readFileSync as
|
|
29756
|
-
import { join as
|
|
29906
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync10, writeFileSync as writeFileSync5 } from "fs";
|
|
29907
|
+
import { join as join14 } from "path";
|
|
29757
29908
|
|
|
29758
29909
|
// ../../packages/plugin-sdk/src/paths.ts
|
|
29759
|
-
import { readdirSync as readdirSync3, realpathSync as
|
|
29760
|
-
import { basename as basename4, dirname as
|
|
29910
|
+
import { readdirSync as readdirSync3, realpathSync as realpathSync3 } from "fs";
|
|
29911
|
+
import { basename as basename4, dirname as dirname4, sep as sep3 } from "path";
|
|
29761
29912
|
|
|
29762
29913
|
// ../../packages/plugin-sdk/src/project-files.ts
|
|
29763
|
-
import { existsSync as
|
|
29764
|
-
import { basename as basename5, join as
|
|
29914
|
+
import { existsSync as existsSync9, readdirSync as readdirSync4 } from "fs";
|
|
29915
|
+
import { basename as basename5, join as join15 } from "path";
|
|
29765
29916
|
|
|
29766
29917
|
// ../../packages/plugin-sdk/src/provider-env-antigravity.ts
|
|
29767
29918
|
var optionalBaseUrl2 = external_exports.preprocess((v) => {
|
|
@@ -29796,8 +29947,8 @@ import { randomUUID as randomUUID14 } from "crypto";
|
|
|
29796
29947
|
var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
29797
29948
|
|
|
29798
29949
|
// ../../packages/plugin-sdk/src/throttle.ts
|
|
29799
|
-
import { mkdirSync as mkdirSync3, statSync as
|
|
29800
|
-
import { join as
|
|
29950
|
+
import { mkdirSync as mkdirSync3, statSync as statSync8, writeFileSync as writeFileSync6 } from "fs";
|
|
29951
|
+
import { join as join16 } from "path";
|
|
29801
29952
|
|
|
29802
29953
|
// ../../packages/plugin-sdk/src/tokenize.ts
|
|
29803
29954
|
function redactedPlaceholder(category) {
|
|
@@ -30114,13 +30265,13 @@ function describePointerSafe(token) {
|
|
|
30114
30265
|
import {
|
|
30115
30266
|
mkdirSync as mkdirSync4,
|
|
30116
30267
|
readdirSync as readdirSync5,
|
|
30117
|
-
readFileSync as
|
|
30268
|
+
readFileSync as readFileSync11,
|
|
30118
30269
|
renameSync as renameSync5,
|
|
30119
|
-
rmSync as
|
|
30120
|
-
statSync as
|
|
30270
|
+
rmSync as rmSync6,
|
|
30271
|
+
statSync as statSync9,
|
|
30121
30272
|
writeFileSync as writeFileSync7
|
|
30122
30273
|
} from "fs";
|
|
30123
|
-
import { dirname as
|
|
30274
|
+
import { dirname as dirname5, join as join17 } from "path";
|
|
30124
30275
|
var EMPTY_CARRY = Object.freeze({
|
|
30125
30276
|
tail: "",
|
|
30126
30277
|
fence: null,
|
|
@@ -30317,7 +30468,7 @@ var CARRY_FILE_PREFIX = "display-carry";
|
|
|
30317
30468
|
var STALE_CARRY_MS = 15 * 60 * 1e3;
|
|
30318
30469
|
function carryFilePath(dataDir2, sessionId) {
|
|
30319
30470
|
const safe = sessionId.replace(/[^A-Za-z0-9_-]/g, "_").slice(0, 80);
|
|
30320
|
-
return
|
|
30471
|
+
return join17(dataDir2, `${CARRY_FILE_PREFIX}-${safe === "" ? "session" : safe}.json`);
|
|
30321
30472
|
}
|
|
30322
30473
|
function parseFence(value) {
|
|
30323
30474
|
if (typeof value !== "object" || value === null) return null;
|
|
@@ -30328,7 +30479,7 @@ function parseFence(value) {
|
|
|
30328
30479
|
}
|
|
30329
30480
|
function loadCarry(file2, keys) {
|
|
30330
30481
|
try {
|
|
30331
|
-
const parsed = JSON.parse(
|
|
30482
|
+
const parsed = JSON.parse(readFileSync11(file2, "utf8"));
|
|
30332
30483
|
if (typeof parsed !== "object" || parsed === null) return EMPTY_CARRY;
|
|
30333
30484
|
const record2 = parsed;
|
|
30334
30485
|
const revealedCount = record2.messageKey === keys.messageKey && typeof record2.revealedCount === "number" && Number.isFinite(record2.revealedCount) ? record2.revealedCount : 0;
|
|
@@ -30381,10 +30532,10 @@ function removeStaleCarryFiles(dir, keep) {
|
|
|
30381
30532
|
const cutoff = Date.now() - STALE_CARRY_MS;
|
|
30382
30533
|
for (const name of readdirSync5(dir)) {
|
|
30383
30534
|
if (!name.startsWith(CARRY_FILE_PREFIX) || !name.endsWith(".json")) continue;
|
|
30384
|
-
const path =
|
|
30535
|
+
const path = join17(dir, name);
|
|
30385
30536
|
if (path === keep) continue;
|
|
30386
30537
|
try {
|
|
30387
|
-
if (
|
|
30538
|
+
if (statSync9(path).mtimeMs < cutoff) rmSync6(path, { force: true });
|
|
30388
30539
|
} catch {
|
|
30389
30540
|
}
|
|
30390
30541
|
}
|
|
@@ -30393,7 +30544,7 @@ function removeStaleCarryFiles(dir, keep) {
|
|
|
30393
30544
|
}
|
|
30394
30545
|
function saveCarry(file2, keys, carry) {
|
|
30395
30546
|
try {
|
|
30396
|
-
const dir =
|
|
30547
|
+
const dir = dirname5(file2);
|
|
30397
30548
|
mkdirSync4(dir, { recursive: true });
|
|
30398
30549
|
removeStaleCarryFiles(dir, file2);
|
|
30399
30550
|
writeCarryRecord(file2, keys.blockKey, keys.messageKey, carry);
|
|
@@ -30403,7 +30554,7 @@ function saveCarry(file2, keys, carry) {
|
|
|
30403
30554
|
function finalizeCarry(file2, keys, carry) {
|
|
30404
30555
|
try {
|
|
30405
30556
|
if (carry.revealedCount > 0) {
|
|
30406
|
-
mkdirSync4(
|
|
30557
|
+
mkdirSync4(dirname5(file2), { recursive: true });
|
|
30407
30558
|
writeCarryRecord(file2, null, keys.messageKey, {
|
|
30408
30559
|
...EMPTY_CARRY,
|
|
30409
30560
|
revealedCount: carry.revealedCount
|
|
@@ -30412,21 +30563,21 @@ function finalizeCarry(file2, keys, carry) {
|
|
|
30412
30563
|
}
|
|
30413
30564
|
let owned = true;
|
|
30414
30565
|
try {
|
|
30415
|
-
const parsed = JSON.parse(
|
|
30566
|
+
const parsed = JSON.parse(readFileSync11(file2, "utf8"));
|
|
30416
30567
|
if (typeof parsed === "object" && parsed !== null) {
|
|
30417
30568
|
const record2 = parsed;
|
|
30418
30569
|
owned = record2.blockKey === keys.blockKey || record2.messageKey === keys.messageKey;
|
|
30419
30570
|
}
|
|
30420
30571
|
} catch {
|
|
30421
30572
|
}
|
|
30422
|
-
if (owned)
|
|
30573
|
+
if (owned) rmSync6(file2, { force: true });
|
|
30423
30574
|
} catch {
|
|
30424
30575
|
}
|
|
30425
30576
|
}
|
|
30426
30577
|
|
|
30427
30578
|
// src/hooks/shared.ts
|
|
30428
30579
|
async function readStdin() {
|
|
30429
|
-
return new Promise((
|
|
30580
|
+
return new Promise((resolve2) => {
|
|
30430
30581
|
let data = "";
|
|
30431
30582
|
let settled = false;
|
|
30432
30583
|
const finish = () => {
|
|
@@ -30435,7 +30586,7 @@ async function readStdin() {
|
|
|
30435
30586
|
clearTimeout(timer);
|
|
30436
30587
|
process.stdin.removeListener("data", onData);
|
|
30437
30588
|
process.stdin.removeListener("end", finish);
|
|
30438
|
-
|
|
30589
|
+
resolve2(data);
|
|
30439
30590
|
};
|
|
30440
30591
|
const onData = (chunk) => {
|
|
30441
30592
|
data += chunk;
|
|
@@ -30460,12 +30611,12 @@ function getString(record2, key) {
|
|
|
30460
30611
|
return typeof value === "string" ? value : void 0;
|
|
30461
30612
|
}
|
|
30462
30613
|
function emit(output) {
|
|
30463
|
-
return new Promise((
|
|
30614
|
+
return new Promise((resolve2) => {
|
|
30464
30615
|
let settled = false;
|
|
30465
30616
|
const finish = () => {
|
|
30466
30617
|
if (settled) return;
|
|
30467
30618
|
settled = true;
|
|
30468
|
-
|
|
30619
|
+
resolve2();
|
|
30469
30620
|
};
|
|
30470
30621
|
process.stdout.on("error", finish);
|
|
30471
30622
|
process.stdout.write(JSON.stringify(output), finish);
|