@akasecurity/ai-tc-copilot 0.9.20 → 0.9.22

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/README.md CHANGED
@@ -73,7 +73,7 @@ Then point VS Code at the unpacked folder in your user settings:
73
73
  The setup skill's [Known limitations](https://github.com/akasecurity/ai-tc/blob/main/plugins/copilot/skills/setup/SKILL.md#known-limitations) section is the authority on what AKA can do on each surface. In brief:
74
74
 
75
75
  - **Only a tool call can be stopped.** Prompts and tool results are captured, scanned and recorded, so a secret in either shows up as a finding, but neither is ever blocked or rewritten.
76
- - **AKA's notices are not shown to you.** On the Copilot CLI in `-p` mode they appeared only in the debug log; in VS Code, only in the "GitHub Copilot Chat Hooks" output channel.
76
+ - **AKA's notices may not be shown to you.** On the Copilot CLI they are sent as hook progress lines, which the Copilot hooks reference documents as shown in the CLI timeline; that has not yet been observed on a real install, and an earlier build's notices appeared only in the debug log in `-p` mode. In VS Code they appear only in the "GitHub Copilot Chat Hooks" output channel. A deny is the one message that carries its own reason, so set `redactFallback` to `block` where a flagged command must not pass silently.
77
77
  - **No setup wizard and no history backfill yet.** Use the `aka` CLI directly (`aka init`, `aka detections`, `aka scan`), and nothing reads the sessions that happened before the plugin was installed.
78
78
 
79
79
  ## Where your data lives
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akasecurity/ai-tc-copilot",
3
- "version": "0.9.20",
3
+ "version": "0.9.22",
4
4
  "description": "AI Traffic Control — inspect and govern AI prompts in GitHub Copilot",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -22,16 +22,16 @@
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/node": "^25.9.9",
25
- "@vitest/coverage-v8": "^4.1.11",
25
+ "@vitest/coverage-v8": "^4.1.12",
26
26
  "eslint": "^9.39.5",
27
27
  "tsup": "^9.0.0",
28
28
  "typescript": "^5.8.0",
29
- "vitest": "^4.1.11",
29
+ "vitest": "^4.1.12",
30
30
  "@akasecurity/eslint-config": "0.8.0",
31
+ "@akasecurity/plugin-runtime": "0.8.0",
31
32
  "@akasecurity/persistence": "0.8.0",
32
33
  "@akasecurity/plugin-sdk": "0.8.0",
33
34
  "@akasecurity/scanner": "0.8.0",
34
- "@akasecurity/plugin-runtime": "0.8.0",
35
35
  "@akasecurity/schema": "0.8.0",
36
36
  "@akasecurity/setup-wizard": "0.8.0"
37
37
  },
package/plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aka-copilot",
3
- "version": "0.9.20",
3
+ "version": "0.9.22",
4
4
  "description": "AI Traffic Control — inspect and govern AI prompts in GitHub Copilot. Detection runs locally; events are recorded to a local SQLite store on your machine.",
5
5
  "hooks": "./hooks.json",
6
6
  "skills": "./skills",
@@ -8956,6 +8956,12 @@ var CaptureSighting = object({
8956
8956
  ruleId: string2().min(1),
8957
8957
  category: DetectionCategory
8958
8958
  }).meta({ id: "CaptureSighting" });
