scoutline 0.1.0 → 0.6.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 (242) hide show
  1. package/README.md +394 -7
  2. package/bin/scoutline.js +36 -15
  3. package/dist/capabilities/diagnostics.d.ts +135 -0
  4. package/dist/capabilities/diagnostics.d.ts.map +1 -0
  5. package/dist/capabilities/diagnostics.js +139 -0
  6. package/dist/capabilities/diagnostics.js.map +1 -0
  7. package/dist/capabilities/quota.d.ts +99 -0
  8. package/dist/capabilities/quota.d.ts.map +1 -0
  9. package/dist/capabilities/quota.js +129 -0
  10. package/dist/capabilities/quota.js.map +1 -0
  11. package/dist/capabilities/reader.d.ts +227 -0
  12. package/dist/capabilities/reader.d.ts.map +1 -0
  13. package/dist/capabilities/reader.js +100 -0
  14. package/dist/capabilities/reader.js.map +1 -0
  15. package/dist/capabilities/repository.d.ts +221 -0
  16. package/dist/capabilities/repository.d.ts.map +1 -0
  17. package/dist/capabilities/repository.js +172 -0
  18. package/dist/capabilities/repository.js.map +1 -0
  19. package/dist/capabilities/search.d.ts +110 -0
  20. package/dist/capabilities/search.d.ts.map +1 -0
  21. package/dist/capabilities/search.js +21 -0
  22. package/dist/capabilities/search.js.map +1 -0
  23. package/dist/capabilities/vision.d.ts +156 -0
  24. package/dist/capabilities/vision.d.ts.map +1 -0
  25. package/dist/capabilities/vision.js +111 -0
  26. package/dist/capabilities/vision.js.map +1 -0
  27. package/dist/command-invocation.d.ts +58 -0
  28. package/dist/command-invocation.d.ts.map +1 -0
  29. package/dist/command-invocation.js +95 -0
  30. package/dist/command-invocation.js.map +1 -0
  31. package/dist/commands/cache.d.ts +106 -0
  32. package/dist/commands/cache.d.ts.map +1 -0
  33. package/dist/commands/cache.js +203 -0
  34. package/dist/commands/cache.js.map +1 -0
  35. package/dist/commands/code.d.ts +11 -4
  36. package/dist/commands/code.d.ts.map +1 -1
  37. package/dist/commands/code.js +16 -42
  38. package/dist/commands/code.js.map +1 -1
  39. package/dist/commands/doctor.d.ts +69 -3
  40. package/dist/commands/doctor.d.ts.map +1 -1
  41. package/dist/commands/doctor.js +179 -52
  42. package/dist/commands/doctor.js.map +1 -1
  43. package/dist/commands/quota.d.ts +45 -3
  44. package/dist/commands/quota.d.ts.map +1 -1
  45. package/dist/commands/quota.js +116 -60
  46. package/dist/commands/quota.js.map +1 -1
  47. package/dist/commands/read.d.ts +76 -2
  48. package/dist/commands/read.d.ts.map +1 -1
  49. package/dist/commands/read.js +260 -121
  50. package/dist/commands/read.js.map +1 -1
  51. package/dist/commands/repo.d.ts +55 -4
  52. package/dist/commands/repo.d.ts.map +1 -1
  53. package/dist/commands/repo.js +115 -172
  54. package/dist/commands/repo.js.map +1 -1
  55. package/dist/commands/repository-explorer.d.ts +147 -0
  56. package/dist/commands/repository-explorer.d.ts.map +1 -0
  57. package/dist/commands/repository-explorer.js +550 -0
  58. package/dist/commands/repository-explorer.js.map +1 -0
  59. package/dist/commands/search.d.ts +27 -2
  60. package/dist/commands/search.d.ts.map +1 -1
  61. package/dist/commands/search.js +95 -103
  62. package/dist/commands/search.js.map +1 -1
  63. package/dist/commands/tools.d.ts +9 -3
  64. package/dist/commands/tools.d.ts.map +1 -1
  65. package/dist/commands/tools.js +29 -59
  66. package/dist/commands/tools.js.map +1 -1
  67. package/dist/commands/vision.d.ts +35 -9
  68. package/dist/commands/vision.d.ts.map +1 -1
  69. package/dist/commands/vision.js +184 -131
  70. package/dist/commands/vision.js.map +1 -1
  71. package/dist/index.d.ts +62 -1
  72. package/dist/index.d.ts.map +1 -1
  73. package/dist/index.js +580 -223
  74. package/dist/index.js.map +1 -1
  75. package/dist/lib/cache.d.ts +178 -12
  76. package/dist/lib/cache.d.ts.map +1 -1
  77. package/dist/lib/cache.js +377 -39
  78. package/dist/lib/cache.js.map +1 -1
  79. package/dist/lib/code-mode.d.ts +13 -0
  80. package/dist/lib/code-mode.d.ts.map +1 -1
  81. package/dist/lib/code-mode.js +26 -6
  82. package/dist/lib/code-mode.js.map +1 -1
  83. package/dist/lib/config.d.ts.map +1 -1
  84. package/dist/lib/config.js +15 -18
  85. package/dist/lib/config.js.map +1 -1
  86. package/dist/lib/errors.d.ts +89 -11
  87. package/dist/lib/errors.d.ts.map +1 -1
  88. package/dist/lib/errors.js +168 -21
  89. package/dist/lib/errors.js.map +1 -1
  90. package/dist/lib/execution.d.ts +190 -0
  91. package/dist/lib/execution.d.ts.map +1 -0
  92. package/dist/lib/execution.js +383 -0
  93. package/dist/lib/execution.js.map +1 -0
  94. package/dist/lib/index.d.ts +10 -2
  95. package/dist/lib/index.d.ts.map +1 -1
  96. package/dist/lib/index.js +10 -2
  97. package/dist/lib/index.js.map +1 -1
  98. package/dist/lib/mcp-client.d.ts +75 -16
  99. package/dist/lib/mcp-client.d.ts.map +1 -1
  100. package/dist/lib/mcp-client.js +173 -108
  101. package/dist/lib/mcp-client.js.map +1 -1
  102. package/dist/lib/mcp-config.d.ts +17 -0
  103. package/dist/lib/mcp-config.d.ts.map +1 -1
  104. package/dist/lib/mcp-config.js +29 -0
  105. package/dist/lib/mcp-config.js.map +1 -1
  106. package/dist/lib/monitor-client.d.ts +17 -3
  107. package/dist/lib/monitor-client.d.ts.map +1 -1
  108. package/dist/lib/monitor-client.js +23 -69
  109. package/dist/lib/monitor-client.js.map +1 -1
  110. package/dist/lib/output.d.ts +53 -7
  111. package/dist/lib/output.d.ts.map +1 -1
  112. package/dist/lib/output.js +126 -39
  113. package/dist/lib/output.js.map +1 -1
  114. package/dist/lib/redact.d.ts +62 -3
  115. package/dist/lib/redact.d.ts.map +1 -1
  116. package/dist/lib/redact.js +165 -31
  117. package/dist/lib/redact.js.map +1 -1
  118. package/dist/lib/tool-cache.d.ts +86 -0
  119. package/dist/lib/tool-cache.d.ts.map +1 -0
  120. package/dist/lib/tool-cache.js +123 -0
  121. package/dist/lib/tool-cache.js.map +1 -0
  122. package/dist/lib/tty.d.ts +7 -20
  123. package/dist/lib/tty.d.ts.map +1 -1
  124. package/dist/lib/tty.js +51 -30
  125. package/dist/lib/tty.js.map +1 -1
  126. package/dist/node-command-invocation-adapter.d.ts +28 -0
  127. package/dist/node-command-invocation-adapter.d.ts.map +1 -0
  128. package/dist/node-command-invocation-adapter.js +88 -0
  129. package/dist/node-command-invocation-adapter.js.map +1 -0
  130. package/dist/providers/minimax/adapter.d.ts +49 -0
  131. package/dist/providers/minimax/adapter.d.ts.map +1 -0
  132. package/dist/providers/minimax/adapter.js +450 -0
  133. package/dist/providers/minimax/adapter.js.map +1 -0
  134. package/dist/providers/minimax/coding-plan-client.d.ts +60 -0
  135. package/dist/providers/minimax/coding-plan-client.d.ts.map +1 -0
  136. package/dist/providers/minimax/coding-plan-client.js +204 -0
  137. package/dist/providers/minimax/coding-plan-client.js.map +1 -0
  138. package/dist/providers/minimax/config.d.ts +32 -0
  139. package/dist/providers/minimax/config.d.ts.map +1 -0
  140. package/dist/providers/minimax/config.js +84 -0
  141. package/dist/providers/minimax/config.js.map +1 -0
  142. package/dist/providers/minimax/media.d.ts +88 -0
  143. package/dist/providers/minimax/media.d.ts.map +1 -0
  144. package/dist/providers/minimax/media.js +232 -0
  145. package/dist/providers/minimax/media.js.map +1 -0
  146. package/dist/providers/minimax/quota-client.d.ts +44 -0
  147. package/dist/providers/minimax/quota-client.d.ts.map +1 -0
  148. package/dist/providers/minimax/quota-client.js +83 -0
  149. package/dist/providers/minimax/quota-client.js.map +1 -0
  150. package/dist/providers/minimax/quota.d.ts +48 -0
  151. package/dist/providers/minimax/quota.d.ts.map +1 -0
  152. package/dist/providers/minimax/quota.js +120 -0
  153. package/dist/providers/minimax/quota.js.map +1 -0
  154. package/dist/providers/minimax/sdk-client.d.ts +29 -0
  155. package/dist/providers/minimax/sdk-client.d.ts.map +1 -0
  156. package/dist/providers/minimax/sdk-client.js +50 -0
  157. package/dist/providers/minimax/sdk-client.js.map +1 -0
  158. package/dist/providers/minimax/vision-attestations.d.ts +52 -0
  159. package/dist/providers/minimax/vision-attestations.d.ts.map +1 -0
  160. package/dist/providers/minimax/vision-attestations.js +79 -0
  161. package/dist/providers/minimax/vision-attestations.js.map +1 -0
  162. package/dist/providers/minimax/vision-conformance.d.ts +186 -0
  163. package/dist/providers/minimax/vision-conformance.d.ts.map +1 -0
  164. package/dist/providers/minimax/vision-conformance.js +371 -0
  165. package/dist/providers/minimax/vision-conformance.js.map +1 -0
  166. package/dist/providers/minimax/vision-mappings/chart.d.ts +35 -0
  167. package/dist/providers/minimax/vision-mappings/chart.d.ts.map +1 -0
  168. package/dist/providers/minimax/vision-mappings/chart.js +55 -0
  169. package/dist/providers/minimax/vision-mappings/chart.js.map +1 -0
  170. package/dist/providers/minimax/vision-mappings/common.d.ts +60 -0
  171. package/dist/providers/minimax/vision-mappings/common.d.ts.map +1 -0
  172. package/dist/providers/minimax/vision-mappings/common.js +75 -0
  173. package/dist/providers/minimax/vision-mappings/common.js.map +1 -0
  174. package/dist/providers/minimax/vision-mappings/diagnose-error.d.ts +35 -0
  175. package/dist/providers/minimax/vision-mappings/diagnose-error.d.ts.map +1 -0
  176. package/dist/providers/minimax/vision-mappings/diagnose-error.js +55 -0
  177. package/dist/providers/minimax/vision-mappings/diagnose-error.js.map +1 -0
  178. package/dist/providers/minimax/vision-mappings/diagram.d.ts +35 -0
  179. package/dist/providers/minimax/vision-mappings/diagram.d.ts.map +1 -0
  180. package/dist/providers/minimax/vision-mappings/diagram.js +55 -0
  181. package/dist/providers/minimax/vision-mappings/diagram.js.map +1 -0
  182. package/dist/providers/minimax/vision-mappings/extract-text.d.ts +35 -0
  183. package/dist/providers/minimax/vision-mappings/extract-text.d.ts.map +1 -0
  184. package/dist/providers/minimax/vision-mappings/extract-text.js +55 -0
  185. package/dist/providers/minimax/vision-mappings/extract-text.js.map +1 -0
  186. package/dist/providers/minimax/vision-mappings/ui-artifact.d.ts +35 -0
  187. package/dist/providers/minimax/vision-mappings/ui-artifact.d.ts.map +1 -0
  188. package/dist/providers/minimax/vision-mappings/ui-artifact.js +69 -0
  189. package/dist/providers/minimax/vision-mappings/ui-artifact.js.map +1 -0
  190. package/dist/providers/minimax/vision-mappings.generated.d.ts +29 -0
  191. package/dist/providers/minimax/vision-mappings.generated.d.ts.map +1 -0
  192. package/dist/providers/minimax/vision-mappings.generated.js +29 -0
  193. package/dist/providers/minimax/vision-mappings.generated.js.map +1 -0
  194. package/dist/providers/minimax/vision-revisions.d.ts +29 -0
  195. package/dist/providers/minimax/vision-revisions.d.ts.map +1 -0
  196. package/dist/providers/minimax/vision-revisions.js +34 -0
  197. package/dist/providers/minimax/vision-revisions.js.map +1 -0
  198. package/dist/providers/registry.d.ts +36 -0
  199. package/dist/providers/registry.d.ts.map +1 -0
  200. package/dist/providers/registry.js +45 -0
  201. package/dist/providers/registry.js.map +1 -0
  202. package/dist/providers/selection.d.ts +44 -0
  203. package/dist/providers/selection.d.ts.map +1 -0
  204. package/dist/providers/selection.js +85 -0
  205. package/dist/providers/selection.js.map +1 -0
  206. package/dist/providers/types.d.ts +281 -0
  207. package/dist/providers/types.d.ts.map +1 -0
  208. package/dist/providers/types.js +127 -0
  209. package/dist/providers/types.js.map +1 -0
  210. package/dist/providers/zai/adapter.d.ts +35 -0
  211. package/dist/providers/zai/adapter.d.ts.map +1 -0
  212. package/dist/providers/zai/adapter.js +685 -0
  213. package/dist/providers/zai/adapter.js.map +1 -0
  214. package/dist/providers/zai/credentials.d.ts +38 -0
  215. package/dist/providers/zai/credentials.d.ts.map +1 -0
  216. package/dist/providers/zai/credentials.js +60 -0
  217. package/dist/providers/zai/credentials.js.map +1 -0
  218. package/dist/providers/zai/encoded-error.d.ts +90 -0
  219. package/dist/providers/zai/encoded-error.d.ts.map +1 -0
  220. package/dist/providers/zai/encoded-error.js +169 -0
  221. package/dist/providers/zai/encoded-error.js.map +1 -0
  222. package/dist/providers/zai/media.d.ts +38 -0
  223. package/dist/providers/zai/media.d.ts.map +1 -0
  224. package/dist/providers/zai/media.js +107 -0
  225. package/dist/providers/zai/media.js.map +1 -0
  226. package/dist/providers/zai/monitor-client.d.ts +53 -0
  227. package/dist/providers/zai/monitor-client.d.ts.map +1 -0
  228. package/dist/providers/zai/monitor-client.js +117 -0
  229. package/dist/providers/zai/monitor-client.js.map +1 -0
  230. package/dist/providers/zai/quota.d.ts +47 -0
  231. package/dist/providers/zai/quota.d.ts.map +1 -0
  232. package/dist/providers/zai/quota.js +127 -0
  233. package/dist/providers/zai/quota.js.map +1 -0
  234. package/dist/providers/zai/reader.d.ts +82 -0
  235. package/dist/providers/zai/reader.d.ts.map +1 -0
  236. package/dist/providers/zai/reader.js +490 -0
  237. package/dist/providers/zai/reader.js.map +1 -0
  238. package/dist/providers/zai/repository.d.ts +76 -0
  239. package/dist/providers/zai/repository.d.ts.map +1 -0
  240. package/dist/providers/zai/repository.js +715 -0
  241. package/dist/providers/zai/repository.js.map +1 -0
  242. package/package.json +11 -6
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Provider Vision Capability (DESIGN.md §8, PRD FR-020, FR-022 to FR-026,
3
+ * FR-050, NFR-004, NFR-006).
4
+ *
5
+ * Defines the normalized Vision Capability shared by every Provider that
6
+ * supports single-image interpretation. Commands pass a `VisionRequest`
7
+ * (a discriminated union over the eight operation shapes) and the
8
+ * shared `invokeVision` helper:
9
+ *
10
+ * 1. Maps the operation to a stable `vision.<operation>` Capability id.
11
+ * 2. Reads descriptor-level capability metadata (pure; no Adapter
12
+ * construction). If the descriptor does not advertise the
13
+ * Capability, throws `UnsupportedCapabilityError(provider, ...)`
14
+ * BEFORE `descriptor.create()` is called. No credentials, no media,
15
+ * no transport, no cache, no fallback Adapter are observed.
16
+ * 3. Calls `descriptor.create(context)` and defensively double-checks
17
+ * the Adapter's `supports(operation)`. If the Adapter says no,
18
+ * throws the same error before `invoke` runs.
19
+ * 4. Calls `adapter.vision.invoke(request)` and returns the normalized
20
+ * text. Vision never uses the response cache and never falls back
21
+ * to another Provider.
22
+ *
23
+ * This module imports no Provider transport and no Provider Adapter.
24
+ * The error class import below is from `lib/errors.ts` (a shared error
25
+ * contract, not Provider transport), which is the existing boundary
26
+ * pattern for the Search Capability Module. The retry wrapper lives
27
+ * above `invokeVision` and passes a `() => Promise<string>` closure so
28
+ * Vision can be invoked through `executeProviderOperation("vision",
29
+ * ...)` (DESIGN.md §10) without coupling this file to that contract.
30
+ *
31
+ * P3-01 introduces only the contract + the early-fail ordering proof.
32
+ * Real Z.AI and MiniMax `vision` Adapters arrive in P3-03; the
33
+ * built-in descriptor factories in `providers/types.ts` advertise
34
+ * `vision.<operation>` Capability metadata now so the support check is
35
+ * wired through descriptor metadata from the start.
36
+ */
37
+ /**
38
+ * A Provider-neutral Vision request. Commands construct one of these
39
+ * shapes from their semantic arguments; Adapters map them to the
40
+ * Provider's transport shape. Adding a new operation requires extending
41
+ * this union, the `ProviderCapability` union in `providers/types.ts`,
42
+ * and the `ALL_VISION_OPERATIONS` set below.
43
+ */
44
+ export type VisionRequest = {
45
+ operation: "interpret-image";
46
+ source: string;
47
+ instruction: string;
48
+ } | {
49
+ operation: "ui-artifact";
50
+ source: string;
51
+ instruction: string;
52
+ outputType: "code" | "prompt" | "spec" | "description";
53
+ } | {
54
+ operation: "extract-text";
55
+ source: string;
56
+ instruction: string;
57
+ programmingLanguage?: string;
58
+ } | {
59
+ operation: "diagnose-error";
60
+ source: string;
61
+ instruction: string;
62
+ context?: string;
63
+ } | {
64
+ operation: "diagram";
65
+ source: string;
66
+ instruction: string;
67
+ diagramType?: string;
68
+ } | {
69
+ operation: "chart";
70
+ source: string;
71
+ instruction: string;
72
+ focus?: string;
73
+ } | {
74
+ operation: "diff";
75
+ expectedSource: string;
76
+ actualSource: string;
77
+ instruction: string;
78
+ } | {
79
+ operation: "video";
80
+ source: string;
81
+ instruction: string;
82
+ };
83
+ /** Convenience: the set of every supported operation. */
84
+ export type VisionOperation = VisionRequest["operation"];
85
+ /** Every operation that exists in the discriminated union. */
86
+ export declare const ALL_VISION_OPERATIONS: ReadonlySet<VisionOperation>;
87
+ /**
88
+ * Stable Capability id for a Vision operation. Each id matches a member
89
+ * of the `ProviderCapability` union declared in `providers/types.ts`.
90
+ * This mapping is the single source of truth: Adapters advertise the id;
91
+ * `invokeVision` reads it; commands never branch on the id directly.
92
+ */
93
+ export declare function visionOperationToCapability(operation: VisionOperation): "vision.interpret-image" | "vision.ui-artifact" | "vision.extract-text" | "vision.diagnose-error" | "vision.diagram" | "vision.chart" | "vision.diff" | "vision.video";
94
+ /**
95
+ * Vision Capability contract. Every Adapter that supports a Vision
96
+ * operation implements this interface and exposes it as `adapter.vision`.
97
+ * The Adapter owns Provider field mapping, transport, and credentials;
98
+ * commands call only these two methods.
99
+ *
100
+ * `supports` is a pure metadata check. It MUST NOT construct a
101
+ * transport, read a credential, inspect a source, or perform I/O. The
102
+ * shared `invokeVision` helper uses descriptor metadata first and
103
+ * `supports` only as a defensive double-check after `create()`.
104
+ */
105
+ export interface VisionCapability {
106
+ /**
107
+ * Report whether the Adapter can perform `operation` against the
108
+ * current environment. Pure metadata; no construction.
109
+ */
110
+ supports(operation: VisionOperation): boolean;
111
+ /**
112
+ * Invoke the Provider and return the normalized text result. The
113
+ * Adapter owns credentials, transport lifecycle, Provider field
114
+ * mapping, and failure normalization. The Adapter closes its
115
+ * transport and never retries inside this method.
116
+ */
117
+ invoke(request: VisionRequest): Promise<string>;
118
+ }
119
+ /**
120
+ * Minimal Adapter shape `invokeVision` needs. Defined here (instead of
121
+ * importing from `providers/types.ts`) so this file remains free of
122
+ * any Provider imports — the Boundary rule for Capability Modules
123
+ * (ARCHITECTURE.md §2).
124
+ *
125
+ * The descriptor's `create(context)` returns a `ProviderAdapter`; the
126
+ * shared helper accepts anything that exposes `id` and an optional
127
+ * `vision` VisionCapability, matching the Phase 3 ProviderAdapter
128
+ * shape defined in DESIGN.md §5.
129
+ */
130
+ export interface VisionInvocationDescriptor {
131
+ readonly id: string;
132
+ capabilities(): ReadonlySet<string>;
133
+ create(context: {
134
+ readonly env: NodeJS.ProcessEnv;
135
+ }): {
136
+ readonly id: string;
137
+ readonly vision?: VisionCapability;
138
+ };
139
+ }
140
+ /**
141
+ * Invoke a Vision request through a Provider descriptor. The support
142
+ * check happens BEFORE `descriptor.create()` (using descriptor
143
+ * metadata) and is then double-checked against the Adapter's
144
+ * `supports` after construction. Failures throw
145
+ * `UnsupportedCapabilityError` and never touch credentials, media,
146
+ * transport, cache, or a fallback Adapter.
147
+ *
148
+ * Phase 3 P3-01 introduces the contract and the early-fail ordering
149
+ * proof; Phase 3 P3-03 supplies the real Adapter implementations.
150
+ * Until then the built-in descriptors advertise metadata so the
151
+ * ordering is provable today.
152
+ */
153
+ export declare function invokeVision(descriptor: VisionInvocationDescriptor, request: VisionRequest, context: {
154
+ readonly env: NodeJS.ProcessEnv;
155
+ }): Promise<string>;
156
+ //# sourceMappingURL=vision.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vision.d.ts","sourceRoot":"","sources":["../../src/capabilities/vision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAQH;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GACrB;IACE,SAAS,EAAE,iBAAiB,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB,GACD;IACE,SAAS,EAAE,aAAa,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,aAAa,CAAC;CACxD,GACD;IACE,SAAS,EAAE,cAAc,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,GACD;IACE,SAAS,EAAE,gBAAgB,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAA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,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAA;KAAE,GAAG;QACpD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAC;KACpC,CAAC;CACH;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,0BAA0B,EACtC,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAA;CAAE,GAC3C,OAAO,CAAC,MAAM,CAAC,CAuBjB"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Provider Vision Capability (DESIGN.md §8, PRD FR-020, FR-022 to FR-026,
3
+ * FR-050, NFR-004, NFR-006).
4
+ *
5
+ * Defines the normalized Vision Capability shared by every Provider that
6
+ * supports single-image interpretation. Commands pass a `VisionRequest`
7
+ * (a discriminated union over the eight operation shapes) and the
8
+ * shared `invokeVision` helper:
9
+ *
10
+ * 1. Maps the operation to a stable `vision.<operation>` Capability id.
11
+ * 2. Reads descriptor-level capability metadata (pure; no Adapter
12
+ * construction). If the descriptor does not advertise the
13
+ * Capability, throws `UnsupportedCapabilityError(provider, ...)`
14
+ * BEFORE `descriptor.create()` is called. No credentials, no media,
15
+ * no transport, no cache, no fallback Adapter are observed.
16
+ * 3. Calls `descriptor.create(context)` and defensively double-checks
17
+ * the Adapter's `supports(operation)`. If the Adapter says no,
18
+ * throws the same error before `invoke` runs.
19
+ * 4. Calls `adapter.vision.invoke(request)` and returns the normalized
20
+ * text. Vision never uses the response cache and never falls back
21
+ * to another Provider.
22
+ *
23
+ * This module imports no Provider transport and no Provider Adapter.
24
+ * The error class import below is from `lib/errors.ts` (a shared error
25
+ * contract, not Provider transport), which is the existing boundary
26
+ * pattern for the Search Capability Module. The retry wrapper lives
27
+ * above `invokeVision` and passes a `() => Promise<string>` closure so
28
+ * Vision can be invoked through `executeProviderOperation("vision",
29
+ * ...)` (DESIGN.md §10) without coupling this file to that contract.
30
+ *
31
+ * P3-01 introduces only the contract + the early-fail ordering proof.
32
+ * Real Z.AI and MiniMax `vision` Adapters arrive in P3-03; the
33
+ * built-in descriptor factories in `providers/types.ts` advertise
34
+ * `vision.<operation>` Capability metadata now so the support check is
35
+ * wired through descriptor metadata from the start.
36
+ */
37
+ import { UnsupportedCapabilityError } from "../lib/errors.js";
38
+ /** Every operation that exists in the discriminated union. */
39
+ export const ALL_VISION_OPERATIONS = new Set([
40
+ "interpret-image",
41
+ "ui-artifact",
42
+ "extract-text",
43
+ "diagnose-error",
44
+ "diagram",
45
+ "chart",
46
+ "diff",
47
+ "video",
48
+ ]);
49
+ // ---------------------------------------------------------------------------
50
+ // Operation → Capability id mapping (no Provider imports)
51
+ // ---------------------------------------------------------------------------
52
+ /**
53
+ * Stable Capability id for a Vision operation. Each id matches a member
54
+ * of the `ProviderCapability` union declared in `providers/types.ts`.
55
+ * This mapping is the single source of truth: Adapters advertise the id;
56
+ * `invokeVision` reads it; commands never branch on the id directly.
57
+ */
58
+ export function visionOperationToCapability(operation) {
59
+ switch (operation) {
60
+ case "interpret-image":
61
+ return "vision.interpret-image";
62
+ case "ui-artifact":
63
+ return "vision.ui-artifact";
64
+ case "extract-text":
65
+ return "vision.extract-text";
66
+ case "diagnose-error":
67
+ return "vision.diagnose-error";
68
+ case "diagram":
69
+ return "vision.diagram";
70
+ case "chart":
71
+ return "vision.chart";
72
+ case "diff":
73
+ return "vision.diff";
74
+ case "video":
75
+ return "vision.video";
76
+ }
77
+ }
78
+ /**
79
+ * Invoke a Vision request through a Provider descriptor. The support
80
+ * check happens BEFORE `descriptor.create()` (using descriptor
81
+ * metadata) and is then double-checked against the Adapter's
82
+ * `supports` after construction. Failures throw
83
+ * `UnsupportedCapabilityError` and never touch credentials, media,
84
+ * transport, cache, or a fallback Adapter.
85
+ *
86
+ * Phase 3 P3-01 introduces the contract and the early-fail ordering
87
+ * proof; Phase 3 P3-03 supplies the real Adapter implementations.
88
+ * Until then the built-in descriptors advertise metadata so the
89
+ * ordering is provable today.
90
+ */
91
+ export async function invokeVision(descriptor, request, context) {
92
+ const capabilityId = visionOperationToCapability(request.operation);
93
+ // Step 1: descriptor-level metadata. NO create(), NO construction.
94
+ if (!descriptor.capabilities().has(capabilityId)) {
95
+ throw new UnsupportedCapabilityError(descriptor.id, capabilityId);
96
+ }
97
+ // Step 2: create() is allowed now — it is side-effect-free, only
98
+ // captures the injected env. Credentials, transport, and SDK are
99
+ // built lazily inside Capability invocation.
100
+ const adapter = descriptor.create(context);
101
+ // Step 3: defensive double-check against the Adapter's own metadata.
102
+ // If the Adapter says no, fail closed before invoke runs.
103
+ const vision = adapter.vision;
104
+ if (!vision || !vision.supports(request.operation)) {
105
+ throw new UnsupportedCapabilityError(descriptor.id, capabilityId);
106
+ }
107
+ // Step 4: invoke. No cache lookup, no fallback Adapter. Retries live
108
+ // above this call in `executeProviderOperation("vision", ...)`.
109
+ return vision.invoke(request);
110
+ }
111
+ //# sourceMappingURL=vision.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vision.js","sourceRoot":"","sources":["../../src/capabilities/vision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAgE9D,8DAA8D;AAC9D,MAAM,CAAC,MAAM,qBAAqB,GAAiC,IAAI,GAAG,CAAC;IACzE,iBAAiB;IACjB,aAAa;IACb,cAAc;IACd,gBAAgB;IAChB,SAAS;IACT,OAAO;IACP,MAAM;IACN,OAAO;CACR,CAAC,CAAC;AAEH,8EAA8E;AAC9E,0DAA0D;AAC1D,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CACzC,SAA0B;IAU1B,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,iBAAiB;YACpB,OAAO,wBAAwB,CAAC;QAClC,KAAK,aA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that separates
5
+ * command behaviour from process effects. `invokeCommand` owns
6
+ * invocation-local presentation, notice storage, and error conversion.
7
+ * The Node Adapter is the only Module that touches process streams,
8
+ * TTY state, and `process.exitCode`.
9
+ *
10
+ * Requirements: NFR-002, NFR-003, NFR-007.
11
+ */
12
+ import type { OutputMode } from "./lib/output.js";
13
+ export type TextOutputMode = "compact" | "markdown" | "refs" | "tty";
14
+ export type CommandPresentations = Readonly<Partial<Record<TextOutputMode, string>>>;
15
+ export interface DataCommandResult<T = unknown> {
16
+ readonly kind: "data";
17
+ readonly data: T;
18
+ readonly presentations?: CommandPresentations;
19
+ readonly exitCode?: number;
20
+ }
21
+ export interface TextCommandResult {
22
+ readonly kind: "text";
23
+ readonly text: string;
24
+ readonly exitCode?: number;
25
+ }
26
+ export type CommandResult<T = unknown> = DataCommandResult<T> | TextCommandResult;
27
+ export interface CommandContext {
28
+ readonly stdinIsTTY: boolean;
29
+ readStdin(): Promise<string>;
30
+ notice(message: string): void;
31
+ }
32
+ export interface CommandInvocationAdapter {
33
+ readonly stdoutIsTTY: boolean;
34
+ readonly stdinIsTTY: boolean;
35
+ readonly environmentOutputMode?: string;
36
+ readStdin(): Promise<string>;
37
+ writeStdout(value: string): void;
38
+ writeStderr(value: string): void;
39
+ runQuietly<T>(operation: () => Promise<T>): Promise<T>;
40
+ setExitCode(value: number): void;
41
+ }
42
+ /**
43
+ * Run command behaviour through the invocation seam.
44
+ *
45
+ * 1. Create invocation-local context and notice storage.
46
+ * 2. Run command behaviour through `runQuietly`.
47
+ * 3. `runQuietly` restores dependency logging before returning.
48
+ * 4. Flush notices to stderr in encounter order.
49
+ * 5. Select a presentation override or the base data.
50
+ * 6. Write one final successful value to stdout.
51
+ * 7. Convert a thrown error into one structured stderr value.
52
+ * 8. Return an exit status without terminating the process.
53
+ *
54
+ * The trailing newline is appended at the Node Adapter boundary, not
55
+ * here, so `invokeCommand` itself is process-effect-free.
56
+ */
57
+ export declare function invokeCommand(adapter: CommandInvocationAdapter, behavior: (context: CommandContext) => Promise<CommandResult>, outputMode: OutputMode, now?: () => number, secrets?: string[]): Promise<number>;
58
+ //# sourceMappingURL=command-invocation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-invocation.d.ts","sourceRoot":"","sources":["../src/command-invocation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAKlD,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,GAAG,KAAK,CAAC;AAErE,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;AAErF,MAAM,WAAW,iBAAiB,CAAC,CAAC,GAAG,OAAO;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACjB,QAAQ,CAAC,aAAa,CAAC,EAAE,oBAAoB,CAAC;IAC9C,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,OAAO,IAAI,iBAAiB,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC;AAElF,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IACxC,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,UAAU,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACvD,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAkCD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,wBAAwB,EACjC,QAAQ,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,aAAa,CAAC,EAC7D,UAAU,EAAE,UAAU,EACtB,GAAG,GAAE,MAAM,MAAiB,EAC5B,OAAO,CAAC,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,MAAM,CAAC,CAyCjB"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Command Invocation Seam (DESIGN.md §2).
3
+ *
4
+ * This Module defines the pure invocation contract that separates
5
+ * command behaviour from process effects. `invokeCommand` owns
6
+ * invocation-local presentation, notice storage, and error conversion.
7
+ * The Node Adapter is the only Module that touches process streams,
8
+ * TTY state, and `process.exitCode`.
9
+ *
10
+ * Requirements: NFR-002, NFR-003, NFR-007.
11
+ */
12
+ import { formatSuccessOutput, formatErrorOutput } from "./lib/output.js";
13
+ import { getErrorExitCode } from "./lib/errors.js";
14
+ import { redactSecrets, configuredSecrets } from "./lib/redact.js";
15
+ const TEXT_OUTPUT_MODES = ["compact", "markdown", "refs", "tty"];
16
+ function isTextOutputMode(mode) {
17
+ return TEXT_OUTPUT_MODES.includes(mode);
18
+ }
19
+ /**
20
+ * Select the final output string for a successful CommandResult.
21
+ *
22
+ * - `TextCommandResult`: the text is used verbatim regardless of mode.
23
+ * - `DataCommandResult` in a text-oriented mode: a command-supplied
24
+ * presentation override is preferred; otherwise the base data is
25
+ * formatted through `formatSuccessOutput`.
26
+ * - `DataCommandResult` in a data-oriented mode: base data formatted
27
+ * through `formatSuccessOutput` (data → raw JSON, json/pretty →
28
+ * success envelope).
29
+ */
30
+ function selectOutput(result, outputMode, now) {
31
+ if (result.kind === "text") {
32
+ return result.text;
33
+ }
34
+ if (isTextOutputMode(outputMode)) {
35
+ const override = result.presentations?.[outputMode];
36
+ if (typeof override === "string") {
37
+ return override;
38
+ }
39
+ }
40
+ return formatSuccessOutput(result.data, outputMode, now);
41
+ }
42
+ /**
43
+ * Run command behaviour through the invocation seam.
44
+ *
45
+ * 1. Create invocation-local context and notice storage.
46
+ * 2. Run command behaviour through `runQuietly`.
47
+ * 3. `runQuietly` restores dependency logging before returning.
48
+ * 4. Flush notices to stderr in encounter order.
49
+ * 5. Select a presentation override or the base data.
50
+ * 6. Write one final successful value to stdout.
51
+ * 7. Convert a thrown error into one structured stderr value.
52
+ * 8. Return an exit status without terminating the process.
53
+ *
54
+ * The trailing newline is appended at the Node Adapter boundary, not
55
+ * here, so `invokeCommand` itself is process-effect-free.
56
+ */
57
+ export async function invokeCommand(adapter, behavior, outputMode, now = Date.now, secrets) {
58
+ const notices = [];
59
+ const context = {
60
+ stdinIsTTY: adapter.stdinIsTTY,
61
+ readStdin: () => adapter.readStdin(),
62
+ notice: (message) => {
63
+ notices.push(message);
64
+ },
65
+ };
66
+ let result;
67
+ try {
68
+ result = await adapter.runQuietly(() => behavior(context));
69
+ }
70
+ catch (error) {
71
+ for (const notice of notices) {
72
+ adapter.writeStderr(notice);
73
+ }
74
+ // Recursively redact the thrown value at the outward boundary so any
75
+ // credential-shaped field embedded in the error tree — whether in
76
+ // `message`, `cause`, or any custom field — is replaced with the
77
+ // redaction marker before formatting. `formatErrorOutput` then
78
+ // performs an additional string-level pass on the message/help
79
+ // fields it actually serialises.
80
+ //
81
+ // B3: secrets resolved from an injected env (MainDependencies.env)
82
+ // are honoured here so a credential that exists only in the injected
83
+ // env is redacted even when absent from ambient process.env.
84
+ const resolvedSecrets = secrets ?? configuredSecrets();
85
+ const redactedError = redactSecrets(error, resolvedSecrets);
86
+ adapter.writeStderr(formatErrorOutput(redactedError, outputMode, resolvedSecrets));
87
+ return getErrorExitCode(error);
88
+ }
89
+ for (const notice of notices) {
90
+ adapter.writeStderr(notice);
91
+ }
92
+ adapter.writeStdout(selectOutput(result, outputMode, now));
93
+ return result.exitCode ?? 0;
94
+ }
95
+ //# sourceMappingURL=command-invocation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-invocation.js","sourceRoot":"","sources":["../src/command-invocation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAsCnE,MAAM,iBAAiB,GAA8B,CAAC,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AAE5F,SAAS,gBAAgB,CAAC,IAAgB;IACxC,OAAQ,iBAAuC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACjE,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAS,YAAY,CAAC,MAAqB,EAAE,UAAsB,EAAE,GAAiB;IACpF,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC3B,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,IAAI,gBAAgB,CAAC,UAAU,CAAC,EAAE,CAAC;QACjC,MAAM,QAAQ,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC,UAAU,CAAC,CAAC;QACpD,IAAI,OAAO,QAAQ,KAAK,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AC,CAAC,CAAC;QACnF,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC;IAE3D,OAAO,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Cache command — local cache inspection and clearing
3
+ * (Cache Module Unification Ticket 03).
4
+ *
5
+ * The command is presentation-only: it receives already-resolved stats
6
+ * or clear results through injected dependencies and wraps them with a
7
+ * TTY presentation override. Directory resolution, env-var policy, and
8
+ * on-disk I/O live in `src/lib/cache.ts` (Ticket 01). The dispatcher
9
+ * (`src/index.ts`) wires production to the real `cacheStats()` and
10
+ * `clearAllCaches()` and threads them through these dependencies; tests
11
+ * inject doubles.
12
+ *
13
+ * Output format (core-flows artifact):
14
+ *
15
+ * ```text
16
+ * Cache directory: ~/.scoutline/
17
+ * Status: enabled (TTL 24h, cap 100MB)
18
+ *
19
+ * Response cache:
20
+ * Entries: 47
21
+ * Size: 12.3 MB
22
+ *
23
+ * Tool cache:
24
+ * Entries: 1
25
+ * Size: 8.2 KB
26
+ * ```
27
+ *
28
+ * L1 fix: Doctor's one-line cache summary is computed from the same
29
+ * `cacheStats()` shape but formatted by the dispatcher, not by this
30
+ * module. See `formatDoctorCacheSummary`.
31
+ */
32
+ import type { CommandResult } from "../command-invocation.js";
33
+ export interface CacheStatsReport {
34
+ readonly dir: string;
35
+ readonly enabled: boolean;
36
+ readonly ttlMs: number;
37
+ readonly sizeCapBytes: number;
38
+ readonly responseCache: {
39
+ readonly entries: number;
40
+ readonly totalBytes: number;
41
+ };
42
+ readonly toolCache: {
43
+ readonly entries: number;
44
+ readonly totalBytes: number;
45
+ };
46
+ }
47
+ export interface CacheClearReport {
48
+ readonly responsesCleared: number;
49
+ readonly toolsCleared: number;
50
+ readonly bytesFreed: number;
51
+ }
52
+ /**
53
+ * Format a byte count as e.g. `"12.3 MB"`, `"8.2 KB"`, `"510 B"`. Used
54
+ * by `cache stats` presentation and by Doctor's one-line summary. Pure:
55
+ * no I/O, no env reads.
56
+ */
57
+ export declare function formatBytes(bytes: number): string;
58
+ /**
59
+ * Format a TTL in ms as `"24h"`, `"30m"`, or `"60s"`. Chooses the
60
+ * largest whole-unit that divides the input evenly so the default
61
+ * 24h renders as `24h` rather than `86400000ms`.
62
+ */
63
+ export declare function formatTtl(ms: number): string;
64
+ /**
65
+ * Format the inventory of both caches as a multi-line TTY block per
66
+ * the core-flows artifact. Used as the TTY/compact/markdown/refs
67
+ * presentation for `cache stats`. Pure.
68
+ */
69
+ export declare function formatCacheStats(stats: CacheStatsReport): string;
70
+ /**
71
+ * Format a clear result as a one-line TTY notice.
72
+ */
73
+ export declare function formatCacheClear(result: CacheClearReport): string;
74
+ /**
75
+ * Format the one-line Doctor cache summary from a `cacheStats()` value.
76
+ * The dispatcher calls this before invoking `buildDiagnosticsReport`;
77
+ * the report builder embeds the result verbatim. Examples:
78
+ *
79
+ * ```text
80
+ * Cache: enabled, 47 response entries (12.3 MB), 1 tool entry (8.2 KB), ~/.scoutline/
81
+ * Cache: disabled
82
+ * ```
83
+ *
84
+ * Pure: never reads env or touches the filesystem.
85
+ */
86
+ export declare function formatDoctorCacheSummary(stats: CacheStatsReport): string;
87
+ export interface CacheStatsDependencies {
88
+ readonly getStats: () => Promise<CacheStatsReport>;
89
+ }
90
+ export interface CacheClearDependencies {
91
+ readonly clear: () => Promise<CacheClearReport>;
92
+ }
93
+ /**
94
+ * Run the `cache stats` subcommand. Returns the inventory as base data
95
+ * with a TTY presentation override. Exit code is always 0 on success;
96
+ * I/O failures propagate as ordinary errors through the dispatcher.
97
+ */
98
+ export declare function cacheStatsCommand(deps: CacheStatsDependencies): Promise<CommandResult<CacheStatsReport>>;
99
+ /**
100
+ * Run the `cache clear` subcommand. Returns the count of cleared
101
+ * entries and bytes freed as base data with a TTY presentation
102
+ * override.
103
+ */
104
+ export declare function cacheClearCommand(deps: CacheClearDependencies): Promise<CommandResult<CacheClearReport>>;
105
+ export declare const CACHE_HELP: string;
106
+ //# sourceMappingURL=cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/commands/cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAkB,MAAM,0BAA0B,CAAC;AAS9E,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,aAAa,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IAClF,QAAQ,CAAC,SAAS,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/E;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAMD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAWjD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAK5C;AAkBD;;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