@hop-top/kit 0.5.0-alpha.1 → 0.5.0-alpha.10

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 (285) hide show
  1. package/CHANGELOG.md +251 -0
  2. package/LICENSE +1 -1
  3. package/LICENSE-cobra.txt +174 -0
  4. package/NOTICE +15 -0
  5. package/README.md +55 -259
  6. package/dist/aim-DZHwwiIc.d.ts +139 -0
  7. package/dist/aim.d.ts +1 -116
  8. package/dist/aim.js +13 -414
  9. package/dist/alias-D9_qFlyP.d.ts +174 -0
  10. package/dist/alias.d.ts +2 -73
  11. package/dist/alias.js +27 -207
  12. package/dist/api-DAexsu2H.d.ts +77 -0
  13. package/dist/api.d.ts +1 -62
  14. package/dist/api.js +10 -164
  15. package/dist/auth-2-jfgiHn.d.ts +34 -0
  16. package/dist/auth.d.ts +1 -26
  17. package/dist/auth.js +6 -40
  18. package/dist/chunk-2JV3A7OP.js +1894 -0
  19. package/dist/chunk-3FIKGFKI.js +54 -0
  20. package/dist/chunk-4UE5TCMQ.js +104 -0
  21. package/dist/chunk-6HFAEZ52.js +29 -0
  22. package/dist/chunk-6SVOHNIC.js +17 -0
  23. package/dist/chunk-72XZWQX7.js +504 -0
  24. package/dist/chunk-ABQSE7AI.js +513 -0
  25. package/dist/chunk-BDNNPRX6.js +41 -0
  26. package/dist/chunk-BLS2OBIQ.js +263 -0
  27. package/dist/chunk-BRNEKPWX.js +37 -0
  28. package/dist/chunk-CSJWB6D3.js +151 -0
  29. package/dist/chunk-GGWJRWWA.js +309 -0
  30. package/dist/chunk-GHPJJV5L.js +613 -0
  31. package/dist/chunk-IXVQ62NZ.js +334 -0
  32. package/dist/chunk-JKMQSAJP.js +174 -0
  33. package/dist/chunk-JZ22ZUFA.js +1131 -0
  34. package/dist/chunk-K7VCKJ27.js +814 -0
  35. package/dist/chunk-KVG7YCTS.js +115 -0
  36. package/dist/chunk-L23O2FFE.js +51 -0
  37. package/dist/chunk-MQXYDYRD.js +968 -0
  38. package/dist/chunk-MUIQVU6E.js +251 -0
  39. package/dist/chunk-NLMS7HGP.js +178 -0
  40. package/dist/chunk-POR5L2DG.js +247 -0
  41. package/dist/chunk-PSFYJGDG.js +1445 -0
  42. package/dist/chunk-QJVSKKRQ.js +369 -0
  43. package/dist/chunk-QPUCXQXT.js +67 -0
  44. package/dist/chunk-QQQYCWSC.js +240 -0
  45. package/dist/chunk-R5U7XKVJ.js +16 -0
  46. package/dist/chunk-SNVGDYX7.js +187 -0
  47. package/dist/chunk-T46YPHKN.js +669 -0
  48. package/dist/chunk-UKZIAQA7.js +26 -0
  49. package/dist/chunk-WBVO43HU.js +355 -0
  50. package/dist/chunk-WUOAQVOA.js +86 -0
  51. package/dist/chunk-WWUKGJB5.js +90 -0
  52. package/dist/chunk-XJTRY453.js +868 -0
  53. package/dist/chunk-YGYQUFGY.js +219 -0
  54. package/dist/chunk-YOBAUCVN.js +583 -0
  55. package/dist/cli-C5B5tnpA.d.ts +400 -0
  56. package/dist/cli.d.ts +7 -309
  57. package/dist/cli.js +70 -945
  58. package/dist/completion-csVun6SP.d.ts +112 -0
  59. package/dist/completion-values-By-mnjNt.d.ts +142 -0
  60. package/dist/completion-values.d.ts +1 -0
  61. package/dist/completion-values.js +29 -0
  62. package/dist/completion.d.ts +3 -0
  63. package/dist/completion.js +34 -0
  64. package/dist/compliance-AxFf-uMy.d.ts +60 -0
  65. package/dist/compliance.d.ts +1 -0
  66. package/dist/compliance.js +17 -0
  67. package/dist/config-CaK60ByQ.d.ts +241 -0
  68. package/dist/config.d.ts +1 -97
  69. package/dist/config.js +8 -78
  70. package/dist/errcorrect-BcX1Ft0K.d.ts +44 -0
  71. package/dist/errcorrect.d.ts +1 -37
  72. package/dist/errcorrect.js +8 -68
  73. package/dist/error-Do8Qji43.d.ts +231 -0
  74. package/dist/id/index.d.ts +2 -83
  75. package/dist/id/index.js +14 -65
  76. package/dist/index-BKJZClJx.d.ts +1486 -0
  77. package/dist/index-C3Zw4wDJ.d.ts +359 -0
  78. package/dist/index-DCe1boBz.d.ts +328 -0
  79. package/dist/index-VLDcI5NF.d.ts +95 -0
  80. package/dist/index.d.ts +37 -0
  81. package/dist/index.js +132 -0
  82. package/dist/llm-DYuR7_uX.d.ts +1069 -0
  83. package/dist/llm-anthropic-Cd_I2xXB.d.ts +67 -0
  84. package/dist/llm-anthropic.d.ts +2 -0
  85. package/dist/llm-anthropic.js +13 -0
  86. package/dist/llm-openai-DyFrucmV.d.ts +87 -0
  87. package/dist/llm-openai.d.ts +2 -0
  88. package/dist/llm-openai.js +19 -0
  89. package/dist/llm.d.ts +1 -188
  90. package/dist/llm.js +101 -356
  91. package/dist/log-CkaxMX3U.d.ts +115 -0
  92. package/dist/log.d.ts +2 -0
  93. package/dist/log.js +14 -0
  94. package/dist/mcp/index.d.ts +4 -0
  95. package/dist/mcp/index.js +184 -0
  96. package/dist/netpolicy-Brx5XZUB.d.ts +151 -0
  97. package/dist/netpolicy.d.ts +1 -0
  98. package/dist/netpolicy.js +25 -0
  99. package/dist/output-CjZWmL8s.d.ts +420 -0
  100. package/dist/output.d.ts +3 -213
  101. package/dist/output.js +137 -447
  102. package/dist/parity-CvMuYcVI.d.ts +61 -0
  103. package/dist/progress-CAzyxeWl.d.ts +38 -0
  104. package/dist/progress.d.ts +1 -30
  105. package/dist/progress.js +6 -55
  106. package/dist/provenance-SMFHm5gx.d.ts +30 -0
  107. package/dist/provenance.d.ts +1 -24
  108. package/dist/provenance.js +6 -31
  109. package/dist/routellm-B0nv59mH.d.ts +111 -0
  110. package/dist/routellm.d.ts +2 -64
  111. package/dist/routellm.js +13 -255
  112. package/dist/rpc-D31Lg0Kc.d.ts +32 -0
  113. package/dist/rpc.d.ts +2 -25
  114. package/dist/rpc.js +4 -98
  115. package/dist/safety-CUaYEjZc.d.ts +30 -0
  116. package/dist/safety.d.ts +1 -24
  117. package/dist/safety.js +6 -43
  118. package/dist/scope-BrhYB4ij.d.ts +141 -0
  119. package/dist/scope.d.ts +1 -121
  120. package/dist/scope.js +20 -377
  121. package/dist/serve-D8yWMrTc.d.ts +646 -0
  122. package/dist/serve.d.ts +3 -0
  123. package/dist/serve.js +75 -0
  124. package/dist/sqlstore.js +6 -39
  125. package/dist/stream-CrjeCp0M.d.ts +44 -0
  126. package/dist/stream.d.ts +1 -35
  127. package/dist/stream.js +8 -51
  128. package/dist/telemetry/index.d.ts +1 -315
  129. package/dist/telemetry/index.js +26 -599
  130. package/dist/toolspec-DcPwwoAZ.d.ts +368 -0
  131. package/dist/toolspec.d.ts +2 -0
  132. package/dist/toolspec.js +37 -0
  133. package/dist/tui/index.d.ts +6 -298
  134. package/dist/tui/index.js +17 -381
  135. package/dist/upgrade-p_zh3pvV.d.ts +102 -0
  136. package/dist/upgrade.d.ts +1 -95
  137. package/dist/upgrade.js +6 -114
  138. package/dist/xdg-DB7Shoib.d.ts +179 -0
  139. package/dist/xdg.d.ts +1 -169
  140. package/dist/xdg.js +14 -128
  141. package/package.json +192 -24
  142. package/src/README.md +15 -0
  143. package/src/alias.conformance.test.ts +250 -0
  144. package/src/alias.test.ts +206 -2
  145. package/src/alias.ts +196 -21
  146. package/src/cli.help-command.test.ts +105 -0
  147. package/src/cli.offline.test.ts +93 -0
  148. package/src/cli.parity.test.ts +192 -0
  149. package/src/cli.test.ts +95 -1
  150. package/src/cli.ts +195 -25
  151. package/src/completion-scripts.ts +16 -0
  152. package/src/completion-values.test.ts +76 -16
  153. package/src/completion-values.ts +170 -66
  154. package/src/completion.conformance.test.ts +297 -0
  155. package/src/completion.test.ts +256 -145
  156. package/src/completion.ts +767 -121
  157. package/src/compliance.test.ts +196 -2
  158. package/src/compliance.ts +440 -20
  159. package/src/config-merge.test.ts +425 -0
  160. package/src/config.test.ts +228 -1
  161. package/src/config.ts +429 -16
  162. package/src/gen/crud_pb.ts +7 -7
  163. package/src/id/README.md +38 -0
  164. package/src/id/contract.test.ts +1 -1
  165. package/src/id/index.test.ts +1 -1
  166. package/src/id/index.ts +3 -2
  167. package/src/index.test.ts +71 -0
  168. package/src/index.ts +46 -0
  169. package/src/llm-anthropic.conformance.test.ts +1135 -0
  170. package/src/llm-anthropic.test.ts +152 -0
  171. package/src/llm-anthropic.ts +940 -0
  172. package/src/llm-choice-hermetic.test.ts +335 -0
  173. package/src/llm-config.test.ts +232 -0
  174. package/src/llm-config.ts +106 -0
  175. package/src/llm-endpoint.ts +254 -0
  176. package/src/llm-error.ts +17 -0
  177. package/src/llm-errors.ts +152 -0
  178. package/src/llm-file.ts +126 -0
  179. package/src/llm-http.ts +317 -0
  180. package/src/llm-keys.ts +167 -0
  181. package/src/llm-media.conformance.test.ts +87 -0
  182. package/src/llm-media.test.ts +279 -0
  183. package/src/llm-media.ts +322 -0
  184. package/src/llm-openai.conformance.test.ts +407 -0
  185. package/src/llm-openai.test.ts +510 -0
  186. package/src/llm-openai.ts +708 -0
  187. package/src/llm-payload.ts +155 -0
  188. package/src/llm-quote.ts +46 -0
  189. package/src/llm-routellm.conformance.test.ts +44 -0
  190. package/src/llm-toolnames.conformance.test.ts +112 -0
  191. package/src/llm-toolnames.test.ts +132 -0
  192. package/src/llm-toolnames.ts +298 -0
  193. package/src/llm-uri.ts +99 -0
  194. package/src/llm.test.ts +43 -15
  195. package/src/llm.toolcall.test.ts +175 -0
  196. package/src/llm.ts +602 -190
  197. package/src/log.parity.test.ts +105 -0
  198. package/src/log.test.ts +270 -1
  199. package/src/log.ts +228 -49
  200. package/src/mcp/README.md +63 -0
  201. package/src/mcp/args-separator.test.ts +164 -0
  202. package/src/mcp/args.test.ts +223 -0
  203. package/src/mcp/args.ts +160 -0
  204. package/src/mcp/audit.test.ts +520 -0
  205. package/src/mcp/audit.ts +70 -0
  206. package/src/mcp/bridge.test.ts +222 -0
  207. package/src/mcp/bridge.ts +291 -0
  208. package/src/mcp/conformance.test.ts +357 -0
  209. package/src/mcp/dispatch.ts +359 -0
  210. package/src/mcp/identity.test.ts +166 -0
  211. package/src/mcp/identity.ts +72 -0
  212. package/src/mcp/index.ts +176 -0
  213. package/src/mcp/legacy-notify.test.ts +59 -0
  214. package/src/mcp/legacy.ts +367 -0
  215. package/src/mcp/mcp.test.ts +707 -0
  216. package/src/mcp/modern-confirm.test.ts +520 -0
  217. package/src/mcp/modern-confirm.ts +484 -0
  218. package/src/mcp/modern.ts +788 -0
  219. package/src/mcp/stdio.test.ts +313 -0
  220. package/src/mcp/stdio.ts +254 -0
  221. package/src/mcp/tasks.ts +82 -0
  222. package/src/mcp/testtree.ts +250 -0
  223. package/src/mcp/toolname.test.ts +147 -0
  224. package/src/mcp/types.ts +689 -0
  225. package/src/netpolicy.test.ts +280 -0
  226. package/src/netpolicy.ts +256 -0
  227. package/src/output/README.md +46 -0
  228. package/src/output/builtins.ts +5 -5
  229. package/src/output/dispatch.ts +10 -2
  230. package/src/output/error.ts +459 -0
  231. package/src/output/formatter.ts +29 -5
  232. package/src/output/formatters/README.md +50 -0
  233. package/src/output/formatters/csv.ts +48 -12
  234. package/src/output/formatters/json.ts +4 -25
  235. package/src/output/formatters/project.ts +34 -0
  236. package/src/output/formatters/table.ts +8 -6
  237. package/src/output/formatters/text.ts +7 -3
  238. package/src/output/formatters/yaml.ts +5 -22
  239. package/src/output/projection.test.ts +298 -0
  240. package/src/output/projection.ts +33 -59
  241. package/src/output/template.ts +11 -21
  242. package/src/output.surface.test.ts +41 -0
  243. package/src/output.ts +64 -3
  244. package/src/published-types.test.ts +133 -0
  245. package/src/routellm.test.ts +209 -28
  246. package/src/routellm.toolcall.test.ts +521 -0
  247. package/src/routellm.ts +213 -177
  248. package/src/router/README.md +44 -0
  249. package/src/router/server.test.ts +41 -0
  250. package/src/router/server.ts +11 -0
  251. package/src/safety.test.ts +19 -9
  252. package/src/scope-defaults.json +29 -29
  253. package/src/serve.test.ts +1257 -0
  254. package/src/serve.ts +1665 -0
  255. package/src/telemetry/README.md +48 -0
  256. package/src/telemetry/client.test.ts +31 -0
  257. package/src/telemetry/client.ts +12 -6
  258. package/src/telemetry/offline.test.ts +64 -0
  259. package/src/toolspec-internal.ts +279 -0
  260. package/src/toolspec-manifest.test.ts +167 -0
  261. package/src/toolspec-manifest.ts +410 -0
  262. package/src/toolspec-spec-schemas.ts +12 -0
  263. package/src/toolspec-spec.test.ts +273 -0
  264. package/src/toolspec-spec.ts +458 -0
  265. package/src/toolspec.from-command.test.ts +350 -0
  266. package/src/toolspec.test.ts +2 -2
  267. package/src/toolspec.ts +222 -0
  268. package/src/triton/README.md +34 -0
  269. package/src/tui/README.md +42 -0
  270. package/src/tui/parity.test.ts +120 -31
  271. package/src/tui/parity.ts +58 -7
  272. package/src/wizard.test.ts +7 -7
  273. package/test/llm/conformance-helpers.ts +100 -0
  274. package/test/output/csv.test.ts +164 -0
  275. package/test/output/dispatch.test.ts +1 -2
  276. package/test/output/error.test.ts +277 -0
  277. package/test/output/smoke-capture.ts +2 -2
  278. package/test/output/smoke.test.ts +2 -2
  279. package/test/output/taxonomy-contract.test.ts +148 -0
  280. package/test/setup-env.ts +16 -0
  281. package/test/toolspec/fixture.ts +79 -0
  282. package/tsconfig.json +3 -1
  283. package/tsconfig.test.json +10 -0
  284. package/vitest.config.ts +9 -0
  285. package/src/tui/parity.json +0 -74
