@hop-top/kit 0.5.0-alpha.0 → 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 (284) hide show
  1. package/CHANGELOG.md +262 -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 -885
  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 +18 -322
  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 +236 -46
  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 +142 -0
  271. package/src/tui/parity.ts +59 -13
  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
package/dist/config.d.ts CHANGED
@@ -1,97 +1 @@
1
- /**
2
- * @packageDocumentation
3
- *
4
- * Layered YAML configuration loader — TypeScript port of hop.top/kit/config.
5
- *
6
- * Merges configuration from up to three file layers in priority order:
7
- * system → user → project → envOverride
8
- *
9
- * Each later layer's values overwrite earlier ones via {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign | Object.assign}.
10
- * Missing files are silently skipped. A file that exists but contains invalid
11
- * YAML causes {@link load} to throw.
12
- *
13
- * @example
14
- * ```ts
15
- * import { load } from "@hop-top/kit/config";
16
- *
17
- * interface AppConfig {
18
- * host: string;
19
- * port: number;
20
- * debug: boolean;
21
- * token: string;
22
- * }
23
- *
24
- * const cfg: AppConfig = { host: "localhost", port: 3000, debug: false, token: "" };
25
- *
26
- * load(cfg, {
27
- * systemConfigPath: "/etc/mytool/config.yaml",
28
- * userConfigPath: `${process.env.HOME}/.config/mytool/config.yaml`,
29
- * projectConfigPath: ".mytool.yaml",
30
- * envOverride(c) {
31
- * if (process.env.HOST) c.host = process.env.HOST;
32
- * if (process.env.PORT) c.port = Number(process.env.PORT);
33
- * if (process.env.TOKEN) c.token = process.env.TOKEN;
34
- * },
35
- * });
36
- * ```
37
- */
38
- /**
39
- * Configuration sources for {@link load}.
40
- *
41
- * All path fields are optional; an empty or omitted path is silently skipped.
42
- * {@link Options.envOverride} is called last, after all file layers, so it can
43
- * apply environment-variable overrides on top of file values.
44
- */
45
- interface Options<T extends object = object> {
46
- /**
47
- * Path to the system-wide config file, e.g. `/etc/mytool/config.yaml`.
48
- * Applied first (lowest priority).
49
- */
50
- systemConfigPath?: string;
51
- /**
52
- * Path to the per-user config file, e.g. `~/.config/mytool/config.yaml`.
53
- * Applied second; overwrites system values for shared keys.
54
- */
55
- userConfigPath?: string;
56
- /**
57
- * Path to the project-level config file, e.g. `.mytool.yaml`.
58
- * Applied third; overwrites system and user values for shared keys.
59
- */
60
- projectConfigPath?: string;
61
- /**
62
- * Optional callback invoked after all file layers have been merged.
63
- * Receives the fully-merged `dst` object so the caller can apply
64
- * environment-variable overrides last (highest priority).
65
- *
66
- * @param cfg - The merged config object (same reference as `dst`).
67
- */
68
- envOverride?: (cfg: T) => void;
69
- }
70
- /**
71
- * Merges layered YAML configuration into `dst` and returns it.
72
- *
73
- * Merge order: `systemConfigPath` → `userConfigPath` → `projectConfigPath` →
74
- * `envOverride`.
75
- *
76
- * - Missing files (ENOENT) are silently skipped.
77
- * - A file that exists but is not valid YAML causes this function to throw
78
- * a descriptive error wrapping the parse failure.
79
- * - `envOverride`, when provided, is called last with the merged `dst`.
80
- * - Returns `dst` (the same object reference passed in).
81
- *
82
- * @param dst - Destination object to merge config into. Must be a non-null
83
- * object; mutated in place.
84
- * @param opts - Config sources. All fields are optional.
85
- * @returns The mutated `dst` object.
86
- * @throws {Error} When a file exists but cannot be parsed as YAML.
87
- *
88
- * @example
89
- * ```ts
90
- * const cfg = { host: "localhost", port: 8080 };
91
- * load(cfg, { projectConfigPath: ".tool.yaml" });
92
- * console.log(cfg.host); // value from .tool.yaml, or "localhost" if file missing
93
- * ```
94
- */
95
- declare function load<T extends object>(dst: T, opts?: Options<T>): T;
96
-
97
- export { type Options, load };
1
+ export { A as ArrayMergeFn, a as ArrayPolicy, C as ConfigParser, M as MergeOptions, N as NullPolicy, O as Options, l as load, m as mergeLayers } from './config-CaK60ByQ.js';
package/dist/config.js CHANGED
@@ -1,79 +1,9 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
29
2
 
