@gaunt-sloth/core 2.0.0-alpha.8 → 2.0.0-beta.0

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.
Files changed (275) hide show
  1. package/.gsloth.review.md +2 -0
  2. package/README.md +71 -20
  3. package/dist/config/colour.d.ts +38 -0
  4. package/dist/config/colour.js +36 -0
  5. package/dist/config/colour.js.map +1 -0
  6. package/dist/config/configDiscovery.d.ts +79 -0
  7. package/dist/config/configDiscovery.js +80 -0
  8. package/dist/config/configDiscovery.js.map +1 -0
  9. package/dist/config/defaults.d.ts +20 -20
  10. package/dist/config/defaults.js +10 -8
  11. package/dist/config/defaults.js.map +1 -1
  12. package/dist/config/filesystem-tools.d.ts +41 -0
  13. package/dist/config/filesystem-tools.js +56 -0
  14. package/dist/config/filesystem-tools.js.map +1 -0
  15. package/dist/config/loader.d.ts +171 -19
  16. package/dist/config/loader.js +1054 -144
  17. package/dist/config/loader.js.map +1 -1
  18. package/dist/config/mouse.d.ts +50 -0
  19. package/dist/config/mouse.js +44 -0
  20. package/dist/config/mouse.js.map +1 -0
  21. package/dist/config/profiles.d.ts +68 -0
  22. package/dist/config/profiles.js +93 -0
  23. package/dist/config/profiles.js.map +1 -0
  24. package/dist/config/providerKeys.d.ts +69 -0
  25. package/dist/config/providerKeys.js +69 -0
  26. package/dist/config/providerKeys.js.map +1 -0
  27. package/dist/config/schema.d.ts +2671 -138
  28. package/dist/config/schema.js +1361 -85
  29. package/dist/config/schema.js.map +1 -1
  30. package/dist/config/shell-policy.d.ts +899 -111
  31. package/dist/config/shell-policy.js +800 -70
  32. package/dist/config/shell-policy.js.map +1 -1
  33. package/dist/config/tool-descriptions.d.ts +211 -0
  34. package/dist/config/tool-descriptions.js +272 -0
  35. package/dist/config/tool-descriptions.js.map +1 -0
  36. package/dist/config/types.d.ts +352 -41
  37. package/dist/config/types.js +1 -0
  38. package/dist/config/types.js.map +1 -1
  39. package/dist/config.d.ts +35 -1
  40. package/dist/config.js +16 -1
  41. package/dist/config.js.map +1 -1
  42. package/dist/constants.d.ts +28 -1
  43. package/dist/constants.js +28 -1
  44. package/dist/constants.js.map +1 -1
  45. package/dist/core/GthAbstractAgent.d.ts +166 -11
  46. package/dist/core/GthAbstractAgent.js +484 -45
  47. package/dist/core/GthAbstractAgent.js.map +1 -1
  48. package/dist/core/GthAgentRunner.d.ts +543 -57
  49. package/dist/core/GthAgentRunner.js +1494 -140
  50. package/dist/core/GthAgentRunner.js.map +1 -1
  51. package/dist/core/GthLangChainAgent.d.ts +117 -2
  52. package/dist/core/GthLangChainAgent.js +602 -29
  53. package/dist/core/GthLangChainAgent.js.map +1 -1
  54. package/dist/core/approvals/annotations.d.ts +122 -0
  55. package/dist/core/approvals/annotations.js +137 -0
  56. package/dist/core/approvals/annotations.js.map +1 -0
  57. package/dist/core/approvals/grants.d.ts +216 -0
  58. package/dist/core/approvals/grants.js +469 -0
  59. package/dist/core/approvals/grants.js.map +1 -0
  60. package/dist/core/approvals/matcher.d.ts +202 -0
  61. package/dist/core/approvals/matcher.js +267 -0
  62. package/dist/core/approvals/matcher.js.map +1 -0
  63. package/dist/core/approvals/mcpSubjects.d.ts +40 -0
  64. package/dist/core/approvals/mcpSubjects.js +99 -0
  65. package/dist/core/approvals/mcpSubjects.js.map +1 -0
  66. package/dist/core/approvals/promptHeader.d.ts +28 -0
  67. package/dist/core/approvals/promptHeader.js +62 -0
  68. package/dist/core/approvals/promptHeader.js.map +1 -0
  69. package/dist/core/approvals/toolAnnotationSources.d.ts +105 -0
  70. package/dist/core/approvals/toolAnnotationSources.js +277 -0
  71. package/dist/core/approvals/toolAnnotationSources.js.map +1 -0
  72. package/dist/core/approvals/toolHost.d.ts +46 -0
  73. package/dist/core/approvals/toolHost.js +108 -0
  74. package/dist/core/approvals/toolHost.js.map +1 -0
  75. package/dist/core/debugCapture.d.ts +74 -0
  76. package/dist/core/debugCapture.js +100 -0
  77. package/dist/core/debugCapture.js.map +1 -0
  78. package/dist/core/gthLeanAgentFactory.d.ts +4 -4
  79. package/dist/core/gthLeanAgentFactory.js +4 -4
  80. package/dist/core/launchBanner.d.ts +127 -0
  81. package/dist/core/launchBanner.js +414 -0
  82. package/dist/core/launchBanner.js.map +1 -0
  83. package/dist/core/modelLabel.d.ts +19 -0
  84. package/dist/core/modelLabel.js +26 -0
  85. package/dist/core/modelLabel.js.map +1 -0
  86. package/dist/core/plainToolIndication.d.ts +15 -0
  87. package/dist/core/plainToolIndication.js +174 -0
  88. package/dist/core/plainToolIndication.js.map +1 -0
  89. package/dist/core/reasoningBlocks.d.ts +65 -0
  90. package/dist/core/reasoningBlocks.js +103 -0
  91. package/dist/core/reasoningBlocks.js.map +1 -0
  92. package/dist/core/refusal.d.ts +53 -0
  93. package/dist/core/refusal.js +133 -0
  94. package/dist/core/refusal.js.map +1 -0
  95. package/dist/core/runHeader.d.ts +38 -0
  96. package/dist/core/runHeader.js +42 -0
  97. package/dist/core/runHeader.js.map +1 -0
  98. package/dist/core/runStats.d.ts +14 -3
  99. package/dist/core/runStats.js +48 -3
  100. package/dist/core/runStats.js.map +1 -1
  101. package/dist/core/shell/ShellCommandFailedError.d.ts +3 -4
  102. package/dist/core/shell/ShellCommandFailedError.js +3 -4
  103. package/dist/core/shell/ShellCommandFailedError.js.map +1 -1
  104. package/dist/core/shell/abstention.d.ts +88 -0
  105. package/dist/core/shell/abstention.js +184 -0
  106. package/dist/core/shell/abstention.js.map +1 -0
  107. package/dist/core/shell/approvalCapture.d.ts +271 -0
  108. package/dist/core/shell/approvalCapture.js +108 -0
  109. package/dist/core/shell/approvalCapture.js.map +1 -0
  110. package/dist/core/shell/approvalStop.d.ts +123 -0
  111. package/dist/core/shell/approvalStop.js +269 -0
  112. package/dist/core/shell/approvalStop.js.map +1 -0
  113. package/dist/core/shell/arity.d.ts +6 -0
  114. package/dist/core/shell/arity.js +20 -6
  115. package/dist/core/shell/arity.js.map +1 -1
  116. package/dist/core/shell/denylist.d.ts +11 -0
  117. package/dist/core/shell/denylist.js +37 -0
  118. package/dist/core/shell/denylist.js.map +1 -0
  119. package/dist/core/shell/escalationSeverity.d.ts +141 -0
  120. package/dist/core/shell/escalationSeverity.js +89 -0
  121. package/dist/core/shell/escalationSeverity.js.map +1 -0
  122. package/dist/core/shell/framing.d.ts +190 -0
  123. package/dist/core/shell/framing.js +633 -0
  124. package/dist/core/shell/framing.js.map +1 -0
  125. package/dist/core/shell/hardline.d.ts +103 -0
  126. package/dist/core/shell/hardline.js +780 -0
  127. package/dist/core/shell/hardline.js.map +1 -0
  128. package/dist/core/shell/negotiation.d.ts +328 -0
  129. package/dist/core/shell/negotiation.js +488 -0
  130. package/dist/core/shell/negotiation.js.map +1 -0
  131. package/dist/core/shell/normalize.d.ts +44 -4
  132. package/dist/core/shell/normalize.js +61 -7
  133. package/dist/core/shell/normalize.js.map +1 -1
  134. package/dist/core/shell/openWorld.d.ts +263 -0
  135. package/dist/core/shell/openWorld.js +1188 -0
  136. package/dist/core/shell/openWorld.js.map +1 -0
  137. package/dist/core/shell/rater.d.ts +873 -0
  138. package/dist/core/shell/rater.js +1454 -0
  139. package/dist/core/shell/rater.js.map +1 -0
  140. package/dist/core/shell/raterModel.d.ts +41 -0
  141. package/dist/core/shell/raterModel.js +51 -0
  142. package/dist/core/shell/raterModel.js.map +1 -0
  143. package/dist/core/shell/raterVocabulary.d.ts +121 -0
  144. package/dist/core/shell/raterVocabulary.js +116 -0
  145. package/dist/core/shell/raterVocabulary.js.map +1 -0
  146. package/dist/core/shell/rejection.d.ts +69 -0
  147. package/dist/core/shell/rejection.js +38 -0
  148. package/dist/core/shell/rejection.js.map +1 -0
  149. package/dist/core/toolCallRepair/grammar.d.ts +41 -0
  150. package/dist/core/toolCallRepair/grammar.js +116 -0
  151. package/dist/core/toolCallRepair/grammar.js.map +1 -0
  152. package/dist/core/toolCallRepair/index.d.ts +2 -0
  153. package/dist/core/toolCallRepair/index.js +7 -0
  154. package/dist/core/toolCallRepair/index.js.map +1 -0
  155. package/dist/core/toolCallRepair/payload.d.ts +36 -0
  156. package/dist/core/toolCallRepair/payload.js +341 -0
  157. package/dist/core/toolCallRepair/payload.js.map +1 -0
  158. package/dist/core/toolCallRepair/promote.d.ts +45 -0
  159. package/dist/core/toolCallRepair/promote.js +90 -0
  160. package/dist/core/toolCallRepair/promote.js.map +1 -0
  161. package/dist/core/toolDisplay.d.ts +123 -0
  162. package/dist/core/toolDisplay.js +451 -0
  163. package/dist/core/toolDisplay.js.map +1 -0
  164. package/dist/core/toolOutputChannel.d.ts +95 -0
  165. package/dist/core/toolOutputChannel.js +165 -0
  166. package/dist/core/toolOutputChannel.js.map +1 -0
  167. package/dist/core/types.d.ts +349 -16
  168. package/dist/core/types.js.map +1 -1
  169. package/dist/history/historyFormat.d.ts +12 -3
  170. package/dist/history/historyFormat.js +50 -8
  171. package/dist/history/historyFormat.js.map +1 -1
  172. package/dist/history/historyStore.d.ts +77 -0
  173. package/dist/history/historyStore.js +173 -6
  174. package/dist/history/historyStore.js.map +1 -1
  175. package/dist/history/recordSession.d.ts +10 -1
  176. package/dist/history/recordSession.js +27 -0
  177. package/dist/history/recordSession.js.map +1 -1
  178. package/dist/providers/anthropic.js +12 -0
  179. package/dist/providers/anthropic.js.map +1 -1
  180. package/dist/providers/configurationPassthrough.d.ts +107 -0
  181. package/dist/providers/configurationPassthrough.js +148 -0
  182. package/dist/providers/configurationPassthrough.js.map +1 -0
  183. package/dist/providers/geminiSchemaSanitizer.d.ts +55 -0
  184. package/dist/providers/geminiSchemaSanitizer.js +347 -0
  185. package/dist/providers/geminiSchemaSanitizer.js.map +1 -0
  186. package/dist/providers/geminiThinking.d.ts +60 -0
  187. package/dist/providers/geminiThinking.js +92 -0
  188. package/dist/providers/geminiThinking.js.map +1 -0
  189. package/dist/providers/google-genai.js +18 -1
  190. package/dist/providers/google-genai.js.map +1 -1
  191. package/dist/providers/groq.js +12 -0
  192. package/dist/providers/groq.js.map +1 -1
  193. package/dist/providers/huggingface.d.ts +25 -0
  194. package/dist/providers/huggingface.js +69 -0
  195. package/dist/providers/huggingface.js.map +1 -0
  196. package/dist/providers/modelCatalog.d.ts +109 -0
  197. package/dist/providers/modelCatalog.js +245 -0
  198. package/dist/providers/modelCatalog.js.map +1 -0
  199. package/dist/providers/modelDiscovery.d.ts +99 -5
  200. package/dist/providers/modelDiscovery.js +191 -35
  201. package/dist/providers/modelDiscovery.js.map +1 -1
  202. package/dist/providers/ollama.d.ts +18 -4
  203. package/dist/providers/ollama.js +67 -37
  204. package/dist/providers/ollama.js.map +1 -1
  205. package/dist/providers/openai.js +34 -0
  206. package/dist/providers/openai.js.map +1 -1
  207. package/dist/providers/openrouter.d.ts +26 -4
  208. package/dist/providers/openrouter.js +83 -26
  209. package/dist/providers/openrouter.js.map +1 -1
  210. package/dist/providers/vertexai.js +19 -1
  211. package/dist/providers/vertexai.js.map +1 -1
  212. package/dist/providers/xai.js +20 -0
  213. package/dist/providers/xai.js.map +1 -1
  214. package/dist/runtime/askStructured.d.ts +105 -0
  215. package/dist/runtime/askStructured.js +120 -0
  216. package/dist/runtime/askStructured.js.map +1 -0
  217. package/dist/runtime/conversation.d.ts +64 -0
  218. package/dist/runtime/conversation.js +171 -0
  219. package/dist/runtime/conversation.js.map +1 -0
  220. package/dist/runtime/singleShot.d.ts +37 -6
  221. package/dist/runtime/singleShot.js +113 -67
  222. package/dist/runtime/singleShot.js.map +1 -1
  223. package/dist/runtime/structuredOutput.d.ts +104 -0
  224. package/dist/runtime/structuredOutput.js +393 -0
  225. package/dist/runtime/structuredOutput.js.map +1 -0
  226. package/dist/utils/ProgressIndicator.d.ts +21 -0
  227. package/dist/utils/ProgressIndicator.js +30 -3
  228. package/dist/utils/ProgressIndicator.js.map +1 -1
  229. package/dist/utils/aiignoreUtils.js.map +1 -1
  230. package/dist/utils/binaryOutputUtils.js.map +1 -1
  231. package/dist/utils/consoleUtils.d.ts +95 -0
  232. package/dist/utils/consoleUtils.js +112 -2
  233. package/dist/utils/consoleUtils.js.map +1 -1
  234. package/dist/utils/crashHandler.d.ts +87 -0
  235. package/dist/utils/crashHandler.js +128 -0
  236. package/dist/utils/crashHandler.js.map +1 -0
  237. package/dist/utils/debugDump.d.ts +134 -0
  238. package/dist/utils/debugDump.js +381 -0
  239. package/dist/utils/debugDump.js.map +1 -0
  240. package/dist/utils/debugUtils.d.ts +13 -4
  241. package/dist/utils/debugUtils.js +36 -13
  242. package/dist/utils/debugUtils.js.map +1 -1
  243. package/dist/utils/displayWidth.d.ts +53 -0
  244. package/dist/utils/displayWidth.js +195 -0
  245. package/dist/utils/displayWidth.js.map +1 -0
  246. package/dist/utils/fileUtils.js.map +1 -1
  247. package/dist/utils/globalConfigUtils.d.ts +14 -2
  248. package/dist/utils/globalConfigUtils.js +22 -4
  249. package/dist/utils/globalConfigUtils.js.map +1 -1
  250. package/dist/utils/llmUtils.d.ts +39 -8
  251. package/dist/utils/llmUtils.js +76 -8
  252. package/dist/utils/llmUtils.js.map +1 -1
  253. package/dist/utils/redactSecrets.d.ts +63 -0
  254. package/dist/utils/redactSecrets.js +286 -0
  255. package/dist/utils/redactSecrets.js.map +1 -0
  256. package/dist/utils/systemPromptNotes.d.ts +222 -0
  257. package/dist/utils/systemPromptNotes.js +338 -0
  258. package/dist/utils/systemPromptNotes.js.map +1 -0
  259. package/dist/utils/systemUtils.d.ts +18 -1
  260. package/dist/utils/systemUtils.js +38 -3
  261. package/dist/utils/systemUtils.js.map +1 -1
  262. package/dist/utils/toolMatching.d.ts +30 -0
  263. package/dist/utils/toolMatching.js +44 -0
  264. package/dist/utils/toolMatching.js.map +1 -0
  265. package/dist/utils/untrustedText.d.ts +86 -0
  266. package/dist/utils/untrustedText.js +101 -0
  267. package/dist/utils/untrustedText.js.map +1 -0
  268. package/package.json +21 -7
  269. package/schema/gsloth-config.schema.json +1921 -326
  270. package/dist/core/shell/allowlist.d.ts +0 -75
  271. package/dist/core/shell/allowlist.js +0 -187
  272. package/dist/core/shell/allowlist.js.map +0 -1
  273. package/dist/core/shell/judge.d.ts +0 -161
  274. package/dist/core/shell/judge.js +0 -261
  275. package/dist/core/shell/judge.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"GthLangChainAgent.js","sourceRoot":"","sources":["../../src/core/GthLangChainAgent.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,cAAc,EACd,cAAc,GACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AACvF,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAM1D;;;;GAIG;AACH,MAAM,OAAO,iBAAkB,SAAQ,gBAAgB;IACrD,KAAK,CAAC,IAAI,CACR,OAA+B,EAC/B,QAAmB,EACnB,YAA8C;QAE9C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,QAAQ,CAAC,+CAA+C,OAAO,IAAI,SAAS,EAAE,CAAC,CAAC;QAEhF,uDAAuD;QACvD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACzD,cAAc,CAAC,kBAAkB,EAAE;YACjC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU;YAClC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY;YACtC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY;YACtC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;SAC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,KAAK;YACL,UAAU;YACV,YAAY;YACZ,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1C,CAAC,CAAC;QACH,QAAQ,CAAC,kCAAkC,CAAC,CAAC;IAC/C,CAAC;CACF"}