@@ -0,0 +1,359 @@
1
+ /**
2
+ * @module telemetry/mode
3
+ * @package @hop-top/kit
4
+ *
5
+ * Telemetry Mode + env-variable precedence — the TS mirror of
6
+ * `go/runtime/telemetry/mode.go`. Three tiers control what an emit
7
+ * call ships:
8
+ *
9
+ * - `Mode.Off`: default; emit is a no-op.
10
+ * - `Mode.Anon`: anonymous payload (installation_id, command_path,
11
+ * exit_code, duration_ms, occurred_at, kit_version, sdk_lang/version).
12
+ * - `Mode.Full`: anon + args + flags, both post-redact.
13
+ *
14
+ * See the event-schema doc at `sdk/docs/telemetry-event-schema.md`
15
+ * for the on-wire shape.
16
+ *
17
+ * The env-precedence rule is intentionally simple:
18
+ *
19
+ * 1. If `KIT_APP_PREFIX=spaced` is set AND `SPACED_TELEMETRY_MODE` has
20
+ * a parseable value, that wins.
21
+ * 2. Otherwise `KIT_TELEMETRY_MODE` is consulted.
22
+ * 3. Anything else (missing, garbage, whitespace) → `Mode.Off`.
23
+ */
24
+ /**
25
+ * Mode controls how much detail the telemetry emitter ships.
26
+ *
27
+ * Encoded as a string-literal union so the on-disk / on-wire token IS
28
+ * the enum value. Mirrors Go's `Mode.String()` which renders these same
29
+ * three lowercase tokens.
30
+ */
31
+ declare const Mode: {
32
+ readonly Off: "off";
33
+ readonly Anon: "anon";
34
+ readonly Full: "full";
35
+ };
36
+ type Mode = (typeof Mode)[keyof typeof Mode];
37
+ /**
38
+ * parseMode maps a string token (case-insensitive: "off", "anon",
39
+ * "full") to a Mode. Empty / null / undefined input returns
40
+ * `[Mode.Off, true]` so an unset env var doesn't masquerade as an
41
+ * error. Unknown tokens return `[Mode.Off, false]` so callers can
42
+ * distinguish "operator typoed the env var" from "operator opted out".
43
+ *
44
+ * Mirrors `telemetry.ParseMode` in `go/runtime/telemetry/mode.go`.
45
+ */
46
+ declare function parseMode(s: string | undefined | null): [Mode, boolean];
47
+ /**
48
+ * resolveMode reads the env vars in canonical precedence order and
49
+ * returns the resolved Mode. Defaults to `Mode.Off`.
50
+ *
51
+ * Precedence (mirrors `telemetry.readEnvMode`):
52
+ *
53
+ * 1. `<APP>_TELEMETRY_MODE` where `<APP>` = uppercased `KIT_APP_PREFIX`.
54
+ * 2. `KIT_TELEMETRY_MODE`.
55
+ * 3. `Mode.Off`.
56
+ *
57
+ * Unparseable values at any tier are skipped (NOT a hard error); the
58
+ * resolver falls through to the next tier and ultimately to Off.
59
+ *
60
+ * @param env Inject a custom env map for testing. Defaults to `process.env`.
61
+ */
62
+ declare function resolveMode(env?: NodeJS.ProcessEnv): Mode;
63
+
64
+ /**
65
+ * @module telemetry/installId
66
+ * @package @hop-top/kit
67
+ *
68
+ * Persisted anonymous installation identifier — the TS mirror of
69
+ * `go/runtime/telemetry/installid.go`.
70
+ *
71
+ * On-disk format: 32 raw bytes from `crypto.randomBytes` stored at
72
+ * `<XDG_STATE_HOME>/kit/telemetry/installation_id`. The surface API
73
+ * returns the lowercase hex SHA-256 of those bytes (64 chars) so the
74
+ * file format stays canonical across polyglot SDKs (Go / Py / TS / Rs /
75
+ * PHP) while the hashed string is what flows through events.
76
+ *
77
+ * Perms: file 0600, parent dir 0700.
78
+ */
79
+ /**
80
+ * installIdPath returns the canonical on-disk path used by this module.
81
+ * Useful for SDK consumers and compliance checks that need to verify
82
+ * the storage location without invoking the read path.
83
+ */
84
+ declare function installIdPath(): string;
85
+ /**
86
+ * getInstallId returns the persisted anonymous install identifier as
87
+ * lowercase hex SHA-256 of 32 random bytes stored on disk. It generates
88
+ * and persists the bytes on first call. Concurrent first calls across
89
+ * processes are race-safe via a tmp + rename pattern with an
90
+ * existence-precheck: if a peer already wrote a valid file by the time
91
+ * we go to rename, we adopt their bytes.
92
+ *
93
+ * Mirrors `telemetry.InstallationID` in Go.
94
+ */
95
+ declare function getInstallId(): Promise<string>;
96
+ /**
97
+ * rotate atomically replaces the persisted bytes with 32 fresh
98
+ * `crypto.randomBytes` and returns the new hex. Used by the
99
+ * `kit consent reset` CLI flow.
100
+ *
101
+ * Mirrors `telemetry.Rotate` in Go.
102
+ */
103
+ declare function rotate(): Promise<string>;
104
+ /**
105
+ * resetForTest deletes the persisted file. Test helper exposed so
106
+ * adopters can drive first-run code paths in their own tests. Never
107
+ * call from production code.
108
+ *
109
+ * Mirrors `telemetry.ResetForTest` in Go.
110
+ */
111
+ declare function resetForTest(): Promise<void>;
112
+
113
+ /**
114
+ * @module telemetry/consent
115
+ * @package @hop-top/kit
116
+ *
117
+ * Read-only consent-file loader — the TS mirror of the read path in
118
+ * `go/core/consent/file_store.go`.
119
+ *
120
+ * On-disk shape (YAML under `<XDG_CONFIG_HOME>/kit/config.yaml` at the
121
+ * `kit.telemetry.consent` partition):
122
+ *
123
+ * ```yaml
124
+ * kit:
125
+ * telemetry:
126
+ * consent:
127
+ * state: granted # | denied
128
+ * prompt_version: 1
129
+ * decision_source: prompt # | flag | config | env
130
+ * decided_at: 2026-05-19T12:00:00Z
131
+ * ```
132
+ *
133
+ * A pre-refactor layout at `<XDG_CONFIG_HOME>/kit/telemetry.yaml` (with
134
+ * a bare `telemetry.consent` block at the top level) is read as a
135
+ * fallback so installs that have not been migrated yet still work.
136
+ *
137
+ * This TS module is **read-only**: writing the consent file remains the
138
+ * job of the Go `kit consent` CLI. SDK consumers just need to know
139
+ * whether emission is allowed.
140
+ *
141
+ * Anything that isn't a clean, parseable, `state: granted` block
142
+ * collapses to `deniedConsent` — a fail-closed default so a corrupt
143
+ * config can never accidentally enable emission.
144
+ */
145
+ /**
146
+ * Consent is the resolved telemetry decision for the current
147
+ * installation. The shape mirrors the relevant subset of the Go
148
+ * `consent.Decision` struct.
149
+ */
150
+ interface Consent {
151
+ /** allowed is true only when state == "granted". */
152
+ readonly allowed: boolean;
153
+ /** promptVersion records which prompt revision the user accepted. */
154
+ readonly promptVersion: number;
155
+ /**
156
+ * decisionSource records how the decision was captured —
157
+ * "prompt" | "flag" | "config" | "env". Defaults to "config" when
158
+ * the file is missing or unreadable.
159
+ */
160
+ readonly decisionSource: string;
161
+ /** decidedAt is the RFC3339 timestamp of the decision, if present. */
162
+ readonly decidedAt?: string;
163
+ }
164
+ /**
165
+ * deniedConsent is the canonical fail-closed default. Returned whenever
166
+ * the file is missing, unreadable, malformed, or carries an unknown
167
+ * state value.
168
+ */
169
+ declare const deniedConsent: Consent;
170
+ /**
171
+ * consentPath returns the canonical on-disk path used by this module
172
+ * (`<XDG_CONFIG_HOME>/kit/config.yaml`). Useful for `kit telemetry
173
+ * status` diagnostics and SDK consumers that want to surface the
174
+ * location.
175
+ */
176
+ declare function consentPath(): string;
177
+ /**
178
+ * loadConsent reads and parses the consent file, returning a fully
179
+ * resolved Consent struct. Failure modes fold to `deniedConsent`:
180
+ *
181
+ * - File missing → denied.
182
+ * - File unreadable → denied.
183
+ * - YAML parse error → denied.
184
+ * - Missing `kit.telemetry.consent` block (and no legacy) → denied.
185
+ * - `state` neither "granted" nor "denied" → denied.
186
+ *
187
+ * `state: "denied"` returns a Consent with `allowed=false` but with the
188
+ * other fields populated, so callers can distinguish an explicit deny
189
+ * from a fail-closed default.
190
+ *
191
+ * Read order: canonical `config.yaml` (`kit.telemetry.consent`) first,
192
+ * then legacy `telemetry.yaml` (`telemetry.consent`) as a fallback.
193
+ */
194
+ declare function loadConsent(): Promise<Consent>;
195
+
196
+ /**
197
+ * redactString applies every pattern in the opinionated set to `s`.
198
+ * Returns a new string; the input is never mutated.
199
+ */
200
+ declare function redactString(s: string): string;
201
+ /**
202
+ * redact returns a NEW value with the opinionated regex set applied to
203
+ * every reachable string. Walks plain objects and arrays recursively.
204
+ * Non-string scalars (number, boolean, null, undefined, bigint, symbol)
205
+ * pass through unchanged. Input is never mutated.
206
+ *
207
+ * NOT parity with `go/core/redact`. Use a per-Client redactor callback
208
+ * for stricter or custom rules; this is the default-on backstop.
209
+ */
210
+ declare function redact(value: unknown): unknown;
211
+
212
+ /** Sink kinds understood by the Client. */
213
+ type SinkKind = 'https' | 'jsonl';
214
+ /**
215
+ * ClientOptions tune the Client. Every field has an env-var equivalent
216
+ * so adopters can configure via the process environment without a
217
+ * code-side touch.
218
+ */
219
+ interface ClientOptions {
220
+ /** HTTPS endpoint for the `https` sink. Env: `KIT_TELEMETRY_ENDPOINT`. */
221
+ endpoint?: string;
222
+ /** Sink kind. Env: `KIT_TELEMETRY_SINK`. Default `jsonl`. */
223
+ sink?: SinkKind;
224
+ /** Target file for the `jsonl` sink. Env: `KIT_TELEMETRY_SINK_FILE`. */
225
+ sinkFile?: string;
226
+ /** Bounded queue capacity. Env: `KIT_TELEMETRY_QUEUE_SIZE`. Default 1024. */
227
+ queueSize?: number;
228
+ /** Custom redactor — runs BEFORE the default opinionated redact pass. */
229
+ redactor?: (attrs: Record<string, unknown>) => Record<string, unknown>;
230
+ /** SDK version surfaced in the envelope's `sdk_version` field. */
231
+ sdkVersion?: string;
232
+ }
233
+ /**
234
+ * Envelope shape this Client emits. Aligned with the cross-language
235
+ * event-schema doc's "common fields" plus the TS/Py free-form `event`
236
+ * + `attrs` extension.
237
+ *
238
+ * `attrs` is `null` when `mode === Mode.Anon` (matches the rs SDK's
239
+ * ``Value::Null`` strip) — the key stays for envelope-shape stability,
240
+ * the payload is dropped to avoid PII leakage. In `Mode.Full` it carries
241
+ * the caller's attrs dict after the redactor pipeline.
242
+ */
243
+ interface Envelope {
244
+ schema_version: string;
245
+ sdk_lang: 'ts';
246
+ sdk_version: string;
247
+ installation_id: string;
248
+ mode: Mode;
249
+ occurred_at: string;
250
+ event: string;
251
+ attrs: Record<string, unknown> | null;
252
+ }
253
+ /**
254
+ * Client is the non-blocking telemetry emitter. Construct one per
255
+ * process (or per long-lived adopter context) and call `record()` from
256
+ * any path; call `shutdown()` before process exit to drain queued
257
+ * events.
258
+ */
259
+ declare class Client {
260
+ private readonly endpoint?;
261
+ private readonly sinkKind;
262
+ private readonly sinkFile;
263
+ private readonly queueCap;
264
+ private readonly userRedactor?;
265
+ private readonly sdkVersion;
266
+ private readonly queue;
267
+ private dropped;
268
+ private installIdPromise?;
269
+ private flushTimer?;
270
+ private flushing;
271
+ private closed;
272
+ constructor(opts?: ClientOptions);
273
+ /**
274
+ * record enqueues an event for background delivery. Returns
275
+ * synchronously; never throws. Gating order: closed → consent → mode.
276
+ * Queue-full bumps `droppedCount` and returns silently.
277
+ */
278
+ record(event: string, attrs?: Record<string, unknown>): void;
279
+ /** Saturation counter — reads, not writes. */
280
+ get droppedCount(): number;
281
+ /**
282
+ * shutdown stops the flush timer, drains pending events to the sink,
283
+ * and resolves once drained OR the timeout elapses (default 5000ms).
284
+ * Idempotent.
285
+ */
286
+ shutdown(timeoutMs?: number): Promise<void>;
287
+ /**
288
+ * drainOnce ships every event currently in the queue (snapshot at
289
+ * call time) to the configured sink. Errors bump `dropped` but never
290
+ * propagate.
291
+ */
292
+ private drainOnce;
293
+ /**
294
+ * envelopeBatch materialises pending records into on-wire envelopes,
295
+ * applying the user redactor first and then the default `redact()`
296
+ * pass. install_id is resolved lazily + cached.
297
+ */
298
+ private envelopeBatch;
299
+ /**
300
+ * shipHttps POSTs the batch as NDJSON. One retry on 5xx OR network
301
+ * error, then drops the batch. `AbortController` enforces the
302
+ * connect + total timeouts.
303
+ */
304
+ private shipHttps;
305
+ /**
306
+ * shipJsonl appends envelopes as NDJSON to `sinkFile`. Rotates to
307
+ * `<sinkFile>.1` once the file crosses `JSONL_ROTATE_BYTES`. Single
308
+ * append per batch keeps the I/O cost predictable.
309
+ */
310
+ private shipJsonl;
311
+ /** Rotate the JSONL sink when it crosses the size threshold. */
312
+ private maybeRotateJsonl;
313
+ }
314
+
315
+ /**
316
+ * @module telemetry
317
+ * @package @hop-top/kit
318
+ *
319
+ * SDK-side telemetry primitives — TS mirror of
320
+ * `go/runtime/telemetry` (Mode + install_id) and the read path of
321
+ * `go/core/consent` (consent file reader).
322
+ *
323
+ * This module covers the three building blocks SDK consumers need
324
+ * before composing an emitter:
325
+ *
326
+ * - `Mode` / `parseMode` / `resolveMode` — what tier do we emit?
327
+ * - `getInstallId` / `rotate` / `installIdPath` — anonymous installation id.
328
+ * - `loadConsent` / `consentPath` / `Consent` — has the operator opted in?
329
+ *
330
+ * The emit path itself, the BatchProcessor, and the OTLP exporter land
331
+ * in follow-up sdk-telemetry tasks.
332
+ *
333
+ * Ground truth:
334
+ * - Event-schema doc `sdk/docs/telemetry-event-schema.md`
335
+ */
336
+
337
+ type index_Client = Client;
338
+ declare const index_Client: typeof Client;
339
+ type index_ClientOptions = ClientOptions;
340
+ type index_Consent = Consent;
341
+ type index_Envelope = Envelope;
342
+ type index_Mode = Mode;
343
+ type index_SinkKind = SinkKind;
344
+ declare const index_consentPath: typeof consentPath;
345
+ declare const index_deniedConsent: typeof deniedConsent;
346
+ declare const index_getInstallId: typeof getInstallId;
347
+ declare const index_installIdPath: typeof installIdPath;
348
+ declare const index_loadConsent: typeof loadConsent;
349
+ declare const index_parseMode: typeof parseMode;
350
+ declare const index_redact: typeof redact;
351
+ declare const index_redactString: typeof redactString;
352
+ declare const index_resetForTest: typeof resetForTest;
353
+ declare const index_resolveMode: typeof resolveMode;
354
+ declare const index_rotate: typeof rotate;
355
+ declare namespace index {
356
+ export { index_Client as Client, type index_ClientOptions as ClientOptions, type index_Consent as Consent, type index_Envelope as Envelope, type index_Mode as Mode, type index_SinkKind as SinkKind, index_consentPath as consentPath, index_deniedConsent as deniedConsent, index_getInstallId as getInstallId, index_installIdPath as installIdPath, index_loadConsent as loadConsent, index_parseMode as parseMode, index_redact as redact, index_redactString as redactString, index_resetForTest as resetForTest, index_resolveMode as resolveMode, index_rotate as rotate };
357
+ }
358
+
359
+ export { Client as C, type Envelope as E, Mode as M, type SinkKind as S, type ClientOptions as a, type Consent as b, consentPath as c, deniedConsent as d, installIdPath as e, redactString as f, getInstallId as g, resetForTest as h, index as i, resolveMode as j, rotate as k, loadConsent as l, parseMode as p, redact as r };
@@ -0,0 +1,328 @@
1
+ import { T as Theme } from './cli-C5B5tnpA.js';
2
+
3
+ /**
4
+ * @module tui/badge
5
+ * @package @hop-top/kit
6
+ *
7
+ * Renders a styled badge/pill string.
8
+ * Mirrors Go's badge concept from hop.top/kit/tui — pure string, no bubbletea dep.
9
+ */
10
+
11
+ interface BadgeOpts {
12
+ /** Override background color (hex, e.g. "#FF0000"). Defaults to theme.accent. */
13
+ color?: string;
14
+ }
15
+ /**
16
+ * Renders a styled inline badge.
17
+ *
18
+ * Background defaults to `theme.accent`; text is rendered in white for contrast.
19
+ * Padding of one space is added on each side (mirrors lipgloss Padding(0, 1)).
20
+ *
21
+ * @param theme - Active CLI theme.
22
+ * @param text - Badge label text.
23
+ * @param opts - Optional overrides.
24
+ * @returns ANSI-styled badge string.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import { buildTheme } from '@hop-top/kit/cli';
29
+ * import { badge } from '@hop-top/kit/tui';
30
+ * console.log(badge(buildTheme(), '^ UPDATE'));
31
+ * ```
32
+ */
33
+ declare function badge(theme: Theme, text: string, opts?: BadgeOpts): string;
34
+
35
+ /**
36
+ * @module tui/status
37
+ * @package @hop-top/kit
38
+ *
39
+ * Renders a prefixed status line with kind-derived symbol + color.
40
+ * Mirrors Go's InfoType/Status concept from hop.top/kit/tui.
41
+ */
42
+
43
+ /** Classification of a status message — maps to indicator symbol and color. */
44
+ type StatusKind = 'info' | 'success' | 'error' | 'warn';
45
+ /**
46
+ * Renders a prefixed status line.
47
+ *
48
+ * Indicator symbols and colors mirror Go's InfoType constants:
49
+ * - info → ℹ accent
50
+ * - success → ✓ success
51
+ * - error → ● error
52
+ * - warn → ▲ secondary
53
+ *
54
+ * @param theme - Active CLI theme.
55
+ * @param text - Status message text.
56
+ * @param kind - Message classification (default: `'info'`).
57
+ * @returns ANSI-styled status string with indicator prefix.
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * import { buildTheme } from '@hop-top/kit/cli';
62
+ * import { status } from '@hop-top/kit/tui';
63
+ * console.log(status(buildTheme(), 'Operation complete', 'success'));
64
+ * ```
65
+ */
66
+ declare function status(theme: Theme, text: string, kind?: StatusKind): string;
67
+
68
+ /**
69
+ * @module tui/pills
70
+ * @package @hop-top/kit
71
+ *
72
+ * Renders a horizontal list of styled pills.
73
+ * Mirrors Go's Pill/PillBar concept from hop.top/kit/tui — pure string output.
74
+ */
75
+
76
+ /**
77
+ * Renders a space-separated row of styled pills.
78
+ *
79
+ * Each item is wrapped in `theme.secondary` foreground color with one space of
80
+ * padding on each side, mirroring lipgloss Padding(0, 1) on a blurred pill.
81
+ *
82
+ * @param theme - Active CLI theme.
83
+ * @param items - Labels to render as pills.
84
+ * @returns Space-joined ANSI-styled pill string. Empty string when no items.
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * import { buildTheme } from '@hop-top/kit/cli';
89
+ * import { pills } from '@hop-top/kit/tui';
90
+ * console.log(pills(buildTheme(), ['branch: main', 'env: prod']));
91
+ * ```
92
+ */
93
+ declare function pills(theme: Theme, items: string[]): string;
94
+
95
+ /**
96
+ * @module tui/spinner
97
+ * @package @hop-top/kit
98
+ *
99
+ * Terminal spinner component.
100
+ * Mirrors Go's NewSpinner from hop.top/kit/tui — pure ANSI, no bubbletea dep.
101
+ */
102
+
103
+ interface Spinner {
104
+ /** Start spinning with optional message. */
105
+ start(msg?: string): void;
106
+ /** Stop spinner, print optional final message. */
107
+ stop(msg?: string): void;
108
+ /** Update the spinner message while running. */
109
+ message(msg: string): void;
110
+ }
111
+ /**
112
+ * Creates a terminal spinner styled with theme.accent.
113
+ *
114
+ * Renders to stderr; uses \r to overwrite the current line each frame.
115
+ *
116
+ * @param theme - Active CLI theme.
117
+ * @returns Spinner control object.
118
+ *
119
+ * @example
120
+ * ```ts
121
+ * import { buildTheme } from '@hop-top/kit/cli';
122
+ * import { spinner } from '@hop-top/kit/tui';
123
+ * const s = spinner(buildTheme());
124
+ * s.start('Loading…');
125
+ * // await work
126
+ * s.stop('Done');
127
+ * ```
128
+ */
129
+ declare function spinner(theme: Theme): Spinner;
130
+
131
+ /**
132
+ * @module tui/progress
133
+ * @package @hop-top/kit
134
+ *
135
+ * Terminal progress bar component.
136
+ * Mirrors Go's Progress from hop.top/kit/tui — pure ANSI, no bubbletea dep.
137
+ *
138
+ * Renders a 30-char ASCII bar: filled chars in theme.accent, empty in theme.muted.
139
+ */
140
+
141
+ interface Progress {
142
+ /** Start the progress bar with optional message. */
143
+ start(msg?: string): void;
144
+ /** Update progress value (0.0–1.0) with optional message. */
145
+ update(value: number, msg?: string): void;
146
+ /** Stop the progress bar with optional final message. */
147
+ stop(msg?: string): void;
148
+ }
149
+ /**
150
+ * Creates a terminal progress bar styled with theme colors.
151
+ *
152
+ * Fill chars rendered in theme.accent; empty track in theme.muted.
153
+ * Renders to stderr using \r to overwrite the current line.
154
+ *
155
+ * @param theme - Active CLI theme.
156
+ * @param total - Optional total units (unused — value is always 0.0–1.0 ratio).
157
+ * @returns Progress control object.
158
+ *
159
+ * @example
160
+ * ```ts
161
+ * import { buildTheme } from '@hop-top/kit/cli';
162
+ * import { progress } from '@hop-top/kit/tui';
163
+ * const p = progress(buildTheme());
164
+ * p.start('Downloading…');
165
+ * p.update(0.5, 'Half done');
166
+ * p.stop('Complete');
167
+ * ```
168
+ */
169
+ declare function progress(theme: Theme, _total?: number): Progress;
170
+ declare function clamp01(v: number): number;
171
+ /** Render a plain bar string (no ANSI) for testing. */
172
+ declare function renderBarPlain(value: number): string;
173
+
174
+ /**
175
+ * @module tui/anim
176
+ * @package @hop-top/kit
177
+ *
178
+ * Gradient animation component — cycling character scramble.
179
+ * Mirrors Go's Anim from hop.top/kit/tui — pure ANSI, no bubbletea dep.
180
+ *
181
+ * Cycles random chars through a gradient from theme.accent → theme.secondary
182
+ * at ~100ms per frame. Uses \r to overwrite the current line.
183
+ */
184
+
185
+ interface AnimOpts {
186
+ /** Number of animated characters (default: 10). */
187
+ width?: number;
188
+ /** Optional label rendered after the animation. */
189
+ label?: string;
190
+ }
191
+ interface Anim {
192
+ /** Start the animation loop. */
193
+ start(): void;
194
+ /** Stop the animation loop and clear the line. */
195
+ stop(): void;
196
+ /** Update the label shown after the animated chars. */
197
+ setLabel(label: string): void;
198
+ }
199
+ /**
200
+ * Creates a gradient-cycling character scramble animation.
201
+ *
202
+ * Colors cycle from theme.accent to theme.secondary across the width.
203
+ * Renders to stderr; uses \r to overwrite the current line each tick.
204
+ *
205
+ * @param theme - Active CLI theme.
206
+ * @param opts - Optional width and initial label.
207
+ * @returns Anim control object.
208
+ *
209
+ * @example
210
+ * ```ts
211
+ * import { buildTheme } from '@hop-top/kit/cli';
212
+ * import { anim } from '@hop-top/kit/tui';
213
+ * const a = anim(buildTheme(), { label: 'processing' });
214
+ * a.start();
215
+ * // await work
216
+ * a.stop();
217
+ * ```
218
+ */
219
+ declare function anim(theme: Theme, opts?: AnimOpts): Anim;
220
+ /** Linear RGB blend from hexA → hexB across `steps` positions. */
221
+ declare function makeGradient(hexA: string, hexB: string, steps: number): Array<[number, number, number]>;
222
+
223
+ /**
224
+ * @module tui/confirm
225
+ * @package @hop-top/kit
226
+ *
227
+ * Interactive yes/no confirmation prompt.
228
+ * Wraps @clack/prompts confirm(); throws on cancel (Ctrl-C).
229
+ * Mirrors Go's NewConfirm from hop.top/kit/tui.
230
+ */
231
+
232
+ interface ConfirmOpts {
233
+ /** Default selection when user presses Enter without input. */
234
+ initial?: boolean;
235
+ }
236
+ /**
237
+ * Prompt the user with a yes/no question.
238
+ *
239
+ * @param _theme - Active CLI theme (reserved for future accent styling).
240
+ * @param message - Question to display.
241
+ * @param opts - Optional config; `initial` sets the default selection.
242
+ * @returns `true` if accepted, `false` if denied.
243
+ * @throws Error('cancelled') if user presses Ctrl-C.
244
+ *
245
+ * @example
246
+ * ```ts
247
+ * import { buildTheme } from '@hop-top/kit/cli';
248
+ * import { confirm } from '@hop-top/kit/tui';
249
+ * const ok = await confirm(buildTheme(), 'Deploy now?');
250
+ * ```
251
+ */
252
+ declare function confirm(_theme: Theme, message: string, opts?: ConfirmOpts): Promise<boolean>;
253
+
254
+ /**
255
+ * @module tui/list
256
+ * @package @hop-top/kit
257
+ *
258
+ * Interactive selection list prompt.
259
+ * Wraps @clack/prompts select(); throws on cancel (Ctrl-C).
260
+ * Mirrors Go's NewList from hop.top/kit/tui (selection variant).
261
+ */
262
+
263
+ interface ListItem {
264
+ /** Display label shown in the prompt. */
265
+ label: string;
266
+ /** Value returned when this item is selected. */
267
+ value: string;
268
+ /** Optional hint shown alongside the label. */
269
+ hint?: string;
270
+ }
271
+ interface ListOpts {
272
+ /** Value of the initially highlighted item. */
273
+ initial?: string;
274
+ }
275
+ /**
276
+ * Prompt the user to pick one item from a list.
277
+ *
278
+ * @param _theme - Active CLI theme (reserved for future accent styling).
279
+ * @param message - Prompt label shown above the list.
280
+ * @param items - Selectable options.
281
+ * @param opts - Optional config; `initial` sets the pre-selected value.
282
+ * @returns The `value` of the selected item.
283
+ * @throws Error('cancelled') if user presses Ctrl-C.
284
+ *
285
+ * @example
286
+ * ```ts
287
+ * import { buildTheme } from '@hop-top/kit/cli';
288
+ * import { list } from '@hop-top/kit/tui';
289
+ * const env = await list(buildTheme(), 'Pick environment', [
290
+ * { label: 'Production', value: 'prod' },
291
+ * { label: 'Staging', value: 'staging', hint: 'default' },
292
+ * ]);
293
+ * ```
294
+ */
295
+ declare function list(_theme: Theme, message: string, items: ListItem[], opts?: ListOpts): Promise<string>;
296
+
297
+ /**
298
+ * @module tui
299
+ * @package @hop-top/kit
300
+ *
301
+ * Barrel re-export of TUI display components.
302
+ */
303
+
304
+ type index_Anim = Anim;
305
+ type index_AnimOpts = AnimOpts;
306
+ type index_BadgeOpts = BadgeOpts;
307
+ type index_ConfirmOpts = ConfirmOpts;
308
+ type index_ListItem = ListItem;
309
+ type index_ListOpts = ListOpts;
310
+ type index_Progress = Progress;
311
+ type index_Spinner = Spinner;
312
+ type index_StatusKind = StatusKind;
313
+ declare const index_anim: typeof anim;
314
+ declare const index_badge: typeof badge;
315
+ declare const index_clamp01: typeof clamp01;
316
+ declare const index_confirm: typeof confirm;
317
+ declare const index_list: typeof list;
318
+ declare const index_makeGradient: typeof makeGradient;
319
+ declare const index_pills: typeof pills;
320
+ declare const index_progress: typeof progress;
321
+ declare const index_renderBarPlain: typeof renderBarPlain;
322
+ declare const index_spinner: typeof spinner;
323
+ declare const index_status: typeof status;
324
+ declare namespace index {
325
+ export { type index_Anim as Anim, type index_AnimOpts as AnimOpts, type index_BadgeOpts as BadgeOpts, type index_ConfirmOpts as ConfirmOpts, type index_ListItem as ListItem, type index_ListOpts as ListOpts, type index_Progress as Progress, type index_Spinner as Spinner, type index_StatusKind as StatusKind, index_anim as anim, index_badge as badge, index_clamp01 as clamp01, index_confirm as confirm, index_list as list, index_makeGradient as makeGradient, index_pills as pills, index_progress as progress, index_renderBarPlain as renderBarPlain, index_spinner as spinner, index_status as status };
326
+ }
327
+
328
+ export { type Anim as A, type BadgeOpts as B, type ConfirmOpts as C, type ListItem as L, type Progress as P, type Spinner as S, type AnimOpts as a, type ListOpts as b, type StatusKind as c, anim as d, badge as e, clamp01 as f, confirm as g, progress as h, index as i, status as j, list as l, makeGradient as m, pills as p, renderBarPlain as r, spinner as s };