30
- // src/config.ts
31
- var config_exports = {};
32
- __export(config_exports, {
33
- load: () => load2
34
- });
35
- module.exports = __toCommonJS(config_exports);
36
- var fs = __toESM(require("fs"));
37
- var yaml = __toESM(require("js-yaml"));
38
- function load2(dst, opts = {}) {
39
- const paths = [
40
- opts.systemConfigPath,
41
- opts.userConfigPath,
42
- opts.projectConfigPath
43
- ];
44
- for (const p of paths) {
45
- if (!p) continue;
46
- mergeFile(dst, p);
47
- }
48
- if (opts.envOverride) {
49
- opts.envOverride(dst);
50
- }
51
- return dst;
52
- }
53
- function mergeFile(dst, filePath) {
54
- let raw;
55
- try {
56
- raw = fs.readFileSync(filePath, "utf8");
57
- } catch (err) {
58
- if (isEnoent(err)) return;
59
- throw err;
60
- }
61
- let parsed;
62
- try {
63
- parsed = yaml.load(raw);
64
- } catch (err) {
65
- throw new Error(
66
- `config: failed to parse ${filePath}: ${err instanceof Error ? err.message : String(err)}`
67
- );
68
- }
69
- if (parsed !== null && parsed !== void 0 && typeof parsed === "object") {
70
- Object.assign(dst, parsed);
71
- }
72
- }
73
- function isEnoent(err) {
74
- return typeof err === "object" && err !== null && "code" in err && err.code === "ENOENT";
75
- }
76
- // Annotate the CommonJS export names for ESM import in node:
77
- 0 && (module.exports = {
78
- load
79
- });
3
+
4
+ var _chunkQQQYCWSCjs = require('./chunk-QQQYCWSC.js');
5
+ require('./chunk-R5U7XKVJ.js');
6
+
7
+
8
+
9
+ exports.load = _chunkQQQYCWSCjs.load; exports.mergeLayers = _chunkQQQYCWSCjs.mergeLayers;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @module errcorrect
3
+ * @package @hop-top/kit
4
+ *
5
+ * Factor 4 — Corrective Error Model.
6
+ *
7
+ * Structured errors with machine-readable code, human-readable message,
8
+ * likely cause, suggested fix, and alternative commands.
9
+ */
10
+ interface CorrectedError {
11
+ code: string;
12
+ message: string;
13
+ cause?: string;
14
+ fix?: string;
15
+ alternatives?: string[];
16
+ retryable?: boolean;
17
+ }
18
+ /**
19
+ * Creates an Error instance augmented with CorrectedError fields.
20
+ * Serializes cleanly to JSON (only defined fields).
21
+ */
22
+ declare function createCorrectedError(opts: CorrectedError): Error & CorrectedError;
23
+ /**
24
+ * Formats a CorrectedError for terminal display.
25
+ *
26
+ * ```
27
+ * ERROR mission not found
28
+ * Cause: no mission matches "bogux"
29
+ * Fix: spaced mission list
30
+ * Try: spaced mission search bogux
31
+ * ```
32
+ */
33
+ declare function formatError(err: CorrectedError, opts?: {
34
+ noColor?: boolean;
35
+ }): string;
36
+
37
+ type errcorrect_CorrectedError = CorrectedError;
38
+ declare const errcorrect_createCorrectedError: typeof createCorrectedError;
39
+ declare const errcorrect_formatError: typeof formatError;
40
+ declare namespace errcorrect {
41
+ export { type errcorrect_CorrectedError as CorrectedError, errcorrect_createCorrectedError as createCorrectedError, errcorrect_formatError as formatError };
42
+ }
43
+
44
+ export { type CorrectedError as C, createCorrectedError as c, errcorrect as e, formatError as f };
@@ -1,37 +1 @@
1
- /**
2
- * @module errcorrect
3
- * @package @hop-top/kit
4
- *
5
- * Factor 4 — Corrective Error Model.
6
- *
7
- * Structured errors with machine-readable code, human-readable message,
8
- * likely cause, suggested fix, and alternative commands.
9
- */
10
- interface CorrectedError {
11
- code: string;
12
- message: string;
13
- cause?: string;
14
- fix?: string;
15
- alternatives?: string[];
16
- retryable?: boolean;
17
- }
18
- /**
19
- * Creates an Error instance augmented with CorrectedError fields.
20
- * Serializes cleanly to JSON (only defined fields).
21
- */
22
- declare function createCorrectedError(opts: CorrectedError): Error & CorrectedError;
23
- /**
24
- * Formats a CorrectedError for terminal display.
25
- *
26
- * ```
27
- * ERROR mission not found
28
- * Cause: no mission matches "bogux"
29
- * Fix: spaced mission list
30
- * Try: spaced mission search bogux
31
- * ```
32
- */
33
- declare function formatError(err: CorrectedError, opts?: {
34
- noColor?: boolean;
35
- }): string;
36
-
37
- export { type CorrectedError, createCorrectedError, formatError };
1
+ export { C as CorrectedError, c as createCorrectedError, f as formatError } from './errcorrect-BcX1Ft0K.js';
@@ -1,69 +1,9 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
19
2
 
