@hop-top/kit 0.5.0-alpha.2 → 0.5.0-alpha.4

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 (188) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/LICENSE +1 -1
  3. package/README.md +48 -480
  4. package/dist/{aim-CTp-kJW2.d.ts → aim-DZHwwiIc.d.ts} +1 -1
  5. package/dist/aim.d.ts +1 -1
  6. package/dist/aim.js +13 -414
  7. package/dist/{alias-dhhr08Ei.d.ts → alias-BOj0-VAr.d.ts} +1 -1
  8. package/dist/alias.d.ts +1 -1
  9. package/dist/alias.js +18 -206
  10. package/dist/{api-miiso81x.d.ts → api-DAexsu2H.d.ts} +1 -1
  11. package/dist/api.d.ts +1 -1
  12. package/dist/api.js +10 -164
  13. package/dist/auth.js +6 -40
  14. package/dist/chunk-3FIKGFKI.js +54 -0
  15. package/dist/chunk-4UE5TCMQ.js +104 -0
  16. package/dist/chunk-6HFAEZ52.js +29 -0
  17. package/dist/chunk-6SVOHNIC.js +17 -0
  18. package/dist/chunk-72XZWQX7.js +504 -0
  19. package/dist/chunk-ABQSE7AI.js +513 -0
  20. package/dist/chunk-BDNNPRX6.js +41 -0
  21. package/dist/chunk-BRNEKPWX.js +37 -0
  22. package/dist/chunk-CSJWB6D3.js +151 -0
  23. package/dist/chunk-GGWJRWWA.js +309 -0
  24. package/dist/chunk-IQXEISMC.js +142 -0
  25. package/dist/chunk-JTMPNXVQ.js +1491 -0
  26. package/dist/chunk-KVG7YCTS.js +115 -0
  27. package/dist/chunk-L23O2FFE.js +51 -0
  28. package/dist/chunk-MQXYDYRD.js +968 -0
  29. package/dist/chunk-MUIQVU6E.js +251 -0
  30. package/dist/chunk-POR5L2DG.js +247 -0
  31. package/dist/chunk-PSFYJGDG.js +1445 -0
  32. package/dist/chunk-QJVSKKRQ.js +369 -0
  33. package/dist/chunk-QPUCXQXT.js +67 -0
  34. package/dist/chunk-R5U7XKVJ.js +16 -0
  35. package/dist/chunk-S45UHXQF.js +182 -0
  36. package/dist/chunk-T46YPHKN.js +669 -0
  37. package/dist/chunk-UIOOOK6M.js +334 -0
  38. package/dist/chunk-UKZIAQA7.js +26 -0
  39. package/dist/chunk-WBVO43HU.js +355 -0
  40. package/dist/chunk-WTYDHXPW.js +574 -0
  41. package/dist/chunk-WUOAQVOA.js +86 -0
  42. package/dist/chunk-WWUKGJB5.js +90 -0
  43. package/dist/chunk-YGYQUFGY.js +219 -0
  44. package/dist/chunk-YOBAUCVN.js +583 -0
  45. package/dist/{cli-DgOEOsPB.d.ts → cli-8rfITnv4.d.ts} +13 -4
  46. package/dist/cli.d.ts +4 -3
  47. package/dist/cli.js +50 -1056
  48. package/dist/{config-BUY7_W2n.d.ts → config-Bm9fBXch.d.ts} +35 -4
  49. package/dist/config.d.ts +1 -1
  50. package/dist/config.js +6 -78
  51. package/dist/errcorrect.js +8 -68
  52. package/dist/error-Do8Qji43.d.ts +231 -0
  53. package/dist/id/index.d.ts +1 -1
  54. package/dist/id/index.js +14 -65
  55. package/dist/{index-MLrRDvEG.d.ts → index-B-pqGHhU.d.ts} +113 -19
  56. package/dist/{index--C7Mtsmm.d.ts → index-DEyjGoo2.d.ts} +1 -1
  57. package/dist/{index-QSffbLnj.d.ts → index-VLDcI5NF.d.ts} +3 -2
  58. package/dist/index.d.ts +18 -13
  59. package/dist/index.js +40 -5792
  60. package/dist/llm-DYuR7_uX.d.ts +1069 -0
  61. package/dist/llm-anthropic-Cd_I2xXB.d.ts +67 -0
  62. package/dist/llm-anthropic.d.ts +2 -0
  63. package/dist/llm-anthropic.js +13 -0
  64. package/dist/llm-openai-DyFrucmV.d.ts +87 -0
  65. package/dist/llm-openai.d.ts +2 -0
  66. package/dist/llm-openai.js +19 -0
  67. package/dist/llm.d.ts +1 -1
  68. package/dist/llm.js +101 -356
  69. package/dist/mcp/index.d.ts +2 -1
  70. package/dist/mcp/index.js +155 -1453
  71. package/dist/{netpolicy-asvCfwi8.d.ts → netpolicy-Brx5XZUB.d.ts} +16 -3
  72. package/dist/netpolicy.d.ts +1 -1
  73. package/dist/netpolicy.js +25 -118
  74. package/dist/{output-VFFLqor9.d.ts → output-CjZWmL8s.d.ts} +29 -130
  75. package/dist/output.d.ts +2 -1
  76. package/dist/output.js +137 -958
  77. package/dist/progress.js +6 -55
  78. package/dist/provenance.js +6 -31
  79. package/dist/routellm-B0nv59mH.d.ts +111 -0
  80. package/dist/routellm.d.ts +2 -2
  81. package/dist/routellm.js +13 -255
  82. package/dist/{rpc-D5xLEf8V.d.ts → rpc-D31Lg0Kc.d.ts} +1 -1
  83. package/dist/rpc.d.ts +2 -2
  84. package/dist/rpc.js +4 -98
  85. package/dist/safety.js +6 -43
  86. package/dist/scope.js +20 -377
  87. package/dist/serve-D8yWMrTc.d.ts +646 -0
  88. package/dist/serve.d.ts +3 -0
  89. package/dist/serve.js +75 -0
  90. package/dist/sqlstore.js +6 -39
  91. package/dist/stream.js +8 -51
  92. package/dist/telemetry/index.js +24 -608
  93. package/dist/tui/index.d.ts +5 -4
  94. package/dist/tui/index.js +17 -373
  95. package/dist/upgrade.js +6 -114
  96. package/dist/xdg.js +14 -128
  97. package/package.json +135 -25
  98. package/src/README.md +15 -0
  99. package/src/cli.test.ts +56 -1
  100. package/src/cli.ts +24 -4
  101. package/src/completion-values.test.ts +10 -10
  102. package/src/compliance.test.ts +196 -2
  103. package/src/compliance.ts +440 -20
  104. package/src/config.test.ts +187 -1
  105. package/src/config.ts +173 -7
  106. package/src/gen/crud_pb.ts +7 -7
  107. package/src/id/README.md +38 -0
  108. package/src/id/contract.test.ts +1 -1
  109. package/src/id/index.test.ts +1 -1
  110. package/src/id/index.ts +3 -2
  111. package/src/index.test.ts +12 -0
  112. package/src/index.ts +3 -0
  113. package/src/llm-anthropic.conformance.test.ts +1135 -0
  114. package/src/llm-anthropic.test.ts +152 -0
  115. package/src/llm-anthropic.ts +940 -0
  116. package/src/llm-choice-hermetic.test.ts +335 -0
  117. package/src/llm-config.test.ts +232 -0
  118. package/src/llm-config.ts +106 -0
  119. package/src/llm-endpoint.ts +254 -0
  120. package/src/llm-error.ts +17 -0
  121. package/src/llm-errors.ts +152 -0
  122. package/src/llm-file.ts +126 -0
  123. package/src/llm-http.ts +317 -0
  124. package/src/llm-keys.ts +167 -0
  125. package/src/llm-media.conformance.test.ts +87 -0
  126. package/src/llm-media.test.ts +279 -0
  127. package/src/llm-media.ts +322 -0
  128. package/src/llm-openai.conformance.test.ts +407 -0
  129. package/src/llm-openai.test.ts +510 -0
  130. package/src/llm-openai.ts +708 -0
  131. package/src/llm-payload.ts +155 -0
  132. package/src/llm-quote.ts +46 -0
  133. package/src/llm-routellm.conformance.test.ts +44 -0
  134. package/src/llm-toolnames.conformance.test.ts +112 -0
  135. package/src/llm-toolnames.test.ts +132 -0
  136. package/src/llm-toolnames.ts +298 -0
  137. package/src/llm-uri.ts +99 -0
  138. package/src/llm.test.ts +43 -15
  139. package/src/llm.toolcall.test.ts +175 -0
  140. package/src/llm.ts +602 -190
  141. package/src/mcp/README.md +57 -0
  142. package/src/mcp/conformance.test.ts +24 -3
  143. package/src/mcp/dispatch.ts +4 -4
  144. package/src/mcp/identity.test.ts +166 -0
  145. package/src/mcp/identity.ts +72 -0
  146. package/src/mcp/index.ts +6 -0
  147. package/src/mcp/legacy.ts +21 -8
  148. package/src/mcp/mcp.test.ts +14 -4
  149. package/src/mcp/modern-confirm.ts +1 -1
  150. package/src/mcp/modern.ts +12 -11
  151. package/src/mcp/tasks.ts +1 -1
  152. package/src/mcp/types.ts +80 -8
  153. package/src/netpolicy.test.ts +78 -0
  154. package/src/netpolicy.ts +28 -3
  155. package/src/output/README.md +46 -0
  156. package/src/output/builtins.ts +5 -5
  157. package/src/output/error.ts +167 -1
  158. package/src/output/formatters/README.md +50 -0
  159. package/src/output.ts +26 -1
  160. package/src/published-types.test.ts +115 -0
  161. package/src/routellm.test.ts +209 -28
  162. package/src/routellm.toolcall.test.ts +521 -0
  163. package/src/routellm.ts +213 -177
  164. package/src/router/README.md +44 -0
  165. package/src/router/server.test.ts +41 -0
  166. package/src/router/server.ts +11 -0
  167. package/src/safety.test.ts +19 -9
  168. package/src/scope-defaults.json +29 -29
  169. package/src/serve.test.ts +1257 -0
  170. package/src/serve.ts +1665 -0
  171. package/src/telemetry/README.md +48 -0
  172. package/src/telemetry/client.ts +5 -5
  173. package/src/toolspec.test.ts +2 -2
  174. package/src/triton/README.md +34 -0
  175. package/src/tui/README.md +42 -0
  176. package/src/wizard.test.ts +7 -7
  177. package/test/llm/conformance-helpers.ts +100 -0
  178. package/test/output/dispatch.test.ts +1 -2
  179. package/test/output/error.test.ts +38 -2
  180. package/test/output/smoke-capture.ts +2 -2
  181. package/test/output/smoke.test.ts +2 -2
  182. package/test/output/taxonomy-contract.test.ts +148 -0
  183. package/test/setup-env.ts +16 -0
  184. package/tsconfig.json +3 -1
  185. package/tsconfig.test.json +10 -0
  186. package/vitest.config.ts +9 -0
  187. package/dist/llm-B5XUWH8T.d.ts +0 -231
  188. package/dist/routellm-PGSt2D1y.d.ts +0 -75
