@akasecurity/ai-tc-claude-code 0.9.6 → 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/commands/setup.md +0 -23
- package/package.json +6 -5
- package/scripts/apply-suppressions.js +1649 -1040
- package/scripts/backfill.js +3440 -1462
- package/scripts/dashboard.js +131 -10
- package/scripts/filescan.js +3348 -1421
- package/scripts/firstrun.js +3064 -1140
- package/scripts/intro.js +1160 -930
- package/scripts/message-display.js +1647 -1071
- package/scripts/onboard.js +1618 -1028
- package/scripts/post-tool-use.js +3506 -1419
- package/scripts/pre-tool-use.js +3446 -1372
- package/scripts/query.js +3069 -1140
- package/scripts/reconcile.js +3373 -1435
- package/scripts/remediate.js +3391 -1413
- package/scripts/scan-worker.js +1114 -916
- package/scripts/session-start.js +4299 -2216
- package/scripts/start-light.js +1078 -849
- package/scripts/statusline.js +3070 -1144
- package/scripts/stop.js +1380 -902
- package/scripts/sync.js +19413 -0
- package/scripts/user-prompt-submit.js +3433 -1359
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;
|
|
@@ -15070,6 +15069,47 @@ function date4(params) {
|
|
|
15070
15069
|
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
|
|
15071
15070
|
config(en_default());
|
|
15072
15071
|
|
|
15072
|
+
// ../../packages/schema/src/zod/harness-map.ts
|
|
15073
|
+
var HARNESS = {
|
|
15074
|
+
ClaudeCode: "claudecode",
|
|
15075
|
+
Cursor: "cursor",
|
|
15076
|
+
Copilot: "copilot",
|
|
15077
|
+
Codex: "codex",
|
|
15078
|
+
Antigravity: "antigravity",
|
|
15079
|
+
Windsurf: "windsurf",
|
|
15080
|
+
ClaudeDesktop: "claudedesktop",
|
|
15081
|
+
ChatGpt: "chatgpt",
|
|
15082
|
+
ClaudeAi: "claudeai",
|
|
15083
|
+
Api: "api"
|
|
15084
|
+
};
|
|
15085
|
+
var Harness = external_exports.enum(HARNESS).meta({ id: "Harness" });
|
|
15086
|
+
var SOURCE_TOOL = {
|
|
15087
|
+
ClaudeCode: "claude-code",
|
|
15088
|
+
ClaudeDesktop: "claude-desktop",
|
|
15089
|
+
Cursor: "cursor",
|
|
15090
|
+
ChatGpt: "chatgpt",
|
|
15091
|
+
ClaudeAi: "claude-ai",
|
|
15092
|
+
Copilot: "github-copilot",
|
|
15093
|
+
Codex: "codex",
|
|
15094
|
+
Antigravity: "antigravity",
|
|
15095
|
+
// No harness counterpart, deliberately: the CLI's own captures and a capture
|
|
15096
|
+
// whose tool could not be identified both render through the read side's
|
|
15097
|
+
// miss path rather than as a harness of their own.
|
|
15098
|
+
Cli: "cli",
|
|
15099
|
+
Unknown: "unknown"
|
|
15100
|
+
};
|
|
15101
|
+
var SourceTool = external_exports.enum(SOURCE_TOOL).meta({ id: "SourceTool" });
|
|
15102
|
+
var TOOL_TO_HARNESS = {
|
|
15103
|
+
[SOURCE_TOOL.ClaudeCode]: HARNESS.ClaudeCode,
|
|
15104
|
+
[SOURCE_TOOL.ClaudeDesktop]: HARNESS.ClaudeDesktop,
|
|
15105
|
+
[SOURCE_TOOL.Copilot]: HARNESS.Copilot,
|
|
15106
|
+
[SOURCE_TOOL.Cursor]: HARNESS.Cursor,
|
|
15107
|
+
[SOURCE_TOOL.ChatGpt]: HARNESS.ChatGpt,
|
|
15108
|
+
[SOURCE_TOOL.Codex]: HARNESS.Codex,
|
|
15109
|
+
[SOURCE_TOOL.Antigravity]: HARNESS.Antigravity,
|
|
15110
|
+
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi
|
|
15111
|
+
};
|
|
15112
|
+
|
|
15073
15113
|
// ../../packages/schema/src/zod/finding.ts
|
|
15074
15114
|
var DetectionCategory = external_exports.enum(["pii", "financial", "secret", "phi", "code_context", "code_flaw", "custom", "config"]).meta({ id: "DetectionCategory" });
|
|
15075
15115
|
var Severity = external_exports.enum(["critical", "high", "medium", "low"]).meta({ id: "Severity" });
|
|
@@ -15092,21 +15132,22 @@ var Finding = external_exports.object({
|
|
|
15092
15132
|
}).meta({ id: "Finding" });
|
|
15093
15133
|
var DetectedFinding = Finding.meta({ id: "DetectedFinding" });
|
|
15094
15134
|
var FindingAction = external_exports.enum(["blocked", "redacted", "warned", "allowed", "quarantined", "monitored"]).meta({ id: "FindingAction" });
|
|
15095
|
-
var FindingProvider =
|
|
15096
|
-
"
|
|
15097
|
-
"
|
|
15098
|
-
"
|
|
15099
|
-
"
|
|
15100
|
-
"
|
|
15101
|
-
"
|
|
15102
|
-
"
|
|
15103
|
-
"
|
|
15104
|
-
"
|
|
15135
|
+
var FindingProvider = Harness.extract([
|
|
15136
|
+
"ClaudeCode",
|
|
15137
|
+
"ClaudeDesktop",
|
|
15138
|
+
"Cursor",
|
|
15139
|
+
"Copilot",
|
|
15140
|
+
"ChatGpt",
|
|
15141
|
+
"ClaudeAi",
|
|
15142
|
+
"Codex",
|
|
15143
|
+
"Antigravity",
|
|
15144
|
+
"Api"
|
|
15105
15145
|
]).meta({ id: "FindingProvider" });
|
|
15106
15146
|
var FindingCategory = external_exports.enum([
|
|
15107
15147
|
"secret",
|
|
15108
15148
|
"pii",
|
|
15109
15149
|
"source_code",
|
|
15150
|
+
"code_flaw",
|
|
15110
15151
|
"external_share",
|
|
15111
15152
|
"mcp_server",
|
|
15112
15153
|
"customer_data",
|
|
@@ -15284,6 +15325,7 @@ var FindingInstanceDetail = FindingInstance.extend({
|
|
|
15284
15325
|
detection: FindingDetectionRef,
|
|
15285
15326
|
policy: FindingPolicyRef
|
|
15286
15327
|
}).meta({ id: "FindingInstanceDetail" });
|
|
15328
|
+
var MAX_FLAT_FINDINGS_LIMIT = 200;
|
|
15287
15329
|
var ListFindingInstancesQuery = external_exports.object({
|
|
15288
15330
|
severity: external_exports.array(Severity).optional(),
|
|
15289
15331
|
// Rule ids, the same vocabulary the grouped list's `subtype` carries.
|
|
@@ -15303,7 +15345,7 @@ var ListFindingInstancesQuery = external_exports.object({
|
|
|
15303
15345
|
q: external_exports.string().optional(),
|
|
15304
15346
|
sessionId: external_exports.string().optional(),
|
|
15305
15347
|
from: external_exports.iso.datetime().optional(),
|
|
15306
|
-
limit: external_exports.coerce.number().int().min(1).max(
|
|
15348
|
+
limit: external_exports.coerce.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
|
|
15307
15349
|
cursor: external_exports.string().optional()
|
|
15308
15350
|
});
|
|
15309
15351
|
var ListFindingInstancesResponse = external_exports.object({
|
|
@@ -15365,20 +15407,6 @@ var ListFindingLocationsResponse = external_exports.object({
|
|
|
15365
15407
|
hasMore: external_exports.boolean()
|
|
15366
15408
|
}).meta({ id: "ListFindingLocationsResponse" });
|
|
15367
15409
|
|
|
15368
|
-
// ../../packages/schema/src/zod/harness-map.ts
|
|
15369
|
-
var Harness = external_exports.enum([
|
|
15370
|
-
"claudecode",
|
|
15371
|
-
"cursor",
|
|
15372
|
-
"copilot",
|
|
15373
|
-
"codex",
|
|
15374
|
-
"antigravity",
|
|
15375
|
-
"windsurf",
|
|
15376
|
-
"claudedesktop",
|
|
15377
|
-
"chatgpt",
|
|
15378
|
-
"claudeai",
|
|
15379
|
-
"api"
|
|
15380
|
-
]).meta({ id: "Harness" });
|
|
15381
|
-
|
|
15382
15410
|
// ../../packages/schema/src/zod/meta.ts
|
|
15383
15411
|
var InventoryObjectType = external_exports.enum(["host", "harness", "user", "skill", "hook", "mcp_server", "config_file"]).meta({ id: "InventoryObjectType" });
|
|
15384
15412
|
var AuditEventType = external_exports.enum([
|
|
@@ -15828,366 +15856,240 @@ var ActivityOverviewResponse = external_exports.object({
|
|
|
15828
15856
|
sessions: ListActivitySessionsResponse
|
|
15829
15857
|
}).meta({ id: "ActivityOverviewResponse" });
|
|
15830
15858
|
|
|
15831
|
-
// ../../packages/schema/src/zod/
|
|
15832
|
-
var
|
|
15833
|
-
var
|
|
15834
|
-
|
|
15835
|
-
|
|
15836
|
-
|
|
15837
|
-
|
|
15838
|
-
|
|
15839
|
-
|
|
15840
|
-
|
|
15841
|
-
|
|
15842
|
-
|
|
15843
|
-
|
|
15844
|
-
|
|
15845
|
-
|
|
15846
|
-
|
|
15847
|
-
|
|
15848
|
-
|
|
15849
|
-
filePath: external_exports.string().optional(),
|
|
15850
|
-
// The host tool whose input/output was scanned (e.g. 'Bash', 'WebFetch'),
|
|
15851
|
-
// set by the tool-scanning hooks. The tool NAME only — never the tool's
|
|
15852
|
-
// arguments or output, which can carry the very value a finding masked
|
|
15853
|
-
// (metadata is stored unredacted). Gives findings on non-file captures a
|
|
15854
|
-
// display location ("via Bash") when no filePath exists.
|
|
15855
|
-
toolName: external_exports.string().optional(),
|
|
15856
|
-
// Set (true) by the worktree scanner when the file is excluded by the
|
|
15857
|
-
// repo's .gitignore. Gitignored files ARE still scanned — local scratch and
|
|
15858
|
-
// generated code can leak real secrets — but the provenance is recorded so
|
|
15859
|
-
// policy/dashboards can treat those findings as informational rather than
|
|
15860
|
-
// blocking. Omitted (not false) for tracked files and non-scan events.
|
|
15861
|
-
gitignored: external_exports.boolean().optional(),
|
|
15862
|
-
// Set (true) ONLY when the event's `content` is the COMPLETE file at
|
|
15863
|
-
// capture time (a worktree scan reading from disk). Hook-captured edits
|
|
15864
|
-
// (e.g. an Edit tool's new_string) are partial fragments and MUST NOT set
|
|
15865
|
-
// this. The resolver-on-ingest keys its fixed-at-source dropout
|
|
15866
|
-
// diff on this marker: only a whole-file snapshot can prove a previously
|
|
15867
|
-
// open finding is gone; a fragment's absence proves nothing (the secret
|
|
15868
|
-
// may live outside the hunk). Omitted (not false) for fragments and
|
|
15869
|
-
// non-scan events, so pre-marker clients safely default to the
|
|
15870
|
-
// non-authoritative path.
|
|
15871
|
-
wholeFile: external_exports.boolean().optional(),
|
|
15872
|
-
model: external_exports.string().optional(),
|
|
15873
|
-
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
15874
|
-
// Distributed-tracing correlation. `correlationId` ties a recorded event back
|
|
15875
|
-
// to the request that captured/ingested it (a UUID, generated independently of
|
|
15876
|
-
// the trace id); `traceId` is the W3C trace id (32 lowercase hex chars) of the
|
|
15877
|
-
// originating span when telemetry is enabled. Both optional + backward
|
|
15878
|
-
// compatible — populated by the plugin (see @akasecurity/plugin-sdk).
|
|
15879
|
-
correlationId: external_exports.uuid().optional(),
|
|
15880
|
-
traceId: external_exports.string().regex(/^[0-9a-f]{32}$/).optional(),
|
|
15881
|
-
// Ids of the detection exceptions that downgraded findings in this capture
|
|
15882
|
-
// to 'allow' — the enforcement audit trail's link back to the grant that
|
|
15883
|
-
// authorized the bypass. Absent on captures where no exception applied.
|
|
15884
|
-
exceptionIds: external_exports.array(external_exports.guid()).optional()
|
|
15885
|
-
}).meta({ id: "EventMetadata" });
|
|
15886
|
-
var Event = external_exports.object({
|
|
15887
|
-
id: external_exports.guid(),
|
|
15888
|
-
sourceTool: SourceTool,
|
|
15889
|
-
kind: EventKind,
|
|
15890
|
-
occurredAt: external_exports.iso.datetime(),
|
|
15891
|
-
contentHash: external_exports.string(),
|
|
15892
|
-
content: external_exports.string(),
|
|
15893
|
-
metadata: EventMetadata.optional()
|
|
15894
|
-
}).meta({ id: "Event" });
|
|
15895
|
-
var IngestEvent = Event.meta({ id: "IngestEvent" });
|
|
15896
|
-
var IngestBatch = external_exports.object({
|
|
15897
|
-
events: external_exports.array(IngestEvent).min(1).max(100),
|
|
15898
|
-
// Dedup policy for this batch. Id-dedup ALWAYS applies. 'content-hash'
|
|
15899
|
-
// additionally rejects any event whose contentHash the store has already
|
|
15900
|
-
// recorded — for re-runnable bulk ingest (worktree scan, transcript
|
|
15901
|
-
// backfill), where a re-run mints fresh event ids for identical content and
|
|
15902
|
-
// would otherwise accumulate duplicates. Live hook traffic must NOT set it:
|
|
15903
|
-
// two genuinely separate prompts can be byte-identical and both belong on
|
|
15904
|
-
// the timeline.
|
|
15905
|
-
dedupe: external_exports.literal("content-hash").optional()
|
|
15906
|
-
}).meta({ id: "IngestBatch" });
|
|
15907
|
-
|
|
15908
|
-
// ../../packages/schema/src/zod/inventory.ts
|
|
15909
|
-
var AssetType = external_exports.enum(["project", "skill", "mcp", "hook", "config"]).meta({ id: "AssetType" });
|
|
15910
|
-
var AccessLevel = external_exports.enum(["open", "approved", "blocked"]).meta({ id: "AccessLevel" });
|
|
15911
|
-
var Origin = external_exports.enum(["source", "public-dep", "vendored", "config", "data", "docs", "generated"]).meta({ id: "Origin" });
|
|
15912
|
-
var TrustLevel = external_exports.enum(["known-good", "risky", "unapproved"]).meta({ id: "TrustLevel" });
|
|
15913
|
-
var Flag = external_exports.enum(["update", "stale", "conflict", "unknown", "change", "untracked", "risk", "findings"]).meta({ id: "Flag" });
|
|
15914
|
-
var Visibility = external_exports.enum(["public", "private"]).meta({ id: "Visibility" });
|
|
15915
|
-
var HarnessEventKind = external_exports.enum(["block", "redact", "warn"]).meta({ id: "HarnessEventKind" });
|
|
15916
|
-
var HarnessId = external_exports.enum(["claudecode", "cursor", "codex", "antigravity"]).meta({ id: "HarnessId" });
|
|
15917
|
-
var AccessCounts = external_exports.object({
|
|
15918
|
-
open: external_exports.number().int().nonnegative(),
|
|
15919
|
-
approved: external_exports.number().int().nonnegative(),
|
|
15920
|
-
blocked: external_exports.number().int().nonnegative(),
|
|
15921
|
-
total: external_exports.number().int().nonnegative()
|
|
15922
|
-
}).meta({ id: "AccessCounts" });
|
|
15923
|
-
var AssetSummary = external_exports.object({
|
|
15924
|
-
id: external_exports.string(),
|
|
15925
|
-
type: AssetType,
|
|
15926
|
-
name: external_exports.string(),
|
|
15927
|
-
sub: external_exports.string(),
|
|
15928
|
-
flags: external_exports.array(Flag),
|
|
15929
|
-
/** MCP servers only — omitted for all other types. */
|
|
15930
|
-
trust: TrustLevel.optional()
|
|
15931
|
-
}).meta({ id: "AssetSummary" });
|
|
15932
|
-
var ProjectSummary = external_exports.object({
|
|
15933
|
-
id: external_exports.string(),
|
|
15934
|
-
name: external_exports.string(),
|
|
15935
|
-
repo: external_exports.string(),
|
|
15936
|
-
visibility: Visibility,
|
|
15937
|
-
language: external_exports.string(),
|
|
15938
|
-
policyDefault: AccessLevel,
|
|
15939
|
-
updatedAt: external_exports.iso.datetime(),
|
|
15940
|
-
accessCounts: AccessCounts,
|
|
15941
|
-
findingsCount: external_exports.number().int().nonnegative()
|
|
15942
|
-
}).meta({ id: "ProjectSummary" });
|
|
15943
|
-
var HarnessCategory = external_exports.object({
|
|
15944
|
-
/** One of config/skill/mcp/hook — never project (enforced at service layer). */
|
|
15945
|
-
type: AssetType,
|
|
15946
|
-
assets: external_exports.array(AssetSummary)
|
|
15859
|
+
// ../../packages/schema/src/zod/config-inventory.ts
|
|
15860
|
+
var ConfigScope = external_exports.enum(["user", "project", "local", "plugin"]);
|
|
15861
|
+
var SkillScanEntry = external_exports.object({
|
|
15862
|
+
name: external_exports.string().min(1),
|
|
15863
|
+
// The identity source: a marketplace repo for plugin skills (e.g.
|
|
15864
|
+
// 'anthropics/skills'), 'local' for personal ~/.claude/skills, or
|
|
15865
|
+
// 'project:<repo-identity>' for checked-in project skills. The surrogate keeps
|
|
15866
|
+
// a personal skill named 'pdf' from colliding with the marketplace 'pdf'.
|
|
15867
|
+
source: external_exports.string().min(1),
|
|
15868
|
+
scope: ConfigScope,
|
|
15869
|
+
pluginName: external_exports.string().optional(),
|
|
15870
|
+
// Volatile — rides the attribute bag, never the identity hash.
|
|
15871
|
+
version: external_exports.string().optional(),
|
|
15872
|
+
description: external_exports.string().optional(),
|
|
15873
|
+
// Skill directory mtime (ISO) — the "updated Nd ago" freshness signal.
|
|
15874
|
+
updatedAt: external_exports.iso.datetime().optional(),
|
|
15875
|
+
// Filesystem path — the promoted inventory `location` column.
|
|
15876
|
+
location: external_exports.string().optional()
|
|
15947
15877
|
});
|
|
15948
|
-
var
|
|
15949
|
-
|
|
15950
|
-
|
|
15951
|
-
|
|
15952
|
-
|
|
15953
|
-
|
|
15954
|
-
|
|
15955
|
-
|
|
15956
|
-
|
|
15957
|
-
|
|
15958
|
-
|
|
15959
|
-
|
|
15960
|
-
|
|
15961
|
-
|
|
15962
|
-
|
|
15963
|
-
|
|
15964
|
-
|
|
15965
|
-
|
|
15966
|
-
|
|
15967
|
-
|
|
15968
|
-
|
|
15969
|
-
|
|
15970
|
-
|
|
15971
|
-
|
|
15972
|
-
|
|
15973
|
-
|
|
15878
|
+
var HookScanEntry = external_exports.object({
|
|
15879
|
+
// Hook event name (PreToolUse, PostToolUse, …). Open string, not an enum: the
|
|
15880
|
+
// set is harness-defined and grows without a schema change.
|
|
15881
|
+
event: external_exports.string().min(1),
|
|
15882
|
+
// The tool matcher ('Bash', 'Edit|Write', …). Absent = matches all tools.
|
|
15883
|
+
matcher: external_exports.string().optional(),
|
|
15884
|
+
command: external_exports.string().min(1),
|
|
15885
|
+
timeout: external_exports.number().optional(),
|
|
15886
|
+
scope: ConfigScope,
|
|
15887
|
+
pluginName: external_exports.string().optional(),
|
|
15888
|
+
// The settings file / hooks.json the entry came from.
|
|
15889
|
+
location: external_exports.string().optional()
|
|
15890
|
+
});
|
|
15891
|
+
var McpServerScanEntry = external_exports.object({
|
|
15892
|
+
// The server's config key ("github", "filesystem", …) — identity, with the
|
|
15893
|
+
// qualified scope (see mcpServerIdentityKey).
|
|
15894
|
+
name: external_exports.string().min(1),
|
|
15895
|
+
scope: ConfigScope,
|
|
15896
|
+
pluginName: external_exports.string().optional(),
|
|
15897
|
+
// The owning plugin's marketplace — part of PLUGIN-scope identity: two
|
|
15898
|
+
// marketplaces can each ship a plugin named `guard`, and without this their
|
|
15899
|
+
// same-named servers would collapse to one row (the second silently dropped,
|
|
15900
|
+
// inheriting the first's trust).
|
|
15901
|
+
marketplace: external_exports.string().optional(),
|
|
15902
|
+
// The repo identity (remote url, or the cwd for un-remoted repos) — part of
|
|
15903
|
+
// PROJECT/LOCAL-scope identity: a server named `github` in repo A and one in
|
|
15904
|
+
// repo B are different servers with different commands, and MUST NOT share a
|
|
15905
|
+
// row — a shared row would let a cloned repo's .mcp.json inherit the trust
|
|
15906
|
+
// the user granted elsewhere.
|
|
15907
|
+
project: external_exports.string().optional(),
|
|
15908
|
+
// 'stdio' when the entry carries a command; otherwise the config's `type`
|
|
15909
|
+
// ('http' / 'sse' / …). Open string — the transport set is harness-defined.
|
|
15910
|
+
transport: external_exports.string().min(1),
|
|
15911
|
+
// Volatile on purpose (unlike hook `command`): a changed command/url is drift
|
|
15912
|
+
// on a stable row — visible across config_scan snapshots and preserving the
|
|
15913
|
+
// user's trust decision — never a quiet new row. One of the two is present.
|
|
15914
|
+
// Secret-masked at collection time (the scanner runs the bundled detection
|
|
15915
|
+
// packs over both — tokens routinely ride command args and URLs).
|
|
15916
|
+
command: external_exports.string().optional(),
|
|
15917
|
+
url: external_exports.string().optional(),
|
|
15918
|
+
// Env var NAMES only, never values (the no-secrets rule).
|
|
15919
|
+
envKeys: external_exports.array(external_exports.string()).optional(),
|
|
15920
|
+
// The config file the entry came from.
|
|
15921
|
+
location: external_exports.string().optional()
|
|
15922
|
+
});
|
|
15923
|
+
var ConfigFileScanEntry = external_exports.object({
|
|
15924
|
+
// Basename (settings.json, CLAUDE.md) or dir name (commands/, agents/).
|
|
15925
|
+
name: external_exports.string().min(1),
|
|
15926
|
+
// The absolute path — identity (with scope) and the promoted `location`.
|
|
15927
|
+
path: external_exports.string().min(1),
|
|
15928
|
+
scope: ConfigScope,
|
|
15929
|
+
// Human label: "User settings", "Project memory", "Slash commands", …
|
|
15930
|
+
kind: external_exports.string().min(1),
|
|
15931
|
+
// Derived SHAPE summary — top-level key names, entry counts, line counts.
|
|
15932
|
+
// Never file content or values (memory files can carry sensitive detail).
|
|
15933
|
+
detail: external_exports.string().optional(),
|
|
15934
|
+
// Dir configs (commands/, agents/) and .mcp.json: how many entries.
|
|
15935
|
+
entryCount: external_exports.number().optional(),
|
|
15936
|
+
// File mtime (ISO) — the freshness signal.
|
|
15937
|
+
updatedAt: external_exports.iso.datetime().optional()
|
|
15938
|
+
});
|
|
15939
|
+
var ConfigScanResult = external_exports.object({
|
|
15940
|
+
scannedAt: external_exports.iso.datetime(),
|
|
15941
|
+
skills: external_exports.array(SkillScanEntry),
|
|
15942
|
+
hooks: external_exports.array(HookScanEntry),
|
|
15943
|
+
mcpServers: external_exports.array(McpServerScanEntry),
|
|
15944
|
+
configFiles: external_exports.array(ConfigFileScanEntry),
|
|
15945
|
+
errors: external_exports.array(external_exports.object({ source: external_exports.string(), reason: external_exports.string() }))
|
|
15946
|
+
});
|
|
15947
|
+
var ConfigPostureFindingInput = external_exports.object({
|
|
15948
|
+
ruleId: external_exports.string().min(1),
|
|
15949
|
+
version: external_exports.string().min(1),
|
|
15950
|
+
span: Span,
|
|
15951
|
+
// For posture rules this is the offending COMMAND (config the user already
|
|
15952
|
+
// holds locally, not captured secret content) — it is also the correlation
|
|
15953
|
+
// key the read surface matches back to a hook row.
|
|
15954
|
+
maskedMatch: external_exports.string(),
|
|
15955
|
+
actionTaken: ActionTaken,
|
|
15956
|
+
confidence: external_exports.number().min(0).max(1)
|
|
15957
|
+
});
|
|
15958
|
+
var ConfigScanRecord = external_exports.object({
|
|
15959
|
+
items: external_exports.array(InventoryInput),
|
|
15960
|
+
scanEvent: AuditEventInput,
|
|
15961
|
+
definitions: external_exports.array(InspectionDefinitionInput).optional(),
|
|
15962
|
+
findings: external_exports.array(ConfigPostureFindingInput).optional()
|
|
15963
|
+
});
|
|
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(),
|
|
15974
16022
|
/**
|
|
15975
|
-
*
|
|
15976
|
-
*
|
|
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.
|
|
15977
16026
|
*/
|
|
15978
|
-
|
|
15979
|
-
|
|
15980
|
-
|
|
15981
|
-
|
|
15982
|
-
|
|
15983
|
-
|
|
15984
|
-
|
|
15985
|
-
|
|
15986
|
-
|
|
15987
|
-
|
|
15988
|
-
|
|
15989
|
-
|
|
15990
|
-
|
|
15991
|
-
|
|
15992
|
-
|
|
15993
|
-
|
|
15994
|
-
|
|
15995
|
-
|
|
15996
|
-
|
|
15997
|
-
|
|
15998
|
-
|
|
15999
|
-
|
|
16000
|
-
|
|
16001
|
-
|
|
16002
|
-
|
|
16003
|
-
|
|
16004
|
-
|
|
16005
|
-
|
|
16006
|
-
|
|
16007
|
-
|
|
16008
|
-
|
|
16009
|
-
|
|
16010
|
-
|
|
16011
|
-
|
|
16012
|
-
|
|
16013
|
-
|
|
16014
|
-
|
|
16015
|
-
|
|
16016
|
-
|
|
16017
|
-
var InventoryStats = external_exports.object({
|
|
16018
|
-
/** Total assets/projects with ≥1 flag or finding (drives the attention header chip). */
|
|
16019
|
-
attention: external_exports.number().int().nonnegative(),
|
|
16020
|
-
byType: external_exports.object({
|
|
16021
|
-
project: external_exports.number().int().nonnegative(),
|
|
16022
|
-
skill: external_exports.number().int().nonnegative(),
|
|
16023
|
-
mcp: external_exports.number().int().nonnegative(),
|
|
16024
|
-
hook: external_exports.number().int().nonnegative(),
|
|
16025
|
-
config: external_exports.number().int().nonnegative()
|
|
16026
|
-
}),
|
|
16027
|
-
harnesses: external_exports.number().int().nonnegative(),
|
|
16028
|
-
mcpTrust: external_exports.object({
|
|
16029
|
-
"known-good": external_exports.number().int().nonnegative(),
|
|
16030
|
-
risky: external_exports.number().int().nonnegative(),
|
|
16031
|
-
unapproved: external_exports.number().int().nonnegative()
|
|
16032
|
-
})
|
|
16033
|
-
}).meta({ id: "InventoryStats" });
|
|
16034
|
-
var FileSummary = external_exports.object({
|
|
16035
|
-
path: external_exports.string(),
|
|
16036
|
-
name: external_exports.string(),
|
|
16037
|
-
origin: Origin,
|
|
16038
|
-
/** Effective access (override applied). */
|
|
16039
|
-
access: AccessLevel,
|
|
16040
|
-
/** True when a file_access_override differs from the computed default. */
|
|
16041
|
-
isCustom: external_exports.boolean(),
|
|
16042
|
-
findings: external_exports.number().int().nonnegative(),
|
|
16043
|
-
/** When the file was auto-blocked by a detection; null when not blocked. */
|
|
16044
|
-
blockedAt: external_exports.iso.datetime().nullable().optional(),
|
|
16045
|
-
/** Why the file was blocked; null when absent. */
|
|
16046
|
-
note: external_exports.string().nullable().optional()
|
|
16047
|
-
}).meta({ id: "FileSummary" });
|
|
16048
|
-
var FolderSummary = external_exports.object({
|
|
16049
|
-
name: external_exports.string(),
|
|
16050
|
-
path: external_exports.string(),
|
|
16051
|
-
/** Rollup of effective access across all descendants. */
|
|
16052
|
-
accessCounts: AccessCounts
|
|
16053
|
-
}).meta({ id: "FolderSummary" });
|
|
16054
|
-
var ProjectTreeResponse = external_exports.object({
|
|
16055
|
-
project: external_exports.object({
|
|
16056
|
-
id: external_exports.string(),
|
|
16057
|
-
repo: external_exports.string(),
|
|
16058
|
-
visibility: Visibility
|
|
16059
|
-
}),
|
|
16060
|
-
path: external_exports.string(),
|
|
16061
|
-
/** Browse mode: one-level folders at the current path. Omitted in search mode. */
|
|
16062
|
-
folders: external_exports.array(FolderSummary).optional(),
|
|
16063
|
-
files: external_exports.array(FileSummary)
|
|
16064
|
-
}).meta({ id: "ProjectTreeResponse" });
|
|
16065
|
-
var FileDetail = FileSummary.extend({
|
|
16066
|
-
project: external_exports.object({
|
|
16067
|
-
repo: external_exports.string(),
|
|
16068
|
-
visibility: Visibility,
|
|
16069
|
-
language: external_exports.string(),
|
|
16070
|
-
policyDefault: AccessLevel,
|
|
16071
|
-
updatedAt: external_exports.iso.datetime()
|
|
16072
|
-
}),
|
|
16073
|
-
findingsRefs: external_exports.array(external_exports.object({ id: external_exports.string(), title: external_exports.string() }))
|
|
16074
|
-
}).meta({ id: "FileDetail" });
|
|
16075
|
-
var SetFileAccessBody = external_exports.object({
|
|
16076
|
-
path: external_exports.string(),
|
|
16077
|
-
access: AccessLevel
|
|
16078
|
-
}).meta({ id: "SetFileAccessBody" });
|
|
16079
|
-
var SetFileAccessResponse = external_exports.object({
|
|
16080
|
-
file: FileSummary,
|
|
16081
|
-
accessCounts: AccessCounts
|
|
16082
|
-
}).meta({ id: "SetFileAccessResponse" });
|
|
16083
|
-
var SetMcpTrustBody = external_exports.object({ trust: TrustLevel }).meta({ id: "SetMcpTrustBody" });
|
|
16084
|
-
var HarnessEventItem = external_exports.object({
|
|
16085
|
-
kind: HarnessEventKind,
|
|
16086
|
-
title: external_exports.string(),
|
|
16087
|
-
detail: external_exports.string(),
|
|
16088
|
-
occurredAt: external_exports.iso.datetime(),
|
|
16089
|
-
findingId: external_exports.string().nullable().optional()
|
|
16090
|
-
}).meta({ id: "HarnessEventItem" });
|
|
16091
|
-
var HarnessEventsResponse = external_exports.object({
|
|
16092
|
-
counts: external_exports.object({
|
|
16093
|
-
block: external_exports.number().int().nonnegative(),
|
|
16094
|
-
redact: external_exports.number().int().nonnegative(),
|
|
16095
|
-
warn: external_exports.number().int().nonnegative()
|
|
16096
|
-
}),
|
|
16097
|
-
items: external_exports.array(HarnessEventItem)
|
|
16098
|
-
}).meta({ id: "HarnessEventsResponse" });
|
|
16099
|
-
var RescanResponse = external_exports.object({
|
|
16100
|
-
jobId: external_exports.string(),
|
|
16101
|
-
startedAt: external_exports.iso.datetime()
|
|
16102
|
-
}).meta({ id: "RescanResponse" });
|
|
16103
|
-
var ConnectProjectBody = external_exports.object({ repo: external_exports.string() }).meta({ id: "ConnectProjectBody" });
|
|
16104
|
-
var ListAssetsQuery = external_exports.object({
|
|
16105
|
-
/** Filter by one or more AssetType values; absent means all types. */
|
|
16106
|
-
type: external_exports.array(AssetType).optional(),
|
|
16107
|
-
/** Free-text search term. */
|
|
16108
|
-
q: external_exports.string().optional()
|
|
16109
|
-
});
|
|
16110
|
-
var GetProjectTreeQuery = external_exports.object({
|
|
16111
|
-
/** Subtree root path; defaults to repository root when absent. */
|
|
16112
|
-
path: external_exports.string().optional(),
|
|
16113
|
-
/** Free-text filter applied to file paths. */
|
|
16114
|
-
q: external_exports.string().optional(),
|
|
16115
|
-
/**
|
|
16116
|
-
* Special listing mode. `blocked` returns every effectively-blocked, auto-blocked
|
|
16117
|
-
* file across the whole repo (folders omitted, most-recent first), ignoring
|
|
16118
|
-
* `path`/`q` — powers the project-wide "recently blocked" strip.
|
|
16119
|
-
*/
|
|
16120
|
-
filter: external_exports.enum(["blocked"]).optional()
|
|
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()
|
|
16121
16066
|
});
|
|
16122
|
-
var
|
|
16123
|
-
|
|
16124
|
-
|
|
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)
|
|
16125
16075
|
});
|
|
16126
|
-
var
|
|
16127
|
-
|
|
16128
|
-
|
|
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()
|
|
16129
16081
|
});
|
|
16130
16082
|
|
|
16131
|
-
// ../../packages/schema/src/zod/
|
|
16132
|
-
var
|
|
16133
|
-
var
|
|
16134
|
-
|
|
16135
|
-
|
|
16136
|
-
provider: external_exports.string().optional()
|
|
16137
|
-
}).strict();
|
|
16138
|
-
var ExceptionCapability = external_exports.enum(["suppress", "reveal_to_model"]);
|
|
16139
|
-
var DetectionException = external_exports.object({
|
|
16140
|
-
id: external_exports.guid(),
|
|
16141
|
-
ruleId: external_exports.string(),
|
|
16142
|
-
// Denormalized from the rule, for reporting — never matched on.
|
|
16143
|
-
category: DetectionCategory,
|
|
16144
|
-
// HMAC-SHA256 hex of the raw match under a machine-local key: a KEYED
|
|
16145
|
-
// fingerprint, never the raw value, and never reversible. Matching recomputes
|
|
16146
|
-
// the fingerprint from a fresh capture; the value itself is never stored.
|
|
16147
|
-
// Shape-constrained so a malformed — or accidentally raw — value is rejected
|
|
16148
|
-
// at the boundary rather than persisted.
|
|
16149
|
-
valueFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
16150
|
-
// Version of the fingerprint key the grant was written under; a rotated key
|
|
16151
|
-
// invalidates old grants rather than silently mismatching them.
|
|
16152
|
-
keyVersion: external_exports.number().int().positive(),
|
|
16153
|
-
// maskMatch() preview of the approved value — never the raw value.
|
|
16154
|
-
maskedValue: external_exports.string(),
|
|
16155
|
-
capability: ExceptionCapability.default("suppress"),
|
|
16156
|
-
scope: ExceptionScope,
|
|
16157
|
-
expiresAt: external_exports.iso.datetime().nullable(),
|
|
16158
|
-
maxUses: external_exports.number().int().positive().nullable(),
|
|
16159
|
-
useCount: external_exports.number().int().nonnegative(),
|
|
16160
|
-
lastUsedAt: external_exports.iso.datetime().nullable(),
|
|
16161
|
-
// Mandatory: every grant carries the human reason it exists.
|
|
16162
|
-
justification: external_exports.string().min(1),
|
|
16163
|
-
conditions: ExceptionConditions.nullable(),
|
|
16164
|
-
createdBy: external_exports.string(),
|
|
16165
|
-
createdVia: external_exports.enum(["cli-approve", "cli-add", "web-approve", "web-add", "api", "setup-triage"]),
|
|
16166
|
-
createdAt: external_exports.iso.datetime(),
|
|
16167
|
-
updatedAt: external_exports.iso.datetime(),
|
|
16168
|
-
// Revocation is terminal and retained — consumed/expired/revoked rows are
|
|
16169
|
-
// audit evidence; nothing in the exception lifecycle hard-deletes.
|
|
16170
|
-
revokedAt: external_exports.iso.datetime().nullable(),
|
|
16171
|
-
revokedBy: external_exports.string().nullable(),
|
|
16172
|
-
revokeReason: external_exports.string().nullable()
|
|
16173
|
-
});
|
|
16174
|
-
var ExceptionBundleEntry = DetectionException.pick({
|
|
16175
|
-
id: true,
|
|
16176
|
-
ruleId: true,
|
|
16177
|
-
valueFingerprint: true,
|
|
16178
|
-
keyVersion: true,
|
|
16179
|
-
capability: true,
|
|
16180
|
-
expiresAt: true,
|
|
16181
|
-
maxUses: true,
|
|
16182
|
-
useCount: true,
|
|
16183
|
-
conditions: true
|
|
16184
|
-
});
|
|
16185
|
-
var ExceptionDescriptor = DetectionException.omit({ valueFingerprint: true });
|
|
16083
|
+
// ../../packages/schema/src/zod/registry.ts
|
|
16084
|
+
var Namespace = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
16085
|
+
var PackId = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
16086
|
+
var SemVer = external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?$/);
|
|
16087
|
+
var PublisherKind = external_exports.enum(["labs", "user", "org"]);
|
|
16186
16088
|
|
|
16187
16089
|
// ../../packages/schema/src/zod/rule.ts
|
|
16188
|
-
var MatcherType = external_exports.enum(["keyword", "regex"
|
|
16090
|
+
var MatcherType = external_exports.enum(["keyword", "regex"]).meta({ id: "MatcherType" });
|
|
16189
16091
|
var RuleProbeVerdict = external_exports.enum(["safe", "quarantined"]).meta({ id: "RuleProbeVerdict" });
|
|
16190
|
-
var KeywordMatcher = external_exports.
|
|
16092
|
+
var KeywordMatcher = external_exports.strictObject({
|
|
16191
16093
|
type: external_exports.literal("keyword"),
|
|
16192
16094
|
// An empty keyword matches at every position, yielding one zero-length span
|
|
16193
16095
|
// per character. Rejected here because a keyword that matches everything is
|
|
@@ -16203,16 +16105,31 @@ function isValidRegex(pattern, flags) {
|
|
|
16203
16105
|
return false;
|
|
16204
16106
|
}
|
|
16205
16107
|
}
|
|
16108
|
+
function probeFlags(flags) {
|
|
16109
|
+
return flags.replace(/[gy]/g, "");
|
|
16110
|
+
}
|
|
16206
16111
|
function matchesEmptyString(pattern, flags) {
|
|
16207
16112
|
try {
|
|
16208
|
-
const re = new RegExp(pattern, flags
|
|
16113
|
+
const re = new RegExp(pattern, probeFlags(flags));
|
|
16209
16114
|
return re.exec("")?.[0].length === 0;
|
|
16210
16115
|
} catch {
|
|
16211
16116
|
return false;
|
|
16212
16117
|
}
|
|
16213
16118
|
}
|
|
16119
|
+
function spansWholeMatch(captureGroup) {
|
|
16120
|
+
return captureGroup === void 0 || captureGroup === 0;
|
|
16121
|
+
}
|
|
16122
|
+
function captureGroupCount(pattern, flags) {
|
|
16123
|
+
try {
|
|
16124
|
+
const probe = new RegExp(`${pattern}|`, probeFlags(flags));
|
|
16125
|
+
const result = probe.exec("");
|
|
16126
|
+
return result ? result.length - 1 : void 0;
|
|
16127
|
+
} catch {
|
|
16128
|
+
return void 0;
|
|
16129
|
+
}
|
|
16130
|
+
}
|
|
16214
16131
|
var MAX_PATTERN_LENGTH = 2e3;
|
|
16215
|
-
var RegexMatcher = external_exports.
|
|
16132
|
+
var RegexMatcher = external_exports.strictObject({
|
|
16216
16133
|
type: external_exports.literal("regex"),
|
|
16217
16134
|
pattern: external_exports.string().min(1).max(MAX_PATTERN_LENGTH),
|
|
16218
16135
|
flags: external_exports.string().default("gi"),
|
|
@@ -16220,28 +16137,47 @@ var RegexMatcher = external_exports.object({
|
|
|
16220
16137
|
}).refine((v) => isValidRegex(v.pattern, v.flags), {
|
|
16221
16138
|
message: "pattern/flags do not form a valid JavaScript regular expression",
|
|
16222
16139
|
path: ["pattern"]
|
|
16223
|
-
}).refine((v) => v.captureGroup
|
|
16140
|
+
}).refine((v) => !spansWholeMatch(v.captureGroup) || !matchesEmptyString(v.pattern, v.flags), {
|
|
16224
16141
|
message: 'a whole-match regex that can match the empty string (e.g. "\\d*", "a?", "(?:)") can hang the matcher \u2014 scope the quantifier to a captureGroup, or require at least one character',
|
|
16225
16142
|
path: ["pattern"]
|
|
16143
|
+
}).superRefine((v, ctx) => {
|
|
16144
|
+
if (v.captureGroup === void 0) return;
|
|
16145
|
+
const groups = captureGroupCount(v.pattern, v.flags);
|
|
16146
|
+
if (groups === void 0 || v.captureGroup <= groups) return;
|
|
16147
|
+
ctx.addIssue({
|
|
16148
|
+
code: "custom",
|
|
16149
|
+
path: ["captureGroup"],
|
|
16150
|
+
message: `captureGroup ${String(v.captureGroup)} is out of range \u2014 the pattern declares ${String(groups)} capture group(s), so valid values are 0-${String(groups)}. An out-of-range group never matches, which would make the rule silently never fire.`
|
|
16151
|
+
});
|
|
16226
16152
|
});
|
|
16227
|
-
var
|
|
16228
|
-
|
|
16229
|
-
|
|
16230
|
-
config: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
16231
|
-
});
|
|
16232
|
-
var Matcher = external_exports.discriminatedUnion("type", [KeywordMatcher, RegexMatcher, ValidatorMatcher]).meta({ id: "Matcher" });
|
|
16233
|
-
var AppliesTo = external_exports.object({
|
|
16153
|
+
var Matcher = external_exports.discriminatedUnion("type", [KeywordMatcher, RegexMatcher]).meta({ id: "Matcher" });
|
|
16154
|
+
var MATCHER_TYPES = MatcherType.options;
|
|
16155
|
+
var AppliesTo = external_exports.strictObject({
|
|
16234
16156
|
// Dot-prefixed, e.g. ".py" — matches the scanner's SOURCE_EXTENSIONS shape.
|
|
16235
16157
|
extensions: external_exports.array(external_exports.string().regex(/^\.[A-Za-z0-9]+$/)).min(1)
|
|
16236
16158
|
}).meta({ id: "AppliesTo" });
|
|
16237
|
-
var
|
|
16238
|
-
|
|
16239
|
-
|
|
16240
|
-
|
|
16241
|
-
|
|
16242
|
-
|
|
16243
|
-
|
|
16244
|
-
|
|
16159
|
+
var PostValidatorName = external_exports.enum(["entropy", "luhn"]).meta({ id: "PostValidatorName" });
|
|
16160
|
+
var PostValidatorRef = external_exports.union(
|
|
16161
|
+
[
|
|
16162
|
+
PostValidatorName,
|
|
16163
|
+
external_exports.strictObject({
|
|
16164
|
+
name: PostValidatorName,
|
|
16165
|
+
config: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
16166
|
+
})
|
|
16167
|
+
],
|
|
16168
|
+
{
|
|
16169
|
+
// A union reports one collapsed issue for every way its arms can fail, so
|
|
16170
|
+
// this has to describe the whole shape rather than just the name — it is
|
|
16171
|
+
// what an author sees for a misspelled name AND for a stray key in the
|
|
16172
|
+
// object form. The names come from the enum so the message cannot go
|
|
16173
|
+
// stale. Without it Zod says only "Invalid input", which is precisely the
|
|
16174
|
+
// no-feedback outcome this schema exists to remove.
|
|
16175
|
+
error: () => `not a valid post-validator: use a bare name (${PostValidatorName.options.map((name) => JSON.stringify(name)).join(
|
|
16176
|
+
" or "
|
|
16177
|
+
)}) or { "name": ..., "config": { ... } }. An unrecognized name would be a false-positive guard that never runs.`
|
|
16178
|
+
}
|
|
16179
|
+
).meta({ id: "PostValidatorRef" });
|
|
16180
|
+
var RequiresNearby = external_exports.strictObject({
|
|
16245
16181
|
// Each array, when present, must be non-empty and contain non-empty strings —
|
|
16246
16182
|
// an empty/blank criterion would either never fire or (for labels) match
|
|
16247
16183
|
// everything.
|
|
@@ -16256,16 +16192,23 @@ var RequiresNearby = external_exports.object({
|
|
|
16256
16192
|
(v) => (v.categories?.length ?? 0) + (v.ruleIds?.length ?? 0) + (v.labels?.length ?? 0) > 0,
|
|
16257
16193
|
{ message: "requiresNearby needs at least one of categories, ruleIds, or labels" }
|
|
16258
16194
|
).meta({ id: "RequiresNearby" });
|
|
16259
|
-
var RuleFixture = external_exports.
|
|
16195
|
+
var RuleFixture = external_exports.strictObject({
|
|
16260
16196
|
label: external_exports.string(),
|
|
16261
16197
|
text: external_exports.string().max(5e4),
|
|
16262
16198
|
shouldMatch: external_exports.boolean(),
|
|
16263
16199
|
// Simulated file context for the scan, so fixtures can assert `appliesTo`
|
|
16264
16200
|
// gating (e.g. a Python-only pattern must NOT fire in a .ts file).
|
|
16265
16201
|
filePath: external_exports.string().optional(),
|
|
16266
|
-
expectedSpans: external_exports.array(external_exports.
|
|
16202
|
+
expectedSpans: external_exports.array(external_exports.strictObject({ start: external_exports.number(), end: external_exports.number() })).optional()
|
|
16267
16203
|
}).meta({ id: "RuleFixture" });
|
|
16268
|
-
var Rule = external_exports.
|
|
16204
|
+
var Rule = external_exports.strictObject({
|
|
16205
|
+
// A pinned literal over a STRICT object, and the two together decide how this
|
|
16206
|
+
// format may grow. A rule carrying a key not listed below is refused with
|
|
16207
|
+
// `unrecognized_keys`; a rule declaring `specVersion: 2` is refused with
|
|
16208
|
+
// `invalid_value`. So the only additive path is adding an OPTIONAL field here
|
|
16209
|
+
// — that keeps every rule authored before it valid — and a rule author has no
|
|
16210
|
+
// way to introduce a field of their own or to opt into a later version.
|
|
16211
|
+
// Widening the format means changing this literal and every consumer of it.
|
|
16269
16212
|
specVersion: external_exports.literal(1),
|
|
16270
16213
|
// `packId/ruleName` (e.g. `secrets/aws-access-key`). NOTE the first segment is
|
|
16271
16214
|
// the PACK id, NOT a namespace — this is a DIFFERENT slug space from a
|
|
@@ -16301,406 +16244,350 @@ var PackManifest = external_exports.object({
|
|
|
16301
16244
|
sourceUrl: external_exports.url().optional()
|
|
16302
16245
|
}).meta({ id: "PackManifest" });
|
|
16303
16246
|
|
|
16304
|
-
// ../../packages/schema/src/zod/
|
|
16305
|
-
var
|
|
16306
|
-
var
|
|
16307
|
-
var
|
|
16308
|
-
|
|
16309
|
-
|
|
16310
|
-
|
|
16311
|
-
|
|
16312
|
-
|
|
16313
|
-
|
|
16314
|
-
|
|
16315
|
-
|
|
16316
|
-
name: external_exports.string().optional()
|
|
16317
|
-
}).meta({ id: "Policy" });
|
|
16318
|
-
var PolicyBundle = external_exports.object({
|
|
16319
|
-
version: external_exports.string(),
|
|
16320
|
-
policies: external_exports.array(Policy),
|
|
16321
|
-
// Rules from the installed marketplace packs (snapshotted by the
|
|
16322
|
-
// control plane). The plugin registers these in addition to its bundled
|
|
16323
|
-
// packs. Optional so older backends — and older on-disk caches — that omit
|
|
16324
|
-
// the field still parse; consumers read `bundle.rules ?? []`.
|
|
16325
|
-
rules: external_exports.array(Rule).optional(),
|
|
16326
|
-
// When true, `rules` IS the complete effective ruleset and the runtime must
|
|
16327
|
-
// NOT merge its compiled-in bundled packs — the standalone gateway sets this
|
|
16328
|
-
// after reading the user's installed snapshot (installed_packs, enabled
|
|
16329
|
-
// packs only), which is how detection updates stay manual: new bundled
|
|
16330
|
-
// rules run only after the user applies the pack update. Absent/false keeps
|
|
16331
|
-
// the historical composition (bundled packs + rules) — older caches.
|
|
16332
|
-
rulesComplete: external_exports.boolean().optional(),
|
|
16333
|
-
// Active detection exceptions, evaluation subset only (see
|
|
16334
|
-
// ExceptionBundleEntry). Optional so older bundle producers — and older
|
|
16335
|
-
// on-disk caches — that omit the field still parse; consumers read
|
|
16336
|
-
// `bundle.exceptions ?? []`.
|
|
16337
|
-
exceptions: external_exports.array(ExceptionBundleEntry).optional(),
|
|
16338
|
-
// Installed pack version, keyed by ruleId, for rules in `rules` that came
|
|
16339
|
-
// from a versioned installed pack. Optional so older backends — and older
|
|
16340
|
-
// on-disk caches — that omit the field still parse; consumers fall back to
|
|
16341
|
-
// the rule's own spec version. NOT the bundle version above — see
|
|
16342
|
-
// installedRuleset's ruleVersions for the source of truth.
|
|
16343
|
-
ruleVersions: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
16344
|
-
customKeywords: external_exports.array(external_exports.string()),
|
|
16345
|
-
fetchedAt: external_exports.iso.datetime()
|
|
16346
|
-
}).meta({ id: "PolicyBundle" });
|
|
16347
|
-
var OBSERVE_ONLY_CATEGORIES = ["config"];
|
|
16348
|
-
var ENFORCEABLE_CATEGORIES = DetectionCategory.options.filter((c) => !OBSERVE_ONLY_CATEGORIES.includes(c));
|
|
16349
|
-
var CATEGORY_PEAK_SEVERITY = {
|
|
16350
|
-
secret: "critical",
|
|
16351
|
-
financial: "critical",
|
|
16352
|
-
// core-financial/credit-card
|
|
16353
|
-
code_flaw: "critical",
|
|
16354
|
-
pii: "high",
|
|
16355
|
-
phi: "high",
|
|
16356
|
-
custom: "high",
|
|
16357
|
-
// user-defined; conservative
|
|
16358
|
-
code_context: "low",
|
|
16359
|
-
config: "low"
|
|
16360
|
-
// observe-only; floors to monitor regardless
|
|
16361
|
-
};
|
|
16362
|
-
function severityFloorPolicy(category) {
|
|
16363
|
-
if (OBSERVE_ONLY_CATEGORIES.includes(category)) return "monitor";
|
|
16364
|
-
const peak = CATEGORY_PEAK_SEVERITY[category];
|
|
16365
|
-
return peak === "critical" || peak === "high" ? "warn" : "monitor";
|
|
16366
|
-
}
|
|
16367
|
-
var PolicyKind = external_exports.enum(["builtin", "custom"]).meta({ id: "PolicyKind" });
|
|
16368
|
-
var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "block"];
|
|
16369
|
-
var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
|
|
16370
|
-
var BUILTIN_POLICY_SPECS = {
|
|
16371
|
-
monitor: {
|
|
16372
|
-
name: "Monitor",
|
|
16373
|
-
action: "log",
|
|
16374
|
-
description: "Log every match for audit. The request is allowed through untouched."
|
|
16375
|
-
},
|
|
16376
|
-
warn: {
|
|
16377
|
-
name: "Warn",
|
|
16378
|
-
action: "warn",
|
|
16379
|
-
description: "Allow the request, but warn the user inline before it is sent."
|
|
16380
|
-
},
|
|
16381
|
-
redact: {
|
|
16382
|
-
name: "Redact",
|
|
16383
|
-
action: "redact",
|
|
16384
|
-
description: "Automatically strip the matched value from the request, then continue."
|
|
16385
|
-
},
|
|
16386
|
-
block: {
|
|
16387
|
-
name: "Block",
|
|
16388
|
-
action: "block",
|
|
16389
|
-
description: "Refuse the request entirely whenever any rule in this detection matches."
|
|
16390
|
-
}
|
|
16391
|
-
};
|
|
16392
|
-
function builtinPolicyToAction(id) {
|
|
16393
|
-
return BUILTIN_POLICY_SPECS[id].action;
|
|
16394
|
-
}
|
|
16395
|
-
var DEFAULT_ACTIONS = Object.fromEntries(
|
|
16396
|
-
DetectionCategory.options.map((c) => [c, builtinPolicyToAction(severityFloorPolicy(c))])
|
|
16397
|
-
);
|
|
16398
|
-
var BUILTIN_POLICIES = Object.fromEntries(
|
|
16399
|
-
KNOWN_BUILTIN_IDS.map((id) => [id, { id, ...BUILTIN_POLICY_SPECS[id] }])
|
|
16400
|
-
);
|
|
16401
|
-
var UsedByItem = external_exports.object({
|
|
16247
|
+
// ../../packages/schema/src/zod/detection.ts
|
|
16248
|
+
var OriginEnum = external_exports.enum(["library"]).meta({ id: "OriginEnum" });
|
|
16249
|
+
var DetectionFilterEnum = external_exports.enum(["all", "library", "custom", "customized", "updates"]);
|
|
16250
|
+
var LibraryStateEnum = external_exports.enum(["new", "imported", "update"]).meta({ id: "LibraryStateEnum" });
|
|
16251
|
+
var DetectionCounts = external_exports.object({
|
|
16252
|
+
all: external_exports.number().int().nonnegative(),
|
|
16253
|
+
library: external_exports.number().int().nonnegative(),
|
|
16254
|
+
custom: external_exports.number().int().nonnegative(),
|
|
16255
|
+
customized: external_exports.number().int().nonnegative(),
|
|
16256
|
+
updates: external_exports.number().int().nonnegative()
|
|
16257
|
+
}).meta({ id: "DetectionCounts" });
|
|
16258
|
+
var DetectionListItem = external_exports.object({
|
|
16402
16259
|
id: external_exports.string(),
|
|
16403
16260
|
name: external_exports.string(),
|
|
16261
|
+
version: SemVer,
|
|
16262
|
+
enabled: external_exports.boolean(),
|
|
16263
|
+
origin: OriginEnum,
|
|
16264
|
+
publisher: Namespace.optional(),
|
|
16265
|
+
publisherKind: PublisherKind.optional(),
|
|
16404
16266
|
ruleCount: external_exports.number().int().nonnegative(),
|
|
16405
|
-
|
|
16406
|
-
|
|
16407
|
-
|
|
16267
|
+
namespace: Namespace,
|
|
16268
|
+
packId: PackId,
|
|
16269
|
+
// Per-pack enforcement-policy assignment. Holds a BuiltinPolicyId ARCHETYPE
|
|
16270
|
+
// (monitor|warn|redact|block) — NOT a policies-table Policy.id guid; a
|
|
16271
|
+
// detection is a PACK, and its policy is the archetype applied to all its
|
|
16272
|
+
// rules. Absent == unassigned, which resolves to Monitor everywhere
|
|
16273
|
+
// (DEFAULT_PACK_POLICY_ID). Every enforcement surface expands it into
|
|
16274
|
+
// per-rule policies (see policyIdToAction). Typed z.string() (not
|
|
16275
|
+
// the enum) to keep the OpenAPI response tolerant of a future custom id.
|
|
16276
|
+
policyId: external_exports.string().optional(),
|
|
16277
|
+
// Set ONLY when a newer snapshot is available for this pack (OSS: the
|
|
16278
|
+
// bundled inventory recorded in available_packs differs from the installed
|
|
16279
|
+
// row). Absent == up to date or unknown. Powers the list's per-row update
|
|
16280
|
+
// badge and the `updates` filter/count without a per-item detail read.
|
|
16281
|
+
latestVersion: SemVer.optional()
|
|
16282
|
+
}).meta({ id: "DetectionListItem" });
|
|
16283
|
+
var ListDetectionsResponse = external_exports.object({
|
|
16284
|
+
counts: DetectionCounts,
|
|
16285
|
+
items: external_exports.array(DetectionListItem)
|
|
16286
|
+
}).meta({ id: "ListDetectionsResponse" });
|
|
16287
|
+
var ListDetectionsQuery = external_exports.object({
|
|
16288
|
+
filter: DetectionFilterEnum.optional().default("all"),
|
|
16289
|
+
q: external_exports.string().optional()
|
|
16290
|
+
});
|
|
16291
|
+
var DetectionStats = external_exports.object({
|
|
16292
|
+
detections: external_exports.number().int().nonnegative(),
|
|
16293
|
+
rules: external_exports.number().int().nonnegative(),
|
|
16294
|
+
active: external_exports.number().int().nonnegative(),
|
|
16295
|
+
findingsLast30d: external_exports.number().int().nonnegative()
|
|
16296
|
+
}).meta({ id: "DetectionStats" });
|
|
16297
|
+
var DetectionRule = external_exports.object({
|
|
16408
16298
|
id: external_exports.string(),
|
|
16409
|
-
kind: PolicyKind,
|
|
16410
16299
|
name: external_exports.string(),
|
|
16411
|
-
|
|
16412
|
-
|
|
16413
|
-
|
|
16414
|
-
|
|
16415
|
-
|
|
16300
|
+
category: DetectionCategory,
|
|
16301
|
+
severity: Severity,
|
|
16302
|
+
matcher: Matcher
|
|
16303
|
+
}).meta({ id: "DetectionRule" });
|
|
16304
|
+
var DetectionUpdate = external_exports.object({
|
|
16305
|
+
available: external_exports.boolean(),
|
|
16306
|
+
latestVersion: SemVer,
|
|
16307
|
+
// Rule count of the latest snapshot. Lets the update UI show a meaningful
|
|
16308
|
+
// delta ("2 rules → 14 rules") when the version did NOT change but the rule
|
|
16309
|
+
// content did — the OSS store compares content, not just version. Optional:
|
|
16310
|
+
// registry-backed updates omit it.
|
|
16311
|
+
latestRuleCount: external_exports.number().int().nonnegative().optional()
|
|
16312
|
+
}).nullable().meta({ id: "DetectionUpdate" });
|
|
16313
|
+
var DetectionDetail = external_exports.object({
|
|
16416
16314
|
id: external_exports.string(),
|
|
16417
|
-
kind: PolicyKind,
|
|
16418
16315
|
name: external_exports.string(),
|
|
16316
|
+
version: SemVer,
|
|
16419
16317
|
enabled: external_exports.boolean(),
|
|
16420
|
-
|
|
16421
|
-
|
|
16422
|
-
|
|
16423
|
-
|
|
16424
|
-
|
|
16425
|
-
|
|
16426
|
-
|
|
16427
|
-
|
|
16428
|
-
|
|
16429
|
-
|
|
16430
|
-
|
|
16431
|
-
|
|
16432
|
-
|
|
16433
|
-
|
|
16434
|
-
|
|
16435
|
-
|
|
16436
|
-
|
|
16437
|
-
|
|
16438
|
-
|
|
16439
|
-
|
|
16440
|
-
|
|
16441
|
-
|
|
16442
|
-
|
|
16443
|
-
|
|
16444
|
-
|
|
16445
|
-
|
|
16446
|
-
|
|
16447
|
-
|
|
16448
|
-
|
|
16449
|
-
|
|
16450
|
-
|
|
16451
|
-
|
|
16452
|
-
|
|
16453
|
-
|
|
16454
|
-
|
|
16455
|
-
|
|
16456
|
-
|
|
16457
|
-
|
|
16458
|
-
}).meta({ id: "
|
|
16459
|
-
var
|
|
16460
|
-
|
|
16461
|
-
|
|
16462
|
-
});
|
|
16463
|
-
var
|
|
16464
|
-
|
|
16465
|
-
|
|
16466
|
-
error: external_exports.object({
|
|
16467
|
-
code: external_exports.string(),
|
|
16468
|
-
message: external_exports.string(),
|
|
16469
|
-
details: external_exports.unknown().optional()
|
|
16318
|
+
origin: OriginEnum,
|
|
16319
|
+
publisher: Namespace.optional(),
|
|
16320
|
+
publisherKind: PublisherKind.optional(),
|
|
16321
|
+
ruleCount: external_exports.number().int().nonnegative(),
|
|
16322
|
+
namespace: Namespace,
|
|
16323
|
+
packId: PackId,
|
|
16324
|
+
description: external_exports.string().optional(),
|
|
16325
|
+
editedAt: external_exports.iso.datetime(),
|
|
16326
|
+
findingsLast30d: external_exports.number().int().nonnegative(),
|
|
16327
|
+
latestVersion: SemVer.nullable().optional(),
|
|
16328
|
+
update: DetectionUpdate,
|
|
16329
|
+
rules: external_exports.array(DetectionRule),
|
|
16330
|
+
modified: external_exports.boolean(),
|
|
16331
|
+
// Per-pack enforcement-policy assignment. Holds a BuiltinPolicyId ARCHETYPE
|
|
16332
|
+
// (monitor|warn|redact|block) — NOT a policies-table Policy.id guid; a
|
|
16333
|
+
// detection is a PACK, and its policy is the archetype applied to all its
|
|
16334
|
+
// rules. Absent == unassigned, which resolves to Monitor everywhere
|
|
16335
|
+
// (DEFAULT_PACK_POLICY_ID). Every enforcement surface expands it into
|
|
16336
|
+
// per-rule policies (see policyIdToAction). Typed z.string() (not
|
|
16337
|
+
// the enum) to keep the OpenAPI response tolerant of a future custom id.
|
|
16338
|
+
policyId: external_exports.string().optional()
|
|
16339
|
+
}).meta({ id: "DetectionDetail" });
|
|
16340
|
+
var LibraryItem = external_exports.object({
|
|
16341
|
+
id: external_exports.string(),
|
|
16342
|
+
name: external_exports.string(),
|
|
16343
|
+
publisher: Namespace,
|
|
16344
|
+
publisherKind: PublisherKind.optional(),
|
|
16345
|
+
// LOSSY single-category view of a pack. A pack MAY span several categories;
|
|
16346
|
+
// this carries only the canonical-first one for display. Do NOT filter/facet
|
|
16347
|
+
// on it — the library filter matches a pack's full category set (see
|
|
16348
|
+
// ListLibraryResponse.categories).
|
|
16349
|
+
category: DetectionCategory.optional(),
|
|
16350
|
+
version: SemVer,
|
|
16351
|
+
ruleCount: external_exports.number().int().nonnegative(),
|
|
16352
|
+
description: external_exports.string().optional(),
|
|
16353
|
+
updatedAt: external_exports.iso.datetime(),
|
|
16354
|
+
state: LibraryStateEnum,
|
|
16355
|
+
importedAs: external_exports.string().nullable()
|
|
16356
|
+
}).meta({ id: "LibraryItem" });
|
|
16357
|
+
var ListLibraryResponse = external_exports.object({
|
|
16358
|
+
categories: external_exports.array(DetectionCategory),
|
|
16359
|
+
items: external_exports.array(LibraryItem)
|
|
16360
|
+
}).meta({ id: "ListLibraryResponse" });
|
|
16361
|
+
var ImportDetectionRequest = external_exports.object({
|
|
16362
|
+
libraryId: external_exports.string().refine((v) => /^[^/]+\/[^/]+$/.test(v), {
|
|
16363
|
+
message: "libraryId must be in namespace/packId format"
|
|
16470
16364
|
})
|
|
16471
|
-
}).meta({ id: "
|
|
16365
|
+
}).meta({ id: "ImportDetectionRequest" });
|
|
16472
16366
|
|
|
16473
|
-
// ../../packages/schema/src/zod/
|
|
16474
|
-
var
|
|
16475
|
-
var
|
|
16476
|
-
|
|
16477
|
-
|
|
16478
|
-
|
|
16479
|
-
|
|
16480
|
-
|
|
16481
|
-
|
|
16482
|
-
|
|
16483
|
-
pluginName: external_exports.string().optional(),
|
|
16484
|
-
// Volatile — rides the attribute bag, never the identity hash.
|
|
16485
|
-
version: external_exports.string().optional(),
|
|
16486
|
-
description: external_exports.string().optional(),
|
|
16487
|
-
// Skill directory mtime (ISO) — the "updated Nd ago" freshness signal.
|
|
16488
|
-
updatedAt: external_exports.iso.datetime().optional(),
|
|
16489
|
-
// Filesystem path — the promoted inventory `location` column.
|
|
16490
|
-
location: external_exports.string().optional()
|
|
16491
|
-
});
|
|
16492
|
-
var HookScanEntry = external_exports.object({
|
|
16493
|
-
// Hook event name (PreToolUse, PostToolUse, …). Open string, not an enum: the
|
|
16494
|
-
// set is harness-defined and grows without a schema change.
|
|
16495
|
-
event: external_exports.string().min(1),
|
|
16496
|
-
// The tool matcher ('Bash', 'Edit|Write', …). Absent = matches all tools.
|
|
16497
|
-
matcher: external_exports.string().optional(),
|
|
16498
|
-
command: external_exports.string().min(1),
|
|
16499
|
-
timeout: external_exports.number().optional(),
|
|
16500
|
-
scope: ConfigScope,
|
|
16501
|
-
pluginName: external_exports.string().optional(),
|
|
16502
|
-
// The settings file / hooks.json the entry came from.
|
|
16503
|
-
location: external_exports.string().optional()
|
|
16367
|
+
// ../../packages/schema/src/zod/inventory.ts
|
|
16368
|
+
var AssetType = external_exports.enum(["project", "skill", "mcp", "hook", "config"]).meta({ id: "AssetType" });
|
|
16369
|
+
var AccessLevel = external_exports.enum(["open", "approved", "blocked"]).meta({ id: "AccessLevel" });
|
|
16370
|
+
var Origin = external_exports.enum(["source", "public-dep", "vendored", "config", "data", "docs", "generated"]).meta({ id: "Origin" });
|
|
16371
|
+
var TrustLevel = external_exports.enum(["known-good", "risky", "unapproved"]).meta({ id: "TrustLevel" });
|
|
16372
|
+
var Flag = external_exports.enum(["update", "stale", "conflict", "unknown", "change", "untracked", "risk", "findings"]).meta({ id: "Flag" });
|
|
16373
|
+
var Visibility = external_exports.enum(["public", "private"]).meta({ id: "Visibility" });
|
|
16374
|
+
var HarnessEventKind = external_exports.enum(["block", "redact", "warn"]).meta({ id: "HarnessEventKind" });
|
|
16375
|
+
var HarnessId = Harness.extract(["ClaudeCode", "Cursor", "Codex", "Antigravity"]).meta({
|
|
16376
|
+
id: "HarnessId"
|
|
16504
16377
|
});
|
|
16505
|
-
var
|
|
16506
|
-
|
|
16507
|
-
|
|
16508
|
-
|
|
16509
|
-
|
|
16510
|
-
|
|
16511
|
-
|
|
16512
|
-
|
|
16513
|
-
|
|
16514
|
-
|
|
16515
|
-
|
|
16516
|
-
|
|
16517
|
-
|
|
16518
|
-
|
|
16519
|
-
|
|
16520
|
-
|
|
16521
|
-
|
|
16522
|
-
|
|
16523
|
-
|
|
16524
|
-
|
|
16525
|
-
|
|
16526
|
-
|
|
16527
|
-
|
|
16528
|
-
|
|
16529
|
-
|
|
16530
|
-
|
|
16531
|
-
|
|
16532
|
-
|
|
16533
|
-
|
|
16534
|
-
|
|
16535
|
-
location: external_exports.string().optional()
|
|
16378
|
+
var AccessCounts = external_exports.object({
|
|
16379
|
+
open: external_exports.number().int().nonnegative(),
|
|
16380
|
+
approved: external_exports.number().int().nonnegative(),
|
|
16381
|
+
blocked: external_exports.number().int().nonnegative(),
|
|
16382
|
+
total: external_exports.number().int().nonnegative()
|
|
16383
|
+
}).meta({ id: "AccessCounts" });
|
|
16384
|
+
var AssetSummary = external_exports.object({
|
|
16385
|
+
id: external_exports.string(),
|
|
16386
|
+
type: AssetType,
|
|
16387
|
+
name: external_exports.string(),
|
|
16388
|
+
sub: external_exports.string(),
|
|
16389
|
+
flags: external_exports.array(Flag),
|
|
16390
|
+
/** MCP servers only — omitted for all other types. */
|
|
16391
|
+
trust: TrustLevel.optional()
|
|
16392
|
+
}).meta({ id: "AssetSummary" });
|
|
16393
|
+
var ProjectSummary = external_exports.object({
|
|
16394
|
+
id: external_exports.string(),
|
|
16395
|
+
name: external_exports.string(),
|
|
16396
|
+
repo: external_exports.string(),
|
|
16397
|
+
visibility: Visibility,
|
|
16398
|
+
language: external_exports.string(),
|
|
16399
|
+
policyDefault: AccessLevel,
|
|
16400
|
+
updatedAt: external_exports.iso.datetime(),
|
|
16401
|
+
accessCounts: AccessCounts,
|
|
16402
|
+
findingsCount: external_exports.number().int().nonnegative()
|
|
16403
|
+
}).meta({ id: "ProjectSummary" });
|
|
16404
|
+
var HarnessCategory = external_exports.object({
|
|
16405
|
+
/** One of config/skill/mcp/hook — never project (enforced at service layer). */
|
|
16406
|
+
type: AssetType,
|
|
16407
|
+
assets: external_exports.array(AssetSummary)
|
|
16536
16408
|
});
|
|
16537
|
-
var
|
|
16538
|
-
|
|
16539
|
-
|
|
16540
|
-
|
|
16541
|
-
|
|
16542
|
-
|
|
16543
|
-
|
|
16544
|
-
|
|
16545
|
-
|
|
16546
|
-
|
|
16547
|
-
|
|
16548
|
-
|
|
16549
|
-
|
|
16550
|
-
|
|
16551
|
-
|
|
16409
|
+
var HarnessSummary = external_exports.object({
|
|
16410
|
+
id: HarnessId,
|
|
16411
|
+
label: external_exports.string(),
|
|
16412
|
+
kind: external_exports.string(),
|
|
16413
|
+
version: external_exports.string(),
|
|
16414
|
+
sessions: external_exports.number().int().nonnegative(),
|
|
16415
|
+
assetCount: external_exports.number().int().nonnegative(),
|
|
16416
|
+
flagCount: external_exports.number().int().nonnegative(),
|
|
16417
|
+
projects: external_exports.array(ProjectSummary),
|
|
16418
|
+
categories: external_exports.array(HarnessCategory)
|
|
16419
|
+
}).meta({ id: "HarnessSummary" });
|
|
16420
|
+
var ListHarnessesResponse = external_exports.object({ items: external_exports.array(HarnessSummary) }).meta({ id: "ListHarnessesResponse" });
|
|
16421
|
+
var AssetGroup = external_exports.object({
|
|
16422
|
+
/** Group key — never project (enforced at service layer). */
|
|
16423
|
+
type: AssetType,
|
|
16424
|
+
total: external_exports.number().int().nonnegative(),
|
|
16425
|
+
/**
|
|
16426
|
+
* MCP group only — omitted for all other types.
|
|
16427
|
+
* Partial: only TrustLevel keys with non-zero counts are included.
|
|
16428
|
+
* Strict: unknown keys are rejected — only TrustLevel values are valid keys.
|
|
16429
|
+
*/
|
|
16430
|
+
trustRollup: external_exports.object({
|
|
16431
|
+
"known-good": external_exports.number().int().nonnegative(),
|
|
16432
|
+
risky: external_exports.number().int().nonnegative(),
|
|
16433
|
+
unapproved: external_exports.number().int().nonnegative()
|
|
16434
|
+
}).partial().strict().optional(),
|
|
16435
|
+
/**
|
|
16436
|
+
* Partial: only Flag keys with non-zero counts are included.
|
|
16437
|
+
* Strict: unknown keys are rejected — only Flag values are valid keys.
|
|
16438
|
+
*/
|
|
16439
|
+
flagRollup: external_exports.object({
|
|
16440
|
+
update: external_exports.number().int().nonnegative(),
|
|
16441
|
+
stale: external_exports.number().int().nonnegative(),
|
|
16442
|
+
conflict: external_exports.number().int().nonnegative(),
|
|
16443
|
+
unknown: external_exports.number().int().nonnegative(),
|
|
16444
|
+
change: external_exports.number().int().nonnegative(),
|
|
16445
|
+
untracked: external_exports.number().int().nonnegative(),
|
|
16446
|
+
risk: external_exports.number().int().nonnegative(),
|
|
16447
|
+
findings: external_exports.number().int().nonnegative()
|
|
16448
|
+
}).partial().strict(),
|
|
16449
|
+
items: external_exports.array(AssetSummary)
|
|
16450
|
+
}).meta({ id: "AssetGroup" });
|
|
16451
|
+
var ListAssetsResponse = external_exports.object({ groups: external_exports.array(AssetGroup) }).meta({ id: "ListAssetsResponse" });
|
|
16452
|
+
var McpTool = external_exports.object({
|
|
16453
|
+
name: external_exports.string(),
|
|
16454
|
+
signature: external_exports.string(),
|
|
16455
|
+
description: external_exports.string(),
|
|
16456
|
+
write: external_exports.boolean(),
|
|
16457
|
+
/** Non-null string when tool is dangerous / blocked; null otherwise. */
|
|
16458
|
+
risk: external_exports.string().nullable()
|
|
16459
|
+
}).meta({ id: "McpTool" });
|
|
16460
|
+
var AssetFindingRef = external_exports.object({
|
|
16461
|
+
id: external_exports.string(),
|
|
16462
|
+
title: external_exports.string(),
|
|
16463
|
+
note: external_exports.string()
|
|
16552
16464
|
});
|
|
16553
|
-
var
|
|
16554
|
-
|
|
16555
|
-
|
|
16556
|
-
|
|
16557
|
-
|
|
16558
|
-
|
|
16559
|
-
|
|
16465
|
+
var AssetDetail = AssetSummary.extend({
|
|
16466
|
+
/** string | null — null when no description is available. */
|
|
16467
|
+
description: external_exports.string().nullable(),
|
|
16468
|
+
/** trustLevel | null — null for non-MCP assets. */
|
|
16469
|
+
trust: TrustLevel.nullable(),
|
|
16470
|
+
/** Type-specific raw key/values — FE renders the grid. */
|
|
16471
|
+
meta: external_exports.record(external_exports.string(), external_exports.unknown()),
|
|
16472
|
+
/** always present — object when there is an active finding, null when absent. */
|
|
16473
|
+
finding: AssetFindingRef.nullable(),
|
|
16474
|
+
/** MCP exposed-tools list — omitted for non-mcp. */
|
|
16475
|
+
tools: external_exports.array(McpTool).optional()
|
|
16476
|
+
}).meta({ id: "AssetDetail" });
|
|
16477
|
+
var ListProjectsResponse = external_exports.object({ items: external_exports.array(ProjectSummary) }).meta({ id: "ListProjectsResponse" });
|
|
16478
|
+
var InventoryStats = external_exports.object({
|
|
16479
|
+
/** Total assets/projects with ≥1 flag or finding (drives the attention header chip). */
|
|
16480
|
+
attention: external_exports.number().int().nonnegative(),
|
|
16481
|
+
byType: external_exports.object({
|
|
16482
|
+
project: external_exports.number().int().nonnegative(),
|
|
16483
|
+
skill: external_exports.number().int().nonnegative(),
|
|
16484
|
+
mcp: external_exports.number().int().nonnegative(),
|
|
16485
|
+
hook: external_exports.number().int().nonnegative(),
|
|
16486
|
+
config: external_exports.number().int().nonnegative()
|
|
16487
|
+
}),
|
|
16488
|
+
harnesses: external_exports.number().int().nonnegative(),
|
|
16489
|
+
mcpTrust: external_exports.object({
|
|
16490
|
+
"known-good": external_exports.number().int().nonnegative(),
|
|
16491
|
+
risky: external_exports.number().int().nonnegative(),
|
|
16492
|
+
unapproved: external_exports.number().int().nonnegative()
|
|
16493
|
+
})
|
|
16494
|
+
}).meta({ id: "InventoryStats" });
|
|
16495
|
+
var FileSummary = external_exports.object({
|
|
16496
|
+
path: external_exports.string(),
|
|
16497
|
+
name: external_exports.string(),
|
|
16498
|
+
origin: Origin,
|
|
16499
|
+
/** Effective access (override applied). */
|
|
16500
|
+
access: AccessLevel,
|
|
16501
|
+
/** True when a file_access_override differs from the computed default. */
|
|
16502
|
+
isCustom: external_exports.boolean(),
|
|
16503
|
+
findings: external_exports.number().int().nonnegative(),
|
|
16504
|
+
/** When the file was auto-blocked by a detection; null when not blocked. */
|
|
16505
|
+
blockedAt: external_exports.iso.datetime().nullable().optional(),
|
|
16506
|
+
/** Why the file was blocked; null when absent. */
|
|
16507
|
+
note: external_exports.string().nullable().optional()
|
|
16508
|
+
}).meta({ id: "FileSummary" });
|
|
16509
|
+
var FolderSummary = external_exports.object({
|
|
16510
|
+
name: external_exports.string(),
|
|
16511
|
+
path: external_exports.string(),
|
|
16512
|
+
/** Rollup of effective access across all descendants. */
|
|
16513
|
+
accessCounts: AccessCounts
|
|
16514
|
+
}).meta({ id: "FolderSummary" });
|
|
16515
|
+
var ProjectTreeResponse = external_exports.object({
|
|
16516
|
+
project: external_exports.object({
|
|
16517
|
+
id: external_exports.string(),
|
|
16518
|
+
repo: external_exports.string(),
|
|
16519
|
+
visibility: Visibility
|
|
16520
|
+
}),
|
|
16521
|
+
path: external_exports.string(),
|
|
16522
|
+
/** Browse mode: one-level folders at the current path. Omitted in search mode. */
|
|
16523
|
+
folders: external_exports.array(FolderSummary).optional(),
|
|
16524
|
+
files: external_exports.array(FileSummary)
|
|
16525
|
+
}).meta({ id: "ProjectTreeResponse" });
|
|
16526
|
+
var FileDetail = FileSummary.extend({
|
|
16527
|
+
project: external_exports.object({
|
|
16528
|
+
repo: external_exports.string(),
|
|
16529
|
+
visibility: Visibility,
|
|
16530
|
+
language: external_exports.string(),
|
|
16531
|
+
policyDefault: AccessLevel,
|
|
16532
|
+
updatedAt: external_exports.iso.datetime()
|
|
16533
|
+
}),
|
|
16534
|
+
findingsRefs: external_exports.array(external_exports.object({ id: external_exports.string(), title: external_exports.string() }))
|
|
16535
|
+
}).meta({ id: "FileDetail" });
|
|
16536
|
+
var SetFileAccessBody = external_exports.object({
|
|
16537
|
+
path: external_exports.string(),
|
|
16538
|
+
access: AccessLevel
|
|
16539
|
+
}).meta({ id: "SetFileAccessBody" });
|
|
16540
|
+
var SetFileAccessResponse = external_exports.object({
|
|
16541
|
+
file: FileSummary,
|
|
16542
|
+
accessCounts: AccessCounts
|
|
16543
|
+
}).meta({ id: "SetFileAccessResponse" });
|
|
16544
|
+
var SetMcpTrustBody = external_exports.object({ trust: TrustLevel }).meta({ id: "SetMcpTrustBody" });
|
|
16545
|
+
var HarnessEventItem = external_exports.object({
|
|
16546
|
+
kind: HarnessEventKind,
|
|
16547
|
+
title: external_exports.string(),
|
|
16548
|
+
detail: external_exports.string(),
|
|
16549
|
+
occurredAt: external_exports.iso.datetime(),
|
|
16550
|
+
findingId: external_exports.string().nullable().optional()
|
|
16551
|
+
}).meta({ id: "HarnessEventItem" });
|
|
16552
|
+
var HarnessEventsResponse = external_exports.object({
|
|
16553
|
+
counts: external_exports.object({
|
|
16554
|
+
block: external_exports.number().int().nonnegative(),
|
|
16555
|
+
redact: external_exports.number().int().nonnegative(),
|
|
16556
|
+
warn: external_exports.number().int().nonnegative()
|
|
16557
|
+
}),
|
|
16558
|
+
items: external_exports.array(HarnessEventItem)
|
|
16559
|
+
}).meta({ id: "HarnessEventsResponse" });
|
|
16560
|
+
var RescanResponse = external_exports.object({
|
|
16561
|
+
jobId: external_exports.string(),
|
|
16562
|
+
startedAt: external_exports.iso.datetime()
|
|
16563
|
+
}).meta({ id: "RescanResponse" });
|
|
16564
|
+
var ConnectProjectBody = external_exports.object({ repo: external_exports.string() }).meta({ id: "ConnectProjectBody" });
|
|
16565
|
+
var ListAssetsQuery = external_exports.object({
|
|
16566
|
+
/** Filter by one or more AssetType values; absent means all types. */
|
|
16567
|
+
type: external_exports.array(AssetType).optional(),
|
|
16568
|
+
/** Free-text search term. */
|
|
16569
|
+
q: external_exports.string().optional()
|
|
16560
16570
|
});
|
|
16561
|
-
var
|
|
16562
|
-
|
|
16563
|
-
|
|
16564
|
-
|
|
16565
|
-
|
|
16566
|
-
|
|
16567
|
-
|
|
16568
|
-
|
|
16569
|
-
|
|
16570
|
-
|
|
16571
|
+
var GetProjectTreeQuery = external_exports.object({
|
|
16572
|
+
/** Subtree root path; defaults to repository root when absent. */
|
|
16573
|
+
path: external_exports.string().optional(),
|
|
16574
|
+
/** Free-text filter applied to file paths. */
|
|
16575
|
+
q: external_exports.string().optional(),
|
|
16576
|
+
/**
|
|
16577
|
+
* Special listing mode. `blocked` returns every effectively-blocked, auto-blocked
|
|
16578
|
+
* file across the whole repo (folders omitted, most-recent first), ignoring
|
|
16579
|
+
* `path`/`q` — powers the project-wide "recently blocked" strip.
|
|
16580
|
+
*/
|
|
16581
|
+
filter: external_exports.enum(["blocked"]).optional()
|
|
16571
16582
|
});
|
|
16572
|
-
var
|
|
16573
|
-
|
|
16574
|
-
|
|
16575
|
-
definitions: external_exports.array(InspectionDefinitionInput).optional(),
|
|
16576
|
-
findings: external_exports.array(ConfigPostureFindingInput).optional()
|
|
16583
|
+
var GetProjectFileQuery = external_exports.object({
|
|
16584
|
+
/** Repository-relative file path; absent or empty → 400. */
|
|
16585
|
+
path: external_exports.string()
|
|
16577
16586
|
});
|
|
16578
|
-
|
|
16579
|
-
|
|
16580
|
-
|
|
16581
|
-
var PackId = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
16582
|
-
var SemVer = external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?$/);
|
|
16583
|
-
var PublisherKind = external_exports.enum(["labs", "user", "org"]);
|
|
16584
|
-
|
|
16585
|
-
// ../../packages/schema/src/zod/detection.ts
|
|
16586
|
-
var OriginEnum = external_exports.enum(["library"]).meta({ id: "OriginEnum" });
|
|
16587
|
-
var DetectionFilterEnum = external_exports.enum(["all", "library", "custom", "customized", "updates"]);
|
|
16588
|
-
var LibraryStateEnum = external_exports.enum(["new", "imported", "update"]).meta({ id: "LibraryStateEnum" });
|
|
16589
|
-
var DetectionCounts = external_exports.object({
|
|
16590
|
-
all: external_exports.number().int().nonnegative(),
|
|
16591
|
-
library: external_exports.number().int().nonnegative(),
|
|
16592
|
-
custom: external_exports.number().int().nonnegative(),
|
|
16593
|
-
customized: external_exports.number().int().nonnegative(),
|
|
16594
|
-
updates: external_exports.number().int().nonnegative()
|
|
16595
|
-
}).meta({ id: "DetectionCounts" });
|
|
16596
|
-
var DetectionListItem = external_exports.object({
|
|
16597
|
-
id: external_exports.string(),
|
|
16598
|
-
name: external_exports.string(),
|
|
16599
|
-
version: SemVer,
|
|
16600
|
-
enabled: external_exports.boolean(),
|
|
16601
|
-
origin: OriginEnum,
|
|
16602
|
-
publisher: Namespace.optional(),
|
|
16603
|
-
publisherKind: PublisherKind.optional(),
|
|
16604
|
-
ruleCount: external_exports.number().int().nonnegative(),
|
|
16605
|
-
namespace: Namespace,
|
|
16606
|
-
packId: PackId,
|
|
16607
|
-
// Per-pack enforcement-policy assignment. Holds a BuiltinPolicyId ARCHETYPE
|
|
16608
|
-
// (monitor|warn|redact|block) — NOT a policies-table Policy.id guid; a
|
|
16609
|
-
// detection is a PACK, and its policy is the archetype applied to all its
|
|
16610
|
-
// rules. Absent == unassigned, which resolves to Monitor everywhere
|
|
16611
|
-
// (DEFAULT_PACK_POLICY_ID). Every enforcement surface expands it into
|
|
16612
|
-
// per-rule policies (see policyIdToAction). Typed z.string() (not
|
|
16613
|
-
// the enum) to keep the OpenAPI response tolerant of a future custom id.
|
|
16614
|
-
policyId: external_exports.string().optional(),
|
|
16615
|
-
// Set ONLY when a newer snapshot is available for this pack (OSS: the
|
|
16616
|
-
// bundled inventory recorded in available_packs differs from the installed
|
|
16617
|
-
// row). Absent == up to date or unknown. Powers the list's per-row update
|
|
16618
|
-
// badge and the `updates` filter/count without a per-item detail read.
|
|
16619
|
-
latestVersion: SemVer.optional()
|
|
16620
|
-
}).meta({ id: "DetectionListItem" });
|
|
16621
|
-
var ListDetectionsResponse = external_exports.object({
|
|
16622
|
-
counts: DetectionCounts,
|
|
16623
|
-
items: external_exports.array(DetectionListItem)
|
|
16624
|
-
}).meta({ id: "ListDetectionsResponse" });
|
|
16625
|
-
var ListDetectionsQuery = external_exports.object({
|
|
16626
|
-
filter: DetectionFilterEnum.optional().default("all"),
|
|
16627
|
-
q: external_exports.string().optional()
|
|
16587
|
+
var GetHarnessEventsQuery = external_exports.object({
|
|
16588
|
+
/** Maximum number of events to return. Range: 1–50; default: 7. */
|
|
16589
|
+
limit: external_exports.coerce.number().int().min(1).max(50).default(7)
|
|
16628
16590
|
});
|
|
16629
|
-
var DetectionStats = external_exports.object({
|
|
16630
|
-
detections: external_exports.number().int().nonnegative(),
|
|
16631
|
-
rules: external_exports.number().int().nonnegative(),
|
|
16632
|
-
active: external_exports.number().int().nonnegative(),
|
|
16633
|
-
findingsLast30d: external_exports.number().int().nonnegative()
|
|
16634
|
-
}).meta({ id: "DetectionStats" });
|
|
16635
|
-
var DetectionRule = external_exports.object({
|
|
16636
|
-
id: external_exports.string(),
|
|
16637
|
-
name: external_exports.string(),
|
|
16638
|
-
category: DetectionCategory,
|
|
16639
|
-
severity: Severity,
|
|
16640
|
-
matcher: Matcher
|
|
16641
|
-
}).meta({ id: "DetectionRule" });
|
|
16642
|
-
var DetectionUpdate = external_exports.object({
|
|
16643
|
-
available: external_exports.boolean(),
|
|
16644
|
-
latestVersion: SemVer,
|
|
16645
|
-
// Rule count of the latest snapshot. Lets the update UI show a meaningful
|
|
16646
|
-
// delta ("2 rules → 14 rules") when the version did NOT change but the rule
|
|
16647
|
-
// content did — the OSS store compares content, not just version. Optional:
|
|
16648
|
-
// registry-backed updates omit it.
|
|
16649
|
-
latestRuleCount: external_exports.number().int().nonnegative().optional()
|
|
16650
|
-
}).nullable().meta({ id: "DetectionUpdate" });
|
|
16651
|
-
var DetectionDetail = external_exports.object({
|
|
16652
|
-
id: external_exports.string(),
|
|
16653
|
-
name: external_exports.string(),
|
|
16654
|
-
version: SemVer,
|
|
16655
|
-
enabled: external_exports.boolean(),
|
|
16656
|
-
origin: OriginEnum,
|
|
16657
|
-
publisher: Namespace.optional(),
|
|
16658
|
-
publisherKind: PublisherKind.optional(),
|
|
16659
|
-
ruleCount: external_exports.number().int().nonnegative(),
|
|
16660
|
-
namespace: Namespace,
|
|
16661
|
-
packId: PackId,
|
|
16662
|
-
description: external_exports.string().optional(),
|
|
16663
|
-
editedAt: external_exports.iso.datetime(),
|
|
16664
|
-
findingsLast30d: external_exports.number().int().nonnegative(),
|
|
16665
|
-
latestVersion: SemVer.nullable().optional(),
|
|
16666
|
-
update: DetectionUpdate,
|
|
16667
|
-
rules: external_exports.array(DetectionRule),
|
|
16668
|
-
modified: external_exports.boolean(),
|
|
16669
|
-
// Per-pack enforcement-policy assignment. Holds a BuiltinPolicyId ARCHETYPE
|
|
16670
|
-
// (monitor|warn|redact|block) — NOT a policies-table Policy.id guid; a
|
|
16671
|
-
// detection is a PACK, and its policy is the archetype applied to all its
|
|
16672
|
-
// rules. Absent == unassigned, which resolves to Monitor everywhere
|
|
16673
|
-
// (DEFAULT_PACK_POLICY_ID). Every enforcement surface expands it into
|
|
16674
|
-
// per-rule policies (see policyIdToAction). Typed z.string() (not
|
|
16675
|
-
// the enum) to keep the OpenAPI response tolerant of a future custom id.
|
|
16676
|
-
policyId: external_exports.string().optional()
|
|
16677
|
-
}).meta({ id: "DetectionDetail" });
|
|
16678
|
-
var LibraryItem = external_exports.object({
|
|
16679
|
-
id: external_exports.string(),
|
|
16680
|
-
name: external_exports.string(),
|
|
16681
|
-
publisher: Namespace,
|
|
16682
|
-
publisherKind: PublisherKind.optional(),
|
|
16683
|
-
// LOSSY single-category view of a pack. A pack MAY span several categories;
|
|
16684
|
-
// this carries only the canonical-first one for display. Do NOT filter/facet
|
|
16685
|
-
// on it — the library filter matches a pack's full category set (see
|
|
16686
|
-
// ListLibraryResponse.categories).
|
|
16687
|
-
category: DetectionCategory.optional(),
|
|
16688
|
-
version: SemVer,
|
|
16689
|
-
ruleCount: external_exports.number().int().nonnegative(),
|
|
16690
|
-
description: external_exports.string().optional(),
|
|
16691
|
-
updatedAt: external_exports.iso.datetime(),
|
|
16692
|
-
state: LibraryStateEnum,
|
|
16693
|
-
importedAs: external_exports.string().nullable()
|
|
16694
|
-
}).meta({ id: "LibraryItem" });
|
|
16695
|
-
var ListLibraryResponse = external_exports.object({
|
|
16696
|
-
categories: external_exports.array(DetectionCategory),
|
|
16697
|
-
items: external_exports.array(LibraryItem)
|
|
16698
|
-
}).meta({ id: "ListLibraryResponse" });
|
|
16699
|
-
var ImportDetectionRequest = external_exports.object({
|
|
16700
|
-
libraryId: external_exports.string().refine((v) => /^[^/]+\/[^/]+$/.test(v), {
|
|
16701
|
-
message: "libraryId must be in namespace/packId format"
|
|
16702
|
-
})
|
|
16703
|
-
}).meta({ id: "ImportDetectionRequest" });
|
|
16704
16591
|
|
|
16705
16592
|
// ../../packages/schema/src/zod/shares.ts
|
|
16706
16593
|
var DestinationKind = external_exports.enum(["provider", "internal", "external", "ip"]).meta({ id: "DestinationKind" });
|
|
@@ -16908,6 +16795,127 @@ var EgressWriteSummary = external_exports.object({
|
|
|
16908
16795
|
droppedFiles: external_exports.array(external_exports.string()).default([])
|
|
16909
16796
|
}).meta({ id: "EgressWriteSummary" });
|
|
16910
16797
|
|
|
16798
|
+
// ../../packages/schema/src/zod/event.ts
|
|
16799
|
+
var EventKind = external_exports.enum(["prompt", "response", "code_change", "tool_use"]).meta({ id: "EventKind" });
|
|
16800
|
+
var CAPTURE_EVENT_TYPES_SQL = EventKind.options.map((k) => `'${k}'`).join(",");
|
|
16801
|
+
var EventMetadata = external_exports.object({
|
|
16802
|
+
sessionId: external_exports.string().optional(),
|
|
16803
|
+
repo: external_exports.string().optional(),
|
|
16804
|
+
filePath: external_exports.string().optional(),
|
|
16805
|
+
// The host tool whose input/output was scanned (e.g. 'Bash', 'WebFetch'),
|
|
16806
|
+
// set by the tool-scanning hooks. The tool NAME only — never the tool's
|
|
16807
|
+
// arguments or output, which can carry the very value a finding masked
|
|
16808
|
+
// (metadata is stored unredacted). Gives findings on non-file captures a
|
|
16809
|
+
// display location ("via Bash") when no filePath exists.
|
|
16810
|
+
toolName: external_exports.string().optional(),
|
|
16811
|
+
// Set (true) by the worktree scanner when the file is excluded by the
|
|
16812
|
+
// repo's .gitignore. Gitignored files ARE still scanned — local scratch and
|
|
16813
|
+
// generated code can leak real secrets — but the provenance is recorded so
|
|
16814
|
+
// policy/dashboards can treat those findings as informational rather than
|
|
16815
|
+
// blocking. Omitted (not false) for tracked files and non-scan events.
|
|
16816
|
+
gitignored: external_exports.boolean().optional(),
|
|
16817
|
+
// Set (true) ONLY when the event's `content` is the COMPLETE file at
|
|
16818
|
+
// capture time (a worktree scan reading from disk). Hook-captured edits
|
|
16819
|
+
// (e.g. an Edit tool's new_string) are partial fragments and MUST NOT set
|
|
16820
|
+
// this. The resolver-on-ingest keys its fixed-at-source dropout
|
|
16821
|
+
// diff on this marker: only a whole-file snapshot can prove a previously
|
|
16822
|
+
// open finding is gone; a fragment's absence proves nothing (the secret
|
|
16823
|
+
// may live outside the hunk). Omitted (not false) for fragments and
|
|
16824
|
+
// non-scan events, so pre-marker clients safely default to the
|
|
16825
|
+
// non-authoritative path.
|
|
16826
|
+
wholeFile: external_exports.boolean().optional(),
|
|
16827
|
+
model: external_exports.string().optional(),
|
|
16828
|
+
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
16829
|
+
// Distributed-tracing correlation. `correlationId` ties a recorded event back
|
|
16830
|
+
// to the request that captured/ingested it (a UUID, generated independently of
|
|
16831
|
+
// the trace id); `traceId` is the W3C trace id (32 lowercase hex chars) of the
|
|
16832
|
+
// originating span when telemetry is enabled. Both optional + backward
|
|
16833
|
+
// compatible — populated by the plugin (see @akasecurity/plugin-sdk).
|
|
16834
|
+
correlationId: external_exports.uuid().optional(),
|
|
16835
|
+
traceId: external_exports.string().regex(/^[0-9a-f]{32}$/).optional(),
|
|
16836
|
+
// Ids of the detection exceptions that downgraded findings in this capture
|
|
16837
|
+
// to 'allow' — the enforcement audit trail's link back to the grant that
|
|
16838
|
+
// authorized the bypass. Absent on captures where no exception applied.
|
|
16839
|
+
exceptionIds: external_exports.array(external_exports.guid()).optional()
|
|
16840
|
+
}).meta({ id: "EventMetadata" });
|
|
16841
|
+
var Event = external_exports.object({
|
|
16842
|
+
id: external_exports.guid(),
|
|
16843
|
+
sourceTool: SourceTool,
|
|
16844
|
+
kind: EventKind,
|
|
16845
|
+
occurredAt: external_exports.iso.datetime(),
|
|
16846
|
+
contentHash: external_exports.string(),
|
|
16847
|
+
content: external_exports.string(),
|
|
16848
|
+
metadata: EventMetadata.optional()
|
|
16849
|
+
}).meta({ id: "Event" });
|
|
16850
|
+
var IngestEvent = Event.meta({ id: "IngestEvent" });
|
|
16851
|
+
var IngestBatch = external_exports.object({
|
|
16852
|
+
events: external_exports.array(IngestEvent).min(1).max(100),
|
|
16853
|
+
// Dedup policy for this batch. Id-dedup ALWAYS applies. 'content-hash'
|
|
16854
|
+
// additionally rejects any event whose contentHash the store has already
|
|
16855
|
+
// recorded — for re-runnable bulk ingest (worktree scan, transcript
|
|
16856
|
+
// backfill), where a re-run mints fresh event ids for identical content and
|
|
16857
|
+
// would otherwise accumulate duplicates. Live hook traffic must NOT set it:
|
|
16858
|
+
// two genuinely separate prompts can be byte-identical and both belong on
|
|
16859
|
+
// the timeline.
|
|
16860
|
+
dedupe: external_exports.literal("content-hash").optional()
|
|
16861
|
+
}).meta({ id: "IngestBatch" });
|
|
16862
|
+
|
|
16863
|
+
// ../../packages/schema/src/zod/exception.ts
|
|
16864
|
+
var ExceptionScope = external_exports.enum(["once", "temporary", "permanent"]);
|
|
16865
|
+
var ExceptionConditions = external_exports.object({
|
|
16866
|
+
repo: external_exports.string().optional(),
|
|
16867
|
+
sourceTool: external_exports.string().optional(),
|
|
16868
|
+
provider: external_exports.string().optional()
|
|
16869
|
+
}).strict();
|
|
16870
|
+
var ExceptionCapability = external_exports.enum(["suppress", "reveal_to_model"]);
|
|
16871
|
+
var DetectionException = external_exports.object({
|
|
16872
|
+
id: external_exports.guid(),
|
|
16873
|
+
ruleId: external_exports.string(),
|
|
16874
|
+
// Denormalized from the rule, for reporting — never matched on.
|
|
16875
|
+
category: DetectionCategory,
|
|
16876
|
+
// HMAC-SHA256 hex of the raw match under a machine-local key: a KEYED
|
|
16877
|
+
// fingerprint, never the raw value, and never reversible. Matching recomputes
|
|
16878
|
+
// the fingerprint from a fresh capture; the value itself is never stored.
|
|
16879
|
+
// Shape-constrained so a malformed — or accidentally raw — value is rejected
|
|
16880
|
+
// at the boundary rather than persisted.
|
|
16881
|
+
valueFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
16882
|
+
// Version of the fingerprint key the grant was written under; a rotated key
|
|
16883
|
+
// invalidates old grants rather than silently mismatching them.
|
|
16884
|
+
keyVersion: external_exports.number().int().positive(),
|
|
16885
|
+
// maskMatch() preview of the approved value — never the raw value.
|
|
16886
|
+
maskedValue: external_exports.string(),
|
|
16887
|
+
capability: ExceptionCapability.default("suppress"),
|
|
16888
|
+
scope: ExceptionScope,
|
|
16889
|
+
expiresAt: external_exports.iso.datetime().nullable(),
|
|
16890
|
+
maxUses: external_exports.number().int().positive().nullable(),
|
|
16891
|
+
useCount: external_exports.number().int().nonnegative(),
|
|
16892
|
+
lastUsedAt: external_exports.iso.datetime().nullable(),
|
|
16893
|
+
// Mandatory: every grant carries the human reason it exists.
|
|
16894
|
+
justification: external_exports.string().min(1),
|
|
16895
|
+
conditions: ExceptionConditions.nullable(),
|
|
16896
|
+
createdBy: external_exports.string(),
|
|
16897
|
+
createdVia: external_exports.enum(["cli-approve", "cli-add", "web-approve", "web-add", "api", "setup-triage"]),
|
|
16898
|
+
createdAt: external_exports.iso.datetime(),
|
|
16899
|
+
updatedAt: external_exports.iso.datetime(),
|
|
16900
|
+
// Revocation is terminal and retained — consumed/expired/revoked rows are
|
|
16901
|
+
// audit evidence; nothing in the exception lifecycle hard-deletes.
|
|
16902
|
+
revokedAt: external_exports.iso.datetime().nullable(),
|
|
16903
|
+
revokedBy: external_exports.string().nullable(),
|
|
16904
|
+
revokeReason: external_exports.string().nullable()
|
|
16905
|
+
});
|
|
16906
|
+
var ExceptionBundleEntry = DetectionException.pick({
|
|
16907
|
+
id: true,
|
|
16908
|
+
ruleId: true,
|
|
16909
|
+
valueFingerprint: true,
|
|
16910
|
+
keyVersion: true,
|
|
16911
|
+
capability: true,
|
|
16912
|
+
expiresAt: true,
|
|
16913
|
+
maxUses: true,
|
|
16914
|
+
useCount: true,
|
|
16915
|
+
conditions: true
|
|
16916
|
+
});
|
|
16917
|
+
var ExceptionDescriptor = DetectionException.omit({ valueFingerprint: true });
|
|
16918
|
+
|
|
16911
16919
|
// ../../packages/schema/src/zod/exception-action.ts
|
|
16912
16920
|
var confirmation = external_exports.string().optional();
|
|
16913
16921
|
var ApproveBlockedInput = external_exports.object({
|
|
@@ -17112,6 +17120,7 @@ var ListVaultDerefsResponse = external_exports.object({
|
|
|
17112
17120
|
});
|
|
17113
17121
|
var VaultKeyCustody = external_exports.string();
|
|
17114
17122
|
var VaultInlineReveal = external_exports.enum(["masked", "full", "off"]);
|
|
17123
|
+
var VAULT_CONSENT_VERSION = 1;
|
|
17115
17124
|
var VaultConsent = external_exports.object({
|
|
17116
17125
|
acknowledgedAt: external_exports.iso.datetime(),
|
|
17117
17126
|
version: external_exports.number().int().positive()
|
|
@@ -17119,7 +17128,14 @@ var VaultConsent = external_exports.object({
|
|
|
17119
17128
|
|
|
17120
17129
|
// ../../packages/schema/src/zod/local.ts
|
|
17121
17130
|
var WORKSPACE_SETTINGS_SPEC_VERSION = 5;
|
|
17122
|
-
var
|
|
17131
|
+
var MODEL_JUDGE_PAYLOAD_VERSION = 1;
|
|
17132
|
+
var RunMode = external_exports.enum(["standalone", "attached"]);
|
|
17133
|
+
var ControlPlaneConnection = external_exports.object({
|
|
17134
|
+
endpoint: external_exports.string().min(1),
|
|
17135
|
+
// Display name for the deployment, shown instead of the raw endpoint.
|
|
17136
|
+
label: external_exports.string().min(1).optional(),
|
|
17137
|
+
attachedAt: external_exports.iso.datetime()
|
|
17138
|
+
}).meta({ id: "ControlPlaneConnection" });
|
|
17123
17139
|
var SimpleDetectionPolicy = external_exports.enum(["redact", "warn"]);
|
|
17124
17140
|
var HistoricalAccess = external_exports.enum(["full", "session-only"]);
|
|
17125
17141
|
var ModelJudgeConsent = external_exports.object({
|
|
@@ -17128,12 +17144,10 @@ var ModelJudgeConsent = external_exports.object({
|
|
|
17128
17144
|
});
|
|
17129
17145
|
var WorkspaceSettings = external_exports.object({
|
|
17130
17146
|
specVersion: external_exports.number().int().positive().default(WORKSPACE_SETTINGS_SPEC_VERSION),
|
|
17131
|
-
|
|
17132
|
-
//
|
|
17133
|
-
runMode:
|
|
17134
|
-
|
|
17135
|
-
RunMode.default("standalone")
|
|
17136
|
-
),
|
|
17147
|
+
runMode: RunMode.default("standalone"),
|
|
17148
|
+
// Present only while attached; a detach clears it. Its presence is what makes
|
|
17149
|
+
// `runMode: 'attached'` mean anything — see isAttached.
|
|
17150
|
+
controlPlane: ControlPlaneConnection.optional(),
|
|
17137
17151
|
policy: SimpleDetectionPolicy.default("redact"),
|
|
17138
17152
|
// Consent for scanning pre-install surfaces; opt-in (see HistoricalAccess).
|
|
17139
17153
|
historicalAccess: HistoricalAccess.default("session-only"),
|
|
@@ -17162,6 +17176,196 @@ function defaultWorkspaceSettings() {
|
|
|
17162
17176
|
return WorkspaceSettings.parse({});
|
|
17163
17177
|
}
|
|
17164
17178
|
|
|
17179
|
+
// ../../packages/schema/src/zod/managed.ts
|
|
17180
|
+
var MANAGED_SETTINGS_FILENAME = "managed-settings.json";
|
|
17181
|
+
var MANAGED_SETTINGS_SPEC_VERSION = 1;
|
|
17182
|
+
var ManagedSettingKey = external_exports.enum([
|
|
17183
|
+
"runMode",
|
|
17184
|
+
"historicalAccess",
|
|
17185
|
+
"vaultConsent",
|
|
17186
|
+
"vaultKeyCustody",
|
|
17187
|
+
"vaultInlineReveal",
|
|
17188
|
+
"modelJudgeConsent",
|
|
17189
|
+
"dataSharesInPlace"
|
|
17190
|
+
]).meta({ id: "ManagedSettingKey" });
|
|
17191
|
+
var ManagedSettingsValues = external_exports.object({
|
|
17192
|
+
runMode: external_exports.enum(["standalone", "attached"]).optional(),
|
|
17193
|
+
controlPlane: external_exports.object({
|
|
17194
|
+
endpoint: external_exports.string().min(1),
|
|
17195
|
+
label: external_exports.string().min(1).optional()
|
|
17196
|
+
}).optional(),
|
|
17197
|
+
historicalAccess: external_exports.enum(["full", "session-only"]).optional(),
|
|
17198
|
+
vaultConsent: external_exports.boolean().optional(),
|
|
17199
|
+
vaultKeyCustody: external_exports.enum(["file", "keychain"]).optional(),
|
|
17200
|
+
vaultInlineReveal: external_exports.enum(["masked", "full", "off"]).optional(),
|
|
17201
|
+
modelJudgeConsent: external_exports.boolean().optional(),
|
|
17202
|
+
dataSharesInPlace: external_exports.boolean().optional()
|
|
17203
|
+
}).meta({ id: "ManagedSettingsValues" });
|
|
17204
|
+
var ManagedSettings = external_exports.object({
|
|
17205
|
+
specVersion: external_exports.number().int().positive().default(MANAGED_SETTINGS_SPEC_VERSION),
|
|
17206
|
+
// Shown on every locked control, so the user can tell an administrative
|
|
17207
|
+
// decision from a bug. Absent renders as a generic "your organization".
|
|
17208
|
+
organization: external_exports.string().min(1).optional(),
|
|
17209
|
+
// What the administrator pinned.
|
|
17210
|
+
values: ManagedSettingsValues.default({}),
|
|
17211
|
+
// Which of those the user may not change. A key here with no matching value
|
|
17212
|
+
// freezes whatever the user last chose; a value with no lock is a DEFAULT
|
|
17213
|
+
// the user may still override. The two are separable on purpose.
|
|
17214
|
+
lockedFields: external_exports.array(ManagedSettingKey).default([])
|
|
17215
|
+
}).meta({ id: "ManagedSettings" });
|
|
17216
|
+
|
|
17217
|
+
// ../../packages/schema/src/zod/policy.ts
|
|
17218
|
+
var PolicyScope = external_exports.enum(["global", "repo", "user"]).meta({ id: "PolicyScope" });
|
|
17219
|
+
var PolicyTarget = external_exports.union([external_exports.object({ ruleId: external_exports.string() }), external_exports.object({ category: DetectionCategory })]).meta({ id: "PolicyTarget" });
|
|
17220
|
+
var Policy = external_exports.object({
|
|
17221
|
+
id: external_exports.guid(),
|
|
17222
|
+
scope: PolicyScope,
|
|
17223
|
+
target: PolicyTarget,
|
|
17224
|
+
action: ActionTaken,
|
|
17225
|
+
enabled: external_exports.boolean().default(true),
|
|
17226
|
+
customKeywords: external_exports.array(external_exports.string()).optional(),
|
|
17227
|
+
// Display name — optional so older policy rows without name still parse.
|
|
17228
|
+
// Added for the findings API (policy.name column migration).
|
|
17229
|
+
name: external_exports.string().optional()
|
|
17230
|
+
}).meta({ id: "Policy" });
|
|
17231
|
+
var PolicyBundle = external_exports.object({
|
|
17232
|
+
version: external_exports.string(),
|
|
17233
|
+
policies: external_exports.array(Policy),
|
|
17234
|
+
// Rules from the installed marketplace packs (snapshotted by the
|
|
17235
|
+
// control plane). The plugin registers these in addition to its bundled
|
|
17236
|
+
// packs. Optional so older backends — and older on-disk caches — that omit
|
|
17237
|
+
// the field still parse; consumers read `bundle.rules ?? []`.
|
|
17238
|
+
rules: external_exports.array(Rule).optional(),
|
|
17239
|
+
// When true, `rules` IS the complete effective ruleset and the runtime must
|
|
17240
|
+
// NOT merge its compiled-in bundled packs — the standalone gateway sets this
|
|
17241
|
+
// after reading the user's installed snapshot (installed_packs, enabled
|
|
17242
|
+
// packs only), which is how detection updates stay manual: new bundled
|
|
17243
|
+
// rules run only after the user applies the pack update. Absent/false keeps
|
|
17244
|
+
// the historical composition (bundled packs + rules) — older caches.
|
|
17245
|
+
rulesComplete: external_exports.boolean().optional(),
|
|
17246
|
+
// Active detection exceptions, evaluation subset only (see
|
|
17247
|
+
// ExceptionBundleEntry). Optional so older bundle producers — and older
|
|
17248
|
+
// on-disk caches — that omit the field still parse; consumers read
|
|
17249
|
+
// `bundle.exceptions ?? []`.
|
|
17250
|
+
exceptions: external_exports.array(ExceptionBundleEntry).optional(),
|
|
17251
|
+
// Rule ids whose pack is assigned a REVERSIBLE archetype (Redact & Vault).
|
|
17252
|
+
// A second axis over the same `redact` action, carried beside the policies
|
|
17253
|
+
// rather than on them: nothing writes ruleId-targeted policies to disk, so
|
|
17254
|
+
// widening Policy itself would change a persisted shape to express something
|
|
17255
|
+
// only the in-memory bundle needs. Optional so an older producer — or an
|
|
17256
|
+
// older on-disk cache — still parses; consumers read `?? []` and get the
|
|
17257
|
+
// pre-existing one-way behaviour, which is the safe direction to default.
|
|
17258
|
+
reversibleRuleIds: external_exports.array(external_exports.string()).optional(),
|
|
17259
|
+
// Installed pack version, keyed by ruleId, for rules in `rules` that came
|
|
17260
|
+
// from a versioned installed pack. Optional so older backends — and older
|
|
17261
|
+
// on-disk caches — that omit the field still parse; consumers fall back to
|
|
17262
|
+
// the rule's own spec version. NOT the bundle version above — see
|
|
17263
|
+
// installedRuleset's ruleVersions for the source of truth.
|
|
17264
|
+
ruleVersions: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
17265
|
+
customKeywords: external_exports.array(external_exports.string()),
|
|
17266
|
+
fetchedAt: external_exports.iso.datetime()
|
|
17267
|
+
}).meta({ id: "PolicyBundle" });
|
|
17268
|
+
var OBSERVE_ONLY_CATEGORIES = ["config"];
|
|
17269
|
+
var ENFORCEABLE_CATEGORIES = DetectionCategory.options.filter((c) => !OBSERVE_ONLY_CATEGORIES.includes(c));
|
|
17270
|
+
var CATEGORY_PEAK_SEVERITY = {
|
|
17271
|
+
secret: "critical",
|
|
17272
|
+
financial: "critical",
|
|
17273
|
+
// core-financial/credit-card
|
|
17274
|
+
code_flaw: "critical",
|
|
17275
|
+
pii: "high",
|
|
17276
|
+
phi: "high",
|
|
17277
|
+
custom: "high",
|
|
17278
|
+
// user-defined; conservative
|
|
17279
|
+
code_context: "low",
|
|
17280
|
+
config: "low"
|
|
17281
|
+
// observe-only; floors to monitor regardless
|
|
17282
|
+
};
|
|
17283
|
+
function severityFloorPolicy(category) {
|
|
17284
|
+
if (OBSERVE_ONLY_CATEGORIES.includes(category)) return "monitor";
|
|
17285
|
+
const peak = CATEGORY_PEAK_SEVERITY[category];
|
|
17286
|
+
return peak === "critical" || peak === "high" ? "warn" : "monitor";
|
|
17287
|
+
}
|
|
17288
|
+
var PolicyKind = external_exports.enum(["builtin", "custom"]).meta({ id: "PolicyKind" });
|
|
17289
|
+
var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
|
|
17290
|
+
var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
|
|
17291
|
+
var BUILTIN_POLICY_SPECS = {
|
|
17292
|
+
monitor: {
|
|
17293
|
+
name: "Monitor",
|
|
17294
|
+
action: "log",
|
|
17295
|
+
reversible: false,
|
|
17296
|
+
description: "Log every match for audit. The request is allowed through untouched."
|
|
17297
|
+
},
|
|
17298
|
+
warn: {
|
|
17299
|
+
name: "Warn",
|
|
17300
|
+
action: "warn",
|
|
17301
|
+
reversible: false,
|
|
17302
|
+
description: "Allow the request, but warn the user inline before it is sent."
|
|
17303
|
+
},
|
|
17304
|
+
redact: {
|
|
17305
|
+
name: "Redact",
|
|
17306
|
+
action: "redact",
|
|
17307
|
+
reversible: false,
|
|
17308
|
+
description: "Strip the matched value from the request and destroy it, then continue. What was removed cannot be recovered."
|
|
17309
|
+
},
|
|
17310
|
+
vault: {
|
|
17311
|
+
name: "Redact & Vault",
|
|
17312
|
+
action: "redact",
|
|
17313
|
+
reversible: true,
|
|
17314
|
+
description: "Strip the matched value from the request and keep an encrypted, recoverable copy in the local vault, leaving a pointer in its place. Needs the vault consent granted under Settings; without it this behaves as Redact."
|
|
17315
|
+
},
|
|
17316
|
+
block: {
|
|
17317
|
+
name: "Block",
|
|
17318
|
+
action: "block",
|
|
17319
|
+
reversible: false,
|
|
17320
|
+
description: "Refuse the request entirely whenever any rule in this detection matches."
|
|
17321
|
+
}
|
|
17322
|
+
};
|
|
17323
|
+
function builtinPolicyToAction(id) {
|
|
17324
|
+
return BUILTIN_POLICY_SPECS[id].action;
|
|
17325
|
+
}
|
|
17326
|
+
var CATEGORY_EXPRESSIBLE_IDS = KNOWN_BUILTIN_IDS.filter(
|
|
17327
|
+
(id) => !BUILTIN_POLICY_SPECS[id].reversible
|
|
17328
|
+
);
|
|
17329
|
+
var CATEGORY_INEXPRESSIBLE_IDS = KNOWN_BUILTIN_IDS.filter(
|
|
17330
|
+
(id) => BUILTIN_POLICY_SPECS[id].reversible
|
|
17331
|
+
);
|
|
17332
|
+
var CategoryPolicyId = external_exports.enum(CATEGORY_EXPRESSIBLE_IDS).meta({ id: "CategoryPolicyId" });
|
|
17333
|
+
var DEFAULT_ACTIONS = Object.fromEntries(
|
|
17334
|
+
DetectionCategory.options.map((c) => [c, builtinPolicyToAction(severityFloorPolicy(c))])
|
|
17335
|
+
);
|
|
17336
|
+
var BUILTIN_POLICIES = Object.fromEntries(
|
|
17337
|
+
KNOWN_BUILTIN_IDS.map((id) => [id, { id, ...BUILTIN_POLICY_SPECS[id] }])
|
|
17338
|
+
);
|
|
17339
|
+
var UsedByItem = external_exports.object({
|
|
17340
|
+
id: external_exports.string(),
|
|
17341
|
+
name: external_exports.string(),
|
|
17342
|
+
ruleCount: external_exports.number().int().nonnegative(),
|
|
17343
|
+
enabled: external_exports.boolean()
|
|
17344
|
+
}).meta({ id: "UsedByItem" });
|
|
17345
|
+
var PolicyListItem = external_exports.object({
|
|
17346
|
+
id: external_exports.string(),
|
|
17347
|
+
kind: PolicyKind,
|
|
17348
|
+
name: external_exports.string(),
|
|
17349
|
+
enabled: external_exports.boolean(),
|
|
17350
|
+
usedByCount: external_exports.number().int().nonnegative()
|
|
17351
|
+
}).meta({ id: "PolicyListItem" });
|
|
17352
|
+
var ListPoliciesResponse = external_exports.object({ items: external_exports.array(PolicyListItem) }).meta({ id: "ListPoliciesResponse" });
|
|
17353
|
+
var PolicyDetail = external_exports.object({
|
|
17354
|
+
specVersion: external_exports.literal(1),
|
|
17355
|
+
id: external_exports.string(),
|
|
17356
|
+
kind: PolicyKind,
|
|
17357
|
+
name: external_exports.string(),
|
|
17358
|
+
enabled: external_exports.boolean(),
|
|
17359
|
+
description: external_exports.string(),
|
|
17360
|
+
usedBy: external_exports.array(UsedByItem)
|
|
17361
|
+
}).meta({ id: "PolicyDetail" });
|
|
17362
|
+
var PolicyStatsResponse = external_exports.object({
|
|
17363
|
+
policies: external_exports.number().int().nonnegative(),
|
|
17364
|
+
builtin: external_exports.number().int().nonnegative(),
|
|
17365
|
+
custom: external_exports.number().int().nonnegative(),
|
|
17366
|
+
detectionsGoverned: external_exports.number().int().nonnegative()
|
|
17367
|
+
}).meta({ id: "PolicyStatsResponse" });
|
|
17368
|
+
|
|
17165
17369
|
// ../../packages/schema/src/zod/project-files.ts
|
|
17166
17370
|
var ProjectFileInput = external_exports.object({
|
|
17167
17371
|
path: external_exports.string().min(1),
|
|
@@ -17234,44 +17438,6 @@ var BatchedRemediation = external_exports.discriminatedUnion("kind", [
|
|
|
17234
17438
|
NoRemediationDecision
|
|
17235
17439
|
]);
|
|
17236
17440
|
|
|
17237
|
-
// ../../packages/schema/src/zod/rule-test.ts
|
|
17238
|
-
var TestRulesRequest = external_exports.object({
|
|
17239
|
-
rules: external_exports.array(Rule).min(1).max(100),
|
|
17240
|
-
text: external_exports.string().max(5e4).optional(),
|
|
17241
|
-
fixtures: external_exports.array(RuleFixture).max(200).optional()
|
|
17242
|
-
}).refine((v) => v.text !== void 0 || (v.fixtures?.length ?? 0) > 0, {
|
|
17243
|
-
message: "Provide `text`, `fixtures`, or both \u2014 there must be something to test"
|
|
17244
|
-
}).meta({ id: "TestRulesRequest" });
|
|
17245
|
-
var RuleTestMatch = external_exports.object({
|
|
17246
|
-
ruleId: external_exports.string(),
|
|
17247
|
-
category: DetectionCategory,
|
|
17248
|
-
severity: Severity,
|
|
17249
|
-
span: Span,
|
|
17250
|
-
confidence: external_exports.number().min(0).max(1),
|
|
17251
|
-
match: external_exports.string()
|
|
17252
|
-
}).meta({ id: "RuleTestMatch" });
|
|
17253
|
-
var FixtureResult = external_exports.object({
|
|
17254
|
-
label: external_exports.string(),
|
|
17255
|
-
shouldMatch: external_exports.boolean(),
|
|
17256
|
-
didMatch: external_exports.boolean(),
|
|
17257
|
-
passed: external_exports.boolean(),
|
|
17258
|
-
matches: external_exports.array(RuleTestMatch)
|
|
17259
|
-
}).meta({ id: "FixtureResult" });
|
|
17260
|
-
var TestRulesResponse = external_exports.object({
|
|
17261
|
-
// Present only when the request supplied `text`.
|
|
17262
|
-
adhoc: external_exports.object({ matches: external_exports.array(RuleTestMatch) }).optional(),
|
|
17263
|
-
fixtures: external_exports.array(FixtureResult),
|
|
17264
|
-
summary: external_exports.object({
|
|
17265
|
-
total: external_exports.number().int().nonnegative(),
|
|
17266
|
-
passed: external_exports.number().int().nonnegative(),
|
|
17267
|
-
failed: external_exports.number().int().nonnegative()
|
|
17268
|
-
}),
|
|
17269
|
-
// Ids of rules whose matcher type the engine cannot evaluate today (e.g.
|
|
17270
|
-
// `validator`), so they silently never match. Surfaced so an author is not
|
|
17271
|
-
// misled by a green run that actually skipped a rule.
|
|
17272
|
-
unsupportedRuleIds: external_exports.array(external_exports.string())
|
|
17273
|
-
}).meta({ id: "TestRulesResponse" });
|
|
17274
|
-
|
|
17275
17441
|
// ../../packages/schema/src/zod/security.ts
|
|
17276
17442
|
var SeveritySummaryItem = external_exports.object({
|
|
17277
17443
|
severity: Severity,
|
|
@@ -17369,10 +17535,22 @@ var TopSourcesQuery = external_exports.object({
|
|
|
17369
17535
|
// Omit for both kinds.
|
|
17370
17536
|
kind: external_exports.enum(SOURCE_KINDS).optional()
|
|
17371
17537
|
});
|
|
17372
|
-
var Provider =
|
|
17538
|
+
var Provider = Harness.extract([
|
|
17539
|
+
"ClaudeCode",
|
|
17540
|
+
"Cursor",
|
|
17541
|
+
"Codex",
|
|
17542
|
+
"Antigravity",
|
|
17543
|
+
"ClaudeAi",
|
|
17544
|
+
"ChatGpt",
|
|
17545
|
+
"Copilot",
|
|
17546
|
+
"Api"
|
|
17547
|
+
]).meta({ id: "Provider" });
|
|
17373
17548
|
var ScanCoverageProvider = external_exports.object({
|
|
17374
17549
|
provider: Provider,
|
|
17375
|
-
// Percent of that provider's traffic
|
|
17550
|
+
// Percent of that provider's traffic the shipped capture surface reaches.
|
|
17551
|
+
// A curated business fact, constant across every `range` — not a measured
|
|
17552
|
+
// per-window metric. 0 exactly when `supported` is false. See the comment
|
|
17553
|
+
// above the block for where these numbers are decided.
|
|
17376
17554
|
coverage: external_exports.number().int().min(0).max(100),
|
|
17377
17555
|
supported: external_exports.boolean()
|
|
17378
17556
|
}).meta({ id: "ScanCoverageProvider" });
|
|
@@ -17426,6 +17604,18 @@ var ApplyRecommendedActionResponse = external_exports.object({
|
|
|
17426
17604
|
var DismissRecommendedActionResponse = external_exports.object({ id: external_exports.string(), status: external_exports.literal("dismissed") }).meta({ id: "DismissRecommendedActionResponse" });
|
|
17427
17605
|
var RecommendedActionIdParam = external_exports.object({ id: external_exports.string() });
|
|
17428
17606
|
|
|
17607
|
+
// ../../packages/schema/src/zod/settings-action.ts
|
|
17608
|
+
var SaveSettingsInput = external_exports.object({
|
|
17609
|
+
historicalAccess: external_exports.string(),
|
|
17610
|
+
modelJudgeConsent: external_exports.boolean(),
|
|
17611
|
+
vaultConsent: external_exports.string(),
|
|
17612
|
+
vaultInlineReveal: external_exports.string()
|
|
17613
|
+
});
|
|
17614
|
+
var AttachInput = external_exports.object({
|
|
17615
|
+
endpoint: external_exports.string(),
|
|
17616
|
+
label: external_exports.string().optional()
|
|
17617
|
+
});
|
|
17618
|
+
|
|
17429
17619
|
// ../../packages/schema/src/zod/triage.ts
|
|
17430
17620
|
var TriageHit = external_exports.object({
|
|
17431
17621
|
ruleId: external_exports.string(),
|
|
@@ -17440,7 +17630,7 @@ var TriageHit = external_exports.object({
|
|
|
17440
17630
|
valueFingerprint: external_exports.string().optional(),
|
|
17441
17631
|
keyVersion: external_exports.number().int().nonnegative().optional()
|
|
17442
17632
|
});
|
|
17443
|
-
var TriagePolicy =
|
|
17633
|
+
var TriagePolicy = CategoryPolicyId;
|
|
17444
17634
|
var TriageCategoryRec = external_exports.object({
|
|
17445
17635
|
category: DetectionCategory,
|
|
17446
17636
|
action: TriagePolicy,
|
|
@@ -17534,14 +17724,6 @@ var SetupHandoffOffer = external_exports.object({
|
|
|
17534
17724
|
path: ["liveKeys"]
|
|
17535
17725
|
});
|
|
17536
17726
|
|
|
17537
|
-
// ../../packages/persistence/src/ids.ts
|
|
17538
|
-
import { createHash } from "crypto";
|
|
17539
|
-
|
|
17540
|
-
// ../../packages/persistence/src/internal/snapshot.ts
|
|
17541
|
-
import { randomUUID } from "crypto";
|
|
17542
|
-
import { existsSync, readdirSync, renameSync as renameSync2, rmSync as rmSync2, statSync } from "fs";
|
|
17543
|
-
import { basename, dirname, join } from "path";
|
|
17544
|
-
|
|
17545
17727
|
// ../../packages/persistence/src/paths.ts
|
|
17546
17728
|
import {
|
|
17547
17729
|
chmodSync,
|
|
@@ -17572,16 +17754,32 @@ function chmodBestEffort(path, mode) {
|
|
|
17572
17754
|
function tightenDir(dir) {
|
|
17573
17755
|
chmodBestEffort(dir, DATA_DIR_MODE);
|
|
17574
17756
|
}
|
|
17757
|
+
function mkdirOwnerOnlySync(dir, recursive = false) {
|
|
17758
|
+
mkdirSync(dir, { recursive, mode: DATA_DIR_MODE });
|
|
17759
|
+
}
|
|
17575
17760
|
function ensureDataDirSync(dir) {
|
|
17576
|
-
|
|
17761
|
+
mkdirOwnerOnlySync(dir, true);
|
|
17577
17762
|
tightenDir(dir);
|
|
17578
17763
|
}
|
|
17579
17764
|
function tightenFile(file2) {
|
|
17580
17765
|
chmodBestEffort(file2, DATA_FILE_MODE);
|
|
17581
17766
|
}
|
|
17582
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
|
+
|
|
17583
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";
|
|
17584
17780
|
var STALE_PARTIAL_MS = 5 * 6e4;
|
|
17781
|
+
var SNAPSHOT_STAGING_SUFFIX = ".partial";
|
|
17782
|
+
var STAGED_NAME_SUFFIX = `.bak${SNAPSHOT_STAGING_SUFFIX}`;
|
|
17585
17783
|
|
|
17586
17784
|
// ../../packages/persistence/src/internal/json.ts
|
|
17587
17785
|
function parseJsonObject(s) {
|
|
@@ -17596,6 +17794,7 @@ function parseJsonObject(s) {
|
|
|
17596
17794
|
|
|
17597
17795
|
// ../../packages/persistence/src/repositories/activity.ts
|
|
17598
17796
|
var LIVE_ACTIVITY_WINDOW_MS = 30 * 6e4;
|
|
17797
|
+
var DEFAULT_HARNESS = HARNESS.ClaudeCode;
|
|
17599
17798
|
|
|
17600
17799
|
// ../../packages/persistence/src/repositories/exceptions.ts
|
|
17601
17800
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
@@ -17614,7 +17813,20 @@ import { createHash as createHash2, randomUUID as randomUUID3 } from "crypto";
|
|
|
17614
17813
|
// ../../packages/persistence/src/repositories/inventory-assets.ts
|
|
17615
17814
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
17616
17815
|
var VALID_HARNESS_IDS = new Set(HarnessId.options);
|
|
17816
|
+
var HARNESS_LABELS = {
|
|
17817
|
+
[HARNESS.ClaudeCode]: "Claude Code",
|
|
17818
|
+
[HARNESS.Cursor]: "Cursor",
|
|
17819
|
+
[HARNESS.Codex]: "Codex",
|
|
17820
|
+
[HARNESS.Antigravity]: "Antigravity"
|
|
17821
|
+
};
|
|
17617
17822
|
var HARNESS_LIVENESS_WINDOW_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
17823
|
+
var stripSeparators = (value) => value.toLowerCase().replace(/[\s-]/g, "");
|
|
17824
|
+
var TITLE_NEEDLES = {
|
|
17825
|
+
ClaudeCode: stripSeparators(SOURCE_TOOL.ClaudeCode),
|
|
17826
|
+
Cursor: stripSeparators(SOURCE_TOOL.Cursor),
|
|
17827
|
+
Codex: stripSeparators(SOURCE_TOOL.Codex),
|
|
17828
|
+
Antigravity: stripSeparators(SOURCE_TOOL.Antigravity)
|
|
17829
|
+
};
|
|
17618
17830
|
|
|
17619
17831
|
// ../../packages/persistence/src/repositories/policies.ts
|
|
17620
17832
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
@@ -17628,6 +17840,18 @@ import { randomUUID as randomUUID7 } from "crypto";
|
|
|
17628
17840
|
// ../../packages/persistence/src/repositories/secret-vault.ts
|
|
17629
17841
|
import { randomUUID as randomUUID8 } from "crypto";
|
|
17630
17842
|
|
|
17843
|
+
// ../../packages/persistence/src/repositories/security.ts
|
|
17844
|
+
var SCAN_COVERAGE = {
|
|
17845
|
+
[HARNESS.Antigravity]: { coverage: 60, supported: true },
|
|
17846
|
+
[HARNESS.Api]: { coverage: 0, supported: false },
|
|
17847
|
+
[HARNESS.ChatGpt]: { coverage: 40, supported: true },
|
|
17848
|
+
[HARNESS.ClaudeAi]: { coverage: 40, supported: true },
|
|
17849
|
+
[HARNESS.ClaudeCode]: { coverage: 100, supported: true },
|
|
17850
|
+
[HARNESS.Codex]: { coverage: 80, supported: true },
|
|
17851
|
+
[HARNESS.Copilot]: { coverage: 0, supported: false },
|
|
17852
|
+
[HARNESS.Cursor]: { coverage: 0, supported: false }
|
|
17853
|
+
};
|
|
17854
|
+
|
|
17631
17855
|
// ../../packages/persistence/src/repositories/shares.ts
|
|
17632
17856
|
import { randomUUID as randomUUID9 } from "crypto";
|
|
17633
17857
|
|
|
@@ -17637,9 +17861,9 @@ import {
|
|
|
17637
17861
|
closeSync,
|
|
17638
17862
|
existsSync as existsSync2,
|
|
17639
17863
|
openSync,
|
|
17640
|
-
readFileSync,
|
|
17641
|
-
rmSync as
|
|
17642
|
-
statSync as
|
|
17864
|
+
readFileSync as readFileSync2,
|
|
17865
|
+
rmSync as rmSync4,
|
|
17866
|
+
statSync as statSync3,
|
|
17643
17867
|
writeFileSync as writeFileSync2
|
|
17644
17868
|
} from "fs";
|
|
17645
17869
|
import { hostname as hostname3 } from "os";
|
|
@@ -17650,26 +17874,29 @@ import { createHash as createHash3 } from "crypto";
|
|
|
17650
17874
|
|
|
17651
17875
|
// ../../packages/persistence/src/fingerprint.ts
|
|
17652
17876
|
import { createHmac, randomBytes } from "crypto";
|
|
17653
|
-
import { existsSync as existsSync3, readFileSync as
|
|
17654
|
-
import { join as
|
|
17877
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
17878
|
+
import { join as join4 } from "path";
|
|
17655
17879
|
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
17656
17880
|
|
|
17657
17881
|
// ../../packages/persistence/src/local-layout.ts
|
|
17658
17882
|
import { renameSync as renameSync3 } from "fs";
|
|
17659
17883
|
import { mkdir } from "fs/promises";
|
|
17660
17884
|
import { homedir } from "os";
|
|
17661
|
-
import { join as
|
|
17885
|
+
import { join as join5 } from "path";
|
|
17662
17886
|
function defaultDataDir() {
|
|
17663
|
-
return
|
|
17887
|
+
return join5(homedir(), ".aka");
|
|
17664
17888
|
}
|
|
17665
17889
|
function settingsDir(base = defaultDataDir()) {
|
|
17666
|
-
return
|
|
17890
|
+
return join5(base, "settings");
|
|
17667
17891
|
}
|
|
17668
17892
|
function dataDir(base = defaultDataDir()) {
|
|
17669
|
-
return
|
|
17893
|
+
return join5(base, "data");
|
|
17670
17894
|
}
|
|
17671
17895
|
function dbPath(base = defaultDataDir()) {
|
|
17672
|
-
return
|
|
17896
|
+
return join5(dataDir(base), "aka.db");
|
|
17897
|
+
}
|
|
17898
|
+
function keysDir(base = defaultDataDir()) {
|
|
17899
|
+
return join5(base, "keys");
|
|
17673
17900
|
}
|
|
17674
17901
|
function ensureLayoutDirSync(dir = defaultDataDir()) {
|
|
17675
17902
|
ensureDataDirSync(dir);
|
|
@@ -17682,20 +17909,88 @@ function migrateLegacyLayout(base = defaultDataDir()) {
|
|
|
17682
17909
|
for (const { name, dest } of moves) {
|
|
17683
17910
|
try {
|
|
17684
17911
|
ensureDataDirSync(dest);
|
|
17685
|
-
const moved =
|
|
17686
|
-
renameSync3(
|
|
17912
|
+
const moved = join5(dest, name);
|
|
17913
|
+
renameSync3(join5(base, name), moved);
|
|
17687
17914
|
tightenFile(moved);
|
|
17688
17915
|
} catch {
|
|
17689
17916
|
}
|
|
17690
17917
|
}
|
|
17691
17918
|
}
|
|
17692
17919
|
|
|
17920
|
+
// ../../packages/persistence/src/managed-settings.ts
|
|
17921
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
17922
|
+
import { posix, win32 } from "path";
|
|
17923
|
+
function managedSettingsPaths(platform2 = process.platform) {
|
|
17924
|
+
if (platform2 === "darwin") {
|
|
17925
|
+
return [
|
|
17926
|
+
posix.join("/Library", "Application Support", "AKASecurity", MANAGED_SETTINGS_FILENAME),
|
|
17927
|
+
posix.join("/Library", "Managed Preferences", MANAGED_SETTINGS_FILENAME)
|
|
17928
|
+
];
|
|
17929
|
+
}
|
|
17930
|
+
if (platform2 === "win32") {
|
|
17931
|
+
return [win32.join("C:\\", "ProgramData", "AKASecurity", MANAGED_SETTINGS_FILENAME)];
|
|
17932
|
+
}
|
|
17933
|
+
return [posix.join("/etc", "aka", MANAGED_SETTINGS_FILENAME)];
|
|
17934
|
+
}
|
|
17935
|
+
function readManagedSettings(paths = managedSettingsPaths()) {
|
|
17936
|
+
for (const path of paths) {
|
|
17937
|
+
let text;
|
|
17938
|
+
try {
|
|
17939
|
+
text = readFileSync4(path, "utf8");
|
|
17940
|
+
} catch {
|
|
17941
|
+
continue;
|
|
17942
|
+
}
|
|
17943
|
+
const record2 = parseJsonObject(text);
|
|
17944
|
+
if (!record2) continue;
|
|
17945
|
+
const parsed = ManagedSettings.safeParse(record2);
|
|
17946
|
+
if (parsed.success) return parsed.data;
|
|
17947
|
+
}
|
|
17948
|
+
return null;
|
|
17949
|
+
}
|
|
17950
|
+
function overlayManagedSettings(settings, managed, now = () => /* @__PURE__ */ new Date()) {
|
|
17951
|
+
if (!managed) return settings;
|
|
17952
|
+
const { values } = managed;
|
|
17953
|
+
const merged = { ...settings };
|
|
17954
|
+
if (values.runMode !== void 0) merged.runMode = values.runMode;
|
|
17955
|
+
if (values.controlPlane !== void 0) {
|
|
17956
|
+
merged.controlPlane = {
|
|
17957
|
+
...values.controlPlane,
|
|
17958
|
+
// The administrator pinned WHICH deployment, not WHEN this machine
|
|
17959
|
+
// joined it. Keep the user's own attach time when the endpoint is
|
|
17960
|
+
// unchanged, so a managed machine does not appear to re-attach on every
|
|
17961
|
+
// read; stamp a fresh one when the administrator moved it.
|
|
17962
|
+
attachedAt: settings.controlPlane?.endpoint === values.controlPlane.endpoint ? settings.controlPlane.attachedAt : now().toISOString()
|
|
17963
|
+
};
|
|
17964
|
+
}
|
|
17965
|
+
if (values.historicalAccess !== void 0) merged.historicalAccess = values.historicalAccess;
|
|
17966
|
+
if (values.vaultKeyCustody !== void 0) merged.vaultKeyCustody = values.vaultKeyCustody;
|
|
17967
|
+
if (values.vaultInlineReveal !== void 0) merged.vaultInlineReveal = values.vaultInlineReveal;
|
|
17968
|
+
if (values.dataSharesInPlace !== void 0) merged.dataSharesInPlace = values.dataSharesInPlace;
|
|
17969
|
+
if (values.vaultConsent !== void 0) {
|
|
17970
|
+
merged.vaultConsent = values.vaultConsent ? (
|
|
17971
|
+
// Keep an existing valid grant so its acknowledgedAt survives; mint one
|
|
17972
|
+
// at the current version otherwise.
|
|
17973
|
+
settings.vaultConsent?.version === VAULT_CONSENT_VERSION ? settings.vaultConsent : { acknowledgedAt: now().toISOString(), version: VAULT_CONSENT_VERSION }
|
|
17974
|
+
) : void 0;
|
|
17975
|
+
}
|
|
17976
|
+
if (values.modelJudgeConsent !== void 0) {
|
|
17977
|
+
merged.modelJudgeConsent = values.modelJudgeConsent ? settings.modelJudgeConsent?.payloadVersion === MODEL_JUDGE_PAYLOAD_VERSION ? settings.modelJudgeConsent : {
|
|
17978
|
+
acknowledgedAt: now().toISOString(),
|
|
17979
|
+
payloadVersion: MODEL_JUDGE_PAYLOAD_VERSION
|
|
17980
|
+
} : void 0;
|
|
17981
|
+
}
|
|
17982
|
+
return merged;
|
|
17983
|
+
}
|
|
17984
|
+
|
|
17693
17985
|
// ../../packages/persistence/src/settings.ts
|
|
17694
|
-
import { readFileSync as
|
|
17695
|
-
import { join as
|
|
17986
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
17987
|
+
import { join as join6 } from "path";
|
|
17696
17988
|
var SETTINGS_FILENAME = "settings.json";
|
|
17697
17989
|
function readWorkspaceSettings(base = defaultDataDir()) {
|
|
17698
|
-
|
|
17990
|
+
return overlayManagedSettings(readUserSettings(base), readManagedSettings());
|
|
17991
|
+
}
|
|
17992
|
+
function readUserSettings(base) {
|
|
17993
|
+
const record2 = readJson(join6(settingsDir(base), SETTINGS_FILENAME));
|
|
17699
17994
|
if (!record2) return defaultWorkspaceSettings();
|
|
17700
17995
|
try {
|
|
17701
17996
|
return WorkspaceSettings.parse(record2);
|
|
@@ -17706,13 +18001,64 @@ function readWorkspaceSettings(base = defaultDataDir()) {
|
|
|
17706
18001
|
function readJson(file2) {
|
|
17707
18002
|
let text;
|
|
17708
18003
|
try {
|
|
17709
|
-
text =
|
|
18004
|
+
text = readFileSync5(file2, "utf8");
|
|
17710
18005
|
} catch {
|
|
17711
18006
|
return null;
|
|
17712
18007
|
}
|
|
17713
18008
|
return parseJsonObject(text) ?? null;
|
|
17714
18009
|
}
|
|
17715
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
|
+
|
|
17716
18062
|
// ../../packages/persistence/src/vault/crypto.ts
|
|
17717
18063
|
import {
|
|
17718
18064
|
createCipheriv,
|
|
@@ -17725,23 +18071,15 @@ import {
|
|
|
17725
18071
|
// ../../packages/persistence/src/vault/key-provider.ts
|
|
17726
18072
|
import { execFileSync } from "child_process";
|
|
17727
18073
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
17728
|
-
import {
|
|
17729
|
-
|
|
17730
|
-
mkdirSync as mkdirSync2,
|
|
17731
|
-
readFileSync as readFileSync4,
|
|
17732
|
-
renameSync as renameSync4,
|
|
17733
|
-
rmSync as rmSync4,
|
|
17734
|
-
statSync as statSync3,
|
|
17735
|
-
writeFileSync as writeFileSync3
|
|
17736
|
-
} from "fs";
|
|
17737
|
-
import { join as join6 } from "path";
|
|
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";
|
|
17738
18076
|
|
|
17739
18077
|
// ../../packages/persistence/src/vault/vault.ts
|
|
17740
18078
|
import { randomBytes as randomBytes3, randomUUID as randomUUID12 } from "crypto";
|
|
17741
18079
|
|
|
17742
18080
|
// ../../packages/persistence/src/warn-era-cap.ts
|
|
17743
|
-
import { existsSync as
|
|
17744
|
-
import { join as
|
|
18081
|
+
import { existsSync as existsSync5, writeFileSync as writeFileSync4 } from "fs";
|
|
18082
|
+
import { join as join9 } from "path";
|
|
17745
18083
|
|
|
17746
18084
|
// ../../packages/plugin-sdk/src/provider-env.ts
|
|
17747
18085
|
var DEFAULT_ANTHROPIC_HOST = "api.anthropic.com";
|
|
@@ -17795,8 +18133,8 @@ function resolveProvider() {
|
|
|
17795
18133
|
function loadConfig(base = defaultDataDir(), resolveProviderFn = resolveProvider) {
|
|
17796
18134
|
try {
|
|
17797
18135
|
ensureLayoutDirSync(base);
|
|
17798
|
-
const settingsFile =
|
|
17799
|
-
if (
|
|
18136
|
+
const settingsFile = join10(settingsDir(base), "settings.json");
|
|
18137
|
+
if (existsSync6(settingsFile)) tightenFile(settingsFile);
|
|
17800
18138
|
} catch {
|
|
17801
18139
|
}
|
|
17802
18140
|
migrateLegacyLayout(base);
|
|
@@ -17819,9 +18157,9 @@ function resolveProviderSafe(resolveProviderFn) {
|
|
|
17819
18157
|
}
|
|
17820
18158
|
|
|
17821
18159
|
// ../../packages/plugin-sdk/src/config-inventory.ts
|
|
17822
|
-
import { readdirSync as readdirSync2, readFileSync as
|
|
18160
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync8, realpathSync as realpathSync2, statSync as statSync7 } from "fs";
|
|
17823
18161
|
import { homedir as homedir2 } from "os";
|
|
17824
|
-
import { basename as basename3, join as
|
|
18162
|
+
import { basename as basename3, join as join12 } from "path";
|
|
17825
18163
|
|
|
17826
18164
|
// ../../packages/detections/src/egress/registry.ts
|
|
17827
18165
|
var EXTRACTOR_VERSION = "1";
|
|
@@ -18551,6 +18889,7 @@ var CONFIG_POSTURE_RULES = [
|
|
|
18551
18889
|
];
|
|
18552
18890
|
|
|
18553
18891
|
// ../../packages/detections/src/security/redos-probe.ts
|
|
18892
|
+
var BUDGET_MS = 100;
|
|
18554
18893
|
var EXPONENTIAL_UNITS = [
|
|
18555
18894
|
"a",
|
|
18556
18895
|
"0",
|
|
@@ -18574,34 +18913,40 @@ var EXPONENTIAL_PROBES = EXPONENTIAL_UNITS.flatMap(
|
|
|
18574
18913
|
var POLYNOMIAL_PROBES = ["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].map(
|
|
18575
18914
|
(unit) => unit.repeat(1e4).slice(0, 4e4) + "!"
|
|
18576
18915
|
);
|
|
18916
|
+
var CPU_CORROBORATION_SHARE = 0.2;
|
|
18917
|
+
var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
|
|
18577
18918
|
|
|
18578
18919
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
18579
|
-
import { existsSync as
|
|
18580
|
-
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";
|
|
18581
18922
|
|
|
18582
18923
|
// ../../packages/plugin-sdk/src/events.ts
|
|
18583
18924
|
import { createHash as createHash4, randomUUID as randomUUID13 } from "crypto";
|
|
18584
18925
|
|
|
18585
18926
|
// ../../packages/plugin-sdk/src/isolated-scan.ts
|
|
18586
|
-
import { existsSync as
|
|
18927
|
+
import { existsSync as existsSync8 } from "fs";
|
|
18587
18928
|
import { fileURLToPath } from "url";
|
|
18588
18929
|
import { Worker } from "worker_threads";
|
|
18589
18930
|
|
|
18931
|
+
// ../../packages/plugin-sdk/src/ignore-layers.ts
|
|
18932
|
+
var import_ignore = __toESM(require_ignore(), 1);
|
|
18933
|
+
import { readFileSync as readFileSync9 } from "fs";
|
|
18934
|
+
import { join as join13 } from "path";
|
|
18935
|
+
|
|
18590
18936
|
// ../../packages/plugin-sdk/src/inventory-resolver.ts
|
|
18591
18937
|
import { arch, hostname as hostname4, platform, release } from "os";
|
|
18592
18938
|
|
|
18593
18939
|
// ../../packages/plugin-sdk/src/nudge.ts
|
|
18594
|
-
import { mkdirSync as
|
|
18595
|
-
import { join as
|
|
18940
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync10, writeFileSync as writeFileSync5 } from "fs";
|
|
18941
|
+
import { join as join14 } from "path";
|
|
18596
18942
|
|
|
18597
18943
|
// ../../packages/plugin-sdk/src/paths.ts
|
|
18598
|
-
import { readdirSync as readdirSync3, realpathSync as
|
|
18599
|
-
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";
|
|
18600
18946
|
|
|
18601
18947
|
// ../../packages/plugin-sdk/src/project-files.ts
|
|
18602
|
-
|
|
18603
|
-
import {
|
|
18604
|
-
import { basename as basename5, join as join12 } from "path";
|
|
18948
|
+
import { existsSync as existsSync9, readdirSync as readdirSync4 } from "fs";
|
|
18949
|
+
import { basename as basename5, join as join15 } from "path";
|
|
18605
18950
|
|
|
18606
18951
|
// ../../packages/plugin-sdk/src/provider-env-antigravity.ts
|
|
18607
18952
|
var optionalBaseUrl2 = external_exports.preprocess((v) => {
|
|
@@ -18636,16 +18981,16 @@ import { randomUUID as randomUUID14 } from "crypto";
|
|
|
18636
18981
|
var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
18637
18982
|
|
|
18638
18983
|
// ../../packages/plugin-sdk/src/throttle.ts
|
|
18639
|
-
import { mkdirSync as
|
|
18640
|
-
import { join as
|
|
18984
|
+
import { mkdirSync as mkdirSync3, statSync as statSync8, writeFileSync as writeFileSync6 } from "fs";
|
|
18985
|
+
import { join as join16 } from "path";
|
|
18641
18986
|
function throttled(dataDir2, markerName, windowMs) {
|
|
18642
|
-
const marker =
|
|
18987
|
+
const marker = join16(dataDir2, markerName);
|
|
18643
18988
|
try {
|
|
18644
|
-
if (Date.now() -
|
|
18989
|
+
if (Date.now() - statSync8(marker).mtimeMs < windowMs) return true;
|
|
18645
18990
|
} catch {
|
|
18646
18991
|
}
|
|
18647
18992
|
try {
|
|
18648
|
-
|
|
18993
|
+
mkdirSync3(dataDir2, { recursive: true, mode: DATA_DIR_MODE });
|
|
18649
18994
|
writeFileSync6(marker, String(Date.now()), { mode: DATA_FILE_MODE });
|
|
18650
18995
|
} catch {
|
|
18651
18996
|
}
|
|
@@ -18654,7 +18999,7 @@ function throttled(dataDir2, markerName, windowMs) {
|
|
|
18654
18999
|
|
|
18655
19000
|
// src/history/reconcile-trigger.ts
|
|
18656
19001
|
import { spawn } from "child_process";
|
|
18657
|
-
import { dirname as
|
|
19002
|
+
import { dirname as dirname5, join as join18 } from "path";
|
|
18658
19003
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
18659
19004
|
|
|
18660
19005
|
// src/history/tail.ts
|
|
@@ -18662,13 +19007,13 @@ import { createHash as createHash5 } from "crypto";
|
|
|
18662
19007
|
import {
|
|
18663
19008
|
closeSync as closeSync2,
|
|
18664
19009
|
fstatSync,
|
|
18665
|
-
mkdirSync as
|
|
19010
|
+
mkdirSync as mkdirSync4,
|
|
18666
19011
|
openSync as openSync2,
|
|
18667
|
-
readFileSync as
|
|
19012
|
+
readFileSync as readFileSync11,
|
|
18668
19013
|
readSync,
|
|
18669
19014
|
writeFileSync as writeFileSync7
|
|
18670
19015
|
} from "fs";
|
|
18671
|
-
import { join as
|
|
19016
|
+
import { join as join17 } from "path";
|
|
18672
19017
|
var SAFE_SESSION_ID = /^[A-Za-z0-9._-]+$/;
|
|
18673
19018
|
function safeSessionId(sessionId) {
|
|
18674
19019
|
if (SAFE_SESSION_ID.test(sessionId) && sessionId !== "." && sessionId !== "..") {
|
|
@@ -18684,8 +19029,8 @@ function triggerReconcile(dataDir2, sessionId, transcriptPath) {
|
|
|
18684
19029
|
try {
|
|
18685
19030
|
const marker = `${RECONCILE_MARKER_PREFIX}-${safeSessionId(sessionId)}`;
|
|
18686
19031
|
if (throttled(dataDir2, marker, RECONCILE_THROTTLE_MS)) return;
|
|
18687
|
-
const here =
|
|
18688
|
-
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], {
|
|
18689
19034
|
detached: true,
|
|
18690
19035
|
stdio: "ignore"
|
|
18691
19036
|
});
|
|
@@ -18696,7 +19041,7 @@ function triggerReconcile(dataDir2, sessionId, transcriptPath) {
|
|
|
18696
19041
|
|
|
18697
19042
|
// src/hooks/shared.ts
|
|
18698
19043
|
async function readStdin() {
|
|
18699
|
-
return new Promise((
|
|
19044
|
+
return new Promise((resolve2) => {
|
|
18700
19045
|
let data = "";
|
|
18701
19046
|
let settled = false;
|
|
18702
19047
|
const finish = () => {
|
|
@@ -18705,7 +19050,7 @@ async function readStdin() {
|
|
|
18705
19050
|
clearTimeout(timer);
|
|
18706
19051
|
process.stdin.removeListener("data", onData);
|
|
18707
19052
|
process.stdin.removeListener("end", finish);
|
|
18708
|
-
|
|
19053
|
+
resolve2(data);
|
|
18709
19054
|
};
|
|
18710
19055
|
const onData = (chunk) => {
|
|
18711
19056
|
data += chunk;
|
|
@@ -18739,11 +19084,144 @@ function parseStopPayload(input) {
|
|
|
18739
19084
|
return { sessionId, transcriptPath };
|
|
18740
19085
|
}
|
|
18741
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
|
+
|
|
18742
19219
|
// src/hooks/stop.ts
|
|
18743
19220
|
async function main() {
|
|
18744
19221
|
const trigger = parseStopPayload(parseJson(await readStdin()));
|
|
18745
19222
|
if (trigger === void 0) return;
|
|
18746
19223
|
const config2 = loadConfig();
|
|
19224
|
+
warnIfStoreRedirected(config2, trigger.sessionId);
|
|
18747
19225
|
triggerReconcile(config2.dataDir, trigger.sessionId, trigger.transcriptPath);
|
|
18748
19226
|
}
|
|
18749
19227
|
try {
|