20
- // src/errcorrect.ts
21
- var errcorrect_exports = {};
22
- __export(errcorrect_exports, {
23
- createCorrectedError: () => createCorrectedError,
24
- formatError: () => formatError
25
- });
26
- module.exports = __toCommonJS(errcorrect_exports);
27
- function createCorrectedError(opts) {
28
- const err = new Error(opts.message);
29
- err.code = opts.code;
30
- if (opts.cause !== void 0) err.cause = opts.cause;
31
- if (opts.fix !== void 0) err.fix = opts.fix;
32
- if (opts.alternatives !== void 0) err.alternatives = opts.alternatives;
33
- if (opts.retryable !== void 0) err.retryable = opts.retryable;
34
- err.toJSON = () => {
35
- const o = {
36
- code: err.code,
37
- message: err.message
38
- };
39
- if (err.cause !== void 0) o.cause = err.cause;
40
- if (err.fix !== void 0) o.fix = err.fix;
41
- if (err.alternatives !== void 0) o.alternatives = err.alternatives;
42
- if (err.retryable !== void 0) o.retryable = err.retryable;
43
- return o;
44
- };
45
- return err;
46
- }
47
- function formatError(err, opts) {
48
- const red = opts?.noColor ? (s) => s : (s) => `\x1B[31m${s}\x1B[0m`;
49
- const bold = opts?.noColor ? (s) => s : (s) => `\x1B[1m${s}\x1B[0m`;
50
- const lines = [];
51
- lines.push(` ${red(bold("ERROR"))} ${err.message}`);
52
- if (err.cause) {
53
- lines.push(` Cause: ${err.cause}`);
54
- }
55
- if (err.fix) {
56
- lines.push(` Fix: ${err.fix}`);
57
- }
58
- if (err.alternatives && err.alternatives.length > 0) {
59
- for (const alt of err.alternatives) {
60
- lines.push(` Try: ${alt}`);
61
- }
62
- }
63
- return lines.join("\n");
64
- }
65
- // Annotate the CommonJS export names for ESM import in node:
66
- 0 && (module.exports = {
67
- createCorrectedError,
68
- formatError
69
- });
3
+
4
+ var _chunk3FIKGFKIjs = require('./chunk-3FIKGFKI.js');
5
+ require('./chunk-R5U7XKVJ.js');
6
+
7
+
8
+
9
+ exports.createCorrectedError = _chunk3FIKGFKIjs.createCorrectedError; exports.formatError = _chunk3FIKGFKIjs.formatError;
@@ -0,0 +1,231 @@
1
+ /**
2
+ * @module output/error
3
+ *
4
+ * Structured-error envelope. Mirrors Go's `go/console/output` error
5
+ * envelope: when a command fails under `--format json|yaml`, the error is
6
+ * materialized as a {@link CliError} and rendered to stderr by
7
+ * {@link renderError}. Plaintext mode (`--format table` or unset) prints
8
+ * `"Code: Message\nFix: ...\n"`.
9
+ *
10
+ * Fields use the on-wire snake_case keys directly (like the telemetry
11
+ * `Envelope`) so `JSON.stringify` is wire-exact; empty optional fields
12
+ * stay off the wire, mirroring Go's `omitempty`.
13
+ */
14
+ /** Marks a failure a retry may clear (rate limit, timeout, upstream blip). */
15
+ declare const TRANSIENCE_TRANSIENT = "transient";
16
+ /**
17
+ * Marks a failure retrying cannot clear without changing the input or the
18
+ * environment.
19
+ */
20
+ declare const TRANSIENCE_PERMANENT = "permanent";
21
+ /**
22
+ * Marks a failure kit cannot classify. Agents should treat retries as
23
+ * best-effort and bounded.
24
+ */
25
+ declare const TRANSIENCE_UNKNOWN = "unknown";
26
+ declare const CODE_OK = "OK";
27
+ declare const CODE_GENERIC = "GENERIC";
28
+ declare const CODE_USAGE = "USAGE";
29
+ declare const CODE_NOT_FOUND = "NOT_FOUND";
30
+ declare const CODE_CONFLICT = "CONFLICT";
31
+ declare const CODE_UNAUTHORIZED = "UNAUTHORIZED";
32
+ declare const CODE_TRANSIENT = "TRANSIENT";
33
+ declare const CODE_CONSENT_REFUSED = "CONSENT_REFUSED";
34
+ declare const CODE_PROVENANCE_MISSING = "PROVENANCE_MISSING";
35
+ declare const CODE_RATE_LIMITED = "RATE_LIMITED";
36
+ declare const CODE_PREREQUISITE = "PREREQUISITE";
37
+ /**
38
+ * Success. Present for completeness so a table of the full taxonomy can
39
+ * be written without a bare 0.
40
+ */
41
+ declare const EXIT_OK = 0;
42
+ /**
43
+ * Spec-assigned exit code for the generic failure class: the command
44
+ * failed and no narrower code applies. Pair it with {@link genericError}
45
+ * rather than hand-rolling exit 1, so the envelope carries a transience
46
+ * class.
47
+ */
48
+ declare const EXIT_GENERIC = 1;
49
+ /**
50
+ * The caller's invocation being wrong: an unknown flag, a missing
51
+ * argument, a value the command cannot parse. Permanent by
52
+ * construction — the same argv fails identically.
53
+ */
54
+ declare const EXIT_USAGE = 2;
55
+ /** A named resource the command could not locate. */
56
+ declare const EXIT_NOT_FOUND = 3;
57
+ /**
58
+ * A request that cannot be satisfied against the current state: a
59
+ * precondition failed, a write raced, an identifier is already taken.
60
+ */
61
+ declare const EXIT_CONFLICT = 4;
62
+ /**
63
+ * An authentication or authorization refusal. Permanent: the caller
64
+ * needs new credentials or a different policy, not a retry. Distinct
65
+ * from {@link EXIT_CONSENT_REFUSED}, which a re-invocation with
66
+ * `--confirm=yes` clears.
67
+ */
68
+ declare const EXIT_UNAUTHORIZED = 5;
69
+ /**
70
+ * Spec-assigned exit code for transient/retryable failures (Factor 11).
71
+ * Agents branch on it before parsing stderr: exit 6 means a retry may
72
+ * clear the failure.
73
+ */
74
+ declare const EXIT_TRANSIENT = 6;
75
+ /**
76
+ * Exit code for a confirmation gate that declined to run a destructive
77
+ * operation (`--confirm=no`, the non-TTY default, a missing or
78
+ * mismatched `--confirm-token`, or `N` at the prompt). Classified
79
+ * transient: re-invoking with `--confirm=yes` clears it. Distinct from
80
+ * {@link CODE_UNAUTHORIZED} at exit 5, which is permanent because no
81
+ * confirmation can clear a policy denial.
82
+ */
83
+ declare const EXIT_CONSENT_REFUSED = 7;
84
+ /** Conventional exit code for Factor-10 rate-limit refusals. */
85
+ declare const EXIT_RATE_LIMITED = 64;
86
+ /**
87
+ * Conventional exit code for Factor-12 strict-mode provenance refusals.
88
+ * Lives at 65 in kit's extension band (alongside RATE_LIMITED at 64):
89
+ * the spec reserves 0-6 for its core taxonomy and leaves >6 to per-tool
90
+ * codes, and kit as a library stays out of the low per-tool range.
91
+ */
92
+ declare const EXIT_PROVENANCE_MISSING = 65;
93
+ /**
94
+ * Exit code for a declared external dependency kit could not contact:
95
+ * nothing listening on the configured endpoint, connection refused,
96
+ * dial timeout. Separates a correct invocation whose logic never ran
97
+ * from the uncharacterized failures on exit 1. Classified transient,
98
+ * but deliberately not {@link CODE_TRANSIENT}: a dependency that is not
99
+ * running never comes up on its own, so the caller repairs the
100
+ * environment instead of backing off.
101
+ */
102
+ declare const EXIT_PREREQUISITE = 70;
103
+ /**
104
+ * Structured-error envelope rendered to stderr when `--format json|yaml`
105
+ * is set. Keys are the on-wire snake_case names.
106
+ *
107
+ * `transience` classifies the failure for retry decisions (Factor 4):
108
+ * transient (retry-worthy), permanent (do not retry), or unknown.
109
+ * Constructors and {@link wrapError} populate it; {@link renderError}
110
+ * normalizes an unset value to unknown so every structured error carries
111
+ * a valid class on the wire.
112
+ */
113
+ interface CliError {
114
+ code: string;
115
+ message: string;
116
+ cause?: string;
117
+ suggested_fix?: string;
118
+ alternatives?: string[];
119
+ exit_code: number;
120
+ transience?: string;
121
+ }
122
+ /**
123
+ * Default transience class for one of the standard codes. Unrecognized
124
+ * (adopter-defined) codes map to unknown; adopters set `transience`
125
+ * (or use {@link withTransience}) to classify their own codes.
126
+ */
127
+ declare function transienceForCode(code: string): string;
128
+ /**
129
+ * Resolves a standard class symbol to its numeric exit code, or
130
+ * `undefined` for adopter-defined and tool-specific codes.
131
+ *
132
+ * Callers that must produce a number for an unknown class decide their
133
+ * own fallback. This function does not pick one: a built-in fallback
134
+ * turns "this class was added to kit and never copied here" into an
135
+ * assertion against exit 1 that looks like a real failure rather than a
136
+ * stale table.
137
+ */
138
+ declare function exitCodeForClass(code: string): number | undefined;
139
+ /**
140
+ * The class symbols kit defines, in ascending exit-code order (ties
141
+ * broken by symbol). Callers rendering the taxonomy iterate this rather
142
+ * than hard-coding rows, so a class added above appears without a
143
+ * second edit.
144
+ */
145
+ declare function exitClasses(): string[];
146
+ /**
147
+ * Builds an envelope from `err`, retaining it for {@link unwrapError}
148
+ * while rendering as `code` and message. Transience defaults from the
149
+ * code via {@link transienceForCode}; use {@link withTransience} to
150
+ * override.
151
+ */
152
+ declare function wrapError(err: unknown, code: string, exitCode: number): CliError | null;
153
+ /**
154
+ * The error this envelope was built from via {@link wrapError}, so
155
+ * callers can classify failures by cause instead of string-matching
156
+ * `message`. Mirrors Go's `(*Error).Unwrap`.
157
+ */
158
+ declare function unwrapError(e: CliError): unknown;
159
+ /**
160
+ * Copy of `e` with `transience` set, every other field (and the retained
161
+ * source error) untouched. Copies rather than mutating: adopters
162
+ * commonly share module-level envelopes, and writing to one would leak
163
+ * across call sites.
164
+ */
165
+ declare function withTransience(e: CliError, transience: string): CliError;
166
+ /**
167
+ * CODE_GENERIC envelope with exit code 1. The catch-all for failures no
168
+ * narrower code describes; permanent because retrying the same input
169
+ * in the same environment is not expected to help. Wrapping an
170
+ * arbitrary error as CODE_GENERIC via {@link wrapError} still defaults
171
+ * to unknown.
172
+ */
173
+ declare function genericError(message: string): CliError;
174
+ /** CODE_NOT_FOUND envelope with exit code 3. */
175
+ declare function notFoundError(message: string): CliError;
176
+ /** CODE_CONFLICT envelope with exit code 4. */
177
+ declare function conflictError(message: string): CliError;
178
+ /** CODE_UNAUTHORIZED envelope with exit code 5. */
179
+ declare function unauthorizedError(message: string): CliError;
180
+ /** CODE_USAGE envelope with exit code 2. */
181
+ declare function usageError(message: string): CliError;
182
+ /**
183
+ * CODE_TRANSIENT envelope with exit code 6 (Factor 11). Use it for
184
+ * failures a retry may clear: upstream timeouts, connection resets,
185
+ * service-unavailable responses.
186
+ */
187
+ declare function transientError(message: string): CliError;
188
+ /**
189
+ * CODE_CONSENT_REFUSED envelope with exit code 7. Use it when a
190
+ * confirmation gate declines to run a destructive operation:
191
+ * `--confirm=no`, the non-TTY default, a missing or mismatched
192
+ * `--confirm-token`, or `N` at the prompt.
193
+ *
194
+ * Classified transient: the caller clears it by re-invoking with
195
+ * `--confirm=yes` (or the matching token). Do not use it for policy
196
+ * denials, which no confirmation can clear — those stay
197
+ * {@link unauthorizedError} and permanent.
198
+ */
199
+ declare function consentRefusedError(message: string): CliError;
200
+ /**
201
+ * CODE_PREREQUISITE envelope with exit code 70. Use it when a declared
202
+ * external dependency could not be contacted: nothing listening on the
203
+ * configured endpoint, connection refused, dial timeout.
204
+ *
205
+ * Classified transient: the operator starts the dependency and the same
206
+ * command succeeds. Do not use it for a dependency that answered and
207
+ * then misbehaved — that is {@link genericError} — nor for one that was
208
+ * never configured, which is {@link usageError}.
209
+ */
210
+ declare function prerequisiteError(message: string): CliError;
211
+ /** CODE_RATE_LIMITED envelope with exit code 64 (Factor 10). */
212
+ declare function rateLimitedError(message: string): CliError;
213
+ /**
214
+ * CODE_PROVENANCE_MISSING envelope with exit code 65 (Factor 12).
215
+ * `detail` is a free-form string suitable for the `cause` slot
216
+ * (typically the JSON-pointer list of offending fields).
217
+ */
218
+ declare function provenanceMissingError(detail: string): CliError;
219
+ /**
220
+ * Writes `err` to `w` in the requested format. `format === ''` or
221
+ * `'table'` renders human-readable plain text (`"Code: Message\nFix:
222
+ * ..."`); JSON/YAML render the envelope structurally. An unset
223
+ * transience is normalized to unknown on the wire (Factor 4) without
224
+ * mutating `err`. Always returns; the caller decides the exit code from
225
+ * `err.exit_code` after rendering.
226
+ */
227
+ declare function renderError(w: {
228
+ write(chunk: string): unknown;
229
+ }, format: string, err: CliError | null | undefined): void;
230
+
231
+ export { exitCodeForClass as A, genericError as B, type CliError as C, notFoundError as D, EXIT_CONFLICT as E, prerequisiteError as F, provenanceMissingError as G, rateLimitedError as H, renderError as I, transienceForCode as J, transientError as K, unauthorizedError as L, unwrapError as M, usageError as N, withTransience as O, wrapError as P, TRANSIENCE_PERMANENT as T, CODE_TRANSIENT as a, CODE_CONFLICT as b, CODE_CONSENT_REFUSED as c, CODE_GENERIC as d, CODE_NOT_FOUND as e, CODE_OK as f, CODE_PREREQUISITE as g, CODE_PROVENANCE_MISSING as h, CODE_RATE_LIMITED as i, CODE_UNAUTHORIZED as j, CODE_USAGE as k, EXIT_CONSENT_REFUSED as l, EXIT_GENERIC as m, EXIT_NOT_FOUND as n, EXIT_OK as o, EXIT_PREREQUISITE as p, EXIT_PROVENANCE_MISSING as q, EXIT_RATE_LIMITED as r, EXIT_TRANSIENT as s, EXIT_UNAUTHORIZED as t, EXIT_USAGE as u, TRANSIENCE_TRANSIENT as v, TRANSIENCE_UNKNOWN as w, conflictError as x, consentRefusedError as y, exitClasses as z };
@@ -1,83 +1,2 @@
1
- import { z } from 'zod';
2
-
3
- /**
4
- * @module id
5
- * @package @hop-top/kit
6
- *
7
- * TypeID primitive — thin wrapper around `typeid-js` (jetify-com)
8
- * implementing the cross-language kit API SHAPE per ADR 0001.
9
- *
10
- * Canonical wire form: `<prefix>_<26-char-base32>` where the suffix is
11
- * a Crockford-base32-encoded UUIDv7. The TS surface adds a
12
- * template-literal `Typed<P>` for compile-time prefix safety on top of
13
- * the runtime guarantees provided by `typeid-js`.
14
- *
15
- * URI composition (e.g. `tlc://task/task_…`) is NOT in this module —
16
- * callers should use the `@hop-top/cite` package directly. This
17
- * keeps `kit/id` free of any transitive dependency on the URI
18
- * registry, per the ADR's scope boundary.
19
- */
20
-
21
- /**
22
- * Compile-time-typed canonical TypeID string for prefix `P`.
23
- *
24
- * The template-literal `${P}_${string}` form means a `Typed<'task'>`
25
- * is statically distinguishable from a `Typed<'invoice'>` even though
26
- * both are runtime `string`s. Pair with {@link newTyped} or
27
- * {@link parseTyped} to mint values whose prefix is enforced both at
28
- * compile time and at runtime.
29
- */
30
- type Typed<P extends string> = `${P}_${string}`;
31
- /** Parsed components of a canonical TypeID string. */
32
- interface Parsed {
33
- /** Prefix segment (everything before the final underscore). */
34
- prefix: string;
35
- /** Backing UUID in canonical 8-4-4-4-12 hyphenated form. */
36
- uuid: string;
37
- }
38
- /**
39
- * Generate a new TypeID with the given prefix, returning the canonical
40
- * string `<prefix>_<26-char-base32>`.
41
- *
42
- * @example
43
- * newId('task') // => 'task_01h2e8kqv8000000000000000'
44
- */
45
- declare function newId(prefix: string): string;
46
- /**
47
- * Parse a canonical TypeID string into its prefix and backing UUID.
48
- *
49
- * @throws {Error} when the input is not a syntactically valid TypeID
50
- * (e.g. malformed suffix, illegal prefix characters).
51
- */
52
- declare function parse(s: string): Parsed;
53
- /**
54
- * Typed variant of {@link newId}. Returns a `Typed<P>` whose static
55
- * type carries the literal prefix, enabling compile-time discrimination
56
- * between e.g. `TaskId` and `InvoiceId`.
57
- */
58
- declare function newTyped<P extends string>(prefix: P): Typed<P>;
59
- /**
60
- * Typed variant of {@link parse}. Validates that the parsed prefix
61
- * matches the expected `prefix` argument at runtime; returns the
62
- * canonical string narrowed to `Typed<P>`.
63
- *
64
- * @throws {Error} when the parsed prefix does not match `prefix`, or
65
- * when the input is not a syntactically valid TypeID.
66
- */
67
- declare function parseTyped<P extends string>(prefix: P, s: string): Typed<P>;
68
- /**
69
- * Zod schema for runtime validation of a `${prefix}_<26-char-base32>`
70
- * canonical TypeID string.
71
- *
72
- * The schema only validates structure (prefix match + 26-char Crockford
73
- * base32 suffix with the spec's leading-bit constraint). It does not
74
- * decode the UUIDv7 timestamp; use {@link parse} if you need the
75
- * underlying UUID.
76
- *
77
- * @example
78
- * const TaskIdSchema = typeIdSchema('task');
79
- * TaskIdSchema.parse('task_01h2e8kqv8000000000000000');
80
- */
81
- declare function typeIdSchema(prefix: string): z.ZodString;
82
-
83
- export { type Parsed, type Typed, newId, newTyped, parse, parseTyped, typeIdSchema };
1
+ import 'zod';
2
+ export { P as Parsed, T as Typed, n as newId, a as newTyped, p as parse, b as parseTyped, t as typeIdSchema } from '../index-VLDcI5NF.js';