@@ -48,7 +48,13 @@
48
48
  * prefer {@link isOfflineError} over comparing it by hand.
49
49
  */
50
50
  declare const ErrOffline = "OfflineError";
51
- /** Error rejected by {@link guardFetch}. Matchable via {@link isOfflineError}. */
51
+ /**
52
+ * Error rejected by {@link guardFetch}. Matchable via {@link isOfflineError}.
53
+ *
54
+ * The message names the method and the destination as scheme, host and
55
+ * path only; `url` is reduced by {@link destination} whoever constructs
56
+ * the error.
57
+ */
52
58
  declare class OfflineError extends Error {
53
59
  readonly name = "OfflineError";
54
60
  constructor(method: string, url: string);
@@ -79,6 +85,12 @@ declare function setProcessOffline(offline: boolean): void;
79
85
  * {@link setProcessOffline}.
80
86
  */
81
87
  declare function isOffline(): boolean;
88
+ /**
89
+ * Report whether host names a loopback address. Hosts that are not literal
90
+ * IPs (DNS names) are treated as remote: resolving them would itself be
91
+ * network access.
92
+ */
93
+ declare function isLoopback(hostname: string): boolean;
82
94
  /**
83
95
  * Wrap base so requests made in an offline-marked scope reject with an
84
96
  * {@link OfflineError} instead of reaching the network. Wrapping is
@@ -126,13 +138,14 @@ type netpolicy_OfflineError = OfflineError;
126
138
  declare const netpolicy_OfflineError: typeof OfflineError;
127
139
  declare const netpolicy_guardFetch: typeof guardFetch;
128
140
  declare const netpolicy_install: typeof install;
141
+ declare const netpolicy_isLoopback: typeof isLoopback;
129
142
  declare const netpolicy_isOffline: typeof isOffline;
130
143
  declare const netpolicy_isOfflineError: typeof isOfflineError;
131
144
  declare const netpolicy_observabilityFetch: typeof observabilityFetch;
132
145
  declare const netpolicy_setProcessOffline: typeof setProcessOffline;
133
146
  declare const netpolicy_withOffline: typeof withOffline;
134
147
  declare namespace netpolicy {
135
- export { netpolicy_ErrOffline as ErrOffline, netpolicy_OfflineError as OfflineError, netpolicy_guardFetch as guardFetch, netpolicy_install as install, netpolicy_isOffline as isOffline, netpolicy_isOfflineError as isOfflineError, netpolicy_observabilityFetch as observabilityFetch, netpolicy_setProcessOffline as setProcessOffline, netpolicy_withOffline as withOffline };
148
+ export { netpolicy_ErrOffline as ErrOffline, netpolicy_OfflineError as OfflineError, netpolicy_guardFetch as guardFetch, netpolicy_install as install, netpolicy_isLoopback as isLoopback, netpolicy_isOffline as isOffline, netpolicy_isOfflineError as isOfflineError, netpolicy_observabilityFetch as observabilityFetch, netpolicy_setProcessOffline as setProcessOffline, netpolicy_withOffline as withOffline };
136
149
  }
137
150
 
138
- export { ErrOffline as E, OfflineError as O, isOffline as a, isOfflineError as b, guardFetch as g, install as i, netpolicy as n, observabilityFetch as o, setProcessOffline as s, withOffline as w };
151
+ export { ErrOffline as E, OfflineError as O, isOfflineError as a, install as b, isLoopback as c, guardFetch as g, isOffline as i, netpolicy as n, observabilityFetch as o, setProcessOffline as s, withOffline as w };
@@ -1 +1 @@
1
- export { E as ErrOffline, O as OfflineError, g as guardFetch, i as install, a as isOffline, b as isOfflineError, o as observabilityFetch, s as setProcessOffline, w as withOffline } from './netpolicy-asvCfwi8.js';
1
+ export { E as ErrOffline, O as OfflineError, g as guardFetch, b as install, c as isLoopback, i as isOffline, a as isOfflineError, o as observabilityFetch, s as setProcessOffline, w as withOffline } from './netpolicy-Brx5XZUB.js';
package/dist/netpolicy.js CHANGED
@@ -1,118 +1,25 @@
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 = (target2, all) => {
7
- for (var name in all)
8
- __defProp(target2, 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);
19
-
20
- // src/netpolicy.ts
21
- var netpolicy_exports = {};
22
- __export(netpolicy_exports, {
23
- ErrOffline: () => ErrOffline,
24
- OfflineError: () => OfflineError,
25
- guardFetch: () => guardFetch,
26
- install: () => install,
27
- isOffline: () => isOffline,
28
- isOfflineError: () => isOfflineError,
29
- observabilityFetch: () => observabilityFetch,
30
- setProcessOffline: () => setProcessOffline,
31
- withOffline: () => withOffline
32
- });
33
- module.exports = __toCommonJS(netpolicy_exports);
34
- var import_node_async_hooks = require("async_hooks");
35
- var ErrOffline = "OfflineError";
36
- var OfflineError = class extends Error {
37
- constructor(method, url) {
38
- super(`${method} ${url}: network disabled by --offline`);
39
- this.name = ErrOffline;
40
- }
41
- };
42
- function isOfflineError(err) {
43
- return err instanceof Error && err.name === ErrOffline;
44
- }
45
- var store = new import_node_async_hooks.AsyncLocalStorage();
46
- var processOffline = false;
47
- function withOffline(offline, fn) {
48
- if (!offline) return fn();
49
- return store.run(true, fn);
50
- }
51
- function setProcessOffline(offline) {
52
- processOffline = offline;
53
- }
54
- function isOffline() {
55
- return processOffline || store.getStore() === true;
56
- }
57
- function isLoopback(hostname) {
58
- const h = hostname.replace(/^\[|\]$/g, "");
59
- if (h === "localhost") return true;
60
- if (h === "::1") return true;
61
- const v4 = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(h);
62
- if (v4) {
63
- return v4.slice(1).every((o) => Number(o) <= 255) && Number(v4[1]) === 127;
64
- }
65
- const mapped = /^::ffff:(.+)$/i.exec(h);
66
- if (mapped) {
67
- const inner = mapped[1] ?? "";
68
- if (/^7f00:1$/i.test(inner)) return true;
69
- return isLoopback(inner);
70
- }
71
- return false;
72
- }
73
- function target(input, init) {
74
- if (typeof Request !== "undefined" && input instanceof Request) {
75
- return { method: init?.method ?? input.method, url: input.url };
76
- }
77
- return { method: init?.method ?? "GET", url: String(input) };
78
- }
79
- var guarded = /* @__PURE__ */ Symbol.for("hop.top/kit/netpolicy.guarded");
80
- var unguardedBase = /* @__PURE__ */ Symbol.for("hop.top/kit/netpolicy.unguardedBase");
81
- function guardFetch(base) {
82
- if (base[guarded]) return base;
83
- const wrapper = async (input, init) => {
84
- if (isOffline()) {
85
- const { method, url } = target(input, init);
86
- let loopback = false;
87
- try {
88
- loopback = isLoopback(new URL(url).hostname);
89
- } catch {
90
- loopback = false;
91
- }
92
- if (!loopback) throw new OfflineError(method, url);
93
- }
94
- return base(input, init);
95
- };
96
- wrapper[guarded] = true;
97
- wrapper[unguardedBase] = base;
98
- return wrapper;
99
- }
100
- function install() {
101
- globalThis.fetch = guardFetch(globalThis.fetch);
102
- }
103
- function observabilityFetch() {
104
- const current = globalThis.fetch;
105
- return current?.[unguardedBase] ?? globalThis.fetch;
106
- }
107
- // Annotate the CommonJS export names for ESM import in node:
108
- 0 && (module.exports = {
109
- ErrOffline,
110
- OfflineError,
111
- guardFetch,
112
- install,
113
- isOffline,
114
- isOfflineError,
115
- observabilityFetch,
116
- setProcessOffline,
117
- withOffline
118
- });
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+ var _chunkKVG7YCTSjs = require('./chunk-KVG7YCTS.js');
13
+ require('./chunk-R5U7XKVJ.js');
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+ exports.ErrOffline = _chunkKVG7YCTSjs.ErrOffline; exports.OfflineError = _chunkKVG7YCTSjs.OfflineError; exports.guardFetch = _chunkKVG7YCTSjs.guardFetch; exports.install = _chunkKVG7YCTSjs.install; exports.isLoopback = _chunkKVG7YCTSjs.isLoopback; exports.isOffline = _chunkKVG7YCTSjs.isOffline; exports.isOfflineError = _chunkKVG7YCTSjs.isOfflineError; exports.observabilityFetch = _chunkKVG7YCTSjs.observabilityFetch; exports.setProcessOffline = _chunkKVG7YCTSjs.setProcessOffline; exports.withOffline = _chunkKVG7YCTSjs.withOffline;
@@ -1,4 +1,5 @@
1
1
  import { Command } from 'commander';
2
+ import { C as CliError$1, b as CODE_CONFLICT, c as CODE_CONSENT_REFUSED, d as CODE_GENERIC, e as CODE_NOT_FOUND, f as CODE_OK, g as CODE_PREREQUISITE, h as CODE_PROVENANCE_MISSING, i as CODE_RATE_LIMITED, a as CODE_TRANSIENT, j as CODE_UNAUTHORIZED, k as CODE_USAGE, E as EXIT_CONFLICT, l as EXIT_CONSENT_REFUSED, m as EXIT_GENERIC, n as EXIT_NOT_FOUND, o as EXIT_OK, p as EXIT_PREREQUISITE, q as EXIT_PROVENANCE_MISSING, r as EXIT_RATE_LIMITED, s as EXIT_TRANSIENT, t as EXIT_UNAUTHORIZED, u as EXIT_USAGE, T as TRANSIENCE_PERMANENT, v as TRANSIENCE_TRANSIENT, w as TRANSIENCE_UNKNOWN, x as conflictError, y as consentRefusedError, z as exitClasses, A as exitCodeForClass, B as genericError, D as notFoundError, F as prerequisiteError, G as provenanceMissingError, H as rateLimitedError, I as renderError, J as transienceForCode, K as transientError, L as unauthorizedError, M as unwrapError, N as usageError, O as withTransience, P as wrapError } from './error-Do8Qji43.js';
2
3
 
3
4
  /**
4
5
  * @module output/formatter
@@ -268,134 +269,6 @@ interface DispatchOptions<T = unknown> {
268
269
  */
269
270
  declare function dispatch<T>(cmd: Command, data: T | readonly T[], options?: DispatchOptions<T>): Promise<void>;
270
271
 
271
- /**
272
- * @module output/error
273
- *
274
- * Structured-error envelope. Mirrors Go's `go/console/output` error
275
- * envelope: when a command fails under `--format json|yaml`, the error is
276
- * materialized as a {@link CliError} and rendered to stderr by
277
- * {@link renderError}. Plaintext mode (`--format table` or unset) prints
278
- * `"Code: Message\nFix: ...\n"`.
279
- *
280
- * Fields use the on-wire snake_case keys directly (like the telemetry
281
- * `Envelope`) so `JSON.stringify` is wire-exact; empty optional fields
282
- * stay off the wire, mirroring Go's `omitempty`.
283
- */
284
- /** Marks a failure a retry may clear (rate limit, timeout, upstream blip). */
285
- declare const TRANSIENCE_TRANSIENT = "transient";
286
- /**
287
- * Marks a failure retrying cannot clear without changing the input or the
288
- * environment.
289
- */
290
- declare const TRANSIENCE_PERMANENT = "permanent";
291
- /**
292
- * Marks a failure kit cannot classify. Agents should treat retries as
293
- * best-effort and bounded.
294
- */
295
- declare const TRANSIENCE_UNKNOWN = "unknown";
296
- declare const CODE_OK = "OK";
297
- declare const CODE_GENERIC = "GENERIC";
298
- declare const CODE_USAGE = "USAGE";
299
- declare const CODE_NOT_FOUND = "NOT_FOUND";
300
- declare const CODE_CONFLICT = "CONFLICT";
301
- declare const CODE_UNAUTHORIZED = "UNAUTHORIZED";
302
- declare const CODE_TRANSIENT = "TRANSIENT";
303
- declare const CODE_PROVENANCE_MISSING = "PROVENANCE_MISSING";
304
- declare const CODE_RATE_LIMITED = "RATE_LIMITED";
305
- /**
306
- * Spec-assigned exit code for transient/retryable failures (Factor 11).
307
- * Agents branch on it before parsing stderr: exit 6 means a retry may
308
- * clear the failure.
309
- */
310
- declare const EXIT_TRANSIENT = 6;
311
- /** Conventional exit code for Factor-10 rate-limit refusals. */
312
- declare const EXIT_RATE_LIMITED = 64;
313
- /**
314
- * Conventional exit code for Factor-12 strict-mode provenance refusals.
315
- * Lives at 65 in kit's extension band (alongside RATE_LIMITED at 64):
316
- * the spec reserves 0-6 for its core taxonomy and leaves >6 to per-tool
317
- * codes, and kit as a library stays out of the low per-tool range.
318
- */
319
- declare const EXIT_PROVENANCE_MISSING = 65;
320
- /**
321
- * Structured-error envelope rendered to stderr when `--format json|yaml`
322
- * is set. Keys are the on-wire snake_case names.
323
- *
324
- * `transience` classifies the failure for retry decisions (Factor 4):
325
- * transient (retry-worthy), permanent (do not retry), or unknown.
326
- * Constructors and {@link wrapError} populate it; {@link renderError}
327
- * normalizes an unset value to unknown so every structured error carries
328
- * a valid class on the wire.
329
- */
330
- interface CliError {
331
- code: string;
332
- message: string;
333
- cause?: string;
334
- suggested_fix?: string;
335
- alternatives?: string[];
336
- exit_code: number;
337
- transience?: string;
338
- }
339
- /**
340
- * Default transience class for one of the standard codes. Unrecognized
341
- * (adopter-defined) codes map to unknown; adopters set `transience`
342
- * (or use {@link withTransience}) to classify their own codes.
343
- */
344
- declare function transienceForCode(code: string): string;
345
- /**
346
- * Builds an envelope from `err`, retaining it for {@link unwrapError}
347
- * while rendering as `code` and message. Transience defaults from the
348
- * code via {@link transienceForCode}; use {@link withTransience} to
349
- * override.
350
- */
351
- declare function wrapError(err: unknown, code: string, exitCode: number): CliError | null;
352
- /**
353
- * The error this envelope was built from via {@link wrapError}, so
354
- * callers can classify failures by cause instead of string-matching
355
- * `message`. Mirrors Go's `(*Error).Unwrap`.
356
- */
357
- declare function unwrapError(e: CliError): unknown;
358
- /**
359
- * Copy of `e` with `transience` set, every other field (and the retained
360
- * source error) untouched. Copies rather than mutating: adopters
361
- * commonly share module-level envelopes, and writing to one would leak
362
- * across call sites.
363
- */
364
- declare function withTransience(e: CliError, transience: string): CliError;
365
- /** CODE_NOT_FOUND envelope with exit code 3. */
366
- declare function notFoundError(message: string): CliError;
367
- /** CODE_CONFLICT envelope with exit code 4. */
368
- declare function conflictError(message: string): CliError;
369
- /** CODE_UNAUTHORIZED envelope with exit code 5. */
370
- declare function unauthorizedError(message: string): CliError;
371
- /** CODE_USAGE envelope with exit code 2. */
372
- declare function usageError(message: string): CliError;
373
- /**
374
- * CODE_TRANSIENT envelope with exit code 6 (Factor 11). Use it for
375
- * failures a retry may clear: upstream timeouts, connection resets,
376
- * service-unavailable responses.
377
- */
378
- declare function transientError(message: string): CliError;
379
- /** CODE_RATE_LIMITED envelope with exit code 64 (Factor 10). */
380
- declare function rateLimitedError(message: string): CliError;
381
- /**
382
- * CODE_PROVENANCE_MISSING envelope with exit code 65 (Factor 12).
383
- * `detail` is a free-form string suitable for the `cause` slot
384
- * (typically the JSON-pointer list of offending fields).
385
- */
386
- declare function provenanceMissingError(detail: string): CliError;
387
- /**
388
- * Writes `err` to `w` in the requested format. `format === ''` or
389
- * `'table'` renders human-readable plain text (`"Code: Message\nFix:
390
- * ..."`); JSON/YAML render the envelope structurally. An unset
391
- * transience is normalized to unknown on the wire (Factor 4) without
392
- * mutating `err`. Always returns; the caller decides the exit code from
393
- * `err.exit_code` after rendering.
394
- */
395
- declare function renderError(w: {
396
- write(chunk: string): unknown;
397
- }, format: string, err: CliError | null | undefined): void;
398
-
399
272
  /**
400
273
  * @module output
401
274
  * @package @hop-top/kit
@@ -431,6 +304,17 @@ declare function renderError(w: {
431
304
  * (ColumnSpec lists, `--cols`) are accessed via `dispatch()`.
432
305
  */
433
306
 
307
+ /**
308
+ * Structured error envelope; see `output/error`.
309
+ *
310
+ * A local alias, not `export type { CliError } from`: the declaration
311
+ * bundler rewrites a namespace member imported from another chunk as a
312
+ * value (`declare const ...: typeof CliError`), so the root barrel's
313
+ * `output` namespace would fail consumer type-checks (TS2693). A type
314
+ * declared in this module stays a type.
315
+ */
316
+ type CliError = CliError$1;
317
+
434
318
  /**
435
319
  * Supported output formats. Includes the original three for backward-compat
436
320
  * + new built-ins (csv, text) registered on the default registry.
@@ -456,9 +340,11 @@ declare const TEXT_FORMAT: "text";
456
340
  declare function render(w: NodeJS.WritableStream, format: Format, v: unknown): void;
457
341
 
458
342
  declare const output_CODE_CONFLICT: typeof CODE_CONFLICT;
343
+ declare const output_CODE_CONSENT_REFUSED: typeof CODE_CONSENT_REFUSED;
459
344
  declare const output_CODE_GENERIC: typeof CODE_GENERIC;
460
345
  declare const output_CODE_NOT_FOUND: typeof CODE_NOT_FOUND;
461
346
  declare const output_CODE_OK: typeof CODE_OK;
347
+ declare const output_CODE_PREREQUISITE: typeof CODE_PREREQUISITE;
462
348
  declare const output_CODE_PROVENANCE_MISSING: typeof CODE_PROVENANCE_MISSING;
463
349
  declare const output_CODE_RATE_LIMITED: typeof CODE_RATE_LIMITED;
464
350
  declare const output_CODE_TRANSIENT: typeof CODE_TRANSIENT;
@@ -468,9 +354,17 @@ declare const output_CSV_FORMAT: typeof CSV_FORMAT;
468
354
  type output_CliError = CliError;
469
355
  type output_ColumnSpec = ColumnSpec;
470
356
  type output_DispatchOptions<T = unknown> = DispatchOptions<T>;
357
+ declare const output_EXIT_CONFLICT: typeof EXIT_CONFLICT;
358
+ declare const output_EXIT_CONSENT_REFUSED: typeof EXIT_CONSENT_REFUSED;
359
+ declare const output_EXIT_GENERIC: typeof EXIT_GENERIC;
360
+ declare const output_EXIT_NOT_FOUND: typeof EXIT_NOT_FOUND;
361
+ declare const output_EXIT_OK: typeof EXIT_OK;
362
+ declare const output_EXIT_PREREQUISITE: typeof EXIT_PREREQUISITE;
471
363
  declare const output_EXIT_PROVENANCE_MISSING: typeof EXIT_PROVENANCE_MISSING;
472
364
  declare const output_EXIT_RATE_LIMITED: typeof EXIT_RATE_LIMITED;
473
365
  declare const output_EXIT_TRANSIENT: typeof EXIT_TRANSIENT;
366
+ declare const output_EXIT_UNAUTHORIZED: typeof EXIT_UNAUTHORIZED;
367
+ declare const output_EXIT_USAGE: typeof EXIT_USAGE;
474
368
  type output_Format = Format;
475
369
  type output_Formatter<T = unknown> = Formatter<T>;
476
370
  declare const output_JSON_FORMAT: typeof JSON_FORMAT;
@@ -488,14 +382,19 @@ declare const output_TRANSIENCE_UNKNOWN: typeof TRANSIENCE_UNKNOWN;
488
382
  declare const output_YAML_FORMAT: typeof YAML_FORMAT;
489
383
  declare const output_columnName: typeof columnName;
490
384
  declare const output_conflictError: typeof conflictError;
385
+ declare const output_consentRefusedError: typeof consentRefusedError;
491
386
  declare const output_defaultRegistry: typeof defaultRegistry;
492
387
  declare const output_deriveHeaders: typeof deriveHeaders;
493
388
  declare const output_dispatch: typeof dispatch;
389
+ declare const output_exitClasses: typeof exitClasses;
390
+ declare const output_exitCodeForClass: typeof exitCodeForClass;
391
+ declare const output_genericError: typeof genericError;
494
392
  declare const output_jsonFormatter: typeof jsonFormatter;
495
393
  declare const output_newRegistry: typeof newRegistry;
496
394
  declare const output_notFoundError: typeof notFoundError;
497
395
  declare const output_optionTypeName: typeof optionTypeName;
498
396
  declare const output_parseOptions: typeof parseOptions;
397
+ declare const output_prerequisiteError: typeof prerequisiteError;
499
398
  declare const output_projectRows: typeof projectRows;
500
399
  declare const output_provenanceMissingError: typeof provenanceMissingError;
501
400
  declare const output_rateLimitedError: typeof rateLimitedError;
@@ -515,7 +414,7 @@ declare const output_withTransience: typeof withTransience;
515
414
  declare const output_wrapError: typeof wrapError;
516
415
  declare const output_yamlFormatter: typeof yamlFormatter;
517
416
  declare namespace output {
518
- export { output_CODE_CONFLICT as CODE_CONFLICT, output_CODE_GENERIC as CODE_GENERIC, output_CODE_NOT_FOUND as CODE_NOT_FOUND, output_CODE_OK as CODE_OK, output_CODE_PROVENANCE_MISSING as CODE_PROVENANCE_MISSING, output_CODE_RATE_LIMITED as CODE_RATE_LIMITED, output_CODE_TRANSIENT as CODE_TRANSIENT, output_CODE_UNAUTHORIZED as CODE_UNAUTHORIZED, output_CODE_USAGE as CODE_USAGE, output_CSV_FORMAT as CSV_FORMAT, type output_CliError as CliError, type output_ColumnSpec as ColumnSpec, type output_DispatchOptions as DispatchOptions, output_EXIT_PROVENANCE_MISSING as EXIT_PROVENANCE_MISSING, output_EXIT_RATE_LIMITED as EXIT_RATE_LIMITED, output_EXIT_TRANSIENT as EXIT_TRANSIENT, type output_Format as Format, type output_Formatter as Formatter, output_JSON_FORMAT as JSON_FORMAT, type output_OptionSpec as OptionSpec, type output_OptionType as OptionType, type output_Options as Options, type output_RegisterOutputFlagsOptions as RegisterOutputFlagsOptions, output_Registry as Registry, output_TABLE_FORMAT as TABLE_FORMAT, output_TEXT_FORMAT as TEXT_FORMAT, output_TRANSIENCE_PERMANENT as TRANSIENCE_PERMANENT, output_TRANSIENCE_TRANSIENT as TRANSIENCE_TRANSIENT, output_TRANSIENCE_UNKNOWN as TRANSIENCE_UNKNOWN, output_YAML_FORMAT as YAML_FORMAT, output_columnName as columnName, output_conflictError as conflictError, output_defaultRegistry as defaultRegistry, output_deriveHeaders as deriveHeaders, output_dispatch as dispatch, output_jsonFormatter as jsonFormatter, output_newRegistry as newRegistry, output_notFoundError as notFoundError, output_optionTypeName as optionTypeName, output_parseOptions as parseOptions, output_projectRows as projectRows, output_provenanceMissingError as provenanceMissingError, output_rateLimitedError as rateLimitedError, output_registerOutputFlags as registerOutputFlags, output_registryFor as registryFor, output_render as render, output_renderError as renderError, output_resolveCols as resolveCols, output_resolveEffectiveCols as resolveEffectiveCols, output_tableFormatter as tableFormatter, output_transienceForCode as transienceForCode, output_transientError as transientError, output_unauthorizedError as unauthorizedError, output_unwrapError as unwrapError, output_usageError as usageError, output_withTransience as withTransience, output_wrapError as wrapError, output_yamlFormatter as yamlFormatter };
417
+ export { output_CODE_CONFLICT as CODE_CONFLICT, output_CODE_CONSENT_REFUSED as CODE_CONSENT_REFUSED, output_CODE_GENERIC as CODE_GENERIC, output_CODE_NOT_FOUND as CODE_NOT_FOUND, output_CODE_OK as CODE_OK, output_CODE_PREREQUISITE as CODE_PREREQUISITE, output_CODE_PROVENANCE_MISSING as CODE_PROVENANCE_MISSING, output_CODE_RATE_LIMITED as CODE_RATE_LIMITED, output_CODE_TRANSIENT as CODE_TRANSIENT, output_CODE_UNAUTHORIZED as CODE_UNAUTHORIZED, output_CODE_USAGE as CODE_USAGE, output_CSV_FORMAT as CSV_FORMAT, type output_CliError as CliError, type output_ColumnSpec as ColumnSpec, type output_DispatchOptions as DispatchOptions, output_EXIT_CONFLICT as EXIT_CONFLICT, output_EXIT_CONSENT_REFUSED as EXIT_CONSENT_REFUSED, output_EXIT_GENERIC as EXIT_GENERIC, output_EXIT_NOT_FOUND as EXIT_NOT_FOUND, output_EXIT_OK as EXIT_OK, output_EXIT_PREREQUISITE as EXIT_PREREQUISITE, output_EXIT_PROVENANCE_MISSING as EXIT_PROVENANCE_MISSING, output_EXIT_RATE_LIMITED as EXIT_RATE_LIMITED, output_EXIT_TRANSIENT as EXIT_TRANSIENT, output_EXIT_UNAUTHORIZED as EXIT_UNAUTHORIZED, output_EXIT_USAGE as EXIT_USAGE, type output_Format as Format, type output_Formatter as Formatter, output_JSON_FORMAT as JSON_FORMAT, type output_OptionSpec as OptionSpec, type output_OptionType as OptionType, type output_Options as Options, type output_RegisterOutputFlagsOptions as RegisterOutputFlagsOptions, output_Registry as Registry, output_TABLE_FORMAT as TABLE_FORMAT, output_TEXT_FORMAT as TEXT_FORMAT, output_TRANSIENCE_PERMANENT as TRANSIENCE_PERMANENT, output_TRANSIENCE_TRANSIENT as TRANSIENCE_TRANSIENT, output_TRANSIENCE_UNKNOWN as TRANSIENCE_UNKNOWN, output_YAML_FORMAT as YAML_FORMAT, output_columnName as columnName, output_conflictError as conflictError, output_consentRefusedError as consentRefusedError, output_defaultRegistry as defaultRegistry, output_deriveHeaders as deriveHeaders, output_dispatch as dispatch, output_exitClasses as exitClasses, output_exitCodeForClass as exitCodeForClass, output_genericError as genericError, output_jsonFormatter as jsonFormatter, output_newRegistry as newRegistry, output_notFoundError as notFoundError, output_optionTypeName as optionTypeName, output_parseOptions as parseOptions, output_prerequisiteError as prerequisiteError, output_projectRows as projectRows, output_provenanceMissingError as provenanceMissingError, output_rateLimitedError as rateLimitedError, output_registerOutputFlags as registerOutputFlags, output_registryFor as registryFor, output_render as render, output_renderError as renderError, output_resolveCols as resolveCols, output_resolveEffectiveCols as resolveEffectiveCols, output_tableFormatter as tableFormatter, output_transienceForCode as transienceForCode, output_transientError as transientError, output_unauthorizedError as unauthorizedError, output_unwrapError as unwrapError, output_usageError as usageError, output_withTransience as withTransience, output_wrapError as wrapError, output_yamlFormatter as yamlFormatter };
519
418
  }
520
419
 
521
- export { unauthorizedError as $, jsonFormatter as A, newRegistry as B, CODE_CONFLICT as C, type DispatchOptions as D, EXIT_PROVENANCE_MISSING as E, type Format as F, notFoundError as G, optionTypeName as H, output as I, JSON_FORMAT as J, parseOptions as K, projectRows as L, provenanceMissingError as M, rateLimitedError as N, type OptionSpec as O, registerOutputFlags as P, registryFor as Q, type RegisterOutputFlagsOptions as R, render as S, TABLE_FORMAT as T, renderError as U, resolveCols as V, resolveEffectiveCols as W, tableFormatter as X, YAML_FORMAT as Y, transienceForCode as Z, transientError as _, CODE_GENERIC as a, unwrapError as a0, usageError as a1, withTransience as a2, wrapError as a3, yamlFormatter as a4, CODE_NOT_FOUND as b, CODE_OK as c, CODE_PROVENANCE_MISSING as d, CODE_RATE_LIMITED as e, CODE_TRANSIENT as f, CODE_UNAUTHORIZED as g, CODE_USAGE as h, CSV_FORMAT as i, type CliError as j, type ColumnSpec as k, EXIT_RATE_LIMITED as l, EXIT_TRANSIENT as m, type Formatter as n, type OptionType as o, type Options as p, Registry as q, TEXT_FORMAT as r, TRANSIENCE_PERMANENT as s, TRANSIENCE_TRANSIENT as t, TRANSIENCE_UNKNOWN as u, columnName as v, conflictError as w, defaultRegistry as x, deriveHeaders as y, dispatch as z };
420
+ export { CSV_FORMAT as C, type DispatchOptions as D, type Format as F, JSON_FORMAT as J, type OptionSpec as O, type RegisterOutputFlagsOptions as R, TABLE_FORMAT as T, YAML_FORMAT as Y, type CliError as a, type ColumnSpec as b, type Formatter as c, type OptionType as d, type Options as e, Registry as f, TEXT_FORMAT as g, columnName as h, defaultRegistry as i, deriveHeaders as j, dispatch as k, jsonFormatter as l, optionTypeName as m, newRegistry as n, output as o, parseOptions as p, projectRows as q, registerOutputFlags as r, registryFor as s, render as t, resolveCols as u, resolveEffectiveCols as v, tableFormatter as w, yamlFormatter as y };
package/dist/output.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export { C as CODE_CONFLICT, a as CODE_GENERIC, b as CODE_NOT_FOUND, c as CODE_OK, d as CODE_PROVENANCE_MISSING, e as CODE_RATE_LIMITED, f as CODE_TRANSIENT, g as CODE_UNAUTHORIZED, h as CODE_USAGE, i as CSV_FORMAT, j as CliError, k as ColumnSpec, D as DispatchOptions, E as EXIT_PROVENANCE_MISSING, l as EXIT_RATE_LIMITED, m as EXIT_TRANSIENT, F as Format, n as Formatter, J as JSON_FORMAT, O as OptionSpec, o as OptionType, p as Options, R as RegisterOutputFlagsOptions, q as Registry, T as TABLE_FORMAT, r as TEXT_FORMAT, s as TRANSIENCE_PERMANENT, t as TRANSIENCE_TRANSIENT, u as TRANSIENCE_UNKNOWN, Y as YAML_FORMAT, v as columnName, w as conflictError, x as defaultRegistry, y as deriveHeaders, z as dispatch, A as jsonFormatter, B as newRegistry, G as notFoundError, H as optionTypeName, K as parseOptions, L as projectRows, M as provenanceMissingError, N as rateLimitedError, P as registerOutputFlags, Q as registryFor, S as render, U as renderError, V as resolveCols, W as resolveEffectiveCols, X as tableFormatter, Z as transienceForCode, _ as transientError, $ as unauthorizedError, a0 as unwrapError, a1 as usageError, a2 as withTransience, a3 as wrapError, a4 as yamlFormatter } from './output-VFFLqor9.js';
1
+ export { C as CSV_FORMAT, a as CliError, b as ColumnSpec, D as DispatchOptions, F as Format, c as Formatter, J as JSON_FORMAT, O as OptionSpec, d as OptionType, e as Options, R as RegisterOutputFlagsOptions, f as Registry, T as TABLE_FORMAT, g as TEXT_FORMAT, Y as YAML_FORMAT, h as columnName, i as defaultRegistry, j as deriveHeaders, k as dispatch, l as jsonFormatter, n as newRegistry, m as optionTypeName, p as parseOptions, q as projectRows, r as registerOutputFlags, s as registryFor, t as render, u as resolveCols, v as resolveEffectiveCols, w as tableFormatter, y as yamlFormatter } from './output-CjZWmL8s.js';
2
+ export { b as CODE_CONFLICT, c as CODE_CONSENT_REFUSED, d as CODE_GENERIC, e as CODE_NOT_FOUND, f as CODE_OK, g as CODE_PREREQUISITE, h as CODE_PROVENANCE_MISSING, i as CODE_RATE_LIMITED, a as CODE_TRANSIENT, j as CODE_UNAUTHORIZED, k as CODE_USAGE, E as EXIT_CONFLICT, l as EXIT_CONSENT_REFUSED, m as EXIT_GENERIC, n as EXIT_NOT_FOUND, o as EXIT_OK, p as EXIT_PREREQUISITE, q as EXIT_PROVENANCE_MISSING, r as EXIT_RATE_LIMITED, s as EXIT_TRANSIENT, t as EXIT_UNAUTHORIZED, u as EXIT_USAGE, T as TRANSIENCE_PERMANENT, v as TRANSIENCE_TRANSIENT, w as TRANSIENCE_UNKNOWN, x as conflictError, y as consentRefusedError, z as exitClasses, A as exitCodeForClass, B as genericError, D as notFoundError, F as prerequisiteError, G as provenanceMissingError, H as rateLimitedError, I as renderError, J as transienceForCode, K as transientError, L as unauthorizedError, M as unwrapError, N as usageError, O as withTransience, P as wrapError } from './error-Do8Qji43.js';
2
3
  import 'commander';