8959
+ var REVIEW_VALUES_MAX = 16;
8960
+ var REVIEW_VALUE_MAX_CHARS = 1024;
8961
+ var ReviewValue = object({
8962
+ ruleId: string2().min(1).max(256),
8963
+ value: string2().min(1).max(REVIEW_VALUE_MAX_CHARS)
8964
+ }).meta({ id: "ReviewValue" });
8959
8965
  var EventMetadata = object({
8960
8966
  sessionId: string2().optional(),
8961
8967
  repo: string2().optional(),
@@ -9063,7 +9069,14 @@ var EventMetadata = object({
9063
9069
  scanIncomplete: _enum(["timeout", "unavailable"]).optional(),
9064
9070
  // The sighting tokens in `content`, one entry per distinct token and rule.
9065
9071
  // Set only on a forwarded capture; the locally stored copy holds the values.
9066
- sightings: array(CaptureSighting).optional()
9072
+ sightings: array(CaptureSighting).optional(),
9073
+ // The length of the text this capture was cut from, when its content holds only the first
9074
+ // part of it. Absent when the content is the whole text.
9075
+ contentTruncatedFrom: number2().int().nonnegative().optional(),
9076
+ // The raw value of each finding in this capture, for review by the deployment. Set only on
9077
+ // a forwarded capture from a repository the organization's capture settings name; the
9078
+ // locally stored copy never carries it.
9079
+ reviewValues: array(ReviewValue).max(REVIEW_VALUES_MAX).optional()
9067
9080
  }).meta({ id: "EventMetadata" });
9068
9081
  var Event = object({
9069
9082
  id: guid2(),
@@ -9917,6 +9930,8 @@ var AssetType = _enum(["project", "skill", "mcp", "hook", "config"]).meta({ id:
9917
9930
  var AccessLevel = _enum(["open", "approved", "blocked"]).meta({ id: "AccessLevel" });
9918
9931
  var Origin = _enum(["source", "public-dep", "vendored", "config", "data", "docs", "generated"]).meta({ id: "Origin" });
9919
9932
  var TrustLevel = _enum(["known-good", "risky", "unapproved"]).meta({ id: "TrustLevel" });
9933
+ var ATTENTION_TRUST_LEVELS = ["unapproved", "risky"];
9934
+ var isAttentionTrust = (trust) => trust !== null && trust !== void 0 && ATTENTION_TRUST_LEVELS.includes(trust);
9920
9935
  var Flag = _enum(["update", "stale", "conflict", "unknown", "change", "untracked", "risk", "findings"]).meta({ id: "Flag" });
9921
9936
  var Visibility = _enum(["public", "private"]).meta({ id: "Visibility" });
9922
9937
  var HarnessEventKind = _enum(["block", "redact", "warn"]).meta({ id: "HarnessEventKind" });
@@ -10094,7 +10109,7 @@ var McpTool = object({
10094
10109
  signature: string2(),
10095
10110
  description: string2(),
10096
10111
  write: boolean2(),
10097
- /** Non-null string when tool is dangerous / blocked; null otherwise. */
10112
+ /** What makes the tool dangerous; null when nothing does. */
10098
10113
  risk: string2().nullable()
10099
10114
  }).meta({ id: "McpTool" });
10100
10115
  var AssetFindingRef = object({
@@ -10141,8 +10156,9 @@ var ProjectSensitiveData = object({ items: array(SensitiveDataClass) }).meta({ i
10141
10156
  var ListProjectsResponse = object({ items: array(ProjectSummary) }).meta({ id: "ListProjectsResponse" });
10142
10157
  var InventoryStats = object({
10143
10158
  /**
10144
- * Assets with a flag, plus projects with a finding in the last
10145
- * `PROJECT_FINDINGS_WINDOW_DAYS` days (drives the attention header chip).
10159
+ * Assets with a flag or with an `ATTENTION_TRUST_LEVELS` effective trust,
10160
+ * plus projects with a finding in the last `PROJECT_FINDINGS_WINDOW_DAYS`
10161
+ * days (drives the attention header chip). An asset counts once.
10146
10162
  */
10147
10163
  attention: number2().int().nonnegative(),
10148
10164
  byType: object({
@@ -10685,6 +10701,10 @@ var EgressIngestHit = object({
10685
10701
  */
10686
10702
  credentialRefs: EgressCredentialRefs.optional()
10687
10703
  }).meta({ id: "EgressIngestHit" });
10704
+ var SUPERSEDED_PROJECT_KEYS_MAX = 4;
10705
+ var SupersededProjectKeys = array(
10706
+ string2().regex(/^[0-9a-f]{64}$/, "a superseded key must be a 64-character lowercase hex digest")
10707
+ ).max(SUPERSEDED_PROJECT_KEYS_MAX);
10688
10708
  var EgressIngestRequest = object({
10689
10709
  /**
10690
10710
  * Hash digest of the local `projectKey`, never the plaintext.
@@ -10697,6 +10717,7 @@ var EgressIngestRequest = object({
10697
10717
  * that still has the plaintext to not send.
10698
10718
  */
10699
10719
  projectKey: string2().regex(/^[0-9a-f]{64}$/, "projectKey must be a 64-character lowercase hex digest"),
10720
+ supersededProjectKeys: SupersededProjectKeys.optional(),
10700
10721
  /** Display name only — never keys reconciliation. */
10701
10722
  project: string2(),
10702
10723
  reconcile: EgressReconcile,
@@ -10806,6 +10827,10 @@ var DeviceCommand = object({
10806
10827
  expiresAt: printable(64).min(1)
10807
10828
  }).strict();
10808
10829
  var DeviceCommandPollResponse = object({ command: DeviceCommand.nullable() });
10830
+ var SessionHoldResponse = object({
10831
+ held: boolean2(),
10832
+ reason: printable(500).optional()
10833
+ });
10809
10834
  var DeviceCommandFailureReason = _enum(["scan_failed", "no_projects", "expired"]);
10810
10835
  var DeviceCommandAckBody = discriminatedUnion("outcome", [
10811
10836
  object({
@@ -10868,7 +10893,9 @@ var CredentialSighting = object({
10868
10893
  }).strict().meta({ id: "CredentialSighting" });
10869
10894
  var CredentialSightingsRequest = object({
10870
10895
  sightings: array(CredentialSighting).min(1).max(CREDENTIAL_SIGHTINGS_BATCH_MAX),
10871
- scanId: uuid2().optional()
10896
+ scanId: uuid2().optional(),
10897
+ /** The earlier digests of the one project every sighting in the request names. */
10898
+ supersededProjectKeys: SupersededProjectKeys.optional()
10872
10899
  }).strict().meta({ id: "CredentialSightingsRequest" });
10873
10900
  var CredentialSightingsAck = object({
10874
10901
  accepted: number2().int().nonnegative()
@@ -10999,6 +11026,18 @@ var ModelPolicy = object({
10999
11026
  mode: literal("allowlist"),
11000
11027
  approved: array(string2().min(1).max(512)).max(1e3)
11001
11028
  }).meta({ id: "ModelPolicy" });
11029
+ var TOOL_OUTPUT_FORWARD_MIN_CHARS = 2;
11030
+ var TOOL_OUTPUT_FORWARD_MAX_CHARS = 65536;
11031
+ var CAPTURE_REPOS_MAX = 1e3;
11032
+ var CaptureRepos = array(string2().min(1).max(512)).max(CAPTURE_REPOS_MAX);
11033
+ var CaptureSettings = object({
11034
+ toolOutput: object({
11035
+ maxChars: number2().int().min(TOOL_OUTPUT_FORWARD_MIN_CHARS).max(TOOL_OUTPUT_FORWARD_MAX_CHARS),
11036
+ repos: CaptureRepos.optional()
11037
+ }).optional(),
11038
+ reviewValueRepos: CaptureRepos.optional(),
11039
+ sessionHold: boolean2().optional()
11040
+ }).meta({ id: "CaptureSettings" });
11002
11041
  var PolicyBundle = object({
11003
11042
  version: string2(),
11004
11043
  policies: array(Policy),
@@ -11062,6 +11101,9 @@ var PolicyBundle = object({
11062
11101
  // absent leaves the device's own setting in force, which is the behaviour
11063
11102
  // that predates the field and the safe direction to default.
11064
11103
  redactFallback: RedactFallback.optional(),
11104
+ // Optional so an older backend, and an older on-disk cache, still parses; absent sends what
11105
+ // the machine sent before the field existed.
11106
+ capture: CaptureSettings.optional(),
11065
11107
  customKeywords: array(string2()),
11066
11108
  fetchedAt: iso_exports.datetime()
11067
11109
  }).meta({ id: "PolicyBundle" });
@@ -11070,7 +11112,8 @@ var POLICY_BUNDLE_SHAPE_ID = [
11070
11112
  ...Object.keys(Policy.shape).map((key) => `policies.${key}`),
11071
11113
  ...PolicyTarget.options.flatMap((member) => "shape" in member ? Object.keys(member.shape) : []).map((key) => `policies.target.${key}`),
11072
11114
  ...Object.keys(ExceptionBundleEntry.shape).map((key) => `exceptions.${key}`),
11073
- ...Object.keys(ModelPolicy.shape).map((key) => `modelPolicy.${key}`)
11115
+ ...Object.keys(ModelPolicy.shape).map((key) => `modelPolicy.${key}`),
11116
+ ...Object.keys(CaptureSettings.shape).map((key) => `capture.${key}`)
11074
11117
  ].sort().join(",");
11075
11118
  var OBSERVE_ONLY_CATEGORIES = ["config"];
11076
11119
  var ENFORCEABLE_CATEGORIES = DetectionCategory.options.filter((c) => !OBSERVE_ONLY_CATEGORIES.includes(c));
@@ -11462,7 +11505,7 @@ var DetectedWebAccounts = object({
11462
11505
  var DetectedWebAccountsEnvelope = DetectedWebAccounts.extend({ accounts: array(unknown()) });
11463
11506
 
11464
11507
  // ../../packages/schema/src/zod/local.ts
11465
- var WORKSPACE_SETTINGS_SPEC_VERSION = 10;
11508
+ var WORKSPACE_SETTINGS_SPEC_VERSION = 11;
11466
11509
  var MODEL_JUDGE_PAYLOAD_VERSION = 1;
11467
11510
  var RunMode = _enum(["standalone", "attached"]);
11468
11511
  var ControlPlaneConnection = object({
@@ -11622,6 +11665,15 @@ var BodyRetention = object({
11622
11665
  // candidate set that is already bounded by "delivered, or never owed".
11623
11666
  retainDays: number2().int().min(1).max(3650).default(BODY_RETENTION_DEFAULT_DAYS)
11624
11667
  }).meta({ id: "BodyRetention" });
11668
+ var MAX_PROTECTED_PATH_ENTRIES = 256;
11669
+ var MAX_PROTECTED_PATH_ENTRY_CHARS = 1024;
11670
+ var ProtectedPathEntry = string2().trim().min(1).max(MAX_PROTECTED_PATH_ENTRY_CHARS);
11671
+ var ProtectedPaths = array(unknown()).transform(
11672
+ (entries) => entries.flatMap((entry) => {
11673
+ const parsed = ProtectedPathEntry.safeParse(entry);
11674
+ return parsed.success ? [parsed.data] : [];
11675
+ }).slice(0, MAX_PROTECTED_PATH_ENTRIES)
11676
+ );
11625
11677
  var WorkspaceSettings = object({
11626
11678
  specVersion: number2().int().positive().default(WORKSPACE_SETTINGS_SPEC_VERSION),
11627
11679
  runMode: RunMode.default("standalone"),
@@ -11712,7 +11764,18 @@ var WorkspaceSettings = object({
11712
11764
  bodyRetention: BodyRetention.default({
11713
11765
  enabled: false,
11714
11766
  retainDays: BODY_RETENTION_DEFAULT_DAYS
11715
- })
11767
+ }),
11768
+ // Folders and file name globs whose files a tool call may not touch
11769
+ // unflagged: a Read, Grep, Glob or Bash naming one becomes a finding under
11770
+ // the command-risk pack's policy. Absent means none are protected, and
11771
+ // protectedPathsOf is the one reader.
11772
+ //
11773
+ // A bad entry is dropped on its own (see ProtectedPaths); `.catch(undefined)`
11774
+ // reads a value that is not a list at all as no list. A settings.json that
11775
+ // fails this schema reads as the unonboarded defaults, and the next save
11776
+ // writes those back over it, so a malformed value must not cost every other
11777
+ // setting. Not a ManagedSettingKey.
11778
+ protectedPaths: ProtectedPaths.optional().catch(void 0)
11716
11779
  });
11717
11780
  function defaultWorkspaceSettings() {
11718
11781
  return WorkspaceSettings.parse({});
@@ -12059,6 +12122,9 @@ var ConfigInventoryAck = object({
12059
12122
  accepted: number2().int().nonnegative()
12060
12123
  });
12061
12124
 
12125
+ // ../../packages/schema/src/zod/credential-status.ts
12126
+ var CredentialStatus = _enum(["rotation_overdue", "exposed"]).meta({ id: "CredentialStatus" });
12127
+
12062
12128
  // ../../packages/schema/src/zod/registry.ts
12063
12129
  var Namespace = string2().regex(/^[a-z][a-z0-9-]*$/);
12064
12130
  var PackId = string2().regex(/^[a-z][a-z0-9-]*$/);
@@ -13868,6 +13934,48 @@ function codingScopeExtras(dataDir2, settings, credential) {
13868
13934
  }
13869
13935
  }
13870
13936
 
13937
+ // ../../packages/persistence/src/repo-key.ts
13938
+ import { createHash as createHash2 } from "crypto";
13939
+ var SCP_FORM = /^(?:[^@/]+@)?([^/:]+):(.+)$/;
13940
+ var DOS_DRIVE = /^[A-Za-z]:[\\/]/;
13941
+ var FILE_URL = /^file:\/\//i;
13942
+ var SCHEME_FORM = /^[a-z][a-z0-9+.-]*:\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?(\/.*)?$/i;
13943
+ var SLASH = "/".charCodeAt(0);
13944
+ var GIT_SUFFIX = ".git";
13945
+ function trimSlashes(path) {
13946
+ let start = 0;
13947
+ let end = path.length;
13948
+ while (start < end && path.charCodeAt(start) === SLASH) start += 1;
13949
+ while (end > start && path.charCodeAt(end - 1) === SLASH) end -= 1;
13950
+ return path.slice(start, end);
13951
+ }
13952
+ function parseRemote(url2, foldsForgePathCase) {
13953
+ const trimmed = url2.trim();
13954
+ if (DOS_DRIVE.test(trimmed) || FILE_URL.test(trimmed)) return void 0;
13955
+ const scheme = SCHEME_FORM.exec(trimmed);
13956
+ const scp = scheme === null ? SCP_FORM.exec(trimmed) : null;
13957
+ const host = (scheme?.[1] ?? scp?.[1])?.toLowerCase();
13958
+ if (host === void 0) return void 0;
13959
+ const bare = trimSlashes((scheme === null ? scp?.[2] : scheme[2]) ?? "");
13960
+ const path = bare.endsWith(GIT_SUFFIX) ? bare.slice(0, -GIT_SUFFIX.length) : bare;
13961
+ const folds = foldsForgePathCase && CASE_INSENSITIVE_FORGES.has(host);
13962
+ return { host, path: folds ? path.toLowerCase() : path };
13963
+ }
13964
+ var CASE_INSENSITIVE_FORGES = /* @__PURE__ */ new Set([
13965
+ "github.com",
13966
+ "gitlab.com",
13967
+ "bitbucket.org"
13968
+ ]);
13969
+ function canonicalGitUrl(url2) {
13970
+ return canonicalUnder(url2, true);
13971
+ }
13972
+ function canonicalUnder(url2, foldsForgePathCase) {
13973
+ const remote = parseRemote(url2, foldsForgePathCase);
13974
+ if (remote === void 0) return url2.trim();
13975
+ return remote.path === "" ? remote.host : `${remote.host}/${remote.path}`;
13976
+ }
13977
+ var SCOPE_KEY = printable(ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH);
13978
+
13871
13979
  // ../../packages/persistence/src/capture-id-key.ts
13872
13980
  import { randomBytes } from "crypto";
13873
13981
  import { readFileSync as readFileSync4 } from "fs";
@@ -14062,9 +14170,6 @@ import { createHash as createHash4, randomUUID as randomUUID3 } from "crypto";
14062
14170
  import { homedir as homedir2 } from "os";
14063
14171
  import { isAbsolute as isAbsolute2, relative as relative2, sep as sep2 } from "path";
14064
14172
 
14065
- // ../../packages/persistence/src/egress-wire.ts
14066
- import { createHash as createHash2 } from "crypto";
14067
-
14068
14173
  // ../../packages/persistence/src/repositories/shares.ts
14069
14174
  import { randomUUID as randomUUID2 } from "crypto";
14070
14175
 
@@ -14887,10 +14992,6 @@ var SqliteSharesRepository = class {
14887
14992
  }
14888
14993
  };
14889
14994
 
14890
- // ../../packages/persistence/src/egress-wire.ts
14891
- var SLASH = "/".charCodeAt(0);
14892
- var SCOPE_KEY = printable(ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH);
14893
-
14894
14995
  // ../../packages/persistence/src/git-index.ts
14895
14996
  import { readFileSync as readFileSync5, statSync as statSync3 } from "fs";
14896
14997
  import { dirname, isAbsolute, join as join6, relative, resolve, sep } from "path";
@@ -15040,7 +15141,7 @@ function inventoryId(objectType, identityKey) {
15040
15141
  return sha256Hex(canonicalIdentity(["inventory", objectType, identityKey]));
15041
15142
  }
15042
15143
  function sourceProjectId(url2) {
15043
- return sha256Hex(canonicalIdentity(["source_project", url2]));
15144
+ return sha256Hex(canonicalIdentity(["source_project", canonicalGitUrl(url2)]));
15044
15145
  }
15045
15146
  function classifiedDataId(cls) {
15046
15147
  return sha256Hex(canonicalIdentity(["classified_data", cls]));
@@ -20386,7 +20487,7 @@ var SqliteInventoryRepository = class {
20386
20487
  import { randomUUID as randomUUID7 } from "crypto";
20387
20488
  var CATEGORY_ORDER = ["config", "skill", "mcp", "hook"];
20388
20489
  var VALID_HARNESS_IDS = new Set(HarnessId.options);
20389
- var WORKTREE_CHECKOUT_FILTER = "(url IS NULL OR (url NOT LIKE '%/.claude/worktrees/%' AND url NOT LIKE '%\\.claude\\worktrees\\%'))";
20490
+ var GHOST_PROJECT_FILTER = "(url IS NULL OR (url NOT LIKE '%/.claude/worktrees/%' AND url NOT LIKE '%\\.claude\\worktrees\\%' AND url NOT LIKE '%/.git/worktrees/%' AND url NOT LIKE '%\\.git\\worktrees\\%'))";
20390
20491
  var HARNESS_LABELS = {
20391
20492
  [HARNESS.ClaudeCode]: "Claude Code",
20392
20493
  [HARNESS.Cursor]: "Cursor",
@@ -20395,6 +20496,7 @@ var HARNESS_LABELS = {
20395
20496
  [HARNESS.Copilot]: "GitHub Copilot"
20396
20497
  };
20397
20498
  var HARNESS_LIVENESS_WINDOW_MS = 30 * 24 * 60 * 60 * 1e3;
20499
+ var ATTENTION_TRUST_SQL = ATTENTION_TRUST_LEVELS.map((t) => `'${t}'`).join(", ");
20398
20500
  var PROJECT_FINDINGS_WINDOW_MS = PROJECT_FINDINGS_WINDOW_DAYS * 24 * 60 * 60 * 1e3;
20399
20501
  var MCP_TOOLS_USED_WINDOW_MS = MCP_TOOLS_USED_WINDOW_DAYS * 24 * 60 * 60 * 1e3;
20400
20502
  var PROJECT_FINDINGS_FROM = `audit_events s
@@ -20468,11 +20570,7 @@ function buildAssetDetail(row) {
20468
20570
  finding: null
20469
20571
  };
20470
20572
  if (row.assetType === "mcp" && row.toolsJson !== null) {
20471
- const rawTools = safeJson(row.toolsJson, []);
20472
- detail.tools = row.effectiveTrust === "unapproved" ? rawTools.map((t) => ({
20473
- ...t,
20474
- risk: t.risk ?? "Tool access blocked: MCP server trust is unapproved."
20475
- })) : rawTools;
20573
+ detail.tools = safeJson(row.toolsJson, []);
20476
20574
  }
20477
20575
  return detail;
20478
20576
  }
@@ -20537,7 +20635,7 @@ var SqliteInventoryAssetsRepository = class {
20537
20635
  };
20538
20636
  byType.project = countScalar(
20539
20637
  this.db,
20540
- `SELECT count(*) AS n FROM source_project WHERE ${WORKTREE_CHECKOUT_FILTER}`
20638
+ `SELECT count(*) AS n FROM source_project WHERE ${GHOST_PROJECT_FILTER}`
20541
20639
  );
20542
20640
  const mcpTrustCounts = countBy(
20543
20641
  this.db,
@@ -20561,12 +20659,17 @@ var SqliteInventoryAssetsRepository = class {
20561
20659
  );
20562
20660
  const flaggedAssets = countScalar(
20563
20661
  this.db,
20564
- "SELECT count(*) AS n FROM inventory_asset WHERE flags_json <> '[]'"
20662
+ `SELECT count(*) AS n
20663
+ FROM inventory_asset a
20664
+ LEFT JOIN mcp_trust_override o ON o.asset_id = a.id
20665
+ WHERE a.flags_json <> '[]'
20666
+ OR (a.asset_type = 'mcp'
20667
+ AND coalesce(o.trust, a.trust) IN (${ATTENTION_TRUST_SQL}))`
20565
20668
  );
20566
20669
  const flaggedProjects = countScalar(
20567
20670
  this.db,
20568
20671
  `SELECT count(*) AS n FROM source_project p
20569
- WHERE ${WORKTREE_CHECKOUT_FILTER}
20672
+ WHERE ${GHOST_PROJECT_FILTER}
20570
20673
  AND EXISTS (SELECT 1 FROM ${PROJECT_FINDINGS_FROM}
20571
20674
  WHERE s.source_project_id = p.id AND ${PROJECT_FINDINGS_JOIN})`,
20572
20675
  [this.findingsSince()]
@@ -20576,7 +20679,9 @@ var SqliteInventoryAssetsRepository = class {
20576
20679
  byType[r.assetType] += 1;
20577
20680
  if (r.assetType === "mcp" && r.effectiveTrust) mcpTrust[r.effectiveTrust] += 1;
20578
20681
  }
20579
- const flaggedConfig = configRows.filter((r) => r.flagsJson !== "[]").length;
20682
+ const flaggedConfig = configRows.filter(
20683
+ (r) => r.flagsJson !== "[]" || r.assetType === "mcp" && isAttentionTrust(r.effectiveTrust)
20684
+ ).length;
20580
20685
  return Promise.resolve({
20581
20686
  attention: flaggedAssets + flaggedProjects + flaggedConfig,
20582
20687
  byType,
@@ -21031,7 +21136,7 @@ var SqliteInventoryAssetsRepository = class {
21031
21136
  }
21032
21137
  fetchProjects(q) {
21033
21138
  let sql = `SELECT id, url, name, attributes, last_seen AS lastSeen FROM source_project
21034
- WHERE ${WORKTREE_CHECKOUT_FILTER}`;
21139
+ WHERE ${GHOST_PROJECT_FILTER}`;
21035
21140
  const params = [];
21036
21141
  if (q) {
21037
21142
  const pat = containsPattern(q);
@@ -23332,17 +23437,30 @@ function openLocalDatabase(dir, options = {}) {
23332
23437
  throw err;
23333
23438
  }
23334
23439
  }
23335
- function reconcileWorktreeProjects(canonicalId, headRoot, worktreeRoot) {
23440
+ function reconcileWorktreeProjects(canonicalId, headRoot, worktreeRoot, supersededUrls = []) {
23336
23441
  try {
23337
23442
  const headPosix = headRoot.split(sep3).join("/");
23338
23443
  const worktreePosix = worktreeRoot.split(sep3).join("/");
23339
23444
  const exactArm = worktreeRoot === headRoot ? "" : "url IN (:worktreePosix, :worktreeWin) OR ";
23445
+ const superseded = [
23446
+ ...new Set(
23447
+ supersededUrls.flatMap((url2) => {
23448
+ const posix2 = url2.split(sep3).join("/");
23449
+ return [posix2, posix2.split("/").join("\\")];
23450
+ })
23451
+ )
23452
+ ];
23453
+ const supersededParams = Object.fromEntries(
23454
+ superseded.map((url2, i) => [`superseded${String(i)}`, url2])
23455
+ );
23456
+ const supersededArm = superseded.length === 0 ? "" : `url IN (${superseded.map((_, i) => `:superseded${String(i)}`).join(", ")}) OR `;
23340
23457
  const stale = db.prepare(
23341
23458
  `SELECT id FROM source_project
23342
23459
  WHERE id <> :canonicalId
23343
- AND (${exactArm}url LIKE :pattern ESCAPE '\\' OR url LIKE :patternWin ESCAPE '\\')`
23460
+ AND (${supersededArm}${exactArm}url LIKE :pattern ESCAPE '\\' OR url LIKE :patternWin ESCAPE '\\')`
23344
23461
  ).all({
23345
23462
  canonicalId,
23463
+ ...supersededParams,
23346
23464
  ...worktreeRoot === headRoot ? {} : { worktreePosix, worktreeWin: worktreePosix.split("/").join("\\") },
23347
23465
  pattern: `${escapeLikePattern(headPosix)}/.claude/worktrees/%`,
23348
23466
  patternWin: `${escapeLikePattern(headPosix.split("/").join("\\"))}\\\\.claude\\\\worktrees\\\\%`
@@ -23492,8 +23610,8 @@ import { dirname as dirname5 } from "path";
23492
23610
 
23493
23611
  // ../../packages/plugin-runtime/src/attached/config-inventory-sync.ts
23494
23612
  import { createHash as createHash10 } from "crypto";
23495
- import { readFileSync as readFileSync16 } from "fs";
23496
- import { join as join25 } from "path";
23613
+ import { readFileSync as readFileSync17 } from "fs";
23614
+ import { join as join26 } from "path";
23497
23615
 
23498
23616
  // ../../packages/plugin-runtime/src/attached/history-sync.ts
23499
23617
  import { createHash as createHash9 } from "crypto";
@@ -23507,9 +23625,9 @@ var REDACT_DEGRADED_TO = EventMetadata.shape.redactDegradedTo.unwrap();
23507
23625
  var SCAN_INCOMPLETE = EventMetadata.shape.scanIncomplete.unwrap();
23508
23626
 
23509
23627
  // ../../packages/plugin-runtime/src/attached/policy-store.ts
23510
- import { randomUUID as randomUUID15 } from "crypto";
23511
- import { readFile as readFile2, rm, writeFile as writeFile2 } from "fs/promises";
23512
- import { join as join24 } from "path";
23628
+ import { randomUUID as randomUUID16 } from "crypto";
23629
+ import { readFile as readFile2, rm as rm2, writeFile as writeFile3 } from "fs/promises";
23630
+ import { join as join25 } from "path";
23513
23631
 
23514
23632
  // ../../packages/plugin-runtime/src/attached/atomic-publish.ts
23515
23633
  import { rename as rename2 } from "fs/promises";
@@ -23517,6 +23635,16 @@ var IMMEDIATE_RETRIES = 8;
23517
23635
  var TIMED_RETRIES = 4;
23518
23636
  var ATTEMPTS = 1 + IMMEDIATE_RETRIES + TIMED_RETRIES;
23519
23637
 
23638
+ // ../../packages/plugin-runtime/src/attached/capture-settings.ts
23639
+ import { randomUUID as randomUUID15 } from "crypto";
23640
+ import { readFileSync as readFileSync16 } from "fs";
23641
+ import { rm, writeFile as writeFile2 } from "fs/promises";
23642
+ import { join as join24 } from "path";
23643
+ var HookCaptureSettingsSchema = CaptureSettings.pick({
23644
+ toolOutput: true,
23645
+ sessionHold: true
23646
+ });
23647
+
23520
23648
  // ../../packages/plugin-runtime/src/attached/history-sync.ts
23521
23649
  var CAPTURE_BATCH_BYTES = 1024 * 1024;
23522
23650
 
@@ -23526,22 +23654,22 @@ var CONFIG_INVENTORY_STAGED_MAX_AGE_MS = 30 * 24 * 60 * 60 * 1e3;
23526
23654
  var CONFIG_INVENTORY_STAGED_MAX_BYTES = 8 * 1024 * 1024;
23527
23655
 
23528
23656
  // ../../packages/plugin-runtime/src/attached/forward-drops.ts
23529
- import { readFileSync as readFileSync17 } from "fs";
23530
- import { join as join26 } from "path";
23657
+ import { readFileSync as readFileSync18 } from "fs";
23658
+ import { join as join27 } from "path";
23531
23659
 
23532
23660
  // ../../packages/plugin-runtime/src/attached/plugin-block.ts
23533
- import { readFileSync as readFileSync18 } from "fs";
23661
+ import { readFileSync as readFileSync19 } from "fs";
23534
23662
 
23535
23663
  // ../../packages/plugin-runtime/src/attached/install-record.ts
23536
23664
  import { readFile as readFile3, stat } from "fs/promises";
23537
- import { basename as basename2, dirname as dirname6, join as join27, resolve as resolve3 } from "path";
23665
+ import { basename as basename2, dirname as dirname6, join as join28, resolve as resolve3 } from "path";
23538
23666
 
23539
23667
  // ../../packages/plugin-runtime/src/attached/plugin-block.ts
23540
23668
  var INSTALL_RECORD_READ_TIMEOUT_MS = REQUEST_TIMEOUT_MS / 2;
23541
23669
 
23542
23670
  // ../../packages/plugin-runtime/src/attached/posture-report-state.ts
23543
- import { readFileSync as readFileSync19 } from "fs";
23544
- import { join as join28 } from "path";
23671
+ import { readFileSync as readFileSync20 } from "fs";
23672
+ import { join as join29 } from "path";
23545
23673
  var OUTCOME_KEYS = {
23546
23674
  ok: true,
23547
23675
  unauthorized: true,
@@ -23562,18 +23690,18 @@ import { statSync as statSync7 } from "fs";
23562
23690
  import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
23563
23691
 
23564
23692
  // ../../packages/plugin-runtime/src/attached/posture-store.ts
23565
- import { randomUUID as randomUUID16 } from "crypto";
23566
- import { readFile as readFile4, rm as rm2, writeFile as writeFile3 } from "fs/promises";
23567
- import { join as join29 } from "path";
23568
-
23569
- // ../../packages/plugin-runtime/src/attached/label-drops.ts
23570
- import { readFileSync as readFileSync20 } from "fs";
23693
+ import { randomUUID as randomUUID17 } from "crypto";
23694
+ import { readFile as readFile4, rm as rm3, writeFile as writeFile4 } from "fs/promises";
23571
23695
  import { join as join30 } from "path";
23572
23696
 
23573
- // ../../packages/plugin-runtime/src/attached/sync-state.ts
23697
+ // ../../packages/plugin-runtime/src/attached/label-drops.ts
23574
23698
  import { readFileSync as readFileSync21 } from "fs";
23575
23699
  import { join as join31 } from "path";
23576
23700
 
23701
+ // ../../packages/plugin-runtime/src/attached/sync-state.ts
23702
+ import { readFileSync as readFileSync22 } from "fs";
23703
+ import { join as join32 } from "path";
23704
+
23577
23705
  // ../../packages/plugin-runtime/src/attached/status.ts
23578
23706
  var REFUSAL_LINES = {
23579
23707
  unauthorized: "KEY REJECTED \u2014 re-attach with a valid plugin key",
@@ -23603,10 +23731,13 @@ var WORK_LINES = {
23603
23731
  // ../../packages/plugin-runtime/src/attached/history-sync-trigger.ts
23604
23732
  import { spawn } from "child_process";
23605
23733
  import { existsSync as existsSync8, statSync as statSync8 } from "fs";
23606
- import { join as join32 } from "path";
23734
+ import { join as join33 } from "path";
23607
23735
  import { fileURLToPath } from "url";
23608
23736
  var HISTORY_SYNC_THROTTLE_MS = 5 * 60 * 1e3;
23609
23737
 
23738
+ // ../../packages/plugin-runtime/src/attached/session-hold.ts
23739
+ import { dirname as dirname7 } from "path";
23740
+
23610
23741
  // ../../packages/plugin-runtime/src/attached/sighting-key-sync.ts
23611
23742
  var SIGHTING_KEY_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
23612
23743
 
@@ -23665,10 +23796,10 @@ import { fileURLToPath as fileURLToPath3 } from "url";
23665
23796
  var CONTENT_RETENTION_THROTTLE_MS = 60 * 60 * 1e3;
23666
23797
 
23667
23798
  // ../../packages/plugin-runtime/src/handle-session-start.ts
23668
- import { randomUUID as randomUUID17 } from "crypto";
23799
+ import { randomUUID as randomUUID18 } from "crypto";
23669
23800
 
23670
23801
  // ../../packages/plugin-runtime/src/attached/forwarding-line.ts
23671
- import { dirname as dirname7 } from "path";
23802
+ import { dirname as dirname8 } from "path";
23672
23803
 
23673
23804
  // ../../packages/plugin-runtime/src/handle-session-start.ts
23674
23805
  var EXCEPTION_RETENTION_MS = 90 * 24 * 60 * 60 * 1e3;