@@ -0,0 +1,122 @@
1
+ /**
2
+ * @module core/approvals/annotations
3
+ *
4
+ * EXT-70 (spec §4.7, §4.7.1, §4.7.5) — **the one derivation of a tool call's effective annotation
5
+ * set**, and the only place trust is applied to an annotation. Everything downstream — the §4.7.2
6
+ * table, `hint` entries (§3.1), exposure (§4.7.6), the snapshot a sticky grant records (§4.7.4) —
7
+ * reads what {@link createEffectiveToolAnnotationSource} computes and never re-derives it. A second
8
+ * derivation is how a gate and a display come to disagree about what a tool is.
9
+ *
10
+ * ## Trust is decided by provenance, not by the annotation
11
+ *
12
+ * An annotation we did not write is a **claim, not a credential**: a third-party server's
13
+ * `readOnlyHint=true` exempts it from nothing, because a gate that honours it unconditionally is a
14
+ * gate any server can opt itself out of. So:
15
+ *
16
+ * - **our own tools are trusted** — a `tool` subject is a built-in or a tool the user wired into
17
+ * their own config, and its annotations are read verbatim;
18
+ * - **an MCP server's are trusted per hint**, and only where the user said so in
19
+ * `approvals.mcp` (§9). Per hint, never per server: believing a server's `readOnlyHint` while
20
+ * disbelieving its `openWorldHint` is a coherent position and the common one.
21
+ *
22
+ * Every untrusted hint takes the MCP fail-closed default ({@link MCP_FAIL_CLOSED_ANNOTATIONS}), so
23
+ * **an untrusted server's effective set IS that constant** and its declarations cannot perturb any
24
+ * rule. They begin to matter at the moment the user trusts them — which is also the only moment
25
+ * they could start lying usefully.
26
+ *
27
+ * ## The one derivation on top
28
+ *
29
+ * **Where effective `readOnlyHint` is true, effective `destructiveHint` is false.** That is the MCP
30
+ * schema's own rule that `destructiveHint` is meaningful only when `readOnlyHint == false`, applied
31
+ * once here so no consumer ever reads a hint the specification itself calls meaningless.
32
+ *
33
+ * ## What a trusted annotation can buy
34
+ *
35
+ * A trusted external annotation may only ever bring a tool **up to** what the same annotation
36
+ * grants one of our own — never more. That holds by construction rather than by a rule: both
37
+ * provenances resolve into the same four booleans through this one function, so a fully-trusted
38
+ * server's declaration and a built-in's identical declaration produce identical effective sets, and
39
+ * there is no path by which the external one could produce something the internal one could not.
40
+ */
41
+ import { type McpApprovalsConfig, type ToolAnnotationHint } from '#src/config/shell-policy.js';
42
+ import { type EffectiveToolAnnotationSource } from '#src/core/approvals/matcher.js';
43
+ /**
44
+ * What a tool **declares** about itself: the four MCP `ToolAnnotations` booleans, each optional
45
+ * because a tool that says nothing about a hint is the ordinary case and takes the fail-closed
46
+ * default. Distinct from {@link EffectiveToolAnnotations}, where all four are present, because the
47
+ * gap between *declared* and *effective* is exactly what trust decides.
48
+ */
49
+ export interface DeclaredToolAnnotations {
50
+ readOnlyHint?: boolean;
51
+ destructiveHint?: boolean;
52
+ idempotentHint?: boolean;
53
+ openWorldHint?: boolean;
54
+ }
55
+ /**
56
+ * Where declared annotations come from, split by the provenance that decides their trust.
57
+ *
58
+ * Both members are optional and both may return `undefined` for a tool they do not know, which
59
+ * yields the fail-closed defaults — never "trusted, declaring nothing". An absent lookup is
60
+ * therefore the safe configuration rather than a broken one, and a source built with neither member
61
+ * is exactly the constant fail-closed source.
62
+ */
63
+ export interface DeclaredToolAnnotationLookup {
64
+ /**
65
+ * Our own tools, by tool name. Whatever this returns is trusted **verbatim** — no per-hint
66
+ * filter applies, because we (or the user, in their own config) authored it.
67
+ */
68
+ builtIn?: (name: string) => DeclaredToolAnnotations | undefined;
69
+ /**
70
+ * One MCP server's declaration for one tool, from its `tools/list` response. `server` is the
71
+ * user's own `mcpServers` config key (§4.7.5), which is also the key its trust is looked up
72
+ * under; nothing a server says about its own name ever participates.
73
+ */
74
+ mcp?: (server: string, name: string) => DeclaredToolAnnotations | undefined;
75
+ }
76
+ /** Everything {@link createEffectiveToolAnnotationSource} needs. Both parts optional. */
77
+ export interface EffectiveToolAnnotationOptions {
78
+ /** The resolved `approvals.mcp` block (§9), or `undefined` to trust nothing external. */
79
+ mcp?: McpApprovalsConfig;
80
+ /** The declared-annotation sources. Absent members simply declare nothing. */
81
+ declared?: DeclaredToolAnnotationLookup;
82
+ }
83
+ /**
84
+ * §4.7.1/§9 — the hints the user believes from ONE server, by the user's own config key.
85
+ *
86
+ * **`defaults` applies to servers not named under `servers`.** A server that names itself states
87
+ * its relationship in full, so `{"jira": {}}` trusts nothing however permissive `defaults` is.
88
+ * The alternative — falling back to `defaults` field by field — would mean a server named with an
89
+ * empty body silently inherits trust, and trust by omission is the failure this section exists to
90
+ * prevent.
91
+ *
92
+ * The lookup is an **own-property** one, and that is load-bearing rather than defensive noise.
93
+ * `servers` is a plain user-authored map, so a server key that collides with an `Object.prototype`
94
+ * member (`constructor`, `toString`, `hasOwnProperty`, `valueOf`) would otherwise resolve to the
95
+ * INHERITED value — truthy, so `defaults` is never consulted and that one server silently gets a
96
+ * relationship nobody wrote. Here that lands fail-closed; on the `expose` field [[EXT-73]] adds to
97
+ * this same block it lands fail-OPEN, because an absent `expose` means "expose every tool". A
98
+ * server's identity is the user's own config key (§4.7.5) and every such key must resolve by the
99
+ * same rule.
100
+ *
101
+ * **{@link UNRESOLVED_MCP_SERVER} trusts nothing, whatever `defaults` says.** A call whose server
102
+ * could not be resolved has no identity, so there is no relationship for it to inherit: it is not
103
+ * a server the user declined to name, it is a server nobody can name. Because the sentinel is
104
+ * `z.string().min(1)`-unspellable it can never appear under `servers`, so without this it would
105
+ * fall through to `defaults` and a permissive default would hand an *unattributable* tool the
106
+ * trust its user granted to real, identified ones — believing a tool that claims to be harmless
107
+ * precisely where we cannot say whose claim it is. The guard belongs here, where §4.7.5's "no
108
+ * trust can be granted to it" is asserted, rather than only in whichever lookup happens to run
109
+ * next.
110
+ */
111
+ export declare function trustedAnnotationHints(mcp: McpApprovalsConfig | undefined, server: string): readonly ToolAnnotationHint[];
112
+ /**
113
+ * EXT-70 §4.7.1 — build the {@link EffectiveToolAnnotationSource} the matcher reads a `hint` entry
114
+ * through, from the user's `approvals.mcp` block and whatever declared annotations are available.
115
+ *
116
+ * **It never returns `undefined`.** The contract admits it for a source that genuinely cannot
117
+ * answer, but this one always can: a tool nothing has declared for is not unknown, it is
118
+ * fail-closed — a writer that destroys, is not idempotent and reaches the open world. Answering
119
+ * with that constant is both more useful and no less safe than answering "undecidable", which the
120
+ * matcher would resolve in the same direction anyway.
121
+ */
122
+ export declare function createEffectiveToolAnnotationSource(options?: EffectiveToolAnnotationOptions): EffectiveToolAnnotationSource;
@@ -0,0 +1,137 @@
1
+ /**
2
+ * @module core/approvals/annotations
3
+ *
4
+ * EXT-70 (spec §4.7, §4.7.1, §4.7.5) — **the one derivation of a tool call's effective annotation
5
+ * set**, and the only place trust is applied to an annotation. Everything downstream — the §4.7.2
6
+ * table, `hint` entries (§3.1), exposure (§4.7.6), the snapshot a sticky grant records (§4.7.4) —
7
+ * reads what {@link createEffectiveToolAnnotationSource} computes and never re-derives it. A second
8
+ * derivation is how a gate and a display come to disagree about what a tool is.
9
+ *
10
+ * ## Trust is decided by provenance, not by the annotation
11
+ *
12
+ * An annotation we did not write is a **claim, not a credential**: a third-party server's
13
+ * `readOnlyHint=true` exempts it from nothing, because a gate that honours it unconditionally is a
14
+ * gate any server can opt itself out of. So:
15
+ *
16
+ * - **our own tools are trusted** — a `tool` subject is a built-in or a tool the user wired into
17
+ * their own config, and its annotations are read verbatim;
18
+ * - **an MCP server's are trusted per hint**, and only where the user said so in
19
+ * `approvals.mcp` (§9). Per hint, never per server: believing a server's `readOnlyHint` while
20
+ * disbelieving its `openWorldHint` is a coherent position and the common one.
21
+ *
22
+ * Every untrusted hint takes the MCP fail-closed default ({@link MCP_FAIL_CLOSED_ANNOTATIONS}), so
23
+ * **an untrusted server's effective set IS that constant** and its declarations cannot perturb any
24
+ * rule. They begin to matter at the moment the user trusts them — which is also the only moment
25
+ * they could start lying usefully.
26
+ *
27
+ * ## The one derivation on top
28
+ *
29
+ * **Where effective `readOnlyHint` is true, effective `destructiveHint` is false.** That is the MCP
30
+ * schema's own rule that `destructiveHint` is meaningful only when `readOnlyHint == false`, applied
31
+ * once here so no consumer ever reads a hint the specification itself calls meaningless.
32
+ *
33
+ * ## What a trusted annotation can buy
34
+ *
35
+ * A trusted external annotation may only ever bring a tool **up to** what the same annotation
36
+ * grants one of our own — never more. That holds by construction rather than by a rule: both
37
+ * provenances resolve into the same four booleans through this one function, so a fully-trusted
38
+ * server's declaration and a built-in's identical declaration produce identical effective sets, and
39
+ * there is no path by which the external one could produce something the internal one could not.
40
+ */
41
+ import { TOOL_ANNOTATION_HINTS, } from '#src/config/shell-policy.js';
42
+ import { MCP_FAIL_CLOSED_ANNOTATIONS, } from '#src/core/approvals/matcher.js';
43
+ import { UNRESOLVED_MCP_SERVER } from '#src/core/approvals/mcpSubjects.js';
44
+ /**
45
+ * §4.7.1/§9 — the hints the user believes from ONE server, by the user's own config key.
46
+ *
47
+ * **`defaults` applies to servers not named under `servers`.** A server that names itself states
48
+ * its relationship in full, so `{"jira": {}}` trusts nothing however permissive `defaults` is.
49
+ * The alternative — falling back to `defaults` field by field — would mean a server named with an
50
+ * empty body silently inherits trust, and trust by omission is the failure this section exists to
51
+ * prevent.
52
+ *
53
+ * The lookup is an **own-property** one, and that is load-bearing rather than defensive noise.
54
+ * `servers` is a plain user-authored map, so a server key that collides with an `Object.prototype`
55
+ * member (`constructor`, `toString`, `hasOwnProperty`, `valueOf`) would otherwise resolve to the
56
+ * INHERITED value — truthy, so `defaults` is never consulted and that one server silently gets a
57
+ * relationship nobody wrote. Here that lands fail-closed; on the `expose` field [[EXT-73]] adds to
58
+ * this same block it lands fail-OPEN, because an absent `expose` means "expose every tool". A
59
+ * server's identity is the user's own config key (§4.7.5) and every such key must resolve by the
60
+ * same rule.
61
+ *
62
+ * **{@link UNRESOLVED_MCP_SERVER} trusts nothing, whatever `defaults` says.** A call whose server
63
+ * could not be resolved has no identity, so there is no relationship for it to inherit: it is not
64
+ * a server the user declined to name, it is a server nobody can name. Because the sentinel is
65
+ * `z.string().min(1)`-unspellable it can never appear under `servers`, so without this it would
66
+ * fall through to `defaults` and a permissive default would hand an *unattributable* tool the
67
+ * trust its user granted to real, identified ones — believing a tool that claims to be harmless
68
+ * precisely where we cannot say whose claim it is. The guard belongs here, where §4.7.5's "no
69
+ * trust can be granted to it" is asserted, rather than only in whichever lookup happens to run
70
+ * next.
71
+ */
72
+ export function trustedAnnotationHints(mcp, server) {
73
+ if (server === UNRESOLVED_MCP_SERVER)
74
+ return [];
75
+ const servers = mcp?.servers;
76
+ const named = servers && Object.hasOwn(servers, server) ? servers[server] : undefined;
77
+ const relationship = named ?? mcp?.defaults;
78
+ return relationship?.trustAnnotations ?? [];
79
+ }
80
+ /**
81
+ * §4.7.1 — the derivation that rides on top of every effective set: where `readOnlyHint` is true,
82
+ * `destructiveHint` is false. Applied to BOTH provenances, since it is a statement about the
83
+ * vocabulary rather than about who supplied it.
84
+ */
85
+ function applyReadOnlyDerivation(annotations) {
86
+ return annotations.readOnlyHint ? { ...annotations, destructiveHint: false } : annotations;
87
+ }
88
+ /**
89
+ * Resolve one tool's effective set: each hint independently takes the declared value where that
90
+ * hint is trusted from that provenance, and the MCP fail-closed default everywhere else.
91
+ *
92
+ * A declared value that is not a boolean is treated as not declared — a `tools/list` response is
93
+ * network input, and a string `"true"` must not become a `true` the gate acts on.
94
+ */
95
+ function effectiveAnnotations(declared, trusted) {
96
+ const resolved = { ...MCP_FAIL_CLOSED_ANNOTATIONS };
97
+ if (declared) {
98
+ for (const hint of TOOL_ANNOTATION_HINTS) {
99
+ if (!trusted.has(hint))
100
+ continue;
101
+ const value = declared[hint];
102
+ if (typeof value === 'boolean')
103
+ resolved[hint] = value;
104
+ }
105
+ }
106
+ return applyReadOnlyDerivation(resolved);
107
+ }
108
+ /** Our own tools are trusted on every hint. */
109
+ const ALL_HINTS = new Set(TOOL_ANNOTATION_HINTS);
110
+ /**
111
+ * EXT-70 §4.7.1 — build the {@link EffectiveToolAnnotationSource} the matcher reads a `hint` entry
112
+ * through, from the user's `approvals.mcp` block and whatever declared annotations are available.
113
+ *
114
+ * **It never returns `undefined`.** The contract admits it for a source that genuinely cannot
115
+ * answer, but this one always can: a tool nothing has declared for is not unknown, it is
116
+ * fail-closed — a writer that destroys, is not idempotent and reaches the open world. Answering
117
+ * with that constant is both more useful and no less safe than answering "undecidable", which the
118
+ * matcher would resolve in the same direction anyway.
119
+ */
120
+ export function createEffectiveToolAnnotationSource(options = {}) {
121
+ const { mcp, declared } = options;
122
+ return (subject) => {
123
+ // Both branches are spelled out, and the TRUSTED one is never the fall-through. A trusted path
124
+ // reached by `else` silently widens the moment a third subject kind appears: the new kind would
125
+ // inherit read-everything-verbatim without anyone deciding that it should. The tail below is
126
+ // unreachable while the union has two members, and is what a third one would land on instead.
127
+ if (subject.kind === 'mcpTool') {
128
+ const trusted = new Set(trustedAnnotationHints(mcp, subject.server));
129
+ return effectiveAnnotations(declared?.mcp?.(subject.server, subject.name), trusted);
130
+ }
131
+ if (subject.kind === 'tool') {
132
+ return effectiveAnnotations(declared?.builtIn?.(subject.name), ALL_HINTS);
133
+ }
134
+ return { ...MCP_FAIL_CLOSED_ANNOTATIONS };
135
+ };
136
+ }
137
+ //# sourceMappingURL=annotations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotations.js","sourceRoot":"","sources":["../../../src/core/approvals/annotations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,OAAO,EAEL,qBAAqB,GAEtB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAGL,2BAA2B,GAG5B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AA6C3E;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,sBAAsB,CACpC,GAAmC,EACnC,MAAc;IAEd,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E,GAAG,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAElC,OAAO,CAAC,OAAqD,EAA4B,EAAE;QACzF,+FAA+F;QAC/F,gGAAgG;QAChG,6FAA6F;QAC7F,8FAA8F;QAC9F,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC/B,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,sBAAsB,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;YACrE,OAAO,oBAAoB,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;QACtF,CAAC;QACD,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAC5B,OAAO,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;QAC5E,CAAC;QACD,OAAO,EAAE,GAAG,2BAA2B,EAAE,CAAC;IAC5C,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,216 @@
1
+ import type { ApprovalEntry, McpToolApprovalEntry, ShellApprovalEntry, ToolApprovalEntry, ToolAnnotationHint } from '#src/config/shell-policy.js';
2
+ import type { ShellApprovalGateNotice } from '#src/config/shell-policy.js';
3
+ import { type EffectiveToolAnnotations, type McpToolApprovalSubject, type ToolApprovalSubject } from '#src/core/approvals/matcher.js';
4
+ import { type ToolApprovalScope } from '#src/core/types.js';
5
+ /**
6
+ * The scopes a grant can be REMEMBERED at. `once` is absent by construction: it persists nothing,
7
+ * so it never becomes a grant.
8
+ */
9
+ export type ApprovalGrantScope = Exclude<ToolApprovalScope, 'once'>;
10
+ /**
11
+ * §3 — one thing the human granted: the entry that will be matched, plus what the approvals UI
12
+ * must be able to show about it (*what* was granted, *when*, and *at what scope*).
13
+ *
14
+ * The metadata is display only. The `entry` is the whole of what decides.
15
+ */
16
+ export interface ApprovalGrant {
17
+ /** §3.1 — the entry, in the one grammar. */
18
+ entry: ApprovalEntry;
19
+ /** ISO-8601 instant the grant was made. */
20
+ grantedAt: string;
21
+ /** `session` for the life of this runner instance, `always` for the persisted store. */
22
+ scope: ApprovalGrantScope;
23
+ /**
24
+ * §4.7.4 — **the effective annotation set (§4.7.1) this tool grant was made under**, so a later
25
+ * `tools/list` that weakens it can be seen to have done so ({@link annotationWeakenings}) and the
26
+ * approvals UI can show what the user believed they were granting.
27
+ *
28
+ * Absent on a `shell` grant, which has no annotations, and on a tool grant restored from a file
29
+ * written before this field existed — in both cases there is nothing to compare, so the grant
30
+ * simply stands.
31
+ *
32
+ * **A private copy, always**, made on the way into the store: an effective set is something the
33
+ * source may hand out afresh or a caller may hold, and a snapshot that aliased either would let
34
+ * one grant's record be rewritten by something outside it — which is the same class of bug as a
35
+ * source returning the shared fail-closed constant instead of a copy.
36
+ */
37
+ annotations?: EffectiveToolAnnotations;
38
+ }
39
+ /**
40
+ * §3.1/§6 — the entry the escalation menu writes for a shell command: **that command, and only
41
+ * that command**.
42
+ *
43
+ * The single place a menu grant's entry is built, so the line the prompt shows the human ("this is
44
+ * what will be stored") and the line that lands in the store cannot drift apart.
45
+ */
46
+ export declare function shellGrantEntry(command: string): ShellApprovalEntry;
47
+ /**
48
+ * §4.7.4/§6 — the entry the escalation menu writes for a **tool** call: the tool's identity, plus
49
+ * the host where the call carries one.
50
+ *
51
+ * The counterpart of {@link shellGrantEntry} and the single place a tool grant's entry is built, so
52
+ * the line the prompt shows the human and the line that lands in the store cannot drift apart.
53
+ *
54
+ * **Identity, never arguments.** A grant recording a full argument signature would never match a
55
+ * second time — not a narrower grant, a useless one. That is knowingly broader than the shell's
56
+ * exact-command grant, with one bound: on the shell path §4.6's escape carries the host inside the
57
+ * command string, so it is host-scoped by construction, while a tool-identity-only grant on a fetch
58
+ * tool would be every host, forever.
59
+ *
60
+ * `server` on an `mcpTool` grant is the user's own `mcpServers` config key (§4.7.5). Nothing a
61
+ * server declares about its own name participates, and a grant for one server's tool can never be
62
+ * claimed by another server's same-named tool because the other server sits under a different key.
63
+ *
64
+ * **Returns `null` for a call whose server could not be resolved.** {@link UNRESOLVED_MCP_SERVER}
65
+ * is the empty string, which `server` (`z.string().min(1)`) cannot hold: such an entry would be
66
+ * written to the file and then silently dropped by the grammar's own validator on the next read, so
67
+ * the human would be told their approval was remembered when it was not. A call nobody can attribute
68
+ * to a server is not one anything can remember.
69
+ */
70
+ export declare function toolGrantEntry(subject: ToolApprovalSubject | McpToolApprovalSubject): ToolApprovalEntry | McpToolApprovalEntry | null;
71
+ /**
72
+ * §4.7.4 — which hints moved in the weakening direction between the set a grant was made under and
73
+ * the set that holds now. Empty means the grant still stands.
74
+ *
75
+ * **Only the four booleans are compared, so schema and description changes invalidate nothing** —
76
+ * not by a rule that exempts them, but because a snapshot is four booleans and a description is not
77
+ * one of them. Descriptions churn on every server release, and a grant that dissolved on churn
78
+ * would teach users that grants are worthless.
79
+ *
80
+ * **An untrusted server's declaration change likewise invalidates nothing**, again by construction:
81
+ * §4.7.1 makes an untrusted server's effective set the constant fail-closed default, so both sides
82
+ * of this comparison are that constant however the server re-declares itself. Only a **trusted**
83
+ * server can move an effective value — which is exactly where invalidation matters, since the
84
+ * trusted server is the one whose rug-pull would otherwise ride an existing grant.
85
+ */
86
+ export declare function annotationWeakenings(snapshot: EffectiveToolAnnotations, current: EffectiveToolAnnotations): ToolAnnotationHint[];
87
+ /**
88
+ * §4.7.1/§4.7.4 — **can WITHDRAWING trust in this hint weaken an effective set?**
89
+ *
90
+ * Withdrawing trust pushes a hint back to its MCP fail-closed default, and every weakening move
91
+ * *ends* at that default, so the answer does not depend on what a server declared: it is exactly
92
+ * whether the move (not-the-default → the default) is one of {@link WEAKENING_MOVES}. Three of the
93
+ * four hints answer yes — `readOnlyHint`, `openWorldHint` and `destructiveHint`, whose fail-closed
94
+ * default is `true`, so a server whose `destructiveHint: false` was believed becomes destructive
95
+ * again the moment it is not. `idempotentHint` is the only one that answers no, because no
96
+ * weakening move names it.
97
+ *
98
+ * **It asks {@link annotationWeakenings} rather than restating the table.** A second statement of
99
+ * which moves weaken is how a warning comes to describe a rule the gate no longer has — which
100
+ * matters most here, since this decides whether the human is told their saved approvals are about
101
+ * to be withdrawn.
102
+ */
103
+ export declare function trustWithdrawalWeakens(hint: ToolAnnotationHint): boolean;
104
+ /**
105
+ * §4.7.4 — the notice a weakened grant is removed with. **It names the tool, the server and the
106
+ * hint that moved**, because the human approved a tool *as annotated*: a tool that re-annotates
107
+ * itself into a more dangerous shape is a different proposition wearing the same name, and a notice
108
+ * that did not say which name changed would be indistinguishable from the gate malfunctioning.
109
+ *
110
+ * It takes the **entry** rather than the call's subject, so it describes the grant that was actually
111
+ * withdrawn — including its host bound, where it had one. One call may withdraw both a host-bound
112
+ * grant and a tool-only one, and two notices that could not be told apart would be worse than one.
113
+ * The entry is rendered by {@link describeApprovalEntry}, the same one-liner every other provenance
114
+ * message uses.
115
+ */
116
+ export declare function describeWeakenedGrant(entry: ApprovalEntry, weakened: readonly ToolAnnotationHint[], snapshot: EffectiveToolAnnotations, current: EffectiveToolAnnotations): string;
117
+ /**
118
+ * A set of grants with entry-identity semantics. Pure data + membership: it holds what the human
119
+ * granted and answers *is this the same grant*, never *does this grant cover that command*.
120
+ */
121
+ export declare class ApprovalGrantStore {
122
+ private readonly grants;
123
+ constructor(initial?: readonly ApprovalGrant[]);
124
+ /**
125
+ * Add a grant. Returns whether it was new — an identical entry is not stored twice.
126
+ *
127
+ * The {@link ApprovalGrant.annotations} snapshot is **copied on the way in**, so what the store
128
+ * holds is private to this grant whatever the caller passed: the effective set may be a live
129
+ * object the caller keeps, or (were a source ever to regress) the shared fail-closed constant, and
130
+ * a store aliasing either would let one grant's record be rewritten from outside it. Copying here
131
+ * rather than at each call site makes that structural instead of a habit every caller must keep.
132
+ */
133
+ add(grant: ApprovalGrant): boolean;
134
+ /**
135
+ * The grant stored under this entry's identity, or `undefined`.
136
+ *
137
+ * **Identity, never a match decision** — the same de-duplication question {@link add} asks. It
138
+ * answers *"is this the same grant"*, and whether a grant covers a call remains
139
+ * `resolveApprovalRules`'s alone.
140
+ */
141
+ find(entry: ApprovalEntry): ApprovalGrant | undefined;
142
+ /**
143
+ * Drop the grant stored under this entry's identity. Returns whether one was there.
144
+ *
145
+ * §4.7.4's invalidation is a **removal** rather than a skip, and that is load-bearing: {@link add}
146
+ * de-duplicates by entry identity, so a grant left in place while being ignored would silently
147
+ * swallow the human's re-approval of the same tool — the grant would appear to be re-made and the
148
+ * stale snapshot would keep invalidating it.
149
+ */
150
+ remove(entry: ApprovalEntry): boolean;
151
+ /** Every grant, in the order they were made. */
152
+ list(): ApprovalGrant[];
153
+ /** Just the entries, for handing to the matcher as one of its rule lists. */
154
+ entries(): ApprovalEntry[];
155
+ /** How many grants are held. */
156
+ size(): number;
157
+ }
158
+ /** Optional seams for {@link PersistedApprovalGrants}. */
159
+ export interface PersistedApprovalGrantsOptions {
160
+ /**
161
+ * Where the v1→v2 migration notice goes — the established {@link ShellApprovalGateNotice} shape
162
+ * the runner forwards to `statusUpdate`. Absent means the migration happens silently, which is
163
+ * why the runner always passes one.
164
+ */
165
+ onNotice?: (notice: ShellApprovalGateNotice) => void;
166
+ }
167
+ /**
168
+ * The persisted (`always`) grant store, backed by a JSON file whose path is injected (the runner
169
+ * resolves it via fileUtils → `.gsloth/.gsloth-settings/shell-allowlist.json`) so tests can point it
170
+ * at a temp dir.
171
+ *
172
+ * ## The v1 migration, and the direction it goes
173
+ *
174
+ * The shipped v1 file held `prefixes: string[]` — classified command PREFIXES, so a stored
175
+ * `npm test` also auto-approved `npm test --watch`. Each prefix migrates to an **`exact` entry for
176
+ * the same string**, with **one** notice naming the file.
177
+ *
178
+ * That narrows what the file grants, on purpose: a v1 prefix was broader than what the human was
179
+ * actually shown when they answered the prompt, so narrowing it costs at worst a re-prompt and
180
+ * never an execution — the direction every ambiguity in this design resolves. The migrated file is
181
+ * rewritten as v2 immediately, so the notice is a one-time event rather than a per-session one; a
182
+ * write that fails (read-only checkout) is not fatal — the grants are in force for this session and
183
+ * the notice simply appears again next time.
184
+ */
185
+ export declare class PersistedApprovalGrants {
186
+ private readonly store;
187
+ private readonly filePath;
188
+ constructor(filePath: string, options?: PersistedApprovalGrantsOptions);
189
+ private static load;
190
+ /** Each v1 prefix → an `exact` entry for the same string, with ONE notice naming the file. */
191
+ private static migrateFromV1;
192
+ /** Every grant. */
193
+ list(): ApprovalGrant[];
194
+ /** Just the entries, for handing to the matcher as one of its rule lists. */
195
+ entries(): ApprovalEntry[];
196
+ /** How many grants are persisted. */
197
+ size(): number;
198
+ /** Add a grant and persist the whole store. A duplicate entry rewrites nothing. */
199
+ add(grant: ApprovalGrant): void;
200
+ /** The grant held under this entry's identity, or `undefined`. */
201
+ find(entry: ApprovalEntry): ApprovalGrant | undefined;
202
+ /**
203
+ * Drop the grant held under this entry's identity and rewrite the file. Returns whether one was
204
+ * there.
205
+ *
206
+ * The write is what makes §4.7.4's invalidation a one-time event: a removal held only in memory
207
+ * would be undone by the next session reloading the same stale snapshot, so the user would be
208
+ * told their grant had been withdrawn once per session, forever.
209
+ */
210
+ remove(entry: ApprovalEntry): boolean;
211
+ /**
212
+ * Write the file. Never throws: the grants are already in force for this session, and a
213
+ * read-only checkout must not end a run over a bookkeeping write.
214
+ */
215
+ private tryPersist;
216
+ }