@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/stop.js
CHANGED
|
@@ -50,7 +50,7 @@ var require_ignore = __commonJS({
|
|
|
50
50
|
var REGEX_SPLITALL_CRLF = /\r?\n/g;
|
|
51
51
|
var REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/;
|
|
52
52
|
var REGEX_TEST_TRAILING_SLASH = /\/$/;
|
|
53
|
-
var
|
|
53
|
+
var SLASH2 = "/";
|
|
54
54
|
var TMP_KEY_IGNORE = "node-ignore";
|
|
55
55
|
if (typeof Symbol !== "undefined") {
|
|
56
56
|
TMP_KEY_IGNORE = /* @__PURE__ */ Symbol.for("node-ignore");
|
|
@@ -422,11 +422,11 @@ var require_ignore = __commonJS({
|
|
|
422
422
|
if (!REGEX_TEST_TRAILING_SLASH.test(path)) {
|
|
423
423
|
return this.test(path);
|
|
424
424
|
}
|
|
425
|
-
const slices = path.split(
|
|
425
|
+
const slices = path.split(SLASH2).filter(Boolean);
|
|
426
426
|
slices.pop();
|
|
427
427
|
if (slices.length) {
|
|
428
428
|
const parent = this._t(
|
|
429
|
-
slices.join(
|
|
429
|
+
slices.join(SLASH2) + SLASH2,
|
|
430
430
|
this._testCache,
|
|
431
431
|
true,
|
|
432
432
|
slices
|
|
@@ -442,14 +442,14 @@ var require_ignore = __commonJS({
|
|
|
442
442
|
return cache[path];
|
|
443
443
|
}
|
|
444
444
|
if (!slices) {
|
|
445
|
-
slices = path.split(
|
|
445
|
+
slices = path.split(SLASH2).filter(Boolean);
|
|
446
446
|
}
|
|
447
447
|
slices.pop();
|
|
448
448
|
if (!slices.length) {
|
|
449
449
|
return cache[path] = this._rules.test(path, checkUnignored, MODE_IGNORE);
|
|
450
450
|
}
|
|
451
451
|
const parent = this._t(
|
|
452
|
-
slices.join(
|
|
452
|
+
slices.join(SLASH2) + SLASH2,
|
|
453
453
|
cache,
|
|
454
454
|
checkUnignored,
|
|
455
455
|
slices
|
|
@@ -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/exception-scope.ts
|
|
504
503
|
var MINUTE_MS = 6e4;
|
|
@@ -15963,6 +15962,124 @@ var ConfigScanRecord = external_exports.object({
|
|
|
15963
15962
|
findings: external_exports.array(ConfigPostureFindingInput).optional()
|
|
15964
15963
|
});
|
|
15965
15964
|
|
|
15965
|
+
// ../../packages/schema/src/zod/control-plane.ts
|
|
15966
|
+
var ATTACHED_CREDENTIAL_SPEC_VERSION = 1;
|
|
15967
|
+
var AttachedCredential = external_exports.object({
|
|
15968
|
+
specVersion: external_exports.literal(ATTACHED_CREDENTIAL_SPEC_VERSION),
|
|
15969
|
+
// The control-plane endpoint this credential was minted against.
|
|
15970
|
+
endpoint: external_exports.string().min(1),
|
|
15971
|
+
// The bearer credential itself. Never logged, never rendered — status
|
|
15972
|
+
// surfaces show `keyPrefix` and nothing else.
|
|
15973
|
+
apiKey: external_exports.string().min(1),
|
|
15974
|
+
// First few characters of the key, safe to display so a user can match the
|
|
15975
|
+
// credential against their organization's key list.
|
|
15976
|
+
keyPrefix: external_exports.string().min(1).max(16).optional(),
|
|
15977
|
+
mintedAt: external_exports.iso.datetime().optional()
|
|
15978
|
+
});
|
|
15979
|
+
var MAX_DATE_MS = 253402300799999;
|
|
15980
|
+
var MAX_INT4 = 2147483647;
|
|
15981
|
+
var StorePosturePack = external_exports.object({
|
|
15982
|
+
packId: external_exports.string().min(1),
|
|
15983
|
+
// 'namespace/packId'
|
|
15984
|
+
version: external_exports.string().min(1),
|
|
15985
|
+
enabled: external_exports.boolean(),
|
|
15986
|
+
// Stringified pass-through of the local store's `installed_packs.updated_at`
|
|
15987
|
+
// — the column format is store-version-dependent (epoch millis vs ISO), so
|
|
15988
|
+
// the wire shape assumes neither.
|
|
15989
|
+
updatedAt: external_exports.string().nullable()
|
|
15990
|
+
}).meta({ id: "StorePosturePack" });
|
|
15991
|
+
var StorePosturePolicyCounts = external_exports.object({
|
|
15992
|
+
total: external_exports.number().int().min(0),
|
|
15993
|
+
disabled: external_exports.number().int().min(0),
|
|
15994
|
+
// Exhaustive per-action map; the builder pre-fills every action with 0.
|
|
15995
|
+
//
|
|
15996
|
+
// Spelled out member-by-member rather than `z.record(ActionTaken, …)`. Zod
|
|
15997
|
+
// enforces exhaustiveness either way, but z.record emits `propertyNames` +
|
|
15998
|
+
// `additionalProperties` into a generated schema document, and a type
|
|
15999
|
+
// generator renders THAT with every key optional — a sender built against
|
|
16000
|
+
// the generated type would typecheck and still be rejected at runtime. An
|
|
16001
|
+
// explicit object emits `properties` + `required`, so generated types
|
|
16002
|
+
// demand all five.
|
|
16003
|
+
//
|
|
16004
|
+
// `satisfies Record<ActionTaken, …>` keeps the link to the enum: adding an
|
|
16005
|
+
// ActionTaken member is a COMPILE error here instead of silent drift.
|
|
16006
|
+
// `.strict()` is load-bearing — it rejects an unknown action key, which a
|
|
16007
|
+
// bare object would silently STRIP, accepting a miscounted map as valid.
|
|
16008
|
+
byAction: external_exports.object({
|
|
16009
|
+
warn: external_exports.number().int().min(0),
|
|
16010
|
+
redact: external_exports.number().int().min(0),
|
|
16011
|
+
block: external_exports.number().int().min(0),
|
|
16012
|
+
allow: external_exports.number().int().min(0),
|
|
16013
|
+
log: external_exports.number().int().min(0)
|
|
16014
|
+
}).strict()
|
|
16015
|
+
}).meta({ id: "StorePosturePolicyCounts" });
|
|
16016
|
+
var StorePosturePlugin = external_exports.object({
|
|
16017
|
+
/** Package name of the reporting plugin. */
|
|
16018
|
+
package: external_exports.string().min(1).max(200),
|
|
16019
|
+
version: external_exports.string().min(1).max(64),
|
|
16020
|
+
/** Version of the bundled core, when the build records one separately. */
|
|
16021
|
+
ossVersion: external_exports.string().max(64).nullable(),
|
|
16022
|
+
/**
|
|
16023
|
+
* `version` of the policy bundle this machine last fetched. Bounded at 200
|
|
16024
|
+
* rather than the 64 a bare sha256 hex digest needs today, so a later
|
|
16025
|
+
* format with an algorithm prefix does not start rejecting the channel.
|
|
16026
|
+
*/
|
|
16027
|
+
policyBundleVersion: external_exports.string().max(200).nullable(),
|
|
16028
|
+
/** Epoch millis, on the CLIENT clock, of that fetch. */
|
|
16029
|
+
policyFetchedAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable()
|
|
16030
|
+
}).meta({ id: "StorePosturePlugin" });
|
|
16031
|
+
var StorePostureSnapshot = external_exports.object({
|
|
16032
|
+
deviceId: external_exports.guid(),
|
|
16033
|
+
hostname: external_exports.string().min(1).max(253),
|
|
16034
|
+
// Epoch millis on the CLIENT clock. Bounded by what a receiving store
|
|
16035
|
+
// accepts (see MAX_DATE_MS), not by what a JavaScript Date can hold.
|
|
16036
|
+
capturedAt: external_exports.number().int().min(0).max(MAX_DATE_MS),
|
|
16037
|
+
// False is a measurement, not an error state: "no local store exists on
|
|
16038
|
+
// this machine".
|
|
16039
|
+
storePresent: external_exports.boolean(),
|
|
16040
|
+
schemaVersion: external_exports.number().int().min(0).max(MAX_INT4).nullable(),
|
|
16041
|
+
// PRAGMA user_version
|
|
16042
|
+
findingsTotal: external_exports.number().int().min(0).max(MAX_INT4),
|
|
16043
|
+
// Epoch millis, bounded like `capturedAt` — see MAX_DATE_MS on what that
|
|
16044
|
+
// bound does and does not do. Worth stating for these two specifically:
|
|
16045
|
+
// they are read from the local store's own ROWS rather than from this
|
|
16046
|
+
// machine's clock, so a damaged or hand-edited store is enough to produce
|
|
16047
|
+
// an out-of-range value with no clock skew involved.
|
|
16048
|
+
findingsFirstAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable(),
|
|
16049
|
+
findingsLastAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable(),
|
|
16050
|
+
packs: external_exports.array(StorePosturePack).max(500),
|
|
16051
|
+
policyCounts: StorePosturePolicyCounts,
|
|
16052
|
+
// OPTIONAL, not nullable: a reporter that predates this member keeps
|
|
16053
|
+
// getting its 200 without a payload change.
|
|
16054
|
+
plugin: StorePosturePlugin.optional()
|
|
16055
|
+
}).meta({ id: "StorePostureSnapshot" });
|
|
16056
|
+
var CAPTURE_VERSION_PREFIX = "capture/";
|
|
16057
|
+
var RecordAuditEventRequest = AuditEventInput.extend({
|
|
16058
|
+
inspections: external_exports.array(ToolCallInspection).default([])
|
|
16059
|
+
}).refine((v) => v.inspections.every((i) => !i.ruleVersion.startsWith(CAPTURE_VERSION_PREFIX)), {
|
|
16060
|
+
message: `inspections[].ruleVersion must not start with \`${CAPTURE_VERSION_PREFIX}\` \u2014 that namespace is reserved for capture definitions the control plane mints itself`,
|
|
16061
|
+
path: ["inspections"]
|
|
16062
|
+
}).meta({ id: "RecordAuditEventRequest" });
|
|
16063
|
+
var IngestAck = external_exports.object({
|
|
16064
|
+
accepted: external_exports.number().int().nonnegative(),
|
|
16065
|
+
duplicates: external_exports.number().int().nonnegative()
|
|
16066
|
+
});
|
|
16067
|
+
var PRINTABLE = /^[^\p{Cc}\p{Cf}]*$/u;
|
|
16068
|
+
var printable = (max) => external_exports.string().max(max).regex(PRINTABLE, "must not contain control characters");
|
|
16069
|
+
var PluginWhoami = external_exports.object({
|
|
16070
|
+
tenantName: printable(200),
|
|
16071
|
+
userEmail: printable(320),
|
|
16072
|
+
role: printable(64),
|
|
16073
|
+
keyKind: printable(64),
|
|
16074
|
+
serverTime: printable(64)
|
|
16075
|
+
});
|
|
16076
|
+
var ControlPlaneErrorBody = external_exports.object({
|
|
16077
|
+
error: external_exports.object({
|
|
16078
|
+
code: external_exports.string().optional(),
|
|
16079
|
+
message: external_exports.string().optional()
|
|
16080
|
+
}).optional()
|
|
16081
|
+
});
|
|
16082
|
+
|
|
15966
16083
|
// ../../packages/schema/src/zod/registry.ts
|
|
15967
16084
|
var Namespace = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
15968
16085
|
var PackId = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
@@ -17607,14 +17724,6 @@ var SetupHandoffOffer = external_exports.object({
|
|
|
17607
17724
|
path: ["liveKeys"]
|
|
17608
17725
|
});
|
|
17609
17726
|
|
|
17610
|
-
// ../../packages/persistence/src/ids.ts
|
|
17611
|
-
import { createHash } from "crypto";
|
|
17612
|
-
|
|
17613
|
-
// ../../packages/persistence/src/internal/snapshot.ts
|
|
17614
|
-
import { randomUUID } from "crypto";
|
|
17615
|
-
import { existsSync, readdirSync, renameSync as renameSync2, rmSync as rmSync2, statSync } from "fs";
|
|
17616
|
-
import { basename, dirname, join } from "path";
|
|
17617
|
-
|
|
17618
17727
|
// ../../packages/persistence/src/paths.ts
|
|
17619
17728
|
import {
|
|
17620
17729
|
chmodSync,
|
|
@@ -17656,7 +17765,18 @@ function tightenFile(file2) {
|
|
|
17656
17765
|
chmodBestEffort(file2, DATA_FILE_MODE);
|
|
17657
17766
|
}
|
|
17658
17767
|
|
|
17768
|
+
// ../../packages/persistence/src/database.ts
|
|
17769
|
+
import { randomUUID as randomUUID10 } from "crypto";
|
|
17770
|
+
import { join as join3, sep } from "path";
|
|
17771
|
+
import { DatabaseSync } from "node:sqlite";
|
|
17772
|
+
|
|
17773
|
+
// ../../packages/persistence/src/ids.ts
|
|
17774
|
+
import { createHash } from "crypto";
|
|
17775
|
+
|
|
17659
17776
|
// ../../packages/persistence/src/internal/snapshot.ts
|
|
17777
|
+
import { randomUUID } from "crypto";
|
|
17778
|
+
import { existsSync, readdirSync, renameSync as renameSync2, rmSync as rmSync3, statSync as statSync2 } from "fs";
|
|
17779
|
+
import { basename, dirname, join as join2 } from "path";
|
|
17660
17780
|
var STALE_PARTIAL_MS = 5 * 6e4;
|
|
17661
17781
|
var SNAPSHOT_STAGING_SUFFIX = ".partial";
|
|
17662
17782
|
var STAGED_NAME_SUFFIX = `.bak${SNAPSHOT_STAGING_SUFFIX}`;
|
|
@@ -17741,9 +17861,9 @@ import {
|
|
|
17741
17861
|
closeSync,
|
|
17742
17862
|
existsSync as existsSync2,
|
|
17743
17863
|
openSync,
|
|
17744
|
-
readFileSync,
|
|
17745
|
-
rmSync as
|
|
17746
|
-
statSync as
|
|
17864
|
+
readFileSync as readFileSync2,
|
|
17865
|
+
rmSync as rmSync4,
|
|
17866
|
+
statSync as statSync3,
|
|
17747
17867
|
writeFileSync as writeFileSync2
|
|
17748
17868
|
} from "fs";
|
|
17749
17869
|
import { hostname as hostname3 } from "os";
|
|
@@ -17754,26 +17874,29 @@ import { createHash as createHash3 } from "crypto";
|
|
|
17754
17874
|
|
|
17755
17875
|
// ../../packages/persistence/src/fingerprint.ts
|
|
17756
17876
|
import { createHmac, randomBytes } from "crypto";
|
|
17757
|
-
import { existsSync as existsSync3, readFileSync as
|
|
17758
|
-
import { join as
|
|
17877
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
17878
|
+
import { join as join4 } from "path";
|
|
17759
17879
|
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
17760
17880
|
|
|
17761
17881
|
// ../../packages/persistence/src/local-layout.ts
|
|
17762
17882
|
import { renameSync as renameSync3 } from "fs";
|
|
17763
17883
|
import { mkdir } from "fs/promises";
|
|
17764
17884
|
import { homedir } from "os";
|
|
17765
|
-
import { join as
|
|
17885
|
+
import { join as join5 } from "path";
|
|
17766
17886
|
function defaultDataDir() {
|
|
17767
|
-
return
|
|
17887
|
+
return join5(homedir(), ".aka");
|
|
17768
17888
|
}
|
|
17769
17889
|
function settingsDir(base = defaultDataDir()) {
|
|
17770
|
-
return
|
|
17890
|
+
return join5(base, "settings");
|
|
17771
17891
|
}
|
|
17772
17892
|
function dataDir(base = defaultDataDir()) {
|
|
17773
|
-
return
|
|
17893
|
+
return join5(base, "data");
|
|
17774
17894
|
}
|
|
17775
17895
|
function dbPath(base = defaultDataDir()) {
|
|
17776
|
-
return
|
|
17896
|
+
return join5(dataDir(base), "aka.db");
|
|
17897
|
+
}
|
|
17898
|
+
function keysDir(base = defaultDataDir()) {
|
|
17899
|
+
return join5(base, "keys");
|
|
17777
17900
|
}
|
|
17778
17901
|
function ensureLayoutDirSync(dir = defaultDataDir()) {
|
|
17779
17902
|
ensureDataDirSync(dir);
|
|
@@ -17786,8 +17909,8 @@ function migrateLegacyLayout(base = defaultDataDir()) {
|
|
|
17786
17909
|
for (const { name, dest } of moves) {
|
|
17787
17910
|
try {
|
|
17788
17911
|
ensureDataDirSync(dest);
|
|
17789
|
-
const moved =
|
|
17790
|
-
renameSync3(
|
|
17912
|
+
const moved = join5(dest, name);
|
|
17913
|
+
renameSync3(join5(base, name), moved);
|
|
17791
17914
|
tightenFile(moved);
|
|
17792
17915
|
} catch {
|
|
17793
17916
|
}
|
|
@@ -17795,7 +17918,7 @@ function migrateLegacyLayout(base = defaultDataDir()) {
|
|
|
17795
17918
|
}
|
|
17796
17919
|
|
|
17797
17920
|
// ../../packages/persistence/src/managed-settings.ts
|
|
17798
|
-
import { readFileSync as
|
|
17921
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
17799
17922
|
import { posix, win32 } from "path";
|
|
17800
17923
|
function managedSettingsPaths(platform2 = process.platform) {
|
|
17801
17924
|
if (platform2 === "darwin") {
|
|
@@ -17813,7 +17936,7 @@ function readManagedSettings(paths = managedSettingsPaths()) {
|
|
|
17813
17936
|
for (const path of paths) {
|
|
17814
17937
|
let text;
|
|
17815
17938
|
try {
|
|
17816
|
-
text =
|
|
17939
|
+
text = readFileSync4(path, "utf8");
|
|
17817
17940
|
} catch {
|
|
17818
17941
|
continue;
|
|
17819
17942
|
}
|
|
@@ -17860,14 +17983,14 @@ function overlayManagedSettings(settings, managed, now = () => /* @__PURE__ */ n
|
|
|
17860
17983
|
}
|
|
17861
17984
|
|
|
17862
17985
|
// ../../packages/persistence/src/settings.ts
|
|
17863
|
-
import { readFileSync as
|
|
17864
|
-
import { join as
|
|
17986
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
17987
|
+
import { join as join6 } from "path";
|
|
17865
17988
|
var SETTINGS_FILENAME = "settings.json";
|
|
17866
17989
|
function readWorkspaceSettings(base = defaultDataDir()) {
|
|
17867
17990
|
return overlayManagedSettings(readUserSettings(base), readManagedSettings());
|
|
17868
17991
|
}
|
|
17869
17992
|
function readUserSettings(base) {
|
|
17870
|
-
const record2 = readJson(
|
|
17993
|
+
const record2 = readJson(join6(settingsDir(base), SETTINGS_FILENAME));
|
|
17871
17994
|
if (!record2) return defaultWorkspaceSettings();
|
|
17872
17995
|
try {
|
|
17873
17996
|
return WorkspaceSettings.parse(record2);
|
|
@@ -17878,13 +18001,64 @@ function readUserSettings(base) {
|
|
|
17878
18001
|
function readJson(file2) {
|
|
17879
18002
|
let text;
|
|
17880
18003
|
try {
|
|
17881
|
-
text =
|
|
18004
|
+
text = readFileSync5(file2, "utf8");
|
|
17882
18005
|
} catch {
|
|
17883
18006
|
return null;
|
|
17884
18007
|
}
|
|
17885
18008
|
return parseJsonObject(text) ?? null;
|
|
17886
18009
|
}
|
|
17887
18010
|
|
|
18011
|
+
// ../../packages/persistence/src/store-symlinks.ts
|
|
18012
|
+
import { existsSync as existsSync4, lstatSync as lstatSync3, readlinkSync, realpathSync, statSync as statSync4 } from "fs";
|
|
18013
|
+
import { dirname as dirname2, join as join7, resolve } from "path";
|
|
18014
|
+
var STORE_DB = "the store database (including the prompt corpus)";
|
|
18015
|
+
var STORE_SETTINGS = "your settings file";
|
|
18016
|
+
function storeContents(home) {
|
|
18017
|
+
return /* @__PURE__ */ new Map([
|
|
18018
|
+
[home, "the store (including the prompt corpus in aka.db)"],
|
|
18019
|
+
[settingsDir(home), STORE_SETTINGS],
|
|
18020
|
+
[dataDir(home), STORE_DB],
|
|
18021
|
+
[keysDir(home), "the vault key"],
|
|
18022
|
+
[join7(settingsDir(home), "settings.json"), STORE_SETTINGS],
|
|
18023
|
+
[dbPath(home), STORE_DB]
|
|
18024
|
+
]);
|
|
18025
|
+
}
|
|
18026
|
+
function symlinkedStorePaths(home, platform2 = process.platform) {
|
|
18027
|
+
return [...storeContents(home)].flatMap(([path, holds]) => {
|
|
18028
|
+
try {
|
|
18029
|
+
if (!lstatSync3(path).isSymbolicLink()) return [];
|
|
18030
|
+
return [
|
|
18031
|
+
{
|
|
18032
|
+
path,
|
|
18033
|
+
target: linkTarget(path),
|
|
18034
|
+
holds,
|
|
18035
|
+
// existsSync follows the link, so a target that is gone reads as
|
|
18036
|
+
// absent here while lstat above still sees the link itself.
|
|
18037
|
+
missing: !existsSync4(path),
|
|
18038
|
+
mode: targetMode(path, platform2)
|
|
18039
|
+
}
|
|
18040
|
+
];
|
|
18041
|
+
} catch {
|
|
18042
|
+
return [];
|
|
18043
|
+
}
|
|
18044
|
+
});
|
|
18045
|
+
}
|
|
18046
|
+
function linkTarget(path) {
|
|
18047
|
+
try {
|
|
18048
|
+
return realpathSync(path);
|
|
18049
|
+
} catch {
|
|
18050
|
+
return resolve(dirname2(path), readlinkSync(path));
|
|
18051
|
+
}
|
|
18052
|
+
}
|
|
18053
|
+
function targetMode(path, platform2) {
|
|
18054
|
+
if (platform2 === "win32") return void 0;
|
|
18055
|
+
try {
|
|
18056
|
+
return statSync4(path).mode & 511;
|
|
18057
|
+
} catch {
|
|
18058
|
+
return void 0;
|
|
18059
|
+
}
|
|
18060
|
+
}
|
|
18061
|
+
|
|
17888
18062
|
// ../../packages/persistence/src/vault/crypto.ts
|
|
17889
18063
|
import {
|
|
17890
18064
|
createCipheriv,
|
|
@@ -17897,15 +18071,15 @@ import {
|
|
|
17897
18071
|
// ../../packages/persistence/src/vault/key-provider.ts
|
|
17898
18072
|
import { execFileSync } from "child_process";
|
|
17899
18073
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
17900
|
-
import { chmodSync as
|
|
17901
|
-
import { join as
|
|
18074
|
+
import { chmodSync as chmodSync3, readFileSync as readFileSync6, renameSync as renameSync4, rmSync as rmSync5, statSync as statSync5, writeFileSync as writeFileSync3 } from "fs";
|
|
18075
|
+
import { join as join8 } from "path";
|
|
17902
18076
|
|
|
17903
18077
|
// ../../packages/persistence/src/vault/vault.ts
|
|
17904
18078
|
import { randomBytes as randomBytes3, randomUUID as randomUUID12 } from "crypto";
|
|
17905
18079
|
|
|
17906
18080
|
// ../../packages/persistence/src/warn-era-cap.ts
|
|
17907
|
-
import { existsSync as
|
|
17908
|
-
import { join as
|
|
18081
|
+
import { existsSync as existsSync5, writeFileSync as writeFileSync4 } from "fs";
|
|
18082
|
+
import { join as join9 } from "path";
|
|
17909
18083
|
|
|
17910
18084
|
// ../../packages/plugin-sdk/src/provider-env.ts
|
|
17911
18085
|
var DEFAULT_ANTHROPIC_HOST = "api.anthropic.com";
|
|
@@ -17959,8 +18133,8 @@ function resolveProvider() {
|
|
|
17959
18133
|
function loadConfig(base = defaultDataDir(), resolveProviderFn = resolveProvider) {
|
|
17960
18134
|
try {
|
|
17961
18135
|
ensureLayoutDirSync(base);
|
|
17962
|
-
const settingsFile =
|
|
17963
|
-
if (
|
|
18136
|
+
const settingsFile = join10(settingsDir(base), "settings.json");
|
|
18137
|
+
if (existsSync6(settingsFile)) tightenFile(settingsFile);
|
|
17964
18138
|
} catch {
|
|
17965
18139
|
}
|
|
17966
18140
|
migrateLegacyLayout(base);
|
|
@@ -17983,9 +18157,9 @@ function resolveProviderSafe(resolveProviderFn) {
|
|
|
17983
18157
|
}
|
|
17984
18158
|
|
|
17985
18159
|
// ../../packages/plugin-sdk/src/config-inventory.ts
|
|
17986
|
-
import { readdirSync as readdirSync2, readFileSync as
|
|
18160
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync8, realpathSync as realpathSync2, statSync as statSync7 } from "fs";
|
|
17987
18161
|
import { homedir as homedir2 } from "os";
|
|
17988
|
-
import { basename as basename3, join as
|
|
18162
|
+
import { basename as basename3, join as join12 } from "path";
|
|
17989
18163
|
|
|
17990
18164
|
// ../../packages/detections/src/egress/registry.ts
|
|
17991
18165
|
var EXTRACTOR_VERSION = "1";
|
|
@@ -18743,36 +18917,36 @@ var CPU_CORROBORATION_SHARE = 0.2;
|
|
|
18743
18917
|
var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
|
|
18744
18918
|
|
|
18745
18919
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
18746
|
-
import { existsSync as
|
|
18747
|
-
import { basename as basename2, dirname as
|
|
18920
|
+
import { existsSync as existsSync7, readFileSync as readFileSync7, statSync as statSync6 } from "fs";
|
|
18921
|
+
import { basename as basename2, dirname as dirname3, isAbsolute, join as join11, sep as sep2 } from "path";
|
|
18748
18922
|
|
|
18749
18923
|
// ../../packages/plugin-sdk/src/events.ts
|
|
18750
18924
|
import { createHash as createHash4, randomUUID as randomUUID13 } from "crypto";
|
|
18751
18925
|
|
|
18752
18926
|
// ../../packages/plugin-sdk/src/isolated-scan.ts
|
|
18753
|
-
import { existsSync as
|
|
18927
|
+
import { existsSync as existsSync8 } from "fs";
|
|
18754
18928
|
import { fileURLToPath } from "url";
|
|
18755
18929
|
import { Worker } from "worker_threads";
|
|
18756
18930
|
|
|
18757
18931
|
// ../../packages/plugin-sdk/src/ignore-layers.ts
|
|
18758
18932
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
18759
|
-
import { readFileSync as
|
|
18760
|
-
import { join as
|
|
18933
|
+
import { readFileSync as readFileSync9 } from "fs";
|
|
18934
|
+
import { join as join13 } from "path";
|
|
18761
18935
|
|
|
18762
18936
|
// ../../packages/plugin-sdk/src/inventory-resolver.ts
|
|
18763
18937
|
import { arch, hostname as hostname4, platform, release } from "os";
|
|
18764
18938
|
|
|
18765
18939
|
// ../../packages/plugin-sdk/src/nudge.ts
|
|
18766
|
-
import { mkdirSync as mkdirSync2, readFileSync as
|
|
18767
|
-
import { join as
|
|
18940
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync10, writeFileSync as writeFileSync5 } from "fs";
|
|
18941
|
+
import { join as join14 } from "path";
|
|
18768
18942
|
|
|
18769
18943
|
// ../../packages/plugin-sdk/src/paths.ts
|
|
18770
|
-
import { readdirSync as readdirSync3, realpathSync as
|
|
18771
|
-
import { basename as basename4, dirname as
|
|
18944
|
+
import { readdirSync as readdirSync3, realpathSync as realpathSync3 } from "fs";
|
|
18945
|
+
import { basename as basename4, dirname as dirname4, sep as sep3 } from "path";
|
|
18772
18946
|
|
|
18773
18947
|
// ../../packages/plugin-sdk/src/project-files.ts
|
|
18774
|
-
import { existsSync as
|
|
18775
|
-
import { basename as basename5, join as
|
|
18948
|
+
import { existsSync as existsSync9, readdirSync as readdirSync4 } from "fs";
|
|
18949
|
+
import { basename as basename5, join as join15 } from "path";
|
|
18776
18950
|
|
|
18777
18951
|
// ../../packages/plugin-sdk/src/provider-env-antigravity.ts
|
|
18778
18952
|
var optionalBaseUrl2 = external_exports.preprocess((v) => {
|
|
@@ -18807,12 +18981,12 @@ import { randomUUID as randomUUID14 } from "crypto";
|
|
|
18807
18981
|
var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
18808
18982
|
|
|
18809
18983
|
// ../../packages/plugin-sdk/src/throttle.ts
|
|
18810
|
-
import { mkdirSync as mkdirSync3, statSync as
|
|
18811
|
-
import { join as
|
|
18984
|
+
import { mkdirSync as mkdirSync3, statSync as statSync8, writeFileSync as writeFileSync6 } from "fs";
|
|
18985
|
+
import { join as join16 } from "path";
|
|
18812
18986
|
function throttled(dataDir2, markerName, windowMs) {
|
|
18813
|
-
const marker =
|
|
18987
|
+
const marker = join16(dataDir2, markerName);
|
|
18814
18988
|
try {
|
|
18815
|
-
if (Date.now() -
|
|
18989
|
+
if (Date.now() - statSync8(marker).mtimeMs < windowMs) return true;
|
|
18816
18990
|
} catch {
|
|
18817
18991
|
}
|
|
18818
18992
|
try {
|
|
@@ -18825,7 +18999,7 @@ function throttled(dataDir2, markerName, windowMs) {
|
|
|
18825
18999
|
|
|
18826
19000
|
// src/history/reconcile-trigger.ts
|
|
18827
19001
|
import { spawn } from "child_process";
|
|
18828
|
-
import { dirname as
|
|
19002
|
+
import { dirname as dirname5, join as join18 } from "path";
|
|
18829
19003
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
18830
19004
|
|
|
18831
19005
|
// src/history/tail.ts
|
|
@@ -18835,11 +19009,11 @@ import {
|
|
|
18835
19009
|
fstatSync,
|
|
18836
19010
|
mkdirSync as mkdirSync4,
|
|
18837
19011
|
openSync as openSync2,
|
|
18838
|
-
readFileSync as
|
|
19012
|
+
readFileSync as readFileSync11,
|
|
18839
19013
|
readSync,
|
|
18840
19014
|
writeFileSync as writeFileSync7
|
|
18841
19015
|
} from "fs";
|
|
18842
|
-
import { join as
|
|
19016
|
+
import { join as join17 } from "path";
|
|
18843
19017
|
var SAFE_SESSION_ID = /^[A-Za-z0-9._-]+$/;
|
|
18844
19018
|
function safeSessionId(sessionId) {
|
|
18845
19019
|
if (SAFE_SESSION_ID.test(sessionId) && sessionId !== "." && sessionId !== "..") {
|
|
@@ -18855,8 +19029,8 @@ function triggerReconcile(dataDir2, sessionId, transcriptPath) {
|
|
|
18855
19029
|
try {
|
|
18856
19030
|
const marker = `${RECONCILE_MARKER_PREFIX}-${safeSessionId(sessionId)}`;
|
|
18857
19031
|
if (throttled(dataDir2, marker, RECONCILE_THROTTLE_MS)) return;
|
|
18858
|
-
const here =
|
|
18859
|
-
const child = spawn(process.execPath, [
|
|
19032
|
+
const here = dirname5(fileURLToPath2(import.meta.url));
|
|
19033
|
+
const child = spawn(process.execPath, [join18(here, "reconcile.js"), sessionId, transcriptPath], {
|
|
18860
19034
|
detached: true,
|
|
18861
19035
|
stdio: "ignore"
|
|
18862
19036
|
});
|
|
@@ -18867,7 +19041,7 @@ function triggerReconcile(dataDir2, sessionId, transcriptPath) {
|
|
|
18867
19041
|
|
|
18868
19042
|
// src/hooks/shared.ts
|
|
18869
19043
|
async function readStdin() {
|
|
18870
|
-
return new Promise((
|
|
19044
|
+
return new Promise((resolve2) => {
|
|
18871
19045
|
let data = "";
|
|
18872
19046
|
let settled = false;
|
|
18873
19047
|
const finish = () => {
|
|
@@ -18876,7 +19050,7 @@ async function readStdin() {
|
|
|
18876
19050
|
clearTimeout(timer);
|
|
18877
19051
|
process.stdin.removeListener("data", onData);
|
|
18878
19052
|
process.stdin.removeListener("end", finish);
|
|
18879
|
-
|
|
19053
|
+
resolve2(data);
|
|
18880
19054
|
};
|
|
18881
19055
|
const onData = (chunk) => {
|
|
18882
19056
|
data += chunk;
|
|
@@ -18910,11 +19084,144 @@ function parseStopPayload(input) {
|
|
|
18910
19084
|
return { sessionId, transcriptPath };
|
|
18911
19085
|
}
|
|
18912
19086
|
|
|
19087
|
+
// src/hooks/store-health.ts
|
|
19088
|
+
import { mkdirSync as mkdirSync5, readFileSync as readFileSync15, writeFileSync as writeFileSync8 } from "fs";
|
|
19089
|
+
import { dirname as dirname6, join as join24 } from "path";
|
|
19090
|
+
|
|
19091
|
+
// ../../packages/plugin-runtime/src/attached/forward-drops.ts
|
|
19092
|
+
import { readFileSync as readFileSync12 } from "fs";
|
|
19093
|
+
import { join as join19 } from "path";
|
|
19094
|
+
|
|
19095
|
+
// ../../packages/plugin-runtime/src/attached/forward-policy.ts
|
|
19096
|
+
import { randomUUID as randomUUID15 } from "crypto";
|
|
19097
|
+
import { readFileSync as readFileSync13 } from "fs";
|
|
19098
|
+
import { readFile, rename, writeFile } from "fs/promises";
|
|
19099
|
+
import { join as join20 } from "path";
|
|
19100
|
+
|
|
19101
|
+
// ../../packages/plugin-runtime/src/attached/policy-store.ts
|
|
19102
|
+
import { randomUUID as randomUUID16 } from "crypto";
|
|
19103
|
+
import { readFile as readFile2, rm, writeFile as writeFile2 } from "fs/promises";
|
|
19104
|
+
import { join as join21 } from "path";
|
|
19105
|
+
|
|
19106
|
+
// ../../packages/plugin-runtime/src/attached/atomic-publish.ts
|
|
19107
|
+
import { rename as rename2 } from "fs/promises";
|
|
19108
|
+
|
|
19109
|
+
// ../../packages/remote/src/http.ts
|
|
19110
|
+
import { request as httpRequest } from "http";
|
|
19111
|
+
import { request as httpsRequest } from "https";
|
|
19112
|
+
var MAX_RESPONSE_BYTES = 8 * 1024 * 1024;
|
|
19113
|
+
|
|
19114
|
+
// ../../packages/remote/src/client.ts
|
|
19115
|
+
var SLASH = "/".charCodeAt(0);
|
|
19116
|
+
|
|
19117
|
+
// ../../packages/plugin-runtime/src/attached/posture-reporter.ts
|
|
19118
|
+
var POSTURE_REPORT_INTERVAL_MS = 60 * 60 * 1e3;
|
|
19119
|
+
|
|
19120
|
+
// ../../packages/plugin-runtime/src/attached/posture-snapshot.ts
|
|
19121
|
+
import { statSync as statSync9 } from "fs";
|
|
19122
|
+
import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
19123
|
+
|
|
19124
|
+
// ../../packages/plugin-runtime/src/attached/posture-store.ts
|
|
19125
|
+
import { randomUUID as randomUUID17 } from "crypto";
|
|
19126
|
+
import { readFile as readFile3, rm as rm2, writeFile as writeFile3 } from "fs/promises";
|
|
19127
|
+
import { join as join22 } from "path";
|
|
19128
|
+
|
|
19129
|
+
// ../../packages/plugin-runtime/src/attached/sync-state.ts
|
|
19130
|
+
import { readFileSync as readFileSync14 } from "fs";
|
|
19131
|
+
import { join as join23 } from "path";
|
|
19132
|
+
|
|
19133
|
+
// ../../packages/plugin-runtime/src/attached/status.ts
|
|
19134
|
+
var REFUSAL_LINES = {
|
|
19135
|
+
unauthorized: "KEY REJECTED \u2014 re-attach with a valid plugin key",
|
|
19136
|
+
forbidden: "ACCESS REFUSED \u2014 key is valid but not permitted; ask your org admin"
|
|
19137
|
+
};
|
|
19138
|
+
var OUTCOME_LINES = {
|
|
19139
|
+
ok: "policy synced",
|
|
19140
|
+
"not-modified": "policy up to date",
|
|
19141
|
+
unauthorized: REFUSAL_LINES.unauthorized,
|
|
19142
|
+
forbidden: REFUSAL_LINES.forbidden,
|
|
19143
|
+
unreachable: "control plane unreachable at last attempt",
|
|
19144
|
+
"invalid-bundle": "control plane sent a policy bundle this build cannot read"
|
|
19145
|
+
};
|
|
19146
|
+
|
|
19147
|
+
// ../../packages/plugin-runtime/src/attached/sync-trigger.ts
|
|
19148
|
+
import { spawn as spawn2 } from "child_process";
|
|
19149
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
19150
|
+
var SYNC_THROTTLE_MS = 15 * 60 * 1e3;
|
|
19151
|
+
|
|
19152
|
+
// ../../packages/plugin-runtime/src/attached/factory.ts
|
|
19153
|
+
import { hostname as hostname5 } from "os";
|
|
19154
|
+
|
|
19155
|
+
// ../../packages/plugin-runtime/src/standalone-gateway.ts
|
|
19156
|
+
import { randomUUID as randomUUID18 } from "crypto";
|
|
19157
|
+
|
|
19158
|
+
// ../../packages/plugin-runtime/src/handle-session-start.ts
|
|
19159
|
+
import { randomUUID as randomUUID19 } from "crypto";
|
|
19160
|
+
var EXCEPTION_RETENTION_MS = 90 * 24 * 60 * 60 * 1e3;
|
|
19161
|
+
|
|
19162
|
+
// src/hooks/store-health.ts
|
|
19163
|
+
var STORE_REDIRECT_MARKER = "store-redirect-last-session";
|
|
19164
|
+
function markerDirs(dataDir2) {
|
|
19165
|
+
return [dataDir2, dirname6(dataDir2)];
|
|
19166
|
+
}
|
|
19167
|
+
function alreadyClaimed(dirs, marker, sessionId) {
|
|
19168
|
+
return dirs.some((dir) => {
|
|
19169
|
+
try {
|
|
19170
|
+
return readFileSync15(join24(dir, marker), "utf8") === sessionId;
|
|
19171
|
+
} catch {
|
|
19172
|
+
return false;
|
|
19173
|
+
}
|
|
19174
|
+
});
|
|
19175
|
+
}
|
|
19176
|
+
function recordClaim(dirs, marker, sessionId) {
|
|
19177
|
+
for (const dir of dirs) {
|
|
19178
|
+
try {
|
|
19179
|
+
mkdirSync5(dir, { recursive: true, mode: DATA_DIR_MODE });
|
|
19180
|
+
writeFileSync8(join24(dir, marker), sessionId, { mode: DATA_FILE_MODE });
|
|
19181
|
+
return;
|
|
19182
|
+
} catch {
|
|
19183
|
+
}
|
|
19184
|
+
}
|
|
19185
|
+
}
|
|
19186
|
+
function storeRedirectedMessage(paths, platform2 = process.platform) {
|
|
19187
|
+
const where = paths.map(({ path, target, holds, missing, mode }) => {
|
|
19188
|
+
if (missing) return `${path} -> ${target} (which does not exist; ${holds} cannot land there)`;
|
|
19189
|
+
const loose = mode !== void 0 && (mode & 63) !== 0 ? ", NOT owner-only" : "";
|
|
19190
|
+
const inherited = mode === void 0 ? "" : ` (${formatMode(mode)}${loose})`;
|
|
19191
|
+
return `${path} -> ${target}${inherited}, holding ${holds}`;
|
|
19192
|
+
}).join("; ");
|
|
19193
|
+
const subject = paths.length === 1 ? "a store path is a symlink" : `${String(paths.length)} store paths are symlinks`;
|
|
19194
|
+
const anyResolves = paths.some(({ missing }) => !missing);
|
|
19195
|
+
const lead = anyResolves ? `${subject}, so AKA is writing into the target instead: ${where}. ` : `${subject} resolving nowhere, so AKA cannot write there: ${where}. `;
|
|
19196
|
+
const kept = anyResolves && platform2 !== "win32" ? "Permissions are never changed through a symlink, so the store keeps whatever the target already had. " : "";
|
|
19197
|
+
return `[aka] ${lead}${kept}If you did not create that link, treat it as untrusted and run \`aka init\` for the full report.
|
|
19198
|
+
`;
|
|
19199
|
+
}
|
|
19200
|
+
function formatMode(mode) {
|
|
19201
|
+
return `0${mode.toString(8).padStart(3, "0")}`;
|
|
19202
|
+
}
|
|
19203
|
+
function warnIfStoreRedirected(config2, sessionId, write = (message) => void process.stderr.write(message)) {
|
|
19204
|
+
try {
|
|
19205
|
+
const paths = symlinkedStorePaths(dirname6(config2.dataDir));
|
|
19206
|
+
if (paths.length === 0) return;
|
|
19207
|
+
if (!sessionId) {
|
|
19208
|
+
write(storeRedirectedMessage(paths));
|
|
19209
|
+
return;
|
|
19210
|
+
}
|
|
19211
|
+
const dirs = markerDirs(config2.dataDir);
|
|
19212
|
+
if (alreadyClaimed(dirs, STORE_REDIRECT_MARKER, sessionId)) return;
|
|
19213
|
+
write(storeRedirectedMessage(paths));
|
|
19214
|
+
recordClaim(dirs, STORE_REDIRECT_MARKER, sessionId);
|
|
19215
|
+
} catch {
|
|
19216
|
+
}
|
|
19217
|
+
}
|
|
19218
|
+
|
|
18913
19219
|
// src/hooks/stop.ts
|
|
18914
19220
|
async function main() {
|
|
18915
19221
|
const trigger = parseStopPayload(parseJson(await readStdin()));
|
|
18916
19222
|
if (trigger === void 0) return;
|
|
18917
19223
|
const config2 = loadConfig();
|
|
19224
|
+
warnIfStoreRedirected(config2, trigger.sessionId);
|
|
18918
19225
|
triggerReconcile(config2.dataDir, trigger.sessionId, trigger.transcriptPath);
|
|
18919
19226
|
}
|
|
18920
19227
|
try {
|